aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js/src/Keyring.js
diff options
context:
space:
mode:
authorMaximilian Krambach <[email protected]>2018-04-24 16:44:30 +0000
committerMaximilian Krambach <[email protected]>2018-04-24 16:44:30 +0000
commit461dd0c8b41683a91073b362d100ee5217ec53f6 (patch)
tree15ab814b70a583db52f7f9e664aaa016057d98d0 /lang/js/src/Keyring.js
parentjs: don't allow message operation changes (diff)
downloadgpgme-461dd0c8b41683a91073b362d100ee5217ec53f6.tar.gz
gpgme-461dd0c8b41683a91073b362d100ee5217ec53f6.zip
js: change in initialization ancd connection handling
-- * The Connection will now be started before an object is created, to better account for failures. * index.js: now exposes an init(), which returns a Promise of configurable <GpgME | gpgmeGpgME_openPGPCompatibility> with an established connection. * TODO: There is currently no way to recover from a "connection lost" * Connection.js offers Connection.isConnected, which toggles on port closing.
Diffstat (limited to '')
-rw-r--r--lang/js/src/Keyring.js30
1 files changed, 15 insertions, 15 deletions
diff --git a/lang/js/src/Keyring.js b/lang/js/src/Keyring.js
index d8cb84b2..ef8028ff 100644
--- a/lang/js/src/Keyring.js
+++ b/lang/js/src/Keyring.js
@@ -19,27 +19,27 @@
*/
import {GPGME_Message} from './Message'
-import {Connection} from './Connection'
import {GPGME_Key} from './Key'
import { isFingerprint, isLongId } from './Helpers';
export class GPGME_Keyring {
- constructor(){
- this.reconnect();
+ constructor(connection){
+ this.connection = connection;
}
- /**
- * (Re)-establishes the connection
- * TODO TEMP: should we better use the connection of our parent,
- * which we do not control?
- */
- reconnect(){
- if (!this._connection || ! this._connection instanceof Connection){
- this._connection = new Connection;
- } else {
- this._connection.disconnect();
- this._connection.connect();
+ set connection(connection){
+ if (!this._connection && connection instanceof Connection){
+ this._connection = connection;
+ }
+ }
+ get connection(){
+ if (this._connection instanceof Connection){
+ if (this._connection.isConnected){
+ return this._connection;
+ }
+ return undefined; //TODO: connection was lost!
}
+ return undefined; //TODO: no connection there
}
/**
@@ -57,7 +57,7 @@ export class GPGME_Keyring {
msg.setParameter('with-secret', true);
}
- this._connection.post(msg).then(function(result){
+ this.connection.post(msg).then(function(result){
let fpr_list = [];
let resultset = [];
if (!Array.isArray(result.keys)){