void SmtpSyncOutboxCommand::UpdateAccountWatchActivity()
{
	MojLogInfo(m_log, "UpdatingAccountWatchActivity");
	
	try {
		// accoundId json object
		MojString accountIdJson;
		MojErr err = m_accountId.toJson(accountIdJson);
		ErrorToException(err);

		SmtpActivityFactory factory;
		ActivityBuilder ab;

		factory.BuildSmtpConfigWatch(ab, m_accountId, m_accountRev);

		bool updating = m_accountWatchActivity.get();

		// and either update and complete the updated activity if we had adopted it, or re-create it.
		
		if ( updating ) {
			
			MojLogInfo(m_log, "updating account watch activity");
	
			m_accountWatchActivity->SetSlots(m_accountActivityUpdatedSlot, m_accountActivityErrorSlot);
	
			m_accountWatchActivity->UpdateAndComplete(m_client, ab.GetActivityObject());
			
		} else {
			// Create payload
			MojObject payload;
			err = payload.put("activity", ab.GetActivityObject());
			ErrorToException(err);
			err = payload.put("start", true);
			ErrorToException(err);
			err = payload.put("replace", true);
			ErrorToException(err);
				
			MojLogInfo(m_log, "creating account watch activity");
							
			m_client.SendRequest(m_createAccountWatchActivityResponseSlot, "com.palm.activitymanager", "create", payload);
		}

	} catch (std::exception & e) {
		HandleException(e, __func__);
	} catch (...) {
		HandleException(__func__);
	}
}
void SmtpAccountEnableCommand::CreateSmtpConfigWatch()
{
	SmtpActivityFactory factory;
	ActivityBuilder ab;

	factory.BuildSmtpConfigWatch(ab, m_client.GetAccountId(), m_accountRev);

	// Create payload
	MojObject payload;
	MojErr err;

	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_createSmtpConfigWatchSlot, "com.palm.activitymanager", "create", payload);
}