10c7f804cSAxel Dörfler /* 2715bf3d1SAxel Dörfler * Copyright 2011-2012, Haiku, Inc. All rights reserved. 30c7f804cSAxel Dörfler * Copyright 2001-2003 Dr. Zoidberg Enterprises. All rights reserved. 4f7215ac8SNathan Whitehorn */ 5f7215ac8SNathan Whitehorn 6f7215ac8SNathan Whitehorn 7715bf3d1SAxel Dörfler //#include <assert.h> 8f7215ac8SNathan Whitehorn #include <stdio.h> 96e927a5fSIngo Weinhold #include <stdlib.h> 10715bf3d1SAxel Dörfler 11715bf3d1SAxel Dörfler #include <fs_attr.h> 12f7215ac8SNathan Whitehorn 13dfc6cf01SPhilippe Houdoin #include <Alert.h> 14dfc6cf01SPhilippe Houdoin #include <Directory.h> 15dfc6cf01SPhilippe Houdoin #include <FindDirectory.h> 16dfc6cf01SPhilippe Houdoin #include <E-mail.h> 17715bf3d1SAxel Dörfler #include <Locker.h> 18dfc6cf01SPhilippe Houdoin #include <Node.h> 19dfc6cf01SPhilippe Houdoin #include <NodeInfo.h> 20dfc6cf01SPhilippe Houdoin #include <NodeMonitor.h> 21dfc6cf01SPhilippe Houdoin #include <Path.h> 22715bf3d1SAxel Dörfler #include <Query.h> 231af4fa4bSClemens Zeidler #include <Roster.h> 24dfc6cf01SPhilippe Houdoin #include <String.h> 25dfc6cf01SPhilippe Houdoin #include <StringList.h> 26dfc6cf01SPhilippe Houdoin #include <VolumeRoster.h> 27dfc6cf01SPhilippe Houdoin 28715bf3d1SAxel Dörfler #include <MailFilter.h> 29b8d2bbd6SClemens Zeidler #include <MailDaemon.h> 30f7215ac8SNathan Whitehorn #include <MailProtocol.h> 311af4fa4bSClemens Zeidler #include <MailSettings.h> 32f7215ac8SNathan Whitehorn 33715bf3d1SAxel Dörfler #include <mail_util.h> 34146357b5SAxel Dörfler #include <MailPrivate.h> 35715bf3d1SAxel Dörfler 361af4fa4bSClemens Zeidler #include "HaikuMailFormatFilter.h" 37f7215ac8SNathan Whitehorn 38f7215ac8SNathan Whitehorn 39146357b5SAxel Dörfler using namespace BPrivate; 40f7215ac8SNathan Whitehorn 41f7215ac8SNathan Whitehorn 420c7f804cSAxel Dörfler const uint32 kMsgDeleteMessage = '&DeM'; 430c7f804cSAxel Dörfler const uint32 kMsgAppendMessage = '&ApM'; 440c7f804cSAxel Dörfler 450c7f804cSAxel Dörfler const uint32 kMsgMoveFile = '&MoF'; 460c7f804cSAxel Dörfler const uint32 kMsgDeleteFile = '&DeF'; 470c7f804cSAxel Dörfler const uint32 kMsgFileRenamed = '&FiR'; 480c7f804cSAxel Dörfler const uint32 kMsgFileDeleted = '&FDe'; 490c7f804cSAxel Dörfler const uint32 kMsgInit = '&Ini'; 500c7f804cSAxel Dörfler 510c7f804cSAxel Dörfler const uint32 kMsgSendMessage = '&SeM'; 520c7f804cSAxel Dörfler 530c7f804cSAxel Dörfler 54715bf3d1SAxel Dörfler BMailProtocol::BMailProtocol(const BMailAccountSettings& settings) 55f7215ac8SNathan Whitehorn : 56715bf3d1SAxel Dörfler fAccountSettings(settings), 57715bf3d1SAxel Dörfler fMailNotifier(NULL) 58f7215ac8SNathan Whitehorn { 591af4fa4bSClemens Zeidler AddFilter(new HaikuMailFormatFilter(*this, settings)); 601af4fa4bSClemens Zeidler } 611af4fa4bSClemens Zeidler 621af4fa4bSClemens Zeidler 63715bf3d1SAxel Dörfler BMailProtocol::~BMailProtocol() 641af4fa4bSClemens Zeidler { 651af4fa4bSClemens Zeidler delete fMailNotifier; 661af4fa4bSClemens Zeidler 671af4fa4bSClemens Zeidler for (int i = 0; i < fFilterList.CountItems(); i++) 681af4fa4bSClemens Zeidler delete fFilterList.ItemAt(i); 691af4fa4bSClemens Zeidler 70146357b5SAxel Dörfler std::map<entry_ref, image_id>::iterator it = fFilterImages.begin(); 711af4fa4bSClemens Zeidler for (; it != fFilterImages.end(); it++) 721af4fa4bSClemens Zeidler unload_add_on(it->second); 731af4fa4bSClemens Zeidler } 741af4fa4bSClemens Zeidler 751af4fa4bSClemens Zeidler 76715bf3d1SAxel Dörfler const BMailAccountSettings& 77715bf3d1SAxel Dörfler BMailProtocol::AccountSettings() const 781af4fa4bSClemens Zeidler { 791af4fa4bSClemens Zeidler return fAccountSettings; 801af4fa4bSClemens Zeidler } 811af4fa4bSClemens Zeidler 821af4fa4bSClemens Zeidler 831af4fa4bSClemens Zeidler void 84715bf3d1SAxel Dörfler BMailProtocol::SetMailNotifier(BMailNotifier* mailNotifier) 851af4fa4bSClemens Zeidler { 861af4fa4bSClemens Zeidler delete fMailNotifier; 871af4fa4bSClemens Zeidler fMailNotifier = mailNotifier; 881af4fa4bSClemens Zeidler } 891af4fa4bSClemens Zeidler 901af4fa4bSClemens Zeidler 91715bf3d1SAxel Dörfler BMailNotifier* 92715bf3d1SAxel Dörfler BMailProtocol::MailNotifier() const 931af4fa4bSClemens Zeidler { 94715bf3d1SAxel Dörfler return fMailNotifier; 951af4fa4bSClemens Zeidler } 961af4fa4bSClemens Zeidler 971af4fa4bSClemens Zeidler 981af4fa4bSClemens Zeidler bool 99715bf3d1SAxel Dörfler BMailProtocol::AddFilter(BMailFilter* filter) 1001af4fa4bSClemens Zeidler { 101715bf3d1SAxel Dörfler BLocker locker(this); 1021af4fa4bSClemens Zeidler return fFilterList.AddItem(filter); 1031af4fa4bSClemens Zeidler } 1041af4fa4bSClemens Zeidler 1051af4fa4bSClemens Zeidler 1061af4fa4bSClemens Zeidler int32 107715bf3d1SAxel Dörfler BMailProtocol::CountFilter() const 1081af4fa4bSClemens Zeidler { 109715bf3d1SAxel Dörfler BLocker locker(this); 1101af4fa4bSClemens Zeidler return fFilterList.CountItems(); 1111af4fa4bSClemens Zeidler } 1121af4fa4bSClemens Zeidler 1131af4fa4bSClemens Zeidler 114715bf3d1SAxel Dörfler BMailFilter* 115715bf3d1SAxel Dörfler BMailProtocol::FilterAt(int32 index) const 1161af4fa4bSClemens Zeidler { 117715bf3d1SAxel Dörfler BLocker locker(this); 1181af4fa4bSClemens Zeidler return fFilterList.ItemAt(index); 1191af4fa4bSClemens Zeidler } 1201af4fa4bSClemens Zeidler 1211af4fa4bSClemens Zeidler 122715bf3d1SAxel Dörfler BMailFilter* 123715bf3d1SAxel Dörfler BMailProtocol::RemoveFilter(int32 index) 1241af4fa4bSClemens Zeidler { 125715bf3d1SAxel Dörfler BLocker locker(this); 1261af4fa4bSClemens Zeidler return fFilterList.RemoveItemAt(index); 1271af4fa4bSClemens Zeidler } 1281af4fa4bSClemens Zeidler 1291af4fa4bSClemens Zeidler 1301af4fa4bSClemens Zeidler bool 131715bf3d1SAxel Dörfler BMailProtocol::RemoveFilter(BMailFilter* filter) 1321af4fa4bSClemens Zeidler { 133715bf3d1SAxel Dörfler BLocker locker(this); 1341af4fa4bSClemens Zeidler return fFilterList.RemoveItem(filter); 1351af4fa4bSClemens Zeidler } 1361af4fa4bSClemens Zeidler 1371af4fa4bSClemens Zeidler 1381af4fa4bSClemens Zeidler void 139715bf3d1SAxel Dörfler BMailProtocol::MessageReceived(BMessage* message) 1401af4fa4bSClemens Zeidler { 141715bf3d1SAxel Dörfler switch (message->what) { 142715bf3d1SAxel Dörfler case kMsgMoveFile: 143715bf3d1SAxel Dörfler { 144715bf3d1SAxel Dörfler entry_ref file; 145715bf3d1SAxel Dörfler message->FindRef("file", &file); 146715bf3d1SAxel Dörfler entry_ref dir; 147715bf3d1SAxel Dörfler message->FindRef("directory", &dir); 148715bf3d1SAxel Dörfler BDirectory directory(&dir); 149715bf3d1SAxel Dörfler MoveMessage(file, directory); 150715bf3d1SAxel Dörfler break; 1511af4fa4bSClemens Zeidler } 1521af4fa4bSClemens Zeidler 153715bf3d1SAxel Dörfler case kMsgDeleteFile: 1541af4fa4bSClemens Zeidler { 155715bf3d1SAxel Dörfler entry_ref file; 156715bf3d1SAxel Dörfler message->FindRef("file", &file); 157715bf3d1SAxel Dörfler DeleteMessage(file); 158715bf3d1SAxel Dörfler break; 1591af4fa4bSClemens Zeidler } 1601af4fa4bSClemens Zeidler 161715bf3d1SAxel Dörfler case kMsgFileRenamed: 1621af4fa4bSClemens Zeidler { 163715bf3d1SAxel Dörfler entry_ref from; 164715bf3d1SAxel Dörfler message->FindRef("from", &from); 165715bf3d1SAxel Dörfler entry_ref to; 166715bf3d1SAxel Dörfler message->FindRef("to", &to); 167715bf3d1SAxel Dörfler FileRenamed(from, to); 168715bf3d1SAxel Dörfler break; 1691af4fa4bSClemens Zeidler } 1701af4fa4bSClemens Zeidler 171715bf3d1SAxel Dörfler case kMsgFileDeleted: 1721af4fa4bSClemens Zeidler { 173715bf3d1SAxel Dörfler node_ref node; 174715bf3d1SAxel Dörfler message->FindInt32("device",&node.device); 175715bf3d1SAxel Dörfler message->FindInt64("node", &node.node); 176715bf3d1SAxel Dörfler FileDeleted(node); 177715bf3d1SAxel Dörfler break; 1781af4fa4bSClemens Zeidler } 1791af4fa4bSClemens Zeidler 180715bf3d1SAxel Dörfler default: 181715bf3d1SAxel Dörfler BLooper::MessageReceived(message); 182715bf3d1SAxel Dörfler } 1831af4fa4bSClemens Zeidler } 1841af4fa4bSClemens Zeidler 1851af4fa4bSClemens Zeidler 1861af4fa4bSClemens Zeidler status_t 187715bf3d1SAxel Dörfler BMailProtocol::MoveMessage(const entry_ref& ref, BDirectory& dir) 1881af4fa4bSClemens Zeidler { 1891af4fa4bSClemens Zeidler BEntry entry(&ref); 1901af4fa4bSClemens Zeidler return entry.MoveTo(&dir); 1911af4fa4bSClemens Zeidler } 1921af4fa4bSClemens Zeidler 1931af4fa4bSClemens Zeidler 1941af4fa4bSClemens Zeidler status_t 195715bf3d1SAxel Dörfler BMailProtocol::DeleteMessage(const entry_ref& ref) 1961af4fa4bSClemens Zeidler { 1971af4fa4bSClemens Zeidler BEntry entry(&ref); 1981af4fa4bSClemens Zeidler return entry.Remove(); 1991af4fa4bSClemens Zeidler } 2001af4fa4bSClemens Zeidler 2011af4fa4bSClemens Zeidler 2021af4fa4bSClemens Zeidler void 203715bf3d1SAxel Dörfler BMailProtocol::FileRenamed(const entry_ref& from, const entry_ref& to) 2041af4fa4bSClemens Zeidler { 2051af4fa4bSClemens Zeidler } 2061af4fa4bSClemens Zeidler 2071af4fa4bSClemens Zeidler 2081af4fa4bSClemens Zeidler void 209715bf3d1SAxel Dörfler BMailProtocol::FileDeleted(const node_ref& node) 2101af4fa4bSClemens Zeidler { 2111af4fa4bSClemens Zeidler } 2121af4fa4bSClemens Zeidler 2131af4fa4bSClemens Zeidler 2141af4fa4bSClemens Zeidler void 215715bf3d1SAxel Dörfler BMailProtocol::ShowError(const char* error) 216715bf3d1SAxel Dörfler { 217715bf3d1SAxel Dörfler if (MailNotifier() != NULL) 218715bf3d1SAxel Dörfler MailNotifier()->ShowError(error); 219715bf3d1SAxel Dörfler } 220715bf3d1SAxel Dörfler 221715bf3d1SAxel Dörfler 222715bf3d1SAxel Dörfler void 223715bf3d1SAxel Dörfler BMailProtocol::ShowMessage(const char* message) 224715bf3d1SAxel Dörfler { 225715bf3d1SAxel Dörfler if (MailNotifier() != NULL) 226715bf3d1SAxel Dörfler MailNotifier()->ShowMessage(message); 227715bf3d1SAxel Dörfler } 228715bf3d1SAxel Dörfler 229715bf3d1SAxel Dörfler 230715bf3d1SAxel Dörfler void 231715bf3d1SAxel Dörfler BMailProtocol::SetTotalItems(uint32 items) 232715bf3d1SAxel Dörfler { 233715bf3d1SAxel Dörfler if (MailNotifier() != NULL) 234715bf3d1SAxel Dörfler MailNotifier()->SetTotalItems(items); 235715bf3d1SAxel Dörfler } 236715bf3d1SAxel Dörfler 237715bf3d1SAxel Dörfler 238715bf3d1SAxel Dörfler void 239715bf3d1SAxel Dörfler BMailProtocol::SetTotalItemsSize(uint64 size) 240715bf3d1SAxel Dörfler { 241715bf3d1SAxel Dörfler if (MailNotifier() != NULL) 242715bf3d1SAxel Dörfler MailNotifier()->SetTotalItemsSize(size); 243715bf3d1SAxel Dörfler } 244715bf3d1SAxel Dörfler 245715bf3d1SAxel Dörfler 246715bf3d1SAxel Dörfler void 247715bf3d1SAxel Dörfler BMailProtocol::ReportProgress(uint32 messages, uint64 bytes, 248715bf3d1SAxel Dörfler const char* message) 249715bf3d1SAxel Dörfler { 250715bf3d1SAxel Dörfler if (MailNotifier() != NULL) 251715bf3d1SAxel Dörfler MailNotifier()->ReportProgress(messages, bytes, message); 252715bf3d1SAxel Dörfler } 253715bf3d1SAxel Dörfler 254715bf3d1SAxel Dörfler 255715bf3d1SAxel Dörfler void 256715bf3d1SAxel Dörfler BMailProtocol::ResetProgress(const char* message) 257715bf3d1SAxel Dörfler { 258715bf3d1SAxel Dörfler if (MailNotifier() != NULL) 259715bf3d1SAxel Dörfler MailNotifier()->ResetProgress(message); 260715bf3d1SAxel Dörfler } 261715bf3d1SAxel Dörfler 262715bf3d1SAxel Dörfler 263715bf3d1SAxel Dörfler void 264715bf3d1SAxel Dörfler BMailProtocol::NotifyNewMessagesToFetch(int32 count) 265715bf3d1SAxel Dörfler { 266715bf3d1SAxel Dörfler ResetProgress(); 267715bf3d1SAxel Dörfler SetTotalItems(count); 268715bf3d1SAxel Dörfler } 269715bf3d1SAxel Dörfler 270715bf3d1SAxel Dörfler 271715bf3d1SAxel Dörfler void 272715bf3d1SAxel Dörfler BMailProtocol::NotifyHeaderFetched(const entry_ref& ref, BFile* data) 273715bf3d1SAxel Dörfler { 274715bf3d1SAxel Dörfler for (int i = 0; i < fFilterList.CountItems(); i++) 275715bf3d1SAxel Dörfler fFilterList.ItemAt(i)->HeaderFetched(ref, data); 276715bf3d1SAxel Dörfler } 277715bf3d1SAxel Dörfler 278715bf3d1SAxel Dörfler 279715bf3d1SAxel Dörfler void 280715bf3d1SAxel Dörfler BMailProtocol::NotifyBodyFetched(const entry_ref& ref, BFile* data) 281715bf3d1SAxel Dörfler { 282715bf3d1SAxel Dörfler for (int i = 0; i < fFilterList.CountItems(); i++) 283715bf3d1SAxel Dörfler fFilterList.ItemAt(i)->BodyFetched(ref, data); 284715bf3d1SAxel Dörfler } 285715bf3d1SAxel Dörfler 286715bf3d1SAxel Dörfler 287715bf3d1SAxel Dörfler void 288715bf3d1SAxel Dörfler BMailProtocol::NotifyMessageReadyToSend(const entry_ref& ref, BFile* data) 289715bf3d1SAxel Dörfler { 290715bf3d1SAxel Dörfler for (int i = 0; i < fFilterList.CountItems(); i++) 291715bf3d1SAxel Dörfler fFilterList.ItemAt(i)->MessageReadyToSend(ref, data); 292715bf3d1SAxel Dörfler } 293715bf3d1SAxel Dörfler 294715bf3d1SAxel Dörfler 295715bf3d1SAxel Dörfler void 296715bf3d1SAxel Dörfler BMailProtocol::NotifyMessageSent(const entry_ref& ref, BFile* data) 297715bf3d1SAxel Dörfler { 298715bf3d1SAxel Dörfler for (int i = 0; i < fFilterList.CountItems(); i++) 299715bf3d1SAxel Dörfler fFilterList.ItemAt(i)->MessageSent(ref, data); 300715bf3d1SAxel Dörfler } 301715bf3d1SAxel Dörfler 302715bf3d1SAxel Dörfler 303715bf3d1SAxel Dörfler void 304715bf3d1SAxel Dörfler BMailProtocol::LoadFilters(const BMailProtocolSettings& settings) 3051af4fa4bSClemens Zeidler { 3061af4fa4bSClemens Zeidler for (int i = 0; i < settings.CountFilterSettings(); i++) { 307715bf3d1SAxel Dörfler BMailAddOnSettings* filterSettings = settings.FilterSettingsAt(i); 308*ca3341c7SAxel Dörfler BMailFilter* filter = _LoadFilter(*filterSettings); 309715bf3d1SAxel Dörfler if (filter != NULL) 3101af4fa4bSClemens Zeidler AddFilter(filter); 3111af4fa4bSClemens Zeidler } 3121af4fa4bSClemens Zeidler } 3131af4fa4bSClemens Zeidler 3141af4fa4bSClemens Zeidler 315715bf3d1SAxel Dörfler BMailFilter* 316*ca3341c7SAxel Dörfler BMailProtocol::_LoadFilter(const BMailAddOnSettings& settings) 3171af4fa4bSClemens Zeidler { 318*ca3341c7SAxel Dörfler const entry_ref& ref = settings.AddOnRef(); 319146357b5SAxel Dörfler std::map<entry_ref, image_id>::iterator it = fFilterImages.find(ref); 3201af4fa4bSClemens Zeidler image_id image; 3211af4fa4bSClemens Zeidler if (it != fFilterImages.end()) 3221af4fa4bSClemens Zeidler image = it->second; 3231af4fa4bSClemens Zeidler else { 3241af4fa4bSClemens Zeidler BEntry entry(&ref); 3251af4fa4bSClemens Zeidler BPath path(&entry); 3261af4fa4bSClemens Zeidler image = load_add_on(path.Path()); 3271af4fa4bSClemens Zeidler } 3281af4fa4bSClemens Zeidler if (image < 0) 3291af4fa4bSClemens Zeidler return NULL; 3301af4fa4bSClemens Zeidler 331*ca3341c7SAxel Dörfler BMailFilter* (*instantiateFilter)(BMailProtocol& protocol, 332*ca3341c7SAxel Dörfler const BMailAddOnSettings& settings); 333715bf3d1SAxel Dörfler if (get_image_symbol(image, "instantiate_filter", B_SYMBOL_TYPE_TEXT, 334*ca3341c7SAxel Dörfler (void**)&instantiateFilter) != B_OK) { 3351af4fa4bSClemens Zeidler unload_add_on(image); 3361af4fa4bSClemens Zeidler return NULL; 3371af4fa4bSClemens Zeidler } 3381af4fa4bSClemens Zeidler 3391af4fa4bSClemens Zeidler fFilterImages[ref] = image; 340*ca3341c7SAxel Dörfler return instantiateFilter(*this, settings); 3411af4fa4bSClemens Zeidler } 3421af4fa4bSClemens Zeidler 3431af4fa4bSClemens Zeidler 3440c7f804cSAxel Dörfler // #pragma mark - 3450c7f804cSAxel Dörfler 3460c7f804cSAxel Dörfler 347715bf3d1SAxel Dörfler BInboundMailProtocol::BInboundMailProtocol(const BMailAccountSettings& settings) 3481af4fa4bSClemens Zeidler : 349715bf3d1SAxel Dörfler BMailProtocol(settings) 3501af4fa4bSClemens Zeidler { 3511af4fa4bSClemens Zeidler LoadFilters(fAccountSettings.InboundSettings()); 3521af4fa4bSClemens Zeidler } 3531af4fa4bSClemens Zeidler 3541af4fa4bSClemens Zeidler 355715bf3d1SAxel Dörfler BInboundMailProtocol::~BInboundMailProtocol() 3561af4fa4bSClemens Zeidler { 3571af4fa4bSClemens Zeidler } 3581af4fa4bSClemens Zeidler 3591af4fa4bSClemens Zeidler 3601af4fa4bSClemens Zeidler void 361715bf3d1SAxel Dörfler BInboundMailProtocol::MessageReceived(BMessage* message) 3621af4fa4bSClemens Zeidler { 3631af4fa4bSClemens Zeidler switch (message->what) { 3641af4fa4bSClemens Zeidler case kMsgSyncMessages: 3651af4fa4bSClemens Zeidler { 366715bf3d1SAxel Dörfler NotiyMailboxSynchronized(SyncMessages()); 3671af4fa4bSClemens Zeidler break; 3681af4fa4bSClemens Zeidler } 3691af4fa4bSClemens Zeidler 3701af4fa4bSClemens Zeidler case kMsgFetchBody: 3711af4fa4bSClemens Zeidler { 3721af4fa4bSClemens Zeidler entry_ref ref; 3731af4fa4bSClemens Zeidler message->FindRef("ref", &ref); 374715bf3d1SAxel Dörfler status_t status = FetchBody(ref); 375b8d2bbd6SClemens Zeidler 376b8d2bbd6SClemens Zeidler BMessenger target; 377b8d2bbd6SClemens Zeidler if (message->FindMessenger("target", &target) != B_OK) 3781af4fa4bSClemens Zeidler break; 3790e657c0bSClemens Zeidler 380bcf60bbbSAxel Dörfler BMessage message(B_MAIL_BODY_FETCHED); 381b8d2bbd6SClemens Zeidler message.AddInt32("status", status); 382b8d2bbd6SClemens Zeidler message.AddRef("ref", &ref); 383b8d2bbd6SClemens Zeidler target.SendMessage(&message); 3841af4fa4bSClemens Zeidler break; 3851af4fa4bSClemens Zeidler } 3861af4fa4bSClemens Zeidler 3871af4fa4bSClemens Zeidler case kMsgMarkMessageAsRead: 3881af4fa4bSClemens Zeidler { 3891af4fa4bSClemens Zeidler entry_ref ref; 3901af4fa4bSClemens Zeidler message->FindRef("ref", &ref); 3919967dfd9SClemens Zeidler read_flags read = (read_flags)message->FindInt32("read"); 392715bf3d1SAxel Dörfler MarkMessageAsRead(ref, read); 3931af4fa4bSClemens Zeidler break; 3941af4fa4bSClemens Zeidler } 3951af4fa4bSClemens Zeidler 3961af4fa4bSClemens Zeidler case kMsgDeleteMessage: 3971af4fa4bSClemens Zeidler { 3981af4fa4bSClemens Zeidler entry_ref ref; 3991af4fa4bSClemens Zeidler message->FindRef("ref", &ref); 400715bf3d1SAxel Dörfler DeleteMessage(ref); 4011af4fa4bSClemens Zeidler break; 4021af4fa4bSClemens Zeidler } 4031af4fa4bSClemens Zeidler 4041af4fa4bSClemens Zeidler case kMsgAppendMessage: 4051af4fa4bSClemens Zeidler { 4061af4fa4bSClemens Zeidler entry_ref ref; 4071af4fa4bSClemens Zeidler message->FindRef("ref", &ref); 408715bf3d1SAxel Dörfler AppendMessage(ref); 4091af4fa4bSClemens Zeidler break; 4101af4fa4bSClemens Zeidler } 4111af4fa4bSClemens Zeidler 4121af4fa4bSClemens Zeidler default: 413715bf3d1SAxel Dörfler BMailProtocol::MessageReceived(message); 4140c7f804cSAxel Dörfler break; 4151af4fa4bSClemens Zeidler } 4161af4fa4bSClemens Zeidler } 4171af4fa4bSClemens Zeidler 4181af4fa4bSClemens Zeidler 419715bf3d1SAxel Dörfler status_t 420715bf3d1SAxel Dörfler BInboundMailProtocol::MarkMessageAsRead(const entry_ref& ref, read_flags flag) 4211af4fa4bSClemens Zeidler { 422715bf3d1SAxel Dörfler BNode node(&ref); 423715bf3d1SAxel Dörfler return write_read_attr(node, flag); 424715bf3d1SAxel Dörfler } 425715bf3d1SAxel Dörfler 426715bf3d1SAxel Dörfler 427715bf3d1SAxel Dörfler status_t 428715bf3d1SAxel Dörfler BInboundMailProtocol::AppendMessage(const entry_ref& ref) 429715bf3d1SAxel Dörfler { 430715bf3d1SAxel Dörfler return B_OK; 4311af4fa4bSClemens Zeidler } 4321af4fa4bSClemens Zeidler 4331af4fa4bSClemens Zeidler 4341af4fa4bSClemens Zeidler void 435715bf3d1SAxel Dörfler BInboundMailProtocol::NotiyMailboxSynchronized(status_t status) 4361af4fa4bSClemens Zeidler { 437715bf3d1SAxel Dörfler for (int32 i = 0; i < CountFilter(); i++) 438715bf3d1SAxel Dörfler FilterAt(i)->MailboxSynchronized(status); 4391af4fa4bSClemens Zeidler } 4401af4fa4bSClemens Zeidler 4411af4fa4bSClemens Zeidler 4420c7f804cSAxel Dörfler // #pragma mark - 4431af4fa4bSClemens Zeidler 4441af4fa4bSClemens Zeidler 445715bf3d1SAxel Dörfler BOutboundMailProtocol::BOutboundMailProtocol( 446715bf3d1SAxel Dörfler const BMailAccountSettings& settings) 4471af4fa4bSClemens Zeidler : 448715bf3d1SAxel Dörfler BMailProtocol(settings) 4491af4fa4bSClemens Zeidler { 450715bf3d1SAxel Dörfler LoadFilters(fAccountSettings.OutboundSettings()); 4511af4fa4bSClemens Zeidler } 4521af4fa4bSClemens Zeidler 4531af4fa4bSClemens Zeidler 454715bf3d1SAxel Dörfler BOutboundMailProtocol::~BOutboundMailProtocol() 4551af4fa4bSClemens Zeidler { 4561af4fa4bSClemens Zeidler } 4571af4fa4bSClemens Zeidler 4581af4fa4bSClemens Zeidler 4591af4fa4bSClemens Zeidler void 460715bf3d1SAxel Dörfler BOutboundMailProtocol::MessageReceived(BMessage* message) 4611af4fa4bSClemens Zeidler { 4621af4fa4bSClemens Zeidler switch (message->what) { 4631af4fa4bSClemens Zeidler case kMsgSendMessage: 464146357b5SAxel Dörfler SendMessages(*message, message->FindInt64("bytes")); 4651af4fa4bSClemens Zeidler break; 4661af4fa4bSClemens Zeidler 4671af4fa4bSClemens Zeidler default: 468715bf3d1SAxel Dörfler BMailProtocol::MessageReceived(message); 4691af4fa4bSClemens Zeidler } 4701af4fa4bSClemens Zeidler } 471