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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* main.c
*
* Copyright (C) 2000, 2001, 2002, 2003 Ximian, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: Ettore Perazzoli
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <glib.h>
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-init.h>
#include <libgnomevfs/gnome-vfs-init.h>
#include <glade/glade.h>
#include <bonobo/bonobo-main.h>
#include <bonobo/bonobo-shlib-factory.h>
#include <bonobo/bonobo-exception.h>
#include <gal/widgets/e-cursors.h>
#include <evolution-shell-client.h>
#include "dialogs/cal-prefs-dialog.h"
#include "calendar-commands.h"
#include "calendar-config.h"
#include "calendar-component.h"
#include "e-comp-editor-registry.h"
#include "comp-editor-factory.h"
#include "control-factory.h"
#include "itip-bonobo-control.h"
#include "tasks-control.h"
#include "tasks-component.h"
#define FACTORY_ID "OAFIID:GNOME_Evolution_Calendar_Factory_2"
#define CALENDAR_COMPONENT_ID "OAFIID:GNOME_Evolution_Calendar_Component"
#define CALENDAR_CONTROL_ID "OAFIID:GNOME_Evolution_Calendar_Control"
#define TASKS_COMPONENT_ID "OAFIID:GNOME_Evolution_Tasks_Component"
#define TASKS_CONTROL_ID "OAFIID:GNOME_Evolution_Tasks_Control"
#define ITIP_CONTROL_ID "OAFIID:GNOME_Evolution_Calendar_iTip_Control"
#define CONFIG_CONTROL_ID "OAFIID:GNOME_Evolution_Calendar_ConfigControl"
#define COMP_EDITOR_FACTORY_ID "OAFIID:GNOME_Evolution_Calendar_CompEditorFactory"
ECompEditorRegistry *comp_editor_registry = NULL;
/* The component editor factory */
static CompEditorFactory *comp_editor_factory = NULL;
/* Factory function for the calendar component factory; just creates and
* references a singleton service object.
*/
static BonoboObject *
comp_editor_factory_fn (void)
{
if (!comp_editor_factory) {
comp_editor_factory = comp_editor_factory_new ();
if (!comp_editor_factory)
return NULL;
}
bonobo_object_ref (BONOBO_OBJECT (comp_editor_factory));
return BONOBO_OBJECT (comp_editor_factory);
}
/* Does a simple activation and unreffing of the alarm notification service so
* that the daemon will be launched if it is not running yet.
*/
static gboolean
launch_alarm_daemon_cb (gpointer data)
{
CORBA_Environment ev;
GNOME_Evolution_Calendar_AlarmNotify an;
guint *idle_id = (guint *) data;
/* remove the idle function */
g_source_remove (*idle_id);
g_free (idle_id);
/* activate the alarm daemon */
CORBA_exception_init (&ev);
an = bonobo_activation_activate_from_id ("OAFIID:GNOME_Evolution_Calendar_AlarmNotify", 0, NULL, &ev);
if (BONOBO_EX (&ev)) {
g_message ("launch_alarm_daemon_cb(): Could not activate the alarm notification service");
CORBA_exception_free (&ev);
return FALSE;
}
CORBA_exception_free (&ev);
/* Just get rid of it; what we are interested in is that it gets launched */
CORBA_exception_init (&ev);
bonobo_object_release_unref (an, &ev);
if (BONOBO_EX (&ev))
g_message ("add_alarms(): Could not unref the alarm notification service");
CORBA_exception_free (&ev);
return FALSE;
}
static void
launch_alarm_daemon (void)
{
guint *idle_id;
idle_id = g_new0 (guint, 1);
*idle_id = g_idle_add ((GSourceFunc) launch_alarm_daemon_cb, idle_id);
}
static void
initialize (void)
{
comp_editor_registry = E_COMP_EDITOR_REGISTRY (e_comp_editor_registry_new ());
calendar_config_init ();
#if 0
itip_control_factory_init ();
component_editor_factory_init ();
#endif
launch_alarm_daemon ();
}
static BonoboObject *
factory (BonoboGenericFactory *factory,
const char *component_id,
void *closure)
{
static gboolean initialized = FALSE;
if (! initialized) {
initialize ();
initialized = TRUE;
}
if (strcmp (component_id, CALENDAR_COMPONENT_ID) == 0) {
BonoboObject *object = BONOBO_OBJECT (calendar_component_peek ());
bonobo_object_ref (object);
return object;
} else if (strcmp (component_id, CALENDAR_CONTROL_ID) == 0)
return BONOBO_OBJECT (control_factory_new_control ());
else if (strcmp (component_id, TASKS_COMPONENT_ID) == 0) {
BonoboObject *object = BONOBO_OBJECT (tasks_component_peek ());
bonobo_object_ref (object);
return object;
} else if (strcmp (component_id, TASKS_CONTROL_ID) == 0)
return BONOBO_OBJECT (tasks_control_new ());
else if (strcmp (component_id, ITIP_CONTROL_ID) == 0)
return BONOBO_OBJECT (itip_bonobo_control_new ());
else if (strcmp (component_id, CONFIG_CONTROL_ID) == 0)
return BONOBO_OBJECT (cal_prefs_dialog_new ());
else if (strcmp (component_id, COMP_EDITOR_FACTORY_ID) == 0)
return BONOBO_OBJECT (comp_editor_factory_fn ());
g_warning (FACTORY_ID ": Don't know what to do with %s", component_id);
return NULL;
}
BONOBO_ACTIVATION_SHLIB_FACTORY (FACTORY_ID, "Evolution Calendar component factory", factory, NULL)
|