--- a/libpurple/protocols/gg/pubdir-prpl.c Fri Oct 11 05:45:14 2019 -0400
+++ b/libpurple/protocols/gg/pubdir-prpl.c Fri Oct 11 20:16:27 2019 -0400
@@ -58,22 +58,6 @@
-void ggp_pubdir_request_free(ggp_pubdir_request *request);
-void ggp_pubdir_record_free(ggp_pubdir_record *records, int count);
-static void ggp_pubdir_get_info_got_token(PurpleConnection *gc,
- const gchar *token, gpointer _request);
-static void ggp_pubdir_got_data(PurpleHttpConnection *http_conn,
- PurpleHttpResponse *response, gpointer user_data);
-static void ggp_pubdir_get_info_protocol_got(PurpleConnection *gc,
- int records_count, const ggp_pubdir_record *records, int next_offset,
-static void ggp_pubdir_request_buddy_alias_got(PurpleConnection *gc,
- int records_count, const ggp_pubdir_record *records, int next_offset,
/* Searching for buddies. */
#define GGP_PUBDIR_SEARCH_TITLE _("Gadu-Gadu Public Directory")
@@ -89,44 +73,10 @@
-void ggp_pubdir_search_form_free(ggp_pubdir_search_form *form);
-ggp_pubdir_search_form * ggp_pubdir_search_form_clone(
- const ggp_pubdir_search_form *form);
-static void ggp_pubdir_search_request(PurpleConnection *gc,
- PurpleRequestFields *fields);
-static gchar * ggp_pubdir_search_make_query(const ggp_pubdir_search_form *form);
-static void ggp_pubdir_search_execute(PurpleConnection *gc,
- const ggp_pubdir_search_form *form,
- ggp_pubdir_request_cb cb, void *user_data);
-static void ggp_pubdir_search_got_token(PurpleConnection *gc,
- const gchar *token, gpointer _request);
+/* For ggp_pubdir_search_results_next, which is called by this. */ static void ggp_pubdir_search_results_display(PurpleConnection *gc,
int records_count, const ggp_pubdir_record *records, int next_offset,
-static void ggp_pubdir_search_results_close(gpointer _form);
-static void ggp_pubdir_search_results_next(PurpleConnection *gc, GList *row,
-static void ggp_pubdir_search_results_add(PurpleConnection *gc, GList *row,
-static void ggp_pubdir_search_results_im(PurpleConnection *gc, GList *row,
-static void ggp_pubdir_search_results_info(PurpleConnection *gc, GList *row,
-static void ggp_pubdir_search_results_new(PurpleConnection *gc, GList *row,
-static void ggp_pubdir_set_info_dialog(PurpleConnection *gc, int records_count,
- const ggp_pubdir_record *records, int next_offset, void *user_data);
-static void ggp_pubdir_set_info_request(PurpleConnection *gc,
- PurpleRequestFields *fields);
-static void ggp_pubdir_set_info_got_token(PurpleConnection *gc,
- const gchar *token, gpointer _record);
-static void ggp_pubdir_set_info_got_response(PurpleHttpConnection *http_conn,
- PurpleHttpResponse *response, gpointer user_data);
/******************************************************************************/
@@ -155,7 +105,8 @@
/******************************************************************************/
-void ggp_pubdir_record_free(ggp_pubdir_record *records, int count)
+ggp_pubdir_record_free(ggp_pubdir_record *records, int count) for (i = 0; i < count; i++) {
@@ -168,54 +119,22 @@
-void ggp_pubdir_request_free(ggp_pubdir_request *request)
+ggp_pubdir_search_form_free(ggp_pubdir_search_form *form) +ggp_pubdir_request_free(ggp_pubdir_request *request) if (request->type == GGP_PUBDIR_REQUEST_TYPE_SEARCH)
ggp_pubdir_search_form_free(request->params.search_form);
-void ggp_pubdir_get_info(PurpleConnection *gc, uin_t uin,
- ggp_pubdir_request_cb cb, void *user_data)
- ggp_pubdir_request *request = g_new0(ggp_pubdir_request, 1);
- request->type = GGP_PUBDIR_REQUEST_TYPE_INFO;
- request->user_data = user_data;
- request->params.user_info.uin = uin;
- url = g_strdup_printf("http://api.gadu-gadu.pl/users/%u", uin);
- ggp_oauth_request(gc, ggp_pubdir_get_info_got_token, request,
-static void ggp_pubdir_get_info_got_token(PurpleConnection *gc,
- const gchar *token, gpointer _request)
- PurpleHttpRequest *req;
- ggp_pubdir_request *request = _request;
- PURPLE_ASSERT_CONNECTION_IS_VALID(gc);
- request->cb(gc, -1, NULL, 0, request->user_data);
- ggp_pubdir_request_free(request);
- req = purple_http_request_new(NULL);
- purple_http_request_set_url_printf(req,
- "http://api.gadu-gadu.pl/users/%u",
- request->params.user_info.uin);
- purple_http_request_header_set(req, "Authorization", token);
- purple_http_request(gc, req, ggp_pubdir_got_data, request);
- purple_http_request_unref(req);
static void ggp_pubdir_got_data(PurpleHttpConnection *http_conn,
PurpleHttpResponse *response, gpointer _request)
@@ -349,16 +268,45 @@
ggp_pubdir_record_free(records, record_count);
-void ggp_pubdir_get_info_protocol(PurpleConnection *gc, const char *name)
+ggp_pubdir_get_info_got_token(PurpleConnection *gc, const gchar *token, - uin_t uin = ggp_str_to_uin(name);
- uin_t *uin_p = g_new0(uin_t, 1);
+ PurpleHttpRequest *req; + ggp_pubdir_request *request = _request; + PURPLE_ASSERT_CONNECTION_IS_VALID(gc); + request->cb(gc, -1, NULL, 0, request->user_data); + ggp_pubdir_request_free(request);
+ req = purple_http_request_new(NULL); + purple_http_request_set_url_printf(req, "http://api.gadu-gadu.pl/users/%u", + request->params.user_info.uin); + purple_http_request_header_set(req, "Authorization", token); + purple_http_request(gc, req, ggp_pubdir_got_data, request); + purple_http_request_unref(req); - purple_debug_info("gg", "ggp_pubdir_get_info_protocol: %u\n", uin);
+ggp_pubdir_get_info(PurpleConnection *gc, uin_t uin, ggp_pubdir_request_cb cb, + ggp_pubdir_request *request = g_new0(ggp_pubdir_request, 1); - ggp_pubdir_get_info(gc, uin, ggp_pubdir_get_info_protocol_got, uin_p);
+ request->type = GGP_PUBDIR_REQUEST_TYPE_INFO; + request->user_data = user_data; + request->params.user_info.uin = uin; + url = g_strdup_printf("http://api.gadu-gadu.pl/users/%u", uin); + ggp_oauth_request(gc, ggp_pubdir_get_info_got_token, request, "GET", url); static void ggp_pubdir_get_info_protocol_got(PurpleConnection *gc,
@@ -445,13 +393,17 @@
purple_notify_user_info_destroy(info);
-void ggp_pubdir_request_buddy_alias(PurpleConnection *gc, PurpleBuddy *buddy)
+ggp_pubdir_get_info_protocol(PurpleConnection *gc, const char *name) - uin_t uin = ggp_str_to_uin(purple_buddy_get_name(buddy));
+ uin_t uin = ggp_str_to_uin(name); + uin_t *uin_p = g_new0(uin_t, 1); - purple_debug_info("gg", "ggp_pubdir_request_buddy_alias: %u\n", uin);
- ggp_pubdir_get_info(gc, uin, ggp_pubdir_request_buddy_alias_got, NULL);
+ purple_debug_info("gg", "ggp_pubdir_get_info_protocol: %u", uin); + ggp_pubdir_get_info(gc, uin, ggp_pubdir_get_info_protocol_got, uin_p); static void ggp_pubdir_request_buddy_alias_got(PurpleConnection *gc,
@@ -481,19 +433,22 @@
purple_serv_got_alias(gc, ggp_uin_to_str(uin), alias);
+ggp_pubdir_request_buddy_alias(PurpleConnection *gc, PurpleBuddy *buddy) + uin_t uin = ggp_str_to_uin(purple_buddy_get_name(buddy)); + purple_debug_info("gg", "ggp_pubdir_request_buddy_alias: %u", uin); + ggp_pubdir_get_info(gc, uin, ggp_pubdir_request_buddy_alias_got, NULL); /*******************************************************************************
******************************************************************************/
-void ggp_pubdir_search_form_free(ggp_pubdir_search_form *form)
-ggp_pubdir_search_form * ggp_pubdir_search_form_clone(
- const ggp_pubdir_search_form *form)
+static ggp_pubdir_search_form * +ggp_pubdir_search_form_clone(const ggp_pubdir_search_form *form) ggp_pubdir_search_form *dup = g_new(ggp_pubdir_search_form, 1);
@@ -508,61 +463,6 @@
-void ggp_pubdir_search(PurpleConnection *gc,
- const ggp_pubdir_search_form *form)
- PurpleRequestFields *fields;
- PurpleRequestFieldGroup *group;
- PurpleRequestField *field;
- purple_debug_info("gg", "ggp_pubdir_search\n");
- fields = purple_request_fields_new();
- group = purple_request_field_group_new(NULL);
- purple_request_fields_add_group(fields, group);
- field = purple_request_field_string_new("name", _("Name"),
- form ? form->nick : NULL, FALSE);
- purple_request_field_group_add_field(group, field);
- field = purple_request_field_string_new("city", _("City"),
- form ? form->city : NULL, FALSE);
- purple_request_field_group_add_field(group, field);
- field = purple_request_field_choice_new("gender", _("Gender"),
- form ? GINT_TO_POINTER(form->gender) : NULL);
- purple_request_field_choice_add(field, _("Male or female"), NULL);
- purple_request_field_choice_add(field, _("Male"),
- GINT_TO_POINTER(GGP_PUBDIR_GENDER_MALE));
- purple_request_field_choice_add(field, _("Female"),
- GINT_TO_POINTER(GGP_PUBDIR_GENDER_FEMALE));
- purple_request_field_group_add_field(group, field);
- purple_request_fields(gc, _("Find buddies"), _("Find buddies"),
- _("Please, enter your search criteria below"), fields,
- _("OK"), G_CALLBACK(ggp_pubdir_search_request),
- purple_request_cpar_from_connection(gc), gc);
-static void ggp_pubdir_search_request(PurpleConnection *gc,
- PurpleRequestFields *fields)
- ggp_pubdir_search_form *form = g_new0(ggp_pubdir_search_form, 1);
- purple_debug_info("gg", "ggp_pubdir_search_request\n");
- form->nick = g_strdup(purple_request_fields_get_string(fields, "name"));
- form->city = g_strdup(purple_request_fields_get_string(fields, "city"));
- form->gender = GPOINTER_TO_INT(purple_request_fields_get_choice(fields,
- form->limit = GGP_PUBDIR_SEARCH_PER_PAGE;
- ggp_pubdir_search_execute(gc, form, ggp_pubdir_search_results_display,
static gchar * ggp_pubdir_search_make_query(const ggp_pubdir_search_form *form)
gchar *nick, *city, *gender;
@@ -598,30 +498,6 @@
-static void ggp_pubdir_search_execute(PurpleConnection *gc,
- const ggp_pubdir_search_form *form,
- ggp_pubdir_request_cb cb, void *user_data)
- ggp_pubdir_request *request = g_new0(ggp_pubdir_request, 1);
- ggp_pubdir_search_form *local_form = ggp_pubdir_search_form_clone(form);
- request->type = GGP_PUBDIR_REQUEST_TYPE_SEARCH;
- request->user_data = user_data;
- request->params.search_form = local_form;
- query = ggp_pubdir_search_make_query(form);
- purple_debug_misc("gg", "ggp_pubdir_search_execute: %s\n", query);
- url = g_strdup_printf("http://api.gadu-gadu.pl%s", query);
- ggp_oauth_request(gc, ggp_pubdir_search_got_token, request,
static void ggp_pubdir_search_got_token(PurpleConnection *gc,
const gchar *token, gpointer _request)
@@ -650,10 +526,77 @@
+ggp_pubdir_search_execute(PurpleConnection *gc, + const ggp_pubdir_search_form *form, + ggp_pubdir_request_cb cb, void *user_data) + ggp_pubdir_request *request = g_new0(ggp_pubdir_request, 1); + ggp_pubdir_search_form *local_form = ggp_pubdir_search_form_clone(form); -static void ggp_pubdir_search_results_display(PurpleConnection *gc,
- int records_count, const ggp_pubdir_record *records, int next_offset,
+ request->type = GGP_PUBDIR_REQUEST_TYPE_SEARCH; + request->user_data = user_data; + request->params.search_form = local_form; + query = ggp_pubdir_search_make_query(form); + purple_debug_misc("gg", "ggp_pubdir_search_execute: %s", query); + url = g_strdup_printf("http://api.gadu-gadu.pl%s", query); + ggp_oauth_request(gc, ggp_pubdir_search_got_token, request, "GET", url); +ggp_pubdir_search_results_new(PurpleConnection *gc, GList *row, gpointer _form) + ggp_pubdir_search_form *form = _form; + ggp_pubdir_search(gc, form); +ggp_pubdir_search_results_close(gpointer _form) + ggp_pubdir_search_form *form = _form; + ggp_pubdir_search_form_free(form); +ggp_pubdir_search_results_next(PurpleConnection *gc, GList *row, gpointer _form) + ggp_pubdir_search_form *form = _form; + ggp_pubdir_search_execute(gc, form, ggp_pubdir_search_results_display, +ggp_pubdir_search_results_add(PurpleConnection *gc, GList *row, gpointer _form) + purple_blist_request_add_buddy(purple_connection_get_account(gc), + g_list_nth_data(row, 0), NULL, + g_list_nth_data(row, 1)); +ggp_pubdir_search_results_im(PurpleConnection *gc, GList *row, gpointer _form) + purple_conversation_present(PURPLE_CONVERSATION(purple_im_conversation_new( + purple_connection_get_account(gc), g_list_nth_data(row, 0)))); +ggp_pubdir_search_results_info(PurpleConnection *gc, GList *row, gpointer _form) + ggp_pubdir_get_info_protocol(gc, g_list_nth_data(row, 0)); +ggp_pubdir_search_results_display(PurpleConnection *gc, int records_count, + const ggp_pubdir_record *records, + int next_offset, void *_form) ggp_pubdir_search_form *form = _form;
PurpleNotifySearchResults *results;
@@ -741,163 +684,80 @@
g_assert(form->display_handle);
-static void ggp_pubdir_search_results_close(gpointer _form)
+ggp_pubdir_search_request(PurpleConnection *gc, PurpleRequestFields *fields) - ggp_pubdir_search_form *form = _form;
- ggp_pubdir_search_form_free(form);
+ ggp_pubdir_search_form *form = g_new0(ggp_pubdir_search_form, 1); + purple_debug_info("gg", "ggp_pubdir_search_request"); -static void ggp_pubdir_search_results_next(PurpleConnection *gc, GList *row,
- ggp_pubdir_search_form *form = _form;
+ form->nick = g_strdup(purple_request_fields_get_string(fields, "name")); + form->city = g_strdup(purple_request_fields_get_string(fields, "city")); + GPOINTER_TO_INT(purple_request_fields_get_choice(fields, "gender")); + form->limit = GGP_PUBDIR_SEARCH_PER_PAGE; ggp_pubdir_search_execute(gc, form, ggp_pubdir_search_results_display,
-static void ggp_pubdir_search_results_add(PurpleConnection *gc, GList *row,
- purple_blist_request_add_buddy(purple_connection_get_account(gc),
- g_list_nth_data(row, 0), NULL, g_list_nth_data(row, 1));
-static void ggp_pubdir_search_results_im(PurpleConnection *gc, GList *row,
+ggp_pubdir_search(PurpleConnection *gc, const ggp_pubdir_search_form *form) - purple_conversation_present(PURPLE_CONVERSATION(purple_im_conversation_new(
- purple_connection_get_account(gc), g_list_nth_data(row, 0))));
+ PurpleRequestFields *fields; + PurpleRequestFieldGroup *group; + PurpleRequestField *field; + purple_debug_info("gg", "ggp_pubdir_search"); + fields = purple_request_fields_new(); + group = purple_request_field_group_new(NULL); + purple_request_fields_add_group(fields, group); + field = purple_request_field_string_new("name", _("Name"), + form ? form->nick : NULL, FALSE); + purple_request_field_group_add_field(group, field); -static void ggp_pubdir_search_results_info(PurpleConnection *gc, GList *row,
- ggp_pubdir_get_info_protocol(gc, g_list_nth_data(row, 0));
+ field = purple_request_field_string_new("city", _("City"), + form ? form->city : NULL, FALSE); + purple_request_field_group_add_field(group, field); -static void ggp_pubdir_search_results_new(PurpleConnection *gc, GList *row,
- ggp_pubdir_search_form *form = _form;
- ggp_pubdir_search(gc, form);
+ field = purple_request_field_choice_new( + "gender", _("Gender"), form ? GINT_TO_POINTER(form->gender) : NULL); + purple_request_field_choice_add(field, _("Male or female"), NULL); + purple_request_field_choice_add(field, _("Male"), + GINT_TO_POINTER(GGP_PUBDIR_GENDER_MALE)); + purple_request_field_choice_add(field, _("Female"), + GINT_TO_POINTER(GGP_PUBDIR_GENDER_FEMALE)); + purple_request_field_group_add_field(group, field); + purple_request_fields(gc, _("Find buddies"), _("Find buddies"), + _("Please, enter your search criteria below"), fields, + _("OK"), G_CALLBACK(ggp_pubdir_search_request), + purple_request_cpar_from_connection(gc), gc); /*******************************************************************************
******************************************************************************/
-void ggp_pubdir_set_info(PurpleConnection *gc)
- ggp_pubdir_get_info(gc, ggp_str_to_uin(purple_account_get_username(
- purple_connection_get_account(gc))),
- ggp_pubdir_set_info_dialog, NULL);
-static void ggp_pubdir_set_info_dialog(PurpleConnection *gc, int records_count,
- const ggp_pubdir_record *records, int next_offset, void *user_data)
+ggp_pubdir_set_info_got_response(PurpleHttpConnection *http_conn, + PurpleHttpResponse *response, - PurpleRequestFields *fields;
- PurpleRequestFieldGroup *group;
- PurpleRequestField *field;
- const ggp_pubdir_record *record;
- purple_debug_info("gg", "ggp_pubdir_set_info_dialog (record: %d)\n",
- record = (records_count == 1 ? &records[0] : NULL);
- fields = purple_request_fields_new();
- group = purple_request_field_group_new(NULL);
- purple_request_fields_add_group(fields, group);
- field = purple_request_field_string_new("first_name", _("First name"),
- record ? record->first_name : NULL, FALSE);
- purple_request_field_group_add_field(group, field);
- field = purple_request_field_string_new("last_name", _("Last name"),
- record ? record->last_name : NULL, FALSE);
- purple_request_field_group_add_field(group, field);
- field = purple_request_field_choice_new("gender", _("Gender"),
- record ? GINT_TO_POINTER(record->gender) :
- GGP_PUBDIR_GENDER_UNSPECIFIED);
- purple_request_field_set_required(field, TRUE);
- purple_request_field_choice_add(field, _("Male"),
- GINT_TO_POINTER(GGP_PUBDIR_GENDER_MALE));
- purple_request_field_choice_add(field, _("Female"),
- GINT_TO_POINTER(GGP_PUBDIR_GENDER_FEMALE));
- purple_request_field_group_add_field(group, field);
- field = purple_request_field_string_new("birth_date", _("Birth Day"),
- (record && record->birth) ?
- ggp_date_strftime("%Y-%m-%d", record->birth) : NULL, FALSE);
- purple_request_field_set_required(field, TRUE);
- purple_request_field_group_add_field(group, field);
- field = purple_request_field_string_new("city", _("City"),
- record ? record->city : NULL, FALSE);
- purple_request_field_group_add_field(group, field);
- /* Translators: This word is basically used to describe a Polish
- province. Gadu-Gadu users outside of Poland might choose to enter some
- equivalent value for themselves. For example, users in the USA might
- use their state (e.g. New York). If there is an equivalent term for
- your language, feel free to use it. Otherwise it's probably acceptable
- to leave it changed or transliterate it into your alphabet. */
- field = purple_request_field_choice_new("province", _("Voivodeship"), 0);
- purple_request_field_group_add_field(group, field);
- for (i = 0; i < ggp_pubdir_provinces_count; i++) {
- purple_request_field_choice_add(field, ggp_pubdir_provinces[i],
- if (record && i == record->province) {
- purple_request_field_choice_set_value(field, GINT_TO_POINTER(i));
- purple_request_field_choice_set_default_value(field, GINT_TO_POINTER(i));
+ if (!purple_http_response_is_successful(response)) { + purple_debug_error("gg", "ggp_pubdir_set_info_got_response: failed"); - purple_request_fields(gc, _("Set User Info"), _("Set User Info"),
- _("OK"), G_CALLBACK(ggp_pubdir_set_info_request),
- purple_request_cpar_from_connection(gc), gc);
-static void ggp_pubdir_set_info_request(PurpleConnection *gc,
- PurpleRequestFields *fields)
- uin_t uin = ggp_str_to_uin(purple_account_get_username(
- purple_connection_get_account(gc)));
- ggp_pubdir_record *record = g_new0(ggp_pubdir_record, 1);
- purple_debug_info("gg", "ggp_pubdir_set_info_request\n");
+ purple_debug_info("gg", "ggp_pubdir_set_info_got_response: [%s]", + purple_http_response_get_data(response, NULL)); + /* <result><status>0</status></result> */
- record->first_name = g_strdup(purple_request_fields_get_string(fields,
- record->last_name = g_strdup(purple_request_fields_get_string(fields,
- record->gender = GPOINTER_TO_INT(
- purple_request_fields_get_choice(fields, "gender"));
- record->city = g_strdup(purple_request_fields_get_string(fields,
- record->province = GPOINTER_TO_INT(
- purple_request_fields_get_choice(fields, "province"));
- birth_s = g_strdup_printf("%sT10:00:00+00:00",
- purple_request_fields_get_string(fields, "birth_date"));
- record->birth = ggp_date_from_iso8601(birth_s);
- purple_debug_info("gg", "ggp_pubdir_set_info_request: birth [%lu][%s]\n",
- record->birth, purple_request_fields_get_string(
- fields, "birth_date"));
- url = g_strdup_printf("http://api.gadu-gadu.pl/users/%u.xml", uin);
- ggp_oauth_request(gc, ggp_pubdir_set_info_got_token, record,
+ /* TODO: notify about failure */ static void ggp_pubdir_set_info_got_token(PurpleConnection *gc,
@@ -956,18 +816,125 @@
ggp_pubdir_record_free(record, 1);
-static void ggp_pubdir_set_info_got_response(PurpleHttpConnection *http_conn,
- PurpleHttpResponse *response, gpointer user_data)
+ggp_pubdir_set_info_request(PurpleConnection *gc, PurpleRequestFields *fields) + uin_t uin = ggp_str_to_uin( + purple_account_get_username(purple_connection_get_account(gc))); + ggp_pubdir_record *record = g_new0(ggp_pubdir_record, 1); + purple_debug_info("gg", "ggp_pubdir_set_info_request"); + g_strdup(purple_request_fields_get_string(fields, "first_name")); + g_strdup(purple_request_fields_get_string(fields, "last_name")); + GPOINTER_TO_INT(purple_request_fields_get_choice(fields, "gender")); + record->city = g_strdup(purple_request_fields_get_string(fields, "city")); + record->province = GPOINTER_TO_INT( + purple_request_fields_get_choice(fields, "province")); + birth_s = g_strdup_printf( + purple_request_fields_get_string(fields, "birth_date")); + record->birth = ggp_date_from_iso8601(birth_s); + purple_debug_info("gg", "ggp_pubdir_set_info_request: birth [%lu][%s]", + purple_request_fields_get_string(fields, "birth_date")); + url = g_strdup_printf("http://api.gadu-gadu.pl/users/%u.xml", uin); + ggp_oauth_request(gc, ggp_pubdir_set_info_got_token, record, "PUT", url); +ggp_pubdir_set_info_dialog(PurpleConnection *gc, int records_count, + const ggp_pubdir_record *records, int next_offset, - if (!purple_http_response_is_successful(response)) {
- purple_debug_error("gg", "ggp_pubdir_set_info_got_response: "
+ PurpleRequestFields *fields; + PurpleRequestFieldGroup *group; + PurpleRequestField *field; + const ggp_pubdir_record *record; + purple_debug_info("gg", "ggp_pubdir_set_info_dialog (record: %d)", + record = (records_count == 1 ? &records[0] : NULL); + fields = purple_request_fields_new(); + group = purple_request_field_group_new(NULL); + purple_request_fields_add_group(fields, group); + field = purple_request_field_string_new("first_name", _("First name"), + record ? record->first_name : NULL, + purple_request_field_group_add_field(group, field); + field = purple_request_field_string_new("last_name", _("Last name"), + record ? record->last_name : NULL, + purple_request_field_group_add_field(group, field); + field = purple_request_field_choice_new( + record ? GINT_TO_POINTER(record->gender) + : GGP_PUBDIR_GENDER_UNSPECIFIED); + purple_request_field_set_required(field, TRUE); + purple_request_field_choice_add(field, _("Male"), + GINT_TO_POINTER(GGP_PUBDIR_GENDER_MALE)); + purple_request_field_choice_add(field, _("Female"), + GINT_TO_POINTER(GGP_PUBDIR_GENDER_FEMALE)); + purple_request_field_group_add_field(group, field); + field = purple_request_field_string_new( + "birth_date", _("Birth Day"), + (record && record->birth) + ? ggp_date_strftime("%Y-%m-%d", record->birth) + purple_request_field_set_required(field, TRUE); + purple_request_field_group_add_field(group, field); + field = purple_request_field_string_new( + "city", _("City"), record ? record->city : NULL, FALSE); + purple_request_field_group_add_field(group, field); + /* Translators: This word is basically used to describe a Polish + province. Gadu-Gadu users outside of Poland might choose to enter some + equivalent value for themselves. For example, users in the USA might + use their state (e.g. New York). If there is an equivalent term for + your language, feel free to use it. Otherwise it's probably acceptable + to leave it changed or transliterate it into your alphabet. */ + field = purple_request_field_choice_new("province", _("Voivodeship"), 0); + purple_request_field_group_add_field(group, field); + for (i = 0; i < ggp_pubdir_provinces_count; i++) { + purple_request_field_choice_add(field, ggp_pubdir_provinces[i], + if (record && i == record->province) { + purple_request_field_choice_set_value(field, GINT_TO_POINTER(i)); + purple_request_field_choice_set_default_value(field, - purple_debug_info("gg", "ggp_pubdir_set_info_got_response: [%s]\n",
- purple_http_response_get_data(response, NULL));
- /* <result><status>0</status></result> */
+ purple_request_fields(gc, _("Set User Info"), _("Set User Info"), NULL, + G_CALLBACK(ggp_pubdir_set_info_request), _("Cancel"), + NULL, purple_request_cpar_from_connection(gc), gc); - /* TODO: notify about failure */
+ggp_pubdir_set_info(PurpleConnection *gc) + ggp_pubdir_get_info(gc, + ggp_str_to_uin(purple_account_get_username( + purple_connection_get_account(gc))), + ggp_pubdir_set_info_dialog, NULL);