📄 minisiptextui.cxx
字号:
state="IDLE"; setPrompt(state); displayMessage("hangupc"); handled=true; inCall=false; delete currentconf; } if ((command.size()>=4) && (command.substr(0,4) == "call")){ if (command.size()>=6){ if (state!="IDLE"){ displayMessage("UNIMPLEMENTED - only one call at the time with this UI.", red); }else{ string uri = trim(command.substr(5)); displayMessage("Uri: "+uri); //CONTINUEHERE!! //callId = callback->guicb_doInvite(uri); CommandString invite("",SipCommandString::invite,uri); CommandString resp = callback->handleCommandResp("sip",invite); callId = resp.getDestinationId(); if (callId=="malformed"){ state="IDLE"; setPrompt(state); displayMessage("The URI is not a valid SIP URI", red); callId=""; }else{ state="TRYING"; setPrompt(state); displayMessage(string("Created call with id=")+callId); } } }else{ displayMessage("Usage: call <userid>");// displayHelp("call"); } handled=true; } if ((command == "conf")){ if (state!="IDLE"){ displayMessage("UNIMPLEMENTED - only one call/conference at the time with this UI.", red); }else{ currentconfname = itoa(rand()); string mysipuri = config->inherited->sipIdentity->sipUsername + "@" + config->inherited->sipIdentity->sipDomain; currentconf=new ConferenceControl(mysipuri,currentconfname, true); //conf->setGui(this); confCallback->setConferenceController(currentconf); //currentconf->setCallback(callback); //state="CONF"; displayMessage("Conf. Name: "+currentconfname); confCallback->guicb_handleConfCommand(currentconfname); addCommand("addc"); addCommand("hangupc"); state="CONF"; setPrompt(state); } handled=true; } if ((command.size()>=8) && (command.substr(0,8) == "transfer")){ if (command.size()>=8){ if (state!="INCALL"){ displayMessage("Not in a call!", red); }else{ string uri = trim(command.substr(9)); CommandString transfer(callId, SipCommandString::user_transfer, uri); //callback->guicb_handleCommand(transfer); sendCommand("sip", transfer); } }else{ displayMessage("Usage: transfer <userid>"); } handled=true; } if ((command.size()>=4) && (command.substr(0,4) == "addc")){ if (command.size()>=6){ string uri = trim(command.substr(5)); displayMessage("Conf.Uri: "+uri); CommandString cmd("","join",uri); cmd.setParam3(currentconfname); confCallback->guicb_handleConfCommand(cmd); /*callId = callback->guicb_doInvite(uri); if (callId=="malformed"){ state="IDLE"; setPrompt(state); displayMessage("The URI is not a valid SIP URI", red); callId=""; }else{ state="TRYING"; setPrompt(state); displayMessage(string("Created call with id=")+callId); }*/ }else{ displayMessage("Usage: call <userid>");// displayHelp("call"); } handled=true; } /** * send any command you want. * Syntax: cmd <subsystem> <command> <param> **/ if ((command.size()>=3) && (command.substr(0,3) == "cmd")) { if(command.size()>=9) { string s_subsystem=""; string s_cmd = ""; string s_param = ""; uint32_t x = 4; for ( ; x<command.size(); x++){ if (command[x]!=' ') s_subsystem+=command[x]; else break; } for( ;x<command.size();x++) { if (command[x]!=' ') s_cmd+=command[x]; else break; } x++; for( ;x<command.size();x++) s_param+=command[x]; CommandString command("",s_cmd, s_param); displayMessage("Created cmd=" + s_cmd + " param=" + s_param+" subsystem="+s_subsystem); //callback->guicb_handleCommand(command); sendCommand(s_subsystem, command); } else { displayMessage("HELP: cmd\nSyntax: cmd <subsystem> <command> <param>", bold); } handled=true; }#ifdef P2T_SUPPORT /** * Commands for Push-2-Talk */ if ((command.size()>=3) && (command.substr(0,4) == "add ") && inCall){ if (command.size()>=5){ string uri = trim(command.substr(4)); grpList->addUser(uri); //if session is already going on, establish SIP Session if(p2tmode==true) { CommandString command("", "p2tAddUser",p2tGroupId, uri); //callback->guicb_handleCommand(command); sendCommand("sip", command); } }else{// displayHelp("call"); } handled=true; } //accept a p2t invitation if (command == "accept" /*FIXME*/&& state != "TRANSFER?" ){ //add P2T commands addCommand("add"); addCommand("edit"); addCommand("download"); addCommand("load"); addCommand("save"); addCommand("show"); addCommand("connect"); addCommand("talk"); addCommand("stop"); addCommand("exit"); addCompletionCallback("add", this); //inform DefaultDialogHandler CommandString cmd1("", "p2tSessionAccepted", p2tGroupId, inviting_user); //callback->guicb_handleCommand(cmd1); sendCommand("sip",cmd1); //Info Screen showP2TInfo(); p2tmode=true; handled=true; state = "P2T IDLE"; setPrompt(state); } //deny a p2t invitation if (command == "deny" ){ //Close SipDialogP2T and he will terminate all //SipDialogP2Tuser Sessions. CommandString command(p2tGroupId, "p2tTerminate"); //callback->guicb_handleCommand(command); sendCommand("sip", command); //reset states inCall=false; p2tmode=false; state = "IDLE"; setPrompt("IDLE"); handled=true; } //enter the P2T Mode if (command == "p2t" && p2tmode == false){ //add possible p2t commands to the TextUI addCommand("add"); addCommand("edit"); addCommand("download"); addCommand("load"); addCommand("save"); addCommand("show"); addCommand("connect"); addCommand("talk"); addCommand("stop"); addCommand("exit"); addCompletionCallback("add", this); //start p2tGroupListServer CommandString command("","p2tStartGroupListServer"); //callback->guicb_handleCommand(command); sendCommand("sip",command); //initiate Group Member List and add //own username to it grpList = MRef<GroupList*>(new GroupList()); //grpList->addUser(config->inherited.userUri); grpList->addUser(config->inherited->sipIdentity->getSipUri()); //InfoScreen showP2TInfo(); //set p2tmode variable and state inCall=true; //p2tmode = true; state = "P2T IDLE"; setPrompt("P2T IDLE"); handled=true; } if (command == "exit" && inCall == true){ //remove p2t commands //TODO: add this function to <libmutil/TextUI> //delete Group Member List grpList=NULL; //inform user displayMessage("You left the P2T-Mode...", blue); p2tmode = false; //stop SipDialogP2T CommandString term(p2tGroupId, "p2tTerminate"); //callback->guicb_handleCommand(term); sendCommand("sip",term); //stop p2tGroupListServer CommandString command("","p2tStopGroupListServer"); //callback->guicb_handleCommand(command); sendCommand("sip",command); //set state inCall=false; state = "IDLE"; setPrompt("IDLE"); handled=true; } if (command == "connect" && inCall == true){ CommandString cmd ("", "p2tStartSession", grpList->print()); //callback->guicb_handleCommand(cmd); sendCommand("sip",cmd); p2tmode=true; handled=true; } if (command == "talk" && p2tmode == true){ CommandString cmd (p2tGroupId, "p2tGetFloor"); //callback->guicb_handleCommand(cmd); sendCommand("sip", cmd); handled=true; } if (command == "stop" && p2tmode == true){ CommandString cmd (p2tGroupId, "p2tReleaseFloor"); //callback->guicb_handleCommand(cmd); sendCommand("sip",cmd); handled=true; } if (command == "edit" && inCall == true){ displayMessage("Not implemented!"); handled=true; } if (command == "save" && inCall == true){ displayMessage("Not implemented!"); handled=true; } if (command == "load" && inCall == true){ displayMessage("Not implemented!"); handled=true; } if (command == "show" && inCall == true){ showGroupList(); handled=true; } //download Group Member List from a server if ((command.size()>=8) && (command.substr(0,8) == "download") && inCall==true){ string file=""; string server=""; string s_port = ""; int port=0; uint32_t x=0; displayMessage(command.substr(9,7)); if(command.substr(9,7)=="http://" && command.size()>10) x=16; else x=9; //parse server for( ;x<command.size();x++){ if(command[x]==':') break; else if(command[x]=='/') { s_port="80"; break; } server+=command[x]; } //parse port for(++x;x<command.size();x++){ if(s_port=="80"){ --x; break; } if(command[x]=='/') break; s_port+=command[x]; } //parse file for( ;x<command.size();x++){ file+=command[x]; } if(s_port==""){ port=80; } else{ for(uint32_t k=0;k<s_port.size();k++) { port = (port*10) + (s_port[k]-'0'); } } displayMessage("Server: " + server); displayMessage("File: " + file); displayMessage("Port: " + s_port); //download GroupList MRef<GroupListClient*>client = new GroupListClient(); grpList = client->downloadGroupList(file, &server[0], port); displayMessage("Received GroupList:",bold); showGroupList(); client=NULL; handled=true; }#endif if (!handled && command.substr(0,2) == "im"){ handled=true; string arg = command.substr(2); arg = trim(arg); unsigned spos = arg.find(" "); if (spos==string::npos){ displayMessage("im usage: im <user> <message>",red); }else{ string addr =arg.substr(0,spos); addr = trim(addr); string msg = arg.substr(spos); msg = trim(msg); cerr << "Sending instant message to <"<< addr <<"> and message is <"<< msg<<">"<< endl; CommandString command("",SipCommandString::outgoing_im, msg, addr); //command["proxy_domain"] = regproxy; //callback->guicb_handleCommand(command); sendCommand("sip",command); } } if (!handled && command.size()>0){ displayMessage("Unknown command: "+command, red); }}void MinisipTextUI::setSipSoftPhoneConfiguration(MRef<SipSoftPhoneConfiguration *>sipphoneconfig){ config = sipphoneconfig; }void MinisipTextUI::setCallback(MRef<CommandReceiver*> callback){ Gui::setCallback(callback); MRef<Semaphore *> localSem = semSipReady; if( localSem ){ localSem->inc(); }}void MinisipTextUI::guimain(){ semSipReady->dec(); semSipReady = NULL; TextUI::guimain();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -