fixed xhtmlim

This commit is contained in:
Jan Kaluza 2011-07-12 08:01:50 +02:00
parent 9477e3f838
commit 441ce14dbf
2 changed files with 16 additions and 1 deletions

View file

@ -648,6 +648,8 @@ static void conv_write_im(PurpleConversation *conv, const char *who, const char
xhtml_ = "";
}
// LOG4CXX_INFO(logger, "Received message body='" << message_ << "' xhtml='" << xhtml_ << "'");
np->handleMessage(np->m_accounts[account], w, message_, "", xhtml_);
}

View file

@ -35,6 +35,7 @@
#include "Swiften/Elements/StreamError.h"
#include "Swiften/Network/BoostConnectionServer.h"
#include "Swiften/Elements/AttentionPayload.h"
#include "Swiften/Elements/XHTMLIMPayload.h"
#include "pbnetwork.pb.h"
#include "sys/wait.h"
#include "sys/signal.h"
@ -391,6 +392,10 @@ void NetworkPluginServer::handleConvMessagePayload(const std::string &data, bool
msg->setBody(payload.message());
}
if (!payload.xhtml().empty()) {
msg->addPayload(boost::make_shared<Swift::XHTMLIMPayload>(payload.xhtml()));
}
NetworkConversation *conv = (NetworkConversation *) user->getConversationManager()->getConversation(payload.buddyname());
if (!conv) {
conv = new NetworkConversation(user->getConversationManager(), payload.buddyname());
@ -695,11 +700,19 @@ void NetworkPluginServer::handleMessageReceived(NetworkConversation *conv, boost
}
if (!msg->getBody().empty()) {
std::string xhtml;
boost::shared_ptr<Swift::XHTMLIMPayload> xhtmlPayload = msg->getPayload<Swift::XHTMLIMPayload>();
if (xhtmlPayload) {
xhtml = xhtmlPayload->getBody();
}
// Send normal message
if (!msg->getBody().empty() || !xhtml.empty()) {
pbnetwork::ConversationMessage m;
m.set_username(conv->getConversationManager()->getUser()->getJID().toBare());
m.set_buddyname(conv->getLegacyName());
m.set_message(msg->getBody());
m.set_xhtml(xhtml);
std::string message;
m.SerializeToString(&message);