📄 minisipmainwindowwidget.cxx
字号:
/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *//* Copyright (C) 2004 * * Authors: Erik Eliasson <eliasson@it.kth.se> * Johan Bilien <jobi@via.ecp.fr>*/#include"MinisipMainWindowWidget.h"#include"qtguistarter.h"#include<qapplication.h>#include<qvbox.h>#include<qpopupmenu.h>#if (QT_VERSION > 0x030000)#include<qkeysequence.h>#endif#include<qmainwindow.h>#include<qstatusbar.h>#include<qpushbutton.h>#include<qhbox.h>#include<qlayout.h>#include<qlineedit.h>#include<qheader.h>#include<qlistview.h>#include<qmenubar.h>#include<qevent.h>#include<qmessagebox.h>//#include"../../../sip/state_machines/SMCommand.h"#ifdef OPIE#include <qcopchannel_qws.h>#endif#include"SettingsDialog.h"#include<libmutil/itoa.h>#include<libmutil/trim.h>#include<fstream>#include<libmutil/XMLParser.h>#include<libmnetutil/IP4ServerSocket.h>#include<libmnetutil/TCPSocket.h>#include<libmsip/SipMessageTransport.h>#include<libmsip/SipCommandString.h>#include"../../../sip/DefaultDialogHandler.h"MinisipMainWindowWidget::MinisipMainWindowWidget(TimeoutProvider<string> *tp, QWidget *parent, const char *name ): QWidget( parent, name ), callboxlayout(), settingsDialog(this), #if (QT_VERSION < 0x030000) tabCount(1),#endif tabs(this), phonebooktabw(&tabs), phonebookvlayout(&phonebooktabw), text(&phonebooktabw), vlayout( this ), statusBar(NULL), timeoutProvider(tp){ setMinimumSize( 180, 200 ); setCaption("Minisip"); callboxlayout.addWidget(&text); QPushButton *call = new QPushButton( "Call", &phonebooktabw, "call" ); callboxlayout.addWidget(call); listView = new QListView(&phonebooktabw); listView->setAllColumnsShowFocus(true); listView->setRootIsDecorated(true); listView->header()->hide(); listView->addColumn("Phone books");#if (QT_VERSION > 0x030000) listView->setResizeMode(QListView::AllColumns);#endif// this->addWidget(&tabs);// phonebookvlayout.addWidget(&tabs); //vlayout.addLayout(&bottombox); phonebookvlayout.addWidget(listView); phonebookvlayout.addLayout(&callboxlayout); //tabs.insertTab(listView, "Phone books"/*title.c_str()*/,0); vlayout.addWidget(&tabs); tabs.insertTab(&phonebooktabw, "Phone books",0); tabs.showPage(&phonebooktabw); connect(qApp, SIGNAL(lastWindowClosed()), qApp, SLOT(quit())); connect(call, SIGNAL(clicked()), this, SLOT(callPressed())); connect(&text, SIGNAL(returnPressed()), this, SLOT(callPressed())); connect(listView, SIGNAL(selectionChanged()), this, SLOT(phoneBookSelect())); connect(listView, SIGNAL(doubleClicked(QListViewItem *, const QPoint &, int)), this, SLOT(userDoubleClicked(QListViewItem *, const QPoint &, int)));/* list<string> phonebooks = sipphone->getPhoneConfig()->phonebooks; for (list<string>::iterator i=phonebooks.begin(); i!=phonebooks.end(); i++){ addPhoneBook(*i); }*/ #ifdef MINISIP_AUTOCALL if (sipphoneconfig->autoCall.size()>0) tp->request_timeout(5000,this, "autocall");#endif#ifdef OPIE setCaption("minisip");#ifndef QT_NO_COP QPEApplication::grabKeyboard();#endif#endif #ifdef OPIE IP4ServerSocket *update_serversock = new IP4ServerSocket(5034,1); update_socket.connectToHost("127.0.0.1",5034); do_update_socket = update_serversock->do_accept(); connect(&update_socket, SIGNAL(readyRead()), this, SLOT(readChar));#endif}void MinisipMainWindowWidget::displayErrorMessage(string m){ QMessageBox msg("Error message", m.c_str(), QMessageBox::Warning,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton,this); msg.exec();}void MinisipMainWindowWidget::setSipSoftPhoneConfiguration(MRef<SipSoftPhoneConfiguration*> sipphoneconfig){ this->sipphoneconfig = sipphoneconfig; settingsDialog.setConfig(sipphoneconfig); list<string> phonebooks = sipphoneconfig->phonebooks; for (list<string>::iterator i=phonebooks.begin(); i!=phonebooks.end(); i++){ addPhoneBook(*i); }}MRef<SipSoftPhoneConfiguration *>MinisipMainWindowWidget::getSipSoftPhoneConfiguration(){ return sipphoneconfig;}void MinisipMainWindowWidget::readChar(){#ifdef OPIE update_socket.getch();#endif}#ifdef OPIEvoid MinisipMainWindowWidget::updateGui(){ char *str="X"; void *buf = (void *)str; do_update_socket->do_write(buf,1);}#endifvoid MinisipMainWindowWidget::phoneBookSelect(){//#if (QT_VERSION > 0x030000)// QListViewItem *sel = listView->selectedItem();// if (sel->rtti()==PersonListItem::RTTI_VAL){// text.setText(((PersonListItem *)sel)->getUri().c_str());// text.setText("");// }else{// text.setText("");// }// //#else QListViewItem *sel = listView->selectedItem(); if (sel->childCount()==0){ text.setText(((PersonListItem *)sel)->getUri().c_str()); }else{ text.setText(""); }//#endif /*if (dynamic_cast<PersonListItem *>(sel)!=NULL){ text.setText(((PersonListItem *)sel)->getUri().c_str()); }else{ text.setText(""); }*/}void MinisipMainWindowWidget::userDoubleClicked(QListViewItem *item,const QPoint &, int){ /*if (dynamic_cast<PersonListItem *>(item)!=NULL){ text.setText(((PersonListItem *)item)->getUri().c_str()); doCall(); }else{ text.setText(""); }*/}#ifdef MINISIP_AUTOCALLvoid MinisipMainWindowWidget::timeout(string command){ // if (command=="tst_error_message"){// handleCommand(CommandString("","error_message","This is an example error message!"));// return;// } assert(command=="autocall"); handleCommand(CommandString("","autocall"));}#endifvoid MinisipMainWindowWidget::createRegisterDialog(string title, string callId, string proxy){ RegCallDialog *regdialog = new RegCallDialog(callId, this, timeoutProvider, proxy);// tabs.addTab(regdialog, title.c_str());// #if (QT_VERSION < 0x030000) tabCount++;#endif tabs.insertTab(regdialog, title.c_str()/*,0*/); //tabs.setCurrentPage(0); tabs.show(); addCallDialog(regdialog); #if (QT_VERSION < 0x030000) tabs.setCurrentPage(tabCount - 1);#else tabs.setCurrentPage(tabs.count() - 1);#endif }void MinisipMainWindowWidget::createCallDialog(string title, string callId, string from="", string secured=""){ CallDialog *calldialog;#if (QT_VERSION < 0x030000) tabCount++;#endif if (from.length()>0 || secured.length()>0){ calldialog = new CallDialog(callId, this, timeoutProvider, from, secured); tabs.insertTab(calldialog, title.c_str()); tabs.showPage( calldialog ); }else{ calldialog = new CallDialog(callId, this, timeoutProvider); tabs.insertTab(calldialog, title.c_str()); tabs.showPage( calldialog ); } addCallDialog(calldialog);}void MinisipMainWindowWidget::doCall(){ string uri=text.text().ascii(); if (uri.length()>0){ string id=callback->guicb_doInvite( uri ); //NOTE: callback is a protected member from the // superclass "GUI". if (id=="malformed"){ QMessageBox::warning(this,"Minisip","The SIP address you specified is not valid", QMessageBox::Ok, QMessageBox::NoButton); return; } createCallDialog("Call",id);// log(LOG_INFO, "MinisipMainWindowWidget::callPressed(): id of new call is "+id); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -