ThbTapiPhone.GetRequestNote
Unit: hbTapi
 

Everytime, hbTapi calls an asynchronous TAPI function, an internal request object will be created. This object holds information like the request ID, the request type, a timeout value and the participating objects (e.g. calls). You are able to store your own information within the request object by using the ThbTapiPhone.SetRequestNote method. The function GetRequestNote is used to query these information of a request. Especially if you are using the asynchronus mode of hbTapi, this function is very helpfull. It provides you with a simple possibility to get information of a request identified by its request ID.

Declaration

function GetRequestNote(RequestID: Integer; Ident: String): Variant;

Parameters

RequestID
ID of an existing request. Use ThbTapiPhone.LastRequestID or the request id given by the parameter RequestID within a ThbTapiPhone event. If no request with the given id exists, an exception will be raised.
Ident

Identifier of the needed information. There are two kinds of identifiers: internal and user defined. Use the method ThbTapiPhone.SetRequestNode to store an information using an user defined identifier. All Internal identifiers are beginning with a '&' like '&TapiRequest'.

Valid internal identifiers are:

Identifier

Result Type

Meaning

&TapiRequest

DWORD (Cardinal)

Type of the request as DWORD using one of the TAPIREQUEST_ consts.

&Timeout

DWORD (Cardinal)

Timeout value of the request in milli seconds

Return Value

Returns the information specified by Ident as a Variant. Use a typecast to convert it into the needed type.

Remarks

The most often used information is the type of the request. The following example gets the type of a failed request to display a corresponding message dialog.

interface
uses hbTapi, tapi, ...

procedure TForm1.TapiPhone1TapiReply(Sender: TObject; RequestID, ReplyCode: Cardinal);
var tr: DWORD;
begin
  if (ReplyCode <> 0) then
  begin
    tr := TapiPhone1.GetRequestNote(RequestID, '&TapiRequest');
    case tr of
      TAPIREQUEST_PHONESETDISPLAY :
         MessageDlg('TapiReply: Setting the display failed!' +#13 + #10 + GetTapiErrorMessage(ReplyCode), mtError, [mbOK], 0);
    else
      MessageDlg('TapiReply: Error' +#13 + #10 + GetTapiErrorMessage(ReplyCode), mtError, [mbOK], 0);
    end
  end;
end;

The following example shows how to store an information together with the request and how to retrieve it back in ThbTapiPhone.OnTapiReply. The text to be shown on the phones display is stored in the request note 'DisplayText' and is retrieved and used in ThbTapiPhone.OnTapiReply to display a message dialog.

interface
uses hbTapi, tapi, ...

procedure TForm1.SetPhoneDisply(AText: String);
begin
  try
    TapiPhone1.Display.Text := AText;
    TapiPhone1.SetRequestNote(TapiPhone1.LastRequestID, 'DisplayText', AText);
  except
    on E:EhbTapiError do
      MessageDlg('Setting the display failed! ' + E.Message, mtError, [mbok], 0);
  end;
end;

procedure TForm1.TapiPhone1TapiReply(Sender: TObject; RequestID, ReplyCode: Cardinal);
begin
  if (ReplyCode <> 0) then
  begin
    if TapiPhone1.GetRequestNote(RequestID, '&TapiRequest') = TAPIREQUEST_PHONESETDISPLAY then
      MessageDlg(Format('TapiReply: Setting the display text "%s" failed! %s', [TapiPhone1.GetRequestNote(RequestID, 'DisplayText')),
         GetTapiErrorMessage(ReplyCode)]), mtError, [mbOK], 0);
    else
      MessageDlg('TapiReply: Error' +#13 + #10 + GetTapiErrorMessage(ReplyCode), mtError, [mbOK], 0);
  end
end;