parent
e88a8372dc
commit
9d8b35fc86
|
@ -875,6 +875,8 @@ init_signals()
|
||||||
&handle, PURPLE_CALLBACK(signal_chat_buddy_joined), NULL);
|
&handle, PURPLE_CALLBACK(signal_chat_buddy_joined), NULL);
|
||||||
purple_signal_connect(purple_conversations_get_handle(), "chat-invited",
|
purple_signal_connect(purple_conversations_get_handle(), "chat-invited",
|
||||||
&handle, PURPLE_CALLBACK(signal_chat_invited), NULL);
|
&handle, PURPLE_CALLBACK(signal_chat_invited), NULL);
|
||||||
|
purple_signal_connect(purple_conversations_get_handle(), "chat-buddy-flags",
|
||||||
|
&handle, PURPLE_CALLBACK(signal_chat_buddy_flags), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1047,6 +1049,8 @@ signal_chat_buddy_joined(PurpleConversation* conv, const char* name,
|
||||||
|
|
||||||
PurpleAccount* account = purple_conversation_get_account(conv);
|
PurpleAccount* account = purple_conversation_get_account(conv);
|
||||||
((PurpleApp*)be_app)->SendMessage(account, joined);
|
((PurpleApp*)be_app)->SendMessage(account, joined);
|
||||||
|
|
||||||
|
send_user_role(conv, name, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1071,6 +1075,14 @@ signal_chat_invited(PurpleAccount* account, const char* inviter,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
signal_chat_buddy_flags(PurpleConversation* conv, const char* name,
|
||||||
|
PurpleConvChatBuddyFlags oldflags, PurpleConvChatBuddyFlags newflags)
|
||||||
|
{
|
||||||
|
send_user_role(conv, name, newflags);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
ui_op_input_add(gint fd, PurpleInputCondition condition,
|
ui_op_input_add(gint fd, PurpleInputCondition condition,
|
||||||
PurpleInputFunction function, gpointer data)
|
PurpleInputFunction function, gpointer data)
|
||||||
|
@ -1091,6 +1103,48 @@ ui_op_input_add(gint fd, PurpleInputCondition condition,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
send_user_role(PurpleConversation* conv, const char* name,
|
||||||
|
PurpleConvChatBuddyFlags flags)
|
||||||
|
{
|
||||||
|
if (flags == 0) return;
|
||||||
|
|
||||||
|
BString role_title;
|
||||||
|
int32 role_perms = 0 | PERM_READ | PERM_WRITE;
|
||||||
|
int32 role_priority = 0;
|
||||||
|
|
||||||
|
if (flags & PURPLE_CBFLAGS_FOUNDER) {
|
||||||
|
role_title = "Founder";
|
||||||
|
role_priority = 3;
|
||||||
|
}
|
||||||
|
if (flags & PURPLE_CBFLAGS_OP) {
|
||||||
|
if (role_title.IsEmpty() == true)
|
||||||
|
role_title = "Operator";
|
||||||
|
role_perms |= PERM_KICK | PERM_BAN | PERM_MUTE | PERM_DEAFEN
|
||||||
|
| PERM_ROLECHANGE | PERM_ROOM_SUBJECT | PERM_ROOM_NAME;
|
||||||
|
role_priority = 2;
|
||||||
|
}
|
||||||
|
if (flags & PURPLE_CBFLAGS_HALFOP) {
|
||||||
|
if (role_title.IsEmpty() == true)
|
||||||
|
role_title = "Moderator";
|
||||||
|
role_perms |= PERM_KICK | PERM_MUTE | PERM_DEAFEN | PERM_ROOM_SUBJECT;
|
||||||
|
role_priority = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (role_title.IsEmpty() == true) return;
|
||||||
|
|
||||||
|
BMessage role(IM_MESSAGE);
|
||||||
|
role.AddInt32("im_what", IM_ROOM_ROLECHANGED);
|
||||||
|
role.AddString("user_id", name);
|
||||||
|
role.AddString("chat_id", purple_conversation_get_name(conv));
|
||||||
|
role.AddString("role_title", role_title);
|
||||||
|
role.AddInt32("role_perms", role_perms);
|
||||||
|
role.AddInt32("role_priority", role_priority);
|
||||||
|
((PurpleApp*)be_app)->SendMessage(purple_conversation_get_account(conv),
|
||||||
|
role);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PurpleStatusPrimitive
|
PurpleStatusPrimitive
|
||||||
cardie_status_to_purple(UserStatus status)
|
cardie_status_to_purple(UserStatus status)
|
||||||
{
|
{
|
||||||
|
|
|
@ -140,6 +140,9 @@ private:
|
||||||
static void signal_chat_invited(PurpleAccount* account,
|
static void signal_chat_invited(PurpleAccount* account,
|
||||||
const char* inviter, const char* chat,
|
const char* inviter, const char* chat,
|
||||||
const char* message, const GHashTable* components);
|
const char* message, const GHashTable* components);
|
||||||
|
static void signal_chat_buddy_flags(PurpleConversation* conv,
|
||||||
|
const char* name, PurpleConvChatBuddyFlags oldflags,
|
||||||
|
PurpleConvChatBuddyFlags newflags);
|
||||||
|
|
||||||
// EventLoop ui ops
|
// EventLoop ui ops
|
||||||
static guint ui_op_input_add(gint fd,
|
static guint ui_op_input_add(gint fd,
|
||||||
|
@ -147,6 +150,8 @@ private:
|
||||||
PurpleInputFunction function, gpointer data);
|
PurpleInputFunction function, gpointer data);
|
||||||
|
|
||||||
// Util
|
// Util
|
||||||
|
void send_user_role(PurpleConversation* conv,
|
||||||
|
const char* name, PurpleConvChatBuddyFlags flags);
|
||||||
PurpleStatusPrimitive cardie_status_to_purple(UserStatus status);
|
PurpleStatusPrimitive cardie_status_to_purple(UserStatus status);
|
||||||
UserStatus purple_status_to_cardie(PurpleStatus* status);
|
UserStatus purple_status_to_cardie(PurpleStatus* status);
|
||||||
|
|
||||||
|
|
Ŝarĝante…
Reference in New Issue