CalClient

Name

CalClient -- GTK+ object for communication with personal calendar server.

Synopsis


#include <cal-client/cal-client.h>


#define     CAL_CLIENT                      (obj)
enum        CalClientOpenStatus;
enum        CalClientGetStatus;
enum        CalClientLoadState;
enum        CalClientChangeType;
CalClient*  cal_client_new                  (void);
gboolean    cal_client_open_calendar        (CalClient *client,
                                             const char *str_uri,
                                             gboolean only_if_exists);
CalClientLoadState cal_client_get_load_state
                                            (CalClient *client);
const char* cal_client_get_uri              (CalClient *client);
int         cal_client_get_n_objects        (CalClient *client,
                                             CalObjType type);
GList*      cal_client_get_uids             (CalClient *client,
                                             CalObjType type);
CalClientGetStatus cal_client_get_object    (CalClient *client,
                                             const char *uid,
                                             CalComponent **comp);
GList*      cal_client_get_changes          (CalClient *client,
                                             CalObjType type,
                                             const char *change_id);
void        cal_client_change_list_free     (GList *list);
GList*      cal_client_get_objects_in_range (CalClient *client,
                                             CalObjType type,
                                             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);
GSList*     cal_client_get_alarms_in_range  (CalClient *client,
                                             time_t start,
                                             time_t end);
void        cal_client_free_alarms          (GSList *comp_alarms);
gboolean    cal_client_get_alarms_for_object
                                            (CalClient *client,
                                             const char *uid,
                                             time_t start,
                                             time_t end,
                                             CalComponentAlarms **alarms);
CalClientResult cal_client_update_object    (CalClient *client,
                                             CalComponent *comp);
CalClientResult cal_client_remove_object    (CalClient *client,
                                             const char *uid);
CalQuery*   cal_client_get_query            (CalClient *client,
                                             const char *sexp);


Object Hierarchy


  GtkObject
   +----CalClient

Signal Prototypes


"cal-opened"
            void        user_function      (CalClient *calclient,
                                            gint arg1,
                                            gpointer user_data);
"cal-set-mode"
            void        user_function      (CalClient *calclient,
                                            gint arg1,
                                            gint arg2,
                                            gpointer user_data);
"obj-updated"
            void        user_function      (CalClient *calclient,
                                            gchar *arg1,
                                            gpointer user_data);
"obj-removed"
            void        user_function      (CalClient *calclient,
                                            gchar *arg1,
                                            gpointer user_data);
"backend-error"
            void        user_function      (CalClient *calclient,
                                            gchar *arg1,
                                            gpointer user_data);
"categories-changed"
            void        user_function      (CalClient *calclient,
                                            gpointer arg1,
                                            gpointer user_data);
"forget-password"
            void        user_function      (CalClient *calclient,
                                            gchar *arg1,
                                            gpointer user_data);
"backend-died"
            void        user_function      (CalClient *calclient,
                                            gpointer user_data);

Description

The CalClient object provides a nice GTK+ wrapper for the CORBA interfaces that are used to communicate between calendar clients and the personal calendar server in the user's Wombat daemon. The CORBA interfaces transfer calendar components in RFC 2445 text format; the CalClient object automatically converts these into CalComponent structures that are easier to handle.

After a CalClient object is created with cal_client_new(), it should be asked to send a request to the personal calendar server to load or create a calendar based on its URI. The server will asynchronously notify the client about completion of the request, and will return an appropriate result code; this should be noted by the client with the cal_loaded signal.

When a client asks the server to update or delete a calendar component from the storage, the server will do so and then notify all the clients about the update or removal. This is the core of the model/view split between calendar clients and the storage in the personal calendar server. Clients should watch the obj_updated and obj_removed signals on the CalClient objects they create so that they can be notified about changes in the storage.

Details

CAL_CLIENT()

#define CAL_CLIENT(obj)            (GTK_CHECK_CAST ((obj), CAL_CLIENT_TYPE, CalClient))

Casts a GtkObject to a CalClient.


enum CalClientOpenStatus

typedef enum {
	CAL_CLIENT_OPEN_SUCCESS,
	CAL_CLIENT_OPEN_ERROR,
	CAL_CLIENT_OPEN_NOT_FOUND,
	CAL_CLIENT_OPEN_PERMISSION_DENIED,
	CAL_CLIENT_OPEN_METHOD_NOT_SUPPORTED
} CalClientOpenStatus;


enum CalClientGetStatus

typedef enum {
	CAL_CLIENT_GET_SUCCESS,
	CAL_CLIENT_GET_NOT_FOUND,
	CAL_CLIENT_GET_SYNTAX_ERROR
} CalClientGetStatus;

These values describe the result of the cal_client_get_object() function.


enum CalClientLoadState

typedef enum {
	CAL_CLIENT_LOAD_NOT_LOADED,
	CAL_CLIENT_LOAD_LOADING,
	CAL_CLIENT_LOAD_LOADED
} CalClientLoadState;


enum CalClientChangeType

typedef enum {
	CAL_CLIENT_CHANGE_ADDED = 1 << 0,
	CAL_CLIENT_CHANGE_MODIFIED = 1 << 1,
	CAL_CLIENT_CHANGE_DELETED = 1 << 2
} CalClientChangeType;


cal_client_new ()

CalClient*  cal_client_new                  (void);

Creates a new calendar client. It should be initialized by calling cal_client_open_calendar().


cal_client_open_calendar ()

gboolean    cal_client_open_calendar        (CalClient *client,
                                             const char *str_uri,
                                             gboolean only_if_exists);

Makes a calendar client initiate a request to open a calendar. The calendar client will emit the "cal_opened" signal when the response from the server is received.


cal_client_get_load_state ()

CalClientLoadState cal_client_get_load_state
                                            (CalClient *client);

Queries the state of loading of a calendar client.


cal_client_get_uri ()

const char* cal_client_get_uri              (CalClient *client);

Queries the URI that is open in a calendar client.


cal_client_get_n_objects ()

int         cal_client_get_n_objects        (CalClient *client,
                                             CalObjType type);

Counts the number of calendar components of the specified type. This can be used to count how many events, to-dos, or journals there are, for example.


cal_client_get_uids ()

GList*      cal_client_get_uids             (CalClient *client,
                                             CalObjType type);

Queries a calendar for a list of unique identifiers corresponding to calendar objects whose type matches one of the types specified in the type flags.


cal_client_get_object ()

CalClientGetStatus cal_client_get_object    (CalClient *client,
                                             const char *uid,
                                             CalComponent **comp);

Queries a calendar for a calendar component object based on its unique identifier.


cal_client_get_changes ()

GList*      cal_client_get_changes          (CalClient *client,
                                             CalObjType type,
                                             const char *change_id);


cal_client_change_list_free ()

void        cal_client_change_list_free     (GList *list);

Frees a list of CalClientChange structures.


cal_client_get_objects_in_range ()

GList*      cal_client_get_objects_in_range (CalClient *client,
                                             CalObjType type,
                                             time_t start,
                                             time_t end);

Queries a calendar for the objects that occur or recur in the specified range of time.


cal_client_generate_instances ()

void        cal_client_generate_instances   (CalClient *client,
                                             CalObjType type,
                                             time_t start,
                                             time_t end,
                                             CalRecurInstanceFn cb,
                                             gpointer cb_data);

Does a combination of cal_client_get_objects_in_range() and cal_recur_generate_instances(). It fetches the list of objects in an atomic way so that the generated instances are actually in the server at the time the initial cal_client_get_objects_in_range() query ends.

The callback function should do a gtk_object_ref() of the calendar component it gets passed if it intends to keep it around.


cal_client_get_alarms_in_range ()

GSList*     cal_client_get_alarms_in_range  (CalClient *client,
                                             time_t start,
                                             time_t end);

Queries a calendar for the alarms that trigger in the specified range of time.


cal_client_free_alarms ()

void        cal_client_free_alarms          (GSList *comp_alarms);

Frees a list of CalComponentAlarms structures as returned by cal_client_get_alarms_in_range().


cal_client_get_alarms_for_object ()

gboolean    cal_client_get_alarms_for_object
                                            (CalClient *client,
                                             const char *uid,
                                             time_t start,
                                             time_t end,
                                             CalComponentAlarms **alarms);

Queries a calendar for the alarms of a particular object that trigger in the specified range of time.


cal_client_update_object ()

CalClientResult cal_client_update_object    (CalClient *client,
                                             CalComponent *comp);

Asks a calendar to update a component. Any existing component with the specified component's UID will be replaced. The client program should not assume that the object is actually in the server's storage until it has received the "obj_updated" notification signal.


cal_client_remove_object ()

CalClientResult cal_client_remove_object    (CalClient *client,
                                             const char *uid);

Asks a calendar to remove a component. If the server is able to remove the component, all clients will be notified and they will emit the "obj_removed" signal.


cal_client_get_query ()

CalQuery*   cal_client_get_query            (CalClient *client,
                                             const char *sexp);

Creates a live query object from a loaded calendar.

Signals

The "cal-opened" signal

void        user_function                  (CalClient *calclient,
                                            gint arg1,
                                            gpointer user_data);


The "cal-set-mode" signal

void        user_function                  (CalClient *calclient,
                                            gint arg1,
                                            gint arg2,
                                            gpointer user_data);


The "obj-updated" signal

void        user_function                  (CalClient *calclient,
                                            gchar *arg1,
                                            gpointer user_data);

This signal is emitted when the calendar clients receives notification of a calendar component's data being changed in the personal calendar server. Graphical clients may want to get the new version of the object and update their display, for example.


The "obj-removed" signal

void        user_function                  (CalClient *calclient,
                                            gchar *arg1,
                                            gpointer user_data);

This signal is emitted when the calendar client receives notification for a calendar component being removed from the storage in the personal calendar server. Graphical clients may want to delete the corresponding object from their display, for example.


The "backend-error" signal

void        user_function                  (CalClient *calclient,
                                            gchar *arg1,
                                            gpointer user_data);


The "categories-changed" signal

void        user_function                  (CalClient *calclient,
                                            gpointer arg1,
                                            gpointer user_data);


The "forget-password" signal

void        user_function                  (CalClient *calclient,
                                            gchar *arg1,
                                            gpointer user_data);


The "backend-died" signal

void        user_function                  (CalClient *calclient,
                                            gpointer user_data);

See Also

CalComponent