Ejemplo n.º 1
0
int main(int argc, char **argv)
{
    QCoreApplication app(argc, argv);

    int logOption = LOG_NDELAY;

#ifdef QT_DEBUG
    if (app.arguments().contains(QLatin1String("-log-console")))
        logOption |= LOG_PERROR;
#endif

    openlog("COMMHISTORYD", logOption, 0);

    qInstallMessageHandler(messageHandler);

    DEBUG() << "MApplication created";

    if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sigtermFd))
       qFatal("Couldn't create TERM socketpair");

    QSocketNotifier *snTerm = new QSocketNotifier(sigtermFd[1], QSocketNotifier::Read, &app);
    QObject::connect(snTerm, SIGNAL(activated(int)), &app, SLOT(quit()));
    setupSigtermHandler();

    ML10N::MLocale locale;
    locale.addTranslationPath("/usr/share/translations/");
    locale.installTrCatalog("messaging");
    locale.installTrCatalog("telephony");
    locale.installTrCatalog("mms");
    locale.installTrCatalog("presence");
    locale.installTrCatalog("recipientedit");
    locale.installTrCatalog("commhistoryd");
    ML10N::MLocale::setDefault(locale);

    DEBUG() << "Translation catalogs loaded";

    CommHistoryService *chService = CommHistoryService::instance();
    if (!chService->isRegistered()) {
        qCritical() << "CommHistoryService registration failed (already running or DBus not found), exiting";
        _exit(1);
    }
    new CommHistoryIfAdaptor(chService);
    DEBUG() << "CommHistoryService created";

    ConnectionUtils *utils = new ConnectionUtils(&app);

    new ContactAuthorizationListener(utils, chService);

    AccountPresenceService *apService = new AccountPresenceService(utils->accountManager(), &app);
    if (!apService->isRegistered()) {
        qCritical() << "AccountPresenceService registration failed (already running or DBus not found), exiting";
        _exit(1);
    }
    new AccountPresenceIfAdaptor(apService);
    DEBUG() << "AccountPresenceService created";

    MessageReviver *reviver = new MessageReviver(utils, &app);
    DEBUG() << "Message reviver created, starting main loop";

    new Logger(utils->accountManager(),
               reviver,
               &app);
    DEBUG() << "Logger created";

    NotificationManager::instance();
    DEBUG() << "NotificationManager created";


    VoiceMailHandler::instance();
    DEBUG() << "VoiceMailHandler created";

    // Init account operations observer to monitor account removals and to react to them.
    new AccountOperationsObserver(utils->accountManager(), &app);

    int result = app.exec();

    close(sigtermFd[0]);
    close(sigtermFd[1]);

    DEBUG() << "exit";

    return result;
}
Ejemplo n.º 2
0
Q_DECL_EXPORT int main(int argc, char **argv)
{
    QCoreApplication app(argc, argv);

    if (argc > 1) {
        if (strcmp(argv[1],"-d") == 0) {
            toggleDebug = true;
        }
    }

    int logOption = LOG_NDELAY;

#ifdef QT_DEBUG
    if (app.arguments().contains(QLatin1String("-log-console")))
        logOption |= LOG_PERROR;
#endif

    openlog("COMMHISTORYD", logOption, 0);

    qInstallMessageHandler(messageHandler);

    DEBUG() << "MApplication created";

    if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sigtermFd))
       qFatal("Couldn't create TERM socketpair");

    QSocketNotifier *snTerm = new QSocketNotifier(sigtermFd[1], QSocketNotifier::Read, &app);
    QObject::connect(snTerm, SIGNAL(activated(int)), &app, SLOT(quit()));
    setupSigtermHandler();

    QScopedPointer<QTranslator> engineeringEnglish(new QTranslator);
    engineeringEnglish->load("commhistoryd_eng_en", "/usr/share/translations");
    QScopedPointer<QTranslator> translator(new QTranslator);
    translator->load(QLocale(), "commhistoryd", "-", "/usr/share/translations");

    app.installTranslator(engineeringEnglish.data());
    app.installTranslator(translator.data());

    CommHistoryService *chService = CommHistoryService::instance();
    if (!chService->isRegistered()) {
        qCritical() << "CommHistoryService registration failed (already running or DBus not found), exiting";
        _exit(1);
    }
    new CommHistoryIfAdaptor(chService);
    DEBUG() << "CommHistoryService created";

    ConnectionUtils *utils = new ConnectionUtils(&app);

    // ContactAuthorizationListener needs to be updated with nemo-notifications and new UI handling
    //new ContactAuthorizationListener(utils, chService);

    AccountPresenceService *apService = new AccountPresenceService(utils->accountManager(), &app);
    if (!apService->isRegistered()) {
        qCritical() << "AccountPresenceService registration failed (already running or DBus not found), exiting";
        _exit(1);
    }
    new AccountPresenceIfAdaptor(apService);
    DEBUG() << "AccountPresenceService created";

    MessageReviver *reviver = new MessageReviver(utils, &app);
    DEBUG() << "Message reviver created, starting main loop";

    if (toggleDebug) {
        Tp::enableDebug(true);
        Tp::enableWarnings(true);
    }
    new Logger(utils->accountManager(),
               reviver,
               &app);
    DEBUG() << "Logger created";

    NotificationManager::instance();
    DEBUG() << "NotificationManager created";

    new LastDialedCache(&app);
    DEBUG() << "LastDialedCache created";

    // Init account operations observer to monitor account removals and to react to them.
    new AccountOperationsObserver(utils->accountManager(), &app);

    new MmsHandlerAdaptor(new MmsHandler(&app));
    new SmartMessagingAgentAdaptor(new SmartMessaging(&app));
    new FsCleanup(&app);

    int result = app.exec();

    close(sigtermFd[0]);
    close(sigtermFd[1]);

    DEBUG() << "exit";

    return result;
}