diff options
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 17 | ||||
-rw-r--r-- | calendar/cal-client/Makefile.am | 3 | ||||
-rw-r--r-- | calendar/cal-client/cal-client.c | 150 | ||||
-rw-r--r-- | calendar/cal-client/cal-client.h | 11 | ||||
-rw-r--r-- | calendar/cal-client/client-test.c | 2 | ||||
-rw-r--r-- | calendar/gui/Makefile.am | 1 | ||||
-rw-r--r-- | calendar/gui/alarm-notify/Makefile.am | 1 |
7 files changed, 184 insertions, 1 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 9869fe6560..3cd487cb5e 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,20 @@ +2001-06-21 Rodrigo Moya <rodrigo@ximian.com> + + * cal-client/cal-client.[ch]: + (cal_client_init): create a WombatClient when creating a CalClient + object, so that we can receive authentication notifications from + the wombat + (cal_client_destroy): destroy the WombatClient object when dying + (cal_client_set_auth_func): new function to set the authentication + function to be called when a password is required by the calendar + server (through the WombatClient object) + (cal_client_get_free_busy): new function for calling the new IDL + method Cal::getFreeBusy + + * gui/alarm-notify/Makefile.am: add libwombat to LDADD + + * gui/Makefile.am: add libwombat to LDADD + 2001-06-20 Dave Camp <dave@ximian.com> * gui/itip-utils.c (itip_send_comp): Changed attach_data diff --git a/calendar/cal-client/Makefile.am b/calendar/cal-client/Makefile.am index 8813db05bf..e7b32ca973 100644 --- a/calendar/cal-client/Makefile.am +++ b/calendar/cal-client/Makefile.am @@ -28,6 +28,8 @@ INCLUDES = \ -I$(top_builddir) \ -I$(top_builddir)/libical/src/libical \ -I$(top_srcdir)/libical/src/libical \ + -I$(top_builddir)/libwombat \ + -I$(top_srcdir)/libwombat \ $(BONOBO_GNOME_CFLAGS) lib_LTLIBRARIES = libcal-client.la @@ -77,6 +79,7 @@ client_test_LDADD = \ $(top_builddir)/calendar/cal-util/libcal-util.la \ $(top_builddir)/libversit/libversit.la \ $(top_builddir)/libical/src/libical/libical.la \ + $(top_builddir)/libwombat/libwombat.la \ libcal-client.la BUILT_SOURCES = $(CORBA_GENERATED) diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c index cd8c8713d6..f9e7fa3512 100644 --- a/calendar/cal-client/cal-client.c +++ b/calendar/cal-client/cal-client.c @@ -29,6 +29,7 @@ #include "cal-client-types.h" #include "cal-client.h" #include "cal-listener.h" +#include "wombat-client.h" @@ -50,6 +51,13 @@ struct _CalClientPrivate { /* The calendar client interface object we are contacting */ GNOME_Evolution_Calendar_Cal cal; + + /* The authentication function */ + CalClientAuthFunc auth_func; + gpointer auth_user_data; + + /* The WombatClient */ + WombatClient *w_client; }; @@ -59,6 +67,7 @@ enum { CAL_OPENED, OBJ_UPDATED, OBJ_REMOVED, + FORGET_PASSWORD, LAST_SIGNAL }; @@ -66,6 +75,14 @@ static void cal_client_class_init (CalClientClass *class); static void cal_client_init (CalClient *client); static void cal_client_destroy (GtkObject *object); +static char *client_get_password_cb (WombatClient *w_client, + const gchar *prompt, + const gchar *key, + gpointer user_data); +static void client_forget_password_cb (WombatClient *w_client, + const gchar *key, + gpointer user_data); + static guint cal_client_signals[LAST_SIGNAL]; static GtkObjectClass *parent_class; @@ -137,6 +154,14 @@ cal_client_class_init (CalClientClass *class) gtk_marshal_NONE__STRING, GTK_TYPE_NONE, 1, GTK_TYPE_STRING); + cal_client_signals[FORGET_PASSWORD] = + gtk_signal_new ("forget_password", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (CalClientClass, forget_password), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, + GTK_TYPE_STRING); gtk_object_class_add_signals (object_class, cal_client_signals, LAST_SIGNAL); @@ -155,6 +180,27 @@ cal_client_init (CalClient *client) priv->load_state = CAL_CLIENT_LOAD_NOT_LOADED; priv->uri = NULL; priv->factory = CORBA_OBJECT_NIL; + + /* create the WombatClient */ + priv->w_client = wombat_client_new ( + (WombatClientGetPasswordFn) client_get_password_cb, + (WombatClientForgetPasswordFn) client_forget_password_cb, + (gpointer) client); +} + +/* Gets rid of the WombatClient that a client knows about */ +static void +destroy_wombat_client (CalClient *client) +{ + CalClientPrivate *priv; + + priv = client->priv; + + if (!priv->w_client) + return; + + bonobo_object_unref (BONOBO_OBJECT (priv->w_client)); + priv->w_client = NULL; } /* Gets rid of the factory that a client knows about */ @@ -258,6 +304,7 @@ cal_client_destroy (GtkObject *object) client = CAL_CLIENT (object); priv = client->priv; + destroy_wombat_client (client); destroy_factory (client); destroy_listener (client); destroy_cal (client); @@ -389,6 +436,40 @@ obj_removed_cb (CalListener *listener, const GNOME_Evolution_Calendar_CalObjUID gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[OBJ_REMOVED], uid); } +/* Handle the get_password signal from the Wombatclient */ +static gchar * +client_get_password_cb (WombatClient *w_client, + const gchar *prompt, + const gchar *key, + gpointer user_data) +{ + CalClient *client; + + client = CAL_CLIENT (user_data); + g_return_val_if_fail (IS_CAL_CLIENT (client), NULL); + + if (client->priv->auth_func) + return client->priv->auth_func (client, prompt, key, client->priv->auth_user_data); + + return NULL; +} + +/* Handle the forget_password signal from the WombatClient */ +static void +client_forget_password_cb (WombatClient *w_client, + const gchar *key, + gpointer user_data) +{ + CalClient *client; + + client = CAL_CLIENT (user_data); + g_return_val_if_fail (IS_CAL_CLIENT (client), NULL); + + gtk_signal_emit (GTK_OBJECT (client), + cal_client_signals [FORGET_PASSWORD], + key); +} + /** @@ -465,6 +546,34 @@ cal_client_new (void) } /** + * cal_client_set_auth_func + * @client: A calendar client. + * @func: The authentication function + * @data: User data to be used when calling the authentication function + * + * Associates the given authentication function with a calendar client. This + * function will be called any time the calendar server needs a password + * from the client. So, calendar clients should provide such authentication + * function, which, when called, should act accordingly (by showing a dialog + * box, for example, to ask the user for the password). + * + * The authentication function must have the following form: + * char * auth_func (CalClient *client, + * const gchar *prompt, + * const gchar *key, + * gpointer user_data) + */ +void +cal_client_set_auth_func (CalClient *client, CalClientAuthFunc func, gpointer data) +{ + g_return_val_if_fail (client != NULL, FALSE); + g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); + + client->priv->auth_func = func; + client->priv->auth_user_data = data; +} + +/** * cal_client_open_calendar: * @client: A calendar client. * @str_uri: URI of calendar to open. @@ -901,6 +1010,47 @@ cal_client_get_objects_in_range (CalClient *client, CalObjType type, time_t star return uids; } +/** + * cal_client_get_free_busy + * @client:: A calendar client. + * @start: Start time for query. + * @end: End time for query. + * + * Gets free/busy information from the calendar server + */ +GList * +cal_client_get_free_busy (CalClient *client, time_t start, time_t end) +{ + CalClientPrivate *priv; + CORBA_Environment ev; + GNOME_Evolution_Calendar_CalObjUIDSeq *seq; + GList *uids; + + g_return_val_if_fail (client != NULL, NULL); + g_return_val_if_fail (IS_CAL_CLIENT (client), NULL); + + priv = client->priv; + g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, NULL); + + g_return_val_if_fail (start != -1 && end != -1, NULL); + g_return_val_if_fail (start <= end, NULL); + + CORBA_exception_init (&ev); + + seq = GNOME_Evolution_Calendar_Cal_getFreeBusy (priv->cal, start, end, &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + g_message ("cal_client_get_free_busy(): could not get the objects"); + CORBA_exception_free (&ev); + return NULL; + } + CORBA_exception_free (&ev); + + uids = build_uid_list (seq); + CORBA_free (seq); + + return uids; +} + /* Callback used when an object is updated and we must update the copy we have */ static void generate_instances_obj_updated_cb (CalClient *client, const char *uid, gpointer data) diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h index 3c6570e5be..07acc0d232 100644 --- a/calendar/cal-client/cal-client.h +++ b/calendar/cal-client/cal-client.h @@ -81,14 +81,23 @@ struct _CalClientClass { void (* obj_updated) (CalClient *client, const char *uid); void (* obj_removed) (CalClient *client, const char *uid); + + void (* forget_password) (CalClient *client, const char *key); }; +typedef gchar * (* CalClientAuthFunc) (CalClient *client, + const gchar *prompt, + const gchar *key, + gpointer user_data); + GtkType cal_client_get_type (void); CalClient *cal_client_construct (CalClient *client); CalClient *cal_client_new (void); +void cal_client_set_auth_func (CalClient *client, CalClientAuthFunc func, gpointer data); + gboolean cal_client_open_calendar (CalClient *client, const char *str_uri, gboolean only_if_exists); CalClientLoadState cal_client_get_load_state (CalClient *client); @@ -107,6 +116,8 @@ GList *cal_client_get_changes (CalClient *client, CalObjType type, const char *c GList *cal_client_get_objects_in_range (CalClient *client, CalObjType type, time_t start, time_t end); +GList *cal_client_get_free_busy (CalClient *client, time_t start, time_t end); + void cal_client_generate_instances (CalClient *client, CalObjType type, time_t start, time_t end, CalRecurInstanceFn cb, gpointer cb_data); diff --git a/calendar/cal-client/client-test.c b/calendar/cal-client/client-test.c index d6a57cbffd..6748ed9ab4 100644 --- a/calendar/cal-client/client-test.c +++ b/calendar/cal-client/client-test.c @@ -208,7 +208,7 @@ main (int argc, char **argv) exit (1); } - create_client (&client1, "/cvs/evolution/calendar/cal-client/test.ics", FALSE); + create_client (&client1, "/tmp/calendar.ics", FALSE); create_client (&client2, "/cvs/evolution/calendar/cal-client/test.ics", TRUE); bonobo_main (); diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index 72df7d6299..9b6e0afd50 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -127,6 +127,7 @@ evolution_calendar_LDADD = \ $(top_builddir)/e-util/libeutil.la \ $(top_builddir)/libversit/libversit.la \ $(top_builddir)/libical/src/libical/libical.la \ + $(top_builddir)/libwombat/libwombat.la \ $(top_builddir)/widgets/meeting-time-sel/libevolutionmtsel.a \ dialogs/libcal-dialogs.a \ $(top_builddir)/widgets/misc/libemiscwidgets.a \ diff --git a/calendar/gui/alarm-notify/Makefile.am b/calendar/gui/alarm-notify/Makefile.am index 528841da89..de0f4fb847 100644 --- a/calendar/gui/alarm-notify/Makefile.am +++ b/calendar/gui/alarm-notify/Makefile.am @@ -49,6 +49,7 @@ evolution_alarm_notify_LDADD = \ $(top_builddir)/calendar/cal-client/libcal-client.la \ $(top_builddir)/calendar/cal-util/libcal-util.la \ $(top_builddir)/libical/src/libical/libical.la \ + $(top_builddir)/libwombat/libwombat.la \ $(BONOBO_VFS_GNOME_LIBS) \ $(EXTRA_GNOME_LIBS) \ $(INTLLIBS) |