コード例 #1
0
ファイル: friend.c プロジェクト: 42p/linphone
/* 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;
}
コード例 #2
0
ファイル: friendlist.c プロジェクト: smking1122/heqinphone
LinphoneFriendListStatus linphone_friend_list_import_friend(LinphoneFriendList *list, LinphoneFriend *lf, bool_t synchronize) {
	if (!lf->uri || lf->friend_list) {
		if (!lf->uri)
			ms_error("linphone_friend_list_add_friend(): invalid friend, no sip uri");
		if (lf->friend_list)
			ms_error("linphone_friend_list_add_friend(): invalid friend, already in list");
		return LinphoneFriendListInvalidFriend;
	}
	lf->friend_list = list;
	lf->lc = list->lc;
	list->friends = bctbx_list_append(list->friends, linphone_friend_ref(lf));
	if (synchronize) {
		list->dirty_friends_to_update = bctbx_list_append(list->dirty_friends_to_update, linphone_friend_ref(lf));
	}
	return LinphoneFriendListOK;
}
コード例 #3
0
ファイル: friendlist.c プロジェクト: smking1122/heqinphone
static void carddav_updated(LinphoneCardDavContext *cdc, LinphoneFriend *lf_new, LinphoneFriend *lf_old) {
	if (cdc) {
		LinphoneFriendList *lfl = cdc->friend_list;
		bctbx_list_t *elem = bctbx_list_find(lfl->friends, lf_old);
		if (elem) {
			elem->data = linphone_friend_ref(lf_new);
		}
		linphone_core_store_friend_in_db(lf_new->lc, lf_new);

		if (cdc->friend_list->cbs->contact_updated_cb) {
			cdc->friend_list->cbs->contact_updated_cb(lfl, lf_new, lf_old);
		}
		linphone_friend_unref(lf_old);
	}
}
コード例 #4
0
ファイル: friend.c プロジェクト: 42p/linphone
void linphone_friend_done(LinphoneFriend *fr) {
	ms_return_if_fail(fr);
	if (!fr->lc || !fr->friend_list) return;
	linphone_friend_apply(fr, fr->lc);
	linphone_friend_save(fr, fr->lc);

	if (fr && fr->vcard) {
		if (linphone_vcard_compare_md5_hash(fr->vcard) != 0) {
			ms_debug("vCard's md5 has changed, mark friend as dirty");
			fr->friend_list->dirty_friends_to_update = bctbx_list_append(fr->friend_list->dirty_friends_to_update, linphone_friend_ref(fr));
		}
	}
}