Fix handling of chat IDs
Don't show status notifications in group chats, make sure chat IDs are found and set properly (on the XMPP side of things).
This commit is contained in:
parent
a89bec40a3
commit
2e1190ae8d
|
@ -290,8 +290,6 @@ Conversation::_EnsureUser(BMessage* msg)
|
|||
fUsers.AddItem(id, user);
|
||||
GetView()->UpdateUserList(fUsers);
|
||||
}
|
||||
|
||||
user->RegisterObserver(this);
|
||||
return user;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -237,6 +237,7 @@ ConversationView::ObserveInteger(int32 what, int32 val)
|
|||
{
|
||||
switch (what) {
|
||||
case INT_CONTACT_STATUS:
|
||||
if (fUserList->CountItems() <= 2)
|
||||
AppendStatus((CayaStatus)val);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
Ŝarĝante…
Reference in New Issue