aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/conduits/calendar/calendar-conduit.h
blob: a8a1c81a507aca80796af4453f0ac43c256bab0f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* $Id$ */

#ifndef __CALENDAR_CONDUIT_H__
#define __CALENDAR_CONDUIT_H__

#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <gnome.h>
#include <pi-datebook.h>
#include <gpilotd/gnome-pilot-conduit.h>
#include <gpilotd/gnome-pilot-conduit-standard-abs.h>
#include <cal-client/cal-client.h>
#include <cal-util/calobj.h>
#include <cal-util/timeutil.h>

#ifdef USING_OAF
#include <liboaf/liboaf.h>
#else
#include <libgnorba/gnorba.h>
#endif


/* This is the local record structure for the GnomeCal conduit. */
typedef struct _GCalLocalRecord GCalLocalRecord;
struct _GCalLocalRecord {
    /* The stuff from gnome-pilot-conduit-standard-abs.h
       Must be first in the structure, or instances of this
       structure cannot be used by gnome-pilot-conduit-standard-abs.
    */
    LocalRecord local;
    /* The corresponding iCal object, as found by GnomeCal. */
    CalComponent *ical;
        /* pilot-link appointment structure, used for implementing Transmit. */ 
    struct Appointment *a;
};
#define GCAL_LOCALRECORD(s) ((GCalLocalRecord*)(s))

/* This is the configuration of the GnomeCal conduit. */
typedef struct _GCalConduitCfg GCalConduitCfg;
struct _GCalConduitCfg {
    gboolean open_secret;
    guint32 pilotId;
    GnomePilotConduitSyncType  sync_type;   /* only used by capplet */
};
#define GET_GCALCONFIG(c) ((GCalConduitCfg*)gtk_object_get_data(GTK_OBJECT(c),"gcalconduit_cfg"))

/* This is the context for all the GnomeCal conduit methods. */
typedef struct _GCalConduitContext GCalConduitContext;
struct _GCalConduitContext {
    struct AppointmentAppInfo ai;
    GCalConduitCfg *cfg;
    CalClient *client;
    CORBA_Environment ev;
    CORBA_ORB orb;
    gboolean calendar_load_tried;
    gboolean calendar_load_success;

    char *calendar_file;
};
#define GET_GCALCONTEXT(c) ((GCalConduitContext*)gtk_object_get_data(GTK_OBJECT(c),"gcalconduit_context"))


/* Given a GCalConduitCfg*, allocates the structure and 
   loads the configuration data for the given pilot.
   this is defined in the header file because it is used by
   both calendar-conduit and calendar-conduit-control-applet,
   and we don't want to export any symbols we don't have to. */
static void 
gcalconduit_load_configuration(GCalConduitCfg **c,
                   guint32 pilotId) 
{
    gchar prefix[256];
    g_snprintf(prefix,255,"/gnome-pilot.d/calendard-conduit/Pilot_%u/",pilotId);
    
    *c = g_new0(GCalConduitCfg,1);
    g_assert(*c != NULL);
    gnome_config_push_prefix(prefix);
    (*c)->open_secret = gnome_config_get_bool("open_secret=FALSE");
    (*c)->sync_type = GnomePilotConduitSyncTypeCustom; /* set in capplets main */
    gnome_config_pop_prefix();
    
    (*c)->pilotId = pilotId;
}


#endif __CALENDAR_CONDUIT_H__