From 045c2a07b9516383deb591fb1e68b2b48ea1bd14 Mon Sep 17 00:00:00 2001 From: Rodrigo Moya Date: Thu, 11 Apr 2002 23:05:56 +0000 Subject: new method. 2002-04-05 Rodrigo Moya * pcs/cal-backend.[ch] (cal_backend_get_query): new method. * pcs/cal-backend-file.c (cal_backend_file_get_query): new method. * pcs/cal.c (impl_Cal_get_query): call the CalBackend's implementation instead of calling query_new directly. * pcs/query.[ch]: fixed headers. svn path=/trunk/; revision=16443 --- calendar/pcs/cal-backend-file.c | 17 +++++++++++++++++ calendar/pcs/cal-backend.c | 27 +++++++++++++++++++++++++++ calendar/pcs/cal-backend.h | 9 +++++++++ calendar/pcs/cal.c | 3 ++- calendar/pcs/query.c | 1 + calendar/pcs/query.h | 3 ++- 6 files changed, 58 insertions(+), 2 deletions(-) (limited to 'calendar/pcs') diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c index 424912e87b..5ca5a06f0e 100644 --- a/calendar/pcs/cal-backend-file.c +++ b/calendar/pcs/cal-backend-file.c @@ -95,6 +95,9 @@ static CalBackendOpenStatus cal_backend_file_open (CalBackend *backend, const char *uristr, gboolean only_if_exists); static gboolean cal_backend_file_is_loaded (CalBackend *backend); +static Query *cal_backend_file_get_query (CalBackend *backend, + GNOME_Evolution_Calendar_QueryListener ql, + const char *sexp); static CalMode cal_backend_file_get_mode (CalBackend *backend); static void cal_backend_file_set_mode (CalBackend *backend, CalMode mode); @@ -180,6 +183,7 @@ cal_backend_file_class_init (CalBackendFileClass *class) backend_class->get_uri = cal_backend_file_get_uri; backend_class->open = cal_backend_file_open; backend_class->is_loaded = cal_backend_file_is_loaded; + backend_class->get_query = cal_backend_file_get_query; backend_class->get_mode = cal_backend_file_get_mode; backend_class->set_mode = cal_backend_file_set_mode; backend_class->get_n_objects = cal_backend_file_get_n_objects; @@ -910,6 +914,19 @@ cal_backend_file_is_loaded (CalBackend *backend) return (priv->icalcomp != NULL); } +/* get_query handler for the file backend */ +static Query * +cal_backend_file_get_query (CalBackend *backend, + GNOME_Evolution_Calendar_QueryListener ql, + const char *sexp) +{ + CalBackendFile *cbfile; + + cbfile = CAL_BACKEND_FILE (backend); + + return query_new (backend, ql, sexp); +} + /* is_remote handler for the file backend */ static CalMode cal_backend_file_get_mode (CalBackend *backend) diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c index e0dd3a713b..95dc9957e6 100644 --- a/calendar/pcs/cal-backend.c +++ b/calendar/pcs/cal-backend.c @@ -143,6 +143,7 @@ cal_backend_class_init (CalBackendClass *class) class->get_uri = NULL; class->open = NULL; class->is_loaded = NULL; + class->get_query = NULL; class->get_mode = NULL; class->set_mode = NULL; class->get_n_objects = NULL; @@ -296,6 +297,32 @@ cal_backend_is_loaded (CalBackend *backend) return result; } +/** + * cal_backend_get_query: + * @backend: A calendar backend. + * @ql: The query listener. + * @sexp: Search expression. + * + * Create a query object for this backend. + */ +Query * +cal_backend_get_query (CalBackend *backend, + GNOME_Evolution_Calendar_QueryListener ql, + const char *sexp) +{ + Query *result; + + g_return_val_if_fail (backend != NULL, FALSE); + g_return_val_if_fail (IS_CAL_BACKEND (backend), FALSE); + + if (CLASS (backend)->get_query != NULL) + result = (* CLASS (backend)->get_query) (backend, ql, sexp); + else + result = query_new (backend, ql, sexp); + + return result; +} + /** * cal_backend_get_mode: * @backend: A calendar backend. diff --git a/calendar/pcs/cal-backend.h b/calendar/pcs/cal-backend.h index e5f10842b4..4fd0a42bd0 100644 --- a/calendar/pcs/cal-backend.h +++ b/calendar/pcs/cal-backend.h @@ -30,6 +30,7 @@ #include "evolution-calendar.h" #include "cal-common.h" #include "cal.h" +#include "query.h" BEGIN_GNOME_DECLS @@ -80,6 +81,10 @@ struct _CalBackendClass { gboolean (* is_loaded) (CalBackend *backend); + Query *(* get_query) (CalBackend *backend, + GNOME_Evolution_Calendar_QueryListener ql, + const char *sexp); + /* Mode relate virtual methods */ CalMode (* get_mode) (CalBackend *backend); void (* set_mode) (CalBackend *backend, CalMode mode); @@ -127,6 +132,10 @@ CalBackendOpenStatus cal_backend_open (CalBackend *backend, const char *uristr, gboolean cal_backend_is_loaded (CalBackend *backend); +Query *cal_backend_get_query (CalBackend *backend, + GNOME_Evolution_Calendar_QueryListener ql, + const char *sexp); + CalMode cal_backend_get_mode (CalBackend *backend); void cal_backend_set_mode (CalBackend *backend, CalMode mode); diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c index 9409d20120..2944563163 100644 --- a/calendar/pcs/cal.c +++ b/calendar/pcs/cal.c @@ -24,6 +24,7 @@ #include #include #include "cal.h" +#include "cal-backend.h" #include "query.h" #include "wombat.h" @@ -427,7 +428,7 @@ impl_Cal_get_query (PortableServer_Servant servant, cal = CAL (bonobo_object_from_servant (servant)); priv = cal->priv; - query = query_new (priv->backend, ql, sexp); + query = cal_backend_get_query (priv->backend, ql, sexp); if (!query) { bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_Cal_CouldNotCreate); return CORBA_OBJECT_NIL; diff --git a/calendar/pcs/query.c b/calendar/pcs/query.c index bf008ab655..d3fc773ff9 100644 --- a/calendar/pcs/query.c +++ b/calendar/pcs/query.c @@ -32,6 +32,7 @@ #include #include #include +#include "cal-backend.h" #include "query.h" diff --git a/calendar/pcs/query.h b/calendar/pcs/query.h index 71f289906e..80b17983a6 100644 --- a/calendar/pcs/query.h +++ b/calendar/pcs/query.h @@ -23,7 +23,8 @@ #include #include -#include "cal-backend.h" +#include "cal-common.h" +#include "evolution-calendar.h" BEGIN_GNOME_DECLS -- cgit v1.2.3