From: Manuel Nickschas Date: Sun, 15 Jun 2008 00:39:17 +0000 (+0200) Subject: Merge branch 'cmake' X-Git-Tag: 0.3.0~381^2~2 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=cb1918d94b5d8ec9f05a192c96fab938782dabf5;hp=262295b3f5665dba8b154a4f82787bb52fef7b99 Merge branch 'cmake' --- diff --git a/scripts/manageusers.py b/scripts/manageusers.py new file mode 100755 index 00000000..c327865f --- /dev/null +++ b/scripts/manageusers.py @@ -0,0 +1,56 @@ +#!/usr/bin/python +# -*- coding: iso-8859-1 -*- + +# ============================== +# Imports +# ============================== +import os +import sha +import sys + +try: + import sqlite3 +except ImportError: + print >> sys.stderr, "ERROR: sqlite3 module not available!" + print >> sys.stderr, "This script needs sqlite3 support which is part of Python 2.5" + print >> sys.stderr, "You probably need to upgrade your Python installation first." + sys.exit(3) + +class UserManager(object): + def __init__(self): + self.db = sqlite3.connect(os.environ['HOME'] + '/.quassel/quassel-storage.sqlite') + + def __del__(self): + self.db.commit() + self.db.close(); + + def shaCrypt(self, password): + shaPass = sha.new(password) + return shaPass.hexdigest() + + def addUser(self, username, password): + cursor = self.db.cursor() + cursor.execute('INSERT INTO quasseluser (username, password) VALUES (:username, :password)', + {'username':username, 'password':self.shaCrypt(password)}) + + def changePass(self, username, password): + cursor = self.db.cursor() + cursor.execute('UPDATE quasseluser SET password = :password WHERE username = :username', + {'username':username, 'password':self.shaCrypt(password)}) + +if __name__ == "__main__": + generalError = "ERROR: Wrong arugment count (Syntax: %s add|changepass )" % sys.argv[0] + if len(sys.argv) < 3: + print generalError + sys.exit(1) + + if sys.argv[1].lower() not in ['add', 'changepass']: + print generalError + sys.exit(2) + + userManager = UserManager() + actions = {'add':userManager.addUser, + 'changepass':userManager.changePass} + + actions[sys.argv[1]](sys.argv[2], sys.argv[3]) + diff --git a/src/client/networkmodel.cpp b/src/client/networkmodel.cpp index 940feb7f..bd2d8a57 100644 --- a/src/client/networkmodel.cpp +++ b/src/client/networkmodel.cpp @@ -313,6 +313,11 @@ QString BufferItem::toolTip(int column) const { toolTip.append(tr("Topic: %1").arg(_topic)); } } + if(_ircChannel) { + QString channelMode = _ircChannel->channelModeString(); // channelModeString is compiled on the fly -> thus cache the result + if(!channelMode.isEmpty()) + toolTip.append(tr("Mode: %1").arg(channelMode)); + } } else { toolTip.append(tr("Not active
Double-click to join")); } diff --git a/src/common/ircchannel.cpp b/src/common/ircchannel.cpp index 57be4e79..9a66d809 100644 --- a/src/common/ircchannel.cpp +++ b/src/common/ircchannel.cpp @@ -21,8 +21,6 @@ #include "ircchannel.h" #include "network.h" -//#include "nicktreemodel.h" -#include "signalproxy.h" #include "ircuser.h" #include "util.h" @@ -33,7 +31,8 @@ #include -IrcChannel::IrcChannel(const QString &channelname, Network *network) : SyncableObject(network), +IrcChannel::IrcChannel(const QString &channelname, Network *network) + : SyncableObject(network), _initialized(false), _name(channelname), _topic(QString()), @@ -44,9 +43,6 @@ IrcChannel::IrcChannel(const QString &channelname, Network *network) : SyncableO setObjectName(QString::number(network->networkId().toInt()) + "/" + channelname); } -IrcChannel::~IrcChannel() { -} - // ==================== // PUBLIC: // ==================== @@ -241,7 +237,6 @@ void IrcChannel::removeUserMode(IrcUser *ircuser, const QString &mode) { emit userModeRemoved(ircuser->nick(), mode); emit ircUserModeRemoved(ircuser, mode); } - } void IrcChannel::removeUserMode(const QString &nick, const QString &mode) { @@ -271,6 +266,73 @@ void IrcChannel::initSetUserModes(const QVariantMap &usermodes) { joinIrcUsers(users, modes); } +QVariantMap IrcChannel::initChanModes() const { + QVariantMap channelModes; + + QVariantMap A_modes; + QHash::const_iterator A_iter = _A_channelModes.constBegin(); + while(A_iter != _A_channelModes.constEnd()) { + A_modes[A_iter.key()] = A_iter.value(); + A_iter++; + } + channelModes["A"] = A_modes; + + QVariantMap B_modes; + QHash::const_iterator B_iter = _B_channelModes.constBegin(); + while(B_iter != _B_channelModes.constEnd()) { + B_modes[B_iter.key()] = B_iter.value(); + B_iter++; + } + channelModes["B"] = B_modes; + + QVariantMap C_modes; + QHash::const_iterator C_iter = _C_channelModes.constBegin(); + while(C_iter != _C_channelModes.constEnd()) { + C_modes[C_iter.key()] = C_iter.value(); + C_iter++; + } + channelModes["C"] = C_modes; + + QString D_modes; + QSet::const_iterator D_iter = _D_channelModes.constBegin(); + while(D_iter != _D_channelModes.constEnd()) { + D_modes += *D_iter; + D_iter++; + } + channelModes["D"] = D_modes; + + return channelModes; +} + +void IrcChannel::initSetChanModes(const QVariantMap &channelModes) { + QVariantMap::const_iterator iter = channelModes["A"].toMap().constBegin(); + QVariantMap::const_iterator iterEnd = channelModes["A"].toMap().constEnd(); + while(iter != iterEnd) { + _A_channelModes[iter.key()[0]] = iter.value().toStringList(); + iter++; + } + + iter = channelModes["B"].toMap().constBegin(); + iterEnd = channelModes["B"].toMap().constEnd(); + while(iter != iterEnd) { + _B_channelModes[iter.key()[0]] = iter.value().toString(); + iter++; + } + + iter = channelModes["C"].toMap().constBegin(); + iterEnd = channelModes["C"].toMap().constEnd(); + while(iter != iterEnd) { + _C_channelModes[iter.key()[0]] = iter.value().toString(); + iter++; + } + + QString D_modes = channelModes["D"].toString(); + for(int i = 0; i < D_modes.count(); i++) { + _D_channelModes << D_modes[i]; + } + +} + void IrcChannel::ircUserDestroyed() { IrcUser *ircUser = static_cast(sender()); Q_ASSERT(ircUser); @@ -285,3 +347,182 @@ void IrcChannel::ircUserNickSet(QString nick) { emit ircUserNickSet(ircUser, nick); } +/******************************************************************************* + * + * 3.3 CHANMODES + * + * o CHANMODES=A,B,C,D + * + * The CHANMODES token specifies the modes that may be set on a channel. + * These modes are split into four categories, as follows: + * + * o Type A: Modes that add or remove an address to or from a list. + * These modes always take a parameter when sent by the server to a + * client; when sent by a client, they may be specified without a + * parameter, which requests the server to display the current + * contents of the corresponding list on the channel to the client. + * o Type B: Modes that change a setting on the channel. These modes + * always take a parameter. + * o Type C: Modes that change a setting on the channel. These modes + * take a parameter only when set; the parameter is absent when the + * mode is removed both in the client's and server's MODE command. + * o Type D: Modes that change a setting on the channel. These modes + * never take a parameter. + * + * If the server sends any additional types after these 4, the client + * MUST ignore them; this is intended to allow future extension of this + * token. + * + * The IRC server MUST NOT list modes in CHANMODES which are also + * present in the PREFIX parameter; however, for completeness, modes + * described in PREFIX may be treated as type B modes. + * + ******************************************************************************/ + + +/******************************************************************************* + * Short Version: + * A --> add/remove from List + * B --> set value or remove + * C --> set value or remove + * D --> on/off + * + * B and C behave very similar... we store the data in different datastructes + * for future compatibility + ******************************************************************************/ + +// NOTE: the behavior of addChannelMode and removeChannelMode depends on the type of mode +// see list above for chanmode types +void IrcChannel::addChannelMode(const QChar &mode, const QString &value) { + Network::ChannelModeType modeType = network->channelModeType(mode); + + switch(modeType) { + case Network::NOT_A_CHANMODE: + return; + case Network::A_CHANMODE: + if(!_A_channelModes.contains(mode)) + _A_channelModes[mode] = QStringList(value); + else if(!_A_channelModes[mode].contains(value)) + _A_channelModes[mode] << value; + break; + + case Network::B_CHANMODE: + _B_channelModes[mode] = value; + break; + + case Network::C_CHANMODE: + _C_channelModes[mode] = value; + break; + + case Network::D_CHANMODE: + _D_channelModes << mode; + break; + } + emit channelModeAdded(mode, value); +} + +void IrcChannel::removeChannelMode(const QChar &mode, const QString &value) { + Network::ChannelModeType modeType = network->channelModeType(mode); + + switch(modeType) { + case Network::NOT_A_CHANMODE: + return; + case Network::A_CHANMODE: + if(_A_channelModes.contains(mode)) + _A_channelModes[mode].removeAll(value); + break; + + case Network::B_CHANMODE: + _B_channelModes.remove(mode); + break; + + case Network::C_CHANMODE: + _C_channelModes.remove(mode); + break; + + case Network::D_CHANMODE: + _D_channelModes.remove(mode); + break; + } + emit channelModeRemoved(mode, value); +} + +bool IrcChannel::hasMode(const QChar &mode) const { + Network::ChannelModeType modeType = network->channelModeType(mode); + + switch(modeType) { + case Network::NOT_A_CHANMODE: + return false; + case Network::A_CHANMODE: + return _A_channelModes.contains(mode); + case Network::B_CHANMODE: + return _B_channelModes.contains(mode); + case Network::C_CHANMODE: + return _C_channelModes.contains(mode); + case Network::D_CHANMODE: + return _D_channelModes.contains(mode); + default: + return false; + } +} + +QString IrcChannel::modeValue(const QChar &mode) const { + Network::ChannelModeType modeType = network->channelModeType(mode); + + switch(modeType) { + case Network::B_CHANMODE: + if(_B_channelModes.contains(mode)) + return _B_channelModes[mode]; + else + return QString(); + case Network::C_CHANMODE: + if(_C_channelModes.contains(mode)) + return _C_channelModes[mode]; + else + return QString(); + default: + return QString(); + } + +} + +QStringList IrcChannel::modeValueList(const QChar &mode) const { + Network::ChannelModeType modeType = network->channelModeType(mode); + + switch(modeType) { + case Network::A_CHANMODE: + if(_A_channelModes.contains(mode)) + return _A_channelModes[mode]; + default: + return QStringList(); + } +} + +QString IrcChannel::channelModeString() const { + QStringList params; + QString modeString; + + QSet::const_iterator D_iter = _D_channelModes.constBegin(); + while(D_iter != _D_channelModes.constEnd()) { + modeString += *D_iter; + D_iter++; + } + + QHash::const_iterator BC_iter = _C_channelModes.constBegin(); + while(BC_iter != _C_channelModes.constEnd()) { + modeString += BC_iter.key(); + params << BC_iter.value(); + BC_iter++; + } + + BC_iter = _B_channelModes.constBegin(); + while(BC_iter != _B_channelModes.constEnd()) { + modeString += BC_iter.key(); + params << BC_iter.value(); + BC_iter++; + } + if(modeString.isEmpty()) + return modeString; + else + return QString("+%1 %2").arg(modeString).arg(params.join(" ")); +} diff --git a/src/common/ircchannel.h b/src/common/ircchannel.h index 26340ce6..24347a8e 100644 --- a/src/common/ircchannel.h +++ b/src/common/ircchannel.h @@ -22,6 +22,7 @@ #define _IRCCHANNEL_H_ #include +#include #include #include #include @@ -30,7 +31,6 @@ class IrcUser; class Network; -class SignalProxy; class IrcChannel : public SyncableObject { Q_OBJECT @@ -41,7 +41,6 @@ class IrcChannel : public SyncableObject { public: IrcChannel(const QString &channelname, Network *network); - ~IrcChannel(); bool isKnownUser(IrcUser *ircuser) const; bool isValidChannelUserMode(const QString &mode) const; @@ -55,6 +54,11 @@ public: QString userModes(IrcUser *ircuser) const; QString userModes(const QString &nick) const; + bool hasMode(const QChar &mode) const; + QString modeValue(const QChar &mode) const; + QStringList modeValueList(const QChar &mode) const; + QString channelModeString() const; + inline QTextCodec *codecForEncoding() const { return _codecForEncoding; } inline QTextCodec *codecForDecoding() const { return _codecForDecoding; } void setCodecForEncoding(const QString &codecName); @@ -86,22 +90,26 @@ public slots: void removeUserMode(IrcUser *ircuser, const QString &mode); void removeUserMode(const QString &nick, const QString &mode); + void addChannelMode(const QChar &mode, const QString &value); + void removeChannelMode(const QChar &mode, const QString &value); + // init geters QVariantMap initUserModes() const; + QVariantMap initChanModes() const; // init seters void initSetUserModes(const QVariantMap &usermodes); + void initSetChanModes(const QVariantMap &chanModes); signals: void topicSet(const QString &topic); void passwordSet(const QString &password); void userModesSet(QString nick, QString modes); - //void userModesSet(IrcUser *ircuser, QString modes); void userModeAdded(QString nick, QString mode); - //void userModeAdded(IrcUser *ircuser, QString mode); void userModeRemoved(QString nick, QString mode); - //void userModeRemoved(IrcUser *ircuser, QString mode); - + void channelModeAdded(const QChar &mode, const QString &value); + void channelModeRemoved(const QChar &mode, const QString &value); + void ircUsersJoined(QList ircusers); void ircUsersJoined(QStringList nicks, QStringList modes); void ircUserParted(IrcUser *ircuser); @@ -126,6 +134,12 @@ private: QTextCodec *_codecForEncoding; QTextCodec *_codecForDecoding; + + QHash _A_channelModes; + QHash _B_channelModes; + QHash _C_channelModes; + QSet _D_channelModes; + }; #endif diff --git a/src/common/network.cpp b/src/common/network.cpp index db15d253..4a1d6c87 100644 --- a/src/common/network.cpp +++ b/src/common/network.cpp @@ -19,10 +19,6 @@ ***************************************************************************/ #include "network.h" -#include "signalproxy.h" -#include "ircuser.h" -#include "ircchannel.h" - #include #include @@ -31,11 +27,11 @@ QTextCodec *Network::_defaultCodecForServer = 0; QTextCodec *Network::_defaultCodecForEncoding = 0; QTextCodec *Network::_defaultCodecForDecoding = 0; - // ==================== // Public: // ==================== -Network::Network(const NetworkId &networkid, QObject *parent) : SyncableObject(parent), +Network::Network(const NetworkId &networkid, QObject *parent) + : SyncableObject(parent), _proxy(0), _networkId(networkid), _identity(0), @@ -59,38 +55,8 @@ Network::Network(const NetworkId &networkid, QObject *parent) : SyncableObject(p setObjectName(QString::number(networkid.toInt())); } -// I think this is unnecessary since IrcUsers have us as their daddy :) - Network::~Network() { emit aboutToBeDestroyed(); -// QHashIterator ircuser(_ircUsers); -// while (ircuser.hasNext()) { -// ircuser.next(); -// delete ircuser.value(); -// } -// qDebug() << "Destroying net" << networkName() << networkId(); -} - - -NetworkId Network::networkId() const { - return _networkId; -} - -SignalProxy *Network::proxy() const { - return _proxy; -} - -void Network::setProxy(SignalProxy *proxy) { - _proxy = proxy; - //proxy->synchronize(this); // we should to this explicitly from the outside! -} - -bool Network::isMyNick(const QString &nick) const { - return (myNick().toLower() == nick.toLower()); -} - -bool Network::isMe(IrcUser *ircuser) const { - return (ircuser->nick().toLower() == myNick().toLower()); } bool Network::isChannelName(const QString &channelname) const { @@ -103,15 +69,6 @@ bool Network::isChannelName(const QString &channelname) const { return QString("#&!+").contains(channelname[0]); } -bool Network::isConnected() const { - return _connected; -} - -//Network::ConnectionState Network::connectionState() const { -int Network::connectionState() const { - return _connectionState; -} - NetworkInfo Network::networkInfo() const { NetworkInfo info; info.networkName = networkName(); @@ -161,10 +118,6 @@ QString Network::prefixToMode(const QString &prefix) { return QString(); } -QString Network::prefixToMode(const QCharRef &prefix) { - return prefixToMode(QString(prefix)); -} - QString Network::modeToPrefix(const QString &mode) { if(prefixModes().contains(mode)) return QString(prefixes()[prefixModes().indexOf(mode)]); @@ -172,26 +125,6 @@ QString Network::modeToPrefix(const QString &mode) { return QString(); } -QString Network::modeToPrefix(const QCharRef &mode) { - return modeToPrefix(QString(mode)); -} - -QString Network::networkName() const { - return _networkName; -} - -QString Network::currentServer() const { - return _currentServer; -} - -QString Network::myNick() const { - return _myNick; -} - -IdentityId Network::identity() const { - return _identity; -} - QStringList Network::nicks() const { // we don't use _ircUsers.keys() since the keys may be // not up to date after a nick change @@ -202,54 +135,6 @@ QStringList Network::nicks() const { return nicks; } -QStringList Network::channels() const { - return _ircChannels.keys(); -} - -QVariantList Network::serverList() const { - return _serverList; -} - -bool Network::useRandomServer() const { - return _useRandomServer; -} - -QStringList Network::perform() const { - return _perform; -} - -bool Network::useAutoIdentify() const { - return _useAutoIdentify; -} - -QString Network::autoIdentifyService() const { - return _autoIdentifyService; -} - -QString Network::autoIdentifyPassword() const { - return _autoIdentifyPassword; -} - -bool Network::useAutoReconnect() const { - return _useAutoReconnect; -} - -quint32 Network::autoReconnectInterval() const { - return _autoReconnectInterval; -} - -quint16 Network::autoReconnectRetries() const { - return _autoReconnectRetries; -} - -bool Network::unlimitedReconnectRetries() const { - return _unlimitedReconnectRetries; -} - -bool Network::rejoinChannels() const { - return _rejoinChannels; -} - QString Network::prefixes() { if(_prefixes.isNull()) determinePrefixes(); @@ -264,8 +149,27 @@ QString Network::prefixModes() { return _prefixModes; } -bool Network::supports(const QString ¶m) const { - return _supports.contains(param); +// example Unreal IRCD: CHANMODES=beI,kfL,lj,psmntirRcOAQKVCuzNSMTG +Network::ChannelModeType Network::channelModeType(const QString &mode) { + if(mode.isEmpty()) + return NOT_A_CHANMODE; + + QString chanmodes = support("CHANMODES"); + if(chanmodes.isEmpty()) + return NOT_A_CHANMODE; + + ChannelModeType modeType = A_CHANMODE; + for(int i = 0; i < chanmodes.count(); i++) { + if(chanmodes[i] == mode[0]) + break; + else if(chanmodes[i] == ',') + modeType = (ChannelModeType)(modeType << 1); + } + if(modeType > D_CHANMODE) { + qWarning() << "Network" << networkId() << "supplied invalid CHANMODES:" << chanmodes; + modeType = NOT_A_CHANMODE; + } + return modeType; } QString Network::support(const QString ¶m) const { @@ -296,10 +200,6 @@ IrcUser *Network::newIrcUser(const QString &hostmask) { return _ircUsers[nick]; } -IrcUser *Network::newIrcUser(const QByteArray &hostmask) { - return newIrcUser(decodeServerString(hostmask)); -} - void Network::ircUserDestroyed() { IrcUser *ircUser = static_cast(sender()); if(!ircUser) @@ -352,18 +252,6 @@ IrcUser *Network::ircUser(QString nickname) const { return 0; } -IrcUser *Network::ircUser(const QByteArray &nickname) const { - return ircUser(decodeServerString(nickname)); -} - -QList Network::ircUsers() const { - return _ircUsers.values(); -} - -quint32 Network::ircUserCount() const { - return _ircUsers.count(); -} - IrcChannel *Network::newIrcChannel(const QString &channelname) { if(!_ircChannels.contains(channelname.toLower())) { IrcChannel *channel = new IrcChannel(channelname, this); @@ -382,10 +270,6 @@ IrcChannel *Network::newIrcChannel(const QString &channelname) { return _ircChannels[channelname.toLower()]; } -IrcChannel *Network::newIrcChannel(const QByteArray &channelname) { - return newIrcChannel(decodeServerString(channelname)); -} - IrcChannel *Network::ircChannel(QString channelname) const { channelname = channelname.toLower(); if(_ircChannels.contains(channelname)) @@ -394,21 +278,9 @@ IrcChannel *Network::ircChannel(QString channelname) const { return 0; } -IrcChannel *Network::ircChannel(const QByteArray &channelname) const { - return ircChannel(decodeServerString(channelname)); -} - - -QList Network::ircChannels() const { - return _ircChannels.values(); -} - -quint32 Network::ircChannelCount() const { - return _ircChannels.count(); -} - QByteArray Network::defaultCodecForServer() { - if(_defaultCodecForServer) return _defaultCodecForServer->name(); + if(_defaultCodecForServer) + return _defaultCodecForServer->name(); return QByteArray(); } @@ -417,7 +289,8 @@ void Network::setDefaultCodecForServer(const QByteArray &name) { } QByteArray Network::defaultCodecForEncoding() { - if(_defaultCodecForEncoding) return _defaultCodecForEncoding->name(); + if(_defaultCodecForEncoding) + return _defaultCodecForEncoding->name(); return QByteArray(); } @@ -426,7 +299,8 @@ void Network::setDefaultCodecForEncoding(const QByteArray &name) { } QByteArray Network::defaultCodecForDecoding() { - if(_defaultCodecForDecoding) return _defaultCodecForDecoding->name(); + if(_defaultCodecForDecoding) + return _defaultCodecForDecoding->name(); return QByteArray(); } @@ -435,7 +309,8 @@ void Network::setDefaultCodecForDecoding(const QByteArray &name) { } QByteArray Network::codecForServer() const { - if(_codecForServer) return _codecForServer->name(); + if(_codecForServer) + return _codecForServer->name(); return QByteArray(); } @@ -449,7 +324,8 @@ void Network::setCodecForServer(QTextCodec *codec) { } QByteArray Network::codecForEncoding() const { - if(_codecForEncoding) return _codecForEncoding->name(); + if(_codecForEncoding) + return _codecForEncoding->name(); return QByteArray(); } @@ -463,7 +339,8 @@ void Network::setCodecForEncoding(QTextCodec *codec) { } QByteArray Network::codecForDecoding() const { - if(_codecForDecoding) return _codecForDecoding->name(); + if(_codecForDecoding) + return _codecForDecoding->name(); else return QByteArray(); } @@ -478,7 +355,8 @@ void Network::setCodecForDecoding(QTextCodec *codec) { // FIXME use server encoding if appropriate QString Network::decodeString(const QByteArray &text) const { - if(_codecForDecoding) return ::decodeString(text, _codecForDecoding); + if(_codecForDecoding) + return ::decodeString(text, _codecForDecoding); else return ::decodeString(text, _defaultCodecForDecoding); } @@ -493,8 +371,10 @@ QByteArray Network::encodeString(const QString &string) const { } QString Network::decodeServerString(const QByteArray &text) const { - if(_codecForServer) return ::decodeString(text, _codecForServer); - else return ::decodeString(text, _defaultCodecForServer); + if(_codecForServer) + return ::decodeString(text, _codecForServer); + else + return ::decodeString(text, _defaultCodecForServer); } QByteArray Network::encodeServerString(const QString &string) const { @@ -521,6 +401,9 @@ void Network::setCurrentServer(const QString ¤tServer) { } void Network::setConnected(bool connected) { + if(_connected == connected) + return; + _connected = connected; if(!connected) { removeChansAndUsers(); @@ -626,10 +509,6 @@ QVariantMap Network::initSupports() const { return supports; } -QVariantList Network::initServerList() const { - return serverList(); -} - QStringList Network::initIrcUsers() const { QStringList hostmasks; foreach(IrcUser *ircuser, ircUsers()) { @@ -656,10 +535,6 @@ void Network::initSetSupports(const QVariantMap &supports) { } } -void Network::initSetServerList(const QVariantList & serverList) { - setServerList(serverList); -} - void Network::initSetIrcUsers(const QStringList &hostmasks) { if(!_ircUsers.empty()) return; @@ -737,30 +612,6 @@ void Network::channelDestroyed() { emit ircChannelRemoved(channel); } -void Network::requestConnect() const { - if(!proxy()) return; - if(proxy()->proxyMode() == SignalProxy::Client) emit connectRequested(); // on the client this triggers calling this slot on the core - else { - if(connectionState() != Disconnected) { - qWarning() << "Requesting connect while already being connected!"; - return; - } - emit connectRequested(networkId()); // and this is for CoreSession :) - } -} - -void Network::requestDisconnect() const { - if(!proxy()) return; - if(proxy()->proxyMode() == SignalProxy::Client) emit disconnectRequested(); // on the client this triggers calling this slot on the core - else { - if(connectionState() == Disconnected) { - qWarning() << "Requesting disconnect while not being connected!"; - return; - } - emit disconnectRequested(networkId()); // and this is for CoreSession :) - } -} - void Network::emitConnectionError(const QString &errorMsg) { emit connectionError(errorMsg); } @@ -887,7 +738,3 @@ QDebug operator<<(QDebug dbg, const NetworkInfo &i) { << " rejoinChannels = " << i.rejoinChannels << ")"; return dbg.space(); } - - - - diff --git a/src/common/network.h b/src/common/network.h index bf430f8e..3759e565 100644 --- a/src/common/network.h +++ b/src/common/network.h @@ -18,10 +18,9 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _NETWORK_H_ -#define _NETWORK_H_ +#ifndef NETWORK_H_ +#define NETWORK_H_ -#include #include #include #include @@ -33,9 +32,9 @@ #include "types.h" #include "syncableobject.h" -class SignalProxy; -class IrcUser; -class IrcChannel; +#include "signalproxy.h" +#include "ircuser.h" +#include "ircchannel.h" // defined below! struct NetworkInfo; @@ -68,48 +67,70 @@ class Network : public SyncableObject { Q_PROPERTY(bool rejoinChannels READ rejoinChannels WRITE setRejoinChannels STORED false) public: - enum ConnectionState { Disconnected, Connecting, Initializing, Initialized, Reconnecting, Disconnecting }; + enum ConnectionState { + Disconnected, + Connecting, + Initializing, + Initialized, + Reconnecting, + Disconnecting + }; + + // see: + // http://www.irc.org/tech_docs/005.html + // http://www.irc.org/tech_docs/draft-brocklesby-irc-isupport-03.txt + enum ChannelModeType { + NOT_A_CHANMODE = 0x00, + A_CHANMODE = 0x01, + B_CHANMODE = 0x02, + C_CHANMODE = 0x04, + D_CHANMODE = 0x08 + }; + Network(const NetworkId &networkid, QObject *parent = 0); ~Network(); - NetworkId networkId() const; + inline NetworkId networkId() const { return _networkId; } - SignalProxy *proxy() const; - void setProxy(SignalProxy *proxy); + inline SignalProxy *proxy() const { return _proxy; } + inline void setProxy(SignalProxy *proxy) { _proxy = proxy; } - bool isMyNick(const QString &nick) const; - bool isMe(IrcUser *ircuser) const; + inline bool isMyNick(const QString &nick) const { return (myNick().toLower() == nick.toLower()); } + inline bool isMe(IrcUser *ircuser) const { return (ircuser->nick().toLower() == myNick().toLower()); } bool isChannelName(const QString &channelname) const; - bool isConnected() const; + inline bool isConnected() const { return _connected; } //Network::ConnectionState connectionState() const; - int connectionState() const; + inline int connectionState() const { return _connectionState; } QString prefixToMode(const QString &prefix); - QString prefixToMode(const QCharRef &prefix); + inline QString prefixToMode(const QCharRef &prefix) { return prefixToMode(QString(prefix)); } QString modeToPrefix(const QString &mode); - QString modeToPrefix(const QCharRef &mode); + inline QString modeToPrefix(const QCharRef &mode) { return modeToPrefix(QString(mode)); } - QString networkName() const; - QString currentServer() const; - QString myNick() const; + ChannelModeType channelModeType(const QString &mode); + inline ChannelModeType channelModeType(const QCharRef &mode) { return channelModeType(QString(mode)); } + + inline const QString &networkName() const { return _networkName; } + inline const QString ¤tServer() const { return _currentServer; } + inline const QString &myNick() const { return _myNick; } inline IrcUser *me() const { return ircUser(myNick()); } - IdentityId identity() const; + inline IdentityId identity() const { return _identity; } QStringList nicks() const; - QStringList channels() const; - QVariantList serverList() const; - bool useRandomServer() const; - QStringList perform() const; - bool useAutoIdentify() const; - QString autoIdentifyService() const; - QString autoIdentifyPassword() const; - bool useAutoReconnect() const; - quint32 autoReconnectInterval() const; - quint16 autoReconnectRetries() const; - bool unlimitedReconnectRetries() const; - bool rejoinChannels() const; + inline QStringList channels() const { return _ircChannels.keys(); } + inline const QVariantList &serverList() const { return _serverList; } + inline bool useRandomServer() const { return _useRandomServer; } + inline const QStringList &perform() const { return _perform; } + inline bool useAutoIdentify() const { return _useAutoIdentify; } + inline const QString &autoIdentifyService() const { return _autoIdentifyService; } + inline const QString &autoIdentifyPassword() const { return _autoIdentifyPassword; } + inline bool useAutoReconnect() const { return _useAutoReconnect; } + inline quint32 autoReconnectInterval() const { return _autoReconnectInterval; } + inline quint16 autoReconnectRetries() const { return _autoReconnectRetries; } + inline bool unlimitedReconnectRetries() const { return _unlimitedReconnectRetries; } + inline bool rejoinChannels() const { return _rejoinChannels; } NetworkInfo networkInfo() const; void setNetworkInfo(const NetworkInfo &); @@ -117,22 +138,22 @@ public: QString prefixes(); QString prefixModes(); - bool supports(const QString ¶m) const; + bool supports(const QString ¶m) const { return _supports.contains(param); } QString support(const QString ¶m) const; IrcUser *newIrcUser(const QString &hostmask); - IrcUser *newIrcUser(const QByteArray &hostmask); + inline IrcUser *newIrcUser(const QByteArray &hostmask) { return newIrcUser(decodeServerString(hostmask)); } IrcUser *ircUser(QString nickname) const; - IrcUser *ircUser(const QByteArray &nickname) const; - QList ircUsers() const; - quint32 ircUserCount() const; + inline IrcUser *ircUser(const QByteArray &nickname) const { return ircUser(decodeServerString(nickname)); } + inline QList ircUsers() const { return _ircUsers.values(); } + inline quint32 ircUserCount() const { return _ircUsers.count(); } IrcChannel *newIrcChannel(const QString &channelname); - IrcChannel *newIrcChannel(const QByteArray &channelname); + inline IrcChannel *newIrcChannel(const QByteArray &channelname) { return newIrcChannel(decodeServerString(channelname)); } IrcChannel *ircChannel(QString channelname) const; - IrcChannel *ircChannel(const QByteArray &channelname) const; - QList ircChannels() const; - quint32 ircChannelCount() const; + inline IrcChannel *ircChannel(const QByteArray &channelname) const { return ircChannel(decodeServerString(channelname)); } + inline QList ircChannels() const { return _ircChannels.values(); } + inline quint32 ircChannelCount() const { return _ircChannels.count(); } QByteArray codecForServer() const; QByteArray codecForEncoding() const; @@ -188,13 +209,13 @@ public slots: //init geters QVariantMap initSupports() const; - QVariantList initServerList() const; + inline QVariantList initServerList() const { return serverList(); } QStringList initIrcUsers() const; QStringList initIrcChannels() const; //init seters void initSetSupports(const QVariantMap &supports); - void initSetServerList(const QVariantList &serverList); + inline void initSetServerList(const QVariantList &serverList) { setServerList(serverList); } void initSetIrcUsers(const QStringList &hostmasks); void initSetIrcChannels(const QStringList &channels); @@ -204,8 +225,8 @@ public slots: // channel lists up to date void ircUserNickChanged(QString newnick); - void requestConnect() const; - void requestDisconnect() const; + virtual inline void requestConnect() const { emit connectRequested(); } + virtual inline void requestDisconnect() const { emit disconnectRequested(); } void emitConnectionError(const QString &); diff --git a/src/core/core.pri b/src/core/core.pri index 333c09d6..8c0f01a6 100644 --- a/src/core/core.pri +++ b/src/core/core.pri @@ -1,9 +1,9 @@ DEPMOD = common QT_MOD = core network sql script -SRCS = core.cpp corebacklogmanager.cpp corebufferviewconfig.cpp corebufferviewmanager.cpp coresession.cpp coresettings.cpp networkconnection.cpp sqlitestorage.cpp abstractsqlstorage.cpp storage.cpp basichandler.cpp \ +SRCS = core.cpp corebacklogmanager.cpp corebufferviewconfig.cpp corebufferviewmanager.cpp corenetwork.cpp coresession.cpp coresettings.cpp networkconnection.cpp sqlitestorage.cpp abstractsqlstorage.cpp storage.cpp basichandler.cpp \ ircserverhandler.cpp userinputhandler.cpp ctcphandler.cpp coreusersettings.cpp sessionthread.cpp -HDRS = core.h corebacklogmanager.h corebufferviewconfig.h corebufferviewmanager.h coresession.h coresettings.h networkconnection.h sqlitestorage.h abstractsqlstorage.h storage.h basichandler.h \ +HDRS = core.h corebacklogmanager.h corebufferviewconfig.h corebufferviewmanager.h corenetwork.h coresession.h coresettings.h networkconnection.h sqlitestorage.h abstractsqlstorage.h storage.h basichandler.h \ ircserverhandler.h userinputhandler.h ctcphandler.h coreusersettings.h sessionthread.h contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) { diff --git a/src/core/corenetwork.cpp b/src/core/corenetwork.cpp new file mode 100644 index 00000000..cdcf1856 --- /dev/null +++ b/src/core/corenetwork.cpp @@ -0,0 +1,44 @@ +/*************************************************************************** + * 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) version 3. * + * * + * 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 "corenetwork.h" +#include "coresession.h" + +CoreNetwork::CoreNetwork(const NetworkId &networkid, CoreSession *session) + : Network(networkid, session), + _coreSession(session) +{ +} + +void CoreNetwork::requestConnect() const { + if(connectionState() != Disconnected) { + qWarning() << "Requesting connect while already being connected!"; + return; + } + emit connectRequested(networkId()); +} + +void CoreNetwork::requestDisconnect() const { + if(connectionState() == Disconnected) { + qWarning() << "Requesting disconnect while not being connected!"; + return; + } + emit disconnectRequested(networkId()); +} diff --git a/src/core/corenetwork.h b/src/core/corenetwork.h new file mode 100644 index 00000000..2d913179 --- /dev/null +++ b/src/core/corenetwork.h @@ -0,0 +1,46 @@ +/*************************************************************************** + * 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) version 3. * + * * + * 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 CORENETWORK_H +#define CORENETWORK_H + +#include "network.h" + +class CoreSession; + +class CoreNetwork : public Network { + Q_OBJECT + +public: + CoreNetwork(const NetworkId &networkid, CoreSession *session); + + virtual const QMetaObject *syncMetaObject() const { return &Network::staticMetaObject; } + + inline CoreSession *coreSession() const { return _coreSession; } + +public slots: + virtual void requestConnect() const; + virtual void requestDisconnect() const; + +private: + CoreSession *_coreSession; +}; + +#endif //CORENETWORK_H diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index 4b471213..f868379b 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.cpp @@ -31,7 +31,7 @@ #include "corebufferviewmanager.h" #include "storage.h" -#include "network.h" +#include "corenetwork.h" #include "ircuser.h" #include "ircchannel.h" #include "identity.h" @@ -99,7 +99,7 @@ CoreSession::~CoreSession() { foreach(NetworkConnection *conn, _connections.values()) { delete conn; } - foreach(Network *net, _networks.values()) { + foreach(CoreNetwork *net, _networks.values()) { delete net; } } @@ -108,7 +108,7 @@ UserId CoreSession::user() const { return _user; } -Network *CoreSession::network(NetworkId id) const { +CoreNetwork *CoreSession::network(NetworkId id) const { if(_networks.contains(id)) return _networks[id]; return 0; } @@ -170,7 +170,7 @@ void CoreSession::updateBufferInfo(UserId uid, const BufferInfo &bufinfo) { } void CoreSession::connectToNetwork(NetworkId id) { - Network *net = network(id); + CoreNetwork *net = network(id); if(!net) { qWarning() << "Connect to unknown network requested! net:" << id << "user:" << user(); return; @@ -408,7 +408,7 @@ void CoreSession::createNetwork(const NetworkInfo &info_) { id = info.networkId.toInt(); if(!_networks.contains(id)) { - Network *net = new Network(id, this); + CoreNetwork *net = new CoreNetwork(id, this); connect(net, SIGNAL(connectRequested(NetworkId)), this, SLOT(connectToNetwork(NetworkId))); connect(net, SIGNAL(disconnectRequested(NetworkId)), this, SLOT(disconnectFromNetwork(NetworkId))); net->setNetworkInfo(info); @@ -422,6 +422,7 @@ void CoreSession::createNetwork(const NetworkInfo &info_) { } } +// FIXME: move to CoreNetwork void CoreSession::updateNetwork(const NetworkInfo &info) { if(!_networks.contains(info.networkId)) { qWarning() << "Update request for unknown network received!"; @@ -472,7 +473,7 @@ void CoreSession::removeBufferRequested(BufferId bufferId) { } if(bufferInfo.type() == BufferInfo::ChannelBuffer) { - Network *net = network(bufferInfo.networkId()); + CoreNetwork *net = network(bufferInfo.networkId()); if(!net) { qWarning() << "CoreSession::removeBufferRequested(): Received BufferInfo with unknown networkId!"; return; diff --git a/src/core/coresession.h b/src/core/coresession.h index 1403c744..913f630b 100644 --- a/src/core/coresession.h +++ b/src/core/coresession.h @@ -31,7 +31,7 @@ class CoreBacklogManager; class CoreBufferViewManager; class Identity; class NetworkConnection; -class Network; +class CoreNetwork; struct NetworkInfo; class SignalProxy; @@ -46,7 +46,7 @@ public: QList buffers() const; UserId user() const; - Network *network(NetworkId) const; + CoreNetwork *network(NetworkId) const; NetworkConnection *networkConnection(NetworkId) const; Identity *identity(IdentityId) const; @@ -178,8 +178,8 @@ private: SignalProxy *_signalProxy; QHash _connections; - QHash _networks; - QHash _networksToRemove; + QHash _networks; + // QHash _networksToRemove; QHash _identities; BufferSyncer *_bufferSyncer; diff --git a/src/core/ircserverhandler.cpp b/src/core/ircserverhandler.cpp index 9bb6e1d5..5034a714 100644 --- a/src/core/ircserverhandler.cpp +++ b/src/core/ircserverhandler.cpp @@ -170,7 +170,10 @@ void IrcServerHandler::handleJoin(const QString &prefix, const QList emit displayMsg(Message::Join, BufferInfo::ChannelBuffer, channel, channel, prefix); //qDebug() << "IrcServerHandler::handleJoin()" << prefix << params; ircuser->joinChannel(channel); - if(network()->isMe(ircuser)) networkConnection()->setChannelJoined(channel); + if(network()->isMe(ircuser)) { + networkConnection()->setChannelJoined(channel); + putCmd("MODE", params[0]); // we want to know the modes of the channel we just joined, so we ask politely + } } void IrcServerHandler::handleKick(const QString &prefix, const QList ¶ms) { @@ -204,11 +207,9 @@ void IrcServerHandler::handleMode(const QString &prefix, const QList emit displayMsg(Message::Mode, BufferInfo::ChannelBuffer, serverDecode(params[0]), serverDecode(params).join(" "), prefix); IrcChannel *channel = network()->ircChannel(params[0]); - // FIXME: currently the IrcChannels only support PREFIX-Modes for users - // This cannot be fixed unless the SignalProxy() doesn't rely on methodIds anymore QString modes = params[1]; bool add = true; - int modeIndex = 2; + int paramOffset = 2; for(int c = 0; c < modes.length(); c++) { if(modes[c] == '+') { add = true; @@ -219,15 +220,36 @@ void IrcServerHandler::handleMode(const QString &prefix, const QList continue; } - // this is the part where we restrict the mode changes to PREFIXES: - if(network()->prefixModes().contains(modes[c]) && modeIndex < params.count()) { - IrcUser *ircUser = network()->ircUser(params[modeIndex]); + if(network()->prefixModes().contains(modes[c])) { + // user channel modes (op, voice, etc...) + if(paramOffset < params.count()) { + IrcUser *ircUser = network()->ircUser(params[paramOffset]); + if(add) + channel->addUserMode(ircUser, QString(modes[c])); + else + channel->removeUserMode(ircUser, QString(modes[c])); + } else { + qWarning() << "Received MODE with too few parameters:" << serverDecode(params); + } + paramOffset++; + } else { + // regular channel modes + QString value; + Network::ChannelModeType modeType = network()->channelModeType(modes[c]); + if(modeType == Network::A_CHANMODE || modeType == Network::B_CHANMODE || (modeType == Network::C_CHANMODE && add)) { + if(paramOffset < params.count()) { + value = params[paramOffset]; + } else { + qWarning() << "Received MODE with too few parameters:" << serverDecode(params); + } + paramOffset++; + } + if(add) - channel->addUserMode(ircUser, QString(modes[c])); + channel->addChannelMode(modes[c], value); else - channel->removeUserMode(ircUser, QString(modes[c])); + channel->removeChannelMode(modes[c], value); } - modeIndex++; } } else { @@ -701,6 +723,18 @@ void IrcServerHandler::handle320(const QString &prefix, const QList emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("[Whois] %1").arg(serverDecode(params).join(" "))); } +/* RPL_CHANNELMODEIS - " " */ +void IrcServerHandler::handle324(const QString &prefix, const QList ¶ms) { + Q_UNUSED(prefix); + handleMode(prefix, params); +} + +/* RPL_??? - " " */ +void IrcServerHandler::handle329(const QString &prefix, const QList ¶ms) { + Q_UNUSED(prefix); + // FIXME implement this... +} + /* RPL_NOTOPIC */ void IrcServerHandler::handle331(const QString &prefix, const QList ¶ms) { Q_UNUSED(prefix); diff --git a/src/core/ircserverhandler.h b/src/core/ircserverhandler.h index f58b2eac..953c3b48 100644 --- a/src/core/ircserverhandler.h +++ b/src/core/ircserverhandler.h @@ -64,6 +64,8 @@ public slots: void handle318(const QString &prefix, const QList ¶ms); // RPL_ENDOFWHOIS void handle319(const QString &prefix, const QList ¶ms); // RPL_WHOISCHANNELS void handle320(const QString &prefix, const QList ¶ms); // RPL_WHOISVIRT (is identified to services) + void handle324(const QString &prefix, const QList ¶ms); // RPL_CHANNELMODEIS + void handle329(const QString &prefix, const QList ¶ms); // RPL_??? (channel creation time) void handle331(const QString &prefix, const QList ¶ms); // RPL_NOTOPIC void handle332(const QString &prefix, const QList ¶ms); // RPL_TOPIC void handle333(const QString &prefix, const QList ¶ms); // Topic set by... diff --git a/src/qtui/configwizard.cpp b/src/qtui/configwizard.cpp deleted file mode 100644 index c08ef6ca..00000000 --- a/src/qtui/configwizard.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/*************************************************************************** - * 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) version 3. * - * * - * 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 - -#include "configwizard.h" - -ConfigWizard::ConfigWizard(const QStringList &storageProviders, QWidget *parent) : QWizard(parent) { - setPage(Page_Intro, new IntroPage()); - setPage(Page_AdminUser, new AdminUserPage()); - setPage(Page_StorageSelection, new StorageSelectionPage(storageProviders)); - setPage(Page_StorageDetails, new StorageDetailsPage()); - setPage(Page_Conclusion, new ConclusionPage(storageProviders)); - - setStartId(Page_Intro); - -#ifndef Q_WS_MAC - setWizardStyle(ModernStyle); -#endif - - setOption(HaveHelpButton, false); - setOption(NoBackButtonOnStartPage, true); - setOption(HaveNextButtonOnLastPage, false); - setOption(HaveFinishButtonOnEarlyPages, false); - setOption(NoCancelButton, true); - - setWindowTitle(tr("Core Configuration Wizard")); -} - - -IntroPage::IntroPage(QWidget *parent) : QWizardPage(parent) { - setTitle(tr("Introduction")); - - label = new QLabel(tr("This wizard will guide you through the setup process for your shiny new Quassel IRC Client.")); - label->setWordWrap(true); - - QVBoxLayout *layout = new QVBoxLayout(); - layout->addWidget(label); - setLayout(layout); -} - -int IntroPage::nextId() const { - return ConfigWizard::Page_AdminUser; -} - - -AdminUserPage::AdminUserPage(QWidget *parent) : QWizardPage(parent) { - setTitle(tr("Setup Admin User")); - setSubTitle(tr("Please enter credentials for the admin user.")); - - nameLabel = new QLabel(tr("Name:")); - nameEdit = new QLineEdit(); - nameLabel->setBuddy(nameEdit); - - passwordLabel = new QLabel(tr("Password:")); - passwordEdit = new QLineEdit(); - passwordEdit->setEchoMode(QLineEdit::Password); - passwordLabel->setBuddy(passwordLabel); - - registerField("adminuser.name*", nameEdit); - registerField("adminuser.password*", passwordEdit); - - QGridLayout *layout = new QGridLayout(); - layout->addWidget(nameLabel, 0, 0); - layout->addWidget(nameEdit, 0, 1); - layout->addWidget(passwordLabel, 1, 0); - layout->addWidget(passwordEdit, 1, 1); - setLayout(layout); -} - -int AdminUserPage::nextId() const { - return ConfigWizard::Page_StorageSelection; -} - - -StorageSelectionPage::StorageSelectionPage(const QStringList &storageProviders, QWidget *parent) : QWizardPage(parent) { - setTitle(tr("Select Storage Provider")); - setSubTitle(tr("Please select the storage provider you want to use.")); - - storageSelection = new QComboBox(); - storageSelection->addItems(storageProviders); - - registerField("storage.provider", storageSelection); - - QVBoxLayout *layout = new QVBoxLayout(); - layout->addWidget(storageSelection); - setLayout(layout); -} - -int StorageSelectionPage::nextId() const { - QString selection = storageSelection->currentText(); - if (!selection.compare("Sqlite", Qt::CaseInsensitive)) { - return ConfigWizard::Page_Conclusion; - } else { - return ConfigWizard::Page_StorageDetails; - } -} - - -StorageDetailsPage::StorageDetailsPage(QWidget *parent) : QWizardPage(parent) { - setTitle(tr("Setup Storage Provider")); - setSubTitle(tr("Please enter credentials for the selected storage provider.")); - - hostLabel = new QLabel(tr("Host:")); - hostEdit = new QLineEdit(); - hostLabel->setBuddy(hostEdit); - - portLabel = new QLabel(tr("Port:")); - portEdit = new QLineEdit(); - QIntValidator *portValidator = new QIntValidator(0, 65535, this); - portEdit->setValidator(portValidator); - portLabel->setBuddy(portEdit); - - databaseLabel = new QLabel(tr("Database:")); - databaseEdit = new QLineEdit(); - databaseLabel->setBuddy(databaseEdit); - - userLabel = new QLabel(tr("User:")); - userEdit = new QLineEdit(); - userLabel->setBuddy(userEdit); - - passwordLabel = new QLabel(tr("Password:")); - passwordEdit = new QLineEdit(); - passwordEdit->setEchoMode(QLineEdit::Password); - passwordLabel->setBuddy(passwordLabel); - - registerField("storage.host*", hostEdit); - registerField("storage.port*", portEdit); - registerField("storage.database*", databaseEdit); - registerField("storage.user*", userEdit); - registerField("storage.password*", passwordEdit); - - QGridLayout *layout = new QGridLayout(); - layout->addWidget(hostLabel, 0, 0); - layout->addWidget(hostEdit, 0, 1); - layout->addWidget(portLabel, 1, 0); - layout->addWidget(portEdit, 1, 1); - layout->addWidget(databaseLabel, 2, 0); - layout->addWidget(databaseEdit, 2, 1); - layout->addWidget(userLabel, 3, 0); - layout->addWidget(userEdit, 3, 1); - layout->addWidget(passwordLabel, 4, 0); - layout->addWidget(passwordEdit, 4, 1); - setLayout(layout); -} - -int StorageDetailsPage::nextId() const { - return ConfigWizard::Page_Conclusion; -} - - -ConclusionPage::ConclusionPage(const QStringList &storageProviders, QWidget *parent) : QWizardPage(parent) { - setTitle(tr("Conclusion")); - setSubTitle(tr("You chose the following configuration:")); - - this->storageProviders = storageProviders; - - adminuser = new QLabel(); - storage = new QLabel(); - storage->setWordWrap(true); - - QVBoxLayout *layout = new QVBoxLayout(); - layout->addWidget(adminuser); - layout->addWidget(storage); - setLayout(layout); -} - -int ConclusionPage::nextId() const { - return -1; -} - -void ConclusionPage::initializePage() { - QString adminuserText = "Admin User: " + field("adminuser.name").toString(); - adminuser->setText(adminuserText); - - QString storageText = "Selected Storage Provider: "; - QString sp = storageProviders.value(field("storage.provider").toInt()); - if (!sp.compare("Sqlite", Qt::CaseInsensitive)) { - storageText.append(sp); - } else { - storageText += sp + "\nHost: " + field("storage.host").toString() + "\nPort: " + field("storage.port").toString() + "\nDatabase: " + field("storage.database").toString() + "\nUser: " + field("storage.user").toString(); - } - storage->setText(storageText); -} - diff --git a/src/qtui/configwizard.h b/src/qtui/configwizard.h deleted file mode 100644 index a63cd549..00000000 --- a/src/qtui/configwizard.h +++ /dev/null @@ -1,120 +0,0 @@ -/*************************************************************************** - * 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) version 3. * - * * - * 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 CONFIGWIZARD_H_ -#define CONFIGWIZARD_H_ - -#include - -class QLabel; -class QLineEdit; -class QComboBox; - -class ConfigWizard : public QWizard { - Q_OBJECT - - public: - enum { - Page_Intro, - Page_AdminUser, - Page_StorageSelection, - Page_StorageDetails, - Page_Conclusion - }; - - ConfigWizard(const QStringList &storageProviders, QWidget *parent = NULL); -}; - -class IntroPage : public QWizardPage { - Q_OBJECT - - public: - IntroPage(QWidget *parent = NULL); - - int nextId() const; - - private: - QLabel *label; -}; - -class AdminUserPage : public QWizardPage { - Q_OBJECT - - public: - AdminUserPage(QWidget *parent = NULL); - - int nextId() const; - - private: - QLabel *nameLabel; - QLineEdit *nameEdit; - QLabel *passwordLabel; - QLineEdit *passwordEdit; -}; - -class StorageSelectionPage : public QWizardPage { - Q_OBJECT - - public: - StorageSelectionPage(const QStringList &storageProviders, QWidget *parent = NULL); - - int nextId() const; - - private: - QComboBox *storageSelection; -}; - -class StorageDetailsPage : public QWizardPage { - Q_OBJECT - - public: - StorageDetailsPage(QWidget *parent = NULL); - - int nextId() const; - - private: - QLabel *hostLabel; - QLineEdit *hostEdit; - QLabel *portLabel; - QLineEdit *portEdit; - QLabel *databaseLabel; - QLineEdit *databaseEdit; - QLabel *userLabel; - QLineEdit *userEdit; - QLabel *passwordLabel; - QLineEdit *passwordEdit; -}; - -class ConclusionPage : public QWizardPage { - Q_OBJECT - - public: - ConclusionPage(const QStringList &storageProviders, QWidget *parent = NULL); - - void initializePage(); - int nextId() const; - - private: - QLabel *adminuser; - QLabel *storage; - QStringList storageProviders; -}; - -#endif /*CONFIGWIZARD_H_*/ diff --git a/src/qtui/coreconfigwizard.cpp b/src/qtui/coreconfigwizard.cpp index 792fbc0b..799801a3 100644 --- a/src/qtui/coreconfigwizard.cpp +++ b/src/qtui/coreconfigwizard.cpp @@ -135,8 +135,8 @@ int IntroPage::nextId() const { AdminUserPage::AdminUserPage(QWidget *parent) : QWizardPage(parent) { ui.setupUi(this); - setTitle(tr("Create User Account")); - setSubTitle(tr("First, we will create a user account on the core. This first user will have administrator privileges.")); + setTitle(tr("Create Admin User")); + setSubTitle(tr("First, we will create a user on the core. This first user will have administrator privileges.")); registerField("adminUser.user*", ui.user); registerField("adminUser.password*", ui.password); diff --git a/src/qtui/qtui.pri b/src/qtui/qtui.pri index 0b186674..729a128a 100644 --- a/src/qtui/qtui.pri +++ b/src/qtui/qtui.pri @@ -2,12 +2,12 @@ DEPMOD = client common uisupport QT_MOD = core gui network SRCS += aboutdlg.cpp bufferwidget.cpp chatline-old.cpp chatwidget.cpp \ - coreconfigwizard.cpp coreconnectdlg.cpp configwizard.cpp debugconsole.cpp inputwidget.cpp \ + coreconfigwizard.cpp coreconnectdlg.cpp debugconsole.cpp inputwidget.cpp \ mainwin.cpp nicklistwidget.cpp qtui.cpp qtuisettings.cpp qtuistyle.cpp settingsdlg.cpp settingspagedlg.cpp \ titlesetter.cpp topicbutton.cpp topicwidget.cpp verticaldock.cpp jumpkeyhandler.cpp HDRS += aboutdlg.h bufferwidget.h chatline-old.h chatwidget.h \ - coreconfigwizard.h configwizard.h debugconsole.h inputwidget.h \ + coreconfigwizard.h debugconsole.h inputwidget.h \ coreconnectdlg.h mainwin.h nicklistwidget.h qtui.h qtuisettings.h qtuistyle.h settingsdlg.h settingspagedlg.h \ titlesetter.h topicbutton.h topicwidget.h verticaldock.h jumpkeyhandler.h diff --git a/src/qtui/ui/coreconfigwizardadminuserpage.ui b/src/qtui/ui/coreconfigwizardadminuserpage.ui index fcab0778..cb6cc92a 100644 --- a/src/qtui/ui/coreconfigwizardadminuserpage.ui +++ b/src/qtui/ui/coreconfigwizardadminuserpage.ui @@ -5,7 +5,7 @@ 0 0 - 415 + 429 273 @@ -65,7 +65,12 @@ - <em>Note: Adding more users and changing your username/password has not been implemented yet. + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Note: Adding more users and changing your username/password is not possible via Quassel's interface yet.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-style:italic;">If you need to do these things have a look at the manageusers.py script which is located in the /scripts directory.</p></body></html> Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop @@ -80,7 +85,7 @@ Qt::Vertical - + 405 51