Mercurial > pidgin.yaz
comparison pidgin/gtkblist.c @ 32767:2ec94166be43
On the way to hiding the PurpleConnection struct.
* Added purple_connection_get_flags() and purple_connection_set_flags()
* Use purple_connection_ accessor functions.
author | andrew.victor@mxit.com |
---|---|
date | Tue, 18 Oct 2011 18:47:48 +0000 |
parents | 10e5000326a5 |
children | b6276b10cb10 |
comparison
equal
deleted
inserted
replaced
32766:ea2b621fd3ba | 32767:2ec94166be43 |
---|---|
914 } | 914 } |
915 | 915 |
916 gtk_dialog_set_response_sensitive(GTK_DIALOG(data->rq_data.window), GTK_RESPONSE_OK, sensitive); | 916 gtk_dialog_set_response_sensitive(GTK_DIALOG(data->rq_data.window), GTK_RESPONSE_OK, sensitive); |
917 | 917 |
918 gc = purple_account_get_connection(data->rq_data.account); | 918 gc = purple_account_get_connection(data->rq_data.account); |
919 prpl_info = (gc != NULL) ? PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl) : NULL; | 919 prpl_info = (gc != NULL) ? PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)) : NULL; |
920 sensitive = (prpl_info != NULL && prpl_info->roomlist_get_list != NULL); | 920 sensitive = (prpl_info != NULL && prpl_info->roomlist_get_list != NULL); |
921 | 921 |
922 gtk_dialog_set_response_sensitive(GTK_DIALOG(data->rq_data.window), 1, sensitive); | 922 gtk_dialog_set_response_sensitive(GTK_DIALOG(data->rq_data.window), 1, sensitive); |
923 } | 923 } |
924 | 924 |
938 PurplePluginProtocolInfo *prpl_info = NULL; | 938 PurplePluginProtocolInfo *prpl_info = NULL; |
939 | 939 |
940 if (gc == NULL) | 940 if (gc == NULL) |
941 return FALSE; | 941 return FALSE; |
942 | 942 |
943 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); | 943 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); |
944 | 944 |
945 return (prpl_info->chat_info != NULL); | 945 return (prpl_info->chat_info != NULL); |
946 } | 946 } |
947 | 947 |
948 gboolean | 948 gboolean |
1028 | 1028 |
1029 static void | 1029 static void |
1030 rebuild_chat_entries(PidginChatData *data, const char *default_chat_name) | 1030 rebuild_chat_entries(PidginChatData *data, const char *default_chat_name) |
1031 { | 1031 { |
1032 PurpleConnection *gc; | 1032 PurpleConnection *gc; |
1033 PurplePluginProtocolInfo *prpl_info; | |
1033 GList *list = NULL, *tmp; | 1034 GList *list = NULL, *tmp; |
1034 GHashTable *defaults = NULL; | 1035 GHashTable *defaults = NULL; |
1035 struct proto_chat_entry *pce; | 1036 struct proto_chat_entry *pce; |
1036 gboolean focus = TRUE; | 1037 gboolean focus = TRUE; |
1037 | 1038 |
1038 g_return_if_fail(data->rq_data.account != NULL); | 1039 g_return_if_fail(data->rq_data.account != NULL); |
1039 | 1040 |
1040 gc = purple_account_get_connection(data->rq_data.account); | 1041 gc = purple_account_get_connection(data->rq_data.account); |
1042 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); | |
1041 | 1043 |
1042 gtk_container_foreach(GTK_CONTAINER(data->rq_data.vbox), (GtkCallback)gtk_widget_destroy, NULL); | 1044 gtk_container_foreach(GTK_CONTAINER(data->rq_data.vbox), (GtkCallback)gtk_widget_destroy, NULL); |
1043 | 1045 |
1044 g_list_free(data->entries); | 1046 g_list_free(data->entries); |
1045 data->entries = NULL; | 1047 data->entries = NULL; |
1046 | 1048 |
1047 if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) | 1049 if (prpl_info->chat_info != NULL) |
1048 list = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info(gc); | 1050 list = prpl_info->chat_info(gc); |
1049 | 1051 |
1050 if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL) | 1052 if (prpl_info->chat_info_defaults != NULL) |
1051 defaults = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, default_chat_name); | 1053 defaults = prpl_info->chat_info_defaults(gc, default_chat_name); |
1052 | 1054 |
1053 for (tmp = list; tmp; tmp = tmp->next) | 1055 for (tmp = list; tmp; tmp = tmp->next) |
1054 { | 1056 { |
1055 GtkWidget *input; | 1057 GtkWidget *input; |
1056 | 1058 |
1409 void | 1411 void |
1410 pidgin_append_blist_node_proto_menu(GtkWidget *menu, PurpleConnection *gc, | 1412 pidgin_append_blist_node_proto_menu(GtkWidget *menu, PurpleConnection *gc, |
1411 PurpleBlistNode *node) | 1413 PurpleBlistNode *node) |
1412 { | 1414 { |
1413 GList *l, *ll; | 1415 GList *l, *ll; |
1414 PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); | 1416 PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); |
1415 | 1417 |
1416 if(!prpl_info || !prpl_info->blist_node_menu) | 1418 if(!prpl_info || !prpl_info->blist_node_menu) |
1417 return; | 1419 return; |
1418 | 1420 |
1419 for(l = ll = prpl_info->blist_node_menu(node); l; l = l->next) { | 1421 for(l = ll = prpl_info->blist_node_menu(node); l; l = l->next) { |
2299 gtk_tree_path_free(sourcerow); | 2301 gtk_tree_path_free(sourcerow); |
2300 return; | 2302 return; |
2301 } | 2303 } |
2302 | 2304 |
2303 protocol = | 2305 protocol = |
2304 PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->list_icon(buddy->account, | 2306 PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc))->list_icon(buddy->account, |
2305 buddy); | 2307 buddy); |
2306 | 2308 |
2307 str = g_string_new(NULL); | 2309 str = g_string_new(NULL); |
2308 g_string_printf(str, | 2310 g_string_printf(str, |
2309 "MIME-Version: 1.0\r\n" | 2311 "MIME-Version: 1.0\r\n" |
2672 if (buddy) { | 2674 if (buddy) { |
2673 account = purple_buddy_get_account(buddy); | 2675 account = purple_buddy_get_account(buddy); |
2674 } | 2676 } |
2675 | 2677 |
2676 if(account && purple_account_get_connection(account)) { | 2678 if(account && purple_account_get_connection(account)) { |
2677 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_account_get_connection(account)->prpl); | 2679 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(purple_account_get_connection(account))); |
2678 } | 2680 } |
2679 | 2681 |
2680 #if 0 | 2682 #if 0 |
2681 if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons")) | 2683 if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons")) |
2682 return NULL; | 2684 return NULL; |
3380 | 3382 |
3381 if (gc) { | 3383 if (gc) { |
3382 const char *text; | 3384 const char *text; |
3383 PurpleAccount *account = purple_connection_get_account(gc); | 3385 PurpleAccount *account = purple_connection_get_account(gc); |
3384 | 3386 |
3385 if (gc->flags & PURPLE_CONNECTION_SUPPORT_MOOD_MESSAGES) { | 3387 if (purple_connection_get_flags(gc) & PURPLE_CONNECTION_SUPPORT_MOOD_MESSAGES) { |
3386 PurpleRequestField *text_field; | 3388 PurpleRequestField *text_field; |
3387 text_field = purple_request_fields_get_field(fields, "text"); | 3389 text_field = purple_request_fields_get_field(fields, "text"); |
3388 text = purple_request_field_string_get_value(text_field); | 3390 text = purple_request_field_string_get_value(text_field); |
3389 } else { | 3391 } else { |
3390 text = NULL; | 3392 text = NULL; |
3396 | 3398 |
3397 for (; accounts ; accounts = g_list_delete_link(accounts, accounts)) { | 3399 for (; accounts ; accounts = g_list_delete_link(accounts, accounts)) { |
3398 PurpleAccount *account = (PurpleAccount *) accounts->data; | 3400 PurpleAccount *account = (PurpleAccount *) accounts->data; |
3399 PurpleConnection *gc = purple_account_get_connection(account); | 3401 PurpleConnection *gc = purple_account_get_connection(account); |
3400 | 3402 |
3401 if (gc && gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS) { | 3403 if (gc && (purple_connection_get_flags(gc) & PURPLE_CONNECTION_SUPPORT_MOODS)) { |
3402 update_status_with_mood(account, mood, NULL); | 3404 update_status_with_mood(account, mood, NULL); |
3403 } | 3405 } |
3404 } | 3406 } |
3405 } | 3407 } |
3406 } | 3408 } |
3431 for (; accounts ; accounts = g_list_delete_link(accounts, accounts)) { | 3433 for (; accounts ; accounts = g_list_delete_link(accounts, accounts)) { |
3432 PurpleAccount *account = (PurpleAccount *) accounts->data; | 3434 PurpleAccount *account = (PurpleAccount *) accounts->data; |
3433 if (purple_account_is_connected(account)) { | 3435 if (purple_account_is_connected(account)) { |
3434 PurpleConnection *gc = purple_account_get_connection(account); | 3436 PurpleConnection *gc = purple_account_get_connection(account); |
3435 | 3437 |
3436 if (gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS) { | 3438 if (purple_connection_get_flags(gc) & PURPLE_CONNECTION_SUPPORT_MOODS) { |
3437 PurplePluginProtocolInfo *prpl_info = | 3439 PurplePluginProtocolInfo *prpl_info = |
3438 PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); | 3440 PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); |
3439 PurpleMood *mood = NULL; | 3441 PurpleMood *mood = NULL; |
3440 | 3442 |
3441 /* PURPLE_CONNECTION_SUPPORT_MOODS would not be set if the prpl doesn't | 3443 /* PURPLE_CONNECTION_SUPPORT_MOODS would not be set if the prpl doesn't |
3442 * have get_moods, so using PURPLE_PROTOCOL_PLUGIN_HAS_FUNC isn't necessary | 3444 * have get_moods, so using PURPLE_PROTOCOL_PLUGIN_HAS_FUNC isn't necessary |
3443 * here */ | 3445 * here */ |
3491 | 3493 |
3492 for (; accounts ; accounts = g_list_delete_link(accounts, accounts)) { | 3494 for (; accounts ; accounts = g_list_delete_link(accounts, accounts)) { |
3493 PurpleAccount *account = (PurpleAccount *) accounts->data; | 3495 PurpleAccount *account = (PurpleAccount *) accounts->data; |
3494 | 3496 |
3495 if (purple_account_is_connected(account) && | 3497 if (purple_account_is_connected(account) && |
3496 (purple_account_get_connection(account)->flags & | 3498 (purple_connection_get_flags(purple_account_get_connection(account)) & |
3497 PURPLE_CONNECTION_SUPPORT_MOODS)) { | 3499 PURPLE_CONNECTION_SUPPORT_MOODS)) { |
3498 PurplePresence *presence = purple_account_get_presence(account); | 3500 PurplePresence *presence = purple_account_get_presence(account); |
3499 PurpleStatus *status = purple_presence_get_status(presence, "mood"); | 3501 PurpleStatus *status = purple_presence_get_status(presence, "mood"); |
3500 const gchar *curr_mood = purple_status_get_attr_string(status, PURPLE_MOOD_NAME); | 3502 const gchar *curr_mood = purple_status_get_attr_string(status, PURPLE_MOOD_NAME); |
3501 | 3503 |
3526 | 3528 |
3527 if (account) { | 3529 if (account) { |
3528 PurplePresence *presence = purple_account_get_presence(account); | 3530 PurplePresence *presence = purple_account_get_presence(account); |
3529 PurpleStatus *status = purple_presence_get_status(presence, "mood"); | 3531 PurpleStatus *status = purple_presence_get_status(presence, "mood"); |
3530 gc = purple_account_get_connection(account); | 3532 gc = purple_account_get_connection(account); |
3531 g_return_if_fail(gc->prpl != NULL); | 3533 g_return_if_fail(purple_connection_get_prpl(gc) != NULL); |
3532 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); | 3534 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); |
3533 current_mood = purple_status_get_attr_string(status, PURPLE_MOOD_NAME); | 3535 current_mood = purple_status_get_attr_string(status, PURPLE_MOOD_NAME); |
3534 } else { | 3536 } else { |
3535 current_mood = get_global_mood_status(); | 3537 current_mood = get_global_mood_status(); |
3536 } | 3538 } |
3537 | 3539 |
3566 purple_request_field_group_add_field(g, f); | 3568 purple_request_field_group_add_field(g, f); |
3567 | 3569 |
3568 purple_request_fields_add_group(fields, g); | 3570 purple_request_fields_add_group(fields, g); |
3569 | 3571 |
3570 /* if the connection allows setting a mood message */ | 3572 /* if the connection allows setting a mood message */ |
3571 if (gc && (gc->flags & PURPLE_CONNECTION_SUPPORT_MOOD_MESSAGES)) { | 3573 if (gc && (purple_connection_get_flags(gc) & PURPLE_CONNECTION_SUPPORT_MOOD_MESSAGES)) { |
3572 g = purple_request_field_group_new(NULL); | 3574 g = purple_request_field_group_new(NULL); |
3573 f = purple_request_field_string_new("text", | 3575 f = purple_request_field_string_new("text", |
3574 _("Message (optional)"), NULL, FALSE); | 3576 _("Message (optional)"), NULL, FALSE); |
3575 purple_request_field_group_add_field(g, f); | 3577 purple_request_field_group_add_field(g, f); |
3576 purple_request_fields_add_group(fields, g); | 3578 purple_request_fields_add_group(fields, g); |
7201 { | 7203 { |
7202 PidginAddChatData *data; | 7204 PidginAddChatData *data; |
7203 GList *l; | 7205 GList *l; |
7204 PurpleConnection *gc; | 7206 PurpleConnection *gc; |
7205 GtkBox *vbox; | 7207 GtkBox *vbox; |
7208 PurplePluginProtocolInfo *prpl_info = NULL; | |
7206 | 7209 |
7207 if (account != NULL) { | 7210 if (account != NULL) { |
7208 gc = purple_account_get_connection(account); | 7211 gc = purple_account_get_connection(account); |
7209 | 7212 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); |
7210 if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->join_chat == NULL) { | 7213 |
7214 if (prpl_info->join_chat == NULL) { | |
7211 purple_notify_error(gc, NULL, _("This protocol does not support chat rooms."), NULL); | 7215 purple_notify_error(gc, NULL, _("This protocol does not support chat rooms."), NULL); |
7212 return; | 7216 return; |
7213 } | 7217 } |
7214 } else { | 7218 } else { |
7215 /* Find an account with chat capabilities */ | 7219 /* Find an account with chat capabilities */ |
7216 for (l = purple_connections_get_all(); l != NULL; l = l->next) { | 7220 for (l = purple_connections_get_all(); l != NULL; l = l->next) { |
7217 gc = (PurpleConnection *)l->data; | 7221 gc = (PurpleConnection *)l->data; |
7218 | 7222 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); |
7219 if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->join_chat != NULL) { | 7223 |
7224 if (prpl_info->join_chat != NULL) { | |
7220 account = purple_connection_get_account(gc); | 7225 account = purple_connection_get_account(gc); |
7221 break; | 7226 break; |
7222 } | 7227 } |
7223 } | 7228 } |
7224 | 7229 |
8079 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); | 8084 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); |
8080 | 8085 |
8081 pidgin_separator(submenu); | 8086 pidgin_separator(submenu); |
8082 | 8087 |
8083 gc = purple_account_get_connection(account); | 8088 gc = purple_account_get_connection(account); |
8084 plugin = gc && PURPLE_CONNECTION_IS_CONNECTED(gc) ? gc->prpl : NULL; | 8089 plugin = gc && PURPLE_CONNECTION_IS_CONNECTED(gc) ? purple_connection_get_prpl(gc) : NULL; |
8085 prpl_info = plugin ? PURPLE_PLUGIN_PROTOCOL_INFO(plugin) : NULL; | 8090 prpl_info = plugin ? PURPLE_PLUGIN_PROTOCOL_INFO(plugin) : NULL; |
8086 | 8091 |
8087 if (prpl_info && | 8092 if (prpl_info && |
8088 (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, get_moods) || | 8093 (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, get_moods) || |
8089 PURPLE_PLUGIN_HAS_ACTIONS(plugin))) { | 8094 PURPLE_PLUGIN_HAS_ACTIONS(plugin))) { |
8090 if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, get_moods) && | 8095 if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, get_moods) && |
8091 gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS) { | 8096 (purple_connection_get_flags(gc) & PURPLE_CONNECTION_SUPPORT_MOODS)) { |
8092 | 8097 |
8093 if (purple_account_get_status(account, "mood")) { | 8098 if (purple_account_get_status(account, "mood")) { |
8094 menuitem = gtk_menu_item_new_with_mnemonic(_("Set _Mood...")); | 8099 menuitem = gtk_menu_item_new_with_mnemonic(_("Set _Mood...")); |
8095 g_signal_connect(G_OBJECT(menuitem), "activate", | 8100 g_signal_connect(G_OBJECT(menuitem), "activate", |
8096 G_CALLBACK(set_mood_cb), account); | 8101 G_CALLBACK(set_mood_cb), account); |