~ubuntu-branches/ubuntu/maverick/libzeitgeist/maverick

« back to all changes in this revision

Viewing changes to src/eggzeitgeistindex.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-06-24 20:38:23 UTC
  • Revision ID: james.westby@ubuntu.com-20100624203823-7a6qwx798gz257mj
Tags: upstream-0.2.2
ImportĀ upstreamĀ versionĀ 0.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/* File: eggzeitgeistindex.c
 
3
 *
 
4
 * Generated by eggdbus-binding-tool 0.6. Do not edit.
 
5
 */
 
6
 
 
7
#ifdef HAVE_CONFIG_H
 
8
#  include "config.h"
 
9
#endif
 
10
#include <string.h>
 
11
#include <eggdbus/eggdbus.h>
 
12
#include "eggzeitgeistbindingstypes.h"
 
13
#include "eggzeitgeistbindings.h"
 
14
#include "eggzeitgeistbindingsmarshal.h"
 
15
#include "eggzeitgeistindex.h"
 
16
 
 
17
/**
 
18
 * SECTION:eggzeitgeistindex
 
19
 * @title: EggZeitgeistIndex
 
20
 * @short_description: FIXME: not documented.
 
21
 *
 
22
 * Do a full text search against the Zeitgeist FTS Extension. The time range and event templates are only used to filter the reulsts and will not affect the relevancy ranking.
 
23
 */
 
24
 
 
25
#define _EGG_ZEITGEIST_TYPE_INDEX_PROXY         (_egg_zeitgeist_index_proxy_get_type())
 
26
#define _EGG_ZEITGEIST_INDEX_PROXY(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), _EGG_ZEITGEIST_TYPE_INDEX_PROXY, _EggZeitgeistIndexProxy))
 
27
#define _EGG_ZEITGEIST_INDEX_PROXY_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), _EGG_ZEITGEIST_TYPE_INDEX_PROXY, _EggZeitgeistIndexProxy))
 
28
#define _EGG_ZEITGEIST_INDEX_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), _EGG_ZEITGEIST_TYPE_INDEX_PROXY, _EggZeitgeistIndexProxy))
 
29
#define _EGG_ZEITGEIST_IS_INDEX_PROXY(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), _EGG_ZEITGEIST_TYPE_INDEX_PROXY))
 
30
#define _EGG_ZEITGEIST_IS_INDEX_PROXY_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), _EGG_ZEITGEIST_TYPE_INDEX_PROXY))
 
31
 
 
32
typedef struct _EggZeitgeistIndexProxy _EggZeitgeistIndexProxy;
 
33
typedef struct _EggZeitgeistIndexProxyClass _EggZeitgeistIndexProxyClass;
 
34
 
 
35
struct _EggZeitgeistIndexProxy
 
36
{
 
37
  EggDBusInterfaceProxy parent_instance;
 
38
 
 
39
  EggDBusObjectProxy *object_proxy;
 
40
};
 
41
 
 
42
struct _EggZeitgeistIndexProxyClass
 
43
{
 
44
  EggDBusInterfaceProxyClass parent_class;
 
45
};
 
46
 
 
47
GType _egg_zeitgeist_index_proxy_get_type (void) G_GNUC_CONST;
 
48
 
 
49
static void
 
50
_proxy_interface_init (EggZeitgeistIndexIface *iface)
 
51
{
 
52
}
 
53
 
 
54
G_DEFINE_TYPE_WITH_CODE (_EggZeitgeistIndexProxy, _egg_zeitgeist_index_proxy, EGG_DBUS_TYPE_INTERFACE_PROXY,
 
55
                         G_IMPLEMENT_INTERFACE (EGG_ZEITGEIST_TYPE_INDEX, _proxy_interface_init));
 
56
 
 
57
static void
 
58
_egg_zeitgeist_index_proxy_init (_EggZeitgeistIndexProxy *interface_proxy)
 
59
{
 
60
}
 
61
 
 
62
static void
 
63
_egg_zeitgeist_index_proxy_object_proxy_finalized (gpointer data,
 
64
                                  GObject  *where_the_object_was)
 
65
{
 
66
  _EggZeitgeistIndexProxy *interface_proxy;
 
67
 
 
68
  interface_proxy = _EGG_ZEITGEIST_INDEX_PROXY (data);
 
69
 
 
70
  g_warning ("object_proxy for _EggZeitgeistIndexProxy finalized but interface proxy still alive; you are not supposed to be reffing instances derived from EggDBusInterfaceProxy");
 
71
 
 
72
  interface_proxy->object_proxy = NULL;
 
73
}
 
74
 
 
75
static void
 
76
_egg_zeitgeist_index_proxy_finalize (GObject *object)
 
77
{
 
78
  _EggZeitgeistIndexProxy *interface_proxy;
 
79
 
 
80
  interface_proxy = _EGG_ZEITGEIST_INDEX_PROXY (object);
 
81
 
 
82
  if (interface_proxy->object_proxy != NULL)
 
83
    g_object_weak_unref (G_OBJECT (interface_proxy->object_proxy), _egg_zeitgeist_index_proxy_object_proxy_finalized, interface_proxy);
 
84
 
 
85
  G_OBJECT_CLASS (_egg_zeitgeist_index_proxy_parent_class)->finalize (object);
 
86
}
 
87
 
 
88
static EggDBusObjectProxy *
 
89
_egg_zeitgeist_index_proxy_get_object_proxy (EggDBusInterfaceProxy *proxy)
 
90
{
 
91
  _EggZeitgeistIndexProxy *interface_proxy;
 
92
 
 
93
  interface_proxy = _EGG_ZEITGEIST_INDEX_PROXY (proxy);
 
94
 
 
95
  return interface_proxy->object_proxy;
 
96
}
 
97
 
 
98
static EggDBusInterfaceIface *
 
99
_egg_zeitgeist_index_proxy_get_interface_iface (EggDBusInterfaceProxy *proxy)
 
100
{
 
101
  return (EggDBusInterfaceIface *) (EGG_ZEITGEIST_INDEX_GET_IFACE (proxy));
 
102
}
 
103
 
 
104
static void
 
105
_egg_zeitgeist_index_proxy_class_init (_EggZeitgeistIndexProxyClass *klass)
 
106
{
 
107
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
 
108
  EggDBusInterfaceProxyClass *interface_proxy_class = EGG_DBUS_INTERFACE_PROXY_CLASS (klass);
 
109
 
 
110
  gobject_class->get_property = G_OBJECT_CLASS(g_type_class_peek_parent (klass))->get_property;
 
111
  gobject_class->set_property = G_OBJECT_CLASS(g_type_class_peek_parent (klass))->set_property;
 
112
  gobject_class->finalize = _egg_zeitgeist_index_proxy_finalize;
 
113
 
 
114
  interface_proxy_class->get_object_proxy    = _egg_zeitgeist_index_proxy_get_object_proxy;
 
115
  interface_proxy_class->get_interface_iface = _egg_zeitgeist_index_proxy_get_interface_iface;
 
116
 
 
117
};
 
118
 
 
119
static EggDBusInterfaceProxy *
 
120
_egg_zeitgeist_index_proxy_new (EggDBusObjectProxy *object_proxy)
 
121
{
 
122
  _EggZeitgeistIndexProxy *interface_proxy;
 
123
 
 
124
  interface_proxy = _EGG_ZEITGEIST_INDEX_PROXY (g_object_new (_EGG_ZEITGEIST_TYPE_INDEX_PROXY, NULL));
 
125
 
 
126
  interface_proxy->object_proxy = object_proxy;
 
127
  g_object_weak_ref (G_OBJECT (object_proxy), _egg_zeitgeist_index_proxy_object_proxy_finalized, interface_proxy);
 
128
 
 
129
  return EGG_DBUS_INTERFACE_PROXY (interface_proxy);
 
130
};
 
131
 
 
132
static const EggDBusInterfaceArgInfo arg_info_method_in_search[] =
 
133
{
 
134
  {
 
135
    "query",
 
136
    "s",
 
137
    NULL,
 
138
  },
 
139
  {
 
140
    "time_range",
 
141
    "(xx)",
 
142
    NULL,
 
143
  },
 
144
  {
 
145
    "event_templates",
 
146
    "a(asaasay)",
 
147
    NULL,
 
148
  },
 
149
  {
 
150
    "offset",
 
151
    "u",
 
152
    NULL,
 
153
  },
 
154
  {
 
155
    "num_events",
 
156
    "u",
 
157
    NULL,
 
158
  },
 
159
  {
 
160
    "result_type",
 
161
    "u",
 
162
    NULL,
 
163
  }
 
164
};
 
165
 
 
166
static const EggDBusInterfaceArgInfo arg_info_method_out_search[] =
 
167
{
 
168
  {
 
169
    "events",
 
170
    "a(asaasay)",
 
171
    NULL,
 
172
  },
 
173
  {
 
174
    "hit_count",
 
175
    "u",
 
176
    NULL,
 
177
  }
 
178
};
 
179
 
 
180
static const EggDBusInterfaceMethodInfo method_info[] =
 
181
{
 
182
  {
 
183
    "Search",
 
184
    "s(xx)a(asaasay)uuu",
 
185
    6,
 
186
    arg_info_method_in_search,
 
187
    "a(asaasay)u",
 
188
    2,
 
189
    arg_info_method_out_search,
 
190
    NULL
 
191
  }
 
192
};
 
193
 
 
194
static const EggDBusInterfaceInfo interface_info =
 
195
{
 
196
  "org.gnome.zeitgeist.Index",
 
197
  1,
 
198
  method_info,
 
199
  0,
 
200
  NULL,
 
201
  0,
 
202
  NULL,
 
203
  NULL,
 
204
};
 
205
 
 
206
static const EggDBusInterfaceInfo *
 
207
get_interface_info (void)
 
208
{
 
209
  return &interface_info;
 
210
}
 
211
 
 
212
static void handle_message     (EggDBusInterface        *interface,
 
213
                                EggDBusMessage          *message);
 
214
 
 
215
static void
 
216
base_init (gpointer g_iface)
 
217
{
 
218
  static gboolean is_initialized = FALSE;
 
219
 
 
220
  if (!is_initialized)
 
221
    {
 
222
      EggDBusInterfaceIface *gdbus_iface_vtable = (EggDBusInterfaceIface *) g_iface;
 
223
 
 
224
      egg_zeitgeist_bindings_get_error_domain_types ();
 
225
 
 
226
      gdbus_iface_vtable->get_interface_info  = get_interface_info;
 
227
      gdbus_iface_vtable->handle_message      = handle_message;
 
228
      gdbus_iface_vtable->get_interface_proxy = _egg_zeitgeist_index_proxy_new;
 
229
 
 
230
 
 
231
 
 
232
      is_initialized = TRUE;
 
233
    }
 
234
}
 
235
 
 
236
GType
 
237
egg_zeitgeist_index_get_type (void)
 
238
{
 
239
  static GType iface_type = 0;
 
240
 
 
241
  if (iface_type == 0)
 
242
    {
 
243
      static const GTypeInfo info =
 
244
      {
 
245
        sizeof (EggZeitgeistIndexIface),
 
246
        base_init,              /* base_init      */
 
247
        NULL,                   /* base_finalize  */
 
248
        NULL,                   /* class_init     */
 
249
        NULL,                   /* class_finalize */
 
250
        NULL,                   /* class_data     */
 
251
        0,                      /* instance_size  */
 
252
        0,                      /* n_preallocs    */
 
253
        NULL,                   /* instance_init  */
 
254
        NULL                    /* value_table    */
 
255
      };
 
256
 
 
257
      iface_type = g_type_register_static (G_TYPE_INTERFACE, "EggZeitgeistIndex", &info, 0);
 
258
 
 
259
      g_type_interface_add_prerequisite (iface_type, G_TYPE_OBJECT);
 
260
    }
 
261
 
 
262
  return iface_type;
 
263
}
 
264
 
 
265
static void
 
266
generic_async_callback (GObject *source_object,
 
267
                        GAsyncResult *res,
 
268
                        gpointer user_data)
 
269
{
 
270
  GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (user_data);
 
271
  EggDBusMessage *reply;
 
272
  GError *error;
 
273
 
 
274
  error = NULL;
 
275
  reply = egg_dbus_connection_send_message_with_reply_finish (EGG_DBUS_CONNECTION (source_object),
 
276
                                                              res,
 
277
                                                              &error);
 
278
  if (reply == NULL)
 
279
    {
 
280
      g_simple_async_result_set_from_error (simple, error);
 
281
      g_error_free (error);
 
282
    }
 
283
  else
 
284
    {
 
285
      g_simple_async_result_set_op_res_gpointer (simple, reply, (GDestroyNotify) g_object_unref);
 
286
    }
 
287
 
 
288
  g_simple_async_result_complete (simple);
 
289
  g_object_unref (simple);
 
290
}
 
291
 
 
292
/**
 
293
 * egg_zeitgeist_index_search:
 
294
 * @instance: A #EggZeitgeistIndex.
 
295
 * @call_flags: Flags from #EggDBusCallFlags detailing how the method should be invoked.
 
296
 * @query: FIXME: not documented.
 
297
 * @time_range: FIXME: not documented.
 
298
 * @event_templates: FIXME: not documented.
 
299
 * @offset: FIXME: not documented.
 
300
 * @num_events: FIXME: not documented.
 
301
 * @result_type: FIXME: not documented.
 
302
 * @cancellable: A #GCancellable or %NULL.
 
303
 * @callback: Callback to invoke when the reply is ready.
 
304
 * @user_data: User data to pass to @callback.
 
305
 *
 
306
 * FIXME: not documented.
 
307
 *
 
308
 * This function asynchronously invokes the <link linkend="eggdbus-method-org.gnome.zeitgeist.Index.Search">Search<!-- -->()</link> method
 
309
 * on the <link linkend="eggdbus-interface-org.gnome.zeitgeist.Index">org.gnome.zeitgeist.Index</link> interface
 
310
 * on the object represented by @instance.
 
311
 * When the reply is ready, @callback will be called (on the main thread).
 
312
 * You can then call egg_zeitgeist_index_search_finish() to get the result.
 
313
 * See egg_zeitgeist_index_search_sync() for the synchronous version of this function.
 
314
 *
 
315
 * Returns: A pending call id (never zero) that can be used with egg_dbus_connection_pending_call_cancel() or egg_dbus_connection_pending_call_block().
 
316
 */
 
317
guint
 
318
egg_zeitgeist_index_search (
 
319
    EggZeitgeistIndex *instance,
 
320
    EggDBusCallFlags call_flags,
 
321
    const gchar *_query,
 
322
    EggZeitgeistTimeRange *_time_range,
 
323
    EggDBusArraySeq *_event_templates,
 
324
    guint _offset,
 
325
    guint _num_events,
 
326
    EggZeitgeistResultType _result_type,
 
327
    GCancellable *cancellable,
 
328
    GAsyncReadyCallback callback,
 
329
    gpointer user_data)
 
330
{
 
331
  EggDBusObjectProxy *object_proxy;
 
332
  EggDBusMessage *message;
 
333
  GSimpleAsyncResult *simple;
 
334
  GError *error;
 
335
  guint pending_call_id;
 
336
 
 
337
  g_return_val_if_fail (EGG_ZEITGEIST_IS_INDEX (instance) && EGG_DBUS_IS_INTERFACE_PROXY (instance), 0);
 
338
 
 
339
  simple = g_simple_async_result_new (G_OBJECT (instance),
 
340
                                      callback,
 
341
                                      user_data,
 
342
                                      egg_zeitgeist_index_search);
 
343
 
 
344
  object_proxy = egg_dbus_interface_proxy_get_object_proxy (EGG_DBUS_INTERFACE_PROXY (instance));
 
345
 
 
346
  message = egg_dbus_connection_new_message_for_method_call (egg_dbus_object_proxy_get_connection (object_proxy),
 
347
                                                             NULL,
 
348
                                                             egg_dbus_object_proxy_get_name (object_proxy),
 
349
                                                             egg_dbus_object_proxy_get_object_path (object_proxy),
 
350
                                                             "org.gnome.zeitgeist.Index",
 
351
                                                             "Search");
 
352
 
 
353
  error = NULL;
 
354
 
 
355
  if (!egg_dbus_message_append_string (message, _query, &error))
 
356
    goto out;
 
357
  if (!egg_dbus_message_append_structure (message, EGG_DBUS_STRUCTURE (_time_range), &error))
 
358
    goto out;
 
359
  if (!egg_dbus_message_append_seq (message, _event_templates, "(asaasay)", &error))
 
360
    goto out;
 
361
  if (!egg_dbus_message_append_uint (message, _offset, &error))
 
362
    goto out;
 
363
  if (!egg_dbus_message_append_uint (message, _num_events, &error))
 
364
    goto out;
 
365
  if (!egg_dbus_message_append_uint (message, (EggZeitgeistResultType ) _result_type, &error))
 
366
    goto out;
 
367
 
 
368
  pending_call_id = egg_dbus_connection_send_message_with_reply (egg_dbus_object_proxy_get_connection (object_proxy), call_flags, message, egg_zeitgeist_bindings_get_error_domain_types (), cancellable, generic_async_callback, simple);
 
369
 
 
370
  g_object_unref (message);
 
371
  return pending_call_id;
 
372
out:
 
373
  g_simple_async_result_set_from_error (simple, error);
 
374
  g_simple_async_result_complete (simple);
 
375
  g_object_unref (simple);
 
376
  g_error_free (error);
 
377
  g_object_unref (message);
 
378
  return 0;
 
379
}
 
380
 
 
381
/**
 
382
 * egg_zeitgeist_index_search_finish:
 
383
 * @instance: A #EggZeitgeistIndex.
 
384
 * @out_events: FIXME: not documented. Free with g_object_unref().
 
385
 * @out_hit_count: FIXME: not documented.
 
386
 * @res: A #GAsyncResult obtained from the #GAsyncReadyCallback function passed to egg_zeitgeist_index_search().
 
387
 * @error: Return location for error.
 
388
 *
 
389
 * Finishes an asynchronous method invocation started with egg_zeitgeist_index_search().
 
390
 *
 
391
 * Returns: %TRUE if the method call succeeded, %FALSE if @error is set.
 
392
 */
 
393
gboolean
 
394
egg_zeitgeist_index_search_finish (
 
395
    EggZeitgeistIndex *instance,
 
396
    EggDBusArraySeq **_out_events,
 
397
    guint *_out_hit_count,
 
398
    GAsyncResult *res,
 
399
    GError **error)
 
400
{
 
401
  GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
 
402
  EggDBusMessage *reply;
 
403
  gboolean ret;
 
404
 
 
405
  g_return_val_if_fail (EGG_ZEITGEIST_IS_INDEX (instance) && EGG_DBUS_IS_INTERFACE_PROXY (instance), FALSE);
 
406
 
 
407
  g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == egg_zeitgeist_index_search);
 
408
 
 
409
  ret = FALSE;
 
410
  reply = NULL;
 
411
 
 
412
  if (g_simple_async_result_propagate_error (simple, error))
 
413
    goto out;
 
414
 
 
415
  reply = EGG_DBUS_MESSAGE (g_object_ref (g_simple_async_result_get_op_res_gpointer (simple)));
 
416
 
 
417
  if (reply == NULL)
 
418
    {
 
419
      g_simple_async_result_propagate_error (simple, error);
 
420
      goto out;
 
421
    }
 
422
 
 
423
  if (!egg_dbus_message_extract_seq (reply, _out_events, error))
 
424
    goto out;
 
425
  if (!egg_dbus_message_extract_uint (reply, _out_hit_count, error))
 
426
    goto out;
 
427
 
 
428
  ret = TRUE;
 
429
 
 
430
out:
 
431
  if (reply != NULL)
 
432
    g_object_unref (reply);
 
433
  return ret;
 
434
}
 
435
 
 
436
/**
 
437
 * egg_zeitgeist_index_search_sync:
 
438
 * @instance: A #EggZeitgeistIndex.
 
439
 * @call_flags: Flags from #EggDBusCallFlags detailing how the method should be invoked.
 
440
 * @query: FIXME: not documented.
 
441
 * @time_range: FIXME: not documented.
 
442
 * @event_templates: FIXME: not documented.
 
443
 * @offset: FIXME: not documented.
 
444
 * @num_events: FIXME: not documented.
 
445
 * @result_type: FIXME: not documented.
 
446
 * @out_events: FIXME: not documented. Free with g_object_unref().
 
447
 * @out_hit_count: FIXME: not documented.
 
448
 * @cancellable: A #GCancellable or %NULL.
 
449
 * @error: Return location for error.
 
450
 *
 
451
 * FIXME: not documented.
 
452
 *
 
453
 * This function synchronously invokes the <link linkend="eggdbus-method-org.gnome.zeitgeist.Index.Search">Search<!-- -->()</link> method on the <link linkend="eggdbus-interface-org.gnome.zeitgeist.Index">org.gnome.zeitgeist.Index</link> interface on the object represented by @instance.
 
454
 * See egg_zeitgeist_index_search() for the asynchronous version of this function.
 
455
 *
 
456
 * Returns: %TRUE if the method call succeeded, %FALSE if @error is set.
 
457
 */
 
458
gboolean
 
459
egg_zeitgeist_index_search_sync (
 
460
    EggZeitgeistIndex *instance,
 
461
    EggDBusCallFlags call_flags,
 
462
    const gchar *_query,
 
463
    EggZeitgeistTimeRange *_time_range,
 
464
    EggDBusArraySeq *_event_templates,
 
465
    guint _offset,
 
466
    guint _num_events,
 
467
    EggZeitgeistResultType _result_type,
 
468
    EggDBusArraySeq **_out_events,
 
469
    guint *_out_hit_count,
 
470
    GCancellable *cancellable,
 
471
    GError **error)
 
472
{
 
473
  EggDBusObjectProxy *object_proxy;
 
474
  EggDBusMessage *message;
 
475
  EggDBusMessage *reply;
 
476
  gboolean ret;
 
477
 
 
478
  g_return_val_if_fail (EGG_ZEITGEIST_IS_INDEX (instance) && EGG_DBUS_IS_INTERFACE_PROXY (instance), FALSE);
 
479
 
 
480
  ret = FALSE;  reply = NULL;
 
481
  object_proxy = egg_dbus_interface_proxy_get_object_proxy (EGG_DBUS_INTERFACE_PROXY (instance));
 
482
 
 
483
  message = egg_dbus_connection_new_message_for_method_call (egg_dbus_object_proxy_get_connection (object_proxy),
 
484
                                                             NULL,
 
485
                                                             egg_dbus_object_proxy_get_name (object_proxy),
 
486
                                                             egg_dbus_object_proxy_get_object_path (object_proxy),
 
487
                                                             "org.gnome.zeitgeist.Index",
 
488
                                                             "Search");
 
489
 
 
490
  if (!egg_dbus_message_append_string (message, _query, error))
 
491
    goto out;
 
492
  if (!egg_dbus_message_append_structure (message, EGG_DBUS_STRUCTURE (_time_range), error))
 
493
    goto out;
 
494
  if (!egg_dbus_message_append_seq (message, _event_templates, "(asaasay)", error))
 
495
    goto out;
 
496
  if (!egg_dbus_message_append_uint (message, _offset, error))
 
497
    goto out;
 
498
  if (!egg_dbus_message_append_uint (message, _num_events, error))
 
499
    goto out;
 
500
  if (!egg_dbus_message_append_uint (message, (EggZeitgeistResultType ) _result_type, error))
 
501
    goto out;
 
502
 
 
503
  reply = egg_dbus_connection_send_message_with_reply_sync (egg_dbus_object_proxy_get_connection (object_proxy), call_flags, message, egg_zeitgeist_bindings_get_error_domain_types (), cancellable, error);
 
504
  if (reply == NULL)
 
505
    goto out;
 
506
 
 
507
  if (!egg_dbus_message_extract_seq (reply, _out_events, error))
 
508
    goto out;
 
509
  if (!egg_dbus_message_extract_uint (reply, _out_hit_count, error))
 
510
    goto out;
 
511
 
 
512
  ret = TRUE;
 
513
 
 
514
out:
 
515
  if (message != NULL)
 
516
    g_object_unref (message);
 
517
  if (reply != NULL)
 
518
    g_object_unref (reply);
 
519
  return ret;
 
520
}
 
521
 
 
522
static void
 
523
handle_signal (EggDBusInterface *interface,
 
524
               EggDBusMessage   *message)
 
525
{
 
526
  g_warning ("%s: Ignoring unknown signal '%s' on interface '%s' with signature '%s'", G_STRFUNC, egg_dbus_message_get_signal_name (message), interface_info.name, egg_dbus_message_get_signature (message));
 
527
}
 
528
 
 
529
static void
 
530
handle_method_call (EggDBusInterface  *interface,
 
531
                    EggDBusMessage    *message)
 
532
{
 
533
  GError *error;
 
534
  const gchar *signature;
 
535
  const gchar *method_name;
 
536
  const gchar *expected_signature;
 
537
  EggZeitgeistIndexIface *iface;
 
538
  EggDBusMethodInvocation *method_invocation;
 
539
 
 
540
  error = NULL;
 
541
 
 
542
  signature = egg_dbus_message_get_signature (message);
 
543
  method_name = egg_dbus_message_get_method_name (message);
 
544
  iface = EGG_ZEITGEIST_INDEX_GET_IFACE (interface);
 
545
 
 
546
  if (strcmp (method_name, "Search") == 0)
 
547
    {
 
548
      gchar *_query;
 
549
      EggZeitgeistTimeRange *_time_range;
 
550
      EggDBusArraySeq *_event_templates;
 
551
      guint _offset;
 
552
      guint _num_events;
 
553
      EggZeitgeistResultType _result_type;
 
554
 
 
555
      expected_signature = "s(xx)a(asaasay)uuu";
 
556
      if (strcmp (signature, expected_signature) != 0)
 
557
        goto wrong_signature;
 
558
 
 
559
      if (iface->handle_search == NULL)
 
560
        goto not_implemented;
 
561
 
 
562
      if (!egg_dbus_message_extract_string (message, &_query, &error))
 
563
        goto extraction_error;
 
564
      if (!egg_dbus_message_extract_structure (message, (EggDBusStructure **) &_time_range, &error))
 
565
        goto extraction_error;
 
566
      if (!egg_dbus_message_extract_seq (message, &_event_templates, &error))
 
567
        goto extraction_error;
 
568
      if (!egg_dbus_message_extract_uint (message, &_offset, &error))
 
569
        goto extraction_error;
 
570
      if (!egg_dbus_message_extract_uint (message, &_num_events, &error))
 
571
        goto extraction_error;
 
572
      {
 
573
        EggZeitgeistResultType temp_value;
 
574
        if (!egg_dbus_message_extract_uint (message, &temp_value, &error))
 
575
          goto extraction_error;
 
576
        _result_type = (EggZeitgeistResultType ) temp_value;
 
577
      }
 
578
 
 
579
      method_invocation = egg_dbus_method_invocation_new (message,
 
580
                                                          egg_zeitgeist_index_handle_search_finish);
 
581
 
 
582
      egg_dbus_method_invocation_add_destroy_notify (method_invocation,
 
583
                                                   _query,
 
584
                                                   (GDestroyNotify) g_free);
 
585
      egg_dbus_method_invocation_add_destroy_notify (method_invocation,
 
586
                                                   _time_range,
 
587
                                                   (GDestroyNotify) g_object_unref);
 
588
      egg_dbus_method_invocation_add_destroy_notify (method_invocation,
 
589
                                                   _event_templates,
 
590
                                                   (GDestroyNotify) g_object_unref);
 
591
 
 
592
      iface->handle_search (EGG_ZEITGEIST_INDEX (interface), _query, _time_range, _event_templates, _offset, _num_events, _result_type, method_invocation);
 
593
 
 
594
    }
 
595
  else
 
596
    {
 
597
      g_warning ("%s: Ignoring unknown method call '%s' on interface '%s' with signature '%s'", G_STRFUNC, method_name, interface_info.name, signature);
 
598
    }
 
599
 
 
600
  return;
 
601
 
 
602
not_implemented:
 
603
  g_warning ("%s: Method call '%s' on interface '%s' with signature '%s' is not implemented on GObject class %s", G_STRFUNC, method_name, interface_info.name, signature, g_type_name (G_TYPE_FROM_INSTANCE (interface)));
 
604
  return;
 
605
 
 
606
wrong_signature:
 
607
  g_warning ("%s: Ignoring method call '%s' on interface '%s' with malformed signature '%s', expected signature '%s'", G_STRFUNC, method_name, interface_info.name, signature, expected_signature);
 
608
  return;
 
609
 
 
610
extraction_error:
 
611
  g_warning ("%s: Error extracting arguments for method call '%s' on interface '%s' with signature '%s': %s", G_STRFUNC, method_name, interface_info.name, signature, error->message);
 
612
  g_error_free (error);
 
613
}
 
614
 
 
615
/**
 
616
 * egg_zeitgeist_index_handle_search_finish:
 
617
 * @events: FIXME: not documented.
 
618
 * @hit_count: FIXME: not documented.
 
619
 * @method_invocation: A #EggDBusMethodInvocation.
 
620
 *
 
621
 * Function to be called by implementers of the
 
622
 * <link linkend="eggdbus-interface-org.gnome.zeitgeist.Index">org.gnome.zeitgeist.Index</link>
 
623
 * D-Bus interface to finish handling the
 
624
 * <link linkend="eggdbus-method-org.gnome.zeitgeist.Index.Search">Search<!-- -->()</link> method.
 
625
 *
 
626
 */
 
627
void
 
628
egg_zeitgeist_index_handle_search_finish (
 
629
    EggDBusMethodInvocation *method_invocation,
 
630
    EggDBusArraySeq *_out_events,
 
631
    guint _out_hit_count)
 
632
{
 
633
  GError *error;
 
634
  EggDBusMessage *reply;
 
635
 
 
636
  error = NULL;
 
637
 
 
638
  g_warn_if_fail (egg_dbus_method_invocation_get_source_tag (method_invocation) ==
 
639
                  egg_zeitgeist_index_handle_search_finish);
 
640
 
 
641
  reply = egg_dbus_method_invocation_create_reply_message (method_invocation);
 
642
 
 
643
  if (!egg_dbus_message_append_seq (reply, _out_events, "(asaasay)", &error))
 
644
    goto malformed;
 
645
  if (!egg_dbus_message_append_uint (reply, _out_hit_count, &error))
 
646
    goto malformed;
 
647
 
 
648
  egg_dbus_connection_send_message (egg_dbus_message_get_connection (reply), reply);
 
649
 
 
650
  g_object_unref (reply);
 
651
  g_object_unref (method_invocation);
 
652
 
 
653
  return;
 
654
 
 
655
malformed:
 
656
  g_warning ("%s: Malformed data passed: %s", G_STRFUNC, error->message);
 
657
  g_error_free (error);
 
658
}
 
659
 
 
660
static void
 
661
handle_message (EggDBusInterface *interface,
 
662
                EggDBusMessage   *message)
 
663
{
 
664
 
 
665
  switch (egg_dbus_message_get_message_type (message))
 
666
    {
 
667
    case EGG_DBUS_MESSAGE_TYPE_SIGNAL:
 
668
      handle_signal (interface, message);
 
669
      break;
 
670
 
 
671
    case EGG_DBUS_MESSAGE_TYPE_METHOD_CALL:
 
672
      handle_method_call (interface, message);
 
673
      break;
 
674
 
 
675
    default:
 
676
      g_assert_not_reached ();
 
677
      break;
 
678
    }
 
679
}
 
680