-/* modest-ui.c */
-
-/* insert (c)/licensing information) */
+/* Copyright (c) 2006, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
#include <gtk/gtk.h>
#include <glade/glade.h>
static void modest_ui_init (ModestUI *obj);
static void modest_ui_finalize (GObject *obj);
-static void modest_ui_window_destroy (GtkWidget *win, GdkEvent *event, gpointer data);
+//static void modest_ui_window_destroy (GtkWidget *win, GdkEvent *event, gpointer data);
static void modest_ui_last_window_closed (GObject *obj, gpointer data);
-static void on_password_requested (ModestTnyAccountStore *account_store, const gchar *account_name, gpointer user_data);
+gchar *on_password_requested (TnyAccountIface *, const gchar *, gboolean *);
/* list my signals */
enum {
priv->header_view = NULL;
priv->message_view = NULL;
priv->current_folder = NULL;
+ priv->program = NULL;
}
g_return_if_fail (MODEST_IS_TNY_FOLDER_TREE_VIEW (priv->folder_view));
g_return_if_fail (MODEST_IS_TNY_HEADER_TREE_VIEW (priv->header_view));
- modest_tny_header_tree_view_set_folder (priv->header_view, NULL);
+ modest_tny_header_tree_view_set_folder (MODEST_TNY_HEADER_TREE_VIEW(priv->header_view),
+ NULL);
- modest_tny_folder_tree_view_update_model(priv->folder_view, account_store);
+ modest_tny_folder_tree_view_update_model(MODEST_TNY_FOLDER_TREE_VIEW(priv->folder_view),
+ TNY_ACCOUNT_STORE(account_store));
}
-GObject*
+ModestUI*
modest_ui_new (ModestConf *modest_conf)
{
GObject *obj;
g_warning ("could not create ModestAccountMgr instance");
g_object_unref (obj);
return NULL;
- }
+ }
modest_id_mgr = MODEST_IDENTITY_MGR(modest_identity_mgr_new (modest_conf));
if (!modest_id_mgr) {
if (!account_store_iface) {
g_warning ("could not initialze ModestTnyAccountStore");
return NULL;
- }
- g_signal_connect (account_store_iface, "password_requested",
- G_CALLBACK(on_password_requested),
- NULL);
+ }
+
+ modest_tny_account_store_set_get_pass_func(MODEST_TNY_ACCOUNT_STORE(account_store_iface),
+ on_password_requested);
+
g_signal_connect (account_store_iface, "accounts_reloaded",
G_CALLBACK(on_accounts_reloaded), priv);
G_CALLBACK(modest_ui_last_window_closed),
NULL);
- account_names_list = modest_account_mgr_server_account_names(modest_acc_mgr,
- NULL, MODEST_PROTO_TYPE_ANY, NULL, FALSE);
+ account_names_list = modest_account_mgr_search_server_accounts (modest_acc_mgr,
+ NULL, MODEST_PROTO_TYPE_ANY, NULL, FALSE);
identities_list = modest_identity_mgr_identity_names(modest_id_mgr, NULL);
if (!(account_names_list != NULL || identities_list != NULL))
wizard_account_dialog(MODEST_UI(obj));
g_slist_free(account_names_list);
g_slist_free(identities_list);
- return obj;
+ return MODEST_UI(obj);
}
}
-static void
-on_password_requested (ModestTnyAccountStore *account_store,
- const gchar *account_name,
- gpointer user_data) {
+gchar *
+on_password_requested (TnyAccountIface *account,
+ const gchar *prompt,
+ gboolean *cancel) {
GtkWidget *passdialog;
GtkWidget *vbox;
+ GtkWidget *infoscroll;
GtkWidget *infolabel;
GtkWidget *passentry;
- gint retval;
- const gchar *infostring = g_strconcat(_("Please enter the password for "), account_name, ".", NULL);
+ GtkTextBuffer *infobuffer;
+ gchar *retval;
+ gint result;
passdialog = gtk_dialog_new_with_buttons(_("Password"),
NULL,
vbox = gtk_vbox_new(FALSE, 0);
- infolabel = gtk_label_new(infostring);
+ infobuffer = gtk_text_buffer_new (NULL);
+ gtk_text_buffer_set_text(infobuffer, prompt, -1);
+ infoscroll = gtk_scrolled_window_new(NULL, NULL);
+ infolabel = gtk_text_view_new_with_buffer(infobuffer);
+ gtk_container_add(GTK_CONTAINER(infoscroll), infolabel);
passentry = gtk_entry_new();
- gtk_entry_set_visibility(passentry, FALSE);
+ gtk_entry_set_visibility(GTK_ENTRY(passentry), FALSE);
- gtk_box_pack_start(GTK_BOX(GTK_DIALOG(passdialog)->vbox), infolabel, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(GTK_DIALOG(passdialog)->vbox), infoscroll, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(passdialog)->vbox), passentry, FALSE, FALSE, 0);
gtk_widget_show_all(passdialog);
- retval = gtk_dialog_run (GTK_DIALOG(passdialog));
+ result = gtk_dialog_run (GTK_DIALOG(passdialog));
- switch (retval) {
+ switch (result) {
case GTK_RESPONSE_ACCEPT:
- modest_account_mgr_set_server_account_string(modest_tny_account_store_get_accout_mgr(account_store),
- account_name,
- "password",
- gtk_entry_get_text(GTK_ENTRY(passentry)),
- NULL);
+ retval = g_strdup(gtk_entry_get_text(GTK_ENTRY(passentry)));
+ *cancel=FALSE;
break;
- case GTK_RESPONSE_CANCEL:
- /* FIXME:
- * What happens, if canceled?"
- */
+ default:
+ retval = g_strdup("");;
+ *cancel=TRUE;
break;
}
+ gtk_widget_hide(passdialog);
gtk_widget_destroy (passdialog);
+ while (gtk_events_pending()){
+ g_message("iterating over pending events");
+ gtk_main_iteration();
+ }
+
+ return retval;
}
free(account_name);
}
-
-