diff --git a/protocols/purple/PurpleApp.cpp b/protocols/purple/PurpleApp.cpp index 3bae512..5589ade 100644 --- a/protocols/purple/PurpleApp.cpp +++ b/protocols/purple/PurpleApp.cpp @@ -354,6 +354,16 @@ PurpleApp::ImMessage(BMessage* msg) SendMessage(account, info); break; } + case IM_SET_ROOM_SUBJECT: + { + PurpleConversation* conv = _ConversationFromMessage(msg); + PurpleConvChat* chat = purple_conversation_get_chat_data(conv); + BString subject; + + if (chat != NULL || msg->FindString("subject", &subject) == B_OK) + purple_conv_chat_set_topic(chat, NULL, subject.String()); + break; + } case IM_ROOM_SEND_INVITE: { PurpleAccount* account = _AccountFromMessage(msg); @@ -1051,6 +1061,8 @@ init_signals() &handle, PURPLE_CALLBACK(signal_sent_chat_msg), NULL); purple_signal_connect(purple_conversations_get_handle(), "sent-im-msg", &handle, PURPLE_CALLBACK(signal_sent_im_msg), NULL); + purple_signal_connect(purple_conversations_get_handle(), "chat-topic-changed", + &handle, PURPLE_CALLBACK(signal_chat_topic_changed), NULL); purple_signal_connect(purple_conversations_get_handle(), "chat-buddy-joined", &handle, PURPLE_CALLBACK(signal_chat_buddy_joined), NULL); purple_signal_connect(purple_conversations_get_handle(), "chat-buddy-left", @@ -1263,6 +1275,19 @@ signal_sent_im_msg(PurpleAccount* account, const char* receiver, } +static void +signal_chat_topic_changed(PurpleConversation* conv, const char* who, + const char* topic) +{ + BMessage subject(IM_MESSAGE); + subject.AddInt32("im_what", IM_ROOM_SUBJECT_SET); + subject.AddString("chat_id", purple_conversation_get_name(conv)); + subject.AddString("subject", topic); + PurpleAccount* account = purple_conversation_get_account(conv); + ((PurpleApp*)be_app)->SendMessage(account, subject); +} + + static void signal_chat_buddy_joined(PurpleConversation* conv, const char* name, PurpleConvChatBuddyFlags flags, gboolean new_arrival) diff --git a/protocols/purple/PurpleApp.h b/protocols/purple/PurpleApp.h index 96f8a9d..db774fa 100644 --- a/protocols/purple/PurpleApp.h +++ b/protocols/purple/PurpleApp.h @@ -144,6 +144,8 @@ private: const char* message, int conv_id); static void signal_sent_im_msg(PurpleAccount* account, const char* receiver, const char* message); + static void signal_chat_topic_changed(PurpleConversation* conv, + const char* who, const char* topic); static void signal_chat_buddy_joined(PurpleConversation* conv, const char* name, PurpleConvChatBuddyFlags flags, gboolean new_arrival);