summaryrefslogtreecommitdiffstats
path: root/src/plugin/manager.hh
blob: a346667e5965541c8e4a1b5ee1b6060a09d9474e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# pragma once

# include <libpeas/peas.h>
# include <vector>

# include "astroid.hh"
# include "proto.hh"

namespace Astroid {
  class PluginManager {
    public:
      PluginManager (bool disabled, bool test);
      ~PluginManager ();

      void refresh ();

      PeasEngine * engine;

      std::vector<PeasPluginInfo *>  astroid_plugins;
      std::vector<PeasPluginInfo *>  thread_index_plugins;
      std::vector<PeasPluginInfo *>  thread_view_plugins;

      class Extension {
        protected:
          PeasEngine        * engine = NULL;
          PeasExtensionSet  * extensions = NULL;
          bool active = false;

        public:
          Extension ();
          virtual ~Extension ();

          virtual void deactivate () = 0;
      };

      class AstroidExtension : public Extension {
        private:
          Astroid * astroid;

        public:
          AstroidExtension (Astroid * a);

          void deactivate () override;

          bool get_user_agent (ustring &);
          bool generate_mid (ustring &);
          std::pair<ustring, ustring> get_tag_colors (ustring tag, ustring bg);
          GMimeStream * process (const char * fname);
      };

      AstroidExtension * astroid_extension; // set up from Astroid

      class ThreadIndexExtension : public Extension {
        private:
          ThreadIndex * thread_index;

        public:
          ThreadIndexExtension (ThreadIndex * ti);

          void deactivate () override;

          bool format_tags (std::vector<ustring> tags, ustring bg, bool selected, ustring &out);
      };

      class ThreadViewExtension : public Extension {

        public:
          ThreadViewExtension (ThreadView * ti);

          void deactivate () override;

          std::vector<ustring> get_allowed_uris ();
          bool get_avatar_uri (ustring email, ustring type, int size, refptr<Message> m, ustring &out);
          bool format_tags (std::vector<ustring> tags, ustring bg, bool selected, ustring &out);
          std::string filter_part (std::string input_text, std::string input_html, std::string mime_type, bool is_patch);

      };

      friend class ThreadIndexExtension;
      friend class ThreadViewExtension;
      friend class AstroidExtension;
      friend class Extension;

    protected:
      bool disabled, test;

  };
}