CalClient

Name

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

Synopsis


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


#define     CAL_CLIENT                      (obj)
enum        CalClientLoadStatus;
enum        CalClientGetStatus;
CalClient*  cal_client_new                  (void);
gboolean    cal_client_load_calendar        (CalClient *client,
                                             const char *str_uri);
gboolean    cal_client_create_calendar      (CalClient *client,
                                             const char *str_uri);
int         cal_client_get_n_objects        (CalClient *client,
                                             CalObjType type);
CalClientGetStatus cal_client_get_object    (CalClient *client,
                                             const char *uid,
                                             CalComponent **comp);
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);
CalClientGetStatus cal_client_get_uid_by_pilot_id
                                            (CalClient *client,
                                             unsigned long pilot_id,
                                             char **uid);
void        cal_client_update_pilot_id      (CalClient *client,
                                             char *uid,
                                             unsigned long pilot_id,
                                             unsigned long pilot_status);
GList*      cal_client_get_uids             (CalClient *client,
                                             CalObjType type);
GList*      cal_client_get_alarms_in_range  (CalClient *client,
                                             time_t start,
                                             time_t end);
gboolean    cal_client_get_alarms_for_object
                                            (CalClient *client,
                                             const char *uid,
                                             time_t start,
                                             time_t end,
                                             GList **alarms);
gboolean    cal_client_update_object        (CalClient *client,
                                             CalComponent *comp);
gboolean    cal_client_remove_object        (CalClient *client,
                                             const char *uid);


Object Hierarchy


  GtkObject
   +----CalClient

Signal Prototypes


"cal-loaded"
            void        user_function      (CalClient *calclient,
                                            GtkEnum arg1,
                                            gpointer user_data);
"obj-updated"
            void        user_function      (CalClient *calclient,
                                            GtkString arg1,
                                            gpointer user_data);
"obj-removed"
            void        user_function      (CalClient *calclient,
                                            GtkString arg1,
                                            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.

obj :A GTK+ object.


enum CalClientLoadStatus

typedef enum {
	CAL_CLIENT_LOAD_SUCCESS,
	CAL_CLIENT_LOAD_ERROR,
	CAL_CLIENT_LOAD_IN_USE,
	CAL_CLIENT_LOAD_METHOD_NOT_SUPPORTED
} CalClientLoadStatus;

These values describe the status of a calendar load or create request. After asking a calendar factory to load or create a calendar, the provided listener will get notification about the result in asynchronous fashion. Such notification is represented by one of these enumeration values. For values other than CAL_CLIENT_LOAD_SUCCESS, the CalClient object will not accept any other operations on the calendar and it should just be destroyed.


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.


cal_client_new ()

CalClient*  cal_client_new                  (void);

Creates a new calendar client. It should be initialized by calling cal_client_load_calendar() or cal_client_create_calendar().

Returns : A newly-created calendar client, or NULL if the client could not be constructed because it could not contact the calendar server.


cal_client_load_calendar ()

gboolean    cal_client_load_calendar        (CalClient *client,
                                             const char *str_uri);

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

client : A calendar client.
str_uri : URI of calendar to load.
Returns : TRUE on success, FALSE on failure to issue the load request.


cal_client_create_calendar ()

gboolean    cal_client_create_calendar      (CalClient *client,
                                             const char *str_uri);

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

client : A calendar client.
str_uri : URI that will contain the calendar data.
Returns : TRUE on success, FALSE on failure to issue the create request.


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.

client : A calendar client.
type : Type of objects that will be counted.
Returns : Number of components.


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.

client : A calendar client.
uid : Unique identifier for a calendar component.
comp : Return value for the calendar component object.
Returns : Result code based on the status of the operation.


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.

client : A calendar client.
type : Bitmask with types of objects to return.
start : Start time for query.
end : End time for query.
Returns : A list of UID strings. This should be freed using the cal_obj_uid_list_free() function.


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.

client : A calendar client.
type : Bitmask with types of objects to return.
start : Start time for query.
end : End time for query.
cb : Callback for each generated instance.
cb_data : Closure data for the callback.


cal_client_get_uid_by_pilot_id ()

CalClientGetStatus cal_client_get_uid_by_pilot_id
                                            (CalClient *client,
                                             unsigned long pilot_id,
                                             char **uid);

client : 
pilot_id : 
uid : 
Returns : 


cal_client_update_pilot_id ()

void        cal_client_update_pilot_id      (CalClient *client,
                                             char *uid,
                                             unsigned long pilot_id,
                                             unsigned long pilot_status);

client : 
uid : 
pilot_id : 
pilot_status : 


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.

client : A calendar client.
type : Bitmask with types of objects to return.
Returns : A list of strings that are the sought UIDs.


cal_client_get_alarms_in_range ()

GList*      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.

client : A calendar client.
start : Start time for query.
end : End time for query.
Returns : A list of CalAlarmInstance structures.


cal_client_get_alarms_for_object ()

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

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

client : A calendar client.
uid : Unique identifier for a calendar object.
start : Start time for query.
end : End time for query.
alarms : Return value for the list of alarm instances.
Returns : TRUE on success, FALSE if the object was not found.


cal_client_update_object ()

gboolean    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.

client : A calendar client.
comp : A calendar component object.
Returns : TRUE on success, FALSE on specifying an invalid component.


cal_client_remove_object ()

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

client : 
uid : 
Returns : 

Signals

The "cal-loaded" signal

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

This signal is emitted some time after the calendar clients sends a load or create request to the personal calendar server. The server will notify the client asynchronously of the completion of the request. The status parameter indicates the status of the request.

calclient :the object which received the signal.
arg1 : 
user_data :user data set when the signal handler was connected.


The "obj-updated" signal

void        user_function                  (CalClient *calclient,
                                            GtkString 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.

calclient :the object which received the signal.
arg1 : 
user_data :user data set when the signal handler was connected.


The "obj-removed" signal

void        user_function                  (CalClient *calclient,
                                            GtkString 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.

calclient :the object which received the signal.
arg1 : 
user_data :user data set when the signal handler was connected.

See Also

CalComponent