return FALSE;
}
-
/* Sanity check: */
/* There must be at least one account now: */
/* Note, when this fails is is caused by a Maemo gconf bug that has been
* fixed in versions after 3.1. */
- GSList *account_names = modest_account_mgr_account_names (self->account_manager, FALSE);
- if(!account_names)
- {
+ if(!modest_account_mgr_has_accounts (self->account_manager, FALSE))
g_warning ("modest_account_mgr_account_names() returned NULL after adding an account.");
- }
- g_slist_free (account_names);
-
-
-
+
/* The user name and email address must be set additionally: */
const gchar* user_name = gtk_entry_get_text (GTK_ENTRY (self->entry_user_name));
modest_account_mgr_set_string (self->account_manager, account_name,
iter = g_slist_next (iter);
}
-
- g_slist_free (account_names);
-
+
+ modest_account_mgr_free_account_names (account_names);
+ account_names = NULL;
modest_ui_actions_do_send_receive (NULL, MODEST_WINDOW (self));
}
iter = iter->next;
}
- g_slist_free (account_names);
+ modest_account_mgr_free_account_names (account_names);
+ account_names = NULL;
/* Order the list of accounts by its display name */
accounts = g_slist_sort (accounts, (GCompareFunc) compare_display_names);
ModestAccountMgr *account_mgr = modest_runtime_get_account_mgr();
GSList *accounts = modest_account_mgr_account_names (account_mgr,
- TRUE /* only enabled accounts. */);
+ TRUE /* only enabled accounts. */);
GSList *cursor = accounts;
while (cursor) {
- const gchar *account_name = cursor->data;
+ gchar *account_name = cursor->data;
gchar *from_string = NULL;
if (account_name) {
from_string = modest_account_mgr_get_from_string (account_mgr,
}
if (from_string && account_name) {
- gchar *name = g_strdup (account_name);
+ gchar *name = account_name;
ModestPair *pair = modest_pair_new ((gpointer) name,
(gpointer) from_string , TRUE);
transports = g_slist_prepend (transports, pair);
cursor = cursor->next;
}
- g_slist_free (accounts);
+ g_slist_free (accounts); /* only free the accounts, not the elements,
+ * because they are used in the pairlist */
return transports;
}
return g_utf8_collate((const gchar*)a, (const gchar*)b);
}
-
-static void
-free_element (gpointer data, gpointer user_data)
-{
- g_free (data);
-}
-
gboolean
modest_account_mgr_set_first_account_as_default (ModestAccountMgr *self)
{
if (account_name)
result = modest_account_mgr_set_default_account (self, account_name);
}
-
- g_slist_foreach (account_names, free_element, NULL);
- g_slist_free (account_names);
-
+
+ modest_account_mgr_free_account_names (account_names);
+ account_names = NULL;
+
return result;
}
}
}
-#if 0
-/* Not used. */
-GSList*
-modest_account_mgr_search_server_accounts (ModestAccountMgr * self,
- const gchar * account_name,
- ModestTransportStoreProtocol proto)
-{
- GSList *accounts;
- GSList *cursor;
- ModestAccountMgrPrivate *priv;
- gchar *key;
- GError *err = NULL;
-
- g_return_val_if_fail (self, NULL);
-
- key = _modest_account_mgr_get_account_keyname (account_name, NULL, TRUE);
- priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
-
- /* get the list of all server accounts */
- accounts = modest_conf_list_subkeys (priv->modest_conf, key, &err);
- if (err) {
- g_printerr ("modest: failed to get subkeys for '%s' (%s)\n", key,
- err->message);
- g_error_free(err);
- return NULL;
- }
-
- /* filter out the ones with the wrong protocol */
- /* we could optimize for unknown proto / unknown type, but it will only
- * make the code more complex */
- cursor = accounts;
- while (cursor) {
- gchar *account = _modest_account_mgr_account_from_key ((gchar*)cursor->data, NULL, NULL);
- gchar *acc_proto = modest_account_mgr_get_string (self, account, MODEST_ACCOUNT_PROTO,TRUE);
- ModestTransportStoreProtocol this_proto =
- modest_protocol_info_get_transport_store_protocol (acc_proto);
- if (this_proto != MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN && this_proto != proto) {
- GSList *nxt = cursor->next;
- accounts = g_slist_delete_link (accounts, cursor);
- cursor = nxt;
- } else
- cursor = cursor->next;
-
- g_free (account);
- g_free (acc_proto);
- }
-
- /* +1 because we must remove the ending '/' as well */
- strip_prefix_from_elements (accounts, strlen(key)+1);
- return accounts;
-}
-#endif
GSList*
modest_account_mgr_account_names (ModestAccountMgr * self, gboolean only_enabled)
continue;
const gchar* account_name_key = (const gchar*)iter->data;
- /* printf ("DEBUG: %s: account_name_key=%s\n", __FUNCTION__, account_name_key); */
gchar* unescaped_name = account_name_key ?
modest_conf_key_unescape (account_name_key)
: NULL;
- /* printf (" DEBUG: %s: unescaped name=%s\n", __FUNCTION__, unescaped_name); */
gboolean add = TRUE;
if (only_enabled) {
}
}
- if (add) {
+ if (add)
result = g_slist_append (result, unescaped_name);
- }
- else {
+ else
g_free (unescaped_name);
- }
-
+
+ g_free (iter->data);
+ iter->data = NULL;
+
iter = g_slist_next (iter);
}
- /* TODO: Free the strings too? */
+
+ /* we already freed the strings in the loop */
g_slist_free (accounts);
+
accounts = NULL;
-
return result;
}
+void
+modest_account_mgr_free_account_names (GSList *account_names)
+{
+ g_slist_foreach (account_names, (GFunc)g_free, NULL);
+ g_slist_free (account_names);
+}
+
+
+
gchar *
modest_account_mgr_get_string (ModestAccountMgr *self, const gchar *name,
const gchar *key, gboolean server_account) {
GSList *cursor = NULL;
cursor = account_names = modest_account_mgr_account_names (self,
- TRUE /* enabled accounts, because disabled accounts are not user visible. */);
+ TRUE /* enabled accounts, because disabled accounts are not user visible. */);
gboolean found = FALSE;
modest_account_mgr_free_account_data (self, account_data);
cursor = cursor->next;
}
- g_slist_free (account_names);
+ modest_account_mgr_free_account_names (account_names);
+ account_names = NULL;
return found;
}
{
/* Check that at least one account exists: */
GSList *account_names = modest_account_mgr_account_names (self,
- enabled);
+ enabled);
gboolean accounts_exist = account_names != NULL;
- g_slist_free (account_names);
+
+ modest_account_mgr_free_account_names (account_names);
+ account_names = NULL;
return accounts_exist;
}
priv->busy_accounts = g_slist_append(priv->busy_accounts, g_strdup(account_name));
g_signal_emit_by_name(G_OBJECT(self), "account-busy-changed", account_name, TRUE);
}
- g_slist_free(account_names);
- }
- else
- {
+ modest_account_mgr_free_account_names (account_names);
+ account_names = NULL;
+ } else {
GSList* account =
g_slist_find_custom(priv->busy_accounts, account_name, (GCompareFunc) compare_account_name);
if (account)
* Returns: a newly allocated list of account names, or NULL in case of error or
* if there are no accounts. The caller must free the returned GSList.
*
- * TODO: I believe that the caller must free the strings in the GSList items too,
- * because this is implemented via gconf_client_all_dirs() which also requires a deep free,
- * though that's not documented. murrayc.
*/
GSList* modest_account_mgr_account_names (ModestAccountMgr *self,
gboolean only_enabled);
-#if 0
-/* Not used. */
/**
- * modest_account_mgr_search_server_account:
- * @self: a ModestAccountMgr instance
- * @account_name: get only server accounts for @account_name, or NULL for any
- * @type: get only server accounts from protocol type @type, or MODEST_PROTOCOL_TYPE_UNKNOWN
- * @proto: get only server account with protocol @proto, or MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN for any
+ * modest_account_mgr_free_account_names:
+ * @account_name: a gslist of account names
*
- * List all the server account names, optionally narrowing the result down to one account.
+ * list all account names
*
- * Returns: a newly allocated list of server account names, or NULL in case of
- * error or if there are no server accounts. The caller must free the returned GSList
+ * free the list of account names
*/
-GSList* modest_account_mgr_search_server_accounts (ModestAccountMgr *self,
- const gchar* account_name,
- ModestProtocolType type,
- ModestTransportStoreProtocol proto);
-#endif
+void modest_account_mgr_free_account_names (GSList *account_names);
+
/**
* modest_account_mgr_account_exists:
bind_textdomain_codeset (gettext_package, "UTF-8");
textdomain (gettext_package);
+
+ setlocale (LC_ALL, "");
}
accounts = g_slist_append (accounts, tny_account_outbox); /* cache it */
};
-
- g_slist_free (account_names);
+
+ modest_account_mgr_free_account_names (account_names);
+ account_names = NULL;
priv->store_accounts_outboxes = accounts;
}
get_server_accounts (TnyAccountStore *self, TnyList *list, TnyAccountType type)
{
g_return_if_fail (self);
-
- /* printf ("DEBUG: %s: list=%p, type=%d\n", __FUNCTION__, list, type); */
ModestTnyAccountStorePrivate *priv =
MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
iter_account_names = g_slist_next (iter_account_names);
}
}
-
- g_slist_free (account_names);
+
+ /* free the account_names */
+ modest_account_mgr_free_account_names (account_names);
account_names = NULL;
-
- /* TODO: Delete the strings in the GSList */
-
-
+
/* We also create a per-account local outbox folder (a _store_ account)
* for each _transport_ account. */
if (type == TNY_ACCOUNT_TYPE_TRANSPORT) {
modest_ui_actions_do_send_receive ((const char*) iter->data, win);
iter = g_slist_next (iter);
}
-
- g_slist_foreach (account_names, (GFunc) g_free, NULL);
- g_slist_free (account_names);
+
+ modest_account_mgr_free_account_names (account_names);
+ account_names = NULL;
}
/*
key = _modest_widget_memory_get_keyname_with_double_type (name, type, style,
MODEST_WIDGET_MEMORY_PARAM_COLUMN_WIDTH);
sort_key = _modest_widget_memory_get_keyname_with_double_type (name, type, style,
- MODEST_WIDGET_MEMORY_PARAM_COLUMN_SORT);
+ MODEST_WIDGET_MEMORY_PARAM_COLUMN_SORT);
if (modest_conf_key_exists (conf, sort_key, NULL)) {
gchar *value = modest_conf_get_string (conf, sort_key, NULL);
}
g_free (key);
+ g_free (sort_key);
+
g_object_unref (G_OBJECT (folder));
return TRUE;
cursor = account_names = modest_account_mgr_account_names (account_mgr,
TRUE /* only enabled accounts. */);
- if(account_names == NULL)
- {
- printf ("debug: modest_account_mgr_account_names() returned NULL\n");
- }
+ if (!account_names)
+ g_warning ("debug: modest_account_mgr_account_names() returned NULL\n");
while (cursor) {
gchar *account_name;
modest_account_mgr_free_account_data (account_mgr, account_data);
cursor = cursor->next;
}
- g_slist_free (account_names);
+
+ modest_account_mgr_free_account_names (account_names);
+ account_names = NULL;
/* Try to re-select the same account: */
if (selected_name) {
header = g_markup_printf_escaped ("%s", (subject && strlen (subject)) ? subject : _("mail_va_no_subject"));
g_free (subject);
g_object_set (G_OBJECT (subject_cell), "markup", header, NULL);
+ g_free (header);
set_common_flags (subject_cell, flags);
-
+
header = g_markup_printf_escaped ("<small>%s</small>", modest_text_utils_get_display_address (address));
g_free (address);
g_object_set (G_OBJECT (recipient_cell), "markup", header, NULL);
-
- g_object_set (G_OBJECT (recipient_cell), "markup", header, NULL);
+ g_free (header);
set_common_flags (recipient_cell, flags);
/* in some rare cases, mail might have no Date: field. it case,
g_free (tmp_date);
g_free (display_date);
set_common_flags (date_cell, flags);
-
- g_free (header);
}
g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN(user_data), 0);
/* col_id = gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (tree_model)); */
col_id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(user_data), MODEST_HEADER_VIEW_FLAG_SORT));
+
-/* if (!(++counter % 100)) { */
-/* GObject *header_view = g_object_get_data(G_OBJECT(user_data), */
-/* MODEST_HEADER_VIEW_PTR); */
-/* g_signal_emit (header_view, */
-/* signals[STATUS_UPDATE_SIGNAL], */
-/* 0, _("Sorting..."), 0, 0); */
-/* } */
switch (col_id) {
case TNY_HEADER_FLAG_ATTACHMENTS:
modest_attachments_view_set_message (MODEST_ATTACHMENTS_VIEW(priv->attachments_view),
msg);
- body = modest_tny_msg_find_body_part (msg,TRUE);
+ body = modest_tny_msg_find_body_part (msg, TRUE);
if (body) {
if (tny_mime_part_content_type_is (body, "text/html"))
set_html_message (self, body, msg);