Compilazione condizionale per evolution-data-server >= 3.
authorAndrea Zagli <azagli@libero.it>
Mon, 29 Aug 2011 08:37:43 +0000 (10:37 +0200)
committerAndrea Zagli <azagli@libero.it>
Mon, 29 Aug 2011 08:37:43 +0000 (10:37 +0200)
refs #38

configure.ac
src/Makefile.am
src/mail.c
tests/Makefile.am

index 1b8ce262c8b409db339caa42bdd91e597d69bcbb..310c23871737e93bf48aaaed1714a33e1728fd74 100644 (file)
@@ -6,7 +6,7 @@ AC_INIT([libsolipa], [0.4.0], [azagli@libero.it])
 AC_CONFIG_SRCDIR([src/solipa.c])
 AC_CONFIG_HEADER([config.h])
 
-AM_INIT_AUTOMAKE
+AM_INIT_AUTOMAKE(-Wall)
 
 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
 
@@ -33,7 +33,6 @@ AC_PROG_RANLIB
 PKG_CHECK_MODULES(SOLIPA, [gobject-2.0 >= 2.24.0
                            glib-2.0 >= 2.26.0
                            libgdaex >= 0.3.0
-                           camel-provider-1.2 >= 2.32
                            libgtkform >= 0.3.0
                            gtk+-2.0 >= 2.20
                            gio-2.0 >= 2.24])
@@ -41,6 +40,18 @@ PKG_CHECK_MODULES(SOLIPA, [gobject-2.0 >= 2.24.0
 AC_SUBST(SOLIPA_CFLAGS)
 AC_SUBST(SOLIPA_LIBS)
 
+PKG_CHECK_MODULES(CAMEL, camel-provider-1.2 >= 3, [camel3_found=yes], [camel3_found=no])
+
+if test x$camel3_found = xno; then
+       PKG_CHECK_MODULES(CAMEL, camel-provider-1.2 >= 2.32)
+fi
+
+AC_SUBST(CAMEL_CFLAGS)
+AC_SUBST(CAMEL_LIBS)
+
+AC_SUBST(CAMEL3_FOUND)
+AM_CONDITIONAL(HAVE_CAMEL3, test $camel3_found = yes)
+
 AC_CHECK_PROG(PYTHON_CFLAGS, [python-config], `python-config --cflags`, [-I/c/Python26/include])
 AC_CHECK_PROG(PYTHON_LIBS, [python-config], `python-config --libs`, [-lpthread -lm -L/c/Python26/libs -lpython26])
 AC_SUBST(PYTHON_CFLAGS)
index 83f8750acdd86db80e9c1cd9cc8230b005c2b670..dda206a0d6c2605c84153027b650199f3a3b36cd 100644 (file)
@@ -1,10 +1,19 @@
 guidir = $(datadir)/$(PACKAGE)/gui
 
-LIBS = $(SOLIPA_LIBS)
+LIBS = $(SOLIPA_LIBS) \
+       $(CAMEL_LIBS)
+
+if HAVE_CAMEL3
+CAMEL3 = -DCAMEL3=\"yes\"
+else
+CAMEL3 =
+endif
 
 AM_CPPFLAGS = $(SOLIPA_CFLAGS) \
+              $(CAMEL_CFLAGS) \
               -DGUIDIR=\""$(guidir)"\" \
-              -DG_LOG_DOMAIN=\"Solipa\"
+              -DG_LOG_DOMAIN=\"Solipa\" \
+              $(CAMEL3)
 
 lib_LTLIBRARIES = libsolipa.la \
                   libsolipaooo.la
index cc78e95e1e7a76d8468baffdae175fad1bcf496c..7ae1acf8b87829ed239e5235fb617741c7e1265c 100644 (file)
@@ -326,7 +326,11 @@ solipa_mail_get_as_string (SolipaMail *mail)
 
        mem = camel_stream_mem_new ();
        error = NULL;
+#ifdef CAMEL3
+       camel_data_wrapper_write_to_stream_sync (CAMEL_DATA_WRAPPER (msg), mem, NULL, &error);
+#else
        camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (msg), mem, &error);
+#endif
        if (error != NULL)
                {
                        g_warning ("Unable to to write to stream: %s.",
@@ -345,7 +349,11 @@ solipa_mail_get_as_string (SolipaMail *mail)
        while (!camel_stream_eos (mem))
                {
                        error = NULL;
+#ifdef CAMEL3
+                       nb_read = camel_stream_read (mem, tmp_buf, sizeof (tmp_buf), NULL, &error);
+#else
                        nb_read = camel_stream_read (mem, tmp_buf, sizeof (tmp_buf), &error);
+#endif
                        if (nb_read < 0)
                                {
                                        g_warning ("Error on camel stream reading: %s.",
@@ -435,7 +443,11 @@ solipa_mail_send (SolipaMail *mail, const gchar *url)
                }
 
        error = NULL;
+#ifdef CAMEL3
+       ret = camel_service_connect_sync (trans, &error);
+#else
        ret = camel_service_connect (trans, &error);
+#endif
        if (!ret || error != NULL)
                {
                        g_warning ("Not connected: %s",
@@ -453,14 +465,38 @@ solipa_mail_send (SolipaMail *mail, const gchar *url)
                        }
        }
 
-       ret = camel_transport_send_to (CAMEL_TRANSPORT (trans), msg, CAMEL_ADDRESS (camel_mime_message_get_from (msg)), CAMEL_ADDRESS (to), &error);
+#ifdef CAMEL3
+       ret = camel_transport_send_to_sync (CAMEL_TRANSPORT (trans),
+                                      msg,
+                                      CAMEL_ADDRESS (camel_mime_message_get_from (msg)),
+                                      CAMEL_ADDRESS (to),
+                                      NULL,
+                                      &error);
+#else
+       ret = camel_transport_send_to (CAMEL_TRANSPORT (trans),
+                                      msg,
+                                      CAMEL_ADDRESS (camel_mime_message_get_from (msg)),
+                                      CAMEL_ADDRESS (to),
+                                      &error);
+#endif
        if (!ret || error != NULL)
                {
                        g_warning ("Unable to send the email: %s",
                                   error != NULL && error->message != NULL ? error->message : "no details");
                }
        g_object_unref (to);
+
+       error = NULL;
+#ifdef CAMEL3
+       camel_service_disconnect_sync (trans, FALSE, NULL);
+#else
        camel_service_disconnect (trans, FALSE, NULL);
+#endif
+       if (error != NULL)
+               {
+                       g_warning ("Unable to disconnect: %s",
+                                  error->message != NULL ? error->message : "no details");
+               }
 
 noconnect:
        g_object_unref (trans);
index 4dccda128f3b2cbae61a74b7d771a028ef88c665..e80c512c7a598027a05f1a1dc1ca0a26920b5e93 100644 (file)
@@ -1,10 +1,12 @@
 AM_CPPFLAGS = $(WARN_CFLAGS) \
               $(DISABLE_DEPRECATED_CFLAGS) \
               $(SOLIPA_CFLAGS) \
+              $(CAMEL_CFLAGS) \
               -I$(top_srcdir)/src \
               -DGUIDIR="\"@abs_builddir@\""
 
 LIBS = $(SOLIPA_LIBS) \
+       $(CAMEL_LIBS) \
        -export-dynamic
 
 LDADD = $(top_builddir)/src/libsolipa.la