revolution 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/revolution.c +137 -89
- metadata +1 -1
data/revolution.c
CHANGED
@@ -1,14 +1,9 @@
|
|
1
1
|
#include <stdio.h>
|
2
|
-
|
3
2
|
#include "ruby.h"
|
4
|
-
|
5
|
-
#include "glib.h"
|
6
|
-
#include <glib-object.h>
|
7
|
-
|
8
3
|
#include <libebook/e-book.h>
|
9
4
|
#include <libecal/e-cal.h>
|
10
5
|
|
11
|
-
VALUE
|
6
|
+
VALUE cRevolution;
|
12
7
|
VALUE module;
|
13
8
|
|
14
9
|
/*
|
@@ -61,23 +56,25 @@ void copy_uid(const VALUE ruby_obj, ECalComponent* ev_obj) {
|
|
61
56
|
|
62
57
|
///////////////////////////////////////////////////////
|
63
58
|
// Tasks
|
64
|
-
VALUE
|
59
|
+
VALUE cTask;
|
65
60
|
|
66
61
|
/*
|
67
62
|
* call-seq:
|
68
|
-
* new() ->
|
63
|
+
* new() -> Task
|
69
64
|
*
|
70
|
-
* Creates a new
|
65
|
+
* Creates a new Task object
|
66
|
+
*
|
67
|
+
* Attributes:
|
68
|
+
* @uid - a unique id for this task
|
69
|
+
* @summary
|
70
|
+
* @description
|
71
|
+
* @start - the start Time
|
72
|
+
* @due - the due Time
|
73
|
+
* @status - 'Not started', 'In progress', 'Completed', 'Cancelled'
|
74
|
+
* @priority - 'Low', 'Medium', 'High', or nil
|
75
|
+
* @last_modification - Time of last modification
|
71
76
|
*/
|
72
77
|
static VALUE evTask_init(VALUE self) {
|
73
|
-
rb_define_attr(crEvTask, "uid", 1, 0);
|
74
|
-
rb_define_attr(crEvTask, "summary", 1, 0);
|
75
|
-
rb_define_attr(crEvTask, "description", 1, 0);
|
76
|
-
rb_define_attr(crEvTask, "start", 1, 0);
|
77
|
-
rb_define_attr(crEvTask, "due", 1, 0);
|
78
|
-
rb_define_attr(crEvTask, "status", 1, 0);
|
79
|
-
rb_define_attr(crEvTask, "priority", 1, 0);
|
80
|
-
rb_define_attr(crEvTask, "last_modification", 1, 0);
|
81
78
|
return Qtrue;
|
82
79
|
}
|
83
80
|
|
@@ -172,7 +169,7 @@ static VALUE revolution_get_all_tasks(VALUE self) {
|
|
172
169
|
|
173
170
|
for (l = objects; l;l = l->next) {
|
174
171
|
ECalComponent *ev_task = E_CAL_COMPONENT (l->data);
|
175
|
-
VALUE ruby_task = rb_class_new_instance(0, 0,
|
172
|
+
VALUE ruby_task = rb_class_new_instance(0, 0, cTask);
|
176
173
|
copy_into_task(ruby_task, ev_task);
|
177
174
|
rb_ary_push(result, ruby_task);
|
178
175
|
g_object_unref (ev_task);
|
@@ -183,26 +180,27 @@ static VALUE revolution_get_all_tasks(VALUE self) {
|
|
183
180
|
|
184
181
|
///////////////////////////////////////////////////////
|
185
182
|
// Calendar
|
186
|
-
VALUE
|
183
|
+
VALUE cAppointment;
|
187
184
|
|
188
185
|
/*
|
189
186
|
* call-seq:
|
190
|
-
* new() ->
|
187
|
+
* new() -> Appointment
|
191
188
|
*
|
192
|
-
* Creates a new
|
189
|
+
* Creates a new Appointment object
|
190
|
+
*
|
191
|
+
* Attributes:
|
192
|
+
* @uid - a unique id for this task
|
193
|
+
* @summary
|
194
|
+
* @location
|
195
|
+
* @organizer
|
196
|
+
* @start - start Time
|
197
|
+
* @end - end Time
|
198
|
+
* @alarm_set - is an alarm set for this appointment
|
199
|
+
* @busy_status
|
200
|
+
* @recurring - is this appointment recurring
|
201
|
+
* @last_modification
|
193
202
|
*/
|
194
203
|
static VALUE evAppointment_init(VALUE self) {
|
195
|
-
rb_define_attr(crEvAppointment, "uid", 1, 0);
|
196
|
-
rb_define_attr(crEvAppointment, "summary", 1, 0);
|
197
|
-
rb_define_attr(crEvAppointment, "location", 1, 0);
|
198
|
-
rb_define_attr(crEvAppointment, "organizer", 1, 0);
|
199
|
-
rb_define_attr(crEvAppointment, "start", 1, 0);
|
200
|
-
rb_define_attr(crEvAppointment, "end", 1, 0);
|
201
|
-
rb_define_attr(crEvAppointment, "last_modification", 1, 0);
|
202
|
-
rb_define_attr(crEvAppointment, "alarm_set", 1, 0);
|
203
|
-
rb_define_attr(crEvAppointment, "busy_status", 1, 0);
|
204
|
-
rb_define_attr(crEvAppointment, "recurring", 1, 0);
|
205
|
-
// INLINE RUBY CODE define an "all_day" method
|
206
204
|
return Qtrue;
|
207
205
|
}
|
208
206
|
|
@@ -282,7 +280,7 @@ static VALUE revolution_get_all_appointments(VALUE self, VALUE start, VALUE end)
|
|
282
280
|
|
283
281
|
for (l = results; l;l = l->next) {
|
284
282
|
ECalComponent *ev_appt = E_CAL_COMPONENT(l->data);
|
285
|
-
VALUE ruby_appt = rb_class_new_instance(0, 0,
|
283
|
+
VALUE ruby_appt = rb_class_new_instance(0, 0, cAppointment);
|
286
284
|
copy_into_appt(ruby_appt, ev_appt);
|
287
285
|
rb_ary_push(result, ruby_appt);
|
288
286
|
g_object_unref (ev_appt);
|
@@ -296,69 +294,73 @@ static VALUE revolution_get_all_appointments(VALUE self, VALUE start, VALUE end)
|
|
296
294
|
|
297
295
|
///////////////////////////////////////////////////////
|
298
296
|
// Address Book
|
299
|
-
VALUE
|
300
|
-
VALUE
|
301
|
-
VALUE
|
297
|
+
VALUE cContact;
|
298
|
+
VALUE cContactAddress;
|
299
|
+
VALUE cContactIMAddress;
|
302
300
|
|
303
301
|
/*
|
304
302
|
* call-seq:
|
305
|
-
* new() ->
|
303
|
+
* new() -> Contact
|
306
304
|
*
|
307
|
-
* Creates a new
|
305
|
+
* Creates a new Contact object
|
306
|
+
*
|
307
|
+
* Attributes:
|
308
|
+
* @uid - the unique ID for this contact
|
309
|
+
* @first_name
|
310
|
+
* @last_name
|
311
|
+
* @email_addresses - a Hash of type->addr, i.e. 'HOME'->['tom@home.com', 'tom@bar.com']
|
312
|
+
* @birthday - a Time
|
313
|
+
* @home_phone
|
314
|
+
* @work_phone
|
315
|
+
* @mobile_phone
|
316
|
+
* @home_address - an ContactAddress object
|
317
|
+
* @work_address - an ContactAddress object
|
318
|
+
* @other_address - an ContactAddress object
|
319
|
+
* @organization - employee
|
320
|
+
* @title - job title
|
321
|
+
* @im_addresses - an Array of ContactIMAddress objects
|
308
322
|
*/
|
309
323
|
static VALUE evContact_init(VALUE self) {
|
310
|
-
rb_define_attr(crEvContact, "uid", 1, 0);
|
311
|
-
rb_define_attr(crEvContact, "first_name", 1, 0);
|
312
|
-
rb_define_attr(crEvContact, "last_name", 1, 0);
|
313
|
-
rb_define_attr(crEvContact, "home_email", 1, 0);
|
314
|
-
rb_define_attr(crEvContact, "work_email", 1, 0);
|
315
|
-
rb_define_attr(crEvContact, "email_addresses", 1, 0);
|
316
|
-
rb_define_attr(crEvContact, "birthday", 1, 0);
|
317
|
-
rb_define_attr(crEvContact, "home_phone", 1, 0);
|
318
|
-
rb_define_attr(crEvContact, "work_phone", 1, 0);
|
319
|
-
rb_define_attr(crEvContact, "mobile_phone", 1, 0);
|
320
|
-
rb_define_attr(crEvContact, "home_address", 1, 0);
|
321
|
-
rb_define_attr(crEvContact, "work_address", 1, 0);
|
322
|
-
rb_define_attr(crEvContact, "other_address", 1, 0);
|
323
|
-
rb_define_attr(crEvContact, "organization", 1, 0);
|
324
|
-
rb_define_attr(crEvContact, "title", 1, 0);
|
325
|
-
rb_define_attr(crEvContact, "im_addresses", 1, 0);
|
326
324
|
return Qtrue;
|
327
325
|
}
|
328
326
|
|
329
327
|
/*
|
330
328
|
* call-seq:
|
331
|
-
* new() ->
|
329
|
+
* new() -> ContactIMAddress
|
332
330
|
*
|
333
|
-
* Creates a new
|
331
|
+
* Creates a new ContactIMAddress object
|
332
|
+
*
|
333
|
+
* Attributes:
|
334
|
+
* @provider - i.e., AOL, Yahoo
|
335
|
+
* @address - i.e., tom_copeland
|
336
|
+
* @type - HOME or WORK
|
334
337
|
*/
|
335
338
|
static VALUE evContactIMAddress_init(VALUE self) {
|
336
|
-
rb_define_attr(crEvContactIMAddress, "provider", 1, 0);
|
337
|
-
rb_define_attr(crEvContactIMAddress, "location", 1, 0);
|
338
|
-
rb_define_attr(crEvContactIMAddress, "address", 1, 0);
|
339
339
|
return Qtrue;
|
340
340
|
}
|
341
341
|
/*
|
342
342
|
* call-seq:
|
343
|
-
* new() ->
|
343
|
+
* new() -> ContactAddress
|
344
344
|
*
|
345
|
-
* Creates a new
|
345
|
+
* Creates a new ContactAddress object
|
346
|
+
*
|
347
|
+
* Attributes:
|
348
|
+
* @address_format
|
349
|
+
* @po - P.O. Box
|
350
|
+
* @ext
|
351
|
+
* @street
|
352
|
+
* @locality
|
353
|
+
* @region
|
354
|
+
* @code
|
355
|
+
* @country
|
346
356
|
*/
|
347
357
|
static VALUE evContactAddress_init(VALUE self) {
|
348
|
-
rb_define_attr(crEvContactAddress, "address_format", 1, 0);
|
349
|
-
rb_define_attr(crEvContactAddress, "po", 1, 0);
|
350
|
-
rb_define_attr(crEvContactAddress, "ext", 1, 0);
|
351
|
-
rb_define_attr(crEvContactAddress, "street", 1, 0);
|
352
|
-
rb_define_attr(crEvContactAddress, "locality", 1, 0);
|
353
|
-
rb_define_attr(crEvContactAddress, "region", 1, 0);
|
354
|
-
rb_define_attr(crEvContactAddress, "code", 1, 0);
|
355
|
-
rb_define_attr(crEvContactAddress, "country", 1, 0);
|
356
358
|
return Qtrue;
|
357
359
|
}
|
358
360
|
|
359
361
|
void copy_in_address(EContactAddress* address, VALUE ruby_contact, char* field) {
|
360
362
|
if (address) {
|
361
|
-
VALUE rb_addr = rb_class_new_instance(0, 0,
|
363
|
+
VALUE rb_addr = rb_class_new_instance(0, 0, cContactAddress);
|
362
364
|
rb_iv_set(rb_addr, "@address_format", address->address_format ? rb_str_new2(address->address_format) : Qnil);
|
363
365
|
rb_iv_set(rb_addr, "@po", address->po ? rb_str_new2(address->po) : Qnil);
|
364
366
|
rb_iv_set(rb_addr, "@ext", address->ext ? rb_str_new2(address->ext) : Qnil);
|
@@ -377,7 +379,7 @@ void copy_in_im_address(VALUE im_addresses, char* address, char* provider, char*
|
|
377
379
|
if (!address) {
|
378
380
|
return;
|
379
381
|
}
|
380
|
-
VALUE rb_addr = rb_class_new_instance(0, 0,
|
382
|
+
VALUE rb_addr = rb_class_new_instance(0, 0, cContactIMAddress);
|
381
383
|
rb_iv_set(rb_addr, "@provider", rb_str_new2(provider));
|
382
384
|
rb_iv_set(rb_addr, "@location", rb_str_new2(location));
|
383
385
|
rb_iv_set(rb_addr, "@address", rb_str_new2(address));
|
@@ -492,7 +494,7 @@ static VALUE revolution_get_all_contacts(VALUE self) {
|
|
492
494
|
}
|
493
495
|
for (l = results; l; l = l->next) {
|
494
496
|
EContact* ev_contact = E_CONTACT(l->data);
|
495
|
-
VALUE ruby_contact = rb_class_new_instance(0, 0,
|
497
|
+
VALUE ruby_contact = rb_class_new_instance(0, 0, cContact);
|
496
498
|
copy_into_contact(ruby_contact, ev_contact);
|
497
499
|
rb_ary_push(result, ruby_contact);
|
498
500
|
g_object_unref(ev_contact);
|
@@ -510,24 +512,70 @@ static VALUE revolution_get_all_contacts(VALUE self) {
|
|
510
512
|
void Init_revolution() {
|
511
513
|
module = rb_define_module("Revolution");
|
512
514
|
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
515
|
+
cContact = rb_define_class_under(module, "Contact", rb_cObject);
|
516
|
+
rb_define_attr(cContact, "uid", 1, 0);
|
517
|
+
rb_define_attr(cContact, "first_name", 1, 0);
|
518
|
+
rb_define_attr(cContact, "last_name", 1, 0);
|
519
|
+
rb_define_attr(cContact, "home_email", 1, 0);
|
520
|
+
rb_define_attr(cContact, "work_email", 1, 0);
|
521
|
+
rb_define_attr(cContact, "email_addresses", 1, 0);
|
522
|
+
rb_define_attr(cContact, "birthday", 1, 0);
|
523
|
+
rb_define_attr(cContact, "home_phone", 1, 0);
|
524
|
+
rb_define_attr(cContact, "work_phone", 1, 0);
|
525
|
+
rb_define_attr(cContact, "mobile_phone", 1, 0);
|
526
|
+
rb_define_attr(cContact, "home_address", 1, 0);
|
527
|
+
rb_define_attr(cContact, "work_address", 1, 0);
|
528
|
+
rb_define_attr(cContact, "other_address", 1, 0);
|
529
|
+
rb_define_attr(cContact, "organization", 1, 0);
|
530
|
+
rb_define_attr(cContact, "title", 1, 0);
|
531
|
+
rb_define_attr(cContact, "im_addresses", 1, 0);
|
532
|
+
rb_define_method(cContact, "initialize", evContact_init, 0);
|
533
|
+
cContactAddress = rb_define_class_under(module, "ContactAddress", rb_cObject);
|
534
|
+
rb_define_attr(cContactAddress, "address_format", 1, 0);
|
535
|
+
rb_define_attr(cContactAddress, "po", 1, 0);
|
536
|
+
rb_define_attr(cContactAddress, "ext", 1, 0);
|
537
|
+
rb_define_attr(cContactAddress, "street", 1, 0);
|
538
|
+
rb_define_attr(cContactAddress, "locality", 1, 0);
|
539
|
+
rb_define_attr(cContactAddress, "region", 1, 0);
|
540
|
+
rb_define_attr(cContactAddress, "code", 1, 0);
|
541
|
+
rb_define_attr(cContactAddress, "country", 1, 0);
|
542
|
+
rb_define_method(cContactAddress, "initialize", evContactAddress_init, 0);
|
543
|
+
cContactIMAddress = rb_define_class_under(module, "ContactIMAddress", rb_cObject);
|
544
|
+
rb_define_attr(cContactIMAddress, "provider", 1, 0);
|
545
|
+
rb_define_attr(cContactIMAddress, "location", 1, 0);
|
546
|
+
rb_define_attr(cContactIMAddress, "address", 1, 0);
|
547
|
+
rb_define_method(cContactIMAddress, "initialize", evContactIMAddress_init, 0);
|
548
|
+
|
549
|
+
cAppointment = rb_define_class_under(module, "Appointment", rb_cObject);
|
550
|
+
rb_define_attr(cAppointment, "uid", 1, 0);
|
551
|
+
rb_define_attr(cAppointment, "summary", 1, 0);
|
552
|
+
rb_define_attr(cAppointment, "location", 1, 0);
|
553
|
+
rb_define_attr(cAppointment, "organizer", 1, 0);
|
554
|
+
rb_define_attr(cAppointment, "start", 1, 0);
|
555
|
+
rb_define_attr(cAppointment, "end", 1, 0);
|
556
|
+
rb_define_attr(cAppointment, "last_modification", 1, 0);
|
557
|
+
rb_define_attr(cAppointment, "alarm_set", 1, 0);
|
558
|
+
rb_define_attr(cAppointment, "busy_status", 1, 0);
|
559
|
+
rb_define_attr(cAppointment, "recurring", 1, 0);
|
560
|
+
rb_define_method(cAppointment, "initialize", evAppointment_init, 0);
|
561
|
+
// INLINE RUBY CODE define an "all_day" method
|
525
562
|
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
563
|
+
cTask = rb_define_class_under(module, "Task", rb_cObject);
|
564
|
+
rb_define_attr(cTask, "uid", 1, 0);
|
565
|
+
rb_define_attr(cTask, "summary", 1, 0);
|
566
|
+
rb_define_attr(cTask, "description", 1, 0);
|
567
|
+
rb_define_attr(cTask, "start", 1, 0);
|
568
|
+
rb_define_attr(cTask, "due", 1, 0);
|
569
|
+
rb_define_attr(cTask, "status", 1, 0);
|
570
|
+
rb_define_attr(cTask, "priority", 1, 0);
|
571
|
+
rb_define_attr(cTask, "last_modification", 1, 0);
|
572
|
+
rb_define_method(cTask, "initialize", evTask_init, 0);
|
573
|
+
|
574
|
+
cRevolution = rb_define_class_under(module, "Revolution", rb_cObject);
|
575
|
+
rb_define_method(cRevolution, "initialize", revolution_init, 0);
|
576
|
+
rb_define_method(cRevolution, "get_all_contacts", revolution_get_all_contacts, 0);
|
577
|
+
rb_define_method(cRevolution, "get_all_appointments", revolution_get_all_appointments, 2);
|
578
|
+
rb_define_method(cRevolution, "get_all_tasks", revolution_get_all_tasks, 0);
|
531
579
|
|
532
580
|
g_type_init();
|
533
581
|
}
|