// // 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: mainwindowSub.h,v $ * Revision 1.9 2004/06/02 04:56:43 dereksmithies * Bring up to date with CVS as of today, Uses codec plugins now. * You may need to set the PWLIBPLUGINPATH environment variable. * * Revision 1.8 2004/04/23 05:09:59 dereksmithies * Fixes so it works with latest openh323 lib, and not lock X display. * * Revision 1.7 2003/09/02 03:37:32 dereksmithies * Add statistics, new icons, toolbuttons (icon + name) * * Revision 1.6 2003/08/26 04:48:02 dereksmithies * Fixes to get statistics working right, add icons, add ok,cancel,apply buttons * * Revision 1.5 2003/08/07 23:56:38 dereksmithies * Main Program Icon always comes up at the end of a call. * * Revision 1.4 2003/05/20 03:32:28 dereksmithies * Better handling of ixj handset states, and call progress states. * * Revision 1.3 2003/05/09 03:08:24 dereksmithies * Fix Microtelco handling, and message display * * Revision 1.2 2003/04/04 04:37:49 dereksmithies * Major upgrade. * Ixj & microtelco support added. Fix threading issues. * * Revision 1.1.1.1 2002/05/12 22:55:05 dereksmithies * Initial release. * * * * */ #ifndef MAINUI_H #define MAINUI_H #include "mainwindow.h" #include "cpendpoint.h" #include #include #include #define MAIN_UI_UP (QEvent::User + 100) #define CALL_ANSWER_RESPONSE_YES (QEvent::User + 200) #define CALL_ANSWER_RESPONSE_NO (QEvent::User + 300) #define CALL_ANSWER_RESPONSE_TMO (QEvent::User + 400) #define CALL_ANSWER_INITIATE (QEvent::User + 500) #define CUSTOM_EVENT_DIE (QEvent::User + 1000) #define CUSTOM_EVENT_MESSAGE (QEvent::User + 1100) class MainUi : public FormMainWindow, H323EndPoint { PCLASSINFO(MainUi, H323EndPoint); public: MainUi(); ~MainUi(); /** Determines the default settings of everything, and sets it appropriately. Does this by opening each of the descendant forms, which reads each parameter (with a default setting available*/ void InitialiseConfiguration(); PVideoOutputDevice *GetDisplayModule (BOOL isEncoding, BOOL isFlipped); void AudioClicked_slot(); void ConnectClicked_slot(); void ExitClicked_slot(); void SettingsClicked_slot(); void VideoClicked_slot(); void OpenStatistics_slot(); void QueryCallAnswer(PString remoteNode); void SetDisplayString(QString message); void DisplayInfoMessage(char *message); void DisplayInfoMessage(PString message); void DisplayInfoMessage(QString message); void DisplayCriticalError(char * message); void DisplayCriticalError(PString message); void DisplayCriticalError(QString message); void closeEvent(QCloseEvent *e); void customEvent(QCustomEvent *e); void timerEvent(QTimerEvent *); void OnConnectionEstablished(PString message); void OnConnectionCleared(PString message); void OnConnectionEstablished(BOOL isEstablished); void SendDieMessageToWindow(enum WindowName name); void StopCallAnswer(); BOOL SetEchoCancellation(PString newLevel); const PString & GetLocalUserName() const { return H323EndPoint::GetLocalUserName(); } void TranslateTCPAddress(PIPSocket::Address &localAddr, const PIPSocket::Address &remoteAddr); // overrides from H323EndPoint virtual H323Connection * CreateConnection(unsigned callReference); virtual BOOL OnIncomingCall(H323Connection &, const H323SignalPDU &, H323SignalPDU &); virtual void OnConnectionEstablished(H323Connection &, const PString &); virtual void OnConnectionCleared(H323Connection &, const PString &); virtual BOOL OpenAudioChannel(H323Connection &, BOOL, unsigned, H323AudioCodec &); virtual BOOL OpenVideoChannel(H323Connection &, BOOL, H323VideoCodec &); // Functions that are added to the base H323EndPoint class. BOOL InitialiseVoipSettings(void); BOOL SearchForAGatekeeper(PString gkName=""); BOOL SetDisableSilenceDetection(BOOL disableSilence); BOOL WaitingForACall(); PString GetCurrentCallToken() const { return currentCallToken; } CpVideoChannel *GetReceiveVideoChannel() { return receiveVideoChannel; } CpVideoChannel *GetTransmitVideoChannel() { return transmitVideoChannel; } void SetCodecFrames(const PString & fmt, unsigned frames); void AddAllCapabilities(); void RebuildCapabilityTable(); void StartTerminationProcess(); void ExitCurrentCall(); void UpdateToolButtonConnect(BOOL isEstablished); void GetVideoFrameSizeSetting(unsigned &newFrameWidth, unsigned &newFrameHeight); void MakeOutgoingCall(const PString &, const PString &); void OnNoAnswerTimeout(); void StartCall(const PString & str); void ReorderCapabilities(); void UpdateUdpPorts(); PStringToString GetInterfaceAddressList(); void UpdateUserName(); void DisplayMessage(QString message); void UpdateNatTraversalAddress(); void DisplayMessage(PString message); void DisplayMessage(char * message); BOOL CreateLocalVideoDisplayThread(); BOOL DeleteLocalVideoDisplayThread(); BOOL InitialiseVideoDisplay(); void DeleteVideoDisplay(); BOOL DisplayLocalIsNow(BOOL doDisplayLocal); BOOL AttachPlayerReaderToVideoChannel(BOOL isEncoding); AudioOptions audioOpts; ConnectOptions connectOpts; VideoOptions videoOpts; QImage *cPhoneIcon; void AnswerCall(H323Connection::AnswerCallResponse response); PStringArray GetAvailableDeviceNames(); PStringArray GetAvailableIxjDeviceNames() { return ixjCardNames; } PStringArray GetAvailableEchoCancNames(); void SetSoundChannelBufferDepth(unsigned int newDepth); void SetAudioJitterDelay(unsigned int low, unsigned int high); virtual BOOL SetSoundChannelRecordDevice(const PString &newDevice); virtual BOOL SetSoundChannelPlayDevice(const PString &newDevice); H323Connection::AnswerCallResponse AnswerCallConditional(const PString & caller, PString newCallToken); H323Connection *GetCurrentConnectionWithLock(); #ifdef HAS_IXJ LidHandlerThread lidThread; #endif enum States { epNoTone, /*0*/ epDialTone, /*1*/ epAnsweringCall, /*2*/ epConnectingCall, /*3*/ epWaitingForAnswer,/*4*/ epCallInProgress, /*5*/ epCallHungup, /*6*/ epStateIllegal, }; protected: States epState; public: BOOL IsWaitingForAnswer() { return epState == epWaitingForAnswer; } BOOL IsInCall() { return epState == epCallInProgress; } States GetEpState() { return epState; } BOOL MicroTelcoActivate(BOOL doActivate); BOOL InitialiseGatekeeper(); PString GetGatekeeperName(); PString GetGatekeeperRegistrationMessage(); void HandleHandsetDown(BOOL isDown); protected: // only used internally QString remoteComputer; LocalVideoDisplayThread * localVideoThread; PIPSocket::Address masqAddress; BOOL SetSoundDevice(const char *, PSoundChannel::Directions); CpVideoChannel *receiveVideoChannel; CpVideoChannel *transmitVideoChannel; PString currentCallToken; PString setupInformation; BOOL firstErrorOpenAudioChannel; BOOL applicationIsExiting; PStringArray soundCardNames; PStringArray ixjCardNames; friend class CpConnection; }; //////////////////////////////////////////////////////////////////////////////// class MessageCustomEvent : public QCustomEvent { public: MessageCustomEvent(int id, QString newTitle, QString newMessage) : QCustomEvent(id) { message = newMessage; title = newTitle; }; QString GetMessage() { return message; } QString GetTitle() { return title; } protected: QString message; QString title; }; #endif // MAINUI_H