3 Copyright (C) 2000 Simon MORLAT (simon.morlat@linphone.org)
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Library General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include "linphonecore.h"
25 #include "mediastreamer2/mediastream.h"
31 void linphone_proxy_config_write_all_to_config_file(LinphoneCore *lc){
34 if (!linphone_core_ready(lc)) return;
36 for(elem=lc->sip_conf.proxies,i=0;elem!=NULL;elem=ms_list_next(elem),i++){
37 LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data;
38 linphone_proxy_config_write_to_config_file(lc->config,cfg,i);
40 /*to ensure removed configs are erased:*/
41 linphone_proxy_config_write_to_config_file(lc->config,NULL,i);
42 lp_config_set_int(lc->config,"sip","default_proxy",linphone_core_get_default_proxy(lc,NULL));
45 void linphone_proxy_config_init(LinphoneProxyConfig *obj){
46 memset(obj,0,sizeof(LinphoneProxyConfig));
47 obj->magic=linphone_proxy_config_magic;
57 * Creates an empty proxy config.
59 LinphoneProxyConfig *linphone_proxy_config_new(){
60 LinphoneProxyConfig *obj=NULL;
61 obj=ms_new(LinphoneProxyConfig,1);
62 linphone_proxy_config_init(obj);
67 * Destroys a proxy config.
69 * @note: LinphoneProxyConfig that have been removed from LinphoneCore with
70 * linphone_core_remove_proxy_config() must not be freed.
72 void linphone_proxy_config_destroy(LinphoneProxyConfig *obj){
73 if (obj->reg_proxy!=NULL) ms_free(obj->reg_proxy);
74 if (obj->reg_identity!=NULL) ms_free(obj->reg_identity);
75 if (obj->reg_route!=NULL) ms_free(obj->reg_route);
76 if (obj->ssctx!=NULL) sip_setup_context_free(obj->ssctx);
77 if (obj->realm!=NULL) ms_free(obj->realm);
78 if (obj->type!=NULL) ms_free(obj->type);
79 if (obj->dial_prefix!=NULL) ms_free(obj->dial_prefix);
80 if (obj->op) sal_op_release(obj->op);
81 if (obj->publish_op) sal_op_release(obj->publish_op);
85 * Returns a boolean indicating that the user is sucessfully registered on the proxy.
87 bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *obj){
88 return obj->state == LinphoneRegistrationOk;
92 * Sets the proxy address
94 * Examples of valid sip proxy address are:
95 * - IP address: sip:87.98.157.38
96 * - IP address with port: sip:87.98.157.38:5062
97 * - hostnames : sip:sip.example.net
99 int linphone_proxy_config_set_server_addr(LinphoneProxyConfig *obj, const char *server_addr){
100 LinphoneAddress *addr=NULL;
103 if (obj->reg_proxy!=NULL) ms_free(obj->reg_proxy);
106 if (server_addr!=NULL && strlen(server_addr)>0){
107 if (strstr(server_addr,"sip:")==NULL){
108 modified=ms_strdup_printf("sip:%s",server_addr);
109 addr=linphone_address_new(modified);
113 addr=linphone_address_new(server_addr);
115 obj->reg_proxy=linphone_address_as_string_uri_only(addr);
116 linphone_address_destroy(addr);
118 ms_warning("Could not parse %s",server_addr);
126 * Sets the user identity as a SIP address.
128 * This identity is normally formed with display name, username and domain, such
130 * Alice <sip:alice@example.net>
131 * The REGISTER messages will have from and to set to this identity.
134 int linphone_proxy_config_set_identity(LinphoneProxyConfig *obj, const char *identity){
135 LinphoneAddress *addr;
136 if (identity!=NULL && strlen(identity)>0){
137 addr=linphone_address_new(identity);
138 if (!addr || linphone_address_get_username(addr)==NULL){
139 ms_warning("Invalid sip identity: %s",identity);
141 linphone_address_destroy(addr);
144 if (obj->reg_identity!=NULL) {
145 ms_free(obj->reg_identity);
146 obj->reg_identity=NULL;
148 obj->reg_identity=ms_strdup(identity);
152 obj->realm=ms_strdup(linphone_address_get_domain(addr));
153 linphone_address_destroy(addr);
160 const char *linphone_proxy_config_get_domain(const LinphoneProxyConfig *cfg){
166 * When a route is set, all outgoing calls will go to the route's destination if this proxy
167 * is the default one (see linphone_core_set_default_proxy() ).
169 int linphone_proxy_config_set_route(LinphoneProxyConfig *obj, const char *route)
171 if (obj->reg_route!=NULL){
172 ms_free(obj->reg_route);
178 /*try to prepend 'sip:' */
179 if (strstr(route,"sip:")==NULL){
180 tmp=ms_strdup_printf("sip:%s",route);
181 }else tmp=ms_strdup(route);
182 addr=sal_address_new(tmp);
184 sal_address_destroy(addr);
194 bool_t linphone_proxy_config_check(LinphoneCore *lc, LinphoneProxyConfig *obj){
195 if (obj->reg_proxy==NULL){
196 if (lc->vtable.display_warning)
197 lc->vtable.display_warning(lc,_("The sip proxy address you entered is invalid, it must start with \"sip:\""
198 " followed by a hostname."));
201 if (obj->reg_identity==NULL){
202 if (lc->vtable.display_warning)
203 lc->vtable.display_warning(lc,_("The sip identity you entered is invalid.\nIt should look like "
204 "sip:username@proxydomain, such as sip:alice@example.net"));
211 * Indicates whether a REGISTER request must be sent to the proxy.
213 void linphone_proxy_config_enableregister(LinphoneProxyConfig *obj, bool_t val){
214 obj->reg_sendregister=val;
218 * Sets the registration expiration time in seconds.
220 void linphone_proxy_config_expires(LinphoneProxyConfig *obj, int val){
225 void linphone_proxy_config_enable_publish(LinphoneProxyConfig *obj, bool_t val){
229 * Starts editing a proxy configuration.
231 * Because proxy configuration must be consistent, applications MUST
232 * call linphone_proxy_config_edit() before doing any attempts to modify
233 * proxy configuration (such as identity, proxy address and so on).
234 * Once the modifications are done, then the application must call
235 * linphone_proxy_config_done() to commit the changes.
237 void linphone_proxy_config_edit(LinphoneProxyConfig *obj){
238 if (obj->reg_sendregister){
240 if (obj->state != LinphoneRegistrationNone && obj->state != LinphoneRegistrationCleared) {
241 sal_unregister(obj->op);
246 void linphone_proxy_config_apply(LinphoneProxyConfig *obj,LinphoneCore *lc)
249 linphone_proxy_config_done(obj);
252 static char *guess_contact_for_register(LinphoneProxyConfig *obj){
253 LinphoneAddress *proxy=linphone_address_new(obj->reg_proxy);
256 if (proxy==NULL) return NULL;
257 host=linphone_address_get_domain (proxy);
259 LinphoneAddress *contact;
260 char localip[LINPHONE_IPADDR_SIZE];
263 linphone_core_get_local_ip(obj->lc,host,localip);
264 contact=linphone_address_new(obj->reg_identity);
265 linphone_address_set_domain (contact,localip);
266 linphone_address_set_port_int(contact,linphone_core_get_sip_port(obj->lc));
267 linphone_address_set_display_name(contact,NULL);
269 linphone_core_get_sip_transports(obj->lc,&tr);
270 if (tr.udp_port <= 0) {
272 sal_address_set_param(contact,"transport","tcp");
273 } else if (tr.tls_port>0) {
274 sal_address_set_param(contact,"transport","tls");
277 ret=linphone_address_as_string(contact);
278 linphone_address_destroy(contact);
280 linphone_address_destroy (proxy);
284 static void linphone_proxy_config_register(LinphoneProxyConfig *obj){
285 if (obj->reg_sendregister){
288 sal_op_release(obj->op);
289 obj->op=sal_op_new(obj->lc->sal);
290 contact=guess_contact_for_register(obj);
291 sal_op_set_contact(obj->op,contact);
293 sal_op_set_user_pointer(obj->op,obj);
294 if (sal_register(obj->op,obj->reg_proxy,obj->reg_identity,obj->expires)==0) {
295 linphone_proxy_config_set_state(obj,LinphoneRegistrationProgress,"Registration in progress");
297 linphone_proxy_config_set_state(obj,LinphoneRegistrationFailed,"Registration failed");
303 * Refresh a proxy registration.
304 * This is useful if for example you resuming from suspend, thus IP address may have changed.
306 void linphone_proxy_config_refresh_register(LinphoneProxyConfig *obj){
307 if (obj->reg_sendregister && obj->op){
308 if (sal_register_refresh(obj->op,obj->expires) == 0) {
309 linphone_proxy_config_set_state(obj,LinphoneRegistrationProgress, "Refresh registration");
316 * Sets a dialing prefix to be automatically prepended when inviting a number with
317 * #linphone_core_invite.
320 void linphone_proxy_config_set_dial_prefix(LinphoneProxyConfig *cfg, const char *prefix){
321 if (cfg->dial_prefix!=NULL){
322 ms_free(cfg->dial_prefix);
323 cfg->dial_prefix=NULL;
325 if (prefix && prefix[0]!='\0') cfg->dial_prefix=ms_strdup(prefix);
329 * Returns dialing prefix.
333 const char *linphone_proxy_config_get_dial_prefix(const LinphoneProxyConfig *cfg){
334 return cfg->dial_prefix;
338 * Sets whether liblinphone should replace "+" by "00" in dialed numbers (passed to
339 * #linphone_core_invite ).
342 void linphone_proxy_config_set_dial_escape_plus(LinphoneProxyConfig *cfg, bool_t val){
343 cfg->dial_escape_plus=val;
347 * Returns whether liblinphone should replace "+" by "00" in dialed numbers (passed to
348 * #linphone_core_invite ).
351 bool_t linphone_proxy_config_get_dial_escape_plus(const LinphoneProxyConfig *cfg){
352 return cfg->dial_escape_plus;
356 static bool_t is_a_phone_number(const char *username){
358 for(p=username;*p!='\0';++p){
371 static char *flatten_number(const char *number){
372 char *result=ms_malloc0(strlen(number)+1);
375 for(r=number;*r!='\0';++r){
376 if (*r=='+' || isdigit(*r)){
384 static void copy_result(const char *src, char *dest, size_t destlen, bool_t escape_plus){
387 if (escape_plus && src[0]=='+' && destlen>2){
394 for(;(i<destlen-1) && *src!='\0';++i){
402 static char *append_prefix(const char *number, const char *prefix){
403 char *res=ms_malloc(strlen(number)+strlen(prefix)+1);
405 return strcat(res,number);
408 int linphone_proxy_config_normalize_number(LinphoneProxyConfig *proxy, const char *username, char *result, size_t result_len){
411 if (is_a_phone_number(username)){
412 flatten=flatten_number(username);
413 ms_message("Flattened number is '%s'",flatten);
414 numlen=strlen(flatten);
415 if (numlen>10 || flatten[0]=='+' || proxy->dial_prefix==NULL || proxy->dial_prefix[0]=='\0'){
416 ms_message("No need to add a prefix");
417 /* prefix is already there */
418 copy_result(flatten,result,result_len,proxy->dial_escape_plus);
421 }else if (proxy->dial_prefix && proxy->dial_prefix[0]!='\0'){
424 ms_message("Need to prefix with %s",proxy->dial_prefix);
426 /*remove initial number before prepending prefix*/
429 prefixed=append_prefix(flatten+skipped,proxy->dial_prefix);
431 copy_result(prefixed,result,result_len,proxy->dial_escape_plus);
434 }else strncpy(result,username,result_len);
439 * Commits modification made to the proxy configuration.
441 int linphone_proxy_config_done(LinphoneProxyConfig *obj)
443 if (!linphone_proxy_config_check(obj->lc,obj)) return -1;
445 linphone_proxy_config_write_all_to_config_file(obj->lc);
449 void linphone_proxy_config_set_realm(LinphoneProxyConfig *cfg, const char *realm)
451 if (cfg->realm!=NULL) {
455 if (realm!=NULL) cfg->realm=ms_strdup(realm);
458 int linphone_proxy_config_send_publish(LinphoneProxyConfig *proxy,
459 LinphoneOnlineStatus presence_mode){
461 SalOp *op=sal_op_new(proxy->lc->sal);
462 err=sal_publish(op,linphone_proxy_config_get_identity(proxy),
463 linphone_proxy_config_get_identity(proxy),linphone_online_status_to_sal(presence_mode));
464 if (proxy->publish_op!=NULL)
465 sal_op_release(proxy->publish_op);
466 proxy->publish_op=op;
471 * Returns the route set for this proxy configuration.
473 const char *linphone_proxy_config_get_route(const LinphoneProxyConfig *obj){
474 return obj->reg_route;
478 * Returns the SIP identity that belongs to this proxy configuration.
480 * The SIP identity is a SIP address (Display Name <sip:username@@domain> )
482 const char *linphone_proxy_config_get_identity(const LinphoneProxyConfig *obj){
483 return obj->reg_identity;
487 * Returns TRUE if PUBLISH request is enabled for this proxy.
489 bool_t linphone_proxy_config_publish_enabled(const LinphoneProxyConfig *obj){
494 * Returns the proxy's SIP address.
496 const char *linphone_proxy_config_get_addr(const LinphoneProxyConfig *obj){
497 return obj->reg_proxy;
501 * Returns the duration of registration.
503 int linphone_proxy_config_get_expires(const LinphoneProxyConfig *obj){
508 * Returns TRUE if registration to the proxy is enabled.
510 bool_t linphone_proxy_config_register_enabled(const LinphoneProxyConfig *obj){
511 return obj->reg_sendregister;
514 struct _LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig *obj){
519 * Add a proxy configuration.
520 * This will start registration on the proxy, if registration is enabled.
522 int linphone_core_add_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *cfg){
523 if (!linphone_proxy_config_check(lc,cfg)) {
526 if (ms_list_find(lc->sip_conf.proxies,cfg)!=NULL){
527 ms_warning("ProxyConfig already entered, ignored.");
530 lc->sip_conf.proxies=ms_list_append(lc->sip_conf.proxies,(void *)cfg);
531 linphone_proxy_config_apply(cfg,lc);
536 * Removes a proxy configuration.
538 * LinphoneCore will then automatically unregister and place the proxy configuration
539 * on a deleted list. For that reason, a removed proxy does NOT need to be freed.
541 void linphone_core_remove_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *cfg){
542 /* check this proxy config is in the list before doing more*/
543 if (ms_list_find(lc->sip_conf.proxies,cfg)==NULL){
544 ms_error("linphone_core_remove_proxy_config: LinphoneProxyConfig %p is not known by LinphoneCore (programming error?)",cfg);
547 lc->sip_conf.proxies=ms_list_remove(lc->sip_conf.proxies,(void *)cfg);
548 /* add to the list of destroyed proxies, so that the possible unREGISTER request can succeed authentication */
549 lc->sip_conf.deleted_proxies=ms_list_append(lc->sip_conf.deleted_proxies,(void *)cfg);
550 cfg->deletion_date=ms_time(NULL);
551 if (cfg->state==LinphoneRegistrationOk){
552 /* this will unREGISTER */
553 linphone_proxy_config_edit(cfg);
555 if (lc->default_proxy==cfg){
556 lc->default_proxy=NULL;
558 linphone_proxy_config_write_all_to_config_file(lc);
561 * Erase all proxies from config.
565 void linphone_core_clear_proxy_config(LinphoneCore *lc){
566 MSList* list=ms_list_copy(linphone_core_get_proxy_config_list((const LinphoneCore*)lc));
568 for(;list!=NULL;list=list->next){
569 linphone_core_remove_proxy_config(lc,(LinphoneProxyConfig *)list->data);
572 linphone_proxy_config_write_all_to_config_file(lc);
575 * Sets the default proxy.
577 * This default proxy must be part of the list of already entered LinphoneProxyConfig.
578 * Toggling it as default will make LinphoneCore use the identity associated with
579 * the proxy configuration in all incoming and outgoing calls.
581 void linphone_core_set_default_proxy(LinphoneCore *lc, LinphoneProxyConfig *config){
582 /* check if this proxy is in our list */
584 if (ms_list_find(lc->sip_conf.proxies,config)==NULL){
585 ms_warning("Bad proxy address: it is not in the list !");
586 lc->default_proxy=NULL;
590 lc->default_proxy=config;
591 if (linphone_core_ready(lc))
592 lp_config_set_int(lc->config,"sip","default_proxy",linphone_core_get_default_proxy(lc,NULL));
595 void linphone_core_set_default_proxy_index(LinphoneCore *lc, int index){
596 if (index<0) linphone_core_set_default_proxy(lc,NULL);
597 else linphone_core_set_default_proxy(lc,ms_list_nth_data(lc->sip_conf.proxies,index));
601 * Returns the default proxy configuration, that is the one used to determine the current identity.
603 int linphone_core_get_default_proxy(LinphoneCore *lc, LinphoneProxyConfig **config){
605 if (config!=NULL) *config=lc->default_proxy;
606 if (lc->default_proxy!=NULL){
607 pos=ms_list_position(lc->sip_conf.proxies,ms_list_find(lc->sip_conf.proxies,(void *)lc->default_proxy));
613 * Returns an unmodifiable list of entered proxy configurations.
615 const MSList *linphone_core_get_proxy_config_list(const LinphoneCore *lc){
616 return lc->sip_conf.proxies;
619 void linphone_proxy_config_write_to_config_file(LpConfig *config, LinphoneProxyConfig *obj, int index)
623 sprintf(key,"proxy_%i",index);
624 lp_config_clean_section(config,key);
628 if (obj->type!=NULL){
629 lp_config_set_string(config,key,"type",obj->type);
631 if (obj->reg_proxy!=NULL){
632 lp_config_set_string(config,key,"reg_proxy",obj->reg_proxy);
634 if (obj->reg_route!=NULL){
635 lp_config_set_string(config,key,"reg_route",obj->reg_route);
637 if (obj->reg_identity!=NULL){
638 lp_config_set_string(config,key,"reg_identity",obj->reg_identity);
640 lp_config_set_int(config,key,"reg_expires",obj->expires);
641 lp_config_set_int(config,key,"reg_sendregister",obj->reg_sendregister);
642 lp_config_set_int(config,key,"publish",obj->publish);
643 lp_config_set_int(config,key,"dial_escape_plus",obj->dial_escape_plus);
644 lp_config_set_string(config,key,"dial_prefix",obj->dial_prefix);
649 LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LpConfig *config, int index)
652 const char *identity;
654 LinphoneProxyConfig *cfg;
657 sprintf(key,"proxy_%i",index);
659 if (!lp_config_has_section(config,key)){
663 cfg=linphone_proxy_config_new();
665 identity=lp_config_get_string(config,key,"reg_identity",NULL);
666 proxy=lp_config_get_string(config,key,"reg_proxy",NULL);
668 linphone_proxy_config_set_identity(cfg,identity);
669 linphone_proxy_config_set_server_addr(cfg,proxy);
671 tmp=lp_config_get_string(config,key,"reg_route",NULL);
672 if (tmp!=NULL) linphone_proxy_config_set_route(cfg,tmp);
674 linphone_proxy_config_expires(cfg,lp_config_get_int(config,key,"reg_expires",600));
675 linphone_proxy_config_enableregister(cfg,lp_config_get_int(config,key,"reg_sendregister",0));
677 linphone_proxy_config_enable_publish(cfg,lp_config_get_int(config,key,"publish",0));
679 linphone_proxy_config_set_dial_escape_plus(cfg,lp_config_get_int(config,key,"dial_escape_plus",0));
680 linphone_proxy_config_set_dial_prefix(cfg,lp_config_get_string(config,key,"dial_prefix",NULL));
682 tmp=lp_config_get_string(config,key,"type",NULL);
683 if (tmp!=NULL && strlen(tmp)>0)
684 linphone_proxy_config_set_sip_setup(cfg,tmp);
689 static void linphone_proxy_config_activate_sip_setup(LinphoneProxyConfig *cfg){
690 SipSetupContext *ssc;
691 SipSetup *ss=sip_setup_lookup(cfg->type);
692 LinphoneCore *lc=linphone_proxy_config_get_core(cfg);
695 ssc=sip_setup_context_new(ss,cfg);
697 if (cfg->reg_identity==NULL){
698 ms_error("Invalid identity for this proxy configuration.");
701 caps=sip_setup_context_get_capabilities(ssc);
702 if (caps & SIP_SETUP_CAP_ACCOUNT_MANAGER){
703 if (sip_setup_context_login_account(ssc,cfg->reg_identity,NULL)!=0){
704 if (lc->vtable.display_warning){
705 char *tmp=ms_strdup_printf(_("Could not login as %s"),cfg->reg_identity);
706 lc->vtable.display_warning(lc,tmp);
712 if (caps & SIP_SETUP_CAP_PROXY_PROVIDER){
714 if (sip_setup_context_get_proxy(ssc,NULL,proxy,sizeof(proxy))==0){
715 linphone_proxy_config_set_server_addr(cfg,proxy);
717 ms_error("Could not retrieve proxy uri !");
723 SipSetup *linphone_proxy_config_get_sip_setup(LinphoneProxyConfig *cfg){
724 if (cfg->ssctx!=NULL) return cfg->ssctx->funcs;
725 if (cfg->type!=NULL){
726 return sip_setup_lookup(cfg->type);
731 void linphone_proxy_config_update(LinphoneProxyConfig *cfg){
732 LinphoneCore *lc=cfg->lc;
734 if (cfg->type && cfg->ssctx==NULL){
735 linphone_proxy_config_activate_sip_setup(cfg);
737 if (!lc->sip_conf.register_only_when_network_is_up || lc->network_reachable)
738 linphone_proxy_config_register(cfg);
739 if (cfg->publish && cfg->publish_op==NULL){
740 linphone_proxy_config_send_publish(cfg,lc->presence_mode);
746 void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *type){
749 cfg->type=ms_strdup(type);
750 if (linphone_proxy_config_get_addr(cfg)==NULL){
751 /*put a placeholder so that the sip setup gets saved into the config */
752 linphone_proxy_config_set_server_addr(cfg,"sip:undefined");
756 SipSetupContext *linphone_proxy_config_get_sip_setup_context(LinphoneProxyConfig *cfg){
764 LinphoneAccountCreator *linphone_account_creator_new(struct _LinphoneCore *core, const char *type){
765 LinphoneAccountCreator *obj;
766 LinphoneProxyConfig *cfg;
767 SipSetup *ss=sip_setup_lookup(type);
768 SipSetupContext *ssctx;
772 if (!(sip_setup_get_capabilities(ss) & SIP_SETUP_CAP_ACCOUNT_MANAGER)){
773 ms_error("%s cannot manage accounts.",type);
776 obj=ms_new0(LinphoneAccountCreator,1);
777 cfg=linphone_proxy_config_new();
778 ssctx=sip_setup_context_new(ss,cfg);
781 set_string(&obj->domain,sip_setup_context_get_domains(ssctx)[0]);
786 void linphone_account_creator_set_username(LinphoneAccountCreator *obj, const char *username){
787 set_string(&obj->username,username);
790 void linphone_account_creator_set_password(LinphoneAccountCreator *obj, const char *password){
791 set_string(&obj->password,password);
794 void linphone_account_creator_set_domain(LinphoneAccountCreator *obj, const char *domain){
795 set_string(&obj->domain,domain);
798 void linphone_account_creator_set_route(LinphoneAccountCreator *obj, const char *route) {
799 set_string(&obj->route,route);
802 void linphone_account_creator_set_email(LinphoneAccountCreator *obj, const char *email) {
803 set_string(&obj->email,email);
806 void linphone_account_creator_set_suscribe(LinphoneAccountCreator *obj, int suscribe) {
807 obj->suscribe = suscribe;
810 const char * linphone_account_creator_get_username(LinphoneAccountCreator *obj){
811 return obj->username;
814 const char * linphone_account_creator_get_domain(LinphoneAccountCreator *obj){
818 int linphone_account_creator_test_existence(LinphoneAccountCreator *obj){
819 SipSetupContext *ssctx=obj->ssctx;
820 char *uri=ms_strdup_printf("%s@%s",obj->username,obj->domain);
821 int err=sip_setup_context_account_exists(ssctx,uri);
826 int linphone_account_creator_test_validation(LinphoneAccountCreator *obj) {
827 SipSetupContext *ssctx=obj->ssctx;
828 int err=sip_setup_context_account_validated(ssctx,obj->username);
832 LinphoneProxyConfig * linphone_account_creator_validate(LinphoneAccountCreator *obj){
833 SipSetupContext *ssctx=obj->ssctx;
834 char *uri=ms_strdup_printf("%s@%s",obj->username,obj->domain);
835 int err=sip_setup_context_create_account(ssctx, uri, obj->password, obj->email, obj->suscribe);
839 return sip_setup_context_get_proxy_config(ssctx);
844 void linphone_account_creator_destroy(LinphoneAccountCreator *obj){
846 ms_free(obj->username);
848 ms_free(obj->password);
850 ms_free(obj->domain);
851 if (!obj->succeeded){
852 linphone_proxy_config_destroy(sip_setup_context_get_proxy_config(obj->ssctx));
856 void linphone_proxy_config_set_user_data(LinphoneProxyConfig *cr, void * ud) {
860 void * linphone_proxy_config_get_user_data(LinphoneProxyConfig *cr) {
861 return cr->user_data;
864 void linphone_proxy_config_set_state(LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const char *message){
865 LinphoneCore *lc=cfg->lc;
867 if (lc && lc->vtable.registration_state_changed){
868 lc->vtable.registration_state_changed(lc,cfg,state,message);
872 LinphoneRegistrationState linphone_proxy_config_get_state(const LinphoneProxyConfig *cfg){
876 const char *linphone_registration_state_to_string(LinphoneRegistrationState cs){
878 case LinphoneRegistrationCleared:
879 return "LinphoneRegistrationCleared";
881 case LinphoneRegistrationNone:
882 return "LinphoneRegistrationNone";
884 case LinphoneRegistrationProgress:
885 return "LinphoneRegistrationProgress";
887 case LinphoneRegistrationOk:
888 return "LinphoneRegistrationOk";
890 case LinphoneRegistrationFailed:
891 return "LinphoneRegistrationFailed";
897 LinphoneReason linphone_proxy_config_get_error(const LinphoneProxyConfig *cfg) {
901 void linphone_proxy_config_set_error(LinphoneProxyConfig *cfg,LinphoneReason error) {