Add a GetQuota command for the IMAP QUOTA extension.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40975 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f96f677b90
commit
3f9320c6a2
@ -85,6 +85,20 @@ IMAPFolders::UnsubscribeFolder(const char* folder)
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
IMAPFolders::GetQuota(double& used, double& total)
|
||||
{
|
||||
GetQuotaCommand quotaCommand;
|
||||
status_t status = ProcessCommand("aCommand);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
used = quotaCommand.UsedStorage();
|
||||
total = quotaCommand.TotalStorage();
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
IMAPFolders::_GetAllFolders(StringList& folders)
|
||||
{
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
status_t SubscribeFolder(const char* folder);
|
||||
status_t UnsubscribeFolder(const char* folder);
|
||||
|
||||
status_t GetQuota(double& used, double& total);
|
||||
private:
|
||||
status_t _GetAllFolders(StringList& folders);
|
||||
status_t _GetSubscribedFolders(StringList& folders);
|
||||
|
@ -852,3 +852,56 @@ UnsubscribeCommand::Handle(const BString& response)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
GetQuotaCommand::GetQuotaCommand(const char* mailboxName)
|
||||
:
|
||||
fMailboxName(mailboxName),
|
||||
|
||||
fUsedStorage(-1),
|
||||
fTotalStorage(-1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
BString
|
||||
GetQuotaCommand::Command()
|
||||
{
|
||||
BString command = "GETQUOTA \"";
|
||||
command += fMailboxName;
|
||||
command += "\"";
|
||||
return command;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
GetQuotaCommand::Handle(const BString& response)
|
||||
{
|
||||
if (response.FindFirst("QUOTA") < 0)
|
||||
return false;
|
||||
|
||||
BString data = IMAPParser::ExtractBetweenBrackets(response, "(", ")");
|
||||
IMAPParser::RemovePrimitiveFromLeft(data);
|
||||
fUsedStorage = IMAPParser::RemoveIntegerFromLeft(data);
|
||||
fUsedStorage *= 1024;
|
||||
fTotalStorage = IMAPParser::RemoveIntegerFromLeft(data);
|
||||
fTotalStorage *= 1024;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
double
|
||||
GetQuotaCommand::UsedStorage()
|
||||
{
|
||||
return fUsedStorage;
|
||||
}
|
||||
|
||||
|
||||
double
|
||||
GetQuotaCommand::TotalStorage()
|
||||
{
|
||||
return fTotalStorage;
|
||||
}
|
||||
|
@ -280,4 +280,22 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class GetQuotaCommand : public IMAPCommand {
|
||||
public:
|
||||
GetQuotaCommand(const char* mailboxName = "");
|
||||
|
||||
BString Command();
|
||||
bool Handle(const BString& response);
|
||||
|
||||
double UsedStorage();
|
||||
double TotalStorage();
|
||||
private:
|
||||
BString fMailboxName;
|
||||
|
||||
double fUsedStorage;
|
||||
double fTotalStorage;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // IMAP_HANDLER_H
|
||||
|
Loading…
Reference in New Issue
Block a user