2
* psiplugin.h - Psi plugin interface
3
* Copyright (C) 2006-2006 Kevin Smith
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.
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.
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.
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
44
* \brief An abstract class for implementing a plugin
46
class PsiPlugin : public QObject
52
* The full name of the plugin.
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
61
virtual QString shortName() const = 0;
64
* \brief Plugin version
65
* Free-form string of the plugin version. Human readable
66
* \return Plugin version string
68
virtual QString version() const = 0;
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);}
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.
81
virtual QWidget* options() {return NULL;}
84
virtual bool processEvent( const PsiAccount* account, QDomNode &event ) {Q_UNUSED(account);Q_UNUSED(event);return true;}
87
* Convenience method for plugins, allowing them to convert a QDomElement to a QString
89
static QString toString(const QDomNode& xml)
92
stream.setString(new QString(""));
94
return QString(*stream.string());
99
* \brief Signals that the plugin wants to send a stanza.
101
* \param account The account name, as used by the plugin interface.
102
* \param stanza The stanza to be sent.
104
//void sendStanza( const PsiAccount* account, const QDomElement& stanza);
107
* \brief Signals that the plugin wants to send a stanza.
109
* \param account The account name, as used by the plugin interface.
110
* \param stanza The stanza to be sent.
112
void sendStanza( const PsiAccount* account, const QString& stanza);
115
* \brief Requests an item in the Psi menu for the plugin
117
* \param label The text to be inserted in the menu
119
void registerMainMenu( const QString& label);
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
131
void setPluginOption( const QString& option, const QVariant& value);
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
143
void getPluginOption( const QString& option, QVariant& value);
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
153
void setGlobalOption( const QString& option, const QVariant& value);
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
163
void getGlobalOption( const QString& option, QVariant& value);
171
Q_DECLARE_INTERFACE(PsiPlugin, "org.psi-im.plugin/0.2.1");