~romuloalves/encrypt-now-desktop

c4b9a026f36909040e7543f9fbcf2a7e301a2a51 — romuloalves 1 year, 7 months ago 08e0a6b
Calling go to copy files
3 files changed, 102 insertions(+), 8 deletions(-)

A native/transfer-worker.dylib
A native/transfer-worker.h
M renderer.js
A native/transfer-worker.dylib => native/transfer-worker.dylib +0 -0

A native/transfer-worker.h => native/transfer-worker.h +78 -0
@@ 0,0 1,78 @@
/* Code generated by cmd/cgo; DO NOT EDIT. */

/* package gitlab.com/encrypt-now/transfer-worker */


#line 1 "cgo-builtin-prolog"

#include <stddef.h> /* for ptrdiff_t below */

#ifndef GO_CGO_EXPORT_PROLOGUE_H
#define GO_CGO_EXPORT_PROLOGUE_H

typedef struct { const char *p; ptrdiff_t n; } _GoString_;

#endif

/* Start of preamble from import "C" comments.  */




/* End of preamble from import "C" comments.  */


/* Start of boilerplate cgo prologue.  */
#line 1 "cgo-gcc-export-header-prolog"

#ifndef GO_CGO_PROLOGUE_H
#define GO_CGO_PROLOGUE_H

typedef signed char GoInt8;
typedef unsigned char GoUint8;
typedef short GoInt16;
typedef unsigned short GoUint16;
typedef int GoInt32;
typedef unsigned int GoUint32;
typedef long long GoInt64;
typedef unsigned long long GoUint64;
typedef GoInt64 GoInt;
typedef GoUint64 GoUint;
typedef __SIZE_TYPE__ GoUintptr;
typedef float GoFloat32;
typedef double GoFloat64;
typedef float _Complex GoComplex64;
typedef double _Complex GoComplex128;

/*
  static assertion to make sure the file is being used on architecture
  at least with matching size of GoInt.
*/
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];

typedef _GoString_ GoString;
typedef void *GoMap;
typedef void *GoChan;
typedef struct { void *t; void *v; } GoInterface;
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;

#endif

/* End of boilerplate cgo prologue.  */

#ifdef __cplusplus
extern "C" {
#endif


// Encrypt copies files encrypting them

extern GoString Encrypt(GoString p0, GoString p1, GoString p2);

// Decrypt copies files encrypting them

extern GoInterface Decrypt(GoString p0, GoString p1, GoString p2);

#ifdef __cplusplus
}
#endif

M renderer.js => renderer.js +24 -8
@@ 3,11 3,11 @@
// All of the Node.js APIs are available in this process.
const { remote } = require('electron');

const { copyEncrypting, copyDecrypting } = require('./copy');

const state = {
  from: '',
  to: '',
  encrypt: true,
  secret: ''
  to: ''
};

function selectFolder(properties) {


@@ 37,13 37,29 @@ document.getElementById('selectToPath').addEventListener('click', function(event
});

document.querySelector('form').addEventListener('submit', function(event) {
  const secret = document.getElementById('secret').value;
  const encrypt = document.getElementById('encrypt').checked;
  try {
    const secret = document.getElementById('secret').value;
    const encrypt = document.getElementById('encrypt').checked;
  
    alert(JSON.stringify(state));
  
    let response = null;
  
    if (encrypt) {
      response = copyEncrypting(state.from, state.to, secret);
    } else {
      response = copyDecrypting(state.from, state.to, secret);
    }

  state.secret = secret;
  state.encrypt = encrypt;
    alert(response);
  } catch (err) {
    if (err.message) {
      alert(err.message);
    } else {
      alert(err);
    }
  }

  alert(JSON.stringify(state));
  event.preventDefault();
  return false;
});
\ No newline at end of file