Skip to end of metadata
Go to start of metadata

Declaration

Delphi

procedure OnGetSignedDocHash(Hash: OleVariant; out Data: OleVariant; out RetCode: Integer);

ActiveX

HRESULT OnGetSignedDocHash([in] VARIANT Hash, [out] VARIANT* Data, [out] long* RetCode);

 

Description

This function should provide the final document hash to the device driver, read the signed document hash and return it to the API. After the final document hash is provided to the naturaSign signature device, it calculates the signed hash and shows three virtual buttons on the device display: OK, Repeat and Cancel.

The user must either:

  • confirm his signature by pressing OK or
  • request to sign again (Repeat) or
  • cancel the signature process (Cancel).

The computation and confirmation by the user takes some time, and if OnGetSignedDocHash is implemented only in the most simple way (like in the sample below), the application on the PC may freeze for that time. It's often desirable to implement asynchronous polling of the device driver, which should be done by the developer of the client application.

In case you doesn´t want to use this Hash Dialog, you need to enable the Emulation Mode with SetDriverOptions.

Sample

C#
void axSignAPIv4_OnGetSignedDocHash(object sender, IStepOverSignatureAPIv4Events_OnGetSignedDocHashEvent e)
{
    // return codes;
    const int adrOk = 0;
    const int adrError = 1;
    const int adrCancelled = 2;
    const int adrRepeat = 3;
    Cursor.Current = Cursors.WaitCursor;
    SigDev.SetFinalDocumentHash(e.hash);
    bool finished = false;
    while (!finished)
    {        int status;
        try
        {
            e.data = SigDev.GetSignedDocHash(out status);
        }
        catch(Exception)
        {
            status = 0x03;
        }
        // Computation finished and OK pressed?
        if(status == 0x11)
        {
            e.retCode = adrOk;
            finished = true;
        }        // Cancel or repeat pressed?
        switch(status & 0x0F)
        {
        case 2: e.retCode = adrRepeat;
 		finished = true; break;
        case 3: e.retCode = adrCancelled;
 		finished = true; break;
        }
        Thread.Sleep(50);
    }
    Cursor.Current = Cursors.Default;
}
Delphi
procedure TForm1.SignApiGetSignedDocHash(Sender: TObject; Hash: OleVariant;
   out Data: OleVariant; out RetCode: Integer); var  res: TSignProcessResult;
  DataStr: String;
  p: TWinControl;
 begin
  res := sprError;
 if StepOverSignatureDevice1.SetFinalDocumentHash(Hash) then begin   if CheckBoxDisplayHashDialog.Checked then
    p := Self
   else
    p := nil;
  case GetSignedDocHashFromDevice(p, VariantToString(Hash), StepOverSignatureDevice1, DataStr) of
    mrOk: begin
     if Length(DataStr) > 0 then      res := sprOk     else      res := sprError;
    end;
    mrCancel: res := sprCancelled;
    mrRetry: res := sprRepeat;
   end;
  end;
    Data := StringToVariant(DataStr);
  RetCode := Integer(res);
 end;
vb.net
Private Sub signapi4_OnGetSignedDocHash(ByVal Hash As Object, ByVal Data As Object, ByVal RetCode As Long)
        ' return codes;
        Dim adrOk As Integer
        adrOk = 0
        Dim adrError As Integer
        adrError = 1
        Dim adrCancelled As Integer
        adrCancelled = 2
        Dim adrRepeat As Integer
        adrRepeat = 3
        Dim finished As Boolean
        mSignaturDevice.SetFinalDocumentHash(Hash)
        finished = False
        Dim status As Long
        status = &H3
        Do While (Not finished)
            Data = mSignaturDevice.GetSignedDocHash(status)
            ' // Computation finished and OK pressed?
            If status = &H11 Then
                RetCode = adrOk
                finished = True
            End If
            '// Cancel or repeat pressed?
            Select Case (status And &HF)
                Case 2
                    RetCode = adrRepeat
                    finished = True
                Case 3
                    RetCode = adrCancelled
                    finished = True
            End Select
        Loop
    End Sub
VB6
Private Sub signapi4_OnGetSignedDocHash(ByVal Hash As Variant, Data As Variant, RetCode As Long)
  ' return codes;
          Dim adrOk As Integer
          adrOk = 0
          Dim adrError As Integer
          adrError = 1
          Dim adrCancelled As Integer
          adrCancelled = 2
          Dim adrRepeat As Integer
          adrRepeat = 3
          Dim finished As Boolean
          sigdev.SetFinalDocumentHash (Hash)
          finished = False
          Dim status As Long
          status = &H3
             Do While (Not finished)
                  Data = sigdev.GetSignedDocHash(status)
                ' // Computation finished and OK pressed?
                             If status = &H11 Then
                                     RetCode = adrOk
                     finished = True
                 End If                 '// Cancel or repeat pressed?
                 Select Case (status And &HF)
                  Case 2
                     RetCode = adrRepeat
                     finished = True
                  Case 3
                     RetCode = adrCancelled
                     finished = True
                 End Select
           Loop
 End Sub
  • No labels