Solved

Tapi

Posted on 1997-04-21
7
465 Views
Last Modified: 2006-11-17
I'm building a Tapi application.  
When a call comes in, tapi sends a message to the application (a line_callState message). How do i know when tapi sent such a message ? Is there a procedure started at that time ?
0
Comment
Question by:we47126
  • 4
  • 2
7 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 1162870
You can download an example code from Microsoft web site:
http://www.microsoft.com/WIN32DEV/NETWRK/CTA2669B.ZIP
The example creates the CTapiConnection class. It provides an easy way to initialize TAPI, connect, and make a voice-based telephone call.

0
 

Author Comment

by:we47126
ID: 1162871
First of all I should have mentioned that I'm using Borland c++ 5 and not visual C (the example was for visual c)
Second, is is an example to make a call.  I still don't know haw to receive a call or recognise the button the caller pressed.

0
 

Author Comment

by:we47126
ID: 1162872
Edited text of question
0
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

Author Comment

by:we47126
ID: 1162873
Adjusted points to 80
0
 
LVL 1

Accepted Solution

by:
edtmihu earned 80 total points
ID: 1162874
look at the function lineInitialize(...)
One of the params is a callback-function, where Tapi
sends you notofications.
You also need to call lineOpen(..) in order to get any events of incoming calls.

0
 

Author Comment

by:we47126
ID: 1162875
Why isn't mthis working :
...
lReturn = lineInitialize(&hLineApp, hInstance, lineCallbackFunc,
      szAppName, &dwNumDevs)
...
lReturn = lineOpen(hLineApp, 0,&hLine, dwApiVersion, 0,0,LINECALLPRIVILEGE_MONITOR,0,0);
...
void CALLBACK lineCallbackFunc(
    DWORD dwDevice, DWORD dwMsg, DWORD dwCallbackInstance,
    DWORD dwParam1, DWORD dwParam2, DWORD dwParam3)
{
      cout << "A message is received !";
... }

And how can I make my program wait for a call ? If it does nothing it just closes !
0
 
LVL 1

Expert Comment

by:edtmihu
ID: 1162876
This is how I do it.
Works with BC4.53 and BC5.01.

bool TTapi::Start( LPCSTR appName )
{
.
. Declare variables
.
      if ( ( _lpfnLineCallback = (LINECALLBACK) MakeProcInstance( (FARPROC) lineCallbackFunc, hInst() ) ) == NULL )
            {
            return( false );
            }
      lRet = lineInitialize( &_hLineApp, hInst(), _lpfnLineCallback, appName, _dwNumDevs );
      if ( lRet < 0 )
            {
            return( false );
            }
      lineRegisterRequestRecipient( hLineApp(), (DWORD)this, LINEREQUESTMODE_MAKECALL, true );
      // fill lineCapsList with LineCaps object
      for ( dwDeviceId = 0; dwDeviceId < _dwNumDevs; dwDeviceId++ )
            {
            TRACE("LineDevice = " << dwDeviceId );
            LONG lRet;
            HLINE hLine;
            DWORD dwEXTVersion = 0;
            LINEEXTENSIONID extensionID;
            bool mdExt, claraExt, maryExt;
            TRACE("lineNegotiateAPIVersion");
            lRet = lineNegotiateAPIVersion( _hLineApp, dwDeviceId, SupportAPILowVersion(), SupportAPIHighVersion(), _dwAPIVersion, &extensionID );
            if ( lRet < 0 )
                  {
                  return( false );
                  }
            mdExt                  = isMD110Ext(      extensionID );
            claraExt      = isClaraExt(      extensionID );
            maryExt            = isMaryExt(      extensionID );
            if ( mdExt || claraExt || maryExt )
                  {
                  lRet = lineNegotiateExtVersion( _hLineApp, dwDeviceId, _dwAPIVersion, SupportExtLowVersion(), SupportExtHighVersion(), &dwEXTVersion );
                  if ( lRet < 0 )
                        {
                        dwEXTVersion = 0;
                        return( false );
                        }
                  }
            else
                  {
                  dwEXTVersion = 0;
                  }
            if ( mdExt || claraExt )
                  {
                  lRet = lineOpen( _hLineApp, dwDeviceId, (LPHLINE) &hLine, _dwAPIVersion, dwEXTVersion, (DWORD) this, LINECALLPRIVILEGE_MONITOR | LINECALLPRIVILEGE_OWNER, LINEMEDIAMODE_INTERACTIVEVOICE, 0 );
                  }
            else
                  {
                  lRet = lineOpen( _hLineApp, dwDeviceId, (LPHLINE) &hLine, _dwAPIVersion, 0, (DWORD) this, LINECALLPRIVILEGE_MONITOR | LINECALLPRIVILEGE_OWNER, LINEMEDIAMODE_INTERACTIVEVOICE, 0 );
                  if ( lRet < 0 )
                        {
                        TRACE("First lineOpen failed with error = " << lRet );
                        // Unimodem can not open line with owner priviliege
                        lRet = lineOpen( _hLineApp, dwDeviceId, (LPHLINE) &hLine, _dwAPIVersion, 0, (DWORD) this, LINECALLPRIVILEGE_MONITOR, LINEMEDIAMODE_INTERACTIVEVOICE, 0 );
                        }
                  if ( lRet < 0 )
                        {
                        TRACE( "Second lineOpen failed with error = " << lRet );
                        continue;                        // just skip this line device, it's not voice
                        }
                  }
            if ( lRet < 0 )
                  {
                  return( false );
                  }
            // fill lineList with LineDev object
            LineDevice::LineTypeEnum lineType = mdExt ? LineDevice::ltMD110 : claraExt ? LineDevice::ltClaraBGS : maryExt ? LineDevice::ltMary :LineDevice::ltUnknown;
            LineDevice * pLineDevice;
            if ( lineType == LineDevice::ltMary )
                  {
                  pLineDevice = new LineDeviceMary( hLine, dwDeviceId, _dwAPIVersion, dwEXTVersion, extensionID, lineType );
                  }
            pLineDevice = new LineDevice( hLine, dwDeviceId, _dwAPIVersion, dwEXTVersion, extensionID, lineType );
            // get line device capabilities
            LineCaps lineCaps( _hLineApp, pLineDevice );
            lineCaps.capability();
            if ( mdExt || claraExt )
                  {
                  SwitchInfo( lineCaps.switchInfo() );
                  getMsgDivTextStrings( lineCaps );
                  }
            pLineDevice->SetLineName( lineCaps.lineName() );
            pLineDevice->SetPPId( lineCaps.PPId() );
            lineList().AddAtTail( pLineDevice );
            if ( pLineDevice->GetLineType() == LineDevice::ltMD110 )
                  {
                  LineDevice::SetMD110Line( pLineDevice );
                  StrStream str;
                  IniFile ini( IniFileTelephone );
                  DWORD dw = lineCaps.PPId() >> 16;
                  str << "Provider" << dw << ends;
                  setDefaultTimeout( ini.read( str.str(), EntryTimeoutASYNC, (unsigned int) 5000 ) );
                  }
            if ( pLineDevice->GetLineType() == LineDevice::ltClaraBGS )
                  {
                  LineDevice::SetClaraLine( pLineDevice );
                  }
            TRACE("Before if ( !FillAddresses( pLineDevice, &lineCaps ) )");
            if ( !FillAddresses( pLineDevice, &lineCaps ) )
                  {
                  return( false );
                  }
            lineSetStatusMessages(      hLine,
                                                                                    LINEDEVSTATE_OTHER |
                                                                                    LINEDEVSTATE_RINGING |
                                                                                    LINEDEVSTATE_CONNECTED |
                                                                                    LINEDEVSTATE_DISCONNECTED |
                                                                                    LINEDEVSTATE_MSGWAITON |
                                                                                    LINEDEVSTATE_MSGWAITOFF |
                                                                                    LINEDEVSTATE_INSERVICE |
                                                                                    LINEDEVSTATE_OUTOFSERVICE |
                                                                                    LINEDEVSTATE_MAINTENANCE |
                                                                                    LINEDEVSTATE_OPEN |
                                                                                    LINEDEVSTATE_CLOSE |
                                                                                    LINEDEVSTATE_NUMCALLS |
                                                                                    LINEDEVSTATE_NUMCOMPLETIONS |
                                                                                    LINEDEVSTATE_TERMINALS |
                                                                                    LINEDEVSTATE_ROAMMODE |
                                                                                    LINEDEVSTATE_BATTERY |
                                                                                    LINEDEVSTATE_SIGNAL |
                                                                                    LINEDEVSTATE_DEVSPECIFIC |
                                                                                    LINEDEVSTATE_REINIT |
                                                                                    LINEDEVSTATE_LOCK,
                                                                                    LINEADDRESSSTATE_OTHER |
                                                                                    LINEADDRESSSTATE_DEVSPECIFIC |
                                                                                    LINEADDRESSSTATE_INUSEZERO |
                                                                                    LINEADDRESSSTATE_INUSEONE |
                                                                                    LINEADDRESSSTATE_INUSEMANY |
                                                                                    LINEADDRESSSTATE_NUMCALLS |
                                                                                    LINEADDRESSSTATE_FORWARD |
                                                                                    LINEADDRESSSTATE_TERMINALS );
            checkLineStatus( pLineDevice );
            }
      _killTimer = new KillOCTimer( this, 500 );
      return true;
}


0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question