本文整理汇总了C++中MojObject类的典型用法代码示例。如果您正苦于以下问题:C++ MojObject类的具体用法?C++ MojObject怎么用?C++ MojObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MojObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SmtpCommand
// TODO: Need to use ActivitySet for activity hanlding
SmtpSyncOutboxCommand::SmtpSyncOutboxCommand(SmtpClient& client, const MojObject& accountId, const MojObject& folderId, bool force, bool clear)
: SmtpCommand(client),
m_client(client),
m_accountId(accountId),
m_folderId(folderId),
m_highestRev(0),
m_canAdopt(true),
m_setSyncStatusSlot(this, &SmtpSyncOutboxCommand::SetSyncStatusResponse),
m_clearSyncStatusSlot(this, &SmtpSyncOutboxCommand::ClearSyncStatusResponse),
m_setSyncStatusSlot2(this, &SmtpSyncOutboxCommand::SetSyncStatusResponse2),
m_clearSyncStatusSlot2(this, &SmtpSyncOutboxCommand::ClearSyncStatusResponse2),
m_getOutboxEmailsSlot(this, &SmtpSyncOutboxCommand::GetOutboxEmailsResponse),
m_sendDoneSlot(this, &SmtpSyncOutboxCommand::SendDone),
m_activityUpdatedSlot(this, &SmtpSyncOutboxCommand::ActivityUpdated),
m_activityErrorSlot(this, &SmtpSyncOutboxCommand::ActivityError),
m_accountActivityUpdatedSlot(this, &SmtpSyncOutboxCommand::AccountActivityUpdated),
m_accountActivityErrorSlot(this, &SmtpSyncOutboxCommand::AccountActivityError),
m_getAccountSlot(this, &SmtpSyncOutboxCommand::GotAccount),
m_temporaryError(false),
m_createWatchActivitySlot(this, &SmtpSyncOutboxCommand::CreateWatchActivityResponse),
m_createAccountWatchActivityResponseSlot(this, &SmtpSyncOutboxCommand::CreateAccountWatchResponse),
m_findFolderSlot(this, &SmtpSyncOutboxCommand::FindOutgoingFolderResponse),
m_updateRetrySlot(this, &SmtpSyncOutboxCommand::UpdateRetryResponse),
m_updateErrorSlot(this, &SmtpSyncOutboxCommand::UpdateErrorResponse),
m_resetErrorSlot(this, &SmtpSyncOutboxCommand::ResetErrorResponse),
m_cancelled(false),
m_force(force),
m_clear(clear),
m_networkStatus(new NetworkStatus()),
m_networkActivityUpdatedSlot(this, &SmtpSyncOutboxCommand::NetworkActivityUpdated),
m_networkActivityErrorSlot(this, &SmtpSyncOutboxCommand::NetworkActivityError)
{
MojString d;
m_accountId.stringValue(d);
m_outboxWatchActivityName.format(SmtpActivityFactory::OUTBOX_WATCH_ACTIVITY_FMT, d.data());
m_accountWatchActivityName.format(SmtpActivityFactory::ACCOUNT_WATCH_ACTIVITY_FMT, d.data());
#ifdef WEBOS_TARGET_MACHINE_STANDALONE
MojObject cmStatus;
MojErr err;
err = cmStatus.put("isInternetConnectionAvailable", true);
ErrorToException(err);
m_networkStatus->ParseStatus(cmStatus);
#endif
}
示例2: MojLogTrace
MojErr AuthYahooCommand::GetYahooCookiesSlot(MojObject& response, MojErr err)
{
MojLogTrace(m_log);
try {
ResponseToException(response, err);
MojObject object;
err = response.getRequired("tCookie", m_tCookie);
ErrorToException(err);
err = response.getRequired("yCookie", m_yCookie);
ErrorToException(err);
} catch (const std::exception& e) {
MojLogInfo(m_log, "Failed to retrieve Yahoo cookies, failing login: %s", e.what());
// FIXME: We should possibly try to decode and pass along a specific error
SmtpSession::SmtpError error;
error.errorCode = MailError::ACCOUNT_UNAVAILABLE;
error.errorOnAccount = true;
error.internalError = std::string("Unable to retrieve yahoo cookies: ") + e.what();
m_session.AuthYahooFailure(error);
Complete();
return MojErrNone;
} catch (...) {
MojLogInfo(m_log, "Failed to retrieve Yahoo cookies, failing login: unknown exception");
// FIXME: We should possibly try to decode and pass along a specific error
SmtpSession::SmtpError error;
error.errorCode = MailError::ACCOUNT_UNAVAILABLE;
error.errorOnAccount = true;
error.internalError = "Unable to retrieve yahoo cookies: unknown exception";
m_session.AuthYahooFailure(error);
Complete();
return MojErrNone;
}
m_state = State_SendingYCookie;
WriteCommand();
return MojErrNone;
}
示例3: MojLogTrace
MojErr OnEnabledHandler::getAccountInfoResult(MojObject& payload, MojErr resultErr)
{
MojLogTrace(IMServiceApp::s_log);
IMServiceHandler::logMojObjectJsonString(_T("OnEnabledHandler::getAccountInfoResult payload: %s"), payload);
if (resultErr != MojErrNone) {
MojLogError(IMServiceApp::s_log, _T("OnEnabledHandler getAccountInfo result error %d"), resultErr);
return resultErr;
}
MojObject result;
MojErr err = payload.getRequired("result", result);
if (err != MojErrNone || result.empty()) {
MojLogError(IMServiceApp::s_log, _T("OnEnabledHandler::getAccountInfoResult result empty or error %d"), err);
return err;
}
MojString accountId;
err = result.getRequired("_id", accountId);
if (err != MojErrNone || accountId.empty()) {
MojLogError(IMServiceApp::s_log, _T("OnEnabledHandler::getAccountInfoResult accountId empty or error %d"), err);
return err;
}
MojString username;
err = result.getRequired("username", username);
if (err != MojErrNone || username.empty()) {
MojLogError(IMServiceApp::s_log, _T("OnEnabledHandler::getAccountInfoResult username empty or error %d"), err);
return err;
}
MojString serviceName;
getServiceNameFromCapabilityId(serviceName);
if (serviceName.empty()) {
MojLogError(IMServiceApp::s_log, _T("OnEnabledHandler::getAccountInfoResult serviceName empty"));
return err;
}
if (m_enable) {
err = accountEnabled(accountId, serviceName, username);
} else {
err = accountDisabled(accountId, serviceName, username);
}
return err;
}
示例4:
MojoObjectJson::MojoObjectJson(const MojObject& obj)
{
MojErr err = obj.toJson(m_str);
/* Intentially ignore err here. This is for debug output, let's not
* make the problem worse... */
(void)err;
}
示例5: MojAssert
MojErr MojDbServiceHandler::handleMerge(MojServiceMessage* msg, MojObject& payload, MojDbReq& req)
{
MojAssert(msg);
MojLogTrace(s_log);
MojErr err = MojErrNone;
MojUInt32 count = 0;
MojObject obj;
if (payload.get(MojDbServiceDefs::ObjectsKey, obj)) {
if (payload.contains(MojDbServiceDefs::QueryKey))
MojErrThrowMsg(MojErrInvalidArg, _T("db: cannot have both an objects param and a query param"));
MojObject::ArrayIterator begin;
bool ignoreM = false;
payload.get(MojDbServiceDefs::IgnoreMissingKey, ignoreM);
MojUInt32 mflags = MojDb::FlagNone;
if (ignoreM)
mflags = mflags | MojDb::FlagIgnoreMissing;
err = obj.arrayBegin(begin);
MojErrCheck(err);
MojObject::ConstArrayIterator end = obj.arrayEnd();
err = m_db.merge(begin, end, mflags, req);
MojErrCheck(err);
err = formatPut(msg, begin, end); // TO DO: we need to drop non-existing objects
MojErrCheck(err);
}
else if (payload.get(MojDbServiceDefs::QueryKey, obj)) {
MojObject props;
err = payload.getRequired(MojDbServiceDefs::PropsKey, props);
MojErrCheck(err);
bool ignoreM = false;
if (payload.get(MojDbServiceDefs::IgnoreMissingKey, ignoreM))
MojErrThrowMsg(MojErrInvalidArg, _T("db: ignoreMissing - invalid option for merge query"));
MojDbQuery query;
err = query.fromObject(obj);
MojErrCheck(err);
MojUInt32 queryCount = 0;
err = m_db.merge(query, props, queryCount, MojDb::FlagNone, req);
MojErrCheck(err);
count += queryCount;
err = formatCount(msg, count);
MojErrCheck(err);
}
else {
MojErrThrowMsg(MojErrInvalidArg, _T("db: either objects or query param required for merge"));
}
return MojErrNone;
}
示例6: LOG_TRACE
void TelephonyProxy::Enable()
{
LOG_TRACE("Entering function %s", __FUNCTION__);
LOG_DEBUG("Enabling TIL Proxy");
MojObject params;
params.putBool(_T("subscribe"), true);
// Start out with a platformQuery
m_platformQuery = boost::make_shared<MojoWeakPtrCall<TelephonyProxy> >(
boost::dynamic_pointer_cast<TelephonyProxy, RequirementManager>
(shared_from_this()),
&TelephonyProxy::PlatformQueryUpdate, m_service,
"palm://com.palm.telephony/platformQuery", params,
MojoCall::Unlimited);
m_platformQuery->Call();
}
示例7: ToJson
MojErr MojoCompareMatcher::ToJson(MojObject& rep, unsigned long flags) const
{
MojErr err;
MojObject compare;
err = compare.put(_T("key"), m_key);
MojErrCheck(err);
err = compare.put(_T("value"), m_value);
MojErrCheck(err);
err = rep.put(_T("compare"), compare);
MojErrCheck(err);
return MojErrNone;
}
示例8: LOG_TRACE
void MojoDBProxy::PreparePurgeCall()
{
LOG_TRACE("Entering function %s", __FUNCTION__);
LOG_DEBUG("Preparing to purge batch of old Activities");
MojObject ids(MojObject::TypeArray);
PopulatePurgeIds(ids);
MojObject params;
params.put(_T("ids"), ids);
m_call = boost::make_shared<MojoWeakPtrCall<MojoDBProxy> >(
boost::dynamic_pointer_cast<MojoDBProxy, PersistProxy>
(shared_from_this()),
&MojoDBProxy::ActivityPurgeComplete,
m_service, "palm://com.palm.db/del", params);
}
示例9: sendEcho
MojErr sendEcho(const MojChar* json, const MojObject& expectedResponse, const MojChar* method)
{
MojRefCountedPtr<EchoResponseHdlr> handler(new EchoResponseHdlr(expectedResponse, ++m_pendingResponseCount));
MojAllocCheck(handler.get());
MojRefCountedPtr<MojServiceRequest> req;
MojErr err = m_service.createRequest(req);
MojTestErrCheck(err);
MojObject payload;
err = payload.fromJson(json);
MojTestErrCheck(err);
err = req->send(handler->m_slot, ServiceName, method, payload);
MojTestErrCheck(err);
return MojErrNone;
}
示例10: put
MojErr MojDbQuotaEngine::put(MojObject& obj, MojDbReq& req, bool putObj)
{
MojLogTrace(s_log);
MojAssertWriteLocked(m_db->schemaLock());
// check for admin permission
if (!req.admin()) {
MojErrThrow(MojErrDbPermissionDenied);
}
// pull params out of object
MojString owner;
MojErr err = obj.getRequired(MojDbServiceDefs::OwnerKey, owner);
MojErrCheck(err);
MojInt64 size = 0;
err = obj.getRequired(MojDbServiceDefs::SizeKey, size);
MojErrCheck(err);
// validate owner
err = validateWildcard(owner, MojErrDbInvalidOwner);
MojErrCheck(err);
// put object
if (putObj) {
MojString id;
err = id.format(_T("_quotas/%s"), owner.data());
MojErrCheck(err);
err = obj.put(MojDb::IdKey, id);
MojErrCheck(err);
err = obj.putString(MojDb::KindKey, MojDbKindEngine::QuotaId);
MojErrCheck(err);
MojDbAdminGuard adminGuard(req);
err = m_db->put(obj, MojDb::FlagForce, req);
MojErrCheck(err);
// defer commit of quota until txn commit
MojRefCountedPtr<MojDbQuotaCommitHandler> handler(new MojDbQuotaCommitHandler(this, owner, size, req.txn()));
MojAllocCheck(handler.get());
} else {
err = commitQuota(owner, size);
MojErrCheck(err);
}
return MojErrNone;
}
示例11: 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);
}
示例12: CommandTraceFunction
MojErr PopAccountUpdateCommand::GetPasswordResponse(MojObject& response, MojErr err)
{
CommandTraceFunction();
try {
// check the result first
ErrorToException(err);
MojObject credentials;
err = response.getRequired("credentials", credentials);
ErrorToException(err);
MojString password;
err = credentials.getRequired("password", password);
ErrorToException(err);
boost::shared_ptr<PopAccount> newPopAccount(new PopAccount());
PopAccountAdapter::GetPopAccountFromTransportObject(m_transportObj, *(newPopAccount.get()));
newPopAccount->SetPassword(password.data());
boost::shared_ptr<PopAccount> oldPopAccount = m_client.GetAccount();
if (!oldPopAccount.get()) {
m_callSyncFolderOnClient = true;
} else if (newPopAccount->GetPort() != oldPopAccount->GetPort() ||
newPopAccount->GetEncryption() != oldPopAccount->GetEncryption() ||
newPopAccount->GetUsername() != oldPopAccount->GetUsername() ||
newPopAccount->GetSyncFrequencyMins() != oldPopAccount->GetSyncWindowDays() ||
newPopAccount->GetHostName() != oldPopAccount->GetHostName()) {
m_callSyncFolderOnClient = true;
}
// Should be initial sync if the old account does not exist
// or the old account is in initial sync state.
newPopAccount->SetInitialSync(!oldPopAccount.get() || oldPopAccount->IsInitialSync());
m_client.SetAccount(newPopAccount);
UpdateAccountWatchActivity();
} catch (const std::exception& ex) {
Failure(ex);
} catch (...) {
Failure(MailException("unknown exception", __FILE__, __LINE__));
}
return MojErrNone;
}
示例13: MojAssert
MojErr MojDbKindState::delIndex(const MojChar* indexName, MojDbReq& req)
{
MojAssert(indexName);
MojThreadGuard guard(m_lock);
MojObject obj;
MojRefCountedPtr<MojDbStorageItem> item;
MojErr err = readIds(IndexIdsKey, req, obj, item);
MojErrCheck(err);
bool found = false;
err = obj.del(indexName, found);
MojErrCheck(err);
MojAssert(found);
err = writeIds(IndexIdsKey, obj, req, item);
MojErrCheck(err);
return MojErrNone;
}
示例14: replySuccess
MojErr MojServiceMessage::replySuccess(MojObject& payload)
{
MojErr err = payload.putBool(ReturnValueKey, true);
MojErrCheck(err);
err = reply(payload);
MojErrCheck(err);
return MojErrNone;
}
示例15: ToJson
MojErr ControlGroup::ToJson(MojObject& rep) const
{
std::string path = GetRoot() + "/" + m_name;
MojErr err = rep.putString(_T("path"), path.c_str());
MojErrCheck(err);
return ResourceContainer::ToJson(rep);
}