Prevent from renaming 'INBOX' folder in IMAP (illegal_operation exception).
This commit is contained in:
parent
85dfb65a7f
commit
de09abb036
@ -415,6 +415,22 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** Illegal operation: cannot run this operation on the object.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class illegal_operation : public messaging_exception
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
illegal_operation(const string& msg = "")
|
||||||
|
: messaging_exception(msg.empty()
|
||||||
|
? "Illegal operation."
|
||||||
|
: "Illegal operation: " + msg + "."
|
||||||
|
) {}
|
||||||
|
~illegal_operation() throw() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/** Command error: operation failed (this is specific to the underlying protocol).
|
/** Command error: operation failed (this is specific to the underlying protocol).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1228,6 +1228,8 @@ void IMAPFolder::rename(const folder::path& newPath)
|
|||||||
throw exceptions::illegal_state("Store disconnected");
|
throw exceptions::illegal_state("Store disconnected");
|
||||||
else if (isOpen())
|
else if (isOpen())
|
||||||
throw exceptions::illegal_state("Folder open");
|
throw exceptions::illegal_state("Folder open");
|
||||||
|
else if (m_path.getSize() == 1 && m_name.getBuffer() == "INBOX")
|
||||||
|
throw exceptions::illegal_operation("Cannot rename 'INBOX' folder");
|
||||||
|
|
||||||
// Build the request text
|
// Build the request text
|
||||||
std::ostringstream command;
|
std::ostringstream command;
|
||||||
|
Loading…
Reference in New Issue
Block a user