From 1db95ac56a12fd4250a8cad9f73654f4ba0113e0 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Mon, 29 Nov 2010 10:07:22 +0100 Subject: [PATCH] Spostata l'inizializzazione di libcaml in solipa. Aggiunto il test (da implementare) per SolipaMail. --- .gitignore | 1 + Makefile.am | 2 +- configure.ac | 1 + src/libsolipa.h | 2 ++ src/mail.c | 5 ----- src/solipa.c | 21 ++++++++++++++++++++- tests/Makefile.am | 12 ++++++++++++ tests/mail.c | 30 ++++++++++++++++++++++++++++++ 8 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 tests/Makefile.am create mode 100644 tests/mail.c diff --git a/.gitignore b/.gitignore index bdde395..e86113a 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,4 @@ stamp-it intltool-* Rules-quot *.exe +tests/mail diff --git a/Makefile.am b/Makefile.am index 6ff19b6..be8c6a8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = src data +SUBDIRS = src data tests ACLOCAL_AMFLAGS = -I m4 diff --git a/configure.ac b/configure.ac index 9e37eef..6ca328c 100644 --- a/configure.ac +++ b/configure.ac @@ -52,5 +52,6 @@ AC_CONFIG_FILES([ data/Makefile data/libsolipa/Makefile data/libsolipa/gui/Makefile + tests/Makefile ]) AC_OUTPUT diff --git a/src/libsolipa.h b/src/libsolipa.h index 3eceb84..81b2379 100644 --- a/src/libsolipa.h +++ b/src/libsolipa.h @@ -20,5 +20,7 @@ #define __LIBSOLIPA_H__ #include +#include +#include #endif /* __LIBSOLIPA_H__ */ diff --git a/src/mail.c b/src/mail.c index 37ec693..23cd481 100644 --- a/src/mail.c +++ b/src/mail.c @@ -271,11 +271,6 @@ solipa_mail_get_as_string (SolipaMail *mail) return NULL; } - g_thread_init (NULL); - - camel_init (NULL, FALSE); - camel_provider_init (); - msg = camel_mime_message_new (); camel_mime_message_set_subject (msg, priv->subject); diff --git a/src/solipa.c b/src/solipa.c index 1e940f9..46072af 100644 --- a/src/solipa.c +++ b/src/solipa.c @@ -20,6 +20,9 @@ #include #endif +#include +#include + #include "solipa.h" static void solipa_class_init (SolipaClass *class); @@ -69,8 +72,24 @@ solipa_init (Solipa *solipa) Solipa *solipa_new () { + Solipa *solipa; + + gchar *camel_tmpdir; + + /* inizializzo GType e GThread */ + g_type_init (); + g_thread_init (NULL); + + /* creo la directory temporanea per camel */ + camel_tmpdir = mkdtemp (g_build_filename (g_get_tmp_dir (), g_strdup ("solipa-camel-XXXXXX"), NULL)); + + /* inizializzo camel */ + camel_init (camel_tmpdir, FALSE); + camel_provider_init (); + + solipa = SOLIPA (g_object_new (solipa_get_type (), NULL)); - return SOLIPA (g_object_new (solipa_get_type (), NULL)); + return solipa; } void diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..373e824 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,12 @@ +AM_CPPFLAGS = $(WARN_CFLAGS) \ + $(DISABLE_DEPRECATED_CFLAGS) \ + $(SOLIPA_CFLAGS) \ + -I$(top_srcdir)/src \ + -DGUIDIR="\"@abs_builddir@\"" + +LIBS = $(SOLIPA_LIBS) \ + -export-dynamic + +LDADD = $(top_builddir)/src/libsolipa.la + +noinst_PROGRAMS = mail diff --git a/tests/mail.c b/tests/mail.c new file mode 100644 index 0000000..30a97fb --- /dev/null +++ b/tests/mail.c @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2010 Andrea Zagli + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include +#include + +int +main (int argc, char **argv) +{ + Solipa *solipa; + + solipa = solipa_new (); + + return 0; +} -- 2.49.0