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


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

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


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

示例1: createDBObject

/**
 * Return MojObject formated to save to MojDb
 * Used for incoming messages
 */
MojErr IMMessage::createDBObject(MojObject& returnObj) {

	MojLogInfo(IMServiceApp::s_log, _T("createMojObject"));

	// Communications kind
	// From/to address is itself a CommunicationsAddress object
	// "name" and "type" properties are optional
	// Sender
	MojObject addressObj;
	MojErr err = addressObj.putString(MOJDB_ADDRESS, fromAddress);
	MojErrCheck(err);
	err = returnObj.put(MOJDB_FROM, addressObj);
	MojErrCheck(err);

	// Recipient
	MojObject recipientArray, recipient;
	err = recipient.put(MOJDB_ADDRESS, toAddress);
	MojErrCheck(err);
	err = recipientArray.push(recipient);
	MojErrCheck(err);
	err = returnObj.put(MOJDB_TO, recipientArray);
	MojErrCheck(err);

	// Message kind
	err = returnObj.putString(MOJDB_FOLDER, folderStrings[folder]);
	MojErrCheck(err);
	err = returnObj.putString(MOJDB_STATUS, statusStrings[status]);
	MojErrCheck(err);

	err = returnObj.putString(MOJDB_MSG_TEXT, msgText);
	MojErrCheck(err);

	// username - since this is incoming message, the username is always in toAddress
	err = returnObj.putString(MOJDB_USERNAME, toAddress);
	MojErrCheck(err);

	// service name
	err = returnObj.putString(MOJDB_SERVICENAME, msgType);
	MojErrCheck(err);

	// localTimestamp
	err = returnObj.putInt(MOJDB_DEVICE_TIMESTAMP, deviceTimestamp);
	MojErrCheck(err);

	// incoming server
	err = returnObj.putInt(MOJDB_SERVER_TIMESTAMP, serverTimestamp);
	MojErrCheck(err);

	IMServiceHandler::privatelogIMMessage(_T("DB Message object %s:"), returnObj, MOJDB_MSG_TEXT);

	return err;
}
开发者ID:dkirker,项目名称:webos-messaging,代码行数:56,代码来源:IMMessage.cpp

示例2: testEnforce

MojErr MojDbQuotaTest::testEnforce(MojDb& db)
{
	// set quota size to current usage
	MojInt64 quotaUsage1 = 0;
	MojErr err = getQuotaUsage(db, _T("com.foo.bar"), quotaUsage1);
	MojTestErrCheck(err);
	MojObject obj;
	err = obj.putString(_T("owner"), _T("com.foo.bar"));
	MojErrCheck(err);
	err = obj.putInt(_T("size"), quotaUsage1);
	MojErrCheck(err);
	err = db.putQuotas(&obj, &obj + 1);
	MojErrCheck(err);
	err = put(db, MojTestKind1Objects[3]);
	MojTestErrExpected(err, MojErrDbQuotaExceeded);
	// Try to delete the kind
	MojString kindStr;
	err = kindStr.assign(_T("Test:1"));
	MojTestErrCheck(err);
	bool found = false;
	err = db.delKind(kindStr, found);

    //The delete should be failure, because it contain sub kind "Test2:1"
    MojTestErrExpected(err,MojErrDbKindHasSubKinds); 
    MojTestAssert(!found); 

	return MojErrNone;
}
开发者ID:rogerjstringer,项目名称:db8,代码行数:28,代码来源:MojDbQuotaTest.cpp

示例3: ScheduleShutdown

void BusClient::ScheduleShutdown()
{
	MojLogTrace(m_log);
	// Reply to the "run" message now that we're done
	if (m_launchedAsService && m_msg.get()) {
		const Configurator::ConfigCollection& ok = Configurator::ConfigureOk();
		const Configurator::ConfigCollection& failed = Configurator::ConfigureFailure();

		if (m_wrongAplication) {
			MojString response;
			response.appendFormat("Aplication or service doesn't exist");
			m_wrongAplication = false;
			m_msg->replyError(MojErrInternal, response.data());

		} else if (!failed.empty()) {
			MojString response;
			response.appendFormat("Partial configuration - %zu ok, %zu failed", ok.size(), failed.size());
			m_msg->replyError(MojErrInternal, response.data());
		} else {
			MojObject response;
			response.putInt("configured", ok.size());
			m_msg->replySuccess(response);
		}
		m_msg.reset();
	}

	if (!m_pending.empty()) {
		MojLogDebug(m_log, "%d pending service calls to handle remaining", m_pending.size());

		// still more pending work
		m_configuratorsCompleted = 0;
		m_configurators.clear();
		Configurator::ResetConfigStats();

		const PendingWork &pending = m_pending.back();
		(pending.instance->*(pending.callback))(pending.msg.get(), pending.payload);

		m_pending.pop_back();
		return;
	}

	MojLogDebug(m_log, "No more pending service calls to handle - scheduling shutdown");

	// Schedule an event to shutdown once the stack is unwound.
	if (m_timerTimeout == 0) {
		// this is to work around around a race condition where the LSCall is delivered
		// after we shutdown causing us to start back up - give some time for the LSCall
		// to get delivered.  NOV-114626.  This needs a proper fix within ls2 (can't be
		// worked around anywhere else).
		m_timerTimeout = g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE, /* timer priority */
		    500, /* timeout in ms */
		    &BusClient::ShutdownCallback, // callback
		    this, /* callback data */
		    NULL /*destroy notify callback*/
		);
	}
	//g_idle_add(&BusClient::ShutdownCallback, this);

	m_shuttingDown = true;
}
开发者ID:feniksa,项目名称:configurator,代码行数:60,代码来源:BusClient.cpp

示例4: CreateRemotePowerActivity

MojErr PowerdPowerActivity::CreateRemotePowerActivity(bool debounce)
{
	LOG_AM_TRACE("Entering function %s", __FUNCTION__);

	MojErr err;
	MojObject params;

	err = params.putString(_T("id"), GetRemotePowerActivityName().c_str());
	MojErrCheck(err);

	int duration;
	if (debounce) {
		duration = PowerActivityDebounceDuration * 1000;
	} else {
		duration = PowerActivityLockDuration * 1000;
	}

	err = params.putInt(_T("duration_ms"), duration);
	MojErrCheck(err);

	m_call = boost::make_shared<MojoWeakPtrCall<PowerdPowerActivity> >(
		boost::dynamic_pointer_cast<PowerdPowerActivity, PowerActivity>(
			shared_from_this()), debounce ?
		&PowerdPowerActivity::PowerUnlockedNotificationDebounce :
		&PowerdPowerActivity::PowerLockedNotification,
		m_service, "palm://com.palm.power/com/palm/power/activityStart",
		params);
	m_call->Call();

	return MojErrNone;
}
开发者ID:ctbrowser,项目名称:activitymanager,代码行数:31,代码来源:PowerdPowerActivity.cpp

示例5: testEnforce

MojErr MojDbQuotaTest::testEnforce(MojDb& db)
{
	// set quota size to current usage
	MojInt64 quotaUsage1 = 0;
	MojErr err = getQuotaUsage(db, _T("com.foo.bar"), quotaUsage1);
	MojTestErrCheck(err);
	MojObject obj;
	err = obj.putString(_T("owner"), _T("com.foo.bar"));
	MojErrCheck(err);
	err = obj.putInt(_T("size"), quotaUsage1);
	MojErrCheck(err);
	err = db.putQuotas(&obj, &obj + 1);
	MojErrCheck(err);
	err = put(db, MojTestKind1Objects[3]);
	MojTestErrExpected(err, MojErrDbQuotaExceeded);
	// make sure we can delete the kind
	MojString kindStr;
	err = kindStr.assign(_T("Test:1"));
	MojTestErrCheck(err);
	bool found = false;
	err = db.delKind(kindStr, found);
	MojTestErrCheck(err);
	MojTestAssert(found);

	return MojErrNone;
}
开发者ID:anttiharju-owo,项目名称:db8,代码行数:26,代码来源:MojDbQuotaTest.cpp

示例6: Failure

void SmtpValidator::Failure(MailError::ErrorCode errorCode, const std::string& errorText)
{
	if (m_timeoutId) {
		g_source_remove(m_timeoutId);
		m_timeoutId = 0;
	}

	MojLogInfo(m_log, "SmtpValidator %p Failure1", this);
	//MojLogInfo(m_log, "SmtpValidator %p Failure1, was trying to connect to %s:%d", this, m_account->GetHostname().c_str(), m_account->GetPort());
	
	MojLogTrace(m_log);

	MojObject reply;
	MojErr err = reply.putBool(MojServiceMessage::ReturnValueKey, false);
	ErrorToException(err);

	std::string accountErrorCode = MailError::GetAccountErrorCode(errorCode);

	err = reply.putString(MojServiceMessage::ErrorCodeKey, accountErrorCode.c_str());
	ErrorToException(err);

	err = reply.putInt("mailErrorCode", errorCode);
	ErrorToException(err);

	err = reply.putString("errorText", errorText.c_str());
	ErrorToException(err);

	if (!m_replied) {
		// if we already replied due to a timeout, don't reply again.
		err = m_msg->reply(reply);
		ErrorToException(err);
		
		m_replied = true;
	}
}
开发者ID:Garfonso,项目名称:app-services,代码行数:35,代码来源:SmtpValidator.cpp

示例7: MojAssertNoErr

TEST_F(QuotaTest, enforce)
{
    MojObject obj;

    // put quota
    MojAssertNoErr( obj.fromJson(_T("{\"owner\":\"com.foo.bar\",\"size\":1000}")) );
    MojAssertNoErr( db.putQuotas(&obj, &obj + 1) );

    // make kind2 inherit from kind1
    MojAssertNoErr( obj.fromJson(MojTestKind2Str3) );
    MojExpectNoErr( db.putKind(obj) );

    //// end of prerequisites form prev tests

    // set quota size to current usage
    MojInt64 quotaUsage1 = 0;
    EXPECT_NO_FATAL_FAILURE( getQuotaUsage(db, _T("com.foo.bar"), quotaUsage1) );
    MojAssertNoErr( obj.putString(_T("owner"), _T("com.foo.bar")) );
    MojAssertNoErr( obj.putInt(_T("size"), quotaUsage1) );
    MojExpectNoErr( db.putQuotas(&obj, &obj + 1) );

    MojAssertNoErr( obj.fromJson(MojTestKind1Objects[3]) );
    EXPECT_EQ( MojErrDbQuotaExceeded, db.put(obj) );

    // Try to delete the kind
    MojString kindStr;
    MojAssertNoErr( kindStr.assign(_T("Test:1")) );
    bool found = false;
    EXPECT_EQ( MojErrDbKindHasSubKinds, db.delKind(kindStr, found) )
        << "The delete should be failure, because it contain sub kind \"Test2:1\"";
    EXPECT_FALSE( found );
}
开发者ID:feniksa,项目名称:indb8,代码行数:32,代码来源:QuotaTest.cpp

示例8: Status

void Command::Status(MojObject& status) const
{
	MojErr err;

	err = status.putString("class", GetClassName().c_str());
	ErrorToException(err);
	err = status.putInt("priority", m_priority);
	ErrorToException(err);
}
开发者ID:Garfonso,项目名称:app-services,代码行数:9,代码来源:Command.cpp

示例9: Status

void SmtpValidator::Status(MojObject& status) const
{
	char buf[64];
	memset(buf, '\0', sizeof(buf));
	snprintf(buf, sizeof(buf)-1, "%p", this);
	MojErr err = status.putString("pointer",buf);;
	ErrorToException(err);

	err = status.putBool("running", m_running);
	ErrorToException(err);
	
	err = status.putString("hostname", m_account->GetHostname().c_str());
	ErrorToException(err);

	err = status.putInt("port", m_account->GetPort());
	ErrorToException(err);

	err = status.putInt("encryption", m_account->GetEncryption());
	ErrorToException(err);
}
开发者ID:Garfonso,项目名称:app-services,代码行数:20,代码来源:SmtpValidator.cpp

示例10: ToJson

MojErr MojoDBPersistToken::ToJson(MojObject& rep) const
{
	MojErr err;

	if (!m_valid) {
		throw std::runtime_error("ID not set");
	}

	err = rep.putString(_T("_id"), m_id);
	MojErrCheck(err);

	err = rep.putInt(_T("_rev"), m_rev);
	MojErrCheck(err);

	return MojErrNone;
}
开发者ID:edwin12345pro,项目名称:activitymanager,代码行数:16,代码来源:MojoDBPersistToken.cpp

示例11: formatErrResponse

	MojErr formatErrResponse(MojErr errExpected, MojObject& objOut)
	{
		MojString errTxt;
		MojErr err = MojErrToString(errExpected, errTxt);
		MojTestErrCheck(err);

		// format expected error return
		err = objOut.putBool(MojServiceMessage::ReturnValueKey, false);
		MojErrCheck(err);
		err = objOut.putInt(MojServiceMessage::ErrorCodeKey, (MojInt64)errExpected);
		MojErrCheck(err);
		err = objOut.putString(MojServiceMessage::ErrorTextKey, errTxt);
		MojErrCheck(err);

		return MojErrNone;
	}
开发者ID:KyleMaas,项目名称:db8,代码行数:16,代码来源:MojLunaServiceTest.cpp

示例12: mergeObj

MojErr MojDbPerfUpdateTest::mergeObj(MojDb& db, MojObject& obj, MojTime& objTime)
{
	MojTime startTime;
	MojTime endTime;

	for (MojUInt64 i = 0; i < numMergeIterations; i++) {
		MojErr err = MojGetCurrentTime(startTime);
		MojTestErrCheck(err);
		err = obj.putInt(_T("newProp"), i);
		MojTestErrCheck(err);
		err = db.merge(obj);
		MojTestErrCheck(err);
		err = MojGetCurrentTime(endTime);
		MojTestErrCheck(err);
		objTime += (endTime - startTime);
		totalTestTime += (endTime - startTime);
	}

	return MojErrNone;
}
开发者ID:KyleMaas,项目名称:db8,代码行数:20,代码来源:MojDbPerfUpdateTest.cpp

示例13: replyError

MojErr MojServiceMessage::replyError(MojErr code, const MojChar* text)
{
	MojAssert(code != MojErrNone && text);

	MojObject payload;
	MojErr err = payload.putBool(ReturnValueKey, false);
	MojErrCheck(err);
	err = payload.putInt(ErrorCodeKey, (MojInt64) code);
	MojErrCheck(err);
	err = payload.putString(ErrorTextKey, text);
	MojErrCheck(err);

	// reset the writer first, then reply with this payload
	err = writer().reset();
	MojErrCheck(err);
	err = reply(payload);
	MojErrCheck(err);

	return MojErrNone;
}
开发者ID:ctbrowser,项目名称:db8,代码行数:20,代码来源:MojServiceMessage.cpp

示例14: accountEnabled

/*
 * Enabling an IM account requires the following
 *     add com.palm.imloginstate.libpurple record
 */
MojErr OnEnabledHandler::accountEnabled(const MojString& accountId, const MojString& serviceName, const MojString& username)
{
	//TODO: first issue a merge in case the account already exists?
	MojLogTrace(IMServiceApp::s_log);
	MojLogInfo(IMServiceApp::s_log, _T("accountEnabled id=%s, serviceName=%s"), accountId.data(), serviceName.data());

	MojObject imLoginState;
	imLoginState.putString(_T("_kind"), IM_LOGINSTATE_KIND);
	imLoginState.put(_T("accountId"), accountId);
	imLoginState.put(_T("serviceName"), serviceName);
	imLoginState.put(_T("username"), username);
	imLoginState.putString(_T("state"), LOGIN_STATE_OFFLINE);
	imLoginState.putInt(_T("availability"), PalmAvailability::ONLINE); //default to online so we automatically login at first
	MojErr err = m_dbClient.put(m_addImLoginStateSlot, imLoginState);
	if (err != MojErrNone) {
		MojString error;
		MojErrToString(err, error);
		MojLogError(IMServiceApp::s_log, _T("OnEnabledHandler db.put() failed: error %d - %s"), err, error.data());
	}

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

示例15: GetImapAccountFromPayload

// Copy fields from createAccount payload into com.palm.imap.account object
void ImapAccountAdapter::GetImapAccountFromPayload(const MojObject& accountObj, const MojObject& payload, MojObject& imapAccount)
{
	MojErr err = imapAccount.putString(ImapAccountAdapter::KIND, ImapAccountAdapter::SCHEMA);
	ErrorToException(err);

	MojObject accountId;
	err = payload.getRequired(ImapAccountAdapter::ACCOUNT_ID, accountId);
	ErrorToException(err);

	err = imapAccount.put(ImapAccountAdapter::ACCOUNT_ID, accountId);
	ErrorToException(err);

	MojObject config;
	err = payload.getRequired(ImapAccountAdapter::CONFIG, config);
	ErrorToException(err);

	MojString username;
	bool hasUsername = false;
	err = config.get(ImapAccountAdapter::USERNAME, username, hasUsername);
	ErrorToException(err);
	if(!hasUsername)
	{
		err = accountObj.getRequired(ImapAccountAdapter::USERNAME, username);
		ErrorToException(err);
	}
	err = imapAccount.put(ImapAccountAdapter::USERNAME, username);
	ErrorToException(err);

	MojString hostname;
	err = config.getRequired(ImapAccountAdapter::HOSTNAME, hostname);
	ErrorToException(err);

	err = imapAccount.put(ImapAccountAdapter::HOSTNAME, hostname);
	ErrorToException(err);

	int port;
	err = config.getRequired(ImapAccountAdapter::PORT, port);
	ErrorToException(err);

	err = imapAccount.put(ImapAccountAdapter::PORT, port);
	ErrorToException(err);

	MojString encryption;
	err = config.getRequired(ImapAccountAdapter::ENCRYPTION, encryption);
	ErrorToException(err);

	err = imapAccount.put(ImapAccountAdapter::ENCRYPTION, encryption);
	ErrorToException(err);

	/* Optional config parameters; fill in with defaults if not provided */

	bool hasSyncFrequency = false;
	int syncFrequencyMins = 0;
	config.get(EmailAccountAdapter::SYNC_FREQUENCY_MINS, syncFrequencyMins, hasSyncFrequency);
	ErrorToException(err);

	err = imapAccount.putInt(EmailAccountAdapter::SYNC_FREQUENCY_MINS,
			hasSyncFrequency ? syncFrequencyMins : DEFAULT_SYNC_FREQUENCY_MINS);
	ErrorToException(err);

	bool hasSyncWindow = false;
	int syncWindow = 0;
	err = config.get(EmailAccountAdapter::SYNC_WINDOW_DAYS, syncWindow, hasSyncWindow);
	ErrorToException(err);

	err = imapAccount.putInt(EmailAccountAdapter::SYNC_WINDOW_DAYS,
			hasSyncWindow ? syncWindow : DEFAULT_SYNC_WINDOW_DAYS);
	ErrorToException(err);
}
开发者ID:Garfonso,项目名称:app-services,代码行数:70,代码来源:ImapAccountAdapter.cpp


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