GValue *value,
GParamSpec *pspec);
+static void solipa_dispose (GObject *gobject);
+static void solipa_finalize (GObject *gobject);
+
#define SOLIPA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), SOLIPA_TYPE, SolipaPrivate))
typedef struct _SolipaPrivate SolipaPrivate;
struct _SolipaPrivate
{
+ gchar *camel_tmpdir;
CamelSession *camel_session;
GdaEx *gdaex;
object_class->set_property = solipa_set_property;
object_class->get_property = solipa_get_property;
+ object_class->dispose = solipa_dispose;
+ object_class->finalize = solipa_finalize;
g_type_class_add_private (object_class, sizeof (SolipaPrivate));
}
Solipa *solipa;
SolipaPrivate *priv;
- gchar *camel_tmpdir;
-
/* inizializzo GType e GThread */
g_type_init ();
g_thread_init (NULL);
priv = SOLIPA_GET_PRIVATE (solipa);
/* creo la directory temporanea per camel */
- camel_tmpdir = g_mkdtemp (g_build_filename (g_get_tmp_dir (), g_strdup ("solipa-camel-XXXXXX"), NULL));
+ priv->camel_tmpdir = g_mkdtemp (g_build_filename (g_get_tmp_dir (), g_strdup ("solipa-camel-XXXXXX"), NULL));
/* inizializzo camel */
- camel_init (camel_tmpdir, FALSE);
+ camel_init (priv->camel_tmpdir, FALSE);
camel_provider_init ();
- priv->camel_session = solipa_camel_session_new (camel_tmpdir);
+ priv->camel_session = solipa_camel_session_new (priv->camel_tmpdir);
/* gui */
#ifdef G_OS_WIN32
GParamSpec *pspec)
{
Solipa *solipa = (Solipa *)object;
-
SolipaPrivate *priv = SOLIPA_GET_PRIVATE (solipa);
switch (property_id)
GParamSpec *pspec)
{
Solipa *solipa = (Solipa *)object;
-
SolipaPrivate *priv = SOLIPA_GET_PRIVATE (solipa);
switch (property_id)
break;
}
}
+
+static void
+solipa_dispose (GObject *gobject)
+{
+ Solipa *solipa = (Solipa *)gobject;
+ SolipaPrivate *priv = SOLIPA_GET_PRIVATE (solipa);
+
+ if (priv->gdaex)
+ {
+ g_object_unref (priv->gdaex);
+ priv->gdaex = NULL;
+ }
+
+ if (priv->gtkbuilder)
+ {
+ g_object_unref (priv->gtkbuilder);
+ priv->gtkbuilder = NULL;
+ }
+
+ if (priv->camel_session)
+ {
+ g_object_unref (priv->camel_session);
+ priv->camel_session = NULL;
+ }
+
+ GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
+ parent_class->dispose (gobject);
+}
+
+static void
+solipa_finalize (GObject *gobject)
+{
+ Solipa *solipa = (Solipa *)gobject;
+ SolipaPrivate *priv = SOLIPA_GET_PRIVATE (solipa);
+
+ /* delete camel tmp dir */
+ g_rmdir (priv->camel_tmpdir);
+
+ g_free (priv->camel_tmpdir);
+ g_free (priv->guidir);
+ g_free (priv->guifile);
+
+ GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
+ parent_class->finalize (gobject);
+}