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