KVIrc 5.2.6
Developer APIs
Plugin.h
Go to the documentation of this file.
1#ifndef _PLUGIN_H_
2#define _PLUGIN_H_
3//=============================================================================
4//
5// File : Plugin.h
6// Creation date : Wed Apr 11 04 2007 00:54:00 GMT+1 by TheXception
7//
8// This file is part of the KVIrc IRC client distribution
9// Copyright (C) 2007-2008 TheXception
10//
11// This program is FREE software. You can redistribute it and/or
12// modify it under the terms of the GNU General Public License
13// as published by the Free Software Foundation; either version 2
14// of the License, or (at your option) any later version.
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.
19// See the GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program. If not, write to the Free Software Foundation,
23// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24//
25//=============================================================================
26
27#include "KviModule.h"
28#include "KviPointerHashTable.h"
29#include <QLibrary>
30
31typedef int (*plugin_function)(int argc, char * argv[], char ** buffer);
32typedef int (*plugin_unload)();
33typedef int (*plugin_canunload)();
34typedef int (*plugin_load)();
35typedef int (*plugin_free)(char * pBuffer);
36
37class Plugin
38{
39protected:
40 // You have to create plugin instance by calling Plugin::load()
41 Plugin(QLibrary * pLibrary, const QString & name);
42
43public:
44 ~Plugin();
45
46private:
47 // shared
48 // internal
49 QLibrary * m_pLibrary;
50 QString m_szName;
51
52public:
53 static Plugin * load(const QString & szFileName);
54 bool pfree(char * pBuffer);
55 bool unload();
56 bool canunload();
57 int call(const QString & szFunctionName, int argc, char * argv[], char ** pBuffer);
58 QString name() const;
59 void setName(const QString & szName);
60
61protected:
62};
63
65{
66public:
69
70private:
71 // shared
73 // internal
75
76public:
78 bool checkUnload();
79 void unloadAll();
80
81protected:
82 bool findPlugin(QString & szName);
83 bool isPluginLoaded(const QString & szFileNameOrPathToLoad);
84 bool loadPlugin(const QString & szPluginPath);
85 Plugin * getPlugin(const QString & szPluginPath);
86};
87
88#endif //_PLUGIN_H_
Pointer Hash Table.
int(* plugin_free)(char *pBuffer)
Definition Plugin.h:35
int(* plugin_unload)()
Definition Plugin.h:32
int(* plugin_function)(int argc, char *argv[], char **buffer)
Definition Plugin.h:31
int(* plugin_load)()
Definition Plugin.h:34
int(* plugin_canunload)()
Definition Plugin.h:33
Definition KviKvsModuleInterface.h:112
A fast pointer hash table implementation.
Definition KviPointerHashTable.h:450
KviPointerHashTable< QString, Plugin > * m_pPluginDict
Definition Plugin.h:74
PluginManager()
Definition Plugin.cpp:211
bool loadPlugin(const QString &szPluginPath)
Definition Plugin.cpp:410
bool checkUnload()
Definition Plugin.cpp:334
bool m_bCanUnload
Definition Plugin.h:72
bool pluginCall(KviKvsModuleFunctionCall *c)
Definition Plugin.cpp:224
~PluginManager()
Definition Plugin.cpp:219
bool findPlugin(QString &szName)
Definition Plugin.cpp:373
Plugin * getPlugin(const QString &szPluginPath)
Definition Plugin.cpp:428
bool isPluginLoaded(const QString &szFileNameOrPathToLoad)
Definition Plugin.cpp:401
void unloadAll()
Definition Plugin.cpp:361
Definition Plugin.h:38
void setName(const QString &szName)
Definition Plugin.cpp:206
bool pfree(char *pBuffer)
Definition Plugin.cpp:139
QString m_szName
Definition Plugin.h:50
QString name() const
Definition Plugin.cpp:201
bool canunload()
Definition Plugin.cpp:169
bool unload()
Definition Plugin.cpp:154
int call(const QString &szFunctionName, int argc, char *argv[], char **pBuffer)
Definition Plugin.cpp:182
QLibrary * m_pLibrary
Definition Plugin.h:49
Plugin(QLibrary *pLibrary, const QString &name)
Definition Plugin.cpp:104
static Plugin * load(const QString &szFileName)
Definition Plugin.cpp:117
~Plugin()
Definition Plugin.cpp:110