diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/IMAPFolderConfig.cpp b/src/add-ons/mail_daemon/inbound_protocols/imap/IMAPFolderConfig.cpp index 70e1d4cee5..214730d1c8 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/IMAPFolderConfig.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/IMAPFolderConfig.cpp @@ -39,14 +39,6 @@ protected: }; -EditableListItem::EditableListItem() - : - fListView(NULL) -{ - -} - - class CheckBoxItem : public BStringItem, public EditableListItem { public: CheckBoxItem(const char* text, bool checked); @@ -65,6 +57,67 @@ private: }; +class EditListView : public BListView { +public: + EditListView(const char* name, + list_view_type type + = B_SINGLE_SELECTION_LIST, + uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS + | B_NAVIGABLE); + + virtual void MouseDown(BPoint where); + virtual void MouseUp(BPoint where); + virtual void FrameResized(float newWidth, float newHeight); + +private: + EditableListItem* fLastMouseDown; +}; + + +class StatusWindow : public BWindow { +public: + StatusWindow(const char* text) + : + BWindow(BRect(0, 0, 10, 10), B_TRANSLATE("status"), B_MODAL_WINDOW_LOOK, + B_MODAL_APP_WINDOW_FEEL, B_NO_WORKSPACE_ACTIVATION | B_NOT_ZOOMABLE + | B_AVOID_FRONT | B_NOT_RESIZABLE) + { + BView* rootView = new BView(Bounds(), "root", B_FOLLOW_ALL, + B_WILL_DRAW); + AddChild(rootView); + rootView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + float spacing = be_control_look->DefaultItemSpacing(); + BALMLayout* layout = new BALMLayout(spacing); + rootView->SetLayout(layout); + layout->SetInset(spacing); + + BStringView* string = new BStringView("text", text); + layout->AddView(string, layout->Left(), layout->Top(), layout->Right(), + layout->Bottom()); + BSize min = layout->MinSize(); + ResizeTo(min.Width(), min.Height()); + CenterOnScreen(); + } +}; + + +const uint32 kMsgApplyButton = '&Abu'; +const uint32 kMsgInit = '&Ini'; + + +// #pragma mark - + + +EditableListItem::EditableListItem() + : + fListView(NULL) +{ + +} + + +// #pragma mark - + CheckBoxItem::CheckBoxItem(const char* text, bool checked) : @@ -134,21 +187,7 @@ CheckBoxItem::MouseUp(BPoint where) } -class EditListView : public BListView { -public: - EditListView(const char* name, - list_view_type type - = B_SINGLE_SELECTION_LIST, - uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS - | B_NAVIGABLE); - - virtual void MouseDown(BPoint where); - virtual void MouseUp(BPoint where); - virtual void FrameResized(float newWidth, float newHeight); - -private: - EditableListItem* fLastMouseDown; -}; +// #pragma mark - EditListView::EditListView(const char* name, list_view_type type, uint32 flags) @@ -156,7 +195,7 @@ EditListView::EditListView(const char* name, list_view_type type, uint32 flags) BListView(name, type, flags), fLastMouseDown(NULL) { - + } @@ -201,42 +240,14 @@ EditListView::FrameResized(float newWidth, float newHeight) } -class StatusWindow : public BWindow { -public: - StatusWindow(const char* text) - : - BWindow(BRect(0, 0, 10, 10), B_TRANSLATE("status"), B_MODAL_WINDOW_LOOK, - B_MODAL_APP_WINDOW_FEEL, B_NO_WORKSPACE_ACTIVATION | B_NOT_ZOOMABLE - | B_AVOID_FRONT | B_NOT_RESIZABLE) - { - BView* rootView = new BView(Bounds(), "root", B_FOLLOW_ALL, - B_WILL_DRAW); - AddChild(rootView); - rootView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - float spacing = be_control_look->DefaultItemSpacing(); - BALMLayout* layout = new BALMLayout(spacing); - rootView->SetLayout(layout); - layout->SetInset(spacing); - - BStringView* string = new BStringView("text", text); - layout->AddView(string, layout->Left(), layout->Top(), layout->Right(), - layout->Bottom()); - BSize min = layout->MinSize(); - ResizeTo(min.Width(), min.Height()); - CenterOnScreen(); - } -}; - - -const uint32 kMsgApplyButton = '&Abu'; -const uint32 kMsgInit = '&Ini'; +// #pragma mark - FolderConfigWindow::FolderConfigWindow(BRect parent, const BMessage& settings) : BWindow(BRect(0, 0, 300, 300), B_TRANSLATE("IMAP Folders"), - B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, B_NO_WORKSPACE_ACTIVATION - | B_NOT_ZOOMABLE | B_AVOID_FRONT), + B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, + B_NO_WORKSPACE_ACTIVATION | B_NOT_ZOOMABLE | B_AVOID_FRONT), fSettings(settings) { BView* rootView = new BView(Bounds(), "root", B_FOLLOW_ALL, B_WILL_DRAW); @@ -316,7 +327,7 @@ FolderConfigWindow::_LoadFolders() BString password; char* passwd = get_passwd(&fSettings, "cpasswd"); - if (passwd) { + if (passwd != NULL) { password = passwd; delete[] passwd; } @@ -331,7 +342,7 @@ FolderConfigWindow::_LoadFolders() item->SetListView(fFolderListView); } - double used, total; + uint64 used, total; if (fIMAPFolders.GetQuota(used, total) == B_OK) { char buffer[256]; BString quotaString = "Server storage: "; diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/IMAPInboundProtocol.h b/src/add-ons/mail_daemon/inbound_protocols/imap/IMAPInboundProtocol.h index a06380c8bd..954a1fc685 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/IMAPInboundProtocol.h +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/IMAPInboundProtocol.h @@ -42,9 +42,6 @@ private: class IMAPInboundProtocol; -int32 watch_mailbox(void* data); - - /*! Just wait for a IDLE (watching) IMAP response in this thread. */ class IMAPMailboxThread { public: @@ -57,11 +54,11 @@ public: status_t StopWatchingMailbox(); private: + static status_t _WatchThreadFunction(void* data); void _Watch(); - friend int32 watch_mailbox(void* data); - - IMAPInboundProtocol& fProtocol; +private: + IMAPInboundProtocol& fProtocol; IMAPMailbox& fIMAPMailbox; BLocker fLock; diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/IMAPRootInboundProtocol.cpp b/src/add-ons/mail_daemon/inbound_protocols/imap/IMAPRootInboundProtocol.cpp index 2f24efb528..b7e49275d8 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/IMAPRootInboundProtocol.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/IMAPRootInboundProtocol.cpp @@ -16,7 +16,6 @@ IMAPRootInboundProtocol::IMAPRootInboundProtocol(BMailAccountSettings* settings) : IMAPInboundProtocol(settings, "INBOX") { - } @@ -179,6 +178,9 @@ IMAPRootInboundProtocol::_FindThreadFor(const entry_ref& ref) } +// #pragma mark - + + InboundProtocol* instantiate_inbound_protocol(BMailAccountSettings* settings) { diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_config.cpp b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_config.cpp index 8169baaaa0..b5128c0914 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_config.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_config.cpp @@ -66,13 +66,13 @@ IMAPConfig::IMAPConfig(MailAddonSettings& settings, SetTo(settings); - ((BControl *)(FindView("leave_mail_on_server")))->SetValue(B_CONTROL_ON); - ((BControl *)(FindView("leave_mail_on_server")))->Hide(); + ((BControl*)(FindView("leave_mail_on_server")))->SetValue(B_CONTROL_ON); + ((BControl*)(FindView("leave_mail_on_server")))->Hide(); BRect frame = FindView("delete_remote_when_local")->Frame(); - ((BControl *)(FindView("delete_remote_when_local")))->SetEnabled(true); - ((BControl *)(FindView("delete_remote_when_local")))->MoveBy(0, -25); + ((BControl*)(FindView("delete_remote_when_local")))->SetEnabled(true); + ((BControl*)(FindView("delete_remote_when_local")))->MoveBy(0, -25); fIMAPFolderButton = new BButton(frame, "IMAP Folders", B_TRANSLATE( "IMAP Folders"), new BMessage(kMsgOpenIMAPFolder)); @@ -83,7 +83,7 @@ IMAPConfig::IMAPConfig(MailAddonSettings& settings, BPath defaultFolder = BPrivate::default_mail_directory(); defaultFolder.Append(accountSettings.Name()); - fFileView = new BMailFileConfigView(B_TRANSLATE("Destination:"), + fFileView = new BMailFileConfigView(B_TRANSLATE("Destination:"), "destination", false, defaultFolder.Path()); fFileView->SetTo(&settings.Settings(), NULL); AddChild(fFileView); @@ -95,7 +95,6 @@ IMAPConfig::IMAPConfig(MailAddonSettings& settings, IMAPConfig::~IMAPConfig() { - } @@ -119,18 +118,18 @@ void IMAPConfig::MessageReceived(BMessage* message) { switch (message->what) { - case kMsgOpenIMAPFolder: - { - BMessage settings; - Archive(&settings); - BWindow* window = new FolderConfigWindow(Window()->Frame(), - settings); - window->Show(); - break; - } + case kMsgOpenIMAPFolder: + { + BMessage settings; + Archive(&settings); + BWindow* window = new FolderConfigWindow(Window()->Frame(), + settings); + window->Show(); + break; + } - default: - BMailProtocolConfigView::MessageReceived(message); + default: + BMailProtocolConfigView::MessageReceived(message); } } @@ -142,6 +141,9 @@ IMAPConfig::AttachedToWindow() } +// #pragma mark - + + BView* instantiate_config_panel(MailAddonSettings& settings, BMailAccountSettings& accountSettings) diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPFolders.cpp b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPFolders.cpp index b64fea79cb..6d16ab2bf2 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPFolders.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPFolders.cpp @@ -29,16 +29,16 @@ IMAPFolders::GetFolders(FolderList& folders) status_t status = _GetAllFolders(allFolders); if (status != B_OK) return status; - StringList subscibedFolders; - status = _GetSubscribedFolders(subscibedFolders); + StringList subscribedFolders; + status = _GetSubscribedFolders(subscribedFolders); if (status != B_OK) return status; for (unsigned int i = 0; i < allFolders.size(); i++) { FolderInfo info; info.folder = allFolders[i]; - for (unsigned int a = 0; a < subscibedFolders.size(); a++) { - if (allFolders[i] == subscibedFolders[a] + for (unsigned int a = 0; a < subscribedFolders.size(); a++) { + if (allFolders[i] == subscribedFolders[a] || allFolders[i].ICompare("INBOX") == 0) { info.subscribed = true; break; @@ -48,10 +48,10 @@ IMAPFolders::GetFolders(FolderList& folders) } // you could be subscribed to a folder which not exist currently, add them: - for (unsigned int a = 0; a < subscibedFolders.size(); a++) { + for (unsigned int a = 0; a < subscribedFolders.size(); a++) { bool isInlist = false; for (unsigned int i = 0; i < allFolders.size(); i++) { - if (subscibedFolders[a] == allFolders[i]) { + if (subscribedFolders[a] == allFolders[i]) { isInlist = true; break; } @@ -60,7 +60,7 @@ IMAPFolders::GetFolders(FolderList& folders) continue; FolderInfo info; - info.folder = subscibedFolders[a]; + info.folder = subscribedFolders[a]; info.subscribed = true; folders.push_back(info); } @@ -86,7 +86,7 @@ IMAPFolders::UnsubscribeFolder(const char* folder) status_t -IMAPFolders::GetQuota(double& used, double& total) +IMAPFolders::GetQuota(uint64& used, uint64& total) { if (fCapabilityHandler.Capabilities() == "") ProcessCommand(fCapabilityHandler.Command()); @@ -100,7 +100,7 @@ IMAPFolders::GetQuota(double& used, double& total) used = quotaCommand.UsedStorage(); total = quotaCommand.TotalStorage(); - return status; + return B_OK; } diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPFolders.h b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPFolders.h index 5d72745689..8f230b02bc 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPFolders.h +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPFolders.h @@ -39,7 +39,7 @@ public: status_t SubscribeFolder(const char* folder); status_t UnsubscribeFolder(const char* folder); - status_t GetQuota(double& used, double& total); + status_t GetQuota(uint64& used, uint64& total); private: status_t _GetAllFolders(StringList& folders); status_t _GetSubscribedFolders(StringList& folders); diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.cpp b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.cpp index 0b5510fa81..695f8693fc 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.cpp @@ -7,7 +7,7 @@ #include "IMAPHandler.h" -#include // for atoi +#include #include @@ -17,12 +17,11 @@ #define DEBUG_IMAP_HANDLER - #ifdef DEBUG_IMAP_HANDLER -#include -#define TRACE(x...) printf(x) +# include +# define TRACE(x...) printf(x) #else -#define TRACE(x...) /* nothing */ +# define TRACE(x...) ; #endif @@ -31,7 +30,6 @@ using namespace BPrivate; IMAPCommand::~IMAPCommand() { - } @@ -48,16 +46,17 @@ IMAPMailboxCommand::IMAPMailboxCommand(IMAPMailbox& mailbox) fStorage(mailbox.GetStorage()), fConnectionReader(mailbox.GetConnectionReader()) { - } IMAPMailboxCommand::~IMAPMailboxCommand() { - } +// #pragma mark - + + MailboxSelectHandler::MailboxSelectHandler(IMAPMailbox& mailbox) : IMAPMailboxCommand(mailbox), @@ -66,7 +65,6 @@ MailboxSelectHandler::MailboxSelectHandler(IMAPMailbox& mailbox) fNextUID(-1), fUIDValidity(-1) { - } @@ -105,11 +103,13 @@ MailboxSelectHandler::Handle(const BString& response) } +// #pragma mark - + + CapabilityHandler::CapabilityHandler() : fCapabilities("") { - } @@ -139,7 +139,7 @@ CapabilityHandler::Capabilities() } -// FetchHandler +// #pragma mark - FetchMinMessageCommand::FetchMinMessageCommand(IMAPMailbox& mailbox, @@ -152,7 +152,6 @@ FetchMinMessageCommand::FetchMinMessageCommand(IMAPMailbox& mailbox, fMinMessageList(list), fData(data) { - } @@ -167,7 +166,6 @@ FetchMinMessageCommand::FetchMinMessageCommand(IMAPMailbox& mailbox, fMinMessageList(list), fData(data) { - } @@ -255,6 +253,9 @@ FetchMinMessageCommand::ExtractFlags(const BString& response) } +// #pragma mark - + + FetchMessageListCommand::FetchMessageListCommand(IMAPMailbox& mailbox, MinMessageList* list, int32 nextId) : @@ -263,7 +264,6 @@ FetchMessageListCommand::FetchMessageListCommand(IMAPMailbox& mailbox, fMinMessageList(list), fNextId(nextId) { - } @@ -294,6 +294,9 @@ FetchMessageListCommand::Handle(const BString& response) } +// #pragma mark - + + FetchMessageCommand::FetchMessageCommand(IMAPMailbox& mailbox, int32 message, BPositionIO* data, int32 fetchBodyLimit) : @@ -304,7 +307,6 @@ FetchMessageCommand::FetchMessageCommand(IMAPMailbox& mailbox, int32 message, fOutData(data), fFetchBodyLimit(fetchBodyLimit) { - } @@ -431,6 +433,9 @@ FetchMessageCommand::Handle(const BString& response) } +// #pragma mark - + + FetchBodyCommand::FetchBodyCommand(IMAPMailbox& mailbox, int32 message, BPositionIO* data) : @@ -439,7 +444,6 @@ FetchBodyCommand::FetchBodyCommand(IMAPMailbox& mailbox, int32 message, fMessage(message), fOutData(data) { - } @@ -502,6 +506,9 @@ FetchBodyCommand::Handle(const BString& response) } +// #pragma mark - + + SetFlagsCommand::SetFlagsCommand(IMAPMailbox& mailbox, int32 message, int32 flags) : @@ -552,6 +559,9 @@ SetFlagsCommand::GenerateFlagList(int32 flags) } +// #pragma mark - + + AppendCommand::AppendCommand(IMAPMailbox& mailbox, BPositionIO& message, off_t size, int32 flags, time_t time) : @@ -562,7 +572,6 @@ AppendCommand::AppendCommand(IMAPMailbox& mailbox, BPositionIO& message, fFlags(flags), fTime(time) { - } @@ -607,13 +616,16 @@ AppendCommand::Handle(const BString& response) } +// #pragma mark - + + ExistsHandler::ExistsHandler(IMAPMailbox& mailbox) : IMAPMailboxCommand(mailbox) { - } + bool ExistsHandler::Handle(const BString& response) { @@ -647,13 +659,16 @@ ExistsHandler::Handle(const BString& response) } +// #pragma mark - + + ExpungeCommmand::ExpungeCommmand(IMAPMailbox& mailbox) : IMAPMailboxCommand(mailbox) { - } + BString ExpungeCommmand::Command() { @@ -668,13 +683,16 @@ ExpungeCommmand::Handle(const BString& response) } +// #pragma mark - + + ExpungeHandler::ExpungeHandler(IMAPMailbox& mailbox) : IMAPMailboxCommand(mailbox) { - } + bool ExpungeHandler::Handle(const BString& response) { @@ -703,11 +721,13 @@ ExpungeHandler::Handle(const BString& response) } +// #pragma mark - + + FlagsHandler::FlagsHandler(IMAPMailbox& mailbox) : IMAPMailboxCommand(mailbox) { - } @@ -731,6 +751,9 @@ FlagsHandler::Handle(const BString& response) } +// #pragma mark - + + BString ListCommand::Command() { @@ -783,6 +806,9 @@ ListCommand::ParseList(const char* command, const BString& response, } +// #pragma mark - + + BString ListSubscribedCommand::Command() { @@ -805,11 +831,13 @@ ListSubscribedCommand::FolderList() } +// #pragma mark - + + SubscribeCommand::SubscribeCommand(const char* mailboxName) : fMailboxName(mailboxName) { - } @@ -830,11 +858,13 @@ SubscribeCommand::Handle(const BString& response) } +// #pragma mark - + + UnsubscribeCommand::UnsubscribeCommand(const char* mailboxName) : fMailboxName(mailboxName) { - } @@ -855,15 +885,15 @@ UnsubscribeCommand::Handle(const BString& response) } +// #pragma mark - + GetQuotaCommand::GetQuotaCommand(const char* mailboxName) : fMailboxName(mailboxName), - - fUsedStorage(-1), - fTotalStorage(-1) + fUsedStorage(0), + fTotalStorage(0) { - } @@ -885,23 +915,21 @@ GetQuotaCommand::Handle(const BString& response) BString data = IMAPParser::ExtractBetweenBrackets(response, "(", ")"); IMAPParser::RemovePrimitiveFromLeft(data); - fUsedStorage = IMAPParser::RemoveIntegerFromLeft(data); - fUsedStorage *= 1024; - fTotalStorage = IMAPParser::RemoveIntegerFromLeft(data); - fTotalStorage *= 1024; + fUsedStorage = (uint64)IMAPParser::RemoveIntegerFromLeft(data) * 1024; + fTotalStorage = (uint64)IMAPParser::RemoveIntegerFromLeft(data) * 1024; return true; } -double +uint64 GetQuotaCommand::UsedStorage() { return fUsedStorage; } -double +uint64 GetQuotaCommand::TotalStorage() { return fTotalStorage; diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.h b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.h index b172294e3b..ed322db076 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.h +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.h @@ -1,5 +1,5 @@ /* - * Copyright 2010, Haiku Inc. All Rights Reserved. + * Copyright 2010-2011, Haiku Inc. All Rights Reserved. * Copyright 2010 Clemens Zeidler. All rights reserved. * * Distributed under the terms of the MIT License. @@ -74,10 +74,10 @@ private: struct MinMessage { - MinMessage(); + MinMessage(); - int32 uid; - int32 flags; + int32 uid; + int32 flags; }; @@ -99,6 +99,7 @@ public: static bool ParseMinMessage(const BString& response, MinMessage& minMessage); static int32 ExtractFlags(const BString& response); + private: int32 fMessage; int32 fEndMessage; @@ -169,6 +170,7 @@ public: bool Handle(const BString& response); static BString GenerateFlagList(int32 flags); + private: int32 fMessage; int32 fFlags; @@ -183,6 +185,7 @@ public: BString Command(); bool Handle(const BString& response); + private: BPositionIO& fMessageData; off_t fDataSize; @@ -287,15 +290,14 @@ public: BString Command(); bool Handle(const BString& response); - double UsedStorage(); - double TotalStorage(); + uint64 UsedStorage(); + uint64 TotalStorage(); private: BString fMailboxName; - double fUsedStorage; - double fTotalStorage; + uint64 fUsedStorage; + uint64 fTotalStorage; }; - #endif // IMAP_HANDLER_H diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPMailbox.cpp b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPMailbox.cpp index 310d3750e1..4db97d9a9f 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPMailbox.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPMailbox.cpp @@ -12,12 +12,11 @@ #define DEBUG_IMAP_MAILBOX - #ifdef DEBUG_IMAP_MAILBOX -#include -#define TRACE(x...) printf(x) +# include +# define TRACE(x...) printf(x) #else -#define TRACE(x...) /* nothing */ +# define TRACE(x...) ; #endif @@ -28,6 +27,9 @@ MinMessage::MinMessage() } +// #pragma mark - + + IMAPMailbox::IMAPMailbox(IMAPStorage& storage) : fStorage(storage), diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPParser.cpp b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPParser.cpp index cb60a5f738..5ea949701f 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPParser.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPParser.cpp @@ -1,6 +1,14 @@ +/* + * Copyright 2010, Haiku Inc. All Rights Reserved. + * Copyright 2010 Clemens Zeidler. All rights reserved. + * + * Distributed under the terms of the MIT License. + */ + + #include "IMAPParser.h" -#include // for atoi +#include BString diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.cpp b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.cpp index cc85a3faef..b8fe7a3430 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.cpp @@ -12,13 +12,13 @@ #else #define TRACE(x...) /* nothing */ #endif - + ConnectionReader::ConnectionReader(ServerConnection* connection) : fServerConnection(connection) { - + } @@ -130,6 +130,9 @@ ConnectionReader::_ExtractTillEndOfLine(BString& out) } +// #pragma mark - + + IMAPProtocol::IMAPProtocol() : fServerConnection(&fOwnServerConnection), @@ -138,7 +141,6 @@ IMAPProtocol::IMAPProtocol() fStopNow(0), fIsConnected(false) { - } @@ -150,7 +152,6 @@ IMAPProtocol::IMAPProtocol(IMAPProtocol& connection) fStopNow(0), fIsConnected(false) { - } @@ -320,7 +321,7 @@ IMAPProtocol::HandleResponse(int32 commandId, bigtime_t timeout, bool disconnect TRACE("S:read error %s", line.String()); _Disconnect(); } else if (disconnectOnTimeout) { - _Disconnect(); + _Disconnect(); } return status; } diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPStorage.cpp b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPStorage.cpp index 6ae12fb741..17c6f043de 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPStorage.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPStorage.cpp @@ -1,3 +1,11 @@ +/* + * Copyright 2010-2011, Haiku Inc. All Rights Reserved. + * Copyright 2010 Clemens Zeidler. All rights reserved. + * + * Distributed under the terms of the MIT License. + */ + + #include "IMAPStorage.h" #include @@ -13,12 +21,11 @@ #define DEBUG_IMAP_STORAGE - #ifdef DEBUG_IMAP_STORAGE -#include -#define TRACE(x...) printf(x) +# include +# define TRACE(x...) printf(x) #else -#define TRACE(x...) /* nothing */ +# define TRACE(x...) /* nothing */ #endif @@ -100,12 +107,7 @@ IMAPMailboxSync::Sync(IMAPStorage& storage, IMAPMailbox& mailbox) } -int32 -ReadDirThreadFunction(void *data) -{ - IMAPStorage* storage = (IMAPStorage*)data; - return storage->_ReadFilesThread(); -} +// #pragma mark - IMAPStorage::IMAPStorage() @@ -134,7 +136,7 @@ IMAPStorage::StartReadDatabase() if (status != B_OK) return status; - thread_id id = spawn_thread(ReadDirThreadFunction, "read mailbox", + thread_id id = spawn_thread(_ReadFilesThreadFunction, "read mailbox", B_LOW_PRIORITY, this); if (id < 0) return id; @@ -417,7 +419,15 @@ IMAPStorage::UIDToRef(int32 uid, entry_ref& ref) status_t -IMAPStorage::_ReadFilesThread() +IMAPStorage::_ReadFilesThreadFunction(void* data) +{ + IMAPStorage* storage = (IMAPStorage*)data; + return storage->_ReadFiles(); +} + + +status_t +IMAPStorage::_ReadFiles() { fMailEntryMap.clear(); diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPStorage.h b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPStorage.h index 185ea1e04c..d402e5e166 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPStorage.h +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPStorage.h @@ -82,13 +82,13 @@ public: status_t ReadUniqueID(BNode& node, int32& uid); private: - friend int32 ReadDirThreadFunction(void *data); - - status_t _ReadFilesThread(); + static status_t _ReadFilesThreadFunction(void* data); + status_t _ReadFiles(); status_t _WriteFlags(int32 flags, BNode& node); status_t _WriteUniqueID(BNode& node, int32 uid); +private: BPath fMailboxPath; sem_id fLoadDatabaseLock; @@ -104,6 +104,7 @@ public: status_t Sync(IMAPStorage& storage, IMAPMailbox& mailbox); const MessageNumberList& ToFetchList() { return fToFetchList; } + private: MessageNumberList fToFetchList; };