working PM
This commit is contained in:
parent
2add374fbd
commit
943dc1925b
5 changed files with 41 additions and 19 deletions
|
@ -1445,7 +1445,7 @@ DOT_IMAGE_FORMAT = png
|
|||
# The tag DOT_PATH can be used to specify the path where the dot tool can be
|
||||
# found. If left blank, it is assumed the dot tool can be found in the path.
|
||||
|
||||
DOT_PATH = ""
|
||||
DOT_PATH = "/usr/bin"
|
||||
|
||||
# The DOTFILE_DIRS tag can be used to specify one or more directories that
|
||||
# contain dot files that are included in the documentation (see the
|
||||
|
|
|
@ -34,7 +34,7 @@ class ConversationManager;
|
|||
class Conversation {
|
||||
public:
|
||||
/// Constructor.
|
||||
Conversation(ConversationManager *conversationManager, const std::string &legacyName);
|
||||
Conversation(ConversationManager *conversationManager, const std::string &legacyName, bool m_muc = false);
|
||||
|
||||
/// Destructor
|
||||
virtual ~Conversation();
|
||||
|
@ -53,11 +53,24 @@ class Conversation {
|
|||
return m_conversationManager;
|
||||
}
|
||||
|
||||
bool isMUC() {
|
||||
return m_muc;
|
||||
}
|
||||
|
||||
void setRoom(const std::string &room) {
|
||||
m_room = room;
|
||||
}
|
||||
|
||||
const std::string &getRoom() {
|
||||
return m_room;
|
||||
}
|
||||
|
||||
private:
|
||||
ConversationManager *m_conversationManager;
|
||||
std::string m_legacyName;
|
||||
std::string m_nickname;
|
||||
int m_muc;
|
||||
std::string m_room;
|
||||
bool m_muc;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -28,10 +28,10 @@
|
|||
|
||||
namespace Transport {
|
||||
|
||||
Conversation::Conversation(ConversationManager *conversationManager, const std::string &legacyName) : m_conversationManager(conversationManager) {
|
||||
Conversation::Conversation(ConversationManager *conversationManager, const std::string &legacyName, bool isMUC) : m_conversationManager(conversationManager) {
|
||||
m_legacyName = legacyName;
|
||||
m_conversationManager->setConversation(this);
|
||||
m_muc = -1;
|
||||
m_muc = isMUC;
|
||||
}
|
||||
|
||||
Conversation::~Conversation() {
|
||||
|
@ -39,9 +39,7 @@ Conversation::~Conversation() {
|
|||
}
|
||||
|
||||
void Conversation::handleMessage(boost::shared_ptr<Swift::Message> &message, const std::string &nickname) {
|
||||
if (m_muc == -1)
|
||||
m_muc = message->getType() != Swift::Message::Groupchat;
|
||||
if (m_muc == 0) {
|
||||
if (m_muc) {
|
||||
message->setType(Swift::Message::Groupchat);
|
||||
}
|
||||
else {
|
||||
|
@ -64,7 +62,12 @@ void Conversation::handleMessage(boost::shared_ptr<Swift::Message> &message, con
|
|||
}
|
||||
// PM message
|
||||
else {
|
||||
message->setFrom(Swift::JID(nickname, m_conversationManager->getComponent()->getJID().toBare(), "user"));
|
||||
if (m_room.empty()) {
|
||||
message->setFrom(Swift::JID(nickname, m_conversationManager->getComponent()->getJID().toBare(), "user"));
|
||||
}
|
||||
else {
|
||||
message->setFrom(Swift::JID(m_room, m_conversationManager->getComponent()->getJID().toBare(), nickname));
|
||||
}
|
||||
}
|
||||
m_conversationManager->getComponent()->getStanzaChannel()->sendMessage(message);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,11 @@ void ConversationManager::setConversation(Conversation *conv) {
|
|||
}
|
||||
|
||||
void ConversationManager::unsetConversation(Conversation *conv) {
|
||||
for (std::map<std::string, Conversation *>::const_iterator it = m_convs.begin(); it != m_convs.end(); it++) {
|
||||
if ((*it).second->getRoom() == conv->getLegacyName()) {
|
||||
(*it).second->setRoom("");
|
||||
}
|
||||
}
|
||||
m_convs.erase(conv->getLegacyName());
|
||||
}
|
||||
|
||||
|
@ -55,6 +60,15 @@ void ConversationManager::handleMessageReceived(Swift::Message::ref message) {
|
|||
if (!m_convs[name]) {
|
||||
m_convs[name] = m_component->getFactory()->createConversation(this, name);
|
||||
}
|
||||
else if (m_convs[name]->isMUC() && message->getType() != Swift::Message::Groupchat) {
|
||||
std::string room_name = name;
|
||||
name = message->getTo().getResource();
|
||||
if (!m_convs[name]) {
|
||||
m_convs[name] = m_component->getFactory()->createConversation(this, name);
|
||||
m_convs[name]->setRoom(room_name);
|
||||
}
|
||||
}
|
||||
|
||||
m_convs[name]->sendMessage(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace Transport {
|
|||
|
||||
class NetworkConversation : public Conversation {
|
||||
public:
|
||||
NetworkConversation(ConversationManager *conversationManager, const std::string &legacyName) : Conversation(conversationManager, legacyName) {
|
||||
NetworkConversation(ConversationManager *conversationManager, const std::string &legacyName, bool muc = false) : Conversation(conversationManager, legacyName, muc) {
|
||||
}
|
||||
|
||||
void sendMessage(boost::shared_ptr<Swift::Message> &message) {
|
||||
|
@ -263,15 +263,7 @@ void NetworkPluginServer::handleConvMessagePayload(const std::string &data) {
|
|||
conv = new NetworkConversation(user->getConversationManager(), payload.buddyname());
|
||||
conv->onMessageToSend.connect(boost::bind(&NetworkPluginServer::handleMessageReceived, this, _1, _2));
|
||||
}
|
||||
else {
|
||||
// groupchat messages can be created only for conversations initiated from XMPP side, not from legacy network side.
|
||||
// ie. you can't create Groupchat conversation from legacy network side.
|
||||
if (!payload.nickname().empty()) {
|
||||
msg->setType(Swift::Message::Groupchat);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
conv->handleMessage(msg, payload.nickname());
|
||||
}
|
||||
|
||||
|
@ -387,7 +379,7 @@ void NetworkPluginServer::handleRoomJoined(User *user, const std::string &r, con
|
|||
|
||||
send(m_client, message);
|
||||
|
||||
NetworkConversation *conv = new NetworkConversation(user->getConversationManager(), r);
|
||||
NetworkConversation *conv = new NetworkConversation(user->getConversationManager(), r, true);
|
||||
conv->onMessageToSend.connect(boost::bind(&NetworkPluginServer::handleMessageReceived, this, _1, _2));
|
||||
conv->setNickname(nickname);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue