* src/gtk/pixmaps/internet-mail.svg:
authorDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Sun, 26 Nov 2006 18:32:09 +0000 (18:32 +0000)
committerDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Sun, 26 Nov 2006 18:32:09 +0000 (18:32 +0000)
  - new icon
*  src/gtk/modest-main-window.c src/modest-text-utils.c
   src/modest-text-utils.h src/modest-mail-operation.c
   src/modest-tny-msg-actions.c  src/widgets/modest-msg-view.c:
  - move text->html conversion from msgview to textutils
  - cleanup text utils incl. some renaming
  - add documentation to text utils
  - update other files for renaming
* src/Makefile.am:
  - remove double-entry of modest-ui.h

pmo-trunk-r490

src/Makefile.am
src/gtk/modest-main-window.c
src/gtk/pixmaps/internet-mail.svg
src/modest-mail-operation.c
src/modest-text-utils.c
src/modest-text-utils.h
src/modest-tny-msg-actions.c
src/widgets/modest-msg-view.c

index b8144e1..c9dfe01 100644 (file)
@@ -1,6 +1,6 @@
 #
 # Makefile.am
 #
 # Makefile.am
-# Time-stamp: <2006-08-17 14:29:08 (djcb)>
+# Time-stamp: <2006-11-26 19:23:53 (djcb)>
 SUBDIRS=$(MODEST_PLATFORM_DIR) widgets
 DIST_SUBDIRS = widgets gtk
 
 SUBDIRS=$(MODEST_PLATFORM_DIR) widgets
 DIST_SUBDIRS = widgets gtk
 
@@ -55,7 +55,6 @@ modest_SOURCES=\
        modest-tny-stream-gtkhtml.c\
        modest-tny-attachment.h\
        modest-tny-attachment.c\
        modest-tny-stream-gtkhtml.c\
        modest-tny-attachment.h\
        modest-tny-attachment.c\
-       modest-ui.h \
        modest-marshal.c \
        modest-marshal.h \
        modest-mail-operation.c \
        modest-marshal.c \
        modest-marshal.h \
        modest-mail-operation.c \
index 88a9732..60ffaea 100644 (file)
@@ -243,7 +243,7 @@ on_menu_reply_forward (ModestMainWindow *self, guint action, GtkWidget *widget)
        reply_key = g_strdup_printf ("%s/%s", MODEST_CONF_NAMESPACE, MODEST_CONF_REPLY_TYPE);
        reply_type = modest_conf_get_int (conf, reply_key, &error);
        if (error) {
        reply_key = g_strdup_printf ("%s/%s", MODEST_CONF_NAMESPACE, MODEST_CONF_REPLY_TYPE);
        reply_type = modest_conf_get_int (conf, reply_key, &error);
        if (error) {
-               g_warning (N_("Key %s not defined"), reply_key);
+               g_warning ("key %s not defined", reply_key);
                reply_type = MODEST_MAIL_OPERATION_REPLY_TYPE_CITE;
                g_error_free (error);
                error = NULL;
                reply_type = MODEST_MAIL_OPERATION_REPLY_TYPE_CITE;
                g_error_free (error);
                error = NULL;
@@ -253,7 +253,7 @@ on_menu_reply_forward (ModestMainWindow *self, guint action, GtkWidget *widget)
        forward_key = g_strdup_printf ("%s/%s", MODEST_CONF_NAMESPACE, MODEST_CONF_FORWARD_TYPE);
        forward_type = modest_conf_get_int (conf, forward_key, NULL);
        if (error) {
        forward_key = g_strdup_printf ("%s/%s", MODEST_CONF_NAMESPACE, MODEST_CONF_FORWARD_TYPE);
        forward_type = modest_conf_get_int (conf, forward_key, NULL);
        if (error) {
-               g_warning (N_("Key %s not defined"), forward_key);
+               g_warning ("key %s not defined", forward_key);
                reply_type = MODEST_MAIL_OPERATION_FORWARD_TYPE_INLINE;
                g_error_free (error);
        }
                reply_type = MODEST_MAIL_OPERATION_FORWARD_TYPE_INLINE;
                g_error_free (error);
        }
@@ -293,6 +293,8 @@ on_menu_reply_forward (ModestMainWindow *self, guint action, GtkWidget *widget)
                                        modest_mail_operation_create_forward_mail (msg, from, forward_type);
                                edit_type = MODEST_EDIT_TYPE_FORWARD;
                                break;
                                        modest_mail_operation_create_forward_mail (msg, from, forward_type);
                                edit_type = MODEST_EDIT_TYPE_FORWARD;
                                break;
+                       default:
+                               g_warning ("unexpected action type: %d", action);
                        }
 
                        /* Set from */
                        }
 
                        /* Set from */
index cfaed48..3022653 100644 (file)
    xmlns:svg="http://www.w3.org/2000/svg"
    xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:svg="http://www.w3.org/2000/svg"
    xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink"
-   xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
    xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
    xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
-   sodipodi:docname="internet-mail.svg"
-   sodipodi:docbase="/home/jimmac/gfx/ximian/tango-desktop-theme/scalable/apps"
-   inkscape:version="0.41+cvs"
+   sodipodi:docname="modest-email.svg"
+   sodipodi:docbase="/home/djcb/Desktop"
+   inkscape:version="0.44"
    sodipodi:version="0.32"
    id="svg5816"
    height="48px"
    width="48px">
   <defs
    sodipodi:version="0.32"
    id="svg5816"
    height="48px"
    width="48px">
   <defs
-     id="defs3"><linearGradient
-   id="linearGradient28260">
-  <stop
-   style="stop-color:#9aa29a;stop-opacity:1.0000000;"
-   offset="0.0000000"
-   id="stop28262" />
-
-
-  <stop
-   style="stop-color:#ffffff;stop-opacity:1.0000000;"
-   offset="1.0000000"
-   id="stop28264" />
-
-
-</linearGradient>
-<linearGradient
-   id="linearGradient28254">
-  <stop
-   id="stop28256"
-   offset="0.0000000"
-   style="stop-color:#9aa29a;stop-opacity:1.0000000;" />
-
-
-  <stop
-   id="stop28258"
-   offset="1.0000000"
-   style="stop-color:none" />
-
-
-</linearGradient>
-<linearGradient
-   id="linearGradient2274">
-  <stop
-   style="stop-color:#000000;stop-opacity:0.12871288;"
-   offset="0.0000000"
-   id="stop2276" />
-
-
-  <stop
-   style="stop-color:#000000;stop-opacity:0.0000000;"
-   offset="1.0000000"
-   id="stop2278" />
-
-
-</linearGradient>
-<linearGradient
-   id="linearGradient9749">
-  <stop
-   style="stop-color:#ffffff;stop-opacity:1;"
-   offset="0"
-   id="stop9751" />
-
-
-  <stop
-   style="stop-color:#ededed;stop-opacity:1.0000000;"
-   offset="1.0000000"
-   id="stop9753" />
-
-
-</linearGradient>
-<linearGradient
-   id="linearGradient2152">
-  <stop
-   style="stop-color:#9aa29a;stop-opacity:1.0000000;"
-   offset="0.0000000"
-   id="stop2154" />
-
-
-  <stop
-   style="stop-color:#b5beb5;stop-opacity:1.0000000;"
-   offset="1.0000000"
-   id="stop2156" />
-
-
-</linearGradient>
-<linearGradient
-   id="linearGradient2166">
-  <stop
-   style="stop-color:#ffffff;stop-opacity:1;"
-   offset="0"
-   id="stop2168" />
-
-
-  <stop
-   style="stop-color:#dcdcdc;stop-opacity:1.0000000;"
-   offset="1.0000000"
-   id="stop2170" />
-
-
-</linearGradient>
-<linearGradient
-   id="linearGradient18913">
-  <stop
-   style="stop-color:#ededed;stop-opacity:1.0000000;"
-   offset="0.0000000"
-   id="stop18915" />
-
-
-  <stop
-   style="stop-color:#c8c8c8;stop-opacity:1.0000000;"
-   offset="1.0000000"
-   id="stop18917" />
-
-
-</linearGradient>
-<linearGradient
-   id="linearGradient2136">
-  <stop
-   style="stop-color:#989690;stop-opacity:1.0000000;"
-   offset="0.0000000"
-   id="stop2138" />
-
-
-  <stop
-   style="stop-color:#656460;stop-opacity:1.0000000;"
-   offset="1.0000000"
-   id="stop2140" />
-
-
-</linearGradient>
-<linearGradient
-   id="linearGradient15107">
-  <stop
-   style="stop-color:#ffffff;stop-opacity:1.0000000;"
-   offset="0.0000000"
-   id="stop15109" />
-
-
-  <stop
-   style="stop-color:#e2e2e2;stop-opacity:1.0000000;"
-   offset="1.0000000"
-   id="stop15111" />
-
-
-</linearGradient>
-<linearGradient
-   id="linearGradient10691"
-   inkscape:collect="always">
-  <stop
-   id="stop10693"
-   offset="0"
-   style="stop-color:#000000;stop-opacity:1;" />
-
-
-  <stop
-   id="stop10695"
-   offset="1"
-   style="stop-color:#000000;stop-opacity:0;" />
-
-
-</linearGradient>
-<radialGradient
-   r="7.2284161"
-   fy="73.615714"
-   fx="6.7027131"
-   cy="73.615714"
-   cx="6.7027131"
-   gradientTransform="scale(1.902215,0.525703)"
-   gradientUnits="userSpaceOnUse"
-   id="radialGradient11382"
-   xlink:href="#linearGradient10691"
-   inkscape:collect="always" />
-
-  
-
-  
-
-  
-
-  
-
-  
-
-  
-
-  
-
-  
-
-  
-
-  
-
-  
-
-  
-
-  
-
-<linearGradient
-   y2="32.203162"
-   x2="9.7619219"
-   y1="37.784682"
-   x1="8.7803760"
-   gradientTransform="matrix(2.394900,0.000000,0.000000,0.781058,2.879512,0.343005)"
-   gradientUnits="userSpaceOnUse"
-   id="linearGradient27463"
-   xlink:href="#linearGradient2274"
-   inkscape:collect="always" />
-<linearGradient
-   y2="24.132717"
-   x2="21.111549"
-   y1="13.686079"
-   x1="11.233107"
-   gradientTransform="matrix(1.370928,0.000000,0.000000,1.443758,2.431133,-0.140786)"
-   gradientUnits="userSpaceOnUse"
-   id="linearGradient27468"
-   xlink:href="#linearGradient9749"
-   inkscape:collect="always" />
-<linearGradient
-   y2="52.090678"
-   x2="9.8855033"
-   y1="37.197018"
-   x1="8.9156475"
-   gradientTransform="matrix(2.454781,0.000000,0.000000,0.762004,2.879512,0.343005)"
-   gradientUnits="userSpaceOnUse"
-   id="linearGradient27471"
-   xlink:href="#linearGradient2152"
-   inkscape:collect="always" />
-<linearGradient
-   y2="52.090678"
-   x2="9.8855033"
-   y1="37.197018"
-   x1="8.9156475"
-   gradientTransform="matrix(2.454781,0.000000,0.000000,0.762004,2.879512,0.343005)"
-   gradientUnits="userSpaceOnUse"
-   id="linearGradient27474"
-   xlink:href="#linearGradient2152"
-   inkscape:collect="always" />
-<linearGradient
-   y2="29.568739"
-   x2="15.310744"
-   y1="15.148383"
-   x1="10.184240"
-   gradientTransform="matrix(1.819266,0.000000,0.000000,1.028193,2.879512,0.343005)"
-   gradientUnits="userSpaceOnUse"
-   id="linearGradient27477"
-   xlink:href="#linearGradient2166"
-   inkscape:collect="always" />
-<linearGradient
-   y2="17.876846"
-   x2="13.467486"
-   y1="7.2310905"
-   x1="5.8266134"
-   gradientTransform="matrix(1.570607,0.000000,0.000000,1.190976,2.879512,0.343005)"
-   gradientUnits="userSpaceOnUse"
-   id="linearGradient27483"
-   xlink:href="#linearGradient18913"
-   inkscape:collect="always" />
-<linearGradient
-   y2="26.022910"
-   x2="18.475286"
-   y1="4.7461626"
-   x1="11.572842"
-   gradientTransform="matrix(1.343475,0.000000,0.000000,1.417854,2.879511,0.314599)"
-   gradientUnits="userSpaceOnUse"
-   id="linearGradient27486"
-   xlink:href="#linearGradient15107"
-   inkscape:collect="always" />
-<linearGradient
-   y2="15.257116"
-   x2="30.599684"
-   y1="15.257116"
-   x1="2.0618774"
-   gradientTransform="matrix(1.343475,0.000000,0.000000,1.417854,2.879511,0.314599)"
-   gradientUnits="userSpaceOnUse"
-   id="linearGradient27488"
-   xlink:href="#linearGradient2136"
-   inkscape:collect="always" />
-</defs>
+     id="defs3">
+    <radialGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient5060"
+       id="radialGradient6719"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(-2.774389,0,0,1.969706,112.7623,-872.8854)"
+       cx="605.71429"
+       cy="486.64789"
+       fx="605.71429"
+       fy="486.64789"
+       r="117.14286" />
+    <linearGradient
+       inkscape:collect="always"
+       id="linearGradient5060">
+      <stop
+         style="stop-color:black;stop-opacity:1;"
+         offset="0"
+         id="stop5062" />
+      <stop
+         style="stop-color:black;stop-opacity:0;"
+         offset="1"
+         id="stop5064" />
+    </linearGradient>
+    <radialGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient5060"
+       id="radialGradient6717"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(2.774389,0,0,1.969706,-1891.633,-872.8854)"
+       cx="605.71429"
+       cy="486.64789"
+       fx="605.71429"
+       fy="486.64789"
+       r="117.14286" />
+    <linearGradient
+       id="linearGradient5048">
+      <stop
+         style="stop-color:black;stop-opacity:0;"
+         offset="0"
+         id="stop5050" />
+      <stop
+         id="stop5056"
+         offset="0.5"
+         style="stop-color:black;stop-opacity:1;" />
+      <stop
+         style="stop-color:black;stop-opacity:0;"
+         offset="1"
+         id="stop5052" />
+    </linearGradient>
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient5048"
+       id="linearGradient6715"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(2.774389,0,0,1.969706,-1892.179,-872.8854)"
+       x1="302.85715"
+       y1="366.64789"
+       x2="302.85715"
+       y2="609.50507" />
+    <linearGradient
+       id="linearGradient28260">
+      <stop
+         style="stop-color:#9aa29a;stop-opacity:1.0000000;"
+         offset="0.0000000"
+         id="stop28262" />
+      <stop
+         style="stop-color:#ffffff;stop-opacity:1.0000000;"
+         offset="1.0000000"
+         id="stop28264" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient28254">
+      <stop
+         id="stop28256"
+         offset="0.0000000"
+         style="stop-color:#9aa29a;stop-opacity:1.0000000;" />
+      <stop
+         id="stop28258"
+         offset="1.0000000"
+         style="stop-color:none" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient2274">
+      <stop
+         style="stop-color:#000000;stop-opacity:0.12871288;"
+         offset="0.0000000"
+         id="stop2276" />
+      <stop
+         style="stop-color:#000000;stop-opacity:0.0000000;"
+         offset="1.0000000"
+         id="stop2278" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient9749">
+      <stop
+         style="stop-color:#ffffff;stop-opacity:1;"
+         offset="0"
+         id="stop9751" />
+      <stop
+         style="stop-color:#ededed;stop-opacity:1.0000000;"
+         offset="1.0000000"
+         id="stop9753" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient2152">
+      <stop
+         style="stop-color:#9aa29a;stop-opacity:1.0000000;"
+         offset="0.0000000"
+         id="stop2154" />
+      <stop
+         style="stop-color:#b5beb5;stop-opacity:1.0000000;"
+         offset="1.0000000"
+         id="stop2156" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient2166">
+      <stop
+         style="stop-color:#ffffff;stop-opacity:1;"
+         offset="0"
+         id="stop2168" />
+      <stop
+         style="stop-color:#dcdcdc;stop-opacity:1.0000000;"
+         offset="1.0000000"
+         id="stop2170" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient18913">
+      <stop
+         style="stop-color:#ededed;stop-opacity:1.0000000;"
+         offset="0.0000000"
+         id="stop18915" />
+      <stop
+         style="stop-color:#c8c8c8;stop-opacity:1.0000000;"
+         offset="1.0000000"
+         id="stop18917" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient2136">
+      <stop
+         style="stop-color:#989690;stop-opacity:1.0000000;"
+         offset="0.0000000"
+         id="stop2138" />
+      <stop
+         style="stop-color:#656460;stop-opacity:1.0000000;"
+         offset="1.0000000"
+         id="stop2140" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient15107">
+      <stop
+         style="stop-color:#ffffff;stop-opacity:1.0000000;"
+         offset="0.0000000"
+         id="stop15109" />
+      <stop
+         style="stop-color:#e2e2e2;stop-opacity:1.0000000;"
+         offset="1.0000000"
+         id="stop15111" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient10691"
+       inkscape:collect="always">
+      <stop
+         id="stop10693"
+         offset="0"
+         style="stop-color:#000000;stop-opacity:1;" />
+      <stop
+         id="stop10695"
+         offset="1"
+         style="stop-color:#000000;stop-opacity:0;" />
+    </linearGradient>
+    <radialGradient
+       r="7.2284161"
+       fy="73.615714"
+       fx="6.7027131"
+       cy="73.615714"
+       cx="6.7027131"
+       gradientTransform="scale(1.902215,0.525703)"
+       gradientUnits="userSpaceOnUse"
+       id="radialGradient11382"
+       xlink:href="#linearGradient10691"
+       inkscape:collect="always" />
+    <linearGradient
+       y2="32.203162"
+       x2="9.7619219"
+       y1="37.784682"
+       x1="8.7803760"
+       gradientTransform="matrix(2.394900,0.000000,0.000000,0.781058,2.879512,0.343005)"
+       gradientUnits="userSpaceOnUse"
+       id="linearGradient27463"
+       xlink:href="#linearGradient2274"
+       inkscape:collect="always" />
+    <linearGradient
+       y2="24.132717"
+       x2="21.111549"
+       y1="13.686079"
+       x1="11.233107"
+       gradientTransform="matrix(1.370928,0.000000,0.000000,1.443758,2.431133,-0.140786)"
+       gradientUnits="userSpaceOnUse"
+       id="linearGradient27468"
+       xlink:href="#linearGradient9749"
+       inkscape:collect="always" />
+    <linearGradient
+       y2="52.090678"
+       x2="9.8855033"
+       y1="37.197018"
+       x1="8.9156475"
+       gradientTransform="matrix(2.454781,0.000000,0.000000,0.762004,2.879512,0.343005)"
+       gradientUnits="userSpaceOnUse"
+       id="linearGradient27471"
+       xlink:href="#linearGradient2152"
+       inkscape:collect="always" />
+    <linearGradient
+       y2="52.090678"
+       x2="9.8855033"
+       y1="37.197018"
+       x1="8.9156475"
+       gradientTransform="matrix(2.454781,0.000000,0.000000,0.762004,2.879512,0.343005)"
+       gradientUnits="userSpaceOnUse"
+       id="linearGradient27474"
+       xlink:href="#linearGradient2152"
+       inkscape:collect="always" />
+    <linearGradient
+       y2="29.568739"
+       x2="15.310744"
+       y1="15.148383"
+       x1="10.184240"
+       gradientTransform="matrix(1.819266,0.000000,0.000000,1.028193,2.879512,0.343005)"
+       gradientUnits="userSpaceOnUse"
+       id="linearGradient27477"
+       xlink:href="#linearGradient2166"
+       inkscape:collect="always" />
+    <linearGradient
+       y2="17.876846"
+       x2="13.467486"
+       y1="7.2310905"
+       x1="5.8266134"
+       gradientTransform="matrix(1.570607,0.000000,0.000000,1.190976,2.879512,0.343005)"
+       gradientUnits="userSpaceOnUse"
+       id="linearGradient27483"
+       xlink:href="#linearGradient18913"
+       inkscape:collect="always" />
+    <linearGradient
+       y2="26.022910"
+       x2="18.475286"
+       y1="4.7461626"
+       x1="11.572842"
+       gradientTransform="matrix(1.343475,0.000000,0.000000,1.417854,2.879511,0.314599)"
+       gradientUnits="userSpaceOnUse"
+       id="linearGradient27486"
+       xlink:href="#linearGradient15107"
+       inkscape:collect="always" />
+    <linearGradient
+       y2="15.257116"
+       x2="30.599684"
+       y1="15.257116"
+       x1="2.0618774"
+       gradientTransform="matrix(1.343475,0.000000,0.000000,1.417854,2.879511,0.314599)"
+       gradientUnits="userSpaceOnUse"
+       id="linearGradient27488"
+       xlink:href="#linearGradient2136"
+       inkscape:collect="always" />
+  </defs>
   <sodipodi:namedview
   <sodipodi:namedview
-     inkscape:window-y="202"
-     inkscape:window-x="331"
+     inkscape:window-y="81"
+     inkscape:window-x="518"
      inkscape:window-height="743"
      inkscape:window-height="743"
-     inkscape:window-width="849"
+     inkscape:window-width="874"
      inkscape:document-units="px"
      inkscape:grid-bbox="true"
      showgrid="false"
      inkscape:document-units="px"
      inkscape:grid-bbox="true"
      showgrid="false"
-     inkscape:current-layer="layer1"
-     inkscape:cy="18.816166"
+     inkscape:current-layer="layer2"
+     inkscape:cy="18.316166"
      inkscape:cx="28.384904"
      inkscape:cx="28.384904"
-     inkscape:zoom="9.8994949"
+     inkscape:zoom="8"
      inkscape:pageshadow="2"
      inkscape:pageopacity="0.0"
      borderopacity="1.0"
      inkscape:pageshadow="2"
      inkscape:pageopacity="0.0"
      borderopacity="1.0"
      id="base" />
   <metadata
      id="metadata4">
      id="base" />
   <metadata
      id="metadata4">
-    <rdf:RDF
-       id="RDF5">
+    <rdf:RDF>
       <cc:Work
       <cc:Work
-         id="Work6"
          rdf:about="">
          rdf:about="">
-        <dc:format
-           id="format7">image/svg+xml</dc:format>
+        <dc:format>image/svg+xml</dc:format>
         <dc:type
         <dc:type
-           rdf:resource="http://purl.org/dc/dcmitype/StillImage"
-           id="type9" />
-        <dc:title
-           id="title29050">Mail</dc:title>
-        <dc:creator
-           id="creator29052">
-          <cc:Agent
-             id="Agent29054">
-            <dc:title
-               id="title29056">Jakub Steiner</dc:title>
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title>Mail</dc:title>
+        <dc:creator>
+          <cc:Agent>
+            <dc:title>Jakub Steiner</dc:title>
           </cc:Agent>
         </dc:creator>
           </cc:Agent>
         </dc:creator>
-        <dc:contributor
-           id="contributor29058">
-          <cc:Agent
-             id="Agent29060">
-            <dc:title
-               id="title29062">Andreas Nilsson</dc:title>
+        <dc:contributor>
+          <cc:Agent>
+            <dc:title>Andreas Nilsson</dc:title>
           </cc:Agent>
         </dc:contributor>
         <cc:license
           </cc:Agent>
         </dc:contributor>
         <cc:license
-           rdf:resource="http://creativecommons.org/licenses/by-sa/2.0/"
-           id="license29064" />
-        <dc:subject
-           id="subject29080">
-          <rdf:Bag
-             id="Bag29082">
-            <rdf:li
-               id="li29148">mail</rdf:li>
-            <rdf:li
-               id="li29150">e-mail</rdf:li>
-            <rdf:li
-               id="li29152">MUA</rdf:li>
+           rdf:resource="http://creativecommons.org/licenses/by-sa/2.0/" />
+        <dc:subject>
+          <rdf:Bag>
+            <rdf:li>mail</rdf:li>
+            <rdf:li>e-mail</rdf:li>
+            <rdf:li>MUA</rdf:li>
           </rdf:Bag>
         </dc:subject>
       </cc:Work>
       <cc:License
           </rdf:Bag>
         </dc:subject>
       </cc:Work>
       <cc:License
-         id="License29066"
          rdf:about="http://creativecommons.org/licenses/by-sa/2.0/">
         <cc:permits
          rdf:about="http://creativecommons.org/licenses/by-sa/2.0/">
         <cc:permits
-           id="permits29068"
            rdf:resource="http://web.resource.org/cc/Reproduction" />
         <cc:permits
            rdf:resource="http://web.resource.org/cc/Reproduction" />
         <cc:permits
-           id="permits29070"
            rdf:resource="http://web.resource.org/cc/Distribution" />
         <cc:requires
            rdf:resource="http://web.resource.org/cc/Distribution" />
         <cc:requires
-           id="requires29072"
            rdf:resource="http://web.resource.org/cc/Notice" />
         <cc:requires
            rdf:resource="http://web.resource.org/cc/Notice" />
         <cc:requires
-           id="requires29074"
            rdf:resource="http://web.resource.org/cc/Attribution" />
         <cc:permits
            rdf:resource="http://web.resource.org/cc/Attribution" />
         <cc:permits
-           id="permits29076"
            rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
         <cc:requires
            rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
         <cc:requires
-           id="requires29078"
            rdf:resource="http://web.resource.org/cc/ShareAlike" />
       </cc:License>
     </rdf:RDF>
            rdf:resource="http://web.resource.org/cc/ShareAlike" />
       </cc:License>
     </rdf:RDF>
      inkscape:groupmode="layer"
      inkscape:label="Layer 1"
      id="layer1">
      inkscape:groupmode="layer"
      inkscape:label="Layer 1"
      id="layer1">
-    <path
-       sodipodi:type="arc"
-       style="opacity:0.45569620;color:#000000;fill:url(#radialGradient11382);fill-opacity:1.0000000;fill-rule:nonzero;stroke:none;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4.0000000;stroke-dashoffset:0.0000000;stroke-opacity:1.0000000;visibility:visible;display:inline;overflow:visible"
-       id="path10699"
-       sodipodi:cx="12.750000"
-       sodipodi:cy="38.700001"
-       sodipodi:rx="13.750000"
-       sodipodi:ry="3.8000000"
-       d="M 26.500000 38.700001 A 13.750000 3.8000000 0 1 1  -1.0000000,38.700001 A 13.750000 3.8000000 0 1 1  26.500000 38.700001 z"
-       transform="matrix(1.800603,0.000000,0.000000,1.974782,1.083944,-38.01261)" />
+    <g
+       transform="matrix(2.269972e-2,0,0,2.297929e-2,44.98918,37.78447)"
+       id="g6707">
+      <rect
+         style="opacity:0.40206185;color:black;fill:url(#linearGradient6715);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+         id="rect6709"
+         width="1339.6335"
+         height="478.35718"
+         x="-1559.2523"
+         y="-150.69685" />
+      <path
+         style="opacity:0.40206185;color:black;fill:url(#radialGradient6717);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+         d="M -219.61876,-150.68038 C -219.61876,-150.68038 -219.61876,327.65041 -219.61876,327.65041 C -76.744594,328.55086 125.78146,220.48075 125.78138,88.454235 C 125.78138,-43.572302 -33.655436,-150.68036 -219.61876,-150.68038 z "
+         id="path6711"
+         sodipodi:nodetypes="cccc" />
+      <path
+         sodipodi:nodetypes="cccc"
+         id="path6713"
+         d="M -1559.2523,-150.68038 C -1559.2523,-150.68038 -1559.2523,327.65041 -1559.2523,327.65041 C -1702.1265,328.55086 -1904.6525,220.48075 -1904.6525,88.454235 C -1904.6525,-43.572302 -1745.2157,-150.68036 -1559.2523,-150.68038 z "
+         style="opacity:0.40206185;color:black;fill:url(#radialGradient6719);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" />
+    </g>
     <path
        style="fill:url(#linearGradient27486);fill-opacity:1.0000000;fill-rule:evenodd;stroke:url(#linearGradient27488);stroke-width:0.85660440;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"
        d="M 6.3334395,16.972251 L 6.3334395,41.481799 L 43.305555,41.481799 L 43.244499,17.089859 C 43.241050,15.712272 31.395999,2.4121110 29.210877,2.4121110 L 20.659391,2.4121110 C 18.362072,2.4121110 6.3334395,15.673953 6.3334395,16.972251 z "
     <path
        style="fill:url(#linearGradient27486);fill-opacity:1.0000000;fill-rule:evenodd;stroke:url(#linearGradient27488);stroke-width:0.85660440;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"
        d="M 6.3334395,16.972251 L 6.3334395,41.481799 L 43.305555,41.481799 L 43.244499,17.089859 C 43.241050,15.712272 31.395999,2.4121110 29.210877,2.4121110 L 20.659391,2.4121110 C 18.362072,2.4121110 6.3334395,15.673953 6.3334395,16.972251 z "
        d="M 41.812936,17.847945 L 31.861315,30.479232 L 30.792812,29.624431 L 41.812936,17.847945 z "
        style="color:#000000;fill:#b1b1b1;fill-opacity:1.0000000;fill-rule:evenodd;stroke:none;stroke-width:1.0000000;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4.0000000;stroke-dashoffset:0.0000000;stroke-opacity:1.0000000;visibility:visible;display:inline;overflow:visible" />
   </g>
        d="M 41.812936,17.847945 L 31.861315,30.479232 L 30.792812,29.624431 L 41.812936,17.847945 z "
        style="color:#000000;fill:#b1b1b1;fill-opacity:1.0000000;fill-rule:evenodd;stroke:none;stroke-width:1.0000000;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4.0000000;stroke-dashoffset:0.0000000;stroke-opacity:1.0000000;visibility:visible;display:inline;overflow:visible" />
   </g>
+  <g
+     inkscape:groupmode="layer"
+     id="layer2"
+     inkscape:label="M">
+    <text
+       xml:space="preserve"
+       style="font-size:32px;font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:80.00000119%;writing-mode:lr-tb;text-anchor:start;fill:#f57900;fill-opacity:1;stroke:none;stroke-width:1pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Century Schoolbook L"
+       x="12"
+       y="36.125"
+       id="text1968"
+       sodipodi:linespacing="80.000001%"><tspan
+         sodipodi:role="line"
+         id="tspan1970"
+         x="12"
+         y="36.125">m</tspan></text>
+  </g>
 </svg>
 </svg>
index f5cb15c..c2b3c67 100644 (file)
 #include <tny-store-account.h>
 #include <tny-folder-store.h>
 #include <tny-folder-store-query.h>
 #include <tny-store-account.h>
 #include <tny-folder-store.h>
 #include <tny-folder-store-query.h>
+#include <tny-camel-msg.h>
+#include <tny-camel-header.h>
+#include <tny-camel-stream.h>
+#include <tny-camel-mime-part.h>
+#include <tny-simple-list.h>
+
 #include <glib/gi18n.h>
 #include <glib/gi18n.h>
+
+#include <modest-text-utils.h>
+#include <modest-tny-msg-actions.h>
 #include "modest-tny-platform-factory.h"
 
 /* 'private'/'protected' functions */
 #include "modest-tny-platform-factory.h"
 
 /* 'private'/'protected' functions */
@@ -294,8 +303,7 @@ modest_mail_operation_create_forward_mail (TnyMsg *msg,
 {
        TnyMsg *new_msg;
        TnyHeader *new_header, *header;
 {
        TnyMsg *new_msg;
        TnyHeader *new_header, *header;
-       TnyStream *attachment_stream;
-       gchar *new_subject, *new_body, *content_type, *quoted;
+       gchar *new_subject, *new_body, *content_type;
        TnyMimePart *text_body_part = NULL;
        GList *attachments_list;
        TnyList *parts;
        TnyMimePart *text_body_part = NULL;
        GList *attachments_list;
        TnyList *parts;
@@ -312,7 +320,8 @@ modest_mail_operation_create_forward_mail (TnyMsg *msg,
        tny_header_set_from (new_header, from);
 
        /* Change the subject */
        tny_header_set_from (new_header, from);
 
        /* Change the subject */
-       new_subject = (gchar *) modest_text_utils_create_forward_subject (tny_header_get_subject(header));
+       new_subject = (gchar *) modest_text_utils_derived_subject (tny_header_get_subject(header),
+                                                                  _("Fwd:"));
        tny_header_set_subject (new_header, (const gchar *) new_subject);
        g_free (new_subject);
 
        tny_header_set_subject (new_header, (const gchar *) new_subject);
        g_free (new_subject);
 
@@ -350,11 +359,11 @@ modest_mail_operation_create_forward_mail (TnyMsg *msg,
        case MODEST_MAIL_OPERATION_FORWARD_TYPE_INLINE:
                /* Prepend "Original message" text */
                inlined_text = (gchar *) 
        case MODEST_MAIL_OPERATION_FORWARD_TYPE_INLINE:
                /* Prepend "Original message" text */
                inlined_text = (gchar *) 
-                       modest_text_utils_create_inlined_text (tny_header_get_from (header),
-                                                              tny_header_get_date_sent (header),
-                                                              tny_header_get_to (header),
-                                                              tny_header_get_subject (header),
-                                                              (const gchar*) new_body);
+                       modest_text_utils_inlined_text (tny_header_get_from (header),
+                                                       tny_header_get_date_sent (header),
+                                                       tny_header_get_to (header),
+                                                       tny_header_get_subject (header),
+                                                       (const gchar*) new_body);
                g_free (new_body);
                new_body = inlined_text;
 
                g_free (new_body);
                new_body = inlined_text;
 
@@ -402,9 +411,7 @@ modest_mail_operation_create_reply_mail (TnyMsg *msg,
 {
        TnyMsg *new_msg;
        TnyHeader *new_header, *header;
 {
        TnyMsg *new_msg;
        TnyHeader *new_header, *header;
-       TnyStream *attachment_stream;
        gchar *new_subject, *new_body, *content_type, *quoted;
        gchar *new_subject, *new_body, *content_type, *quoted;
-       TnyList *parts;
        TnyMimePart *text_body_part;
 
        /* Create new objects */
        TnyMimePart *text_body_part;
 
        /* Create new objects */
@@ -439,8 +446,8 @@ modest_mail_operation_create_reply_mail (TnyMsg *msg,
 
                /* Remove my own address from the cc list */
                new_cc = (gchar *) 
 
                /* Remove my own address from the cc list */
                new_cc = (gchar *) 
-                       modest_text_utils_remove_mail_from_mail_list ((const gchar *) tmp->str, 
-                                                                     (const gchar *) from);
+                       modest_text_utils_remove_address ((const gchar *) tmp->str, 
+                                                         (const gchar *) from);
                /* FIXME: remove also the mails from the new To: */
                tny_header_set_cc (new_header, new_cc);
 
                /* FIXME: remove also the mails from the new To: */
                tny_header_set_cc (new_header, new_cc);
 
@@ -451,7 +458,8 @@ modest_mail_operation_create_reply_mail (TnyMsg *msg,
        }
 
        /* Change the subject */
        }
 
        /* Change the subject */
-       new_subject = (gchar*) modest_text_utils_create_reply_subject (tny_header_get_subject(header));
+       new_subject = (gchar*) modest_text_utils_derived_subject (tny_header_get_subject(header),
+                                                                 _("Re:"));
        tny_header_set_subject (new_header, (const gchar *) new_subject);
        g_free (new_subject);
 
        tny_header_set_subject (new_header, (const gchar *) new_subject);
        g_free (new_subject);
 
@@ -468,9 +476,9 @@ modest_mail_operation_create_reply_mail (TnyMsg *msg,
 
        case MODEST_MAIL_OPERATION_REPLY_TYPE_CITE:
                /* Prepend "Original message" text */
 
        case MODEST_MAIL_OPERATION_REPLY_TYPE_CITE:
                /* Prepend "Original message" text */
-               cited_text = (gchar *) modest_text_utils_create_cited_text (tny_header_get_from (header),
-                                                                           tny_header_get_date_sent (header),
-                                                                           (const gchar*) new_body);
+               cited_text = (gchar *) modest_text_utils_cited_text (tny_header_get_from (header),
+                                                                    tny_header_get_date_sent (header),
+                                                                    (const gchar*) new_body);
                g_free (new_body);
                new_body = cited_text;
                break;
                g_free (new_body);
                new_body = cited_text;
                break;
@@ -606,12 +614,12 @@ get_content_type(const gchar *s)
 static GQuark 
 modest_error_quark (void)
 {
 static GQuark 
 modest_error_quark (void)
 {
-  static GQuark err_q = 0;
-
-  if (err_q == 0)
-    err_q = g_quark_from_static_string ("modest-error-quark");
-
-  return err_q;
+       static GQuark err_q = 0;
+       
+       if (err_q == 0)
+               err_q = g_quark_from_static_string ("modest-error-quark");
+       
+       return err_q;
 }
 
 
 }
 
 
@@ -691,6 +699,7 @@ add_attachments (TnyMsg *msg, const GList *attachments_list)
        }
 }
 
        }
 }
 
+
 static TnyMimePart *
 add_body_part (TnyMsg *msg, 
               const gchar *body,
 static TnyMimePart *
 add_body_part (TnyMsg *msg, 
               const gchar *body,
index 2f28c91..fafb338 100644 (file)
  */
 
 
  */
 
 
-/* modest-ui.c */
-
-#include <gtk/gtk.h>
+#include <glib.h>
 #include <string.h>
 #include <stdlib.h>
 #include <glib/gi18n.h>
 #include <string.h>
 #include <stdlib.h>
 #include <glib/gi18n.h>
+#include <regex.h>
 #include "modest-text-utils.h"
 
 
 #include "modest-text-utils.h"
 
 
@@ -202,19 +201,19 @@ get_breakpoint (const gchar * s, const gint indent, const gint limit)
 /* just to prevent warnings:
  * warning: `%x' yields only last 2 digits of year in some locales
  */
 /* just to prevent warnings:
  * warning: `%x' yields only last 2 digits of year in some locales
  */
-static size_t
-my_strftime(char *s, size_t max, const char  *fmt,  const
-           struct tm *tm) {
+size_t
+modest_text_utils_strftime(char *s, size_t max, const char  *fmt, const  struct tm *tm)
+{
        return strftime(s, max, fmt, tm);
 }
 
 static gchar *
        return strftime(s, max, fmt, tm);
 }
 
 static gchar *
-cite (const time_t sent_date, const gchar *from) {
-       gchar *str;
+cite (const time_t sent_date, const gchar *from)
+{
        gchar sent_str[101];
 
        /* format sent_date */
        gchar sent_str[101];
 
        /* format sent_date */
-       my_strftime (sent_str, 100, "%c", localtime (&sent_date));
+       modest_text_utils_strftime (sent_str, 100, "%c", localtime (&sent_date));
        return g_strdup_printf (N_("On %s, %s wrote:\n"), sent_str, from);
 }
 
        return g_strdup_printf (N_("On %s, %s wrote:\n"), sent_str, from);
 }
 
@@ -280,10 +279,11 @@ modest_text_utils_quote (const gchar * to_quote, const gchar * from,
        return g_string_free (q, FALSE);
 }
 
        return g_string_free (q, FALSE);
 }
 
-static gchar *
-create_derivated_subject (const gchar *subject, const gchar *prefix)
+
+gchar *
+modest_text_utils_derived_subject (const gchar *subject, const gchar *prefix)
 {
 {
-       gchar *tmp, *buffer;
+       gchar *tmp;
 
        if (!subject)
                return g_strdup_printf ("%s ", prefix);
 
        if (!subject)
                return g_strdup_printf ("%s ", prefix);
@@ -298,36 +298,9 @@ create_derivated_subject (const gchar *subject, const gchar *prefix)
        }
 }
 
        }
 }
 
-/**
- * modest_text_utils_create_reply_subject:
- * @subject: 
- * 
- * creates a new subject with a reply prefix if not present before
- * 
- * Returns: a new subject with the reply prefix
- **/
-gchar * 
-modest_text_utils_create_reply_subject (const gchar *subject)
-{
-       return create_derivated_subject (subject, _("Re:"));
-}
-
-/**
- * modest_text_utils_create_forward_subject:
- * @subject: 
- * 
- * creates a new subject with a forward prefix if not present before
- * 
- * Returns:  a new subject with the forward prefix
- **/
-gchar * 
-modest_text_utils_create_forward_subject (const gchar *subject)
-{
-       return create_derivated_subject (subject, _("Fw:"));
-}
 
 gchar *
 
 gchar *
-modest_text_utils_create_cited_text (const gchar *from, 
+modest_text_utils_cited_text (const gchar *from, 
                                     time_t sent_date, 
                                     const gchar *text)
 {
                                     time_t sent_date, 
                                     const gchar *text)
 {
@@ -340,25 +313,15 @@ modest_text_utils_create_cited_text (const gchar *from,
        return retval;
 }
 
        return retval;
 }
 
-/**
- * modest_text_utils_create_inlined_text:
- * @text: the original text
- * 
- * creates a new string with the "Original message" text prepended to
- * the text passed as argument and some data of the header
- * 
- * Returns:  a newly allocated text
- **/
+
 gchar * 
 gchar * 
-modest_text_utils_create_inlined_text (const gchar *from,
-                                      time_t sent_date,
-                                      const gchar *to,
-                                     const gchar *subject,
-                                     const gchar *text)
+modest_text_utils_inlined_text (const gchar *from, time_t sent_date,
+                               const gchar *to, const gchar *subject,
+                               const gchar *text)
 {
        gchar sent_str[101];
 
 {
        gchar sent_str[101];
 
-       my_strftime (sent_str, 100, "%c", localtime (&sent_date));
+       modest_text_utils_strftime (sent_str, 100, "%c", localtime (&sent_date));
 
        return g_strdup_printf ("%s\n%s %s\n%s %s\n%s %s\n%s %s\n\n%s", 
                                _("-----Forwarded Message-----"),
 
        return g_strdup_printf ("%s\n%s %s\n%s %s\n%s %s\n%s %s\n\n%s", 
                                _("-----Forwarded Message-----"),
@@ -370,28 +333,27 @@ modest_text_utils_create_inlined_text (const gchar *from,
 }
 
 gchar *
 }
 
 gchar *
-modest_text_utils_remove_mail_from_mail_list (const gchar *emails,
-                                             const gchar *email)
+modest_text_utils_remove_address (const gchar *address, const gchar *address_list)
 {
        char *dup, *token, *ptr, *result;
        GString *filtered_emails;
 
 {
        char *dup, *token, *ptr, *result;
        GString *filtered_emails;
 
-       if (!emails)
+       if (!address_list)
                return NULL;
 
        /* Search for substring */
                return NULL;
 
        /* Search for substring */
-       if (!strstr ((const char *) emails, (const char *) email))
-               return g_strdup (emails);
+       if (!strstr ((const char *) address_list, (const char *) address))
+               return g_strdup (address_list);
 
 
-       dup = g_strdup (emails);
+       dup = g_strdup (address_list);
        filtered_emails = g_string_new (NULL);
        filtered_emails = g_string_new (NULL);
-
+       
        token = strtok_r (dup, ",", &ptr);
 
        while (token != NULL) {
                /* Add to list if not found */
        token = strtok_r (dup, ",", &ptr);
 
        while (token != NULL) {
                /* Add to list if not found */
-               if (!strstr ((const char *) token, (const char *) email)) {
-                       if (G_UNLIKELY (filtered_emails->len) == 0)
+               if (!strstr ((const char *) token, (const char *) address)) {
+                       if (filtered_emails->len == 0)
                                g_string_append_printf (filtered_emails, "%s", token);
                        else
                                g_string_append_printf (filtered_emails, ",%s", token);
                                g_string_append_printf (filtered_emails, "%s", token);
                        else
                                g_string_append_printf (filtered_emails, ",%s", token);
@@ -406,3 +368,216 @@ modest_text_utils_remove_mail_from_mail_list (const gchar *emails,
 
        return result;
 }
 
        return result;
 }
+
+
+
+
+/*
+ * we need these regexps to find URLs in plain text e-mails
+ */
+typedef struct _url_match_pattern_t url_match_pattern_t;
+struct _url_match_pattern_t {
+       gchar   *regex;
+       regex_t *preg;
+       gchar   *prefix;
+};
+
+typedef struct _url_match_t url_match_t;
+struct _url_match_t {
+       guint offset;
+       guint len;
+       const gchar* prefix;
+};
+
+
+#define MAIL_VIEWER_URL_MATCH_PATTERNS  {                              \
+       { "(file|rtsp|http|ftp|https)://[-A-Za-z0-9_$.+!*(),;:@%&=?/~#]+[-A-Za-z0-9_$%&=?/~#]",\
+         NULL, NULL },\
+       { "www\\.[-a-z0-9.]+[-a-z0-9](:[0-9]*)?(/[-A-Za-z0-9_$.+!*(),;:@%&=?/~#]*[^]}\\),?!;:\"]?)?",\
+         NULL, "http://" },\
+       { "ftp\\.[-a-z0-9.]+[-a-z0-9](:[0-9]*)?(/[-A-Za-z0-9_$.+!*(),;:@%&=?/~#]*[^]}\\),?!;:\"]?)?",\
+         NULL, "ftp://" },\
+       { "(voipto|callto|chatto|jabberto|xmpp):[-_a-z@0-9.\\+]+", \
+          NULL, NULL},                                             \
+       { "mailto:[-_a-z0-9.\\+]+@[-_a-z0-9.]+",                    \
+         NULL, NULL},\
+       { "[-_a-z0-9.\\+]+@[-_a-z0-9.]+",\
+         NULL, "mailto:"}\
+       }
+
+
+static gint 
+cmp_offsets_reverse (const url_match_t *match1, const url_match_t *match2)
+{
+       return match2->offset - match1->offset;
+}
+
+
+
+/*
+ * check if the match is inside an existing match... */
+static void
+chk_partial_match (const url_match_t *match, guint* offset)
+{
+       if (*offset >= match->offset && *offset < match->offset + match->len)
+               *offset = -1;
+}
+
+static GSList*
+get_url_matches (GString *txt)
+{
+       regmatch_t rm;
+        guint rv, i, offset = 0;
+        GSList *match_list = NULL;
+
+       static url_match_pattern_t patterns[] = MAIL_VIEWER_URL_MATCH_PATTERNS;
+       const size_t pattern_num = sizeof(patterns)/sizeof(url_match_pattern_t);
+
+       /* initalize the regexps */
+       for (i = 0; i != pattern_num; ++i) {
+               patterns[i].preg = g_new0 (regex_t,1);
+               g_assert(regcomp (patterns[i].preg, patterns[i].regex,
+                                 REG_ICASE|REG_EXTENDED|REG_NEWLINE) == 0);
+       }
+        /* find all the matches */
+       for (i = 0; i != pattern_num; ++i) {
+               offset     = 0; 
+               while (1) {
+                       int test_offset;
+                       if ((rv = regexec (patterns[i].preg, txt->str + offset, 1, &rm, 0)) != 0) {
+                               g_assert (rv == REG_NOMATCH); /* this should not happen */
+                               break; /* try next regexp */ 
+                       }
+                       if (rm.rm_so == -1)
+                               break;
+
+                       /* FIXME: optimize this */
+                       /* to avoid partial matches on something that was already found... */
+                       /* check_partial_match will put -1 in the data ptr if that is the case */
+                       test_offset = offset + rm.rm_so;
+                       g_slist_foreach (match_list, (GFunc)chk_partial_match, &test_offset);
+                       
+                       /* make a list of our matches (<offset, len, prefix> tupels)*/
+                       if (test_offset != -1) {
+                               url_match_t *match = g_new (url_match_t,1);
+                               match->offset = offset + rm.rm_so;
+                               match->len    = rm.rm_eo - rm.rm_so;
+                               match->prefix = patterns[i].prefix;
+                               match_list = g_slist_prepend (match_list, match);
+                       }
+                       offset += rm.rm_eo;
+               }
+       }
+
+       for (i = 0; i != pattern_num; ++i) {
+               regfree (patterns[i].preg);
+               g_free  (patterns[i].preg);
+       } /* don't free patterns itself -- it's static */
+       
+       /* now sort the list, so the matches are in reverse order of occurence.
+        * that way, we can do the replacements starting from the end, so we don't need
+        * to recalculate the offsets
+        */
+       match_list = g_slist_sort (match_list,
+                                  (GCompareFunc)cmp_offsets_reverse); 
+       return match_list;      
+}
+
+
+
+static void
+hyperlinkify_plain_text (GString *txt)
+{
+       GSList *cursor;
+       GSList *match_list = get_url_matches (txt);
+
+       /* we will work backwards, so the offsets stay valid */
+       for (cursor = match_list; cursor; cursor = cursor->next) {
+
+               url_match_t *match = (url_match_t*) cursor->data;
+               gchar *url  = g_strndup (txt->str + match->offset, match->len);
+               gchar *repl = NULL; /* replacement  */
+
+               /* the prefix is NULL: use the one that is already there */
+               repl = g_strdup_printf ("<a href=\"%s%s\">%s</a>",
+                                       match->prefix ? match->prefix : "", url, url);
+
+               /* replace the old thing with our hyperlink
+                * replacement thing */
+               g_string_erase  (txt, match->offset, match->len);
+               g_string_insert (txt, match->offset, repl);
+               
+               g_free (url);
+               g_free (repl);
+
+               g_free (cursor->data);  
+       }
+       
+       g_slist_free (match_list);
+}
+
+
+
+gchar*
+modest_text_utils_convert_to_html (const gchar *data)
+{
+       guint            i;
+       gboolean         first_space = TRUE;
+       GString         *html;      
+       gsize           len;
+
+       if (!data)
+               return NULL;
+
+       len = strlen (data);
+       html = g_string_sized_new (len + 100);  /* just a  guess... */
+       
+       g_string_append_printf (html,
+                               "<html>"
+                               "<head>"
+                               "<meta http-equiv=\"content-type\""
+                               " content=\"text/html; charset=utf8\">"
+                               "</head>"
+                               "<body><tt>");
+       
+       /* replace with special html chars where needed*/
+       for (i = 0; i != len; ++i)  {
+               char    kar = data[i]; 
+               switch (kar) {
+                       
+               case 0:  break; /* ignore embedded \0s */       
+               case '<' : g_string_append   (html, "&lt;"); break;
+               case '>' : g_string_append   (html, "&gt;"); break;
+               case '&' : g_string_append   (html, "&quot;"); break;
+               case '\n': g_string_append   (html, "<br>\n"); break;
+               default:
+                       if (kar == ' ') {
+                               g_string_append (html, first_space ? " " : "&nbsp;");
+                               first_space = FALSE;
+                       } else  if (kar == '\t')
+                               g_string_append (html, "&nbsp; &nbsp;&nbsp;");
+                       else {
+                               int charnum = 0;
+                               first_space = TRUE;
+                               /* optimization trick: accumulate 'normal' chars, then copy */
+                               do {
+                                       kar = data [++charnum + i];
+                                       
+                               } while ((i + charnum < len) &&
+                                        (kar > '>' || (kar != '<' && kar != '>'
+                                                       && kar != '&' && kar !=  ' '
+                                                       && kar != '\n' && kar != '\t')));
+                               g_string_append_len (html, &data[i], charnum);
+                               i += (charnum  - 1);
+                       }
+               }
+       }
+       
+       g_string_append (html, "</tt></body></html>");
+       hyperlinkify_plain_text (html);
+
+       return g_string_free (html, FALSE);
+}
+
+
+
index 3f5bb68..f7da471 100644 (file)
@@ -35,8 +35,6 @@
 
 #include <time.h>
 
 
 #include <time.h>
 
-/* public */
-
 /**
  * modest_text_utils_quote:
  * @buf: a string which contains the message to quote
 /**
  * modest_text_utils_quote:
  * @buf: a string which contains the message to quote
  * @sent_date: sent date/time of the original message
  * @limit: specifies the maximum characters per line in the quoted text
  * 
  * @sent_date: sent date/time of the original message
  * @limit: specifies the maximum characters per line in the quoted text
  * 
- * Returns: a string containing the quoted message
+ * quote an existing message
+ * 
+ * Returns: a newly allocated string containing the quoted message
+ */
+gchar* modest_text_utils_quote(const gchar *buf, const gchar *from,
+                              const time_t sent_date, const int limit);
+
+
+/**
+ * modest_text_utils_derived_subject:
+ * @subject: a string which contains the original subject
+ * @prefix: the prefix for the new subject (such as 'Re:' or 'Fwd:')
+ *
+ * create a 'derived' subject line for eg. replies and forwards 
+ * 
+ * Returns: a newly allocated string containing the resulting subject
+ */
+gchar* modest_text_utils_derived_subject (const gchar *subject, const gchar* prefix);
+
+
+/**
+ * modest_text_utils_cited_text:
+ * @from: sender of the message
+ * @sent_date: the sent date of the original message
+ * @text: the text of the original message
+ *
+ * cite the text in a message
+ * 
+ * Returns: a newly allocated string containing the cited text
+ */
+gchar* modest_text_utils_cited_text (const gchar *from,
+                                    time_t sent_date,
+                                    const gchar *text);
+
+/**
+ * modest_text_utils_inlined_text
+ * @from: the sender of the original message
+ * @sent_date: sent date/time of the original message
+ * @to: sent date/time of the original message
+ * @subject: sent date/time of the original message
+ * @text: sent date/time of the original message
+ *
+ * creates a new string with the "Original message" text prepended to
+ * the text passed as argument and some data of the header
+ * 
+ * Returns: a newly allocated string containing the quoted message
  */
  */
-gchar* modest_text_utils_quote(const gchar *buf,
-                        const gchar *from,
-                        const time_t sent_date,
-                        const int limit);
+gchar*   modest_text_utils_inlined_text (const gchar *from,
+                                        time_t sent_date,
+                                        const gchar *to,
+                                        const gchar *subject,
+                                        const gchar *text);
 
 
-gchar* modest_text_utils_create_reply_subject (const gchar *subject);
+/**
+ * modest_text_utils_remove_address
+ * @address_list: string with a comma-separated list of email addresses
+ * @address: an specific e-mail address
+ *
+ * remove a specific address from a list of email addresses
+ * 
+ * Returns: a newly allocated string containing the new list
+ */
+gchar*   modest_text_utils_remove_address (const gchar *address_list, 
+                                          const gchar *address);
+
+/**
+ * modest_text_utils_convert_to_html:
+ * @txt: a string which contains the message to quote
+ *
+ * convert plain text (utf8) into html
+ * 
+ * Returns: a newly allocated string containing the html
+ */
+gchar*  modest_text_utils_convert_to_html (const gchar *data);
 
 
-gchar* modest_text_utils_create_forward_subject (const gchar *subject);
 
 
-gchar* modest_text_utils_create_cited_text (const gchar *from,
-                                           time_t sent_date,
-                                           const gchar *text);
+/**
+ * modest_text_utils_strftime:
+ * @s:
+ * @max:
+ * @fmt:
+ * @tm
+ *
+ * this is just an alias for strftime(3), so we can use that without
+ * getting warning from gcc
+ * 
+ * Returns: a formatted string of max length @max in @s
+ */
+size_t modest_text_utils_strftime(char *s, size_t max, const char  *fmt, const  struct tm *tm);
 
 
-gchar* modest_text_utils_create_inlined_text (const gchar *from,
-                                             time_t sent_date,
-                                             const gchar *to,
-                                             const gchar *subject,
-                                             const gchar *text);
 
 
-gchar* modest_text_utils_remove_mail_from_mail_list (const gchar *emails, 
-                                                    const gchar *email);
 #endif /* __MODEST_TEXT_UTILS_H__ */
 #endif /* __MODEST_TEXT_UTILS_H__ */
index 55c0269..f05abcc 100644 (file)
@@ -53,7 +53,6 @@ get_body_text (TnyMsg *msg, gboolean want_html)
        GtkTextBuffer *buf;
        GtkTextIter start, end;
        const gchar *to_quote;
        GtkTextBuffer *buf;
        GtkTextIter start, end;
        const gchar *to_quote;
-       gchar *quoted;
 
        body = modest_tny_msg_actions_find_body_part(msg, want_html);
        if (!body)
 
        body = modest_tny_msg_actions_find_body_part(msg, want_html);
        if (!body)
index c1fcdeb..5b6d5ac 100644 (file)
@@ -39,6 +39,7 @@
 #include <tny-simple-list.h>
 
 #include <modest-tny-msg-actions.h>
 #include <tny-simple-list.h>
 
 #include <modest-tny-msg-actions.h>
+#include <modest-text-utils.h>
 #include "modest-msg-view.h"
 #include "modest-tny-stream-gtkhtml.h"
 
 #include "modest-msg-view.h"
 #include "modest-tny-stream-gtkhtml.h"
 
@@ -48,41 +49,13 @@ static void     modest_msg_view_class_init   (ModestMsgViewClass *klass);
 static void     modest_msg_view_init         (ModestMsgView *obj);
 static void     modest_msg_view_finalize     (GObject *obj);
 
 static void     modest_msg_view_init         (ModestMsgView *obj);
 static void     modest_msg_view_finalize     (GObject *obj);
 
-
-static GSList*  get_url_matches (GString *txt);
 static gboolean on_link_clicked (GtkWidget *widget, const gchar *uri, ModestMsgView *msg_view);
 static gboolean on_url_requested (GtkWidget *widget, const gchar *uri, GtkHTMLStream *stream,
                                  ModestMsgView *msg_view);
 static gboolean on_link_hover (GtkWidget *widget, const gchar *uri, ModestMsgView *msg_view);
 
 static gboolean on_link_clicked (GtkWidget *widget, const gchar *uri, ModestMsgView *msg_view);
 static gboolean on_url_requested (GtkWidget *widget, const gchar *uri, GtkHTMLStream *stream,
                                  ModestMsgView *msg_view);
 static gboolean on_link_hover (GtkWidget *widget, const gchar *uri, ModestMsgView *msg_view);
 
-/*
- * we need these regexps to find URLs in plain text e-mails
- */
-typedef struct _UrlMatchPattern UrlMatchPattern;
-struct _UrlMatchPattern {
-       gchar   *regex;
-       regex_t *preg;
-       gchar   *prefix;
-};
-
 #define ATT_PREFIX "att:"
 
 #define ATT_PREFIX "att:"
 
-#define MAIL_VIEWER_URL_MATCH_PATTERNS  {                              \
-       { "(file|rtsp|http|ftp|https)://[-A-Za-z0-9_$.+!*(),;:@%&=?/~#]+[-A-Za-z0-9_$%&=?/~#]",\
-         NULL, NULL },\
-       { "www\\.[-a-z0-9.]+[-a-z0-9](:[0-9]*)?(/[-A-Za-z0-9_$.+!*(),;:@%&=?/~#]*[^]}\\),?!;:\"]?)?",\
-         NULL, "http://" },\
-       { "ftp\\.[-a-z0-9.]+[-a-z0-9](:[0-9]*)?(/[-A-Za-z0-9_$.+!*(),;:@%&=?/~#]*[^]}\\),?!;:\"]?)?",\
-         NULL, "ftp://" },\
-       { "(voipto|callto|chatto|jabberto|xmpp):[-_a-z@0-9.\\+]+", \
-          NULL, NULL},                                             \
-       { "mailto:[-_a-z0-9.\\+]+@[-_a-z0-9.]+",                    \
-         NULL, NULL},\
-       { "[-_a-z0-9.\\+]+@[-_a-z0-9.]+",\
-         NULL, "mailto:"}\
-       }
-
-
 /* list my signals */
 enum {
        LINK_CLICKED_SIGNAL,
 /* list my signals */
 enum {
        LINK_CLICKED_SIGNAL,
@@ -354,14 +327,6 @@ on_url_requested (GtkWidget *widget, const gchar *uri,
 }
 
 
 }
 
 
-typedef struct  {
-       guint offset;
-       guint len;
-       const gchar* prefix;
-} url_match_t;
-
-
-
 /* render the attachments as hyperlinks in html */
 static gchar*
 attachments_as_html (ModestMsgView *self, TnyMsg *msg)
 /* render the attachments as hyperlinks in html */
 static gchar*
 attachments_as_html (ModestMsgView *self, TnyMsg *msg)
@@ -416,181 +381,6 @@ attachments_as_html (ModestMsgView *self, TnyMsg *msg)
 
 
 
 
 
 
-static void
-hyperlinkify_plain_text (GString *txt)
-{
-       GSList *cursor;
-       GSList *match_list = get_url_matches (txt);
-
-       /* we will work backwards, so the offsets stay valid */
-       for (cursor = match_list; cursor; cursor = cursor->next) {
-
-               url_match_t *match = (url_match_t*) cursor->data;
-               gchar *url  = g_strndup (txt->str + match->offset, match->len);
-               gchar *repl = NULL; /* replacement  */
-
-               /* the prefix is NULL: use the one that is already there */
-               repl = g_strdup_printf ("<a href=\"%s%s\">%s</a>",
-                                       match->prefix ? match->prefix : "", url, url);
-
-               /* replace the old thing with our hyperlink
-                * replacement thing */
-               g_string_erase  (txt, match->offset, match->len);
-               g_string_insert (txt, match->offset, repl);
-               
-               g_free (url);
-               g_free (repl);
-
-               g_free (cursor->data);  
-       }
-       
-       g_slist_free (match_list);
-}
-
-
-
-static gchar *
-convert_to_html (const gchar *data)
-{
-       guint            i;
-       gboolean         first_space = TRUE;
-       GString         *html;      
-       gsize           len;
-
-       if (!data)
-               return NULL;
-
-       len = strlen (data);
-       html = g_string_sized_new (len + 100);  /* just a  guess... */
-       
-       g_string_append_printf (html,
-                               "<html>"
-                               "<head>"
-                               "<meta http-equiv=\"content-type\""
-                               " content=\"text/html; charset=utf8\">"
-                               "</head>"
-                               "<body><tt>");
-       
-       /* replace with special html chars where needed*/
-       for (i = 0; i != len; ++i)  {
-               char    kar = data[i]; 
-               switch (kar) {
-                       
-               case 0:  break; /* ignore embedded \0s */       
-               case '<' : g_string_append   (html, "&lt;"); break;
-               case '>' : g_string_append   (html, "&gt;"); break;
-               case '&' : g_string_append   (html, "&quot;"); break;
-               case '\n': g_string_append   (html, "<br>\n"); break;
-               default:
-                       if (kar == ' ') {
-                               g_string_append (html, first_space ? " " : "&nbsp;");
-                               first_space = FALSE;
-                       } else  if (kar == '\t')
-                               g_string_append (html, "&nbsp; &nbsp;&nbsp;");
-                       else {
-                               int charnum = 0;
-                               first_space = TRUE;
-                               /* optimization trick: accumulate 'normal' chars, then copy */
-                               do {
-                                       kar = data [++charnum + i];
-                                       
-                               } while ((i + charnum < len) &&
-                                        (kar > '>' || (kar != '<' && kar != '>'
-                                                       && kar != '&' && kar !=  ' '
-                                                       && kar != '\n' && kar != '\t')));
-                               g_string_append_len (html, &data[i], charnum);
-                               i += (charnum  - 1);
-                       }
-               }
-       }
-       
-       g_string_append (html, "</tt></body></html>");
-       hyperlinkify_plain_text (html);
-
-       return g_string_free (html, FALSE);
-}
-
-
-
-
-static gint 
-cmp_offsets_reverse (const url_match_t *match1, const url_match_t *match2)
-{
-       return match2->offset - match1->offset;
-}
-
-
-
-/*
- * check if the match is inside an existing match... */
-static void
-chk_partial_match (const url_match_t *match, guint* offset)
-{
-       if (*offset >= match->offset && *offset < match->offset + match->len)
-               *offset = -1;
-}
-
-static GSList*
-get_url_matches (GString *txt)
-{
-       regmatch_t rm;
-        guint rv, i, offset = 0;
-        GSList *match_list = NULL;
-
-       static UrlMatchPattern patterns[] = MAIL_VIEWER_URL_MATCH_PATTERNS;
-       const size_t pattern_num = sizeof(patterns)/sizeof(UrlMatchPattern);
-
-       /* initalize the regexps */
-       for (i = 0; i != pattern_num; ++i) {
-               patterns[i].preg = g_new0 (regex_t,1);
-               g_assert(regcomp (patterns[i].preg, patterns[i].regex,
-                                 REG_ICASE|REG_EXTENDED|REG_NEWLINE) == 0);
-       }
-        /* find all the matches */
-       for (i = 0; i != pattern_num; ++i) {
-               offset     = 0; 
-               while (1) {
-                       int test_offset;
-                       if ((rv = regexec (patterns[i].preg, txt->str + offset, 1, &rm, 0)) != 0) {
-                               g_assert (rv == REG_NOMATCH); /* this should not happen */
-                               break; /* try next regexp */ 
-                       }
-                       if (rm.rm_so == -1)
-                               break;
-
-                       /* FIXME: optimize this */
-                       /* to avoid partial matches on something that was already found... */
-                       /* check_partial_match will put -1 in the data ptr if that is the case */
-                       test_offset = offset + rm.rm_so;
-                       g_slist_foreach (match_list, (GFunc)chk_partial_match, &test_offset);
-                       
-                       /* make a list of our matches (<offset, len, prefix> tupels)*/
-                       if (test_offset != -1) {
-                               url_match_t *match = g_new (url_match_t,1);
-                               match->offset = offset + rm.rm_so;
-                               match->len    = rm.rm_eo - rm.rm_so;
-                               match->prefix = patterns[i].prefix;
-                               match_list = g_slist_prepend (match_list, match);
-                       }
-                       offset += rm.rm_eo;
-               }
-       }
-
-       for (i = 0; i != pattern_num; ++i) {
-               regfree (patterns[i].preg);
-               g_free  (patterns[i].preg);
-       } /* don't free patterns itself -- it's static */
-       
-       /* now sort the list, so the matches are in reverse order of occurence.
-        * that way, we can do the replacements starting from the end, so we don't need
-        * to recalculate the offsets
-        */
-       match_list = g_slist_sort (match_list,
-                                  (GCompareFunc)cmp_offsets_reverse); 
-       return match_list;      
-}
-
-
 
 static gboolean
 set_html_message (ModestMsgView *self, TnyMimePart *tny_body, TnyMsg *msg)
 
 static gboolean
 set_html_message (ModestMsgView *self, TnyMimePart *tny_body, TnyMsg *msg)
@@ -669,7 +459,7 @@ set_text_message (ModestMsgView *self, TnyMimePart *tny_body, TnyMsg *msg)
        gtk_text_buffer_get_bounds (buf, &begin, &end);
        txt = gtk_text_buffer_get_text (buf, &begin, &end, FALSE);
        if (txt) {
        gtk_text_buffer_get_bounds (buf, &begin, &end);
        txt = gtk_text_buffer_get_text (buf, &begin, &end, FALSE);
        if (txt) {
-               gchar *html = convert_to_html (txt);
+               gchar *html = modest_text_utils_convert_to_html (txt);
                tny_stream_write (gtkhtml_stream, html, strlen(html));
                tny_stream_reset (gtkhtml_stream);
                g_free (txt);
                tny_stream_write (gtkhtml_stream, html, strlen(html));
                tny_stream_reset (gtkhtml_stream);
                g_free (txt);