linphone-developers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Linphone-developers] how can I register to a server without entering th


From: Asias He
Subject: [Linphone-developers] how can I register to a server without entering the passwd again in linphonec
Date: Mon, 25 May 2009 17:09:00 +0800

Hi,all

I am using Linphone 3.1.1.

When I am using this to register to a server

linphonec >register sip:address@hidden sip:example.com mypasswd

I was promoted for entering  the passwd while I had given the passwd on the command line.

I want to do the register stuff in my script without any user inputs.

 Any sugesstions? Thanks!

==============================================================

  static int lpc_cmd_register(LinphoneCore *lc, char *args){
        char identity[512];
        char proxy[512];
        char passwd[512];
        LinphoneProxyConfig *cfg;
        const MSList *elem;
        passwd[0]=proxy[0]=identity[0]='\0';
        sscanf(args,"%s %s %s",identity,proxy,passwd);
        if (proxy[0]=='\0' || identity[0]=='\0'){
                linphonec_out("Missing parameters, see help register\n");
                return 1;
        }   
        if (passwd[0]!='\0'){
                osip_from_t *from;
                LinphoneAuthInfo *info;
                osip_from_init(&from);
                if (osip_from_parse(from,identity)==0){
                        char realm[128];
                        snprintf(realm,sizeof(realm)-1,"\"%s\"",from->url->host);
                        info=linphone_auth_info_new(from->url->username,NULL,passwd,NULL,realm);
                        linphone_core_add_auth_info(lc,info);
                }   
                osip_from_free(from);
        }   
        elem=linphone_core_get_proxy_config_list(lc);
        if (elem) {
                cfg=(LinphoneProxyConfig*)elem->data;
                linphone_proxy_config_edit(cfg);
        }
        else cfg=linphone_proxy_config_new();
        linphone_proxy_config_set_identity(cfg,identity);
        linphone_proxy_config_set_server_addr(cfg,proxy);
        linphone_proxy_config_enable_register(cfg,TRUE);
        if (elem) linphone_proxy_config_done(cfg);
        else linphone_core_add_proxy_config(lc,cfg);
        linphone_core_set_default_proxy(lc,cfg);
        return 1;
}
   

reply via email to

[Prev in Thread] Current Thread [Next in Thread]