From 039f194d917badcbf619b055067364be29b14544 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Wed, 20 Jul 2016 18:40:16 -0300 Subject: [PATCH] Adds bitcoin/copay URL handler support for Windows --- config-templates/setup-win.iss | 105 ++++++++++++++++++--------------- src/js/services/openURL.js | 25 ++++++++ webkitbuilds/setup-win.iss | 105 ++++++++++++++++++--------------- 3 files changed, 141 insertions(+), 94 deletions(-) diff --git a/config-templates/setup-win.iss b/config-templates/setup-win.iss index fa123be28..a764e7542 100755 --- a/config-templates/setup-win.iss +++ b/config-templates/setup-win.iss @@ -1,47 +1,58 @@ -; Script generated by the Inno Setup Script Wizard. -; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! - -#define MyAppName "Copay" -#define MyAppVersion "%APP-VERSION%" -#define MyAppPublisher "BitPay" -#define MyAppURL "https://copay.io" -#define MyAppExeName "Copay.exe" - -[Setup] -AppId={{804636ee-b017-4cad-8719-e58ac97ffa5c} -AppName={#MyAppName} -AppVersion={#MyAppVersion} -;AppVerName={#MyAppName} {#MyAppVersion} -AppPublisher={#MyAppPublisher} -AppPublisherURL={#MyAppURL} -AppSupportURL={#MyAppURL} -AppUpdatesURL={#MyAppURL} -DefaultDirName={pf}\{#MyAppName} -DefaultGroupName={#MyAppName} -OutputBaseFilename=Copay-win -OutputDir=./ -Compression=lzma -SolidCompression=yes - -[Languages] -Name: "english"; MessagesFile: "compiler:Default.isl" -Name: "french"; MessagesFile: "compiler:Languages\French.isl" -Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl" -Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl" - -[Tasks] -Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked - -[Files] -Source: "Copay\win64\copay.exe"; DestDir: "{app}"; Flags: ignoreversion -Source: "Copay\win64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs -Source: "../public/img/icons/favicon.ico"; DestDir: "{app}"; DestName: "icon.ico"; Flags: ignoreversion -; NOTE: Don't use "Flags: ignoreversion" on any shared system files - -[Icons] -Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; WorkingDir: "{app}"; IconFilename: "{app}/icon.ico" -Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}/icon.ico"; Tasks: desktopicon - -[Run] -Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent - +; Script generated by the Inno Setup Script Wizard. +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! + +#define MyAppName "Copay" +#define MyAppVersion "%APP-VERSION%" +#define MyAppPublisher "BitPay" +#define MyAppURL "https://copay.io" +#define MyAppExeName "Copay.exe" + +[Setup] +AppId={{804636ee-b017-4cad-8719-e58ac97ffa5c} +AppName={#MyAppName} +AppVersion={#MyAppVersion} +;AppVerName={#MyAppName} {#MyAppVersion} +AppPublisher={#MyAppPublisher} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +DefaultDirName={pf}\{#MyAppName} +DefaultGroupName={#MyAppName} +OutputBaseFilename=Copay-win +OutputDir=./ +Compression=lzma +SolidCompression=yes + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" +Name: "french"; MessagesFile: "compiler:Languages\French.isl" +Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl" +Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl" + +[Tasks] +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked + +[Files] +Source: "Copay\win64\copay.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "Copay\win64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs +Source: "../public/img/icons/favicon.ico"; DestDir: "{app}"; DestName: "icon.ico"; Flags: ignoreversion +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Icons] +Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; WorkingDir: "{app}"; IconFilename: "{app}/icon.ico" +Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}/icon.ico"; Tasks: desktopicon + +[Run] +Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent + +[Registry] +Root: HKCR; Subkey: "bitcoin"; ValueType: "string"; ValueData: "URL:Bitcoin Custom Protocol"; Flags: uninsdeletekey +Root: HKCR; Subkey: "bitcoin"; ValueType: "string"; ValueName: "URL Protocol"; ValueData: "" +Root: HKCR; Subkey: "bitcoin\DefaultIcon"; ValueType: "string"; ValueData: "{app}\{#MyAppExeName},0" +Root: HKCR; Subkey: "bitcoin\shell\open\command"; ValueType: "string"; ValueData: """{app}\{#MyAppExeName}"" ""%1""" + +Root: HKCR; Subkey: "copay"; ValueType: "string"; ValueData: "URL:Copay Custom Protocol"; Flags: uninsdeletekey +Root: HKCR; Subkey: "copay"; ValueType: "string"; ValueName: "URL Protocol"; ValueData: "" +Root: HKCR; Subkey: "copay\DefaultIcon"; ValueType: "string"; ValueData: "{app}\{#MyAppExeName},0" +Root: HKCR; Subkey: "copay\shell\open\command"; ValueType: "string"; ValueData: """{app}\{#MyAppExeName}"" ""%1""" + diff --git a/src/js/services/openURL.js b/src/js/services/openURL.js index c154d94a7..084126a57 100644 --- a/src/js/services/openURL.js +++ b/src/js/services/openURL.js @@ -90,6 +90,31 @@ angular.module('copayApp.services').factory('openURLService', function($rootScop handleOpenURL(request.url); } }); + } else if (platformInfo.isNW) { + var gui = require('nw.gui'); + + // This event is sent to an existent instance of Copay (only for standalone apps) + gui.App.on('open', function(pathData) { + if (pathData.indexOf('bitcoin:') != -1) { + $log.debug('Bitcoin URL found'); + handleOpenURL({ + url: pathData.substring(pathData.indexOf('bitcoin:')) + }); + } else if (pathData.indexOf('copay:') != -1) { + $log.debug('Copay URL found'); + handleOpenURL({ + url: pathData.substring(pathData.indexOf('copay:')) + }); + } + }); + + // Used at the startup of Copay + var argv = gui.App.argv; + if (argv && argv[0]) { + handleOpenURL({ + url: argv[0] + }); + } } else if (platformInfo.isDevel) { var base = window.location.origin + '/'; diff --git a/webkitbuilds/setup-win.iss b/webkitbuilds/setup-win.iss index 808739447..35196271e 100755 --- a/webkitbuilds/setup-win.iss +++ b/webkitbuilds/setup-win.iss @@ -1,47 +1,58 @@ -; Script generated by the Inno Setup Script Wizard. -; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! - -#define MyAppName "Copay" -#define MyAppVersion "2.3.0" -#define MyAppPublisher "BitPay" -#define MyAppURL "https://copay.io" -#define MyAppExeName "Copay.exe" - -[Setup] -AppId={{804636ee-b017-4cad-8719-e58ac97ffa5c} -AppName={#MyAppName} -AppVersion={#MyAppVersion} -;AppVerName={#MyAppName} {#MyAppVersion} -AppPublisher={#MyAppPublisher} -AppPublisherURL={#MyAppURL} -AppSupportURL={#MyAppURL} -AppUpdatesURL={#MyAppURL} -DefaultDirName={pf}\{#MyAppName} -DefaultGroupName={#MyAppName} -OutputBaseFilename=Copay-win -OutputDir=./ -Compression=lzma -SolidCompression=yes - -[Languages] -Name: "english"; MessagesFile: "compiler:Default.isl" -Name: "french"; MessagesFile: "compiler:Languages\French.isl" -Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl" -Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl" - -[Tasks] -Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked - -[Files] -Source: "Copay\win64\copay.exe"; DestDir: "{app}"; Flags: ignoreversion -Source: "Copay\win64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs -Source: "../public/img/icons/favicon.ico"; DestDir: "{app}"; DestName: "icon.ico"; Flags: ignoreversion -; NOTE: Don't use "Flags: ignoreversion" on any shared system files - -[Icons] -Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; WorkingDir: "{app}"; IconFilename: "{app}/icon.ico" -Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}/icon.ico"; Tasks: desktopicon - -[Run] -Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent - +; Script generated by the Inno Setup Script Wizard. +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! + +#define MyAppName "Copay" +#define MyAppVersion "2.3.0" +#define MyAppPublisher "BitPay" +#define MyAppURL "https://copay.io" +#define MyAppExeName "Copay.exe" + +[Setup] +AppId={{804636ee-b017-4cad-8719-e58ac97ffa5c} +AppName={#MyAppName} +AppVersion={#MyAppVersion} +;AppVerName={#MyAppName} {#MyAppVersion} +AppPublisher={#MyAppPublisher} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +DefaultDirName={pf}\{#MyAppName} +DefaultGroupName={#MyAppName} +OutputBaseFilename=Copay-win +OutputDir=./ +Compression=lzma +SolidCompression=yes + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" +Name: "french"; MessagesFile: "compiler:Languages\French.isl" +Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl" +Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl" + +[Tasks] +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked + +[Files] +Source: "Copay\win64\copay.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "Copay\win64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs +Source: "../public/img/icons/favicon.ico"; DestDir: "{app}"; DestName: "icon.ico"; Flags: ignoreversion +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Icons] +Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; WorkingDir: "{app}"; IconFilename: "{app}/icon.ico" +Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}/icon.ico"; Tasks: desktopicon + +[Run] +Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent + +[Registry] +Root: HKCR; Subkey: "bitcoin"; ValueType: "string"; ValueData: "URL:Bitcoin Custom Protocol"; Flags: uninsdeletekey +Root: HKCR; Subkey: "bitcoin"; ValueType: "string"; ValueName: "URL Protocol"; ValueData: "" +Root: HKCR; Subkey: "bitcoin\DefaultIcon"; ValueType: "string"; ValueData: "{app}\{#MyAppExeName},0" +Root: HKCR; Subkey: "bitcoin\shell\open\command"; ValueType: "string"; ValueData: """{app}\{#MyAppExeName}"" ""%1""" + +Root: HKCR; Subkey: "copay"; ValueType: "string"; ValueData: "URL:Copay Custom Protocol"; Flags: uninsdeletekey +Root: HKCR; Subkey: "copay"; ValueType: "string"; ValueName: "URL Protocol"; ValueData: "" +Root: HKCR; Subkey: "copay\DefaultIcon"; ValueType: "string"; ValueData: "{app}\{#MyAppExeName},0" +Root: HKCR; Subkey: "copay\shell\open\command"; ValueType: "string"; ValueData: """{app}\{#MyAppExeName}"" ""%1""" +