B4J Library Chilkat-Bundle

This is a - partially - wrap for the Components of https://www.chilkatsoft.com/

Note that the B4A and B4J wrappers are free but you need a Chilkat License to Unlock the Chilkat Library.
The prices starting at $US 289
Buy a Chilkat License
More information about licensing: Licensing Explained

Licensing Information:
  • The Bundle provides licenses to all existing Chilkat classes.
  • A 1-Developer license is for a single named developer, 4-Developers allows for up to 4 named developers.
  • A Site-Wide license is for any number of developers at a single company location.
  • A license is valid across all supported operating systems, programming languages, architectures, frameworks, etc.
  • The license covers new versions while maintenance/support has not expired.
The interesting part is "A license is valid across all supported operating systems, programming languages, architectures, frameworks, etc." which means that you only need ONE License to use the Chilkat Library in every programming language you want.
I do use them in the 1st line in Delphi for example. But i also wanted to use them in B4J and B4A so i started doing wrappers for it :)

Chilkat is a cross-language, cross-platform API providing 90+ classes for many Internet protocols, formats, and algorithms.
Some classes need a license: SSH, SFTP, FTP2, HTTP, REST, Socket/TLS, IMAP, ...
Some are free: JSON, XML, Cert, PrivateKey, ...

The Objects wrapped so far are:
  • CkAuthGoogle
  • CkBinData
  • CkCert
  • CkDateTime ' Testedpartially (it is used n the Dropboxtest)
  • CkDtObj ' Testedpartially (it is used n the Dropboxtest)
  • CkEmail
  • CkFileAccess
  • CkFtp2
  • CkFtp2Progress
  • CkGlobal ' Tested. It is needed to Unlock the Chilkat Library
  • CkHttp ' Tested partially (it is used n the Dropboxtest)
  • CkImap ' Tested partially (it is used in the IMAP Test)
  • CkJavaKeyStore
  • CkJsonObject' Tested partially (it is used n the Dropboxtest)
  • CkJwt
  • CkPem
  • CkPfx
  • CkPrivateKey
  • CkPrng
  • CkPublicKey
  • CkRest' Tested partially (it is used in the Dropboxtest)
  • CkRsa
  • CkSFtp
  • CkSFtpDir
  • CkSFtpFile
  • CkSFtpProgress
  • CkSocket
  • CkSsh ' Tested partially (it is used in the SSHtest)
  • CkSshKey
  • CkSshTunnel
  • CkStream' Tested partially (it is used n the Dropboxtest)
  • CkString
  • CkStringArray
  • CkStringBuilder
  • CkTask
  • CkUrl
  • CkWebSocket
  • CkZipCrc
But, honestly, only a few of them are tested as of now :D
I spent a lot of time doing the wraps though

Some notes:
- As the Library behind (-so Files) is written to support multiple languages the Methods are somehow "Crypted" looking at them from a B4X perspective.
I did try to change the Methods and Properties available to be "B4X conform" :)

For example:
Java:
  public int get_AnsiCodePage() {
    return chilkatJNI.CkGlobal_get_AnsiCodePage(swigCPtr, this);
  }

  public void put_AnsiCodePage(int newVal) {
    chilkatJNI.CkGlobal_put_AnsiCodePage(swigCPtr, this, newVal);
  }
The 1st is a getter, the second a setter for the Values inside the native code.

Inside the wrapper such code is translated into
Java:
  public int getAnsiCodePage() {
    return this.getObject().get_AnsiCodePage();
  }

  public void setAnsiCodePage(int newVal) {
      this.getObject().put_AnsiCodePage(newVal);
  }
meaning that in B4A and B4J you would use
B4X:
' Set
global1.AnsiCodepage = 1
' Get
dim cp as Int = global1.AnsiCodepage
- Usually the Methods wants to return something "into a special Object". But all methods also has a similar Method/Property which returns a String instead of using CkString-Object.
Java:
  public void getThreadPoolLogPath2(CkString str) {
      this.getObject().get_ThreadPoolLogPath(str);
  }

  public String getThreadPoolLogPath() {
    return this.getObject().threadPoolLogPath();
  }
getThreadPoolLogPath2(CkString str) will return the result into the CkString Object named str.
and getThreadPoolLogPath() will return the String directly.

Library and Example can be downloaded from this Dropbox Link:

The B4A Version is HERE.
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User

avalle

Active Member
Licensed User
Longtime User
Hi Don, great idea! I've used these libraries with C in the past.
I tried to compile the Test1-Unlock but I found multiple issues:

- The IDE reports an error in the DropBox class: " ',' expected " for this line of code:
B4X:
Dim responseStr As String = rest.fullRequestNoBody2("POST","/2/files/download")
I tried to solve by commenting it out and replacing it with
B4X:
Dim responseStr as String = rest.fullRequestNoBody("POST","/2/files/download")
This removes the error but I don't know if it's a good solution.

- I get the following error in the compilation window:
B4X:
src\b4j\example\imap.java:36: error: cannot access CkImapwrapper
public de.donmanfred.CkImapwrapper _imap = null;
                    ^
  bad class file: C:\Users\Andrea\Development\B4J\libraries\chilkatbundle.jar(de/donmanfred/CkImapwrapper.class)
    class file has wrong version 55.0, should be 52.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.
Not sure what that error means...

- The IMAP and SSH class names are in conflict with variables that were defined with the same name. It's just a warning but I tried to change the names to avoid issues, but the problem above is not related to this.
 

avalle

Active Member
Licensed User
Longtime User
Thanks.
Do you mean Java 11 instead of Java 8 (which I'm using)?
 

Culjko

Member
Hello,
I have problem with :
Sub Class_Globals
Dim cert As CkCert
Dim apin As String
End Sub

Public Sub Initialize
cert.Initialize("")
cert.LoadFromSmartcard("")
apin = "3226"
cert.smartCardPin = apin
End Sub

When i run this i get message like on picture:
cert.smartCardPin = apin
shell\src\b4a\example\b4xmainpage_subs_0.java:1874: error: unexpected type
__ref.getField(false,"_cert" /*RemoteObject*/ ).runMethod(true,"smartCardPin") = _apin;Debug.locals.put("_ref", __ref);
^
required: variable
found: value
1 error

How to define PIN?
 

Attachments

  • error.jpg
    error.jpg
    238.8 KB · Views: 105
Top