• Skip to content
  • Skip to link menu
KDE 4.1 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 SIGINT:
00042             if ( qApp ) {
00043                 qApp->quit();
00044             }
00045         }
00046     }
00047 #endif
00048 
00049     void installSignalHandler() {
00050 #ifndef Q_OS_WIN
00051         struct sigaction sa;
00052         ::memset( &sa, 0, sizeof( sa ) );
00053         sa.sa_handler = signalHandler;
00054         sigaction( SIGHUP, &sa, 0 );
00055         sigaction( SIGINT, &sa, 0 );
00056         sigaction( SIGQUIT, &sa, 0 );
00057 #endif
00058     }
00059 }
00060 
00061 
00062 namespace Nepomuk {
00063     class ServerApplication : public KUniqueApplication
00064     {
00065     public:
00066         ServerApplication()
00067             : KUniqueApplication(),
00068               m_server( 0 ) {
00069         }
00070 
00071         int newInstance() {
00072             if ( !m_server ) {
00073                 m_server = new Server( this );
00074             }
00075             return 0;
00076         }
00077 
00078     private:
00079         Server* m_server;
00080     };
00081 }
00082 
00083 
00084 extern "C" NEPOMUK_SERVER_EXPORT int kdemain( int argc, char** argv )
00085 {
00086     KAboutData aboutData( "NepomukServer", "nepomuk",
00087                           ki18n("Nepomuk Server"),
00088                           "0.2",
00089                           ki18n("Nepomuk Server - Manages Nepomuk storage and services"),
00090                           KAboutData::License_GPL,
00091                           ki18n("(c) 2008, Sebastian Trüg"),
00092                           KLocalizedString(),
00093                           "http://nepomuk.kde.org" );
00094     aboutData.addAuthor(ki18n("Sebastian Trüg"),ki18n("Maintainer"), "trueg@kde.org");
00095 
00096     KCmdLineArgs::init( argc, argv, &aboutData );
00097 
00098     KUniqueApplication::addCmdLineOptions();
00099 
00100     KComponentData componentData( &aboutData );
00101 
00102     if ( !KUniqueApplication::start() ) {
00103         fprintf( stderr, "Nepomuk server already running.\n" );
00104         return 0;
00105     }
00106 
00107     installSignalHandler();
00108 
00109     Nepomuk::ServerApplication app;
00110     app.setQuitOnLastWindowClosed( false );
00111     return app.exec();
00112 }

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.4
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