Pass source instead of URI, and s/uri/source/. (e_book_async_load_source):
authorHans Petter Jansson <hpj@ximian.com>
Mon, 1 Dec 2003 06:49:54 +0000 (06:49 +0000)
committerHans Petter <hansp@src.gnome.org>
Mon, 1 Dec 2003 06:49:54 +0000 (06:49 +0000)
2003-12-01  Hans Petter Jansson  <hpj@ximian.com>

* libebook/e-book-async.c (_load_uri_response_handler)
(_load_uri_response_dtor)
(_load_uri_handler)
(_load_uri_dtor)
(_default_book_response_handler)
(_default_book_response_dtor): Pass source instead of URI, and
s/uri/source/.
(e_book_async_load_source): Implement.
(e_book_async_load_uri): Create a source and pass that to worker.

addressbook/ChangeLog
addressbook/libebook/e-book-async.c
addressbook/libebook/e-book-async.h

index c180512..69c2839 100644 (file)
@@ -1,3 +1,15 @@
+2003-12-01  Hans Petter Jansson  <hpj@ximian.com>
+
+       * libebook/e-book-async.c (_load_uri_response_handler)
+       (_load_uri_response_dtor)
+       (_load_uri_handler)
+       (_load_uri_dtor)
+       (_default_book_response_handler)
+       (_default_book_response_dtor): Pass source instead of URI, and
+       s/uri/source/.
+       (e_book_async_load_source): Implement.
+       (e_book_async_load_uri): Create a source and pass that to worker.
+
 2003-11-28  Chris Toshok  <toshok@ximian.com>
 
        * tests/ebook/Makefile.am (test_ebook_view_LDADD): new variable.
index 0a6f6ff..2f4fe59 100644 (file)
@@ -67,10 +67,10 @@ typedef struct {
        EBookMsg msg;
 
        EBook *book;
-       char *uri;
+       ESource *source;
        EBookCallback open_response;
        gpointer closure;
-} LoadUriMsg;
+} LoadSourceMsg;
 
 typedef struct {
        EBookMsg msg;
@@ -79,55 +79,76 @@ typedef struct {
        EBookStatus status;
        EBookCallback open_response;
        gpointer closure;
-} LoadUriResponse;
+} LoadSourceResponse;
 
 static void
-_load_uri_response_handler (EBookMsg *msg)
+_load_source_response_handler (EBookMsg *msg)
 {
-       LoadUriResponse *resp = (LoadUriResponse*)msg;
+       LoadSourceResponse *resp = (LoadSourceResponse*)msg;
 
        resp->open_response (resp->book, resp->status, resp->closure);
 }
 
 static void
-_load_uri_response_dtor (EBookMsg *msg)
+_load_source_response_dtor (EBookMsg *msg)
 {
-       LoadUriResponse *resp = (LoadUriResponse*)msg;
+       LoadSourceResponse *resp = (LoadSourceResponse*)msg;
 
        g_object_unref (resp->book);
        g_free (resp);
 }
 
 static void
-_load_uri_handler (EBookMsg *msg)
+_load_source_handler (EBookMsg *msg)
 {
-       LoadUriMsg *uri_msg = (LoadUriMsg *)msg;
-       LoadUriResponse *response;
+       LoadSourceMsg *source_msg = (LoadSourceMsg *)msg;
+       LoadSourceResponse *response;
        GError *error = NULL;
 
-       response = g_new (LoadUriResponse, 1);
-       e_book_msg_init ((EBookMsg*)response, _load_uri_response_handler, _load_uri_response_dtor);
+       response = g_new (LoadSourceResponse, 1);
+       e_book_msg_init ((EBookMsg*)response, _load_source_response_handler, _load_source_response_dtor);
 
        response->status = E_BOOK_ERROR_OK;
-       if (!e_book_load_uri (uri_msg->book, uri_msg->uri, FALSE, &error)) {
+       if (!e_book_load_source (source_msg->book, source_msg->source, FALSE, &error)) {
                response->status = error->code;
                g_error_free (error);
        }
 
-       response->book = uri_msg->book;
-       response->open_response = uri_msg->open_response;
-       response->closure = uri_msg->closure;
+       response->book = source_msg->book;
+       response->open_response = source_msg->open_response;
+       response->closure = source_msg->closure;
 
        g_async_queue_push (from_worker_queue, response);
 }
 
 static void
-_load_uri_dtor (EBookMsg *msg)
+_load_source_dtor (EBookMsg *msg)
 {
-       LoadUriMsg *uri_msg = (LoadUriMsg *)msg;
+       LoadSourceMsg *source_msg = (LoadSourceMsg *)msg;
        
-       g_free (uri_msg->uri);
-       g_free (uri_msg);
+       g_object_unref (source_msg->source);
+       g_free (source_msg);
+}
+
+void
+e_book_async_load_source (EBook                 *book,
+                         ESource               *source,
+                         EBookCallback          open_response,
+                         gpointer               closure)
+{
+       LoadSourceMsg *msg;
+
+       init_async ();
+
+       msg = g_new (LoadSourceMsg, 1);
+       e_book_msg_init ((EBookMsg*)msg, _load_source_handler, _load_source_dtor);
+
+       msg->book = g_object_ref (book);
+       msg->source = e_source_copy (source);
+       msg->open_response = open_response;
+       msg->closure = closure;
+
+       g_async_queue_push (to_worker_queue, msg);
 }
 
 void
@@ -136,19 +157,28 @@ e_book_async_load_uri (EBook                 *book,
                       EBookCallback          open_response,
                       gpointer               closure)
 {
-       LoadUriMsg *msg;
+       LoadSourceMsg *msg;
+       ESourceGroup *group;
+       ESource *source;
 
        init_async ();
 
-       msg = g_new (LoadUriMsg, 1);
-       e_book_msg_init ((EBookMsg*)msg, _load_uri_handler, _load_uri_dtor);
+       msg = g_new (LoadSourceMsg, 1);
+       e_book_msg_init ((EBookMsg*)msg, _load_source_handler, _load_source_dtor);
+
+       group = e_source_group_new ("", uri);
+       source = e_source_new ("", "");
+       e_source_set_group (source, group);
 
        msg->book = g_object_ref (book);
-       msg->uri = g_strdup (uri);
+       msg->source = e_source_copy (source);
        msg->open_response = open_response;
        msg->closure = closure;
 
        g_async_queue_push (to_worker_queue, msg);
+
+       g_object_unref (source);
+       g_object_unref (group);
 }
 
 
@@ -180,7 +210,7 @@ typedef struct {
 static void
 _default_book_response_handler (EBookMsg *msg)
 {
-       LoadUriResponse *resp = (LoadUriResponse*)msg;
+       LoadSourceResponse *resp = (LoadSourceResponse*)msg;
 
        resp->open_response (resp->book, resp->status, resp->closure);
 }
@@ -188,7 +218,7 @@ _default_book_response_handler (EBookMsg *msg)
 static void
 _default_book_response_dtor (EBookMsg *msg)
 {
-       LoadUriResponse *resp = (LoadUriResponse*)msg;
+       LoadSourceResponse *resp = (LoadSourceResponse*)msg;
 
        g_object_unref (resp->book);
        g_free (resp);
index 23a5909..a22121c 100644 (file)
@@ -38,6 +38,11 @@ void      e_book_async_load_uri                 (EBook                 *book,
                                                 EBookCallback          open_response,
                                                 gpointer               closure);
 
+void      e_book_async_load_source              (EBook                 *book,
+                                                ESource               *source,
+                                                EBookCallback          open_response,
+                                                gpointer               closure);
+
 void      e_book_async_get_default_addressbook  (EBookCallback          open_response,
                                                 gpointer               closure);