Changeset 244:341831610f7f in mediastreamer2


Ignore:
Timestamp:
Feb 7, 2009 9:51:56 PM (4 years ago)
Author:
smorlat <smorlat@…>
Branch:
default
Message:

new linphonec commands.

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@247 3f6dc0c8-ddfe-455d-9043-3cd528dc4637

Location:
linphone
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • linphone/console/commands.c

    r242 r244  
    6060static int lpc_cmd_record(LinphoneCore *, char *); 
    6161static int lpc_cmd_register(LinphoneCore *, char *); 
     62static int lpc_cmd_unregister(LinphoneCore *, char *); 
    6263static int lpc_cmd_duration(LinphoneCore *lc, char *args); 
    6364 
     
    6869static void linphonec_proxy_remove(LinphoneCore *lc, int index); 
    6970static  int linphonec_proxy_use(LinphoneCore *lc, int index); 
     71static void linphonec_proxy_show(LinphoneCore *lc,int index); 
    7072static void linphonec_friend_display(LinphoneFriend *fr); 
    7173static int linphonec_friend_list(LinphoneCore *lc, char *arg); 
     
    110112                "'proxy use <index>' : use proxy with number index as default proxy.\n" 
    111113                "'proxy unuse' : don't use a default proxy." 
     114                "'proxy show <index>' : show configuration and status of the proxy numbered by index.\n" 
     115                "'proxy show default' : show configuration and status of the default proxy.\n" 
    112116        }, 
    113117        { "soundcard", lpc_cmd_soundcard, "Manage soundcards", 
     
    160164        { "quit", lpc_cmd_quit, "Exit linphonec", NULL }, 
    161165        { "register", lpc_cmd_register, "Register in one line to a proxy" , "register <sip identity> <sip proxy> <password>"}, 
     166        { "unregister", lpc_cmd_unregister, "Unregister from default proxy", NULL       }, 
    162167        { "duration", lpc_cmd_duration, "Print duration in seconds of the last call.", NULL }, 
    163168        { (char *)NULL, (lpc_cmd_handler)NULL, (char *)NULL, (char *)NULL } 
     
    634639                        else linphonec_out("Current default proxy is %d.\n", proxynum); 
    635640                } 
    636         } 
    637         else if (strcmp(arg1, "unuse")==0) 
    638         { 
     641        }else if (strcmp(arg1, "unuse")==0){ 
    639642                linphone_core_set_default_proxy(lc, NULL); 
    640643                linphonec_out("Use no proxy.\n"); 
    641         } 
    642         else 
     644        }else if (strcmp(arg1,"show")==0){ 
     645                if (arg2 && *arg2){ 
     646                        if (strstr(arg2,"default")==0){ 
     647                                proxynum=linphone_core_get_default_proxy(lc, NULL); 
     648                                linphonec_proxy_show(lc,proxynum); 
     649                        }else linphonec_proxy_show(lc,atoi(arg2)); 
     650                } 
     651        }else 
    643652        { 
    644653                linphonec_out("Syntax error - see 'help proxy'\n"); 
     
    967976linphonec_proxy_display(LinphoneProxyConfig *cfg) 
    968977{ 
    969         linphonec_out("sip address: %s\nroute: %s\nidentity: %s\nregister: %s\nexpires: %i\n", 
     978        linphonec_out("sip address: %s\nroute: %s\nidentity: %s\nregister: %s\nexpires: %i\nregistered: %s\n", 
    970979                        cfg->reg_proxy, 
    971980                        (cfg->reg_route!=NULL)?cfg->reg_route:"", 
    972981                        (cfg->reg_identity!=NULL)?cfg->reg_identity:"", 
    973982                        (cfg->reg_sendregister)?"yes":"no", 
    974                         cfg->expires); 
     983                        cfg->expires, 
     984                        linphone_proxy_config_is_registered(cfg) ? "yes" : "no"); 
     985} 
     986 
     987static void linphonec_proxy_show(LinphoneCore *lc, int index){ 
     988        const MSList *elem; 
     989        int i; 
     990        for(elem=linphone_core_get_proxy_config_list(lc),i=0;elem!=NULL;elem=elem->next,++i){ 
     991                if (index==i){ 
     992                        LinphoneProxyConfig *cfg=(LinphoneProxyConfig *)elem->data; 
     993                        linphonec_proxy_display(cfg); 
     994                        return; 
     995                } 
     996        } 
     997        linphonec_out("No proxy with index %i",index); 
    975998} 
    976999 
     
    11621185} 
    11631186 
     1187static int lpc_cmd_unregister(LinphoneCore *lc, char *args){ 
     1188        LinphoneProxyConfig *cfg=NULL; 
     1189        linphone_core_get_default_proxy(lc,&cfg); 
     1190        if (cfg) { 
     1191                linphone_proxy_config_edit(cfg); 
     1192                linphone_proxy_config_enable_register(cfg,FALSE); 
     1193                linphone_proxy_config_done(cfg); 
     1194        }else{ 
     1195                linphonec_out("unregistered\n"); 
     1196        } 
     1197        return 1; 
     1198} 
     1199 
    11641200int lpc_cmd_duration(LinphoneCore *lc, char *args){ 
    11651201        LinphoneCallLog *cl; 
  • linphone/console/shell.c

    r242 r244  
    171171} 
    172172 
     173static int unregister_execute(int argc, char *argv[]){ 
     174        return send_generic_command("unregister",FALSE); 
     175} 
     176 
     177 
    173178static int dial_execute(int argc, char *argv[]){ 
    174179        char cmd[512]; 
     
    181186        return -1; 
    182187} 
     188 
     189static int status_execute(int argc, char *argv[]){ 
     190        char cmd[512]; 
     191        if (argc==1){ 
     192                snprintf(cmd,sizeof(cmd),"call %s",argv[0]); 
     193                return send_generic_command(cmd,TRUE); 
     194        }else{ 
     195                print_usage(); 
     196        } 
     197        return -1; 
     198} 
     199 
    183200int main(int argc, char *argv[]){ 
    184201        int argi; 
     
    202219                }else if (strcmp(argv[argi],"register")==0){ 
    203220                        return register_execute(argc-argi-1,&argv[argi+1]); 
     221                }else if (strcmp(argv[argi],"unregister")==0){ 
     222                        return unregister_execute(argc-argi-1,&argv[argi+1]); 
    204223                }else if (strcmp(argv[argi],"dial")==0){ 
    205224                        return dial_execute(argc-argi-1,&argv[argi+1]); 
     
    207226                        send_generic_command("terminate",FALSE); 
    208227                        send_generic_command("duration",TRUE); 
     228                }else if (strcmp(argv[argi],"status")==0){ 
     229                        return status_execute(argc-argi-1,&argv[argi+1]); 
    209230                } 
    210231        } 
  • linphone/coreapi/linphonecore.h

    r222 r244  
    305305int linphone_proxy_config_done(LinphoneProxyConfig *obj); 
    306306void linphone_proxy_config_enable_publish(LinphoneProxyConfig *obj, bool_t val); 
     307bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *obj); 
    307308#define linphone_proxy_config_get_route(obj)  ((obj)->reg_route) 
    308309#define linphone_proxy_config_get_identity(obj) ((obj)->reg_identity) 
  • linphone/coreapi/proxy.c

    r222 r244  
    4747} 
    4848 
     49bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *obj){ 
     50        return obj->registered; 
     51} 
     52 
    4953static void linphone_proxy_config_register(LinphoneProxyConfig *obj){ 
    5054        osip_message_t *msg; 
Note: See TracChangeset for help on using the changeset viewer.