void SearchCommand::processText( Kate::View *view, const TQString &cmd ) { static TQRegExp re_ifind("ifind(?::([bcrs]*))?\\s(.*)"); if ( re_ifind.search( cmd ) > -1 ) { TQString flags = re_ifind.cap( 1 ); TQString pattern = re_ifind.cap( 2 ); // if there is no setup, or the text length is 0, set up the properties if ( ! m_ifindFlags || pattern.isEmpty() ) ifindInit( flags ); // if there is no fromCursor, add it if this is not the first character else if ( ! ( m_ifindFlags & KFindDialog::FromCursor ) && ! pattern.isEmpty() ) m_ifindFlags |= KFindDialog::FromCursor; // search.. if ( ! pattern.isEmpty() ) { KateView *v = (KateView*)view; // If it *looks like* we are continuing, place the cursor // at the beginning of the selection, so that the search continues. // ### check more carefully, like is the cursor currently at the end // of the selection. if ( pattern.startsWith( v->selection() ) && v->selection().length() + 1 == pattern.length() ) v->setCursorPositionInternal( v->selStartLine(), v->selStartCol() ); v->find( pattern, m_ifindFlags, false ); } } }
bool isNetworkFileSystem(TQString fileSystemType) { if ((fileSystemType.startsWith("nfs")) || (fileSystemType == "cifs") ) { return TRUE; } return FALSE; }
bool PropertiesPage::save() { TQStringList result; if (options.contains("ro")) result << TQString("ro=%1").arg(option_ro->isChecked() ? "true" : "false"); if (options.contains("quiet")) result << TQString("quiet=%1").arg(option_quiet->isChecked() ? "true" : "false"); if (options.contains("sync")) result << TQString("sync=%1").arg(option_sync->isChecked() ? "true" : "false"); if (options.contains("atime")) result << TQString("atime=%1").arg(option_atime->isChecked() ? "true" : "false"); if (options.contains("flush")) result << TQString("flush=%1").arg(option_flush->isChecked() ? "true" : "false"); if (options.contains("utf8")) result << TQString("utf8=%1").arg(option_utf8->isChecked() ? "true" : "false"); if (options.contains("uid")) result << TQString("uid=%1").arg(option_uid->isChecked() ? "true" : "false"); if (options.contains("shortname")) result << TQString("shortname=%1").arg(short_names[option_shortname->currentItem()]); if (options.contains("journaling")) result << TQString("journaling=%1").arg(journales[option_journaling->currentItem()]); TQString mp = option_mountpoint->text(); if (!mp.startsWith("/media/")) { KMessageBox::sorry(this, i18n("Mountpoint has to be below /media")); return false; } result << TQString("mountpoint=%1").arg(mp); result << TQString("automount=%1").arg(option_automount->isChecked() ? "true" : "false"); result << TQString("use_defaults=%1").arg(option_defaults->isChecked() ? "true" : "false"); kdDebug() << result << endl; DCOPRef mediamanager("kded", "mediamanager"); DCOPReply reply = mediamanager.call( "setMountoptions", id, result); if (reply.isValid()) return (bool)reply; else { KMessageBox::sorry(this, i18n("Saving the changes failed")); return false; } }
TQString TDEStorageDevice::determineFileSystemType(TQString path) { TQStringList mountTable; TQString prevPath = path; dev_t prevDev = 0; int pos; struct stat directory_info; if (path.startsWith("/")) { stat(path.local8Bit(), &directory_info); prevDev = directory_info.st_dev; // Walk the directory tree up to the root, checking for any change in st_dev // If a change is found, the previous value of path is the mount point itself while (path != "/") { pos = path.findRev("/", -1, TRUE); if (pos < 0) { break; } path = path.mid(0, pos); if (path == "") { path = "/"; } stat(path.local8Bit(), &directory_info); if (directory_info.st_dev != prevDev) { break; } prevPath = path; prevDev = directory_info.st_dev; } } // Read in mount table mountTable.clear(); TQFile file( "/proc/mounts" ); if ( file.open( IO_ReadOnly ) ) { TQTextStream stream( &file ); while ( !stream.atEnd() ) { mountTable.append(stream.readLine()); } file.close(); } // Parse mount table TQStringList::Iterator it; for ( it = mountTable.begin(); it != mountTable.end(); ++it ) { TQStringList mountInfo = TQStringList::split(" ", (*it), true); if ((*mountInfo.at(1)) == prevPath) { return (*mountInfo.at(2)); } } // Unknown file system type return TQString::null; }
TQString TrashImpl::makeRelativePath( const TQString& topdir, const TQString& path ) { const TQString realPath = TDEStandardDirs::realFilePath( path ); // topdir ends with '/' if ( realPath.startsWith( topdir ) ) { const TQString rel = realPath.mid( topdir.length() ); Q_ASSERT( rel[0] != '/' ); return rel; } else { // shouldn't happen... kdWarning() << "Couldn't make relative path for " << realPath << " (" << path << "), with topdir=" << topdir << endl; return realPath; } }
void EvaChatView::slotLinkClicked( const KURL & url, const KParts::URLArgs &/*args*/) { TQString cmd = url.url(); TQString strSession = cmd.mid(13,cmd.length() - 13); bool ok; unsigned int session = strSession.toUInt(&ok); if(ok) { if(cmd.startsWith(protocolAccept) ) { emit fileTransferAcceptRequest(session); return; } if(cmd.startsWith(protocolSaveAs) ) { emit fileTransferSaveAsRequest(session); return; } if(cmd.startsWith(protocolCancel) ) { emit fileTransferCancelRequest(session); return; } if(cmd.startsWith(protocolResume) ) { emit fileTransferResume(session, true); return; } if(cmd.startsWith(protocolNewOne) ) { emit fileTransferResume(session, false); return; } } TQStringList args; if(url.isLocalFile()) { args<<"exec"<< TQString::fromLocal8Bit(url.path().ascii()); } else { args<<"exec" <<cmd; } kapp->tdeinitExec("kfmclient",args); }
void KMMainView::slotChangePrinterState() { TQString opname = TQT_TQOBJECT_CONST(sender())->name(); if (m_current && opname.startsWith("printer_")) { opname = opname.mid(8); KMTimer::self()->hold(); bool result(false); if (opname == "enable") result = m_manager->enablePrinter(m_current, true); else if (opname == "disable") result = m_manager->enablePrinter(m_current, false); else if (opname == "start") result = m_manager->startPrinter(m_current, true); else if (opname == "stop") result = m_manager->startPrinter(m_current, false); if (!result) showErrorMsg(i18n("Unable to modify the state of printer %1.").arg(m_current->printerName())); KMTimer::self()->release(result); } }
void KJavaAppletContext::received( const TQString& cmd, const TQStringList& arg ) { kdDebug(6100) << "KJavaAppletContext::received, cmd = >>" << cmd << "<<" << endl; kdDebug(6100) << "arg count = " << arg.count() << endl; if ( cmd == TQString::fromLatin1("showstatus") && !arg.empty() ) { TQString tmp = arg.first(); tmp.replace(TQRegExp("[\n\r]"), ""); kdDebug(6100) << "status message = " << tmp << endl; emit showStatus( tmp ); } else if ( cmd == TQString::fromLatin1( "showurlinframe" ) && arg.count() > 1 ) { kdDebug(6100) << "url = " << arg[0] << ", frame = " << arg[1] << endl; emit showDocument( arg[0], arg[1] ); } else if ( cmd == TQString::fromLatin1( "showdocument" ) && !arg.empty() ) { kdDebug(6100) << "url = " << arg.first() << endl; emit showDocument( arg.first(), "_top" ); } else if ( cmd == TQString::fromLatin1( "resizeapplet" ) && arg.count() > 2 ) { //arg[1] should be appletID //arg[2] should be new width //arg[3] should be new height bool ok; const int appletID = arg[0].toInt( &ok ); const int width = arg[1].toInt( &ok ); const int height = arg[2].toInt( &ok ); if( !ok ) { kdError(DEBUGAREA) << "could not parse out parameters for resize" << endl; } else { KJavaApplet* const tmp = d->applets[appletID]; if (tmp) tmp->resizeAppletWidget( width, height ); } } else if (cmd.startsWith(TQString::fromLatin1("audioclip_"))) { kdDebug(DEBUGAREA) << "process Audio command (not yet implemented): " << cmd << " " << arg[0] << endl; } else if ( cmd == TQString::fromLatin1( "JS_Event" ) && arg.count() > 2 ) { bool ok; const int appletID = arg.first().toInt(&ok); KJavaApplet * applet; if (ok && (applet = d->applets[appletID])) { TQStringList js_args(arg); js_args.pop_front(); applet->jsData(js_args); } else kdError(DEBUGAREA) << "parse JS event " << arg[0] << " " << arg[1] << endl; } else if ( cmd == TQString::fromLatin1( "AppletStateNotification" ) ) { bool ok; const int appletID = arg.first().toInt(&ok); if (ok) { KJavaApplet* const applet = d->applets[appletID]; if ( applet ) { const int newState = arg[1].toInt(&ok); if (ok) { applet->stateChange(newState); if (newState == KJavaApplet::INITIALIZED) { kdDebug(DEBUGAREA) << "emit appletLoaded" << endl; emit appletLoaded(); } } else kdError(DEBUGAREA) << "AppletStateNotification: status is not numerical" << endl; } else kdWarning(DEBUGAREA) << "AppletStateNotification: No such Applet with ID=" << arg[0] << endl; } else kdError(DEBUGAREA) << "AppletStateNotification: Applet ID is not numerical" << endl; } else if ( cmd == TQString::fromLatin1( "AppletFailed" ) ) { bool ok; const int appletID = arg.first().toInt(&ok); if (ok) { KJavaApplet* const applet = d->applets[appletID]; /* TQString errorDetail(arg[1]); errorDetail.replace(TQRegExp(":\\s*"), ":\n"); KMessageBox::detailedError(0L, i18n("Java error while loading applet."), errorDetail); */ if (applet) applet->setFailed(); emit appletLoaded(); } } }
//BEGIN SearchCommand bool SearchCommand::exec(class Kate::View *view, const TQString &cmd, TQString &msg) { TQString flags, pattern, replacement; if ( cmd.startsWith( "find" ) ) { static TQRegExp re_find("find(?::([bcersw]*))?\\s+(.+)"); if ( re_find.search( cmd ) < 0 ) { msg = i18n("Usage: find[:[bcersw]] PATTERN"); return false; } flags = re_find.cap( 1 ); pattern = re_find.cap( 2 ); } else if ( cmd.startsWith( "ifind" ) ) { static TQRegExp re_ifind("ifind(?::([bcrs]*))?\\s+(.*)"); if ( re_ifind.search( cmd ) < 0 ) { msg = i18n("Usage: ifind[:[bcrs]] PATTERN"); return false; } ifindClear(); return true; } else if ( cmd.startsWith( "replace" ) ) { // Try if the pattern and replacement is quoted, using a quote character ["'] static TQRegExp re_rep("replace(?::([bceprsw]*))?\\s+([\"'])((?:[^\\\\\\\\2]|\\\\.)*)\\2\\s+\\2((?:[^\\\\\\\\2]|\\\\.)*)\\2\\s*$"); // Or one quoted argument TQRegExp re_rep1("replace(?::([bceprsw]*))?\\s+([\"'])((?:[^\\\\\\\\2]|\\\\.)*)\\2\\s*$"); // Else, it's just one or two (space separated) words TQRegExp re_rep2("replace(?::([bceprsw]*))?\\s+(\\S+)(.*)"); #define unbackslash(s) p=0;\ while ( (p = pattern.find( '\\' + delim, p )) > -1 )\ {\ if ( !p || pattern[p-1] != '\\' )\ pattern.remove( p, 1 );\ p++;\ } if ( re_rep.search( cmd ) >= 0 ) { flags = re_rep.cap(1); pattern = re_rep.cap( 3 ); replacement = re_rep.cap( 4 ); int p(0); // unbackslash backslashed delimiter strings // in pattern .. TQString delim = re_rep.cap( 2 ); unbackslash(pattern); // .. and in replacement unbackslash(replacement); } else if ( re_rep1.search( cmd ) >= 0 ) { flags = re_rep1.cap(1); pattern = re_rep1.cap( 3 ); int p(0); TQString delim = re_rep1.cap( 2 ); unbackslash(pattern); } else if ( re_rep2.search( cmd ) >= 0 ) { flags = re_rep2.cap( 1 ); pattern = re_rep2.cap( 2 ); replacement = TQString(re_rep2.cap( 3 )).stripWhiteSpace(); } else { msg = i18n("Usage: replace[:[bceprsw]] PATTERN [REPLACEMENT]"); return false; } kdDebug()<<"replace '"<<pattern<<"' with '"<<replacement<<"'"<<endl; #undef unbackslash } long f = 0; if ( flags.contains( 'b' ) ) f |= KFindDialog::FindBackwards; if ( flags.contains( 'c' ) ) f |= KFindDialog::FromCursor; if ( flags.contains( 'e' ) ) f |= KFindDialog::SelectedText; if ( flags.contains( 'r' ) ) f |= KFindDialog::RegularExpression; if ( flags.contains( 'p' ) ) f |= KReplaceDialog::PromptOnReplace; if ( flags.contains( 's' ) ) f |= KFindDialog::CaseSensitive; if ( flags.contains( 'w' ) ) f |= KFindDialog::WholeWordsOnly; if ( cmd.startsWith( "find" ) ) { ((KateView*)view)->find( pattern, f ); return true; } else if ( cmd.startsWith( "replace" ) ) { f |= KReplaceDialog::BackReference; // mandatory here? ((KateView*)view)->replace( pattern, replacement, f ); return true; } return false; }
void Security::slotDataArrived(KProcIO *procIO) { TQString data; while (procIO->readln(data, true) != -1) { switch (m_runMode) { case List: case ListSecret: if (data.startsWith("pub") || data.startsWith("sec")) { KeyStruct key; if (data.startsWith("pub")) key.secret = false; else key.secret = true; TQStringList line = TQStringList::split(":", data, true); key.id = line[4]; TQString shortId = key.id.right(8); TQString trustStr = line[1]; key.trusted = false; if (trustStr == "u" || trustStr == "f") key.trusted = true; data = line[9]; key.mail=data.section('<', -1, -1); key.mail.truncate(key.mail.length() - 1); key.name=data.section('<',0,0); if (key.name.find("(")!=-1) key.name=key.name.section('(',0,0); m_keys[shortId] = key; } break; case Verify: data = TQString(data.section("]",1,-1)).stripWhiteSpace(); if (data.startsWith("GOODSIG")) { m_result &= SIGNED_BAD_CLEAR; m_result |= SIGNED_OK; TQString id = data.section(" ", 1 , 1).right(8); if (!m_keys.contains(id)) { m_result |= UNKNOWN; } else { m_signatureKey = m_keys[id]; } } else if (data.startsWith("NO_PUBKEY")) { m_result &= SIGNED_BAD_CLEAR; m_result |= UNKNOWN; } else if (data.startsWith("BADSIG")) { m_result |= SIGNED_BAD; TQString id = data.section(" ", 1 , 1).right(8); if (!m_keys.contains(id)) { m_result |= UNKNOWN; } else { m_signatureKey = m_keys[id]; } } else if (data.startsWith("TRUST_ULTIMATE")) { m_result &= SIGNED_BAD_CLEAR; m_result |= TRUSTED; } break; case Sign: if (data.find("passphrase.enter") != -1) { TQCString password; KeyStruct key = m_keys[m_secretKey]; int result = KPasswordDialog::getPassword(password, i18n("<qt>Enter passphrase for key <b>0x%1</b>, belonging to<br><i>%2<%3></i>:</qt>").arg(m_secretKey).arg(key.name).arg(key.mail)); if (result == KPasswordDialog::Accepted) { procIO->writeStdin(password, true); password.fill(' '); } else { m_result |= BAD_PASSPHRASE; slotProcessExited(procIO); return; } } else if (data.find("BAD_PASSPHRASE") != -1) { m_result |= BAD_PASSPHRASE; } break; } } }
int main( int argc, char *argv[] ) { TDEAboutData aboutData( "ksystraycmd", I18N_NOOP( "KSysTrayCmd" ), "KSysTrayCmd 0.1", I18N_NOOP( "Allows any application to be kept in the system tray" ), TDEAboutData::License_GPL, "(C) 2001-2002 Richard Moore ([email protected])" ); aboutData.addAuthor( "Richard Moore", 0, "*****@*****.**" ); TDECmdLineArgs::init( argc, argv, &aboutData ); TDECmdLineArgs::addCmdLineOptions( options ); // Add our own options. TDEApplication app; // // Setup the tray icon from the arguments. // TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); KSysTrayCmd cmd; // Read the window id TQString wid = args->getOption( "wid" ); if ( !wid.isEmpty() ) { int base = 10; if ( wid.startsWith( "0x" ) ) { base = 16; wid = wid.right( wid.length() - 2 ); } bool ok=true; ulong w = wid.toULong( &ok, base ); if ( ok ) cmd.setTargetWindow( w ); else { kdWarning() << "KSysTrayCmd: Got bad win id" << endl; } } // Read window title regexp TQString title = args->getOption( "window" ); if ( !title.isEmpty() ) cmd.setPattern( title ); if ( !title && !wid && (args->count() == 0) ) TDECmdLineArgs::usage(i18n("No command or window specified")); // Read the command TQString command; for ( int i = 0; i < args->count(); i++ ) command += TDEProcess::quote(TQString::fromLocal8Bit( args->arg(i) )) + " "; if ( !command.isEmpty() ) cmd.setCommand( command ); // Tooltip TQString tip = args->getOption( "tooltip" ); if ( !tip.isEmpty() ) cmd.setDefaultTip( tip ); // Keep running flag if ( args->isSet( "keeprunning" ) ) cmd.setNoQuit( true ); if ( args->isSet( "quitonhide" ) ) { cmd.setNoQuit( true ); cmd.setQuitOnHide( true ); } // Start hidden if ( args->isSet( "hidden" ) ) cmd.hideWindow(); // On top if ( args->isSet( "ontop" ) ) cmd.setOnTop(true); // Use ksystraycmd icon if ( args->isSet( "ownicon" ) ) cmd.setOwnIcon(true); // Lazy invocation flag if ( args->isSet( "startonshow" ) ) { cmd.setStartOnShow( true ); cmd.show(); } else { if ( !cmd.start() ) return 1; } fcntl(ConnectionNumber(tqt_xdisplay()), F_SETFD, 1); args->clear(); return app.exec(); }
void CupsAddSmb::slotReceived(TDEProcess*, char *buf, int buflen) { TQString line; int index(0); bool partial(false); static bool incomplete(false); kdDebug(500) << "slotReceived()" << endl; while (1) { // read a line line = TQString::fromLatin1(""); partial = true; while (index < buflen) { TQChar c(buf[index++]); if (c == '\n') { partial = false; break; } else if (c.isPrint()) line += c; } if (line.isEmpty()) { kdDebug(500) << "NOTHING TO READ" << endl; return; } kdDebug(500) << "ANSWER = " << line << " (END = " << line.length() << ")" << endl; if (!partial) { if (incomplete && m_buffer.count() > 0) m_buffer[m_buffer.size()-1].append(line); else m_buffer << line; incomplete = false; kdDebug(500) << "COMPLETE LINE READ (" << m_buffer.count() << ")" << endl; } else { if (line.startsWith("smb:") || line.startsWith("rpcclient $")) { kdDebug(500) << "END OF ACTION" << endl; checkActionStatus(); if (m_status) nextAction(); else { // quit program kdDebug(500) << "EXITING PROGRAM..." << endl; m_proc.writeStdin("quit\n", 5); kdDebug(500) << "SENT" << endl; } return; } else { if (incomplete && m_buffer.count() > 0) m_buffer[m_buffer.size()-1].append(line); else m_buffer << line; incomplete = true; kdDebug(500) << "INCOMPLETE LINE READ (" << m_buffer.count() << ")" << endl; } } } }
void BasicTab::slotExecSelected() { TQString path = _execEdit->lineEdit()->text(); if (!path.startsWith("'")) _execEdit->lineEdit()->setText(TDEProcess::quote(path)); }