File: clientswitcherplugin.h

package info (click to toggle)
psi-plugins 1.5-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 4,368 kB
  • sloc: cpp: 42,063; xml: 714; ansic: 84; makefile: 61; sh: 12
file content (164 lines) | stat: -rw-r--r-- 5,458 bytes parent folder | download
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
 * clientswitcherplugin.h - Client Switcher plugin
 * Copyright (C) 2010  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 PLUGIN_MAIN_H
#define PLUGIN_MAIN_H

#include <QtGui>
#include <QtCore>
#include <QDomElement>

#include "ui_options.h"

#include "psiplugin.h"
#include "optionaccessor.h"
#include "optionaccessinghost.h"
#include "stanzasender.h"
#include "stanzasendinghost.h"
#include "stanzafilter.h"
#include "plugininfoprovider.h"
#include "applicationinfoaccessor.h"
#include "applicationinfoaccessinghost.h"
#include "popupaccessor.h"
#include "popupaccessinghost.h"
#include "accountinfoaccessor.h"
#include "accountinfoaccessinghost.h"
#include "psiaccountcontroller.h"
#include "psiaccountcontrollinghost.h"
#include "contactinfoaccessor.h"
#include "contactinfoaccessinghost.h"
#include "iconfactoryaccessor.h"
#include "iconfactoryaccessinghost.h"

#include "accountsettings.h"

class ClientSwitcherPlugin: public QObject, public PsiPlugin, public OptionAccessor, public StanzaSender, public StanzaFilter, public PluginInfoProvider, public PopupAccessor, public ApplicationInfoAccessor, public AccountInfoAccessor, public PsiAccountController, public ContactInfoAccessor, public IconFactoryAccessor

{
	Q_OBJECT
#ifdef HAVE_QT5
	Q_PLUGIN_METADATA(IID "com.psi-plus.ClientSwitcherPlugin")
#endif
	Q_INTERFACES(PsiPlugin OptionAccessor StanzaSender StanzaFilter PluginInfoProvider PopupAccessor ApplicationInfoAccessor AccountInfoAccessor PsiAccountController ContactInfoAccessor IconFactoryAccessor)

public:
	ClientSwitcherPlugin();
	~ClientSwitcherPlugin();
	virtual QString name() const;
	virtual QString shortName() const;
	virtual QString version() const;
	virtual bool enable();
	virtual bool disable();
	virtual QWidget* options();
	virtual void applyOptions();
	virtual void restoreOptions();
	virtual QPixmap icon() const;
	// OptionAccessor
	virtual void setOptionAccessingHost(OptionAccessingHost*);
	virtual void optionChanged(const QString&);
	// StanzaSender
	virtual void setStanzaSendingHost(StanzaSendingHost*);
	// StanzaFilter
	virtual bool incomingStanza(int, const QDomElement&);
	virtual bool outgoingStanza(int, QDomElement&);
	// EventFilter
	virtual QString pluginInfo();
	// PopupAccessor
	virtual void setPopupAccessingHost(PopupAccessingHost*);
	// ApplicationInfoAccessor
	virtual void setApplicationInfoAccessingHost(ApplicationInfoAccessingHost*);
	// AccountInfoAccessing
	virtual void setAccountInfoAccessingHost(AccountInfoAccessingHost*);
	// PsiAccountController
	virtual void setPsiAccountControllingHost(PsiAccountControllingHost*);
	// ContactInfoAccessor
	virtual void setContactInfoAccessingHost(ContactInfoAccessingHost*);
	// IconFactoryAccessor
	virtual void setIconFactoryAccessingHost(IconFactoryAccessingHost* host);

private:
	struct OsStruct {
		QString name;
		OsStruct(const QString &n) : name(n) {}
	};

	struct ClientStruct {
		QString name;
		QString version;
		QString caps_node;
		QString caps_version;
		ClientStruct(const QString &n, const QString &v, const QString &cn, const QString &cv) : name(n), version(v), caps_node(cn), caps_version(cv) {}
	};
	Ui::OptionsWidget ui_options;
	StanzaSendingHost* sender_;
	OptionAccessingHost* psiOptions;
	PopupAccessingHost* psiPopup;
	ApplicationInfoAccessingHost* psiInfo;
	AccountInfoAccessingHost* psiAccount;
	PsiAccountControllingHost* psiAccountCtl;
	ContactInfoAccessingHost* psiContactInfo;
	IconFactoryAccessingHost* psiIcon;
	//--
	bool enabled;
	bool for_all_acc;
	QList<AccountSettings*> settingsList;
	//--
	QString def_os_name;
	QString def_client_name;
	QString def_client_version;
	QString def_caps_node;
	QString def_caps_version;
	QList<struct OsStruct> os_presets;
	QList<struct ClientStruct> client_presets;
	QString logsDir;
	int heightLogsView;
	int widthLogsView;
	QString lastLogItem;
	int popupId;
	//--

	int getOsTemplateIndex(QString&);
	int getClientTemplateIndex(QString&, QString&, QString&, QString&);
	int getAccountById(QString&);
	AccountSettings* getAccountSetting(const QString&);
	bool isSkipStanza(AccountSettings*, int, QString);
	QString jidToNick(int account, const QString &jid);
	void showPopup(const QString &nick);
	void showLog(QString filename);
	void saveToLog(int, QString, QString);

private slots:
	void enableAccountsList(int);
	void restoreOptionsAcc(int);
	void enableMainParams(int);
	void enableOsParams(int);
	void enableClientParams(int);
	void setNewCaps(int);
	void viewFromOpt();
	void onCloseView(int, int);

};

#endif