📄 kphoneview.cpp
字号:
emit(stateChanged());}void KPhoneView::buttonOffOnlineClicked( void ){ if( isOnline ) { buttonSetOffline = true; isOnline = false; buttonUpdate->setEnabled( false ); stateComboBox->setEnabled( false ); QIconSet icon1; icon1.setPixmap(SHARE_DIR "/icons/offline.png", QIconSet::Automatic ); buttonOffOnline->setIconSet( icon1 ); stateUpdated( OFFLINE ); } else { buttonSetOffline = false; isOnline = true; KStatics::noLine=0; buttonUpdate->setEnabled( true ); stateComboBox->setEnabled( true ); QIconSet icon2; icon2.setPixmap(SHARE_DIR "/icons/online.png", QIconSet::Automatic ); buttonOffOnline->setIconSet( icon2 ); stateUpdated( ONLINE ); }}void KPhoneView::buttonUpdateClicked( void ){ if( isOnline ) { stateUpdated( ONLINE ); }}void KPhoneView::stateUpdated( int id ){ QString subject; if( id == OFFLINE ) { isOnline = false; buttonUpdate->setEnabled( false ); QIconSet icon; icon.setPixmap(SHARE_DIR "/icons/offline.png", QIconSet::Automatic ); buttonOffOnline->setIconSet( icon ); } SipCallIterator it( client->getCallList() ); it.toFirst(); for( it.toFirst(); it.current(); ++it ) { if( it.current()->getCallType() == SipCall::inSubscribeCall ) { if( it.current()->getCallStatus() == SipCall::callInProgress ) { SipCallMember *member = it.current()->getMemberList().toFirst(); if( member ) { sendNotify( id, member ); } } else { delete it.current(); } } }emit (stateChanged());}QString KPhoneView::stateText( QString text ){ QString state; if( text == "Online" ) { state = "online"; } else if( text == "Busy" ) { state = "busy"; } else if( text == "Be Right Back" ) { state = "berightback"; } else if( text == "Away" ) { state = "away"; } else if( text =="Permanent absent") { state = "permanent-absence"; } else if( text == "Appointment") { state ="appointment"; } else if( text == "On Breakfast") { state ="breakfast"; } else if( text == "On Dinner") { state = "dinner"; } else if( text == "On Holidays") { state = "holiday"; } else if( text == "On Lunch") { state ="lunch"; } else if( text == "Having a Meal") { state ="meal"; } else if( text == "On Meeting") { state ="meeting"; } else if( text == "Travelling") { state ="travel"; } else if( text =="In Transit") { state = "in-transit"; } else if( text =="Steering") { state = "steering"; } else if( text =="Shopping") { state = "shopping"; } else if( text =="Sleeping") { state = "sleeping"; } else if( text =="Looking TV") { state = "tv"; } else if( text == "On Vacation") { state ="vacation"; } else if( text == "On The Phone" ) { state = "onthephone"; } else if( text == "Offline" ) { state = "offline"; } else { state = (text.lower()).simplifyWhiteSpace(); } return state;}void KPhoneView::sendNotify( int id, SipCallMember *member ){ QString s; QString tmp; QString state = "offline"; QString basic = "closed"; QString mime; time_t ti; tm *t; ti = time( NULL ); t = gmtime( &ti ); QDateTime dt( QDate( t->tm_year+1900, t->tm_mon + 1, t->tm_mday ), QTime( t->tm_hour, t->tm_min, t->tm_sec ) ); if( id == ONLINE ) { basic = "open"; if( stateComboBox->currentText().isEmpty() ) { state = "online"; } else { state = stateText(stateComboBox->currentText()); } } if(member->getCall()->getPresBody() == 0) { s = "<?xml version=\"1.0\"?>\n"; s += "<!DOCTYPE presence\n"; s += "PUBLIC \"-//IETF//DTD RFCxxxx XPIDF 1.0//EN\" \"xpidf.dtd\">\n"; s += "<presence>\n"; s += "<presentity uri=\""; s += member->getUri().reqUri(); s += ";method=SUBSCRIBE\"/>\n"; s += "<atom id=\""; s += tmp.setNum( atomId++ ).latin1(); s += "\">\n"; s += "<address uri=\""; s += client->getContactUri().reqUri(); s += ";user=ip\" priority=\"0,800000\">\n"; s += "<status status=\"open\"/>\n"; s += "<msnsubstatus substatus=\""; s += state; s += "\" />\n"; s += "</address>\n"; s += "</atom>\n"; s += "</presence>\n"; mime = "application/xpidf+xml"; } else { s = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n"; s += "<pr:presence\n"; s += " xmlns:pr=\"urn:ietf:params:xml:ns:pidf\"\n"; s += " entity=\"sip:" + member->getUri().reqUri() + "\"\n"; s += " xmlns:caps=\"urn:ietf:params:xml:ns:pidf:caps\"\n"; s += " xmlns:cipid=\"urn:ietf:params:xml:ns:pidf:cipid\"\n"; s += " xmlns:dm=\"urn:ietf:params:xml:ns:pidf:data-model\"\n"; s += " xmlns:rpid=\"urn:ietf:params:xml:ns:pidf:rpid\">\n"; s += " <pr:tuple id=\"bs35r9\">\n"; s += " <pr:status>\n"; s += " <pr:basic>" + basic + "</pr:basic>\n"; s += " </pr:status>\n"; s += " <pr:note>" + state +"</pr:note>\n"; s += " <pr:timestamp>" + dt.toString(Qt::ISODate)+ "</pr:timestamp>\n"; s += " </pr:tuple>\n"; s += " <dm:person id=\"p1\">\n"; s += " <rpid:activities><rpid:" + state.lower() + "/></rpid:activities>\n"; s += " <dm:note>" + state + "</dm:note>\n"; s += " </dm:person>\n"; s += "</pr:presence>\n"; mime = "application/pidf+xml"; } if( stateComboBox->currentText().lower() == "busy" ) { client->setBusy( true ); } else { client->setBusy( false ); } if( member != 0 ) { if( id == OFFLINE ) { member->requestClearNotify( s.latin1(), MimeContentType(mime) ); } else { if( !buttonSetOffline ) { member->requestNotify( s.latin1(), MimeContentType( mime ) ); } } } }void KPhoneView::informPhoneView( int info, int wNr){ if(info == (UPDATEWLIST) ) { emit auditKCW(); }}void KPhoneView::redirectCall( const SipUri &calluri, const QString &subject, int ct, KCallWidget *trfrom , int wNr){ updateWidgetList(); SipCall *newcall = new SipCall( user ); newcall->setSubject( subject ); newcall->setCallTrType(ct); KCallWidget *widget = new KCallWidget( sipauthentication, sessionControl, newcall, callAudio, this, this, trfrom ,wNr ); cwList.append( widget ); widget->pleaseDial( calluri ); connect( widget, SIGNAL( redirectCall( const SipUri &, const QString &, int, KCallWidget *, int ) ), this, SLOT( redirectCall( const SipUri &, const QString &, int, KCallWidget *, int ) ) ); connect( widget, SIGNAL( informPhoneView( int ,int) ), this, SLOT( informPhoneView( int ,int) ) ); widget->show(); }bool KPhoneView::startCallWidget(QString num, SipCall::CallType ct) { updateWidgetList(); if( !buttonSipUri->text().compare( "Set Identity" ) ){ QMessageBox::information( this, "Dialling", "Set First Identity." ); return false; } SipCall *newcall = new SipCall( user, QString::null, ct ); QString subject; subject.sprintf( user->getUri().uri() ); newcall->setSubject( subject ); KCallWidget *widget = new KCallWidget( sipauthentication, sessionControl, newcall, callAudio, this, this ,NULL ,0 ); cwList.append( widget ); if( !num.isEmpty() ) { widget->setRemote( num ); widget->clickDial();//newcall->setSwitchThru(true); } connect( widget, SIGNAL( redirectCall( const SipUri &, const QString &, int, KCallWidget *, int ) ), this, SLOT( redirectCall( const SipUri &, const QString &, int, KCallWidget *, int ) ) ); connect( widget, SIGNAL( informPhoneView( int ,int) ), this, SLOT( informPhoneView( int ,int) ) ); widget->show(); return true;} void KPhoneView::makeNewCall( void ){ if (startCallWidget(lineeditCall->text(),SipCall::StandardCall) ) lineeditCall->setText("");}void KPhoneView::makeNewExt1( void ){ if (startCallWidget(lineeditCall->text(),SipCall::extCall1) ) lineeditCall->setText("");}void KPhoneView::makeNewExt2( void ){ if (startCallWidget(lineeditCall->text(),SipCall::extCall2) ) lineeditCall->setText("");}void KPhoneView::makeNewExt3( void ){ if (startCallWidget(lineeditCall->text(),SipCall::extCall3) ) lineeditCall->setText("");}void KPhoneView::makeNewExt4( void ){ if (startCallWidget(lineeditCall->text(),SipCall::extCall4) ) lineeditCall->setText("");}void KPhoneView::makeVideoCall( void ){ if (startCallWidget(lineeditCall->text(),SipCall::videoCall) ) lineeditCall->setText("");}void KPhoneView::makeAuViCall( void ){ if (startCallWidget(lineeditCall->text(),SipCall::auviCall) ) lineeditCall->setText("");}void KPhoneView::updateIdentity( SipUser *newUser, SipRegister *newReg ){ if( newReg != 0 ) { if( reg != 0 ) { disconnect( reg, SIGNAL( statusUpdated() ), this, SLOT( localStatusUpdate() ) ); } reg = newReg; connect( reg, SIGNAL( statusUpdated() ), this, SLOT( localStatusUpdate() ) ); localStatusUpdate(); } buttonSipUri->setText( newUser->getUri().uri() ); user = newUser;}void KPhoneView::busyToggled( bool onoff ){ client->setBusy( onoff );}void KPhoneView::showIdentities( void ){ identitiesDialog->showIdentity();}void KPhoneView::identities( KSipRegistrations *i ){ identitiesDialog = i;}void KPhoneView::setContactsOffline( void ){ stateUpdated( KPhoneView::OFFLINE ); setSubscribeOffline = true; localStatusUpdate();}void KPhoneView::setContactsOnline( void ){ stateUpdated( KPhoneView::ONLINE );}void KPhoneView::kphoneQuit( void ){ KCallWidget *widget; for( widget = cwList.first(); widget != 0; widget = cwList.next() ) { if( widget->isHided() ) { cwList.remove( widget ); } else { widget->clickHangup(); } } setContactsOffline(); identitiesDialog->unregAllRegistration();}QString KPhoneView::getUserPrefix( void ){ return ((KPhone *)parentWidget())->getUserPrefix();}void KPhoneView::saveRejectContactList( void ){ QSettings settings; QString p = KStatics::dBase + getUserPrefix() + "/presence/"; QString label; int count = 0; label.setNum( count ); label = p + "/Rejected" + label; QString s = settings.readEntry( label, "" ); while( !s.isEmpty() ) { settings.writeEntry( label, ""); label.setNum( ++count ); label = p + "/Rejected" + label; s = settings.readEntry( label, "" ); } count = 0; for ( QStringList::Iterator it = rejectedContactList.begin(); it != rejectedContactList.end(); ++it ) { label.setNum( count++ ); label = p + "/Rejected" + label; settings.writeEntry( label, QString(*it) ); }}void KPhoneView::updateWidgetList( void ){ KCallWidget *widget; for( widget = cwList.first(); widget != 0; widget = cwList.next() ) { if( widget->isHided() ) { cwList.remove( widget ); emit auditKCW(); } }}void KPhoneView::testWidgetList( void ){ KCallWidget *widget; for( widget = cwList.first(); widget != 0; widget = cwList.next() ) { printf("\n^^^^^ callwidget=%d\n",widget->myNumber); }}int KPhoneView::isExistingWidget( int wNr ){ KCallWidget *widget; for( widget = cwList.first(); widget != 0; widget = cwList.next() ) { if ( (widget->myNumber == wNr) && (!widget->isHided() ) ){ return wNr; } else return 0; } return 0;}void KPhoneView::rideCalls( void ) {SipCallIterator it( client->getCallList() ); for( it.toFirst(); it.current(); ++it ) { printf("next:\n"); switch ( it.current()->getCallType()) { case SipCall::GarKeinCall: printf("Call not yet defined"); break; case SipCall::StandardCall: printf("StandardCall"); break; case SipCall::videoCall: printf("videoCall"); break; case SipCall::OptionsCall: printf("OptionsCall"); break; case SipCall::RegisterCall: printf("RegisterCall"); break; case SipCall::MsgCall: printf("MsgCall"); break; case SipCall::BrokenCall: printf("BrokenCall"); break; case SipCall::UnknownCall: printf("UnknownCall"); break; case SipCall::outSubscribeCall: printf("outSubscribeCall"); break; case SipCall::inSubscribeCall: printf("inSubscribeCall"); break; case SipCall::inSubscribeCall_2: printf("inSubscribeCall_2"); break; case SipCall::extCall1: printf("ExtCall1"); break; case SipCall::extCall2: printf("ExtCall2"); break; case SipCall::extCall3: printf("ExtCall3"); break; case SipCall::extCall4: printf("ExtCall4"); break; default: printf("undefined call = %d",(int)it.current()->getCallType()); break; } printf( "\n"); printf( "\nHoldFlag = %d\n",(int)it.current()->getHoldCall()); printf( "HoldMaster = %d\n",(int)it.current()->getHoldMaster()); }}int KPhoneView::countActiveCalls(void) {int cnt=0;SipCallIterator it( client->getCallList() ); for( it.toFirst(); it.current(); ++it ) { if( it.current()->blockCall() && (it.current()->isActive() ) ) { cnt++; } }return cnt;}bool KPhoneView::activateAllowed( void ) {SipCallIterator it( client->getCallList() ); bool isfree = true; for( it.toFirst(); it.current(); ++it ) { if(it.current()->isOnlyMeActive() && !(it.current()->getHoldCall())) { isfree = false; break; } }return isfree; }void KPhoneView::info(void) {infostat1->setText(sic->getContactText());}bool KPhoneView::getState( void ){ return isOnline;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -