static ModestErrorCode
-start_ui (const gchar *account, const gchar* mailto, const gchar *cc, const gchar *bcc,
+start_ui (const gchar *account_name, const gchar* mailto, const gchar *cc, const gchar *bcc,
const gchar* subject, const gchar *body)
{
ModestWindow *win = NULL;
if (mailto||cc||bcc||subject||body) {
gchar *from;
- TnyMsg *msg;
- TnyFolder *folder;
- if (!account) {
- g_printerr ("modest: no valid account provided, nor is default one available\n");
+ TnyMsg *msg;
+ TnyFolder *folder;
+ TnyAccount *account;
+
+ if (!account_name) {
+ g_printerr ("modest: no valid account provided, "
+ "nor is default one available\n");
return MODEST_ERR_PARAM;
}
- from = modest_account_mgr_get_from_string (modest_runtime_get_account_mgr(), account);
+ from = modest_account_mgr_get_from_string (modest_runtime_get_account_mgr(),
+ account_name);
msg = modest_tny_msg_new (mailto,from,cc,bcc,subject,body,NULL);
if (!msg) {
g_printerr ("modest: failed to create message\n");
g_free (from);
return MODEST_ERR_SEND;
}
+
+ account = modest_tny_account_store_get_tny_account_by_account (
+ modest_runtime_get_account_store(), account_name,
+ TNY_ACCOUNT_TYPE_TRANSPORT);
+ if (!account) {
+ g_printerr ("modest: failed to get tny account folder\n");
+ g_free (from);
+ g_object_unref (G_OBJECT(msg));
+ return MODEST_ERR_SEND;
+ }
+
folder = modest_tny_account_get_special_folder (account,
TNY_FOLDER_TYPE_DRAFTS);
if (!folder) {
g_printerr ("modest: failed to find Drafts folder\n");
g_free (from);
g_object_unref (G_OBJECT(msg));
+ g_object_unref (G_OBJECT(account));
return MODEST_ERR_SEND;
}
tny_folder_add_msg (folder, msg, NULL); /* FIXME: check err */
- win = modest_msg_edit_window_new (msg, account);
+ win = modest_msg_edit_window_new (msg, account_name);
g_object_unref (G_OBJECT(msg));
+ g_object_unref (G_OBJECT(account));
+ g_object_unref (G_OBJECT(folder));
g_free (from);
} else
win = modest_main_window_new ();
MODEST_RUNTIME_DEBUG_LOG_ACTIONS = 1 << 1, /* not in use atm */
MODEST_RUNTIME_DEBUG_DEBUG_OBJECTS = 1 << 2, /* for g_type_init */
MODEST_RUNTIME_DEBUG_DEBUG_SIGNALS = 1 << 3, /* for g_type_init */
- MODEST_RUNTIME_DEBUG_FACTORY_SETTINGS = 1 << 4, /* reset to factory defaults */
+ MODEST_RUNTIME_DEBUG_FACTORY_SETTINGS = 1 << 4 /* reset to factory defaults */
} ModestRuntimeDebugFlags;
/**
* - "abort-on-warning": abort the program when a gtk/glib/.. warning occurs.
* useful when running in debugger
* - "log-actions": log user actions (not in use atm)
- * - "track-object": track the use of (g)objects in the program. this option influences
+ * - "debug-objects": track the use of (g)objects in the program. this option influences
* g_type_init_with_debug_flags
- * - "track-signals": track the use of (g)signals in the program. this option influences
+ * - "debug-signals": track the use of (g)signals in the program. this option influences
* g_type_init_with_debug_flags
* if you would want to track signals and log actions, you could do something like:
* MODEST_DEBUG="log-actions:track-signals" ./modest
*/
#include "modest-singletons.h"
+#include "modest-runtime.h"
/* 'private'/'protected' functions */
static void modest_singletons_class_init (ModestSingletonsClass *klass);
check_object_is_dead (GObject *obj, gchar *name)
{
if (G_IS_OBJECT(obj))
- g_warning ("BUG: %s is still alive\n", name);
+ g_warning ("BUG: %s still has %d ref(s)\n", name, obj->ref_count);
}
static void
modest_singletons_finalize (GObject *obj)
{
ModestSingletonsPrivate *priv;
+ gboolean debug = modest_runtime_get_debug_flags() & MODEST_RUNTIME_DEBUG_DEBUG_OBJECTS;
+
priv = MODEST_SINGLETONS_GET_PRIVATE(obj);
if (priv->account_store) {
g_object_unref (G_OBJECT(priv->account_store));
- check_object_is_dead ((GObject*)priv->account_store,
- "priv->account_store");
+ if (debug)
+ check_object_is_dead ((GObject*)priv->account_store,
+ "priv->account_store");
priv->account_store = NULL;
}
if (priv->account_mgr) {
g_object_unref (G_OBJECT(priv->account_mgr));
- check_object_is_dead ((GObject*)priv->account_mgr,
- "priv->account_mgr");
+ if (debug)
+ check_object_is_dead ((GObject*)priv->account_mgr,
+ "priv->account_mgr");
priv->account_mgr = NULL;
}
if (priv->conf) {
g_object_unref (G_OBJECT(priv->conf));
- check_object_is_dead ((GObject*)priv->conf,
- "priv->conf");
+ if (debug)
+ check_object_is_dead ((GObject*)priv->conf,
+ "priv->conf");
priv->conf = NULL;
}
if (priv->cache_mgr) {
g_object_unref (G_OBJECT(priv->cache_mgr));
- check_object_is_dead ((GObject*)priv->cache_mgr,
- "priv->cache_mgr");
+ if (debug)
+ check_object_is_dead ((GObject*)priv->cache_mgr,
+ "priv->cache_mgr");
priv->cache_mgr = NULL;
}
if (priv->device) {
g_object_unref (G_OBJECT(priv->device));
- check_object_is_dead ((GObject*)priv->cache_mgr,
- "priv->device");
+ if (debug)
+ check_object_is_dead ((GObject*)priv->cache_mgr,
+ "priv->device");
priv->device = NULL;
}
if (priv->platform_fact) {
g_object_unref (G_OBJECT(priv->platform_fact));
- check_object_is_dead ((GObject*)priv->cache_mgr,
- "priv->platform_fact");
+ if (debug)
+ check_object_is_dead ((GObject*)priv->cache_mgr,
+ "priv->platform_fact");
priv->platform_fact = NULL;
}
account_list_free (GSList *accounts)
{
GSList *cursor = accounts;
+ gboolean debug = modest_runtime_get_debug_flags() & MODEST_RUNTIME_DEBUG_DEBUG_OBJECTS;
+
while (cursor) {
g_object_unref (G_OBJECT(cursor->data));
-/* if (G_IS_OBJECT(cursor->data)) */
-/* g_warning ("BUG: account %s still holds refs", */
-/* tny_account_get_id (TNY_ACCOUNT(cursor->data))); */
+ if (debug && G_IS_OBJECT(cursor->data))
+ g_warning ("BUG: account %s still holds %d ref(s)",
+ tny_account_get_id (TNY_ACCOUNT(cursor->data)),
+ G_OBJECT(cursor->data)->ref_count);
cursor = cursor->next;
}
g_slist_free (accounts);
{
ModestTnyAccountStore *self = MODEST_TNY_ACCOUNT_STORE(obj);
ModestTnyAccountStorePrivate *priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
+
+ gboolean debug = modest_runtime_get_debug_flags() & MODEST_RUNTIME_DEBUG_DEBUG_OBJECTS;
g_free (priv->cache_dir);
priv->cache_dir = NULL;
if (priv->session) {
camel_object_unref (CAMEL_OBJECT(priv->session));
+ if (debug && CAMEL_IS_OBJECT(priv->session))
+ g_warning ("BUG: TnyCamelSession still holds %d ref(s)",
+ CAMEL_OBJECT(priv->session)->ref_count);
priv->session = NULL;
}
/* only return enabled accounts */
if (modest_account_mgr_get_enabled(priv->account_mgr, account_name)) {
TnyAccount *tny_account =
- modest_tny_account_new_from_account (priv->account_mgr, account_name,
- type, priv->session, get_password,
+ modest_tny_account_new_from_account (priv->account_mgr,
+ account_name,
+ type, priv->session,
+ get_password,
forget_password);
if (tny_account) { /* something went wrong */
- g_object_set_data (G_OBJECT(tny_account), "account_store", (gpointer)self);
+ g_object_set_data (G_OBJECT(tny_account), "account_store",
+ (gpointer)self);
tny_list_prepend (list, G_OBJECT(tny_account));
accounts = g_slist_append (accounts, tny_account); /* cache it */
} else
- g_printerr ("modest: failed to create account for %s\n", account_name);
+ g_printerr ("modest: failed to create account for %s\n",
+ account_name);
}
g_free (account_name);
}
priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
if (request_type == TNY_ACCOUNT_STORE_BOTH) {
- modest_tny_account_store_get_accounts (self, list, TNY_ACCOUNT_STORE_STORE_ACCOUNTS);
- modest_tny_account_store_get_accounts (self, list, TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS);
+ modest_tny_account_store_get_accounts (self, list,
+ TNY_ACCOUNT_STORE_STORE_ACCOUNTS);
+ modest_tny_account_store_get_accounts (self, list,
+ TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS);
return;
}
} else if (request_type == TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS) {
if (!priv->transport_accounts)
- priv->transport_accounts = get_accounts (self, list, TNY_ACCOUNT_TYPE_TRANSPORT);
+ priv->transport_accounts =
+ get_accounts (self, list, TNY_ACCOUNT_TYPE_TRANSPORT);
else
get_cached_accounts (self, list, TNY_ACCOUNT_TYPE_TRANSPORT);
} else {
#include <tny-gtk-text-buffer-stream.h>
#include <tny-simple-list.h>
#include <tny-folder.h>
-#include <modest-tny-platform-factory.h>
+#include <modest-runtime.h>
#include <tny-camel-stream.h>
#include <camel/camel-stream-mem.h>
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /*HAVE_CONFIG_H */
g_object_set (rendobj,"text", fname, "weight", 400, NULL);
g_free (fname);
+ if (folder)
+ g_object_unref (G_OBJECT(folder));
+
}
/* Set new model */
gtk_tree_view_set_model (GTK_TREE_VIEW(self), sortable);
expand_root_items (self); /* expand all account folders */
+ g_object_unref (account_list);
}
- g_object_unref (model);
+ //if (model)
+ // g_object_unref (model);
+
return TRUE;
}
cmp = modest_text_utils_utf8_strcmp (name1, name2, TRUE);
} else
cmp = modest_text_utils_utf8_strcmp (name1, name2, TRUE);
+
+
+ if (folder1)
+ g_object_unref(G_OBJECT(folder1));
+ if (folder2)
+ g_object_unref(G_OBJECT(folder2));
g_free (name1);
g_free (name2);
success = TRUE;
}
gtk_tree_row_reference_free (source_row_reference);
+
+ if (folder)
+ g_object_unref (G_OBJECT(folder));
+ if (parent_folder)
+ g_object_unref (G_OBJECT(parent_folder));
+
}
out:
gtk_tree_path_free (child_dest_row);