(jabber) Setting own nickname

This commit is contained in:
Jaidyn Ann 2021-08-03 19:35:09 -05:00
parent db70ce4f57
commit d3f775d8b8

View File

@ -117,6 +117,14 @@ JabberHandler::Process(BMessage* msg)
} }
break; break;
} }
case IM_SET_OWN_NICKNAME:
{
const char* nick = msg->FindString("user_name");
if (nick != NULL)
for (int i = 0; i < fRooms.CountItems(); i++)
fRooms.ValueAt(i)->setNick(nick);
break;
}
case IM_SEND_MESSAGE: case IM_SEND_MESSAGE:
{ {
const char* id = msg->FindString("chat_id"); const char* id = msg->FindString("chat_id");
@ -1619,7 +1627,17 @@ JabberHandler::handleMUCParticipantPresence(gloox::MUCRoom *room,
if (chat_id.IsEmpty() == true || user_id.IsEmpty() == true) if (chat_id.IsEmpty() == true || user_id.IsEmpty() == true)
return; return;
if (isSelf == true) { if (participant.flags & gloox::UserSelf) {
if ((participant.flags & gloox::UserNickChanged)
|| (participant.flags & gloox::UserNickAssigned))
{
BMessage nickChanged(IM_MESSAGE);
nickChanged.AddInt32("im_what", IM_OWN_NICKNAME_SET);
nickChanged.AddString("user_name", participant.newNick.c_str());
_SendMessage(&nickChanged);
fNick = participant.newNick.c_str();
}
else {
int im_what = IM_ROOM_JOINED; int im_what = IM_ROOM_JOINED;
if (presence.presence() == 5) if (presence.presence() == 5)
im_what = IM_ROOM_LEFT; im_what = IM_ROOM_LEFT;
@ -1629,6 +1647,7 @@ JabberHandler::handleMUCParticipantPresence(gloox::MUCRoom *room,
joinedMsg.AddString("chat_id", chat_id); joinedMsg.AddString("chat_id", chat_id);
_SendMessage(&joinedMsg); _SendMessage(&joinedMsg);
_RoleChangedMsg(chat_id, user_id, role, aff); _RoleChangedMsg(chat_id, user_id, role, aff);
}
return; return;
} }
@ -1866,7 +1885,7 @@ JabberHandler::handleSelfPresence(const gloox::RosterItem& item, const std::stri
msg.AddInt32("im_what", IM_OWN_CONTACT_INFO); msg.AddInt32("im_what", IM_OWN_CONTACT_INFO);
msg.AddString("protocol", Signature()); msg.AddString("protocol", Signature());
msg.AddString("user_id", item.jidJID().full().c_str()); msg.AddString("user_id", item.jidJID().full().c_str());
msg.AddString("user_name", item.name().c_str()); msg.AddString("user_name", fNick.String());
msg.AddInt32("subscription", item.subscription()); msg.AddInt32("subscription", item.subscription());
msg.AddInt32("status", _GlooxStatusToApp(type)); msg.AddInt32("status", _GlooxStatusToApp(type));
msg.AddString("message", presenceMsg.c_str()); msg.AddString("message", presenceMsg.c_str());