// Copyright (c) 2010 Martin Knafve / hMailServer.com. // http://www.hmailserver.com #include "stdafx.h" #include "IMAPCommandGetAcl.h" #include "IMAPConnection.h" #include "IMAPSimpleCommandParser.h" #include "IMAPACLHelper.h" #include "IMAPConfiguration.h" #include "../Common/BO/IMAPFolder.h" #ifdef _DEBUG #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) #define new DEBUG_NEW #endif namespace HM { IMAPResult IMAPCommandGetAcl::ExecuteCommand(std::shared_ptr pConnection, std::shared_ptr pArgument) { if (!pConnection->IsAuthenticated()) return IMAPResult(IMAPResult::ResultNo, "Authenticate first"); if (!Configuration::Instance()->GetIMAPConfiguration()->GetUseIMAPACL()) return IMAPResult(IMAPResult::ResultBad, "ACL is not enabled."); std::shared_ptr pParser = std::shared_ptr(new IMAPSimpleCommandParser()); pParser->Parse(pArgument); if (pParser->WordCount() != 2) return IMAPResult(IMAPResult::ResultBad, "MYRIGHTS command requires 1 parameter."); String sOriginalFolderName; String sFolderName; if (pParser->Word(1)->Clammerized()) { sOriginalFolderName = pArgument->Literal(0); sOriginalFolderName = sFolderName; } else { sOriginalFolderName = pParser->Word(1)->Value(); sFolderName = sOriginalFolderName; IMAPFolder::UnescapeFolderString(sFolderName); } std::shared_ptr pFolder = pConnection->GetFolderByFullPath(sFolderName); if (!pFolder) return IMAPResult(IMAPResult::ResultBad, "Folder could not be found."); String sResponse = IMAPACLHelper::CreateACLList(pFolder, sOriginalFolderName); sResponse += pArgument->Tag() + _T(" OK GetAcl complete\r\n"); pConnection->SendAsciiData(sResponse); return IMAPResult(); } }