diff --git a/application/Conversation.cpp b/application/Conversation.cpp index 530dbb3..6744d44 100644 --- a/application/Conversation.cpp +++ b/application/Conversation.cpp @@ -290,8 +290,6 @@ Conversation::_EnsureUser(BMessage* msg) fUsers.AddItem(id, user); GetView()->UpdateUserList(fUsers); } - - user->RegisterObserver(this); return user; } diff --git a/application/Server.cpp b/application/Server.cpp index afe5251..a7c9ceb 100644 --- a/application/Server.cpp +++ b/application/Server.cpp @@ -99,7 +99,6 @@ Server::Filter(BMessage* message, BHandler **target) "messenger", messenger); if (ret != B_OK || !messenger->IsValid()) { - message->PrintToStream(); printf("err %s\n", strerror(ret)); break; } @@ -306,9 +305,9 @@ Server::ImMessage(BMessage* msg) case IM_CONTACT_STARTED_TYPING: case IM_CONTACT_STOPPED_TYPING: { - BString id = msg->FindString("chat_id"); - Conversation* item = _EnsureConversation(msg); - item->ImMessage(msg); +// BString id = msg->FindString("chat_id"); +// Conversation* item = _EnsureConversation(msg); +// item->ImMessage(msg); result = B_SKIP_MESSAGE; break; diff --git a/application/views/ConversationView.cpp b/application/views/ConversationView.cpp index e59f0ce..f9bb916 100644 --- a/application/views/ConversationView.cpp +++ b/application/views/ConversationView.cpp @@ -237,7 +237,8 @@ ConversationView::ObserveInteger(int32 what, int32 val) { switch (what) { case INT_CONTACT_STATUS: - AppendStatus((CayaStatus)val); + if (fUserList->CountItems() <= 2) + AppendStatus((CayaStatus)val); break; } } diff --git a/protocols/xmpp/JabberHandler.cpp b/protocols/xmpp/JabberHandler.cpp index 9e25d5d..c491619 100644 --- a/protocols/xmpp/JabberHandler.cpp +++ b/protocols/xmpp/JabberHandler.cpp @@ -848,18 +848,21 @@ JabberHandler::_GlooxStatusToCaya(gloox::Presence::PresenceType type) } -const char* +BString JabberHandler::_MUCChatId(gloox::MUCRoom* room) { BString chat_id(room->name().c_str()); chat_id << "@" << room->service().c_str(); - return chat_id.String(); + BStringList parts; + chat_id.Split("/", false, parts); + + return parts.StringAt(0); } bool -JabberHandler::_MUCUserId(const char* chat_id, const char* nick, BString* id) +JabberHandler::_MUCUserId(BString chat_id, const char* nick, BString* id) { BString chat(chat_id); chat << "/" << nick; @@ -1113,12 +1116,15 @@ JabberHandler::handleMUCParticipantPresence(gloox::MUCRoom *room, const gloox::MUCRoomParticipant participant, const gloox::Presence &presence) { - const char* chat_id = _MUCChatId(room); const char* nick = participant.nick->resource().c_str(); BString user_id; + BString chat_id = _MUCChatId(room); bool isSelf = _MUCUserId(chat_id, nick, &user_id); + if (chat_id.IsEmpty() == true || user_id.IsEmpty() == true) + return; + if (isSelf == true) { BMessage joinedMsg(IM_MESSAGE); joinedMsg.AddInt32("im_what", IM_ROOM_JOINED); @@ -1156,10 +1162,13 @@ void JabberHandler::handleMUCMessage(gloox::MUCRoom *room, const gloox::Message &m, bool priv) { - const char* chat_id = _MUCChatId(room); BString user_id; + BString chat_id = _MUCChatId(room); bool isSelf = _MUCUserId(chat_id, m.from().resource().c_str(), &user_id); + if (chat_id.IsEmpty() == true || user_id.IsEmpty() == true) + return; + int32 im_what = IM_MESSAGE_RECEIVED; // We need a body @@ -1173,7 +1182,7 @@ JabberHandler::handleMUCMessage(gloox::MUCRoom *room, const gloox::Message &m, // when() is only nonzero when sending backdated messages (logs) if (m.when() != 0) - im_what = IM_LOGS_RECEIVED; + im_what = IM_LOGS_RECEIVED; // Notify that a chat message was received BMessage msg(IM_MESSAGE); @@ -1227,10 +1236,12 @@ JabberHandler::handleMUCInfo(gloox::MUCRoom *room, int features, void JabberHandler::handleMUCItems(gloox::MUCRoom *room, const gloox::Disco::ItemList &items) { + BString chat_id = _MUCChatId(room); BStringList nicks; BStringList ids; - const char* chat_id = _MUCChatId(room); + if (chat_id.IsEmpty() == true) + return; for (auto item: items) { BString nick = item->jid().resource().c_str(); diff --git a/protocols/xmpp/JabberHandler.h b/protocols/xmpp/JabberHandler.h index 93129d6..e3ee2dd 100644 --- a/protocols/xmpp/JabberHandler.h +++ b/protocols/xmpp/JabberHandler.h @@ -130,8 +130,8 @@ private: CayaStatus _GlooxStatusToCaya(gloox::Presence::PresenceType type); - const char* _MUCChatId(gloox::MUCRoom* room); - bool _MUCUserId(const char* chat_id, const char* nick, BString* id); + BString _MUCChatId(gloox::MUCRoom* room); + bool _MUCUserId(BString chat_id, const char* nick, BString* id); virtual void onConnect(); virtual void onDisconnect(gloox::ConnectionError);