⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainwindow.cxx

📁 这是一个开源码的sip用户代理 写的都很清楚是用C++语言开发的 对于研究sip协议的朋友绝对是有很好的参考价值
💻 CXX
📖 第 1 页 / 共 2 页
字号:
/* *  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"MainWindow.h"#include"CallWidget.h"#include"PhoneBook.h"#include"SettingsDialog.h"#include"CertificateDialog.h"#ifndef WIN32#include"TrayIcon.h"#endif#include"LogWidget.h"#include"ImWidget.h"#include"../../../sip/SipSoftPhoneConfiguration.h"#include"../../contactdb/ContactDb.h"#include<libmsip/SipCommandString.h>//#include<libmsip/SipSoftPhone.h>//#ifdef OLDLIBGLADEMM#define SLOT(a,b) SigC::slot(a,b)#define BIND SigC::bind #else#define SLOT(a,b) sigc::mem_fun(a,b) #define BIND sigc::bind#endifMainWindow::MainWindow( int argc, char ** argv ):kit( argc, argv ){	Gtk::Button * callButton;	Gtk::Button * imButton;	Gtk::MenuItem * prefMenu;	Gtk::MenuItem * certMenu;	Gtk::MenuItem * quitMenu;	Gtk::MenuBar  * minisipMenubar;	Gtk::MenuItem * addContactMenu;	Gtk::MenuItem * addAddressContactMenu;	Gtk::MenuItem * removeContactMenu;	Gtk::MenuItem * editContactMenu;	Gtk::MenuItem * callMenu;	Gtk::MenuItem * imMenu;	Glib::RefPtr<Gnome::Glade::Xml>  refXml;  	try{    		refXml = Gnome::Glade::Xml::create((string)MINISIP_DATADIR + "/minisip.glade");  	}  	catch(const Gnome::Glade::XmlError& ex){    		std::cerr << ex.what() << std::endl;    		exit( 1 );  	}  	//Get the Glade-instantiated Dialog:  	//Gtk::Widget* mainWindow = 0;  	refXml->get_widget( "minisipMain", mainWindowWidget );	refXml->get_widget( "mainTabWidget", mainTabWidget );	refXml->get_widget( "phoneBookTree", phoneBookTreeView );		refXml->get_widget( "phoneMenu", phoneMenu );	refXml->get_widget( "phoneAddMenu", phoneAddMenu );	refXml->get_widget( "phoneAddAddressMenu", phoneAddAddressMenu );	refXml->get_widget( "phoneRemoveMenu", phoneRemoveMenu );	refXml->get_widget( "phoneEditMenu", phoneEditMenu );		refXml->get_widget( "addContactMenu", addContactMenu );	refXml->get_widget( "addAddressContactMenu", addAddressContactMenu );	refXml->get_widget( "removeContactMenu", removeContactMenu );	refXml->get_widget( "editContactMenu", editContactMenu );	refXml->get_widget( "callMenu", callMenu );	refXml->get_widget( "imMenu", imMenu );	treeSelection = phoneBookTreeView->get_selection();//	treeSelection->set_select_function( SigC::slot( *this, //				&MainWindow::phoneSelect ) );		treeSelection->signal_changed().connect(		SLOT( *this, &MainWindow::phoneSelected ) );	phoneBookTree = new PhoneBookTree;	phoneBookModel = new PhoneBookModel( phoneBookTree );	phoneBookTreeView->set_headers_visible( false );	phoneBookTreeView->set_rules_hint( false );	phoneBookTreeView->signal_button_press_event().connect_notify( 		SLOT( *this, &MainWindow::phoneTreeClicked ), false );	/* Context menu */	phoneAddAddressMenu->signal_activate().connect(		BIND<Glib::RefPtr<Gtk::TreeSelection>, bool >(		SLOT( *phoneBookModel, &PhoneBookModel::addContact ),		treeSelection, true ));		phoneAddMenu->signal_activate().connect(		BIND<Glib::RefPtr<Gtk::TreeSelection>, bool>(		SLOT( *phoneBookModel, &PhoneBookModel::addContact ),		treeSelection, false ));		phoneRemoveMenu->signal_activate().connect(		BIND<Glib::RefPtr<Gtk::TreeSelection> >(		SLOT( *phoneBookModel, &PhoneBookModel::removeContact ),		treeSelection ));		phoneEditMenu->signal_activate().connect(		BIND<Glib::RefPtr<Gtk::TreeSelection> >(		SLOT( *phoneBookModel, &PhoneBookModel::editContact ),		treeSelection ));		/* Contact menu from the menubar */	addAddressContactMenu->signal_activate().connect(		BIND<Glib::RefPtr<Gtk::TreeSelection>, bool >(		SLOT( *phoneBookModel, &PhoneBookModel::addContact ),		treeSelection, true ));		addContactMenu->signal_activate().connect(		BIND<Glib::RefPtr<Gtk::TreeSelection>, bool>(		SLOT( *phoneBookModel, &PhoneBookModel::addContact ),		treeSelection, false ));		removeContactMenu->signal_activate().connect(		BIND<Glib::RefPtr<Gtk::TreeSelection> >(		SLOT( *phoneBookModel, &PhoneBookModel::removeContact ),		treeSelection ));		editContactMenu->signal_activate().connect(		BIND<Glib::RefPtr<Gtk::TreeSelection> >(		SLOT( *phoneBookModel, &PhoneBookModel::editContact ),		treeSelection ));		refXml->get_widget( "callButton", callButton );	callButton->signal_clicked().connect( SLOT( *this, &MainWindow::invite ) );		callMenu->signal_activate().connect( SLOT( *this, &MainWindow::invite ) );	phoneBookTreeView->signal_row_activated().connect( SLOT( *this, &MainWindow::inviteFromTreeview ) );	refXml->get_widget( "imButton", imButton );	imButton->signal_clicked().connect( SLOT( *this, &MainWindow::im ) );		imMenu->signal_activate().connect( SLOT( *this, &MainWindow::im ) );		certificateDialog = new CertificateDialog( refXml );	settingsDialog = new SettingsDialog( refXml, certificateDialog );		refXml->get_widget( "uriEntry", uriEntry );	refXml->get_widget( "prefMenu", prefMenu );	refXml->get_widget( "certMenu", certMenu );	refXml->get_widget( "quitMenu", quitMenu );		refXml->get_widget( "viewCallListMenu", viewCallListMenu );	prefMenu->signal_activate().connect( SLOT( *settingsDialog, &SettingsDialog::show ) );	certMenu->signal_activate().connect( SLOT( *this, &MainWindow::runCertificateSettings ) );	quitMenu->signal_activate().connect( SLOT( *this, &MainWindow::quit ) );		viewCallListMenu->signal_activate().connect( SLOT( *this, &MainWindow::viewCallListToggle ) );	dispatcher.connect( SLOT( *this, &MainWindow::gotCommand ) );#ifndef WIN32	trayIcon = new MTrayIcon( this, refXml );	mainWindowWidget->signal_hide().connect( SLOT( *this, &MainWindow::hideSlot ));#endif	logWidget = new LogWidget( this );	mainTabWidget->append_page( *logWidget, "Call list" );	logDispatcher.connect( SLOT( *this, &MainWindow::gotLogEntry ) );	mainWindowWidget->set_sensitive( false );}MainWindow::~MainWindow(){}void MainWindow::run(){#ifndef WIN32	if( trayIcon != NULL )		kit.run( *(trayIcon->getWindow()) );	else#endif		kit.run( *mainWindowWidget );}void MainWindow::quit(){	kit.quit();}bool MainWindow::isVisible(){	return mainWindowWidget->is_visible();}void MainWindow::hide(){	mainWindowWidget->hide();}void MainWindow::runPref(){	settingsDialog->run();}void MainWindow::show(){	mainWindowWidget->show();}void MainWindow::hideSlot(){}void MainWindow::handleCommand( CommandString command ){	commandsLock.lock();	commands.push_front( command );	commandsLock.unlock();	dispatcher.emit();}void MainWindow::gotCommand(){	list<CallWidget *>::iterator i;	commandsLock.lock();	CommandString command = commands.pop_back();	commandsLock.unlock();	if( command.getOp() == "sip_ready" ){		mainWindowWidget->set_sensitive( true );		return;	}		if( command.getOp() == "config_updated" ){		updateConfig();		return;	}	if( command.getOp() == "error_message" ){		doDisplayErrorMessage( command.getParam() );		return;	}		for( i = callWidgets.begin(); i != callWidgets.end(); i++ ){		if( (*i)->handleCommand( command ) ){			return;		}	}	if (command.getOp() == SipCommandString::incoming_im){		list<ImWidget *>::iterator i;		for (i = imWidgets.begin(); i != imWidgets.end(); i++ ){			if( (*i)->handleIm( command.getParam(), command.getParam2()/*, command.getParam3()*/ ) ){				return;			}		}		addIm(command.getParam2());		for (i = imWidgets.begin(); i != imWidgets.end(); i++ ){			if( (*i)->handleIm( command.getParam(), command.getParam2()/*, command.getParam3()*/ ) ){				return;			}		}				return;	}	if( command.getOp() == SipCommandString::incoming_available ){		addCall( command.getDestinationId(), command.getParam(), true,			 command.getParam2() );		return;	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -