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])
#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;
#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);
{
gchar *ret;
+ GError *error;
+
CamelMimeMessage *msg;
CamelStream *mem;
}
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)
{
SolipaMailPrivate *priv;
+ GError *error;
+ gboolean ret;
+
CamelMimeMessage *msg;
- CamelException *ex;
CamelInternetAddress *from, *addr, *to;
CamelService *trans;
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;
}
}
}
- 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 */
#include <gtk/gtk.h>
#include "solipa.h"
+#include "camelsession.h"
#include "utils.h"
static void solipa_class_init (SolipaClass *class);
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));
camel_provider_init ();
priv->camel_session = solipa_camel_session_new (camel_tmpdir);
-#endif
/* gui */
#ifdef G_OS_WIN32
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);