~ubuntu-branches/ubuntu/quantal/cairo-dock-plug-ins/quantal-201208191523

« back to all changes in this revision

Viewing changes to Recent-Events/src/applet-search.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2011-04-20 20:46:51 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20110420204651-ftnpzesj6uc7qeul
Tags: 2.3.0~1-0ubuntu1
* New Upstream Version (LP: #723995)
* Upstream short ChangeLog (since 2.3.0~0rc1):
 - Updated translations
 - Updated the integration of the new versions of kwin and compiz
    (Switcher, ShowDesktop, etc.)
 - Removed a lot of useless g_print
 - Updated a few plug-ins to fit with the new version of the API (gldit)
 - Fixed a few bugs
 - Updated MeMenu, MessagingMenu and Status-Notifier to works
    with the latest version of dbusmenu, etc.
* Switch to dpkg-source 3.0 (quilt) format
* debian/cairo-dock-plug-ins.install:
 - Added new files (interfaces for python, ruby, vala and mono)
* debian/control:
 - Added new dependences for new applets (sensors and zeitgeist)
    and new interfaces (python, valac, ruby and mono)
 - Updated the version of cairo-dock build-dependences
* debian/rules:
 - Added a new CMake flag to install python interface in debian/tmp
* Updated debian/watch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
* This file is a part of the Cairo-Dock project
 
3
*
 
4
* Copyright : (C) see the 'copyright' file.
 
5
* E-mail    : see the 'copyright' file.
 
6
*
 
7
* This program is free software; you can redistribute it and/or
 
8
* modify it under the terms of the GNU General Public License
 
9
* as published by the Free Software Foundation; either version 3
 
10
* of the License, or (at your option) any later version.
 
11
*
 
12
* This program is distributed in the hope that it will be useful,
 
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
* GNU General Public License for more details.
 
16
* You should have received a copy of the GNU General Public License
 
17
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
*/
 
19
 
 
20
#include <stdlib.h>
 
21
#include <string.h>
 
22
 
 
23
#include <zeitgeist.h>
 
24
 
 
25
#include "applet-struct.h"
 
26
#include "applet-search.h"
 
27
 
 
28
 
 
29
static ZeitgeistEvent *_get_event_template_for_category (CDEventType iCategory)
 
30
{
 
31
        if (myData.pEvents == NULL)
 
32
        {
 
33
                myData.pEvents = g_new0 (ZeitgeistEvent*, CD_NB_EVENT_TYPES);
 
34
                
 
35
                ZeitgeistSubject *subj;
 
36
                subj = zeitgeist_subject_new_full ("",  // any type of uri.
 
37
                        "",  // interpretation
 
38
                        "",  // manifestation (ZEITGEIST_NFO_FILE_DATA_OBJECT/ZEITGEIST_NFO_REMOTE_DATA_OBJECT)
 
39
                        "",  // mimetype
 
40
                        "",  // origin
 
41
                        "",  // text
 
42
                        "");  // storage
 
43
                myData.pEvents[CD_EVENT_ALL] = zeitgeist_event_new_full (
 
44
                        ZEITGEIST_ZG_ACCESS_EVENT,  // interpretation type of the event (ZEITGEIST_ZG_EVENT_INTERPRETATION)
 
45
                        ZEITGEIST_ZG_USER_ACTIVITY,  // manifestation type of the event (ZEITGEIST_ZG_EVENT_MANIFESTATION)
 
46
                        "",  // actor (the party responsible for triggering the event, eg: app://firefox.desktop)
 
47
                        subj,  // a list of subjects
 
48
                        NULL);  // terminated with NULL
 
49
                
 
50
                subj = zeitgeist_subject_new_full ("file://*",  // uri, application://* for apps
 
51
                        ZEITGEIST_NFO_DOCUMENT,  // interpretation
 
52
                        ZEITGEIST_NFO_FILE_DATA_OBJECT,  // manifestation
 
53
                        "",  // mimetype
 
54
                        "",  // origin
 
55
                        "",  // text
 
56
                        "");  // storage
 
57
                myData.pEvents[CD_EVENT_DOCUMENT] = zeitgeist_event_new_full (
 
58
                        ZEITGEIST_ZG_ACCESS_EVENT,  // interpretation type of the event (ZEITGEIST_ZG_EVENT_INTERPRETATION)
 
59
                        ZEITGEIST_ZG_USER_ACTIVITY,  // manifestation type of the event (ZEITGEIST_ZG_EVENT_MANIFESTATION)
 
60
                        "",  // actor (the party responsible for triggering the event, eg: app://firefox.desktop)
 
61
                        subj,  // a list of subjects
 
62
                        NULL);  // terminated with NULL
 
63
                
 
64
                /**subj = zeitgeist_subject_new_full ("file://*",  // uri, application://* for apps
 
65
                        ZEITGEIST_NFO_FOLDER,  // interpretation
 
66
                        ZEITGEIST_NFO_FILE_DATA_OBJECT,  // manifestation
 
67
                        "",  // mimetype
 
68
                        "",  // origin
 
69
                        "",  // text
 
70
                        "");  // storage
 
71
                myData.pEvents[CD_EVENT_FOLDER] = zeitgeist_event_new_full (
 
72
                        ZEITGEIST_ZG_ACCESS_EVENT,  // interpretation type of the event (ZEITGEIST_ZG_EVENT_INTERPRETATION)
 
73
                        ZEITGEIST_ZG_USER_ACTIVITY,  // manifestation type of the event (ZEITGEIST_ZG_EVENT_MANIFESTATION)
 
74
                        "",  // actor (the party responsible for triggering the event, eg: app://firefox.desktop)
 
75
                        subj,  // a list of subjects
 
76
                        NULL);  // terminated with NULL*/
 
77
                
 
78
                subj = zeitgeist_subject_new_full ("file://*",  // uri, application://* for apps
 
79
                        ZEITGEIST_NFO_IMAGE,  // interpretation
 
80
                        ZEITGEIST_NFO_FILE_DATA_OBJECT,  // manifestation
 
81
                        "",  // mimetype
 
82
                        "",  // origin
 
83
                        "",  // text
 
84
                        "");  // storage
 
85
                myData.pEvents[CD_EVENT_IMAGE] = zeitgeist_event_new_full (
 
86
                        ZEITGEIST_ZG_ACCESS_EVENT,  // interpretation type of the event (ZEITGEIST_ZG_EVENT_INTERPRETATION)
 
87
                        ZEITGEIST_ZG_USER_ACTIVITY,  // manifestation type of the event (ZEITGEIST_ZG_EVENT_MANIFESTATION)
 
88
                        "",  // actor (the party responsible for triggering the event, eg: app://firefox.desktop)
 
89
                        subj,  // a list of subjects
 
90
                        NULL);  // terminated with NULL
 
91
                
 
92
                subj = zeitgeist_subject_new_full ("file://*",  // uri, application://* for apps
 
93
                        ZEITGEIST_NFO_AUDIO,  // interpretation
 
94
                        ZEITGEIST_NFO_FILE_DATA_OBJECT,  // manifestation
 
95
                        "",  // mimetype
 
96
                        "",  // origin
 
97
                        "",  // text
 
98
                        "");  // storage
 
99
                myData.pEvents[CD_EVENT_AUDIO] = zeitgeist_event_new_full (
 
100
                        ZEITGEIST_ZG_ACCESS_EVENT,  // interpretation type of the event (ZEITGEIST_ZG_EVENT_INTERPRETATION)
 
101
                        ZEITGEIST_ZG_USER_ACTIVITY,  // manifestation type of the event (ZEITGEIST_ZG_EVENT_MANIFESTATION)
 
102
                        "",  // actor (the party responsible for triggering the event, eg: app://firefox.desktop)
 
103
                        subj,  // a list of subjects
 
104
                        NULL);  // terminated with NULL
 
105
                
 
106
                subj = zeitgeist_subject_new_full ("file://*",  // uri, application://* for apps
 
107
                        ZEITGEIST_NFO_VIDEO,  // interpretation
 
108
                        ZEITGEIST_NFO_FILE_DATA_OBJECT,  // manifestation
 
109
                        "",  // mimetype
 
110
                        "",  // origin
 
111
                        "",  // text
 
112
                        "");  // storage
 
113
                myData.pEvents[CD_EVENT_VIDEO] = zeitgeist_event_new_full (
 
114
                        ZEITGEIST_ZG_ACCESS_EVENT,  // interpretation type of the event (ZEITGEIST_ZG_EVENT_INTERPRETATION)
 
115
                        ZEITGEIST_ZG_USER_ACTIVITY,  // manifestation type of the event (ZEITGEIST_ZG_EVENT_MANIFESTATION)
 
116
                        "",  // actor (the party responsible for triggering the event, eg: app://firefox.desktop)
 
117
                        subj,  // a list of subjects
 
118
                        NULL);  // terminated with NULL
 
119
                
 
120
                subj = zeitgeist_subject_new_full ("",  // url
 
121
                        ZEITGEIST_NFO_WEBSITE,  // interpretation
 
122
                        ZEITGEIST_NFO_REMOTE_DATA_OBJECT,  // manifestation
 
123
                        "",  // mimetype
 
124
                        "",  // origin
 
125
                        "",  // text
 
126
                        "");  // storage
 
127
                myData.pEvents[CD_EVENT_WEB] = zeitgeist_event_new_full (
 
128
                        ZEITGEIST_ZG_ACCESS_EVENT,  // interpretation type of the event (ZEITGEIST_ZG_EVENT_INTERPRETATION)
 
129
                        ZEITGEIST_ZG_USER_ACTIVITY,  // manifestation type of the event (ZEITGEIST_ZG_EVENT_MANIFESTATION)
 
130
                        "",  // actor (the party responsible for triggering the event, eg: app://firefox.desktop)
 
131
                        subj,  // a list of subjects
 
132
                        NULL);  // terminated with NULL
 
133
                
 
134
                subj = zeitgeist_subject_new_full ("file://*",  // uri, application://* for apps
 
135
                        "!"ZEITGEIST_NFO_DOCUMENT,  // interpretation
 
136
                        "",  // manifestation
 
137
                        "",  // mimetype
 
138
                        "",  // origin
 
139
                        "",  // text
 
140
                        "");  // storage
 
141
                myData.pEvents[CD_EVENT_OTHER] = zeitgeist_event_new_full (
 
142
                        ZEITGEIST_ZG_ACCESS_EVENT,  // interpretation type of the event (ZEITGEIST_ZG_EVENT_INTERPRETATION)
 
143
                        ZEITGEIST_ZG_USER_ACTIVITY,  // manifestation type of the event (ZEITGEIST_ZG_EVENT_MANIFESTATION)
 
144
                        "",  // actor (the party responsible for triggering the event, eg: app://firefox.desktop)
 
145
                        subj,  // a list of subjects
 
146
                        NULL);  // terminated with NULL
 
147
                /**subj = zeitgeist_subject_new_full ("",  // uri, application://* for apps
 
148
                        "!"ZEITGEIST_NFO_FOLDER,  // interpretation
 
149
                        "",  // manifestation
 
150
                        "",  // mimetype
 
151
                        "",  // origin
 
152
                        "",  // text
 
153
                        "");  // storage
 
154
                zeitgeist_event_add_subject (myData.pEvents[CD_EVENT_OTHER], subj);*/
 
155
                subj = zeitgeist_subject_new_full ("",  // uri, application://* for apps
 
156
                        "!"ZEITGEIST_NFO_IMAGE,  // interpretation
 
157
                        "",  // manifestation
 
158
                        "",  // mimetype
 
159
                        "",  // origin
 
160
                        "",  // text
 
161
                        "");  // storage
 
162
                zeitgeist_event_add_subject (myData.pEvents[CD_EVENT_OTHER], subj);
 
163
                subj = zeitgeist_subject_new_full ("",  // uri, application://* for apps
 
164
                        "!"ZEITGEIST_NFO_AUDIO,  // interpretation
 
165
                        "",  // manifestation
 
166
                        "",  // mimetype
 
167
                        "",  // origin
 
168
                        "",  // text
 
169
                        "");  // storage
 
170
                zeitgeist_event_add_subject (myData.pEvents[CD_EVENT_OTHER], subj);
 
171
                subj = zeitgeist_subject_new_full ("",  // uri, application://* for apps
 
172
                        "!"ZEITGEIST_NFO_VIDEO,  // interpretation
 
173
                        "",  // manifestation
 
174
                        "",  // mimetype
 
175
                        "",  // origin
 
176
                        "",  // text
 
177
                        "");  // storage
 
178
                zeitgeist_event_add_subject (myData.pEvents[CD_EVENT_OTHER], subj);
 
179
        }
 
180
        
 
181
        g_return_val_if_fail (iCategory < CD_NB_EVENT_TYPES, NULL);
 
182
        g_object_ref (myData.pEvents[iCategory]);
 
183
        return myData.pEvents[iCategory];
 
184
}
 
185
 
 
186
 
 
187
static void on_related_events_received (ZeitgeistLog  *log, GAsyncResult *res, gpointer *user_data)
 
188
{
 
189
        ZeitgeistResultSet *events;
 
190
        GError *error = NULL;
 
191
        CDOnGetEventsFunc pCallback = user_data[0];
 
192
        gpointer data = user_data[1];
 
193
        
 
194
        events = zeitgeist_log_find_events_finish (log, res, &error);
 
195
        if (error)
 
196
        {
 
197
                cd_warning ("Error reading results: %s", error->message);
 
198
                g_error_free (error);
 
199
                return;
 
200
        }
 
201
        cd_debug ("Got %i events:", zeitgeist_result_set_size (events));
 
202
        
 
203
        if (zeitgeist_result_set_has_next (events))
 
204
                pCallback (events, data);
 
205
        g_object_unref (events);
 
206
}
 
207
void cd_find_recent_related_files (const gchar **cMimeTypes, CDOnGetEventsFunc pCallback, gpointer data)  // right-click on a launcher/appli
 
208
{
 
209
        cd_debug ("%s ()", __func__);
 
210
        static gpointer s_data[2];
 
211
        s_data[0] = pCallback;
 
212
        s_data[1] = data;
 
213
        
 
214
        GPtrArray* zg_templates = g_ptr_array_sized_new (10);
 
215
        int i;
 
216
        for (i = 0; cMimeTypes[i] != NULL; i ++)
 
217
        {
 
218
                ZeitgeistSubject *subj = zeitgeist_subject_new_full ("file:*",  // uri, application://* for apps
 
219
                        "",  // interpretation
 
220
                        "",  // manifestation
 
221
                        cMimeTypes[i],  // mimetype
 
222
                        "",  // origin
 
223
                        "",  // text
 
224
                        "");  // storage
 
225
                ZeitgeistEvent* ev = zeitgeist_event_new_full (
 
226
                        ZEITGEIST_ZG_ACCESS_EVENT,  // interpretation type of the event (ZEITGEIST_ZG_EVENT_INTERPRETATION)
 
227
                        ZEITGEIST_ZG_USER_ACTIVITY,  // manifestation type of the event (ZEITGEIST_ZG_EVENT_MANIFESTATION)
 
228
                        "",  // actor (the party responsible for triggering the event, eg: app://firefox.desktop)
 
229
                        subj, NULL);  // a list of subjects, terminated with NULL
 
230
                g_ptr_array_add (zg_templates, ev);
 
231
        }
 
232
        
 
233
        if (myData.pLog == NULL)
 
234
                myData.pLog = zeitgeist_log_new ();
 
235
        
 
236
        zeitgeist_log_find_events (myData.pLog,
 
237
                zeitgeist_time_range_new_to_now (),
 
238
                zg_templates,
 
239
                ZEITGEIST_STORAGE_STATE_ANY,
 
240
                myConfig.iNbRelatedFilesMax,
 
241
                ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS,  // MOST_RECENT_ORIGIN for folders
 
242
                (GCancellable *)NULL,
 
243
                (GAsyncReadyCallback)on_related_events_received,
 
244
                s_data);
 
245
}
 
246
 
 
247
 
 
248
static void on_recent_events_received (ZeitgeistLog  *log, GAsyncResult *res, gpointer *user_data)
 
249
{
 
250
        ZeitgeistResultSet *events;
 
251
        GError *error = NULL;
 
252
        CDOnGetEventsFunc pCallback = user_data[0];
 
253
        gpointer data = user_data[1];
 
254
        
 
255
        events = zeitgeist_log_find_events_finish (log, res, &error);
 
256
        if (error)
 
257
        {
 
258
                g_warning ("Error reading results: %s", error->message);
 
259
                g_error_free (error);
 
260
                return;
 
261
        }
 
262
        
 
263
        cd_debug ("Got %i events:", zeitgeist_result_set_size (events));
 
264
        
 
265
        if (zeitgeist_result_set_has_next (events))
 
266
                pCallback (events, data);
 
267
        g_object_unref (events);        
 
268
}
 
269
void cd_find_recent_events (CDEventType iEventType, int iSortType, CDOnGetEventsFunc pCallback, gpointer data)  // sorted by date or frequency, click on the icon
 
270
{
 
271
        static gpointer s_data[2];
 
272
        s_data[0] = pCallback;
 
273
        s_data[1] = data;
 
274
        
 
275
        ZeitgeistEvent *ev;
 
276
        ZeitgeistSubject *subj;
 
277
        ev = _get_event_template_for_category (iEventType);
 
278
        
 
279
        GPtrArray* zg_templates = g_ptr_array_sized_new (1);
 
280
        g_ptr_array_add (zg_templates, ev);
 
281
        
 
282
        if (myData.pLog == NULL)
 
283
                myData.pLog = zeitgeist_log_new ();
 
284
        
 
285
        zeitgeist_log_find_events (myData.pLog,
 
286
                zeitgeist_time_range_new_to_now (),
 
287
                zg_templates,
 
288
                ZEITGEIST_STORAGE_STATE_ANY,
 
289
                myConfig.iNbResultsMax,
 
290
                iSortType == 0 ? ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS : ZEITGEIST_RESULT_TYPE_MOST_POPULAR_SUBJECTS,
 
291
                (GCancellable *)NULL,
 
292
                (GAsyncReadyCallback)on_recent_events_received,
 
293
                s_data);
 
294
}
 
295
 
 
296
 
 
297
static void on_events_received (ZeitgeistIndex *index, GAsyncResult *res, gpointer *user_data)
 
298
{
 
299
        ZeitgeistResultSet *events;
 
300
        GError *error = NULL;
 
301
        CDOnGetEventsFunc pCallback = user_data[0];
 
302
        gpointer data = user_data[1];
 
303
        
 
304
        events = zeitgeist_index_search_finish (index, res, &error);
 
305
        if (error)
 
306
        {
 
307
                g_warning ("Error reading results: %s", error->message);
 
308
                g_error_free (error);
 
309
                return;
 
310
        }
 
311
        
 
312
        cd_message ("Got %i events:", zeitgeist_result_set_size (events));
 
313
        
 
314
        if (zeitgeist_result_set_has_next (events))
 
315
                pCallback (events, data);
 
316
        g_object_unref (events);
 
317
}
 
318
void cd_search_events (const gchar *cQuery, CDEventType iEventType, CDOnGetEventsFunc pCallback, gpointer data)  // dialog box on middle-click
 
319
{
 
320
        static gpointer s_data[2];
 
321
        s_data[0] = pCallback;
 
322
        s_data[1] = data;
 
323
        
 
324
        if (myData.pIndex == NULL)
 
325
                myData.pIndex = zeitgeist_index_new ();
 
326
        
 
327
        cd_debug ("Searching for '%s'...", cQuery);
 
328
        
 
329
        GPtrArray* zg_templates = g_ptr_array_sized_new (1);
 
330
        ZeitgeistEvent *ev = _get_event_template_for_category (iEventType);
 
331
        g_ptr_array_add (zg_templates, ev);
 
332
        zeitgeist_index_search (myData.pIndex,
 
333
                cQuery,
 
334
                zeitgeist_time_range_new_anytime (),
 
335
                zg_templates,
 
336
                0,  // offset
 
337
                myConfig.iNbResultsMax,  // number of events
 
338
                ZEITGEIST_RESULT_TYPE_RELEVANCY,  // sorting type
 
339
                (GCancellable*)NULL,
 
340
                (GAsyncReadyCallback)on_events_received,
 
341
                s_data);  // data
 
342
}
 
343
 
 
344
 
 
345
static void on_delete_events (ZeitgeistLog *log, GAsyncResult *res, gpointer *user_data)
 
346
{
 
347
        cd_debug ("events deleted");
 
348
        CDOnDeleteEventsFunc pCallback = user_data[0];
 
349
        gpointer data = user_data[1];
 
350
        int iNbEvents = GPOINTER_TO_INT (user_data[2]);
 
351
        
 
352
        GError *error = NULL;
 
353
        gboolean bSuccess = zeitgeist_log_delete_events_finish (log, res, &error);
 
354
        if (error)
 
355
        {
 
356
                cd_warning ("Error deleting log: %s", error->message);
 
357
                g_error_free (error);
 
358
                pCallback (0, data);
 
359
        }
 
360
        else
 
361
        {
 
362
                pCallback (iNbEvents, data);
 
363
        }
 
364
}
 
365
static void on_deleting_event_received (ZeitgeistLog *log, GAsyncResult *res, gpointer *user_data)
 
366
{
 
367
        CDOnDeleteEventsFunc pCallback = user_data[0];
 
368
        gpointer data = user_data[1];
 
369
        
 
370
        GError *error = NULL;
 
371
        GArray *event_ids = zeitgeist_log_find_event_ids_finish (log, res, &error);
 
372
        cd_debug ("got %d events", event_ids->len);
 
373
        if (error)
 
374
        {
 
375
                cd_warning ("Error finding in log: %s", error->message);
 
376
                g_error_free (error);
 
377
                pCallback (0, data);
 
378
                return;
 
379
        }
 
380
        // delete events IDs
 
381
        user_data[2] = GINT_TO_POINTER (event_ids->len);
 
382
        zeitgeist_log_delete_events (log,
 
383
                event_ids,
 
384
                (GCancellable *)NULL,
 
385
                (GAsyncReadyCallback)on_delete_events,
 
386
                user_data);
 
387
}
 
388
static void on_delete_whole_log (ZeitgeistLog *log, GAsyncResult *res, gpointer *user_data)
 
389
{
 
390
        CDOnDeleteEventsFunc pCallback = user_data[0];
 
391
        gpointer data = user_data[1];
 
392
        
 
393
        GError *error = NULL;
 
394
        gboolean bSuccess = zeitgeist_log_delete_log_finish (log, res, &error);
 
395
        if (error)
 
396
        {
 
397
                cd_warning ("Error deleting log: %s", error->message);
 
398
                g_error_free (error);
 
399
                pCallback (0, data);
 
400
        }
 
401
        else
 
402
        {
 
403
                pCallback (-1, data);
 
404
        }
 
405
}
 
406
void cd_delete_recent_events (int iNbDays, CDOnDeleteEventsFunc pCallback, gpointer data)  // entry in the menu
 
407
{
 
408
        static gpointer s_data[3];
 
409
        s_data[0] = pCallback;
 
410
        s_data[1] = data;
 
411
        s_data[2] = 0;
 
412
        
 
413
        if (myData.pLog == NULL)
 
414
                myData.pLog = zeitgeist_log_new ();
 
415
        
 
416
        if (iNbDays > 0)
 
417
        {
 
418
                // find events IDs of less than 'iNbDays' days
 
419
                GArray *event_ids;
 
420
                time_t t = (time_t) time (NULL);
 
421
                gint64 now = t * 1e3;  // msec
 
422
                ZeitgeistTimeRange *time_range = zeitgeist_time_range_new (now - iNbDays*24*3600*1e3, now);
 
423
                
 
424
                GPtrArray* event_templates = g_ptr_array_new ();
 
425
                
 
426
                zeitgeist_log_find_event_ids (myData.pLog,
 
427
                        time_range,
 
428
                        event_templates,
 
429
                        ZEITGEIST_STORAGE_STATE_ANY,
 
430
                        999,  // 999 is the max number of events available in zeitgeist 0.2, and 1499 is the max in sqlite3 :-/
 
431
                        ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS,
 
432
                        (GCancellable *)NULL,
 
433
                        (GAsyncReadyCallback)on_deleting_event_received,
 
434
                        s_data);
 
435
        }
 
436
        else  // delete the whole log
 
437
        {
 
438
                zeitgeist_log_delete_log (myData.pLog,
 
439
                        (GCancellable *)NULL,
 
440
                        (GAsyncReadyCallback)on_delete_whole_log,
 
441
                        s_data);
 
442
        }
 
443
}
 
444
 
 
445
 
 
446
void cd_delete_event (guint32 id, CDOnDeleteEventsFunc pCallback, gpointer data)
 
447
{
 
448
        static gpointer s_data[3];
 
449
        s_data[0] = pCallback;
 
450
        s_data[1] = data;
 
451
        s_data[2] = GINT_TO_POINTER (1);
 
452
        
 
453
        GArray *event_ids = g_array_sized_new (TRUE,
 
454
                TRUE,
 
455
                sizeof (guint32),
 
456
                1);
 
457
        g_array_append_val (event_ids, id);
 
458
        
 
459
        zeitgeist_log_delete_events (myData.pLog,
 
460
                event_ids,
 
461
                (GCancellable *)NULL,
 
462
                (GAsyncReadyCallback)on_delete_events,
 
463
                s_data);  // this function unrefs the array
 
464
}