Pass to account protocol request to handle the calendar
authorJosé Dapena Paz <jdapena@igalia.com>
Thu, 17 Dec 2009 16:29:43 +0000 (17:29 +0100)
committerJosé Dapena Paz <jdapena@igalia.com>
Mon, 18 Jan 2010 16:12:37 +0000 (17:12 +0100)
src/modest-account-protocol.c
src/modest-account-protocol.h
src/widgets/modest-msg-view-window.c

index a995db2..850be4e 100644 (file)
@@ -133,6 +133,11 @@ static void modest_account_protocol_save_remote_draft_default (ModestAccountProt
                                                               TnyMsg *old_msg,
                                                               ModestAccountProtocolSaveRemoteDraftCallback callback,
                                                               gpointer userdata);
+static gboolean
+modest_account_protocol_handle_calendar_default (ModestAccountProtocol *self,
+                                                ModestWindow *window,
+                                                TnyMimePart *calendar_part,
+                                                GtkContainer *container);
 
 /* globals */
 static GObjectClass *parent_class = NULL;
@@ -242,6 +247,8 @@ modest_account_protocol_class_init (ModestAccountProtocolClass *klass)
                modest_account_protocol_get_service_icon_default;
        account_class->save_remote_draft =
                modest_account_protocol_save_remote_draft_default;
+       account_class->handle_calendar =
+               modest_account_protocol_handle_calendar_default;
 
 }
 
@@ -903,3 +910,21 @@ modest_account_protocol_save_remote_draft_default (ModestAccountProtocol *self,
        }
 }
 
+gboolean
+modest_account_protocol_handle_calendar (ModestAccountProtocol *self,
+                                        ModestWindow *window,
+                                        TnyMimePart *calendar_part,
+                                        GtkContainer *container)
+{
+       return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->handle_calendar (self, window, 
+                                                                         calendar_part, container);
+}
+
+static gboolean
+modest_account_protocol_handle_calendar_default (ModestAccountProtocol *self,
+                                                ModestWindow *window,
+                                                TnyMimePart *calendar_part,
+                                                GtkContainer *container)
+{
+       return FALSE;
+}
index f773f61..16e8e44 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "widgets/modest-account-settings-dialog.h"
 #include "modest-protocol.h"
+#include "widgets/modest-window.h"
 #include "widgets/modest-wizard-dialog.h"
 #include "modest-pair.h"
 #include <tny-account.h>
@@ -114,8 +115,12 @@ struct _ModestAccountProtocolClass {
                                                 TnyStatusCallback status_callback, 
                                                 gpointer user_data);
 
+       gboolean (*handle_calendar) (ModestAccountProtocol *protocol,
+                                    ModestWindow *window,
+                                    TnyMimePart *calendar_part,
+                                    GtkContainer *container);
+
        /* Padding for future expansions */
-       void (*_reserved8) (void);
        void (*_reserved9) (void);
        void (*_reserved10) (void);
        void (*_reserved11) (void);
@@ -545,6 +550,23 @@ gboolean modest_account_protocol_decode_part_to_stream_async (ModestAccountProto
                                                              TnyStatusCallback status_callback, 
                                                              gpointer user_data);
 
+/**
+ * modest_account_protocol_handle_calendar:
+ * @self: a #ModestAccountProtocol
+ * @window: the #ModestWindow requesting to handle calendar
+ * @calendar_part: a #TnyMimePart
+ * @container: a #GtkContainer (a #GtkVBox now)
+ *
+ * Instruct the account protocol to handle a calendar mime part. The account protocol
+ * will fill @container with the controls to handle the @calendar invitation.
+ *
+ * Returns: %TRUE if account protocol handles the calendar request, %FALSE otherwise
+ */
+gboolean modest_account_protocol_handle_calendar (ModestAccountProtocol *self,
+                                                 ModestWindow *window,
+                                                 TnyMimePart *calendar_part,
+                                                 GtkContainer *container);
+
 
 G_END_DECLS
 
index 4883400..7580a2f 100644 (file)
@@ -250,6 +250,8 @@ static gboolean _modest_msg_view_window_map_event (GtkWidget *widget,
                                                   gpointer userdata);
 static void update_branding (ModestMsgViewWindow *self);
 static void sync_flags      (ModestMsgViewWindow *self);
+static gboolean on_handle_calendar (ModestMsgView *msgview, TnyMimePart *calendar_part, 
+                                   GtkContainer *container, ModestMsgViewWindow *self);
 
 static gboolean on_realize (GtkWidget *widget,
                            gpointer userdata);
@@ -841,6 +843,8 @@ modest_msg_view_window_construct (ModestMsgViewWindow *self,
                          G_CALLBACK (modest_ui_actions_on_msg_link_contextual), obj);
        g_signal_connect (G_OBJECT(priv->msg_view), "limit_error",
                          G_CALLBACK (modest_ui_actions_on_limit_error), obj);
+       g_signal_connect (G_OBJECT(priv->msg_view), "handle_calendar",
+                         G_CALLBACK (on_handle_calendar), obj);
        g_signal_connect (G_OBJECT (priv->msg_view), "fetch_image",
                          G_CALLBACK (on_fetch_image), obj);
 
@@ -4173,3 +4177,27 @@ on_realize (GtkWidget *widget,
        return FALSE;
 }
 #endif
+
+static gboolean
+on_handle_calendar (ModestMsgView *msgview, TnyMimePart *calendar_part, GtkContainer *container, ModestMsgViewWindow *self)
+{
+       const gchar *account_name;
+       ModestProtocolType proto_type;
+       ModestProtocol *protocol;
+       gboolean retval = FALSE;
+
+       account_name = modest_window_get_active_account (MODEST_WINDOW (self));
+       
+       /* Get proto */
+       proto_type = modest_account_mgr_get_store_protocol (modest_runtime_get_account_mgr (), 
+                                                           account_name);
+       protocol = 
+               modest_protocol_registry_get_protocol_by_type (modest_runtime_get_protocol_registry (), 
+                                                              proto_type);
+
+       if (MODEST_IS_ACCOUNT_PROTOCOL (protocol)) {
+               retval = modest_account_protocol_handle_calendar (MODEST_ACCOUNT_PROTOCOL (protocol), MODEST_WINDOW (self),
+                                                                 calendar_part, container);
+       }
+       return retval;
+}