X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fgnome%2Fmodest-store-widget.c;h=8583343f0c8557d12b858a889471c9db9fabd35f;hb=81d949c4ed42a31732c189d6274434b62251fba9;hp=d536e4a2bbcb896a4787dc94c943296392153410;hpb=3e7a3b4e5759d63285d8795435b2ceedaf63b216;p=modest diff --git a/src/gnome/modest-store-widget.c b/src/gnome/modest-store-widget.c index d536e4a..8583343 100644 --- a/src/gnome/modest-store-widget.c +++ b/src/gnome/modest-store-widget.c @@ -48,11 +48,16 @@ struct _ModestStoreWidgetPrivate { GtkWidget *servername; GtkWidget *username; + + ModestProtoList *security_protos; GtkWidget *security; + + ModestProtoList *auth_protos; GtkWidget *auth; + GtkWidget *chooser; - ModestProtocol proto; + ModestTransportStoreProtocol proto; }; #define MODEST_STORE_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ MODEST_TYPE_STORE_WIDGET, \ @@ -115,7 +120,7 @@ modest_store_widget_init (ModestStoreWidget *obj) ModestStoreWidgetPrivate *priv; priv = MODEST_STORE_WIDGET_GET_PRIVATE(obj); - priv->proto = MODEST_PROTOCOL_UNKNOWN; + priv->proto = MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN; } @@ -195,7 +200,6 @@ on_entry_changed (GtkEntry *entry, gpointer user_data) static GtkWidget* imap_pop_configuration (ModestStoreWidget *self) { - ModestPairList *protos; ModestStoreWidgetPrivate *priv; GtkWidget *label, *box, *hbox; @@ -226,9 +230,12 @@ imap_pop_configuration (ModestStoreWidget *self) gtk_label_set_markup (GTK_LABEL(label),_("Security")); gtk_box_pack_start (GTK_BOX(box), label, FALSE, FALSE, 0); - protos = modest_protocol_info_get_protocol_pair_list (MODEST_PROTOCOL_TYPE_SECURITY); - priv->security = modest_combo_box_new (protos, g_str_equal); - modest_pair_list_free (protos); + /* Note: This ModestPairList* must exist for as long as the combo + * that uses it, because the ModestComboBox uses the ID opaquely, + * so it can't know how to manage its memory. */ + priv->security_protos = modest_protocol_info_get_connection_protocol_pair_list (); + + priv->security = modest_combo_box_new (priv->security_protos, g_str_equal); hbox = gtk_hbox_new (FALSE, 6); label = gtk_label_new(NULL); @@ -243,9 +250,11 @@ imap_pop_configuration (ModestStoreWidget *self) gtk_label_set_text (GTK_LABEL(label),_("Authentication:")); gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 6); - protos = modest_protocol_info_get_protocol_pair_list (MODEST_PROTOCOL_TYPE_AUTH); - priv->auth = modest_combo_box_new (protos, g_str_equal); - modest_pair_list_free (protos); + /* Note: This ModestPairList* must exist for as long as the combo + * that uses it, because the ModestComboBox uses the ID opaquely, + * so it can't know how to manage its memory. */ + priv->auth_protos = modest_protocol_info_get_auth_protocol_pair_list (; + priv->auth = modest_combo_box_new (priv->auth_protos, g_str_equal); gtk_box_pack_start (GTK_BOX(hbox), priv->auth, FALSE, FALSE, 0); @@ -262,13 +271,19 @@ imap_pop_configuration (ModestStoreWidget *self) static void modest_store_widget_finalize (GObject *obj) { + ModestStoreWidgetPrivate *priv = MODEST_STORE_WIDGET_GET_PRIVATE(obj); + + /* These had to stay alive for as long as the comboboxes that used them: */ + modest_pair_list_free (priv->security_protos); + modest_pair_list_free (priv->auth_protos); + G_OBJECT_CLASS(parent_class)->finalize (obj); } GtkWidget* -modest_store_widget_new (ModestProtocol proto) +modest_store_widget_new (ModestTransportStoreProtocol proto) { GObject *obj; GtkWidget *w; @@ -327,12 +342,12 @@ modest_store_widget_get_servername (ModestStoreWidget *self) } -ModestProtocol +ModestTransportStoreProtocol modest_store_widget_get_proto (ModestStoreWidget *self) { ModestStoreWidgetPrivate *priv; - g_return_val_if_fail (self, MODEST_PROTOCOL_UNKNOWN); + g_return_val_if_fail (self, MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN); priv = MODEST_STORE_WIDGET_GET_PRIVATE(self); return priv->proto; @@ -344,7 +359,7 @@ modest_store_widget_get_path (ModestStoreWidget *self) { ModestStoreWidgetPrivate *priv; - g_return_val_if_fail (self, MODEST_PROTOCOL_UNKNOWN); + g_return_val_if_fail (self, NULL); priv = MODEST_STORE_WIDGET_GET_PRIVATE(self); if (GTK_IS_FILE_CHOOSER(priv->chooser)) @@ -353,38 +368,38 @@ modest_store_widget_get_path (ModestStoreWidget *self) return NULL; } -static ModestProtocol -get_protocol_from_combo (GtkWidget *combo) +static gint +get_value_from_combo (GtkWidget *combo) { gchar *chosen; if (!combo) - return MODEST_PROTOCOL_UNKNOWN; + return -1; chosen = gtk_combo_box_get_active_text (GTK_COMBO_BOX (combo)); - return modest_protocol_info_get_protocol (chosen); + return modest_protocol_info_get_transport_store_protocol (chosen); } -ModestProtocol +ModestAuthProtocol modest_store_widget_get_auth (ModestStoreWidget *self) { ModestStoreWidgetPrivate *priv; - g_return_val_if_fail (self, MODEST_PROTOCOL_UNKNOWN); + g_return_val_if_fail (self, MODEST_PROTOCOL_AUTH_NONE); priv = MODEST_STORE_WIDGET_GET_PRIVATE(self); - return get_protocol_from_combo (priv->auth); + return get_value_from_combo (priv->auth); } -ModestProtocol +ModestConnectionProtocol modest_store_widget_get_security (ModestStoreWidget *self) { ModestStoreWidgetPrivate *priv; - g_return_val_if_fail (self, MODEST_PROTOCOL_UNKNOWN); + g_return_val_if_fail (self, MODEST_PROTOCOL_CONNECTION_NORMAL); priv = MODEST_STORE_WIDGET_GET_PRIVATE(self); - return get_protocol_from_combo (priv->security); + return get_value_from_combo (priv->security); }