Fix license headers: Quassel IRC Team -> Quassel Project, 2007 -> 2008
[quassel.git] / src / core / server.h
index 2841323..771db62 100644 (file)
@@ -1,11 +1,11 @@
 /***************************************************************************
- *   Copyright (C) 2005/06 by The Quassel Team                             *
+ *   Copyright (C) 2005-08 by the Quassel Project                          *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
+ *   (at your option) version 3.                                           *
  *                                                                         *
  *   This program is distributed in the hope that it will be useful,       *
  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
@@ -48,7 +48,7 @@ class Server : public QThread {
   Q_OBJECT
 
 public:
-  Server(UserId uid, uint networkId, QString network);
+  Server(UserId uid, NetworkId networkId, QString network, const QVariant &previousState = QVariant());
   ~Server();
 
   UserId userId() const { return _userId; } 
@@ -56,14 +56,34 @@ public:
   // serverState state();
   bool isConnected() const { return socket.state() == QAbstractSocket::ConnectedState; }
 
-  uint networkId() const;
-  QString networkName();  // hasbeen getNetwork()
+  NetworkId networkId() const;
+  QString networkName() const;  // hasbeen getNetwork()
+
+  NetworkInfo *networkInfo() const { return _networkInfo; }
+  IrcServerHandler *ircServerHandler() const { return _ircServerHandler; }
+  UserInputHandler *userInputHandler() const { return _userInputHandler; }
+  CtcpHandler *ctcpHandler() const { return _ctcpHandler; }
+
+  QVariant state(); ///< Return data necessary to restore the server's state upon core restart
+
+  //! Decode a string using the server (network) decoding.
+  QString serverDecode(const QByteArray &string) const;
+
+  //! Decode a string using a buffer-specific encoding if one is set (and use the server encoding else).
+  QString bufferDecode(const QString &bufferName, const QByteArray &string) const;
+
+  //! Decode a string using a IrcUser specific encoding, if one exists (using the server encoding else).
+  QString userDecode(const QString &userNick, const QByteArray &string) const;
+
+  //! Encode a string using the server (network) encoding.
+  QByteArray serverEncode(const QString &string) const;
+
+  //! Encode a string using the buffer-specific encoding, if set, and use the server encoding else.
+  QByteArray bufferEncode(const QString &bufferName, const QString &string) const;
+
+  //! Encode a string using the user-specific encoding, if set, and use the server encoding else.
+  QByteArray userEncode(const QString &userNick, const QString &string) const;
 
-  NetworkInfo *networkInfo() { return _networkInfo; }
-  IrcServerHandler *ircServerHandler() {return _ircServerHandler; }
-  UserInputHandler *userInputHandler() {return _userInputHandler; }
-  CtcpHandler *ctcpHandler() {return _ctcpHandler; }
-  
 public slots:
   // void setServerOptions();
   void connectToIrc(QString net);
@@ -76,6 +96,7 @@ public slots:
 
 private slots:
   void threadFinished();
+  void sendPerform();
 
 signals:
   void serverState(QString net, QVariantMap data);
@@ -86,6 +107,8 @@ signals:
   void connected(uint networkId);
   void disconnected(uint networkId);
 
+  void connectionInitialized(); ///< Emitted after receipt of 001 to indicate that we can now send data to the IRC server
+
   void synchronizeClients();
   
   void queryRequested(QString network, QString nick);
@@ -100,7 +123,7 @@ private slots:
 
 private:
   UserId _userId;
-  uint _networkId;
+  NetworkId _networkId;
 
   QTcpSocket socket;
 
@@ -113,6 +136,8 @@ private:
   QVariantMap networkSettings;
   QVariantMap identity;
 
+  QVariant _previousState;
+
   CoreSession *coreSession() const;
   
   class ParseError : public Exception {