aboutsummaryrefslogtreecommitdiffstats
path: root/executive-summary/test-service
diff options
context:
space:
mode:
Diffstat (limited to 'executive-summary/test-service')
-rw-r--r--executive-summary/test-service/main.c10
-rw-r--r--executive-summary/test-service/rdf-summary.c160
2 files changed, 116 insertions, 54 deletions
diff --git a/executive-summary/test-service/main.c b/executive-summary/test-service/main.c
index 2a3b25975c..d2d35e9c96 100644
--- a/executive-summary/test-service/main.c
+++ b/executive-summary/test-service/main.c
@@ -176,6 +176,7 @@ create_view (ExecutiveSummaryComponentFactory *_factory,
BonoboObject *component, *view;
BonoboPersistStream *stream;
BonoboPropertyBag *bag;
+ BonoboEventSource *event_source;
UserData *ud;
/* Create the component object */
@@ -201,8 +202,12 @@ create_view (ExecutiveSummaryComponentFactory *_factory,
ii) Use bonobo_object_add_interface ().
*/
+ /* Create an event source to share with all the interfaces,
+ as we can only aggregate one onto the ExecutiveSummaryComponent */
+ event_source = bonobo_event_source_new ();
+
/* The Summary::HTMLView interface */
- view = executive_summary_html_view_new ();
+ view = executive_summary_html_view_new_full (event_source);
/* Set the default HTML */
executive_summary_html_view_set_html (EXECUTIVE_SUMMARY_HTML_VIEW (view),
"<B>Hello World</b>");
@@ -210,7 +215,8 @@ create_view (ExecutiveSummaryComponentFactory *_factory,
bonobo_object_add_interface (component, view);
/* Add the Bonobo::PropertyBag interface */
- bag = bonobo_property_bag_new (get_property, set_property, ud);
+ bag = bonobo_property_bag_new_full (get_property, set_property,
+ event_source, ud);
/* Add the properties. There should be 2:
window_title: For the window title.
window_icon: For the window icon.
diff --git a/executive-summary/test-service/rdf-summary.c b/executive-summary/test-service/rdf-summary.c
index a2a01aa541..a1aca7d88b 100644
--- a/executive-summary/test-service/rdf-summary.c
+++ b/executive-summary/test-service/rdf-summary.c
@@ -50,6 +50,9 @@ struct _RdfSummary {
char *icon;
char *location;
int limit;
+
+ GString *str;
+ char *buffer;
};
typedef struct _RdfSummary RdfSummary;
@@ -283,79 +286,131 @@ view_destroyed (GtkObject *object,
}
}
-static int
-download (RdfSummary *summary)
+static void
+close_callback (GnomeVFSAsyncHandle *handle,
+ GnomeVFSResult result,
+ RdfSummary *summary)
{
- ExecutiveSummaryHtmlView *view;
- GString *rdf;
GString *html;
- char *xml;
- GnomeVFSHandle *handle = NULL;
- GnomeVFSResult result;
xmlDocPtr doc;
- char *location;
- int len = 0;
+ char *xml;
+
+ if (summary == NULL)
+ return;
- /* Download the RDF file here */
- /* Then parse it */
- /* The update it */
+ g_free (summary->buffer);
+ xml = summary->str->str;
+ g_string_free (summary->str, FALSE);
- g_print ("Starting download\n");
- view = EXECUTIVE_SUMMARY_HTML_VIEW (summary->view);
- result = gnome_vfs_open (&handle, summary->location,
- GNOME_VFS_OPEN_READ);
- if (result != GNOME_VFS_OK) {
+ doc = xmlParseMemory (xml, strlen (xml));
+ if (doc == NULL) {
char *emsg;
+ BonoboArg *arg;
+ arg = bonobo_arg_new (BONOBO_ARG_STRING);
+ BONOBO_ARG_SET_STRING (arg, _("Error"));
+ bonobo_property_bag_set_value (summary->bag,
+ "window_title",
+ (const BonoboArg *) arg,
+ NULL);
+ bonobo_arg_release (arg);
+
emsg = g_strdup_printf ("<b>Cannot open location:<br>%s</b>",
summary->location);
- executive_summary_html_view_set_html (view, emsg);
+ executive_summary_html_view_set_html (EXECUTIVE_SUMMARY_HTML_VIEW (summary->view), emsg);
g_free (emsg);
- return FALSE;
+ g_free (xml);
+ return;
}
+
+ g_free (xml);
+ html = g_string_new ("");
- rdf = g_string_new ("");
+ tree_walk (doc->root, summary, html);
+ executive_summary_html_view_set_html (EXECUTIVE_SUMMARY_HTML_VIEW (summary->view), html->str);
+ g_string_free (html, TRUE);
+}
- while (1) {
- char buffer[4096];
- GnomeVFSFileSize size;
+static void
+read_callback (GnomeVFSAsyncHandle *handle,
+ GnomeVFSResult result,
+ gpointer buffer,
+ GnomeVFSFileSize bytes_requested,
+ GnomeVFSFileSize bytes_read,
+ RdfSummary *summary)
+{
+ if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_EOF) {
+ char *emsg;
+ BonoboArg *arg;
+
+ arg = bonobo_arg_new (BONOBO_ARG_STRING);
+ BONOBO_ARG_SET_STRING (arg, _("Error"));
+ bonobo_property_bag_set_value (summary->bag,
+ "window_title",
+ (const BonoboArg *) arg,
+ NULL);
+ bonobo_arg_release (arg);
+
+ emsg = g_strdup_printf ("<b>Cannot open location:<br>%s</b>",
+ summary->location);
+ executive_summary_html_view_set_html (EXECUTIVE_SUMMARY_HTML_VIEW (summary->view), emsg);
+ g_free (emsg);
+ gnome_vfs_async_close (handle, close_callback, NULL);
+ }
- memset (buffer, 0x00, 4096);
+ if (bytes_read == 0) {
+ /* EOF */
+ gnome_vfs_async_close (handle, close_callback, summary);
+ } else {
+ *((char *) buffer + bytes_read) = 0;
+ g_string_append (summary->str, (const char *) buffer);
+ gnome_vfs_async_read (handle, buffer, 4095, read_callback,
+ summary);
+ }
+}
- result = gnome_vfs_read (handle, buffer, 4096, &size);
- if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_EOF) {
- executive_summary_html_view_set_html (view,
- "<b>Error reading data.</b>");
- g_string_free (rdf, TRUE);
- return FALSE;
- }
+static void
+open_callback (GnomeVFSAsyncHandle *handle,
+ GnomeVFSResult result,
+ RdfSummary *summary)
+{
+ GList *uri;
+ char *buffer;
- if (size == 0) {
- break;
- }
+ if (result != GNOME_VFS_OK) {
+ char *emsg;
+ BonoboArg *arg;
- rdf = g_string_append (rdf, buffer);
- len += size;
+ arg = bonobo_arg_new (BONOBO_ARG_STRING);
+ BONOBO_ARG_SET_STRING (arg, _("Error"));
+ bonobo_property_bag_set_value (summary->bag,
+ "window_title",
+ (const BonoboArg *) arg,
+ NULL);
+ bonobo_arg_release (arg);
+
+ emsg = g_strdup_printf ("<b>Cannot open location:<br>%s</b>",
+ summary->location);
+ executive_summary_html_view_set_html (EXECUTIVE_SUMMARY_HTML_VIEW (summary->view), emsg);
+ g_free (emsg);
+ return;
}
- gnome_vfs_close (handle);
- xml = rdf->str;
- g_string_free (rdf, FALSE);
+ summary->str = g_string_new ("");
+ summary->buffer = g_new (char, 4096);
- doc = xmlParseMemory (xml, len);
- if (doc == NULL) {
- g_warning ("Unable to parse document.");
- return FALSE;
- }
-
- g_free (xml);
- html = g_string_new ("");
+ gnome_vfs_async_read (handle, summary->buffer, 4095, read_callback, summary);
+}
- tree_walk (doc->root, summary, html);
- executive_summary_html_view_set_html (view, html->str);
- g_string_free (html, TRUE);
+static int
+download (RdfSummary *summary)
+{
+ GnomeVFSAsyncHandle *handle;
+
+ gnome_vfs_async_open (&handle, summary->location, GNOME_VFS_OPEN_READ,
+ (GnomeVFSAsyncOpenCallback) open_callback,
+ summary);
- g_print ("Finished Download\n");
return FALSE;
}
@@ -527,7 +582,8 @@ create_view (ExecutiveSummaryComponentFactory *_factory,
html);
bonobo_object_add_interface (component, view);
- bag = bonobo_property_bag_new (get_prop, set_prop, summary);
+ bag = bonobo_property_bag_new_full (get_prop, set_prop,
+ event_source, summary);
summary->bag = bag;
bonobo_property_bag_add (bag,
"window_title", PROPERTY_TITLE,
* Update the stunnel port to version 4.22b2 to fix inetd mode logging[1].roam2008-01-248-142/+28 * Add an official fix for the chroot mode resolving bug.roam2007-11-133-0/+105 * Update to stunnel-4.21.roam2007-10-307-18/+29 * Remove always-false/true conditions based on OSVERSION 500000edwin2007-10-041-2/+0 * Reserve a user and group ID for the stunnel daemon.roam2007-08-282-2/+3 * Use libtool port instead of included version to avoid objformat a.out botchkris2007-02-011-0/+1 * Update to stunnel 4.20.roam2006-12-022-4/+4 * Update to stunnel 4.19 and fix the NOPORTDOCS installation to reallyroam2006-11-152-5/+6 * Fix the problem with unattended deinstallation by not even attemptingroam2006-10-092-63/+1 * A trivial update to stunnel-4.18 - Windows-related changes only.roam2006-09-262-7/+4 * Update to stunnel 4.17.roam2006-09-182-8/+4 * Update to stunnel 4.15, which has the major new feature of almost allroam2006-04-218-42/+25 * Conversion to a single libtool environment.ade2006-02-232-3/+3 * Catch up with stunnel's tools/Makefile to make the port's "make cert"roam2006-01-311-4/+3 * SHA256ifyedwin2006-01-241-0/+1 * Mass-conversion to the USE_AUTOTOOLS New World Order. The code presentade2005-11-151-1/+1 * Update to stunnel 4.14, which is mostly a bugfix release.roam2005-11-035-3/+39 * Update to 4.13, which ought to fix the libc_r detection problem inroam2005-11-012-4/+5 * Update to stunnel 4.11, which is deemed a stable release.roam2005-07-134-70/+11 * OPTIONS'ify, but still leave WITH_STUNNEL_SSL_ENGINE out of it - it isroam2005-06-141-11/+8 * Fix the stunnel ucontext-related problems using a patch from the author,roam2005-06-143-1/+84 * - Fix deinstall script when running in BATCH mode.flz2005-06-062-1/+2 * Update to 4.10, fixing the execvp() and pid file issues while I'm here.roam2005-05-127-39/+29 * At Kris's request, back out the MACHINE_ARCH spelling correction untilobrien2005-04-121-1/+1 * Assist getting more ports working on AMD64 by obeying theobrien2005-04-111-1/+1 * Update stunnel to 4.07, which incorporates most of our fixes to 4.06roam2005-01-033-34/+9 * Okay then, purge the last reference to MySQL in the startup script...roam2004-12-302-2/+2 * The last update for this year, I hope :)roam2004-12-304-39/+79 * Fix a getnameinfo() out-of-memory error caused by passing a 20-characterroam2004-12-302-4/+7 * Fix the build on FreeBSD versions around 5.2 when EAI_NODATA wasroam2004-12-291-4/+6 * Update to stunnel-4.06. In addition to the PR:roam2004-12-277-36/+68 * Fix the bus error on startup in -CURRENT and 5.x-BETA. It turns outroam2004-09-022-1/+32 * BROKEN -> IGNORE, since this is a runtime error and the port itself buildsroam2004-06-171-1/+1 * Use DOCSDIR.roam2004-06-171-24/+24 * Mark broken on -CURRENT until I figure out why stunnel doesn't likeroam2004-06-121-1/+7 * And hot on the heels of the distsite update, here's the promised updateroam2004-06-033-12/+9 * Fix the distsites; an update to stunnel-4.05 is coming shortly, but still,roam2004-06-031-3/+2 * SIZEify (maintainer timeout)trevor2004-03-311-0/+2 * Brian Hatch updated his RSA blinding patch to only applyroam2003-05-012-4/+4