Show last authors
1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc /}}
3 {{/box}}
4
5 = vCard 4 =
6
7 == How to check if vCard/CardDAV support is enabled ==
8
9 * VCARD_ENABLED is defined
10 * the VCard suite of liblinphone tester is OK
11
12 == vCards ==
13
14 Linphone library will edit the FN and IMPP fields when using {{code language="C"}}int linphone_friend_set_address(LinphoneFriend *lf, const LinphoneAddress *addr){{/code}} and {{code language="C"}}int linphone_friend_set_name(LinphoneFriend *lf, const char *name){{/code}} if the LinphoneFriend has a vCard attached.
15
16 On Android, the vCard update for SIP address and display name is done using {{code language="java"}}LinphoneFriend.setAddress(LinphoneAddress addr){{/code}} and {{code language="java"}}LinphoneFriend.setName(String name){{/code}}
17
18 == Import / Export of Friends from/to vCards ==
19
20 === How to import LinphoneFriends from a vCard 4 file ===
21
22 Call the {{code language="C"}}int linphone_friend_list_import_friends_from_vcard4_file(LinphoneFriendList *list, const char *vcard_file){{/code}} or {{code language="C"}}int linphone_friend_list_import_friends_from_vcard4_buffer(LinphoneFriendList *list, const char *vcard_buffer){{/code}} methods. If the operation succeeds, it returns the number of LinphoneFriend created.
23
24 On Android, use {{code language="java"}}LinphoneFriendList.importFriendsFromVCardFile(String path){{/code}} or {{code language="java"}}LinphoneFriendList.importFriendsFromVCardBuffer(String buffer){{/code}} methods.
25
26 === How to export LinphoneFriends to a vCard 4 file ===
27
28 Call the {{code language="C"}}void linphone_friend_list_export_friends_as_vcard4_file(LinphoneFriendList *list, const char *vcard_file){{/code}} method. If the file already exists, it is overidden. If there is no LinphoneFriend (with a vCard attached or none at all), the file will be empty.
29
30 On Android, use {{code language="java"}}LinphoneFriendList.exportFriendsToVCardFile(String path){{/code}} method.
31
32 == Supported RFCs ==
33
34 Currently the following RFCs regarding vCards and CardDAV are supported:
35
36 * [[RFC 6350>>https://tools.ietf.org/html/rfc6350]]
37 * [[RFC 6474>>https://tools.ietf.org/html/rfc6474]]
38 * [[RFC 6352>>https://tools.ietf.org/html/rfc6352]]
39
40 == vCards database storage ==
41
42 First, linphone library has to be compiled with SQLite.
43
44 Then you can enable the friend storage using {{code language="C"}}void linphone_core_set_friends_database_path(LinphoneCore *lc, const char *path){{/code}}.
45
46 On Android, use {{code language="java"}}void LinphoneCore.setFriendsDatabasePath(String path){{/code}}.
47
48 Previous friends (stored in linphonerc) will be moved to the database storage on first call, and LinphoneFriend objects remain available through the same APIs as before.
49
50 = CardDAV =
51
52 When vCard support is enabled, CardDAV synchronization is also available.
53
54 A few requirements for the CardDAV server are:
55
56 * Authentication (if any) must be Digest (and not Basic)
57 * It must support vCards version 4
58
59 So far, the following CardDAV servers have been successfully tested:
60
61 * sabre/dav 3.0.5 and 3.0.6
62 * sabre/dav 3.1.0
63
64 == Configuring a CardDAV addressbook synchronization ==
65
66 CardDAV sync is enabled on a LinphoneFriendList object. This way you can have CardDAV sync with multiple servers/addressbooks easily.
67
68
69 First of all, create a LinphoneFriendList that will contain the local LinphoneFriends:
70
71 {{code language="C"}}
72 LinphoneFriendList *lfl = linphone_core_create_friend_list(lc);
73 {{/code}}
74
75 It is recommended to listen for LinphoneFriendList events:
76
77 {{code language="C"}}
78 LinphoneFriendListCbs *cbs = linphone_friend_list_get_callbacks(lfl);
79
80 linphone_friend_list_cbs_set_contact_created(cbs, carddav_contact_created);
81
82 linphone_friend_list_cbs_set_contact_deleted(cbs, carddav_contact_deleted);
83
84 linphone_friend_list_cbs_set_contact_updated(cbs, carddav_contact_updated);
85
86 linphone_friend_list_cbs_set_sync_status_changed(cbs, carddav_sync_status_changed);
87 {{/code}}
88
89 Now add the LinphoneFriendList in the LinphoneCore:
90
91 {{code language="C"}}
92 linphone_core_add_friend_list(lc, lfl);
93 {{/code}}
94
95 Then, configure the CardDAV remote address:
96
97 {{code language="C"}}
98 linphone_friend_list_set_uri(lfl, "http://192.168.0.230/sabredav/addressbookserver.php/addressbooks/sylvain/default");
99 {{/code}}
100
101 If authentication is needed, add an auth info:
102
103 {{code language="ini"}}
104 [auth_info_0]
105 domain=192.168.0.230
106 username=sylvain
107 ha1=<ha1> or password=<password>
108 realm=SabreDAV
109 {{/code}}
110
111 Finally, do a synchronization:
112
113 {{code language="C"}}
114 linphone_friend_list_synchronize_friends_from_server(lfl);
115 {{/code}}
116
117 Note that when a change is detected on a LinphoneFriend between {{code language="c"}}edit(){{/code}} and {{code language="c"}}done(){{/code}}, the LinphoneFriend will be added to a "dirty" list. Every second (in the iterate), if one or more LinphoneFriend are found in the dirty list, they are pushed to the CardDAV server automatically. Also when a LinphoneFriend is added to a LinphoneFriendList, it is automatically added to the dirty list.
118
119
120 On Android, there is a CardDAV tutorial available in src/org/linphone/tutorials/TutorialCardDavSync.java