carddav.h 5.8 KB
Newer Older
Sylvain Berfini's avatar
Sylvain Berfini committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
carddav.h
Copyright (C) 2015  Belledonne Communications SARL

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
Sylvain Berfini's avatar
Sylvain Berfini committed
18 19 20 21 22
*/

#ifndef LINPHONE_CARDDAV_H
#define LINPHONE_CARDDAV_H

23
#include "linphone/core.h"
24

Sylvain Berfini's avatar
Sylvain Berfini committed
25 26 27
#ifdef __cplusplus
extern "C" {
#endif
28 29 30 31 32

/**
 * @addtogroup carddav_vcard
 * @{
 */
33 34
	
typedef struct _LinphoneCardDavContext LinphoneCardDavContext;
Sylvain Berfini's avatar
Sylvain Berfini committed
35

36 37 38
typedef enum _LinphoneCardDavQueryType {
	LinphoneCardDavQueryTypePropfind,
	LinphoneCardDavQueryTypeAddressbookQuery,
39 40 41
	LinphoneCardDavQueryTypeAddressbookMultiget,
	LinphoneCardDavQueryTypePut,
	LinphoneCardDavQueryTypeDelete
42
} LinphoneCardDavQueryType;
Sylvain Berfini's avatar
Sylvain Berfini committed
43

44 45 46 47 48 49 50
typedef struct _LinphoneCardDavQuery LinphoneCardDavQuery;

typedef struct _LinphoneCardDavResponse LinphoneCardDavResponse;

/**
 * Callback used to notify a new contact has been created on the CardDAV server
**/
51
typedef void (*LinphoneCardDavContactCreatedCb)(LinphoneCardDavContext *cdc, LinphoneFriend *lf);
52 53 54 55

/**
 * Callback used to notify a contact has been updated on the CardDAV server
**/
56
typedef void (*LinphoneCardDavContactUpdatedCb)(LinphoneCardDavContext *cdc, LinphoneFriend *new_friend, LinphoneFriend *old_friend);
57 58 59 60

/**
 * Callback used to notify a contact has been removed on the CardDAV server
**/
61
typedef void (*LinphoneCardDavContactRemovedCb)(LinphoneCardDavContext *cdc, LinphoneFriend *lf);
62 63 64 65 66 67 68 69

/**
 * Callback used to notify a contact has been removed on the CardDAV server
**/
typedef void (*LinphoneCardDavSynchronizationDoneCb)(LinphoneCardDavContext *cdc, bool_t success, const char *message);

/**
 * Creates a CardDAV context for all related operations
70
 * @param lfl LinphoneFriendList object
71 72
 * @return LinphoneCardDavContext object if vCard support is enabled and server URL is available, NULL otherwise
 */
73
LINPHONE_PUBLIC LinphoneCardDavContext* linphone_carddav_context_new(LinphoneFriendList *lfl);
74 75 76 77 78

/**
 * Deletes a LinphoneCardDavContext object
 * @param cdc LinphoneCardDavContext object
 */
79
LINPHONE_PUBLIC void linphone_carddav_context_destroy(LinphoneCardDavContext *cdc);
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121

/**
 * Sets a user pointer to the LinphoneCardDAVContext object
 * @param cdc LinphoneCardDavContext object
 * @param ud The user data pointer
 */
LINPHONE_PUBLIC void linphone_carddav_set_user_data(LinphoneCardDavContext *cdc, void *ud);

/**
 * Gets the user pointer set in the LinphoneCardDAVContext object
 * @param cdc LinphoneCardDavContext object
 * @return The user data pointer if set, NULL otherwise
 */
LINPHONE_PUBLIC void* linphone_carddav_get_user_data(LinphoneCardDavContext *cdc);

/**
 * Starts a synchronization with the remote server to update local friends with server changes
 * @param cdc LinphoneCardDavContext object
 */
LINPHONE_PUBLIC void linphone_carddav_synchronize(LinphoneCardDavContext *cdc);

/**
 * Sends a LinphoneFriend to the CardDAV server for update or creation
 * @param cdc LinphoneCardDavContext object
 * @param lf a LinphoneFriend object to update/create on the server
 */
LINPHONE_PUBLIC void linphone_carddav_put_vcard(LinphoneCardDavContext *cdc, LinphoneFriend *lf);

/**
 * Deletes a LinphoneFriend on the CardDAV server 
 * @param cdc LinphoneCardDavContext object
 * @param lf a LinphoneFriend object to delete on the server
 */
LINPHONE_PUBLIC void linphone_carddav_delete_vcard(LinphoneCardDavContext *cdc, LinphoneFriend *lf);

/**
 * Set the synchronization done callback.
 * @param cdc LinphoneCardDavContext object
 * @param cb The synchronization done callback to be used.
 */
LINPHONE_PUBLIC void linphone_carddav_set_synchronization_done_callback(LinphoneCardDavContext *cdc, LinphoneCardDavSynchronizationDoneCb cb);

122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
/**
 * Set the new contact callback.
 * @param cdc LinphoneCardDavContext object
 * @param cb The new contact callback to be used.
 */
LINPHONE_PUBLIC void linphone_carddav_set_new_contact_callback(LinphoneCardDavContext *cdc, LinphoneCardDavContactCreatedCb cb);

/**
 * Set the updated contact callback.
 * @param cdc LinphoneCardDavContext object
 * @param cb The updated contact callback to be used.
 */
LINPHONE_PUBLIC void linphone_carddav_set_updated_contact_callback(LinphoneCardDavContext *cdc, LinphoneCardDavContactUpdatedCb cb);

/**
 * Set the removed contact callback.
 * @param cdc LinphoneCardDavContext object
 * @param cb The removed contact callback to be used.
 */
LINPHONE_PUBLIC void linphone_carddav_set_removed_contact_callback(LinphoneCardDavContext *cdc, LinphoneCardDavContactRemovedCb cb);

143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
/**
 * Retrieves the current cTag value for the remote server
 * @param cdc LinphoneCardDavContext object
 */
void linphone_carddav_get_current_ctag(LinphoneCardDavContext *cdc);

/**
 * Retrieves a list of all the vCards on server side to be able to detect changes
 * @param cdc LinphoneCardDavContext object
 */
void linphone_carddav_fetch_vcards(LinphoneCardDavContext *cdc);

/**
 * Download asked vCards from the server
 * @param cdc LinphoneCardDavContext object
 * @param vcards_to_pull a MSList of LinphoneCardDavResponse objects with at least the url field filled
 */
void linphone_carddav_pull_vcards(LinphoneCardDavContext *cdc, MSList *vcards_to_pull);
Sylvain Berfini's avatar
Sylvain Berfini committed
161

162 163 164 165
/**
 * @}
 */

Sylvain Berfini's avatar
Sylvain Berfini committed
166 167 168 169
#ifdef __cplusplus
}
#endif

170
#endif