revolution 0.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/extconf.rb +2 -1
- data/revolution.c +314 -392
- metadata +3 -3
data/extconf.rb
CHANGED
@@ -5,7 +5,8 @@ pkg_config('libecal-1.2') || pkg_config('libecal-1.0')
|
|
5
5
|
pkg_config('evolution-data-server-1.2') || pkg_config('evolution-data-server-1.0')
|
6
6
|
pkg_config('glib-2.0')
|
7
7
|
|
8
|
-
$CPPFLAGS += " -Wall
|
8
|
+
$CPPFLAGS += " -Wall"
|
9
|
+
#$CPPFLAGS += " -W -Wwrite-strings -Waggregate-return -Wnested-externs -Wundef -Wpointer-arith -Wcast-align -Wshadow -Werror"
|
9
10
|
|
10
11
|
create_makefile("revolution")
|
11
12
|
|
data/revolution.c
CHANGED
@@ -1,10 +1,20 @@
|
|
1
1
|
#include <stdio.h>
|
2
2
|
#include "ruby.h"
|
3
3
|
#include <libebook/e-book.h>
|
4
|
+
#include <libebook/e-contact.h>
|
4
5
|
#include <libecal/e-cal.h>
|
5
6
|
|
6
|
-
|
7
|
-
VALUE
|
7
|
+
|
8
|
+
static VALUE rb_cRevolution;
|
9
|
+
static VALUE rb_cRevolutionException;
|
10
|
+
static VALUE rb_mRevolution;
|
11
|
+
static VALUE rb_cAppointment;
|
12
|
+
static VALUE rb_cTask;
|
13
|
+
static VALUE rb_cContact;
|
14
|
+
static VALUE rb_cContactAddress;
|
15
|
+
static VALUE rb_cContactIMAddress;
|
16
|
+
|
17
|
+
static GHashTable* im_hash;
|
8
18
|
|
9
19
|
/*
|
10
20
|
* call-seq:
|
@@ -16,10 +26,26 @@ static VALUE revolution_init(VALUE self) {
|
|
16
26
|
return Qnil;
|
17
27
|
}
|
18
28
|
|
19
|
-
|
29
|
+
void check_error(GError* error, const char* msg_fmt) {
|
30
|
+
if (error) {
|
31
|
+
char* msg = g_strdup(error->message);
|
32
|
+
g_clear_error(&error);
|
33
|
+
rb_raise(rb_cRevolutionException, msg_fmt, msg);
|
34
|
+
}
|
35
|
+
}
|
20
36
|
|
21
|
-
|
22
|
-
|
37
|
+
ECal* open_cal(short open_tasks) {
|
38
|
+
// This works, but what about getting an ESourceList and all that?
|
39
|
+
ECal* cal;
|
40
|
+
if (open_tasks) {
|
41
|
+
cal = e_cal_new_system_tasks();
|
42
|
+
} else {
|
43
|
+
cal = e_cal_new_system_calendar();
|
44
|
+
}
|
45
|
+
GError* error = 0;
|
46
|
+
e_cal_open(cal, FALSE, &error);
|
47
|
+
check_error(error, "Unable to open calendar: %s");
|
48
|
+
return cal;
|
23
49
|
}
|
24
50
|
|
25
51
|
void copy_summary(const VALUE ruby_obj, ECalComponent* ev_obj) {
|
@@ -56,8 +82,6 @@ void copy_uid(const VALUE ruby_obj, ECalComponent* ev_obj) {
|
|
56
82
|
|
57
83
|
///////////////////////////////////////////////////////
|
58
84
|
// Tasks
|
59
|
-
VALUE cTask;
|
60
|
-
|
61
85
|
/*
|
62
86
|
* call-seq:
|
63
87
|
* new() -> Task
|
@@ -138,50 +162,24 @@ void copy_into_task(const VALUE ruby_task, ECalComponent* ev_task) {
|
|
138
162
|
* Fetches all tasks
|
139
163
|
*/
|
140
164
|
static VALUE revolution_get_all_tasks(VALUE self) {
|
141
|
-
|
142
|
-
|
143
|
-
ECal* cal = e_cal_new_system_tasks();
|
144
|
-
g_signal_connect(G_OBJECT(cal), "cal-opened", G_CALLBACK(revolution_calendar_opened_callback), NULL);
|
145
|
-
GError* error = 0;
|
146
|
-
e_cal_open(cal, FALSE, &error);
|
147
|
-
if (error) {
|
148
|
-
g_warning("Unable to open calendar: %s", error->message);
|
149
|
-
g_clear_error(&error);
|
150
|
-
return result;
|
151
|
-
}
|
152
|
-
|
153
|
-
while (cal_opened_status == -1) {
|
154
|
-
g_usleep(G_USEC_PER_SEC*0.01);
|
155
|
-
}
|
156
|
-
if (cal_opened_status != 0) {
|
157
|
-
g_warning("Unable to open calendar; error code %d", cal_opened_status);
|
158
|
-
return result;
|
159
|
-
}
|
160
|
-
|
165
|
+
ECal* cal = open_cal(1);
|
161
166
|
GList* objects, *l;
|
162
|
-
|
167
|
+
GError* error = 0;
|
163
168
|
e_cal_get_object_list_as_comp(cal, "#t", &objects, &error);
|
164
|
-
|
165
|
-
|
166
|
-
g_clear_error(&error);
|
167
|
-
return result;
|
168
|
-
}
|
169
|
-
|
169
|
+
check_error(error, "Unable to query calendar: %s");
|
170
|
+
VALUE result = rb_ary_new();
|
170
171
|
for (l = objects; l;l = l->next) {
|
171
172
|
ECalComponent *ev_task = E_CAL_COMPONENT (l->data);
|
172
|
-
VALUE ruby_task = rb_class_new_instance(0, 0,
|
173
|
+
VALUE ruby_task = rb_class_new_instance(0, 0, rb_cTask);
|
173
174
|
copy_into_task(ruby_task, ev_task);
|
174
175
|
rb_ary_push(result, ruby_task);
|
175
176
|
g_object_unref (ev_task);
|
176
177
|
}
|
177
|
-
|
178
178
|
return result;
|
179
179
|
}
|
180
180
|
|
181
181
|
///////////////////////////////////////////////////////
|
182
182
|
// Calendar
|
183
|
-
VALUE cAppointment;
|
184
|
-
|
185
183
|
/*
|
186
184
|
* call-seq:
|
187
185
|
* new() -> Appointment
|
@@ -249,55 +247,26 @@ void copy_into_appt(const VALUE ruby_appt, ECalComponent* ev_appt) {
|
|
249
247
|
* Fetches all appointments between the given Time values.
|
250
248
|
*/
|
251
249
|
static VALUE revolution_get_all_appointments(VALUE self, VALUE start, VALUE end) {
|
252
|
-
|
253
|
-
|
254
|
-
// This works, but what about getting an ESourceList and all that?
|
255
|
-
ECal* cal = e_cal_new_system_calendar();
|
256
|
-
g_signal_connect(G_OBJECT(cal), "cal-opened", G_CALLBACK(revolution_calendar_opened_callback), NULL);
|
250
|
+
ECal* cal = open_cal(0);
|
257
251
|
GError* error = 0;
|
258
|
-
e_cal_open(cal, FALSE, &error);
|
259
|
-
if (error) {
|
260
|
-
g_warning("Unable to open calendar: %s", error->message);
|
261
|
-
g_clear_error(&error);
|
262
|
-
return result;
|
263
|
-
}
|
264
|
-
|
265
|
-
while (cal_opened_status == -1) {
|
266
|
-
g_usleep(G_USEC_PER_SEC*0.01);
|
267
|
-
}
|
268
|
-
if (cal_opened_status != 0) {
|
269
|
-
g_warning("Unable to open calendar; error code %d", cal_opened_status);
|
270
|
-
return result;
|
271
|
-
}
|
272
|
-
|
273
252
|
GList* results, *l;
|
274
253
|
e_cal_get_object_list_as_comp(cal, "#t", &results, &error);
|
275
|
-
|
276
|
-
|
277
|
-
g_clear_error(&error);
|
278
|
-
return result;
|
279
|
-
}
|
280
|
-
|
254
|
+
check_error(error, "Unable to query calendar %s");
|
255
|
+
VALUE result = rb_ary_new();
|
281
256
|
for (l = results; l;l = l->next) {
|
282
257
|
ECalComponent *ev_appt = E_CAL_COMPONENT(l->data);
|
283
|
-
VALUE ruby_appt = rb_class_new_instance(0, 0,
|
258
|
+
VALUE ruby_appt = rb_class_new_instance(0, 0, rb_cAppointment);
|
284
259
|
copy_into_appt(ruby_appt, ev_appt);
|
285
260
|
rb_ary_push(result, ruby_appt);
|
286
261
|
g_object_unref (ev_appt);
|
287
262
|
}
|
288
|
-
|
289
263
|
g_list_free(results);
|
290
|
-
|
291
264
|
return result;
|
292
265
|
}
|
293
266
|
|
294
267
|
|
295
268
|
///////////////////////////////////////////////////////
|
296
269
|
// Address Book
|
297
|
-
VALUE cContact;
|
298
|
-
VALUE cContactAddress;
|
299
|
-
VALUE cContactIMAddress;
|
300
|
-
|
301
270
|
/*
|
302
271
|
* call-seq:
|
303
272
|
* new() -> Contact
|
@@ -321,6 +290,7 @@ VALUE cContactIMAddress;
|
|
321
290
|
* @im_addresses [Array] An Array of ContactIMAddress objects
|
322
291
|
*/
|
323
292
|
static VALUE contact_init(VALUE self) {
|
293
|
+
rb_iv_set(self, "@im_addresses", rb_ary_new());
|
324
294
|
return Qtrue;
|
325
295
|
}
|
326
296
|
|
@@ -332,12 +302,16 @@ static VALUE contact_init(VALUE self) {
|
|
332
302
|
*
|
333
303
|
* Attributes:
|
334
304
|
* @provider [String] i.e., AOL, Yahoo
|
305
|
+
* @location [String] HOME or WORK
|
335
306
|
* @address [String] i.e., tom_copeland
|
336
|
-
* @type [String] HOME or WORK
|
337
307
|
*/
|
338
|
-
static VALUE contactIMAddress_init(VALUE self) {
|
308
|
+
static VALUE contactIMAddress_init(VALUE self, VALUE provider, VALUE location, VALUE address) {
|
309
|
+
rb_iv_set(self, "@provider", provider);
|
310
|
+
rb_iv_set(self, "@location", location);
|
311
|
+
rb_iv_set(self, "@address", address);
|
339
312
|
return Qtrue;
|
340
313
|
}
|
314
|
+
|
341
315
|
/*
|
342
316
|
* call-seq:
|
343
317
|
* new() -> ContactAddress
|
@@ -358,9 +332,21 @@ static VALUE contactAddress_init(VALUE self) {
|
|
358
332
|
return Qtrue;
|
359
333
|
}
|
360
334
|
|
361
|
-
|
335
|
+
EBook* open_book() {
|
336
|
+
GError* error = 0;
|
337
|
+
EBook* book = e_book_new_default_addressbook(&error);
|
338
|
+
check_error(error, "Unable to locate the default Evolution address book: %s");
|
339
|
+
e_book_open(book, TRUE, &error);
|
340
|
+
check_error(error, "Unable to open the Evolution address book: %s");
|
341
|
+
if (!book) {
|
342
|
+
rb_raise(rb_cRevolutionException, "Unable to open EBook");
|
343
|
+
}
|
344
|
+
return book;
|
345
|
+
}
|
346
|
+
|
347
|
+
void address_importer(EContactAddress* address, VALUE ruby_contact, const char* field) {
|
362
348
|
if (address) {
|
363
|
-
VALUE rb_addr = rb_class_new_instance(0, 0,
|
349
|
+
VALUE rb_addr = rb_class_new_instance(0, 0, rb_cContactAddress);
|
364
350
|
rb_iv_set(rb_addr, "@address_format", address->address_format ? rb_str_new2(address->address_format) : Qnil);
|
365
351
|
rb_iv_set(rb_addr, "@po", address->po ? rb_str_new2(address->po) : Qnil);
|
366
352
|
rb_iv_set(rb_addr, "@ext", address->ext ? rb_str_new2(address->ext) : Qnil);
|
@@ -369,95 +355,99 @@ void copy_in_address(EContactAddress* address, VALUE ruby_contact, char* field)
|
|
369
355
|
rb_iv_set(rb_addr, "@region", address->region ? rb_str_new2(address->region) : Qnil);
|
370
356
|
rb_iv_set(rb_addr, "@code", address->code ? rb_str_new2(address->code) : Qnil);
|
371
357
|
rb_iv_set(rb_addr, "@country", address->country ? rb_str_new2(address->country) : Qnil);
|
372
|
-
|
373
358
|
rb_iv_set(ruby_contact, field, rb_addr);
|
374
359
|
e_contact_address_free(address);
|
375
360
|
}
|
376
361
|
}
|
377
362
|
|
378
|
-
void
|
379
|
-
|
380
|
-
|
381
|
-
}
|
382
|
-
VALUE rb_addr = rb_class_new_instance(0, 0, cContactIMAddress);
|
383
|
-
rb_iv_set(rb_addr, "@provider", rb_str_new2(provider));
|
384
|
-
rb_iv_set(rb_addr, "@location", rb_str_new2(location));
|
385
|
-
rb_iv_set(rb_addr, "@address", rb_str_new2(address));
|
386
|
-
rb_ary_push(im_addresses, rb_addr);
|
363
|
+
void string_importer(const VALUE ruby_contact, EContact* ev_contact, const char* ruby_iv_name, int ev_field) {
|
364
|
+
char* value = e_contact_get(ev_contact, ev_field);
|
365
|
+
rb_iv_set(ruby_contact, ruby_iv_name, value ? rb_str_new2(value) : Qnil);
|
387
366
|
}
|
388
367
|
|
389
|
-
void
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
char* value = e_contact_get(ev_contact, E_CONTACT_GIVEN_NAME);
|
396
|
-
rb_iv_set(ruby_contact, "@first_name", value ? rb_str_new2(value) : Qnil);
|
397
|
-
|
398
|
-
value = e_contact_get(ev_contact, E_CONTACT_FAMILY_NAME);
|
399
|
-
rb_iv_set(ruby_contact, "@last_name", value ? rb_str_new2(value) : Qnil);
|
400
|
-
|
401
|
-
value = e_contact_get(ev_contact, E_CONTACT_PHONE_HOME);
|
402
|
-
rb_iv_set(ruby_contact, "@home_phone", value ? rb_str_new2(value) : Qnil);
|
403
|
-
|
404
|
-
value = e_contact_get(ev_contact, E_CONTACT_PHONE_BUSINESS);
|
405
|
-
rb_iv_set(ruby_contact, "@work_phone", value ? rb_str_new2(value) : Qnil);
|
406
|
-
|
407
|
-
value = e_contact_get(ev_contact, E_CONTACT_PHONE_MOBILE);
|
408
|
-
rb_iv_set(ruby_contact, "@mobile_phone", value ? rb_str_new2(value) : Qnil);
|
409
|
-
|
410
|
-
value = e_contact_get(ev_contact, E_CONTACT_ORG);
|
411
|
-
rb_iv_set(ruby_contact, "@organization", value ? rb_str_new2(value) : Qnil);
|
412
|
-
|
413
|
-
value = e_contact_get(ev_contact, E_CONTACT_TITLE);
|
414
|
-
rb_iv_set(ruby_contact, "@title", value ? rb_str_new2(value) : Qnil);
|
415
|
-
|
416
|
-
EContactDate *birth_date = e_contact_get(ev_contact, E_CONTACT_BIRTH_DATE);
|
417
|
-
if (birth_date) {
|
418
|
-
rb_iv_set(ruby_contact, "@birthday", rb_funcall(rb_cTime, rb_intern("gm"), 6, INT2NUM(birth_date->year), INT2NUM(birth_date->month), INT2NUM(birth_date->day), INT2NUM(0), INT2NUM(0), INT2NUM(0)));
|
419
|
-
e_contact_date_free(birth_date);
|
368
|
+
void date_importer(const VALUE ruby_contact, EContact* ev_contact, const char* ruby_iv_name, int ev_field) {
|
369
|
+
EContactDate* date = e_contact_get(ev_contact, ev_field);
|
370
|
+
if (date) {
|
371
|
+
rb_iv_set(ruby_contact, ruby_iv_name, rb_funcall(rb_cTime, rb_intern("gm"), 6, INT2NUM(date->year), INT2NUM(date->month), INT2NUM(date->day), INT2NUM(0), INT2NUM(0), INT2NUM(0)));
|
372
|
+
e_contact_date_free(date);
|
420
373
|
}
|
374
|
+
}
|
421
375
|
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
VALUE email_addresses = rb_iv_get(ruby_contact, "@email_addresses");
|
433
|
-
VALUE rb_type = rb_str_new2(e_vcard_attribute_param_get_values(p)->data);
|
434
|
-
if (rb_hash_aref(email_addresses, rb_type) == Qnil) {
|
435
|
-
rb_hash_aset(email_addresses, rb_type, rb_ary_new());
|
436
|
-
}
|
437
|
-
rb_ary_push(rb_hash_aref(email_addresses, rb_type), rb_str_new2(e_vcard_attribute_get_value(a)));
|
376
|
+
void email_importer(VALUE ruby_contact, EContact* ev_contact) {
|
377
|
+
VALUE email_addresses = rb_hash_new();
|
378
|
+
GList* attrs = e_contact_get_attributes(ev_contact, E_CONTACT_EMAIL), *attr = NULL;
|
379
|
+
for (attr = attrs; attr; attr = attr->next) {
|
380
|
+
GList* l;
|
381
|
+
for (l = e_vcard_attribute_get_params(attr->data); l; l = l->next) {
|
382
|
+
if (!g_ascii_strcasecmp((char*)e_vcard_attribute_param_get_name(l->data), "TYPE")) {
|
383
|
+
VALUE rb_addr_type = rb_str_new2(e_vcard_attribute_param_get_values(l->data)->data);
|
384
|
+
if (rb_hash_aref(email_addresses, rb_addr_type) == Qnil) {
|
385
|
+
rb_hash_aset(email_addresses, rb_addr_type, rb_ary_new());
|
438
386
|
}
|
387
|
+
rb_ary_push(rb_hash_aref(email_addresses, rb_addr_type), rb_str_new2(e_vcard_attribute_get_value(attr->data)));
|
439
388
|
}
|
440
|
-
}
|
389
|
+
}
|
390
|
+
}
|
391
|
+
rb_iv_set(ruby_contact, "@email_addresses", email_addresses);
|
392
|
+
}
|
393
|
+
|
394
|
+
void im_importer(const VALUE ruby_contact, const char* address, const char* provider, const char* location) {
|
395
|
+
if (!address) {
|
396
|
+
return;
|
441
397
|
}
|
398
|
+
VALUE args[3] = {rb_str_new2(provider), rb_str_new2(location), rb_str_new2(address)};
|
399
|
+
VALUE rb_addr = rb_class_new_instance(3, args, rb_cContactIMAddress);
|
400
|
+
VALUE ary = rb_iv_get(ruby_contact, "@im_addresses");
|
401
|
+
rb_ary_push(ary, rb_addr);
|
402
|
+
rb_iv_set(ruby_contact, "@im_addresses", ary);
|
403
|
+
}
|
404
|
+
|
405
|
+
GList* run_query(EBook* book, EBookQuery* query) {
|
406
|
+
GError* error = 0;
|
407
|
+
GList* results = NULL;
|
408
|
+
e_book_get_contacts(book, query, &results, &error);
|
409
|
+
check_error(error, "Unable to query the Evolution address book: %s");
|
410
|
+
return results;
|
411
|
+
}
|
442
412
|
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
413
|
+
VALUE copy_contacts(GList* results) {
|
414
|
+
VALUE result = rb_ary_new();
|
415
|
+
GList* l = NULL;
|
416
|
+
for (l = results; l; l = l->next) {
|
417
|
+
EContact* ev_contact = E_CONTACT(l->data);
|
418
|
+
VALUE ruby_contact = rb_class_new_instance(0, 0, rb_cContact);
|
419
|
+
// last mod time will work in v2.16+ : e_contact_get (ev_contact, E_CONTACT_REV));
|
420
|
+
// what's the best way to handle version differences? #ifdef them in?
|
421
|
+
string_importer(ruby_contact, ev_contact, "@uid", E_CONTACT_UID);
|
422
|
+
string_importer(ruby_contact, ev_contact, "@first_name", E_CONTACT_GIVEN_NAME);
|
423
|
+
string_importer(ruby_contact, ev_contact, "@last_name", E_CONTACT_FAMILY_NAME);
|
424
|
+
string_importer(ruby_contact, ev_contact, "@home_phone", E_CONTACT_PHONE_HOME);
|
425
|
+
string_importer(ruby_contact, ev_contact, "@work_phone", E_CONTACT_PHONE_BUSINESS);
|
426
|
+
string_importer(ruby_contact, ev_contact, "@mobile_phone", E_CONTACT_PHONE_MOBILE);
|
427
|
+
string_importer(ruby_contact, ev_contact, "@organization", E_CONTACT_ORG);
|
428
|
+
string_importer(ruby_contact, ev_contact, "@title", E_CONTACT_TITLE);
|
429
|
+
date_importer(ruby_contact, ev_contact, "@birthday", E_CONTACT_BIRTH_DATE);
|
430
|
+
email_importer(ruby_contact, ev_contact);
|
431
|
+
address_importer(e_contact_get(ev_contact, E_CONTACT_ADDRESS_HOME), ruby_contact, "@home_address");
|
432
|
+
address_importer(e_contact_get(ev_contact, E_CONTACT_ADDRESS_WORK), ruby_contact, "@work_address");
|
433
|
+
address_importer(e_contact_get(ev_contact, E_CONTACT_ADDRESS_OTHER), ruby_contact, "@other_address");
|
434
|
+
im_importer(ruby_contact, e_contact_get(ev_contact, E_CONTACT_IM_AIM_HOME_1), "AIM", "HOME");
|
435
|
+
im_importer(ruby_contact, e_contact_get(ev_contact, E_CONTACT_IM_AIM_WORK_1), "AIM", "WORK");
|
436
|
+
im_importer(ruby_contact, e_contact_get(ev_contact, E_CONTACT_IM_YAHOO_HOME_1), "Yahoo", "HOME");
|
437
|
+
im_importer(ruby_contact, e_contact_get(ev_contact, E_CONTACT_IM_YAHOO_WORK_1), "Yahoo", "WORK");
|
438
|
+
im_importer(ruby_contact, e_contact_get(ev_contact, E_CONTACT_IM_GROUPWISE_HOME_1), "Groupwise", "HOME");
|
439
|
+
im_importer(ruby_contact, e_contact_get(ev_contact, E_CONTACT_IM_GROUPWISE_WORK_1), "Groupwise", "WORK");
|
440
|
+
im_importer(ruby_contact, e_contact_get(ev_contact, E_CONTACT_IM_JABBER_HOME_1), "Jabber", "HOME");
|
441
|
+
im_importer(ruby_contact, e_contact_get(ev_contact, E_CONTACT_IM_JABBER_WORK_1), "Jabber", "WORK");
|
442
|
+
im_importer(ruby_contact, e_contact_get(ev_contact, E_CONTACT_IM_MSN_HOME_1), "MSN", "HOME");
|
443
|
+
im_importer(ruby_contact, e_contact_get(ev_contact, E_CONTACT_IM_MSN_WORK_1), "MSN", "WORK");
|
444
|
+
im_importer(ruby_contact, e_contact_get(ev_contact, E_CONTACT_IM_ICQ_HOME_1), "ICQ", "HOME");
|
445
|
+
im_importer(ruby_contact, e_contact_get(ev_contact, E_CONTACT_IM_ICQ_WORK_1), "ICQ", "WORK");
|
446
|
+
rb_ary_push(result, ruby_contact);
|
447
|
+
g_object_unref(ev_contact);
|
448
|
+
}
|
449
|
+
g_list_free(results);
|
450
|
+
return result;
|
461
451
|
}
|
462
452
|
|
463
453
|
/*
|
@@ -467,60 +457,12 @@ void copy_into_contact(const VALUE ruby_contact, EContact* ev_contact) {
|
|
467
457
|
* Fetches all contacts
|
468
458
|
*/
|
469
459
|
static VALUE revolution_get_all_contacts(VALUE self) {
|
470
|
-
VALUE result = rb_ary_new();
|
471
|
-
GError* error = 0;
|
472
|
-
EBook* book = e_book_new_default_addressbook(&error);
|
473
|
-
if (error != NULL) {
|
474
|
-
g_warning("Unable to locate the default Evolution address book: %s", error->message);
|
475
|
-
g_clear_error(&error);
|
476
|
-
return result;
|
477
|
-
}
|
478
|
-
e_book_open(book, TRUE, &error);
|
479
|
-
if (error) {
|
480
|
-
g_warning("Unable to open the Evolution address book: %s", error->message);
|
481
|
-
g_clear_error(&error);
|
482
|
-
return result;
|
483
|
-
}
|
484
|
-
|
485
460
|
EBookQuery* query = e_book_query_any_field_contains("");
|
486
|
-
|
487
|
-
GList* results, *l = NULL;
|
488
|
-
e_book_get_contacts(book, query, &results, &error);
|
489
|
-
if (error) {
|
490
|
-
g_warning("Unable to query the Evolution address book: %s", error->message);
|
491
|
-
g_clear_error(&error);
|
492
|
-
return result;
|
493
|
-
}
|
494
|
-
for (l = results; l; l = l->next) {
|
495
|
-
EContact* ev_contact = E_CONTACT(l->data);
|
496
|
-
VALUE ruby_contact = rb_class_new_instance(0, 0, cContact);
|
497
|
-
copy_into_contact(ruby_contact, ev_contact);
|
498
|
-
rb_ary_push(result, ruby_contact);
|
499
|
-
g_object_unref(ev_contact);
|
500
|
-
}
|
461
|
+
VALUE result = copy_contacts(run_query(open_book(), query));
|
501
462
|
e_book_query_unref(query);
|
502
|
-
g_list_free(results);
|
503
|
-
|
504
463
|
return result;
|
505
464
|
}
|
506
465
|
|
507
|
-
EBook* open_book() {
|
508
|
-
GError* error = 0;
|
509
|
-
EBook* book = e_book_new_default_addressbook(&error);
|
510
|
-
if (error != NULL) {
|
511
|
-
g_warning("Unable to locate the default Evolution address book: %s", error->message);
|
512
|
-
g_clear_error(&error);
|
513
|
-
return NULL;
|
514
|
-
}
|
515
|
-
e_book_open(book, TRUE, &error);
|
516
|
-
if (error) {
|
517
|
-
g_warning("Unable to open the Evolution address book: %s", error->message);
|
518
|
-
g_clear_error(&error);
|
519
|
-
return NULL;
|
520
|
-
}
|
521
|
-
return book;
|
522
|
-
}
|
523
|
-
|
524
466
|
/*
|
525
467
|
* call-seq:
|
526
468
|
* get_contacts_with_query(query)
|
@@ -529,32 +471,9 @@ EBook* open_book() {
|
|
529
471
|
* return any contacts whose named contained "Smith" - Joe Smith, Fred Smithson, etc.
|
530
472
|
*/
|
531
473
|
static VALUE revolution_get_contacts_with_query(VALUE self, VALUE rb_query) {
|
532
|
-
|
533
|
-
|
534
|
-
if (!book) {
|
535
|
-
return Qnil;
|
536
|
-
}
|
537
|
-
|
538
|
-
EBookQuery* query = e_book_query_from_string(RSTRING(StringValue(rb_query))->ptr);
|
539
|
-
GError* error = 0;
|
540
|
-
GList* results, *l = NULL;
|
541
|
-
e_book_get_contacts(book, query, &results, &error);
|
542
|
-
if (error) {
|
543
|
-
g_warning("Unable to query the Evolution address book: %s", error->message);
|
544
|
-
g_clear_error(&error);
|
545
|
-
return Qnil;
|
546
|
-
}
|
547
|
-
|
548
|
-
for (l = results; l; l = l->next) {
|
549
|
-
EContact* ev_contact = E_CONTACT(l->data);
|
550
|
-
VALUE ruby_contact = rb_class_new_instance(0, 0, cContact);
|
551
|
-
copy_into_contact(ruby_contact, ev_contact);
|
552
|
-
rb_ary_push(result, ruby_contact);
|
553
|
-
g_object_unref(ev_contact);
|
554
|
-
}
|
474
|
+
EBookQuery* query = e_book_query_from_string(RSTRING(StringValue(rb_query))->ptr);
|
475
|
+
VALUE result = copy_contacts(run_query(open_book(), query));
|
555
476
|
e_book_query_unref(query);
|
556
|
-
g_list_free(results);
|
557
|
-
|
558
477
|
return result;
|
559
478
|
}
|
560
479
|
|
@@ -565,33 +484,9 @@ static VALUE revolution_get_contacts_with_query(VALUE self, VALUE rb_query) {
|
|
565
484
|
* Gets contacts by name; returns any name that contains the passed in parameter
|
566
485
|
*/
|
567
486
|
static VALUE revolution_get_contacts_by_name(VALUE self, VALUE rb_name) {
|
568
|
-
|
569
|
-
|
570
|
-
EBook* book = open_book();
|
571
|
-
if (!book) {
|
572
|
-
return Qnil;
|
573
|
-
}
|
574
|
-
char* name = RSTRING(StringValue(rb_name))->ptr;
|
575
|
-
char* query_str = g_strdup_printf ("(contains \"full_name\" \"%s\")", name);
|
576
|
-
EBookQuery* query = e_book_query_from_string(query_str);
|
577
|
-
GList* results, *l = NULL;
|
578
|
-
e_book_get_contacts(book, query, &results, &error);
|
579
|
-
if (error) {
|
580
|
-
g_warning("Unable to query the Evolution address book: %s", error->message);
|
581
|
-
g_clear_error(&error);
|
582
|
-
return Qnil;
|
583
|
-
}
|
584
|
-
|
585
|
-
for (l = results; l; l = l->next) {
|
586
|
-
EContact* ev_contact = E_CONTACT(l->data);
|
587
|
-
VALUE ruby_contact = rb_class_new_instance(0, 0, cContact);
|
588
|
-
copy_into_contact(ruby_contact, ev_contact);
|
589
|
-
rb_ary_push(result, ruby_contact);
|
590
|
-
g_object_unref(ev_contact);
|
591
|
-
}
|
487
|
+
EBookQuery* query = e_book_query_from_string(g_strdup_printf ("(contains \"full_name\" \"%s\")", RSTRING(StringValue(rb_name))->ptr));
|
488
|
+
VALUE result = copy_contacts(run_query(open_book(), query));
|
592
489
|
e_book_query_unref(query);
|
593
|
-
g_list_free(results);
|
594
|
-
|
595
490
|
return result;
|
596
491
|
}
|
597
492
|
|
@@ -602,35 +497,14 @@ static VALUE revolution_get_contacts_by_name(VALUE self, VALUE rb_name) {
|
|
602
497
|
* Gets a single contact by the Evolution unique id
|
603
498
|
*/
|
604
499
|
static VALUE revolution_get_contact_by_uid(VALUE self, VALUE contact_uid) {
|
605
|
-
GError* error = 0;
|
606
|
-
EBook* book = open_book();
|
607
|
-
if (!book) {
|
608
|
-
return Qnil;
|
609
|
-
}
|
610
|
-
|
611
500
|
char* uid = RSTRING(StringValue(contact_uid))->ptr;
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
if (error) {
|
617
|
-
g_warning("Unable to query the Evolution address book: %s", error->message);
|
618
|
-
g_clear_error(&error);
|
619
|
-
return Qnil;
|
620
|
-
}
|
621
|
-
if (!results) {
|
622
|
-
// A contact for that id wasn't found, so just return nil
|
623
|
-
return Qnil;
|
501
|
+
EBookQuery* query = e_book_query_from_string(g_strdup_printf ("(is \"id\" \"%s\")", uid));
|
502
|
+
VALUE result = rb_ary_pop(copy_contacts(run_query(open_book(), query)));
|
503
|
+
if (result == Qnil) {
|
504
|
+
rb_raise(rb_cRevolutionException, "Unable to find contact with UID %s, so couldn't get it", uid);
|
624
505
|
}
|
625
|
-
|
626
|
-
EContact* ev_contact = E_CONTACT(results->data);
|
627
|
-
VALUE ruby_contact = rb_class_new_instance(0, 0, cContact);
|
628
|
-
copy_into_contact(ruby_contact, ev_contact);
|
629
|
-
g_object_unref(ev_contact);
|
630
506
|
e_book_query_unref(query);
|
631
|
-
|
632
|
-
|
633
|
-
return ruby_contact;
|
507
|
+
return result;
|
634
508
|
}
|
635
509
|
|
636
510
|
/*
|
@@ -641,49 +515,34 @@ static VALUE revolution_get_contact_by_uid(VALUE self, VALUE contact_uid) {
|
|
641
515
|
*/
|
642
516
|
static VALUE revolution_delete_contact(VALUE self, VALUE contact_uid) {
|
643
517
|
GError* error = 0;
|
644
|
-
|
645
|
-
|
646
|
-
return Qnil;
|
647
|
-
}
|
648
|
-
|
649
|
-
char* uid = RSTRING(StringValue(contact_uid))->ptr;
|
650
|
-
char* query_str = g_strdup_printf ("(is \"id\" \"%s\")", uid);
|
651
|
-
EBookQuery* query = e_book_query_from_string(query_str);
|
652
|
-
GList* results = NULL;
|
653
|
-
e_book_get_contacts(book, query, &results, &error);
|
654
|
-
if (error) {
|
655
|
-
g_warning("Unable to query the Evolution address book: %s", error->message);
|
656
|
-
g_clear_error(&error);
|
657
|
-
return Qnil;
|
658
|
-
}
|
659
|
-
if (!results) { // A contact for that id wasn't found, so just bail out
|
660
|
-
return Qnil;
|
661
|
-
}
|
662
|
-
|
663
|
-
e_book_remove_contact(book, uid, &error);
|
664
|
-
if (error) {
|
665
|
-
g_warning("Unable to delete contact: %s", error->message);
|
666
|
-
g_clear_error(&error);
|
667
|
-
}
|
668
|
-
|
518
|
+
e_book_remove_contact(open_book(), RSTRING(StringValue(contact_uid))->ptr, &error);
|
519
|
+
check_error(error, "Unable to delete contact: %s");
|
669
520
|
return Qnil;
|
670
521
|
}
|
671
522
|
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
523
|
+
void export_email_addresses(VALUE email_addresses, GList** email_attrs, const char* type) {
|
524
|
+
VALUE addresses = rb_hash_aref(email_addresses, rb_str_new2(type));
|
525
|
+
if (addresses != Qnil) {
|
526
|
+
addresses = rb_funcall(addresses, rb_intern("reverse"), 0);
|
527
|
+
VALUE rb_addr = Qnil;
|
528
|
+
while ((rb_addr = rb_ary_pop(addresses)) != Qnil) {
|
529
|
+
char* addr = RSTRING(StringValue(rb_addr))->ptr;
|
530
|
+
EVCardAttribute* attr = e_vcard_attribute_new (NULL, EVC_EMAIL);
|
531
|
+
e_vcard_attribute_add_value(attr, addr);
|
532
|
+
e_vcard_attribute_add_param_with_value(attr, e_vcard_attribute_param_new (EVC_TYPE), type);
|
533
|
+
*email_attrs = g_list_append(*email_attrs, attr);
|
534
|
+
}
|
683
535
|
}
|
684
|
-
|
685
|
-
|
536
|
+
}
|
537
|
+
|
538
|
+
void string_exporter(const VALUE rb_contact, EContact* ev_contact, const char* ruby_iv_name, int ev_field) {
|
539
|
+
VALUE value = rb_iv_get(rb_contact, ruby_iv_name);
|
540
|
+
if (value != Qnil) {
|
541
|
+
e_contact_set(ev_contact, ev_field, RSTRING(StringValue(value))->ptr);
|
542
|
+
}
|
543
|
+
}
|
686
544
|
|
545
|
+
void name_exporter(const VALUE rb_contact, EContact* ev_contact) {
|
687
546
|
EContactName* name = e_contact_name_new ();
|
688
547
|
VALUE fname = rb_iv_get(rb_contact, "@first_name");
|
689
548
|
if (fname) {
|
@@ -693,98 +552,161 @@ static VALUE revolution_add_contact(VALUE self, VALUE rb_contact) {
|
|
693
552
|
if (lname) {
|
694
553
|
name->family = RSTRING(StringValue(lname))->ptr;
|
695
554
|
}
|
696
|
-
|
697
555
|
e_contact_set(ev_contact, E_CONTACT_FULL_NAME, e_contact_name_to_string (name));
|
698
|
-
|
699
|
-
|
700
|
-
|
556
|
+
// Hm, this causes problems... if I leave it here it segfaults,
|
557
|
+
// and if I move to down to after the contact commit call
|
558
|
+
// GLib complains about a double free
|
559
|
+
//e_contact_name_free(name);
|
560
|
+
}
|
701
561
|
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
562
|
+
void date_exporter(const VALUE rb_contact, EContact* ev_contact, const char* ruby_iv_name, int ev_field) {
|
563
|
+
VALUE date = rb_iv_get(rb_contact, ruby_iv_name);
|
564
|
+
if (date != Qnil) {
|
565
|
+
EContactDate* d = e_contact_date_new();
|
566
|
+
d->year = NUM2INT(rb_funcall(date, rb_intern("year"), 0));
|
567
|
+
d->month = NUM2INT(rb_funcall(date, rb_intern("mon"), 0));
|
568
|
+
d->day = NUM2INT(rb_funcall(date, rb_intern("day"), 0));
|
569
|
+
e_contact_set(ev_contact, ev_field, d);
|
570
|
+
}
|
571
|
+
}
|
572
|
+
|
573
|
+
void email_exporter(const VALUE rb_contact, EContact* ev_contact) {
|
574
|
+
VALUE email_addresses = rb_iv_get(rb_contact, "@email_addresses");
|
575
|
+
if (email_addresses != Qnil) {
|
576
|
+
GList* email_attrs = NULL;
|
577
|
+
export_email_addresses(email_addresses, &email_attrs, "WORK");
|
578
|
+
export_email_addresses(email_addresses, &email_attrs, "HOME");
|
579
|
+
export_email_addresses(email_addresses, &email_attrs, "OTHER");
|
580
|
+
if (g_list_length(email_attrs) > 0) {
|
581
|
+
e_contact_set_attributes (ev_contact, E_CONTACT_EMAIL, email_attrs);
|
582
|
+
}
|
583
|
+
g_list_free(email_attrs);
|
584
|
+
}
|
585
|
+
}
|
586
|
+
|
587
|
+
void im_exporter(const VALUE rb_contact, EContact* ev_contact) {
|
588
|
+
VALUE im_addresses = rb_iv_get(rb_contact, "@im_addresses");
|
589
|
+
if (im_addresses != Qnil) {
|
590
|
+
VALUE rb_addr = Qnil;
|
591
|
+
while ((rb_addr = rb_ary_pop(im_addresses)) != Qnil) {
|
592
|
+
VALUE prov = rb_iv_get(rb_addr, "@provider");
|
593
|
+
char* provider = RSTRING(StringValue(prov))->ptr;
|
594
|
+
VALUE loc = rb_iv_get(rb_addr, "@location");
|
595
|
+
char* location = RSTRING(StringValue(loc))->ptr;
|
596
|
+
VALUE ad = rb_iv_get(rb_addr, "@address");
|
597
|
+
char* addr = RSTRING(StringValue(ad))->ptr;
|
598
|
+
e_contact_set(ev_contact, GPOINTER_TO_INT(g_hash_table_lookup(im_hash, g_strconcat(provider, location, NULL))), addr);
|
599
|
+
}
|
706
600
|
}
|
601
|
+
}
|
707
602
|
|
603
|
+
/*
|
604
|
+
* call-seq:
|
605
|
+
* add_contact(contact) -> [String] the new contact's Evolution unique ID
|
606
|
+
*
|
607
|
+
* Adds a contact
|
608
|
+
*/
|
609
|
+
static VALUE revolution_add_contact(VALUE self, VALUE rb_contact) {
|
610
|
+
EContact* ev_contact = e_contact_new();
|
611
|
+
name_exporter(rb_contact, ev_contact);
|
612
|
+
string_exporter(rb_contact, ev_contact, "@home_phone", E_CONTACT_PHONE_HOME);
|
613
|
+
string_exporter(rb_contact, ev_contact, "@work_phone", E_CONTACT_PHONE_BUSINESS);
|
614
|
+
string_exporter(rb_contact, ev_contact, "@mobile_phone", E_CONTACT_PHONE_MOBILE);
|
615
|
+
string_exporter(rb_contact, ev_contact, "@organization", E_CONTACT_ORG);
|
616
|
+
string_exporter(rb_contact, ev_contact, "@title", E_CONTACT_TITLE);
|
617
|
+
date_exporter(rb_contact, ev_contact, "@birthday", E_CONTACT_BIRTH_DATE);
|
618
|
+
email_exporter(rb_contact, ev_contact);
|
619
|
+
im_exporter(rb_contact, ev_contact);
|
620
|
+
GError* error = 0;
|
621
|
+
e_book_add_contact(open_book(), ev_contact, &error);
|
622
|
+
check_error(error, "Unable to add contact: %s");
|
708
623
|
return rb_str_new2(e_contact_get(ev_contact, E_CONTACT_UID));
|
709
624
|
}
|
710
625
|
|
626
|
+
|
711
627
|
/*
|
712
628
|
* An interface to the Evolution[http://www.gnome.org/projects/evolution/]
|
713
629
|
* calendar, contact, and task information.
|
714
630
|
*/
|
715
631
|
void Init_revolution() {
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
rb_define_attr(
|
720
|
-
rb_define_attr(
|
721
|
-
rb_define_attr(
|
722
|
-
rb_define_attr(
|
723
|
-
rb_define_attr(
|
724
|
-
rb_define_attr(
|
725
|
-
rb_define_attr(
|
726
|
-
rb_define_attr(
|
727
|
-
rb_define_attr(
|
728
|
-
rb_define_attr(
|
729
|
-
rb_define_attr(
|
730
|
-
rb_define_attr(
|
731
|
-
rb_define_attr(
|
732
|
-
rb_define_attr(
|
733
|
-
rb_define_attr(
|
734
|
-
rb_define_attr(
|
735
|
-
rb_define_method(
|
736
|
-
|
737
|
-
rb_define_attr(
|
738
|
-
rb_define_attr(
|
739
|
-
rb_define_attr(
|
740
|
-
rb_define_attr(
|
741
|
-
rb_define_attr(
|
742
|
-
rb_define_attr(
|
743
|
-
rb_define_attr(
|
744
|
-
rb_define_attr(
|
745
|
-
rb_define_method(
|
746
|
-
|
747
|
-
rb_define_attr(
|
748
|
-
rb_define_attr(
|
749
|
-
rb_define_attr(
|
750
|
-
rb_define_method(
|
751
|
-
|
752
|
-
|
753
|
-
rb_define_attr(
|
754
|
-
rb_define_attr(
|
755
|
-
rb_define_attr(
|
756
|
-
rb_define_attr(
|
757
|
-
rb_define_attr(
|
758
|
-
rb_define_attr(
|
759
|
-
rb_define_attr(
|
760
|
-
rb_define_attr(
|
761
|
-
rb_define_attr(
|
762
|
-
rb_define_attr(
|
763
|
-
rb_define_method(
|
632
|
+
rb_mRevolution = rb_define_module("Revolution");
|
633
|
+
|
634
|
+
rb_cContact = rb_define_class_under(rb_mRevolution, "Contact", rb_cObject);
|
635
|
+
rb_define_attr(rb_cContact, "uid", 1, 1);
|
636
|
+
rb_define_attr(rb_cContact, "first_name", 1, 1);
|
637
|
+
rb_define_attr(rb_cContact, "last_name", 1, 1);
|
638
|
+
rb_define_attr(rb_cContact, "home_email", 1, 1);
|
639
|
+
rb_define_attr(rb_cContact, "work_email", 1, 1);
|
640
|
+
rb_define_attr(rb_cContact, "email_addresses", 1, 1);
|
641
|
+
rb_define_attr(rb_cContact, "birthday", 1, 1);
|
642
|
+
rb_define_attr(rb_cContact, "home_phone", 1, 1);
|
643
|
+
rb_define_attr(rb_cContact, "work_phone", 1, 1);
|
644
|
+
rb_define_attr(rb_cContact, "mobile_phone", 1, 1);
|
645
|
+
rb_define_attr(rb_cContact, "home_address", 1, 1);
|
646
|
+
rb_define_attr(rb_cContact, "work_address", 1, 1);
|
647
|
+
rb_define_attr(rb_cContact, "other_address", 1, 1);
|
648
|
+
rb_define_attr(rb_cContact, "organization", 1, 1);
|
649
|
+
rb_define_attr(rb_cContact, "title", 1, 1);
|
650
|
+
rb_define_attr(rb_cContact, "im_addresses", 1, 1);
|
651
|
+
rb_define_method(rb_cContact, "initialize", contact_init, 0);
|
652
|
+
rb_cContactAddress = rb_define_class_under(rb_mRevolution, "ContactAddress", rb_cObject);
|
653
|
+
rb_define_attr(rb_cContactAddress, "address_format", 1, 1);
|
654
|
+
rb_define_attr(rb_cContactAddress, "po", 1, 1);
|
655
|
+
rb_define_attr(rb_cContactAddress, "ext", 1, 1);
|
656
|
+
rb_define_attr(rb_cContactAddress, "street", 1, 1);
|
657
|
+
rb_define_attr(rb_cContactAddress, "locality", 1, 1);
|
658
|
+
rb_define_attr(rb_cContactAddress, "region", 1, 1);
|
659
|
+
rb_define_attr(rb_cContactAddress, "code", 1, 1);
|
660
|
+
rb_define_attr(rb_cContactAddress, "country", 1, 1);
|
661
|
+
rb_define_method(rb_cContactAddress, "initialize", contactAddress_init, 0);
|
662
|
+
rb_cContactIMAddress = rb_define_class_under(rb_mRevolution, "ContactIMAddress", rb_cObject);
|
663
|
+
rb_define_attr(rb_cContactIMAddress, "provider", 1, 1);
|
664
|
+
rb_define_attr(rb_cContactIMAddress, "location", 1, 1);
|
665
|
+
rb_define_attr(rb_cContactIMAddress, "address", 1, 1);
|
666
|
+
rb_define_method(rb_cContactIMAddress, "initialize", contactIMAddress_init, 3);
|
667
|
+
|
668
|
+
rb_cAppointment = rb_define_class_under(rb_mRevolution, "Appointment", rb_cObject);
|
669
|
+
rb_define_attr(rb_cAppointment, "uid", 1, 1);
|
670
|
+
rb_define_attr(rb_cAppointment, "summary", 1, 1);
|
671
|
+
rb_define_attr(rb_cAppointment, "location", 1, 1);
|
672
|
+
rb_define_attr(rb_cAppointment, "organizer", 1, 1);
|
673
|
+
rb_define_attr(rb_cAppointment, "start", 1, 1);
|
674
|
+
rb_define_attr(rb_cAppointment, "end", 1, 1);
|
675
|
+
rb_define_attr(rb_cAppointment, "last_modification", 1, 1);
|
676
|
+
rb_define_attr(rb_cAppointment, "alarm_set", 1, 1);
|
677
|
+
rb_define_attr(rb_cAppointment, "busy_status", 1, 1);
|
678
|
+
rb_define_attr(rb_cAppointment, "recurring", 1, 1);
|
679
|
+
rb_define_method(rb_cAppointment, "initialize", evAppointment_init, 0);
|
764
680
|
// INLINE RUBY CODE define an "all_day" method
|
765
681
|
|
766
|
-
|
767
|
-
rb_define_attr(
|
768
|
-
rb_define_attr(
|
769
|
-
rb_define_attr(
|
770
|
-
rb_define_attr(
|
771
|
-
rb_define_attr(
|
772
|
-
rb_define_attr(
|
773
|
-
rb_define_attr(
|
774
|
-
rb_define_attr(
|
775
|
-
rb_define_method(
|
776
|
-
|
777
|
-
|
778
|
-
rb_define_method(
|
779
|
-
rb_define_method(
|
780
|
-
rb_define_method(
|
781
|
-
rb_define_method(
|
782
|
-
rb_define_method(
|
783
|
-
rb_define_method(
|
784
|
-
rb_define_method(
|
785
|
-
rb_define_method(
|
786
|
-
rb_define_method(
|
682
|
+
rb_cTask = rb_define_class_under(rb_mRevolution, "Task", rb_cObject);
|
683
|
+
rb_define_attr(rb_cTask, "uid", 1, 1);
|
684
|
+
rb_define_attr(rb_cTask, "summary", 1, 1);
|
685
|
+
rb_define_attr(rb_cTask, "description", 1, 1);
|
686
|
+
rb_define_attr(rb_cTask, "start", 1, 1);
|
687
|
+
rb_define_attr(rb_cTask, "due", 1, 1);
|
688
|
+
rb_define_attr(rb_cTask, "status", 1, 1);
|
689
|
+
rb_define_attr(rb_cTask, "priority", 1, 1);
|
690
|
+
rb_define_attr(rb_cTask, "last_modification", 1, 1);
|
691
|
+
rb_define_method(rb_cTask, "initialize", evTask_init, 0);
|
692
|
+
|
693
|
+
rb_cRevolution = rb_define_class_under(rb_mRevolution, "Revolution", rb_cObject);
|
694
|
+
rb_define_method(rb_cRevolution, "initialize", revolution_init, 0);
|
695
|
+
rb_define_method(rb_cRevolution, "add_contact", revolution_add_contact, 1);
|
696
|
+
rb_define_method(rb_cRevolution, "delete_contact", revolution_delete_contact, 1);
|
697
|
+
rb_define_method(rb_cRevolution, "get_contact_by_uid", revolution_get_contact_by_uid, 1);
|
698
|
+
rb_define_method(rb_cRevolution, "get_contacts_by_name", revolution_get_contacts_by_name, 1);
|
699
|
+
rb_define_method(rb_cRevolution, "get_contacts_with_query", revolution_get_contacts_with_query, 1);
|
700
|
+
rb_define_method(rb_cRevolution, "get_all_contacts", revolution_get_all_contacts, 0);
|
701
|
+
rb_define_method(rb_cRevolution, "get_all_appointments", revolution_get_all_appointments, 2);
|
702
|
+
rb_define_method(rb_cRevolution, "get_all_tasks", revolution_get_all_tasks, 0);
|
703
|
+
|
704
|
+
rb_cRevolutionException = rb_define_class_under(rb_mRevolution, "RevolutionException", rb_eStandardError);
|
787
705
|
|
788
706
|
g_type_init();
|
707
|
+
|
708
|
+
im_hash = g_hash_table_new(g_str_hash, g_str_equal);
|
709
|
+
g_hash_table_insert(im_hash, "AIMHOME", GINT_TO_POINTER(E_CONTACT_IM_AIM_HOME_1));
|
710
|
+
g_hash_table_insert(im_hash, "AIMWORK", GINT_TO_POINTER(E_CONTACT_IM_AIM_WORK_1));
|
789
711
|
}
|
790
712
|
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.
|
2
|
+
rubygems_version: 0.8.10
|
3
3
|
specification_version: 1
|
4
4
|
name: revolution
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "0.
|
7
|
-
date: 2005-
|
6
|
+
version: "0.5"
|
7
|
+
date: 2005-05-06
|
8
8
|
summary: Revolution is a binding for the Evolution email client
|
9
9
|
require_paths:
|
10
10
|
- ''
|