diff --git a/backends/libcommuni/ircnetworkplugin.cpp b/backends/libcommuni/ircnetworkplugin.cpp index 4996a874558f3bfe6f918f9e0c66e902b21930c2..85182c67608944c30ff94156a96422b8532884ad 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 c13297ff73cabc7df41022f85a9cc60d4b4690e3..a75bc523d6f4b0bf356b6b5f3377c8f7a8f8824e 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 029905a7342327229556e4853ba9f530df1981d7..95d88aa707c3eb7147d45be30188bf678f4976ab 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; };