kphone.cpp
来自「KphoneSI (kpsi) is a SIP (Session Initia」· C++ 代码 · 共 531 行 · 第 1/2 页
CPP
531 行
extcontrol3->show();}void KPhone::showExtPreferences4( void ){ if( !extcontrol4 ) { extcontrol4 = new ExtControl(4, sessionC, this, getUserPrefix() ); } extcontrol4->show();}void KPhone::showRegistrations( void ){ registrations->showIdentity();}void KPhone::showGlobalPreferences( void ){ if( !sipprefs ) { sipprefs = new KSipPreferences( client, sessionC, this, getUserPrefix() ); } sipprefs->show();}void KPhone::showQueryOptions( void ){ if( !queryoptions ) { queryoptions = new KSipOptions( user ); } queryoptions->show();}void KPhone::showTestOptions( void ){ if( !testoptions ) { testoptions = new KTestOptions( client ); } client->setTest( true ); testoptions->show();}void KPhone::showHelp( void ){ QMessageBox mb( "KPhoneSI", "When starting KPhoneSI for the first time, you should enter your identity information in the window appearing.\n" " The information required for successful sipping are 'Full Name', 'User part of SIP URL' and 'Host part of SIP URL'.\n" "\n" "Filling the 'Outbound Proxy' Field is recommended, possibly necessary. Study you provider's documentation for the \n" " details. The field should contain your proxy's IP address or that of a Media Gateway if used.\n" " Mark the auto register selection if you wish KPhone SI to automatically register your identity on application start.\n" " If you want to use multiple identities, start KPhone SI with the '-u' option and the username of your selection.\n" " For example: 'KPhoneSI -u jsmith'.\n" " The -v <n> (n= 1, 2, 3) commandline option produces different forms of logging. \n" "\n" "If you are behind a NAT (Network Address Translation) device, you should go to Preferences -> SIP Preferences -> Socket and\n" " check the 'Use STUN Server' and specify the STUN server's IP address\n" "\n" "There are different ways to start a call.\n" " One way is to type the SIP-URI and then select the call type (audio, video, ...)\n" " If you select the call type first, you may type the URI right after the Call Widged popped up\n" "\n" "A started call is displayed in the 'Session Info' window, right clicking an entry pops up a window with the controls for that call\n" " This is the place where you release the call (hangup entry). Alternatively you may double click the entry. Then the call widget\n" " pops up, to allow the control functions\n" "\n" "You should edit the Phone Book and enter all your favorite contacts there. Of course this is not mandatory but it increases your\n" " efficiency with KPhoneSI.When adding contacts to your Phone Book, simply click Add and enter the person's real name, SIP identity\n" " and the optional description. If you double click a existing contact, the URI appears in the dial window\n" "\n" "More detailed documentation plus graphic material can be found in the html written user manual. Its available in the document \n" " subdirectory of the source code.\n" "\n", QMessageBox::NoIcon, QMessageBox::Ok | QMessageBox::Default, QMessageBox::NoButton, QMessageBox::NoButton ); mb.exec();}void KPhone::showAboutKPhone( void ){ QMessageBox::about( this, "About KPhhoneSI", "KPhone SI " + KPhoneVersion + " is an 'Applicaltion Over Internet' device\n" "utilizing the Session Initiation Protocol\n\n" "For more information about the KPhone SI see\n" "http://sourceforge.net/projects/kphone\n\n" "The KPhone SI is actually designed and developed by\n" "Klaus Fleischmann <kgfleischmann@t-online.de>\n\n" "The KPhoneSI is released under the GPL\n\n" );}void KPhone::toggleTrayIcon( int id ){ if ( preferencesMenu->isItemChecked( id ) ) { preferencesMenu->setItemChecked( id, false ); deleteTrayIcon(); } else { preferencesMenu->setItemChecked( id, true ); createTrayIcon(); }}void KPhone::createTrayIcon( void ){ if ( ! trayIcon ) { if ( view->getState() ) { trayIcon=new TrayIcon( this, "trayIcon", QPixmap::fromMimeSource( SHARE_DIR "/icons/online.png" ), "KPhoneSI" ); } else { trayIcon=new TrayIcon( this, "trayIcon", QPixmap::fromMimeSource( SHARE_DIR "/icons/offline.png" ), "KPhoneSI" ); } connect( trayIcon, SIGNAL( clicked() ), this, SLOT( toggleVisibility() ) ); connect( trayIcon, SIGNAL( contextMenuRequested( const QPoint& ) ), this, SLOT( trayMenuRequested( const QPoint& ) ) ); trayIcon->show(); } else { updateTrayIcon(); }}void KPhone::deleteTrayIcon( void ){ if ( trayIcon ) { trayIcon->close(); delete trayIcon; trayIcon = NULL; }}void KPhone::updateTrayIcon( void ){ if ( trayIcon ) { if ( view->getState() ) { trayIcon->setPixmap( QPixmap::fromMimeSource( SHARE_DIR "/icons/online.png" ) ); } else { trayIcon->setPixmap( QPixmap::fromMimeSource( SHARE_DIR "/icons/offline.png" ) ); } trayIcon->repaint(); }}void KPhone::toggleVisibility(){ if ( this->isVisible() ) { this->hide(); } else { this->show(); }}void KPhone::trayMenuRequested( const QPoint& pos ){ QPopupMenu* trayMenu = new QPopupMenu(this); trayMenu->insertItem( isVisible() ? "&Hide" : "S&how", this, SLOT( toggleVisibility() ) ); trayMenu->insertItem( view->getState() ? "&Offline" : "&Online" , view, SLOT( buttonOffOnlineClicked() ) ); trayMenu->insertSeparator(); trayMenu->insertItem( "&Quit", this, SLOT( kphoneQuit() ) ); trayMenu->exec(pos); delete trayMenu;}void KPhone::kphoneQuit( void ){ QSettings settings; QString p = KStatics::dBase + getUserPrefix() + "/General/TrayIcon"; if ( trayIcon ) { settings.writeEntry( p, "Yes" ); trayIcon->close(); delete trayIcon; trayIcon = NULL; } else { settings.writeEntry( p, "No" ); } delRDialSocket(); view->kphoneQuit(); quitTimer = new QTimer( this ); connect( quitTimer, SIGNAL( timeout() ), qApp, SLOT( quit() ) ); quitTimer->start( quitTime ); hide();}void KPhone::closeEvent( QCloseEvent* ce ){ ce->ignore(); kphoneQuit();}bool KPhone::newRDialSocket(void) { int l; if(!sessionC->getRem()) return false; /* Create socket on which to send. */ rdSock = socket(AF_UNIX, SOCK_DGRAM, 0); if (rdSock < 0) { perror("opening datagram socket"); return false; } /* Construct name of socket to send to. */ //for (l=0; l<100; l++) mess[l] = 0x0; bzero( &mess[0], 100 ); rdServer.sun_family = AF_UNIX; strcpy(rdServer.sun_path, "/tmp/kpsidg"); l = strlen(rdServer.sun_path)+sizeof(rdServer.sun_family); if(bind (rdSock,(struct sockaddr *)&rdServer, l) <0) { perror("bind");// unlink(rdServer.sun_path); return false; } // set the socket nonblocking, it could be called by another application! int flags = fcntl(rdSock, F_GETFL, 0); flags |= O_NONBLOCK|O_NDELAY; if (fcntl(rdSock, F_SETFL, flags) == -1) { perror("fcntl: F_SETFL"); return false; } return true;}void KPhone::checkRDialSocket(void) { int cllen=0,n=0,l=0; n=recvfrom(rdSock,&mess[0],100,0,(struct sockaddr *)&rdClient,(socklen_t *)&cllen); if (n>0) { SipCall::CallType ct; QString num = &mess[1]; switch (mess[0]){ case 'a': ct=SipCall::StandardCall; break; case 'v': ct=SipCall::auviCall; break; case 'o': ct=SipCall::videoCall; break; case '1': ct=SipCall::extCall1; break; case '2': ct=SipCall::extCall2; break; case '3': ct=SipCall::extCall2; break; case '4': ct=SipCall::extCall2; break; default: ct=SipCall::StandardCall; break; } printf ("server: %s %s %d\n",&mess[0],num.latin1(),(int)ct); view->startCallWidget (num, ct); bzero( &mess[0], n ); //for (l=0; l<n; l++) mess[l] = 0; }}void KPhone::delRDialSocket(void) { if (haveRDSock) { haveRDSock = false; delete rdTimer; rdTimer = 0; close(rdSock); unlink(rdServer.sun_path); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?