Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
handler.h
1 
2 /***************************************************************************
3  * handler.h - Fawkes plugin network handler
4  *
5  * Created: Thu Feb 12 10:23:02 2009
6  * Copyright 2006-2009 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __PLUGIN_NET_HANDLER_H_
25 #define __PLUGIN_NET_HANDLER_H_
26 
27 #include <netcomm/fawkes/handler.h>
28 #include <core/threading/thread.h>
29 #include <core/utils/lock_queue.h>
30 #include <core/utils/lock_list.h>
31 #include <core/utils/lock_map.h>
32 #include <config/change_handler.h>
33 #include <utils/system/fam.h>
34 #include <plugin/listener.h>
35 
36 #include <map>
37 #include <list>
38 #include <string>
39 #include <utility>
40 
41 namespace fawkes {
42 #if 0 /* just to make Emacs auto-indent happy */
43 }
44 #endif
45 
46 class ThreadCollector;
47 class FawkesNetworkHub;
48 class Plugin;
49 class PluginLoader;
50 class PluginListMessage;
51 class Configuration;
52 class FamThread;
53 
55 : public fawkes::Thread,
58 {
59  public:
62 
63  virtual void handle_network_message(FawkesNetworkMessage *msg);
64  virtual void client_connected(unsigned int clid);
65  virtual void client_disconnected(unsigned int clid);
66 
67  virtual void loop();
68 
69  virtual void plugin_loaded(const char *plugin_name);
70  virtual void plugin_unloaded(const char *plugin_name);
71 
72  private:
73  PluginListMessage * list_avail();
74  PluginListMessage * list_loaded();
75  void send_load_failure(const char *plugin_name, unsigned int client_id);
76  void send_load_success(const char *plugin_name, unsigned int client_id);
77  void send_unload_failure(const char *plugin_name, unsigned int client_id);
78  void send_unload_success(const char *plugin_name, unsigned int client_id);
79  void send_loaded(const char *plugin_name);
80  void send_unloaded(const char *plugin_name);
81 
82  void load(const char *plugin_list, unsigned int clid);
83  void unload(const char *plugin_list, unsigned int clid);
84 
85  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
86  protected: virtual void run() { Thread::run(); }
87 
88  private:
89  PluginManager *__manager;
90  FawkesNetworkHub *__hub;
91 
93 
94  LockList<unsigned int> __subscribers;
96 };
97 
98 } // end namespace fawkes
99 
100 #endif