Exemplo n.º 1
0
/* Show privacy settings */
static void waprpl_show_privacy(PurplePluginAction * action)
{
	PurpleConnection *gc = (PurpleConnection *) action->context;
	whatsapp_connection *wconn = purple_connection_get_protocol_data(gc);
	if (!wconn)
		return;

	char priv[3][30];
	waAPI_queryprivacy(wconn->waAPI, priv[0], priv[1], priv[2]);

	PurpleRequestField *field;

	PurpleRequestFields *fields = purple_request_fields_new();
	PurpleRequestFieldGroup *group = purple_request_field_group_new(NULL);
	purple_request_fields_add_group(fields, group);

	int i,j;
	for (j = 0; j < 3; j++) {
		field = purple_request_field_list_new(priv_type[j], priv_type_nice[j]);
		for (i = 0; i < 3; i++) {
			purple_request_field_list_add(field, priv_opt_nice[i], g_strdup(priv_opt[i]));
			if (strcmp(priv_opt[i], priv[j]) == 0)
				purple_request_field_list_add_selected(field, priv_opt_nice[i]);
		}
		purple_request_field_group_add_field(group, field);
	}

	purple_request_fields(gc, "Edit privacy settings", "Edit privacy settings",
						NULL, fields, 
						"Save", G_CALLBACK(waprpl_update_privacy),
						"Cancel", NULL,
						purple_connection_get_account(gc), NULL, NULL,
						gc);
}
Exemplo n.º 2
0
static void fb_login_captcha_image_cb(FacebookAccount *fba, gchar *response, 
		gsize len, gpointer userdata)
{
	PurpleRequestFields *fields;
	PurpleRequestFieldGroup *group;
	PurpleRequestField *field;
	
	fields = purple_request_fields_new();
	group = purple_request_field_group_new(NULL);
	purple_request_fields_add_group(fields, group);
	
	field = purple_request_field_image_new("captcha_image", "", response, len);
	purple_request_field_group_add_field(group, field);
	
	field = purple_request_field_string_new("captcha_response", "", "", FALSE);
	purple_request_field_group_add_field(group, field);
	
	purple_request_fields(fba->pc, 
		_("Facebook Captcha"), _("Facebook Captcha"), 
		_("Enter both words below, separated by a space"), 
		fields, 
		_("OK"), G_CALLBACK(fb_login_captcha_ok_cb), 
		_("Logout"), G_CALLBACK(fb_login_captcha_cancel_cb), 
		fba->account, NULL, NULL, fba->pc	 
	);
}
Exemplo n.º 3
0
/* Add buddy dialog */
static void plainprpl_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *buddy_group)
{
	purple_debug_info("plainprpl", "plainprpl_add_buddy_with_invite: %s\n", buddy->name);
	PurpleRequestFields *request;
	PurpleRequestFieldGroup *group;
	PurpleRequestField *field;

	group = purple_request_field_group_new(NULL);

	field = purple_request_field_string_new("addr_str", _("IP Address"), "", FALSE);
	purple_request_field_group_add_field(group, field);

	field = purple_request_field_string_new("invite_msg", _("Invite Message"), "Please allow me to add you as a contact!", FALSE);
	purple_request_field_group_add_field(group, field);

	request = purple_request_fields_new();
	purple_request_fields_add_group(request, group);

	purple_request_fields(gc, "Add Contact", "Add a new contact.",
		NULL, request,
		"OK",  G_CALLBACK(plainprpl_add_buddy_ok),
		"Cancel",  G_CALLBACK(plainprpl_add_buddy_cancel),
		NULL, NULL, NULL, (void *) buddy
	);

	purple_prpl_got_user_status(gc->account, buddy->name, PLAIN_STATUS_OFFLINE, NULL);
}
Exemplo n.º 4
0
//with invite message
static void plainprpl_add_buddy_by_contact_request(PurpleConnection *gc, const char *addr_str, const char *message)
{
	PurpleBuddy *buddy;

	/* Create the basic buddy item */
	buddy = purple_buddy_new(gc->account, addr_str, NULL);
	purple_blist_add_buddy(buddy, NULL, NULL, NULL);

	PurpleRequestFields *request;
	PurpleRequestFieldGroup *group;
	PurpleRequestField *field;

	group = purple_request_field_group_new(NULL);

	field = purple_request_field_string_new("name", _("Name"), addr_str, FALSE);
	purple_request_field_group_add_field(group, field);

	request = purple_request_fields_new();
	purple_request_fields_add_group(request, group);

	char *msg = g_strdup_printf("Add a new contact from %s. Message: %s", addr_str, message);
	purple_request_fields(gc, "Contact Request", msg,
		NULL, request,
		"OK",  G_CALLBACK(plainprpl_add_buddy_by_contact_request_ok),
		"Cancel",  G_CALLBACK(plainprpl_add_buddy_by_contact_request_cancel),
		NULL, NULL, NULL, (void *) buddy
	);
	g_free(msg);

	purple_prpl_got_user_status(gc->account, buddy->name, PLAIN_STATUS_OFFLINE, NULL);
}
Exemplo n.º 5
0
static void alias_add (GtkButton *button, gpointer data)
{
  PurpleRequestFields *fields;
  PurpleRequestFieldGroup *group;
  PurpleRequestField *field;

  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("alias", _("Alias"),
    NULL, FALSE);
  purple_request_field_set_required(field, TRUE);
  purple_request_field_set_type_hint(field, "alias");
  purple_request_field_group_add_field(group, field);

  purple_request_fields(purple_get_blist(), _("Add Alias"),
    NULL,
    _("Type in the alias that you use"),
    fields,
    _("OK"), G_CALLBACK(new_alias),
    _("Cancel"), NULL,
    NULL, NULL, NULL, NULL);
}
Exemplo n.º 6
0
/*------------------------------------------------------------------------
 * Enable the user to change their PIN.
 *
 *  @param action	The action object
 */
static void mxit_change_pin_action( PurplePluginAction* action )
{
	PurpleConnection*			gc		= (PurpleConnection*) action->context;

	PurpleRequestFields*		fields	= NULL;
	PurpleRequestFieldGroup*	group	= NULL;
	PurpleRequestField*			field	= NULL;

	purple_debug_info( MXIT_PLUGIN_ID, "mxit_change_pin_action\n" );

	fields = purple_request_fields_new();
	group = purple_request_field_group_new( NULL );
	purple_request_fields_add_group( fields, group );

	/* pin */
	field = purple_request_field_string_new( "pin", _( "PIN" ), purple_connection_get_password( gc ), FALSE );
	purple_request_field_string_set_masked( field, TRUE );
	purple_request_field_group_add_field( group, field );

	/* verify pin */
	field = purple_request_field_string_new( "pin2", _( "Verify PIN" ), purple_connection_get_password( gc ), FALSE );
	purple_request_field_string_set_masked( field, TRUE );
	purple_request_field_group_add_field( group, field );

	/* (reference: "libpurple/request.h") */
	purple_request_fields( gc, _( "Change PIN" ), _( "Change MXit PIN" ), NULL, fields, _( "Set" ),
			G_CALLBACK( mxit_change_pin_cb ), _( "Cancel" ), NULL, purple_request_cpar_from_connection(gc), gc );
}
Exemplo n.º 7
0
static void info_modify_dialogue(PurpleConnection *gc, gchar **segments, int iclass)
{
	qq_data *qd;
	PurpleRequestFieldGroup *group;
	PurpleRequestFields *fields;
	modify_info_request *info_request;
	gchar *utf8_title, *utf8_prim;
	int index;

	qd = (qq_data *) gc->proto_data;
	/* Keep one dialog once a time */
	purple_request_close_with_handle(gc);

	fields = purple_request_fields_new();
	group = purple_request_field_group_new(NULL);
	purple_request_fields_add_group(fields, group);

	for (index = 1; segments[index] != NULL && index < QQ_INFO_LAST; index++) {
		if (field_infos[index].iclass != iclass) {
			continue;
		}
		field_request_new(group, index, segments);
	}

	switch (iclass) {
		case QQ_FIELD_CONTACT:
			utf8_title = g_strdup(_("Modify Contact"));
			utf8_prim = g_strdup_printf("%s for %s", _("Modify Contact"), segments[0]);
		case QQ_FIELD_ADDR:
			utf8_title = g_strdup(_("Modify Address"));
			utf8_prim = g_strdup_printf("%s for %s", _("Modify Address"), segments[0]);
		case QQ_FIELD_EXT:
			utf8_title = g_strdup(_("Modify Extended Information"));
			utf8_prim = g_strdup_printf("%s for %s", _("Modify Extended Information"), segments[0]);
			break;
		case QQ_FIELD_BASE:
		default:
			utf8_title = g_strdup(_("Modify Information"));
			utf8_prim = g_strdup_printf("%s for %s", _("Modify Information"), segments[0]);
	}

	info_request = g_new0(modify_info_request, 1);
	info_request->gc = gc;
	info_request->iclass = iclass;
	info_request->segments = segments;

	purple_request_fields(gc,
			utf8_title,
			utf8_prim,
			NULL,
			fields,
			_("Update"), G_CALLBACK(info_modify_ok_cb),
			_("Cancel"), G_CALLBACK(info_modify_cancel_cb),
			purple_connection_get_account(gc), NULL, NULL,
			info_request);

	g_free(utf8_title);
	g_free(utf8_prim);
}
Exemplo n.º 8
0
/*------------------------------------------------------------------------
 * Display the current splash-screen.
 *
 *  @param session		The MXit session object
 */
void splash_display(struct MXitSession* session)
{
	const char* splashId = NULL;
	char* filename;
	gchar* imgdata;
	gsize imglen;
	int imgid = -1;

	/* Get current splash ID */
	splashId = splash_current(session);
	if (splashId == NULL)		/* no splash-screen */
		return;

	purple_debug_info(MXIT_PLUGIN_ID, "Display Splash: '%s'\n", splashId);

	/* Load splash-screen image from file */
	filename = g_strdup_printf("%s" G_DIR_SEPARATOR_S "mxit" G_DIR_SEPARATOR_S "%s.png", purple_user_dir(), splashId);
	if (g_file_get_contents(filename, &imgdata, &imglen, NULL)) {
		char buf[128];

		/* Add splash-image to imagestore */
		imgid = purple_imgstore_new_with_id(g_memdup(imgdata, imglen), imglen, NULL);

		/* Generate and display message */
		g_snprintf(buf, sizeof(buf),
		           "<img src=\"" PURPLE_STORED_IMAGE_PROTOCOL "%d\">", imgid);

		/* Open a request-type popup to display the image */
		{
			PurpleRequestFields*		fields;
			PurpleRequestFieldGroup*	group;
			PurpleRequestField*			field;

			fields = purple_request_fields_new();
			group = purple_request_field_group_new(NULL);
			purple_request_fields_add_group(fields, group);

			field = purple_request_field_image_new("splash", "", imgdata, imglen);		/* add splash image */
			purple_request_field_group_add_field(group, field);

			if (splash_clickable(session)) {
				purple_request_fields(session->con, _("MXit Advertising"), NULL, NULL, fields,
					_("More Information"), G_CALLBACK(splash_click_ok), _("Close"), NULL, purple_request_cpar_from_account(session->acc), session->con);
			}
			else {
				purple_request_fields(session->con, _("MXit Advertising"), NULL, NULL, fields,
					_("Continue"), G_CALLBACK(splash_click_ok), _("Close"), NULL, purple_request_cpar_from_account(session->acc), session->con);
			}
		}

		/* Release reference to image */
		purple_imgstore_unref_by_id(imgid);

		g_free(imgdata);
	}

	g_free(filename);
}
Exemplo n.º 9
0
/* memo modify dialogue */
static void memo_modify_dialogue(PurpleConnection *gc, guint32 bd_uid, gchar **segments, guint32 action)
{
	modify_memo_request *memo_request;
	PurpleRequestField *field;
	PurpleRequestFields *fields;
	PurpleRequestFieldGroup *group;
	int index;
	gchar *utf8_title;
	gchar *utf8_primary;

	g_return_if_fail(NULL != gc && NULL != segments);

	switch (action) {
		case QQ_BUDDY_MEMO_GET:
			memo_free(segments);
			break;
		case QQ_BUDDY_MEMO_MODIFY:
			/* keep one dialog once a time */
			purple_request_close_with_handle(gc);
			/* show dialog */
			fields = purple_request_fields_new();
			group = purple_request_field_group_new(NULL);
			purple_request_fields_add_group(fields, group);

			for(index = 0; index < QQ_MEMO_SIZE; index++) {
				/*
				   purple_debug_info("QQ", "id:%s txt:%s segment:%s\n",
				   memo_id[index], memo_txt[index], segments[index]);
				   */
				field = purple_request_field_string_new(memo_id[index], memo_txt[index],
						segments[index], FALSE);
				purple_request_field_group_add_field(group, field);
			}

			/* for upload cb */
			memo_request = g_new0(modify_memo_request, 1);
			memo_request->gc = gc;
			memo_request->bd_uid = bd_uid;
			memo_request->segments = segments;
			/* callback */
			utf8_title = g_strdup(_("Buddy Memo"));
			utf8_primary = g_strdup(_("Change his/her memo as you like"));

			purple_request_fields(gc, utf8_title, utf8_primary, NULL,
					fields,
					_("_Modify"), G_CALLBACK(memo_modify_ok_cb),
					_("_Cancel"), G_CALLBACK(memo_modify_cancle_cb),
					purple_connection_get_account(gc), NULL, NULL,
					memo_request);

			g_free(utf8_title);
			g_free(utf8_primary);
			break;
		default:
			purple_debug_info("QQ", "Error...unknown memo action, please tell us\n");
			break;
	}
}
Exemplo n.º 10
0
void auth_token_captcha_input_cb(PurpleUtilFetchUrlData *url_data, 
	gpointer user_data, const gchar *url_text, gsize len, const gchar *error_message)
{
	PurpleAccount *account;
	PurpleRequestFields *fields;
	PurpleRequestFieldGroup *group;
	PurpleRequestField *field;
	qq_buddy_opt_req *opt_req = (qq_buddy_opt_req *)user_data;
	gchar *end_of_headers, *p;
	guint header_len, content_len;

	g_return_if_fail(opt_req && opt_req->gc && opt_req->uid>0 );
	g_return_if_fail(url_text && len>0);

	account = purple_connection_get_account(opt_req->gc);

	end_of_headers = strstr(url_text, "\r\n\r\n");
	if (end_of_headers) {
		header_len = (end_of_headers + 4 - url_text);
	}

	p = find_header_content(url_text, header_len, "\nContent-Length: ", sizeof("\nContent-Length: ") - 1);
	if (p) {
		sscanf(p, "%" G_GSIZE_FORMAT, &content_len);
	} else {
		purple_debug_error("QQ", "can not parse http header, maybe it's chunked!");
	}

	p = find_header_content(url_text, header_len, "\ngetqqsession: ", sizeof("\ngetqqsession: ") - 1);
	if (!p) purple_debug_error("QQ", "can not find qqsession in http header!");
	
	opt_req->session_len = strstr(p, "\r\n")-p;
	opt_req->session = g_new0(guint8, opt_req->session_len);
	g_memmove(opt_req->session, p, opt_req->session_len);

	fields = purple_request_fields_new();
	group = purple_request_field_group_new(NULL);
	purple_request_fields_add_group(fields, group);

	field = purple_request_field_image_new("captcha_img",
		_("Captcha Image"), url_text+header_len, content_len);
	purple_request_field_group_add_field(group, field);

	field = purple_request_field_string_new("captcha_code",
		_("Enter code"), "", FALSE);
	purple_request_field_string_set_masked(field, FALSE);
	purple_request_field_group_add_field(group, field);

	purple_request_fields(account,
		_("QQ Captcha Verification"),
		_("QQ Captcha Verification"),
		_("Enter the text from the image"),
		fields,
		_("OK"), G_CALLBACK(auth_token_captcha_input_ok_cb),
		_("Cancel"), G_CALLBACK(auth_token_captcha_input_cancel_cb),
		account, NULL, NULL,
		opt_req);
}
Exemplo n.º 11
0
void GeneralMenu::openRequestFieldsTest(CppConsUI::Button& /*activator*/)
{
  PurpleRequestFields *fields = purple_request_fields_new();
  PurpleRequestFieldGroup *g = purple_request_field_group_new("Group 0");

  purple_request_fields_add_group(fields, g);

  PurpleRequestField *f;
  f = purple_request_field_string_new("text0", "String field 0", "def0",
      FALSE);
  purple_request_field_group_add_field(g, f);
  f = purple_request_field_string_new("text1", "String field 1", NULL,
      FALSE);
  purple_request_field_group_add_field(g, f);
  f = purple_request_field_int_new("int0", "Int field 0", INT_MAX);
  purple_request_field_group_add_field(g, f);
  f = purple_request_field_bool_new("bool0", "Bool field 0", FALSE);
  purple_request_field_group_add_field(g, f);

  f = purple_request_field_choice_new("choice0", "Choice field 0", 2);
  purple_request_field_choice_add(f, "One");
  purple_request_field_choice_add(f, "Two");
  purple_request_field_choice_add(f, "Three");
  purple_request_field_choice_add(f, "Four");
  purple_request_field_group_add_field(g, f);

  f = purple_request_field_list_new("list0", "List field 0, multiple");
  purple_request_field_list_set_multi_select(f, TRUE);
  purple_request_field_list_add(f, "One", this);
  purple_request_field_list_add(f, "Two", this);
  purple_request_field_list_add(f, "Three", this);
  purple_request_field_list_add(f, "Four", this);
  purple_request_field_list_add_selected(f, "Three");
  purple_request_field_group_add_field(g, f);

  f = purple_request_field_list_new("list1", "List field 1, single");
  purple_request_field_list_set_multi_select(f, FALSE);
  purple_request_field_list_add(f, "One", this);
  purple_request_field_list_add(f, "Two", this);
  purple_request_field_list_add(f, "Three", this);
  purple_request_field_list_add(f, "Four", this);
  purple_request_field_list_add_selected(f, "Three");
  purple_request_field_group_add_field(g, f);

  f = purple_request_field_account_new("account0", "Account field 0", NULL);
  purple_request_field_account_set_show_all(f, TRUE);
  purple_request_field_group_add_field(g, f);

  purple_request_fields(NULL, "Title", "Primary", "Secondary", fields,
      "Ok", G_CALLBACK(fields_ok_cb_),
      "Cancel", NULL,
      NULL, NULL, NULL, this);

  close();
}
Exemplo n.º 12
0
static void
history_prefs_check(PurplePlugin *plugin)
{
	if (!purple_prefs_get_bool("/purple/logging/log_ims") &&
	    !purple_prefs_get_bool("/purple/logging/log_chats"))
	{
		PurpleRequestFields *fields = purple_request_fields_new();
		PurpleRequestFieldGroup *group;
		PurpleRequestField *field;
		struct {
			const char *pref;
			const char *label;
		} prefs[] = {
			{"/purple/logging/log_ims", N_("Log IMs")},
			{"/purple/logging/log_chats", N_("Log chats")},
			{NULL, NULL}
		};
		int iter;
		GList *list = purple_log_logger_get_options();
		const char *system = purple_prefs_get_string("/purple/logging/format");

		group = purple_request_field_group_new(_("Logging"));

		field = purple_request_field_list_new("/purple/logging/format", _("Log format"));
		while (list) {
			const char *label = _(list->data);
			list = g_list_delete_link(list, list);
			purple_request_field_list_add_icon(field, label, NULL, list->data);
			if (system && strcmp(system, list->data) == 0)
				purple_request_field_list_add_selected(field, label);
			list = g_list_delete_link(list, list);
		}
		purple_request_field_group_add_field(group, field);

		for (iter = 0; prefs[iter].pref; iter++) {
			field = purple_request_field_bool_new(prefs[iter].pref, _(prefs[iter].label),
						purple_prefs_get_bool(prefs[iter].pref));
			purple_request_field_group_add_field(group, field);
		}

		purple_request_fields_add_group(fields, group);

		purple_request_fields(plugin, NULL, _("History Plugin Requires Logging"),
				      _("Logging can be enabled from Tools -> Preferences -> Logging.\n\n"
				      "Enabling logs for instant messages and/or chats will activate "
				      "history for the same conversation type(s)."),
				      fields,
				      _("OK"), G_CALLBACK(finch_request_save_in_prefs),
				      _("Cancel"), NULL,
				      NULL, NULL, NULL, plugin);
	}
}
Exemplo n.º 13
0
static void
_purple_events_ui_events_selection_dialog(PurpleBlistNode *node, PurpleEventsContext *context)
{
    node = _purple_events_ui_get_good_node(node);
    if ( node == NULL )
        return;

    PurpleRequestFields *request;
    PurpleRequestFieldGroup *group;
    PurpleRequestField *field;

    group = purple_request_field_group_new(NULL);

    gint current;
    guint i;
    gboolean v;
    for ( i = 0 ; _purple_events_ui_events[i] != NULL ; ++i )
    {
        current = purple_blist_node_get_int(node, _purple_events_ui_events[i]);
        if ( current != 0 )
            v = ( current > 0 );
        else
        {
            gchar *pref_name;

            pref_name = g_strconcat("/plugins/core/events/", _purple_events_ui_events[i], NULL);
            v = purple_prefs_get_bool(pref_name);
            g_free(pref_name);
        }

        field = purple_request_field_bool_new(_purple_events_ui_events[i], _(_purple_events_ui_events_labels[i]), v);
        purple_request_field_group_add_field(group, field);
    }

    request = purple_request_fields_new();
    purple_request_fields_add_group(request, group);

    purple_request_fields(context->plugin,
        _("Events selection"),
        PURPLE_BLIST_NODE_IS_CONTACT(node) ? _("Select events for contact") : _("Select events for group"),
        NULL,
        request,
        PURPLE_BLIST_NODE_IS_CONTACT(node) ? _("_Set events for contact") : _("_Set events for group"),
        G_CALLBACK(_purple_events_ui_events_selection),
        _("_Cancel"),
        NULL,
        NULL,
        PURPLE_BLIST_NODE_IS_CONTACT(node) ? purple_buddy_get_name(purple_contact_get_priority_buddy(PURPLE_CONTACT(node))) : NULL,
        NULL,
        node);

}
Exemplo n.º 14
0
static void
add_pref_group(PurpleRequestFields *fields, const char *title, Prefs *prefs)
{
	PurpleRequestField *field;
	PurpleRequestFieldGroup *group;
	int i;

	group = purple_request_field_group_new(title);
	purple_request_fields_add_group(fields, group);
	for (i = 0; prefs[i].pref; i++)
	{
		field = get_pref_field(prefs + i);
		if (field)
			purple_request_field_group_add_field(group, field);
	}
}
Exemplo n.º 15
0
Arquivo: buddy.c Projeto: dylex/pidgin
static void
silcpurple_add_buddy_select(SilcPurpleBuddyRes r,
			  SilcClientEntry *clients,
			  SilcUInt32 clients_count)
{
	PurpleRequestFields *fields;
	PurpleRequestFieldGroup *g;
	PurpleRequestField *f;
	char tmp[512], tmp2[128];
	int i;
	char *fingerprint;

	fields = purple_request_fields_new();
	g = purple_request_field_group_new(NULL);
	f = purple_request_field_list_new("list", NULL);
	purple_request_field_group_add_field(g, f);
	purple_request_field_list_set_multi_select(f, FALSE);
	purple_request_fields_add_group(fields, g);

	for (i = 0; i < clients_count; i++) {
		fingerprint = NULL;
		if (clients[i]->fingerprint) {
			fingerprint = silc_fingerprint(clients[i]->fingerprint,
						       clients[i]->fingerprint_len);
			g_snprintf(tmp2, sizeof(tmp2), "\n%s", fingerprint);
		}
		g_snprintf(tmp, sizeof(tmp), "%s - %s (%s@%s)%s",
			   clients[i]->realname, clients[i]->nickname,
			   clients[i]->username, clients[i]->hostname ?
			   clients[i]->hostname : "",
			   fingerprint ? tmp2 : "");
		purple_request_field_list_add_icon(f, tmp, NULL, clients[i]);
		silc_free(fingerprint);
	}

	purple_request_fields(r->client->application, _("Add Buddy"),
				_("Select correct user"),
				r->pubkey_search
					? _("More than one user was found with the same public key. Select "
						"the correct user from the list to add to the buddy list.")
					: _("More than one user was found with the same name. Select "
						"the correct user from the list to add to the buddy list."),
				fields,
				_("OK"), G_CALLBACK(silcpurple_add_buddy_select_cb),
				_("Cancel"), G_CALLBACK(silcpurple_add_buddy_select_cancel),
				purple_buddy_get_account(r->b), purple_buddy_get_name(r->b), NULL, r);
}
Exemplo n.º 16
0
void BuddyList::request_add_buddy(PurpleAccount *account,
    const char *username, const char *group, const char *alias)
{
  if (!CheckAnyAccountConnected())
    return;

  PurpleRequestFields *fields = purple_request_fields_new();
  PurpleRequestFieldGroup *g = purple_request_field_group_new(NULL);

  purple_request_fields_add_group(fields, g);

  PurpleRequestField *f;
  f = purple_request_field_account_new("account", _("Account"), account);
  purple_request_field_group_add_field(g, f);
  f = purple_request_field_string_new("name", _("Buddy name"), username,
      FALSE);
  purple_request_field_group_add_field(g, f);
  f = purple_request_field_string_new("alias", _("Alias"), alias, FALSE);
  purple_request_field_group_add_field(g, f);

  f = purple_request_field_choice_new("group", _("Group"), 0);
  bool add_default_group = true;
  int dval = 0;
  bool dval_set = false;
  for (PurpleBlistNode *i = purple_blist_get_root(); i; i = i->next)
    if (PURPLE_BLIST_NODE_IS_GROUP(i)) {
      const char *cur_name = purple_group_get_name(
          reinterpret_cast<PurpleGroup*>(i));
      purple_request_field_choice_add(f, cur_name);
      if (!dval_set) {
        if (group && !strcmp(group, cur_name)) {
          purple_request_field_choice_set_default_value(f, dval);
          dval_set = true;
        }
        dval++;
      }
      add_default_group = false;
    }
  if (add_default_group)
      purple_request_field_choice_add(f, _("Buddies"));
  purple_request_field_group_add_field(g, f);

  purple_request_fields(NULL, _("Add buddy"), NULL, NULL, fields, _("Add"),
      G_CALLBACK(add_buddy_ok_cb_), CANCEL_BUTTON_TEXT, NULL, NULL, NULL,
      NULL, this);
}
Exemplo n.º 17
0
static void
lh_migrate_source_request_cb(void *ignored, PurpleRequestFields *fields)
{
    PurpleRequestFields *request;
    PurpleRequestFieldGroup *group;
    PurpleRequestField *field;

    source_account = purple_request_fields_get_account(fields,
                     "migrate_source_acct");
    valid_target_prpl_id = purple_account_get_protocol_id(source_account);

    /* It seems Purple is super-picky about the order of these first three calls */
    /* create a request */
    request = purple_request_fields_new();

    /* now create a field group */
    group = purple_request_field_group_new(NULL);
    /* and add that group to the request created above */
    purple_request_fields_add_group(request, group);

    /* create a field */
    field = purple_request_field_account_new("migrate_target_acct",
            _("Account"), NULL);

    /* mark the field as required */
    purple_request_field_set_required(field, TRUE);

    /* filter this list so that only accounts with the same prpl as the
     * source account can be chosen as a destination */
    purple_request_field_account_set_filter(field, lh_migrate_filter);

    /* add the field to the group created above */
    purple_request_field_group_add_field(group, field);

    /* and finally we can create the request */
    purple_request_fields(purple_get_blist(), _("Listhandler - Copying"),
                          _("Choose the account to add buddies to:"), NULL,
                          request, _("_Add"),
                          G_CALLBACK(lh_migrate_target_request_cb), _("_Cancel"),
                          NULL, NULL, NULL, NULL, NULL);

    return;
}
Exemplo n.º 18
0
static PurpleRequestFields *
request_fields_from_personal_details(YahooPersonalDetails *ypd, const char *id)
{
	PurpleRequestFields *fields;
	PurpleRequestFieldGroup *group;
	PurpleRequestField *field;
	int i;
	struct {
		char *id;
		char *text;
		char *value;
	} yfields[] = {
		{"fn", N_("First Name"), ypd->names.first},
		{"ln", N_("Last Name"), ypd->names.last},
		{"nn", N_("Nickname"), ypd->names.nick},
		{"mn", N_("Middle Name"), ypd->names.middle},
		{"hp", N_("Home Phone Number"), ypd->phone.home},
		{"wp", N_("Work Phone Number"), ypd->phone.work},
		{"mo", N_("Mobile Phone Number"), ypd->phone.mobile},
		{NULL, NULL, 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("yname", "", id, FALSE);
	purple_request_field_set_visible(field, FALSE);
	purple_request_field_group_add_field(group, field);

	field = purple_request_field_string_new("yid", "", ypd->id, FALSE);
	purple_request_field_set_visible(field, FALSE);
	purple_request_field_group_add_field(group, field);

	for (i = 0; yfields[i].id; i++) {
		field = purple_request_field_string_new(yfields[i].id, _(yfields[i].text),
				yfields[i].value, FALSE);
		purple_request_field_group_add_field(group, field);
	}

	return fields;
}
Exemplo n.º 19
0
static void plainprpl_change_address(PurpleBlistNode *node, gpointer userdata)
{
	PurpleBuddy *buddy;
	plain_buddy_state *bstate;

	char *request_str;
	const char *addr_str;

	PurpleRequestFields *fields;
	PurpleRequestFieldGroup *group;
	PurpleRequestField *field;

	fields = purple_request_fields_new();
	group = purple_request_field_group_new(NULL);
	purple_request_fields_add_group(fields, group);

	buddy = (PurpleBuddy *) node;
	bstate = purple_buddy_get_protocol_data(buddy);

	if (bstate) {
		addr_str = purple_blist_node_get_string(PURPLE_BLIST_NODE(buddy), "addr_str");
		field = purple_request_field_string_new("addr_str", _("Address"), addr_str, FALSE);
		purple_request_field_string_set_masked(field, FALSE);
		purple_request_field_group_add_field(group, field);

		request_str = g_strdup_printf("Address to reach buddy '%s'.", buddy->name);
		purple_request_fields(buddy->account, "Change Address",
			request_str,
			NULL, fields,
			_("OK"), G_CALLBACK(plainprpl_change_address_ok),
			_("Cancel"), G_CALLBACK(plainprpl_change_address_cancel),
			NULL, NULL, NULL, (void *) buddy
		);
		g_free(request_str);
	} else {
		purple_debug_info("plainprpl", "Buddy %s has no bstate set.\n", buddy->name);
	}
}
Exemplo n.º 20
0
void
lh_migrate_action_cb(PurplePluginAction *action)
{
    PurpleRequestFields *request;
    PurpleRequestFieldGroup *group;
    PurpleRequestField *field;

    /* It seems Purple is super-picky about the order of these first three calls */
    /* create a request */
    request = purple_request_fields_new();

    /* now create a field group */
    group = purple_request_field_group_new(NULL);
    /* and add that group to the request created above */
    purple_request_fields_add_group(request, group);

    /* create a field */
    field = purple_request_field_account_new("migrate_source_acct",
            _("Account"), NULL);

    /* mark the field as required */
    purple_request_field_set_required(field, TRUE);

    /* let's show offline accounts too */
    purple_request_field_account_set_show_all(field, TRUE);

    /* add the field to the group created above */
    purple_request_field_group_add_field(group, field);

    /* and finally we can create the request */
    purple_request_fields(purple_get_blist(), _("Listhandler - Copying"),
                          _("Choose the account to copy from:"), NULL, request,
                          _("C_opy"), G_CALLBACK(lh_migrate_source_request_cb),
                          _("_Cancel"), NULL, NULL, NULL, NULL, NULL);
    return;
}
Exemplo n.º 21
0
void fchat_select_buddies_list(FChatConnection *fchat_conn, const gchar *msg_text, GHashTable *buddies, FChatSelectBuddiesListCb *ok_cb, FChatSelectBuddiesListCb *cancel_cb, void *user_data) {
	PurpleRequestFields *fields;
	PurpleRequestFieldGroup *group;
	PurpleRequestField *field;
	fields = purple_request_fields_new();
	group = purple_request_field_group_new(NULL);
	purple_request_fields_add_group(fields, group);

	field = purple_request_field_list_new("buddies", _("Buddies"));
	purple_request_field_list_set_multi_select(field, TRUE);

	GHashTableIter iter;
	gchar *buddy_host;
	FChatBuddy *buddy;
	g_hash_table_iter_init (&iter, buddies);
	while (g_hash_table_iter_next (&iter, (gpointer *)&buddy_host, (gpointer *)&buddy)) {
		gchar *item = g_strdup_printf("%s (%s)", buddy->host, buddy->alias ? buddy->alias : "");
		purple_request_field_list_add(field, item, buddy);
		g_free(item);
		/*	purple_request_field_list_add_selected(field, item, buddy); */
	}
	purple_request_field_group_add_field(group, field);

	FChatSelectBuddiesListCbData *fchat_select_buddies_list_cb_data = g_new(FChatSelectBuddiesListCbData, 1);
	fchat_select_buddies_list_cb_data->fchat_conn = fchat_conn;
	fchat_select_buddies_list_cb_data->ok_cb = ok_cb;
	fchat_select_buddies_list_cb_data->cancel_cb = cancel_cb;
	fchat_select_buddies_list_cb_data->user_data = user_data;

	purple_request_fields(fchat_conn->gc, _("Select buddies"),
		msg_text, _("Use Ctrl or Shift keys for multiply select"), fields,
		_("Ok"), G_CALLBACK(fchat_select_buddies_list_ok_cb),
		_("Cancel"), G_CALLBACK(fchat_select_buddies_list_cancel_cb),
		fchat_conn->gc->account, NULL, NULL,
		fchat_select_buddies_list_cb_data);
}
Exemplo n.º 22
0
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),
		_("Cancel"), NULL,
		purple_request_cpar_from_connection(gc), gc);
}
Exemplo n.º 23
0
gpointer
fb_util_request_buddy(PurpleConnection *gc, const gchar *title,
                      const gchar *primary, const gchar *secondary,
                      GSList *select, gboolean multi, GCallback ok_cb,
		      GCallback cancel_cb, gpointer data)
{
	const gchar *alias;
	const gchar *name;
	gchar *str;
	GList *items = NULL;
	gpointer *mata;
	GSList *buddies;
	GSList *l;
	PurpleAccount *acct;
	PurpleRequestCommonParameters *cpar;
	PurpleRequestField *field;
	PurpleRequestFieldGroup *group;
	PurpleRequestFields *fields;

	mata = g_new0(gpointer, 3);
	mata[0] = ok_cb;
	mata[1] = cancel_cb;
	mata[2] = data;

	acct = purple_connection_get_account(gc);
	buddies = purple_blist_find_buddies(acct, NULL);
	buddies = g_slist_sort(buddies, (GCompareFunc) g_ascii_strcasecmp);

	fields = purple_request_fields_new();
	group = purple_request_field_group_new(NULL);
	purple_request_fields_add_group(fields, group);

	field = purple_request_field_list_new("buddy", NULL);
	purple_request_field_list_set_multi_select(field, multi);
	purple_request_field_set_required(field, TRUE);
	purple_request_field_group_add_field(group, field);

	for (l = buddies; l != NULL; l = l->next) {
		name = purple_buddy_get_name(l->data);
		alias = purple_buddy_get_alias(l->data);
		str = g_strdup_printf("%s (%s)", alias, name);
		purple_request_field_list_add_icon(field, str, NULL, l->data);
		g_free(str);
	}

	for (l = select; l != NULL; l = l->next) {
		name = purple_buddy_get_name(l->data);
		alias = purple_buddy_get_alias(l->data);
		str = g_strdup_printf("%s (%s)", alias, name);
		items = g_list_append(items, str);
	}

	purple_request_field_list_set_selected(field, items);
	g_slist_free(buddies);
	g_list_free_full(items, g_free);

	cpar = purple_request_cpar_from_connection(gc);
	return purple_request_fields(gc, title, primary, secondary, fields,
	                             _("Ok"),
	                             G_CALLBACK(fb_util_request_buddy_ok),
				     _("Cancel"),
	                             G_CALLBACK(fb_util_request_buddy_cancel),
				     cpar, mata);
}
Exemplo n.º 24
0
/*------------------------------------------------------------------------
 * Display and update the user's profile.
 *
 *  @param action	The action object
 */
static void mxit_profile_action( PurplePluginAction* action )
{
	PurpleConnection*			gc		= (PurpleConnection*) action->context;
	struct MXitSession*			session	= purple_connection_get_protocol_data( gc );
	struct MXitProfile*			profile	= session->profile;

	PurpleRequestFields*		fields	= NULL;
	PurpleRequestField*			field	= NULL;

	purple_debug_info( MXIT_PLUGIN_ID, "mxit_profile_action\n" );

	/* ensure that we actually have the user's profile information */
	if ( !profile ) {
		/* no profile information yet, so we cannot update */
		mxit_popup( PURPLE_NOTIFY_MSG_WARNING, _( "Profile" ), _( "Your profile information is not yet retrieved. Please try again later." ) );
		return;
	}

	fields = purple_request_fields_new();

	/* Public information - what other users can see */
	{
		PurpleRequestFieldGroup* public_group = purple_request_field_group_new( "Public information" );

		/* display name */
		field = purple_request_field_string_new( "name", _( "Display Name" ), profile->nickname, FALSE );
		purple_request_field_group_add_field( public_group, field );

		/* birthday */
		field = purple_request_field_string_new( "bday", _( "Birthday" ), profile->birthday, FALSE );
		purple_request_field_group_add_field( public_group, field );
		if ( profile->flags & CP_PROF_DOBLOCKED )
			purple_request_field_set_sensitive( field, FALSE );

		/* gender */
		field = purple_request_field_choice_new( "male", _( "Gender" ), GINT_TO_POINTER(profile->male ? 1 : 0));
		purple_request_field_choice_add( field, _( "Female" ), GINT_TO_POINTER(0));
		purple_request_field_choice_add( field, _( "Male" ), GINT_TO_POINTER(1));
		purple_request_field_group_add_field( public_group, field );

		/* first name */
		field = purple_request_field_string_new( "firstname", _( "First Name" ), profile->firstname, FALSE );
		purple_request_field_group_add_field( public_group, field );

		/* last name */
		field = purple_request_field_string_new( "lastname", _( "Last Name" ), profile->lastname, FALSE );
		purple_request_field_group_add_field( public_group, field );

		/* about me */
		field = purple_request_field_string_new( "aboutme", _( "About Me" ), profile->aboutme, FALSE);
		purple_request_field_group_add_field( public_group, field );

		/* where I live */
		field = purple_request_field_string_new( "whereami", _( "Where I Live" ), profile->whereami, FALSE);
		purple_request_field_group_add_field( public_group, field );

		/* relationship status */
		field = purple_request_field_list_new( "relationship", _( "Relationship Status" ) );
		purple_request_field_list_set_multi_select( field, FALSE );
		purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_UNKNOWN ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_UNKNOWN ) );
		purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_DONTSAY ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_DONTSAY ) );
		purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_SINGLE ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_SINGLE ) );
		purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_INVOLVED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_INVOLVED ) );
		purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_ENGAGED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_ENGAGED ) );
		purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_MARRIED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_MARRIED ) );
		purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_COMPLICATED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_COMPLICATED ) );
		purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_WIDOWED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_WIDOWED ) );
		purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_SEPARATED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_SEPARATED ) );
		purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_DIVORCED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_DIVORCED ) );
		purple_request_field_list_add_selected( field, mxit_relationship_to_name( profile->relationship ) );
		purple_request_field_group_add_field( public_group, field );

		purple_request_fields_add_group( fields, public_group );
	}

	/* Private information - what only MXit can see */
	{
		PurpleRequestFieldGroup* private_group = purple_request_field_group_new( "Private information" );

		/* title */
		field = purple_request_field_string_new( "title", _( "Title" ), profile->title, FALSE );
		purple_request_field_group_add_field( private_group, field );

		/* email */
		field = purple_request_field_string_new( "email", _( "Email" ), profile->email, FALSE );
		purple_request_field_group_add_field( private_group, field );

		/* mobile number */
		field = purple_request_field_string_new( "mobilenumber", _( "Mobile Number" ), profile->mobilenr, FALSE );
		purple_request_field_group_add_field( private_group, field );

		/* is searchable */
		field = purple_request_field_bool_new( "searchable", _( "Can be searched" ), ( ( profile->flags & CP_PROF_NOT_SEARCHABLE ) == 0) );
		purple_request_field_group_add_field( private_group, field );

		/* is suggestable */
		field = purple_request_field_bool_new( "suggestable", _( "Can be suggested" ), ( ( profile->flags & CP_PROF_NOT_SUGGESTABLE ) == 0 ) );
		purple_request_field_group_add_field( private_group, field );

		purple_request_fields_add_group( fields, private_group );
	}

	/* (reference: "libpurple/request.h") */
	purple_request_fields( gc, _( "Profile" ), _( "Update your MXit Profile" ), NULL, fields, _( "Set" ),
			G_CALLBACK( mxit_profile_cb ), _( "Cancel" ), NULL, purple_request_cpar_from_connection(gc), gc );
}
Exemplo n.º 25
0
void BuddyList::request_add_chat(PurpleAccount *account, PurpleGroup *group,
    const char *alias, const char *name)
{
  if (!CheckAnyAccountConnected())
    return;

  if (account) {
    PurpleConnection *gc = purple_account_get_connection(account);

    if (!PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->join_chat) {
      LOG->Message(_("This protocol does not support chat rooms."));
      return;
    }
  }
  else {
    // find an account with chat capabilities
    for (GList *l = purple_connections_get_all(); l; l = l->next) {
      PurpleConnection *gc = reinterpret_cast<PurpleConnection*>(l->data);

      if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->join_chat) {
        account = purple_connection_get_account(gc);
        break;
      }
    }

    if (!account) {
      LOG->Message(_("You are not currently signed on with any "
            "protocols that have the ability to chat."));
      return;
    }
  }

  PurpleRequestFields *fields = purple_request_fields_new();
  PurpleRequestFieldGroup *g = purple_request_field_group_new(NULL);

  purple_request_fields_add_group(fields, g);

  PurpleRequestField *f;
  f = purple_request_field_account_new("account", _("Account"), account);
  purple_request_field_group_add_field(g, f);
  f = purple_request_field_string_new("name", _("Chat name"), NULL, FALSE);
  purple_request_field_group_add_field(g, f);
  f = purple_request_field_string_new("alias", _("Alias"), NULL, FALSE);
  purple_request_field_group_add_field(g, f);

  f = purple_request_field_choice_new("group", _("Group"), 0);
  bool add_default_group = true;
  int dval = 0;
  bool dval_set = false;
  for (PurpleBlistNode *i = purple_blist_get_root(); i; i = i->next)
    if (PURPLE_BLIST_NODE_IS_GROUP(i)) {
      PurpleGroup *cur_group = reinterpret_cast<PurpleGroup*>(i);
      const char *cur_name = purple_group_get_name(cur_group);
      purple_request_field_choice_add(f, cur_name);
      if (!dval_set) {
        if (group == cur_group) {
          purple_request_field_choice_set_default_value(f, dval);
          dval_set = true;
        }
        dval++;
      }
      add_default_group = false;
    }
  if (add_default_group)
      purple_request_field_choice_add(f, _("Chats"));
  purple_request_field_group_add_field(g, f);

  f = purple_request_field_bool_new("autojoin", _("Auto-join"), FALSE);
  purple_request_field_group_add_field(g, f);

  purple_request_fields(NULL, _("Add chat"), NULL, NULL, fields, _("Add"),
      G_CALLBACK(add_chat_ok_cb_), CANCEL_BUTTON_TEXT, NULL, NULL, NULL, NULL,
      this);
}
Exemplo n.º 26
0
static void ggp_pubdir_set_info_dialog(PurpleConnection *gc, int records_count,
	const ggp_pubdir_record *records, int next_offset, void *user_data)
{
	PurpleRequestFields *fields;
	PurpleRequestFieldGroup *group;
	PurpleRequestField *field;
	gsize i;
	const ggp_pubdir_record *record;

	purple_debug_info("gg", "ggp_pubdir_set_info_dialog (record: %d)\n",
		records_count);

	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],
			GINT_TO_POINTER(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));
		}
	}

	purple_request_fields(gc, _("Set User Info"), _("Set User Info"),
		NULL, fields,
		_("OK"), G_CALLBACK(ggp_pubdir_set_info_request),
		_("Cancel"), NULL,
		purple_request_cpar_from_connection(gc), gc);
}
Exemplo n.º 27
0
static GntWidget*
process_pref_frame(PurplePluginPrefFrame *frame)
{
	PurpleRequestField *field;
	PurpleRequestFields *fields;
	PurpleRequestFieldGroup *group = NULL;
	GList *prefs;
	GList *stringlist = NULL;
	GntWidget *ret = NULL;

	fields = purple_request_fields_new();

	for (prefs = purple_plugin_pref_frame_get_prefs(frame); prefs; prefs = prefs->next) {
		PurplePluginPref *pref = prefs->data;
		PurplePrefType type;
		const char *name = purple_plugin_pref_get_name(pref);
		const char *label = purple_plugin_pref_get_label(pref);
		if(name == NULL) {
			if(label == NULL)
				continue;

			if(purple_plugin_pref_get_pref_type(pref) == PURPLE_PLUGIN_PREF_INFO) {
				field = purple_request_field_label_new("*", purple_plugin_pref_get_label(pref));
				purple_request_field_group_add_field(group, field);
			} else {
				group = purple_request_field_group_new(label);
				purple_request_fields_add_group(fields, group);
			}
			continue;
		}

		field = NULL;
		type = purple_prefs_get_pref_type(name);
		if(purple_plugin_pref_get_pref_type(pref) == PURPLE_PLUGIN_PREF_CHOICE) {
			GList *list = purple_plugin_pref_get_choices(pref);
			gpointer current_value = NULL;

			switch(type) {
				case PURPLE_PREF_BOOLEAN:
					current_value = g_strdup_printf("%d", (int)purple_prefs_get_bool(name));
					break;
				case PURPLE_PREF_INT:
					current_value = g_strdup_printf("%d", (int)purple_prefs_get_int(name));
					break;
				case PURPLE_PREF_STRING:
					current_value = g_strdup(purple_prefs_get_string(name));
					break;
				default:
					continue;
			}

			field = purple_request_field_list_new(name, label);
			purple_request_field_list_set_multi_select(field, FALSE);
			while (list && list->next) {
				const char *label = list->data;
				char *value = NULL;
				switch(type) {
					case PURPLE_PREF_BOOLEAN:
						value = g_strdup_printf("%d", GPOINTER_TO_INT(list->next->data));
						break;
					case PURPLE_PREF_INT:
						value = g_strdup_printf("%d", GPOINTER_TO_INT(list->next->data));
						break;
					case PURPLE_PREF_STRING:
						value = g_strdup(list->next->data);
						break;
					default:
						break;
				}
				stringlist = g_list_prepend(stringlist, value);
				purple_request_field_list_add_icon(field, label, NULL, value);
				if (strcmp(value, current_value) == 0)
					purple_request_field_list_add_selected(field, label);
				list = list->next->next;
			}
			g_free(current_value);
		} else {
			switch(type) {
				case PURPLE_PREF_BOOLEAN:
					field = purple_request_field_bool_new(name, label, purple_prefs_get_bool(name));
					break;
				case PURPLE_PREF_INT:
					field = purple_request_field_int_new(name, label, purple_prefs_get_int(name), INT_MIN, INT_MAX);
					break;
				case PURPLE_PREF_STRING:
					field = purple_request_field_string_new(name, label, purple_prefs_get_string(name),
							purple_plugin_pref_get_format_type(pref) & PURPLE_STRING_FORMAT_TYPE_MULTILINE);
					break;
				default:
					break;
			}
		}

		if (field) {
			if (group == NULL) {
				group = purple_request_field_group_new(_("Preferences"));
				purple_request_fields_add_group(fields, group);
			}
			purple_request_field_group_add_field(group, field);
		}
	}

	ret = purple_request_fields(NULL, _("Preferences"), NULL, NULL, fields,
			_("Save"), G_CALLBACK(finch_request_save_in_prefs), _("Cancel"), NULL,
			NULL, NULL);
	g_signal_connect_swapped(G_OBJECT(ret), "destroy", G_CALLBACK(free_stringlist), stringlist);
	return ret;
}
Exemplo n.º 28
0
static void
buddytimezone_createfields_cb(PurpleRequestFields * fields, PurpleBlistNode * data)
{
    purple_debug(PURPLE_DEBUG_INFO, PLUGIN_STATIC_NAME, "buddytimezone_createfields_cb(%p,%p)\n", fields, data);
    PurpleRequestField *field;
    PurpleRequestFieldGroup *group;
    const char *timezone;
    gboolean is_default;

    switch (data->type)
    {
        case PURPLE_BLIST_BUDDY_NODE:
        case PURPLE_BLIST_CONTACT_NODE:
            is_default = FALSE;
            break;
        case PURPLE_BLIST_GROUP_NODE:
            is_default = TRUE;
            break;
        case PURPLE_BLIST_CHAT_NODE:
        case PURPLE_BLIST_OTHER_NODE:
        default:
            /* Not applicable */
            return;
    }

    group = purple_request_field_group_new(NULL);
    purple_request_fields_add_group(fields, group);

    timezone = buddy_get_timezone(data, FALSE, NULL);

    if (ui_ops != NULL && ui_ops->create_menu)
    {
        field =
            purple_request_field_new(CONTROL_NAME,
                                   is_default ? "Default timezone for group" : "Timezone of contact",
                                   PURPLE_REQUEST_FIELD_LIST);
        field->ui_data = ui_ops->create_menu(timezone);
    }
    else
    {
        field =
            purple_request_field_list_new(CONTROL_NAME,
                                        is_default ? "Default timezone for group" :
                                        "Timezone of contact (type to select)");
        purple_request_field_list_set_multi_select(field, FALSE);
        purple_request_field_list_add(field, "<Default>", "");
        purple_request_field_list_add(field, "<Disabled>", DISABLED_FLAG);

        recurse_directory("/usr/share/zoneinfo/", buddy_add_timezone_cb, field);

        if (timezone)
        {
            if (strcmp(timezone, "none") == 0)
                purple_request_field_list_add_selected(field, "<Disabled>");
            else
                purple_request_field_list_add_selected(field, timezone);
        }
        else
            purple_request_field_list_add_selected(field, "<Default>");
    }

    purple_request_field_group_add_field(group, field);
}