| 114 g_free(records[i].label); |
114 g_free(records[i].label); |
| 115 g_free(records[i].nickname); |
115 g_free(records[i].nickname); |
| 116 g_free(records[i].first_name); |
116 g_free(records[i].first_name); |
| 117 g_free(records[i].last_name); |
117 g_free(records[i].last_name); |
| 118 g_free(records[i].city); |
118 g_free(records[i].city); |
| |
119 g_date_time_unref(records[i].birth); |
| 119 } |
120 } |
| 120 g_free(records); |
121 g_free(records); |
| 121 } |
122 } |
| 122 |
123 |
| 123 static void |
124 static void |
| 212 record->label = ggp_free_if_equal(record->label, ""); |
213 record->label = ggp_free_if_equal(record->label, ""); |
| 213 record->nickname = ggp_free_if_equal(record->nickname, uin_s); |
214 record->nickname = ggp_free_if_equal(record->nickname, uin_s); |
| 214 record->nickname = ggp_free_if_equal(record->nickname, ""); |
215 record->nickname = ggp_free_if_equal(record->nickname, ""); |
| 215 record->first_name = ggp_free_if_equal(record->first_name, ""); |
216 record->first_name = ggp_free_if_equal(record->first_name, ""); |
| 216 record->last_name = ggp_free_if_equal(record->last_name, ""); |
217 record->last_name = ggp_free_if_equal(record->last_name, ""); |
| |
218 g_clear_pointer(&record->birth, g_date_time_unref); |
| 217 |
219 |
| 218 if (record->label) {} |
220 if (record->label) {} |
| 219 else if (record->nickname) |
221 else if (record->nickname) |
| 220 record->label = g_strdup(record->nickname); |
222 record->label = g_strdup(record->nickname); |
| 221 else if (record->first_name && record->last_name) |
223 else if (record->first_name && record->last_name) |
| 244 if (!record->city) { |
246 if (!record->city) { |
| 245 g_free(record->city); |
247 g_free(record->city); |
| 246 record->city = NULL; |
248 record->city = NULL; |
| 247 } |
249 } |
| 248 |
250 |
| 249 record->birth = ggp_date_from_iso8601(birth_s); |
251 record->birth = g_date_time_new_from_iso8601(birth_s, NULL); |
| 250 /*TODO: calculate age from birth */ |
252 /*TODO: calculate age from birth */ |
| 251 |
253 |
| 252 if (purple_debug_is_verbose()) { |
254 if (purple_debug_is_verbose()) { |
| 253 purple_debug_misc("gg", "ggp_pubdir_got_data: [uin:%d] " |
255 purple_debug_misc("gg", "ggp_pubdir_got_data: [uin:%d] " |
| 254 "[label:%s] [nick:%s] [first name:%s] " |
256 "[label:%s] [nick:%s] [first name:%s] " |
| 255 "[last name:%s] [city:%s] [gender:%d] [age:%d] " |
257 "[last name:%s] [city:%s] [gender:%d] [age:%d] " |
| 256 "[birth:%lu]\n", record->uin, record->label, |
258 "[birth:%lu]\n", record->uin, record->label, |
| 257 record->nickname, record->first_name, |
259 record->nickname, record->first_name, |
| 258 record->last_name, record->city, record->gender, |
260 record->last_name, record->city, record->gender, |
| 259 record->age, record->birth); |
261 record->age, g_date_time_to_unix(record->birth)); |
| 260 } |
262 } |
| 261 |
263 |
| 262 g_free(city); |
264 g_free(city); |
| 263 |
265 |
| 264 xml = purple_xmlnode_get_next_twin(xml); |
266 xml = purple_xmlnode_get_next_twin(xml); |
| 384 if (record->city) { |
386 if (record->city) { |
| 385 purple_notify_user_info_add_pair_plaintext(info, _("City"), |
387 purple_notify_user_info_add_pair_plaintext(info, _("City"), |
| 386 record->city); |
388 record->city); |
| 387 } |
389 } |
| 388 if (record->birth) { |
390 if (record->birth) { |
| 389 purple_notify_user_info_add_pair_plaintext(info, _("Birthday"), |
391 gchar *bday = g_date_time_format(record->birth, "%Y-%m-%d"); |
| 390 ggp_date_strftime("%Y-%m-%d", record->birth)); |
392 |
| |
393 purple_notify_user_info_add_pair_plaintext(info, _("Birthday"), bday); |
| |
394 |
| |
395 g_free(bday); |
| 391 } else if (record->age) { |
396 } else if (record->age) { |
| 392 gchar *age_s = g_strdup_printf("%d", record->age); |
397 gchar *age_s = g_strdup_printf("%d", record->age); |
| 393 purple_notify_user_info_add_pair_plaintext(info, _("Age"), |
398 purple_notify_user_info_add_pair_plaintext(info, _("Age"), |
| 394 age_s); |
399 age_s); |
| 395 g_free(age_s); |
400 g_free(age_s); |
| 791 info = purple_connection_get_protocol_data(gc); |
797 info = purple_connection_get_protocol_data(gc); |
| 792 |
798 |
| 793 name = g_uri_escape_string(record->first_name, NULL, FALSE); |
799 name = g_uri_escape_string(record->first_name, NULL, FALSE); |
| 794 surname = g_uri_escape_string(record->last_name, NULL, FALSE); |
800 surname = g_uri_escape_string(record->last_name, NULL, FALSE); |
| 795 city = g_uri_escape_string(record->city, NULL, FALSE); |
801 city = g_uri_escape_string(record->city, NULL, FALSE); |
| |
802 |
| |
803 bday = g_date_time_format(record->birth, "%Y-%m-%d"); |
| 796 |
804 |
| 797 request_data = g_strdup_printf( |
805 request_data = g_strdup_printf( |
| 798 "name=%s&" |
806 "name=%s&" |
| 799 "surname=%s&" |
807 "surname=%s&" |
| 800 "birth=%sT10:00:00%%2B00:00&" |
808 "birth=%sT10:00:00%%2B00:00&" |
| 802 "gender=%d&" |
810 "gender=%d&" |
| 803 "gender_priv=2&" |
811 "gender_priv=2&" |
| 804 "city=%s&" |
812 "city=%s&" |
| 805 "province=%d", |
813 "province=%d", |
| 806 name, surname, |
814 name, surname, |
| 807 ggp_date_strftime("%Y-%m-%d", record->birth), |
815 bday, |
| 808 record->gender, |
816 record->gender, |
| 809 city, |
817 city, |
| 810 record->province); |
818 record->province); |
| |
819 |
| |
820 g_free(bday); |
| 811 |
821 |
| 812 if (purple_debug_is_verbose() && purple_debug_is_unsafe()) { |
822 if (purple_debug_is_verbose() && purple_debug_is_unsafe()) { |
| 813 purple_debug_misc("gg", "ggp_pubdir_set_info_got_token: " |
823 purple_debug_misc("gg", "ggp_pubdir_set_info_got_token: " |
| 814 "query [%s]\n", request_data); |
824 "query [%s]\n", request_data); |
| 815 } |
825 } |
| 849 purple_request_fields_get_choice(fields, "province")); |
859 purple_request_fields_get_choice(fields, "province")); |
| 850 |
860 |
| 851 birth_s = g_strdup_printf( |
861 birth_s = g_strdup_printf( |
| 852 "%sT10:00:00+00:00", |
862 "%sT10:00:00+00:00", |
| 853 purple_request_fields_get_string(fields, "birth_date")); |
863 purple_request_fields_get_string(fields, "birth_date")); |
| 854 record->birth = ggp_date_from_iso8601(birth_s); |
864 record->birth = g_date_time_new_from_iso8601(birth_s, NULL); |
| 855 g_free(birth_s); |
865 g_free(birth_s); |
| 856 purple_debug_info("gg", "ggp_pubdir_set_info_request: birth [%lu][%s]", |
866 purple_debug_info("gg", "ggp_pubdir_set_info_request: birth [%lu][%s]", |
| 857 record->birth, |
867 g_date_time_to_unix(record->birth), |
| 858 purple_request_fields_get_string(fields, "birth_date")); |
868 purple_request_fields_get_string(fields, "birth_date")); |
| 859 |
869 |
| 860 url = g_strdup_printf("http://api.gadu-gadu.pl/users/%u.xml", uin); |
870 url = g_strdup_printf("http://api.gadu-gadu.pl/users/%u.xml", uin); |
| 861 ggp_oauth_request(gc, ggp_pubdir_set_info_got_token, record, "PUT", url); |
871 ggp_oauth_request(gc, ggp_pubdir_set_info_got_token, record, "PUT", url); |
| 862 g_free(url); |
872 g_free(url); |
| 868 void *user_data) |
878 void *user_data) |
| 869 { |
879 { |
| 870 PurpleRequestFields *fields; |
880 PurpleRequestFields *fields; |
| 871 PurpleRequestFieldGroup *group; |
881 PurpleRequestFieldGroup *group; |
| 872 PurpleRequestField *field; |
882 PurpleRequestField *field; |
| |
883 gchar *bday = NULL; |
| 873 gsize i; |
884 gsize i; |
| 874 const ggp_pubdir_record *record; |
885 const ggp_pubdir_record *record; |
| 875 |
886 |
| 876 purple_debug_info("gg", "ggp_pubdir_set_info_dialog (record: %d)", |
887 purple_debug_info("gg", "ggp_pubdir_set_info_dialog (record: %d)", |
| 877 records_count); |
888 records_count); |
| 901 GINT_TO_POINTER(GGP_PUBDIR_GENDER_MALE)); |
912 GINT_TO_POINTER(GGP_PUBDIR_GENDER_MALE)); |
| 902 purple_request_field_choice_add(field, _("Female"), |
913 purple_request_field_choice_add(field, _("Female"), |
| 903 GINT_TO_POINTER(GGP_PUBDIR_GENDER_FEMALE)); |
914 GINT_TO_POINTER(GGP_PUBDIR_GENDER_FEMALE)); |
| 904 purple_request_field_group_add_field(group, field); |
915 purple_request_field_group_add_field(group, field); |
| 905 |
916 |
| |
917 if(record != NULL && record->birth != NULL) { |
| |
918 bday = g_date_time_format(record->birth, "%Y-%m-%d"); |
| |
919 } |
| |
920 |
| 906 field = purple_request_field_string_new( |
921 field = purple_request_field_string_new( |
| 907 "birth_date", _("Birth Day"), |
922 "birth_date", _("Birth Day"), bday, |
| 908 (record && record->birth) |
|
| 909 ? ggp_date_strftime("%Y-%m-%d", record->birth) |
|
| 910 : NULL, |
|
| 911 FALSE); |
923 FALSE); |
| |
924 g_free(bday); |
| 912 purple_request_field_set_required(field, TRUE); |
925 purple_request_field_set_required(field, TRUE); |
| 913 purple_request_field_group_add_field(group, field); |
926 purple_request_field_group_add_field(group, field); |
| 914 |
927 |
| 915 field = purple_request_field_string_new( |
928 field = purple_request_field_string_new( |
| 916 "city", _("City"), record ? record->city : NULL, FALSE); |
929 "city", _("City"), record ? record->city : NULL, FALSE); |