aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addressbook/ChangeLog7
-rw-r--r--addressbook/gui/widgets/eab-gui-util.c4
-rw-r--r--e-util/ChangeLog7
-rw-r--r--e-util/e-util.c43
-rw-r--r--e-util/e-util.h2
5 files changed, 37 insertions, 26 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 49fba26257..f93fe4162c 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,10 @@
+2008-04-23 Milan Crha <mcrha@redhat.com>
+
+ ** Part of fix for bug #529254
+
+ * gui/widgets/eab-gui-util.c: (save_it):
+ Prototype and return value of e_write_file_uri has been changed.
+
2008-04-22 Matthew Barnes <mbarnes@redhat.com>
** Fixes bug #529465
diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c
index 27b81e7110..6b8973637b 100644
--- a/addressbook/gui/widgets/eab-gui-util.c
+++ b/addressbook/gui/widgets/eab-gui-util.c
@@ -353,7 +353,6 @@ save_it(GtkWidget *widget, SaveAsInfo *info)
{
const char *filename;
char *uri;
- gint error = 0;
gint response = 0;
@@ -370,8 +369,7 @@ save_it(GtkWidget *widget, SaveAsInfo *info)
}
}
- error = e_write_file_uri (uri, info->vcard);
- if (error != 0) {
+ if (!e_write_file_uri (uri, info->vcard)) {
char *err_str_ext;
if (info->has_multiple_contacts) {
/* more than one, finding the total number of contacts might
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index 023c708dcc..af0027fd51 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,10 @@
+2008-04-23 Milan Crha <mcrha@redhat.com>
+
+ ** Fix for bug #529254
+
+ * e-util.c: (e_write_file_uri): Save file properly.
+ Handle either URI or filename. Return success or failure, not gint.
+
2008-04-22 Matthew Barnes <mbarnes@redhat.com>
* Makefile.am:
diff --git a/e-util/e-util.c b/e-util/e-util.c
index f1bc8968c4..161a65789a 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -161,19 +161,29 @@ e_int_compare (gconstpointer x, gconstpointer y)
return (nx == ny) ? 0 : (nx < ny) ? -1 : 1;
}
-gint
+gboolean
e_write_file_uri (const gchar *filename, const gchar *data)
{
- gsize length = strlen (data);
- gssize bytes;
+ gboolean res;
+ gsize length;
GFile *file;
GOutputStream *stream;
GError *error = NULL;
- file = g_file_new_for_path (filename);
+ g_return_val_if_fail (filename != NULL, FALSE);
+ g_return_val_if_fail (data != NULL, FALSE);
+
+ length = strlen (data);
+
+ /* if it is uri, then create file for uri, otherwise for path */
+ if (strstr (filename, "://"))
+ file = g_file_new_for_uri (filename);
+ else
+ file = g_file_new_for_path (filename);
+
if (!file) {
g_warning ("Couldn't save item");
- return 1;
+ return FALSE;
}
stream = G_OUTPUT_STREAM (g_file_replace (file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &error));
@@ -188,25 +198,14 @@ e_write_file_uri (const gchar *filename, const gchar *data)
if (error)
g_error_free (error);
- return 1;
+ return FALSE;
}
- while (length > 0) {
- bytes = g_output_stream_write_all (stream, data, length, NULL, NULL, &error);
- if (bytes > 0 && !error) {
- length -= bytes;
- data += bytes;
- } else {
- g_warning ("Couldn't save item%s%s", error ? ": " : "", error ? error->message : "");
+ res = g_output_stream_write_all (stream, data, length, NULL, NULL, &error);
- if (error)
- g_error_free (error);
-
- g_output_stream_close (stream, NULL, NULL);
- g_object_unref (stream);
-
- return 1;
- }
+ if (error) {
+ g_warning ("Couldn't save item: %s", error->message);
+ g_clear_error (&error);
}
g_output_stream_close (stream, NULL, &error);
@@ -217,7 +216,7 @@ e_write_file_uri (const gchar *filename, const gchar *data)
g_error_free (error);
}
- return 0;
+ return res;
}
/* Include build marshalers */
diff --git a/e-util/e-util.h b/e-util/e-util.h
index 0f76e9e29e..5bdb218296 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -55,7 +55,7 @@ gint e_collate_compare (gconstpointer x,
gconstpointer y);
gint e_int_compare (gconstpointer x,
gconstpointer y);
-gint e_write_file_uri (const gchar *filename,
+gboolean e_write_file_uri (const gchar *filename,
const gchar *data);
/* This only makes a filename safe for usage as a filename.