Merge branch 'cmake'
authorManuel Nickschas <sputnick@quassel-irc.org>
Tue, 17 Jun 2008 18:31:07 +0000 (20:31 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Tue, 17 Jun 2008 18:31:07 +0000 (20:31 +0200)
Mangled the CMakeLists.txt a bit to make WIN32 support less fugly

66 files changed:
CMakeLists.txt
INSTALL.cmake [moved from README.cmake with 93% similarity]
build/modules/module.pri
quasselclient.desktop [new file with mode: 0644]
scripts/manageusers.py [new file with mode: 0755]
src/client/buffer.cpp
src/client/clientsyncer.cpp
src/client/networkmodel.cpp
src/common/genversion.cpp
src/common/ircchannel.cpp
src/common/ircchannel.h
src/common/main.cpp
src/common/network.cpp
src/common/network.h
src/core/CMakeLists.txt
src/core/core.cpp
src/core/core.pri
src/core/corenetwork.cpp [new file with mode: 0644]
src/core/corenetwork.h [new file with mode: 0644]
src/core/coresession.cpp
src/core/coresession.h
src/core/ircserverhandler.cpp
src/core/ircserverhandler.h
src/core/userinputhandler.cpp
src/icons/quassel/connected/128.png [changed mode: 0755->0644]
src/icons/quassel/connected/16.png [changed mode: 0755->0644]
src/icons/quassel/connected/24.png [changed mode: 0755->0644]
src/icons/quassel/connected/256.png [changed mode: 0755->0644]
src/icons/quassel/connected/32.png [changed mode: 0755->0644]
src/icons/quassel/connected/48.png [changed mode: 0755->0644]
src/icons/quassel/connected/64.png [changed mode: 0755->0644]
src/icons/quassel/disconnected/128.png [changed mode: 0755->0644]
src/icons/quassel/disconnected/16.png [changed mode: 0755->0644]
src/icons/quassel/disconnected/24.png [changed mode: 0755->0644]
src/icons/quassel/disconnected/256.png [changed mode: 0755->0644]
src/icons/quassel/disconnected/32.png [changed mode: 0755->0644]
src/icons/quassel/disconnected/48.png [changed mode: 0755->0644]
src/icons/quassel/disconnected/512.png [changed mode: 0755->0644]
src/icons/quassel/disconnected/64.png [changed mode: 0755->0644]
src/icons/quassel/ico_version/128.ico [changed mode: 0755->0644]
src/icons/quassel/ico_version/16.ico [changed mode: 0755->0644]
src/icons/quassel/ico_version/24.ico [changed mode: 0755->0644]
src/icons/quassel/ico_version/256.ico [changed mode: 0755->0644]
src/icons/quassel/ico_version/32.ico [changed mode: 0755->0644]
src/icons/quassel/ico_version/48.ico [changed mode: 0755->0644]
src/icons/quassel/ico_version/64.ico [changed mode: 0755->0644]
src/icons/quassel/newmessage/128.png [changed mode: 0755->0644]
src/icons/quassel/newmessage/16.png [changed mode: 0755->0644]
src/icons/quassel/newmessage/24.png [changed mode: 0755->0644]
src/icons/quassel/newmessage/256.png [changed mode: 0755->0644]
src/icons/quassel/newmessage/32.png [changed mode: 0755->0644]
src/icons/quassel/newmessage/48.png [changed mode: 0755->0644]
src/icons/quassel/newmessage/512.png [changed mode: 0755->0644]
src/icons/quassel/newmessage/64.png [changed mode: 0755->0644]
src/qtui/CMakeLists.txt
src/qtui/chatwidget.cpp
src/qtui/configwizard.cpp [deleted file]
src/qtui/configwizard.h [deleted file]
src/qtui/coreconfigwizard.cpp
src/qtui/qtui.pri
src/qtui/settingsdlg.cpp
src/qtui/settingsdlg.h
src/qtui/ui/coreconfigwizardadminuserpage.ui
src/qtui/ui/settingsdlg.ui
src/uisupport/bufferviewfilter.cpp
src/uisupport/old-uistyle.cpp

index 5088178..0f481a4 100644 (file)
@@ -3,8 +3,7 @@
 # -DWANT_(CORE|QTCLIENT|MONO)=(ON|OFF)
 #                  : select binaries to build
 # -DQT=/path/to/qt : Choose a Qt4 installation to use instead of the system Qt4
-# -DSTATIC=1       : Enable static building of Quassel, most useful with a static Qt.
-# -DSTATICWIN=1    : Enable static building for Windows.
+# -DSTATIC         : Enable static building of Quassel. Use with care.
 # -DSPUTDEV        : Do not use.
 #
 # NOTE: You need to remove CMakeCache.txt if you plan to change any of these values!
@@ -18,10 +17,15 @@ cmake_minimum_required(VERSION 2.4.7 FATAL_ERROR)
 # with 2.4, so... DUH!
 # cmake_policy(SET CMP0003 OLD)  # suppress linker warnings
 
+# Temporary
 if(STATICWIN)
-  set(CMAKE_BUILD_TYPE Release)
+  set(STATIC 1)
 endif(STATICWIN)
 
+if(STATIC)
+  set(CMAKE_BUILD_TYPE Release)
+endif(STATIC)
+
 # Enable various flags on gcc
 include(CheckCXXCompilerFlag)
 check_cxx_compiler_flag(-Wall Wall)
@@ -100,17 +104,22 @@ qt4_add_resources(RC_QUASSEL_ICONS src/icons/quassel-icons.qrc)
 qt4_add_resources(RC_SQL src/core/sql.qrc)
 
 # Set global buildflags
-if(DEFINED STATIC)
-  set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc ${CMAKE_EXE_LINKER_FLAGS}")
-  link_directories(${CMAKE_BINARY_DIR}/staticlibs)
-endif(DEFINED STATIC)
-
-if(STATICWIN AND WIN32)
+# This is very much non-portable, so don't use -DSTATICGCC until you know what
+# you do.
+if(STATIC AND CMAKE_COMPILER_IS_GNUCXX)
+  set(CMAKE_CXX_FLAGS "-static-libgcc ${CMAKE_CXX_FLAGS}")
+  link_directories(${CMAKE_BINARY_DIR}/staticlibs) # override dynamic libs
+  if(OPENSSL_FOUND)
+    set(QUASSEL_SSL_LIBRARIES ssl crypto)  # these miss in static builds
+  endif(OPENSSL_FOUND)
+endif(STATIC AND CMAKE_COMPILER_IS_GNUCXX)
+
+if(STATIC AND WIN32)
   link_libraries(imm32 winmm)  # missing by default :/
    if(OPENSSL_FOUND)
      link_libraries(${OPENSSL_LIBRARIES} libeay32MD)
    endif(OPENSSL_FOUND)
-endif(STATICWIN AND WIN32)
+endif(STATIC AND WIN32)
 
 if(WIN32)
   set(WIN32_RC src/icons/win32.rc)  # for app icons on windows
@@ -123,7 +132,10 @@ endif(WIN32)
 # This macro sets variables for additional Qt modules.
 macro(setup_qt4_variables)
   set(QUASSEL_QT_LIBRARIES )
-  foreach(qtmod CORE ${ARGV})
+  IF(WIN32)
+    set(MAIN MAIN)
+  ENDIF(WIN32)
+  foreach(qtmod CORE ${ARGV} ${MAIN})
     set(QUASSEL_QT_LIBRARIES ${QUASSEL_QT_LIBRARIES} ${QT_QT${qtmod}_LIBRARY} ${QT_${qtmod}_LIB_DEPENDENCIES})
   endforeach(qtmod ${ARGV})
   set(QUASSEL_QT_LIBRARIES ${QUASSEL_QT_LIBRARIES} ${QT_LIBRARIES})
@@ -136,25 +148,28 @@ if(WANT_CORE)
                              ${RC_SQL} ${RC_I18N} ${WIN32_RC})
   set_target_properties(quasselcore PROPERTIES 
                                     COMPILE_FLAGS "-DQT_NETWORK_LIB -DQT_SCRIPT_LIB -DQT_SQL_LIB -DBUILD_CORE")
-  target_link_libraries(quasselcore mod_core mod_common ${QUASSEL_QT_LIBRARIES})
+  target_link_libraries(quasselcore mod_core mod_common 
+                                    ${QUASSEL_QT_LIBRARIES} ${QUASSEL_SSL_LIBRARIES})
 endif(WANT_CORE)
 
 if(WANT_QTCLIENT)
-  setup_qt4_variables(GUI NETWORK MAIN)
+  setup_qt4_variables(GUI NETWORK)
   add_executable(quasselclient WIN32 ${CMAKE_SOURCE_DIR}/src/common/main.cpp
-                               ${RC_ICONS} ${RC_QUASSEL_ICONS} ${RC_I18N} ${WIN32_RC})
+                                     ${RC_ICONS} ${RC_QUASSEL_ICONS} ${RC_I18N} ${WIN32_RC})
   set_target_properties(quasselclient PROPERTIES
                                       COMPILE_FLAGS "-DQT_GUI_LIB -DQT_NETWORK_LIB -DBUILD_QTUI")
-  target_link_libraries(quasselclient mod_qtui mod_uisupport mod_client mod_common ${QUASSEL_QT_LIBRARIES})
+  target_link_libraries(quasselclient mod_qtui mod_uisupport mod_client mod_common
+                                      ${QUASSEL_QT_LIBRARIES} ${QUASSEL_SSL_LIBRARIES})
 endif(WANT_QTCLIENT)
 
 if(WANT_MONO)
-  setup_qt4_variables(GUI NETWORK SCRIPT SQL MAIN)
+  setup_qt4_variables(GUI NETWORK SCRIPT SQL)
   add_executable(quassel WIN32 ${CMAKE_SOURCE_DIR}/src/common/main.cpp
-                         ${RC_ICONS} ${RC_QUASSEL_ICONS} ${RC_SQL} ${RC_I18N} ${WIN32_RC})
+                               ${RC_ICONS} ${RC_QUASSEL_ICONS} ${RC_SQL} ${RC_I18N} ${WIN32_RC})
   set_target_properties(quassel PROPERTIES 
                                 COMPILE_FLAGS "-DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_SCRIPT_LIB -DQT_SQL_LIB -DBUILD_MONO")
-  target_link_libraries(quassel mod_qtui mod_uisupport mod_client mod_core mod_common ${QUASSEL_QT_LIBRARIES})
+  target_link_libraries(quassel mod_qtui mod_uisupport mod_client mod_core mod_common 
+                                ${QUASSEL_QT_LIBRARIES} ${QUASSEL_SSL_LIBRARIES})
 endif(WANT_MONO)
 
 # Build bundles for MacOSX
similarity index 93%
rename from README.cmake
rename to INSTALL.cmake
index 28a6c39..1555d4b 100644 (file)
@@ -20,9 +20,8 @@ NOTE: In order to reconfigure, you need to remove CMakeCache.txt (or empty
 
 Quassel recognizes the following options:
 
--DBUILD=<string>
-    Specify which Quassel binaries to build. <string> may contain any combination of
-    "core", "client", "mono" or "all".
+-DWANT_(CORE|QTCLIENT|MONO)=(ON|OFF)
+    Allow to choose which Quassel binaries to build.
 
 -DQT=/path/to/qt
     Use a non-system Qt installation. This is for example useful if you have a static
index cc452f8..6dc018d 100644 (file)
@@ -46,7 +46,7 @@ include(../contrib/contrib.pri)
 for(dep, DEPMOD) {
   INCLUDEPATH *= $$SRCPATH/$$dep
 }
-INCLUDEPATH *= $$MODPATH  # and don't forget our own dir
+INCLUDEPATH *= $$MODPATH ../../  # and don't forget our own dir
 
 # Now prefix all filenames with the correct dirname
 
diff --git a/quasselclient.desktop b/quasselclient.desktop
new file mode 100644 (file)
index 0000000..887082a
--- /dev/null
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Type=Application
+Version=1.0
+Name=Quassel IRC
+GenericName=IRC Client
+Comment=Distributed IRC client with central core component
+Icon=quassel
+TryExec=quasselclient
+Exec=quasselclient
+Categories=Qt;Network;Chat;IRCClient;
diff --git a/scripts/manageusers.py b/scripts/manageusers.py
new file mode 100755 (executable)
index 0000000..c327865
--- /dev/null
@@ -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 <username> <password>)" % 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])
+    
index c020424..0cb9fac 100644 (file)
@@ -84,7 +84,7 @@ void Buffer::setVisible(bool visible) {
 void Buffer::setLastSeenMsg(const MsgId &msgId) {
   // qDebug() << "want to set lastSeen:" << bufferInfo() << seen << lastSeen();
   const MsgId oldLastSeen = lastSeenMsg();
-  if(!oldLastSeen.isValid() || msgId.isValid() && msgId > oldLastSeen) {
+  if(!oldLastSeen.isValid() || (msgId.isValid() && msgId > oldLastSeen)) {
     //qDebug() << "setting:" << bufferInfo().bufferName() << seen;
     _lastSeenMsg = msgId;
     Client::setBufferLastSeenMsg(bufferInfo().bufferId(), msgId);
index 93d73bb..be5c95b 100644 (file)
@@ -186,8 +186,8 @@ void ClientSyncer::coreSocketDisconnected() {
 
 void ClientSyncer::clientInitAck(const QVariantMap &msg) {
   // Core has accepted our version info and sent its own. Let's see if we accept it as well...
-  if(msg.contains("CoreBuild") && msg["CoreBuild"].toUInt() < 732  // legacy!
-    || !msg.contains("CoreBuild") && msg["ProtocolVersion"].toUInt() < Global::clientNeedsProtocol) {
+  if((msg.contains("CoreBuild") && msg["CoreBuild"].toUInt() < 732)  // legacy!
+     || (!msg.contains("CoreBuild") && msg["ProtocolVersion"].toUInt() < Global::clientNeedsProtocol)) {
     emit connectionError(tr("<b>The Quassel Core you are trying to connect to is too old!</b><br>"
         "Need at least core/client protocol v%1 to connect.").arg(Global::clientNeedsProtocol));
     disconnectFromCore();
index 940feb7..d09605f 100644 (file)
@@ -255,7 +255,7 @@ void BufferItem::removeUserFromCategory(IrcUser *ircUser) {
   UserCategoryItem *categoryItem = 0;
   for(int i = 0; i < childCount(); i++) {
     categoryItem = qobject_cast<UserCategoryItem *>(child(i));
-    if(success = categoryItem->removeUser(ircUser)) {
+    if((success = categoryItem->removeUser(ircUser))) {
       if(categoryItem->childCount() == 0)
        removeChild(i);
       break;
@@ -313,6 +313,11 @@ QString BufferItem::toolTip(int column) const {
             toolTip.append(tr("<b>Topic:</b> %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("<b>Mode:</b> %1").arg(channelMode));
+       }
       } else {
         toolTip.append(tr("Not active <br /> Double-click to join"));
       }
index e8e75f9..e48d494 100644 (file)
@@ -75,7 +75,7 @@ int main(int argc, char **argv) {
   // ok, create our version.gen now
   QFile gen(target);
   if(!gen.open(QIODevice::WriteOnly | QIODevice::Text)) {
-    qFatal(QString("Could not write %1!").arg(target).toAscii());
+    qFatal("%s", qPrintable(QString("Could not write %1!").arg(target)));
     return 255;
   }
   gen.write(QString("quasselGeneratedVersion = \"%1\";\n"
index 57be4e7..9a66d80 100644 (file)
@@ -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 <QDebug>
 
 
-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<QChar, QStringList>::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<QChar, QString>::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<QChar, QString>::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<QChar>::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<IrcUser *>(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<QChar>::const_iterator D_iter = _D_channelModes.constBegin();
+  while(D_iter != _D_channelModes.constEnd()) {
+    modeString += *D_iter;
+    D_iter++;
+  }
+
+  QHash<QChar, QString>::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(" "));
+}
index 26340ce..24347a8 100644 (file)
@@ -22,6 +22,7 @@
 #define _IRCCHANNEL_H_
 
 #include <QHash>
+#include <QSet>
 #include <QString>
 #include <QStringList>
 #include <QVariantMap>
@@ -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<IrcUser *> ircusers);
   void ircUsersJoined(QStringList nicks, QStringList modes);
   void ircUserParted(IrcUser *ircuser);
@@ -126,6 +134,12 @@ private:
 
   QTextCodec *_codecForEncoding;
   QTextCodec *_codecForDecoding;
+
+  QHash<QChar, QStringList> _A_channelModes;
+  QHash<QChar, QString> _B_channelModes;
+  QHash<QChar, QString> _C_channelModes;
+  QSet<QChar> _D_channelModes;
+
 };
 
 #endif
index eca54ba..dca7033 100644 (file)
@@ -54,7 +54,7 @@
 
 //! Signal handler for graceful shutdown.
 void handle_signal(int sig) {
-  qWarning(QString("Caught signal %1 - exiting.").arg(sig).toAscii());
+  qWarning("%s", qPrintable(QString("Caught signal %1 - exiting.").arg(sig)));
   QCoreApplication::quit();
 }
 
index db15d25..4a1d6c8 100644 (file)
  ***************************************************************************/
 #include "network.h"
 
-#include "signalproxy.h"
-#include "ircuser.h"
-#include "ircchannel.h"
-
 #include <QDebug>
 #include <QTextCodec>
 
 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<QString, IrcUser *> 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 &param) 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 &param) 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<IrcUser *>(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<IrcUser *> 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<IrcChannel *> 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 &currentServer) {
 }
 
 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();
 }
-
-
-
-
index bf430f8..3759e56 100644 (file)
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#ifndef _NETWORK_H_
-#define _NETWORK_H_
+#ifndef NETWORK_H_
+#define NETWORK_H_
 
-#include <QDebug>
 #include <QString>
 #include <QStringList>
 #include <QList>
@@ -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 &currentServer() 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 &param) const;
+  bool supports(const QString &param) const { return _supports.contains(param); }
   QString support(const QString &param) 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<IrcUser *> ircUsers() const;
-  quint32 ircUserCount() const;
+  inline IrcUser *ircUser(const QByteArray &nickname) const { return ircUser(decodeServerString(nickname)); }
+  inline QList<IrcUser *> 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<IrcChannel *> ircChannels() const;
-  quint32 ircChannelCount() const;
+  inline IrcChannel *ircChannel(const QByteArray &channelname) const { return ircChannel(decodeServerString(channelname)); }
+  inline QList<IrcChannel *> 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 &);
 
index 37110f3..2219f0a 100644 (file)
@@ -13,6 +13,7 @@ set(SOURCES
     corebacklogmanager.cpp
     corebufferviewconfig.cpp
     corebufferviewmanager.cpp
+    corenetwork.cpp
     coresession.cpp
     coresettings.cpp
     coreusersettings.cpp
@@ -31,6 +32,7 @@ set(MOC_HDRS
     corebacklogmanager.h
     corebufferviewconfig.h
     corebufferviewmanager.h
+    corenetwork.h
     coresession.h
     ctcphandler.h
     ircserverhandler.h
index ebfe491..b156b2d 100644 (file)
@@ -333,7 +333,7 @@ QHash<BufferId, MsgId> Core::bufferLastSeenMsgIds(UserId user) {
 
 bool Core::startListening(uint port) {
   if(!server.listen(QHostAddress::Any, port)) {
-    qWarning(qPrintable(QString("Could not open GUI client port %1: %2").arg(port).arg(server.errorString())));
+    qWarning("%s", qPrintable(QString("Could not open GUI client port %1: %2").arg(port).arg(server.errorString())));
     return false;
   }
   qDebug() << "Listening for GUI clients on port" << server.serverPort();
@@ -386,8 +386,8 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) {
     QVariantMap reply;
 
     // Just version information -- check it!
-    if(msg.contains("ClientBuild") && msg["ClientBuild"].toUInt() < 732
-       || !msg.contains("ClientBuild") && msg["ProtocolVersion"].toUInt() < Global::coreNeedsProtocol) {
+    if((msg.contains("ClientBuild") && msg["ClientBuild"].toUInt() < 732)
+       || (!msg.contains("ClientBuild") && msg["ProtocolVersion"].toUInt() < Global::coreNeedsProtocol)) {
       reply["MsgType"] = "ClientInitReject";
       reply["Error"] = tr("<b>Your Quassel Client is too old!</b><br>"
       "This core needs at least client/core protocol version %1.<br>"
index 333c09d..8c0f01a 100644 (file)
@@ -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 (file)
index 0000000..cdcf185
--- /dev/null
@@ -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 (file)
index 0000000..2d91317
--- /dev/null
@@ -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
index 4b47121..f868379 100644 (file)
@@ -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;
index 1403c74..913f630 100644 (file)
@@ -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<BufferInfo> 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<NetworkId, NetworkConnection *> _connections;
-  QHash<NetworkId, Network *> _networks;
-  QHash<NetworkId, Network *> _networksToRemove;
+  QHash<NetworkId, CoreNetwork *> _networks;
+  //  QHash<NetworkId, CoreNetwork *> _networksToRemove;
   QHash<IdentityId, Identity *> _identities;
 
   BufferSyncer *_bufferSyncer;
index 9bb6e1d..5034a71 100644 (file)
@@ -170,7 +170,10 @@ void IrcServerHandler::handleJoin(const QString &prefix, const QList<QByteArray>
   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<QByteArray> &params) {
@@ -204,11 +207,9 @@ void IrcServerHandler::handleMode(const QString &prefix, const QList<QByteArray>
     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<QByteArray>
        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<QByteArray>
   emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("[Whois] %1").arg(serverDecode(params).join(" ")));
 }
 
+/* RPL_CHANNELMODEIS - "<channel> <mode> <mode params>" */
+void IrcServerHandler::handle324(const QString &prefix, const QList<QByteArray> &params) {
+  Q_UNUSED(prefix);
+  handleMode(prefix, params);
+}
+
+/* RPL_??? - "<channel> <creation time (unix)>" */
+void IrcServerHandler::handle329(const QString &prefix, const QList<QByteArray> &params) {
+  Q_UNUSED(prefix);
+  // FIXME implement this... 
+}
+
 /* RPL_NOTOPIC */
 void IrcServerHandler::handle331(const QString &prefix, const QList<QByteArray> &params) {
   Q_UNUSED(prefix);
index f58b2ea..953c3b4 100644 (file)
@@ -64,6 +64,8 @@ public slots:
   void handle318(const QString &prefix, const QList<QByteArray> &params);   // RPL_ENDOFWHOIS
   void handle319(const QString &prefix, const QList<QByteArray> &params);   // RPL_WHOISCHANNELS
   void handle320(const QString &prefix, const QList<QByteArray> &params);   // RPL_WHOISVIRT (is identified to services)
+  void handle324(const QString &prefix, const QList<QByteArray> &params);   // RPL_CHANNELMODEIS
+  void handle329(const QString &prefix, const QList<QByteArray> &params);   // RPL_??? (channel creation time)
   void handle331(const QString &prefix, const QList<QByteArray> &params);   // RPL_NOTOPIC
   void handle332(const QString &prefix, const QList<QByteArray> &params);   // RPL_TOPIC
   void handle333(const QString &prefix, const QList<QByteArray> &params);   // Topic set by...
index 550e168..ee335e6 100644 (file)
@@ -56,7 +56,7 @@ void UserInputHandler::handleUserInput(const BufferInfo &bufferInfo, const QStri
 void UserInputHandler::handleAway(const BufferInfo &bufferInfo, const QString &msg) {
   Q_UNUSED(bufferInfo)
 
-  QString awayMsg;
+  QString awayMsg = msg;
   // if there is no message supplied we have to check if we are already away or not
   if(msg.isEmpty()) {
     IrcUser *me = network()->me();
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 89da3d2..98e83c6 100644 (file)
@@ -9,7 +9,6 @@ set(SOURCES
     bufferwidget.cpp
     coreconfigwizard.cpp
     coreconnectdlg.cpp
-    configwizard.cpp
     debugconsole.cpp
     inputwidget.cpp
     jumpkeyhandler.cpp
index f386b8e..8a70a6d 100644 (file)
@@ -628,7 +628,7 @@ void ChatWidget::viewportChanged(int newPos) {
     if(buffer->contents().isEmpty())
       return;
     MsgId msgId = buffer->contents().first()->msgId();
-    if(!lastBacklogOffset.isValid() || msgId < lastBacklogOffset && lastBacklogSize + REQUEST_COUNT <= buffer->contents().count()) {
+    if(!lastBacklogOffset.isValid() || (msgId < lastBacklogOffset && lastBacklogSize + REQUEST_COUNT <= buffer->contents().count())) {
       Client::backlogManager()->requestBacklog(bufferId, REQUEST_COUNT, msgId.toInt());
       lastBacklogOffset = msgId;
       lastBacklogSize = buffer->contents().size();
diff --git a/src/qtui/configwizard.cpp b/src/qtui/configwizard.cpp
deleted file mode 100644 (file)
index c08ef6c..0000000
+++ /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 <QtGui>
-
-#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 (file)
index a63cd54..0000000
+++ /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 <QWizard>
-
-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_*/
index 792fbc0..799801a 100644 (file)
@@ -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);
index 0b18667..729a128 100644 (file)
@@ -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
 
index 0b372f6..5f255b1 100644 (file)
 
 #include "settingsdlg.h"
 
-SettingsDlg::SettingsDlg(QWidget *parent) : QDialog(parent) {
+SettingsDlg::SettingsDlg(QWidget *parent)
+  : QDialog(parent),
+    _currentPage(0)
+{
   ui.setupUi(this);
-  _currentPage = 0;
-
-  //recommendedSize = layout()->minimumSize();
-
-  // make the scrollarea behave sanely
-  ui.settingsFrame->setWidgetResizable(true);
-  ui.settingsFrame->setWidget(ui.settingsStack);
 
   updateGeometry();
 
@@ -38,21 +34,10 @@ SettingsDlg::SettingsDlg(QWidget *parent) : QDialog(parent) {
   connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *)));
 }
 
-/*
-QSize SettingsDlg::sizeHint() const {
-  return recommendedSize;
-}
-*/
-
-SettingsPage *SettingsDlg::currentPage() const {
-  return _currentPage;
-}
-
 void SettingsDlg::registerSettingsPage(SettingsPage *sp) {
   sp->setParent(ui.settingsStack);
   ui.settingsStack->addWidget(sp);
-  //recommendedSize = recommendedSize.expandedTo(sp->sizeHint());
-  //updateGeometry();
+  
   connect(sp, SIGNAL(changed(bool)), this, SLOT(setButtonStates()));
 
   QTreeWidgetItem *cat;
@@ -61,27 +46,27 @@ void SettingsDlg::registerSettingsPage(SettingsPage *sp) {
     cat = new QTreeWidgetItem(ui.settingsTree, QStringList(sp->category()));
     cat->setExpanded(true);
     cat->setFlags(Qt::ItemIsEnabled);
-  } else cat = cats[0];
+  } else {
+    cat = cats[0];
+  }
   QTreeWidgetItem *item = new QTreeWidgetItem(cat, QStringList(sp->title()));
-  treeItems[sp] = item;
-  pages[QString("%1$%2").arg(sp->category(), sp->title())] = sp;
+  item->setData(0, SettingsPageRole, qVariantFromValue<QObject *>(sp));
   pageIsLoaded[sp] = false;
-  // TESTING
-  // selectPage(sp->category(), sp->title());
 }
 
-void SettingsDlg::selectPage(const QString &cat, const QString &title) {
-  SettingsPage *sp = pages[QString("%1$%2").arg(cat, title)];
+void SettingsDlg::selectPage(SettingsPage *sp) {
   if(!sp) {
     _currentPage = 0;
     ui.settingsStack->setCurrentIndex(0);
-    ui.settingsTree->setCurrentItem(0);
+    ui.pageTitle->setText(tr("Settings"));
     return;
   }
+
   if(!pageIsLoaded[sp]) {
     sp->load();
     pageIsLoaded[sp] = true;
   }
+
   if(sp != currentPage() && currentPage() != 0 && currentPage()->hasChanged()) {
     int ret = QMessageBox::warning(this, tr("Save changes"),
                                   tr("There are unsaved changes on the current configuration page. Would you like to apply your changes now?"),
@@ -92,27 +77,22 @@ void SettingsDlg::selectPage(const QString &cat, const QString &title) {
       undoChanges();
     } else sp = currentPage();
   }
+
   if(sp != currentPage()) {
     ui.pageTitle->setText(sp->title());
     ui.settingsStack->setCurrentWidget(sp);
-    ui.settingsStack->setMinimumSize(sp->minimumSizeHint());  // we don't want our page shrinked, use scrollbars instead...
     _currentPage = sp;
   }
-  ui.settingsTree->setCurrentItem(treeItems[sp]);
   setButtonStates();
 }
 
 void SettingsDlg::itemSelected() {
   QList<QTreeWidgetItem *> items = ui.settingsTree->selectedItems();
-  if(!items.count()) {
-    return;
-  } else {
-    QTreeWidgetItem *parent = items[0]->parent();
-    if(!parent) return;
-    QString cat = parent->text(0);
-    QString title = items[0]->text(0);
-    selectPage(cat, title);
+  SettingsPage *sp = 0;
+  if(!items.isEmpty()) {
+    sp = qobject_cast<SettingsPage *>(items[0]->data(0, SettingsPageRole).value<QObject *>());
   }
+  selectPage(sp);
 }
 
 void SettingsDlg::setButtonStates() {
index 3cfda43..ba47da3 100644 (file)
 
 class SettingsDlg : public QDialog {
   Q_OBJECT
-  public:
-    SettingsDlg(QWidget *parent = 0);
-    void registerSettingsPage(SettingsPage *);
-    void unregisterSettingsPage(SettingsPage *);
 
-    SettingsPage *currentPage() const;
-
-    //QSize sizeHint() const;
-
-  public slots:
-    void selectPage(const QString &category, const QString &title);
-
-  private slots:
-    void itemSelected();
-    void buttonClicked(QAbstractButton *);
-    bool applyChanges();
-    void undoChanges();
-    void reload();
-    void loadDefaults();
-    void setButtonStates();
-
-  private:
-    Ui::SettingsDlg ui;
-
-    SettingsPage *_currentPage;
-    QHash<QString, SettingsPage *> pages;
-    QHash<SettingsPage *, QTreeWidgetItem *> treeItems;
-    QHash<SettingsPage *, bool> pageIsLoaded;
-
-    //QSize recommendedSize;
+public:
+  SettingsDlg(QWidget *parent = 0);
+  void registerSettingsPage(SettingsPage *);
+  void unregisterSettingsPage(SettingsPage *);
+
+  inline SettingsPage *currentPage() const { return _currentPage; }
+
+public slots:
+  void selectPage(SettingsPage *sp); // const QString &category, const QString &title);
+
+private slots:
+  void itemSelected();
+  void buttonClicked(QAbstractButton *);
+  bool applyChanges();
+  void undoChanges();
+  void reload();
+  void loadDefaults();
+  void setButtonStates();
+  
+private:
+  Ui::SettingsDlg ui;
+  
+  SettingsPage *_currentPage;
+  QHash<SettingsPage *, bool> pageIsLoaded;
+
+  enum {
+    SettingsPageRole = Qt::UserRole
+  };
 };
 
 
index fcab077..cb6cc92 100644 (file)
@@ -5,7 +5,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>415</width>
+    <width>429</width>
     <height>273</height>
    </rect>
   </property>
    <item>
     <widget class="QLabel" name="label" >
      <property name="text" >
-      <string>&lt;em>Note: Adding more users and changing your username/password has not been implemented yet.</string>
+      <string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
+p, li { white-space: pre-wrap; }
+&lt;/style>&lt;/head>&lt;body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;">
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-style:italic;">Note: Adding more users and changing your username/password is not possible via Quassel's interface yet.&lt;/span>&lt;/p>
+&lt;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.&lt;/p>&lt;/body>&lt;/html></string>
      </property>
      <property name="alignment" >
       <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
@@ -80,7 +85,7 @@
      <property name="orientation" >
       <enum>Qt::Vertical</enum>
      </property>
-     <property name="sizeHint" >
+     <property name="sizeHint" stdset="0" >
       <size>
        <width>405</width>
        <height>51</height>
index efb131b..97d41de 100644 (file)
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>828</width>
-    <height>587</height>
+    <width>725</width>
+    <height>575</height>
    </rect>
   </property>
   <property name="windowTitle" >
    <string>Configure Quassel</string>
   </property>
-  <layout class="QVBoxLayout" >
+  <layout class="QVBoxLayout" name="verticalLayout_2" >
    <item>
-    <layout class="QVBoxLayout" >
-     <item>
-      <widget class="QSplitter" name="splitter" >
-       <property name="orientation" >
-        <enum>Qt::Horizontal</enum>
+    <widget class="QSplitter" name="splitter" >
+     <property name="orientation" >
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <widget class="QTreeWidget" name="settingsTree" >
+      <property name="maximumSize" >
+       <size>
+        <width>200</width>
+        <height>16777215</height>
+       </size>
+      </property>
+      <column>
+       <property name="text" >
+        <string>Settings</string>
        </property>
-       <widget class="QTreeWidget" name="settingsTree" >
-        <property name="sizePolicy" >
-         <sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
-          <horstretch>0</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-        <property name="maximumSize" >
-         <size>
-          <width>200</width>
-          <height>16777215</height>
-         </size>
-        </property>
-        <column>
+      </column>
+     </widget>
+     <widget class="QWidget" name="" >
+      <layout class="QVBoxLayout" name="verticalLayout" >
+       <item>
+        <widget class="QLabel" name="pageTitle" >
+         <property name="font" >
+          <font>
+           <weight>75</weight>
+           <bold>true</bold>
+          </font>
+         </property>
          <property name="text" >
           <string>Settings</string>
          </property>
-        </column>
-       </widget>
-       <widget class="QWidget" name="layoutWidget" >
-        <layout class="QVBoxLayout" >
-         <item>
-          <widget class="QLabel" name="pageTitle" >
-           <property name="font" >
-            <font>
-             <weight>75</weight>
-             <bold>true</bold>
-            </font>
-           </property>
-           <property name="text" >
-            <string>Settings</string>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <widget class="Line" name="line" >
-           <property name="orientation" >
-            <enum>Qt::Horizontal</enum>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <widget class="QScrollArea" name="settingsFrame" >
-           <property name="frameShape" >
-            <enum>QFrame::StyledPanel</enum>
-           </property>
-           <property name="frameShadow" >
-            <enum>QFrame::Sunken</enum>
-           </property>
-           <layout class="QVBoxLayout" >
-            <item>
-             <widget class="QStackedWidget" name="settingsStack" >
-              <property name="minimumSize" >
-               <size>
-                <width>16</width>
-                <height>16</height>
-               </size>
-              </property>
-              <property name="currentIndex" >
-               <number>0</number>
-              </property>
-              <widget class="QWidget" name="page_3" />
-             </widget>
-            </item>
-           </layout>
-          </widget>
-         </item>
-        </layout>
-       </widget>
-      </widget>
-     </item>
-     <item>
-      <widget class="QDialogButtonBox" name="buttonBox" >
-       <property name="orientation" >
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="standardButtons" >
-        <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok|QDialogButtonBox::Reset|QDialogButtonBox::RestoreDefaults</set>
-       </property>
-      </widget>
-     </item>
-    </layout>
+        </widget>
+       </item>
+       <item>
+        <widget class="Line" name="line" >
+         <property name="orientation" >
+          <enum>Qt::Horizontal</enum>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QStackedWidget" name="settingsStack" >
+         <widget class="QWidget" name="page" >
+          <property name="geometry" >
+           <rect>
+            <x>0</x>
+            <y>0</y>
+            <width>492</width>
+            <height>466</height>
+           </rect>
+          </property>
+         </widget>
+        </widget>
+       </item>
+      </layout>
+     </widget>
+    </widget>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox" >
+     <property name="orientation" >
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons" >
+      <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset|QDialogButtonBox::RestoreDefaults</set>
+     </property>
+    </widget>
    </item>
   </layout>
  </widget>
- <customwidgets>
-  <customwidget>
-   <class>QScrollArea</class>
-   <extends>QFrame</extends>
-   <header>QScrollArea</header>
-   <container>1</container>
-  </customwidget>
- </customwidgets>
  <resources/>
  <connections/>
 </ui>
index 396922d..0adf8eb 100644 (file)
@@ -102,7 +102,7 @@ void BufferViewFilter::configInitialized() {
 
 Qt::ItemFlags BufferViewFilter::flags(const QModelIndex &index) const {
   Qt::ItemFlags flags = mapToSource(index).flags();
-  if(_config && index == QModelIndex() || index.parent() == QModelIndex())
+  if(_config && (index == QModelIndex() || index.parent() == QModelIndex()))
     flags |= Qt::ItemIsDropEnabled;
   return flags;
 }
index 83024aa..bbbe48e 100644 (file)
@@ -199,7 +199,7 @@ UiStyle::StyledText UiStyle::styleString(const QString &_s) {
       if(s[pos+1] == 'D') code += s[pos+2];
       FormatType ftype = formatType(code);
       if(ftype == Invalid) {
-        qWarning(qPrintable(QString("Invalid format code in string: %1").arg(s)));
+        qWarning("%s", qPrintable(QString("Invalid format code in string: %1").arg(s)));
         continue;
       }
       //Q_ASSERT(ftype != Invalid);