00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef OPAL_OPAL_CONSOLE_MGR_H
00032 #define OPAL_OPAL_CONSOLE_MGR_H
00033
00034 #ifdef P_USE_PRAGMA
00035 #pragma interface
00036 #endif
00037
00038 #include <opal/manager.h>
00039 #include <ptclib/cli.h>
00040
00041 #if P_CLI
00042
00043 class SIPEndPoint;
00044 class H323EndPoint;
00045 class OpalLineEndPoint;
00046 class OpalCapiEndPoint;
00047
00048
00054 class OpalManagerConsole : public OpalManager
00055 {
00056 PCLASSINFO(OpalManagerConsole, OpalManager);
00057
00058 public:
00059 OpalManagerConsole();
00060
00061 virtual PString GetArgumentSpec() const;
00062 virtual void Usage(ostream & strm, const PArgList & args);
00063
00064 virtual bool Initialise(
00065 PArgList & args,
00066 bool verbose,
00067 const PString & defaultRoute = PString::Empty()
00068 );
00069 virtual void Run();
00070 virtual void EndRun(bool interrupt = false);
00071
00072 void OnEstablishedCall(OpalCall & call);
00073 void OnHold(OpalConnection & connection, bool fromRemote, bool onHold);
00074 PBoolean OnOpenMediaStream(OpalConnection & connection, OpalMediaStream & stream);
00075 void OnClosedMediaStream(const OpalMediaStream & stream);
00076 virtual void OnClearedCall(OpalCall & call);
00077
00078 protected:
00079 #if OPAL_SIP
00080 SIPEndPoint * CreateSIPEndPoint();
00081 #endif
00082 #if OPAL_H323
00083 H323EndPoint * CreateH323EndPoint();
00084 #endif
00085 #if OPAL_LID
00086 OpalLineEndPoint * CreateLineEndPoint();
00087 #endif
00088 #if OPAL_CAPI
00089 OpalCapiEndPoint * CreateCapiEndPoint();
00090 #endif
00091
00092 PSyncPoint m_endRun;
00093 bool m_interrupted;
00094 bool m_verbose;
00095 };
00096
00097
00104 class OpalManagerCLI : public OpalManagerConsole
00105 {
00106 PCLASSINFO(OpalManagerCLI, OpalManagerConsole);
00107
00108 public:
00109 OpalManagerCLI();
00110 ~OpalManagerCLI();
00111
00112 virtual PString GetArgumentSpec() const;
00113 virtual bool Initialise(
00114 PArgList & args,
00115 bool verbose,
00116 const PString & defaultRoute = PString::Empty()
00117 );
00118 virtual void Run();
00119 virtual void EndRun(bool interrupt);
00120
00121 protected:
00122 PCLI * CreatePCLI(
00123 #if P_TELNET
00124 WORD port
00125 #endif
00126 );
00127
00128 #if OPAL_SIP
00129 PDECLARE_NOTIFIER(PCLI::Arguments, OpalManagerCLI, CmdRegister);
00130 #endif
00131
00132 #if P_NAT
00133 PDECLARE_NOTIFIER(PCLI::Arguments, OpalManagerCLI, CmdNat);
00134 #endif
00135
00136 #if PTRACING
00137 PDECLARE_NOTIFIER(PCLI::Arguments, OpalManagerCLI, CmdTrace);
00138 #endif
00139
00140 PDECLARE_NOTIFIER(PCLI::Arguments, OpalManagerCLI, CmdListCodecs);
00141 PDECLARE_NOTIFIER(PCLI::Arguments, OpalManagerCLI, CmdDelay);
00142 PDECLARE_NOTIFIER(PCLI::Arguments, OpalManagerCLI, CmdVersion);
00143 PDECLARE_NOTIFIER(PCLI::Arguments, OpalManagerCLI, CmdQuit);
00144 PDECLARE_NOTIFIER(PCLI::Arguments, OpalManagerCLI, CmdShutDown);
00145
00146 PCLI * m_cli;
00147 };
00148
00149
00152 template <class Manager,
00153 const char Manuf[],
00154 const char Name[],
00155 WORD MajorVersion = OPAL_MAJOR,
00156 WORD MinorVersion = OPAL_MINOR,
00157 PProcess::CodeStatus Status = PProcess::ReleaseCode,
00158 WORD BuildNumber = OPAL_BUILD,
00159 bool Verbose = true>
00160 class OpalConsoleProcess : public PProcess
00161 {
00162 PCLASSINFO(OpalConsoleProcess, PProcess)
00163 public:
00164 OpalConsoleProcess()
00165 : PProcess(Manuf, Name, MajorVersion, MinorVersion, Status, BuildNumber)
00166 , m_manager(NULL)
00167 {
00168 }
00169
00170 ~OpalConsoleProcess()
00171 {
00172 delete this->m_manager;
00173 }
00174
00175 virtual void Main()
00176 {
00177 this->SetTerminationValue(1);
00178 this->m_manager = new Manager;
00179 if (this->m_manager->Initialise(this->GetArguments(), Verbose)) {
00180 this->SetTerminationValue(0);
00181 this->m_manager->Run();
00182 }
00183 }
00184
00185 virtual bool OnInterrupt(bool)
00186 {
00187 if (this->m_manager == NULL)
00188 return false;
00189
00190 this->m_manager->EndRun(true);
00191 return true;
00192 }
00193
00194 private:
00195 Manager * m_manager;
00196 };
00197
00198
00199 #endif // P_CLI
00200
00201 #endif // OPAL_OPAL_CONSOLE_MGR_H
00202
00203