diff options
author | Iain Holmes <iain@src.gnome.org> | 2000-11-22 08:34:39 +0800 |
---|---|---|
committer | Iain Holmes <iain@src.gnome.org> | 2000-11-22 08:34:39 +0800 |
commit | f69d5ec14310f4903a8b88224f7c82cfa1de014a (patch) | |
tree | dc66bdbfc7f7859e5d4ab33dc71354da56725fcb /executive-summary/test-service | |
parent | 615a467b605dfbbdbab66d6edd64f8c298993397 (diff) | |
download | gsoc2013-evolution-f69d5ec14310f4903a8b88224f7c82cfa1de014a.tar.gz gsoc2013-evolution-f69d5ec14310f4903a8b88224f7c82cfa1de014a.tar.zst gsoc2013-evolution-f69d5ec14310f4903a8b88224f7c82cfa1de014a.zip |
Big patch. Evolution-services rewrite, services updated for new system,
Big patch.
Evolution-services rewrite, services updated for new system, Fixes to
Executive Summary and other things. See some changelogs
svn path=/trunk/; revision=6644
Diffstat (limited to 'executive-summary/test-service')
9 files changed, 757 insertions, 98 deletions
diff --git a/executive-summary/test-service/GNOME_Evolution_Summary_rdf.oaf.in b/executive-summary/test-service/GNOME_Evolution_Summary_rdf.oaf.in new file mode 100644 index 0000000000..327fd8de72 --- /dev/null +++ b/executive-summary/test-service/GNOME_Evolution_Summary_rdf.oaf.in @@ -0,0 +1,27 @@ +<oaf_info> + +<oaf_server iid="OAFIID:evolution-summary-component-factory:rdf-summary:8d7a395c-1036-4e54-8aa6-bd30fb5a1379" + type="exe" + location="rdf-summary"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:GNOME:GenericFactory:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Factory for the RDF summary."/> +</oaf_server> + +<oaf_server iid="OAFIID:evolution-summary-component:rdf-summary:65610e8c-7994-4cde-ab35-c907f35e37c0" + type="factory" + location="OAFIID:evolution-summary-component-factory:rdf-summary:8d7a395c-1036-4e54-8aa6-bd30fb5a1379"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Evolution:SummaryComponent:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="RDF Summary"/> +</oaf_server> + +</oaf_info> diff --git a/executive-summary/test-service/GNOME_Evolution_Summary_rdf.oafinfo b/executive-summary/test-service/GNOME_Evolution_Summary_rdf.oafinfo new file mode 100644 index 0000000000..327fd8de72 --- /dev/null +++ b/executive-summary/test-service/GNOME_Evolution_Summary_rdf.oafinfo @@ -0,0 +1,27 @@ +<oaf_info> + +<oaf_server iid="OAFIID:evolution-summary-component-factory:rdf-summary:8d7a395c-1036-4e54-8aa6-bd30fb5a1379" + type="exe" + location="rdf-summary"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:GNOME:GenericFactory:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Factory for the RDF summary."/> +</oaf_server> + +<oaf_server iid="OAFIID:evolution-summary-component:rdf-summary:65610e8c-7994-4cde-ab35-c907f35e37c0" + type="factory" + location="OAFIID:evolution-summary-component-factory:rdf-summary:8d7a395c-1036-4e54-8aa6-bd30fb5a1379"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Evolution:SummaryComponent:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="RDF Summary"/> +</oaf_server> + +</oaf_info> diff --git a/executive-summary/test-service/GNOME_Evolution_Summary_test.oaf.in b/executive-summary/test-service/GNOME_Evolution_Summary_test.oaf.in index dd169b8853..37fbbe9642 100644 --- a/executive-summary/test-service/GNOME_Evolution_Summary_test.oaf.in +++ b/executive-summary/test-service/GNOME_Evolution_Summary_test.oaf.in @@ -5,7 +5,7 @@ location="test-service"> <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME:GenericFactory:1.0"/> + <item value="IDL:GNOME/GenericFactory:1.0"/> </oaf_attribute> <oaf_attribute name="description" type="string" @@ -17,11 +17,37 @@ location="OAFIID:evolution-summary-component-factory:test-service:0ea887d5-622b-4b8c-b525-18aa1cbe18a6"> <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/Evolution:SummaryComponent:1.0"/> + <item value="IDL:GNOME/Evolution:Summary:ComponentFactory:1.0"/> </oaf_attribute> <oaf_attribute name="description" type="string" value="Test service"/> </oaf_server> +<!-- This does not work +<oaf_server iid="OAFIID:evolution-summary-component-factory:test-bonobo-service:b6da2ad2-1fbb-4539-93f9-038b1702810e" + type="exe" + location="test-bonobo-service"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:GNOME:GenericFactory:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Factory for the test bonobo component."/> +</oaf_server> + +<oaf_server iid="OAFIID:evolution-summary-component:test-bonobo-service:d3cb3ed6-a654-4337-8aa0-f443751d6d1b" + type="factory" + location="OAFIID:evolution-summary-component-factory:test-bonobo-service:b6da2ad2-1fbb-4539-93f9-038b1702810e"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Evolution:SummaryComponent:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Test bonobo service"/> +</oaf_server> + +--> </oaf_info> diff --git a/executive-summary/test-service/GNOME_Evolution_Summary_test.oafinfo b/executive-summary/test-service/GNOME_Evolution_Summary_test.oafinfo index dd169b8853..37fbbe9642 100644 --- a/executive-summary/test-service/GNOME_Evolution_Summary_test.oafinfo +++ b/executive-summary/test-service/GNOME_Evolution_Summary_test.oafinfo @@ -5,7 +5,7 @@ location="test-service"> <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME:GenericFactory:1.0"/> + <item value="IDL:GNOME/GenericFactory:1.0"/> </oaf_attribute> <oaf_attribute name="description" type="string" @@ -17,11 +17,37 @@ location="OAFIID:evolution-summary-component-factory:test-service:0ea887d5-622b-4b8c-b525-18aa1cbe18a6"> <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/Evolution:SummaryComponent:1.0"/> + <item value="IDL:GNOME/Evolution:Summary:ComponentFactory:1.0"/> </oaf_attribute> <oaf_attribute name="description" type="string" value="Test service"/> </oaf_server> +<!-- This does not work +<oaf_server iid="OAFIID:evolution-summary-component-factory:test-bonobo-service:b6da2ad2-1fbb-4539-93f9-038b1702810e" + type="exe" + location="test-bonobo-service"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:GNOME:GenericFactory:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Factory for the test bonobo component."/> +</oaf_server> + +<oaf_server iid="OAFIID:evolution-summary-component:test-bonobo-service:d3cb3ed6-a654-4337-8aa0-f443751d6d1b" + type="factory" + location="OAFIID:evolution-summary-component-factory:test-bonobo-service:b6da2ad2-1fbb-4539-93f9-038b1702810e"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Evolution:SummaryComponent:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Test bonobo service"/> +</oaf_server> + +--> </oaf_info> diff --git a/executive-summary/test-service/Makefile.am b/executive-summary/test-service/Makefile.am index e294a3ea49..56333302d7 100644 --- a/executive-summary/test-service/Makefile.am +++ b/executive-summary/test-service/Makefile.am @@ -15,7 +15,25 @@ test_service_LDADD = \ $(top_builddir)/executive-summary/evolution-services/libevolution-services.la \ $(BONOBO_VFS_GNOME_LIBS) \ $(EXTRA_GNOME_LIBS) + +#test_bonobo_service_SOURCES = \ +# test-bonobo.c + +#test_bonobo_service_LDADD = \ +# $(top_builddir)/executive-summary/evolution-services/libevolution-services.la \ +# $(BONOBO_VFS_GNOME_LIBS) \ +# $(EXTRA_GNOME_LIBS) + +#rdf_summary_SOURCES = \ +# rdf-summary.c + +#rdf_summary_LDADD = \ +# $(top_builddir)/executive-summary/evolution-services/libevolution-services.la \ +# $(BONOBO_VFS_GNOME_LIBS) \ +# $(EXTRA_GNOME_LIBS) + oafdir = $(datadir)/oaf -oaf_DATA = test-service.oafinfo +oaf_DATA = test-service.oafinfo \ + rdf-summary.oafinfo EXTRA_DIST = $(oaf_DATA) diff --git a/executive-summary/test-service/main.c b/executive-summary/test-service/main.c index 75bbc3199b..6a646adecd 100644 --- a/executive-summary/test-service/main.c +++ b/executive-summary/test-service/main.c @@ -30,131 +30,220 @@ #include <bonobo.h> #include <evolution-services/executive-summary-component.h> -#include <evolution-services/executive-summary-component-view.h> +#include <evolution-services/executive-summary-html-view.h> #include <liboaf/liboaf.h> -static int running_views = 0; +enum { + PROPERTY_TITLE, + PROPERTY_ICON +}; -struct userdata { - int i; +struct _UserData { + char *title; + char *icon; }; +typedef struct _UserData UserData; + +static int running_views = 0; #define TEST_SERVICE_ID "OAFIID:evolution-summary-component-factory:test-service:0ea887d5-622b-4b8c-b525-18aa1cbe18a6" static BonoboGenericFactory *factory = NULL; -/* The "do something interesting" function */ -int -add_one (ExecutiveSummaryComponentView *view) +/* PersistStream callbacks */ +static void +load_from_stream (BonoboPersistStream *ps, + Bonobo_Stream stream, + Bonobo_Persist_ContentType type, + gpointer data, + CORBA_Environment *ev) { - char *html; - struct userdata *ud; + char *str; - /* Get the user data from the view */ - ud = gtk_object_get_data (GTK_OBJECT (view), "timer-data"); - if (ud == NULL) { - g_warning ("No user data"); - return FALSE; + if (*type && g_strcasecmp (type, "application/x-test-service") != 0) { + CORBA_exception_set (ev, CORBA_USER_EXCEPTION, + ex_Bonobo_Persist_WrongDataType, NULL); + return; } - - /* Generate the new html */ - html = g_strdup_printf ("Since you started this service<br>" - "<center>%d</center><br>seconds have passed.", ud->i); - - /* Change the html on the view - which will tell the Executive Summary that something needs updating */ - executive_summary_component_view_set_html (view, html); - - /* executive_summary_component_view_set_html () makes a copy of the HTML - passed into it, so we don't need to keep it around */ - g_free (html); - - /* Do something "fun" */ - ud->i++; - - return TRUE; + + bonobo_stream_client_read_string (stream, &str, ev); + if (ev->_major != CORBA_NO_EXCEPTION || str == NULL) { + CORBA_exception_set (ev, CORBA_USER_EXCEPTION, + ex_Bonobo_Persist_WrongDataType, NULL); + return; + } + + g_print ("Restoring with :%s\n", str); + g_free (str); } -void -view_destroyed (GtkObject *object, - gpointer data) +static void +save_to_stream (BonoboPersistStream *ps, + const Bonobo_Stream stream, + Bonobo_Persist_ContentType type, + gpointer data, + CORBA_Environment *ev) { - ExecutiveSummaryComponentView *view; - struct userdata *ud; - int id; - - /* Free the user data for this view*/ - ud = gtk_object_get_data (object, "timer-data"); - gtk_object_set_data (object, "timer-data", NULL); + + if (*type && g_strcasecmp (type, "application/x-test-service") != 0) { + CORBA_exception_set (ev, CORBA_USER_EXCEPTION, + ex_Bonobo_Persist_WrongDataType, NULL); + return; + } + + bonobo_stream_client_printf (stream, TRUE, ev, "Yo yo yo"); + if (ev->_major != CORBA_NO_EXCEPTION) + return; +} + +static Bonobo_Persist_ContentTypeList * +content_types (BonoboPersistStream *ps, + void *closure, + CORBA_Environment *ev) +{ + return bonobo_persist_generate_content_types (1, "application/x-test-service"); +} + +/* PropertyControl callback */ + +/* Propertybag set/get functions */ +static void +set_property (BonoboPropertyBag *bag, + const BonoboArg *arg, + guint arg_id, + gpointer user_data) +{ + switch (arg_id) { + case PROPERTY_TITLE: + g_print ("Setting title.\n"); + break; + + case PROPERTY_ICON: + g_print ("Setting icon.\n"); + break; + + default: + break; + } +} + +static void +get_property (BonoboPropertyBag *bag, + BonoboArg *arg, + guint arg_id, + gpointer user_data) +{ + UserData *ud = (UserData *) user_data; + + switch (arg_id) { + case PROPERTY_TITLE: + BONOBO_ARG_SET_STRING (arg, ud->title); + break; + + case PROPERTY_ICON: + BONOBO_ARG_SET_STRING (arg, ud->icon); + break; + + default: + break; + } +} + +static void +component_destroyed (GtkObject *object, + gpointer data) +{ + UserData *ud = (UserData *) ud; + /* Free the UserData structure */ + g_free (ud->title); + g_free (ud->icon); g_free (ud); - - /* Remove one running view */ + running_views--; - - /* If there are no running views left, quit */ + + g_print ("Destroy!\n"); if (running_views <= 0) gtk_main_quit (); } -/* Create the view: - HTML only */ -static void -create_view (ExecutiveSummaryComponent *component, - ExecutiveSummaryComponentView *view, +static BonoboObject * +create_view (ExecutiveSummaryComponentFactory *_factory, void *closure) { - char *html = "Since you started this service<br><center>0</center><br>seconds have passed."; - struct userdata *ud; - - g_print ("In: %s\n", __FUNCTION__); - /* Create the userdata structure */ - ud = g_new (struct userdata, 1); - - ud->i = 1; - executive_summary_component_view_construct (view, component, NULL, - html, "The Magic Counter", - "gnome-clock.png"); - g_print ("Out: %s\n", __FUNCTION__); - /* Set the user data on the object */ - gtk_object_set_data (GTK_OBJECT (view), "timer-data", ud); + BonoboObject *component, *view, *bag, *stream; + UserData *ud; + + /* Create the component object */ + component = executive_summary_component_new (); + + /* Create the UserData structure and fill it */ + ud = g_new (UserData, 1); + ud->title = g_strdup ("Hello World!"); + ud->icon = g_strdup ("apple-red.png"); + + gtk_signal_connect (GTK_OBJECT (component), "destroy", + GTK_SIGNAL_FUNC (component_destroyed), ud); + + /* Now create the aggregate objects. For a "service" + either a Summary::HTMLView or Bonobo::Control are required. + Other supported agreggate objects are + PersistStream: For saving and restoring the component. + PropertyBag: To set the icon and title and other properties + PropertyControl: To produce a control to configure the service. - /* Connect the the destroyed signal to find out - when the view is destroyed */ - gtk_signal_connect (GTK_OBJECT (view), "destroy", - GTK_SIGNAL_FUNC (view_destroyed), NULL); + To aggregate the objects + i) Create the objects using their creation functions + ii) Use bonobo_object_add_interface (). + */ - /* Increase the number of running views */ - running_views++; + /* The Summary::HTMLView interface */ + view = executive_summary_html_view_new (); + /* Set the default HTML */ + executive_summary_html_view_set_html (EXECUTIVE_SUMMARY_HTML_VIEW (view), + "<B>Hello World</b>"); - /* Do something "interesting" once a second */ - gtk_timeout_add (1000, add_one, view); -} + bonobo_object_add_interface (component, view); -static void -configure (ExecutiveSummaryComponent *component, - void *closure) -{ - GtkWidget *window, *label; - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - label = gtk_label_new ("This is a configuration dialog.\nNo it really is"); - - gtk_container_add (GTK_CONTAINER (window), label); - gtk_widget_show_all (window); + /* Add the Bonobo::PropertyBag interface */ + bag = bonobo_property_bag_new (get_property, set_property, ud); + /* Add the properties. There should be 2: + window_title: For the window title. + window_icon: For the window icon. + */ + bonobo_property_bag_add (BONOBO_PROPERTY_BAG (bag), + "window_title", PROPERTY_TITLE, + BONOBO_ARG_STRING, + NULL, + "The title of this components window", 0); + bonobo_property_bag_add (BONOBO_PROPERTY_BAG (bag), + "window_icon", PROPERTY_ICON, + BONOBO_ARG_STRING, + NULL, + "The icon for this component's window", 0); + + /* Now add the interface */ + bonobo_object_add_interface (component, bag); + + + /* Add the Bonobo::PersistStream interface */ + stream = bonobo_persist_stream_new (load_from_stream, save_to_stream, + NULL, content_types, NULL); + bonobo_object_add_interface (component, stream); + + /* Return the ExecutiveSummaryComponent object */ + return component; } static BonoboObject * -factory_fn (BonoboGenericFactory *_factory, +factory_fn (BonoboGenericFactory *generic_factory, void *closure) { - ExecutiveSummaryComponent *component; + BonoboObject *_factory; - /* Create an executive summary component for this factory */ - component = executive_summary_component_new (create_view, - configure, - NULL); - return BONOBO_OBJECT (component); + /* Create an executive summary component factory */ + _factory = executive_summary_component_factory_new (create_view, NULL); + return _factory; } void diff --git a/executive-summary/test-service/rdf-summary.c b/executive-summary/test-service/rdf-summary.c new file mode 100644 index 0000000000..b87c20a3c3 --- /dev/null +++ b/executive-summary/test-service/rdf-summary.c @@ -0,0 +1,393 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* RDF viewer Evolution Executive Summary Component. + * Bonoboised by Iain Holmes <iain@helixcode.com> + * Copyright (C) 2000 Helix Code, Inc. + * + * Based on code from Portaloo + * Channel retrieval tool + * + * (C) 1998 Alan Cox. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <glib.h> +#include <gnome.h> +#include <bonobo.h> +#include <gnome-xml/parser.h> + +#include <evolution-services/executive-summary-component.h> +#include <evolution-services/executive-summary-component-view.h> +#include <liboaf/liboaf.h> +#include <libgnomevfs/gnome-vfs.h> + +int xmlSubstituteEntitiesDefaultValue = 1; /* DV thinks of everything */ + +static int wipe_trackers = FALSE; +static int running_views = 0; + +static BonoboGenericFactory *factory = NULL; +#define RDF_SUMMARY_ID "OAFIID:evolution-summary-component-factory:rdf-summary:8d7a395c-1036-4e54-8aa6-bd30fb5a1379" + +/************ RDF Parser *******************/ + +static char * +layer_find (xmlNodePtr node, + char *match, + char *fail) +{ + while (node!=NULL) { +#ifdef RDF_DEBUG + xmlDebugDumpNode (stdout, node, 32); + printf("%s.\n", node->name); +#endif + if (strcasecmp (node->name, match)==0) { + if (node->childs != NULL && node->childs->content != NULL) { + return node->childs->content; + } else { + return fail; + } + } + node = node->next; + } + return fail; +} + +static char * +layer_find_url (xmlNodePtr node, + char *match, + char *fail) +{ + char *p = layer_find (node, match, fail); + char *r = p; + static char *wb = NULL; + char *w; + + if (wb) { + free (wb); + } + + wb = w = malloc (3 * strlen (p)); + + if (w == NULL) { + fprintf(stderr, "Out of memory\n"); + exit(1); + } + + if (*r == ' ') r++; /* Fix UF bug */ + + while (*r) { + if (memcmp (r, "&", 5) == 0) { + *w++ = '&'; + r += 5; + continue; + } + if (memcmp (r, "<", 4) == 0) { + *w++ = '<'; + r += 4; + continue; + } + if (memcmp (r, ">", 4) == 0) { + *w++ = '>'; + r += 4; + continue; + } + if (*r == '"' || *r == ' '){ + *w++ = '%'; + *w++ = "0123456789ABCDEF"[*r/16]; + *w++ = "0123456789ABCDEF"[*r&15]; + r++; + continue; + } + *w++ = *r++; + } + *w = 0; + return wb; +} + +static void +tree_walk (xmlNodePtr root, + ExecutiveSummaryComponentView *view, + GString *html) +{ + xmlNodePtr walk; + xmlNodePtr rewalk = root; + xmlNodePtr channel = NULL; + xmlNodePtr image = NULL; + xmlNodePtr item[16]; + int items = 0; + int limit = 10; + int i; + char *t; + char n[512]; + char *tmp; + + do { + walk = rewalk; + rewalk = NULL; + + while (walk!=NULL){ +#ifdef RDF_DEBUG + printf ("%p, %s\n", walk, walk->name); +#endif + if (strcasecmp (walk->name, "rdf") == 0) { + rewalk = walk->childs; + walk = walk->next; + continue; + } + if (strcasecmp (walk->name, "rss") == 0){ + rewalk = walk->childs; + walk = walk->next; + continue; + } + /* This is the channel top level */ +#ifdef RDF_DEBUG + printf ("Top level '%s'.\n", walk->name); +#endif + if (strcasecmp (walk->name, "channel") == 0) { + channel = walk; + rewalk = channel->childs; + } + if (strcasecmp (walk->name, "image") == 0) { + image = walk; + g_print ("Image\n"); + } + if (strcasecmp (walk->name, "item") == 0 && items < 16) { + item[items++] = walk; + } + walk = walk->next; + } + } + while (rewalk); + + if (channel == NULL) { + fprintf(stderr, "No channel definition.\n"); + exit(1); + } + + t = layer_find(channel->childs, "title", "No title"); +/* g_string_append (html, tmp); */ + executive_summary_component_view_set_title (view, t); + + tmp = g_strdup_printf ("%s", + layer_find(channel->childs, "description", "")); + g_string_append (html, tmp); + g_free (tmp); + + if (image && !wipe_trackers) { + g_print ("URL: %s\n", layer_find_url (image->childs, "url", + "green-apple.png")); + executive_summary_component_view_set_icon (view, + layer_find_url + (image->childs, + "url", "apple-green.png")); + } + + g_string_append (html, "<br clear=all><FONT size=\"-1\" face=\"helvetica\"><P><UL>\n"); + + for (i = 0; i < items; i++) { + char *p = layer_find (item[i]->childs, "title", "No information"); + + if(i == limit) + g_string_append (html, "--\n"); + if (wipe_trackers) { + char *p = layer_find_url (item[i]->childs, "link", ""); + char *x = strchr (p, '?'); + unsigned char *r, *w; + int n; + if (x == NULL) + continue; + x++; + r = x; + w = x; + while (*r) { + if (*r == '+') { + *w++ = ' '; + } else if (*r == '%') { + sscanf (r+1, "%02x", &n); + *w++ = n; + r += 2; + } else { + *w++ = *r; + } + r++; + } + *w = 0; + tmp = g_strdup_printf ("<LI><A href=\"%s\">\n", x+4); + g_string_append (html, tmp); + g_free (tmp); + } + else { + tmp = g_strdup_printf ("<LI><A href=\"%s\">\n", layer_find_url(item[i]->childs, "link", "")); + g_string_append (html, tmp); + g_free (tmp); + } + + tmp = g_strdup_printf ("%s\n</A>\n", p); + g_string_append (html, tmp); + g_free (tmp); + } + g_string_append (html, "</UL></FONT>\n"); +} + +/********* ExecutiveSummaryComponent section **************/ +static void +view_destroyed (GtkObject *object, + gpointer data) +{ + running_views--; + if (running_views <= 0) { + gtk_main_quit (); + } +} + +static int +download (ExecutiveSummaryComponentView *view) +{ + GString *rdf; + GString *html; + char *xml; + GnomeVFSHandle *handle = NULL; + GnomeVFSResult result; + xmlDocPtr doc; + char *location; + int len = 0; + + /* Download the RDF file here */ + /* Then parse it */ + /* The update it */ + + location = "/home/iain/gnotices.rdf"; + result = gnome_vfs_open (&handle, location, GNOME_VFS_OPEN_READ); + if (result != GNOME_VFS_OK) { + char *emsg; + + emsg = g_strdup_printf ("<b>Cannot open location:<br>%s</b>", + location); + executive_summary_component_view_set_html (view, emsg); + g_free (emsg); + return FALSE; + } + + rdf = g_string_new (""); + + while (1) { + char buffer[4096]; + GnomeVFSFileSize size; + + memset (buffer, 0x00, 4096); + + result = gnome_vfs_read (handle, buffer, 4096, &size); + if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_EOF) { + executive_summary_component_view_set_html (view, + "<b>Error reading data.</b>"); + g_string_free (rdf, TRUE); + return FALSE; + } + + if (size == 0) { + break; + } + + rdf = g_string_append (rdf, buffer); + len += size; + } + + gnome_vfs_close (handle); + xml = rdf->str; + g_string_free (rdf, FALSE); + + doc = xmlParseMemory (xml, len); + if (doc == NULL) { + g_warning ("Unable to parse document."); + return FALSE; + } + + g_free (xml); + html = g_string_new (""); + + tree_walk (doc->root, view, html); + executive_summary_component_view_set_html (view, html->str); + g_string_free (html, TRUE); + return FALSE; +} + +static void +create_view (ExecutiveSummaryComponent *component, + ExecutiveSummaryComponentView *view, + void *closure) +{ + char *html = "<b>Loading RDF file. . .<br>Please wait</b>"; + + executive_summary_component_view_construct (view, component, NULL, + html, "Downloading", + "apple-green.png"); + gtk_signal_connect (GTK_OBJECT (view), "destroy", + GTK_SIGNAL_FUNC (view_destroyed), NULL); + running_views++; + g_idle_add (download, view); +} + +static BonoboObject * +factory_fn (BonoboGenericFactory *_factory, + void *closure) +{ + ExecutiveSummaryComponent *component; + + component = executive_summary_component_new (create_view, NULL); + return BONOBO_OBJECT (component); +} + +static void +factory_init (void) +{ + if (factory != NULL) { + return; + } + + factory = bonobo_generic_factory_new (RDF_SUMMARY_ID, factory_fn, NULL); + if (factory == NULL) { + g_error ("Cannot initialize factory"); + } +} + +int +main (int argc, + char *argv[]) +{ + CORBA_ORB orb; + + gnome_init_with_popt_table ("RDF-Summary", VERSION, + argc, argv, oaf_popt_options, 0, NULL); + orb = oaf_init (argc, argv); + gnome_vfs_init (); + + if (bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE) { + g_error ("Could not initialize Bonobo"); + } + + factory_init (); + bonobo_main (); + return 0; + +#if 0 + doc=xmlParseMemory(document, docp); + + if(doc==NULL) + { + fprintf(stderr, "Unable to parse document.\n"); + exit(1); + } + + tree_walk(doc->root); + + if(rename(buf, nam)) + perror("rename"); + return 0; +#endif + +} + diff --git a/executive-summary/test-service/rdf-summary.oafinfo b/executive-summary/test-service/rdf-summary.oafinfo new file mode 100644 index 0000000000..327fd8de72 --- /dev/null +++ b/executive-summary/test-service/rdf-summary.oafinfo @@ -0,0 +1,27 @@ +<oaf_info> + +<oaf_server iid="OAFIID:evolution-summary-component-factory:rdf-summary:8d7a395c-1036-4e54-8aa6-bd30fb5a1379" + type="exe" + location="rdf-summary"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:GNOME:GenericFactory:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Factory for the RDF summary."/> +</oaf_server> + +<oaf_server iid="OAFIID:evolution-summary-component:rdf-summary:65610e8c-7994-4cde-ab35-c907f35e37c0" + type="factory" + location="OAFIID:evolution-summary-component-factory:rdf-summary:8d7a395c-1036-4e54-8aa6-bd30fb5a1379"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Evolution:SummaryComponent:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="RDF Summary"/> +</oaf_server> + +</oaf_info> diff --git a/executive-summary/test-service/test-service.oafinfo b/executive-summary/test-service/test-service.oafinfo index dd169b8853..37fbbe9642 100644 --- a/executive-summary/test-service/test-service.oafinfo +++ b/executive-summary/test-service/test-service.oafinfo @@ -5,7 +5,7 @@ location="test-service"> <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME:GenericFactory:1.0"/> + <item value="IDL:GNOME/GenericFactory:1.0"/> </oaf_attribute> <oaf_attribute name="description" type="string" @@ -17,11 +17,37 @@ location="OAFIID:evolution-summary-component-factory:test-service:0ea887d5-622b-4b8c-b525-18aa1cbe18a6"> <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/Evolution:SummaryComponent:1.0"/> + <item value="IDL:GNOME/Evolution:Summary:ComponentFactory:1.0"/> </oaf_attribute> <oaf_attribute name="description" type="string" value="Test service"/> </oaf_server> +<!-- This does not work +<oaf_server iid="OAFIID:evolution-summary-component-factory:test-bonobo-service:b6da2ad2-1fbb-4539-93f9-038b1702810e" + type="exe" + location="test-bonobo-service"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:GNOME:GenericFactory:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Factory for the test bonobo component."/> +</oaf_server> + +<oaf_server iid="OAFIID:evolution-summary-component:test-bonobo-service:d3cb3ed6-a654-4337-8aa0-f443751d6d1b" + type="factory" + location="OAFIID:evolution-summary-component-factory:test-bonobo-service:b6da2ad2-1fbb-4539-93f9-038b1702810e"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Evolution:SummaryComponent:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Test bonobo service"/> +</oaf_server> + +--> </oaf_info> |