home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-09-10 | 4.6 KB | 125 lines |
- /************************************************************************
- * CallNot (by John W. Gibbs)
- *
- * Copyright (c) 1997 Microsoft Corporation, All Rights Reserved.
- ***********************************************************************/
-
- import java.awt.Event;
- import com.ms.com.*;
- import tapi3.*;
-
-
- /////////////////////////////////////////////////////////////////////////
- // CLASS: CallNot
- //
- // PURPOSE: Supporting class to JT3Rec
- // DATE: July 17, 1997
- //
- // DESCRIPTION:
- // Implements the ITCallNotification interface which is called
- // by TAPI 3.0 when incoming calls arrive.
- //
- /////////////////////////////////////////////////////////////////////////
-
- class CallNot extends Object
- implements ITCallNotification, // notification interface
- CALL_EVENT_TYPE, // CET_xxx constants
- CALL_STATE // CS_xxx constants
- {
- // Reference to main program object.
- private JT3Rec m_App = null;
-
-
- /////////////////////////////////////////////////////////////////////
- // Constructor
- /////////////////////////////////////////////////////////////////////
- public CallNot(JT3Rec app)
- {
- m_App = app;
- }
-
- /////////////////////////////////////////////////////////////////////
- // CallEventNotification
- //
- // The only method in the ITCallNotification interface. This gets
- // called by TAPI 3.0 when there is a call event to report.
- //
- // It is important that you use the /X:m- switch when importing the
- // TAPI 3.0 typelib to Java using JActiveX. This will turn off
- // auto-marshalling of variables passed from CallNot to JT3Rec. If
- // you do not, the program will freeze whenever JT3Rec tries to use
- // a variable given to it by CallNot.
- /////////////////////////////////////////////////////////////////////
- public void CallEventNotification(
- ITAddress address,
- int eventType,
- Object event
- )
- {
- // eventType can be CET_CALLMONITOR, CET_CALLOWNER, or
- // CET_CALLSTATEEVENT
-
- switch (eventType)
- {
- case CET_CALLMONITOR:
-
- // CET_CALLMONITOR means that the application is being
- // notified of a new call, and the application has monitor
- // priveleges on that call. event is the Call object.
- //
- // We should not get any CET_CALLMONITOR notifications in
- // this application, since we only registered for owner in
- // RegisterCallTypes.
-
- break;
-
- case CET_CALLOWNER:
-
- // CET_CALLOWNER means that the application is being notified
- // of a call, and the application has owner privileges on
- // that call. event is the Call object.
- //
- // Note that we don't answer the call at this point. The
- // application should wait for a CS_OFFERING CallState
- // message before answering the call.
-
- try {
- m_App.m_Call = (ITBasicCallControl) event;
- m_App.SetStatusMessage("Incoming owner call");
- }
- catch (ComException e) {
- e.printStackTrace();
- m_App.SetStatusMessage("Incoming call, but failed to get the interface");
- }
- break;
-
- case CET_CALLSTATEEVENT:
-
- // CET_CALLSTATEEVENT is a call state event. event is an
- // ITCallStateEvent object.
-
- ITCallStateEvent callStateEvent = (ITCallStateEvent) event;
-
- switch (callStateEvent.getState())
- {
- case CS_DISCONNECTED:
- if (m_App.m_Call != null) {
- Event evt = new Event(
- m_App.ctrls.btnHangup,
- Event.ACTION_EVENT,
- "Hangup"
- );
- m_App.action(evt, "Hangup");
- }
- break;
-
- case CS_OFFERING: // this tells us it's okay to answer
- m_App.ctrls.btnStop.disable();
- m_App.ctrls.btnAnswer.enable();
- m_App.ctrls.btnReject.enable();
- m_App.SetStatusMessage("Click the Answer or Reject button");
- break;
- }
- }
- }
- }