c-magic-search.cpp 4.02 KB
Newer Older
Erwan Croze's avatar
Erwan Croze committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/*
 * c-magic-search.cpp
 * Copyright (C) 2010-2018 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
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#include "search/magic-search.h"
#include "c-wrapper/c-wrapper.h"

using namespace std;

L_DECLARE_C_OBJECT_IMPL(MagicSearch);

27
LinphoneMagicSearch *linphone_core_create_magic_search(LinphoneCore *lc) {
Erwan Croze's avatar
Erwan Croze committed
28 29 30 31 32 33 34
	shared_ptr<LinphonePrivate::MagicSearch> cppPtr = make_shared<LinphonePrivate::MagicSearch>(L_GET_CPP_PTR_FROM_C_OBJECT(lc));

	LinphoneMagicSearch *object = L_INIT(MagicSearch);
	L_SET_CPP_PTR_FROM_C_OBJECT(object, cppPtr);
	return object;
}

35 36 37 38
LinphoneMagicSearch *linphone_new_magic_search(LinphoneCore *lc) {
	return linphone_core_create_magic_search(lc);
}

Erwan Croze's avatar
Erwan Croze committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
LinphoneMagicSearch *linphone_magic_search_ref(LinphoneMagicSearch *magicSearch) {
	belle_sip_object_ref(magicSearch);
	return magicSearch;
}

void linphone_magic_search_unref(LinphoneMagicSearch *magicSearch) {
	belle_sip_object_unref(magicSearch);
}

void linphone_magic_search_set_min_weight(LinphoneMagicSearch *magicSearch, const unsigned int weight) {
	L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->setMinWeight(weight);
}

unsigned int linphone_magic_search_get_min_weight(const LinphoneMagicSearch *magicSearch) {
	return L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->getMinWeight();
}

void linphone_magic_search_set_max_weight(LinphoneMagicSearch *magicSearch, const unsigned int weight) {
	L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->setMaxWeight(weight);
}

unsigned int linphone_magic_search_get_max_weight(const LinphoneMagicSearch *magicSearch) {
	return L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->getMaxWeight();
}

const char *linphone_magic_search_get_delimiter(const LinphoneMagicSearch *magicSearch) {
	return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->getDelimiter());
}

void linphone_magic_search_set_delimiter(LinphoneMagicSearch *magicSearch, const char *delimiter) {
	L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->setDelimiter(L_C_TO_STRING(delimiter));
}

Erwan Croze's avatar
Erwan Croze committed
72 73 74 75 76 77 78 79
bool_t linphone_magic_search_get_use_delimiter(LinphoneMagicSearch *magicSearch) {
	return L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->getUseDelimiter();
}

void linphone_magic_search_set_use_delimiter(LinphoneMagicSearch *magicSearch, bool_t enable) {
	L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->setUseDelimiter(enable);
}

Erwan Croze's avatar
Erwan Croze committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
unsigned int linphone_magic_search_get_search_limit(const LinphoneMagicSearch *magicSearch) {
	return L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->getSearchLimit();
}

void linphone_magic_search_set_search_limit(LinphoneMagicSearch *magicSearch, const unsigned int limit) {
	L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->setSearchLimit(limit);
}

bool_t linphone_magic_search_get_limited_search(const LinphoneMagicSearch *magicSearch) {
	return L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->getLimitedSearch();
}

void linphone_magic_search_set_limited_search(LinphoneMagicSearch *magicSearch, const bool_t limited) {
	L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->setLimitedSearch(limited);
}

Erwan Croze's avatar
Erwan Croze committed
96 97 98 99 100
void linphone_magic_search_reset_search_cache(LinphoneMagicSearch *magicSearch) {
	L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->resetSearchCache();
}

bctbx_list_t* linphone_magic_search_get_contact_list_from_filter(LinphoneMagicSearch *magicSearch, const char *filter, const char *withDomain) {
Erwan Croze's avatar
Erwan Croze committed
101 102
	return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->getContactListFromFilter(L_C_TO_STRING(filter), L_C_TO_STRING(withDomain)));
}