alarmapp.cpp
00001 /* 00002 This file is part of the KDE alarm daemon. 00003 Copyright (c) 1997-1999 Preston Brown 00004 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 00005 Copyright (c) 2001 David Jarvie <software@astrojar.org.uk> 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software 00019 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00020 00021 As a special exception, permission is given to link this program 00022 with any edition of Qt, and distribute the resulting executable, 00023 without including the source code for Qt in the source distribution. 00024 */ 00025 00026 // $Id$ 00027 00028 #include <qstring.h> 00029 00030 #include <kcmdlineargs.h> 00031 #include <kdebug.h> 00032 #include <kstartupinfo.h> 00033 00034 #include "alarmdaemon.h" 00035 00036 #include "alarmapp.h" 00037 #include "alarmapp.moc" 00038 00039 00040 AlarmApp::AlarmApp() : 00041 KUniqueApplication(false,false), 00042 mAd(0L) 00043 { 00044 disableSessionManagement(); 00045 } 00046 00047 AlarmApp::~AlarmApp() 00048 { 00049 } 00050 00051 int AlarmApp::newInstance() 00052 { 00053 kdDebug(5900) << "kalarmd:AlarmApp::newInstance()" << endl; 00054 00055 //KStartupInfo::appStarted(); 00056 00057 /* Prevent the application being restored automatically by the session manager 00058 * at session startup. Instead, the KDE autostart facility is used to start 00059 * the application. This allows the user to configure whether or not it is to 00060 * be started automatically, and also ensures that it is started in the correct 00061 * phase of session startup, i.e. after clients have been restored by the 00062 * session manager. 00063 */ 00064 disableSessionManagement(); 00065 00066 // Check if we already have a running alarm daemon widget 00067 if (mAd) return 0; 00068 00069 // Check if we are starting up at session startup 00070 static bool restored = false; 00071 if (!restored && isRestored()) { 00072 mStartedAtLogin = true; 00073 restored = true; // make sure we restore only once 00074 } 00075 else { 00076 KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); 00077 mStartedAtLogin = args->isSet("login"); 00078 args->clear(); // free up memory 00079 } 00080 00081 mAd = new AlarmDaemon(0L, "ad"); 00082 00083 return 0; 00084 }