~ubuntu-branches/ubuntu/trusty/kvirc/trusty

« back to all changes in this revision

Viewing changes to src/kvirc/kvs/kvi_kvs_scriptaddonmanager.h

  • Committer: Bazaar Package Importer
  • Author(s): Kai Wasserbäch, Kai Wasserbäch, Raúl Sánchez Siles
  • Date: 2011-02-12 10:40:21 UTC
  • mfrom: (14.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110212104021-5mh4f75jlku20mnt
The combined "Twisted Experiment" and "Nocturnal Raid" release.

[ Kai Wasserbäch ]
* Synced to upstream's SVN revision 5467.
* debian/rules:
  - Added .PHONY line.
  - Resurrect -DMANUAL_REVISION, got lost somewhere and we build SVN
    revisions again.
  - Replace "-DWITH_NO_EMBEDDED_CODE=YES" with "-DWANT_CRYPTOPP=YES".
  - Change the remaining -DWITH/-DWITHOUT to the new -DWANT syntax.
* debian/control:
  - Removed DMUA, I'm a DD now.
  - Changed my e-mail address.
  - Removed unneeded relationships (no upgrades over two releases are
    supported).
  - Fix Suggests for kvirc-dbg.
  - kvirc-data: Make the "Suggests: kvirc" a Recommends, doesn't make much
    sense to install the -data package without the program.
* debian/source/local-options: Added with "unapply-patches".
* debian/kvirc.lintian-overrides: Updated to work for 4.1.1.
* debian/patches/21_make_shared-mime-info_B-D_superfluous.patch: Updated.
* debian/kvirc-data.install: Added .notifyrc.

[ Raúl Sánchez Siles ]
* Stating the right version where kvirc-data break and replace should happen.
* Fixing link to license file.
* Added French and Portuguese man pages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef _KVI_KVS_SCRIPTADDONMANAGER_H_
2
 
#define _KVI_KVS_SCRIPTADDONMANAGER_H_
3
 
//=============================================================================
4
 
//
5
 
//   File : kvi_kvs_scriptaddonmanager.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-2008 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 opinion) 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 "kvi_heapobject.h"
29
 
#include "kvi_qstring.h"
30
 
#include "kvi_pointerhashtable.h"
31
 
 
32
 
#include <QStringList>
33
 
 
34
 
class KviConfig;
35
 
class KviKvsScript;
36
 
class KviWindow;
37
 
class QPixmap;
38
 
 
39
 
class KVIRC_API KviKvsScriptAddon : public KviHeapObject
40
 
{
41
 
        friend class KviKvsScriptAddonManager;
42
 
protected:
43
 
        KviKvsScriptAddon();
44
 
        KviKvsScriptAddon(
45
 
                        const QString &szName,
46
 
                        const QString &szVersion,
47
 
                        const QString &szVisibleNameCode,
48
 
                        const QString &szDescriptionCode,
49
 
                        const QString &szUninstallCallbackCode,
50
 
                        const QString &szIconId
51
 
                );
52
 
public:
53
 
        KviKvsScriptAddon(const KviKvsScriptAddon &a);
54
 
public: // KviDict wants that... how to restrict the deletion to KviKvsScriptAddonManager only ?
55
 
        ~KviKvsScriptAddon();
56
 
protected:
57
 
        QString        m_szName;              // the short name of the addon
58
 
        QString        m_szVersion;           // x.y.z
59
 
        KviKvsScript * m_pVisibleNameScript;  // the visible name, possibly translated
60
 
        KviKvsScript * m_pDescriptionScript;  // the description, possibly translated
61
 
        KviKvsScript * m_pUninstallCallback;  // uninstall callback
62
 
        KviKvsScript * m_pConfigureCallback;  // configure callback
63
 
        KviKvsScript * m_pHelpCallback;       // help callback
64
 
        QString        m_szDescription;       // parsed description
65
 
        QString        m_szVisibleName;       // parsed visible name
66
 
        QString        m_szIconId;            // the id of the associated icon
67
 
        QStringList    m_lInstalledFiles;     // the list of the installed files
68
 
public:
69
 
        const QStringList &installedFiles() const { return m_lInstalledFiles; };
70
 
        const QString &name() const { return m_szName; };
71
 
        const QString &version() const { return m_szVersion; };
72
 
        const QString &visibleName();
73
 
        const QString &description();
74
 
        const QString &visibleNameCode();
75
 
        const QString &descriptionCode();
76
 
        const QString &uninstallCallbackCode();
77
 
        const QString &configureCallbackCode();
78
 
        const QString &helpCallbackCode();
79
 
        const QString &iconId(){ return m_szIconId; };
80
 
        QPixmap * icon();
81
 
        ///
82
 
        /// Register a file to be uninstalled after the uninstall callback.
83
 
        /// The file name *MUST* be relative to the local kvirc directory.
84
 
        ///
85
 
        void addInstalledFile(const QString &szFileName);
86
 
        void setConfigureCallback(const QString &szConfigureCallbackCode);
87
 
        void setHelpCallback(const QString &szHelpCallbackCode);
88
 
        void executeConfigureCallback(KviWindow * pWnd);
89
 
        void executeHelpCallback(KviWindow * pWnd);
90
 
protected:
91
 
        bool load(KviConfig * cfg,const QString &szName);
92
 
        void save(KviConfig * cfg);
93
 
        void executeUninstallCallback(KviWindow * pWnd);
94
 
        // this assumes that the script pointers are clean (i.e. not needing to be freed!)
95
 
        void allocateScripts(const QString &sVisibleNameCode,const QString &szDescriptionCode,const QString &szUninstallCallbackCode);
96
 
};
97
 
 
98
 
class KVIRC_API KviKvsScriptAddonRegistrationData
99
 
{
100
 
public:
101
 
        QString szName;                      // the addon name
102
 
        QString szVersion;                   // the addon version in form x.y.z
103
 
        QString szVisibleNameScript;         // the code that evaluates to the visible name, possibly translated
104
 
        QString szDescriptionScript;         // the code that evaluates to the description, possibly translated
105
 
        QString szUninstallCallbackScript;   // the uninstall callback code, will be executed at uninstallation
106
 
        QString szIconId;                    // the icon identifier (scaled to 32x32 atm)
107
 
};
108
 
 
109
 
class KVIRC_API KviKvsScriptAddonManager
110
 
{
111
 
public:
112
 
        KviKvsScriptAddonManager();
113
 
        ~KviKvsScriptAddonManager();
114
 
protected:
115
 
        static KviKvsScriptAddonManager  * m_pInstance;
116
 
        // this class implements delayed loading
117
 
        QString                            m_szFileName;  // the file name that we will load from
118
 
        bool                               m_bLoaded;     // have we loaded stuff from disk yet ?
119
 
        KviPointerHashTable<QString,KviKvsScriptAddon>         * m_pAddonDict;  // all the registered addons
120
 
public:
121
 
        static KviKvsScriptAddonManager * instance(){ return m_pInstance; };
122
 
        static void init(); // called by KviKvs::init()
123
 
        static void done(); // called by KviKvs::done()
124
 
 
125
 
        bool registerAddon(KviKvsScriptAddonRegistrationData * d);
126
 
        KviKvsScriptAddon * findAddon(const QString &szName);
127
 
        bool unregisterAddon(const QString &szName,KviWindow * pWnd,bool bExecuteUninstallCallback = true,bool bUninstallFiles = true);
128
 
        KviPointerHashTable<QString,KviKvsScriptAddon> * addonDict();
129
 
 
130
 
        void clear();
131
 
        void load(const QString &szFileName); // called in the KviKvs namespace
132
 
        void save(const QString &szFileName); // called in the KViKvs namespace
133
 
protected:
134
 
        void delayedLoad();
135
 
};
136
 
 
137
 
#endif //!_KVI_KVS_SCRIPTADDONMANAGER_H_