From 76bbd700763e4b45614df6ad6174fe831ddb932e Mon Sep 17 00:00:00 2001 From: nobody Date: Thu, 24 Jan 2002 19:01:46 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'EVOLUTION_1_0_2'. svn path=/tags/EVOLUTION_1_0_2/; revision=15455 --- my-evolution/ChangeLog | 65 +++------------- my-evolution/Locations | 147 ++++++++++++++++-------------------- my-evolution/Locations.h | 13 ---- my-evolution/Makefile.am | 4 +- my-evolution/e-summary-rdf.c | 166 +++++++++++++++++++++++++++++++---------- my-evolution/e-summary-tasks.c | 22 ++++-- my-evolution/e-summary.c | 156 +++++++++++++++++++++----------------- my-evolution/main.c | 2 + 8 files changed, 305 insertions(+), 270 deletions(-) (limited to 'my-evolution') diff --git a/my-evolution/ChangeLog b/my-evolution/ChangeLog index 93f1c4afed..924525a072 100644 --- a/my-evolution/ChangeLog +++ b/my-evolution/ChangeLog @@ -1,9 +1,3 @@ -2002-01-24 Iain Holmes - - * Locations: Applied the Ukraine patch from Leonid Kanter - - * Locations.h: Re-generated to get the UK stations added. - 2002-01-22 Iain Holmes * e-summary-mail (e_summary_mail_reconfigure): Do the list backwards. @@ -11,59 +5,12 @@ * e-summary-preferences.c (fill_mail_shown_clist): Prepend items. (mail_add_clicked_cb): Prepend items. -2002-01-04 Iain Holmes - - * e-summary-weather.c (message_finished): Made the Weather message - more verbose, and say which station data could not be retrieved for. - -2002-01-03 Iain Holmes - - * Makefile.am: Use SOUP_CFLAGS and SOUP_LIBS - - * e-summary-rdf.c: Include soup.h - (close_callback): Remove. - (message_finished): Generate the cache and other stuff and redraw. - (read_callback): Remove. - (open_callback): Remove. - (e_summary_rdf_update): Replace gnome-vfs with Soup stuff. - (e_summary_rdf_count): Replace gnome-vfs with soup. - (rdf_free): ditto - (e_summary_rdf_set_online): Ditto - - * e-summary-weather.c: Include soup.h - (close_callback): Remove. - (message_finished): Parse all the downloaded html. - (read_callback): Remove. - (open_callback): Remove. - (e_summary_weather_update): Use soup instead of gnome-vfs - (weather_free): Ditto. - (e_summary_weather_count): Ditto. - (e_summary_weather_add): ditto; - (e_summary_weather_set_online): Ditto. - - * e-summary.c (close_callback): Remove. - (read_callback): Remove. - (open_callback): Remove. - (e_read_file_with_length): Read a file. - (e_summary_url_requested): Create the images cache. Load the image - with e_read_file_with_length instead of gnome-vfs. - - * main.c (main): Remove gnome_vfs_init. - - * weather.h: Replace gnome-vfs stuff. +2002-02-03 Iain Holmes -2002-01-03 Iain Holmes - - * e-summary-offline-handler.c (impl_prepareForOffline): Create an + * e-summary-offline-handler.c (impl_prepareForOffline): Create an empty list if the summary == NULL. Fixes bug 18025 -2001-12-20 Ettore Perazzoli - - [Fixes #17377, Evolution doesn't work on multi-depth displays.] - - * main.c (main): Push GdkRGB visual and colormap. - -2001-12-19 JP Rosevear +2001-12-18 JP Rosevear * e-summary-tasks.c (e_summary_tasks_init): use cal_client_open_default_tasks @@ -71,6 +18,12 @@ * e-summary-calendar.c (e_summary_calendar_init): use cal_client_open_default_calendar +2001-12-17 Ettore Perazzoli + + [Fixes #17377, Evolution doesn't work on multi-depth displays.] + + * main.c (main): Push GdkRGB visual and colormap. + 2001-12-14 Iain Holmes * Location-translation-script: shell script to convert Locations to diff --git a/my-evolution/Locations b/my-evolution/Locations index 1d242283df..40ac71b2d8 100644 --- a/my-evolution/Locations +++ b/my-evolution/Locations @@ -1,5 +1,5 @@ [Main] -regions=US CA MX EU AF OZ ME AS M_ AT +regions=US CA EU AF OZ ME AS M_ AT [ME] name=Middle East @@ -1581,74 +1581,9 @@ loc3=Swift\\ Current CYYN ------ --- name=Yukon loc0=Shingle\\ Point CYUA ------ --- -[MX] -name=Mexico -states=MX - -[MX_MX] -name=Mexico -loc0=Acapulco MMAA ------ --- -loc1=Aeropuerto\\ del\\ Norte MMAN ------ --- -loc2=Aguascaliantes MMAS ------ --- -loc3=Bahias\\ de\\ Huatulco MMBT ------ --- -loc4=Campeche MMCP ------ --- -loc5=Cancun MMUN ------ --- -loc6=Chetumal MMCM ------ --- -loc7=Chihuahua MMCU ------ --- -loc8=Ciudad\\ del\\ Carmen MMCE ------ --- -loc9=Ciudad\\ Juarez MMCS ------ --- -loc10=Ciudad\\ Obregon MMCN ------ --- -loc11=Ciudad\\ Victoria MMCV ------ --- -loc12=Colima MMIA ------ --- -loc13=Cozumel MMCZ ------ --- -loc14=Cuernavaca MMCB ------ --- -loc15=Culiacan MMCL ------ --- -loc16=Del\\ Bajio MMLO ------ --- -loc17=Durango MMDO ------ --- -loc18=Guadalajara MMGL ------ --- -loc19=Guaymas MMGM ------ --- -loc20=Hermosillo MMHO ------ --- -loc21=Ixtapa MMZH ------ --- -loc22=La\\ Paz MMLP ------ --- -loc23=Los\\ Mochis MMLM ------ --- -loc24=Manzanillo MMZO ------ --- -loc25=Matamoros MMMA ------ --- -loc26=Mazatlan MMMZ ------ --- -loc27=Merida MMMD ------ --- -loc28=Mexicali MMML ------ --- -loc29=Mexico MMMX ------ --- -loc30=Minatitlan MMMT ------ --- -loc31=Monclova MMMV ------ --- -loc32=Morelia MMMM ------ --- -loc33=Monterrey MMMY ------ --- -loc34=Nuevo\\ Laredo MMNL ------ --- -loc35=Oaxaca MMOX ------ --- -loc36=Piedras\\ Negras MMPG ------ --- -loc37=Poza\\ Rica MMPA ------ --- -loc38=Puebla MMPB ------ --- -loc39=Puerto\\ Vallarta MMPR ------ --- -loc40=Puerto\\ Escondido MMPS ------ --- -loc41=Queretaro MMQT ------ --- -loc42=Reynosa MMRX ------ --- -loc43=Saltillo MMIO ------ --- -loc44=San\\ Jose\\ del\\ Cabo MMSD ------ --- -loc45=San\\ Luis\\ Potosi MMSP ------ --- -loc46=Tampico MMTM ------ --- -loc47=Tapachula MMTP ------ --- -loc48=Tepic MMEP ------ --- -loc49=Tijuana MMTJ ------ --- -loc50=Toluca MMTO ------ --- -loc51=Torreon MMTC ------ --- -loc52=Tulancingo MMTL ------ --- -loc53=Tuxtla\\ Gutierrez MMTG ------ --- -loc54=Uruapan MMPN ------ --- -loc55=Veracruz MMVR ------ --- -loc56=Villahermosa MMVA ------ --- -loc57=Zacatecas MMZC ------ --- - [EU] name=Europe -states=AB OS BE BA BG CZ HR CY DK EE FI FR MK DE GI GR HU IE IS IT LV LT LU MT MD NL NO PL PT RO RU SK SI SP SE CH TR UA UK YU +states=AB OS BE BA BG CZ HR CY DK EE FI FR MK DE GI GR HU IE IS IT LV LT LU MT MD NL NO PL PT RO RU SK SI SP SE CH TR UK YU [EU_AB] name=Albania @@ -1915,21 +1850,6 @@ loc50=Yakutsk UEEE ------ --- loc51=Yekaterinburg USSS ------ --- loc52=Yuzhno-Sakhalinsk UHSS ------ --- -[EU_UA] -name=Ukraine -loc0=Dnipropetrovsk UKDD ------ --- -loc1=Donetsk UKCC ------ --- -loc2=Ivano-Frankivsk UKLI ------ --- -loc3=Kharkiv UKHH ------ --- -loc4=Kyyiv/Boryspil UKBB ------ --- -loc5=Kyyiv/Zhulyany UKKK ------ --- -loc6=Kryviy\\ Rig/Lozovatka UKDR ------ --- -loc7=Lviv UKLL ------ --- -loc8=Odesa UKOO ------ --- -loc9=Rivne UKLR ------ --- -loc10=Sympheropol UKFF ------ --- -loc11=Uzhgorod UKLU ------ --- - [EU_SK] name=Slovakia loc0=Bratislava LZIB ------ --- @@ -2681,7 +2601,7 @@ loc23=Wuchia\\ Observatory RCMQ ------ --- [M_] name=Central and South America -states=BS BZ KY CU CR DO SV GT HT HN JM NI PA AR BR BO CL CO EC PY PE SR UY VE +states=BS BZ KY CU CR DO SV GT HT HN JM MX NI PA AR BR BO CL CO EC PY PE SR UY VE [M__BS] name=Bahamas @@ -2909,6 +2829,67 @@ loc16=San\\ Fernando\\ De\\ Apure SVSR ------ --- loc17=Valera* SVVL ------ --- loc18=Caracas\\ La\\ Carlota SVFM ------ --- +[M__MX] +name=Mexico +loc0=Acapulco MMAA ------ --- +loc1=Aeropuerto\\ del\\ Norte MMAN ------ --- +loc2=Aguascaliantes MMAS ------ --- +loc3=Bahias\\ de\\ Huatulco MMBT ------ --- +loc4=Campeche MMCP ------ --- +loc5=Cancun MMUN ------ --- +loc6=Chetumal MMCM ------ --- +loc7=Chihuahua MMCU ------ --- +loc8=Ciudad\\ del\\ Carmen MMCE ------ --- +loc9=Ciudad\\ Juarez MMCS ------ --- +loc10=Ciudad\\ Obregon MMCN ------ --- +loc11=Ciudad\\ Victoria MMCV ------ --- +loc12=Colima MMIA ------ --- +loc13=Cozumel MMCZ ------ --- +loc14=Cuernavaca MMCB ------ --- +loc15=Culiacan MMCL ------ --- +loc16=Del\\ Bajio MMLO ------ --- +loc17=Durango MMDO ------ --- +loc18=Guadalajara MMGL ------ --- +loc19=Guaymas MMGM ------ --- +loc20=Hermosillo MMHO ------ --- +loc21=Ixtapa MMZH ------ --- +loc22=La\\ Paz MMLP ------ --- +loc23=Los\\ Mochis MMLM ------ --- +loc24=Manzanillo MMZO ------ --- +loc25=Matamoros MMMA ------ --- +loc26=Mazatlan MMMZ ------ --- +loc27=Merida MMMD ------ --- +loc28=Mexicali MMML ------ --- +loc29=Mexico MMMX ------ --- +loc30=Minatitlan MMMT ------ --- +loc31=Monclova MMMV ------ --- +loc32=Morelia MMMM ------ --- +loc33=Monterrey MMMY ------ --- +loc34=Nuevo\\ Laredo MMNL ------ --- +loc35=Oaxaca MMOX ------ --- +loc36=Piedras\\ Negras MMPG ------ --- +loc37=Poza\\ Rica MMPA ------ --- +loc38=Puebla MMPB ------ --- +loc39=Puerto\\ Vallarta MMPR ------ --- +loc40=Puerto\\ Escondido MMPS ------ --- +loc41=Queretaro MMQT ------ --- +loc42=Reynosa MMRX ------ --- +loc43=Saltillo MMIO ------ --- +loc44=San\\ Jose\\ del\\ Cabo MMSD ------ --- +loc45=San\\ Luis\\ Potosi MMSP ------ --- +loc46=Tampico MMTM ------ --- +loc47=Tapachula MMTP ------ --- +loc48=Tepic MMEP ------ --- +loc49=Tijuana MMTJ ------ --- +loc50=Toluca MMTO ------ --- +loc51=Torreon MMTC ------ --- +loc52=Tulancingo MMTL ------ --- +loc53=Tuxtla\\ Gutierrez MMTG ------ --- +loc54=Uruapan MMPN ------ --- +loc55=Veracruz MMVR ------ --- +loc56=Villahermosa MMVA ------ --- +loc57=Zacatecas MMZC ------ --- + [M__AR] name=Argentina loc0=Aeroparque SABE ------ --- diff --git a/my-evolution/Locations.h b/my-evolution/Locations.h index 5f554a78e1..d41489411b 100644 --- a/my-evolution/Locations.h +++ b/my-evolution/Locations.h @@ -600,13 +600,11 @@ N_("Dillon") N_("Dinard") N_("District of Columbia") N_("Diyarbakir") -N_("Dnipropetrovsk") N_("Dobbiaco") N_("Dodge City") N_("Doha") N_("Dole") N_("Dominican Republic") -N_("Donetsk") N_("Dongsha") N_("Dongshi") N_("Don Torcuato") @@ -1015,7 +1013,6 @@ N_("Istanbul") N_("Itaituba") N_("Italy") N_("Ithaca") -N_("Ivano-Frankivsk") N_("Iwakuni MCAS") N_("Iwojima") N_("Ixtapa") @@ -1092,7 +1089,6 @@ N_("Key West") N_("Key West NAS") N_("Khabarovsk") N_("Khamis Mushait") -N_("Kharkiv") N_("Kikai Island") N_("Killeen") N_("Killeen-Ft Hood") @@ -1139,13 +1135,10 @@ N_("Krasnodar") N_("Krasnoyarsk") N_("Kristiansand/Kjevik") N_("Kristiansund/Kvernberget") -N_("Kryviy Rig/Lozovatka") N_("Kumamoto Airport") N_("Kunming") N_("Kushiro Airport") N_("Kuwait") -N_("Kyyiv/Boryspil") -N_("Kyyiv/Zhulyany") N_("La Ceiba") N_("Laconia") N_("La Coruna") @@ -1268,7 +1261,6 @@ N_("Luton") N_("Luxembourg") N_("Luxeuil") N_("Luxor") -N_("Lviv") N_("Lynchburg") N_("Lyneham") N_("Lyon-Bron") @@ -1605,7 +1597,6 @@ N_("Obihiro Airport") N_("Ocala") N_("Oceanside") N_("Odense") -N_("Odesa") N_("Oelwen") N_("Ogden") N_("Ogden-Hill AFB") @@ -1893,7 +1884,6 @@ N_("Rivera") N_("Riverside") N_("Riverside/March AFB") N_("Riverton") -N_("Rivne") N_("Rivolto") N_("Riyadh") N_("Roanoke") @@ -2183,7 +2173,6 @@ N_("Swift Current") N_("Switzerland") N_("Sydney") N_("Syktyvkar") -N_("Sympheropol") N_("Syracuse") N_("Szczecin") N_("Szombathely") @@ -2331,7 +2320,6 @@ N_("Tyumen") N_("Uberaba") N_("Ufa") N_("Ukiah") -N_("Ukraine") N_("Ulan-Ude") N_("Ulsan") N_("Ulyanovsk") @@ -2351,7 +2339,6 @@ N_("Utah") N_("Utica") N_("Utrecht/Soesterberg") N_("Utsunomiya Ab") -N_("Uzhgorod") N_("Vadso") N_("Vaerlose") N_("Vagar") diff --git a/my-evolution/Makefile.am b/my-evolution/Makefile.am index 6e057d9493..1213ac79f2 100644 --- a/my-evolution/Makefile.am +++ b/my-evolution/Makefile.am @@ -13,7 +13,6 @@ INCLUDES = \ $(GTKHTML_CFLAGS) \ $(BONOBO_CONF_CFLAGS) \ $(BONOBO_GNOME_CFLAGS) \ - $(SOUP_CFLAGS) \ -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ -DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \ -DEVOLUTION_DATADIR=\""$(datadir)"\" \ @@ -70,10 +69,9 @@ evolution_executive_summary_LDADD = \ $(top_builddir)/libversit/libversit.la \ $(top_builddir)/libical/src/libical/libical-evolution.la \ $(top_builddir)/libwombat/libwombat.la \ - $(BONOBO_GNOME_LIBS) \ + $(BONOBO_VFS_GNOME_LIBS) \ $(BONOBO_CONF_LIBS) \ $(EXTRA_GNOME_LIBS) \ - $(SOUP_LIBS) \ -lgal \ $(GTKHTML_LIBS) diff --git a/my-evolution/e-summary-rdf.c b/my-evolution/e-summary-rdf.c index 1fe6d33003..015f75246e 100644 --- a/my-evolution/e-summary-rdf.c +++ b/my-evolution/e-summary-rdf.c @@ -33,12 +33,8 @@ #include #include - - #include - -#include - +#include #include "e-summary.h" struct _ESummaryRDF { @@ -53,14 +49,14 @@ struct _ESummaryRDF { typedef struct _RDF { char *uri; char *html; + GnomeVFSAsyncHandle *handle; + GString *string; + char *buffer; xmlDocPtr cache; ESummary *summary; gboolean shown; - - /* Soup stuff */ - SoupMessage *message; } RDF; int xmlSubstituteEntitiesDefaultValue = 1; @@ -318,35 +314,120 @@ display_doc (RDF *r) } static void -message_finished (SoupMessage *msg, - gpointer userdata) +close_callback (GnomeVFSAsyncHandle *handle, + GnomeVFSResult result, + RDF *r) { + ESummary *summary; + char *xml; xmlDocPtr doc; - RDF *r = (RDF *) userdata; - if (SOUP_MESSAGE_IS_ERROR (msg)) { - g_warning ("Message failed: %d\n%s", msg->errorcode, - msg->errorphrase); - r->cache = NULL; - r->message = NULL; + summary = r->summary; + if (summary->rdf->connection->callback) { + ESummaryConnection *connection = summary->rdf->connection; + connection->callback (summary, connection->callback_closure); + } - display_doc (r); + if (r->handle == NULL) { + g_free (r->buffer); + r->buffer = NULL; + g_string_free (r->string, TRUE); + r->string = NULL; return; } + r->handle = NULL; + g_free (r->buffer); + r->buffer = NULL; + xml = r->string->str; + g_string_free (r->string, FALSE); + r->string = NULL; + if (r->cache != NULL) { xmlFreeDoc (r->cache); r->cache = NULL; } - doc = xmlParseMemory (msg->response.body, msg->response.length); + doc = xmlParseMemory (xml, strlen (xml)); +#if 0 + if (doc == NULL) { + g_free (r->html); + r->html = g_strdup ("Error parsing XML"); + + e_summary_draw (r->summary); + g_free (xml); + return; + } +#endif + g_free (xml); r->cache = doc; - r->message = NULL; - /* Display it */ + /* Draw it */ display_doc (r); } +static void +read_callback (GnomeVFSAsyncHandle *handle, + GnomeVFSResult result, + gpointer buffer, + GnomeVFSFileSize bytes_requested, + GnomeVFSFileSize bytes_read, + RDF *r) +{ + if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_EOF) { + char *str; + + g_free (r->html); + str = g_strdup_printf ("%s:
%s", _("Error downloading RDF"), + r->uri); + r->html = e_utf8_from_locale_string (str); + + g_free (str); + + e_summary_draw (r->summary); + r->handle = NULL; + gnome_vfs_async_close (handle, + (GnomeVFSAsyncCloseCallback) close_callback, r); + return; + } + + if (bytes_read == 0) { + gnome_vfs_async_close (handle, + (GnomeVFSAsyncCloseCallback) close_callback, r); + } else { + *((char *) buffer + bytes_read) = 0; + g_string_append (r->string, (const char *) buffer); + gnome_vfs_async_read (handle, buffer, 4095, + (GnomeVFSAsyncReadCallback) read_callback, r); + } +} + +static void +open_callback (GnomeVFSAsyncHandle *handle, + GnomeVFSResult result, + RDF *r) +{ + if (result != GNOME_VFS_OK) { + char *str; + + r->handle = NULL; + g_free (r->html); + str = g_strdup_printf ("%s:
%s", _("Error downloading RDF"), + r->uri); + r->html = e_utf8_from_locale_string (str); + g_free (str); + + display_doc (r); + return; + } + + r->string = g_string_new (""); + r->buffer = g_new (char, 4096); + + gnome_vfs_async_read (handle, r->buffer, 4095, + (GnomeVFSAsyncReadCallback) read_callback, r); +} + gboolean e_summary_rdf_update (ESummary *summary) { @@ -358,23 +439,27 @@ e_summary_rdf_update (ESummary *summary) } for (r = summary->rdf->rdfs; r; r = r->next) { - SoupContext *context; RDF *rdf = r->data; - if (rdf->message) { - soup_message_cancel (rdf->message); + if (rdf->handle) { + gnome_vfs_async_cancel (rdf->handle); + rdf->handle = NULL; } - context = soup_context_get (rdf->uri); - if (context == NULL) { - g_warning ("Invalid URL: %s", rdf->uri); - soup_context_unref (context); - continue; + if (rdf->buffer) { + g_free (rdf->buffer); + rdf->buffer = NULL; + } + + if (rdf->string) { + g_string_free (rdf->string, TRUE); + rdf->string = NULL; } - rdf->message = soup_message_new (context, SOUP_METHOD_GET); - soup_context_unref (context); - soup_message_queue (rdf->message, message_finished, rdf); + g_warning ("Opening %s", rdf->uri); + gnome_vfs_async_open (&rdf->handle, rdf->uri, + GNOME_VFS_OPEN_READ, + (GnomeVFSAsyncOpenCallback) open_callback, rdf); } return TRUE; @@ -425,7 +510,7 @@ e_summary_rdf_count (ESummary *summary, for (p = rdf->rdfs; p; p = p->next) { RDF *r = p->data; - if (r->message != NULL) { + if (r->handle != NULL) { count++; } } @@ -456,7 +541,7 @@ e_summary_rdf_add (ESummary *summary, for (p = rdf->rdfs; p; p = p->next) { RDF *r = p->data; - if (r->message != NULL) { + if (r->handle != NULL) { ESummaryConnectionData *d; d = make_connection (r); @@ -471,12 +556,17 @@ static void rdf_free (RDF *r) { /* Stop the download */ - if (r->message) { - soup_message_cancel (r->message); + if (r->handle) { + gnome_vfs_async_cancel (r->handle); } g_free (r->uri); g_free (r->html); + g_free (r->buffer); + + if (r->string) { + g_string_free (r->string, TRUE); + } if (r->cache) { xmlFreeDoc (r->cache); @@ -509,9 +599,9 @@ e_summary_rdf_set_online (ESummary *summary, RDF *r; r = p->data; - if (r->message) { - soup_message_cancel (r->message); - r->message = NULL; + if (r->handle) { + gnome_vfs_async_cancel (r->handle); + r->handle = NULL; } } diff --git a/my-evolution/e-summary-tasks.c b/my-evolution/e-summary-tasks.c index 6bcc65d2b7..a8c32b1db7 100644 --- a/my-evolution/e-summary-tasks.c +++ b/my-evolution/e-summary-tasks.c @@ -136,8 +136,8 @@ sort_uids (gconstpointer a, CalComponent *comp_a, *comp_b; CalClient *client = user_data; CalClientGetStatus status; - int real_a = 0, real_b = 0; - int *pri_a, *pri_b; + CalComponentDateTime start_a, start_b; + int retval; /* a after b then return > 0 */ @@ -149,13 +149,20 @@ sort_uids (gconstpointer a, if (status != CAL_CLIENT_GET_SUCCESS) return 1; - pri_a = &real_a; - pri_b = &real_b; + cal_component_get_dtstart (comp_a, &start_a); + cal_component_get_dtstart (comp_b, &start_b); - cal_component_get_priority (comp_a, &pri_a); - cal_component_get_priority (comp_b, &pri_b); + if (start_a.value == NULL || start_b.value == NULL) { + /* Try to do something reasonable if one or more of our .values is NULL */ + retval = (start_a.value ? 1 : 0) - (start_b.value ? 1 : 0); + } else { + retval = icaltime_compare (*start_a.value, *start_b.value); + } + + cal_component_free_datetime (&start_a); + cal_component_free_datetime (&start_b); - return *pri_a - *pri_b; + return retval; } static GList * @@ -251,7 +258,6 @@ generate_html (gpointer data) } else { char *s; - uids = cal_list_sort (uids, sort_uids, tasks->client); string = g_string_new ("
"); s = e_utf8_from_locale_string (_("Tasks")); diff --git a/my-evolution/e-summary.c b/my-evolution/e-summary.c index 2e70e74821..f03caa338d 100644 --- a/my-evolution/e-summary.c +++ b/my-evolution/e-summary.c @@ -24,12 +24,6 @@ #include #endif -#include -#include -#include -#include -#include - #include #include #include @@ -40,6 +34,8 @@ #include #include +#include + #include #include #include @@ -81,6 +77,13 @@ struct _ESummaryMailFolderInfo { int unread; }; +typedef struct _DownloadInfo { + GtkHTMLStream *stream; + char *uri; + char *buffer, *ptr; + guint32 bufsize; +} DownloadInfo; + struct _ESummaryPrivate { GNOME_Evolution_Shell shell; GNOME_Evolution_ShellView shell_view_interface; @@ -286,6 +289,74 @@ struct _imgcache { int bufsize; }; +static void +close_callback (GnomeVFSAsyncHandle *handle, + GnomeVFSResult result, + gpointer data) +{ + DownloadInfo *info = data; + struct _imgcache *img; + + if (images_cache == NULL) { + images_cache = g_hash_table_new (g_str_hash, g_str_equal); + } + + img = g_new (struct _imgcache, 1); + img->buffer = info->buffer; + img->bufsize = info->bufsize; + + g_hash_table_insert (images_cache, info->uri, img); + g_free (info); +} + +/* The way this behaves is a workaround for ximian bug 10235: loading + * the image into gtkhtml progressively will result in garbage being + * drawn, so we wait until we've read the whole thing and then write + * it all at once. + */ +static void +read_callback (GnomeVFSAsyncHandle *handle, + GnomeVFSResult result, + gpointer buffer, + GnomeVFSFileSize bytes_requested, + GnomeVFSFileSize bytes_read, + gpointer data) +{ + DownloadInfo *info = data; + + if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_EOF) { + gtk_html_stream_close (info->stream, GTK_HTML_STREAM_ERROR); + gnome_vfs_async_close (handle, close_callback, info); + } else if (bytes_read == 0) { + gtk_html_stream_write (info->stream, info->buffer, info->bufsize); + gtk_html_stream_close (info->stream, GTK_HTML_STREAM_OK); + gnome_vfs_async_close (handle, close_callback, info); + } else { + bytes_read += info->ptr - info->buffer; + info->bufsize += 4096; + info->buffer = g_realloc (info->buffer, info->bufsize); + info->ptr = info->buffer + bytes_read; + gnome_vfs_async_read (handle, info->ptr, 4095, read_callback, info); + } +} + +static void +open_callback (GnomeVFSAsyncHandle *handle, + GnomeVFSResult result, + DownloadInfo *info) +{ + if (result != GNOME_VFS_OK) { + gtk_html_stream_close (info->stream, GTK_HTML_STREAM_ERROR); + g_free (info->uri); + g_free (info); + return; + } + + info->bufsize = 4096; + info->buffer = info->ptr = g_new (char, info->bufsize); + gnome_vfs_async_read (handle, info->buffer, 4095, read_callback, info); +} + static void e_summary_url_clicked (GtkHTML *html, const char *url, @@ -316,52 +387,6 @@ e_summary_url_clicked (GtkHTML *html, protocol_listener->listener (summary, url, protocol_listener->closure); } -static char * -e_read_file_with_length (const char *filename, - size_t *length) -{ - int fd, ret; - struct stat stat_buf; - char *buf; - size_t bytes_read, size; - - g_return_val_if_fail (filename != NULL, NULL); - - fd = open (filename, O_RDONLY); - g_return_val_if_fail (fd != -1, NULL); - - fstat (fd, &stat_buf); - size = stat_buf.st_size; - buf = g_new (char, size + 1); - - bytes_read = 0; - while (bytes_read < size) { - ssize_t rc; - - rc = read (fd, buf + bytes_read, size - bytes_read); - if (rc < 0) { - if (errno != EINTR) { - close (fd); - g_free (buf); - - return NULL; - } - } else if (rc == 0) { - break; - } else { - bytes_read += rc; - } - } - - buf[bytes_read] = '\0'; - - if (length) { - *length = bytes_read; - } - - return buf; -} - static void e_summary_url_requested (GtkHTML *html, const char *url, @@ -369,6 +394,8 @@ e_summary_url_requested (GtkHTML *html, ESummary *summary) { char *filename; + GnomeVFSAsyncHandle *handle; + DownloadInfo *info; struct _imgcache *img = NULL; if (strncasecmp (url, "file:", 5) == 0) { @@ -387,28 +414,19 @@ e_summary_url_requested (GtkHTML *html, if (images_cache != NULL) { img = g_hash_table_lookup (images_cache, filename); - } else { - images_cache = g_hash_table_new (g_str_hash, g_str_equal); } if (img == NULL) { - size_t length; - char *contents; + info = g_new (DownloadInfo, 1); + info->stream = stream; + info->uri = filename; - contents = e_read_file_with_length (filename, &length); - if (contents == NULL) { - return; - } - - img = g_new (struct _imgcache, 1); - img->buffer = contents; - img->bufsize = length; - - g_hash_table_insert (images_cache, g_strdup (filename), img); + gnome_vfs_async_open (&handle, filename, GNOME_VFS_OPEN_READ, + (GnomeVFSAsyncOpenCallback) open_callback, info); + } else { + gtk_html_stream_write (stream, img->buffer, img->bufsize); + gtk_html_stream_close (stream, GTK_HTML_STREAM_OK); } - - gtk_html_stream_write (stream, img->buffer, img->bufsize); - gtk_html_stream_close (stream, GTK_HTML_STREAM_OK); } static void diff --git a/my-evolution/main.c b/my-evolution/main.c index 04e3c925cd..107b0919b8 100644 --- a/my-evolution/main.c +++ b/my-evolution/main.c @@ -43,6 +43,7 @@ #include #endif +#include #include #include "component-factory.h" @@ -71,6 +72,7 @@ main (int argc, #endif glade_gnome_init (); + gnome_vfs_init (); gtk_widget_push_visual (gdk_rgb_get_visual ()); gtk_widget_push_colormap (gdk_rgb_get_cmap ()); -- cgit v1.2.3