1 /* 2 * Copyright 2007-2012, Haiku, Inc. All rights reserved. 3 * Copyright 2001-2002 Dr. Zoidberg Enterprises. All rights reserved. 4 * Copyright 2011, Clemens Zeidler <haiku@clemens-zeidler.de> 5 * Distributed under the terms of the MIT License. 6 */ 7 #ifndef MAIL_DAEMON_APPLICATION_H 8 #define MAIL_DAEMON_APPLICATION_H 9 10 11 #include <map> 12 13 #include <Application.h> 14 #include <ObjectList.h> 15 #include <Message.h> 16 #include <MessageRunner.h> 17 #include <Node.h> 18 #include <Query.h> 19 #include <String.h> 20 21 #include <MailProtocol.h> 22 23 #include "LEDAnimation.h" 24 #include "DefaultNotifier.h" 25 26 27 class BNotification; 28 struct send_mails_info; 29 30 31 struct account_protocols { 32 account_protocols(); 33 34 image_id inboundImage; 35 BInboundMailProtocol* inboundProtocol; 36 image_id outboundImage; 37 BOutboundMailProtocol* outboundProtocol; 38 }; 39 40 41 typedef std::map<int32, account_protocols> AccountMap; 42 43 44 class MailDaemonApplication : public BApplication { 45 public: 46 MailDaemonApplication(); 47 virtual ~MailDaemonApplication(); 48 49 virtual void ReadyToRun(); 50 virtual void RefsReceived(BMessage* message); 51 virtual void MessageReceived(BMessage* message); 52 53 virtual void Pulse(); 54 virtual bool QuitRequested(); 55 56 void InstallDeskbarIcon(); 57 void RemoveDeskbarIcon(); 58 59 void GetNewMessages(BMessage* message); 60 void SendPendingMessages(BMessage* message); 61 62 void MakeMimeTypes(bool remakeMIMETypes = false); 63 64 private: 65 void _InitAccounts(); 66 void _InitAccount(BMailAccountSettings& settings); 67 void _ReloadAccounts(BMessage* message); 68 void _RemoveAccount( 69 const account_protocols& account); 70 71 BInboundMailProtocol* _CreateInboundProtocol( 72 BMailAccountSettings& settings, 73 image_id& image); 74 BOutboundMailProtocol* _CreateOutboundProtocol( 75 BMailAccountSettings& settings, 76 image_id& image); 77 78 BInboundMailProtocol* _InboundProtocol(int32 account); 79 BOutboundMailProtocol* _OutboundProtocol(int32 account); 80 81 void _UpdateAutoCheck(bigtime_t interval); 82 83 void _AddMessage(send_mails_info& info, 84 const BEntry& entry, const BNode& node); 85 86 static bool _IsPending(BNode& node); 87 static bool _IsEntryInTrash(BEntry& entry); 88 89 private: 90 BMessageRunner* fAutoCheckRunner; 91 BMailSettings fSettingsFile; 92 93 int32 fNewMessages; 94 bool fCentralBeep; 95 // TRUE to do a beep when the status window closes. This happens 96 // when all mail has been received, so you get one beep for 97 // everything rather than individual beeps for each mail 98 // account. 99 // Set to TRUE by the 'mcbp' message that the mail Notification 100 // filter sends us, cleared when the beep is done. 101 BObjectList<BMessage> fFetchDoneRespondents; 102 BObjectList<BQuery> fQueries; 103 104 LEDAnimation* fLEDAnimation; 105 106 BString fAlertString; 107 108 AccountMap fAccounts; 109 110 ErrorLogWindow* fErrorLogWindow; 111 BNotification* fNotification; 112 uint32 fNotifyMode; 113 }; 114 115 116 #endif // MAIL_DAEMON_APPLICATION_H 117