diff --git a/coreapi/carddav.c b/coreapi/carddav.c index 0e8b678ad..6bfcb1d8e 100644 --- a/coreapi/carddav.c +++ b/coreapi/carddav.c @@ -73,8 +73,8 @@ static void linphone_carddav_sync_done(LinphoneCardDavContext *cdc, bool_t succe } static int find_matching_friend(LinphoneFriend *lf1, LinphoneFriend *lf2) { - LinphoneVCard *lvc1 = linphone_friend_get_vcard(lf1); - LinphoneVCard *lvc2 = linphone_friend_get_vcard(lf2); + LinphoneVcard *lvc1 = linphone_friend_get_vcard(lf1); + LinphoneVcard *lvc2 = linphone_friend_get_vcard(lf2); const char *uid1 = NULL, *uid2 = NULL; if (!lvc1 || !lvc2) { return 1; @@ -93,7 +93,7 @@ static void linphone_carddav_vcards_pulled(LinphoneCardDavContext *cdc, MSList * while (vCards) { LinphoneCardDavResponse *vCard = (LinphoneCardDavResponse *)vCards->data; if (vCard) { - LinphoneVCard *lvc = linphone_vcard_new_from_vcard4_buffer(vCard->vcard); + LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer(vCard->vcard); LinphoneFriend *lf = NULL; MSList *local_friend = NULL; @@ -201,7 +201,7 @@ static void linphone_carddav_vcards_fetched(LinphoneCardDavContext *cdc, MSList LinphoneCardDavResponse *response = (LinphoneCardDavResponse *)vCard->data; ms_debug("Local friend %s is in the remote vCard list, check eTag", linphone_friend_get_name(lf)); if (response) { - LinphoneVCard *lvc = linphone_friend_get_vcard(lf); + LinphoneVcard *lvc = linphone_friend_get_vcard(lf); const char *etag = linphone_vcard_get_etag(lvc); ms_debug("Local friend eTag is %s, remote vCard eTag is %s", etag, response->etag); if (lvc && etag && strcmp(etag, response->etag) == 0) { @@ -333,7 +333,7 @@ static void process_response_from_carddav_request(void *data, const belle_http_r { belle_sip_header_t *header = belle_sip_message_get_header((belle_sip_message_t *)event->response, "ETag"); LinphoneFriend *lf = (LinphoneFriend *)query->user_data; - LinphoneVCard *lvc = linphone_friend_get_vcard(lf); + LinphoneVcard *lvc = linphone_friend_get_vcard(lf); if (lf && lvc) { if (header) { const char *etag = belle_sip_header_get_unparsed_value(header); @@ -465,7 +465,7 @@ static void linphone_carddav_send_query(LinphoneCardDavQuery *query) { belle_http_provider_send_request(query->context->friend_list->lc->http_provider, req, query->http_request_listener); } -static LinphoneCardDavQuery* linphone_carddav_create_put_query(LinphoneCardDavContext *cdc, LinphoneVCard *lvc) { +static LinphoneCardDavQuery* linphone_carddav_create_put_query(LinphoneCardDavContext *cdc, LinphoneVcard *lvc) { LinphoneCardDavQuery *query = (LinphoneCardDavQuery *)ms_new0(LinphoneCardDavQuery, 1); query->context = cdc; query->depth = NULL; @@ -494,7 +494,7 @@ static char* generate_url_from_server_address_and_uid(const char *server_url) { } void linphone_carddav_put_vcard(LinphoneCardDavContext *cdc, LinphoneFriend *lf) { - LinphoneVCard *lvc = linphone_friend_get_vcard(lf); + LinphoneVcard *lvc = linphone_friend_get_vcard(lf); if (lvc) { LinphoneCardDavQuery *query = NULL; if (!linphone_vcard_get_uid(lvc)) { @@ -522,7 +522,7 @@ void linphone_carddav_put_vcard(LinphoneCardDavContext *cdc, LinphoneFriend *lf) } else { const char *msg = NULL; if (!lvc) { - msg = "LinphoneVCard is NULL"; + msg = "LinphoneVcard is NULL"; } else { msg = "Unknown error"; } @@ -537,7 +537,7 @@ void linphone_carddav_put_vcard(LinphoneCardDavContext *cdc, LinphoneFriend *lf) } } -static LinphoneCardDavQuery* linphone_carddav_create_delete_query(LinphoneCardDavContext *cdc, LinphoneVCard *lvc) { +static LinphoneCardDavQuery* linphone_carddav_create_delete_query(LinphoneCardDavContext *cdc, LinphoneVcard *lvc) { LinphoneCardDavQuery *query = (LinphoneCardDavQuery *)ms_new0(LinphoneCardDavQuery, 1); query->context = cdc; query->depth = NULL; @@ -550,7 +550,7 @@ static LinphoneCardDavQuery* linphone_carddav_create_delete_query(LinphoneCardDa } void linphone_carddav_delete_vcard(LinphoneCardDavContext *cdc, LinphoneFriend *lf) { - LinphoneVCard *lvc = linphone_friend_get_vcard(lf); + LinphoneVcard *lvc = linphone_friend_get_vcard(lf); if (lvc && linphone_vcard_get_uid(lvc) && linphone_vcard_get_etag(lvc)) { LinphoneCardDavQuery *query = NULL; @@ -574,11 +574,11 @@ void linphone_carddav_delete_vcard(LinphoneCardDavContext *cdc, LinphoneFriend * } else { const char *msg = NULL; if (!lvc) { - msg = "LinphoneVCard is NULL"; + msg = "LinphoneVcard is NULL"; } else if (!linphone_vcard_get_uid(lvc)) { - msg = "LinphoneVCard doesn't have an UID"; + msg = "LinphoneVcard doesn't have an UID"; } else if (!linphone_vcard_get_etag(lvc)) { - msg = "LinphoneVCard doesn't have an eTag"; + msg = "LinphoneVcard doesn't have an eTag"; } if (msg) { diff --git a/coreapi/friend.c b/coreapi/friend.c index 53b6a2b8a..b4adc6f8f 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -197,7 +197,7 @@ void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char int linphone_friend_set_address(LinphoneFriend *lf, const LinphoneAddress *addr){ LinphoneAddress *fr = linphone_address_clone(addr); - LinphoneVCard *vcard = NULL; + LinphoneVcard *vcard = NULL; linphone_address_clean(fr); if (lf->uri != NULL) linphone_address_unref(lf->uri); @@ -213,7 +213,7 @@ int linphone_friend_set_address(LinphoneFriend *lf, const LinphoneAddress *addr) int linphone_friend_set_name(LinphoneFriend *lf, const char *name){ LinphoneAddress *fr = lf->uri; - LinphoneVCard *vcard = NULL; + LinphoneVcard *vcard = NULL; bool_t vcard_created = FALSE; vcard = linphone_friend_get_vcard(lf); @@ -833,14 +833,14 @@ void linphone_friend_destroy(LinphoneFriend *lf) { linphone_friend_unref(lf); } -LinphoneVCard* linphone_friend_get_vcard(LinphoneFriend *fr) { +LinphoneVcard* linphone_friend_get_vcard(LinphoneFriend *fr) { if (fr) { return fr->vcard; } return NULL; } -void linphone_friend_set_vcard(LinphoneFriend *fr, LinphoneVCard *vcard) { +void linphone_friend_set_vcard(LinphoneFriend *fr, LinphoneVcard *vcard) { if (!fr) { return; } @@ -853,7 +853,7 @@ void linphone_friend_set_vcard(LinphoneFriend *fr, LinphoneVCard *vcard) { } bool_t linphone_friend_create_vcard(LinphoneFriend *fr, const char *name) { - LinphoneVCard *vcard = NULL; + LinphoneVcard *vcard = NULL; const char *fullName = NULL; LinphoneAddress *addr = NULL; @@ -890,7 +890,7 @@ bool_t linphone_friend_create_vcard(LinphoneFriend *fr, const char *name) { return TRUE; } -LinphoneFriend *linphone_friend_new_from_vcard(LinphoneVCard *vcard) { +LinphoneFriend *linphone_friend_new_from_vcard(LinphoneVcard *vcard) { LinphoneAddress* linphone_address = NULL; LinphoneFriend *fr; const char *name = NULL; @@ -1064,7 +1064,7 @@ static int create_friend_list(void *data, int argc, char **argv, char **colName) static int create_friend(void *data, int argc, char **argv, char **colName) { MSList **list = (MSList **)data; LinphoneFriend *lf = NULL; - LinphoneVCard *vcard = NULL; + LinphoneVcard *vcard = NULL; unsigned int storage_id = atoi(argv[0]); vcard = linphone_vcard_new_from_vcard4_buffer(argv[6]); @@ -1127,7 +1127,7 @@ void linphone_core_store_friend_in_db(LinphoneCore *lc, LinphoneFriend *lf) { if (lc && lc->friends_db) { char *buf; int store_friends = lp_config_get_int(lc->config, "misc", "store_friends", 1); - LinphoneVCard *vcard = linphone_friend_get_vcard(lf); + LinphoneVcard *vcard = linphone_friend_get_vcard(lf); if (!store_friends) { return; diff --git a/coreapi/friendlist.c b/coreapi/friendlist.c index 49485736c..c3d46815f 100644 --- a/coreapi/friendlist.c +++ b/coreapi/friendlist.c @@ -56,35 +56,35 @@ void linphone_friend_list_cbs_set_user_data(LinphoneFriendListCbs *cbs, void *ud cbs->user_data = ud; } -LinphoneFriendListContactCreatedCb linphone_friend_list_cbs_get_contact_created(const LinphoneFriendListCbs *cbs) { +LinphoneFriendListCbsContactCreatedCb linphone_friend_list_cbs_get_contact_created(const LinphoneFriendListCbs *cbs) { return cbs->contact_created_cb; } -void linphone_friend_list_cbs_set_contact_created(LinphoneFriendListCbs *cbs, LinphoneFriendListContactCreatedCb cb) { +void linphone_friend_list_cbs_set_contact_created(LinphoneFriendListCbs *cbs, LinphoneFriendListCbsContactCreatedCb cb) { cbs->contact_created_cb = cb; } -LinphoneFriendListContactDeletedCb linphone_friend_list_cbs_get_contact_deleted(const LinphoneFriendListCbs *cbs) { +LinphoneFriendListCbsContactDeletedCb linphone_friend_list_cbs_get_contact_deleted(const LinphoneFriendListCbs *cbs) { return cbs->contact_deleted_cb; } -void linphone_friend_list_cbs_set_contact_deleted(LinphoneFriendListCbs *cbs, LinphoneFriendListContactDeletedCb cb) { +void linphone_friend_list_cbs_set_contact_deleted(LinphoneFriendListCbs *cbs, LinphoneFriendListCbsContactDeletedCb cb) { cbs->contact_deleted_cb = cb; } -LinphoneFriendListContactUpdatedCb linphone_friend_list_cbs_get_contact_updated(const LinphoneFriendListCbs *cbs) { +LinphoneFriendListCbsContactUpdatedCb linphone_friend_list_cbs_get_contact_updated(const LinphoneFriendListCbs *cbs) { return cbs->contact_updated_cb; } -void linphone_friend_list_cbs_set_contact_updated(LinphoneFriendListCbs *cbs, LinphoneFriendListContactUpdatedCb cb) { +void linphone_friend_list_cbs_set_contact_updated(LinphoneFriendListCbs *cbs, LinphoneFriendListCbsContactUpdatedCb cb) { cbs->contact_updated_cb = cb; } -LinphoneFriendListSyncStateChangedCb linphone_friend_list_cbs_get_sync_status_changed(const LinphoneFriendListCbs *cbs) { +LinphoneFriendListCbsSyncStateChangedCb linphone_friend_list_cbs_get_sync_status_changed(const LinphoneFriendListCbs *cbs) { return cbs->sync_state_changed_cb; } -void linphone_friend_list_cbs_set_sync_status_changed(LinphoneFriendListCbs *cbs, LinphoneFriendListSyncStateChangedCb cb) { +void linphone_friend_list_cbs_set_sync_status_changed(LinphoneFriendListCbs *cbs, LinphoneFriendListCbsSyncStateChangedCb cb) { cbs->sync_state_changed_cb = cb; } @@ -448,7 +448,7 @@ static LinphoneFriendListStatus _linphone_friend_list_remove_friend(LinphoneFrie linphone_core_remove_friend_from_db(lf->lc, lf); #endif if (remove_from_server) { - LinphoneVCard *lvc = linphone_friend_get_vcard(lf); + LinphoneVcard *lvc = linphone_friend_get_vcard(lf); if (lvc && linphone_vcard_get_uid(lvc)) { LinphoneCardDavContext *cdc = linphone_carddav_context_new(list); if (cdc) { @@ -757,7 +757,7 @@ int linphone_friend_list_import_friends_from_vcard4_file(LinphoneFriendList *lis } while (vcards != NULL && vcards->data != NULL) { - LinphoneVCard *vcard = (LinphoneVCard *)vcards->data; + LinphoneVcard *vcard = (LinphoneVcard *)vcards->data; LinphoneFriend *lf = linphone_friend_new_from_vcard(vcard); if (lf) { if (LinphoneFriendListOK == linphone_friend_list_import_friend(list, lf, TRUE)) { @@ -793,7 +793,7 @@ int linphone_friend_list_import_friends_from_vcard4_buffer(LinphoneFriendList *l } while (vcards != NULL && vcards->data != NULL) { - LinphoneVCard *vcard = (LinphoneVCard *)vcards->data; + LinphoneVcard *vcard = (LinphoneVcard *)vcards->data; LinphoneFriend *lf = linphone_friend_new_from_vcard(vcard); if (lf) { if (LinphoneFriendListOK == linphone_friend_list_import_friend(list, lf, TRUE)) { @@ -826,7 +826,7 @@ void linphone_friend_list_export_friends_as_vcard4_file(LinphoneFriendList *list #endif while (friends != NULL && friends->data != NULL) { LinphoneFriend *lf = (LinphoneFriend *)friends->data; - LinphoneVCard *vcard = linphone_friend_get_vcard(lf); + LinphoneVcard *vcard = linphone_friend_get_vcard(lf); if (vcard) { const char *vcard_text = linphone_vcard_as_vcard4_string(vcard); fprintf(file, "%s", vcard_text); diff --git a/coreapi/friendlist.h b/coreapi/friendlist.h index d5ddafb39..acda26934 100644 --- a/coreapi/friendlist.h +++ b/coreapi/friendlist.h @@ -248,23 +248,33 @@ typedef struct _LinphoneFriendListCbs LinphoneFriendListCbs; /** * Callback used to notify a new contact has been created on the CardDAV server and downloaded locally + * @param list The LinphoneFriendList object the new contact is added to + * @param lf The LinphoneFriend object that has been created **/ -typedef void (*LinphoneFriendListContactCreatedCb)(LinphoneFriendList *list, LinphoneFriend *lf); +typedef void (*LinphoneFriendListCbsContactCreatedCb)(LinphoneFriendList *list, LinphoneFriend *lf); /** * Callback used to notify a contact has been deleted on the CardDAV server + * @param list The LinphoneFriendList object a contact has been removed from + * @param lf The LinphoneFriend object that has been deleted **/ -typedef void (*LinphoneFriendListContactDeletedCb)(LinphoneFriendList *list, LinphoneFriend *lf); +typedef void (*LinphoneFriendListCbsContactDeletedCb)(LinphoneFriendList *list, LinphoneFriend *lf); /** * Callback used to notify a contact has been updated on the CardDAV server + * @param list The LinphoneFriendList object in which a contact has been updated + * @param new_friend The new LinphoneFriend object corresponding to the updated contact + * @param old_friend The old LinphoneFriend object before update **/ -typedef void (*LinphoneFriendListContactUpdatedCb)(LinphoneFriendList *list, LinphoneFriend *new_friend, LinphoneFriend *old_friend); +typedef void (*LinphoneFriendListCbsContactUpdatedCb)(LinphoneFriendList *list, LinphoneFriend *new_friend, LinphoneFriend *old_friend); /** * Callback used to notify the status of the synchronization has changed + * @param list The LinphoneFriendList object for which the status has changed + * @param status The new synchronisation status + * @param msg An additional information on the status update **/ -typedef void (*LinphoneFriendListSyncStateChangedCb)(LinphoneFriendList *list, LinphoneFriendListSyncStatus status, const char *msg); +typedef void (*LinphoneFriendListCbsSyncStateChangedCb)(LinphoneFriendList *list, LinphoneFriendListSyncStatus status, const char *msg); /** * Get the LinphoneFriendListCbs object associated with a LinphoneFriendList. @@ -305,56 +315,56 @@ LINPHONE_PUBLIC void linphone_friend_list_cbs_set_user_data(LinphoneFriendListCb * @param[in] cbs LinphoneFriendListCbs object. * @return The current contact created callback. **/ -LINPHONE_PUBLIC LinphoneFriendListContactCreatedCb linphone_friend_list_cbs_get_contact_created(const LinphoneFriendListCbs *cbs); +LINPHONE_PUBLIC LinphoneFriendListCbsContactCreatedCb linphone_friend_list_cbs_get_contact_created(const LinphoneFriendListCbs *cbs); /** * Set the contact created callback. * @param[in] cbs LinphoneFriendListCbs object. * @param[in] cb The contact created to be used. **/ -LINPHONE_PUBLIC void linphone_friend_list_cbs_set_contact_created(LinphoneFriendListCbs *cbs, LinphoneFriendListContactCreatedCb cb); +LINPHONE_PUBLIC void linphone_friend_list_cbs_set_contact_created(LinphoneFriendListCbs *cbs, LinphoneFriendListCbsContactCreatedCb cb); /** * Get the contact deleted callback. * @param[in] cbs LinphoneFriendListCbs object. * @return The current contact deleted callback. **/ -LINPHONE_PUBLIC LinphoneFriendListContactDeletedCb linphone_friend_list_cbs_get_contact_deleted(const LinphoneFriendListCbs *cbs); +LINPHONE_PUBLIC LinphoneFriendListCbsContactDeletedCb linphone_friend_list_cbs_get_contact_deleted(const LinphoneFriendListCbs *cbs); /** * Set the contact deleted callback. * @param[in] cbs LinphoneFriendListCbs object. * @param[in] cb The contact deleted to be used. **/ -LINPHONE_PUBLIC void linphone_friend_list_cbs_set_contact_deleted(LinphoneFriendListCbs *cbs, LinphoneFriendListContactDeletedCb cb); +LINPHONE_PUBLIC void linphone_friend_list_cbs_set_contact_deleted(LinphoneFriendListCbs *cbs, LinphoneFriendListCbsContactDeletedCb cb); /** * Get the contact updated callback. * @param[in] cbs LinphoneFriendListCbs object. * @return The current contact updated callback. **/ -LINPHONE_PUBLIC LinphoneFriendListContactUpdatedCb linphone_friend_list_cbs_get_contact_updated(const LinphoneFriendListCbs *cbs); +LINPHONE_PUBLIC LinphoneFriendListCbsContactUpdatedCb linphone_friend_list_cbs_get_contact_updated(const LinphoneFriendListCbs *cbs); /** * Set the contact updated callback. * @param[in] cbs LinphoneFriendListCbs object. * @param[in] cb The contact updated to be used. **/ -LINPHONE_PUBLIC void linphone_friend_list_cbs_set_contact_updated(LinphoneFriendListCbs *cbs, LinphoneFriendListContactUpdatedCb cb); +LINPHONE_PUBLIC void linphone_friend_list_cbs_set_contact_updated(LinphoneFriendListCbs *cbs, LinphoneFriendListCbsContactUpdatedCb cb); /** * Get the sync status changed callback. * @param[in] cbs LinphoneFriendListCbs object. * @return The current sync status changedcallback. **/ -LINPHONE_PUBLIC LinphoneFriendListSyncStateChangedCb linphone_friend_list_cbs_get_sync_status_changed(const LinphoneFriendListCbs *cbs); +LINPHONE_PUBLIC LinphoneFriendListCbsSyncStateChangedCb linphone_friend_list_cbs_get_sync_status_changed(const LinphoneFriendListCbs *cbs); /** * Set the contact updated callback. * @param[in] cbs LinphoneFriendListCbs object. * @param[in] cb The sync status changed to be used. **/ -LINPHONE_PUBLIC void linphone_friend_list_cbs_set_sync_status_changed(LinphoneFriendListCbs *cbs, LinphoneFriendListSyncStateChangedCb cb); +LINPHONE_PUBLIC void linphone_friend_list_cbs_set_sync_status_changed(LinphoneFriendListCbs *cbs, LinphoneFriendListCbsSyncStateChangedCb cb); /** * Starts a CardDAV synchronization using value set using linphone_friend_list_set_uri. diff --git a/coreapi/linphonefriend.h b/coreapi/linphonefriend.h index c33ef6478..49e1263ba 100644 --- a/coreapi/linphonefriend.h +++ b/coreapi/linphonefriend.h @@ -437,14 +437,14 @@ LINPHONE_PUBLIC LinphoneCore *linphone_friend_get_core(const LinphoneFriend *fr) * Returns the vCard object associated to this friend, if any * @param[in] fr LinphoneFriend object */ -LINPHONE_PUBLIC LinphoneVCard* linphone_friend_get_vcard(LinphoneFriend *fr); +LINPHONE_PUBLIC LinphoneVcard* linphone_friend_get_vcard(LinphoneFriend *fr); /** * Binds a vCard object to a friend * @param[in] fr LinphoneFriend object * @param[in] vcard The vCard object to bind */ -LINPHONE_PUBLIC void linphone_friend_set_vcard(LinphoneFriend *fr, LinphoneVCard *vcard); +LINPHONE_PUBLIC void linphone_friend_set_vcard(LinphoneFriend *fr, LinphoneVcard *vcard); /** * Creates a vCard object associated to this friend if there isn't one yet and if the full name is available, either by the parameter or the one in the friend's SIP URI @@ -459,7 +459,7 @@ LINPHONE_PUBLIC bool_t linphone_friend_create_vcard(LinphoneFriend *fr, const ch * @param vcard a vCard object * @return a new #LinphoneFriend with \link linphone_friend_get_vcard() vCard initialized \endlink */ -LINPHONE_PUBLIC LinphoneFriend *linphone_friend_new_from_vcard(LinphoneVCard *vcard); +LINPHONE_PUBLIC LinphoneFriend *linphone_friend_new_from_vcard(LinphoneVcard *vcard); /** * Sets the database filename where friends will be stored. diff --git a/coreapi/private.h b/coreapi/private.h index c08bcfc3c..530ee0730 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -694,7 +694,7 @@ struct _LinphoneFriend{ bool_t commit; bool_t initial_subscribes_sent; /*used to know if initial subscribe message was sent or not*/ bool_t presence_received; - LinphoneVCard *vcard; + LinphoneVcard *vcard; unsigned int storage_id; LinphoneFriendList *friend_list; }; @@ -704,10 +704,10 @@ BELLE_SIP_DECLARE_VPTR(LinphoneFriend); struct _LinphoneFriendListCbs { belle_sip_object_t base; void *user_data; - LinphoneFriendListContactCreatedCb contact_created_cb; - LinphoneFriendListContactDeletedCb contact_deleted_cb; - LinphoneFriendListContactUpdatedCb contact_updated_cb; - LinphoneFriendListSyncStateChangedCb sync_state_changed_cb; + LinphoneFriendListCbsContactCreatedCb contact_created_cb; + LinphoneFriendListCbsContactDeletedCb contact_deleted_cb; + LinphoneFriendListCbsContactUpdatedCb contact_updated_cb; + LinphoneFriendListCbsSyncStateChangedCb sync_state_changed_cb; }; BELLE_SIP_DECLARE_VPTR(LinphoneFriendListCbs); diff --git a/coreapi/vcard.cc b/coreapi/vcard.cc index 5166b6d10..fe6bc8a2b 100644 --- a/coreapi/vcard.cc +++ b/coreapi/vcard.cc @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "sal/sal.h" #include -struct _LinphoneVCard { +struct _LinphoneVcard { shared_ptr belCard; char *etag; char *url; @@ -34,13 +34,13 @@ struct _LinphoneVCard { extern "C" { #endif -LinphoneVCard* linphone_vcard_new(void) { - LinphoneVCard* vCard = (LinphoneVCard*) ms_new0(LinphoneVCard, 1); +LinphoneVcard* linphone_vcard_new(void) { + LinphoneVcard* vCard = (LinphoneVcard*) ms_new0(LinphoneVcard, 1); vCard->belCard = belcard::BelCardGeneric::create(); return vCard; } -void linphone_vcard_free(LinphoneVCard *vCard) { +void linphone_vcard_free(LinphoneVcard *vCard) { if (!vCard) return; vCard->belCard.reset(); @@ -55,7 +55,7 @@ MSList* linphone_vcard_list_from_vcard4_file(const char *filename) { if (belCards) { for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) { shared_ptr belcard = (*it); - LinphoneVCard *vCard = linphone_vcard_new(); + LinphoneVcard *vCard = linphone_vcard_new(); vCard->belCard = belcard; result = ms_list_append(result, vCard); } @@ -72,7 +72,7 @@ MSList* linphone_vcard_list_from_vcard4_buffer(const char *buffer) { if (belCards) { for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) { shared_ptr belCard = (*it); - LinphoneVCard *vCard = linphone_vcard_new(); + LinphoneVcard *vCard = linphone_vcard_new(); vCard->belCard = belCard; result = ms_list_append(result, vCard); } @@ -81,8 +81,8 @@ MSList* linphone_vcard_list_from_vcard4_buffer(const char *buffer) { return result; } -LinphoneVCard* linphone_vcard_new_from_vcard4_buffer(const char *buffer) { - LinphoneVCard *vCard = NULL; +LinphoneVcard* linphone_vcard_new_from_vcard4_buffer(const char *buffer) { + LinphoneVcard *vCard = NULL; if (buffer) { belcard::BelCardParser parser = belcard::BelCardParser::getInstance(); shared_ptr belCard = parser.parseOne(buffer); @@ -96,13 +96,13 @@ LinphoneVCard* linphone_vcard_new_from_vcard4_buffer(const char *buffer) { return vCard; } -const char * linphone_vcard_as_vcard4_string(LinphoneVCard *vCard) { +const char * linphone_vcard_as_vcard4_string(LinphoneVcard *vCard) { if (!vCard) return NULL; return vCard->belCard->toFoldedString().c_str(); } -void linphone_vcard_set_full_name(LinphoneVCard *vCard, const char *name) { +void linphone_vcard_set_full_name(LinphoneVcard *vCard, const char *name) { if (!vCard || !name) return; shared_ptr fn = belcard::BelCardGeneric::create(); @@ -110,14 +110,14 @@ void linphone_vcard_set_full_name(LinphoneVCard *vCard, const char *name) { vCard->belCard->setFullName(fn); } -const char* linphone_vcard_get_full_name(const LinphoneVCard *vCard) { +const char* linphone_vcard_get_full_name(const LinphoneVcard *vCard) { if (!vCard) return NULL; const char *result = vCard->belCard->getFullName() ? vCard->belCard->getFullName()->getValue().c_str() : NULL; return result; } -void linphone_vcard_add_sip_address(LinphoneVCard *vCard, const char *sip_address) { +void linphone_vcard_add_sip_address(LinphoneVcard *vCard, const char *sip_address) { if (!vCard || !sip_address) return; shared_ptr impp = belcard::BelCardGeneric::create(); @@ -125,7 +125,7 @@ void linphone_vcard_add_sip_address(LinphoneVCard *vCard, const char *sip_addres vCard->belCard->addImpp(impp); } -void linphone_vcard_remove_sip_address(LinphoneVCard *vCard, const char *sip_address) { +void linphone_vcard_remove_sip_address(LinphoneVcard *vCard, const char *sip_address) { if (!vCard) return; for (auto it = vCard->belCard->getImpp().begin(); it != vCard->belCard->getImpp().end(); ++it) { @@ -137,7 +137,7 @@ void linphone_vcard_remove_sip_address(LinphoneVCard *vCard, const char *sip_add } } -void linphone_vcard_edit_main_sip_address(LinphoneVCard *vCard, const char *sip_address) { +void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_address) { if (!vCard || !sip_address) return; if (vCard->belCard->getImpp().size() > 0) { @@ -150,7 +150,7 @@ void linphone_vcard_edit_main_sip_address(LinphoneVCard *vCard, const char *sip_ } } -MSList* linphone_vcard_get_sip_addresses(const LinphoneVCard *vCard) { +MSList* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard) { MSList *result = NULL; if (!vCard) return NULL; @@ -163,7 +163,7 @@ MSList* linphone_vcard_get_sip_addresses(const LinphoneVCard *vCard) { return result; } -bool_t linphone_vcard_generate_unique_id(LinphoneVCard *vCard) { +bool_t linphone_vcard_generate_unique_id(LinphoneVcard *vCard) { char uuid[64]; if (vCard) { @@ -180,7 +180,7 @@ bool_t linphone_vcard_generate_unique_id(LinphoneVCard *vCard) { return FALSE; } -void linphone_vcard_set_uid(LinphoneVCard *vCard, const char *uid) { +void linphone_vcard_set_uid(LinphoneVcard *vCard, const char *uid) { if (!vCard || !uid) return; shared_ptr uniqueId = belcard::BelCardGeneric::create(); @@ -188,14 +188,14 @@ void linphone_vcard_set_uid(LinphoneVCard *vCard, const char *uid) { vCard->belCard->setUniqueId(uniqueId); } -const char* linphone_vcard_get_uid(const LinphoneVCard *vCard) { +const char* linphone_vcard_get_uid(const LinphoneVcard *vCard) { if (vCard && vCard->belCard->getUniqueId()) { return vCard->belCard->getUniqueId()->getValue().c_str(); } return NULL; } -void linphone_vcard_set_etag(LinphoneVCard *vCard, const char * etag) { +void linphone_vcard_set_etag(LinphoneVcard *vCard, const char * etag) { if (!vCard) { return; } @@ -205,12 +205,12 @@ void linphone_vcard_set_etag(LinphoneVCard *vCard, const char * etag) { vCard->etag = ms_strdup(etag); } -const char* linphone_vcard_get_etag(const LinphoneVCard *vCard) { +const char* linphone_vcard_get_etag(const LinphoneVcard *vCard) { if (!vCard) return NULL; return vCard->etag; } -void linphone_vcard_set_url(LinphoneVCard *vCard, const char * url) { +void linphone_vcard_set_url(LinphoneVcard *vCard, const char * url) { if (!vCard) { return; } @@ -220,14 +220,14 @@ void linphone_vcard_set_url(LinphoneVCard *vCard, const char * url) { vCard->url = ms_strdup(url); } -const char* linphone_vcard_get_url(const LinphoneVCard *vCard) { +const char* linphone_vcard_get_url(const LinphoneVcard *vCard) { if (!vCard) return NULL; return vCard->url; } #define VCARD_MD5_HASH_SIZE 16 -void linphone_vcard_compute_md5_hash(LinphoneVCard *vCard) { +void linphone_vcard_compute_md5_hash(LinphoneVcard *vCard) { unsigned char digest[VCARD_MD5_HASH_SIZE]; const char *text = NULL; if (!vCard) { @@ -239,7 +239,7 @@ void linphone_vcard_compute_md5_hash(LinphoneVCard *vCard) { memcpy(vCard->md5, digest, sizeof(digest)); } -bool_t linphone_vcard_compare_md5_hash(LinphoneVCard *vCard) { +bool_t linphone_vcard_compare_md5_hash(LinphoneVcard *vCard) { unsigned char *previous_md5 = vCard->md5; unsigned char *new_md5 = NULL; int result = -1; diff --git a/coreapi/vcard.h b/coreapi/vcard.h index ad1901cae..15a3a891d 100644 --- a/coreapi/vcard.h +++ b/coreapi/vcard.h @@ -36,151 +36,154 @@ extern "C" * @{ */ -typedef struct _LinphoneVCard LinphoneVCard; - /** - * Creates a LinphoneVCard object that has a pointer to an empty vCard + * The LinphoneVcard object. */ -LINPHONE_PUBLIC LinphoneVCard* linphone_vcard_new(void); +typedef struct _LinphoneVcard LinphoneVcard; /** - * Deletes a LinphoneVCard object properly - * @param[in] vCard the LinphoneVCard to destroy + * Creates a LinphoneVcard object that has a pointer to an empty vCard */ -LINPHONE_PUBLIC void linphone_vcard_free(LinphoneVCard *vCard); +LINPHONE_PUBLIC LinphoneVcard* linphone_vcard_new(void); /** - * Uses belcard to parse the content of a file and returns all the vcards it contains as LinphoneVCards, or NULL if it contains none. + * Deletes a LinphoneVcard object properly + * @param[in] vCard the LinphoneVcard to destroy + */ +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] file the path to the file to parse - * @return \mslist{LinphoneVCard} + * @return \mslist{LinphoneVcard} */ LINPHONE_PUBLIC MSList* linphone_vcard_list_from_vcard4_file(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. + * 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] buffer the buffer to parse - * @return \mslist{LinphoneVCard} + * @return \mslist{LinphoneVcard} */ LINPHONE_PUBLIC MSList* linphone_vcard_list_from_vcard4_buffer(const char *buffer); /** * Uses belcard to parse the content of a buffer and returns one vCard if possible, or NULL otherwise. * @param[in] buffer the buffer to parse - * @return a LinphoneVCard if one could be parsed, or NULL otherwise + * @return a LinphoneVcard if one could be parsed, or NULL otherwise */ -LINPHONE_PUBLIC LinphoneVCard* linphone_vcard_new_from_vcard4_buffer(const char *buffer); +LINPHONE_PUBLIC LinphoneVcard* linphone_vcard_new_from_vcard4_buffer(const char *buffer); /** - * Returns the vCard4 representation of the LinphoneVCard. - * @param[in] vCard the LinphoneVCard + * Returns the vCard4 representation of the LinphoneVcard. + * @param[in] vCard the LinphoneVcard * @return a const char * that represents the vCard */ -LINPHONE_PUBLIC const char* linphone_vcard_as_vcard4_string(LinphoneVCard *vCard); +LINPHONE_PUBLIC const char* linphone_vcard_as_vcard4_string(LinphoneVcard *vCard); /** * Sets the FN attribute of the vCard (which is mandatory). - * @param[in] vCard the LinphoneVCard + * @param[in] vCard the LinphoneVcard * @param[in] name the display name to set for the vCard */ -LINPHONE_PUBLIC void linphone_vcard_set_full_name(LinphoneVCard *vCard, const char *name); +LINPHONE_PUBLIC void linphone_vcard_set_full_name(LinphoneVcard *vCard, const char *name); /** * Returns the FN attribute of the vCard, or NULL if it isn't set yet. - * @param[in] vCard the LinphoneVCard + * @param[in] vCard the LinphoneVcard * @return the display name of the vCard, or NULL */ -LINPHONE_PUBLIC const char* linphone_vcard_get_full_name(const LinphoneVCard *vCard); +LINPHONE_PUBLIC const char* linphone_vcard_get_full_name(const LinphoneVcard *vCard); /** * Adds a SIP address in the vCard, using the IMPP property - * @param[in] vCard the LinphoneVCard + * @param[in] vCard the LinphoneVcard * @param[in] sip_address the SIP address to add */ -void linphone_vcard_add_sip_address(LinphoneVCard *vCard, const char *sip_address); +void linphone_vcard_add_sip_address(LinphoneVcard *vCard, const char *sip_address); /** * Removes a SIP address in the vCard (if it exists), using the IMPP property - * @param[in] vCard the LinphoneVCard + * @param[in] vCard the LinphoneVcard * @param[in] sip_address the SIP address to remove */ -void linphone_vcard_remove_sip_address(LinphoneVCard *vCard, const char *sip_address); +void linphone_vcard_remove_sip_address(LinphoneVcard *vCard, const char *sip_address); /** * Edits the preferred SIP address in the vCard (or the first one), using the IMPP property - * @param[in] vCard the LinphoneVCard + * @param[in] vCard the LinphoneVcard * @param[in] sip_address the new SIP address */ -void linphone_vcard_edit_main_sip_address(LinphoneVCard *vCard, const char *sip_address); +void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_address); /** - * Returns the list of SIP addresses (as const char *) in the vCard (all the IMPP attributes that has an URI value starting by "sip:") or NULL - * @param[in] vCard the LinphoneVCard + * Returns the list of SIP addresses (as string) in the vCard (all the IMPP attributes that has an URI value starting by "sip:") or NULL + * @param[in] vCard the LinphoneVcard * @return \mslist{const char *} */ -LINPHONE_PUBLIC MSList* linphone_vcard_get_sip_addresses(const LinphoneVCard *vCard); +LINPHONE_PUBLIC MSList* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard); /** * Generates a random unique id for the vCard. * If is required to be able to synchronize the vCard with a CardDAV server - * @param[in] vCard the LinphoneVCard + * @param[in] vCard the LinphoneVcard * @return TRUE if operation is successful, otherwise FALSE (for example if it already has an unique ID) */ -bool_t linphone_vcard_generate_unique_id(LinphoneVCard *vCard); +bool_t linphone_vcard_generate_unique_id(LinphoneVcard *vCard); /** * Sets the unique ID of the vCard - * @param[in] vCard the LinphoneVCard + * @param[in] vCard the LinphoneVcard * @param[in] uid the unique id */ -void linphone_vcard_set_uid(LinphoneVCard *vCard, const char *uid); +void linphone_vcard_set_uid(LinphoneVcard *vCard, const char *uid); /** * Gets the UID of the vCard - * @param[in] vCard the LinphoneVCard + * @param[in] vCard the LinphoneVcard * @return the UID of the vCard, otherwise NULL */ -LINPHONE_PUBLIC const char* linphone_vcard_get_uid(const LinphoneVCard *vCard); +LINPHONE_PUBLIC const char* linphone_vcard_get_uid(const LinphoneVcard *vCard); /** * Sets the eTAG of the vCard - * @param[in] vCard the LinphoneVCard + * @param[in] vCard the LinphoneVcard * @param[in] etag the eTAG */ -LINPHONE_PUBLIC void linphone_vcard_set_etag(LinphoneVCard *vCard, const char * etag); +LINPHONE_PUBLIC void linphone_vcard_set_etag(LinphoneVcard *vCard, const char * etag); /** * Gets the eTag of the vCard - * @param[in] vCard the LinphoneVCard + * @param[in] vCard the LinphoneVcard * @return the eTag of the vCard in the CardDAV server, otherwise NULL */ -LINPHONE_PUBLIC const char* linphone_vcard_get_etag(const LinphoneVCard *vCard); +LINPHONE_PUBLIC const char* linphone_vcard_get_etag(const LinphoneVcard *vCard); /** * Sets the URL of the vCard - * @param[in] vCard the LinphoneVCard + * @param[in] vCard the LinphoneVcard * @param[in] url the URL */ -LINPHONE_PUBLIC void linphone_vcard_set_url(LinphoneVCard *vCard, const char * url); +LINPHONE_PUBLIC void linphone_vcard_set_url(LinphoneVcard *vCard, const char * url); /** * Gets the URL of the vCard - * @param[in] vCard the LinphoneVCard + * @param[in] vCard the LinphoneVcard * @return the URL of the vCard in the CardDAV server, otherwise NULL */ -LINPHONE_PUBLIC const char* linphone_vcard_get_url(const LinphoneVCard *vCard); +LINPHONE_PUBLIC const char* linphone_vcard_get_url(const LinphoneVcard *vCard); /** * Computes the md5 hash for the vCard - * @param[in] vCard the LinphoneVCard + * @param[in] vCard the LinphoneVcard */ -void linphone_vcard_compute_md5_hash(LinphoneVCard *vCard); +void linphone_vcard_compute_md5_hash(LinphoneVcard *vCard); /** * Compares the previously computed md5 hash (using linphone_vcard_compute_md5_hash) with the current one - * @param[in] vCard the LinphoneVCard + * @param[in] vCard the LinphoneVcard * @return 0 if the md5 hasn't changed, 1 otherwise */ -bool_t linphone_vcard_compare_md5_hash(LinphoneVCard *vCard); +bool_t linphone_vcard_compare_md5_hash(LinphoneVcard *vCard); /** * @} diff --git a/coreapi/vcard_stubs.c b/coreapi/vcard_stubs.c index 500119f20..7c473f129 100644 --- a/coreapi/vcard_stubs.c +++ b/coreapi/vcard_stubs.c @@ -19,15 +19,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "vcard.h" -struct _LinphoneVCard { +struct _LinphoneVcard { void *dummy; }; -LinphoneVCard* linphone_vcard_new(void) { +LinphoneVcard* linphone_vcard_new(void) { return NULL; } -void linphone_vcard_free(LinphoneVCard *vCard) { +void linphone_vcard_free(LinphoneVcard *vCard) { } @@ -39,70 +39,70 @@ MSList* linphone_vcard_list_from_vcard4_buffer(const char *buffer) { return NULL; } -LinphoneVCard* linphone_vcard_new_from_vcard4_buffer(const char *buffer) { +LinphoneVcard* linphone_vcard_new_from_vcard4_buffer(const char *buffer) { return NULL; } -const char * linphone_vcard_as_vcard4_string(LinphoneVCard *vCard) { +const char * linphone_vcard_as_vcard4_string(LinphoneVcard *vCard) { return NULL; } -void linphone_vcard_set_full_name(LinphoneVCard *vCard, const char *name) { +void linphone_vcard_set_full_name(LinphoneVcard *vCard, const char *name) { } -const char* linphone_vcard_get_full_name(const LinphoneVCard *vCard) { +const char* linphone_vcard_get_full_name(const LinphoneVcard *vCard) { return NULL; } -void linphone_vcard_add_sip_address(LinphoneVCard *vCard, const char *sip_address) { +void linphone_vcard_add_sip_address(LinphoneVcard *vCard, const char *sip_address) { } -void linphone_vcard_remove_sip_address(LinphoneVCard *vCard, const char *sip_address) { +void linphone_vcard_remove_sip_address(LinphoneVcard *vCard, const char *sip_address) { } -void linphone_vcard_edit_main_sip_address(LinphoneVCard *vCard, const char *sip_address) { +void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_address) { } -MSList* linphone_vcard_get_sip_addresses(const LinphoneVCard *vCard) { +MSList* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard) { return NULL; } -bool_t linphone_vcard_generate_unique_id(LinphoneVCard *vCard) { +bool_t linphone_vcard_generate_unique_id(LinphoneVcard *vCard) { return FALSE; } -void linphone_vcard_set_uid(LinphoneVCard *vCard, const char *uid) { +void linphone_vcard_set_uid(LinphoneVcard *vCard, const char *uid) { } -const char* linphone_vcard_get_uid(const LinphoneVCard *vCard) { +const char* linphone_vcard_get_uid(const LinphoneVcard *vCard) { return NULL; } -void linphone_vcard_set_etag(LinphoneVCard *vCard, const char * etag) { +void linphone_vcard_set_etag(LinphoneVcard *vCard, const char * etag) { } -const char* linphone_vcard_get_etag(const LinphoneVCard *vCard) { +const char* linphone_vcard_get_etag(const LinphoneVcard *vCard) { return NULL; } -void linphone_vcard_set_url(LinphoneVCard *vCard, const char * url) { +void linphone_vcard_set_url(LinphoneVcard *vCard, const char * url) { } -const char* linphone_vcard_get_url(const LinphoneVCard *vCard) { +const char* linphone_vcard_get_url(const LinphoneVcard *vCard) { return NULL; } -void linphone_vcard_compute_md5_hash(LinphoneVCard *vCard) { +void linphone_vcard_compute_md5_hash(LinphoneVcard *vCard) { } -bool_t linphone_vcard_compare_md5_hash(LinphoneVCard *vCard) { +bool_t linphone_vcard_compare_md5_hash(LinphoneVcard *vCard) { return FALSE; } \ No newline at end of file diff --git a/tester/vcard_tester.c b/tester/vcard_tester.c index f5d2d72eb..0389e77b2 100644 --- a/tester/vcard_tester.c +++ b/tester/vcard_tester.c @@ -195,7 +195,7 @@ static void friends_sqlite_storage(void) { LinphoneFriendList *lfl = NULL; LinphoneFriend *lf = NULL; LinphoneFriend *lf2 = NULL; - LinphoneVCard *lvc = linphone_vcard_new(); + LinphoneVcard *lvc = linphone_vcard_new(); LinphoneAddress *addr = linphone_address_new("sip:sylvain@sip.linphone.org"); const MSList *friends = NULL; MSList *friends_from_db = NULL; @@ -392,7 +392,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("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_new_from_vcard4_buffer("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 = create_filepath(bc_tester_get_writable_dir_prefix(), "friends", "db"); LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc); @@ -432,7 +432,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("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_new_from_vcard4_buffer("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; @@ -493,9 +493,9 @@ 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("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_new_from_vcard4_buffer("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; + LinphoneVcard *lvc2 = NULL; LinphoneFriend *lf2 = NULL; LinphoneFriendListCbs *cbs = NULL; LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1); @@ -577,7 +577,7 @@ static void carddav_clean(void) { // This is to ensure the content of the test LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1); MSList *friends = NULL; LinphoneFriend *lf = NULL; - LinphoneVCard *lvc = NULL; + LinphoneVcard *lvc = NULL; linphone_friend_list_cbs_set_user_data(cbs, stats); linphone_friend_list_cbs_set_contact_created(cbs, carddav_contact_created); diff --git a/tools/python/apixml2python/handwritten_declarations.mustache b/tools/python/apixml2python/handwritten_declarations.mustache index 534efc981..0f694d6c3 100644 --- a/tools/python/apixml2python/handwritten_declarations.mustache +++ b/tools/python/apixml2python/handwritten_declarations.mustache @@ -24,6 +24,9 @@ typedef struct { LCSipTransports lcst; } pylinphone_SipTransportsObject; +PyObject * PyList_FromMSListOfString(const MSList *msl); +MSList * PyList_AsMSListOfString(PyObject *pyl); + int PyLinphoneVideoSize_Check(PyObject *p); MSVideoSize PyLinphoneVideoSize_AsMSVideoSize(PyObject *obj); PyObject * PyLinphoneVideoSize_FromMSVideoSize(MSVideoSize vs); diff --git a/tools/python/apixml2python/handwritten_definitions.mustache b/tools/python/apixml2python/handwritten_definitions.mustache index fcbbdb3d3..95528f8c3 100644 --- a/tools/python/apixml2python/handwritten_definitions.mustache +++ b/tools/python/apixml2python/handwritten_definitions.mustache @@ -1,3 +1,26 @@ +PyObject * PyList_FromMSListOfString(const MSList *msl) { + PyObject *pyl = PyList_New(0); + while (msl != NULL) { + PyObject *item = Py_BuildValue("z", (const char *)msl->data); + PyList_Append(pyl, item); + msl = ms_list_next(msl); + } + return pyl; +} + +MSList * PyList_AsMSListOfString(PyObject *pyl) { + MSList *msl = NULL; + Py_ssize_t idx; + Py_ssize_t size = PyList_Size(pyl); + for (idx = 0; idx < size; idx++) { + PyObject *item = PyList_GetItem(pyl, idx); + char *citem = (char *)PyString_AsString(item); + msl = ms_list_append(msl, citem); + } + return msl; +} + + static void pylinphone_dispatch_messages(void) { #ifdef WIN32 MSG msg; diff --git a/tools/python/apixml2python/linphone.py b/tools/python/apixml2python/linphone.py index 16d726850..9be436235 100644 --- a/tools/python/apixml2python/linphone.py +++ b/tools/python/apixml2python/linphone.py @@ -101,7 +101,7 @@ class ArgumentType: self.use_native_pointer = False self.cast_convert_func_result = True self.__compute() - if self.basic_type == 'MSList' and self.contained_type is not None: + if self.basic_type == 'MSList' and self.contained_type is not None and self.contained_type != 'const char *': self.linphone_module.mslist_types.add(self.contained_type) def __compute(self): @@ -215,10 +215,16 @@ class ArgumentType: self.cfmt_str = '%p' self.cnativefmt_str = '%ld' elif self.basic_type == 'MSList': - self.type_str = 'list of linphone.' + self.contained_type + if self.contained_type == 'const char *': + print("nthoetnuoehautnohutneueosanm") + self.type_str = 'list of string' + self.convert_code = "{result_name}{result_suffix} = {cast}PyList_AsMSListOfString({arg_name});\n" + self.convert_from_func = 'PyList_FromMSListOfString' + else: + self.type_str = 'list of linphone.' + self.contained_type + self.convert_code = "{result_name}{result_suffix} = {cast}PyList_AsMSListOf" + self.contained_type + "({arg_name});\n" + self.convert_from_func = 'PyList_FromMSListOf' + self.contained_type self.check_condition = "!PyList_Check({arg_name})" - self.convert_code = "{result_name}{result_suffix} = {cast}PyList_AsMSListOf" + self.contained_type + "({arg_name});\n" - self.convert_from_func = 'PyList_FromMSListOf' + self.contained_type self.fmt_str = 'O' self.cfmt_str = '%p' elif self.basic_type == 'MSVideoSize':