Ok this is the major rework of quassel we've all been waiting for. For the actual...
[quassel.git] / src / common / synchronizer.h
1 /***************************************************************************
2  *   Copyright (C) 2005/06 by The Quassel Team                             *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifndef _SYNCHRONIZER_H_
22 #define _SYNCHRONIZER_H_
23
24 class SignalProxy;
25
26 #include <QObject>;
27 #include <QList>;
28 #include <QString>;
29 #include <QVariantMap>;
30 #include <QMetaMethod>;
31 #include <QPointer>
32
33 class Synchronizer : public QObject {
34   Q_OBJECT
35
36 public:
37   Synchronizer(QObject *parent, SignalProxy *signalproxy);
38   
39   bool initialized() const;
40   SignalProxy *proxy() const;
41
42   QVariantMap initData() const;
43   void setInitData(const QVariantMap &properties);
44
45 public slots:
46   void synchronizeClients() const;
47   void recvInitData(QVariantMap properties);
48   void parentChangedName();
49   
50 signals:
51   void requestSync() const;
52   void sendInitData(QVariantMap properties) const;
53   void initDone();
54   
55 private:
56   bool _initialized;
57   QPointer<SignalProxy> _signalproxy;
58   
59   QString signalPrefix() const;
60   QString initSignal() const;
61   QString requestSyncSignal() const;
62   
63   QString methodBaseName(const QMetaMethod &method) const;
64   bool methodsMatch(const QMetaMethod &signal, const QMetaMethod &slot) const;
65
66   QList<QMetaProperty> parentProperties() const;
67   QList<QMetaMethod> parentSlots() const;
68   QList<QMetaMethod> parentSignals() const;
69   
70   QList<QMetaMethod> getMethodByName(const QString &methodname);
71   
72   void attach();
73   void attachAsSlave();
74   void attachAsMaster();
75                           
76   bool setInitValue(const QString &property, const QVariant &value);
77 };
78
79 #endif