diff --git a/kmail_part.cpp b/kmail_part.cpp index 1acde82dc..534d6ae02 100644 --- a/kmail_part.cpp +++ b/kmail_part.cpp @@ -69,8 +69,6 @@ KMailPart::KMailPart(QWidget *parentWidget, QObject *parent, const QVariantList KMail::insertLibraryCataloguesAndIcons(); - //KMail::lockOrDie(); - //local, do the init KMKernel *mKMailKernel = new KMKernel(); mKMailKernel->init(); @@ -120,7 +118,6 @@ KMailPart::~KMailPart() mainWidget->destruct(); kmkernel->cleanup(); delete kmkernel; - //KMail::cleanup(); // pid file (see kmstartup.cpp) } bool KMailPart::openFile() diff --git a/kmstartup.cpp b/kmstartup.cpp index f4270318d..1d1b060f3 100644 --- a/kmstartup.cpp +++ b/kmstartup.cpp @@ -89,121 +89,6 @@ void checkConfigUpdates() { GlobalSettings::self()->setUpdateLevel( numUpdates ); } -#if 0 -void lockOrDie() { -// Check and create a lock file to prevent concurrent access to kmail files - QString appName = KGlobal::mainComponent().componentName(); - if ( appName.isEmpty() ) - appName = "kmail2"; - - QString programName; - const KAboutData *about = KGlobal::mainComponent().aboutData(); - if ( about ) - programName = about->programName(); - if ( programName.isEmpty() ) - programName = i18n("KMail"); - - QString lockLocation = KStandardDirs::locateLocal("data", "kmail2/lock"); - KConfig config(lockLocation, KConfig::SimpleConfig); - KConfigGroup group(&config, ""); - int oldPid = group.readEntry("pid", -1 ); - kDebug() << "oldPid=" << oldPid; - const QString oldHostName = group.readEntry("hostname"); - const QString oldAppName = group.readEntry( "appName", appName ); - const QString oldProgramName = group.readEntry( "programName", programName ); - const QString hostName = QHostInfo::localHostName(); - bool first_instance = false; - if ( oldPid == -1 ) { - first_instance = true; - } else if ( hostName == oldHostName && oldPid != getpid() ) { - // check if the lock file is stale -#ifdef Q_OS_LINUX //krazy:exclude=cpp - if ( ::access("/proc", X_OK ) == 0 ) { - // On linux with /proc we can even check that - // it's really kmail and not something else - char path_buffer[MAXPATHLEN + 1]; - path_buffer[MAXPATHLEN] = 0; - const QString procPath = QString( "/proc/%1/exe" ).arg( oldPid ); - const int length = - readlink( procPath.toLatin1(), path_buffer, MAXPATHLEN ); - if ( length == -1 ) { // no such pid - first_instance = true; - } else { - path_buffer[length] = '\0'; - const QString path = QFile::decodeName( path_buffer ); - kDebug() << path; - const int pos = path.lastIndexOf( '/' ); - const QString fileName = path.mid( pos + 1 ); - kDebug() << "Found process" << oldPid - << "running. It's:" << fileName; - first_instance = fileName != "kmail" && fileName != "kontact"; - } - } else -#endif - { - // Otherwise we just check if the other pid is currently running. - // Not 100% correct but better safe than sorry. - if ( kill(oldPid, 0) == -1 ) - first_instance = ( errno == ESRCH ); - } - } - - if ( !first_instance ) { - QString msg; - if ( oldHostName == hostName ) { - // this can only happen if the user is running this application on - // different displays on the same machine. All other cases will be - // taken care of by KUniqueApplication() - if ( oldAppName == appName ) - msg = i18n("%1 already seems to be running on another display on " - "this machine. Running %2 more than once " - "can cause the loss of mail. You should not start %1 " - "unless you are sure that it is not already running.", - programName, programName ); - // QString::arg( st ) only replaces the first occurrence of %1 - // with st while QString::arg( s1, s2 ) replacess all occurrences - // of %1 with s1 and all occurrences of %2 with s2. So don't - // even think about changing the above to .arg( programName ). - else - msg = i18n("%1 seems to be running on another display on this " - "machine. Running %1 and %2 at the same " - "time can cause the loss of mail. You should not start %2 " - "unless you are sure that %1 is not running.", - oldProgramName, programName ); - } - else { - if ( oldAppName == appName ) - msg = i18n("%1 already seems to be running on %2. Running %1 more " - "than once can cause the loss of mail. You should not " - "start %1 on this computer unless you are sure that it is " - "not already running on %2.", - programName, oldHostName ); - else - msg = i18n("%1 seems to be running on %3. Running %1 and %2 at the " - "same time can cause the loss of mail. You should not " - "start %2 on this computer unless you are sure that %1 is " - "not running on %3.", - oldProgramName, programName, oldHostName ); - } - - MessageViewer::KCursorSaver idle( MessageViewer::KBusyPtr::idle() ); - if ( KMessageBox::No == - KMessageBox::warningYesNo( 0, msg, QString(), - KGuiItem(i18nc("Start kmail even when another instance is running.", "Start %1", programName )), - KGuiItem(i18nc("Do not start another kmail instance.","Exit")) ) ) { - exit(1); - } - } - - qlonglong pid = static_cast( getpid() ); - group.writeEntry( "pid", pid ); - group.writeEntry( "hostname", hostName ); - group.writeEntry( "appName", appName ); - group.writeEntry( "programName", programName ); - group.sync(); -} -#endif - void insertLibraryCataloguesAndIcons() { static const char * const catalogs[] = { "libkdepim", @@ -238,14 +123,4 @@ void insertLibraryCataloguesAndIcons() { } -#if 0 -void cleanup() -{ - const QString lockLocation = KStandardDirs::locateLocal("data", "kmail2/lock"); - KConfig config(lockLocation, KConfig::SimpleConfig); - KConfigGroup group(&config, ""); - group.writeEntry("pid", -1); - group.sync(); -} -#endif } diff --git a/kmstartup.h b/kmstartup.h index e758898a6..aa80ed077 100644 --- a/kmstartup.h +++ b/kmstartup.h @@ -28,9 +28,7 @@ extern "C" { namespace KMail { KMAIL_EXPORT void checkConfigUpdates(); - //KMAIL_EXPORT void lockOrDie(); KMAIL_EXPORT void insertLibraryCataloguesAndIcons(); - //KMAIL_EXPORT void cleanup(); } #endif diff --git a/main.cpp b/main.cpp index 65b51e0f8..3c61fb3e2 100644 --- a/main.cpp +++ b/main.cpp @@ -125,8 +125,6 @@ int main(int argc, char *argv[]) // import i18n data and icons from libraries: KMail::insertLibraryCataloguesAndIcons(); - //KMail::lockOrDie(); - //local, do the init KMKernel kmailKernel; kmailKernel.init(); @@ -148,6 +146,5 @@ int main(int argc, char *argv[]) int ret = qApp->exec(); // clean up kmailKernel.cleanup(); - //KMail::cleanup(); // pid file (see kmstartup.cpp) return ret; }