Changeset 1882b70 for protocols/purple
- Timestamp:
- 2016-12-26T23:52:24Z (8 years ago)
- Branches:
- master
- Children:
- faa7abb6
- Parents:
- a04705b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/purple/purple.c
ra04705b r1882b70 763 763 struct groupchat *gc; 764 764 GList *info, *l; 765 GString *missing_settings = NULL; 765 766 766 767 if (!pi->chat_info || !pi->chat_info_defaults || … … 788 789 } else if (strcmp(pce->identifier, "passwd") == 0) { 789 790 g_hash_table_replace(chat_hash, "passwd", g_strdup(password)); 791 } else { 792 char *key, *value; 793 794 key = g_strdup_printf("purple_%s", pce->identifier); 795 str_reject_chars(key, " -", '_'); 796 797 if ((value = set_getstr(sets, key))) { 798 /* sync from bitlbee to the prpl */ 799 g_hash_table_replace(chat_hash, (char *) pce->identifier, g_strdup(value)); 800 } else if ((value = g_hash_table_lookup(chat_hash, pce->identifier))) { 801 /* if the bitlbee one was empty, sync from prpl to bitlbee */ 802 set_setstr(sets, key, value); 803 } 804 805 g_free(key); 806 } 807 808 if (pce->required && !g_hash_table_lookup(chat_hash, pce->identifier)) { 809 if (!missing_settings) { 810 missing_settings = g_string_new(NULL); 811 g_string_printf(missing_settings, 812 "Can't join %s. The following settings are required: ", room); 813 } 814 g_string_append_printf(missing_settings, "%s, ", pce->identifier); 790 815 } 791 816 … … 794 819 795 820 g_list_free(info); 821 822 if (missing_settings) { 823 /* remove the ", " from the end */ 824 g_string_truncate(missing_settings, missing_settings->len - 2); 825 826 imcb_error(ic, missing_settings->str); 827 828 g_string_free(missing_settings, TRUE); 829 g_hash_table_destroy(chat_hash); 830 return NULL; 831 } 796 832 797 833 /* do this before serv_join_chat to handle cases where prplcb_conv_new is called immediately (not async) */ … … 828 864 purple_roomlist_ref(list); 829 865 } 866 } 867 868 /* handles either prpl->chat_(add|free)_settings depending on the value of 'add' */ 869 static void purple_chat_update_settings(account_t *acc, set_t **head, gboolean add) 870 { 871 PurplePlugin *prpl = purple_plugins_find_with_id((char *) acc->prpl->data); 872 PurplePluginProtocolInfo *pi = prpl->info->extra_info; 873 GList *info, *l; 874 875 if (!pi->chat_info || !pi->chat_info_defaults) { 876 return; 877 } 878 879 /* hack / leap of faith: pass a NULL here because we don't have a connection yet. 880 * i reviewed all the built-in prpls and a bunch of third-party ones and none 881 * of them seem to need this parameter at all, so... i hope it never crashes */ 882 info = pi->chat_info(NULL); 883 884 for (l = info; l; l = l->next) { 885 struct proto_chat_entry *pce = l->data; 886 char *key; 887 888 if (strcmp(pce->identifier, "handle") == 0 || 889 strcmp(pce->identifier, "password") == 0 || 890 strcmp(pce->identifier, "passwd") == 0) { 891 /* skip these, they are handled above */ 892 g_free(pce); 893 continue; 894 } 895 896 key = g_strdup_printf("purple_%s", pce->identifier); 897 str_reject_chars(key, " -", '_'); 898 899 if (add) { 900 set_add(head, key, NULL, NULL, NULL); 901 } else { 902 set_del(head, key); 903 } 904 905 g_free(key); 906 g_free(pce); 907 } 908 909 g_list_free(NULL); 910 g_list_free(info); 911 } 912 913 static void purple_chat_add_settings(account_t *acc, set_t **head) 914 { 915 purple_chat_update_settings(acc, head, TRUE); 916 } 917 918 static void purple_chat_free_settings(account_t *acc, set_t **head) 919 { 920 purple_chat_update_settings(acc, head, FALSE); 830 921 } 831 922 … … 1767 1858 funcs.chat_join = purple_chat_join; 1768 1859 funcs.chat_list = purple_chat_list; 1860 funcs.chat_add_settings = purple_chat_add_settings; 1861 funcs.chat_free_settings = purple_chat_free_settings; 1769 1862 funcs.transfer_request = purple_transfer_request; 1770 1863
Note: See TracChangeset
for help on using the changeset viewer.