Beispiel #1
6
static LinphoneAccountCreatorStatus validate_uri(const char* username, const char* domain, const char* route, const char* display_name) {
	LinphoneAddress* addr;
	LinphoneAccountCreatorStatus status = LinphoneAccountCreatorOK;
	LinphoneProxyConfig* proxy = linphone_proxy_config_new();
	linphone_proxy_config_set_identity(proxy, "sip:[email protected]");

	if (route && linphone_proxy_config_set_route(proxy, route) != 0) {
		status = LinphoneAccountCreatorRouteInvalid;
		goto end;
	}

	if (username) {
		addr = linphone_proxy_config_normalize_sip_uri(proxy, username);
	} else {
		addr = linphone_address_clone(linphone_proxy_config_get_identity_address(proxy));
	}

	if (addr == NULL) {
		status = LinphoneAccountCreatorUsernameInvalid;
		goto end;
	}

	if (domain && linphone_address_set_domain(addr, domain) != 0) {
		status = LinphoneAccountCreatorDomainInvalid;
	}

	if (display_name && (!strlen(display_name) || linphone_address_set_display_name(addr, display_name) != 0)) {
		status = LinphoneAccountCreatorDisplayNameInvalid;
	}
	linphone_address_unref(addr);
end:
	linphone_proxy_config_destroy(proxy);
	return status;
}
Beispiel #2
0
static LinphoneAccountCreatorStatus validate_uri(const char* username, const char* domain, const char* route, const char* display_name) {
	LinphoneProxyConfig* proxy = linphone_proxy_config_new();
	LinphoneAddress* addr;

	linphone_proxy_config_set_identity(proxy, "sip:[email protected]");

	if (route && linphone_proxy_config_set_route(proxy, route) != 0) {
		linphone_proxy_config_destroy(proxy);
		return LinphoneAccountCreatorRouteInvalid;
	}

	if (username) {
		addr = linphone_proxy_config_normalize_sip_uri(proxy, username);
	} else {
		addr = linphone_address_clone(linphone_proxy_config_get_identity_address(proxy));
	}
	linphone_proxy_config_destroy(proxy);

	if (addr == NULL) {
		return LinphoneAccountCreatorUsernameInvalid;
	}

	if (domain) {
		ms_error("TODO: detect invalid domain");
		linphone_address_set_domain(addr, domain);
	}

	if (display_name) {
		ms_error("TODO: detect invalid display name");
		linphone_address_set_display_name(addr, display_name);
	}

	linphone_address_unref(addr);
	return LinphoneAccountCreatorOk;
}
Beispiel #3
0
static void sip_uri_normalization(void) {
	char* expected ="sip:%d9%[email protected]";
	BC_ASSERT_PTR_NULL(linphone_proxy_config_normalize_sip_uri(NULL, "test"));
	SIP_URI_CHECK("*****@*****.**", "sip:[email protected]");
	SIP_URI_CHECK("[email protected];transport=tls", "sip:[email protected];transport=tls");

	SIP_URI_CHECK("١", expected); //test that no more invalid memory writes are made (valgrind only)
}
Beispiel #4
0
static char* _get_identity(const LinphoneAccountCreator *creator) {
	char *identity = NULL;
	if (creator->username && creator->domain) {
		//we must escape username
		LinphoneProxyConfig* proxy = linphone_proxy_config_new();
		LinphoneAddress* addr;
		linphone_proxy_config_set_identity(proxy, "sip:[email protected]");
		addr = linphone_proxy_config_normalize_sip_uri(proxy, creator->username);
		linphone_address_set_domain(addr, creator->domain);
		identity = linphone_address_as_string(addr);
		linphone_address_destroy(addr);
		linphone_proxy_config_destroy(proxy);
	}
	return identity;
}
Beispiel #5
0
static char* _get_identity(const LinphoneAccountCreator *creator) {
	char *identity = NULL;
	if (creator->username && creator->domain) {
		//we must escape username
		LinphoneProxyConfig* proxy = linphone_proxy_config_new();
		LinphoneAddress* addr;
		// creator->domain may contain some port or some transport (eg. toto.org:443;transport=tcp),
		// we will accept that
		char * tmpidentity = ms_strdup_printf("sip:username@%s", creator->domain);
		linphone_proxy_config_set_identity(proxy, tmpidentity);
		ms_free(tmpidentity);
		addr = linphone_proxy_config_normalize_sip_uri(proxy, creator->username);

		identity = linphone_address_as_string(addr);
		linphone_address_destroy(addr);
		linphone_proxy_config_destroy(proxy);
	}
	return identity;
}
static void sip_uri_normalization(void) {
	BC_ASSERT_PTR_NULL(linphone_proxy_config_normalize_sip_uri(NULL, "test"));
	SIP_URI_CHECK("*****@*****.**", "sip:[email protected]");
	SIP_URI_CHECK("[email protected];transport=tls", "sip:[email protected];transport=tls");
}