• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

NepomukDaemons

main.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE Project
00002    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016    Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #include "nepomukserver.h"
00020 #include "nepomukserver_export.h"
00021 
00022 #include <kuniqueapplication.h>
00023 #include <kapplication.h>
00024 #include <kcmdlineargs.h>
00025 #include <kaboutdata.h>
00026 #include <klocale.h>
00027 #include <kglobal.h>
00028 #include <kconfig.h>
00029 #include <kconfiggroup.h>
00030 #include <kdebug.h>
00031 
00032 #include <signal.h>
00033 
00034 namespace {
00035 #ifndef Q_OS_WIN
00036     void signalHandler( int signal )
00037     {
00038         switch( signal ) {
00039         case SIGHUP:
00040         case SIGQUIT:
00041         case SIGTERM:
00042         case SIGINT:
00043             if ( qApp ) {
00044                 qApp->quit();
00045             }
00046         }
00047     }
00048 #endif
00049 
00050     void installSignalHandler() {
00051 #ifndef Q_OS_WIN
00052         struct sigaction sa;
00053         ::memset( &sa, 0, sizeof( sa ) );
00054         sa.sa_handler = signalHandler;
00055         sigaction( SIGHUP, &sa, 0 );
00056         sigaction( SIGINT, &sa, 0 );
00057         sigaction( SIGQUIT, &sa, 0 );
00058         sigaction( SIGTERM, &sa, 0 );
00059 #endif
00060     }
00061 }
00062 
00063 
00064 namespace Nepomuk {
00065     class ServerApplication : public KUniqueApplication
00066     {
00067     public:
00068         ServerApplication()
00069             : KUniqueApplication(),
00070               m_server( 0 ) {
00071         }
00072 
00073         int newInstance() {
00074             if ( !m_server ) {
00075                 m_server = new Server( this );
00076             }
00077             return 0;
00078         }
00079 
00080     private:
00081         Server* m_server;
00082     };
00083 }
00084 
00085 
00086 extern "C" NEPOMUK_SERVER_EXPORT int kdemain( int argc, char** argv )
00087 {
00088     KAboutData aboutData( "NepomukServer", "nepomuk",
00089                           ki18n("Nepomuk Server"),
00090                           "0.2",
00091                           ki18n("Nepomuk Server - Manages Nepomuk storage and services"),
00092                           KAboutData::License_GPL,
00093                           ki18n("(c) 2008, Sebastian Trüg"),
00094                           KLocalizedString(),
00095                           "http://nepomuk.kde.org" );
00096     aboutData.addAuthor(ki18n("Sebastian Trüg"),ki18n("Maintainer"), "trueg@kde.org");
00097 
00098     KCmdLineArgs::init( argc, argv, &aboutData );
00099 
00100     KUniqueApplication::addCmdLineOptions();
00101 
00102     KComponentData componentData( &aboutData );
00103 
00104     if ( !KUniqueApplication::start() ) {
00105         fprintf( stderr, "Nepomuk server already running.\n" );
00106         return 0;
00107     }
00108 
00109     installSignalHandler();
00110 
00111     Nepomuk::ServerApplication app;
00112     app.setQuitOnLastWindowClosed( false );
00113     return app.exec();
00114 }

NepomukDaemons

Skip menu "NepomukDaemons"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • KCMShell
  • KNotify
  • KStyles
  • Nepomuk Daemons
Generated for API Reference by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal