示例#1
0
QString CentralServiceReporter::workspaceId() const
{
    QObject parent;
    ISettings *settings = m_proxyConnection->settings(&parent);
    settings->beginGroup("current_workspace");
    return settings->value("id").toString();
}
示例#2
0
/**
 * @brief If is currently a server, reports updates in sync journal to the central services.
 * @return True if success
 */
bool CentralServiceReporter::reportSyncJournal()
{
    QObject parent;
    if (!m_proxyConnection->session(&parent)->isServer())
        return true;

    bool ok;
    QVariantMap serverState = getServerSyncState(&ok);
    if (!ok) {
        m_proxyConnection->message("Central Service Report: Failed to access the service");
        return false;
    }

    SyncServer syncServer(m_proxyConnection);
    QVariantList updates = syncServer.updates(serverState, true, QString());
    if (!updates.count())
        return true;

    ISettings *settings = m_proxyConnection->settings(&parent);
    settings->beginGroup("current_workspace");

    QVariantMap message;
    message.insert("workspace_id", settings->value("id").toString());
    message.insert("workspace_name", settings->value("name").toString());

    bool success = true;
    if (updates.count() < MaxUpdatesInReport) {
        message.insert("updates", updates);
        success = sendUpdates(message);
    } else {
        for (int i = 0; i < updates.count() && success; i += MaxUpdatesInReport) {
            message.insert("updates", updates.mid(i, MaxUpdatesInReport));
            success = sendUpdates(message);
        }
    }
    if (!success)
        m_proxyConnection->message("Central Service Report: Failed to report updates to the service");
    return success;
}