Committing a lot of identity stuff which is still disabled.
[quassel.git] / src / common / identity.h
1 /***************************************************************************
2  *   Copyright (C) 2005-08 by the Quassel Project                          *
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) version 3.                                           *
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 _IDENTITY_H_
22 #define _IDENTITY_H_
23
24 #include <QDataStream>
25 #include <QMetaType>
26 #include <QString>
27 #include <QStringList>
28
29 #include "types.h"
30
31 class Identity : public QObject {
32   Q_OBJECT
33
34   Q_PROPERTY(IdentityId identityId READ id WRITE setId STORED false);
35   Q_PROPERTY(QString identityName READ identityName WRITE setIdentityName STORED false);
36   Q_PROPERTY(QString realName READ realName WRITE setRealName STORED false);
37   Q_PROPERTY(QStringList nicks READ nicks WRITE setNicks STORED false);
38   Q_PROPERTY(QString awayNick READ awayNick WRITE setAwayNick STORED false);
39   Q_PROPERTY(bool awayNickEnabled READ awayNickEnabled WRITE setAwayNickEnabled STORED false);
40   Q_PROPERTY(QString awayReason READ awayReason WRITE setAwayReason STORED false);
41   Q_PROPERTY(bool awayReasonEnabled READ awayReasonEnabled WRITE setAwayReasonEnabled STORED false);
42   Q_PROPERTY(QString returnMessage READ returnMessage WRITE setReturnMessage STORED false);
43   Q_PROPERTY(bool returnMessageEnabled READ returnMessageEnabled WRITE setReturnMessageEnabled STORED false);
44   Q_PROPERTY(bool autoAwayEnabled READ autoAwayEnabled WRITE setAutoAwayEnabled STORED false);
45   Q_PROPERTY(int autoAwayTime READ autoAwayTime WRITE setAutoAwayTime STORED false);
46   Q_PROPERTY(QString autoAwayReason READ autoAwayReason WRITE setAutoAwayReason STORED false);
47   Q_PROPERTY(bool autoAwayReasonEnabled READ autoAwayReasonEnabled WRITE setAutoAwayReasonEnabled STORED false);
48   Q_PROPERTY(QString autoReturnMessage READ autoReturnMessage WRITE setAutoReturnMessage STORED false);
49   Q_PROPERTY(bool autoReturnMessageEnabled READ autoReturnMessageEnabled WRITE setAutoReturnMessageEnabled STORED false);
50   Q_PROPERTY(QString ident READ ident WRITE setIdent STORED false);
51   Q_PROPERTY(QString kickReason READ kickReason WRITE setKickReason STORED false);
52   Q_PROPERTY(QString partReason READ partReason WRITE setPartReason STORED false);
53   Q_PROPERTY(QString quitReason READ quitReason WRITE setQuitReason STORED false);
54
55   public:
56     Identity(IdentityId id = 0, QObject *parent = 0);
57     Identity(const Identity &other, QObject *parent = 0);
58     void setToDefaults();
59
60     bool operator==(const Identity &other);
61     bool operator!=(const Identity &other);
62
63     bool isValid() const;
64
65     IdentityId id() const;
66     QString identityName() const;
67     QString realName() const;
68     QStringList nicks() const;
69     QString awayNick() const;
70     bool awayNickEnabled() const;
71     QString awayReason() const;
72     bool awayReasonEnabled() const;
73     QString returnMessage() const;
74     bool returnMessageEnabled() const;
75     bool autoAwayEnabled() const;
76     int autoAwayTime() const;
77     QString autoAwayReason() const;
78     bool autoAwayReasonEnabled() const;
79     QString autoReturnMessage() const;
80     bool autoReturnMessageEnabled() const;
81     QString ident() const;
82     QString kickReason() const;
83     QString partReason() const;
84     QString quitReason() const;
85
86     bool initialized() const;
87     void setInitialized();
88
89   public slots:
90     void setId(IdentityId id);
91     void setIdentityName(const QString &name);
92     void setRealName(const QString &realName);
93     void setNicks(const QStringList &nicks);
94     void setAwayNick(const QString &awayNick);
95     void setAwayNickEnabled(bool enabled);
96     void setAwayReason(const QString &awayReason);
97     void setAwayReasonEnabled(bool enabled);
98     void setReturnMessage(const QString &returnMessage);
99     void setReturnMessageEnabled(bool enabled);
100     void setAutoAwayEnabled(bool enabled);
101     void setAutoAwayTime(int time);
102     void setAutoAwayReason(const QString &reason);
103     void setAutoAwayReasonEnabled(bool enabled);
104     void setAutoReturnMessage(const QString &message);
105     void setAutoReturnMessageEnabled(bool enabled);
106     void setIdent(const QString &ident);
107     void setKickReason(const QString &reason);
108     void setPartReason(const QString &reason);
109     void setQuitReason(const QString &reason);
110
111     void update(const Identity &other);
112
113   signals:
114     void idSet(IdentityId id);
115     void identityNameSet(const QString &name);
116     void realNameSet(const QString &realName);
117     void nicksSet(const QStringList &nicks);
118     void awayNickSet(const QString &awayNick);
119     void awayNickEnabledSet(bool);
120     void awayReasonSet(const QString &awayReason);
121     void awayReasonEnabledSet(bool);
122     void returnMessageSet(const QString &returnMessage);
123     void returnMessageEnabledSet(bool);
124     void autoAwayEnabledSet(bool);
125     void autoAwayTimeSet(int);
126     void autoAwayReasonSet(const QString &);
127     void autoAwayReasonEnabledSet(bool);
128     void autoReturnMessageSet(const QString &);
129     void autoReturnMessageEnabledSet(bool);
130     void identSet(const QString &);
131     void kickReasonSet(const QString &);
132     void partReasonSet(const QString &);
133     void quitReasonSet(const QString &);
134
135     void updatedRemotely();
136
137   private:
138     bool _initialized;
139     IdentityId _identityId;
140     QString _identityName, _realName;
141     QStringList _nicks;
142     QString _awayNick;
143     bool _awayNickEnabled;
144     QString _awayReason;
145     bool _awayReasonEnabled;
146     QString _returnMessage;
147     bool _returnMessageEnabled;
148     bool _autoAwayEnabled;
149     int _autoAwayTime;
150     QString _autoAwayReason;
151     bool _autoAwayReasonEnabled;
152     QString _autoReturnMessage;
153     bool _autoReturnMessageEnabled;
154     QString _ident, _kickReason, _partReason, _quitReason;
155
156     void init();
157
158     friend QDataStream &operator>>(QDataStream &in, Identity &identity);
159 };
160
161 QDataStream &operator<<(QDataStream &out, const Identity &identity);
162 QDataStream &operator>>(QDataStream &in, Identity &identity);
163
164 Q_DECLARE_METATYPE(Identity);
165
166 #endif