📄 defaultdialoghandler.cxx
字号:
voipCall = new SipDialogVoipServer(sipStack, callConf, phoneconf, mediaSession, pkt->getCallId());// }#endif sipStack->addDialog(voipCall); SipSMCommand cmd(pkt, SipSMCommand::transaction_layer, SipSMCommand::dialog_layer); //cmd.setDispatchCount(dispatchCount); sipStack->getDispatcher()->enqueueCommand(cmd, HIGH_PRIO_QUEUE/*, PRIO_LAST_IN_QUEUE*/); mdbg << cmd << end; } return true; } if (pkt->getType()=="MESSAGE"){ MRef<SipRequest*> im = (SipRequest*)*pkt;#ifdef DEBUG_OUTPUT mdbg << "DefaultDialogHandler:: creating new server transaction for incoming SipIMMessage" << end;#endif string branch = im->getDestinationBranch(); sendIMOk(im, branch); massert(dynamic_cast<SipMessageContentIM*>(*im->getContent())!=NULL); MRef<SipMessageContentIM*> imref = (SipMessageContentIM*)*im->getContent(); string from = im->getHeaderValueFrom()->getUri().getUserName()+"@"+ im->getHeaderValueFrom()->getUri().getIp(); string to = im->getHeaderValueTo()->getUri().getUserName()+"@"+ im->getHeaderValueTo()->getUri().getIp(); CommandString cmdstr("", SipCommandString::incoming_im, imref->getString(), from, to ); sipStack->getCallback()->handleCommand("gui", cmdstr ); return true; } // if (command.getType()==SipSMCommand::COMMAND_PACKET){ mdbg << "DefaultDialogHandler ignoring " << pkt->getString() << end; // } return false;}bool DefaultDialogHandler::handleCommandString( CommandString &cmdstr){/* if (dispatchCount>=2){ mdbg << "WARNING: Command ["<< cmdstr.getOp()<<"] ignored (dispatched flag indication)"<< end; return true; }*/ if (cmdstr.getOp() == SipCommandString::start_presence_client){ cerr << "DefaultDialogHandler: Creating SipDialogPresenceClient for start_presence_client command"<< endl; MRef<SipDialogConfig*> conf = new SipDialogConfig(phoneconf->inherited); MRef<SipDialogPresenceClient*> pres(new SipDialogPresenceClient(sipStack, conf, phoneconf->useSTUN )); sipStack->addDialog( MRef<SipDialog*>(*pres) ); CommandString command(cmdstr); cmdstr.setDestinationId(pres->getCallId()); SipSMCommand cmd( cmdstr, SipSMCommand::transaction_layer, SipSMCommand::dialog_layer); //cmd.setDispatchCount(dispatchCount); sipStack->getDispatcher()->enqueueCommand(cmd, HIGH_PRIO_QUEUE/*, PRIO_LAST_IN_QUEUE*/); return true; } if (cmdstr.getOp() == SipCommandString::start_presence_server){ cerr << "DefaultDialogHandler: Creating SipDialogPresenceServer for start_presence_server command"<< endl; MRef<SipDialogConfig*> conf = new SipDialogConfig(phoneconf->inherited); MRef<SipDialogPresenceServer*> pres(new SipDialogPresenceServer(sipStack, conf, phoneconf->useSTUN )); sipStack->addDialog( MRef<SipDialog*>(*pres) ); CommandString command(cmdstr); cmdstr.setDestinationId(pres->getCallId()); SipSMCommand cmd( cmdstr, SipSMCommand::transaction_layer, SipSMCommand::dialog_layer); //cmd.setDispatchCount(dispatchCount); sipStack->getDispatcher()->enqueueCommand(cmd, HIGH_PRIO_QUEUE/*, PRIO_LAST_IN_QUEUE*/); return true; } if (cmdstr.getOp() == SipCommandString::outgoing_im){ //cerr << "DefaultDialogHandler: Creating SipTransactionClient for outgoing_im command"<< endl; //int im_seq_no= requestSeqNo(); ++outsideDialogSeqNo; //++dialogState.seqNo;/* MRef<SipTransaction*> trans = new SipTransactionNonInviteClient(sipStack, //NULL, outsideDialogSeqNo, "MESSAGE", ""); mdbg << "WWWWWWW: transaction created, branch id is <"<<trans->getBranch()<<">."<< end; //cerr << "command standard arguments is <"<< command.getCommandString().getString() <<">"<< endl; sipStack->getDispatcher()->getLayerTransaction()->addTransaction(trans);*/ sendIM( ""/*trans->getBranch()*/, cmdstr.getParam(), outsideDialogSeqNo, cmdstr.getParam2() ); return true; } if (cmdstr.getOp() == SipCommandString::proxy_register){ //merr << end << "CESC: DefaultDialogHandler: got proxy_register: "<< cmdstr.getString() << end << end; MRef<SipDialogConfig*> conf = new SipDialogConfig(phoneconf->inherited); MRef<SipIdentity *> identity; identity = phoneconf->getIdentity( cmdstr["identityId"] ); string proxyDomainArg = cmdstr["proxy_domain"]; /* Use appropriate identity ... */ if( ! identity.isNull() ) { //FIXME: useSecurity is false ... useIdentity doesn't use it anyway ... conf->useIdentity( identity, false ); } else if (phoneconf->pstnIdentity && (cmdstr.getDestinationId()=="pstn" || (proxyDomainArg!="" && proxyDomainArg==phoneconf->pstnIdentity->sipDomain))){ conf->useIdentity( phoneconf->pstnIdentity, false); } MRef<SipDialogRegister*> reg(new SipDialogRegister(sipStack, conf)); sipStack->addDialog( MRef<SipDialog*>(*reg) ); SipSMCommand cmd( cmdstr, SipSMCommand::dialog_layer, SipSMCommand::dialog_layer); //cmd.setDispatchCount(dispatchCount); sipStack->getDispatcher()->enqueueCommand(cmd, HIGH_PRIO_QUEUE/*, PRIO_LAST_IN_QUEUE*/); return true; }#ifdef P2T_SUPPORT /***** * P2T commands: ****/ //start P2T Session if(cmdstr.getOp() == "p2tStartSession") { startP2TSession( SipSMCommand(cmdstr,source,destination) ); return true; } //start GroupListServer if(cmdstr.getOp() == "p2tStartGroupListServer") { grpListServer = new GroupListServer(phoneconf, 0); grpListServer->start(); return true; } //stop GroupListServer if(cmdstr.getOp() == "p2tStopGroupListServer") { grpListServer->stop(); grpListServer=NULL; return true; } //p2tSession is accepted if(cmdstr.getOp() == "p2tSessionAccepted") { inviteP2Taccepted(SipSMCommand(cmdstr, source , destination) ); return true; } //add user to a P2T Session if(cmdstr.getOp() == "p2tAddUser") { //get SipDialogP2T MRef<SipDialogP2T*>p2tDialog; getP2TDialog(cmdstr.getParam(), p2tDialog); //add user string user = cmdstr.getParam2(); p2tDialog->getGroupList()->addUser(user); //create callConfig MRef<SipDialogConfig*> callConf = MRef<SipDialogConfig*>(new SipDialogConfig(phoneconf->inherited) ); //check user uri and modify DialogConfig if(modifyDialogConfig(user, callConf)==false){ p2tDialog->removeUser(user, "uri malformed", ""); return true; } MRef<SipDialogP2Tuser*> p2tUserDialog = new SipDialogP2Tuser(sipStack, callConf, phoneconf, p2tDialog); sipStack->addDialog(*p2tUserDialog); //set CallId and localStarted in GroupMemberList p2tDialog->getGroupList()->getUser(user)->setCallId(p2tUserDialog->getCallId()); p2tDialog->getGroupList()->getUser(user)->setLocalStarted(true); //send invite message CommandString inv(p2tUserDialog->getCallId(), SipCommandString::invite, user); SipSMCommand cmd(SipSMCommand(inv, SipSMCommand::dialog_layer, SipSMCommand::dialog_layer)); getDialogContainer()->enqueueCommand( cmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE ); return true; }#endif mdbg << "DefaultDialogHandler ignoring command " << cmdstr.getString() << end; return false;}bool DefaultDialogHandler::handleCommand(const SipSMCommand &command){ mdbg << "DefaultDialogHandler: got command "<< command << end; int dst = command.getDestination(); if ( dst!=SipSMCommand::dialog_layer) return false; //int dispatchCount = command.getDispatchCount(); if (command.getType()==SipSMCommand::COMMAND_PACKET){ return handleCommandPacket( command.getCommandPacket()/*, dispatchCount*/); }else{ massert(command.getType()==SipSMCommand::COMMAND_STRING); CommandString cmdstr = command.getCommandString(); return handleCommandString( cmdstr/*, dispatchCount */); }}#ifdef P2T_SUPPORTvoid DefaultDialogHandler::inviteP2Treceived(const SipSMCommand &command){ //type casting MRef<SipMessage*> pack = command.getCommandPacket(); MRef<SipRequest*> inv = MRef<SipRequest*>((SipRequest*)*pack); //get the GroupList from the remote GroupListServer MRef<GroupList*>grpList; massert(dynamic_cast<SdpPacket*>(*inv->getContent())!=NULL); MRef<SdpPacket*> sdp = (SdpPacket*)*inv->getContent(); string gServer = sdp->getSessionLevelAttribute("p2tGroupListServer"); string gID = sdp->getSessionLevelAttribute("p2tGroupIdentity"); string prot = sdp->getSessionLevelAttribute("p2tGroupListProt"); //parse gServer string server=""; int port=0; uint32_t k=0; for(/*k*/;k<gServer.size();k++){ if(gServer[k]!=':') server+=gServer[k]; else break; } for(++k;k<gServer.size();k++) port = (port*10) + (gServer[k]-'0'); //download Group Member List if protocol is http/xml if(prot=="http/xml"){ MRef<GroupListClient*>client = new GroupListClient(); grpList = client->getGroupList(gID,&server[0],port); client=NULL; } else{#ifdef DEBUG_OUTPUT mdbg << "DefaultDialogHandler:: Unknown GroupListProtocol "<<prot<< end;#endif return; } //get inviting user name string inv_user = inv->getHeaderValueFrom()->getUri().getUserId()+"@"+ inv->getHeaderValueFrom()->getUri().getIp(); //start SipDialogP2T only, if there isn't already //one started with this GroupIdentity MRef<SipDialogP2T*>p2tDialog; MRef<SipDialogConfig*> callConf; if(getP2TDialog(gID, p2tDialog)==false){ //start new SipDialogP2T callConf = MRef<SipDialogConfig*>(new SipDialogConfig(phoneconf->inherited) ); p2tDialog = new SipDialogP2T(sipStack, callConf, phoneconf); p2tDialog->setGroupList(grpList); //p2tDialog->getDialogConfig().callId = gID; p2tDialog->setCallId(gID); MRef<SipDialog*> dlg = *p2tDialog; sipStack->addDialog(dlg); //send invitation to the GUI CommandString cmdstr(gID, "p2tInvitation", grpList->print(), inv_user); getDialogContainer()->getCallback()->handleCommand("gui", cmdstr ); } //set now correct GroupList grpList = p2tDialog->getGroupList(); //start SipDialogP2Tuser for inviting user callConf = MRef<SipDialogConfig*>(new SipDialogConfig(phoneconf->inherited) ); MRef<SipDialogP2Tuser*> p2tDialogUser = new SipDialogP2Tuser(sipStack, callConf, phoneconf, p2tDialog); //p2tDialogUser->getDialogConfig().callId = command.getCommandPacket()->getCallId(); p2tDialogUser->setCallId( command.getCommandPacket()->getCallId() ); sipStack->addDialog(*p2tDialogUser); //user doesn't exist in grpList and will be added to it if(grpList->isParticipant(inv_user)==false){ //check memberlist if(grpList->getMembership()==P2T::MEMBERSHIP_OPEN || (grpList->getMembership()==P2T::MEMBERSHIP_RESTRICTED && grpList->isMember(inv_user))){ //adduser to grpList grpList->addUser(inv_user); //set CallId in Group Member List grpList->getUser(inv_user)->setCallId(p2tDialogUser->getCallId()); grpList->getUser(inv_user)->setStatus(P2T::STATUS_WAITACCEPT);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -