1 # pragma once 2 3 # include <libpeas/peas.h> 4 # include <vector> 5 6 # include "astroid.hh" 7 # include "proto.hh" 8 9 namespace Astroid { 10 class PluginManager { 11 public: 12 PluginManager (bool disabled, bool test); 13 ~PluginManager (); 14 15 void refresh (); 16 17 PeasEngine * engine; 18 19 std::vector<PeasPluginInfo *> astroid_plugins; 20 std::vector<PeasPluginInfo *> thread_index_plugins; 21 std::vector<PeasPluginInfo *> thread_view_plugins; 22 23 class Extension { 24 protected: 25 PeasEngine * engine = NULL; 26 PeasExtensionSet * extensions = NULL; 27 bool active = false; 28 29 public: 30 Extension (); 31 virtual ~Extension (); 32 33 virtual void deactivate () = 0; 34 }; 35 36 class AstroidExtension : public Extension { 37 private: 38 Astroid * astroid; 39 40 public: 41 AstroidExtension (Astroid * a); 42 43 void deactivate () override; 44 45 bool get_user_agent (ustring &); 46 bool generate_mid (ustring &); 47 std::pair<ustring, ustring> get_tag_colors (ustring tag, ustring bg); 48 GMimeStream * process (const char * fname); 49 }; 50 51 AstroidExtension * astroid_extension; // set up from Astroid 52 53 class ThreadIndexExtension : public Extension { 54 private: 55 ThreadIndex * thread_index; 56 57 public: 58 ThreadIndexExtension (ThreadIndex * ti); 59 60 void deactivate () override; 61 62 bool format_tags (std::vector<ustring> tags, ustring bg, bool selected, ustring &out); 63 }; 64 65 class ThreadViewExtension : public Extension { 66 67 public: 68 ThreadViewExtension (ThreadView * ti); 69 70 void deactivate () override; 71 72 std::vector<ustring> get_allowed_uris (); 73 bool get_avatar_uri (ustring email, ustring type, int size, refptr<Message> m, ustring &out); 74 bool format_tags (std::vector<ustring> tags, ustring bg, bool selected, ustring &out); 75 std::string filter_part (std::string input_text, std::string input_html, std::string mime_type, bool is_patch); 76 77 }; 78 79 friend class ThreadIndexExtension; 80 friend class ThreadViewExtension; 81 friend class AstroidExtension; 82 friend class Extension; 83 84 protected: 85 bool disabled, test; 86 87 }; 88 } 89 90