本文整理汇总了C++中MojObject::put方法的典型用法代码示例。如果您正苦于以下问题:C++ MojObject::put方法的具体用法?C++ MojObject::put怎么用?C++ MojObject::put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MojObject
的用法示例。
在下文中一共展示了MojObject::put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stats
MojErr MojDbIndex::stats(MojObject& objOut, MojSize& usageOut, MojDbReq& req)
{
LOG_TRACE("Entering function %s", __FUNCTION__);
MojAssert(isOpen());
MojSize count = 0;
MojSize size = 0;
MojErr err = m_index->stats(req.txn(), count, size);
LOG_DEBUG("[db_mojodb] IndexStats: Kind: %s;Index: %s; Id: %zX; count= %zu; size= %zu; delMisses = %d, err= %d \n",
m_kind->name().data(), m_name.data(), idIndex(), count, size, m_delMisses, err);
MojErrCheck(err);
usageOut += size;
err = objOut.put(SizeKey, (MojInt64) size);
MojErrCheck(err);
err = objOut.put(CountKey, (MojInt64) count);
MojErrCheck(err);
err = objOut.put(DelMissesKey, (MojInt64) m_delMisses); // cumulative since start
MojErrCheck(err);
MojThreadReadGuard guard(m_lock);
if (!m_watcherMap.empty()) {
MojObject watcherInfo;
for (WatcherMap::ConstIterator i = m_watcherMap.begin(); i != m_watcherMap.end(); ++i) {
err = watcherInfo.put(i.key(), (MojInt64) i.value());
MojErrCheck(err);
}
err = objOut.put(WatchesKey, watcherInfo);
MojErrCheck(err);
}
return MojErrNone;
}
示例2: Status
void PopClient::Status(MojObject& status) const
{
MojErr err;
err = status.put("accountId", m_accountId);
ErrorToException(err);
err = status.putString("state", GetStateName(m_state));
ErrorToException(err);
if(m_commandManager->GetActiveCommandCount() > 0 || m_commandManager->GetPendingCommandCount() > 0) {
MojObject cmStatus;
m_commandManager->Status(cmStatus);
err = status.put("commandManager", cmStatus);
ErrorToException(err);
}
if(m_session.get()) {
MojObject sessionStatus;
m_session->Status(sessionStatus);
err = status.put("session", sessionStatus);
ErrorToException(err);
}
}
示例3: InsertCacheObject
void FileCacheClient::InsertCacheObject(ReplySignal::SlotRef slot, const char* typeName, const char* fileName, MojInt64 size, MojInt64 cost, MojInt64 lifetime)
{
MojErr err;
MojObject payload;
err = payload.putString("typeName", typeName);
ErrorToException(err);
err = payload.putString("fileName", fileName);
ErrorToException(err);
// Size must be >0 and larger than the actual content.
// If the content is empty, we'll use 1 so FileCache doesn't complain.
err = payload.put("size", size > 0 ? size : 1);
ErrorToException(err);
if(cost >= 0) {
err = payload.put("cost", cost);
ErrorToException(err);
}
if(lifetime >= 0) {
err = payload.put("lifetime", lifetime);
ErrorToException(err);
}
err = payload.put("subscribe", true);
ErrorToException(err);
m_busClient.SendRequest(slot, FILECACHE_SERVICE, "InsertCacheObject", payload, MojServiceRequest::Unlimited);
}
示例4: 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);
}
示例5: ScheduleRetry
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);
}
示例6: 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);
}
示例7: 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);
}
示例8: CallbackInfo
MojErr MojService::CategoryHandler::addMethod(const MojChar* methodName, Callback callback, bool pub, const MojChar* schemaJson)
{
MojAssert(methodName && callback);
MojString str;
MojErr err = str.assign(methodName);
MojErrCheck(err);
MojRefCountedPtr<MojSchema> schema;
if (schemaJson) {
MojObject schemaObj;
err = schemaObj.fromJson(schemaJson);
MojErrCheck(err);
// add implicit $activity property
MojObject properties;
schemaObj.get(MojSchema::PropertiesKey, properties);
MojObject activityProp;
err = activityProp.putBool(MojSchema::OptionalKey, true);
MojErrCheck(err);
err = properties.put(_T("$activity"), activityProp);
MojErrCheck(err);
err = schemaObj.put(MojSchema::PropertiesKey, properties);
MojErrCheck(err);
schema.reset(new MojSchema);
MojAllocCheck(schema.get());
err = schema->fromObject(schemaObj);
MojErrCheck(err);
}
MojAssert(!m_callbackMap.contains(str));
err = m_callbackMap.put(str, CallbackInfo(callback, schema.get(), pub));
MojErrCheck(err);
return MojErrNone;
}
示例9: UpdateAccountWatchActivity
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__));
}
}
示例10: InfoToJson
MojErr ContainerManager::InfoToJson(MojObject& rep) const
{
MojObject containers(MojObject::TypeArray);
std::for_each(m_containers.begin(), m_containers.end(),
boost::bind(&ResourceContainer::PushJson,
boost::bind(&ContainerMap::value_type::second, _1),
boost::ref(containers)));
MojErr err = rep.put(_T("containers"), containers);
MojErrCheck(err);
MojObject entityMap(MojObject::TypeArray);
for (EntityContainerMap::const_iterator iter = m_entityContainers.begin();
iter != m_entityContainers.end(); ++iter) {
MojObject mapping(MojObject::TypeObject);
MojString containerName;
err = containerName.assign(iter->second->GetName().c_str());
MojErrCheck(err);
err = mapping.put(iter->first->GetName().c_str(), containerName);
MojErrCheck(err);
err = entityMap.push(mapping);
MojErrCheck(err);
}
err = rep.put(_T("entityMap"), entityMap);
MojErrCheck(err);
return MojErrNone;
}
示例11: 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);
}
示例12: BuildOutboxWatch
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);
}
示例13: ReportError
void DownloadListener::ReportError(MailError::ErrorCode errorCode, const string& errorText)
{
MojErr err;
MojObject payload;
err = payload.put("returnValue", false);
ErrorToException(err);
err = payload.put("emailId", m_emailId);
ErrorToException(err);
if(!m_partId.undefined()) {
err = payload.put("partId", m_partId);
ErrorToException(err);
}
err = payload.put("errorCode", errorCode);
ErrorToException(err);
err = payload.putString("errorText", errorText.c_str());
ErrorToException(err);
err = m_msg->reply(payload);
ErrorToException(err);
}
示例14: UpdateSendStatus
void SmtpSendMailCommand::UpdateSendStatus()
{
try {
MojObject sendStatus;
MojObject visible;
MojErr err;
bool update = false;
if (m_error.errorCode == 0) {
MojLogInfo(m_log, "updating send status to SENT successfully");
err = sendStatus.put(EmailSchema::SendStatus::SENT, true);
ErrorToException(err);
err = visible.put(EmailSchema::Flags::VISIBLE, false);
ErrorToException(err);
update = true;
} else if (m_error.errorOnEmail) {
MojLogInfo(m_log, "updating send status on email to indicate error");
MojString str;
str.assign(m_error.errorText.c_str());
err = sendStatus.put(EmailSchema::SendStatus::LAST_ERROR, str);
ErrorToException(err);
// FIXME: Should we store an actual error code?
err = sendStatus.put(EmailSchema::SendStatus::FATAL_ERROR, true);
ErrorToException(err);
update = true;
}
// account errors are not handled in sent status: message
// status will not be changed in those cases.
if (update) {
MojString idJson;
m_emailId.toJson(idJson);
MojLogInfo(m_log, "updating send status for email %s", idJson.data());
m_session.GetDatabaseInterface().UpdateSendStatus(m_updateSendStatusSlot, m_emailId, sendStatus, visible);
} else {
// Finish up now
Done();
}
} catch (std::exception & e) {
// Error updating status, just give up.
MojLogInfo(m_log, "Exception %s hit trying to update send status, bailing", e.what());
Done();
} catch (...) {
// Error updating status, just give up.
MojLogInfo(m_log, "Unknown exception hit trying to update send status, bailing");
Done();
}
}
示例15: putTest
MojErr MojObjectTest::putTest(MojObject& obj)
{
MojString str;
MojObject obj2;
MojObject array1;
MojObject str2;
MojObject bool2(false);
MojObject int2(-260000000000LL);
MojObject MojDecimal2(MojDecimal(2.34));
MojErr err = str.assign(_T("howdy"));
MojTestErrCheck(err);
str2 = str;
err = obj2.put(_T("nested"), str);
MojTestErrCheck(err);
err = obj.put(_T("object"), obj2);
MojTestErrCheck(err);
err = obj.put(_T("string"), str2);
MojTestErrCheck(err);
err = obj.put(_T("bool1"), true);
MojTestErrCheck(err);
err = obj.put(_T("bool2"), bool2);
MojTestErrCheck(err);
err = obj.put(_T("int1"), 50);
MojTestErrCheck(err);
err = obj.put(_T("int2"), int2);
MojTestErrCheck(err);
err = obj.put(_T("MojDecimal1"), MojDecimal(0.1));
MojTestErrCheck(err);
err = obj.put(_T("MojDecimal2"), MojDecimal2);
MojTestErrCheck(err);
err = obj.put(_T("null"), MojObject(MojObject::TypeNull));
MojTestErrCheck(err);
// array
err = array1.push(MojObject(MojObject::TypeObject));
MojTestErrCheck(err);
err = array1.push(MojObject(MojObject::TypeArray));
MojTestErrCheck(err);
err = array1.push(str2);
MojTestErrCheck(err);
err = array1.push(true);
MojTestErrCheck(err);
err = array1.setAt(3, false);
MojTestErrCheck(err);
err = array1.push(MojDecimal(3, 140000));
MojTestErrCheck(err);
err = array1.push(100);
MojTestErrCheck(err);
err = array1.push(MojObject(MojObject::TypeNull));
MojTestErrCheck(err);
err = array1.setAt(7, 4);
MojTestErrCheck(err);
err = obj.put(_T("array"), array1);
MojTestErrCheck(err);
return MojErrNone;
}