js: change in initialization ancd connection handling
[gpgme.git] / lang / js / src / gpgmejs_openpgpjs.js
index 54b9dd4..f1ddb5d 100644 (file)
  import { isFingerprint } from "./Helpers"
  import { GPGMEJS_Error } from './Errors'
 
+
 export class GpgME_openPGPCompatibility {
 
-    constructor(){
-        this._gpgme =  new GpgME({
-            null_expire_is_never: false
-        });
-        this.Keyring = this.initKeyring();
+    constructor(connection){
+        this.initGpgME(connection);
+    }
+
+    get Keyring(){
+        if (this._keyring){
+            return this._keyring;
+        }
+        return undefined;
+    }
+
+    initGpgME(connection){
+        this._GpgME = new GpgME(connection);
+        this._Keyring = new GPGME_Keyring_openPGPCompatibility(connection);
+    }
+
+    get GpgME(){
+        if (this._GpGME){
+            return this._GpGME;
+        }
     }
 
     /**
@@ -128,9 +144,6 @@ export class GpgME_openPGPCompatibility {
         // mime:   A Boolean indicating whether the data is a MIME object.
         // info:   An optional object with extra information.
     }
-    initKeyring(){
-        return new GPGME_Keyring_openPGPCompatibility;
-    }
 }
 
 /**
@@ -138,8 +151,8 @@ export class GpgME_openPGPCompatibility {
  * It may still be changed/expanded/merged with GPGME_Keyring
  */
 class GPGME_Keyring_openPGPCompatibility {
-    constructor(){
-        this._gpgme_keyring = new GPGME_Keyring;
+    constructor(connection){
+        this._gpgme_keyring = new GPGME_Keyring(connection);
     }
 
     /**