Solved

Tapi

Posted on 1997-04-21
7
461 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now