Commit c8ae2974 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Moved and renamed some vcard methods for python wrapper

parent 1b0c7e3f
......@@ -115,7 +115,7 @@ static void linphone_carddav_vcards_pulled(LinphoneCardDavContext *cdc, bctbx_li
while (vCards) {
LinphoneCardDavResponse *vCard = (LinphoneCardDavResponse *)vCards->data;
if (vCard) {
LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer(cdc->friend_list->lc->vcard_context, vCard->vcard);
LinphoneVcard *lvc = linphone_vcard_context_get_vcard_from_buffer(cdc->friend_list->lc->vcard_context, vCard->vcard);
LinphoneFriend *lf = NULL;
bctbx_list_t *local_friend = NULL;
......
......@@ -1256,7 +1256,7 @@ static int create_friend(void *data, int argc, char **argv, char **colName) {
LinphoneVcard *vcard = NULL;
unsigned int storage_id = (unsigned int)atoi(argv[0]);
vcard = linphone_vcard_new_from_vcard4_buffer(context, argv[6]);
vcard = linphone_vcard_context_get_vcard_from_buffer(context, argv[6]);
if (vcard) {
linphone_vcard_set_etag(vcard, argv[7]);
linphone_vcard_set_url(vcard, argv[8]);
......
......@@ -781,7 +781,7 @@ int linphone_friend_list_import_friends_from_vcard4_file(LinphoneFriendList *lis
return -1;
}
vcards = linphone_vcard_list_from_vcard4_file(list->lc->vcard_context, vcard_file);
vcards = linphone_vcard_context_get_vcard_list_from_file(list->lc->vcard_context, vcard_file);
vcards_iterator = vcards;
if (!vcards) {
ms_error("Failed to parse the file %s", vcard_file);
......@@ -820,7 +820,7 @@ int linphone_friend_list_import_friends_from_vcard4_buffer(LinphoneFriendList *l
return -1;
}
vcards = linphone_vcard_list_from_vcard4_buffer(list->lc->vcard_context, vcard_buffer);
vcards = linphone_vcard_context_get_vcard_list_from_buffer(list->lc->vcard_context, vcard_buffer);
vcards_iterator = vcards;
if (!vcards) {
ms_error("Failed to parse the buffer");
......
......@@ -1555,11 +1555,6 @@ char *linphone_presence_model_to_xml(LinphonePresenceModel *model) ;
void linphone_call_check_ice_session(LinphoneCall *call, IceRole role, bool_t is_reinvite);
LinphoneVcardContext* linphone_vcard_context_new(void);
void linphone_vcard_context_destroy(LinphoneVcardContext *context);
void* linphone_vcard_context_get_user_data(LinphoneVcardContext *context);
void linphone_vcard_context_set_user_data(LinphoneVcardContext *context, void *data);
#ifdef __cplusplus
}
#endif
......
......@@ -53,7 +53,7 @@ void linphone_vcard_context_destroy(LinphoneVcardContext *context) {
}
}
void* linphone_vcard_context_get_user_data(LinphoneVcardContext *context) {
void* linphone_vcard_context_get_user_data(const LinphoneVcardContext *context) {
return context ? context->user_data : NULL;
}
......@@ -82,11 +82,13 @@ void linphone_vcard_free(LinphoneVcard *vCard) {
ms_free(vCard);
}
bctbx_list_t* linphone_vcard_list_from_vcard4_file(LinphoneVcardContext *context, const char *filename) {
bctbx_list_t* linphone_vcard_context_get_vcard_list_from_file(LinphoneVcardContext *context, const char *filename) {
bctbx_list_t *result = NULL;
if (context && filename) {
belcard::BelCardParser *parser = context->parser;
shared_ptr<belcard::BelCardList> belCards = parser->parseFile(filename);
if (!context->parser) {
context->parser = new belcard::BelCardParser();
}
shared_ptr<belcard::BelCardList> belCards = context->parser->parseFile(filename);
if (belCards) {
for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) {
shared_ptr<belcard::BelCard> belCard = (*it);
......@@ -98,11 +100,13 @@ bctbx_list_t* linphone_vcard_list_from_vcard4_file(LinphoneVcardContext *context
return result;
}
bctbx_list_t* linphone_vcard_list_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer) {
bctbx_list_t* linphone_vcard_context_get_vcard_list_from_buffer(LinphoneVcardContext *context, const char *buffer) {
bctbx_list_t *result = NULL;
if (context && buffer) {
belcard::BelCardParser *parser = context->parser;
shared_ptr<belcard::BelCardList> belCards = parser->parse(buffer);
if (!context->parser) {
context->parser = new belcard::BelCardParser();
}
shared_ptr<belcard::BelCardList> belCards = context->parser->parse(buffer);
if (belCards) {
for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) {
shared_ptr<belcard::BelCard> belCard = (*it);
......@@ -114,11 +118,13 @@ bctbx_list_t* linphone_vcard_list_from_vcard4_buffer(LinphoneVcardContext *conte
return result;
}
LinphoneVcard* linphone_vcard_new_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer) {
LinphoneVcard* linphone_vcard_context_get_vcard_from_buffer(LinphoneVcardContext *context, const char *buffer) {
LinphoneVcard *vCard = NULL;
if (context && buffer) {
belcard::BelCardParser *parser = context->parser;
shared_ptr<belcard::BelCard> belCard = parser->parseOne(buffer);
if (!context->parser) {
context->parser = new belcard::BelCardParser();
}
shared_ptr<belcard::BelCard> belCard = context->parser->parseOne(buffer);
if (belCard) {
vCard = linphone_vcard_new_from_belcard(belCard);
} else {
......
......@@ -37,10 +37,36 @@ extern "C"
*/
/**
* Linphone vCard context object.
* The LinphoneVcardContext object.
*/
typedef struct _LinphoneVcardContext LinphoneVcardContext;
/**
* Creates a vCard context to reuse the same BelCardParser object
* @return a new LinphoneVcardContext object
*/
LINPHONE_PUBLIC LinphoneVcardContext* linphone_vcard_context_new(void);
/**
* Destroys the vCard context
* @param[in] context a LinphoneVcardContext object
*/
LINPHONE_PUBLIC void linphone_vcard_context_destroy(LinphoneVcardContext *context);
/**
* Gets the user data set in the LinphoneVcardContext
* @param[in] context a LinphoneVcardContext object
* @return the user data pointer
*/
LINPHONE_PUBLIC void* linphone_vcard_context_get_user_data(const LinphoneVcardContext *context);
/**
* Sets the user data in the LinphoneVcardContext
* @param[in] context a LinphoneVcardContext object
* @param[in] data the user data pointer
*/
LINPHONE_PUBLIC void linphone_vcard_context_set_user_data(LinphoneVcardContext *context, void *data);
/**
* The LinphoneVcard object.
*/
......@@ -48,6 +74,7 @@ typedef struct _LinphoneVcard LinphoneVcard;
/**
* Creates a LinphoneVcard object that has a pointer to an empty vCard
* @return a new LinphoneVcard object
*/
LINPHONE_PUBLIC LinphoneVcard* linphone_vcard_new(void);
......@@ -59,24 +86,27 @@ LINPHONE_PUBLIC void linphone_vcard_free(LinphoneVcard *vCard);
/**
* Uses belcard to parse the content of a file and returns all the vcards it contains as LinphoneVcards, or NULL if it contains none.
* @param[in] context the vCard context to use (speed up the process by not creating a Belcard parser each time)
* @param[in] file the path to the file to parse
* @return \mslist{LinphoneVcard}
*/
LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_list_from_vcard4_file(LinphoneVcardContext *context, const char *file);
LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_context_get_vcard_list_from_file(LinphoneVcardContext *context, const char *file);
/**
* Uses belcard to parse the content of a buffer and returns all the vcards it contains as LinphoneVcards, or NULL if it contains none.
* @param[in] context the vCard context to use (speed up the process by not creating a Belcard parser each time)
* @param[in] buffer the buffer to parse
* @return \mslist{LinphoneVcard}
*/
LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_list_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer);
LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_context_get_vcard_list_from_buffer(LinphoneVcardContext *context, const char *buffer);
/**
* Uses belcard to parse the content of a buffer and returns one vCard if possible, or NULL otherwise.
* @param[in] context the vCard context to use (speed up the process by not creating a Belcard parser each time)
* @param[in] buffer the buffer to parse
* @return a LinphoneVcard if one could be parsed, or NULL otherwise
*/
LINPHONE_PUBLIC LinphoneVcard* linphone_vcard_new_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer);
LINPHONE_PUBLIC LinphoneVcard* linphone_vcard_context_get_vcard_from_buffer(LinphoneVcardContext *context, const char *buffer);
/**
* Returns the vCard4 representation of the LinphoneVcard.
......
......@@ -35,7 +35,7 @@ void linphone_vcard_context_destroy(LinphoneVcardContext *context) {
}
}
void* linphone_vcard_context_get_user_data(LinphoneVcardContext *context) {
void* linphone_vcard_context_get_user_data(const LinphoneVcardContext *context) {
return context ? context->user_data : NULL;
}
......@@ -55,15 +55,15 @@ void linphone_vcard_free(LinphoneVcard *vCard) {
}
MSList* linphone_vcard_list_from_vcard4_file(LinphoneVcardContext *context, const char *filename) {
MSList* linphone_vcard_context_get_vcard_list_from_file(LinphoneVcardContext *context, const char *filename) {
return NULL;
}
MSList* linphone_vcard_list_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer) {
MSList* linphone_vcard_context_get_vcard_list_from_buffer(LinphoneVcardContext *context, const char *buffer) {
return NULL;
}
LinphoneVcard* linphone_vcard_new_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer) {
LinphoneVcard* linphone_vcard_context_get_vcard_from_buffer(LinphoneVcardContext *context, const char *buffer) {
return NULL;
}
......
......@@ -138,7 +138,7 @@ static void linphone_vcard_update_existing_friends_test(void) {
static void linphone_vcard_phone_numbers_and_sip_addresses(void) {
LinphoneCoreManager* manager = linphone_core_manager_new2("empty_rc", FALSE);
LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sberfini@sip.linphone.org\r\nIMPP;TYPE=home:sip:sylvain@sip.linphone.org\r\nTEL;TYPE=work:0952636505\r\nEND:VCARD\r\n");
LinphoneVcard *lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sberfini@sip.linphone.org\r\nIMPP;TYPE=home:sip:sylvain@sip.linphone.org\r\nTEL;TYPE=work:0952636505\r\nEND:VCARD\r\n");
LinphoneFriend *lf = linphone_friend_new_from_vcard(lvc);
bctbx_list_t *sip_addresses = linphone_friend_get_addresses(lf);
bctbx_list_t *phone_numbers = linphone_friend_get_phone_numbers(lf);
......@@ -150,7 +150,7 @@ static void linphone_vcard_phone_numbers_and_sip_addresses(void) {
if (phone_numbers) bctbx_list_free(phone_numbers);
linphone_friend_unref(lf);
lvc = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nTEL;TYPE=work:0952636505\r\nTEL:0476010203\r\nEND:VCARD\r\n");
lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nTEL;TYPE=work:0952636505\r\nTEL:0476010203\r\nEND:VCARD\r\n");
lf = linphone_friend_new_from_vcard(lvc);
sip_addresses = linphone_friend_get_addresses(lf);
phone_numbers = linphone_friend_get_phone_numbers(lf);
......@@ -473,7 +473,7 @@ static void carddav_sync_2(void) {
static void carddav_sync_3(void) {
LinphoneCoreManager *manager = linphone_core_manager_new2("carddav_rc", FALSE);
LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1);
LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nFN:Sylvain Berfini\r\nIMPP;TYPE=work:sip:sylvain@sip.linphone.org\r\nEND:VCARD\r\n");
LinphoneVcard *lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nFN:Sylvain Berfini\r\nIMPP;TYPE=work:sip:sylvain@sip.linphone.org\r\nEND:VCARD\r\n");
LinphoneFriend *lf = linphone_friend_new_from_vcard(lvc);
char *friends_db = bc_tester_file("friends.db");
LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
......@@ -514,7 +514,7 @@ static void carddav_sync_3(void) {
static void carddav_sync_4(void) {
LinphoneCoreManager *manager = linphone_core_manager_new2("carddav_rc", FALSE);
LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1);
LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:margaux@sip.linphone.org\r\nEND:VCARD\r\n");
LinphoneVcard *lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:margaux@sip.linphone.org\r\nEND:VCARD\r\n");
LinphoneFriend *lf = linphone_friend_new_from_vcard(lvc);
LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
LinphoneCardDavContext *c = NULL;
......@@ -575,7 +575,7 @@ static void carddav_sync_status_changed(LinphoneFriendList *list, LinphoneFriend
static void carddav_integration(void) {
LinphoneCoreManager *manager = linphone_core_manager_new2("carddav_rc", FALSE);
LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:margaux@sip.linphone.org\r\nEND:VCARD\r\n");
LinphoneVcard *lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:margaux@sip.linphone.org\r\nEND:VCARD\r\n");
LinphoneFriend *lf = linphone_friend_new_from_vcard(lvc);
LinphoneVcard *lvc2 = NULL;
LinphoneFriend *lf2 = NULL;
......@@ -608,12 +608,12 @@ static void carddav_integration(void) {
linphone_friend_unref(lf);
lf = NULL;
lvc = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Ghislain Mary\r\nIMPP;TYPE=work:sip:ghislain@sip.linphone.org\r\nEND:VCARD\r\n");
lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Ghislain Mary\r\nIMPP;TYPE=work:sip:ghislain@sip.linphone.org\r\nEND:VCARD\r\n");
lf = linphone_friend_new_from_vcard(lvc);
BC_ASSERT_EQUAL(linphone_friend_list_add_local_friend(lfl, lf), LinphoneFriendListOK, int, "%d");
linphone_friend_unref(lf);
lvc2 = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sberfini@sip.linphone.org\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nEND:VCARD\r\n");
lvc2 = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sberfini@sip.linphone.org\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nEND:VCARD\r\n");
linphone_vcard_set_url(lvc2, "/card.php/addressbooks/tester/default/me.vcf");
lf2 = linphone_friend_new_from_vcard(lvc2);
linphone_friend_set_ref_key(lf2, refkey);
......@@ -691,7 +691,7 @@ static void carddav_clean(void) { // This is to ensure the content of the test
}
bctbx_list_free(friends);
lvc = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sylvain@sip.linphone.org\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nEND:VCARD\r\n");
lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sylvain@sip.linphone.org\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nEND:VCARD\r\n");
linphone_vcard_set_url(lvc, "http://dav.linphone.org/card.php/addressbooks/tester/default/me.vcf");
lf = linphone_friend_new_from_vcard(lvc);
linphone_friend_list_add_friend(lfl, lf);
......@@ -739,9 +739,9 @@ static void carddav_server_to_client_and_client_to_sever_sync(void) {
LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
LinphoneFriendListCbs *cbs = linphone_friend_list_get_callbacks(lfl);
LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1);
LinphoneVcard *lvc1 = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:margaux@sip.linphone.org\r\nEND:VCARD\r\n");
LinphoneVcard *lvc1 = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:margaux@sip.linphone.org\r\nEND:VCARD\r\n");
LinphoneFriend *lf1 = linphone_friend_new_from_vcard(lvc1);
LinphoneVcard *lvc2 = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Ghislain Mary\r\nIMPP;TYPE=work:sip:ghislain@sip.linphone.org\r\nEND:VCARD\r\n");
LinphoneVcard *lvc2 = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Ghislain Mary\r\nIMPP;TYPE=work:sip:ghislain@sip.linphone.org\r\nEND:VCARD\r\n");
LinphoneFriend *lf2 = linphone_friend_new_from_vcard(lvc2);
bctbx_list_t *friends = NULL, *friends_iterator = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment