本文整理汇总了C++中ActivityBuilder::SetForeground方法的典型用法代码示例。如果您正苦于以下问题:C++ ActivityBuilder::SetForeground方法的具体用法?C++ ActivityBuilder::SetForeground怎么用?C++ ActivityBuilder::SetForeground使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActivityBuilder
的用法示例。
在下文中一共展示了ActivityBuilder::SetForeground方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: BuildMoveEmailsWatch
void ActivityBuilderFactory::BuildMoveEmailsWatch(ActivityBuilder& builder)
{
MojString name;
GetMoveEmailsActivityName(name);
MojString desc;
GetMoveEmailsActivityDesc(desc);
builder.SetName(name.data());
builder.SetDescription(desc.data());
builder.SetPersist(true);
builder.SetExplicit(true);
builder.SetForeground(true);
// setup trigger
MojDbQuery trigger;
MojErr err = trigger.from(PopEmailAdapter::POP_EMAIL_KIND);
ErrorToException(err);
err = trigger.where("destFolderId", MojDbQuery::OpNotEq, MojObject());
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(MOVE_EMAILS_CALLBACK, params);
// put accountId in metadata
MojObject metadata;
err = metadata.put(PopFolderAdapter::ACCOUNT_ID, m_accountId);
ErrorToException(err);
builder.SetMetadata(metadata);
}
示例4: BuildIdleWakeup
void ImapActivityFactory::BuildIdleWakeup(ActivityBuilder& ab, const MojObject& accountId, const MojObject& folderId, int seconds)
{
ab.SetName( GetIdleWakeupName(accountId, folderId) );
ab.SetDescription("Wakes up idle connection");
ab.SetExplicit(false); // goes away after a cancel
ab.SetPersist(false);
ab.SetForeground(true); // must run immediately
ab.SetPowerOptions(false, true);
// Wakeup
ab.SetStartDelay(seconds);
}
示例5: BuildConnect
// This is used if we don't have any other activity to get network status from
void ImapActivityFactory::BuildConnect(ActivityBuilder& ab, const MojObject& accountId, MojUInt64 uniqueId)
{
MojString name;
MojErr err = name.format("%s - %lld", CONNECT_NAME, uniqueId);
ErrorToException(err);
ab.SetName( FormatName(name.data(), accountId) );
ab.SetDescription("Activity for connecting to server");
ab.SetExplicit(false);
ab.SetPersist(false);
ab.SetForeground(true);
ab.SetRequiresInternet(false);
}
示例6: CheckNetworkConnectivity
void SmtpSyncOutboxCommand::CheckNetworkConnectivity()
{
try {
if (m_networkStatus->IsKnown()) {
if (m_networkStatus->IsConnected()) {
MojLogInfo(m_log, "CheckNetworkActivity: is connected, moving on");
GetAccount();
return;
} else {
MojLogInfo(m_log, "CheckNetworkActivity: is not connected, erroring out");
// Note that this account error explicitly doesn't delay the retry, on the assumption
// that the next activity will be blocked until the network is available.
m_error.errorCode = MailError::NO_NETWORK;
m_error.errorOnAccount = true;
m_error.errorOnEmail = false;
m_error.internalError = "No network available for outbox sync";
m_error.errorText = "";
CompleteAndUpdateActivities();
return;
}
} else {
MojLogInfo(m_log, "CheckNetworkActivity: state unknown, starting new activity");
MojLogInfo(m_log, "OutboxSyncer creating new network activity");
ActivityBuilder ab;
MojString name;
MojErr err = name.format("SMTP Internal Outbox Sync Network Activity for account %s", AsJsonString(m_accountId).c_str());
ErrorToException(err);
ab.SetName(name);
ab.SetDescription("Activity representing SMTP Outbox Sync Network Monitor");
ab.SetForeground(true);
ab.SetRequiresInternet(false);
ab.SetImmediate(true, ActivityBuilder::PRIORITY_LOW);
m_networkActivity = Activity::PrepareNewActivity(ab);
m_networkActivity->SetSlots(m_networkActivityUpdatedSlot, m_networkActivityErrorSlot);
m_networkActivity->Create(m_client);
}
} catch (std::exception & e) {
HandleException(e, __func__);
} catch (...) {
HandleException(__func__);
}
}
示例7: BuildSentEmailsWatch
void ActivityBuilderFactory::BuildSentEmailsWatch(ActivityBuilder& builder, const MojObject& outboxFolderId, const MojObject& sentFolderId)
{
// activity to setup watch
MojString name;
GetSentEmailsWatchActivityName(name);
// description of watch
MojString desc;
GetSentEmailsWatchActivityDesc(desc);
builder.SetName(name.data());
builder.SetDescription(desc.data());
builder.SetPersist(true);
builder.SetExplicit(true);
builder.SetForeground(true);
// setup trigger
MojDbQuery trigger;
MojErr err = trigger.from(EmailSchema::Kind::EMAIL);
ErrorToException(err);
err = trigger.where(EmailSchema::FOLDER_ID, MojDbQuery::OpEq, outboxFolderId);
ErrorToException(err);
err = trigger.where("sendStatus.sent", 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);
err = params.put(PopFolderAdapter::OUTBOX_FOLDER_ID, outboxFolderId);
ErrorToException(err);
err = params.put(PopFolderAdapter::SENT_FOLDER_ID, sentFolderId);
ErrorToException(err);
builder.SetCallback(SENT_EMAILS_WATCH_CALLBACK, params);
// put accountId in metadata
MojObject metadata;
err = metadata.put("accountId", m_accountId);
ErrorToException(err);
builder.SetMetadata(metadata);
}
示例8: BuildDraftsWatch
void ImapActivityFactory::BuildDraftsWatch(ActivityBuilder& ab, const MojObject& accountId, const MojObject& folderId, MojInt64 rev)
{
MojErr err;
ab.SetName( GetDraftsWatchName(accountId, folderId) );
ab.SetDescription("Watches for updates to draft emails");
ab.SetPersist(true);
ab.SetExplicit(true);
ab.SetForeground(true);
// Metadata
MojObject metadata;
SetMetadata(metadata, DRAFTS_WATCH_NAME, accountId, folderId);
ab.SetMetadata(metadata);
MojDbQuery query;
err = query.from(EmailSchema::Kind::EMAIL);
ErrorToException(err);
err = query.where(EmailSchema::FOLDER_ID, MojDbQuery::OpEq, folderId);
ErrorToException(err);
MojString editedDraftFlag;
editedDraftFlag.format("%s.%s", EmailSchema::FLAGS, EmailSchema::Flags::EDITEDDRAFT);
err = query.where(editedDraftFlag.data(), MojDbQuery::OpEq, true);
ErrorToException(err);
ab.SetDatabaseWatchTrigger(query);
// Callback
MojObject callbackParams;
err = callbackParams.put("accountId", accountId);
ErrorToException(err);
err = callbackParams.put("folderId", accountId);
ErrorToException(err);
ab.SetCallback(DRAFTS_WATCH_CALLBACK, callbackParams);
}
示例9: BuildOutboxWatch
void ImapActivityFactory::BuildOutboxWatch(ActivityBuilder& ab, const MojObject& accountId, const MojObject& folderId, MojInt64 rev)
{
MojErr err;
ab.SetName( GetOutboxWatchName(accountId, folderId) );
ab.SetDescription("Watches for sent emails in outbox");
ab.SetPersist(true);
ab.SetExplicit(true);
ab.SetForeground(true);
// Metadata
MojObject metadata;
SetMetadata(metadata, OUTBOX_WATCH_NAME, accountId, folderId);
ab.SetMetadata(metadata);
MojDbQuery query;
err = query.from(EmailSchema::Kind::EMAIL);
ErrorToException(err);
err = query.where(EmailSchema::FOLDER_ID, MojDbQuery::OpEq, folderId);
ErrorToException(err);
// sendStatus.sent
MojString sentProp;
sentProp.format("%s.%s",EmailSchema::SEND_STATUS, EmailSchema::SendStatus::SENT);
err = query.where(sentProp.data(), MojDbQuery::OpEq, true);
ErrorToException(err);
ab.SetDatabaseWatchTrigger(query);
// Callback
MojObject callbackParams;
err = callbackParams.put("accountId", accountId);
ErrorToException(err);
ab.SetCallback(OUTBOX_WATCH_CALLBACK, callbackParams);
}