1 #ifndef _KVI_MODULEMANAGER_H_
2 #define _KVI_MODULEMANAGER_H_
3 //=============================================================================
4 //
5 //   File : KviModuleManager.h
6 //   Creation date : Sat Aug 12 2000 20:31:17 by Szymon Stefanek
7 //
8 //   This file is part of the KVIrc IRC client distribution
9 //   Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net)
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 "kvi_settings.h"
28 #include "KviModule.h"
29 #include "KviPointerHashTable.h"
30 
31 #include <QTimer>
32 #include <QObject>
33 #include <vector>
34 
35 class KVIRC_API KviModuleManager : public QObject
36 {
37 	Q_OBJECT
38 public:
39 	KviModuleManager();
40 	~KviModuleManager();
41 
42 private:
43 	KviPointerHashTable<QString, KviModule> * m_pModuleDict;
44 	QTimer * m_pCleanupTimer;
45 	QString m_szLastError;
46 
47 public:
lastError()48 	QString & lastError() { return m_szLastError; };
49 	KviModule * findModule(const QString & modName);
50 	KviModule * getModule(const QString & modName);
51 	bool loadModule(const QString & modName);
52 	bool unloadModule(const QString & modName);
53 	bool unloadModule(KviModule * module);
54 	void unloadAllModules();
55 	//void registerDefaultCommands(KviModule * module);
56 	void loadModulesByCaps(const QString & caps, const QString & dir);
57 	void loadModulesByCaps(const QString & caps);
58 	bool hasLockedModules();
59 	void completeModuleNames(const QString & word, std::vector<QString> & matches);
60 
61 protected:
62 	void completeModuleNames(const QString & path, const QString & work, std::vector<QString> & matches);
63 public slots:
64 	void cleanupUnusedModules();
65 signals:
66 	void moduleAboutToUnload(KviModule * m);
67 };
68 
69 extern KVIRC_API KviModuleManager * g_pModuleManager;
70 
71 #endif //_KVI_MODULEMANAGER_H_
72