#include "__imapflag.h" #include "Exception.h" #include "__imap.h" #include namespace jet { __imapflag::__imapflag(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) { coreutils::MString sessionId = resolveKeyword("sessionid"); if (!global.imapSessionExists(sessionId)) throw coreutils::Exception("imap sessionid does not exist.", __FILE__, __LINE__, 502); std::string folder = resolveKeyword("folder").str(); if (folder.empty()) folder = "INBOX"; if (!keywordDefined("uid")) throw coreutils::Exception("imapflag tag must have uid defined.", __FILE__, __LINE__, 400); uint32_t uid = (uint32_t)strtoul(resolveKeyword("uid").str().c_str(), nullptr, 10); if (!keywordDefined("flag")) throw coreutils::Exception("imapflag tag must have flag defined.", __FILE__, __LINE__, 400); std::string flag = resolveKeyword("flag").str(); std::string setStr = resolveKeyword("set").str(); bool add = setStr.empty() || setStr == "yes" || setStr == "true"; out = global.getImapSession(sessionId)->setFlag(folder, uid, flag, add); } }