// check $oldlayouts and $nonlatin groups for XFree 4.3 and later OldLayouts* X11Helper::loadOldLayouts(const TQString& rulesFile) { static const char* oldLayoutsTag = "! $oldlayouts"; static const char* nonLatinLayoutsTag = "! $nonlatin"; TQStringList m_oldLayouts; TQStringList m_nonLatinLayouts; TQFile f(rulesFile); if (f.open(IO_ReadOnly)) { TQTextStream ts(&f); TQString line; while (!ts.eof()) { line = ts.readLine().simplifyWhiteSpace(); if( line.find(oldLayoutsTag) == 0 ) { line = line.mid(strlen(oldLayoutsTag)); line = line.mid(line.find('=')+1).simplifyWhiteSpace(); while( !ts.eof() && line.endsWith("\\") ) line = line.left(line.length()-1) + ts.readLine(); line = line.simplifyWhiteSpace(); m_oldLayouts = TQStringList::split(TQRegExp("\\s"), line); // kdDebug() << "oldlayouts " << m_oldLayouts.join("|") << endl; if( !m_nonLatinLayouts.empty() ) break; } else if( line.find(nonLatinLayoutsTag) == 0 ) { line = line.mid(strlen(nonLatinLayoutsTag)+1).simplifyWhiteSpace(); line = line.mid(line.find('=')+1).simplifyWhiteSpace(); while( !ts.eof() && line.endsWith("\\") ) line = line.left(line.length()-1) + ts.readLine(); line = line.simplifyWhiteSpace(); m_nonLatinLayouts = TQStringList::split(TQRegExp("\\s"), line); // kdDebug() << "nonlatin " << m_nonLatinLayouts.join("|") << endl; if( !m_oldLayouts.empty() ) break; } } f.close(); } OldLayouts* oldLayoutsStruct = new OldLayouts(); oldLayoutsStruct->oldLayouts = m_oldLayouts; oldLayoutsStruct->nonLatinLayouts = m_nonLatinLayouts; return oldLayoutsStruct; }
void TrashImpl::scanTrashDirectories() const { const KMountPoint::List lst = KMountPoint::currentMountPoints(); for ( KMountPoint::List::ConstIterator it = lst.begin() ; it != lst.end() ; ++it ) { const TQCString str = (*it)->mountType().latin1(); // Skip pseudo-filesystems, there's no chance we'll find a .Trash on them :) // ## Maybe we should also skip readonly filesystems if ( str != "proc" && str != "devfs" && str != "usbdevfs" && str != "sysfs" && str != "devpts" && str != "subfs" /* #96259 */ && str != "autofs" /* #101116 */ ) { TQString topdir = (*it)->mountPoint(); TQString trashDir = trashForMountPoint( topdir, false ); if ( !trashDir.isEmpty() ) { // OK, trashDir is a valid trash directory. Ensure it's registered. int trashId = idForTrashDirectory( trashDir ); if ( trashId == -1 ) { // new trash dir found, register it m_trashDirectories.insert( ++m_lastId, trashDir ); kdDebug() << k_funcinfo << "found " << trashDir << " gave it id " << m_lastId << endl; if ( !topdir.endsWith( "/" ) ) topdir += '/'; m_topDirectories.insert( m_lastId, topdir ); } } } } m_trashDirectoriesScanned = true; }
int TrashImpl::findTrashDirectory( const TQString& origPath ) { kdDebug() << k_funcinfo << origPath << endl; // First check if same device as $HOME, then we use the home trash right away. KDE_struct_stat buff; if ( KDE_lstat( TQFile::encodeName( origPath ), &buff ) == 0 && buff.st_dev == m_homeDevice ) return 0; TQString mountPoint = TDEIO::findPathMountPoint( origPath ); const TQString trashDir = trashForMountPoint( mountPoint, true ); kdDebug() << "mountPoint=" << mountPoint << " trashDir=" << trashDir << endl; if ( trashDir.isEmpty() ) return 0; // no trash available on partition int id = idForTrashDirectory( trashDir ); if ( id > -1 ) { kdDebug() << " known with id " << id << endl; return id; } // new trash dir found, register it // but we need stability in the trash IDs, so that restoring or asking // for properties works even tdeio_trash gets killed because idle. #if 0 kdDebug() << k_funcinfo << "found " << trashDir << endl; m_trashDirectories.insert( ++m_lastId, trashDir ); if ( !mountPoint.endsWith( "/" ) ) mountPoint += '/'; m_topDirectories.insert( m_lastId, mountPoint ); return m_lastId; #endif scanTrashDirectories(); return idForTrashDirectory( trashDir ); }
TQStringList KSMServer::windowWmCommand(WId w) { TQStringList ret = getQStringListProperty(w, XA_WM_COMMAND); // hacks here if( ret.count() == 1 ) { TQString command = ret.first(); // Mozilla is launched using wrapper scripts, so it's launched using "mozilla", // but the actual binary is "mozilla-bin" or "<path>/mozilla-bin", and that's what // will be also in WM_COMMAND - using this "mozilla-bin" doesn't work at all though if( command.endsWith( "mozilla-bin" )) return TQStringList() << "mozilla"; if( command.endsWith( "firefox-bin" )) return TQStringList() << "firefox"; if( command.endsWith( "thunderbird-bin" )) return TQStringList() << "thunderbird"; if( command.endsWith( "sunbird-bin" )) return TQStringList() << "sunbird"; } return ret; }
ArchType ArchiveFormatInfo::archTypeByExtension( const TQString & archname ) { InfoList::Iterator it = m_formatInfos.begin(); TQStringList::Iterator ext; for( ; it != m_formatInfos.end(); ++it ) { ext = (*it).extensions.begin(); for( ; ext != (*it).extensions.end(); ++ext ) if( archname.endsWith( (*ext).remove( '*' ) ) ) return (*it).type; } return UNKNOWN_FORMAT; }
/** * Test if a directory exists, create otherwise * @param _name full path of the directory * @return errorcode, or 0 if the dir was created or existed already * Warning, don't use return value like a bool */ int TrashImpl::testDir( const TQString &_name ) const { DIR *dp = opendir( TQFile::encodeName(_name) ); if ( dp == NULL ) { TQString name = _name; if ( name.endsWith( "/" ) ) name.truncate( name.length() - 1 ); TQCString path = TQFile::encodeName(name); bool ok = ::mkdir( path, S_IRWXU ) == 0; if ( !ok && errno == EEXIST ) { #if 0 // this would require to use SlaveBase's method to ask the question //int ret = KMessageBox::warningYesNo( 0, i18n("%1 is a file, but TDE needs it to be a directory. Move it to %2.orig and create directory?").arg(name).arg(name) ); //if ( ret == KMessageBox::Yes ) { #endif if ( ::rename( path, path + ".orig" ) == 0 ) { ok = ::mkdir( path, S_IRWXU ) == 0; } else { // foo.orig existed already. How likely is that? ok = false; } if ( !ok ) { return TDEIO::ERR_DIR_ALREADY_EXIST; } #if 0 //} else { // return 0; //} #endif } if ( !ok ) { //KMessageBox::sorry( 0, i18n( "Couldn't create directory %1. Check for permissions." ).arg( name ) ); kdWarning() << "could not create " << name << endl; return TDEIO::ERR_COULD_NOT_MKDIR; } else { kdDebug() << name << " created." << endl; } } else // exists already { closedir( dp ); } return 0; // success }
TrashImpl::TrashedFileInfoList TrashImpl::list() { // Here we scan for trash directories unconditionally. This allows // noticing plugged-in [e.g. removeable] devices, or new mounts etc. scanTrashDirectories(); TrashedFileInfoList lst; // For each known trash directory... TrashDirMap::const_iterator it = m_trashDirectories.begin(); for ( ; it != m_trashDirectories.end() ; ++it ) { const int trashId = it.key(); TQString infoPath = it.data(); infoPath += "/info"; // Code taken from tdeio_file TQStrList entryNames = listDir( infoPath ); //char path_buffer[PATH_MAX]; //getcwd(path_buffer, PATH_MAX - 1); //if ( chdir( infoPathEnc ) ) // continue; TQStrListIterator entryIt( entryNames ); for (; entryIt.current(); ++entryIt) { TQString fileName = TQFile::decodeName( *entryIt ); if ( fileName == "." || fileName == ".." ) continue; if ( !fileName.endsWith( ".trashinfo" ) ) { kdWarning() << "Invalid info file found in " << infoPath << " : " << fileName << endl; continue; } fileName.truncate( fileName.length() - 10 ); TrashedFileInfo info; if ( infoForFile( trashId, fileName, info ) ) lst << info; } } return lst; }
/** @brief Try to get country code from layout name in xkb before xorg 6.9.0 */ TQString LayoutIcon::getCountryFromLayoutName(const TQString& layoutName) { TQString flag; if( X11Helper::areLayoutsClean() ) { // >= Xorg 6.9.0 if( layoutName == "mkd" ) flag = "mk"; else if( layoutName == "srp" ) { TQString csFlagFile = locate("locale", flagTemplate.arg("cs")); flag = csFlagFile.isEmpty() ? "yu" : "cs"; } else if( layoutName.endsWith("/jp") ) flag = "jp"; else if( layoutName == "trq" || layoutName == "trf" || layoutName == "tralt" ) flag = "tr"; else if( layoutName.length() > 2 ) flag = ""; else flag = layoutName; } else { if( layoutName == "ar" ) // Arabic - not argentina ; else if( layoutName == "sr" || layoutName == "cs") // Serbian language - Yugoslavia flag = "yu"; else if( layoutName == "bs" ) // Bosnian language - Bosnia flag = "ba"; else if( layoutName == "la" ) // Latin America ; else if( layoutName == "lo" ) // Lao flag = "la"; else if( layoutName == "pl2" ) // Poland flag = "pl"; else if( layoutName == "iu" ) // Inuktitut - Canada flag = "ca"; else if( layoutName == "syr" ) // Syriac flag = "sy"; else if( layoutName == "dz" ) // Dzongka/Tibetian - Buthan flag = "bt"; else if( layoutName == "ogham" ) // Ogham - Ireland flag = "ie"; else if( layoutName == "ge_la" || layoutName == "ge_ru" ) flag = "ge"; else if( layoutName == "el" ) flag = "gr"; else if( layoutName.endsWith("/jp") ) flag = "jp"; else if( layoutName == "ml" || layoutName == "dev" || layoutName == "gur" || layoutName == "guj" || layoutName == "kan" || layoutName == "ori" || layoutName == "tel" || layoutName == "tml" || layoutName == "ben" ) // some Indian languages flag = "in"; else { int sepPos = layoutName.find(TQRegExp("[-_]")); TQString leftCode = layoutName.mid(0, sepPos); TQString rightCode; if( sepPos != -1 ) rightCode = layoutName.mid(sepPos+1); // kdDebug() << "layout name breakup: " << leftCode << ":" << rightCode << endl; if( rightCode.length() == 2 && TQRegExp("[A-Z][A-Z]").exactMatch(rightCode) ) { flag = rightCode.lower(); } else { flag = leftCode.length() == 2 ? leftCode : ""; } } } return flag; }
/* --| main |------------------------------------------------------ */ extern "C" int KDE_EXPORT kdemain(int argc, char* argv[]) { setgid(getgid()); setuid(getuid()); // drop privileges // deal with shell/command //////////////////////////// bool histon = true; bool menubaron = true; bool tabbaron = true; bool frameon = true; bool scrollbaron = true; bool showtip = true; TDEAboutData aboutData( "konsole", I18N_NOOP("Konsole"), KONSOLE_VERSION, description, TDEAboutData::License_GPL_V2, "Copyright (c) 2011-2014, The Trinity Desktop project\nCopyright (c) 1997-2006, Lars Doelle"); aboutData.addAuthor( "Timothy Pearson", I18N_NOOP("Maintainer, Trinity bugfixes"), "*****@*****.**" ); aboutData.addAuthor("Robert Knight",I18N_NOOP("Previous Maintainer"), "*****@*****.**"); aboutData.addAuthor("Lars Doelle",I18N_NOOP("Author"), "*****@*****.**"); aboutData.addCredit("Kurt V. Hindenburg", I18N_NOOP("bug fixing and improvements"), "*****@*****.**"); aboutData.addCredit("Waldo Bastian", I18N_NOOP("bug fixing and improvements"), "*****@*****.**"); aboutData.addCredit("Stephan Binner", I18N_NOOP("bug fixing and improvements"), "*****@*****.**"); aboutData.addCredit("Chris Machemer", I18N_NOOP("bug fixing"), "*****@*****.**"); aboutData.addCredit("Stephan Kulow", I18N_NOOP("Solaris support and work on history"), "*****@*****.**"); aboutData.addCredit("Alexander Neundorf", I18N_NOOP("faster startup, bug fixing"), "*****@*****.**"); aboutData.addCredit("Peter Silva", I18N_NOOP("decent marking"), "*****@*****.**"); aboutData.addCredit("Lotzi Boloni", I18N_NOOP("partification\n" "Toolbar and session names"), "*****@*****.**"); aboutData.addCredit("David Faure", I18N_NOOP("partification\n" "overall improvements"), "*****@*****.**"); aboutData.addCredit("Antonio Larrosa", I18N_NOOP("transparency"), "*****@*****.**"); aboutData.addCredit("Matthias Ettrich", I18N_NOOP("most of main.C donated via kvt\n" "overall improvements"), "*****@*****.**"); aboutData.addCredit("Warwick Allison", I18N_NOOP("schema and selection improvements"), "*****@*****.**"); aboutData.addCredit("Dan Pilone", I18N_NOOP("SGI Port"), "*****@*****.**"); aboutData.addCredit("Kevin Street", I18N_NOOP("FreeBSD port"), "*****@*****.**"); aboutData.addCredit("Sven Fischer", I18N_NOOP("bug fixing"), "*****@*****.**"); aboutData.addCredit("Dale M. Flaven", I18N_NOOP("bug fixing"), "*****@*****.**"); aboutData.addCredit("Martin Jones", I18N_NOOP("bug fixing"), "*****@*****.**"); aboutData.addCredit("Lars Knoll", I18N_NOOP("bug fixing"), "*****@*****.**"); aboutData.addCredit("",I18N_NOOP("Thanks to many others.\n" "The above list only reflects the contributors\n" "I managed to keep track of.")); TDECmdLineArgs::init( argc, argv, &aboutData ); TDECmdLineArgs::addCmdLineOptions( options ); // Add our own options. //1.53 sec TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); TDECmdLineArgs *qtargs = TDECmdLineArgs::parsedArgs("qt"); has_noxft = !args->isSet("xft"); TEWidget::setAntialias( !has_noxft ); TEWidget::setStandalone( true ); // The following Qt options have no effect; warn users. if( qtargs->isSet("background") ) kdWarning() << "The Qt option -bg, --background has no effect." << endl; if( qtargs->isSet("foreground") ) kdWarning() << "The Qt option -fg, --foreground has no effect." << endl; if( qtargs->isSet("button") ) kdWarning() << "The Qt option -btn, --button has no effect." << endl; if( qtargs->isSet("font") ) kdWarning() << "The Qt option -fn, --font has no effect." << endl; TDEApplication* a = NULL; #ifdef COMPOSITE a = new TDEApplication(TDEApplication::openX11RGBADisplay()); argb_visual = a->isX11CompositionAvailable(); #else a = new TDEApplication; #endif TQString dataPathBase = TDEStandardDirs::kde_default("data").append("konsole/"); TDEGlobal::dirs()->addResourceType("wallpaper", dataPathBase + "wallpapers"); KImageIO::registerFormats(); // add io for additional image formats //2.1 secs TQString title; if(args->isSet("T")) { title = TQFile::decodeName(args->getOption("T")); } if(qtargs->isSet("title")) { title = TQFile::decodeName(qtargs->getOption("title")); } TQString term = ""; if(args->isSet("tn")) { term=TQString::fromLatin1(args->getOption("tn")); } login_shell = args->isSet("ls"); TQStrList eargs; const char* shell = 0; if (!args->getOption("e").isEmpty()) { if (args->isSet("ls")) TDECmdLineArgs::usage(i18n("You can't use BOTH -ls and -e.\n")); shell = strdup(args->getOption("e")); eargs.append(shell); for(int i=0; i < args->count(); i++) eargs.append( args->arg(i) ); if (title.isEmpty() && (kapp->caption() == kapp->aboutData()->programName())) { title = TQFile::decodeName(shell); // program executed in the title bar } showtip = false; } TQCString sz = ""; sz = args->getOption("vt_sz"); histon = args->isSet("hist"); menubaron = args->isSet("menubar"); tabbaron = args->isSet("tabbar") && args->isSet("toolbar"); frameon = args->isSet("frame"); scrollbaron = args->isSet("scrollbar"); TQCString wname = qtargs->getOption("name"); full_script = args->isSet("script"); auto_close = args->isSet("close"); fixed_size = !args->isSet("resize"); if (!full_script) a->dcopClient()->setQtBridgeEnabled(false); TQCString type = ""; if(args->isSet("type")) { type = args->getOption("type"); } if(args->isSet("types")) { TQStringList types = TDEGlobal::dirs()->findAllResources("appdata", "*.desktop", false, true); types.sort(); for(TQStringList::ConstIterator it = types.begin(); it != types.end(); ++it) { TQString file = *it; file = file.mid(file.findRev('/')+1); if (file.endsWith(".desktop")) file = file.left(file.length()-8); printf("%s\n", TQFile::encodeName(file).data()); } return 0; } if(args->isSet("schemas") || args->isSet("schemata")) { ColorSchemaList colors; colors.checkSchemas(); for(int i = 0; i < (int) colors.count(); i++) { ColorSchema *schema = colors.find(i); TQString relPath = schema->relPath(); if (!relPath.isEmpty()) printf("%s\n", TQFile::encodeName(relPath).data()); } return 0; } if(args->isSet("keytabs")) { TQStringList lst = TDEGlobal::dirs()->findAllResources("data", "konsole/*.keytab"); printf("default\n"); // 'buildin' keytab lst.sort(); for(TQStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { TQFileInfo fi(*it); TQString file = fi.baseName(); printf("%s\n", TQFile::encodeName(file).data()); } return 0; } TQString workDir = TQFile::decodeName( args->getOption("workdir") ); TQString keytab = ""; if (args->isSet("keytab")) keytab = TQFile::decodeName(args->getOption("keytab")); TQString schema = ""; if (args->isSet("schema")) schema = args->getOption("schema"); TDEConfig * sessionconfig = 0; TQString profile = ""; if (args->isSet("profile")) { profile = args->getOption("profile"); TQString path = locate( "data", "konsole/profiles/" + profile ); if ( TQFile::exists( path ) ) sessionconfig=new TDEConfig( path, true ); else profile = ""; } if (args->isSet("profiles")) { TQStringList profiles = TDEGlobal::dirs()->findAllResources("data", "konsole/profiles/*", false, true); profiles.sort(); for(TQStringList::ConstIterator it = profiles.begin(); it != profiles.end(); ++it) { TQString file = *it; file = file.mid(file.findRev('/')+1); printf("%s\n", TQFile::encodeName(file).data()); } return 0; } //FIXME: more: font args->clear(); int c = 0, l = 0; if ( !sz.isEmpty() ) { char *ls = strchr( sz.data(), 'x' ); if ( ls != NULL ) { *ls='\0'; ls++; c=atoi(sz.data()); l=atoi(ls); } else { TDECmdLineArgs::usage(i18n("expected --vt_sz <#columns>x<#lines> e.g. 80x40\n")); } } if (!kapp->authorizeTDEAction("size")) fixed_size = true; // /////////////////////////////////////////////// // Ignore SIGHUP so that we don't get killed when // our parent-shell gets closed. signal(SIGHUP, SIG_IGN); putenv((char*)"COLORTERM="); // to trigger mc's color detection KonsoleSessionManaged ksm; if (a->isRestored() || !profile.isEmpty()) { if (!shell) shell = konsole_shell(eargs); if (profile.isEmpty()) sessionconfig = a->sessionConfig(); sessionconfig->setDesktopGroup(); int n = 1; TQString key; TQString sTitle; TQString sPgm; TQString sTerm; TQString sIcon; TQString sCwd; int n_tabbar; // TODO: Session management stores everything in same group, // should use one group / mainwindow while (TDEMainWindow::canBeRestored(n) || !profile.isEmpty()) { sessionconfig->setGroup(TQString("%1").arg(n)); if (!sessionconfig->hasKey("Pgm0")) sessionconfig->setDesktopGroup(); // Backwards compatible int session_count = sessionconfig->readNumEntry("numSes"); int counter = 0; wname = sessionconfig->readEntry("class",wname).latin1(); sPgm = sessionconfig->readEntry("Pgm0", shell); sessionconfig->readListEntry("Args0", eargs); sTitle = sessionconfig->readEntry("Title0", title); sTerm = sessionconfig->readEntry("Term0"); sIcon = sessionconfig->readEntry("Icon0","konsole"); sCwd = sessionconfig->readPathEntry("Cwd0"); workDir = sessionconfig->readPathEntry("workdir"); n_tabbar = TQMIN(sessionconfig->readUnsignedNumEntry("tabbar",Konsole::TabBottom),2); Konsole *m = new Konsole(wname,histon,menubaron,tabbaron,frameon,scrollbaron,0/*type*/,true,n_tabbar, workDir); m->newSession(sPgm, eargs, sTerm, sIcon, sTitle, sCwd); m->enableFullScripting(full_script); m->enableFixedSize(fixed_size); m->restore(n); sessionconfig->setGroup(TQString("%1").arg(n)); if (!sessionconfig->hasKey("Pgm0")) sessionconfig->setDesktopGroup(); // Backwards compatible m->makeGUI(); m->setEncoding(sessionconfig->readNumEntry("Encoding0")); m->setSchema(sessionconfig->readEntry("Schema0")); // Use konsolerc default as tmpFont instead? TQFont tmpFont = TDEGlobalSettings::fixedFont(); m->initSessionFont(sessionconfig->readFontEntry("SessionFont0", &tmpFont)); m->initSessionKeyTab(sessionconfig->readEntry("KeyTab0")); m->initMonitorActivity(sessionconfig->readBoolEntry("MonitorActivity0",false)); m->initMonitorSilence(sessionconfig->readBoolEntry("MonitorSilence0",false)); m->initMasterMode(sessionconfig->readBoolEntry("MasterMode0",false)); m->initTabColor(sessionconfig->readColorEntry("TabColor0")); // -1 will be changed to the default history in konsolerc m->initHistory(sessionconfig->readNumEntry("History0", -1), sessionconfig->readBoolEntry("HistoryEnabled0", true)); counter++; // show() before 2nd+ sessions are created allows --profile to // initialize the TE size correctly. m->show(); while (counter < session_count) { key = TQString("Title%1").arg(counter); sTitle = sessionconfig->readEntry(key, title); key = TQString("Args%1").arg(counter); sessionconfig->readListEntry(key, eargs); key = TQString("Pgm%1").arg(counter); // if the -e option is passed on the command line, this overrides the program specified // in the profile file if ( args->isSet("e") ) sPgm = (shell ? TQFile::decodeName(shell) : TQString()); else sPgm = sessionconfig->readEntry(key, shell); key = TQString("Term%1").arg(counter); sTerm = sessionconfig->readEntry(key); key = TQString("Icon%1").arg(counter); sIcon = sessionconfig->readEntry(key,"konsole"); key = TQString("Cwd%1").arg(counter); sCwd = sessionconfig->readPathEntry(key); m->newSession(sPgm, eargs, sTerm, sIcon, sTitle, sCwd); m->setSessionTitle(sTitle); // Use title as is key = TQString("Schema%1").arg(counter); m->setSchema(sessionconfig->readEntry(key)); key = TQString("Encoding%1").arg(counter); m->setEncoding(sessionconfig->readNumEntry(key)); key = TQString("SessionFont%1").arg(counter); TQFont tmpFont = TDEGlobalSettings::fixedFont(); m->initSessionFont(sessionconfig->readFontEntry(key, &tmpFont)); key = TQString("KeyTab%1").arg(counter); m->initSessionKeyTab(sessionconfig->readEntry(key)); key = TQString("MonitorActivity%1").arg(counter); m->initMonitorActivity(sessionconfig->readBoolEntry(key,false)); key = TQString("MonitorSilence%1").arg(counter); m->initMonitorSilence(sessionconfig->readBoolEntry(key,false)); key = TQString("MasterMode%1").arg(counter); m->initMasterMode(sessionconfig->readBoolEntry(key,false)); key = TQString("TabColor%1").arg(counter); m->initTabColor(sessionconfig->readColorEntry(key)); // -1 will be changed to the default history in konsolerc key = TQString("History%1").arg(counter); TQString key2 = TQString("HistoryEnabled%1").arg(counter); m->initHistory(sessionconfig->readNumEntry(key, -1), sessionconfig->readBoolEntry(key2, true)); counter++; } m->setDefaultSession( sessionconfig->readEntry("DefaultSession","shell.desktop") ); m->initFullScreen(); if ( !profile.isEmpty() ) { m->callReadPropertiesInternal(sessionconfig,1); profile = ""; // Hack to work-around sessions initialized with minimum size for (int i=0;i<counter;i++) m->activateSession( i ); m->setColLin(c,l); // will use default height and width if called with (0,0) } // works only for the first one, but there won't be more. n++; m->activateSession( sessionconfig->readNumEntry("ActiveSession",0) ); m->setAutoClose(auto_close); } } else { Konsole* m = new Konsole(wname,histon,menubaron,tabbaron,frameon,scrollbaron,type, false, 0, workDir); m->newSession((shell ? TQFile::decodeName(shell) : TQString()), eargs, term, TQString(), title, workDir); m->enableFullScripting(full_script); m->enableFixedSize(fixed_size); //3.8 :-( //exit(0); if (!keytab.isEmpty()) m->initSessionKeyTab(keytab); if (!schema.isEmpty()) { if (schema.right(7)!=".schema") schema+=".schema"; m->setSchema(schema); m->activateSession(0); // Fixes BR83162, transp. schema + notabbar } m->setColLin(c,l); // will use default height and width if called with (0,0) m->initFullScreen(); m->show(); if (showtip) m->showTipOnStart(); m->setAutoClose(auto_close); } int ret = a->exec(); //// Temporary code, waiting for Qt to do this properly // Delete all toplevel widgets that have WDestructiveClose TQWidgetList *list = TQApplication::topLevelWidgets(); // remove all toplevel widgets that have a parent (i.e. they // got WTopLevel explicitly), they'll be deleted by the parent list->first(); while( list->current()) { if( list->current()->parentWidget() != NULL || !list->current()->testWFlags( TQt::WDestructiveClose ) ) { list->remove(); continue; } list->next(); } TQWidgetListIt it(*list); TQWidget * w; while( (w=it.current()) != 0 ) { ++it; delete w; } delete list; delete a; return ret; }
bool TrashImpl::createInfo( const TQString& origPath, int& trashId, TQString& fileId ) { kdDebug() << k_funcinfo << origPath << endl; // Check source const TQCString origPath_c( TQFile::encodeName( origPath ) ); KDE_struct_stat buff_src; if ( KDE_lstat( origPath_c.data(), &buff_src ) == -1 ) { if ( errno == EACCES ) error( TDEIO::ERR_ACCESS_DENIED, origPath ); else error( TDEIO::ERR_DOES_NOT_EXIST, origPath ); return false; } // Choose destination trash trashId = findTrashDirectory( origPath ); if ( trashId < 0 ) { kdWarning() << "OUCH - internal error, TrashImpl::findTrashDirectory returned " << trashId << endl; return false; // ### error() needed? } kdDebug() << k_funcinfo << "trashing to " << trashId << endl; // Grab original filename KURL url; url.setPath( origPath ); const TQString origFileName = url.fileName(); // Make destination file in info/ url.setPath( infoPath( trashId, origFileName ) ); // we first try with origFileName KURL baseDirectory; baseDirectory.setPath( url.directory() ); // Here we need to use O_EXCL to avoid race conditions with other tdeioslave processes int fd = 0; do { kdDebug() << k_funcinfo << "trying to create " << url.path() << endl; fd = ::open( TQFile::encodeName( url.path() ), O_WRONLY | O_CREAT | O_EXCL, 0600 ); if ( fd < 0 ) { if ( errno == EEXIST ) { url.setFileName( TDEIO::RenameDlg::suggestName( baseDirectory, url.fileName() ) ); // and try again on the next iteration } else { error( TDEIO::ERR_COULD_NOT_WRITE, url.path() ); return false; } } } while ( fd < 0 ); const TQString infoPath = url.path(); fileId = url.fileName(); Q_ASSERT( fileId.endsWith( ".trashinfo" ) ); fileId.truncate( fileId.length() - 10 ); // remove .trashinfo from fileId FILE* file = ::fdopen( fd, "w" ); if ( !file ) { // can't see how this would happen error( TDEIO::ERR_COULD_NOT_WRITE, infoPath ); return false; } // Contents of the info file. We could use KSimpleConfig, but that would // mean closing and reopening fd, i.e. opening a race condition... TQCString info = "[Trash Info]\n"; info += "Path="; // Escape filenames according to the way they are encoded on the filesystem // All this to basically get back to the raw 8-bit representation of the filename... if ( trashId == 0 ) // home trash: absolute path info += KURL::encode_string( origPath, m_mibEnum ).latin1(); else info += KURL::encode_string( makeRelativePath( topDirectoryPath( trashId ), origPath ), m_mibEnum ).latin1(); info += "\n"; info += "DeletionDate="; info += TQDateTime::currentDateTime().toString( Qt::ISODate ).latin1(); info += "\n"; size_t sz = info.size() - 1; // avoid trailing 0 from QCString size_t written = ::fwrite(info.data(), 1, sz, file); if ( written != sz ) { ::fclose( file ); TQFile::remove( infoPath ); error( TDEIO::ERR_DISK_FULL, infoPath ); return false; } ::fclose( file ); kdDebug() << k_funcinfo << "info file created in trashId=" << trashId << " : " << fileId << endl; return true; }