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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* pas-book-view.c
*
* Copyright 2000, Ximian, Inc.
*/
#include <config.h>
#include <glib.h>
#include <bonobo/bonobo-main.h>
#include "pas-book-view.h"
static BonoboObjectClass *pas_book_view_parent_class;
POA_GNOME_Evolution_Addressbook_BookView__vepv pas_book_view_vepv;
struct _PASBookViewPrivate {
PASBookViewServant *servant;
GNOME_Evolution_Addressbook_BookView corba_objref;
GNOME_Evolution_Addressbook_BookViewListener listener;
};
/**
* pas_book_view_notify_change:
*/
void
pas_book_view_notify_change (PASBookView *book_view,
const GList *cards)
{
CORBA_Environment ev;
gint i, length;
CORBA_sequence_GNOME_Evolution_Addressbook_VCard card_sequence;
length = g_list_length((GList *) cards);
card_sequence._buffer = CORBA_sequence_GNOME_Evolution_Addressbook_VCard_allocbuf(length);
card_sequence._maximum = length;
card_sequence._length = length;
for ( i = 0; cards; cards = g_list_next(cards), i++ ) {
card_sequence._buffer[i] = CORBA_string_dup((char *) cards->data);
}
CORBA_exception_init (&ev);
GNOME_Evolution_Addressbook_BookViewListener_notifyCardChanged (
book_view->priv->listener, &card_sequence, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("pas_book_view_notify_change: Exception signaling BookViewListener!\n");
}
CORBA_exception_free (&ev);
CORBA_free(card_sequence._buffer);
}
void
pas_book_view_notify_change_1 (PASBookView *book_view,
const char *card)
{
GList *list = g_list_append(NULL, (char *) card);
pas_book_view_notify_change(book_view, list);
g_list_free(list);
}
/**
* pas_book_view_notify_remove:
*/
void
pas_book_view_notify_remove (PASBookView *book_view,
const char *id)
{
CORBA_Environment ev;
CORBA_exception_init (&ev);
GNOME_Evolution_Addressbook_BookViewListener_notifyCardRemoved (
book_view->priv->listener, (GNOME_Evolution_Addressbook_CardId) id, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("pas_book_view_notify_remove: Exception signaling BookViewListener!\n");
}
CORBA_exception_free (&ev);
}
/**
* pas_book_view_notify_add:
*/
void
pas_book_view_notify_add (PASBookView *book_view,
const GList *cards)
{
CORBA_Environment ev;
gint i, length;
CORBA_sequence_GNOME_Evolution_Addressbook_VCard card_sequence;
length = g_list_length((GList *)cards);
card_sequence._buffer = CORBA_sequence_GNOME_Evolution_Addressbook_VCard_allocbuf(length);
card_sequence._maximum = length;
card_sequence._length = length;
for ( i = 0; cards; cards = g_list_next(cards), i++ ) {
card_sequence._buffer[i] = CORBA_string_dup((char *) cards->data);
}
CORBA_exception_init (&ev);
GNOME_Evolution_Addressbook_BookViewListener_notifyCardAdded (
book_view->priv->listener, &card_sequence, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("pas_book_view_notify_add: Exception signaling BookViewListener!\n");
}
CORBA_exception_free (&ev);
CORBA_free(card_sequence._buffer);
}
void
pas_book_view_notify_add_1 (PASBookView *book_view,
const char *card)
{
GList *list = g_list_append(NULL, (char *) card);
pas_book_view_notify_add(book_view, list);
g_list_free(list);
}
void
pas_book_view_notify_complete (PASBookView *book_view,
GNOME_Evolution_Addressbook_BookViewListener_CallStatus status)
{
CORBA_Environment ev;
CORBA_exception_init (&ev);
GNOME_Evolution_Addressbook_BookViewListener_notifySequenceComplete (
book_view->priv->listener, status, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("pas_book_view_notify_complete: Exception signaling BookViewListener!\n");
}
CORBA_exception_free (&ev);
}
void
pas_book_view_notify_status_message (PASBookView *book_view,
const char *message)
{
CORBA_Environment ev;
CORBA_exception_init (&ev);
GNOME_Evolution_Addressbook_BookViewListener_notifyStatusMessage (
book_view->priv->listener, message, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("pas_book_view_notify_status_message: Exception signaling BookViewListener!\n");
}
CORBA_exception_free (&ev);
}
void
pas_book_view_construct (PASBookView *book_view,
GNOME_Evolution_Addressbook_BookView corba_objref,
GNOME_Evolution_Addressbook_BookViewListener listener)
{
PASBookViewPrivate *priv;
CORBA_Environment ev;
g_return_if_fail (book_view != NULL);
g_return_if_fail (corba_objref != CORBA_OBJECT_NIL);
g_return_if_fail (listener != CORBA_OBJECT_NIL);
priv = book_view->priv;
g_return_if_fail (priv->corba_objref == CORBA_OBJECT_NIL);
priv->corba_objref = corba_objref;
CORBA_exception_init (&ev);
bonobo_object_dup_ref (listener, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning("Unable to duplicate & ref listener object in pas-book-view.c\n");
CORBA_exception_free (&ev);
return;
}
CORBA_exception_free (&ev);
priv->listener = listener;
}
static PASBookViewServant *
create_servant (PASBookView *factory)
{
PASBookViewServant *servant;
POA_GNOME_Evolution_Addressbook_BookView *corba_servant;
CORBA_Environment ev;
CORBA_exception_init (&ev);
servant = g_new0 (PASBookViewServant, 1);
corba_servant = (POA_GNOME_Evolution_Addressbook_BookView *) servant;
corba_servant->vepv = &pas_book_view_vepv;
POA_GNOME_Evolution_Addressbook_BookView__init ((PortableServer_Servant) corba_servant, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_free (servant);
CORBA_exception_free (&ev);
return NULL;
}
servant->object = factory;
CORBA_exception_free (&ev);
return servant;
}
static GNOME_Evolution_Addressbook_BookView
activate_servant (PASBookView *factory,
POA_GNOME_Evolution_Addressbook_BookView *servant)
{
GNOME_Evolution_Addressbook_BookView corba_object;
CORBA_Environment ev;
CORBA_exception_init (&ev);
CORBA_free (PortableServer_POA_activate_object (bonobo_poa (), servant, &ev));
corba_object = PortableServer_POA_servant_to_reference (bonobo_poa(), servant, &ev);
if (ev._major == CORBA_NO_EXCEPTION && ! CORBA_Object_is_nil (corba_object, &ev)) {
CORBA_exception_free (&ev);
return corba_object;
}
CORBA_exception_free (&ev);
return CORBA_OBJECT_NIL;
}
/**
* pas_book_view_new:
*/
PASBookView *
pas_book_view_new (GNOME_Evolution_Addressbook_BookViewListener listener)
{
PASBookView *book_view;
PASBookViewPrivate *priv;
GNOME_Evolution_Addressbook_BookView corba_objref;
book_view = g_object_new (PAS_TYPE_BOOK_VIEW, NULL);
priv = book_view->priv;
priv->servant = create_servant (book_view);
corba_objref = activate_servant (book_view, (POA_GNOME_Evolution_Addressbook_BookView*)priv->servant);
pas_book_view_construct (book_view, corba_objref, listener);
return book_view;
}
static void
pas_book_view_dispose (GObject *object)
{
PASBookView *book_view = PAS_BOOK_VIEW (object);
CORBA_Environment ev;
CORBA_exception_init (&ev);
bonobo_object_release_unref (book_view->priv->listener, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
CORBA_exception_free (&ev);
return;
}
CORBA_exception_free (&ev);
g_free (book_view->priv);
G_OBJECT_CLASS (pas_book_view_parent_class)->dispose (object);
}
static void
corba_class_init (PASBookViewClass *klass)
{
POA_GNOME_Evolution_Addressbook_BookView__vepv *vepv;
POA_GNOME_Evolution_Addressbook_BookView__epv *epv;
PortableServer_ServantBase__epv *base_epv;
base_epv = g_new0 (PortableServer_ServantBase__epv, 1);
base_epv->_private = NULL;
base_epv->finalize = NULL;
base_epv->default_POA = NULL;
epv = &klass->epv;
vepv = &pas_book_view_vepv;
vepv->_base_epv = base_epv;
vepv->GNOME_Evolution_Addressbook_BookView_epv = epv;
}
static void
pas_book_view_class_init (PASBookViewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
pas_book_view_parent_class = g_object_new (BONOBO_TYPE_OBJECT, NULL);
object_class->dispose = pas_book_view_dispose;
corba_class_init (klass);
}
static void
pas_book_view_init (PASBookView *book_view)
{
book_view->priv = g_new0 (PASBookViewPrivate, 1);
book_view->priv->listener = CORBA_OBJECT_NIL;
}
BONOBO_TYPE_FUNC_FULL (
PASBookView,
GNOME_Evolution_Addressbook_BookView,
BONOBO_TYPE_OBJECT,
pas_book_view);
|