Changeset 1213

Show
Ignore:
Timestamp:
11/23/06 20:30:29
Author:
pvanhoof
Message:

Support for rfc822

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r1212 r1213  
     12006-11-23  Philip van Hoof <pvanhoof@gnome.org> 
     2 
     3        * Major fixes and refactoring for the rfc822 support 
     4        * Reimplemented TnyGtkMsgWindow 
     5        * Added a tny_msg_view_create_new_mytype API 
     6 
     7        * This was a major API change in libtinymailui & libtinymailui-gtk 
     8 
    192006-11-23  Sergio Villar Senin <svillar@igalia.com> 
    210        * libtinymail-camel/tny-camel-folder.c: added support to rename 
     
    614        * libtinymail-gnome-desktop/tny-gnome-account-store.c: removed a small 
    715        leak 
     16 
     17        * This was a major API change in libtinymail 
    818 
    9192006-11-21  Sergio Villar Senin <svillar@igalia.com> 
  • trunk/libtinymailui-gtk/tny-gtk-msg-view.c

    r1209 r1213  
    323323 
    324324 
     325static TnyMsgView* 
     326tny_gtk_msg_view_create_new_mytype (TnyMsgView *self) 
     327{ 
     328        return TNY_GTK_MSG_VIEW_GET_CLASS (self)->create_new_mytype_func (self); 
     329} 
     330 
     331static TnyMsgView* 
     332tny_gtk_msg_view_create_new_mytype_default (TnyMsgView *self) 
     333{ 
     334        return tny_gtk_msg_view_new (); 
     335} 
     336 
    325337static TnyMimePartView* 
    326338tny_gtk_msg_view_create_mime_part_view_for (TnyMsgView *self, TnyMimePart *part) 
     
    351363        } else if (priv->display_rfc822 && tny_mime_part_content_type_is (part, "message/rfc822")) 
    352364        { 
    353                 retval = TNY_MIME_PART_VIEW (tny_gtk_msg_view_new ()); 
     365                retval = TNY_MIME_PART_VIEW (tny_msg_view_create_new_mytype (self)); 
    354366                gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (retval), 
    355367                                        GTK_POLICY_NEVER, GTK_POLICY_NEVER); 
     
    389401tny_mime_part_view_proxy_func_set_part (TnyMimePartView *mpview, TnyMimePart *part) 
    390402{ 
    391                 if (tny_mime_part_content_type_is (part, "message/rfc822")) 
     403 
     404                if (tny_mime_part_content_type_is (part, "message/rfc822") || 
     405                         TNY_IS_GTK_MSG_VIEW (mpview)) 
    392406                { 
    393407                        TnyList *list = tny_simple_list_new (); 
    394  
    395408                        if (TNY_IS_MSG (part) && TNY_IS_GTK_MSG_VIEW (mpview)) 
    396409                        { 
     
    441454                        !TNY_IS_GTK_TEXT_MIME_PART_VIEW (mpview)) 
    442455                {    
    443                         /* An enhanced HTML component? */ 
     456                         
    444457                        if (priv->text_body_viewer) 
    445458                        { 
     
    492505                        tny_mime_part_view_proxy_func_set_part (mpview, part); 
    493506                } 
    494         } 
     507        } else if (!tny_mime_part_content_type_is (part, "multipart/mixed")) 
     508                g_warning (_("I don't have a mime part viewer for %s\n"), 
     509                        tny_mime_part_get_content_type (part)); 
    495510} 
    496511 
     
    753768        klass->clear_func = tny_gtk_msg_view_clear; 
    754769        klass->create_mime_part_view_for_func = tny_gtk_msg_view_create_mime_part_view_for; 
     770        klass->create_new_mytype_func = tny_gtk_msg_view_create_new_mytype; 
    755771 
    756772        return; 
     
    788804        class->clear_func = tny_gtk_msg_view_clear_default; 
    789805        class->create_mime_part_view_for_func = tny_gtk_msg_view_create_mime_part_view_for_default; 
    790          
     806        class->create_new_mytype_func = tny_gtk_msg_view_create_new_mytype_default; 
     807 
    791808        g_type_class_add_private (object_class, sizeof (TnyGtkMsgViewPriv)); 
    792809 
  • trunk/libtinymailui-gtk/tny-gtk-msg-view.h

    r1192 r1213  
    6060        void (*clear_func) (TnyMsgView *self); 
    6161        TnyMimePartView* (*create_mime_part_view_for_func) (TnyMsgView *self, TnyMimePart *part); 
     62        TnyMsgView* (*create_new_mytype_func) (TnyMsgView *self); 
     63 
    6264}; 
    6365 
  • trunk/libtinymailui-gtk/tny-gtk-msg-window.c

    r1107 r1213  
    9191} 
    9292 
     93 
     94 
     95 
     96static void  
     97tny_gtk_msg_window_clear (TnyMsgView *self) 
     98{ 
     99        return TNY_GTK_MSG_WINDOW_GET_CLASS (self)->clear_func (self); 
     100} 
     101 
     102static void  
     103tny_gtk_msg_window_clear_default (TnyMsgView *self) 
     104{ 
     105        TnyGtkMsgWindowPriv *priv = TNY_GTK_MSG_WINDOW_GET_PRIVATE (self); 
     106 
     107        tny_msg_view_clear (priv->msg_view); 
     108 
     109        return; 
     110} 
     111 
     112static TnyMsgView*  
     113tny_gtk_msg_window_create_new_mytype (TnyMsgView *self) 
     114{ 
     115        return TNY_GTK_MSG_WINDOW_GET_CLASS (self)->create_new_mytype_func (self); 
     116} 
     117 
     118static TnyMsgView*  
     119tny_gtk_msg_window_create_new_mytype_default (TnyMsgView *self) 
     120{ 
     121        TnyGtkMsgWindowPriv *priv = TNY_GTK_MSG_WINDOW_GET_PRIVATE (self); 
     122 
     123        /* This should not be a window, but the decorated one, as it has to be  
     124           embeddable within a window. So we even decorate this one as usual. */ 
     125 
     126        return tny_msg_view_create_new_mytype (priv->msg_view); 
     127} 
     128 
     129static TnyMimePartView*  
     130tny_gtk_msg_window_create_mime_part_view_for (TnyMsgView *self, TnyMimePart *part) 
     131{ 
     132        return TNY_GTK_MSG_WINDOW_GET_CLASS (self)->create_mime_part_view_for_func (self, part); 
     133} 
     134 
     135static TnyMimePartView*  
     136tny_gtk_msg_window_create_mime_part_view_for_default (TnyMsgView *self, TnyMimePart *part) 
     137{ 
     138        TnyGtkMsgWindowPriv *priv = TNY_GTK_MSG_WINDOW_GET_PRIVATE (self); 
     139 
     140        return tny_msg_view_create_mime_part_view_for (priv->msg_view, part); 
     141} 
     142 
     143 
     144 
     145static void  
     146tny_gtk_msg_window_mp_clear (TnyMimePartView *self) 
     147{ 
     148        tny_msg_view_clear (TNY_MSG_VIEW (self)); 
     149 
     150        return; 
     151} 
     152 
     153 
     154static void  
     155tny_gtk_msg_window_mp_set_part (TnyMimePartView *self, TnyMimePart *part) 
     156{ 
     157        TNY_GTK_MSG_WINDOW_GET_CLASS (self)->set_part_func (self, part); 
     158        return; 
     159} 
     160 
     161 
     162static void  
     163tny_gtk_msg_window_mp_set_part_default (TnyMimePartView *self, TnyMimePart *part) 
     164{ 
     165        TnyGtkMsgWindowPriv *priv = TNY_GTK_MSG_WINDOW_GET_PRIVATE (self); 
     166 
     167        tny_mime_part_view_set_part (TNY_MIME_PART_VIEW (priv->msg_view), part); 
     168 
     169        return; 
     170} 
     171 
     172 
     173static TnyMimePart*  
     174tny_gtk_msg_window_mp_get_part (TnyMimePartView *self) 
     175{ 
     176        return TNY_GTK_MSG_WINDOW_GET_CLASS (self)->get_part_func (self); 
     177} 
     178 
     179 
     180static TnyMimePart*  
     181tny_gtk_msg_window_mp_get_part_default (TnyMimePartView *self) 
     182{ 
     183        TnyGtkMsgWindowPriv *priv = TNY_GTK_MSG_WINDOW_GET_PRIVATE (self); 
     184 
     185        return tny_mime_part_view_get_part (TNY_MIME_PART_VIEW (priv->msg_view)); 
     186} 
     187 
     188 
    93189/** 
    94190 * tny_gtk_msg_window_new: 
     
    128224tny_gtk_msg_window_finalize (GObject *object) 
    129225{ 
    130         /* Finalization of a GtkWidet removes references */ 
    131  
    132226        (*parent_class->finalize) (object); 
    133227 
     
    136230 
    137231static void 
    138 tny_gtk_msg_window_init (gpointer g, gpointer iface_data) 
    139 { 
    140         return; 
    141 } 
    142  
    143  
    144 static void 
    145 tny_gtk_msg_view_init (gpointer g, gpointer iface_data) 
     232tny_msg_window_init (gpointer g, gpointer iface_data) 
     233{ 
     234        return; 
     235} 
     236 
     237 
     238static void 
     239tny_msg_view_init (gpointer g, gpointer iface_data) 
    146240{ 
    147241        TnyMsgViewIface *klass = (TnyMsgViewIface *)g; 
     
    150244        klass->set_msg_func = tny_gtk_msg_window_set_msg; 
    151245        klass->set_unavailable_func = tny_gtk_msg_window_set_unavailable; 
     246        klass->clear_func = tny_gtk_msg_window_clear; 
     247 
     248        return; 
     249} 
     250 
     251static void 
     252tny_mime_part_view_init (gpointer g, gpointer iface_data) 
     253{ 
     254        TnyMimePartViewIface *klass = (TnyMimePartViewIface *)g; 
     255 
     256        klass->get_part_func = tny_gtk_msg_window_mp_get_part; 
     257        klass->set_part_func = tny_gtk_msg_window_mp_set_part; 
     258        klass->clear_func = tny_gtk_msg_window_mp_clear; 
    152259 
    153260        return; 
     
    165272        class->set_msg_func = tny_gtk_msg_window_set_msg_default; 
    166273        class->set_unavailable_func = tny_gtk_msg_window_set_unavailable_default; 
     274        class->clear_func = tny_gtk_msg_window_clear_default; 
     275        class->create_new_mytype_func = tny_gtk_msg_window_create_new_mytype_default; 
     276        class->create_mime_part_view_for_func = tny_gtk_msg_window_create_mime_part_view_for_default; 
     277 
     278        class->get_part_func = tny_gtk_msg_window_mp_get_part_default; 
     279        class->set_part_func = tny_gtk_msg_window_mp_set_part_default; 
    167280 
    168281        object_class->finalize = tny_gtk_msg_window_finalize; 
     
    194307                }; 
    195308 
    196                 static const GInterfaceInfo tny_gtk_msg_window_info =  
     309                static const GInterfaceInfo tny_msg_window_info =  
    197310                { 
    198                   (GInterfaceInitFunc) tny_gtk_msg_window_init, /* interface_init */ 
     311                  (GInterfaceInitFunc) tny_msg_window_init, /* interface_init */ 
    199312                  NULL,         /* interface_finalize */ 
    200313                  NULL          /* interface_data */ 
    201314                }; 
    202315 
    203                 static const GInterfaceInfo tny_gtk_msg_view_info =  
     316                static const GInterfaceInfo tny_msg_view_info =  
    204317                { 
    205                   (GInterfaceInitFunc) tny_gtk_msg_view_init, /* interface_init */ 
     318                  (GInterfaceInitFunc) tny_msg_view_init, /* interface_init */ 
    206319                  NULL,         /* interface_finalize */ 
    207320                  NULL          /* interface_data */ 
    208321                }; 
    209322 
     323                static const GInterfaceInfo tny_mime_part_view_info =  
     324                { 
     325                  (GInterfaceInitFunc) tny_mime_part_view_init, /* interface_init */ 
     326                  NULL,         /* interface_finalize */ 
     327                  NULL          /* interface_data */ 
     328                }; 
     329 
    210330                type = g_type_register_static (GTK_TYPE_WINDOW, 
    211331                        "TnyGtkMsgWindow", 
    212332                        &info, 0); 
    213333 
     334                g_type_add_interface_static (type, TNY_TYPE_MIME_PART_VIEW,  
     335                        &tny_mime_part_view_info); 
     336 
    214337                g_type_add_interface_static (type, TNY_TYPE_MSG_VIEW,  
    215                         &tny_gtk_msg_view_info); 
     338                        &tny_msg_view_info); 
    216339 
    217340                g_type_add_interface_static (type, TNY_TYPE_MSG_WINDOW,  
    218                         &tny_gtk_msg_window_info); 
     341                        &tny_msg_window_info); 
    219342 
    220343        } 
  • trunk/libtinymailui-gtk/tny-gtk-msg-window.h

    r1097 r1213  
    5959        void (*clear_func) (TnyMsgView *self); 
    6060        TnyMimePartView* (*create_mime_part_view_for_func) (TnyMsgView *self, TnyMimePart *part); 
     61        TnyMsgView* (*create_new_mytype_func) (TnyMsgView *self); 
     62        TnyMimePart* (*get_part_func) (TnyMimePartView *self); 
     63        void (*set_part_func) (TnyMimePartView *self, TnyMimePart *part); 
    6164}; 
    6265 
  • trunk/libtinymailui-mozembed/tny-moz-embed-msg-view.c

    r1192 r1213  
    107107 
    108108 
     109 
     110static TnyMsgView* 
     111tny_moz_embed_msg_view_create_new_mytype (TnyMsgView *self) 
     112{ 
     113        return TNY_MOZ_EMBED_MSG_VIEW_GET_CLASS (self)->create_new_mytype_func (self); 
     114} 
     115 
     116static TnyMsgView* 
     117tny_moz_embed_msg_view_create_new_mytype_default (TnyMsgView *self) 
     118{ 
     119        return tny_moz_embed_msg_view_new (); 
     120} 
     121 
     122 
    109123static void  
    110124tny_moz_embed_msg_view_class_init (TnyMozEmbedMsgViewClass *class) 
     
    116130 
    117131        class->create_mime_part_view_for_func = tny_moz_embed_msg_view_create_mime_part_view_for_default; 
     132        class->create_new_mytype_func = tny_moz_embed_msg_view_create_new_mytype_default; 
    118133 
    119134        object_class->finalize = tny_moz_embed_msg_view_finalize; 
    120135 
    121136        TNY_GTK_MSG_VIEW_CLASS (class)->create_mime_part_view_for_func = tny_moz_embed_msg_view_create_mime_part_view_for; 
     137        TNY_GTK_MSG_VIEW_CLASS (class)->create_new_mytype_func = tny_moz_embed_msg_view_create_new_mytype; 
    122138 
    123139        return; 
  • trunk/libtinymailui-mozembed/tny-moz-embed-msg-view.h

    r1155 r1213  
    4949        /* virtual methods */ 
    5050        TnyMimePartView* (*create_mime_part_view_for_func) (TnyMsgView *self, TnyMimePart *part); 
     51        TnyMsgView* (*create_new_mytype_func) (TnyMsgView *self); 
    5152}; 
    5253 
  • trunk/libtinymailui/tny-msg-view.c

    r1198 r1213  
    2121 
    2222#include <tny-msg-view.h> 
     23 
     24/** 
     25 * tny_msg_view_create_new_mytype: 
     26 * @self: A #TnyMsgView instance 
     27 * 
     28 * Create a new instance of the same type as @self. 
     29 * 
     30 * Implementors: This method should create and return a new #TnyMsgView instance  
     31 * of the same type as @self. This method will be used when a #TnyMsgView needs 
     32 * to create a new instance of itself to display inlined messages (like what 
     33 * message/rfc822 mime parts are). For example the #TnyGtkMsgView implementation 
     34 * will use this method to create for itself a new #TnyMsgView instance that it 
     35 * can embed. 
     36 * 
     37 * Example: 
     38 * <informalexample><programlisting> 
     39 * static TnyMsgView* 
     40 * tny_my_html_msg_view_create_new_mytype (TnyMsgView *self) 
     41 * { 
     42 *    return tny_my_html_msg_view_new (); 
     43 * } 
     44 * </programlisting></informalexample> 
     45 * 
     46 * Note that if you want to pass contructor parameters, that you will have to 
     47 * store them yourself (for example in a static global field in the .c file) and 
     48 * repeat them in the new instance that will be created by this method. 
     49 * 
     50 * Return value: A #TnyMsgView instance 
     51 **/ 
     52TnyMsgView*  
     53tny_msg_view_create_new_mytype (TnyMsgView *self) 
     54{ 
     55#ifdef DEBUG 
     56        if (!TNY_MSG_VIEW_GET_IFACE (self)->create_new_mytype_func) 
     57                g_critical ("You must implement tny_msg_view_create_new_mytype\n"); 
     58#endif 
     59 
     60        return TNY_MSG_VIEW_GET_IFACE (self)->create_new_mytype_func (self); 
     61} 
    2362 
    2463/** 
     
    235274                type = g_type_register_static (G_TYPE_INTERFACE,  
    236275                        "TnyMsgView", &info, 0); 
     276 
     277                g_type_interface_add_prerequisite (type, TNY_TYPE_MIME_PART_VIEW); 
     278 
    237279        } 
    238280 
  • trunk/libtinymailui/tny-msg-view.h

    r998 r1213  
    4747        void (*clear_func) (TnyMsgView *self); 
    4848        TnyMimePartView* (*create_mime_part_view_for_func) (TnyMsgView *self, TnyMimePart *part); 
     49        TnyMsgView* (*create_new_mytype_func) (TnyMsgView *self); 
    4950}; 
    5051 
     
    5556void  tny_msg_view_set_unavailable (TnyMsgView *self); 
    5657TnyMimePartView* tny_msg_view_create_mime_part_view_for (TnyMsgView *self, TnyMimePart *part); 
     58TnyMsgView* tny_msg_view_create_new_mytype (TnyMsgView *self); 
    5759 
    5860G_END_DECLS 
  • trunk/libtinymailui/tny-msg-window.c

    r900 r1213  
    5353                  NULL    /* instance_init */ 
    5454                }; 
     55 
    5556                type = g_type_register_static (G_TYPE_INTERFACE,  
    5657                        "TnyMsgWindow", &info, 0); 
    5758 
    58                 g_type_interface_add_prerequisite (type, G_TYPE_OBJECT); 
     59                g_type_interface_add_prerequisite (type, TNY_TYPE_MSG_VIEW); 
    5960        } 
    6061 
  • trunk/libtinymailui/tny-msg-window.h

    r900 r1213  
    2424#include <glib-object.h> 
    2525#include <tny-shared.h> 
     26#include <tny-msg-view.h> 
    2627 
    2728G_BEGIN_DECLS