* update to new iterator API in tinymail
[modest] / src / hildon / modest-ui-message-editor.c
index b8e40a5..d0d6170 100644 (file)
@@ -1,3 +1,33 @@
+/* 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>
 #include <glib/gi18n.h>
@@ -87,7 +117,7 @@ close_edit_window (GtkWidget *win, GdkEvent *event, gpointer data)
        if (modest_editor_window_get_modified(edit_win)) {
                if (close_edit_confirm_dialog(edit_win)) {
                        gtk_widget_hide (GTK_WIDGET(edit_win->window));
-                       modest_window_mgr_unregister(priv->modest_window_mgr, HILDON_WINDOW (edit_win->window));
+                       modest_window_mgr_unregister(priv->modest_window_mgr, G_OBJECT(edit_win->window));
                        hildon_program_remove_window (priv->program, HILDON_WINDOW (edit_win->window));
                        g_object_unref(edit_win);
                        g_message("closing window");
@@ -96,7 +126,7 @@ close_edit_window (GtkWidget *win, GdkEvent *event, gpointer data)
                }
        } else {
                gtk_widget_hide (GTK_WIDGET(edit_win->window));
-               modest_window_mgr_unregister(priv->modest_window_mgr, HILDON_WINDOW (edit_win->window));
+               modest_window_mgr_unregister(priv->modest_window_mgr, G_OBJECT (edit_win->window));
                hildon_program_remove_window (priv->program, HILDON_WINDOW (edit_win->window));
                g_object_unref(edit_win);
                g_message("closing window");
@@ -517,7 +547,8 @@ on_send_button_clicked (GtkWidget *widget, ModestEditorWindow *modest_editwin)
        GtkTextIter start, end;
        GtkTextBuffer *buf;
        TnyAccountStoreIface *account_store;
-       const GList *transport_accounts;
+       TnyListIface *transport_accounts;
+       TnyIteratorIface *iter;
        TnyTransportAccountIface *transport_account;
        ModestIdentityMgr *id_mgr;
        EditWinData *win_data;
@@ -535,15 +566,23 @@ on_send_button_clicked (GtkWidget *widget, ModestEditorWindow *modest_editwin)
        priv = MODEST_UI_GET_PRIVATE(modest_ui);
 
        account_store = priv->account_store;
-       transport_accounts =
-               tny_account_store_iface_get_transport_accounts (account_store);
-       if (!transport_accounts) {
+
+       transport_accounts = tny_list_new ();
+       tny_account_store_iface_get_accounts (priv->account_store,
+                                             transport_accounts,
+                                             TNY_ACCOUNT_STORE_IFACE_TRANSPORT_ACCOUNTS);      
+       tny_list_iface_create_iterator (transport_accounts);
+
+       iter = tny_list_iface_create_iterator(transport_accounts);
+       if (!tny_iterator_iface_first(iter))   {
                g_message ("cannot send message: no transport account defined");
                return;
        } else /* take the first one! */
                transport_account =
-                       TNY_TRANSPORT_ACCOUNT_IFACE(transport_accounts->data);
-
+                       TNY_TRANSPORT_ACCOUNT_IFACE(tny_iterator_iface_current(iter));
+       g_object_unref (iter);
+       g_object_unref (transport_accounts);
+       
        to_entry      = glade_xml_get_widget (win_data->glade_xml, "to_entry");
        subject_entry = glade_xml_get_widget (win_data->glade_xml, "subject_entry");
        body_view     = glade_xml_get_widget (win_data->glade_xml, "body_view");