本文整理汇总了C++中ActivityBuilder类的典型用法代码示例。如果您正苦于以下问题:C++ ActivityBuilder类的具体用法?C++ ActivityBuilder怎么用?C++ ActivityBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ActivityBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ErrorToException
MojErr MovePopEmailsCommand::EmailsMovedResponse(MojObject& response, MojErr err)
{
try {
ErrorToException(err);
ActivityBuilder ab;
m_client.GetActivityBuilderFactory()->BuildMoveEmailsWatch(ab);
m_activity->UpdateAndComplete(m_client, ab.GetActivityObject());
m_msg->replySuccess();
if (m_inboxEmailsMoved.size() > 0) {
// add the list of UIDs into UidCache
GetUidCache();
} else {
Complete();
}
} catch (const std::exception& ex) {
m_msg->replyError(MojErrInternal, ex.what());
Failure(ex);
} catch (...) {
m_msg->replyError(MojErrInternal);
Failure(MailException("unknown exception", __FILE__, __LINE__));
}
return MojErrNone;
}
示例2: if
void ScheduleRetryCommand::ScheduleRetry()
{
ActivityBuilder ab;
// Get current retry interval from account
EmailAccount::RetryStatus retryStatus = m_client.GetAccount()->GetRetry();
int interval = retryStatus.GetInterval();
if(interval <= INITIAL_RETRY_SECONDS) {
interval = INITIAL_RETRY_SECONDS;
} else if(interval >= MAX_RETRY_SECONDS) {
interval = MAX_RETRY_SECONDS;
} else {
// TODO: only update this on actual retry?
interval *= RETRY_MULTIPLIER;
}
// Update account just in case it wasn't within the limit
retryStatus.SetInterval(interval);
m_client.GetAccount()->SetRetry(retryStatus);
m_client.GetActivityBuilderFactory()->BuildFolderRetrySync(ab, m_folderId, interval);
MojErr err;
MojObject payload;
err = payload.put("activity", ab.GetActivityObject());
ErrorToException(err);
err = payload.put("start", true);
ErrorToException(err);
err = payload.put("replace", true);
MojLogInfo(m_log, "Creating retry activity in activity manager: %s", AsJsonString(payload).c_str());
m_client.SendRequest(m_scheduleRetrySlot, "com.palm.activitymanager", "create", payload);
}
示例3: CommandTraceFunction
void PopAccountUpdateCommand::UpdateAccountWatchActivity()
{
CommandTraceFunction();
try {
MojObject revPop;
MojErr err = m_transportObj.getRequired("_revPop", revPop);
ErrorToException(err);
ActivityBuilder ab;
m_activityBuilderFactory->BuildAccountPrefsWatch(ab, revPop);
MojObject payload;
err = payload.put("activity", ab.GetActivityObject());
ErrorToException(err);
err = payload.put("start", true);
ErrorToException(err);
err = payload.put("replace", true);
ErrorToException(err);
m_client.SendRequest(m_createActivitySlot, "com.palm.activitymanager", "create", payload);
} catch (const std::exception& ex) {
Failure(ex);
} catch (...) {
Failure(MailException("unknown exception", __FILE__, __LINE__));
}
}
示例4: MojLogInfo
void SyncSession::UpdateScheduledSyncActivity()
{
MojLogInfo(m_log, "updating scheduled sync activity on folder %s", AsJsonString(m_folderId).c_str());
PopClient::AccountPtr account = m_client.GetAccount();
MojObject accountId = account->GetAccountId();
ActivityBuilder ab;
if(!account->IsManualSync()) {
int interval = account->GetSyncFrequencyMins();
MojLogInfo(m_log, "setting sync interval to %d minutes", interval);
m_builderFactory->BuildScheduledSync(ab, interval);
MojObject actObj = ab.GetActivityObject();;
MojLogInfo(m_log, "Replacing scheduled activity: %s", AsJsonString(actObj).c_str());
m_activities->ReplaceActivity(ab.GetName(), actObj);
} else {
MojString scheduledActName;
m_builderFactory->GetScheduledSyncActivityName(scheduledActName);
// Remove activity
ActivityPtr activity = m_activities->GetOrCreateActivity(scheduledActName);
activity->SetEndAction(Activity::EndAction_Cancel);
}
}
示例5: SetNetworkRequirements
void ImapActivityFactory::SetNetworkRequirements(ActivityBuilder& ab, bool requireFair)
{
ab.SetRequiresInternet(false);
if(requireFair && !ImapConfig::GetConfig().GetIgnoreNetworkStatus()) {
ab.SetRequiresInternetConfidence("fair");
}
}
示例6: BuildScheduledSync
void ActivityBuilderFactory::BuildScheduledSync(ActivityBuilder &builder, int intervalMins)
{
// activity to setup watch
MojString name;
GetScheduledSyncActivityName(name);
// description of watch
MojString desc;
GetScheduledSyncActivityDesc(desc);
// sync interval in seconds
int intervalSecs = MinsToSecs(intervalMins);
builder.SetName(name.data());
builder.SetDescription(desc.data());
builder.SetPersist(true);
builder.SetExplicit(true);
builder.SetRequiresInternet(false);
builder.SetSyncInterval(0, intervalSecs);
builder.SetImmediate(true, "low");
// setup parameters (to be sent when trigger is called)
MojObject params;
MojErr err = params.put(PopAccountAdapter::ACCOUNT_ID, m_accountId);
ErrorToException(err);
builder.SetCallback(SCHEDULED_SYNC_CALLBACK, params);
// put accountId in metadata
MojObject metadata;
err = metadata.put("accountId", m_accountId);
ErrorToException(err);
builder.SetMetadata(metadata);
}
示例7: AsJsonString
void SmtpActivityFactory::BuildOutboxWatch(ActivityBuilder& ab, const MojObject& accountId, const MojObject& folderId)
{
ActivityBuilder actBuilder;
MojString name;
name.format(OUTBOX_WATCH_ACTIVITY_FMT, AsJsonString(accountId).c_str());
ab.SetName(name);
ab.SetDescription("Watches SMTP outbox for new emails");
ab.SetPersist(true);
ab.SetExplicit(true);
ab.SetRequiresInternet(false); // don't trigger until we also have connectivity
ab.SetImmediate(true, ActivityBuilder::PRIORITY_LOW);
// Callback
MojObject callbackParams;
MojErr err = callbackParams.put("accountId", accountId);
ErrorToException(err);
err = callbackParams.put("folderId", folderId);
ErrorToException(err);
ab.SetCallback(OUTBOX_BUS_METHOD, callbackParams);
ab.SetMetadata(callbackParams);
}
示例8: BuildDeleteEmailsWatch
void ActivityBuilderFactory::BuildDeleteEmailsWatch(ActivityBuilder& builder)
{
MojString name;
GetDeleteEmailsActivityName(name);
MojString desc;
GetDeleteEmailsActivityDesc(desc);
builder.SetName(name.data());
builder.SetDescription(desc.data());
builder.SetPersist(true);
builder.SetExplicit(true);
builder.SetImmediate(true, "low");
// setup trigger
MojDbQuery trigger;
MojErr err = trigger.from(PopEmailAdapter::POP_EMAIL_KIND);
ErrorToException(err);
err = trigger.where("_del", MojDbQuery::OpEq, true);
ErrorToException(err);
builder.SetDatabaseWatchTrigger(trigger);
// setup parameters (to be sent when trigger is called)
MojObject params;
err = params.put(PopFolderAdapter::ACCOUNT_ID, m_accountId);
ErrorToException(err);
builder.SetCallback(DELETE_EMAILS_CALLBACK, params);
// put accountId in metadata
MojObject metadata;
err = metadata.put(PopFolderAdapter::ACCOUNT_ID, m_accountId);
ErrorToException(err);
builder.SetMetadata(metadata);
}
示例9: BuildScheduledSync
void ImapActivityFactory::BuildScheduledSync(ActivityBuilder& ab, const MojObject& accountId, const MojObject& folderId, int seconds, bool requireFair)
{
MojErr err;
ab.SetName( GetScheduledSyncName(accountId, folderId) );
MojString desc;
err = desc.format("Scheduled sync every %d minutes", seconds/60);
ErrorToException(err);
ab.SetDescription(desc.data());
ab.SetExplicit(true);
ab.SetPersist(true);
ab.SetImmediate(true, "low");
SetNetworkRequirements(ab, requireFair);
// Metadata
MojObject metadata;
SetMetadata(metadata, SCHEDULED_SYNC_NAME, accountId, folderId);
ab.SetMetadata(metadata);
// Wakeup
ab.SetSyncInterval(0, seconds);
// Callback
MojObject params;
err = params.put("accountId", accountId);
ErrorToException(err);
ab.SetCallback(SCHEDULED_SYNC_CALLBACK, params);
}
示例10: BuildAccountPrefsWatch
void ActivityBuilderFactory::BuildAccountPrefsWatch(ActivityBuilder& builder, MojObject& accountRev)
{
MojString name;
GetAccountPrefsWatchActivityName(name);
MojString desc;
GetAccountPrefsWatchActivityDesc(desc);
builder.SetName(name.data());
builder.SetDescription(desc.data());
builder.SetPersist(true);
builder.SetExplicit(true);
builder.SetImmediate(true, "low");
MojDbQuery trigger;
MojErr err = trigger.from(PopAccountAdapter::POP_ACCOUNT_KIND);
ErrorToException(err);
err = trigger.where(PopAccountAdapter::ACCOUNT_ID, MojDbQuery::OpEq, m_accountId);
ErrorToException(err);
err = trigger.where("_revPop", MojDbQuery::OpGreaterThan, accountRev);
ErrorToException(err);
builder.SetDatabaseWatchTrigger(trigger);
MojObject params;
err = params.put(PopAccountAdapter::ACCOUNT_ID, m_accountId);
ErrorToException(err);
builder.SetCallback(ACCOUNT_PREFS_WATCH_CALLBACK, params);
MojObject metadata;
err = metadata.put(PopAccountAdapter::ACCOUNT_ID, m_accountId);
ErrorToException(err);
builder.SetMetadata(metadata);
}
示例11: MojLogInfo
void SmtpSyncOutboxCommand::UpdateAccountWatchActivity()
{
MojLogInfo(m_log, "UpdatingAccountWatchActivity");
try {
// accoundId json object
MojString accountIdJson;
MojErr err = m_accountId.toJson(accountIdJson);
ErrorToException(err);
SmtpActivityFactory factory;
ActivityBuilder ab;
factory.BuildSmtpConfigWatch(ab, m_accountId, m_accountRev);
bool updating = m_accountWatchActivity.get();
// and either update and complete the updated activity if we had adopted it, or re-create it.
if ( updating ) {
MojLogInfo(m_log, "updating account watch activity");
m_accountWatchActivity->SetSlots(m_accountActivityUpdatedSlot, m_accountActivityErrorSlot);
m_accountWatchActivity->UpdateAndComplete(m_client, ab.GetActivityObject());
} else {
// Create payload
MojObject payload;
err = payload.put("activity", ab.GetActivityObject());
ErrorToException(err);
err = payload.put("start", true);
ErrorToException(err);
err = payload.put("replace", true);
ErrorToException(err);
MojLogInfo(m_log, "creating account watch activity");
m_client.SendRequest(m_createAccountWatchActivityResponseSlot, "com.palm.activitymanager", "create", payload);
}
} catch (std::exception & e) {
HandleException(e, __func__);
} catch (...) {
HandleException(__func__);
}
}
示例12: BuildStartIdle
void ImapActivityFactory::BuildStartIdle(ActivityBuilder& ab, const MojObject& accountId, const MojObject& folderId)
{
MojErr err;
ab.SetName( GetStartIdleName(accountId, folderId) );
ab.SetDescription("Starts a push connection when the network is available");
ab.SetExplicit(false);
ab.SetPersist(true);
ab.SetImmediate(true, "low");
SetNetworkRequirements(ab, false);
// Metadata
MojObject metadata;
SetMetadata(metadata, MAINTAIN_IDLE_NAME, accountId, folderId);
ab.SetMetadata(metadata);
// Callback
MojObject params;
err = params.put("accountId", accountId);
ErrorToException(err);
err = params.put("folderId", folderId);
ErrorToException(err);
ab.SetCallback(MAINTAIN_IDLE_CALLBACK, params);
}
示例13: BuildPreferencesWatch
void ImapActivityFactory::BuildPreferencesWatch(ActivityBuilder& ab, const MojObject& accountId, MojInt64 rev)
{
MojErr err;
ab.SetName( GetPreferencesWatchName(accountId) );
ab.SetDescription("IMAP account preferences watch");
ab.SetPersist(true);
ab.SetForeground(true);
// Metadata
MojObject metadata;
SetMetadata(metadata, PREFS_WATCH_NAME, accountId);
ab.SetMetadata(metadata);
MojDbQuery trigger;
err = trigger.from(ImapAccountAdapter::SCHEMA);
ErrorToException(err);
err = trigger.where(ImapAccountAdapter::ACCOUNT_ID, MojDbQuery::OpEq, accountId);
ErrorToException(err);
err = trigger.where(ImapAccountAdapter::CONFIG_REV, MojDbQuery::OpGreaterThan, rev);
ErrorToException(err);
ab.SetDatabaseWatchTrigger(trigger);
MojObject params;
err = params.put("accountId", accountId);
ErrorToException(err);
ab.SetCallback(PREFS_WATCH_CALLBACK, params);
}
示例14: CreateActivity
void NetworkStatusMonitor::CreateActivity()
{
ActivityBuilder ab;
static MojInt64 uniqueId = 0;
string serviceName = m_busClient.GetServiceName();
// FIXME
if(serviceName.empty()) {
throw MailException("no service name", __FILE__, __LINE__);
}
MojString name;
MojErr err = name.format("%s network status check - %lld", serviceName.c_str(), ++uniqueId);
ErrorToException(err);
ab.SetName(name.data());
ab.SetDescription("Monitors network status");
ab.SetExplicit(false);
ab.SetPersist(false);
ab.SetForeground(true);
ab.SetRequiresInternet(true);
m_activity = Activity::PrepareNewActivity(ab, true, true);
m_activity->SetSlots(m_activityUpdateSlot, m_activityErrorSlot);
m_activity->Create(m_busClient);
}
示例15: CommandTraceFunction
void ScheduleRetryCommand::ScheduleRetry()
{
CommandTraceFunction();
ImapActivityFactory factory;
ActivityBuilder ab;
// Get current retry interval from account
EmailAccount::RetryStatus retryStatus = m_client.GetAccount().GetRetry();
int interval = retryStatus.GetInterval();
if(interval < INITIAL_RETRY_SECONDS) {
interval = INITIAL_RETRY_SECONDS;
} else if(interval < SECOND_RETRY_SECONDS) {
interval = SECOND_RETRY_SECONDS;
} else if(interval >= MAX_RETRY_SECONDS) {
interval = MAX_RETRY_SECONDS;
} else {
// TODO: only update this on actual retry?
interval *= RETRY_MULTIPLIER;
}
// Update account just in case it wasn't within the limit
retryStatus.SetInterval(interval);
retryStatus.SetCount(retryStatus.GetCount() + 1);
m_client.GetAccount().SetRetry(retryStatus);
factory.BuildSyncRetry(ab, m_client.GetAccountId(), m_folderId, interval, m_reason);
MojErr err;
MojObject payload;
err = payload.put("activity", ab.GetActivityObject());
ErrorToException(err);
err = payload.put("start", true);
ErrorToException(err);
err = payload.put("replace", true);
MojLogInfo(m_log, "scheduling retry in %.1f minutes for account %s", float(interval) / 60, m_client.GetAccountIdString().c_str());
m_client.SendRequest(m_scheduleRetrySlot, "com.palm.activitymanager", "create", payload);
}