Example #1
0
    void checkMarkWithUpdate(MojUInt32 expect = 50ul, int mark = -1, MojDbReqRef req = MojDbReq())
    {
        MojDbQuery query;
        MojAssertNoErr( query.from(_T("Test:1")) );
        MojAssertNoErr( query.where(_T("bar"), MojDbQuery::OpEq, mark) );

        MojObject update;

        MojUInt32 count = (MojUInt32)(-1);
        MojAssertNoErr( db.merge(query, MojObject(), count, MojDb::FlagNone, req) );
        EXPECT_EQ( expect, count );
    }
Example #2
0
	MojErr stopService()
	{
		MojRefCountedPtr<MojServiceRequest> req;
		MojErr err = m_service.createRequest(req);
		MojTestErrCheck(err);
		MojObject expected;
		MojRefCountedPtr<EchoResponseHdlr> handler(new EchoResponseHdlr(expected, ++m_pendingResponseCount));
		MojAllocCheck(handler.get());
		err = req->send(handler->m_slot, ServiceName, _T("shutdown"), MojObject(MojObject::TypeObject));
		MojTestErrCheck(err);

		return MojErrNone;

	}
MojErr MojoExclusiveTrigger::ToJson(boost::shared_ptr<const Activity> activity,
                                    MojObject& rep, unsigned flags) const
{
    if (flags & ACTIVITY_JSON_CURRENT) {
        if (IsTriggered(activity)) {
            rep = m_response;
        } else {
            rep = MojObject(false);
        }

        return MojErrNone;
    } else {
        return MojoTrigger::ToJson(activity, rep, flags);
    }
}
void ConnectionManagerProxy::UpdateConfidenceRequirements(
	boost::shared_ptr<RequirementCore> *confidenceCores,
	RequirementList *confidenceLists, int confidence)
{
	if (((confidence < 0) || (confidence >= ConnectionConfidenceMax)) &&
		(confidence != ConnectionConfidenceUnknown)) {
		LOG_WARNING(MSGID_UNKNOWN_CONN_CONFIDENCE_LEVEL, 1, PMLOGKFV("conn_confidence_level","%d",confidence),
			    "Unknown connection confidence level seen attempting to update confidence requirements");
		return;
	}

	MojString& confidenceName = (confidence == ConnectionConfidenceUnknown) ?
		ConnectionConfidenceUnknownName :
		ConnectionConfidenceNames[confidence];

	for (int i = 0; i < ConnectionConfidenceMax; ++i) {
		confidenceCores[i]->SetCurrentValue(MojObject(confidenceName));

		if (confidence < i) {
			if (confidenceCores[i]->IsMet()) {
				confidenceCores[i]->Unmet();
				std::for_each(confidenceLists[i].begin(),
					confidenceLists[i].end(),
					boost::mem_fn(&Requirement::Unmet));
			} else {
				std::for_each(confidenceLists[i].begin(),
					confidenceLists[i].end(),
					boost::mem_fn(&Requirement::Updated));
			}
		} else {
			if (!confidenceCores[i]->IsMet()) {
				confidenceCores[i]->Met();
				std::for_each(confidenceLists[i].begin(),
					confidenceLists[i].end(),
					boost::mem_fn(&Requirement::Met));
			} else {
				std::for_each(confidenceLists[i].begin(),
					confidenceLists[i].end(),
					boost::mem_fn(&Requirement::Updated));
			}
		}
	}
}
MojErr MovePopEmailsCommand::GetEmailsToMoveResponse(MojObject& response, MojErr err)
{
	try {
		ErrorToException(err);

		MojLogInfo(m_log, "response to get emails to move: %s", AsJsonString(response).c_str());

		MojObject results;
		err = response.getRequired(_T("results"), results);
		ErrorToException(err);

		MojObject::ObjectVec movedEmails;
		PopClient::AccountPtr account = m_client.GetAccount();

		for (MojObject::ConstArrayIterator it = results.arrayBegin(); it != results.arrayEnd(); it++) {
			MojObject singleMovedEmail;

			MojObject id;
			err = it->getRequired(PopEmailAdapter::ID, id);
			ErrorToException(err);
			MojObject srcFolderId;
			err = it->getRequired(EmailSchema::FOLDER_ID, srcFolderId);
			ErrorToException(err);
			MojObject destFolderId;
			err = it->getRequired("destFolderId", destFolderId);
			ErrorToException(err);
			MojObject flags;
			err = it->getRequired("flags", flags);
			ErrorToException(err);

			// set to be visible
			err = flags.put("visible", true);
			ErrorToException(err);

			// setup moved email, push onto moved emails vector
			err = singleMovedEmail.put(PopEmailAdapter::ID, id);
			ErrorToException(err);
			err = singleMovedEmail.put("folderId", destFolderId);
			ErrorToException(err);
			err = singleMovedEmail.put("destFolderId", MojObject());
			ErrorToException(err);
			err = singleMovedEmail.put("flags", flags);
			ErrorToException(err);
			// add emails to be moved into 'movedEmails' list
			movedEmails.push(singleMovedEmail);

			if (account->GetInboxFolderId() == srcFolderId) {
				// add moved inbox emails inot 'm_inboxEmailsMoved' set
				MojString uid;
				err = it->getRequired(PopEmailAdapter::SERVER_UID, uid);
				ErrorToException(err);

				m_inboxEmailsMoved.insert(std::string(uid));
			}
		}

		m_client.GetDatabaseInterface().UpdateItems(m_emailsMovedSlot, movedEmails);
	} catch (const std::exception& ex) {
		m_msg->replyError(MojErrInternal, ex.what());
		Failure(ex);
	} catch (...) {
		m_msg->replyError(MojErrInternal);
		Failure(MailException("unknown exception", __FILE__, __LINE__));
	}

	return MojErrNone;
}