当前位置: 首页>>代码示例>>C++>>正文


C++ MojObject::toJson方法代码示例

本文整理汇总了C++中MojObject::toJson方法的典型用法代码示例。如果您正苦于以下问题:C++ MojObject::toJson方法的具体用法?C++ MojObject::toJson怎么用?C++ MojObject::toJson使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MojObject的用法示例。


在下文中一共展示了MojObject::toJson方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

MojErr PopBusDispatcher::AccountCreator::CreatePopAccountResponse(MojObject& response, MojErr err)
{
	MojLogInfo(m_log, "AccountCreator::CreatePopAccountResponse");

	MojLogTrace(m_log);
	if (err)
		return m_msg->replyError(err);

	MojString json;
	err = response.toJson(json);
	MojLogInfo(m_log, "%s", json.data());

	// put the id we have just gotten into the payload we send to smtp account
	MojObject resultArray;
	err = response.getRequired("results", resultArray);
	ErrorToException(err);
	MojObject result;
	resultArray.at(0, result);
	MojObject mailAccountId;
	err = result.getRequired("id", mailAccountId);
	ErrorToException(err);
	err = m_payload.put("mailAccountId", mailAccountId);
	ErrorToException(err);

	MojObject accountId;
	err = m_payload.getRequired("accountId", accountId);
	ErrorToException(err);

	ClientPtr client = m_dispatcher.GetOrCreateClient(accountId);
	client->SendRequest(m_smtpAccountCreatedSlot, "com.palm.smtp", "accountCreated", m_payload);

	return MojErrNone;
}
开发者ID:Garfonso,项目名称:app-services,代码行数:33,代码来源:PopBusDispatcher.cpp

示例2: CredentialsChanged

MojErr PopBusDispatcher::CredentialsChanged(MojServiceMessage* msg, MojObject& payload)
{
	// cancel shut down if it is in shut down state
	CancelShutdown();

	MojLogTrace(s_log);

	MojString json;
	MojErr err = payload.toJson(json);
	ErrorToException(err);
	MojLogInfo(s_log, "PopBusDispatcher::CredentialsChanged: payload=%s", json.data());

	MojObject accountId;
	err = payload.getRequired("accountId", accountId);
	ErrorToException(err);

	try {
		ClientPtr client = GetOrCreateClient(accountId);
		// Calling UpdateAccount will force a folder sync.
		client->UpdateAccount(payload, true);
	} catch (const std::exception& e) {
		MojErrThrowMsg(MojErrInternal, "%s", e.what());
	}

	return msg->replySuccess();
}
开发者ID:Garfonso,项目名称:app-services,代码行数:26,代码来源:PopBusDispatcher.cpp

示例3: saveNewIMMessage

/*
 * Save the new incoming IM message to the DB
 *
 * @return MojErr if error - caller will log it
 */
MojErr IncomingIMHandler::saveNewIMMessage(MojRefCountedPtr<IMMessage> IMMessage) {

	MojErr err;

	// The message we are handling
	m_IMMessage = IMMessage;

	// save it
	MojObject dbObject;
	err = m_IMMessage->createDBObject(dbObject);
	MojErrCheck(err);

	//add our kind to the object
	//luna://com.palm.db/put '{"objects":[{"_kind":"com.palm.test:1","foo":1,"bar":1000}]}'
	err = dbObject.putString(_T("_kind"), PALM_DB_IMMESSAGE_KIND);
	MojErrCheck(err);

	// log it - OK to show body in debug log
	MojString json;
	err = dbObject.toJson(json);
	MojErrCheck(err);
	MojLogDebug(IMServiceApp::s_log, _T("saving message to db: %s"), json.data());
	MojLogInfo(IMServiceApp::s_log, _T("saving message to db"));

	// save it
	// the save generates a call to the save result handler
	err = m_dbClient.put(this->m_IMSaveMessageSlot, dbObject);
	MojErrCheck(err);

	return MojErrNone;
}
开发者ID:wosigh,项目名称:messaging-plugins,代码行数:36,代码来源:IncomingIMHandler.cpp

示例4: findBuddyResult

/*
 * Result of query for buddy with given username and serviceName
 *
 * If the buddy is found, we can send no matter what. If buddy is not found, we need to check if this service allows sending IM messages
 * to non buddies (gtalk does not allow this, aol does)
 */
MojErr SendOneMessageHandler::findBuddyResult(MojObject& result, MojErr findErr)
{

	if (findErr) {

		MojString error;
		MojErrToString(findErr, error);
		MojLogError(IMServiceApp::s_log, _T("findBuddyResult: error %d - %s"), findErr, error.data());
		// not much we can do here...
		failMessage(ERROR_SEND_GENERIC_ERROR);

	} else {

		// log the results
		MojString mojStringJson;
		result.toJson(mojStringJson);
		MojLogDebug(IMServiceApp::s_log, _T("findBuddyResult result: %s"), mojStringJson.data());

		// "results" in result
		MojObject results;
		result.get(_T("results"), results);

		// check to see if array is empty - there should really always be 0 or 1 item here
		if (!results.empty()){

			// buddy is on the list - send to the transport
			MojLogInfo(IMServiceApp::s_log, _T("findBuddyResult - user is on buddy list. No need to check account template."));
			sendToTransport();
		}
		else {
			MojLogInfo(IMServiceApp::s_log, _T("findBuddyResult - no buddy found. Need to check account template if this is allowed"));

			// check palm://com.palm.service.accounts/listAccountTemplates {"capability":"MESSAGING"} to get a list of account templates that support messaging.
			// If the account template includes "chatWithNonBuddies":false, it should fail to send.
			MojLogInfo(IMServiceApp::s_log, "Issuing listAccountTemplates request to com.palm.service.accounts");

			// parameters: {“capability”:”MESSAGING”}
			MojObject params;
			params.putString("capability", "MESSAGING");

			// Get a request object from the service
			MojRefCountedPtr<MojServiceRequest> req;
			MojErr err = m_service->createRequest(req);

			if (!err) {
				err = req->send(m_listAccountSlot, "com.palm.service.accounts", "listAccountTemplates", params);
			}

			if (err) {
				MojString error;
				MojErrToString(err, error);
				MojLogError(IMServiceApp::s_log, _T("findBuddyResult failed to send request to accounts: error %d - %s"), err, error.data());
				// not much we can do here...don't leave message still pending
				failMessage(ERROR_SEND_GENERIC_ERROR);
			}
		}
	}

	return MojErrNone;
}
开发者ID:ChrisPHL,项目名称:webos-messaging,代码行数:66,代码来源:SendOneMessageHandler.cpp

示例5:

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;
}
开发者ID:edwin12345pro,项目名称:activitymanager,代码行数:8,代码来源:MojoObjectWrapper.cpp

示例6: handleKindsList

MojErr KindsModel::handleKindsList(MojObject& result, MojErr errCode)
{
	MojString str;
	result.toJson(str);

	result.getRequired(_T("results"))

	return MojErrNone;
}
开发者ID:feniksa,项目名称:mojoview,代码行数:9,代码来源:KindsModel.cpp

示例7: logMojObjectJsonString

/**
 * Log the json for a MojObject - useful for debugging
 */
MojErr IMServiceHandler::logMojObjectJsonString(const MojChar* format, const MojObject mojObject) {

	if (IMServiceApp::s_log.level() <= MojLogger::LevelInfo) {
		MojString mojStringJson;
		mojObject.toJson(mojStringJson);
		MojLogInfo(IMServiceApp::s_log, format, mojStringJson.data());
	}

	return MojErrNone;
}
开发者ID:wosigh,项目名称:messaging-plugins,代码行数:13,代码来源:IMServiceHandler.cpp

示例8: MojErrCheck

MojErr MojDbSearchCache::QueryKey::setQuery(const MojDbQuery& query)
{
    MojObject obj;
    MojErr err = query.toObject(obj);
    MojErrCheck(err);

    bool foundOut=false;
    obj.del(MojDbQuery::PageKey, foundOut);
    obj.del(MojDbQuery::LimitKey, foundOut);

    err = obj.toJson(m_query);
    MojErrCheck(err);

    setKind(query.from());
    return err;
}
开发者ID:ctbrowser,项目名称:db8,代码行数:16,代码来源:MojDbSearchCache.cpp

示例9: echo

	MojErr echo(MojServiceMessage* msg, const MojObject& payload)
	{
		MojString echoStr;
		MojErr err = payload.toJson(echoStr);
		MojTestErrCheck(err);

		MojObject response;
		err = response.putBool(MojServiceMessage::ReturnValueKey, true);
		MojTestErrCheck(err);
		err = response.putString(_T("echo"), echoStr);
		MojTestErrCheck(err);

		err = msg->reply(response);
		MojTestErrCheck(err);
		return MojErrNone;
	}
开发者ID:KyleMaas,项目名称:db8,代码行数:16,代码来源:MojLunaServiceTest.cpp

示例10: findAccountIdForAddResult

/*
 * Result of query for loginState entry with given username and serviceName when adding a buddy
 *
 * Save buddy in buddyStatus and contact DB
 */
MojErr SendOneCommandHandler::findAccountIdForAddResult(MojObject& result, MojErr findErr)
{

	if (findErr) {

		MojString error;
		MojErrToString(findErr, error);
		MojLogError(IMServiceApp::s_log, _T("findAccountIdResult failed: error %d - %s"), findErr, error.data());

	} else {

		// parse out the accountId
		readAccountIdFromResults(result);

		if (!m_accountId.empty()){
			MojObject buddyStatus;
			buddyStatus.putString("_kind", IM_BUDDYSTATUS_KIND);
			buddyStatus.put("accountId", m_accountId);
			buddyStatus.put("username", m_buddyName);
			buddyStatus.put("serviceName", m_serviceName);

			// log it
			MojString json;
			buddyStatus.toJson(json);
			MojLogInfo(IMServiceApp::s_log, _T("saving buddy status to db: %s"), json.data());

			// save it
			// the save generates a call to the save result handler
			MojErr err = m_tempdbClient.put(m_addBuddySlot, buddyStatus);
			if (err) {
				MojString error;
				MojErrToString(err, error);
				MojLogError(IMServiceApp::s_log, _T("findAccountIdResult: dbClient.put() failed: error %d - %s"), err, error.data());
				// tell the outgoing Command handler we are done
				m_outgoingIMHandler->messageFinished();
			}
		}
		else {
			MojLogError(IMServiceApp::s_log, _T("findAccountIdResult: no matching loginState record found for %s %s"), m_username.data(), m_serviceName.data());
			// tell the outgoing Command handler we are done
			m_outgoingIMHandler->messageFinished();
		}
	}

	return MojErrNone;
}
开发者ID:wosigh,项目名称:messaging-plugins,代码行数:51,代码来源:SendOneCommandHandler.cpp

示例11: imSaveCommandResult

/*
 * Callback for DB save results
 *
 * Status change to "waiting-for-connection"
 */
MojErr SendOneCommandHandler::imSaveCommandResult(MojObject& result, MojErr saveErr)
{
	MojLogTrace(IMServiceApp::s_log);

	if (saveErr) {
		MojString error;
		MojErrToString(saveErr, error);
		MojLogError(IMServiceApp::s_log, _T("save imcommand failed. error %d - %s"), saveErr, error.data());
	}
	else {
		MojString json;
		result.toJson(json);
		MojLogInfo(IMServiceApp::s_log, _T("save imcommand %s. response: %s"), this->m_currentCmdDbId.data(), json.data());
	}

	return MojErrNone;
}
开发者ID:wosigh,项目名称:messaging-plugins,代码行数:22,代码来源:SendOneCommandHandler.cpp

示例12: ResetErrorResponse

MojErr SmtpSyncOutboxCommand::ResetErrorResponse(MojObject& response, MojErr err)
{
	try {
		ResponseToException(response, err);

		MojString json;
		response.toJson(json);		
		MojLogInfo(m_log, "SmtpSyncOutboxCommand::ResetErrorResponse got response to updating error status, payload=%s", json.data());
	
		GetOutboxEmails();

	} catch (std::exception & e) {
		HandleException(e, __func__);
	} catch (...) {
		HandleException(__func__);
	}

	return MojErrNone;
}
开发者ID:Garfonso,项目名称:app-services,代码行数:19,代码来源:SmtpSyncOutboxCommand.cpp

示例13: CreateActivityResponse

MojErr PopAccountUpdateCommand::CreateActivityResponse(MojObject& response, MojErr err)
{
	CommandTraceFunction();
	try {
		ErrorToException(err);

		MojString json;
		err = response.toJson(json);
		ErrorToException(err);

		Sync();
	} catch (const std::exception& ex) {
		Failure(ex);
	} catch (...) {
		Failure(MailException("unknown exception", __FILE__, __LINE__));
	}

	return MojErrNone;
}
开发者ID:Garfonso,项目名称:app-services,代码行数:19,代码来源:PopAccountUpdateCommand.cpp

示例14: RunImpl

void SmtpAccountDisableCommand::RunImpl()
{
	MojLogInfo(m_log, "SmtpAccountDisable clearing session account");
	
	m_client.GetSession()->ClearAccount();
	
	MojLogInfo(m_log, "SmtpAccountDisable removing watch");
	
	MojObject payload;
	
	payload.put("activityName", m_outboxWatchActivityName);

	MojString json;
	payload.toJson(json);

	MojLogInfo(m_log, "SmtpAccountDisable payload %s", json.data());

	m_client.SendRequest(m_deleteOutboxWatchResponseSlot, "com.palm.activitymanager", "cancel", payload);
}
开发者ID:hatsada1,项目名称:app-services,代码行数:19,代码来源:SmtpAccountDisableCommand.cpp

示例15: readAccountIdFromResults

/*
 * Parse the account id from the results object for the accountId query
 * saved in m_accountId member variable
 *
 */
MojErr SendOneMessageHandler::readAccountIdFromResults(MojObject& result)
{
	// log the results
	MojString mojStringJson;
	result.toJson(mojStringJson);
	MojLogDebug(IMServiceApp::s_log, _T("readAccountIdFromResults result: %s"), mojStringJson.data());

	// "results" in result
	MojObject results;
	result.get(_T("results"), results);

	// check to see if array is empty - there should really always be 1 item here
	if (!results.empty()){

		// get the db id of the buddy
		MojObject loginState;
		MojObject::ConstArrayIterator itr = results.arrayBegin();
		bool foundOne = false;
		while (itr != results.arrayEnd()) {
			if (foundOne) {
				MojLogError(IMServiceApp::s_log,
						_T("readAccountIdFromResults: found more than one ImLoginState with same username/serviceName - using the first one"));
				break;
			}
			loginState = *itr;
			foundOne = true;
			itr++;
		}

		// create the DB object
		MojErr err = loginState.getRequired("accountId", m_accountId);
		if (err) {
			MojLogError(IMServiceApp::s_log, _T("readAccountIdFromResults: missing accountId in loginState entry"));
		}
		MojLogInfo(IMServiceApp::s_log, _T("readAccountIdFromResults - accountId: %s. "), m_accountId.data());
	}
	else {
		MojLogError(IMServiceApp::s_log, _T("readAccountIdFromResults: no matching loginState record found for %s"), m_serviceName.data());
	}

	return MojErrNone;
}
开发者ID:ChrisPHL,项目名称:webos-messaging,代码行数:47,代码来源:SendOneMessageHandler.cpp


注:本文中的MojObject::toJson方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。