Committing a whole bunch of Identity-related stuff that's not actually used yet,
[quassel.git] / src / common / identity.h
1 /***************************************************************************
2  *   Copyright (C) 2005-08 by the Quassel IRC 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) 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 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(QString awayReason READ awayReason WRITE setAwayReason STORED false)
40   Q_PROPERTY(QString returnMessage READ returnMessage WRITE setReturnMessage STORED false)
41   //Q_PROPERTY(
42
43   public:
44     Identity(IdentityId id = -1, QObject *parent = 0);
45     Identity(const Identity &other, QObject *parent = 0);
46     void setToDefaults();
47
48     IdentityId id() const;
49     QString identityName() const;
50     QString realName() const;
51     QStringList nicks() const;
52     QString awayNick() const;
53     QString awayReason() const;
54     QString returnMessage() const;
55
56     bool initialized() const;
57     void setInitialized();
58
59   public slots:
60     void setIdentityName(const QString &name);
61     void setRealName(const QString &realName);
62     void setNicks(const QStringList &nicks);
63     void setAwayNick(const QString &awayNick);
64     void setAwayReason(const QString &awayReason);
65     void setReturnMessage(const QString &returnMessage);
66
67     void update(const Identity &other);
68
69   signals:
70     void identityNameSet(const QString &name);
71     void realNameSet(const QString &realName);
72     void nicksSet(const QStringList &nicks);
73     void awayNickSet(const QString &awayNick);
74     void awayReasonSet(const QString &awayReason);
75     void returnMessageSet(const QString &returnMessage);
76
77   private:
78     bool _initialized;
79     IdentityId _identityId;
80     QString _identityName, _realName;
81     QStringList _nicks;
82     QString  _awayNick, _awayReason, _returnMessage;
83
84     void init();
85
86     friend QDataStream &operator>>(QDataStream &in, Identity &identity);
87 };
88
89 QDataStream &operator<<(QDataStream &out, const Identity &identity);
90 QDataStream &operator>>(QDataStream &in, Identity &identity);
91
92 Q_DECLARE_METATYPE(Identity);
93
94 #endif