Make BufferInfo qDebug()able as per EgS' request.
[quassel.git] / src / common / ircuser.h
index b6c4b32..e933fb6 100644 (file)
@@ -1,11 +1,11 @@
 /***************************************************************************
- *   Copyright (C) 2005/06 by The Quassel Team                             *
+ *   Copyright (C) 2005-07 by the Quassel IRC Team                         *
  *   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        *
 #ifndef _IRCUSER_H_
 #define _IRCUSER_H_
 
-#include <QtCore>
-#include <QObject>
-#include <QHash>
 #include <QSet>
 #include <QString>
 #include <QStringList>
+#include <QVariantMap>
 
-#include "global.h"
+class SignalProxy;
+class NetworkInfo;
+class IrcChannel;
 
 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<QString> usermodes READ usermodes WRITE setUsermodes)
-//  Q_PROPERTY(QStringList channels READ channels)
-  
+
+  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)
+
+
 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;
+  QString hostmask() const;
+
+  QString userModes() const;
+
+  QStringList channels() 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 setUsermodes(const QSet<QString> &usermodes);
-  QSet<QString> usermodes() const;
+  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 setChannelmode(const QString &channel, const QSet<QString> &channelmode);
-  QSet<QString> channelmode(const QString &channel) const;
+  void userModesSet(QString modes);
   
-  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);
+  void channelJoined(QString channel);
+  void channelParted(QString channel);
 
-  QStringList channels() const;
+  void userModeAdded(QString mode);
+  void userModeRemoved(QString mode);
+
+  void renameObject(QString oldname, QString newname);
   
-  void joinChannel(const QString &channel);
-  void partChannel(const QString &channel);
+//   void setUsermodes(const QSet<QString> &usermodes);
+//   QSet<QString> 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<QString, QSet<QString> > channelmodes_; //keys: channelnames; values: Set of Channelmodes
-  QSet<QString> usermodes_;
-};
 
-struct IrcUserException : public Exception {};
-struct NoSuchChannelException : public IrcUserException {};
-struct NoSuchNickException : public IrcUserException {};
+  bool _initialized;
+
+  QString _nick;
+  QString _user;
+  QString _host;
 
+  // QSet<QString> _channels;
+  QSet<IrcChannel *> _channels;
+  QString _userModes;
+  
+  NetworkInfo *networkInfo;
+};
 
 #endif