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
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Author:
* Nat Friedman (nat@ximian.com)
*
* Copyright 2000, Ximian, Inc.
*/
#include <config.h>
#include "pas-backend.h"
#include "pas-marshal.h"
/* Signal IDs */
enum {
LAST_CLIENT_GONE,
LAST_SIGNAL
};
static guint pas_backend_signals[LAST_SIGNAL];
gboolean
pas_backend_construct (PASBackend *backend)
{
return TRUE;
}
GNOME_Evolution_Addressbook_BookListener_CallStatus
pas_backend_load_uri (PASBackend *backend,
const char *uri)
{
g_return_val_if_fail (backend != NULL, FALSE);
g_return_val_if_fail (PAS_IS_BACKEND (backend), FALSE);
g_return_val_if_fail (uri != NULL, FALSE);
g_assert (PAS_BACKEND_GET_CLASS (backend)->load_uri != NULL);
return (* PAS_BACKEND_GET_CLASS (backend)->load_uri) (backend, uri);
}
/**
* pas_backend_get_uri:
* @backend: An addressbook backend.
*
* Queries the URI that an addressbook backend is serving.
*
* Return value: URI for the backend.
**/
const char *
pas_backend_get_uri (PASBackend *backend)
{
g_return_val_if_fail (backend != NULL, NULL);
g_return_val_if_fail (PAS_IS_BACKEND (backend), NULL);
g_assert (PAS_BACKEND_GET_CLASS (backend)->get_uri != NULL);
return (* PAS_BACKEND_GET_CLASS (backend)->get_uri) (backend);
}
/**
* pas_backend_add_client:
* @backend: An addressbook backend.
* @listener: Listener for notification to the client.
*
* Adds a client to an addressbook backend.
*
* Return value: TRUE on success, FALSE on failure to add the client.
*/
gboolean
pas_backend_add_client (PASBackend *backend,
GNOME_Evolution_Addressbook_BookListener listener)
{
g_return_val_if_fail (backend != NULL, FALSE);
g_return_val_if_fail (PAS_IS_BACKEND (backend), FALSE);
g_return_val_if_fail (listener != CORBA_OBJECT_NIL, FALSE);
g_assert (PAS_BACKEND_GET_CLASS (backend)->add_client != NULL);
return PAS_BACKEND_GET_CLASS (backend)->add_client (backend, listener);
}
void
pas_backend_remove_client (PASBackend *backend,
PASBook *book)
{
g_return_if_fail (backend != NULL);
g_return_if_fail (PAS_IS_BACKEND (backend));
g_return_if_fail (book != NULL);
g_return_if_fail (PAS_IS_BOOK (book));
g_assert (PAS_BACKEND_GET_CLASS (backend)->remove_client != NULL);
PAS_BACKEND_GET_CLASS (backend)->remove_client (backend, book);
}
char *
pas_backend_get_static_capabilities (PASBackend *backend)
{
g_return_val_if_fail (backend != NULL, NULL);
g_return_val_if_fail (PAS_IS_BACKEND (backend), NULL);
g_assert (PAS_BACKEND_GET_CLASS (backend)->get_static_capabilities != NULL);
return PAS_BACKEND_GET_CLASS (backend)->get_static_capabilities (backend);
}
/**
* pas_backend_last_client_gone:
* @backend: An addressbook backend.
*
* Emits the "last_client_gone" signal for the specified backend. Should
* only be called from backend implementations if the backend really does
* not have any more clients.
**/
void
pas_backend_last_client_gone (PASBackend *backend)
{
g_return_if_fail (backend != NULL);
g_return_if_fail (PAS_IS_BACKEND (backend));
g_signal_emit (backend, pas_backend_signals[LAST_CLIENT_GONE], 0);
}
static void
pas_backend_init (PASBackend *backend)
{
}
static void
pas_backend_class_init (PASBackendClass *klass)
{
GObjectClass *object_class;
object_class = (GObjectClass *) klass;
klass->add_client = NULL;
klass->remove_client = NULL;
klass->get_static_capabilities = NULL;
pas_backend_signals[LAST_CLIENT_GONE] =
g_signal_new ("last_client_gone",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (PASBackendClass, last_client_gone),
NULL, NULL,
pas_marshal_NONE__NONE,
G_TYPE_NONE, 0);
}
/**
* pas_backend_get_type:
*/
GType
pas_backend_get_type (void)
{
static GType type = 0;
if (! type) {
GTypeInfo info = {
sizeof (PASBackendClass),
NULL, /* base_class_init */
NULL, /* base_class_finalize */
(GClassInitFunc) pas_backend_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (PASBackend),
0, /* n_preallocs */
(GInstanceInitFunc) pas_backend_init
};
type = g_type_register_static (G_TYPE_OBJECT, "PASBackend", &info, 0);
}
return type;
}
|