X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fircuser.h;h=3235158dde31d66dd2fbbfe981948d9036a28a88;hp=14151bec6e8f203d4286b6233491b8e0308128d7;hb=1ed8c48b0e7d309e1a92c905a19fcb7128b73d3d;hpb=cfbd7e0ec3624307cfb612fe4804d58c34b7eec9 diff --git a/src/common/ircuser.h b/src/common/ircuser.h index 14151bec..3235158d 100644 --- a/src/common/ircuser.h +++ b/src/common/ircuser.h @@ -1,11 +1,11 @@ /*************************************************************************** - * Copyright (C) 2005/06 by The Quassel Team * + * Copyright (C) 2005-08 by the Quassel Project * * devel@quassel-irc.org * * * * 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. * + * (at your option) version 3. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * @@ -21,73 +21,151 @@ #ifndef _IRCUSER_H_ #define _IRCUSER_H_ -#include -#include -#include #include #include #include +#include +#include -#include "global.h" +#include "syncableobject.h" + +class SignalProxy; +class Network; +class IrcChannel; + +class IrcUser : public SyncableObject { + Q_OBJECT + + Q_PROPERTY(QString user READ user WRITE setUser STORED false) + Q_PROPERTY(QString host READ host WRITE setHost STORED false) + Q_PROPERTY(QString nick READ nick WRITE setNick STORED false) + Q_PROPERTY(QString realName READ realName WRITE setRealName STORED false) + Q_PROPERTY(bool away READ isAway WRITE setAway STORED false) + Q_PROPERTY(QString awayMessage READ awayMessage WRITE setAwayMessage STORED false) + Q_PROPERTY(QDateTime idleTime READ idleTime WRITE setIdleTime STORED false) + Q_PROPERTY(QString server READ server WRITE setServer STORED false) + Q_PROPERTY(QString ircOperator READ ircOperator WRITE setIrcOperator STORED false) + Q_PROPERTY(int lastAwayMessage READ lastAwayMessage WRITE setLastAwayMessage STORED false) + + Q_PROPERTY(QStringList channels READ channels STORED false) + // Q_PROPERTY(QStringList usermodes READ usermodes WRITE setUsermodes) -class IrcUser : public QObject{ -// Q_OBJECT - -// Q_PROPERTY(QString user READ user WRITE setUser) -// Q_PROPERTY(QString host READ host WRITE setHost) -// Q_PROPERTY(QString nick READ nick WRITE setNick) -// Q_PROPERTY(QSet usermodes READ usermodes WRITE setUsermodes) -// Q_PROPERTY(QStringList channels READ channels) - public: - IrcUser(QObject *parent = 0); - IrcUser(const QString &hostmask, QObject *parent = 0); - ~IrcUser(); - - void setUser(const QString &user); + IrcUser(const QString &hostmask, Network *network); + virtual ~IrcUser(); + QString user() const; - - void setHost(const QString &host); QString host() const; - - void setNick(const QString &nick); QString nick() const; - - void setUsermodes(const QSet &usermodes); - QSet usermodes() const; - - void setChannelmode(const QString &channel, const QSet &channelmode); - QSet channelmode(const QString &channel) const; - - void updateChannelmode(const QString &channel, const QString &channelmode, bool add=true); - void addChannelmode(const QString &channel, const QString &channelmode); - void removeChannelmode(const QString &channel, const QString &channelmode); + QString realName() const; + QString hostmask() const; + bool isAway() const; + QString awayMessage() const; + QDateTime idleTime() const; + QString server() const; + QString ircOperator() const; + int lastAwayMessage() const; + Network *network() const; + + QString userModes() const; QStringList channels() const; - - void joinChannel(const QString &channel); - void partChannel(const QString &channel); - + + // user-specific encodings + QTextCodec *codecForEncoding() const; + QTextCodec *codecForDecoding() const; + void setCodecForEncoding(const QString &codecName); + void setCodecForEncoding(QTextCodec *codec); + void setCodecForDecoding(const QString &codecName); + void setCodecForDecoding(QTextCodec *codec); + + QString decodeString(const QByteArray &text) const; + QByteArray encodeString(const QString &string) const; + +public slots: + void setUser(const QString &user); + void setHost(const QString &host); + void setNick(const QString &nick); + void setRealName(const QString &realName); + void setAway(const bool &away); + void setAwayMessage(const QString &awayMessage); + void setIdleTime(const QDateTime &idleTime); + void setServer(const QString &server); + void setIrcOperator(const QString &ircOperator); + void setLastAwayMessage(const int &lastAwayMessage); + void updateHostmask(const QString &mask); + + void setUserModes(const QString &modes); + + void joinChannel(IrcChannel *channel); + void joinChannel(const QString &channelname); + void partChannel(IrcChannel *channel); + void partChannel(const QString &channelname); + + void addUserMode(const QString &mode); + void removeUserMode(const QString &mode); + + // init seters + void initSetChannels(const QStringList channels); + +signals: + void userSet(QString user); + void hostSet(QString host); + void nickSet(QString newnick); + void realNameSet(QString realName); + void awaySet(bool away); + void awayMessageSet(QString awayMessage); + void idleTimeSet(QDateTime idleTime); + void serverSet(QString server); + void ircOperatorSet(QString ircOperator); + void lastAwayMessageSet(int lastAwayMessage); + void hostmaskUpdated(QString mask); + + void userModesSet(QString modes); + + void channelJoined(QString channel); + void channelParted(QString channel); + + void userModeAdded(QString mode); + void userModeRemoved(QString mode); + +// void setUsermodes(const QSet &usermodes); +// QSet usermodes() const; + +private slots: + void updateObjectName(); + void channelDestroyed(); + private: inline bool operator==(const IrcUser &ircuser2) { - return (nick_.toLower() == ircuser2.nick().toLower()); + return (_nick.toLower() == ircuser2.nick().toLower()); } inline bool operator==(const QString &nickname) { - return (nick_.toLower() == nickname.toLower()); + return (_nick.toLower() == nickname.toLower()); } + + bool _initialized; + + QString _nick; + QString _user; + QString _host; + QString _realName; + QString _awayMessage; + bool _away; + QString _server; + QDateTime _idleTime; + QString _ircOperator; + int _lastAwayMessage; - QString nick_; - QString user_; - QString host_; - - QHash > channelmodes_; //keys: channelnames; values: Set of Channelmodes - QSet usermodes_; -}; + // QSet _channels; + QSet _channels; + QString _userModes; -struct IrcUserException : public Exception {}; -struct NoSuchChannelException : public IrcUserException {}; -struct NoSuchNickException : public IrcUserException {}; + Network *_network; + QTextCodec *_codecForEncoding; + QTextCodec *_codecForDecoding; +}; #endif