//
//  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.h,v $
 * Revision 1.4  2003/08/26 04:48:02  dereksmithies
 * Fixes to get statistics working right, add icons, add ok,cancel,apply buttons
 *
 * Revision 1.3  2003/04/04 04:37:49  dereksmithies
 * Major upgrade.
 * Ixj & microtelco support added. Fix threading issues.
 *
 * Revision 1.2  2002/11/27 23:52:48  dereksmithies
 * Changes to make compatible with current openh323 library code.
 *
 * Revision 1.1.1.1  2002/05/12 22:55:01  dereksmithies
 * Initial release.
 *
 *
 *
 */

#ifndef _CPhone_MAIN_H
#define _CPhone_MAIN_H

#include <h323.h>
#include "cpendpoint.h"
#include <qwidget.h>

class MainUi;

 enum WindowName { eAudioProperties,
                   eVideoProperties,
                   eAddressBook,
                   eSettings,
                   eCallAnswer,
		   eMainUi,
		   eStatistics,
                   eNumWindows };

class CpConnection : public H323Connection
{
    PCLASSINFO(CpConnection, H323Connection);

  public:
    CpConnection(unsigned, unsigned);

    // overrides from H323Connection
    BOOL OnSendSignalSetup(H323SignalPDU & setupPDU);
    AnswerCallResponse OnAnswerCall(const PString &, const H323SignalPDU &, H323SignalPDU &);
    BOOL OnStartLogicalChannel(H323Channel &);
    BOOL OnAlerting(const H323SignalPDU &, const PString &);
    void OnUserInputString(const PString &);
};

//////////////////////////////////////////

class LocalVideoDisplayThread : public PThread
{
    PCLASSINFO(LocalVideoDisplayThread, PThread);
  public:
    LocalVideoDisplayThread(CpVideoChannel *vChannel);

    void InitiateTermination();

    void Main();

  protected:
    CpVideoChannel  *localVideoChannel;

    PSyncPoint      exitFlag;
};


//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
class CPhone : public PProcess
{
    PCLASSINFO(CPhone, PProcess)
  public:
    CPhone();
    ~CPhone();

    void Main();

    static CPhone & Current() 
      { return (CPhone &)PProcess::Current(); }

    static MainUi & GetUi() { return *((CPhone &)PProcess::Current()).MainUI(); }
  
    void SetUi(MainUi *newUi);

    QWidget *GetWindow(enum WindowName winName);
    void     SetWindowId(enum WindowName winName, WId newId);
    BOOL     ForgetExists(enum WindowName winName, WId currentId);
    void     ForgetCallAnswer();

 protected:
    MainUi *MainUI() { return mainUi; }

    MainUi * mainUi;   

    PMutex accessMutex;
    WId    windowIds[eNumWindows];
    BOOL   isActive[eNumWindows];
};





#endif  // _CPhone_MAIN_H


// End of File ///////////////////////////////////////////////////////////////


syntax highlighted by Code2HTML, v. 0.9.1