/* DB layout: * | 0 | storage_id * | 1 | friend_list_id * | 2 | sip_uri * | 3 | subscribe_policy * | 4 | send_subscribe * | 5 | ref_key * | 6 | vCard * | 7 | vCard eTag * | 8 | vCard URL * | 9 | presence_received */ static int create_friend(void *data, int argc, char **argv, char **colName) { LinphoneVcardContext *context = (LinphoneVcardContext *)data; bctbx_list_t **list = (bctbx_list_t **)linphone_vcard_context_get_user_data(context); LinphoneFriend *lf = NULL; LinphoneVcard *vcard = NULL; unsigned int storage_id = (unsigned int)atoi(argv[0]); 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]); lf = linphone_friend_new_from_vcard(vcard); } if (!lf) { LinphoneAddress *addr = linphone_address_new(argv[2]); lf = linphone_friend_new(); linphone_friend_set_address(lf, addr); linphone_address_unref(addr); } linphone_friend_set_inc_subscribe_policy(lf, atoi(argv[3])); linphone_friend_send_subscribe(lf, atoi(argv[4])); linphone_friend_set_ref_key(lf, ms_strdup(argv[5])); lf->presence_received = atoi(argv[9]); lf->storage_id = storage_id; *list = bctbx_list_append(*list, linphone_friend_ref(lf)); linphone_friend_unref(lf); return 0; }
LinphoneFriend *linphone_friend_new_from_vcard(LinphoneVcard *vcard) { LinphoneAddress* linphone_address = NULL; LinphoneFriend *fr; char *name = NULL; bctbx_list_t *sipAddresses = NULL; if (vcard == NULL) { ms_error("Cannot create friend from null vcard"); return NULL; } name = ms_strdup(linphone_vcard_get_full_name(vcard)); sipAddresses = linphone_vcard_get_sip_addresses(vcard); fr = linphone_friend_new(); // Currently presence takes too much time when dealing with hundreds of friends, so I disabled it for now fr->pol = LinphoneSPDeny; fr->subscribe = FALSE; if (sipAddresses) { const char *sipAddress = (const char *)sipAddresses->data; linphone_address = linphone_address_new(sipAddress); if (linphone_address) { linphone_friend_set_address(fr, linphone_address); linphone_address_unref(linphone_address); } bctbx_list_free(sipAddresses); } fr->vcard = vcard; if (name) { linphone_friend_set_name(fr, name); } ms_free(name); return fr; }
LinphoneFriend *linphone_friend_new_with_address(const char *addr){ LinphoneAddress* linphone_address = linphone_address_new(addr); LinphoneFriend *fr; if (linphone_address == NULL) { ms_error("Cannot create friend for address [%s]",addr?addr:"null"); return NULL; } fr=linphone_friend_new(); linphone_friend_set_address(fr,linphone_address); linphone_address_unref(linphone_address); return fr; }
LinphoneFriend * linphone_core_create_friend(LinphoneCore *lc) { LinphoneFriend * lf = linphone_friend_new(); lf->lc = lc; return lf; }
LinphoneFriend * linphone_core_create_friend(LinphoneCore *lc) { return linphone_friend_new(); }
FriendAPI::FriendAPI() : WrapperAPI(APIDescription(this)) { FBLOG_DEBUG("FriendAPI::FriendAPI", "this=" << this); mFriend = linphone_friend_new(); }
void on_add_address_clicked(GtkButton *button,gpointer user_data) { LinphoneFriend *lf=linphone_friend_new(); contact_new(lf,gtk_widget_get_toplevel(GTK_WIDGET(button))); }