From: Andrea Zagli Date: Tue, 21 Dec 2010 14:39:31 +0000 (+0100) Subject: Correzioni varie. X-Git-Tag: Pre_EvolutionDataServer_2.32~11 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=596495a2939afc7c2aeddbe761890069b1c9a84d;p=solipa%2Flibsolipa Correzioni varie. Sotto windows non esiste la funzione mkdtemp. Sotto windows non funzionano solipa_mail_send e solipa_gtktreemodel_to_csv_gui. --- diff --git a/configure.ac b/configure.ac index 67c870f..c3ccf3c 100644 --- a/configure.ac +++ b/configure.ac @@ -30,7 +30,7 @@ AC_PROG_RANLIB PKG_CHECK_MODULES(SOLIPA, [gobject-2.0 >= 2.24.0 glib-2.0 >= 2.24.0 libgdaex >= 0.2.2 - camel-provider-1.2 >= 2.30 + camel-provider-1.2 >= 2.24 gtk+-2.0 >= 2.20 gio-2.0 >= 2.24]) diff --git a/data/libsolipa/gui/libsolipa.ui b/data/libsolipa/gui/libsolipa.ui index ad6bd4f..f738f8d 100644 --- a/data/libsolipa/gui/libsolipa.ui +++ b/data/libsolipa/gui/libsolipa.ui @@ -151,6 +151,16 @@ + + + + + + + + + + 5 Esporta CSV @@ -424,10 +434,10 @@ True vertical + False False - False save - False + False @@ -495,14 +505,4 @@ button2 - - - - - - - - - - diff --git a/src/Makefile.am b/src/Makefile.am index 880797e..b663c20 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,7 +3,8 @@ guidir = $(datadir)/$(PACKAGE)/gui LIBS = $(SOLIPA_LIBS) AM_CPPFLAGS = $(SOLIPA_CFLAGS) \ - -DGUIDIR=\""$(guidir)"\" + -DGUIDIR=\""$(guidir)"\" \ + -DG_LOG_DOMAIN=\"Solipa\" lib_LTLIBRARIES = libsolipa.la diff --git a/src/allegato.h b/src/allegato.h index 4d0ba30..2bae299 100644 --- a/src/allegato.h +++ b/src/allegato.h @@ -22,7 +22,7 @@ #include #include -#include +#include "solipa.h" G_BEGIN_DECLS diff --git a/src/mail.c b/src/mail.c index 3b922ca..975ad86 100644 --- a/src/mail.c +++ b/src/mail.c @@ -386,8 +386,9 @@ solipa_mail_send (SolipaMail *mail, const gchar *url) g_warning ("Not service: %s", camel_exception_get_description (ex)); return; } + gboolean ret = camel_service_connect (trans, ex); - if (camel_exception_is_set(ex)) + if (camel_exception_is_set (ex)) { g_warning ("Not connected: %s", camel_exception_get_description (ex)); goto noconnect; diff --git a/src/mail.h b/src/mail.h index 1cfbce2..a61584c 100644 --- a/src/mail.h +++ b/src/mail.h @@ -24,7 +24,7 @@ #include -#include +#include "solipa.h" G_BEGIN_DECLS diff --git a/src/solipa.c b/src/solipa.c index 891c428..4a6a88e 100644 --- a/src/solipa.c +++ b/src/solipa.c @@ -25,6 +25,7 @@ #include #include "solipa.h" +#include "utils.h" static void solipa_class_init (SolipaClass *class); static void solipa_init (Solipa *solipa); @@ -92,7 +93,7 @@ Solipa priv = SOLIPA_GET_PRIVATE (solipa); /* creo la directory temporanea per camel */ - camel_tmpdir = mkdtemp (g_build_filename (g_get_tmp_dir (), g_strdup ("solipa-camel-XXXXXX"), NULL)); + camel_tmpdir = g_mkdtemp (g_build_filename (g_get_tmp_dir (), g_strdup ("solipa-camel-XXXXXX"), NULL)); /* inizializzo camel */ camel_init (camel_tmpdir, FALSE); @@ -106,18 +107,18 @@ Solipa gchar *moddir; gchar *p; - moddir = g_win32_get_package_installation_directory_of_module (NULL); + moddir = g_win32_get_package_installation_directory_of_module (NULL); - p = strrchr (moddir, G_DIR_SEPARATOR); - if (p != NULL -     && (g_ascii_strcasecmp (p + 1, "src") == 0 -         || g_ascii_strcasecmp (p + 1, ".libs") == 0)) + p = strrchr (moddir, G_DIR_SEPARATOR); + if (p != NULL + && (g_ascii_strcasecmp (p + 1, "src") == 0 + || g_ascii_strcasecmp (p + 1, ".libs") == 0)) { - solipa->guidir = g_strdup (GUIDIR); + priv->guidir = g_strdup (GUIDIR); } else { - solipa->guidir = g_build_filename (moddir, "share", PACKAGE, "gui", NULL); + priv->guidir = g_build_filename (moddir, "share", PACKAGE, "gui", NULL); } #else @@ -243,7 +244,7 @@ const gchar priv = SOLIPA_GET_PRIVATE (solipa); - return g_strdup (priv->guifile); + return (const gchar *)g_strdup (priv->guifile); } GtkBuilder diff --git a/src/utils.c b/src/utils.c index e0b9fb7..6087e46 100644 --- a/src/utils.c +++ b/src/utils.c @@ -276,6 +276,12 @@ solipa_gtktreemodel_to_csv_gui (Solipa *solipa, GtkTreeModel *model, builder = solipa_get_gtkbuilder (solipa); + if (!GTK_IS_BUILDER (builder)) + { + g_warning ("GtkBuilder not initialized."); + return; + } + error = NULL; gtk_builder_add_objects_from_file (builder, solipa_get_guifile (solipa), @@ -300,9 +306,9 @@ solipa_gtktreemodel_to_csv_gui (Solipa *solipa, GtkTreeModel *model, "toggled", G_CALLBACK (solipa_fixed_toggled), (gpointer)store); g_signal_connect (gtk_builder_get_object (builder, "button3"), - "clicked", G_CALLBACK (solipa_on_btn_unselect_all_clicked), (gpointer *)store); + "clicked", G_CALLBACK (solipa_on_btn_unselect_all_clicked), (gpointer)store); g_signal_connect (gtk_builder_get_object (builder, "button4"), - "clicked", G_CALLBACK (solipa_on_btn_select_all_clicked), (gpointer *)store); + "clicked", G_CALLBACK (solipa_on_btn_select_all_clicked), (gpointer)store); gtk_list_store_clear (store); @@ -458,3 +464,87 @@ gchar return ret; } + +/** + * This function is copied from + * http://bugzilla.gnome.org/show_bug.cgi?id=524831. + * + * If/when this function gets added to glib, it can be removed from + * sources. + * + * + * g_mkdtemp: + * @tmpl: template directory name + * + * Creates a temporary directory. See the mkdtemp() documentation + * on most UNIX-like systems. + * + * The parameter is a string that should follow the rules for + * mkdtemp() templates, i.e. contain the string "XXXXXX". g_mkdtemp() + * is slightly more flexible than mkdtemp() in that the sequence does + * not have to occur at the very end of the template. The X string + * will be modified to form the name of a directory that didn't + * already exist. The string should be in the GLib file name + * encoding. Most importantly, on Windows it should be in UTF-8. + * + * Return value: If a temporary directory was successfully created, + * @tmpl will be returned with the XXXXXX string modified in such a + * way as to make the path unique. In case of errors, %NULL is + * returned. + */ +gchar * +g_mkdtemp (gchar *tmpl) +{ + static const char letters[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + static const int NLETTERS = sizeof (letters) - 1; + static int counter = 0; + char *XXXXXX; + GTimeVal tv; + glong value; + int count; + + /* find the last occurrence of "XXXXXX" */ + XXXXXX = g_strrstr (tmpl, "XXXXXX"); + + if (!XXXXXX || strncmp (XXXXXX, "XXXXXX", 6)) + { + errno = EINVAL; + return NULL; + } + + /* Get some more or less random data. */ + g_get_current_time (&tv); + value = (tv.tv_usec ^ tv.tv_sec) + counter++; + + for (count = 0; count < 100; value += 7777, ++count) + { + glong v = value; + + /* Fill in the random bits. */ + XXXXXX[0] = letters[v % NLETTERS]; + v /= NLETTERS; + XXXXXX[1] = letters[v % NLETTERS]; + v /= NLETTERS; + XXXXXX[2] = letters[v % NLETTERS]; + v /= NLETTERS; + XXXXXX[3] = letters[v % NLETTERS]; + v /= NLETTERS; + XXXXXX[4] = letters[v % NLETTERS]; + v /= NLETTERS; + XXXXXX[5] = letters[v % NLETTERS]; + + /* tmpl is in UTF-8 on Windows, thus use g_mkdir() */ + if (g_mkdir (tmpl, 0700) == 0) + return tmpl; + + if (errno != EEXIST) + /* Any other error will apply also to other names we might + * try, and there are 2^32 or so of them, so give up now. + */ + return NULL; + } + + /* We got out of the loop because we ran out of combinations to try. */ + errno = EEXIST; + return NULL; +} diff --git a/src/utils.h b/src/utils.h index 3bac23d..e73d307 100644 --- a/src/utils.h +++ b/src/utils.h @@ -21,7 +21,7 @@ #include -#include +#include "solipa.h" G_BEGIN_DECLS @@ -44,6 +44,8 @@ void solipa_gtktreemodel_to_csv_gui (Solipa *solipa, GtkTreeModel *model, gchar *solipa_format_money (gdouble number, gint decimals, gboolean with_currency_symbol); +gchar *g_mkdtemp (gchar *tmpl); + G_END_DECLS