[haiku-commits] r40975 - haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib

  • From: clemens.zeidler@xxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 16 Mar 2011 20:12:30 +0100 (CET)

Author: czeidler
Date: 2011-03-16 20:12:30 +0100 (Wed, 16 Mar 2011)
New Revision: 40975
Changeset: http://dev.haiku-os.org/changeset/40975

Modified:
   
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPFolders.cpp
   
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPFolders.h
   
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.cpp
   
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.h
Log:
Add a GetQuota command for the IMAP QUOTA extension.



Modified: 
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPFolders.cpp
===================================================================
--- 
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPFolders.cpp
 2011-03-16 19:09:19 UTC (rev 40974)
+++ 
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPFolders.cpp
 2011-03-16 19:12:30 UTC (rev 40975)
@@ -86,6 +86,20 @@
 
 
 status_t
+IMAPFolders::GetQuota(double& used, double& total)
+{
+       GetQuotaCommand quotaCommand;
+       status_t status = ProcessCommand(&quotaCommand);
+       if (status != B_OK)
+               return status;
+
+       used = quotaCommand.UsedStorage();
+       total = quotaCommand.TotalStorage();
+       return status;
+}
+
+
+status_t
 IMAPFolders::_GetAllFolders(StringList& folders)
 {
        ListCommand listCommand;

Modified: 
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPFolders.h
===================================================================
--- 
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPFolders.h
   2011-03-16 19:09:19 UTC (rev 40974)
+++ 
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPFolders.h
   2011-03-16 19:12:30 UTC (rev 40975)
@@ -39,6 +39,7 @@
                        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);

Modified: 
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.cpp
===================================================================
--- 
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.cpp
 2011-03-16 19:09:19 UTC (rev 40974)
+++ 
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.cpp
 2011-03-16 19:12:30 UTC (rev 40975)
@@ -852,3 +852,56 @@
 {
        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;
+}

Modified: 
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.h
===================================================================
--- 
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.h
   2011-03-16 19:09:19 UTC (rev 40974)
+++ 
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.h
   2011-03-16 19:12:30 UTC (rev 40975)
@@ -280,4 +280,22 @@
 };
 
 
+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


Other related posts:

  • » [haiku-commits] r40975 - haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib - clemens . zeidler