bool SpeechData::readConfig(){ // Load configuration delete config; //config = KGlobal::config(); config = new KConfig("kttsdrc"); // Set the group general for the configuration of KTTSD itself (no plug ins) config->setGroup("General"); // Load the configuration of the text interruption messages and sound textPreMsgEnabled = config->readBoolEntry("TextPreMsgEnabled", false); textPreMsg = config->readEntry("TextPreMsg"); textPreSndEnabled = config->readBoolEntry("TextPreSndEnabled", false); textPreSnd = config->readEntry("TextPreSnd"); textPostMsgEnabled = config->readBoolEntry("TextPostMsgEnabled", false); textPostMsg = config->readEntry("TextPostMsg"); textPostSndEnabled = config->readBoolEntry("TextPostSndEnabled", false); textPostSnd = config->readEntry("TextPostSnd"); keepAudio = config->readBoolEntry("KeepAudio", false); keepAudioPath = config->readEntry("KeepAudioPath", locateLocal("data", "kttsd/audio/")); // Notification (KNotify). notify = config->readBoolEntry("Notify", false); notifyExcludeEventsWithSound = config->readBoolEntry("ExcludeEventsWithSound", true); loadNotifyEventsFromFile( locateLocal("config", "kttsd_notifyevents.xml"), true ); // KTTSMgr auto start and auto exit. autoStartManager = config->readBoolEntry("AutoStartManager", false); autoExitManager = config->readBoolEntry("AutoExitManager", false); // Clear the pool of filter managers so that filters re-init themselves. QPtrListIterator<PooledFilterMgr> it( m_pooledFilterMgrs ); for( ; it.current(); ++it ) { PooledFilterMgr* pooledFilterMgr = it.current(); delete pooledFilterMgr->filterMgr; delete pooledFilterMgr->talkerCode; delete pooledFilterMgr; } m_pooledFilterMgrs.clear(); // Create an initial FilterMgr for the pool to save time later. PooledFilterMgr* pooledFilterMgr = new PooledFilterMgr(); FilterMgr* filterMgr = new FilterMgr(); filterMgr->init(config, "General"); supportsHTML = filterMgr->supportsHTML(); pooledFilterMgr->filterMgr = filterMgr; pooledFilterMgr->busy = false; pooledFilterMgr->job = 0; pooledFilterMgr->partNum = 0; // Connect signals from FilterMgr. connect (filterMgr, SIGNAL(filteringFinished()), this, SLOT(slotFilterMgrFinished())); connect (filterMgr, SIGNAL(filteringStopped()), this, SLOT(slotFilterMgrStopped())); m_pooledFilterMgrs.append(pooledFilterMgr); return true; }
static QString findFileName(const QString* tmpl,bool universal, const QString &profile) { QString myFile, filename; KStandardDirs *dirs = KGlobal::dirs(); QString tmp = *tmpl; if (universal) { dirs->saveLocation("data", "konqsidebartng/kicker_entries/", true); tmp.prepend("/konqsidebartng/kicker_entries/"); } else { dirs->saveLocation("data", "konqsidebartng/" + profile + "/entries/", true); tmp.prepend("/konqsidebartng/" + profile + "/entries/"); } filename = tmp.arg(""); myFile = locateLocal("data", filename); if (QFile::exists(myFile)) { for (ulong l = 0; l < ULONG_MAX; l++) { filename = tmp.arg(l); myFile = locateLocal("data", filename); if (!QFile::exists(myFile)) { break; } else { myFile = QString::null; } } } return myFile; }
void KSUpgradeManager::slotCheckDownload(KIO::Job*, const QString &download, const QString &url) { switch(m_downloadState) { case(REMOVE_BACKUP): { KIO::DeleteJob *temp = KIO::del(KURL(download+"~"), false, false); m_localFile = download; m_remoteFile = url; connect(temp, SIGNAL(result(KIO::Job*)), this, SLOT(slotCheckDownload(KIO::Job*))); temp->setInteractive(false); m_downloadState = BACKUP; break; } case(BACKUP): { KIO::CopyJob *temp = KIO::move(KURL(m_localFile), KURL(m_localFile+"~"), false); connect(temp, SIGNAL(result(KIO::Job*)), this, SLOT(slotCheckDownload(KIO::Job*))); temp->setInteractive(false); m_downloadState = DOWNLOAD; break; } case(DOWNLOAD): { KIO::CopyJob *temp = KIO::copy(KURL(m_remoteFile), KURL(m_localFile), false); connect(temp, SIGNAL(result(KIO::Job*)), this, SLOT(slotCheckDownload(KIO::Job*))); connect(temp, SIGNAL(percent(KIO::Job*, unsigned long)), this, SLOT(slotProgress(KIO::Job*, unsigned long))); temp->setInteractive(false); m_downloadState = COMPLETE; break; } case(DELETE_VERSION): { KIO::DeleteJob *temp = KIO::del(KURL(locateLocal("appdata", "version")), false, false); connect(temp, SIGNAL(result(KIO::Job*)), this, SLOT(slotCheckDownload(KIO::Job*))); temp->setInteractive(false); m_downloadState = MOVE_VERSION; break; } case(MOVE_VERSION): { KIO::CopyJob *temp = KIO::move(KURL("/tmp/version"), KURL(locateLocal("appdata", "version")), false); connect(temp, SIGNAL(result(KIO::Job*)), this, SLOT(slotCheckDownload(KIO::Job*))); temp->setInteractive(false); m_downloadState = -1; break; } case(COMPLETE): { m_mainWidget->downloadProgress->setProgress(0); m_mainWidget->currentLabel->setText(i18n("nothing")); m_completedDownloads++; m_downloadState = DELETE_VERSION; slotCheckDownload(0); KSlovar::KSInstance()->loadLanguages(); break; } } }
// this function support LPRng piping feature, it defaults to // /etc/printcap in any other cases (basic support) QString getPrintcapFileName() { // check if LPRng system QString printcap("/etc/printcap"); QFile f("/etc/lpd.conf"); if (f.exists() && f.open(IO_ReadOnly)) { kdDebug() << "/etc/lpd.conf found: probably LPRng system" << endl; QTextStream t(&f); QString line; while (!t.eof()) { line = t.readLine().stripWhiteSpace(); if (line.startsWith("printcap_path=")) { kdDebug() << "printcap_path entry found: " << line << endl; QString pcentry = line.mid(14).stripWhiteSpace(); kdDebug() << "printcap_path value: " << pcentry << endl; if (pcentry[0] == '|') { // printcap through pipe printcap = locateLocal("tmp","printcap"); QString cmd = QString::fromLatin1("echo \"all\" | %1 > %2").arg(pcentry.mid(1)).arg(printcap); kdDebug() << "printcap obtained through pipe" << endl << "executing: " << cmd << endl; ::system(cmd.local8Bit()); } break; } } } kdDebug() << "printcap file returned: " << printcap << endl; return printcap; }
KCookieServer::KCookieServer(const QCString &name) : KDEDModule(name) { mOldCookieServer = new DCOPClient(); // backwards compatibility. mOldCookieServer->registerAs("kcookiejar", false); mOldCookieServer->setDaemonMode(true); mCookieJar = new KCookieJar; mPendingCookies = new KHttpCookieList; mPendingCookies->setAutoDelete(true); mRequestList = new RequestList; mAdvicePending = false; mTimer = new QTimer(); connect(mTimer, SIGNAL(timeout()), SLOT(slotSave())); mConfig = new KConfig("kcookiejarrc"); mCookieJar->loadConfig(mConfig); QString filename = locateLocal("data", "kcookiejar/cookies"); // Stay backwards compatible! QString filenameOld = locate("data", "kfm/cookies"); if(!filenameOld.isEmpty()) { mCookieJar->loadCookies(filenameOld); if(mCookieJar->saveCookies(filename)) { unlink(QFile::encodeName(filenameOld)); // Remove old kfm cookie file } } else { mCookieJar->loadCookies(filename); } connect(this, SIGNAL(windowUnregistered(long)), this, SLOT(slotDeleteSessionCookies(long))); }
KFileBookmarkHandler::KFileBookmarkHandler( KFileDialog *dialog ) : QObject( dialog, "KFileBookmarkHandler" ), KBookmarkOwner(), m_dialog( dialog ) { m_menu = new KPopupMenu( dialog, "bookmark menu" ); QString file = locate( "data", "kfile/bookmarks.xml" ); if ( file.isEmpty() ) file = locateLocal( "data", "kfile/bookmarks.xml" ); KBookmarkManager *manager = KBookmarkManager::managerForFile( file, false); // import old bookmarks if ( !KStandardDirs::exists( file ) ) { QString oldFile = locate( "data", "kfile/bookmarks.html" ); if ( !oldFile.isEmpty() ) importOldBookmarks( oldFile, manager ); } manager->setUpdate( true ); manager->setShowNSBookmarks( false ); m_bookmarkMenu = new KBookmarkMenu( manager, this, m_menu, dialog->actionCollection(), true ); }
bool BookmarkXXPort::exportContacts( const KABC::AddresseeList &list, const QString& ) { QString fileName = locateLocal( "data", "kabc/bookmarks.xml" ); KBookmarkManager *mgr = KBookmarkManager::managerForFile( fileName ); KBookmarkDomBuilder *builder = new KBookmarkDomBuilder( mgr->root(), mgr ); builder->connectImporter( this ); KABC::AddresseeList::ConstIterator it; emit newFolder( i18n( "AddressBook" ), false, "" ); for ( it = list.begin(); it != list.end(); ++it ) { if ( !(*it).url().isEmpty() ) { QString name = (*it).givenName() + " " + (*it).familyName(); emit newBookmark( name, (*it).url().url().latin1(), QString( "" ) ); } } emit endFolder(); delete builder; mgr->save(); KBookmarkMenu::DynMenuInfo menu; menu.name = i18n( "Addressbook Bookmarks" ); menu.location = fileName; menu.type = "xbel"; menu.show = true; KBookmarkMenu::setDynamicBookmarks( "kabc", menu ); return true; }
QString getVerboseGccIncludePath(bool *ok) { *ok = false; ///Create temp file KTempFile tempFile(locateLocal("tmp", "kdevelop_temp"), ".cpp"); tempFile.setAutoDelete(true); if( tempFile.status() != 0 ) return QString();//Failed to create temp file QString path = tempFile.name(); QFileInfo pathInfo( path ); char fileText[] = "//This source-file is empty"; fwrite(fileText, strlen(fileText), 1, tempFile.fstream() ); tempFile.close(); BlockingKProcess proc; proc.setUseShell(true); proc.setWorkingDirectory(pathInfo.dir(true).path()); proc << "gcc -v " + pathInfo.fileName() + " 2>&1"; if ( !proc.start(KProcess::NotifyOnExit, KProcess::Stdout) ) { kdWarning(9007) << "Couldn't start gcc" << endl; *ok = false; return QString(); } *ok = true; return proc.stdOut(); }
//New saveUserLog, moved from DetailDialog. //Should create a special UserLog widget that encapsulates the "default" //message in the widget when no log exists (much like we do with dmsBox now) void SkyObject::saveUserLog( const QString &newLog ) { QFile file; QString logs; //existing logs //Do nothing if new log is the "default" message //(keep going if new log is empty; we'll want to delete its current entry) if ( newLog == (i18n("Record here observation logs and/or data on %1.").arg(name())) || newLog.isEmpty() ) return; // header label QString KSLabel ="[KSLABEL:" + name() + "]"; //However, we can't accept a star name if it has a greek letter in it: if ( type() == STAR ) { StarObject *star = (StarObject*)this; if ( name() == star->gname() ) KSLabel = "[KSLABEL:" + star->gname( false ) + "]"; //"false": spell out greek letter } file.setName( locateLocal( "appdata", "userlog.dat" ) ); //determine filename in local user KDE directory tree. if ( file.open( IO_ReadOnly)) { QTextStream instream(&file); // read all data into memory logs = instream.read(); file.close(); } //Remove old log entry from the logs text if ( ! userLog.isEmpty() ) { int startIndex, endIndex; QString sub; startIndex = logs.find(KSLabel); sub = logs.mid (startIndex); endIndex = sub.find("[KSLogEnd]"); logs.remove(startIndex, endIndex + 11); } //append the new log entry to the end of the logs text, //but only if the log is not empty if ( ! newLog.stripWhiteSpace().isEmpty() ) logs.append( KSLabel + "\n" + newLog + "\n[KSLogEnd]\n" ); //Open file for writing //FIXME: change error message to "cannot write to user log file" if ( !file.open( IO_WriteOnly ) ) { kdDebug() << i18n( "user log file could not be opened." ) << endl; return; } //Write new logs text QTextStream outstream(&file); outstream << logs; //Set the log text in the object itself. userLog = newLog; file.close(); }
void YahooVerifyAccount::setUrl( KURL url ) { mFile = new KTempFile( locateLocal( "tmp", url.fileName() ) ); mFile->setAutoDelete( true ); KIO::TransferJob *transfer = KIO::get( url, false, false ); connect( transfer, SIGNAL( result( KIO::Job* ) ), this, SLOT( slotComplete( KIO::Job* ) ) ); connect( transfer, SIGNAL( data( KIO::Job*, const QByteArray& ) ), this, SLOT( slotData( KIO::Job*, const QByteArray& ) ) ); }
KateSessionManager::KateSessionManager(QObject *parent) : QObject(parent), m_sessionsDir(locateLocal("data", "kate/sessions")), m_activeSession(new KateSession(this, "", "")) { kdDebug() << "LOCAL SESSION DIR: " << m_sessionsDir << endl; // create dir if needed KGlobal::dirs()->makeDir(m_sessionsDir); }
/* Initiate user-config-file reading. */ int init_user_config(const char * l_name) { struct passwd * pw = getpwnam(l_name); if (!pw) return 0; else { struct stat buf; QString cfgFileName, tkannFileName; /* Set $HOME, because KInstance uses it */ setenv("HOME",pw->pw_dir,1 /* overwrite */); unsetenv("KDEHOME"); unsetenv("XAUTHORITY"); ktalk_debug("%s",pw->pw_dir); KInstance tmpInstance("tmpInstance"); cfgFileName = locateLocal("config", "ktalkdrc", &tmpInstance ); tkannFileName = locateLocal("config", "ktalkannouncerc", &tmpInstance); endpwent(); ktalk_debug("%s","endpwent"); //WABA: New KConfig should be able to handle this gracefully: if (stat(QFile::encodeName(tkannFileName),&buf)!=-1) { // check if it exists, 'cause otherwise it would be created empty with // root as owner ! ktkanncfg = new KConfig(tkannFileName); ktkanncfg -> setGroup("ktalkannounce"); ktkanncfg -> setDollarExpansion(true); } else ktkanncfg = 0L; if (stat(QFile::encodeName(cfgFileName),&buf)!=-1) { // check if it exists, 'cause otherwise it would be created empty with // root as owner ! ktalkdcfg = new KConfig(cfgFileName); ktalkdcfg -> setGroup("ktalkd"); ktalkdcfg -> setDollarExpansion(true); ktalk_debug("User config file ok"); } else { ktalkdcfg = 0L; ktalk_debug("No user config file %s !",cfgFileName.ascii()); } ktalk_debug("%s","done"); return ((ktkanncfg != 0L) || (ktalkdcfg != 0L)); /* Return true if at least one file exists */ } }
void ServiceButton::slotSaveAs(const KURL &oldUrl, KURL &newUrl) { QString oldPath = oldUrl.path(); if (locateLocal("appdata", oldUrl.fileName()) != oldPath) { QString path = KickerLib::newDesktopFile(oldUrl); newUrl.setPath(path); _id = path; } }
QString SloxFolderManager::cacheFile() const { QString host = mBaseUrl.host(); QString file = locateLocal( "cache", "slox/folders_" + host ); kdDebug() << k_funcinfo << file << endl; return file; }
QString KXMLGUIClient::localXMLFile() const { if ( !d->m_localXMLFile.isEmpty() ) return d->m_localXMLFile; if ( !QDir::isRelativePath(d->m_xmlFile) ) return QString::null; // can't save anything here return locateLocal( "data", QString::fromLatin1( instance()->instanceName() + '/' ) + d->m_xmlFile ); }
KSWizard::KSWizard(QWidget *parent, const char *name) :KSWizardWzt(parent, name) { m_mouseNavigation->setChecked(Configuration::mouseNavigation()); m_scrollBar->setChecked(Configuration::scrollBar()); m_smoothScroll->setChecked(Configuration::smoothScroll()); // m_authorName->setText(Configuration::authorName()); // m_authorEmail->setText(Configuration::authorEmail()); locateLocal("appdata", ""); m_downloadProgress->setShown(false); m_downloadLabel->setShown(false); setFinishEnabled(finish, true); connect(finishButton(), SIGNAL(pressed()), this, SLOT(slotFinish())); if(QFile::exists(locateLocal("appdata", "languages.ldft", false))) { languages->setDisabled(true); m_remoteLanguages->setChecked(false); } }
void K3bIsoImager::clearDummyDirs() { QString jobId = qApp->sessionId() + "_" + QString::number( m_sessionNumber ); QDir appDir( locateLocal( "appdata", "temp/" ) ); if( appDir.cd( jobId ) ) { QStringList dummyDirEntries = appDir.entryList( "dummydir*", QDir::Dirs ); for( QStringList::iterator it = dummyDirEntries.begin(); it != dummyDirEntries.end(); ++it ) appDir.rmdir( *it ); appDir.cdUp(); appDir.rmdir( jobId ); } }
void TapeManager::removeTape( Tape* tape ) { emit sigTapeRemoved( tape ); // Remove the index file. QString filename = locateLocal( "appdata", tape->getID() ); unlink( QFile::encodeName(filename) ); _tapeIDs.remove( tape->getID() ); _tapes.remove( tape->getID() ); }
// helper function for NIS support in Solaris-2.6 (use "ypcat printers.conf.byname") QString getEtcPrintersConfName() { QString printersconf("/etc/printers.conf"); if (!QFile::exists(printersconf) && !KStandardDirs::findExe( "ypcat" ).isEmpty()) { // standard file not found, try NIS printersconf = locateLocal("tmp","printers.conf"); QString cmd = QString::fromLatin1("ypcat printers.conf.byname > %1").arg(printersconf); kdDebug() << "printers.conf obtained from NIS server: " << cmd << endl; ::system(QFile::encodeName(cmd)); } return printersconf; }
void HighlightConfig::save() { QString fileName = locateLocal( "appdata", QString::fromLatin1( "highlight.xml" ) ); KSaveFile file( fileName ); if( file.status() == 0 ) { QTextStream *stream = file.textStream(); stream->setEncoding( QTextStream::UnicodeUTF8 ); QString xml = QString::fromLatin1( "<?xml version=\"1.0\"?>\n" "<!DOCTYPE kopete-highlight-plugin>\n" "<highlight-plugin>\n" ); // Save metafilter information. QPtrListIterator<Filter> filtreIt( m_filters ); for( ; filtreIt.current(); ++filtreIt ) { Filter *filtre = *filtreIt; xml += QString::fromLatin1( " <filter>\n <display-name>" ) + QStyleSheet::escape(filtre->displayName) + QString::fromLatin1( "</display-name>\n" ); xml += QString::fromLatin1(" <search caseSensitive=\"") + QString::number( static_cast<int>( filtre->caseSensitive ) ) + QString::fromLatin1("\" regExp=\"") + QString::number( static_cast<int>( filtre->isRegExp ) ) + QString::fromLatin1( "\">" ) + QStyleSheet::escape( filtre->search ) + QString::fromLatin1( "</search>\n" ); xml += QString::fromLatin1(" <BG set=\"") + QString::number( static_cast<int>( filtre->setBG ) ) + QString::fromLatin1( "\">" ) + QStyleSheet::escape( filtre->BG.name() ) + QString::fromLatin1( "</BG>\n" ); xml += QString::fromLatin1(" <FG set=\"") + QString::number( static_cast<int>( filtre->setFG ) ) + QString::fromLatin1( "\">" ) + QStyleSheet::escape( filtre->FG.name() ) + QString::fromLatin1( "</FG>\n" ); xml += QString::fromLatin1(" <importance set=\"") + QString::number( static_cast<int>( filtre->setImportance ) ) + QString::fromLatin1( "\">" ) + QString::number( filtre->importance ) + QString::fromLatin1( "</importance>\n" ); xml += QString::fromLatin1(" <sound set=\"") + QString::number( static_cast<int>( filtre->playSound ) ) + QString::fromLatin1( "\">" ) + QStyleSheet::escape( filtre->soundFN ) + QString::fromLatin1( "</sound>\n" ); xml += QString::fromLatin1(" <raise set=\"") + QString::number( static_cast<int>( filtre->raiseView ) ) + QString::fromLatin1( "\"></raise>\n" ); xml += QString::fromLatin1( " </filter>\n" ); } xml += QString::fromLatin1( "</highlight-plugin>\n" ); *stream << xml; } }
bool HistoryPlugin::detectOldHistory() { KGlobal::config()->setGroup("History Plugin"); QString version=KGlobal::config()->readEntry( "Version" ,"0.6" ); if(version != "0.6") return false; QDir d( locateLocal( "data", QString::fromLatin1( "kopete/logs")) ); d.setFilter( QDir::Dirs ); if(d.count() >= 3) // '.' and '..' are included return false; //the new history already exists QDir d2( locateLocal( "data", QString::fromLatin1( "kopete")) ); d2.setFilter( QDir::Dirs ); const QFileInfoList_qt3 *list = d2.entryInfoList_qt3(); QFileInfoListIterator it( *list ); QFileInfo *fi; while ( (fi = it.current()) != 0 ) { if( dynamic_cast<Kopete::Protocol *>( Kopete::PluginManager::self()->plugin( fi->fileName() ) ) ) return true; if(fi->fileName() == "MSNProtocol" || fi->fileName() == "msn_logs" ) return true; else if(fi->fileName() == "ICQProtocol" || fi->fileName() == "icq_logs" ) return true; else if(fi->fileName() == "AIMProtocol" || fi->fileName() == "aim_logs" ) return true; else if(fi->fileName() == "OscarProtocol" ) return true; else if(fi->fileName() == "JabberProtocol" || fi->fileName() == "jabber_logs") return true; ++it; } return false; }
void KSUpgradeManager::slotCheckVersion() { QString localVersion = "000", remoteVersion = "000"; QString versionFile = locateLocal("appdata", "version"); QString languageFile = locateLocal("appdata", "languages.ksl", false); QFile local(versionFile); if(local.exists()) { local.open(IO_ReadOnly); QString input; local.readLine(input, 5); localVersion = input; local.close(); } QFile remote("/tmp/version"); if(remote.exists()) { remote.open(IO_ReadOnly); QString input; remote.readLine(input, 5); remoteVersion = input; remote.close(); } if(remoteVersion > localVersion) { new KListViewItem(m_mainWidget->downloadList, "Languages.ksl", languageFile, "http://kslovar.berlios.de/languages.ksl"); enableButtonOK(true); m_mainWidget->currentLabel->setText(i18n("nothing")); } else { KSlovar::KSInstance()->loadLanguages(); close(); } }
void KOIncidenceEditor::saveAsTemplate( Incidence *incidence, const QString &templateName ) { if ( !incidence || templateName.isEmpty() ) return; QString fileName = "templates/" + incidence->type(); fileName.append( "/" + templateName ); fileName = locateLocal( "data", "korganizer/" + fileName ); CalendarLocal cal( KOPrefs::instance()->mTimeZoneId ); cal.addIncidence( incidence ); ICalFormat format; format.save( &cal, fileName ); }
void ConfFilters::save() { TQListViewItem *item = m_filters->firstChild(); TQFile f(locateLocal("data","tdeprintfax/faxfilters")); if (f.open(IO_WriteOnly)) { TQTextStream t(&f); while (item) { t << item->text(0) << ' ' << item->text(1) << endl; item = item->nextSibling(); } } }
KVerbosUser::KVerbosUser(spanishVerbList* pL, QString n/*=DEFAULTUSER*/) : name(n), auswahl(""), sessions(0) { // try to read the user-information if there is one. int pos; while ((pos = n.find(' ')) != -1) n.replace(pos, 1, "_"); QFile file(locateLocal("data", "/kverbos/data/"+name+".kverbos")); if ( file.open(IO_ReadOnly) ) { QString s; QTextStream t( &file ); name = t.readLine(); s = t.readLine(); sessions = s.toInt(); for (int i=0; i<MAX_RESULTS; i++) { date[i] = t.readLine(); s = t.readLine(); result[i][0] = s.toInt(); s = t.readLine(); result[i][1] = s.toInt(); }; while (!file.atEnd()) { eintrag e; e.verb = t.readLine(); s = t.readLine(); e.status = s.toInt(); s = t.readLine(); e.right = s.toInt(); s = t.readLine(); e.wrong = s.toInt(); if (e.status == 1) e.counter = STAY_IN_R_LIST; else e.counter = 0; e.used = false; it = liste.find(e); if (liste.end() == it) liste.append(e); }; file.close(); } else for (int i=0; i<MAX_RESULTS; i++) { date[i] = ""; result[i][0] = result[i][1] = 0; }; fillList(pL); it = liste.begin(); sessions = (sessions + 1) & 1073741823; }
bool IconThemesConfig::installThemes(const QStringList &themes, const QString &archiveName) { bool everythingOk = true; QString localThemesDir(locateLocal("icon", "./")); KProgressDialog progressDiag(this, "themeinstallprogress", i18n("Installing icon themes"), QString::null, true); progressDiag.setAutoClose(true); progressDiag.progressBar()->setTotalSteps(themes.count()); progressDiag.show(); KTar archive(archiveName); archive.open(IO_ReadOnly); kapp->processEvents(); const KArchiveDirectory* rootDir = archive.directory(); KArchiveDirectory* currentTheme; for (QStringList::ConstIterator it = themes.begin(); it != themes.end(); ++it) { progressDiag.setLabel( i18n("<qt>Installing <strong>%1</strong> theme</qt>") .arg(*it)); kapp->processEvents(); if (progressDiag.wasCancelled()) break; currentTheme = dynamic_cast<KArchiveDirectory*>( const_cast<KArchiveEntry*>( rootDir->entry(*it))); if (currentTheme == NULL) { // we tell back that something went wrong, but try to install as much // as possible everythingOk = false; continue; } currentTheme->copyTo(localThemesDir + *it); progressDiag.progressBar()->advance(1); } archive.close(); return everythingOk; }
NotificationDialog::NotificationDialog( KFileItem medium, NotifierSettings *settings, TQWidget* parent, const char* name ) : KDialogBase( parent, name, false, i18n( "Medium Detected" ), Ok|Cancel|User1, Ok, true), m_medium(medium), m_settings( settings ) { setCaption( TDEIO::decodeFileName(m_medium.name()) ); clearWState( WState_Polished ); TQWidget *page = new TQWidget( this ); setMainWidget(page); TQVBoxLayout *topLayout = new TQVBoxLayout( page, 0, spacingHint() ); m_view = new NotificationDialogView( page ); topLayout->addWidget(m_view); m_view->iconLabel->setPixmap( m_medium.pixmap(64) ); m_view->mimetypeLabel->setText( i18n( "<b>Medium type:</b>" ) + " " + m_medium.mimeTypePtr()->comment() ); updateActionsListBox(); resize( TQSize(400,400).expandedTo( minimumSizeHint() ) ); m_actionWatcher = new KDirWatch(); TQString services_dir = locateLocal( "data", "konqueror/servicemenus", true ); m_actionWatcher->addDir( services_dir ); setButtonText( User1, i18n("Configure...") ); connect( m_actionWatcher, TQT_SIGNAL( dirty( const TQString & ) ), this, TQT_SLOT( slotActionsChanged( const TQString & ) ) ); connect( this , TQT_SIGNAL( okClicked() ), this, TQT_SLOT( slotOk() ) ); connect( this, TQT_SIGNAL( user1Clicked() ), this, TQT_SLOT( slotConfigure() ) ); connect( m_view->actionsList, TQT_SIGNAL( doubleClicked ( TQListBoxItem*, const TQPoint & ) ), this, TQT_SLOT( slotOk() ) ); connect( this, TQT_SIGNAL( finished() ), this, TQT_SLOT( delayedDestruct() ) ); m_actionWatcher->startScan(); TQPushButton * btn = actionButton( Ok ); btn->setFocus(); }
void KSlovar::loadLanguages() { if(!QFile::exists(locateLocal("appdata", "languages.ksl", false))) //Check if Languages.ksl exists. If not, run the upgrade manager to download it. { if(QFile::exists(locateLocal("appdata", "languages.ksl", false)+"~")) //Check if Languages.ksl exists. If not, run the upgrade manager to download it. { KIO::move(KURL(locateLocal("appdata", "languages.ksl", false)+"~"), KURL(locateLocal("appdata", "languages.ksl", false)), false)->setInteractive(false); KIO::del(KURL(locateLocal("appdata", "version", false)), false, false)->setInteractive(false); KMessageBox::information(this, i18n("Could not find languages.ksl. But found it's backup and using it.")); } else { KIO::del(KURL(locateLocal("appdata", "version", false)), false, false)->setInteractive(false); KMessageBox::error(this, i18n("Could not find languages.ksl. Run Upgrade manager to download it.\n\nIf you do not have any internet connection, you can download it from http://kslovar.berlios.de/languages.ksl and put it into ~/.kde/share/apps/kslovar/.")); return; } } KSData::instance()->setLanguageHandler(new KSDBHandler(QString::fromUtf8(locateLocal("appdata", "languages.ksl", false)))); QStringList input=KSData::instance()->getLanguageHandler()->processList("SELECT id, name FROM language;", 2); if(!input.isEmpty()) { QString id, name; for(QStringList::iterator count=input.begin();count!=input.end();count++) { id=*count; name=*count; KSData::instance()->addLanguage(name.remove(QRegExp("^.+/")), id.remove(QRegExp("/.+$")).toInt()); } } if(m_dictionarydlg) { m_dictionarydlg->populateLanguages(); } input.clear(); input=KSData::instance()->getLanguageHandler()->processList("SELECT fromc, toc FROM conversion_table;", 2); if(!input.isEmpty()) { QChar from, to; for(QStringList::iterator count=input.begin();count!=input.end();count++) { from=(*count).at(0); to=(*count).at(2); KSData::instance()->addConversion(from, to); } } }
KDEsuClient::KDEsuClient() { sockfd = -1; QCString display(getenv("DISPLAY")); if(display.isEmpty()) { kdWarning(900) << k_lineinfo << "$DISPLAY is not set\n"; return; } // strip the screen number from the display display.replace(QRegExp("\\.[0-9]+$"), ""); sock = QFile::encodeName(locateLocal("socket", QString("kdesud_%1").arg(display))); d = new KDEsuClientPrivate; connect(); }
void KOIncidenceEditor::slotLoadTemplate( const QString& templateName ) { CalendarLocal cal( KOPrefs::instance()->mTimeZoneId ); QString fileName = locateLocal( "data", "korganizer/templates/" + type() + "/" + templateName ); if ( fileName.isEmpty() ) { KMessageBox::error( this, i18n("Unable to find template '%1'.") .arg( fileName ) ); } else { ICalFormat format; if ( !format.load( &cal, fileName ) ) { KMessageBox::error( this, i18n("Error loading template file '%1'.") .arg( fileName ) ); return; } } loadTemplate( cal ); }