KVIrc  4.9.2
DeveloperAPIs
KviKvsScriptAddonManager.h
Go to the documentation of this file.
1 #ifndef _KVI_KVS_SCRIPTADDONMANAGER_H_
2 #define _KVI_KVS_SCRIPTADDONMANAGER_H_
3 //=============================================================================
4 //
5 // File : KviKvsScriptAddonManager.h
6 // Creation date : Thu 31 Mar 2005 01:21:23 by Szymon Stefanek
7 //
8 // This file is part of the KVIrc IRC client distribution
9 // Copyright (C) 2005-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 "KviHeapObject.h"
29 #include "KviQString.h"
30 #include "KviPointerHashTable.h"
31 
32 #include <QStringList>
33 
35 class KviKvsScript;
36 class KviWindow;
37 class QPixmap;
38 
40 {
42 
43 protected:
46  const QString & szName,
47  const QString & szVersion,
48  const QString & szVisibleNameCode,
49  const QString & szDescriptionCode,
50  const QString & szUninstallCallbackCode,
51  const QString & szIconId);
52 
53 public:
55 
56 public: // KviDict wants that... how to restrict the deletion to KviKvsScriptAddonManager only ?
58 
59 protected:
60  QString m_szName; // the short name of the addon
61  QString m_szVersion; // x.y.z
62  KviKvsScript * m_pVisibleNameScript; // the visible name, possibly translated
63  KviKvsScript * m_pDescriptionScript; // the description, possibly translated
64  KviKvsScript * m_pUninstallCallback; // uninstall callback
65  KviKvsScript * m_pConfigureCallback; // configure callback
66  KviKvsScript * m_pHelpCallback; // help callback
67  QString m_szDescription; // parsed description
68  QString m_szVisibleName; // parsed visible name
69  QString m_szIconId; // the id of the associated icon
70  QStringList m_lInstalledFiles; // the list of the installed files
71 public:
72  const QStringList & installedFiles() const { return m_lInstalledFiles; };
73  const QString & name() const { return m_szName; };
74  const QString & version() const { return m_szVersion; };
75  const QString & visibleName();
76  const QString & description();
77  const QString & visibleNameCode();
78  const QString & descriptionCode();
79  const QString & uninstallCallbackCode();
80  const QString & configureCallbackCode();
81  const QString & helpCallbackCode();
82  const QString & iconId() { return m_szIconId; };
83  QPixmap * icon();
88  void addInstalledFile(const QString & szFileName);
89  void setConfigureCallback(const QString & szConfigureCallbackCode);
90  void setHelpCallback(const QString & szHelpCallbackCode);
91  void executeConfigureCallback(KviWindow * pWnd);
92  void executeHelpCallback(KviWindow * pWnd);
93 
94 protected:
95  bool load(KviConfigurationFile * cfg, const QString & szName);
96  void save(KviConfigurationFile * cfg);
97  void executeUninstallCallback(KviWindow * pWnd);
98  // this assumes that the script pointers are clean (i.e. not needing to be freed!)
99  void allocateScripts(const QString & sVisibleNameCode, const QString & szDescriptionCode, const QString & szUninstallCallbackCode);
100 };
101 
103 {
104 public:
105  QString szName; // the addon name
106  QString szVersion; // the addon version in form x.y.z
107  QString szVisibleNameScript; // the code that evaluates to the visible name, possibly translated
108  QString szDescriptionScript; // the code that evaluates to the description, possibly translated
109  QString szUninstallCallbackScript; // the uninstall callback code, will be executed at uninstallation
110  QString szIconId; // the icon identifier (scaled to 32x32 atm)
111 };
112 
114 {
115 public:
118 
119 protected:
121  // this class implements delayed loading
122  QString m_szFileName; // the file name that we will load from
123  bool m_bLoaded; // have we loaded stuff from disk yet ?
125 public:
126  static KviKvsScriptAddonManager * instance() { return m_pInstance; };
127  static void init(); // called by KviKvs::init()
128  static void done(); // called by KviKvs::done()
129 
130  bool registerAddon(KviKvsScriptAddonRegistrationData * d);
131  KviKvsScriptAddon * findAddon(const QString & szName);
132  bool unregisterAddon(const QString & szName, KviWindow * pWnd, bool bExecuteUninstallCallback = true, bool bUninstallFiles = true);
134 
135  void clear();
136  void load(const QString & szFileName); // called in the KviKvs namespace
137  void save(const QString & szFileName); // called in the KViKvs namespace
138 protected:
139  void delayedLoad();
140 };
141 
142 #endif
QString m_szVisibleName
Definition: KviKvsScriptAddonManager.h:68
KviKvsScript * m_pHelpCallback
Definition: KviKvsScriptAddonManager.h:66
Definition: KviHeapObject.h:124
KviKvsScript * m_pConfigureCallback
Definition: KviKvsScriptAddonManager.h:65
#define KVIRC_API
Definition: kvi_settings.h:128
QString m_szVersion
Definition: KviKvsScriptAddonManager.h:61
QString m_szName
Definition: KviKvsScriptAddonManager.h:60
#define a
Definition: detector.cpp:91
QStringList m_lInstalledFiles
Definition: KviKvsScriptAddonManager.h:70
The KVIrc Script class.
Definition: KviKvsScript.h:59
Definition: KviConfigurationFile.h:48
static KviKvsScriptAddonManager * instance()
Definition: KviKvsScriptAddonManager.h:126
KviKvsScript * m_pVisibleNameScript
Definition: KviKvsScriptAddonManager.h:62
KviKvsScript * m_pDescriptionScript
Definition: KviKvsScriptAddonManager.h:63
btnDict clear()
Pointer Hash Table.
QString m_szFileName
Definition: KviKvsScriptAddonManager.h:122
char s d
Definition: KviIrcNumericCodes.h:391
void done()
Definition: KviKvs.cpp:50
const QString & name() const
Definition: KviKvsScriptAddonManager.h:73
const QStringList & installedFiles() const
Definition: KviKvsScriptAddonManager.h:72
bool save(KviThemeInfo &options, bool bSaveIcons)
Definition: KviOptions.cpp:986
const QString & iconId()
Definition: KviKvsScriptAddonManager.h:82
QString szVersion
Definition: KviKvsScriptAddonManager.h:106
QString szIconId
Definition: KviKvsScriptAddonManager.h:110
const QString & version() const
Definition: KviKvsScriptAddonManager.h:74
Definition: KviKvsScriptAddonManager.h:113
QString szVisibleNameScript
Definition: KviKvsScriptAddonManager.h:107
Base class for all windows in KVIrc.
Definition: KviWindow.h:74
Definition: KviKvsScriptAddonManager.h:102
Definition: KviKvsScriptAddonManager.h:39
Heap Object.
QString szUninstallCallbackScript
Definition: KviKvsScriptAddonManager.h:109
QString szDescriptionScript
Definition: KviKvsScriptAddonManager.h:108
QString m_szDescription
Definition: KviKvsScriptAddonManager.h:67
int init()
Definition: winamp.cpp:118
This file contains compile time settings.
bool m_bLoaded
Definition: KviKvsScriptAddonManager.h:123
QString m_szIconId
Definition: KviKvsScriptAddonManager.h:69
KviKvsScript * m_pUninstallCallback
Definition: KviKvsScriptAddonManager.h:64
Helper functions for the QString class.
QString szName
Definition: KviKvsScriptAddonManager.h:105
KviPointerHashTable< QString, KviKvsScriptAddon > * m_pAddonDict
Definition: KviKvsScriptAddonManager.h:124
static KviKvsScriptAddonManager * m_pInstance
Definition: KviKvsScriptAddonManager.h:120
void load(const QString &szFileName)
Definition: KviKvsScriptAddonManager.cpp:297