1 #include
2 #include
3
4 void
5 create_person (void)
6 {
7 GError *error = NULL;
8
9
10 if (!sl_init (&error))
11 {
12 example_error (error);
13 }
14
15
16 SlPerson *tim = sl_person_new (g_strdup ("Tim"), g_strdup ("Smith"));
17
18
19 sl_person_add (tim, SL_ATTR_EMAIL, g_strdup ("tim@example.org"));
20 sl_person_add (tim, SL_ATTR_EMAIL, g_strdup ("tim@jabber.org"));
21
22
23 if (!sl_book_add_person (SL_BOOK_DEFAULT, tim, &error))
24 {
25 example_error (error);
26 }
27
28
29 sl_person_set (tim, SL_ATTR_TELEPHONE, g_strdup ("007 123456789"));
30
31
32 sl_person_add (tim, SL_ATTR_TELEPHONE, g_strdup ("007 987654321"));
33
34
35 SlAddress *addr = sl_address_new ();
36 addr->street = "Abbey Road";
37 addr->country = "Free-World";
38 sl_person_set (tim, SL_ATTR_ADDRESS, addr);
39
40
41 GDate *bday = g_date_new_dmy (3, 2, 1980);
42 sl_person_set (tim, SL_ATTR_BIRTHDAY, bday);
43
44
45 sl_person_set_at (tim, SL_ATTR_EMAIL, 1, g_strdup ("tim_smith@jabber.org"));
46
47
48 sl_person_set_nick (tim, g_strdup ("Timmy"));
49
50
51
52 sl_person_set (tim, "mood", g_strdup ("happy"));
53
54
55 if (!sl_person_commit (tim, &error))
56 {
57 example_error (error);
58 }
59
60
61 g_object_unref (tim);
62 sl_cleanup ();
63 }