handle incoming invite, fixes #961
authorJohannes Huber <johu@gmx.de>
Fri, 7 May 2010 11:43:38 +0000 (13:43 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Tue, 10 Aug 2010 18:41:27 +0000 (20:41 +0200)
data/stylesheets/default.qss
src/common/message.h
src/core/ircserverhandler.cpp
src/core/ircserverhandler.h
src/qtui/qtuistyle.cpp
src/uisupport/qssparser.cpp
src/uisupport/uistyle.cpp
src/uisupport/uistyle.h

index cebcfb4..792442c 100644 (file)
@@ -91,6 +91,7 @@ ChatLine#daychange { foreground: #916409; }
 ChatLine#topic { foreground: #960096; }
 ChatLine#netsplit-join { foreground: #960096; }
 ChatLine#netsplit-quit { foreground: #960096; }
+ChatLine#invite { foreground: #916409; }
 
 // BufferView Colors
 ChatListItem[state="inactive"] { foreground: #a0a0a4; }
index 938bf43..96ac10e 100644 (file)
@@ -50,6 +50,7 @@ public:
     Topic     = 0x04000,
     NetsplitJoin = 0x08000,
     NetsplitQuit = 0x10000,
+    Invite = 0x20000,
   };
 
   // DO NOT CHANGE without knowing what you do, some of these flags are stored in the database
index 534229c..033d6c8 100644 (file)
@@ -197,6 +197,21 @@ void IrcServerHandler::defaultHandler(QString cmd, const QString &prefix, const
 //******************************/
 // IRC SERVER HANDLER
 //******************************/
+void IrcServerHandler::handleInvite(const QString &prefix, const QList<QByteArray> &params) {
+  if(!checkParamCount("IrcServerHandler::handleInvite()", params, 2))
+    return;
+//   qDebug() << "IrcServerHandler::handleInvite()" << prefix << params;
+
+  IrcUser *ircuser = network()->updateNickFromMask(prefix);
+  if(!ircuser) {
+    return;
+  }
+
+  QString channel = serverDecode(params[1]);
+
+  emit displayMsg(Message::Invite, BufferInfo::StatusBuffer, "", tr("%1 invited you to channel %2").arg(ircuser->nick()).arg(channel));
+}
+
 void IrcServerHandler::handleJoin(const QString &prefix, const QList<QByteArray> &params) {
   if(!checkParamCount("IrcServerHandler::handleJoin()", params, 1))
     return;
index df5fcbe..652c808 100644 (file)
@@ -34,6 +34,7 @@ public:
   void handleServerMsg(QByteArray rawMsg);
 
 public slots:
+  void handleInvite(const QString &prefix, const QList<QByteArray> &params);
   void handleJoin(const QString &prefix, const QList<QByteArray> &params);
   void handleKick(const QString &prefix, const QList<QByteArray> &params);
   void handleMode(const QString &prefix, const QList<QByteArray> &params);
index 2fa8aeb..cc5fa26 100644 (file)
@@ -85,6 +85,7 @@ void QtUiStyle::generateSettingsQss() const {
         << msgTypeQss("topic", "CommandMsg", s)
         << msgTypeQss("netsplit-join", "CommandMsg", s)
         << msgTypeQss("netsplit-quit", "CommandMsg", s)
+        << msgTypeQss("invite", "CommandMsg", s)
         << "\n";
   }
 
index 06e4db2..f6927e4 100644 (file)
@@ -230,6 +230,8 @@ quint64 QssParser::parseFormatType(const QString &decl) {
       fmtType |= UiStyle::NetsplitJoinMsg;
     else if(msgType == "netsplit-quit")
       fmtType |= UiStyle::NetsplitQuitMsg;
+    else if(msgType == "invite")
+      fmtType |= UiStyle::InviteMsg;
     else {
       qWarning() << Q_FUNC_INFO << tr("Invalid message type in %1").arg(decl);
     }
index 3739fe9..b08134b 100644 (file)
@@ -406,6 +406,8 @@ UiStyle::FormatType UiStyle::formatType(Message::Type msgType) {
       return NetsplitJoinMsg;
     case Message::NetsplitQuit:
       return NetsplitQuitMsg;
+    case Message::Invite:
+      return InviteMsg;
   }
   //Q_ASSERT(false); // we need to handle all message types
   qWarning() << Q_FUNC_INFO << "Unknown message type:" << msgType;
@@ -658,6 +660,9 @@ void UiStyle::StyledMessage::style() const {
         t.append(tr("%DN%1%DN (%2 more)").arg(static_cast<QStringList>(users.mid(0, maxNetsplitNicks)).join(", ")).arg(users.count() - maxNetsplitNicks));
       }
       break;
+    case Message::Invite:
+      //: Invite Message
+      t = tr("%1").arg(txt); break;
     default:
       t = tr("[%1]").arg(txt);
   }
@@ -728,6 +733,8 @@ QString UiStyle::StyledMessage::decoratedSender() const {
       return tr("=>"); break;
     case Message::NetsplitQuit:
       return tr("<="); break;
+    case Message::Invite:
+      return tr("->"); break;
     default:
       return tr("%1").arg(plainSender());
   }
index dcda30a..db82c1a 100644 (file)
@@ -72,6 +72,7 @@ public:
     TopicMsg        = 0x0000000f,
     NetsplitJoinMsg = 0x00000010,
     NetsplitQuitMsg = 0x00000020,
+    InviteMsg       = 0x00000030,
 
     // Standard Formats
     Bold            = 0x00000100,