예제 #1
0
/**
 * For each repo, add the "server-url" property (inferred from account url),
 * which would be used for http sync.
 */
void SeafileApplet::updateReposPropertyForHttpSync()
{
    std::vector<LocalRepo> repos;
    if (rpc_client_->listLocalRepos(&repos) < 0) {
        QTimer::singleShot(kIntervalForUpdateRepoProperty,
                           this, SLOT(updateReposPropertyForHttpSync()));
        return;
    }

    const std::vector<Account>& accounts = account_mgr_->accounts();
    for (int i = 0; i < repos.size(); i++) {
        const LocalRepo& repo = repos[i];
        QString repo_server_url;
        QString relay_addr;
        if (rpc_client_->getRepoProperty(repo.id, kRepoServerUrlProperty, &repo_server_url) < 0) {
            continue;
        }
        if (!repo_server_url.isEmpty()) {
            continue;
        }
        if (rpc_client_->getRepoProperty(repo.id, kRepoRelayAddrProperty, &relay_addr) < 0) {
            continue;
        }
        for (int i = 0; i < accounts.size(); i++) {
            const Account& account = accounts[i];
            if (account.serverUrl.host() == relay_addr) {
                QUrl url(account.serverUrl);
                url.setPath("/");
                rpc_client_->setRepoProperty(repo.id, kRepoServerUrlProperty, url.toString());
                break;
            }
        }
    }
}
예제 #2
0
void SeafileApplet::onDaemonStarted()
{
    main_win_ = new MainWindow;

    rpc_client_->connectDaemon();
    message_listener_->connectDaemon();

    // load proxy settings
    seafApplet->settingsManager()->loadSettings();

    FileCacheDB::instance()->start();
    AutoUpdateManager::instance()->start();

    AvatarService::instance()->start();
    SeahubNotificationsMonitor::instance()->start();
    ServerStatusService::instance()->start();

    account_mgr_->updateServerInfo();

#if defined(Q_OS_MAC)
    seafApplet->settingsManager()->setHideDockIcon(seafApplet->settingsManager()->hideDockIcon());
#endif

    if (configurator_->firstUse() || account_mgr_->accounts().size() == 0) {
        LoginDialog login_dialog;
        login_dialog.exec();
    }

    started_ = true;

    if (configurator_->firstUse() || !settings_mgr_->hideMainWindowWhenStarted()) {
        main_win_->showWindow();
    }

    tray_icon_->start();
    tray_icon_->setState(SeafileTrayIcon::STATE_DAEMON_UP);

#if defined(Q_OS_WIN32)
    QTimer::singleShot(kIntervalBeforeShowInitVirtualDialog, this, SLOT(checkInitVDrive()));
    configurator_->installCustomUrlHandler();
#endif

    if (settings_mgr_->isCheckLatestVersionEnabled()) {
        checkLatestVersionInfo();
    }

    OpenLocalHelper::instance()->checkPendingOpenLocalRequest();

    QTimer::singleShot(kIntervalForUpdateRepoProperty,
                       this, SLOT(updateReposPropertyForHttpSync()));

#if defined(Q_OS_WIN32)
    SeafileExtensionHandler::instance()->start();
#elif defined(HAVE_FINDER_SYNC_SUPPORT)
    finderSyncListenerStart();
#endif
}
예제 #3
0
void SeafileApplet::onDaemonStarted()
{
    main_win_ = new MainWindow;

    rpc_client_->connectDaemon();
    message_listener_->connectDaemon();
    seafApplet->settingsManager()->loadSettings();

#if defined(Q_WS_MAC)
    seafApplet->settingsManager()->setHideDockIcon(seafApplet->settingsManager()->hideDockIcon());
#endif

    if (configurator_->firstUse() || account_mgr_->accounts().size() == 0) {
        LoginDialog login_dialog;
        login_dialog.exec();
    }

    started_ = true;

    if (configurator_->firstUse() || !settings_mgr_->hideMainWindowWhenStarted()) {
        main_win_->showWindow();
    }

    tray_icon_->start();
    tray_icon_->setState(SeafileTrayIcon::STATE_DAEMON_UP);

#if defined(Q_WS_WIN)
    QTimer::singleShot(kIntervalBeforeShowInitVirtualDialog, this, SLOT(checkInitVDrive()));
    configurator_->installCustomUrlHandler();
#endif

    if (settings_mgr_->isCheckLatestVersionEnabled()) {
        checkLatestVersionInfo();
    }

    OpenLocalHelper::instance()->checkPendingOpenLocalRequest();

    QTimer::singleShot(kIntervalForUpdateRepoProperty,
                       this, SLOT(updateReposPropertyForHttpSync()));
}
예제 #4
0
void SeafileApplet::onDaemonStarted()
{
    //
    // start daemon-related services
    //
    rpc_client_->connectDaemon();
    message_listener_->connectDaemon();

    // Sleep 500 millseconds to wait seafile registering services

    msleep(500);

    //
    // load proxy settings (important)
    //
    seafApplet->settingsManager()->loadSettings();

    //
    // start network-related services
    //
    FileCacheDB::instance()->start();
    AutoUpdateManager::instance()->start();

    AvatarService::instance()->start();

    SeahubNotificationsMonitor::instance()->start();
    ServerStatusService::instance()->start();

    account_mgr_->updateServerInfo();

    //
    // start ui part
    //
    main_win_ = new MainWindow;

#if defined(Q_OS_MAC)
    seafApplet->settingsManager()->setHideDockIcon(seafApplet->settingsManager()->hideDockIcon());
#endif

    if (configurator_->firstUse() || account_mgr_->accounts().size() == 0) {
        do {
            QString username = readPreconfigureExpandedString(kPreconfigureUsername);
            QString token = readPreconfigureExpandedString(kPreconfigureUserToken);
            QString url = readPreconfigureExpandedString(kPreconfigureServerAddr);
            QString computer_name = readPreconfigureExpandedString(kPreconfigureComputerName, settingsManager()->getComputerName());
            if (!computer_name.isEmpty())
                settingsManager()->setComputerName(computer_name);
            if (!username.isEmpty() && !token.isEmpty() && !url.isEmpty()) {
                Account account(url, username, token);
                if (account_mgr_->saveAccount(account) < 0) {
                    warningBox(tr("failed to add default account"));
                    exit(1);
                }
                break;
            }

            if (readPreconfigureEntry(kHideConfigurationWizard).toInt())
                break;
            LoginDialog login_dialog;
            login_dialog.exec();
        } while (0);
    }

    started_ = true;

    if (configurator_->firstUse() || !settings_mgr_->hideMainWindowWhenStarted()) {
        main_win_->showWindow();
    }

    tray_icon_->start();
    tray_icon_->setState(SeafileTrayIcon::STATE_DAEMON_UP);

#if defined(Q_OS_WIN32)
    QTimer::singleShot(kIntervalBeforeShowInitVirtualDialog, this, SLOT(checkInitVDrive()));
    configurator_->installCustomUrlHandler();
#endif

    if (settings_mgr_->isCheckLatestVersionEnabled()) {
        checkLatestVersionInfo();
    }

    OpenLocalHelper::instance()->checkPendingOpenLocalRequest();

    QTimer::singleShot(kIntervalForUpdateRepoProperty,
                       this, SLOT(updateReposPropertyForHttpSync()));

    //
    // start finder/explorer extension handler
    //
#if defined(Q_OS_WIN32)
    SeafileExtensionHandler::instance()->start();
#elif defined(HAVE_FINDER_SYNC_SUPPORT)
    finderSyncListenerStart();
#endif
}