~ubuntu-branches/ubuntu/saucy/kactivities/saucy-proposed

« back to all changes in this revision

Viewing changes to service/main.cpp

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman, Jonathan Riddell, Scott Kitterman
  • Date: 2012-11-20 13:47:27 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20121120134727-vqzk04slqjoay3de
Tags: 4:4.9.80-0ubuntu1
[ Jonathan Riddell ]
* New upstream beta release

[ Scott Kitterman ]
* Add new libkactivities-models1 library package (debian/control, .install,
  and .symbols)
* Add nepomuk-core-dev to build-depends
* Wildcard libkactivities6.install so that soversion changes don't cause
  build failures
* Update libkactivities6.symbols
* Update libkactivities-dev.install for new files for libkactivies-models
* Add new files to libkactivities-bin.install, including Activities kcm

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *   Copyright (C) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
3
 
 *
4
 
 *   This program is free software; you can redistribute it and/or modify
5
 
 *   it under the terms of the GNU General Public License version 2,
6
 
 *   or (at your option) any later version, as published by the Free
7
 
 *   Software Foundation
8
 
 *
9
 
 *   This program is distributed in the hope that it will be useful,
10
 
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 *   GNU General Public License for more details
13
 
 *
14
 
 *   You should have received a copy of the GNU General Public
15
 
 *   License along with this program; if not, write to the
16
 
 *   Free Software Foundation, Inc.,
17
 
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18
 
 */
19
 
 
20
 
#include <ActivityManager.h>
21
 
 
22
 
#include <QDebug>
23
 
#include <KCrash>
24
 
 
25
 
#include <KAboutData>
26
 
#include <KCmdLineArgs>
27
 
 
28
 
#include <signal.h>
29
 
#include <stdlib.h>
30
 
 
31
 
#include "jobs/encryption/Common.h"
32
 
 
33
 
static void initSignalCatching();
34
 
 
35
 
int main(int argc, char ** argv)
36
 
{
37
 
    KAboutData about("kactivitymanagerd", 0, ki18n("KDE Activity Manager"), "2.0",
38
 
            ki18n("KDE Activity Management Service"),
39
 
            KAboutData::License_GPL,
40
 
            ki18n("(c) 2010, 2011, 2012 Ivan Cukic, Sebastian Trueg"), KLocalizedString(),
41
 
            "http://www.kde.org/");
42
 
 
43
 
    KCmdLineArgs::init(argc, argv, &about);
44
 
 
45
 
    ActivityManager application;
46
 
 
47
 
    initSignalCatching();
48
 
 
49
 
    return application.exec();
50
 
}
51
 
 
52
 
// Signal handling
53
 
static void signalHandler(int sig)
54
 
{
55
 
    Jobs::Encryption::Common::unmountAll();
56
 
 
57
 
    // something (probably ksmserver) has asked us to terminate.
58
 
    // If it is really ksmserver then the user is probably logging out, so we
59
 
    // had better gently stop now than be killed.
60
 
    if (sig == SIGTERM) {
61
 
        //qDebug() << "signalHandler(SIGTERM): stopping ActivityManager\n";
62
 
 
63
 
        ActivityManager::self()->Stop();
64
 
    }
65
 
 
66
 
    // If we have crashed, then restart
67
 
    if (sig == SIGSEGV) {
68
 
        qDebug() << "Calling the crash handler...";
69
 
        KCrash::defaultCrashHandler(SIGSEGV);
70
 
    }
71
 
 
72
 
    ::exit(EXIT_SUCCESS);
73
 
}
74
 
 
75
 
static void initSignalCatching() {
76
 
#ifndef Q_OS_WIN32 // krazy:skip
77
 
    struct sigaction action;
78
 
 
79
 
    ::sigemptyset(&action.sa_mask);
80
 
    action.sa_flags = 0;
81
 
 
82
 
    /* Use the sa_sigaction field because the handles has two additional parameters */
83
 
    action.sa_handler = signalHandler;
84
 
 
85
 
    ::sigaction(SIGINT,  &action, NULL);
86
 
    ::sigaction(SIGHUP,  &action, NULL);
87
 
    ::sigaction(SIGTERM, &action, NULL);
88
 
    ::sigaction(SIGSEGV, &action, NULL);
89
 
#endif
90
 
}