]> saetta.ns0.it Git - solipa/libsolipa/commitdiff
Migrated to evolution-data-server 2.32.
authorAndrea Zagli <azagli@libero.it>
Sat, 22 Jan 2011 10:46:26 +0000 (11:46 +0100)
committerAndrea Zagli <azagli@libero.it>
Sat, 22 Jan 2011 10:46:26 +0000 (11:46 +0100)
configure.ac
src/camelsession.c
src/camelsession.h
src/mail.c
src/solipa.c
tests/mail.c

index c3ccf3c351346cda7b669cda5fa3b904cab0fd42..131ab1676a0a418c767e1cc279aa3d04bc0f366e 100644 (file)
@@ -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.24
+                           camel-provider-1.2 >= 2.32
                            gtk+-2.0 >= 2.20
                            gio-2.0 >= 2.24])
 
index da3892b6b4bab7099b74315d79d437c14346b627..41749d2acd2a89737482cf7f654b90289fa06c02 100644 (file)
 
 #include "camelsession.h"
 
+G_DEFINE_TYPE (SolipaCamelSession, solipa_camel_session, CAMEL_TYPE_SESSION)
+
 static void
-solipa_camel_session_class_init (SolipaCamelSessionClass *solipa_camel_session_class)
+solipa_camel_session_class_init (SolipaCamelSessionClass *class)
 {
-       CamelSessionClass *camel_session_class = CAMEL_SESSION_CLASS (solipa_camel_session_class);
 }
 
-CamelType
-solipa_camel_session_get_type (void)
+static void
+solipa_camel_session_init (SolipaCamelSession *session)
 {
-       static CamelType type = CAMEL_INVALID_TYPE;
-
-       if (type == CAMEL_INVALID_TYPE) {
-               type = camel_type_register (
-                       camel_session_get_type (),
-                       "SolipaCamelSession",
-                       sizeof (SolipaCamelSession),
-                       sizeof (SolipaCamelSessionClass),
-                       (CamelObjectClassInitFunc) solipa_camel_session_class_init,
-                       NULL,
-                       NULL,
-                       NULL);
-       }
-
-       return type;
 }
 
-CamelSession
-*solipa_camel_session_new (const gchar *path)
+CamelSession *
+solipa_camel_session_new (const gchar *path)
 {
        CamelSession *session;
 
-       session = CAMEL_SESSION (camel_object_new (SOLIPA_CAMEL_SESSION_TYPE));
-
+       session = g_object_new (SOLIPA_TYPE_CAMEL_SESSION, NULL);
        camel_session_construct (session, path);
 
        return session;
index 5d5df24b2ce5c04ce100f7a6245cd529d441197c..3915d411afa4e0f4311a822e7481ac7a0c3de37c 100644 (file)
 #ifndef __SOLIPA_CAMEL_SESSION_H__
 #define __SOLIPA_CAMEL_SESSION_H__
 
-#include <camel/camel-session.h>
+#include <camel/camel.h>
 
 
 G_BEGIN_DECLS
 
 
-#define SOLIPA_CAMEL_SESSION_TYPE     (solipa_camel_session_get_type ())
-#define SOLIPA_CAMEL_SESSION(obj)     (CAMEL_CHECK_CAST((obj), SOLIPA_CAMEL_SESSION_TYPE, SolipaCamelSession))
-#define SOLIPA_CAMEL_SESSION_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), SOLIPA_CAMEL_SESSION_TYPE, SolipaCamelSessionClass))
-#define SOLIPA_CAMEL_IS_SESSION(o)    (CAMEL_CHECK_TYPE((o), SOLIPA_CAMEL_SESSION_TYPE))
+#define SOLIPA_TYPE_CAMEL_SESSION \
+       (solipa_camel_session_get_type ())
+#define SOLIPA_CAMEL_SESSION(obj) \
+       (G_TYPE_CHECK_INSTANCE_CAST \
+       ((obj), SOLIPA_TYPE_CAMEL_SESSION, SolipaCamelSession))
+#define SOLIPA_CAMEL_SESSION_CLASS(cls) \
+       (G_TYPE_CHECK_CLASS_CAST \
+       ((cls), SOLIPA_TYPE_CAMEL_SESSION, SolipaCamelSessionClass))
+#define SOLIPA_IS_CAMEL_SESSION(obj) \
+       (G_TYPE_CHECK_INSTANCE_TYPE \
+       ((obj), SOLIPA_TYPE_CAMEL_SESSION))
+#define SOLIPA_IS_CAMEL_SESSION_CLASS(cls) \
+       (G_TYPE_CHECK_CLASS_TYPE \
+       ((cls), SOLIPA_TYPE_CAMEL_SESSION))
+#define SOLIPA_CAMEL_SESSION_GET_CLASS(obj) \
+       (G_TYPE_INSTANCE_GET_CLASS \
+       ((obj), SOLIPA_TYPE_CAMEL_SESSION, SolipaCamelSessionClass))
+
+G_BEGIN_DECLS
 
 typedef struct _SolipaCamelSession SolipaCamelSession;
 typedef struct _SolipaCamelSessionClass SolipaCamelSessionClass;
 
-struct _SolipaCamelSession
-       {
-               CamelSession parent_object;
-       };
-
-struct _SolipaCamelSessionClass
-       {
-               CamelSessionClass parent_class;
-       };
+struct _SolipaCamelSession {
+       CamelSession parent;
+};
 
-CamelType solipa_camel_session_get_type (void);
+struct _SolipaCamelSessionClass {
+       CamelSessionClass parent_class;
+};
 
+GType solipa_camel_session_get_type (void);
 CamelSession *solipa_camel_session_new (const gchar *path);
 
 
index 975ad860a4a0a43d3ce6cd72e2e78b710f5cb980..0c6022378678acc8a53334b66f64d1d2b0bba5bc 100644 (file)
@@ -305,6 +305,8 @@ solipa_mail_get_as_string (SolipaMail *mail)
 {
        gchar *ret;
 
+       GError *error;
+
        CamelMimeMessage *msg;
 
        CamelStream *mem;
@@ -319,20 +321,31 @@ solipa_mail_get_as_string (SolipaMail *mail)
                }
 
        mem = camel_stream_mem_new ();
-       camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (msg), mem);
-       if (camel_stream_reset (mem) < 0)
+       error = NULL;
+       camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (msg), mem, &error);
+       if (error != NULL)
+               {
+                       g_warning ("Unable to to write to stream: %s.",
+                                  error != NULL && error->message != NULL ? error->message : "no details");
+                       return NULL;
+               }
+       error = NULL;
+       if (camel_stream_reset (mem, &error) < 0)
                {
-                       g_warning ("Unable to reset the camel mem stream.");
+                       g_warning ("Unable to reset the camel mem stream: %s.",
+                                  error != NULL && error->message != NULL ? error->message : "no details");
                        return NULL;
                }
 
        ret = g_strdup ("");
        while (!camel_stream_eos (mem))
                {
-                       nb_read = camel_stream_read (mem, tmp_buf, sizeof (tmp_buf));
+                       error = NULL;
+                       nb_read = camel_stream_read (mem, tmp_buf, sizeof (tmp_buf), &error);
                        if (nb_read < 0)
                                {
-                                       g_warning ("Error on camel stream reading.");
+                                       g_warning ("Error on camel stream reading: %s.",
+                                                  error != NULL && error->message != NULL ? error->message : "no details");
                                        break;
                                }
                        else if (nb_read > 0)
@@ -349,9 +362,11 @@ solipa_mail_send (SolipaMail *mail, const gchar *url)
 {
        SolipaMailPrivate *priv;
 
+       GError *error;
+       gboolean ret;
+
        CamelMimeMessage *msg;
 
-       CamelException *ex;
        CamelInternetAddress *from, *addr, *to;
        CamelService *trans;
 
@@ -372,25 +387,27 @@ solipa_mail_send (SolipaMail *mail, const gchar *url)
                        return;
                }
 
-       ex = camel_exception_new ();
-
        if (camel_mime_message_get_from (msg) == NULL)
                {
-                       camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, "Cannot send message: no from address set.");
+                       g_warning ("Cannot send message: no from address set.");
                        return;
                }
 
-       trans = camel_session_get_service (solipa_get_camel_session (priv->solipa), url, CAMEL_PROVIDER_TRANSPORT, ex);
-       if (camel_exception_is_set (ex))
+       error = NULL;
+       trans = camel_session_get_service (solipa_get_camel_session (priv->solipa), url, CAMEL_PROVIDER_TRANSPORT, &error);
+       if (trans == NULL || error != NULL)
                {
-                       g_warning ("Not service: %s", camel_exception_get_description (ex));
+                       g_warning ("Not service: %s",
+                                  error != NULL && error->message != NULL ? error->message : "no details");
                        return;
                }
 
-       gboolean ret = camel_service_connect (trans, ex);
-       if (camel_exception_is_set (ex))
+       error = NULL;
+       ret = camel_service_connect (trans, &error);
+       if (!ret || error != NULL)
                {
-                       g_warning ("Not connected: %s", camel_exception_get_description (ex));
+                       g_warning ("Not connected: %s",
+                                  error != NULL && error->message != NULL ? error->message : "no details");
                        goto noconnect;
                }
 
@@ -404,12 +421,17 @@ solipa_mail_send (SolipaMail *mail, const gchar *url)
                        }
        }
 
-       camel_transport_send_to (CAMEL_TRANSPORT (trans), msg, CAMEL_ADDRESS (camel_mime_message_get_from (msg)), CAMEL_ADDRESS (to), ex);
-       camel_object_unref (to);
+       ret = camel_transport_send_to (CAMEL_TRANSPORT (trans), msg, CAMEL_ADDRESS (camel_mime_message_get_from (msg)), CAMEL_ADDRESS (to), &error);
+       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);
        camel_service_disconnect (trans, FALSE, NULL);
 
 noconnect:
-       camel_object_unref (trans);
+       g_object_unref (trans);
 }
 
 /* PRIVATE */
index 4556771ea880bf495361be3635ad4bb5b2a36ecb..86ac2e79893ed25642aae2c226c2acfdc9476862 100644 (file)
@@ -25,6 +25,7 @@
 #include <gtk/gtk.h>
 
 #include "solipa.h"
+#include "camelsession.h"
 #include "utils.h"
 
 static void solipa_class_init (SolipaClass *class);
@@ -92,7 +93,6 @@ Solipa
        solipa = SOLIPA (g_object_new (solipa_get_type (), NULL));
        priv = SOLIPA_GET_PRIVATE (solipa);
 
-#ifndef G_OS_WIN32
        /* creo la directory temporanea per camel */
        camel_tmpdir = g_mkdtemp (g_build_filename (g_get_tmp_dir (), g_strdup ("solipa-camel-XXXXXX"), NULL));
 
@@ -101,7 +101,6 @@ Solipa
        camel_provider_init ();
 
        priv->camel_session = solipa_camel_session_new (camel_tmpdir);
-#endif
 
        /* gui */
 #ifdef G_OS_WIN32
index 0c112f697ccfbab4a0a1b11ab0bbe106d1226ed2..26f66737f1e28221d370a25b4e2a07561691aedd 100644 (file)
@@ -42,7 +42,7 @@ main (int argc, char **argv)
 
        camel_internet_address_add (addr, "tux", "tux@sid-sviluppo.miodominio.it");
        solipa_mail_add_recipient (smail, addr, SOLIPA_MAIL_RECIPIENT_TYPE_TO);
-       camel_object_unref (addr);
+       g_object_unref (addr);
 
        solipa_mail_set_body (smail, "This is the text\nof the email\n that i'm trying to send to myself.\n\nBye bye\n\nSee you later.", NULL);