-SET(common_SRCS global.cpp logger.cpp message.cpp settings.cpp util.cpp)
-SET(common_HDRS message.h settings.h util.h)
+SET(common_SRCS global.cpp logger.cpp message.cpp settings.cpp util.cpp ircuser.cpp)
+SET(common_HDRS message.h settings.h util.h ircuser.h)
SET(common_MOCS global.h logger.h quasselui.h)
QT4_WRAP_CPP(_MOC ${common_MOCS})
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005-07 by The Quassel 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. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "ircuser.h"
+#include "util.h"
+
+IrcUser::IrcUser(QObject *parent)
+ : QObject(parent) {
+}
+
+IrcUser::IrcUser(const QString &hostmask, QObject *parent)
+ : QObject(parent),
+ nick_(nickFromMask(hostmask)),
+ user_(userFromMask(hostmask)),
+ host_(hostFromMask(hostmask)) {
+}
+
+IrcUser::~IrcUser() {
+}
+
+void IrcUser::setUser(const QString &user) {
+ user_ = user;
+}
+
+QString IrcUser::user() const {
+ return user_;
+}
+
+void IrcUser::setHost(const QString &host) {
+ host_ = host;
+}
+
+QString IrcUser::host() const {
+ return host_;
+}
+
+void IrcUser::setNick(const QString &nick) {
+ nick_ = nick;
+}
+
+QString IrcUser::nick() const {
+ return nick_;
+}
+
+void IrcUser::setUsermodes(const QSet<QString> &usermodes) {
+ usermodes_ = usermodes;
+}
+
+QSet<QString> IrcUser::usermodes() const {
+ return usermodes_;
+}
+
+void IrcUser::setChannelmode(const QString &channel, const QSet<QString> &channelmode) {
+ if(channelmodes_.contains(channel))
+ channelmodes_[channel] |= channelmode;
+ else
+ channelmodes_[channel] = channelmode;
+}
+
+QSet<QString> IrcUser::channelmode(const QString &channel) const {
+ if(channelmodes_.contains(channel))
+ throw NoSuchChannelException();
+ else
+ return QSet<QString>();
+}
+
+void IrcUser::updateChannelmode(const QString &channel, const QString &channelmode, bool add) {
+ if(add)
+ addChannelmode(channel, channelmode);
+ else
+ removeChannelmode(channel, channelmode);
+}
+
+void IrcUser::addChannelmode(const QString &channel, const QString &channelmode) {
+ if(!channelmodes_.contains(channel))
+ channelmodes_[channel] = QSet<QString>();
+ channelmodes_[channel] << channelmode;
+}
+
+void IrcUser::removeChannelmode(const QString &channel, const QString &channelmode) {
+ if(channelmodes_.contains(channel))
+ channelmodes_[channel].remove(channelmode);
+}
+
+QStringList IrcUser::channels() const {
+ return channelmodes_.keys();
+}
+
+void IrcUser::joinChannel(const QString &channel) {
+ if(!channelmodes_.contains(channel))
+ channelmodes_[channel] = QSet<QString>();
+}
+
+void IrcUser::partChannel(const QString &channel) {
+ channelmodes_.remove(channel);
+}
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005/06 by The Quassel 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. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef _IRCUSER_H_
+#define _IRCUSER_H_
+
+#include <QtCore>
+#include <QObject>
+#include <QHash>
+#include <QSet>
+#include <QString>
+#include <QStringList>
+
+#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<QString> 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);
+ QString user() const;
+
+ void setHost(const QString &host);
+ QString host() const;
+
+ void setNick(const QString &nick);
+ QString nick() const;
+
+ void setUsermodes(const QSet<QString> &usermodes);
+ QSet<QString> usermodes() const;
+
+ void setChannelmode(const QString &channel, const QSet<QString> &channelmode);
+ QSet<QString> 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);
+
+ QStringList channels() const;
+
+ void joinChannel(const QString &channel);
+ void partChannel(const QString &channel);
+
+private:
+ inline bool operator==(const IrcUser &ircuser2) {
+ return (nick_.toLower() == ircuser2.nick().toLower());
+ }
+
+ inline bool operator==(const QString &nickname) {
+ 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 {};
+
+
+#endif
-SET(core_SRCS core.cpp coreproxy.cpp coresession.cpp server.cpp sqlitestorage.cpp storage.cpp)
+SET(core_SRCS core.cpp coreproxy.cpp coresession.cpp server.cpp serverinfo.cpp sqlitestorage.cpp storage.cpp)
SET(core_HDRS )
-SET(core_MOCS core.h coreproxy.h coresession.h server.h sqlitestorage.h storage.h)
+SET(core_MOCS core.h coreproxy.h coresession.h server.h serverinfo.h sqlitestorage.h storage.h)
QT4_WRAP_CPP(_MOC ${core_MOCS})
ADD_LIBRARY(core ${core_SRCS} ${_MOC})
QString XQUOTE = QString('\134');
ctcpXDelimDequoteHash[XQUOTE + XQUOTE] = XQUOTE;
ctcpXDelimDequoteHash[XQUOTE + QString('a')] = XDELIM;
+
+ serverinfo = new ServerInfo();
}
Server::~Server() {
-
+ delete serverinfo;
}
void Server::run() {
#include <QTimer>
#include "message.h"
+#include "serverinfo.h"
#define DEFAULT_PORT 6667
public:
UnknownCmdError(QString cmd, QString prefix, QStringList params);
};
+
+ // stuff needed for new separation of server information
+ ServerInfo *serverinfo;
};
#endif
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005-07 by The Quassel 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. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "serverinfo.h"
+
+ServerInfo::ServerInfo(QObject *parent)
+ : QObject(parent) {
+}
+
+ServerInfo::~ServerInfo() {
+}
+
+void ServerInfo::setNetworkname(const QString &networkname) {
+ networkname_ = networkname;
+}
+
+QString ServerInfo::networkname() const {
+ return networkname_;
+}
+
+void ServerInfo::setCurrentServer(const QString ¤tServer) {
+ currentServer_ = currentServer;
+}
+
+QString ServerInfo::currentServer() const {
+ return currentServer_;
+}
+
+void ServerInfo::setOwnNick(const QString &ownnick) {
+ ownNick_ = ownnick;
+}
+
+QString ServerInfo::ownNick() const {
+ return ownNick_;
+}
+
+QList<IrcUser *> ServerInfo::ircUsers() const {
+ return ircUsers_.values();
+}
+
+
+IrcUser *ServerInfo::newIrcUser(const QString &hostmask) {
+ IrcUser *ircuser = new IrcUser(hostmask);
+ return ircUsers_[ircuser->nick()] = ircuser;
+}
+
+IrcUser *ServerInfo::ircUser(const QString &nickname) const {
+ if(ircUsers_.contains(nickname))
+ return ircUsers_[nickname];
+ else
+ throw NoSuchNickException();
+}
+
+void ServerInfo::setTopics(const QHash<QString, QString> &topics) {
+ topics_ = topics;
+}
+
+QHash<QString, QString> ServerInfo::topics() const {
+ return topics_;
+}
+
+void ServerInfo::updateTopic(const QString &channel, const QString &topic) {
+ topics_[channel] = topic;
+}
+
+QString ServerInfo::topic(const QString &channel) const {
+ if(topics_.contains(channel))
+ return topics_[channel];
+ else
+ throw NoSuchChannelException();
+}
+
+void ServerInfo::setSupports(const QHash<QString, QString> &supports) {
+ supports_ = supports;
+}
+
+QHash<QString, QString> ServerInfo::supports() const {
+ return supports_;
+}
+
+QString ServerInfo::supports(const QString &feature) const {
+ if(supports_.contains(feature))
+ return supports_[feature];
+ else
+ throw UnsupportedFeatureException();
+}
+
+bool ServerInfo::isOwnNick(const QString &nick) const {
+ return (ownNick_.toLower() == nick.toLower());
+}
+
+bool ServerInfo::isOwnNick(const IrcUser &ircuser) const {
+ return (ircuser.nick().toLower() == ownNick_.toLower());
+}
+
+
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005/06 by The Quassel 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. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef _SERVERINFO_H_
+#define _SERVERINFO_H_
+
+#include <QString>
+#include <QList>
+#include <QHash>
+
+#include "global.h"
+#include "ircuser.h"
+
+class ServerInfo : public QObject {
+ Q_OBJECT
+
+ Q_PROPERTY(QString networkname READ networkname WRITE setNetworkname)
+ Q_PROPERTY(QString currentServer READ currentServer WRITE setCurrentServer)
+ Q_PROPERTY(QString ownNick READ ownNick WRITE setOwnNick)
+ Q_PROPERTY(QList<IrcUser *> ircUsers READ ircUsers)
+
+public:
+ ServerInfo(QObject *parent = 0);
+ ~ServerInfo();
+
+ void setNetworkname(const QString &networkname);
+ QString networkname() const;
+
+ void setCurrentServer(const QString ¤tServer);
+ QString currentServer() const;
+
+ void setOwnNick(const QString &ownnick);
+ QString ownNick() const;
+
+ QList<IrcUser *> ircUsers() const;
+ IrcUser *newIrcUser(const QString &hostmask);
+ IrcUser *ircUser(const QString &nickname) const;
+
+ void setTopics(const QHash<QString, QString> &topics);
+ QHash<QString, QString> topics() const;
+
+ void updateTopic(const QString &channel, const QString &topic);
+ QString topic(const QString &channel) const;
+
+ void setSupports(const QHash<QString, QString> &supports);
+ QHash<QString, QString> supports() const;
+ QString supports(const QString &feature) const;
+
+ bool isOwnNick(const QString &nick) const;
+ bool isOwnNick(const IrcUser &ircuser) const;
+
+private:
+ QString networkname_;
+ QString currentServer_;
+ QString ownNick_;
+
+ //VarMap networkSettings;
+ //VarMap identity;
+
+ QHash<QString, IrcUser *> ircUsers_; // stores all known nicks for the server
+ QHash<QString, QString> topics_; // stores topics for each buffer
+ QHash<QString, QString> supports_; // stores results from RPL_ISUPPORT
+};
+
+struct UnsupportedFeatureException : public Exception {};
+
+#endif