src/main.cpp

Go to the documentation of this file.
00001 #include <QApplication>
00002 #include "MainWindow/MainWindow.h"
00003 
00004 int main(int argc, char *argv[]) {
00005 
00006         QFile lockFile( QDir::tempPath()+"/ccln-client.lock" );
00007         if ( lockFile.open( QIODevice::ReadOnly ) ) {
00008                 QTextStream lockStream( &lockFile );
00009                 if ( QDir( "/proc/"+lockStream.readLine() ).exists() ) {
00010                         qWarning("ccln-client: Already running");
00011                         return 0;
00012                 }
00013                 lockFile.close();
00014         }
00015 
00016         if ( lockFile.open( QIODevice::WriteOnly | QIODevice::Truncate ) ) {
00017                 QTextStream lockStream( &lockFile );
00018                 lockStream << getpid() << endl;
00019                 lockFile.close();
00020         }
00021 
00022         QApplication app(argc, argv);
00023         CMainWindow *window = new CMainWindow;
00024 
00025         QCoreApplication::setOrganizationName("QConfigControl");
00026         QCoreApplication::setOrganizationDomain("qconfigcontrol.sourceforge.net");
00027         QCoreApplication::setApplicationName("qconfigcontrol-client");
00028 
00029         /*QFile syslogFile( "/var/log/syslog" );
00030         if ( syslogFile.open( QIODevice::ReadOnly ) ) {*/
00031                 window->show();
00032                 window->loadSettings();
00033                 app.exec();
00034         /*} else {
00035                 QMessageBox::warning(0, "Warning", QString("ccln-client was unable to have read access to one of the following files:\n\n%1\n\nThis happened either because you haven't granted ccln-client root permissions or because these files don't exist (maybe you accidentally deleted them?) ccln-client will now try to automatically start the application with root permissions but it is not guaranteed that it will be successful. If it fails, you should try to manually run it with root permission using one of the following commands:\n\nkdesu " + QCoreApplication::applicationFilePath() + " (if you use KDE)\ngksu " + QCoreApplication::applicationFilePath() + " (if you use GNOME)\nsudo " + QCoreApplication::applicationFilePath() + " (if you use any other Desktop Enviroment).").arg( "/var/log/syslog" ), QMessageBox::Ok );
00036 
00037                 if ( QFile::exists( "/usr/bin/kdesu" ) ) {
00038                         QProcess process;
00039                         process.startDetached( "kdesu", QStringList() << QCoreApplication::applicationFilePath() );
00040                         process.waitForStarted();
00041                 } else {
00042                         QProcess process;
00043                         process.start( "gksu", QStringList() << QCoreApplication::applicationFilePath() );
00044                         process.waitForStarted();
00045                 }
00046         }*/
00047 }

Generated on Fri Feb 29 10:20:46 2008 for QConfigControl by  doxygen 1.5.4