1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
/*
* battleshipgameplugin.h - Battleship Game plugin
* Copyright (C) 2014 Aleksey Andreev
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* You can also redistribute and/or modify this program under the
* terms of the Psi License, specified in the accompanied COPYING
* file, as published by the Psi Project; either dated January 1st,
* 2005, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef BATTLESHIPGAMEPLUGIN_H
#define BATTLESHIPGAMEPLUGIN_H
#include <QtGui>
#include <QtCore>
#include <QObject>
#include <QDomElement>
#include "psiplugin.h"
#include "plugininfoprovider.h"
#include "optionaccessor.h"
#include "optionaccessinghost.h"
#include "iconfactoryaccessor.h"
#include "iconfactoryaccessinghost.h"
#include "toolbariconaccessor.h"
#include "activetabaccessor.h"
#include "activetabaccessinghost.h"
#include "accountinfoaccessor.h"
#include "accountinfoaccessinghost.h"
#include "contactinfoaccessor.h"
#include "contactinfoaccessinghost.h"
#include "stanzasender.h"
#include "stanzasendinghost.h"
#include "stanzafilter.h"
#include "eventcreator.h"
#include "eventcreatinghost.h"
#include "soundaccessor.h"
#include "soundaccessinghost.h"
#include "menuaccessor.h"
#include "popupaccessor.h"
#include "popupaccessinghost.h"
#include "ui_options.h"
class BattleshipGamePlugin : public QObject, public PsiPlugin, public PluginInfoProvider, public OptionAccessor,
public IconFactoryAccessor, public ToolbarIconAccessor, public ActiveTabAccessor, public AccountInfoAccessor,
public ContactInfoAccessor, public StanzaSender, public StanzaFilter, public EventCreator, public SoundAccessor,
public MenuAccessor, public PopupAccessor
{
Q_OBJECT
#ifdef HAVE_QT5
Q_PLUGIN_METADATA(IID "com.psi-plus.BattleshipGame")
#endif
Q_INTERFACES(PsiPlugin PluginInfoProvider OptionAccessor IconFactoryAccessor ToolbarIconAccessor
ActiveTabAccessor AccountInfoAccessor ContactInfoAccessor StanzaSender StanzaFilter
EventCreator SoundAccessor MenuAccessor PopupAccessor)
public:
explicit BattleshipGamePlugin(QObject *parent = 0);
// Psiplugin
virtual QString name() const;
virtual QString shortName() const;
virtual QString version() const;
virtual QWidget* options();
virtual bool enable();
virtual bool disable();
virtual void applyOptions();
virtual void restoreOptions();
virtual QPixmap icon() const;
// Plugin info provider
virtual QString pluginInfo();
// Option accessor
virtual void setOptionAccessingHost(OptionAccessingHost*);
virtual void optionChanged(const QString&);
// Iconfactory accessor
virtual void setIconFactoryAccessingHost(IconFactoryAccessingHost*);
// Toolbar icon accessor
virtual QList<QVariantHash> getButtonParam();
virtual QAction* getAction(QObject* , int , const QString& );
// Activetab accessor
virtual void setActiveTabAccessingHost(ActiveTabAccessingHost*);
// Account info accessor
virtual void setAccountInfoAccessingHost(AccountInfoAccessingHost*);
// Contact info accessor
virtual void setContactInfoAccessingHost(ContactInfoAccessingHost*);
// Stanza sender
virtual void setStanzaSendingHost(StanzaSendingHost*);
// Stanza filter
virtual bool incomingStanza(int account, const QDomElement& xml);
virtual bool outgoingStanza(int account, QDomElement& xml);
// Event creator
virtual void setEventCreatingHost(EventCreatingHost*);
// Sound accessor
virtual void setSoundAccessingHost(SoundAccessingHost*);
// Menu accessor
virtual QList<QVariantHash> getAccountMenuParam();
virtual QList<QVariantHash> getContactMenuParam();
virtual QAction* getContactAction(QObject*, int, const QString&);
virtual QAction* getAccountAction(QObject*, int);
// Popup accessor
virtual void setPopupAccessingHost(PopupAccessingHost*);
private:
bool enabled_;
ActiveTabAccessingHost *psiTab;
IconFactoryAccessingHost *psiIcon;
AccountInfoAccessingHost *psiAccInfo;
ContactInfoAccessingHost *psiContactInfo;
StanzaSendingHost *psiSender;
EventCreatingHost *psiEvent;
SoundAccessingHost *psiSound;
PopupAccessingHost *psiPopup;
// --
Ui::options ui_;
private:
void inviteDlg(int account, QString full_jid);
private slots:
void toolButtonPressed();
void menuActivated();
void doPsiEvent(int, QString, QString, QObject *, const char *);
void sendGameStanza(int account, const QString stanza);
void testSound();
void getSound();
void doPopup(QString text);
void playSound(QString);
};
#endif // BATTLESHIPGAMEPLUGIN_H
|