X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fircuser.h;h=d1ac21e1b2bbf951065d1e8921aba7494c5b3dba;hp=14151bec6e8f203d4286b6233491b8e0308128d7;hb=8699dd758516d0ded076811e8ea656adc95e69d0;hpb=cfbd7e0ec3624307cfb612fe4804d58c34b7eec9 diff --git a/src/common/ircuser.h b/src/common/ircuser.h index 14151bec..d1ac21e1 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,120 @@ #ifndef _IRCUSER_H_ #define _IRCUSER_H_ -#include -#include -#include #include #include #include +#include + +class SignalProxy; +class NetworkInfo; +class IrcChannel; + +class IrcUser : public QObject { + 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(QStringList channels READ channels STORED false) + // Q_PROPERTY(QStringList usermodes READ usermodes WRITE setUsermodes) -#include "global.h" - -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, NetworkInfo *networkInfo); + virtual ~IrcUser(); + + bool initialized() const; + 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 hostmask() 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 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); + + void setInitialized(); + +signals: + void userSet(QString user); + void hostSet(QString host); + void nickSet(QString newnick); + 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 renameObject(QString oldname, QString newname); + +// void setUsermodes(const QSet &usermodes); +// QSet usermodes() const; + + void initDone(); + +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()); } - - QString nick_; - QString user_; - QString host_; - - QHash > channelmodes_; //keys: channelnames; values: Set of Channelmodes - QSet usermodes_; -}; -struct IrcUserException : public Exception {}; -struct NoSuchChannelException : public IrcUserException {}; -struct NoSuchNickException : public IrcUserException {}; + bool _initialized; + QString _nick; + QString _user; + QString _host; + + // QSet _channels; + QSet _channels; + QString _userModes; + + NetworkInfo *networkInfo; + + QTextCodec *_codecForEncoding; + QTextCodec *_codecForDecoding; +}; #endif