📄 main.cxx
字号:
//// The contents of this file are subject to the Mozilla Public License// Version 1.0 (the "License"); you may not use this file except in// compliance with the License. You may obtain a copy of the License at// http://www.mozilla.org/MPL/// // Software distributed under the License is distributed on an "AS IS"// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See// the License for the specific language governing rights and limitations// under the License.// // The Original Code is CPhone, a cross platform voip gui.//// The Initial Developer of the Original Code is Derek Smithies.//// Copyright (C) 2002 Indranet Technologies Ltd, // http://www.indranet-technologies.com// All Rights Reserved.//// Contributor(s): _______________/* * * $Log: main.cxx,v $ * Revision 1.11 2003/05/20 03:32:28 dereksmithies * Better handling of ixj handset states, and call progress states. * * Revision 1.10 2003/05/09 03:08:24 dereksmithies * Fix Microtelco handling, and message display * * Revision 1.9 2003/05/06 22:40:36 dereksmithies * Fixes to get it working correctly on microtelco. * * Revision 1.8 2003/04/27 22:30:06 dereksmithies * Changes to make compatible with current pwlib code * * Revision 1.7 2003/04/11 01:08:35 dereksmithies * Add speed dial support for Quicknet cards. * * Revision 1.6 2003/04/04 04:37:49 dereksmithies * Major upgrade. * Ixj & microtelco support added. Fix threading issues. * * Revision 1.5 2002/11/27 23:52:48 dereksmithies * Changes to make compatible with current openh323 library code. * * Revision 1.4 2002/10/30 00:58:35 dereksmithies * Fix startup problem, in passing command line arguments to the application * * Revision 1.3 2002/10/30 00:57:12 dereksmithies * *** empty log message *** * * Revision 1.2 2002/10/30 00:53:50 dereksmithies * i * * Revision 1.1.1.1 2002/05/12 22:55:01 dereksmithies * Initial release. * * * */ #include <ptlib.h>#include <qapplication.h>#include "addressbookSub.h"#include "gsmcodec.h"#include "h261codec.h"#include "h323pdu.h"#include "keys.h"#include "lpc10codec.h"#include "main.h"#include "mainwindowSub.h"#include "mscodecs.h"#include "version.h"PCREATE_PROCESS(CPhone);#define new PNEW#ifdef HAS_IXJ#include <ixjlid.h>#endif///////////////////////////////////////////////////////////////CPhone::CPhone() : PProcess("Cross platform voip gui.", "CPhone", MAJOR_VERSION, MINOR_VERSION, BUILD_TYPE, BUILD_NUMBER){ for (PINDEX i = 0; i < eNumWindows; i++) isActive[(enum WindowName)i] = FALSE;}CPhone::~CPhone(){}void CPhone::Main(){#ifdef NOT_USEDPTrace::Initialise(5, "log_cphone.txt", PTrace::Timestamp | PTrace::Thread | PTrace::FileAndLine);#endif PConfigArgs args(GetArguments()); PStringStream str; str << args; int argCount = str.GetSize(); char *argV[argCount + 1]; PStringArray arrayArgs; for (int i = 0; i < argCount; i++) { arrayArgs.AppendString(str[i]); argV[i] = arrayArgs[i].GetPointer(); } argV[argCount] = NULL; QApplication *app = new QApplication(argCount, argV); mainUi = new MainUi(); app->setMainWidget(mainUi); //Open the main widget for display. mainUi->show(); //Create Label widgets to render data to. app->connect(app, SIGNAL(lastWindowClosed()), app, SLOT(quit())); app->exec();}QWidget *CPhone::GetWindow(enum WindowName winName){ PWaitAndSignal m(accessMutex); if (!isActive[winName]) return NULL; WId id = windowIds[winName]; return QWidget::find(id);}void CPhone::SetWindowId(enum WindowName winName, WId newId){ PWaitAndSignal m(accessMutex); windowIds[winName] = newId; isActive[winName] = TRUE;}BOOL CPhone::ForgetExists(enum WindowName winName, WId winId){ PWaitAndSignal m(accessMutex); if (windowIds[winName] == winId) { isActive[winName] = FALSE; return TRUE; } return FALSE;}void CPhone::ForgetCallAnswer(){ PWaitAndSignal m(accessMutex); windowIds[eCallAnswer] = windowIds[eMainUi]; isActive[eCallAnswer] = FALSE;}///////////////////////////////////////////////////////////////ConnectOptions::ConnectOptions(){}ConnectOptions::~ConnectOptions(){}BOOL ConnectOptions::Initialise(){ PConfig *config = new PConfig(SETTINGS_CONFIG); noFastStart = config->GetBoolean(CHECKBOXDISABLEFASTSTART_KEY); autoAnswer = config->GetBoolean(CHECKBOXAUTOANSWER_KEY); noH245Tunnelling = config->GetBoolean(CHECKBOXDISABLEH245TUNNEL_KEY); searchForGatekeeper = config->GetBoolean(CHECKBOXSEARCHFORAGATEKEEPER_KEY); gatekeeperName = config->GetString(LINEEDITGATEKEEPER_KEY); useDefaultAudioBandwidth = config->GetBoolean(CHECKBOXDEFAULTAUDIO_KEY); useDefaultVideoBandwidth = config->GetBoolean(CHECKBOXDEFAULTVIDEO_KEY); audioBandwidth = config->GetInteger(SPINBOXBANDWIDTHAUDIO_KEY); videoBandwidth = config->GetInteger(SPINBOXBANDWIDTHVIDEO_KEY); packetUtilization = config->GetInteger(SPINBOXFRAMESETHERNETPACKET_KEY); userName = config->GetString(LINEEDITUSERNAME_KEY); doNatTraversal = config->GetBoolean(DONATTRAVERSAL_KEY); externalNatAddress = config->GetString(EXTERNALNATADDRESS_KEY); videoReceptionEnabled = config->GetBoolean(CHECKBOXVIDEORECEPTIONENABLED_KEY, TRUE); videoTransmissionEnabled = config->GetBoolean(CHECKBOXVIDEOTRANSMISSIONENABLED_KEY, TRUE); doMicroTelco = config->GetBoolean(DOMICROTELCO_KEY); microTelcoAccount = config->GetString(MICROTELCOACCOUNT_KEY); microTelcoPassword = config->GetString(MICROTELCOPASSWORD_KEY); lowUdpPort = config->GetInteger(SPINBOXLOWUDPPORT_KEY); highUdpPort = config->GetInteger(SPINBOXHIGHUDPPORT_KEY); //////////////////////////////// delete config; if (userName.IsEmpty()) userName = CPhone::GetUi().GetLocalUserName(); return TRUE; }void ConnectOptions::LoadCapabilitiesFromDisk(){ PWaitAndSignal m(access); PConfig *config = new PConfig(CODECS_CONFIG); PStringList codecKeys = config->GetKeys(); PINDEX i; for (i = 0; i < codecKeys.GetSize(); i++) if ((availableCapabilities.GetStringsIndex(codecKeys[i]) != P_MAX_INDEX) && config->GetBoolean(codecKeys[i])) enabledCapabilities.AppendString(codecKeys[i]); UpdateDisabledCapabilities(); delete config;}BOOL ConnectOptions::SaveSettings(){ PWaitAndSignal m(access); PConfig *config = new PConfig(SETTINGS_CONFIG); config->SetBoolean(CHECKBOXDISABLEFASTSTART_KEY,noFastStart); config->SetBoolean(CHECKBOXAUTOANSWER_KEY, autoAnswer); config->SetBoolean(CHECKBOXDISABLEH245TUNNEL_KEY, noH245Tunnelling); config->SetBoolean(CHECKBOXSEARCHFORAGATEKEEPER_KEY, searchForGatekeeper); config->SetString(LINEEDITGATEKEEPER_KEY, gatekeeperName); config->SetBoolean(CHECKBOXDEFAULTAUDIO_KEY, useDefaultAudioBandwidth); config->SetBoolean(CHECKBOXDEFAULTVIDEO_KEY, useDefaultVideoBandwidth); config->SetInteger(SPINBOXBANDWIDTHAUDIO_KEY, audioBandwidth); config->SetInteger(SPINBOXBANDWIDTHVIDEO_KEY, videoBandwidth); config->SetInteger(SPINBOXFRAMESETHERNETPACKET_KEY, packetUtilization); config->SetString(LINEEDITUSERNAME_KEY, userName); config->SetBoolean(CHECKBOXVIDEORECEPTIONENABLED_KEY, videoReceptionEnabled); config->SetBoolean(CHECKBOXVIDEOTRANSMISSIONENABLED_KEY, videoTransmissionEnabled); config->SetBoolean(DONATTRAVERSAL_KEY, doNatTraversal); config->SetString(EXTERNALNATADDRESS_KEY, externalNatAddress); config->SetBoolean(DOMICROTELCO_KEY, doMicroTelco ); config->SetString(MICROTELCOACCOUNT_KEY, microTelcoAccount ); config->SetString(MICROTELCOPASSWORD_KEY, microTelcoPassword); config->SetInteger(SPINBOXLOWUDPPORT_KEY, lowUdpPort); config->SetInteger(SPINBOXHIGHUDPPORT_KEY, highUdpPort); delete config; //////////////////////////////// config = new PConfig(CODECS_CONFIG); PINDEX i; PStringList codecKeys = config->GetKeys(); for (i = 0; i < codecKeys.GetSize(); i++) config->DeleteKey(codecKeys[i]); for(i = 0; i < enabledCapabilities.GetSize(); i++) config->SetBoolean(enabledCapabilities[i], TRUE); delete config; return TRUE;}PStringList ConnectOptions::GetAvailableCapabilities(){ PWaitAndSignal m(access); return availableCapabilities; }PStringList ConnectOptions::GetDisabledCapabilities() { PWaitAndSignal m(access); return disabledCapabilities; }PStringList ConnectOptions::GetEnabledCapabilities() {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -