Esempio n. 1
0
DaemonManager::DaemonManager()
    : ccnet_daemon_(0),
    seaf_daemon_(0),
    sync_client_(0)
{
    conn_daemon_timer_ = new QTimer(this);
    connect(conn_daemon_timer_, SIGNAL(timeout()), this, SLOT(tryConnCcnet()));
    shutdown_process (kCcnetDaemonExecutable);

    system_shut_down_ = false;
    connect(qApp, SIGNAL(aboutToQuit()),
            this, SLOT(systemShutDown()));
}
Esempio n. 2
0
void nrf_pwr_mgmt_shutdown(nrf_pwr_mgmt_shutdown_t shutdown_type)
{
    if (shutdown_type != NRF_PWR_MGMT_SHUTDOWN_CONTINUE)
    {
        // Check if shutdown procedure is not started.
        if (!nrf_pwr_mgmt_guard_lock())
        {
            return;
        }
        m_pwr_mgmt_evt = (nrf_pwr_mgmt_evt_t)shutdown_type;
    }
    ASSERT(m_sysoff_guard);
    NRF_LOG_INFO("Shutdown request %d\r\n", shutdown_type);

#if NRF_PWR_MGMT_CONFIG_USE_SCHEDULER
    ret_code_t ret_code = app_sched_event_put(NULL, 0, scheduler_shutdown_handler);
    APP_ERROR_CHECK(ret_code);
#else
    shutdown_process();
#endif // NRF_PWR_MGMT_CONFIG_USE_SCHEDULER
}
Esempio n. 3
0
/**@brief Handle events from app_scheduler.
 */
static void scheduler_shutdown_handler(void * p_event_data, uint16_t event_size)
{
    UNUSED_PARAMETER(p_event_data);
    UNUSED_PARAMETER(event_size);
    shutdown_process();
}
Esempio n. 4
0
int main(int argc, char *argv[])
{
    int ret = 0;

    // call glib's init functions
    initGlib();

    // initialize breakpad if enabled
    initBreakpad();

    // Apply hidpi support
    setupHIDPIFix();

    // TODO imple if we have to restart the application
    // the manual at http://qt-project.org/wiki/ApplicationRestart
#if defined(Q_OS_MAC)
    Application app(argc, argv);
#else
    QApplication app(argc, argv);
#endif
#if defined(Q_OS_WIN32)
    // change the current directory
    QDir::setCurrent(QApplication::applicationDirPath());
#endif

    // don't quit even if the last windows is closed
    app.setQuitOnLastWindowClosed(false);

    // apply some ui fixes for mac
    setupFontFix();

    // set the domains of settings
    setupSettingDomain();

    // initialize i18n settings
    I18NHelper::getInstance()->init();

    // initialize style settings
    app.setStyle(new SeafileProxyStyle());

    // handle with the command arguments
    handleCommandLineOption(argc, argv);

    // count if we have any instance running now. if more than one, exit
    if (count_process(APPNAME) > 1) {
        // have we activated it ? exit
        if (SharedApplication::activate())
            return 0;
        if (QMessageBox::No == QMessageBox::warning(NULL, getBrand(),
                QObject::tr("Found another running process of %1, kill it and start a new one?").arg(getBrand()),
                QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)) {
            return -1;
        }

        // sleep 9 * 100ms to await the os completing the operation
        do_stop();
        int n = 10;
        while(--n >0 && count_process(APPNAME) > 1)
            msleep(100);

        // force shutdown it
        if (count_process(APPNAME) > 1) {
            shutdown_process(APPNAME);
            msleep(100);
        }

        // count if we still have any instance running now. if more than one, exit
        if (count_process(APPNAME) > 1) {
            QMessageBox::critical(NULL, getBrand(),
                QObject::tr("Unable to start %1 due to the failure of shutting down the previous process").arg(getBrand()),
                QMessageBox::Ok);
            return -1;
        }
    }

    // init qtawesome component
    awesome = new QtAwesome(qApp);
    awesome->initFontAwesome();

    // start applet
    SeafileApplet mApplet;
    seafApplet = &mApplet;
    seafApplet->start();

    // start qt eventloop
    ret = app.exec();

    return ret;
}