c-magic-search.cpp 3.44 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 27 28 29 30 31 32 33 34 35 36 37 38 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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
/*
 * 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);

LinphoneMagicSearch *linphone_magic_search_new(LinphoneCore *lc) {
	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;
}

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));
}

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);
}

bctbx_list_t* linphone_magic_search_get_contact_list_from_filter(const LinphoneMagicSearch *magicSearch, const char *filter, const char *withDomain) {
	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)));
}