From d02f987bf2b00d3eae1833cc8ce95979a4cad824 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Sat, 27 Feb 2016 22:11:50 -0300 Subject: [PATCH 1/6] Closes #113; Development branch fails on npm install --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4057fb51b778..c0a5ba3aa0a6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "devDependencies": { "asar": "^0.7.2", - "electron-prebuilt": "git@github.com:RocketChat/electron-prebuilt.git", + "electron-prebuilt": "https://github.com/RocketChat/electron-prebuilt.git", "fs-jetpack": "^0.7.0", "gulp": "^3.9.0", "gulp-less": "^3.0.3", From 83eb0a448d3b0b8f19af1b0d8ed372d6dfef90d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20G=C3=B6ldi?= Date: Sun, 28 Feb 2016 15:07:21 +0100 Subject: [PATCH 2/6] Fixes issues #89, #77 - Added a force quit option to the app, if this is set, the application will quit. Otherwise it'll just hide. - Fixed bug in windows, where you had to triple-click the tray icon show the app --- app/scripts/menus.js | 2 ++ app/scripts/tray.js | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/scripts/menus.js b/app/scripts/menus.js index b6eb0c6c7192..268c9ff74128 100644 --- a/app/scripts/menus.js +++ b/app/scripts/menus.js @@ -56,6 +56,7 @@ if (process.platform === 'darwin') { label: 'Quit', accelerator: 'Command+Q', click: function() { + remote.app.forceQuit = true; app.quit(); } } @@ -169,6 +170,7 @@ if (process.platform === 'darwin') { label: 'Quit', accelerator: 'Ctrl+Q', click: function() { + remote.app.forceQuit = true; app.quit(); } } diff --git a/app/scripts/tray.js b/app/scripts/tray.js index 43609652bc95..403617d33b9c 100644 --- a/app/scripts/tray.js +++ b/app/scripts/tray.js @@ -44,20 +44,21 @@ function createAppTray(mainWindow) { }, { label: 'Quit', click: function() { + remote.app.forceQuit = true; doQuit(); } }]); _tray.setToolTip('Rocket.Chat'); _tray.setContextMenu(contextMenu); - if (process.platform === 'darwin') { - _tray.on('double-clicked', function() { + if (process.platform === 'darwin' || process.platform == 'win32') { + _tray.on('double-click', function() { toggleShowMainWindow(); }); } else { let dblClickDelay = 500, dblClickTimeoutFct = null; - _tray.on('clicked', function() { + _tray.on('click', function() { if (!dblClickTimeoutFct) { dblClickTimeoutFct = setTimeout(function() { // Single click, do nothing for now @@ -97,7 +98,6 @@ function showTrayAlert(showAlert, title) { _tray.setImage(_iconTrayAlert); if (process.platform === 'darwin') { _tray.setTitle(title); - // _tray.setTitle(title); } } else { _tray.setImage(_iconTray); @@ -145,9 +145,16 @@ bindOnQuit(function() { remote.app.quit(); }); -window.addEventListener('beforeunload', function() { - destroy(); -}); +// Closes or hides the client +window.onbeforeunload = function(e) { + if(!remote.app.forceQuit) { + showMainWindow(false); + return false; + } + else { + destroy(); + } +} export default { createAppTray: createAppTray, From 2d71dabc2559d88f85e0eb062e0d35fc95a46b41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20G=C3=B6ldi?= Date: Sun, 28 Feb 2016 22:10:17 +0100 Subject: [PATCH 3/6] Extended installer functionality - Added check, if the application is running, because this lead to errors - Added option to add a shortcut to the autostart folder (#57) - Added option to launch the app after the installation (#37) - Added option to choose the installation directory (#41) - Added the shortcuts as options, so you can choose, if you want a desktop, autostart or start menu shortcut (a part of #96) - Enabled / Added these pages: components, browse installation folder, finish page - Extended the comments, so it's easier to find the correct spots --- resources/windows/installer.nsi | 158 ++++++++++++++++++++++++++++---- 1 file changed, 142 insertions(+), 16 deletions(-) diff --git a/resources/windows/installer.nsi b/resources/windows/installer.nsi index a0816a61c4b2..224cd825d8ca 100644 --- a/resources/windows/installer.nsi +++ b/resources/windows/installer.nsi @@ -1,11 +1,15 @@ ; NSIS packaging/install script ; Docs: http://nsis.sourceforge.net/Docs/Contents.html +; -------------------------------- +; Includes +; -------------------------------- + !include LogicLib.nsh !include nsDialogs.nsh ; -------------------------------- -; Variables +; Variables ; -------------------------------- !define dest "{{dest}}" @@ -26,7 +30,7 @@ !define uninstaller "uninstall.exe" ; -------------------------------- -; Installation +; Installation ; -------------------------------- Unicode true @@ -52,27 +56,56 @@ Caption "${productName} Setup" SubCaption 3 " " SubCaption 4 " " +; -------------------------------- +; Page layout +; -------------------------------- + Page custom welcome +Page components +Page directory Page instfiles +Page custom finish finishEnd + +; -------------------------------- +; Control variables +; -------------------------------- Var Image Var ImageHandle +Var LaunchAppCheckbox +Var LaunchAppCheckbox_State + +; -------------------------------- +; Installer init +; -------------------------------- + Function .onInit ; Extract banner image for welcome page InitPluginsDir ReserveFile "${banner}" File /oname=$PLUGINSDIR\banner.bmp "${banner}" + + ; Check if the application is currently running, show message if it is + retryInstallation: + FindWindow $0 "Chrome_WidgetWin_1" "Rocket.Chat" + StrCmp $0 0 notRunning + MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "${productName} is currently running. Please close the application to continue." /SD IDCANCEL IDRETRY retryInstallation + Abort + notRunning: FunctionEnd -; Custom welcome page +; -------------------------------- +; Welcome page [custom] +; -------------------------------- + Function welcome nsDialogs::Create 1018 - ${NSD_CreateLabel} 185 1u 210 100% "Welcome to ${productName} version ${version} installer.$\r$\n$\r$\nClick install to begin." + ${NSD_CreateLabel} 185 1u 210 100% "Welcome to ${productName} version ${version} installer.$\r$\n$\r$\nClick next to continue." ${NSD_CreateBitmap} 0 0 170 210 "" Pop $Image @@ -84,9 +117,15 @@ Function welcome FunctionEnd -; Installation declarations -Section "Install" +; -------------------------------- +; Installation sections +; -------------------------------- + +Section "Rocket.Chat Client" + ; Make this section a requirement + SectionIn RO + WriteRegStr HKLM "${regkey}" "Install_Dir" "$INSTDIR" WriteRegStr HKLM "${uninstkey}" "DisplayName" "${productName}" WriteRegStr HKLM "${uninstkey}" "DisplayIcon" '"$INSTDIR\icon.ico"' @@ -102,18 +141,68 @@ Section "Install" ; Include all files from /build directory File /r "${src}\*" - ; Create start menu shortcut - SetShellVarContext all - CreateShortCut "$SMPROGRAMS\${productName}.lnk" "$INSTDIR\${exec}" "" "$INSTDIR\icon.ico" + WriteUninstaller "${uninstaller}" + +SectionEnd + +Section "Desktop shortcut" + ; Create desktop shortcut CreateShortCut "$DESKTOP\${productName}.lnk" "$INSTDIR\${exec}" "" "$INSTDIR\icon.ico" + +SectionEnd - WriteUninstaller "${uninstaller}" +Section "Autostart Entry" + + ; Create autostart entry + CreateShortCut "$SMSTARTUP\${productName}.lnk" "$INSTDIR\${exec}" "" "$INSTDIR\icon.ico" + +SectionEnd + +Section "Start Menu Entry" + ; Create start menu entry + SetShellVarContext all + CreateShortCut "$SMPROGRAMS\${productName}.lnk" "$INSTDIR\${exec}" "" "$INSTDIR\icon.ico" + SectionEnd +; -------------------------------- +; Finish page [custom] +; -------------------------------- + +Function finish + + nsDialogs::Create 1018 + + ${NSD_CreateLabel} 185 1u 210 30u "${productName} installation successfully finished." + + ${NSD_CreateCheckbox} 185 35u 100% 10u "Launch ${productName}" + Pop $LaunchAppCheckbox + ${NSD_SetState} $LaunchAppCheckbox ${BST_CHECKED} + + ${NSD_CreateBitmap} 0 0 170 210 "" + Pop $Image + ${NSD_SetImage} $Image $PLUGINSDIR\banner.bmp $ImageHandle + + nsDialogs::Show + + ${NSD_FreeImage} $ImageHandle + +FunctionEnd + +Function finishEnd + ; Save checkbox state on installer leave + ${NSD_GetState} $LaunchAppCheckbox $LaunchAppCheckbox_State + + ; Launch the app, if the box is checked + ${If} $LaunchAppCheckbox_State == ${BST_CHECKED} + Exec "$INSTDIR\${exec}" + ${EndIf} +FunctionEnd + ; -------------------------------- -; Uninstaller +; Uninstaller ; -------------------------------- ShowUninstDetails nevershow @@ -122,13 +211,40 @@ UninstallCaption "Uninstall ${productName}" UninstallText "Don't like ${productName} anymore? Hit uninstall button." UninstallIcon "${icon}" +; -------------------------------- +; Page layout +; -------------------------------- + UninstPage custom un.confirm un.confirmOnLeave UninstPage instfiles +; -------------------------------- +; Control variables +; -------------------------------- + Var RemoveAppDataCheckbox Var RemoveAppDataCheckbox_State -; Custom uninstall confirm page +; -------------------------------- +; Uninstaller init +; -------------------------------- + +Function un.onInit + + ; Check if the application is currently running, show message if it is + retryUninstall: + FindWindow $0 "Chrome_WidgetWin_1" "Rocket.Chat" + StrCmp $0 0 notRunning + MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "${productName} is currently running. Please close the application to continue." /SD IDCANCEL IDRETRY retryUninstall + Abort + notRunning: + +FunctionEnd + +; -------------------------------- +; Confirm page [custom] +; -------------------------------- + Function un.confirm nsDialogs::Create 1018 @@ -149,17 +265,27 @@ Function un.confirmOnLeave FunctionEnd -; Uninstall declarations +; -------------------------------- +; Uninstallation sections +; -------------------------------- + Section "Uninstall" + ; Remove registry entries DeleteRegKey HKLM "${uninstkey}" DeleteRegKey HKLM "${regkey}" - SetShellVarContext all - Delete "$SMPROGRAMS\${productName}.lnk" ; Remove desktop shortcut Delete "$DESKTOP\${productName}.lnk" - ; Remove whole directory from Program Files + + ; Remove autostart entry + Delete "$SMSTARTUP\${productName}.lnk" + + ; Remove start menu entry + SetShellVarContext all + Delete "$SMPROGRAMS\${productName}.lnk" + + ; Remove whole directory from installation directory RMDir /r "$INSTDIR" ; Remove also appData directory generated by your app if user checked this option From 9624eedd5d7c3a35221a960e3a1df029b90f4663 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Mon, 29 Feb 2016 14:38:44 -0300 Subject: [PATCH 4/6] Fix permissions for MAS sandbox --- parent.plist | 4 ---- 1 file changed, 4 deletions(-) diff --git a/parent.plist b/parent.plist index 73e9b2997d30..819e5d354e73 100644 --- a/parent.plist +++ b/parent.plist @@ -16,9 +16,5 @@ com.apple.security.network.server - com.apple.security.personal-information.location - - com.apple.security.print - From f97e324a96e14a17be737b183965e790c58575c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20G=C3=B6ldi?= Date: Mon, 29 Feb 2016 22:06:06 +0100 Subject: [PATCH 5/6] Extended usage of ${productName} Replaced the remaining Rocket.Chat with the ${productName} variable. --- resources/windows/installer.nsi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/windows/installer.nsi b/resources/windows/installer.nsi index 224cd825d8ca..6d729eff68f9 100644 --- a/resources/windows/installer.nsi +++ b/resources/windows/installer.nsi @@ -89,7 +89,7 @@ Function .onInit ; Check if the application is currently running, show message if it is retryInstallation: - FindWindow $0 "Chrome_WidgetWin_1" "Rocket.Chat" + FindWindow $0 "Chrome_WidgetWin_1" "${productName}" StrCmp $0 0 notRunning MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "${productName} is currently running. Please close the application to continue." /SD IDCANCEL IDRETRY retryInstallation Abort @@ -121,7 +121,7 @@ FunctionEnd ; Installation sections ; -------------------------------- -Section "Rocket.Chat Client" +Section "${productName} Client" ; Make this section a requirement SectionIn RO @@ -233,7 +233,7 @@ Function un.onInit ; Check if the application is currently running, show message if it is retryUninstall: - FindWindow $0 "Chrome_WidgetWin_1" "Rocket.Chat" + FindWindow $0 "Chrome_WidgetWin_1" "${productName}" StrCmp $0 0 notRunning MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "${productName} is currently running. Please close the application to continue." /SD IDCANCEL IDRETRY retryUninstall Abort From 241671a5157d5d2b1e1c101dad404a80bd4c7595 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Mon, 29 Feb 2016 21:16:00 -0300 Subject: [PATCH 6/6] Update version to 1.1.0 --- app/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/package.json b/app/package.json index cb1ea90ab57f..69088ceded53 100644 --- a/app/package.json +++ b/app/package.json @@ -3,7 +3,7 @@ "productName": "Rocket.Chat", "identifier": "chat.rocket", "description": "Rocket.Chat Native Cross-Platform Desktop Application via Electron.", - "version": "1.1.0-partial.1", + "version": "1.1.0", "build": "10", "author": "Rocket.Chat Support ", "copyright": "© 2016, Rocket.Chat",