Added support for RFC-3348 (Child Mailbox extension for IMAP). Renamed FLAG_CHILDREN to FLAG_HAS_CHILDREN.
This commit is contained in:
parent
5607c9b189
commit
e13a9d19bc
@ -97,8 +97,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
enum Flags
|
enum Flags
|
||||||
{
|
{
|
||||||
FLAG_CHILDREN = (1 << 0), /**< Folder contains subfolders. */
|
FLAG_HAS_CHILDREN = (1 << 0), /**< Folder contains subfolders. */
|
||||||
FLAG_NO_OPEN = (1 << 1), /**< Folder cannot be open. */
|
FLAG_NO_OPEN = (1 << 1), /**< Folder cannot be open. */
|
||||||
|
|
||||||
FLAG_UNDEFINED = 9999 /**< Used internally (this should not be returned
|
FLAG_UNDEFINED = 9999 /**< Used internally (this should not be returned
|
||||||
by the type() function). */
|
by the type() function). */
|
||||||
|
@ -540,6 +540,20 @@ bool IMAPConnection::hasCapability(const string& capa)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool IMAPConnection::hasCapability(const string& capa) const
|
||||||
|
{
|
||||||
|
const string normCapa = utility::stringUtils::toUpper(capa);
|
||||||
|
|
||||||
|
for (size_t i = 0, n = m_capabilities.size() ; i < n ; ++i)
|
||||||
|
{
|
||||||
|
if (m_capabilities[i] == normCapa)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void IMAPConnection::invalidateCapabilities()
|
void IMAPConnection::invalidateCapabilities()
|
||||||
{
|
{
|
||||||
m_capabilities.clear();
|
m_capabilities.clear();
|
||||||
|
@ -94,6 +94,7 @@ public:
|
|||||||
void invalidateCapabilities();
|
void invalidateCapabilities();
|
||||||
const std::vector <string> getCapabilities();
|
const std::vector <string> getCapabilities();
|
||||||
bool hasCapability(const string& capa);
|
bool hasCapability(const string& capa);
|
||||||
|
bool hasCapability(const string& capa) const;
|
||||||
|
|
||||||
shared_ptr <security::authenticator> getAuthenticator();
|
shared_ptr <security::authenticator> getAuthenticator();
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ int IMAPFolder::getFlags()
|
|||||||
// Root folder
|
// Root folder
|
||||||
if (m_path.isEmpty())
|
if (m_path.isEmpty())
|
||||||
{
|
{
|
||||||
return (FLAG_CHILDREN | FLAG_NO_OPEN);
|
return (FLAG_HAS_CHILDREN | FLAG_NO_OPEN);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -249,7 +249,7 @@ void IMAPFolder::open(const int mode, bool failIfModeIsNotAvailable)
|
|||||||
(responseData->mailbox_data()->mailbox_flag_list());
|
(responseData->mailbox_data()->mailbox_flag_list());
|
||||||
|
|
||||||
m_flags = IMAPUtils::folderFlagsFromFlags
|
m_flags = IMAPUtils::folderFlagsFromFlags
|
||||||
(responseData->mailbox_data()->mailbox_flag_list());
|
(connection, responseData->mailbox_data()->mailbox_flag_list());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -502,7 +502,7 @@ int IMAPFolder::testExistAndGetType()
|
|||||||
(mailboxData->mailbox_list()->mailbox_flag_list());
|
(mailboxData->mailbox_list()->mailbox_flag_list());
|
||||||
|
|
||||||
m_flags = IMAPUtils::folderFlagsFromFlags
|
m_flags = IMAPUtils::folderFlagsFromFlags
|
||||||
(mailboxData->mailbox_list()->mailbox_flag_list());
|
(m_connection, mailboxData->mailbox_list()->mailbox_flag_list());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -742,7 +742,7 @@ std::vector <shared_ptr <folder> > IMAPFolder::getFolders(const bool recursive)
|
|||||||
|
|
||||||
v.push_back(make_shared <IMAPFolder>(path, store,
|
v.push_back(make_shared <IMAPFolder>(path, store,
|
||||||
IMAPUtils::folderTypeFromFlags(mailbox_flag_list),
|
IMAPUtils::folderTypeFromFlags(mailbox_flag_list),
|
||||||
IMAPUtils::folderFlagsFromFlags(mailbox_flag_list)));
|
IMAPUtils::folderFlagsFromFlags(m_connection, mailbox_flag_list)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1811,6 +1811,10 @@ public:
|
|||||||
m_type = NOSELECT;
|
m_type = NOSELECT;
|
||||||
else if (name == "unmarked")
|
else if (name == "unmarked")
|
||||||
m_type = UNMARKED;
|
m_type = UNMARKED;
|
||||||
|
else if (name == "haschildren")
|
||||||
|
m_type = HASCHILDREN;
|
||||||
|
else if (name == "hasnochildren")
|
||||||
|
m_type = HASNOCHILDREN;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_type = UNKNOWN;
|
m_type = UNKNOWN;
|
||||||
@ -1833,6 +1837,11 @@ public:
|
|||||||
|
|
||||||
enum Type
|
enum Type
|
||||||
{
|
{
|
||||||
|
// RFC-3348 - Child Mailbox Extension
|
||||||
|
HASCHILDREN,
|
||||||
|
HASNOCHILDREN,
|
||||||
|
|
||||||
|
// Standard mailbox flags
|
||||||
UNKNOWN,
|
UNKNOWN,
|
||||||
MARKED,
|
MARKED,
|
||||||
NOINFERIORS,
|
NOINFERIORS,
|
||||||
|
@ -386,10 +386,16 @@ int IMAPUtils::folderTypeFromFlags(const IMAPParser::mailbox_flag_list* list)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int IMAPUtils::folderFlagsFromFlags(const IMAPParser::mailbox_flag_list* list)
|
int IMAPUtils::folderFlagsFromFlags
|
||||||
|
(shared_ptr <const IMAPConnection> cnt, const IMAPParser::mailbox_flag_list* list)
|
||||||
{
|
{
|
||||||
// Get folder flags
|
int folderFlags = 0;
|
||||||
int folderFlags = folder::FLAG_CHILDREN;
|
|
||||||
|
// If CHILDREN extension (RFC-3348) is not supported, assume folder has children
|
||||||
|
// as we have no hint about it
|
||||||
|
if (!cnt->hasCapability("CHILDREN"))
|
||||||
|
folderFlags |= folder::FLAG_HAS_CHILDREN;
|
||||||
|
|
||||||
const std::vector <IMAPParser::mailbox_flag*>& flags = list->flags();
|
const std::vector <IMAPParser::mailbox_flag*>& flags = list->flags();
|
||||||
|
|
||||||
for (std::vector <IMAPParser::mailbox_flag*>::const_iterator it = flags.begin() ;
|
for (std::vector <IMAPParser::mailbox_flag*>::const_iterator it = flags.begin() ;
|
||||||
@ -398,7 +404,11 @@ int IMAPUtils::folderFlagsFromFlags(const IMAPParser::mailbox_flag_list* list)
|
|||||||
if ((*it)->type() == IMAPParser::mailbox_flag::NOSELECT)
|
if ((*it)->type() == IMAPParser::mailbox_flag::NOSELECT)
|
||||||
folderFlags |= folder::FLAG_NO_OPEN;
|
folderFlags |= folder::FLAG_NO_OPEN;
|
||||||
else if ((*it)->type() == IMAPParser::mailbox_flag::NOINFERIORS)
|
else if ((*it)->type() == IMAPParser::mailbox_flag::NOINFERIORS)
|
||||||
folderFlags &= ~folder::FLAG_CHILDREN;
|
folderFlags &= ~folder::FLAG_HAS_CHILDREN;
|
||||||
|
else if ((*it)->type() == IMAPParser::mailbox_flag::HASNOCHILDREN)
|
||||||
|
folderFlags &= ~folder::FLAG_HAS_CHILDREN;
|
||||||
|
else if ((*it)->type() == IMAPParser::mailbox_flag::HASCHILDREN)
|
||||||
|
folderFlags |= folder::FLAG_HAS_CHILDREN;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (folderFlags);
|
return (folderFlags);
|
||||||
|
@ -67,7 +67,9 @@ public:
|
|||||||
static const string quoteString(const string& text);
|
static const string quoteString(const string& text);
|
||||||
|
|
||||||
static int folderTypeFromFlags(const IMAPParser::mailbox_flag_list* list);
|
static int folderTypeFromFlags(const IMAPParser::mailbox_flag_list* list);
|
||||||
static int folderFlagsFromFlags(const IMAPParser::mailbox_flag_list* list);
|
static int folderFlagsFromFlags
|
||||||
|
(shared_ptr <const IMAPConnection> cnt,
|
||||||
|
const IMAPParser::mailbox_flag_list* list);
|
||||||
|
|
||||||
static int messageFlagsFromFlags(const IMAPParser::flag_list* list);
|
static int messageFlagsFromFlags(const IMAPParser::flag_list* list);
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ int maildirFolder::getFlags()
|
|||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
if (m_store.lock()->getFormat()->folderHasSubfolders(m_path))
|
if (m_store.lock()->getFormat()->folderHasSubfolders(m_path))
|
||||||
flags |= FLAG_CHILDREN; // Contains at least one sub-folder
|
flags |= FLAG_HAS_CHILDREN; // Contains at least one sub-folder
|
||||||
|
|
||||||
return (flags);
|
return (flags);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user