From a32e962a1a97bccdce50c1f603ca5d7897f681fc Mon Sep 17 00:00:00 2001 From: HanzZ Date: Mon, 11 Feb 2013 20:44:28 +0100 Subject: [PATCH] Libcommuni: Fixed bug when response to PM message initated from XMPP was not sent to the same JID --- backends/libcommuni/ircnetworkplugin.cpp | 3 +++ backends/libcommuni/session.cpp | 18 ++++++++++++++++-- backends/libcommuni/session.h | 5 +++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/backends/libcommuni/ircnetworkplugin.cpp b/backends/libcommuni/ircnetworkplugin.cpp index 4996a874..85182c67 100644 --- a/backends/libcommuni/ircnetworkplugin.cpp +++ b/backends/libcommuni/ircnetworkplugin.cpp @@ -153,6 +153,9 @@ void IRCNetworkPlugin::handleMessageSendRequest(const std::string &user, const s } std::string target = getTargetName(legacyName); + if (legacyName.find("/") != std::string::npos) { + m_sessions[session]->addPM(target, legacyName.substr(0, legacyName.find("@"))); + } LOG4CXX_INFO(logger, user << ": Session name: " << session << ", message to " << target); diff --git a/backends/libcommuni/session.cpp b/backends/libcommuni/session.cpp index c13297ff..a75bc523 100644 --- a/backends/libcommuni/session.cpp +++ b/backends/libcommuni/session.cpp @@ -203,8 +203,22 @@ void MyIrcSession::on_messageReceived(IrcMessage *message) { else { std::string nickname = TO_UTF8(m->sender().name()); correctNickname(nickname); - LOG4CXX_INFO(logger, nickname + suffix); - np->handleMessage(user, nickname + suffix, TO_UTF8(msg)); + if (m_pms.find(nickname) != m_pms.end()) { + if (hasIRCBuddy(m_pms[nickname], nickname)) { + LOG4CXX_INFO(logger, nickname); + np->handleMessage(user, m_pms[nickname] + suffix, TO_UTF8(msg), nickname, "", "", false, true); + return; + } + else { + nickname = nickname + suffix; + } + } + else { + nickname = nickname + suffix; + } + + LOG4CXX_INFO(logger, nickname); + np->handleMessage(user, nickname, TO_UTF8(msg)); } } diff --git a/backends/libcommuni/session.h b/backends/libcommuni/session.h index 029905a7..95d88aa7 100644 --- a/backends/libcommuni/session.h +++ b/backends/libcommuni/session.h @@ -81,6 +81,10 @@ public: removeIRCBuddies(channel); } + void addPM(const std::string &name, const std::string &room) { + m_pms[name] = room; + } + void setIdentify(const std::string &identify) { m_identify = identify; } @@ -133,6 +137,7 @@ protected: bool m_connected; std::list m_rooms; std::list m_names; + std::map m_pms; IRCBuddyMap m_buddies; QTimer *m_awayTimer; };