parent
48db626672
commit
f0256babc1
|
@ -167,6 +167,41 @@ PurpleApp::ImMessage(BMessage* msg)
|
||||||
purple_conv_im_send(im, body.String());
|
purple_conv_im_send(im, body.String());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case IM_GET_ROOM_METADATA:
|
||||||
|
{
|
||||||
|
PurpleConversation* conv = _ConversationFromMessage(msg);
|
||||||
|
PurpleConvChat* chat = purple_conversation_get_chat_data(conv);
|
||||||
|
|
||||||
|
BMessage meta(IM_MESSAGE);
|
||||||
|
meta.AddInt32("im_what", IM_ROOM_METADATA);
|
||||||
|
meta.AddString("chat_id", purple_conversation_get_name(conv));
|
||||||
|
meta.AddString("chat_name", purple_conversation_get_title(conv));
|
||||||
|
if (chat != NULL)
|
||||||
|
meta.AddString("subject", purple_conv_chat_get_topic(chat));
|
||||||
|
SendMessage(purple_conversation_get_account(conv), meta);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case IM_GET_ROOM_PARTICIPANTS:
|
||||||
|
{
|
||||||
|
PurpleConversation* conv = _ConversationFromMessage(msg);
|
||||||
|
PurpleConvChat* chat = purple_conversation_get_chat_data(conv);
|
||||||
|
if (chat == NULL) return;
|
||||||
|
|
||||||
|
|
||||||
|
BStringList user_ids;
|
||||||
|
GList* users = purple_conv_chat_get_users(chat);
|
||||||
|
for (int i = 0; users != NULL; users = users->next) {
|
||||||
|
PurpleConvChatBuddy* user = (PurpleConvChatBuddy*)users->data;
|
||||||
|
user_ids.Add(BString(purple_conv_chat_cb_get_name(user)));
|
||||||
|
}
|
||||||
|
|
||||||
|
BMessage parts(IM_MESSAGE);
|
||||||
|
parts.AddInt32("im_what", IM_ROOM_PARTICIPANTS);
|
||||||
|
parts.AddString("chat_id", purple_conversation_get_name(conv));
|
||||||
|
parts.AddStrings("user_id", user_ids);
|
||||||
|
SendMessage(purple_conversation_get_account(conv), parts);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
std::cout << "IM_MESSAGE unhandled by Purple:\n";
|
std::cout << "IM_MESSAGE unhandled by Purple:\n";
|
||||||
msg->PrintToStream();
|
msg->PrintToStream();
|
||||||
|
@ -495,6 +530,8 @@ init_signals()
|
||||||
&handle, PURPLE_CALLBACK(signal_received_chat_msg), NULL);
|
&handle, PURPLE_CALLBACK(signal_received_chat_msg), NULL);
|
||||||
purple_signal_connect(purple_conversations_get_handle(), "received-im-msg",
|
purple_signal_connect(purple_conversations_get_handle(), "received-im-msg",
|
||||||
&handle, PURPLE_CALLBACK(signal_received_chat_msg), NULL);
|
&handle, PURPLE_CALLBACK(signal_received_chat_msg), NULL);
|
||||||
|
purple_signal_connect(purple_conversations_get_handle(), "chat-buddy-joined",
|
||||||
|
&handle, PURPLE_CALLBACK(signal_chat_buddy_joined), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -539,8 +576,9 @@ signal_chat_joined(PurpleConversation* conv)
|
||||||
BMessage join(IM_MESSAGE);
|
BMessage join(IM_MESSAGE);
|
||||||
join.AddInt32("im_what", IM_ROOM_JOINED);
|
join.AddInt32("im_what", IM_ROOM_JOINED);
|
||||||
join.AddString("chat_id", purple_conversation_get_name(conv));
|
join.AddString("chat_id", purple_conversation_get_name(conv));
|
||||||
((PurpleApp*)be_app)->SendMessage(purple_conversation_get_account(conv),
|
|
||||||
join);
|
PurpleAccount* account = purple_conversation_get_account(conv);
|
||||||
|
((PurpleApp*)be_app)->SendMessage(account, join);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -550,8 +588,9 @@ signal_chat_left(PurpleConversation* conv)
|
||||||
BMessage left(IM_MESSAGE);
|
BMessage left(IM_MESSAGE);
|
||||||
left.AddInt32("im_what", IM_ROOM_LEFT);
|
left.AddInt32("im_what", IM_ROOM_LEFT);
|
||||||
left.AddString("chat_id", purple_conversation_get_name(conv));
|
left.AddString("chat_id", purple_conversation_get_name(conv));
|
||||||
((PurpleApp*)be_app)->SendMessage(purple_conversation_get_account(conv),
|
|
||||||
left);
|
PurpleAccount* account = purple_conversation_get_account(conv);
|
||||||
|
((PurpleApp*)be_app)->SendMessage(account, left);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -596,6 +635,23 @@ signal_sent_im_msg(PurpleAccount* account, const char* receiver,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
signal_chat_buddy_joined(PurpleConversation* conv, const char* name,
|
||||||
|
PurpleConvChatBuddyFlags flags, gboolean new_arrival)
|
||||||
|
{
|
||||||
|
BMessage joined(IM_MESSAGE);
|
||||||
|
if (new_arrival)
|
||||||
|
joined.AddInt32("im_what", IM_ROOM_PARTICIPANT_JOINED);
|
||||||
|
else
|
||||||
|
joined.AddInt32("im_what", IM_ROOM_PARTICIPANTS);
|
||||||
|
joined.AddString("chat_id", purple_conversation_get_name(conv));
|
||||||
|
joined.AddString("user_id", name);
|
||||||
|
PurpleAccount* account = purple_conversation_get_account(conv);
|
||||||
|
((PurpleApp*)be_app)->SendMessage(account, joined);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PurpleStatusPrimitive
|
PurpleStatusPrimitive
|
||||||
cardie_status_to_purple(UserStatus status)
|
cardie_status_to_purple(UserStatus status)
|
||||||
{
|
{
|
||||||
|
|
|
@ -120,6 +120,9 @@ private:
|
||||||
const char* message, int conv_id);
|
const char* message, int conv_id);
|
||||||
static void signal_sent_im_msg(PurpleAccount* account,
|
static void signal_sent_im_msg(PurpleAccount* account,
|
||||||
const char* receiver, const char* message);
|
const char* receiver, const char* message);
|
||||||
|
static void signal_chat_buddy_joined(PurpleConversation* conv,
|
||||||
|
const char* name, PurpleConvChatBuddyFlags flags,
|
||||||
|
gboolean new_arrival);
|
||||||
|
|
||||||
// Util
|
// Util
|
||||||
PurpleStatusPrimitive cardie_status_to_purple(UserStatus status);
|
PurpleStatusPrimitive cardie_status_to_purple(UserStatus status);
|
||||||
|
|
Ŝarĝante…
Reference in New Issue