1 /* 2 * Copyright 2011-2015, Haiku, Inc. All rights reserved. 3 * Copyright 2011, Clemens Zeidler <haiku@clemens-zeidler.de> 4 * Distributed under the terms of the MIT License. 5 */ 6 #ifndef FILTER_LIST_H 7 #define FILTER_LIST_H 8 9 10 #include <MailSettings.h> 11 #include <MailSettingsView.h> 12 13 14 enum direction { 15 kIncoming, 16 kOutgoing 17 }; 18 19 20 struct FilterInfo { 21 image_id image; 22 entry_ref ref; 23 BMailSettingsView* (*instantiateSettingsView)( 24 const BMailAccountSettings& accountSettings, 25 const BMailAddOnSettings& settings); 26 BString (*name)( 27 const BMailAccountSettings& accountSettings, 28 const BMailAddOnSettings* settings); 29 }; 30 31 32 class FilterList { 33 public: 34 FilterList(direction dir); 35 ~FilterList(); 36 37 void Reload(); 38 39 int32 CountInfos() const; 40 const FilterInfo& InfoAt(int32 index) const; 41 int32 InfoIndexFor(const entry_ref& ref) const; 42 43 BString SimpleName(int32 index, 44 const BMailAccountSettings& settings) const; 45 BString SimpleName(const entry_ref& ref, 46 const BMailAccountSettings& settings) const; 47 BString DescriptiveName(int32 index, 48 const BMailAccountSettings& accountSettings, 49 const BMailAddOnSettings* settings) const; 50 BString DescriptiveName(const entry_ref& ref, 51 const BMailAccountSettings& accountSettings, 52 const BMailAddOnSettings* settings) const; 53 54 BMailSettingsView* CreateSettingsView( 55 const BMailAccountSettings& accountSettings, 56 const BMailAddOnSettings& settings); 57 58 private: 59 void _MakeEmpty(); 60 status_t _LoadAddOn(BEntry& entry); 61 62 private: 63 direction fDirection; 64 std::vector<FilterInfo> fList; 65 }; 66 67 68 #endif // FILTER_LIST_H 69