rem
stringlengths
0
274k
add
stringlengths
0
169k
context
stringlengths
9
471k
QString myArgString; QFile myQFile; QStringList myVectorFileStringList, myRasterFileStringList; bool myFileExistsFlag;
int main(int argc, char *argv[]){ QApplication a(argc, argv); // a.setFont(QFont("helvetica", 11)); QTranslator tor(0); // set the location where your .qm files are in load() below as the last parameter instead of "." // for development, use "/" to use the english original as // .qm files are stored in the base project directory. if(argc == 2){ QString translation = "qgis_" + QString(argv[1]); tor.load(translation,"."); }else{ tor.load(QString("qgis_") + QTextCodec::locale(), "."); } //tor.load("qgis_go", "." ); a.installTranslator(&tor); /* uncomment the following line, if you want a Windows 95 look */ //a.setStyle("Windows"); QgisApp *qgis = new QgisApp(); a.setMainWidget(qgis); qgis->show(); a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); // //turn control over to the main application loop... // int result = a.exec(); return result;}
for(int myIteratorInt = 1; myIteratorInt < argc; myIteratorInt++) { #ifdef DEBUG printf("%d: %s\n", myIteratorInt, argv[myIteratorInt]); #endif myQFile.setName(argv[myIteratorInt]); myFileExistsFlag = myQFile.open(IO_ReadOnly); myQFile.close(); if(myFileExistsFlag) { #ifdef DEBUG printf("OK\n"); #endif myArgString = argv[myIteratorInt]; if(myArgString.endsWith(".shp", FALSE)) { myVectorFileStringList.append(myArgString); #ifdef DEBUG printf("Vector count: %d\n",myVectorFileStringList.count()); #endif } else if (myArgString.endsWith(".adf", FALSE) || myArgString.endsWith(".asc", FALSE) || myArgString.endsWith(".grd", FALSE) || myArgString.endsWith(".img", FALSE) || myArgString.endsWith(".tif", FALSE) || myArgString.endsWith(".png", FALSE) || myArgString.endsWith(".jpg", FALSE) || myArgString.endsWith(".dem", FALSE) || myArgString.endsWith(".ddf", FALSE)) { myRasterFileStringList.append(myArgString); #ifdef DEBUG printf("Raster count: %d\n",myRasterFileStringList.count()); #endif } } } #ifdef DEBUG printf("vCount: %d\n",myVectorFileStringList.count()); printf("rCount: %d\n",myRasterFileStringList.count()); #endif if(!myVectorFileStringList.isEmpty()) { #ifdef DEBUG printf("Loading vector files...\n"); #endif qgis->addLayer(myVectorFileStringList); } if(!myRasterFileStringList.isEmpty()) { #ifdef DEBUG printf("Load raster files...\n"); #endif }
int main(int argc, char *argv[]){ QApplication a(argc, argv); // a.setFont(QFont("helvetica", 11)); QTranslator tor(0); // set the location where your .qm files are in load() below as the last parameter instead of "." // for development, use "/" to use the english original as // .qm files are stored in the base project directory. if(argc == 2){ QString translation = "qgis_" + QString(argv[1]); tor.load(translation,"."); }else{ tor.load(QString("qgis_") + QTextCodec::locale(), "."); } //tor.load("qgis_go", "." ); a.installTranslator(&tor); /* uncomment the following line, if you want a Windows 95 look */ //a.setStyle("Windows"); QgisApp *qgis = new QgisApp(); a.setMainWidget(qgis); qgis->show(); a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); // //turn control over to the main application loop... // int result = a.exec(); return result;}
KGlobal::locale()->insertCatalogue("filetypes");
int main(int argc, char ** argv){ KServiceTypeProfile::setConfigurationMode(); KLocale::setMainCatalogue("filetypes"); KAboutData aboutData( "keditfiletype", I18N_NOOP("KEditFileType"), "1.0", I18N_NOOP("KDE file type editor - simplified version for editing a single file type"), KAboutData::License_GPL, I18N_NOOP("(c) 2000, KDE developers") ); aboutData.addAuthor("Preston Brown",0, "[email protected]"); aboutData.addAuthor("David Faure",0, "[email protected]"); KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KApplication app; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); KGlobal::locale()->insertCatalogue("filetypes"); if (args->count() == 0) KCmdLineArgs::usage(); KMimeType::Ptr mime = KMimeType::mimeType( args->arg(0) ); if (!mime) kdFatal() << "Mimetype " << args->arg(0) << " not found" << endl; args->clear(); FileTypeDialog * dlg = new FileTypeDialog( mime ); dlg->setCaption( i18n("Edit File Type %1").arg(mime->name()) ); dlg->exec(); delete dlg; return 0;}
if ((args->count() == 0)&(!args->isSet("c"))) KCmdLineArgs::usage(i18n("No command specified!"));
int main(int argc, char *argv[]){ KAboutData aboutData("kdesu", I18N_NOOP("KDE su"), Version, I18N_NOOP("Runs a program with elevated privileges."), KAboutData::License_Artistic, "Copyright (c) 1998-2000 Geert Jansen, Pietro Iglio"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Maintainer"), "[email protected]", "http://www.stack.nl/~geertj/"); aboutData.addAuthor("Pietro Iglio", I18N_NOOP("Original author"), "[email protected]"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions(options); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); KApplication *app = new KApplication; // Check command // CJM - probably a hack here - but need to check for a "c" for backwords compat. if ((args->count() == 0)&(!args->isSet("c"))) KCmdLineArgs::usage(i18n("No command specified!")); // Stop daemon and exit? if (args->isSet("s")) { KDEsuClient client; if (client.ping() == -1) { kdError(1206) << "Daemon not running -- nothing to stop\n"; exit(1); } if (client.stopServer() != -1) { kdDebug(1206) << "Daemon stopped\n"; exit(0); } kdError(1206) << "Could not stop daemon\n"; exit(1); } // Get target uid QCString user = args->getOption("u"); QCString auth_user = user; struct passwd *pw = getpwnam(user); if (pw == 0L) { kdError(1206) << "User " << user << " does not exist\n"; exit(1); } bool change_uid = (getuid() != pw->pw_uid); // If file is writeable, do not change uid QString file = QFile::decodeName(args->getOption("f")); if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); if (file.isEmpty()) { kdError(1206) << "Config file not found: " << file << "\n"; exit(1); } } QFileInfo fi(file); if (!fi.exists()) { kdError(1206) << "File does not exist: " << file << "\n"; exit(1); } change_uid = !fi.isWritable(); } // Get priority/scheduler QCString tmp = args->getOption("p"); bool ok; int priority = tmp.toInt(&ok); if (!ok || (priority < 0) || (priority > 100)) { KCmdLineArgs::usage(i18n("Illegal priority: %1").arg(tmp)); exit(1); } int scheduler = SuProcess::SchedNormal; if (args->isSet("r")) scheduler = SuProcess::SchedRealtime; if ((priority > 50) || (scheduler != SuProcess::SchedNormal)) { change_uid = true; auth_user = "root"; } // Get command if (args->isSet("c")) { command = args->getOption("c"); for (int i=0; i<args->count(); i++) { command += " "; command += args->arg(i); } } else { command = args->arg(0); for (int i=1; i<args->count(); i++) { command += " "; command += args->arg(i); }}// CJM - Test lines remove when working// kdWarning(1206) << args->count();// kdWarning(1206) << command; // Don't change uid if we're don't need to. if (!change_uid) return system(command); // Check for daemon and start if necessary bool just_started = false; bool have_daemon = true; KDEsuClient client; if (!client.isServerSGID()) { kdWarning(1206) << "Daemon not safe (not sgid), not using it.\n"; have_daemon = false; } else if (client.ping() == -1) { if (client.startServer() == -1) { kdWarning(1206) << "Could not start daemon, reduced functionality.\n"; have_daemon = false; } just_started = true; } // Try to exec the command with kdesud. bool keep = !args->isSet("n") && have_daemon; bool terminal = args->isSet("t"); if (keep && !terminal && !just_started) { client.setPriority(priority); client.setScheduler(scheduler); if (client.exec(command, user) != -1) return 0; } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { kdError(1206) << "rlimit(): " << ERR << "\n"; exit(1); } // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Passwords"); int timeout = config->readNumEntry("Timeout", defTimeout); // Start the dialog KDEsuDialog *dlg = new KDEsuDialog(user, auth_user, keep && !terminal); dlg->addLine(i18n("Command:"), command); if ((priority != 50) || (scheduler != SuProcess::SchedNormal)) { QString prio; if (scheduler == SuProcess::SchedRealtime) prio += i18n("realtime: "); prio += QString("%1/100").arg(priority); dlg->addLine(i18n("Priority:"), prio); } int ret = dlg->exec(); if (ret == KDEsuDialog::Rejected) exit(0); if (ret == KDEsuDialog::AsUser) change_uid = false; QCString password = dlg->password(); int k = dlg->keep(); delete dlg; // Some events may need to be handled (like a button animation) app->processEvents(); if (!change_uid) return system(command); // Run command if (k && have_daemon) { client.setPass(password, timeout); client.setPriority(priority); client.setScheduler(scheduler); return client.exec(command, user); } else { SuProcess proc; proc.setTerminal(terminal); proc.setErase(true); proc.setUser(user); proc.setPriority(priority); proc.setScheduler(scheduler); proc.setCommand(command); return proc.exec(password); }}
if( args->count() == 0 ) { KCmdLineArgs::usage(i18n("No command specified!")); exit(1); }
int main(int argc, char *argv[]){ KAboutData aboutData("kdesu", I18N_NOOP("KDE su"), Version, I18N_NOOP("Runs a program with elevated privileges."), KAboutData::License_Artistic, "Copyright (c) 1998-2000 Geert Jansen, Pietro Iglio"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Maintainer"), "[email protected]", "http://www.stack.nl/~geertj/"); aboutData.addAuthor("Pietro Iglio", I18N_NOOP("Original author"), "[email protected]"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions(options); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); KApplication *app = new KApplication; // Check command // CJM - probably a hack here - but need to check for a "c" for backwords compat. if ((args->count() == 0)&(!args->isSet("c"))) KCmdLineArgs::usage(i18n("No command specified!")); // Stop daemon and exit? if (args->isSet("s")) { KDEsuClient client; if (client.ping() == -1) { kdError(1206) << "Daemon not running -- nothing to stop\n"; exit(1); } if (client.stopServer() != -1) { kdDebug(1206) << "Daemon stopped\n"; exit(0); } kdError(1206) << "Could not stop daemon\n"; exit(1); } // Get target uid QCString user = args->getOption("u"); QCString auth_user = user; struct passwd *pw = getpwnam(user); if (pw == 0L) { kdError(1206) << "User " << user << " does not exist\n"; exit(1); } bool change_uid = (getuid() != pw->pw_uid); // If file is writeable, do not change uid QString file = QFile::decodeName(args->getOption("f")); if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); if (file.isEmpty()) { kdError(1206) << "Config file not found: " << file << "\n"; exit(1); } } QFileInfo fi(file); if (!fi.exists()) { kdError(1206) << "File does not exist: " << file << "\n"; exit(1); } change_uid = !fi.isWritable(); } // Get priority/scheduler QCString tmp = args->getOption("p"); bool ok; int priority = tmp.toInt(&ok); if (!ok || (priority < 0) || (priority > 100)) { KCmdLineArgs::usage(i18n("Illegal priority: %1").arg(tmp)); exit(1); } int scheduler = SuProcess::SchedNormal; if (args->isSet("r")) scheduler = SuProcess::SchedRealtime; if ((priority > 50) || (scheduler != SuProcess::SchedNormal)) { change_uid = true; auth_user = "root"; } // Get command if (args->isSet("c")) { command = args->getOption("c"); for (int i=0; i<args->count(); i++) { command += " "; command += args->arg(i); } } else { command = args->arg(0); for (int i=1; i<args->count(); i++) { command += " "; command += args->arg(i); }}// CJM - Test lines remove when working// kdWarning(1206) << args->count();// kdWarning(1206) << command; // Don't change uid if we're don't need to. if (!change_uid) return system(command); // Check for daemon and start if necessary bool just_started = false; bool have_daemon = true; KDEsuClient client; if (!client.isServerSGID()) { kdWarning(1206) << "Daemon not safe (not sgid), not using it.\n"; have_daemon = false; } else if (client.ping() == -1) { if (client.startServer() == -1) { kdWarning(1206) << "Could not start daemon, reduced functionality.\n"; have_daemon = false; } just_started = true; } // Try to exec the command with kdesud. bool keep = !args->isSet("n") && have_daemon; bool terminal = args->isSet("t"); if (keep && !terminal && !just_started) { client.setPriority(priority); client.setScheduler(scheduler); if (client.exec(command, user) != -1) return 0; } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { kdError(1206) << "rlimit(): " << ERR << "\n"; exit(1); } // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Passwords"); int timeout = config->readNumEntry("Timeout", defTimeout); // Start the dialog KDEsuDialog *dlg = new KDEsuDialog(user, auth_user, keep && !terminal); dlg->addLine(i18n("Command:"), command); if ((priority != 50) || (scheduler != SuProcess::SchedNormal)) { QString prio; if (scheduler == SuProcess::SchedRealtime) prio += i18n("realtime: "); prio += QString("%1/100").arg(priority); dlg->addLine(i18n("Priority:"), prio); } int ret = dlg->exec(); if (ret == KDEsuDialog::Rejected) exit(0); if (ret == KDEsuDialog::AsUser) change_uid = false; QCString password = dlg->password(); int k = dlg->keep(); delete dlg; // Some events may need to be handled (like a button animation) app->processEvents(); if (!change_uid) return system(command); // Run command if (k && have_daemon) { client.setPass(password, timeout); client.setPriority(priority); client.setScheduler(scheduler); return client.exec(command, user); } else { SuProcess proc; proc.setTerminal(terminal); proc.setErase(true); proc.setUser(user); proc.setPriority(priority); proc.setScheduler(scheduler); proc.setCommand(command); return proc.exec(password); }}
{ QString factory("init_%1"); void *init = lib->symbol(factory.arg(funcname)); if (init) { kdDebug() << "Initializing " << libname << ": " << funcname << endl;
{ QString factory("init_%1"); void *init = lib->symbol(factory.arg(funcname)); if (init) { kdDebug() << "Initializing control module " << libname << ": " << funcname << endl;
int main(int argc, char *argv[]){ KApplication app(argc, argv, "kcminit"); QStringList libs; QString libname, funcname, call; // locate the desktop files QStringList files; files = KGlobal::dirs()->findAllResources("apps", "Settings/*.desktop", true); // look for Init=... entries QStringList::Iterator it; for (it = files.begin(); it != files.end(); ++it) { KDesktopFile desktop(*it); libname = desktop.readEntry("X-KDE-Library"); funcname = desktop.readEntry("X-KDE-Init"); call = funcname+"@"+libname; if (!funcname.isEmpty() && !libname.isEmpty() && !libs.contains(call)) libs.append(call); } // get the library loader instance KLibLoader *loader = KLibLoader::self(); for (it = libs.begin(); it != libs.end(); ++it) { int pos = (*it).find("@"); funcname = (*it).left(pos); libname = (*it).mid(pos+1); // try to load the library QString ln("libkcm_%1"); KLibrary *lib = loader->library(ln.arg(libname)); if (lib) { // get the init_ function QString factory("init_%1"); void *init = lib->symbol(factory.arg(funcname)); if (init) { // initialize the module kdDebug() << "Initializing " << libname << ": " << funcname << endl; void (*func)() = (void(*)())init; func(); } } } return 0;}
void (*func)() = (void(*)())init; func(); } }
void (*func)() = (void(*)())init; func(); } loader->unloadLibrary(ln.arg(libname)); }
int main(int argc, char *argv[]){ KApplication app(argc, argv, "kcminit"); QStringList libs; QString libname, funcname, call; // locate the desktop files QStringList files; files = KGlobal::dirs()->findAllResources("apps", "Settings/*.desktop", true); // look for Init=... entries QStringList::Iterator it; for (it = files.begin(); it != files.end(); ++it) { KDesktopFile desktop(*it); libname = desktop.readEntry("X-KDE-Library"); funcname = desktop.readEntry("X-KDE-Init"); call = funcname+"@"+libname; if (!funcname.isEmpty() && !libname.isEmpty() && !libs.contains(call)) libs.append(call); } // get the library loader instance KLibLoader *loader = KLibLoader::self(); for (it = libs.begin(); it != libs.end(); ++it) { int pos = (*it).find("@"); funcname = (*it).left(pos); libname = (*it).mid(pos+1); // try to load the library QString ln("libkcm_%1"); KLibrary *lib = loader->library(ln.arg(libname)); if (lib) { // get the init_ function QString factory("init_%1"); void *init = lib->symbol(factory.arg(funcname)); if (init) { // initialize the module kdDebug() << "Initializing " << libname << ": " << funcname << endl; void (*func)() = (void(*)())init; func(); } } } return 0;}
"v2.0pre", "The KDE Control Centre", KAboutData::GPL,
"v2.0pre", "The KDE Control Centre", KAboutData::License_GPL,
int main(int argc, char *argv[]){ KAboutData aboutData( "kcontrol", I18N_NOOP("KDE Control Centre"), "v2.0pre", "The KDE Control Centre", KAboutData::GPL, "(c) 1998-2000, The KDE Control Centre Developers"); aboutData.addAuthor("Matthias Hoelzer-Kluepfel",0, "[email protected]"); KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. if (!MyApplication::start()) exit(0); // Don't do anything if we are already running MyApplication app; //&aboutData // TODO: MyApplication (a KUniqueApplication) doesn't // support KApplication::KApplication(KAboutData *) // So, I'm leaving this alone, and will let the // maintainter of kcontrol finish it up! // show the whole stuff app.mainWidget()->show(); return app.exec();}
"v2.0pre", "The KDE Control Center", KAboutData::License_GPL,
"v2.0pre", I18N_NOOP("The KDE Control Center"), KAboutData::License_GPL,
int main(int argc, char *argv[]){ KAboutData aboutData( "kcontrol", I18N_NOOP("KDE Control Center"), "v2.0pre", "The KDE Control Center", KAboutData::License_GPL, "(c) 1998-2000, The KDE Control Center Developers"); aboutData.addAuthor("Matthias Hoelzer-Kluepfel",0, "[email protected]"); aboutData.addAuthor("Matthias Elter",0, "[email protected]"); KCmdLineArgs::init( argc, argv, &aboutData ); KUniqueApplication::addCmdLineOptions(); KCGlobal::init(); if (!KControlApp::start()) { kdDebug() << "kcontrol is already running!\n" << endl; return (0); } KControlApp app; // show the whole stuff app.mainWidget()->show(); return app.exec();}
exit(1);
int main(int argc, char *argv[]){ ///////////////////////////////////////////////////////////////// // Command line options 'behaviour' flag setup //////////////////////////////////////////////////////////////// // // Parse the command line arguments, looking to see if the user has asked for any // special behaviours. Any remaining non command arguments will be kept aside to // be passed as a list of layers and / or a project that should be loaded. // // This behaviour is used to load the app, snapshot the map, // save the image to disk and then exit QString mySnapshotFileName=""; // This behaviour will cause QGIS to autoload a project QString myProjectFileName=""; // This behaviour will allow you to force the use of a translation file // which is useful for testing QString myTranslationFileName=""; // This is the 'leftover' arguments collection QStringList * myFileList=new QStringList();#ifndef WIN32 if ( !bundleclicked(argc, argv) ) { //////////////////////////////////////////////////////////////// // USe the GNU Getopts utility to parse cli arguments // Invokes ctor `GetOpt (int argc, char **argv, char *optstring);' /////////////////////////////////////////////////////////////// int optionChar; while (1) { static struct option long_options[] = { /* These options set a flag. */ {"help", no_argument, 0, 'h'}, /* These options don't set a flag. * We distinguish them by their indices. */ {"snapshot", required_argument, 0, 's'}, {"lang", required_argument, 0, 'l'}, {"project", required_argument, 0, 'p'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; optionChar = getopt_long (argc, argv, "slp", long_options, &option_index); /* Detect the end of the options. */ if (optionChar == -1) break; switch (optionChar) { case 0: /* If this option set a flag, do nothing else now. */ if (long_options[option_index].flag != 0) break; printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case 's': mySnapshotFileName = optarg; break; case 'l': myTranslationFileName = optarg; break; case 'p': myProjectFileName = optarg; break; case 'h': case '?': usage( argv[0] ); return 2; // XXX need standard exit codes break; default: std::cerr << argv[0] << ": getopt returned character code " << optionChar << "\n"; return 1; // XXX need standard exit codes } } // Add any remaining args to the file list - we will attempt to load them // as layers in the map view further down....#ifdef QGISDEBUG std::cout << "Files specified on command line: " << optind << std::endl;#endif if (optind < argc) { while (optind < argc) {#ifdef QGISDEBUG int idx = optind; std::cout << idx << ": " << argv[idx] << std::endl;#endif myFileList->append(argv[optind++]); } } }#endif //WIN32 ///////////////////////////////////////////////////////////////////// // Now we have the handlers for the different behaviours... //////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // Initialise the application and the translation stuff /////////////////////////////////////////////////////////////////////#ifdef Q_WS_X11 bool myUseGuiFlag = getenv( "DISPLAY" ) != 0;#else bool myUseGuiFlag = TRUE;#endif if (!myUseGuiFlag) { std::cerr << "QGIS starting in non-interactive mode because you have no DISPLAY environment variable set." << std::endl; } QApplication a(argc, argv, myUseGuiFlag ); // a.setFont(QFont("helvetica", 11));#if defined(Q_OS_MACX) || defined(WIN32) QString PKGDATAPATH = qApp->applicationDirPath() + "/share/qgis";#endif QTranslator tor(0); // For WIN32, get the locale if (myTranslationFileName!="") { QString translation = "qgis_" + myTranslationFileName; tor.load(translation, QString(PKGDATAPATH) + "/i18n"); } else {#ifdef QGISDEBUG std::cout << "Setting translation to " << PKGDATAPATH << "/i18n/qgis_" << QTextCodec::locale() << std::endl; #endif tor.load(QString("qgis_") + QTextCodec::locale(), QString(PKGDATAPATH) + "/i18n"); } //tor.load("qgis_go", "." ); a.installTranslator(&tor); /* uncomment the following line, if you want a Windows 95 look */ //a.setStyle("Windows"); QgisApp *qgis = new QgisApp; // "QgisApp" used to find canonical instance qgis->setName( "QgisApp" ); a.setMainWidget(qgis); ///////////////////////////////////////////////////////////////////// // If no --project was specified, parse the args to look for a // // .qgs file and set myProjectFileName to it. This allows loading // // of a project file by clicking on it in various desktop managers // // where an appropriate mime-type has been set up. // ///////////////////////////////////////////////////////////////////// if(myProjectFileName.isEmpty()) { // check for a .qgs for(int i = 0; i < argc; i++) { QString arg = argv[i]; if(arg.contains(".qgs")) { myProjectFileName = argv[i]; break; } } } ///////////////////////////////////////////////////////////////////// // Load a project file if one was specified ///////////////////////////////////////////////////////////////////// if( ! myProjectFileName.isEmpty() ) {// if ( ! qgis->addProject(myProjectFileName) )// {// #ifdef QGISDEBUG// std::cerr << "unable to load project " << myProjectFileName << "\n";// #endif// } try { if ( ! qgis->addProject(myProjectFileName) ) {#ifdef QGISDEBUG std::cerr << "unable to load project " << myProjectFileName << "\n";#endif } } catch ( QgsIOException & io_exception ) { QMessageBox::critical( 0x0, "QGIS: Unable to load project", "Unable to load project " + myProjectFileName ); } } ///////////////////////////////////////////////////////////////////// // autoload any filenames that were passed in on the command line /////////////////////////////////////////////////////////////////////#ifdef QGISDEBUG std::cout << "Number of files in myFileList: " << myFileList->count() << std::endl;#endif for ( QStringList::Iterator myIterator = myFileList->begin(); myIterator != myFileList->end(); ++myIterator ) {#ifdef QGISDEBUG std::cout << "Trying to load file : " << *myIterator << std::endl;#endif QString myLayerName = *myIterator; // don't load anything with a .qgs extension - these are project files if(!myLayerName.contains(".qgs")) { // try to add all these layers - any unsupported file types will // be rejected automatically // The funky bool ok is so this can be debugged a bit easier... //nope - try and load it as raster bool ok = qgis->addRasterLayer(QFileInfo(myLayerName), false); if(!ok){ //nope - try and load it as a shape/ogr ok = qgis->addLayer(QFileInfo(myLayerName)); //we have no idea what this layer is... if(!ok){ std::cout << "Unable to load " << myLayerName << std::endl; } } } } ///////////////////////////////////////////////////////////////////// // Take a snapshot of the map view then exit if snapshot mode requested ///////////////////////////////////////////////////////////////////// if(mySnapshotFileName!="") { /*You must have at least one paintEvent() delivered for the window to be rendered properly. It looks like you don't run the event loop in non-interactive mode, so the event is never occuring. To achieve this without runing the event loop: show the window, then call qApp->processEvents(), grab the pixmap, save it, hide the window and exit. */ //qgis->show(); a.processEvents(); QPixmap * myQPixmap = new QPixmap(800,600); myQPixmap->fill(); qgis->saveMapAsImage(mySnapshotFileName,myQPixmap); a.processEvents(); qgis->hide(); return 1; } ///////////////////////////////////////////////////////////////////// // Continue on to interactive gui... ///////////////////////////////////////////////////////////////////// qgis->show(); a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); return a.exec();}
KCModule *module = ModuleLoader::module(info);
KCModule *module = ModuleLoader::loadModule(info);
int main(int _argc, char *_argv[]){ KCmdLineArgs::init( _argc, _argv, "kcmshell", I18N_NOOP("A tool to start single kcontrol modules"), "2.0pre" ); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KLocale::setMainCatalogue("kcontrol"); KApplication app; // It has to be unset, if not it will break modules like kcmlocale KLocale::setMainCatalogue(0); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", "Settings/*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); QString module = *it; if (module.left(9) == "Settings/") module = module.mid(9); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { cout << (*modules.at(i)).latin1(); cout << verylong.left(maxwidth - (*modules.at(i)).length()); cout << " - "; cout << (*descriptions.at(i)).local8Bit(); cout << endl; } return 0; } if (args->count() != 1) { args->usage(); return -1; } QCString arg = args->arg(0); // locate the desktop file //QStringList files; if (arg[0] == '/') { kdDebug() << "Full path given to kcmshell - not supported yet" << endl; // (because of KService::findServiceByDesktopPath) //files.append(args->arg(0)); } QCString path = "Settings/"; path += arg; path += ".desktop"; /* else files = KGlobal::dirs()-> findAllResources("apps", QString("Settings/%1.desktop").arg(args->arg(0)), true); // check the matches if (files.count() > 1) cerr << i18n("Module name not unique. Taking the first match.") << endl; */ if (!KService::serviceByDesktopPath( path )) { // Path didn't work. Trying as a name KService::Ptr serv = KService::serviceByDesktopName( arg ); if ( serv ) path = serv->entryPath(); else { cerr << i18n("Module %1 not found!").arg(arg) << endl; return -1; } } args->clear(); // load the module ModuleInfo info(path); KCModule *module = ModuleLoader::module(info); if (module) { // create the dialog KCDialog dlg(module, module->buttons(), info.docPath(), 0, 0, true); dlg.setCaption(info.name()); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg.setAcceptDrops(true); // run the dialog return dlg.exec(); } return 0;}
return dlg.exec();
int ret = dlg.exec(); ModuleLoader::unloadModule(info); return ret;
int main(int _argc, char *_argv[]){ KCmdLineArgs::init( _argc, _argv, "kcmshell", I18N_NOOP("A tool to start single kcontrol modules"), "2.0pre" ); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KLocale::setMainCatalogue("kcontrol"); KApplication app; // It has to be unset, if not it will break modules like kcmlocale KLocale::setMainCatalogue(0); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", "Settings/*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); QString module = *it; if (module.left(9) == "Settings/") module = module.mid(9); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { cout << (*modules.at(i)).latin1(); cout << verylong.left(maxwidth - (*modules.at(i)).length()); cout << " - "; cout << (*descriptions.at(i)).local8Bit(); cout << endl; } return 0; } if (args->count() != 1) { args->usage(); return -1; } QCString arg = args->arg(0); // locate the desktop file //QStringList files; if (arg[0] == '/') { kdDebug() << "Full path given to kcmshell - not supported yet" << endl; // (because of KService::findServiceByDesktopPath) //files.append(args->arg(0)); } QCString path = "Settings/"; path += arg; path += ".desktop"; /* else files = KGlobal::dirs()-> findAllResources("apps", QString("Settings/%1.desktop").arg(args->arg(0)), true); // check the matches if (files.count() > 1) cerr << i18n("Module name not unique. Taking the first match.") << endl; */ if (!KService::serviceByDesktopPath( path )) { // Path didn't work. Trying as a name KService::Ptr serv = KService::serviceByDesktopName( arg ); if ( serv ) path = serv->entryPath(); else { cerr << i18n("Module %1 not found!").arg(arg) << endl; return -1; } } args->clear(); // load the module ModuleInfo info(path); KCModule *module = ModuleLoader::module(info); if (module) { // create the dialog KCDialog dlg(module, module->buttons(), info.docPath(), 0, 0, true); dlg.setCaption(info.name()); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg.setAcceptDrops(true); // run the dialog return dlg.exec(); } return 0;}
QVector<ConnectionHandler> handler;
QPtrVector<ConnectionHandler> handler;
int main(int argc, char *argv[]){ KAboutData aboutData("kdesud", I18N_NOOP("KDE su daemon"), Version, I18N_NOOP("Daemon used by kdesu"), KAboutData::License_Artistic, "Copyright (c) 1999,2000 Geert Jansen"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Author"), "[email protected]", "http://www.stack.nl/~geertj/"); KCmdLineArgs::init(argc, argv, &aboutData); KInstance instance(&aboutData); // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { kdError(1205) << "setrlimit(): " << ERR << "\n"; exit(1); } // Create the Unix socket. int sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { kdError(1205) << "listen(): " << ERR << "\n"; kdesud_cleanup(); exit(1); } int maxfd = sockfd; // Ok, we're accepting connections. Fork to the background. pid_t pid = fork(); if (pid == -1) { kdError(1205) << "fork():" << ERR << "\n"; kdesud_cleanup(); exit(1); } if (pid) exit(0); // Make sure we exit when the display gets closed. int x11Fd = initXconnection(); maxfd = QMAX(maxfd, x11Fd); repo = new Repository; QVector<ConnectionHandler> handler; handler.setAutoDelete(true); // Signal handlers struct sigaction sa; sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); sa.sa_handler = SIG_IGN; sigaction(SIGPIPE, &sa, 0L); // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; struct timeval tv; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); if (x11Fd != -1) FD_SET(x11Fd, &active_fds); while (1) { tmp_fds = active_fds; tv.tv_sec = 5; tv.tv_usec = 0; if (select(maxfd+1, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; kdError(1205) << "select(): " << ERR << "\n"; exit(1); } repo->expire(); for (int i=0; i<=maxfd; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == x11Fd) { // Discard X events XEvent event_return; if (x11Display) XNextEvent(x11Display, &event_return); } if (i == sockfd) { // Accept new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { kdError(1205) << "accept():" << ERR << "\n"; continue; } if (fd+1 > (int) handler.size()) handler.resize(fd+1); handler.insert(fd, new ConnectionHandler(fd)); maxfd = QMAX(maxfd, fd); FD_SET(fd, &active_fds); continue; } // handle alreay established connection if (handler[i] && handler[i]->handle() < 0) { handler.remove(i); FD_CLR(i, &active_fds); } } } kdWarning(1205) << "???\n";}
if (KCGlobal::types().contains("System") && !KCGlobal::root())
if (KCGlobal::types().contains("system") && !KCGlobal::root())
int main(int argc, char *argv[]){ KAboutData aboutData( "kcontrol", I18N_NOOP("KDE Control Centre"), "v2.0pre", "The KDE Control Centre", KAboutData::License_GPL, "(c) 1998-2000, The KDE Control Centre Developers"); aboutData.addAuthor("Matthias Hoelzer-Kluepfel",0, "[email protected]"); aboutData.addAuthor("Matthias Elter",0, "[email protected]"); KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KApplication::addCmdLineOptions(); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); KCGlobal::init(); KCGlobal::setType(args->getOption("type")); MyApplication app; if (KCGlobal::types().contains("System") && !KCGlobal::root()) { KMessageBox::error(0, I18N_NOOP("Only the root user can edit system global settings!") , I18N_NOOP("Error!")); exit(0); } // show the whole stuff app.mainWidget()->show(); return app.exec();}
cursor = strdef; while (cursor) { strdef = cursor->next; delete [] cursor->st; delete cursor; cursor = strdef; } strdef = 0; cursor = chardef; while (cursor) { chardef = cursor->next; delete [] cursor->st; delete cursor; cursor = chardef; } chardef = 0;
void scan_man_page(const char *man_page){ if (!man_page) return; // ## Do more init // Unlike man2html, we actually call this several times, hence the need to // properly cleanup all those static vars s_ifelseval.clear(); section = 0; output_possible = false; int strLength = qstrlen(man_page); char *buf = new char[strLength + 2]; qstrcpy(buf+1, man_page); buf[0] = '\n'; scan_troff(buf+1,0,NULL); while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else if (itemdepth > 0) itemdepth--; } out_html(change_to_font(0)); out_html(change_to_size(0)); if (!fillout) { fillout=1; out_html("</PRE>"); } out_html(NEWLINE); if (section) { output_real("<div style=\"margin-left: 2cm\">\n"); section = 0; } if (output_possible) { output_real("</div>\n"); output_real("<div class=\"bannerBottom\" style=\"background-image: url("); output_real(cssPath); output_real("/bottom-middle.png); background-repeat: x-repeat; width: 100%; height: 100pt; bottom:0pt;\">\n"); output_real("<div class=\"bannerBottomLeft\">\n"); output_real("<img src=\""); output_real(cssPath); output_real("/bottom-left.png\" style=\"margin: 0pt;\" alt=\"Bottom left of the banner\">\n"); output_real("</div>\n"); output_real("<div class=\"bannerBottomRight\">\n"); output_real("<img src=\""); output_real(cssPath); output_real("/bottom-right.png\" style=\"margin: 0pt\" alt=\"Bottom right of the banner\">\n"); output_real("</div>\n"); output_real("</div>\n"); output_real("</BODY>\n</HTML>\n"); } delete [] buf; // reinit static variables for reuse STRDEF *cursor = defdef; while (cursor) { defdef = cursor->next; delete [] cursor->st; delete cursor; cursor = defdef; } defdef = 0; cursor = strdef; while (cursor) { strdef = cursor->next; delete [] cursor->st; delete cursor; cursor = strdef; } strdef = 0; cursor = chardef; while (cursor) { chardef = cursor->next; delete [] cursor->st; delete cursor; cursor = chardef; } chardef = 0; INTDEF *cursor2 = intdef; while (cursor2) { intdef = cursor2->next; delete cursor2; cursor2 = intdef; } intdef = 0; delete [] buffer; buffer = 0; escapesym='\\'; nobreaksym='\''; controlsym='.'; fieldsym=0; padsym=0; buffpos=0; buffmax=0; scaninbuff=false; itemdepth=0; for (int i = 0; i < 20; i++) dl_set[i] = 0; still_dd=false; for (int i = 0; i < 12; i++) tabstops[i] = (i+1)*8; maxtstop=12; curpos=0; argument = 0; mandoc_name_count = 0;}
mandoc_name_count = 0;
void scan_man_page(const char *man_page){ if (!man_page) return; // ## Do more init // Unlike man2html, we actually call this several times, hence the need to // properly cleanup all those static vars s_ifelseval.clear(); section = 0; output_possible = false; int strLength = strlen(man_page); char *buf = new char[strLength + 2]; strcpy(buf+1, man_page); buf[0] = '\n'; scan_troff(buf+1,0,NULL); while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else if (itemdepth > 0) itemdepth--; } out_html(change_to_font(0)); out_html(change_to_size(0)); if (!fillout) { fillout=1; out_html("</PRE>"); } out_html(NEWLINE); if (section) { output_real("<div style=\"margin-left: 2cm\">\n"); section = 0; } if (output_possible) { output_real( "<div id=\"bottom-nav\" style=\"position : relative; width : 100%;\n"); output_real( "height : 185px; left : 0px; right : 0px; top : 0px; margin-top: 100px;\n"); output_real( "background-image : url('KDE_COMMON_DIR/bottom1.png'); background-repeat :\n"); output_real( "repeat-x; background-color : transparent; margin-left: 0px;\n"); output_real( "margin-right: 0px; z-index : 25;\">\n"); output_real( "<img src=\"KDE_COMMON_DIR/bottom2.png\" align=\"right\" height=\"59\" width=\"227\" alt=\"KDE Logo\">\n"); output_real( "<div id=\"navtable2\" style=\"width : 100%; margin-left: 0px; margin-right:\n"); output_real( "0px; z-index : 15; background-color : transparent;\"></div>\n"); output_real( "</div> \n"); output_real("</BODY>\n</HTML>\n"); } delete [] buf; // reinit static variables for reuse STRDEF *cursor = defdef; while (cursor) { defdef = cursor->next; if (cursor->st) delete [] cursor->st; delete cursor; cursor = defdef; } defdef = 0; cursor = strdef; while (cursor) { strdef = cursor->next; if (cursor->st) delete [] cursor->st; delete cursor; cursor = strdef; } strdef = 0; cursor = chardef; while (cursor) { chardef = cursor->next; delete [] cursor->st; delete cursor; cursor = chardef; } chardef = 0; INTDEF *cursor2 = intdef; while (cursor2) { intdef = cursor2->next; delete cursor2; cursor2 = intdef; } intdef = 0; delete [] buffer; buffer = 0; escapesym='\\'; nobreaksym='\''; controlsym='.'; fieldsym=0; padsym=0; buffpos=0; buffmax=0; scaninbuff=0; itemdepth=0; for (int i = 0; i < 20; i++) dl_set[i] = 0; still_dd=0; for (int i = 0; i < 12; i++) tabstops[i] = (i+1)*8; maxtstop=12; curpos=0; argument = 0;}
output_real( "</div> \n");
void scan_man_page(const char *man_page){ if (!man_page) return; // ## Do more init // Unlike man2html, we actually call this several times, hence the need to // properly cleanup all those static vars s_ifelseval.clear(); section = 0; output_possible = false; int strLength = strlen(man_page); char *buf = new char[strLength + 2]; strcpy(buf+1, man_page); buf[0] = '\n'; scan_troff(buf+1,0,NULL); while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else if (itemdepth > 0) itemdepth--; } out_html(change_to_font(0)); out_html(change_to_size(0)); if (!fillout) { fillout=1; out_html("</PRE>"); } out_html(NEWLINE); if (section) { output_real("<div style=\"margin-left: 2cm\">\n"); section = 0; } if (output_possible) { output_real( "<div id=\"bottom-nav\" style=\"position : relative; width : 100%;\n"); output_real( "height : 185px; left : 0px; right : 0px; top : 0px; margin-top: 100px;\n"); output_real( "background-image : url('KDE_COMMON_DIR/bottom1.png'); background-repeat :\n"); output_real( "repeat-x; background-color : transparent; margin-left: 0px;\n"); output_real( "margin-right: 0px; z-index : 25;\">\n"); output_real( "<img src=\"KDE_COMMON_DIR/bottom2.png\" align=\"right\" height=\"59\" width=\"227\" alt=\"KDE Logo\">\n"); output_real( "<div id=\"navtable2\" style=\"width : 100%; margin-left: 0px; margin-right:\n"); output_real( "0px; z-index : 15; background-color : transparent;\"></div>\n"); output_real( "</div> \n"); output_real("</BODY>\n</HTML>\n"); } delete [] buf; // reinit static variables for reuse STRDEF *cursor = defdef; while (cursor) { defdef = cursor->next; if (cursor->st) delete [] cursor->st; delete cursor; cursor = defdef; } defdef = 0; cursor = strdef; while (cursor) { strdef = cursor->next; if (cursor->st) delete [] cursor->st; delete cursor; cursor = strdef; } strdef = 0; cursor = chardef; while (cursor) { chardef = cursor->next; delete [] cursor->st; delete cursor; cursor = chardef; } chardef = 0; INTDEF *cursor2 = intdef; while (cursor2) { intdef = cursor2->next; delete cursor2; cursor2 = intdef; } intdef = 0; delete [] buffer; buffer = 0; escapesym='\\'; nobreaksym='\''; controlsym='.'; fieldsym=0; padsym=0; buffpos=0; buffmax=0; scaninbuff=0; itemdepth=0; for (int i = 0; i < 20; i++) dl_set[i] = 0; still_dd=0; for (int i = 0; i < 12; i++) tabstops[i] = (i+1)*8; maxtstop=12; curpos=0; argument = 0; mandoc_name_count = 0;}
kDebugError("kdesud: Fatal IO error, exiting...");
kdError(1205) << "Fatal IO error, exiting...\n";
int xio_errhandler(Display *){ kDebugError("kdesud: Fatal IO error, exiting..."); kdesud_cleanup(); exit(1);}
kdDebug(KIO_SFTP_DB) << "kio_sftpProtocol::~kio_sftpProtocol(): pid = " << getpid() << endl;
kdDebug(KIO_SFTP_DB) << "~kio_sftpProtocol(): pid = " << getpid() << endl;
kio_sftpProtocol::~kio_sftpProtocol() { kdDebug(KIO_SFTP_DB) << "kio_sftpProtocol::~kio_sftpProtocol(): pid = " << getpid() << endl; closeConnection();}