Fix includes
[quassel.git] / src / core / ircparser.cpp
index 2a06811..cd59e53 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2010 by the Quassel Project                        *
+ *   Copyright (C) 2005-2012 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -34,7 +34,7 @@ IrcParser::IrcParser(CoreSession *session) :
   QObject(session),
   _coreSession(session)
 {
-
+  connect(this, SIGNAL(newEvent(Event *)), coreSession()->eventManager(), SLOT(postEvent(Event *)));
 }
 
 bool IrcParser::checkParamCount(const QString &cmd, const QList<QByteArray> &params, int minParams) {
@@ -50,12 +50,18 @@ QByteArray IrcParser::decrypt(Network *network, const QString &bufferName, const
   if(message.isEmpty())
     return message;
 
+  if(!Cipher::neededFeaturesAvailable())
+    return message;
+
   Cipher *cipher = qobject_cast<CoreNetwork *>(network)->cipher(bufferName);
   if(!cipher)
     return message;
 
   return isTopic? cipher->decryptTopic(message) : cipher->decrypt(message);
 #else
+  Q_UNUSED(network);
+  Q_UNUSED(bufferName);
+  Q_UNUSED(isTopic);
   return message;
 #endif
 }
@@ -130,16 +136,18 @@ void IrcParser::processNetworkIncoming(NetworkDataEvent *e) {
   QList<Event *> events;
   EventManager::EventType type = EventManager::Invalid;
 
-  // numeric replies have the target as first param (RFC 2812 - 2.4). this is usually our own nick. Remove this!
   uint num = cmd.toUInt();
   if(num > 0) {
+    // numeric reply
     if(params.count() == 0) {
       qWarning() << "Message received from server violates RFC and is ignored!" << msg;
       return;
     }
+    // numeric replies have the target as first param (RFC 2812 - 2.4). this is usually our own nick. Remove this!
     target = net->serverDecode(params.takeFirst());
     type = EventManager::IrcEventNumeric;
   } else {
+    // any other irc command
     QString typeName = QLatin1String("IrcEvent") + cmd.at(0).toUpper() + cmd.mid(1).toLower();
     type = eventManager()->eventTypeByName(typeName);
     if(type == EventManager::Invalid) {
@@ -175,7 +183,6 @@ void IrcParser::processNetworkIncoming(NetworkDataEvent *e) {
         msg = decrypt(net, target, msg);
 
         events << new IrcEventRawMessage(EventManager::IrcEventRawPrivmsg, net, msg, prefix, target, e->timestamp());
-        //events << new MessageEvent(Message::Plain, net, net->channelDecode(target, msg), target, prefix);
       }
     }
     break;
@@ -214,7 +221,7 @@ void IrcParser::processNetworkIncoming(NetworkDataEvent *e) {
           if(!net->isChannelName(target))
             target = nickFromMask(prefix);
         }
-        events << new IrcEventRawMessage(EventManager::IrcEventRawNotice, net, msg, prefix, target, e->timestamp());
+        events << new IrcEventRawMessage(EventManager::IrcEventRawNotice, net, params[1], prefix, target, e->timestamp());
       }
     }
     break;
@@ -268,7 +275,7 @@ void IrcParser::processNetworkIncoming(NetworkDataEvent *e) {
       break;
 
     case 333:  /* Topic set by... */
-      if(params.count() >= 2) {
+      if(params.count() >= 3) {
         QString channel = net->serverDecode(params.at(0));
         decParams << channel << net->serverDecode(params.at(1));
         decParams << net->channelDecode(channel, params.at(2));
@@ -295,6 +302,6 @@ void IrcParser::processNetworkIncoming(NetworkDataEvent *e) {
   }
 
   foreach(Event *event, events) {
-    coreSession()->eventManager()->sendEvent(event);
+    emit newEvent(event);
   }
 }