- fix leak when searching through multipart/ messages
(modest_tny_msg_find_body_part_from_mime_part)
* modest-account-mgr.c:
- fix possible NULL dereference
* modest-ui-actions.c:
- remove some dead code
- fix possible NULL dereference
* modest-platform.c:
- small cleanup
pmo-trunk-r3631
#define NUMBER_OF_TRIES 10 /* Try approx every second, ten times. */
static gboolean
#define NUMBER_OF_TRIES 10 /* Try approx every second, ten times. */
static gboolean
-on_timeout_check_account_is_online(gpointer user_data)
+on_timeout_check_account_is_online(CheckAccountIdleData* data)
- printf ("DEBUG: %s:\n", __FUNCTION__);
- CheckAccountIdleData *data = (CheckAccountIdleData*)user_data;
-
+ gboolean stop_trying = FALSE;
g_return_val_if_fail (data && data->account, FALSE);
printf ("DEBUG: %s: tny_account_get_connection_status()==%d\n", __FUNCTION__,
tny_account_get_connection_status (data->account));
g_return_val_if_fail (data && data->account, FALSE);
printf ("DEBUG: %s: tny_account_get_connection_status()==%d\n", __FUNCTION__,
tny_account_get_connection_status (data->account));
- gboolean stop_trying = FALSE;
if (data && data->account &&
/* We want to wait until TNY_CONNECTION_STATUS_INIT has changed to something else,
* after which the account is likely to be usable, or never likely to be usable soon: */
if (data && data->account &&
/* We want to wait until TNY_CONNECTION_STATUS_INIT has changed to something else,
* after which the account is likely to be usable, or never likely to be usable soon: */
data->is_online = TRUE;
stop_trying = TRUE;
data->is_online = TRUE;
stop_trying = TRUE;
/* Give up if we have tried too many times: */
/* Give up if we have tried too many times: */
- if (data->count_tries >= NUMBER_OF_TRIES)
- {
+ if (data->count_tries >= NUMBER_OF_TRIES) {
/* Wait for another timeout: */
++(data->count_tries);
}
/* Wait for another timeout: */
++(data->count_tries);
}
GMainContext *context = NULL; /* g_main_context_new (); */
data->loop = g_main_loop_new (context, FALSE /* not running */);
GMainContext *context = NULL; /* g_main_context_new (); */
data->loop = g_main_loop_new (context, FALSE /* not running */);
- g_timeout_add (1000, on_timeout_check_account_is_online, data);
+ g_timeout_add (1000, (GSourceFunc)(on_timeout_check_account_is_online), data);
/* This main loop will run until the idle handler has stopped it: */
g_main_loop_run (data->loop);
/* This main loop will run until the idle handler has stopped it: */
g_main_loop_run (data->loop);
retval = g_strconcat (namespace, "/", escaped_account_name, NULL);
/* Sanity check: */
retval = g_strconcat (namespace, "/", escaped_account_name, NULL);
/* Sanity check: */
- if (!modest_conf_key_is_valid (retval)) {
- g_warning ("%s: Generated conf key was invalid: %s", __FUNCTION__, retval);
+ if (!retval || !modest_conf_key_is_valid (retval)) {
+ g_warning ("%s: Generated conf key was invalid: %s", __FUNCTION__,
+ retval ? retval: "<empty>");
g_free (retval);
retval = NULL;
}
g_free (retval);
retval = NULL;
}
TnyMimePart*
modest_tny_msg_find_body_part_from_mime_part (TnyMimePart *msg, gboolean want_html)
{
TnyMimePart*
modest_tny_msg_find_body_part_from_mime_part (TnyMimePart *msg, gboolean want_html)
{
- const gchar *mime_type = want_html ? "text/html" : "text/plain";
+ const gchar *desired_mime_type = want_html ? "text/html" : "text/plain";
TnyMimePart *part = NULL;
TnyList *parts = NULL;
TnyIterator *iter = NULL;
TnyMimePart *part = NULL;
TnyList *parts = NULL;
TnyIterator *iter = NULL;
g_object_unref (G_OBJECT(iter));
return TNY_MIME_PART (g_object_ref(G_OBJECT(msg)));
} else {
g_object_unref (G_OBJECT(iter));
return TNY_MIME_PART (g_object_ref(G_OBJECT(msg)));
} else {
- gchar *content_type = NULL;
+ gchar *content_type = NULL;
+
part = TNY_MIME_PART(tny_iterator_get_current (iter));
part = TNY_MIME_PART(tny_iterator_get_current (iter));
+
+ if (!part) {
+ g_warning ("%s: not a valid mime part", __FUNCTION__);
+ continue;
+ }
+
+ /* it's a message --> ignore */
if (part && TNY_IS_MSG (part)) {
g_object_unref (part);
tny_iterator_next (iter);
continue;
}
if (part && TNY_IS_MSG (part)) {
g_object_unref (part);
tny_iterator_next (iter);
continue;
}
/* we need to strdown the content type, because
* tny_mime_part_has_content_type does not do it...
*/
/* we need to strdown the content type, because
* tny_mime_part_has_content_type does not do it...
*/
- if (part) {
- content_type = g_ascii_strdown
- (tny_mime_part_get_content_type (part), -1);
- }
-
- if (g_str_has_prefix (content_type, mime_type) &&
- !tny_mime_part_is_attachment (part))
+ content_type = g_ascii_strdown (tny_mime_part_get_content_type (part), -1);
+
+ if (g_str_has_prefix (content_type, desired_mime_type) && !tny_mime_part_is_attachment (part)) {
+ /* we found the desired mime-type! */
+ g_free (content_type);
-
- if (g_str_has_prefix(content_type, "multipart")) {
+
+ } else if (g_str_has_prefix(content_type, "multipart")) {
+
+ /* multipart? recurse! */
+ g_object_unref (part);
+ g_free (content_type);
part = modest_tny_msg_find_body_part_from_mime_part (part, want_html);
if (part)
break;
part = modest_tny_msg_find_body_part_from_mime_part (part, want_html);
if (part)
break;
+ } else
+ g_free (content_type);
+
+ if (part) {
g_object_unref (G_OBJECT(part));
g_object_unref (G_OBJECT(part));
- g_free (content_type);
- content_type = NULL;
-
tny_iterator_next (iter);
} while (!tny_iterator_is_done(iter));
tny_iterator_next (iter);
} while (!tny_iterator_is_done(iter));
}
g_object_unref (G_OBJECT(iter));
}
g_object_unref (G_OBJECT(iter));
GtkTreeRowReference *prev_row_reference = NULL;
GtkTreePath *next_path = NULL;
GtkTreePath *prev_path = NULL;
GtkTreeRowReference *prev_row_reference = NULL;
GtkTreePath *next_path = NULL;
GtkTreePath *prev_path = NULL;
/* Find last selected row */
if (MODEST_IS_MAIN_WINDOW (win)) {
/* Find last selected row */
if (MODEST_IS_MAIN_WINDOW (win)) {
if (prev_path != NULL)
gtk_tree_path_free (prev_path);
}
if (prev_path != NULL)
gtk_tree_path_free (prev_path);
}
-
- if (err != NULL) {
- printf ("DEBUG: %s: Error: code=%d, text=%s\n", __FUNCTION__, err->code, err->message);
- g_error_free(err);
- }
/* Update toolbar dimming state */
modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (main_window));
/* Update toolbar dimming state */
modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (main_window));
ModestMainWindow *main_window)
{
g_return_if_fail(server_account_name);
ModestMainWindow *main_window)
{
g_return_if_fail(server_account_name);
- /* printf("DEBUG: %s: server_account_name=%s\n", __FUNCTION__, server_account_name); */
/* Initalize output parameters: */
if (cancel)
/* Initalize output parameters: */
if (cancel)
modest_runtime_get_account_mgr(), server_account_name);
if (!server_name) {/* This happened once, though I don't know why. murrayc. */
g_warning("%s: Could not get server name for server account '%s'", __FUNCTION__, server_account_name);
modest_runtime_get_account_mgr(), server_account_name);
if (!server_name) {/* This happened once, though I don't know why. murrayc. */
g_warning("%s: Could not get server name for server account '%s'", __FUNCTION__, server_account_name);
+ if (cancel)
+ *cancel = TRUE;