Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Tapi

Posted on 1997-04-21
7
469 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 Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

792 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