?? my_iax_app.cpp.bak
字號(hào):
#include <QtGui> #include<stdarg.h>#include <qvariant.h>#include "My_IAX_APP.h" #include "iaxclient.h"#include <QAction>#include <QApplication>#include <stdio.h>#include <stdarg.h>#include <stdlib.h>#include <qevent.h>#include <QtDebug>#include "My_IAX_Wrapper.h"//My_IAX_APP * callbackCaller;/* Global method used as callback function in libiaxclient Forwards incoming events to void IaxWrapper::handleIaxCEvent(void* callbackCaller, iaxc_event e) via customEvent(QCustomEvent)*/My_IAX_Wrapper *wrp=new My_IAX_Wrapper();My_IAX_APP::My_IAX_APP(QMainWindow *parent) { setupUi(this); //callbackCaller = this; Button_Dial_2->setHidden(TRUE);Button_Hangup_2->setHidden(TRUE); tabWidget->setCurrentIndex(1); Button_Dial->setEnabled(FALSE); //設(shè)置沒注冊(cè)前不可撥打 Button_Hangup->setEnabled(FALSE); connect(actionsetting, SIGNAL(triggered()), this, SLOT(show_setting())); connect(actionconnect,SIGNAL(triggered()),this,SLOT(My_IAX_Register())); connect(pushButton,SIGNAL(clicked()),this,SLOT(My_IAX_Register())); connect(pushButton_2,SIGNAL(clicked()),this,SLOT(My_IAX_Unregister())); connect(actiondisconnection,SIGNAL(triggered()),this,SLOT(My_IAX_Unregister())); connect(wrp,SIGNAL(signalRegistrationAccepted()),this,SLOT(My_IAX_Handleregister())); connect(wrp,SIGNAL(signalRegistrationRejected()),this,SLOT(My_IAX_HandleregisterReject())); connect(wrp,SIGNAL(signalRegistrationTimeout()),this,SLOT(My_IAX_HandleregisterTimeout())); connect(wrp,SIGNAL(signalIncomingRinging(int,QString)),this,SLOT(My_IAX_HandleAnswer(int,QString))); connect(wrp,SIGNAL(signalInactive(int)),this ,SLOT(My_IAX_HandleHangupother(int))); connect(Button_Digit9,SIGNAL(clicked()),this,SLOT(digit9Pressed())); connect(Button_Digit8,SIGNAL(clicked()),this,SLOT(digit8Pressed())); connect(Button_Digit7,SIGNAL(clicked()),this,SLOT(digit7Pressed())); connect(pushButton_6,SIGNAL(clicked()),this,SLOT(digit6Pressed())); connect(Button_Digit5,SIGNAL(clicked()),this,SLOT(digit5Pressed())); connect(Button_Digit4,SIGNAL(clicked()),this,SLOT(digit4Pressed())); connect(Button_Digit3,SIGNAL(clicked()),this,SLOT(digit3Pressed())); connect(Button_Digit2,SIGNAL(clicked()),this,SLOT(digit2Pressed())); connect(Button_Digit1,SIGNAL(clicked()),this,SLOT(digit1Pressed())); connect(Button_Digit0,SIGNAL(clicked()),this,SLOT(digit0Pressed())); connect(Button_DigitAsterisk,SIGNAL(clicked()),this,SLOT(digitStarPressed())); connect(Button_DigitSharp,SIGNAL(clicked()),this,SLOT(digitSharpPressed())); connect(Button_Dial,SIGNAL(clicked()),this, SLOT(HandleIAXDial())); connect(Button_Dial_2,SIGNAL(clicked()),this, SLOT(My_IAX_HandleReceive())); connect(Button_Hangup_2,SIGNAL(clicked()),this, SLOT(My_IAX_HandleReject())); connect(Button_Hangup,SIGNAL(clicked()),this,SLOT(My_IAX_HandleHangup())); int ok= wrp->init_iax_client(); } void My_IAX_APP:: show_setting() {// My_IAX_SETTING ui ; // ui.exec(); //Local_Account->insertItem(0,ui.Set_Account); //可以把seting的變量返回到My_IAX界面 // My_IAX_Account=ui.Set_Account; // My_IAX_ServerIP=ui.Set_ServerIP; // My_IAX_Password=ui.Set_Password; // 調(diào)用Register函數(shù)//Local_Account->insertItem(0,My_IAX_Account); // My_IAX_Register();//iaxc_start_processing_thread();//iaxc_register("7001","7001","172.31.251.105"); // qDebug()<<stderr<< "IaxWrapper::iaxc_initialize() \n";//init_iax_client();//靠tabWidget靠tabWidget->setCurrentIndex(0);} int My_IAX_APP:: My_IAX_Register() { My_IAX_Account=lineEdit->text();My_IAX_Password=lineEdit_2->text();My_IAX_ServerIP=lineEdit_3->text();if ((My_IAX_Account!="")&&(My_IAX_ServerIP!="")){ // My_IAX_Wrapper *wrp=new My_IAX_Wrapper(); //wrp-> registerWithServer(); //const char* accName = My_IAX_Account.toLocal8Bit().data(); //const char* passwd = My_IAX_Password.toLocal8Bit().data(); //const char* hst =My_IAX_ServerIP.toLocal8Bit().data(); //register_status =wrp->registerAccount(accName,passwd,hst); register_status=wrp->registerAccount(My_IAX_Account,My_IAX_Password,My_IAX_ServerIP);}else{int waring_my=QMessageBox::warning(this, (QString::fromLocal8Bit("信息不完整")), QString::fromLocal8Bit("請(qǐng)補(bǔ)充相關(guān)注冊(cè)信息"), QMessageBox::Ok );} } int My_IAX_APP:: My_IAX_Unregister(){ register_status=wrp->iaxRegistrationId;wrp-> unregisterAccount(register_status); pushButton->setEnabled(TRUE); actionconnect->setEnabled(TRUE);Local_Account->clear();Button_Hangup->setEnabled(FALSE);QMainWindow::statusBar()->showMessage("UnRegister");}void My_IAX_APP::My_IAX_Handleregister(){//Local_Account->insertItem(0,QString::number(register_status,10));添加數(shù)值的方法number函數(shù)Local_Account->insertItem(0, My_IAX_Account);{if (register_status!=-1) { //pushButton->setEnabled(FALSE); // actionconnect->setEnabled(FALSE);//wrp->dial("7001","7001","172.31.251.105","8001"); //Local_Account->insertItem(0,My_IAX_Account);Local_Account->setCurrentIndex(0); }else {} } register_success=1; pushButton->setEnabled(FALSE); actionconnect->setEnabled(FALSE); Button_Dial->setEnabled(TRUE); QMainWindow::statusBar()->showMessage(My_IAX_Account+" "+"Register");}void My_IAX_APP::My_IAX_HandleAnswer(int callNo,QString remoteExten){//QString str; setNum() QMainWindow::statusBar()->showMessage("calling from "+ remoteExten);wrp->startRing();Button_Dial_2->setHidden(FALSE);Button_Hangup_2->setHidden(FALSE);My_IAX_callNo=callNo; QWidget *tab1 = new QWidget(); QFont font; font.setPointSize(12); QLabel *label1=new QLabel(tab1);QLabel *label2=new QLabel(tab1);label1->setFont(font);label2->setFont(font);label1->setGeometry(QRect(40, 16, 111, 31));label2->setGeometry(QRect(60, 34, 111, 124));label1->setText("<font color=blue >calling from</font>");label2->setText(remoteExten);tabWidget->addTab(tab1,QIcon("icons/contact.png"),"Calling ?");tabWidget->setCurrentIndex(4);}void My_IAX_APP::My_IAX_HandleHangupother(int callNo){tabWidget->removeTab(4);}void My_IAX_APP::My_IAX_HandleReceive(){wrp->stopRing();wrp->answer_call(My_IAX_callNo);Button_Dial_2->setHidden(TRUE);Button_Hangup_2->setHidden(TRUE);Button_Hangup->setEnabled(TRUE);}void My_IAX_APP::My_IAX_HandleReject(){wrp->stopRing();wrp->reject_call(My_IAX_callNo);Button_Dial_2->setHidden(TRUE);Button_Hangup_2->setHidden(TRUE);tabWidget->removeTab(4);}void My_IAX_APP::My_IAX_HandleHangup(){wrp->interrupt_call();tabWidget->removeTab(4);}void My_IAX_APP::My_IAX_HandleregisterReject(){ QMainWindow::statusBar()->showMessage(My_IAX_Account+" "+"Rejected");}void My_IAX_APP::My_IAX_HandleregisterTimeout(){ QMainWindow::statusBar()->showMessage(My_IAX_Account+" "+"Timeout");}void My_IAX_APP::digitPressed(char digit) { // if (!wrapper->callSession.count()>0) /* if we dont have any call then print the chars in the combobox */ { Dial_Account->insertItem(0,""); QString lineStr = Dial_Account->currentText(); lineStr.append(digit); Dial_Account->setItemText(Dial_Account->currentIndex(),lineStr); } /* else we send dtmf with the current call */ // else // wrapper->send_dtmf(QChar(digit));}void My_IAX_APP::digit9Pressed() { digitPressed('9');}void My_IAX_APP::digit8Pressed() { digitPressed('8');}void My_IAX_APP::digit7Pressed() { digitPressed('7');}void My_IAX_APP::digit6Pressed() { digitPressed('6');}void My_IAX_APP::digit5Pressed() { digitPressed('5');}void My_IAX_APP::digit4Pressed() { digitPressed('4');}void My_IAX_APP::digit3Pressed() { digitPressed('3');}void My_IAX_APP::digit2Pressed() { digitPressed('2');}void My_IAX_APP::digit1Pressed() { digitPressed('1');}void My_IAX_APP::digit0Pressed() { digitPressed('0');}void My_IAX_APP::digitStarPressed() { digitPressed('*');}void My_IAX_APP::digitSharpPressed() { digitPressed('#');}void My_IAX_APP::HandleIAXDial(){ if (Dial_Account->currentText() !="") {wrp->dial(My_IAX_Account,My_IAX_Password,My_IAX_ServerIP,Dial_Account->currentText()); Button_Hangup->setEnabled(TRUE);}else {int waring_dialnumber=QMessageBox::warning(this, QString::fromLocal8Bit("信息不完整"), QString::fromLocal8Bit("請(qǐng)用撥號(hào)盤鍵入所要撥打的號(hào)碼"), QMessageBox::Ok );}}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -