* Makefile.am:
[modest] / src / modest-widget-factory.c
index cf0c97c..350c60f 100644 (file)
 #include <tny-gtk-account-list-model.h>
 #include <tny-gtk-folder-store-tree-model.h>
 #include <tny-account-store.h>
+#include <tny-simple-list.h>
 #include <tny-device.h>
 #include <tny-folder-store-query.h>
 #include "modest-widget-factory.h"
 #include "modest-widget-memory.h"
-#include "modest-protocol-mgr.h"
+#include <modest-protocol-info.h>
 #include "modest-tny-platform-factory.h"
 #include "modest-account-mgr.h"
 #include "modest-mail-operation.h"
@@ -59,7 +60,6 @@ typedef struct _ModestWidgetFactoryPrivate ModestWidgetFactoryPrivate;
 struct _ModestWidgetFactoryPrivate {
        
        TnyPlatformFactory          *fact;
-       ModestProtocolMgr           *proto_mgr;
        TnyAccountStore             *account_store;
        
        ModestHeaderView            *header_view;
@@ -125,7 +125,6 @@ modest_widget_factory_init (ModestWidgetFactory *obj)
 
        priv->fact          = modest_tny_platform_factory_get_instance ();
        priv->account_store = tny_platform_factory_new_account_store (priv->fact);
-       priv->proto_mgr     = modest_protocol_mgr_new ();
        
        priv->progress_bar = gtk_progress_bar_new ();
        gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(priv->progress_bar),
@@ -142,11 +141,6 @@ modest_widget_factory_finalize (GObject *obj)
        ModestWidgetFactoryPrivate *priv;
        priv = MODEST_WIDGET_FACTORY_GET_PRIVATE(obj);
 
-       if (priv->proto_mgr) {
-               g_object_unref (G_OBJECT(priv->proto_mgr));
-               priv->proto_mgr = NULL;
-       }
-
        G_OBJECT_CLASS(parent_class)->finalize (obj);
 }
 
@@ -173,12 +167,11 @@ init_widgets (ModestWidgetFactory *self)
        /* header view */
        if (!(priv->header_view =
              MODEST_HEADER_VIEW(modest_header_view_new
-                                (NULL, NULL,MODEST_HEADER_VIEW_STYLE_NORMAL)))) {
+                                (NULL, NULL,0)))) {
                g_printerr ("modest: cannot instantiate header view\n");
                return FALSE;
        }
-       
-       
+               
        /* msg preview */
        if (!(priv->msg_preview = MODEST_MSG_VIEW(modest_msg_view_new (NULL)))) {
                g_printerr ("modest: cannot instantiate header view\n");
@@ -208,7 +201,7 @@ modest_widget_factory_new (void)
 
        obj  = g_object_new (MODEST_TYPE_WIDGET_FACTORY, NULL); 
        priv = MODEST_WIDGET_FACTORY_GET_PRIVATE(obj);
-
+       
        if (!init_widgets (MODEST_WIDGET_FACTORY(obj))) {
                g_printerr ("modest: widget factory failed to init widgets\n");
                g_object_unref (obj);
@@ -312,11 +305,50 @@ get_transports (ModestWidgetFactory *self)
 }
 
 
+#if 0
+static const GSList*
+get_stores (ModestWidgetFactory *self, gboolean only_remote)
+{
+       ModestWidgetFactoryPrivate *priv;
+       TnyAccountStore *account_store;
+       TnyList *stores;
+       TnyIterator *iter;
+       
+       priv = MODEST_WIDGET_FACTORY_GET_PRIVATE(self);
+
+       account_store =
+               tny_platform_factory_new_account_store (priv->fact);                    
+
+       stores = tny_simple_list_new ();
+       tny_account_store_get_accounts (account_store, stores,
+                                        TNY_ACCOUNT_STORE_STORE_ACCOUNTS);
+
+       /* simply return all the stores */
+       if (!only_remote)
+               return stores;
+
+       /*  remove the non-remote stores from the list */
+       if (only_remote) {
+               iter = tny_list_create_iterator (stores);
+               while (!tny_iterator_is_done (iter)) {
+                       TnyAccount *acc = (TnyAccount*)tny_iterator_get_current(iter);
+                       /* is it a local account? if so, remove */
+                       ModestProtocol proto = modest_protocol_info_get_protocol (tny_account_get_proto(acc));
+                       if (modest_protocol_info_protocol_is_local_store(proto))
+                               tny_list_remove (stores, acc); /* FIXME: iter still valid? */
+                       tny_iterator_next (iter);
+               }
+               g_object_unref (G_OBJECT(iter));
+       }
+       return stores;          
+}
+#endif
+
 GtkWidget*
 modest_widget_factory_get_combo_box (ModestWidgetFactory *self, ModestComboBoxType type)
 {
        ModestWidgetFactoryPrivate *priv;
-       const GSList *list = NULL;
+       ModestPairList *protos = NULL;
        GtkWidget* combo_box;
        
        g_return_val_if_fail (self, NULL);
@@ -325,26 +357,34 @@ modest_widget_factory_get_combo_box (ModestWidgetFactory *self, ModestComboBoxTy
        
        switch (type) {
        case MODEST_COMBO_BOX_TYPE_STORE_PROTOS:
-               list = modest_protocol_mgr_get_store_protocols (priv->proto_mgr);
+               protos = modest_protocol_info_get_protocol_pair_list (MODEST_PROTOCOL_TYPE_STORE);
                break;
        case MODEST_COMBO_BOX_TYPE_TRANSPORT_PROTOS:
-               list = modest_protocol_mgr_get_transport_protocols (priv->proto_mgr);
+               protos = modest_protocol_info_get_protocol_pair_list (MODEST_PROTOCOL_TYPE_TRANSPORT);
                break;
        case MODEST_COMBO_BOX_TYPE_SECURITY_PROTOS:
-               list = modest_protocol_mgr_get_security_protocols (priv->proto_mgr);
+               protos = modest_protocol_info_get_protocol_pair_list (MODEST_PROTOCOL_TYPE_SECURITY);
                break;
        case MODEST_COMBO_BOX_TYPE_AUTH_PROTOS:
-               list = modest_protocol_mgr_get_auth_protocols (priv->proto_mgr);
+               protos = modest_protocol_info_get_protocol_pair_list (MODEST_PROTOCOL_TYPE_AUTH);
                break;
        case MODEST_COMBO_BOX_TYPE_TRANSPORTS:
-               list = get_transports (self);
+               protos = get_transports (self);
                break;
+/*     case MODEST_COMBO_BOX_TYPE_REMOTE_STORES: */
+/*             // FIXME */
+/*             list = get_stores (self, TRUE); /\* get all *remote* stores *\/ */
+/*             combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL(list)); */
+/*             g_object_unref (G_OBJECT(list)); */
+/*             //return combo_box; */
        default:
                g_warning ("invalid combo box type: %d", type);
                return NULL;
        }
 
-       combo_box = modest_combo_box_new (list);
+       combo_box = modest_combo_box_new (protos);
+       modest_pair_list_free (protos);
+       
        gtk_combo_box_set_active (GTK_COMBO_BOX(combo_box), 0);
        
        return combo_box;