#include <modest-account-mgr.h>
#include <modest-account-mgr-helpers.h>
+#include <modest-tny-account.h>
#include <modest-text-utils.h>
#include <modest-runtime.h>
MODEST_ACCOUNT_VIEW_COLUMN_NUM
} AccountViewColumns;
-
-/* list my signals */
-enum {
- /* MY_SIGNAL_1, */
- /* MY_SIGNAL_2, */
- LAST_SIGNAL
-};
-
typedef struct _ModestAccountViewPrivate ModestAccountViewPrivate;
struct _ModestAccountViewPrivate {
ModestAccountMgr *account_mgr;
- gulong sig1, sig2, sig3;
-
- /* When this is TRUE, we ignore configuration key changes.
- * This is useful when making many changes. */
- gboolean block_conf_updates;
-
+
+ /* Signal handlers */
+ gulong acc_inserted_handler, acc_removed_handler,
+ acc_busy_changed_handler, acc_changed_handler;
};
#define MODEST_ACCOUNT_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_ACCOUNT_VIEW, \
/* globals */
static GtkTreeViewClass *parent_class = NULL;
-/* uncomment the following if you have defined any signals */
-/* static guint signals[LAST_SIGNAL] = {0}; */
-
GType
modest_account_view_get_type (void)
{
modest_account_view_init (ModestAccountView *obj)
{
ModestAccountViewPrivate *priv;
-
+
priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(obj);
priv->account_mgr = NULL;
- priv->sig1 = 0;
- priv->sig2 = 0;
+ priv->acc_inserted_handler = 0;
+ priv->acc_removed_handler = 0;
+ priv->acc_busy_changed_handler = 0;
+ priv->acc_changed_handler = 0;
}
static void
priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(obj);
if (priv->account_mgr) {
- if (priv->sig1)
+ if (g_signal_handler_is_connected (modest_runtime_get_account_store (),
+ priv->acc_inserted_handler))
g_signal_handler_disconnect (modest_runtime_get_account_store (),
- priv->sig1);
+ priv->acc_inserted_handler);
- if (priv->sig2)
- g_signal_handler_disconnect (priv->account_mgr, priv->sig2);
+ if (g_signal_handler_is_connected (modest_runtime_get_account_store (),
+ priv->acc_removed_handler))
+ g_signal_handler_disconnect (modest_runtime_get_account_store (),
+ priv->acc_removed_handler);
+
+ if (g_signal_handler_is_connected (modest_runtime_get_account_store (),
+ priv->acc_changed_handler))
+ g_signal_handler_disconnect (modest_runtime_get_account_store (),
+ priv->acc_changed_handler);
+
+ if (priv->acc_busy_changed_handler)
+ g_signal_handler_disconnect (priv->account_mgr, priv->acc_busy_changed_handler);
- if (priv->sig3)
- g_signal_handler_disconnect (priv->account_mgr, priv->sig3);
g_object_unref (G_OBJECT(priv->account_mgr));
priv->account_mgr = NULL;
/* FIXME: let's assume that 'last update' applies to the store account... */
gchar* last_updated_string;
time_t last_updated = account_data->store_account->last_updated;
- if (!modest_account_mgr_account_is_busy(account_mgr, account_data->account_name))
- {
+ if (!modest_account_mgr_account_is_busy(account_mgr, account_data->account_name)) {
if (last_updated > 0)
- last_updated_string = modest_text_utils_get_display_date(last_updated);
+ last_updated_string = modest_text_utils_get_display_date(last_updated);
else
- last_updated_string = g_strdup (_("mcen_va_never"));
- }
- else
- {
+ last_updated_string = g_strdup (_("mcen_va_never"));
+ } else {
/* FIXME: There should be a logical name in the UI specs */
- last_updated_string = g_strdup(_("Refreshing..."));
+ last_updated_string = g_strdup(_("..."));
}
return last_updated_string;
}
* current use instead */
cursor = account_names = modest_account_mgr_account_names (account_mgr,
TRUE /* only enabled accounts. */);
-
- if (!account_names)
- g_warning ("debug: modest_account_mgr_account_names() returned NULL\n");
while (cursor) {
gchar *account_name;
}
}
-
-static void
-on_account_changed (ModestAccountMgr *account_mgr,
- const gchar* account, GSList *keys,
- gboolean server_account, ModestAccountView *self)
-{
- /* Never update the view in response to gconf changes.
- * Always do it explicitly instead.
- * This is because we have no way to avoid 10 updates when changing
- * 10 items, and this blocks the UI.
- *
- * But this block/unblock API might be useful on platforms where the
- * notification does not happen so long after the key was set.
- * (We have no way to know when the last key was set, to do a final update)..
- */
-
- update_account_view (account_mgr, self);
-}
-
static void
-on_account_busy_changed(ModestAccountMgr *account_mgr, const gchar *account_name,
- gboolean busy, ModestAccountView *self)
+on_account_busy_changed(ModestAccountMgr *account_mgr,
+ const gchar *account_name,
+ gboolean busy,
+ ModestAccountView *self)
{
GtkListStore *model = GTK_LIST_STORE(gtk_tree_view_get_model (GTK_TREE_VIEW(self)));
GtkTreeIter iter;
}
static void
+on_account_inserted (TnyAccountStore *account_store,
+ TnyAccount *account,
+ gpointer user_data)
+{
+ ModestAccountView *self;
+ ModestAccountViewPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_VIEW (user_data));
+
+ self = MODEST_ACCOUNT_VIEW (user_data);
+ priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE (self);
+
+ update_account_view (priv->account_mgr, self);
+}
+
+static void
on_account_removed (TnyAccountStore *account_store,
TnyAccount *account,
gpointer user_data)
ModestAccountView *self;
ModestAccountViewPrivate *priv;
+ g_return_if_fail (MODEST_IS_ACCOUNT_VIEW (user_data));
+
self = MODEST_ACCOUNT_VIEW (user_data);
priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE (self);
- update_account_view (priv->account_mgr, MODEST_ACCOUNT_VIEW (user_data));
+ update_account_view (priv->account_mgr, self);
}
-/* currently unused */
-#if 0
static void
-on_account_enable_toggled (GtkCellRendererToggle *cell_renderer, gchar *path,
- ModestAccountView *self)
+on_account_changed (TnyAccountStore *account_store,
+ TnyAccount *account,
+ gpointer user_data)
{
- GtkTreeIter iter;
- ModestAccountViewPrivate *priv;
- GtkTreeModel *model;
- gchar *account_name;
- gboolean enabled;
+ ModestAccountView *self = NULL;
+ ModestAccountViewPrivate *priv = NULL;
+ TnyTransportAccount *transport_account = NULL;
+ ModestTnySendQueue *send_queue = NULL;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_VIEW (user_data));
+ g_return_if_fail (account);
+ g_return_if_fail (TNY_IS_ACCOUNT (account));
+
+ self = MODEST_ACCOUNT_VIEW (user_data);
+ priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE (self);
- priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(self);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW(self));
+ g_warning ("account changed: %s", tny_account_get_id(account));
- if (!gtk_tree_model_get_iter_from_string (model, &iter, path)) {
- g_printerr ("modest: cannot find iterator\n");
- return;
+ /* Update account view */
+ update_account_view (priv->account_mgr, self);
+
+ /* Get transport account */
+ const gchar *modest_account_name =
+ modest_tny_account_get_parent_modest_account_name_for_server_account (account);
+ g_return_if_fail (modest_account_name);
+
+ transport_account = (TnyTransportAccount*)
+ modest_tny_account_store_get_transport_account_for_open_connection (modest_runtime_get_account_store(),
+ modest_account_name);
+
+ /* Restart send queue */
+ if (transport_account) {
+ g_return_if_fail (TNY_IS_TRANSPORT_ACCOUNT(transport_account));
+ send_queue = modest_runtime_get_send_queue (transport_account);
+ g_return_if_fail (MODEST_IS_TNY_SEND_QUEUE(send_queue));
+ modest_tny_send_queue_try_to_send (send_queue);
+
+ g_object_unref (transport_account);
}
- gtk_tree_model_get (model, &iter, MODEST_ACCOUNT_VIEW_IS_ENABLED_COLUMN, &enabled,
- MODEST_ACCOUNT_VIEW_NAME_COLUMN, &account_name,
- -1);
-
- /* toggle enabled / disabled */
- modest_account_mgr_set_enabled (priv->account_mgr, account_name, !enabled);
- g_free (account_name);
}
-#endif
+
+
static gboolean
find_default_account(ModestAccountView *self, GtkTreeIter *iter)
on_account_default_toggled (GtkCellRendererToggle *cell_renderer, gchar *path,
ModestAccountView *self)
{
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_VIEW (self));
+
gboolean is_default = gtk_cell_renderer_toggle_get_active (cell_renderer);
if (is_default) {
/* Do not allow an account to be marked non-default.
GtkListStore *model;
GtkTreeViewColumn *column;
+ g_return_if_fail (MODEST_IS_ACCOUNT_VIEW (self));
priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(self);
model = gtk_list_store_new (6,
*
* djcb: indeed, they have been removed for post-bora, i added the ifdefs...
*/
-#ifdef MODEST_HILDON_VERSION_0
+#ifdef MODEST_HAVE_HILDON0_WIDGETS
g_object_set(G_OBJECT(self), "allow-checkbox-mode", FALSE, NULL);
g_object_set(G_OBJECT(toggle_renderer), "checkbox-mode", FALSE, NULL);
-#endif /*MODEST_HILDON_VERSION_0 */
+#endif /* MODEST_HAVE_HILDON0_WIDGETS */
+
g_signal_connect (G_OBJECT(toggle_renderer), "toggled", G_CALLBACK(on_account_default_toggled),
self);
*/
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(self), TRUE);
- priv->sig1 = g_signal_connect (G_OBJECT (modest_runtime_get_account_store ()),"account_removed",
- G_CALLBACK(on_account_removed), self);
- priv->sig2 = g_signal_connect (G_OBJECT(priv->account_mgr), "account_changed",
- G_CALLBACK(on_account_changed), self);
- priv->sig3 = g_signal_connect (G_OBJECT(priv->account_mgr), "account_busy_changed",
- G_CALLBACK(on_account_busy_changed), self);
-}
+ priv->acc_removed_handler = g_signal_connect (G_OBJECT (modest_runtime_get_account_store ()),
+ "account_removed",
+ G_CALLBACK(on_account_removed), self);
+
+ priv->acc_inserted_handler = g_signal_connect (G_OBJECT (modest_runtime_get_account_store ()),
+ "account_inserted",
+ G_CALLBACK(on_account_inserted), self);
+ priv->acc_inserted_handler = g_signal_connect (G_OBJECT (modest_runtime_get_account_store ()),
+ "account_changed",
+ G_CALLBACK(on_account_changed), self);
+
+ priv->acc_busy_changed_handler = g_signal_connect (G_OBJECT(priv->account_mgr),
+ "account_busy_changed",
+ G_CALLBACK(on_account_busy_changed), self);
+}
ModestAccountView*