~ubuntu-branches/ubuntu/quantal/psi/quantal

« back to all changes in this revision

Viewing changes to src/psiplugin.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2009-09-25 17:49:51 UTC
  • mfrom: (6.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090925174951-lvm7kdap82o8xhn3
Tags: 0.13-1
* Updated to upstream version 0.13
* Set Standards-Version to 3.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * psiplugin.h - Psi plugin interface
3
 
 * Copyright (C) 2006-2006  Kevin Smith
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or
6
 
 * modify it under the terms of the GNU General Public License
7
 
 * as published by the Free Software Foundation; either version 2
8
 
 * of the License, or (at your option) any later version.
9
 
 *
10
 
 * You can also redistribute and/or modify this program under the
11
 
 * terms of the Psi License, specified in the accompanied COPYING
12
 
 * file, as published by the Psi Project; either dated January 1st,
13
 
 * 2005, or (at your option) any later version.
14
 
 *
15
 
 * This program is distributed in the hope that it will be useful,
16
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 
 * GNU General Public License for more details.
19
 
 *
20
 
 * You should have received a copy of the GNU General Public License
21
 
 * along with this library; if not, write to the Free Software
22
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
 
 *
24
 
 */
25
 
 
26
 
#ifndef PSIPLUGIN_H
27
 
#define PSIPLUGIN_H
28
 
 
29
 
#include <QObject>
30
 
#include <QtCore>
31
 
#include <QDomNode>
32
 
 
33
 
class PsiAccount;
34
 
class QDomElement;
35
 
class QString;
36
 
class QPluginLoader;
37
 
 
38
 
namespace XMPP {
39
 
          class Jid;
40
 
}
41
 
 
42
 
 
43
 
/**
44
 
 * \brief An abstract class for implementing a plugin
45
 
 */
46
 
class PsiPlugin : public QObject
47
 
{
48
 
        Q_OBJECT
49
 
public:
50
 
        /**
51
 
         * \brief Plugin Name
52
 
         * The full name of the plugin.
53
 
         * \return Plugin name
54
 
         */
55
 
        virtual QString name() const = 0;
56
 
        /** \brief Short name for the plugin
57
 
         *      This is the short name of the plugin, used for options structures. 
58
 
         * It must consist of only alphanumerics (no spaces or punctuation).
59
 
         * \return Short plugin name
60
 
        **/
61
 
        virtual QString shortName() const = 0;
62
 
        
63
 
        /**
64
 
         * \brief Plugin version
65
 
         * Free-form string of the plugin version. Human readable
66
 
         * \return Plugin version string
67
 
         */
68
 
        virtual QString version() const = 0; 
69
 
        
70
 
        virtual void message( const PsiAccount* account, const QString& message, const QString& fromJid, const QString& fromDisplay) 
71
 
        {Q_UNUSED(account);Q_UNUSED(message);Q_UNUSED(fromJid);Q_UNUSED(fromDisplay);}
72
 
 
73
 
        /**
74
 
         * \brief Plugin options widget
75
 
         * This method is called by the Psi options system to retrieve
76
 
         * a widget containing the options for this plugin.
77
 
         * This will then be embedded in the options dialog, so this
78
 
         * should be considered when designing the widget. Should return
79
 
         * NULL when there are no user-configurable options.
80
 
         */
81
 
        virtual QWidget* options() {return NULL;} 
82
 
        
83
 
 
84
 
        virtual bool processEvent( const PsiAccount* account, QDomNode &event ) {Q_UNUSED(account);Q_UNUSED(event);return true;}
85
 
 
86
 
        /**
87
 
         * Convenience method for plugins, allowing them to convert a QDomElement to a QString
88
 
         */
89
 
        static QString toString(const QDomNode& xml)
90
 
        {
91
 
                QTextStream stream;
92
 
                stream.setString(new QString(""));
93
 
                xml.save(stream, 0);
94
 
                return QString(*stream.string());
95
 
        }
96
 
        
97
 
signals:
98
 
        /**
99
 
         *      \brief Signals that the plugin wants to send a stanza.
100
 
         * 
101
 
         * \param account The account name, as used by the plugin interface.
102
 
         * \param stanza The stanza to be sent.
103
 
         */
104
 
        //void sendStanza( const PsiAccount* account, const QDomElement& stanza);
105
 
 
106
 
        /**
107
 
         *      \brief Signals that the plugin wants to send a stanza.
108
 
         * 
109
 
         * \param account The account name, as used by the plugin interface.
110
 
         * \param stanza The stanza to be sent.
111
 
         */
112
 
        void sendStanza( const PsiAccount* account, const QString& stanza);
113
 
        
114
 
        /**
115
 
         * \brief Requests an item in the Psi menu for the plugin
116
 
         * 
117
 
         * \param label The text to be inserted in the menu
118
 
         */
119
 
        void registerMainMenu( const QString& label);
120
 
 
121
 
        /**
122
 
         * \brief Sets an option (local to the plugin)
123
 
         * The options will be automatically prefixed by the plugin manager, so
124
 
         * there is no need to uniquely name the options. In the same way as the
125
 
         * main options system, a hierachy is available by dot-delimiting the 
126
 
         * levels ( e.g. "emoticons.show"). Use this and not setGlobalOption
127
 
         * in almost every case.
128
 
         * \param  option Option to set
129
 
         * \param value New option value
130
 
         */
131
 
        void setPluginOption( const QString& option, const QVariant& value);
132
 
        
133
 
        /**
134
 
         * \brief Gets an option (local to the plugin)
135
 
         * The options will be automatically prefixed by the plugin manager, so
136
 
         * there is no need to uniquely name the options. In the same way as the
137
 
         * main options system, a hierachy is available by dot-delimiting the 
138
 
         * levels ( e.g. "emoticons.show"). Use this and not getGlobalOption
139
 
         * in almost every case.
140
 
         * \param  option Option to set
141
 
         * \param value Return value
142
 
         */
143
 
        void getPluginOption( const QString& option, QVariant& value);
144
 
        
145
 
        /**
146
 
         * \brief Sets a global option (not local to the plugin)
147
 
         * The options will be passed unaltered by the plugin manager, so
148
 
         * the options are presented as they are stored in the main option
149
 
         * system. Use setPluginOption instead of this in almost every case.
150
 
         * \param  option Option to set
151
 
         * \param value New option value
152
 
         */
153
 
        void setGlobalOption( const QString& option, const QVariant& value);
154
 
        
155
 
        /**
156
 
         * \brief Gets a global option (not local to the plugin)
157
 
         * The options will be passed unaltered by the plugin manager, so
158
 
         * the options are presented as they are stored in the main option
159
 
         * system. Use getPluginOption instead of this in almost every case.
160
 
         * \param  option Option to set
161
 
         * \param value Return value
162
 
         */
163
 
        void getGlobalOption( const QString& option, QVariant& value);
164
 
        
165
 
//protected:
166
 
 
167
 
        
168
 
 
169
 
};
170
 
 
171
 
Q_DECLARE_INTERFACE(PsiPlugin, "org.psi-im.plugin/0.2.1");
172
 
 
173
 
#endif