Пример #1
0
static void
config_entry_changed_callback(GtkWidget* entry, gpointer data)
{
    GtkWidget* prefs_dialog = data;
    GConfChangeSet* cs;
    gchar* text;
    const gchar* key;

    cs = prefs_dialog_get_change_set(prefs_dialog);

    text = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);

    key = g_object_get_data(entry, "key");

    /* Unset if the string is zero-length, otherwise set */
    if (*text != '\0')
        gconf_change_set_set_string(cs, key, text);
    else
        gconf_change_set_unset(cs, key);

    g_free(text);

    prefs_dialog_update_sensitivity(prefs_dialog);
}
void
gnomegadu_ui_import_userlist_process_line (gchar * line, GConfChangeSet *changeset)
{
	gchar *profile = gnomegadu_conf_get_profile ();
	gchar *profile_path = gnomegadu_conf_find_account_path (profile);
	gchar *conf_path = NULL;
	gchar *tmp = NULL;
	gchar *uin_str = NULL;
	gchar **split_line = NULL;
	gchar *found_path = NULL;
	gchar *line_utf = NULL;
	gint i;
	uuid_t uuid;
	gchar *uuid_str = (gchar *) g_malloc (37);

	line_utf = g_convert (line, strlen (line), "UTF-8", "WINDOWS-1250", NULL, NULL, NULL);

	split_line = g_strsplit (line_utf, ";", 14);
	if (!split_line || !g_strcasecmp ("GG70ExportString,", split_line[0]) || !split_line[6])
	{
		goto end;
	}

	found_path = gnomegadu_conf_contact_path_find_uin (split_line[6]);
	if (!found_path)
	{
		uuid_generate (uuid);
		uuid_unparse (uuid, uuid_str);
		conf_path = g_strconcat (profile_path, "/contacts/", uuid_str, NULL);
		tmp = g_strconcat (conf_path, "/uuid", NULL);
		gconf_change_set_set_string (changeset, tmp, g_strdup (uuid_str));
		g_free (tmp);
	}
	else
	{
		conf_path = g_strdup (found_path);

		tmp = g_strconcat (conf_path, "/uuid", NULL);
		uuid_str = gconf_client_get_string (gconf, tmp, NULL);
		g_free (tmp);
		g_free (found_path);
	}

	for (i = 0; i < g_strv_length (split_line); i++)
	{
		switch (i)
		{
		case 0:	//imie
			tmp = g_strconcat (conf_path, "/first_name", NULL);
			gconf_change_set_set_string (changeset, tmp, g_strdup (split_line[i]));	//moze tu trzeba g_strdup ??
			g_free (tmp);
			break;
		case 1:	//nazwisko
			tmp = g_strconcat (conf_path, "/last_name", NULL);
			gconf_change_set_set_string (changeset, tmp, g_strdup (split_line[i]));	//moze tu trzeba g_strdup ??
			g_free (tmp);
			break;
		case 2:	//pseudo
			tmp = g_strconcat (conf_path, "/nickname", NULL);
			gconf_change_set_set_string (changeset, tmp, g_strdup (split_line[i]));	//moze tu trzeba g_strdup ??
			g_free (tmp);
			break;
		case 3:	//display
			tmp = g_strconcat (conf_path, "/display", NULL);
			gconf_change_set_set_string (changeset, tmp, g_strdup (split_line[i]));	//moze tu trzeba g_strdup ??
			g_free (tmp);
			break;
		case 5:	//group
			tmp = g_strconcat (conf_path, "/group", NULL);
			gconf_change_set_set_string (changeset, tmp, g_strdup (split_line[i]));	//moze tu trzeba g_strdup ??
			g_free (tmp);
			break;
		case 6:	//UIN
			tmp = g_strconcat (conf_path, "/uin", NULL);
			gconf_change_set_set_string (changeset, tmp, g_strdup (split_line[i]));	//moze tu trzeba g_strdup ??
			uin_str = g_strdup (split_line[i]);
			g_free (tmp);
			break;
		}
	}

	gnomegadu_protocol_add_notify (uin_str);

      end:
	g_strfreev (split_line);
	g_free (uin_str);
	g_free (line_utf);
	g_free (profile);
	g_free (profile_path);
	g_free (conf_path);
}