コード例 #1
0
MojErr PopAccountEnableCommand::FindSpecialFoldersResponse(MojObject& response, MojErr err)
{
	CommandTraceFunction();

	PopAccount& account = *m_account.get();

	// Get ids from database response
	MojObject::ObjectVec folderIds;

	// Match up ids
	BOOST_FOREACH(const MojObject& folder, DatabaseAdapter::GetResultsIterators(response)) {
		MojObject id;

		err = folder.getRequired(DatabaseAdapter::ID, id);
		ErrorToException(err);

		folderIds.push(id);
	}
コード例 #2
0
void DeleteLocalEmailsCommand::DeleteLocalEmails(const MojObject::ObjectVec& delEmails)
{
	if (delEmails.size() > 0) {
		//MojLogInfo(m_log, "Deleting %d email(s) from database", delEmails.size());
		m_session.GetDatabaseInterface().DeleteItems(m_deleteLocalEmailsResponseSlot, delEmails);
	} else {
		Complete();
	}
}
コード例 #3
0
void SyncFolderListCommand::DeleteFolders()
{
	CommandTraceFunction();

	MojErr err;
	MojObject::ObjectVec deletedIds;

	MojLogInfo(m_log, "deleting %d folders", m_folderListDiff.GetDeletedFolders().size());
	// Get list of folder ids to delete
	BOOST_FOREACH(const ImapFolderPtr& folder, m_folderListDiff.GetDeletedFolders()) {
		if(boost::iequals(folder->GetFolderName(), ImapFolder::INBOX_FOLDER_NAME)) {
			MojLogError(m_log, "attempted to delete inbox!");
		} else {
			// Delete folder as long as it's not the inbox
			err = deletedIds.push(folder->GetId());
			ErrorToException(err);
		}
	}

	// DeleteFoldersCommands deletes all the specified folders, folders' emails, and watches.
	m_deleteFoldersCommand.reset(new DeleteFoldersCommand(*(m_session.GetClient()), deletedIds));
	m_deleteFoldersCommand->Run(m_deleteFoldersSlot);
}
コード例 #4
0
void MojoDatabase::DeleteItems (Signal::SlotRef slot, const MojObject::ObjectVec& array)
{
	MojErr err = m_dbClient.del(slot, array.begin(), array.end(), MojDb::FlagPurge);
	ErrorToException(err);
}
コード例 #5
0
void MojoDatabase::UpdateItemRevisions(Signal::SlotRef slot, const MojObject::ObjectVec& array)
{
	MojErr err = m_dbClient.merge(slot, array.begin(), array.end());
	ErrorToException(err);
}
コード例 #6
0
void MojoDatabase::AddItems(Signal::SlotRef slot, const MojObject::ObjectVec& array)
{
	MojErr err = m_dbClient.put(slot, array.begin(), array.end());
	ErrorToException(err);
}
コード例 #7
0
void MojoDatabase::GetByIds(Signal::SlotRef slot, const MojObject::ObjectVec& ids)
{
	MojErr err = m_dbClient.get(slot, ids.begin(), ids.end());
	ErrorToException(err);
}
コード例 #8
0
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;
}