KVIrc  4.9.2
DeveloperAPIs
Plugin.h
Go to the documentation of this file.
1 #ifndef _PLUGIN_H_
2 #define _PLUGIN_H_
3 
4 //=============================================================================
5 //
6 // File : Plugin.h
7 // Creation date : Wed Apr 11 04 2007 00:54:00 GMT+1 by TheXception
8 //
9 // This file is part of the KVIrc IRC client distribution
10 // Copyright (C) 2007-2008 TheXception
11 //
12 // This program is FREE software. You can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the HOPE that it will be USEFUL,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 // See the GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program. If not, write to the Free Software Foundation,
24 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 //
26 //=============================================================================
27 
28 #include "KviModule.h"
29 #include "KviPointerHashTable.h"
30 #include <QLibrary>
31 
32 typedef int (*plugin_function)(int argc, char * argv[], char ** buffer);
33 typedef int (*plugin_unload)();
34 typedef int (*plugin_canunload)();
35 typedef int (*plugin_load)();
36 typedef int (*plugin_free)(char * pBuffer);
37 
38 class Plugin
39 {
40 protected:
41  // You have to create plugin instance by calling Plugin::load()
42  Plugin(QLibrary * pLibrary, const QString & name);
43 
44 public:
45  ~Plugin();
46 
47 private:
48  // shared
49  // internal
50  QLibrary * m_pLibrary;
51  QString m_szName;
52 
53 public:
54  static Plugin * load(const QString & szFileName);
55  bool pfree(char * pBuffer);
56  bool unload();
57  bool canunload();
58  int call(const QString & szFunctionName, int argc, char * argv[], char ** pBuffer);
59  QString name() const;
60  void setName(const QString & szName);
61 
62 protected:
63 };
64 
66 {
67 public:
68  PluginManager();
70 
71 private:
72  // shared
74  // internal
76 
77 public:
79  bool checkUnload();
80  void unloadAll();
81 
82 protected:
83  bool findPlugin(QString & szName);
84  bool isPluginLoaded(const QString & szFileNameOrPathToLoad);
85  bool loadPlugin(const QString & szPluginPath);
86  Plugin * getPlugin(const QString & szPluginPath);
87 };
88 
89 #endif //_PLUGIN_H_
Plugin(QLibrary *pLibrary, const QString &name)
Definition: Plugin.cpp:108
bool unload()
Definition: Plugin.cpp:158
Definition: Plugin.h:65
char s char s char s s s s s char char c s *s c s s s d c s *s d c d d d d c
Definition: KviIrcNumericCodes.h:391
void setName(const QString &szName)
Definition: Plugin.cpp:210
bool m_bCanUnload
Definition: Plugin.h:73
int call(const QString &szFunctionName, int argc, char *argv[], char **pBuffer)
Definition: Plugin.cpp:186
~Plugin()
Definition: Plugin.cpp:114
Plugin * getPlugin(const QString &szPluginPath)
Definition: Plugin.cpp:432
QString name() const
Definition: Plugin.cpp:205
void unloadAll()
Definition: Plugin.cpp:365
int(* plugin_canunload)()
Definition: Plugin.h:34
bool canunload()
Definition: Plugin.cpp:173
Pointer Hash Table.
PluginManager()
Definition: Plugin.cpp:215
int(* plugin_function)(int argc, char *argv[], char **buffer)
Definition: Plugin.h:32
static Plugin * load(const QString &szFileName)
Definition: Plugin.cpp:121
Definition: Plugin.h:38
QLibrary * m_pLibrary
Definition: Plugin.h:50
int(* plugin_load)()
Definition: Plugin.h:35
bool pluginCall(KviKvsModuleFunctionCall *c)
Definition: Plugin.cpp:228
bool isPluginLoaded(const QString &szFileNameOrPathToLoad)
Definition: Plugin.cpp:405
~PluginManager()
Definition: Plugin.cpp:223
Definition: KviKvsModuleInterface.h:110
bool pfree(char *pBuffer)
Definition: Plugin.cpp:143
QString m_szName
Definition: Plugin.h:51
bool findPlugin(QString &szName)
Definition: Plugin.cpp:377
bool loadPlugin(const QString &szPluginPath)
Definition: Plugin.cpp:414
int(* plugin_free)(char *pBuffer)
Definition: Plugin.h:36
int(* plugin_unload)()
Definition: Plugin.h:33
KviPointerHashTable< QString, Plugin > * m_pPluginDict
Definition: Plugin.h:75
bool checkUnload()
Definition: Plugin.cpp:338