--- a/libpurple/protocols.c Thu Apr 11 02:10:12 2024 -0500 +++ b/libpurple/protocols.c Thu Apr 11 02:17:44 2024 -0500 @@ -43,133 +43,6 @@ /**************************************************************************/ /* Protocol API */ /**************************************************************************/ -void -purple_protocol_got_user_idle(PurpleAccount *account, const char *name, - gboolean idle, time_t idle_time) -{ - PurplePresence *presence; - GSList *list; - GDateTime *idle_date_time = NULL; - - g_return_if_fail(account != NULL); - g_return_if_fail(name != NULL); - g_return_if_fail(purple_account_is_connected(account) || purple_account_is_connecting(account)); - - if ((list = purple_blist_find_buddies(account, name)) == NULL) - return; - - idle_date_time = g_date_time_new_from_unix_local(idle_time); - while (list) { - presence = purple_buddy_get_presence(list->data); - list = g_slist_delete_link(list, list); - purple_presence_set_idle(presence, idle, idle_date_time); - } - g_date_time_unref(idle_date_time); -} - -void -purple_protocol_got_user_status_with_attributes(PurpleAccount *account, - const gchar *name, - const gchar *status_id, - GHashTable *attributes) -{ - GSList *list, *l; - PurpleBuddy *buddy; - PurplePresence *presence; - PurpleStatus *status; - PurpleStatus *old_status; - - g_return_if_fail(account != NULL); - g_return_if_fail(name != NULL); - g_return_if_fail(status_id != NULL); - g_return_if_fail(purple_account_is_connected(account) || purple_account_is_connecting(account)); - - if((list = purple_blist_find_buddies(account, name)) == NULL) { - return; - } - - for(l = list; l != NULL; l = l->next) { - buddy = l->data; - - presence = purple_buddy_get_presence(buddy); - status = purple_presence_get_status(presence, status_id); - - if(NULL == status) { - /* - * TODO: This should never happen, right? We should call - * g_warning() or something. - */ - continue; - } - - old_status = purple_presence_get_active_status(presence); - - purple_status_set_active_with_attributes(status, TRUE, attributes); - - purple_buddy_update_status(buddy, old_status); - } - - g_slist_free(list); - - /* The buddy is no longer online, they are therefore by definition not - * still typing to us. */ - if (!purple_status_is_online(status)) { - purple_serv_got_typing_stopped(purple_account_get_connection(account), name); - purple_protocol_got_media_caps(account, name); - } -} - -void -purple_protocol_got_user_status(PurpleAccount *account, const gchar *name, - const gchar *status_id, ...) -{ - GHashTable *attributes = NULL; - va_list args; - - va_start(args, status_id); - attributes = purple_attrs_from_vargs(args); - va_end(args); - - purple_protocol_got_user_status_with_attributes(account, name, status_id, - attributes); - - g_hash_table_destroy(attributes); -} - -void purple_protocol_got_user_status_deactive(PurpleAccount *account, const char *name, - const char *status_id) -{ - GSList *list, *l; - PurpleBuddy *buddy; - PurplePresence *presence; - PurpleStatus *status; - - g_return_if_fail(account != NULL); - g_return_if_fail(name != NULL); - g_return_if_fail(status_id != NULL); - g_return_if_fail(purple_account_is_connected(account) || purple_account_is_connecting(account)); - - if((list = purple_blist_find_buddies(account, name)) == NULL) - return; - - for(l = list; l != NULL; l = l->next) { - buddy = l->data; - - presence = purple_buddy_get_presence(buddy); - status = purple_presence_get_status(presence, status_id); - - if(NULL == status) - continue; - - if (purple_status_is_active(status)) { - purple_status_set_active(status, FALSE); - purple_buddy_update_status(buddy, status); - } - } - - g_slist_free(list); -} - static void do_protocol_change_account_status(PurpleAccount *account, G_GNUC_UNUSED PurpleStatus *old_status, @@ -248,80 +121,3 @@ return g_list_copy_deep(purple_account_get_status_types(account), (GCopyFunc)purple_status_new, presence); } - -gboolean -purple_protocol_initiate_media(PurpleAccount *account, - const char *who, - PurpleMediaSessionType type) -{ - PurpleConnection *gc = NULL; - PurpleProtocol *protocol = NULL; - - if(account) { - gc = purple_account_get_connection(account); - } - if(gc) { - protocol = purple_connection_get_protocol(gc); - } - - if(PURPLE_IS_PROTOCOL_MEDIA(protocol)) { - PurpleProtocolMedia *media = PURPLE_PROTOCOL_MEDIA(protocol); - - return purple_protocol_media_initiate_session(media, account, who, - type); - } else { - return FALSE; - } -} - -PurpleMediaCaps -purple_protocol_get_media_caps(PurpleAccount *account, const char *who) -{ - PurpleConnection *gc = NULL; - PurpleProtocol *protocol = NULL; - - if(account) { - gc = purple_account_get_connection(account); - } - if(gc) { - protocol = purple_connection_get_protocol(gc); - } - - if(PURPLE_IS_PROTOCOL_MEDIA(protocol)) { - return purple_protocol_media_get_caps(PURPLE_PROTOCOL_MEDIA(protocol), - account, who); - } else { - return PURPLE_MEDIA_CAPS_NONE; - } -} - -void -purple_protocol_got_media_caps(PurpleAccount *account, const char *name) -{ - GSList *list; - - g_return_if_fail(account != NULL); - g_return_if_fail(name != NULL); - - if ((list = purple_blist_find_buddies(account, name)) == NULL) - return; - - while (list) { - PurpleBuddy *buddy = list->data; - PurpleMediaCaps oldcaps = purple_buddy_get_media_caps(buddy); - PurpleMediaCaps newcaps = 0; - const gchar *bname = purple_buddy_get_name(buddy); - list = g_slist_delete_link(list, list); - - - newcaps = purple_protocol_get_media_caps(account, bname); - purple_buddy_set_media_caps(buddy, newcaps); - - if (oldcaps == newcaps) - continue; - - purple_signal_emit(purple_blist_get_handle(), - "buddy-caps-changed", buddy, - newcaps, oldcaps); - } -}