コード例 #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 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);
}
コード例 #3
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;
}