def register_protocol_handlers(controller): """Register ndrive as a protocol handler in the Registry""" import _winreg exe_path = find_exe_path() if exe_path is None: log.warning("Not a frozen windows exe: " "skipping protocol handler registration") return log.debug("Registering 'nxdrive' protocol handler to: %s", exe_path) reg = _winreg.ConnectRegistry(None, _winreg.HKEY_CURRENT_USER) # Register Nuxeo Drive as a software as a protocol command provider command = '"' + exe_path + '" "%1"' update_win32_reg_key(reg, "Software\\Nuxeo Drive", [("", _winreg.REG_SZ, "Nuxeo Drive")]) # TODO: add an icon for Nuxeo Drive too update_win32_reg_key(reg, "Software\\Nuxeo Drive\\Protocols\\nxdrive", [("URL Protocol", _winreg.REG_SZ, "")]) # TODO: add an icon for the nxdrive protocol too update_win32_reg_key( reg, "Software\\Nuxeo Drive\\Protocols\\nxdrive\\shell\\open\\command", [("", _winreg.REG_SZ, command)] ) # Create the nxdrive protocol key nxdrive_class_path = "Software\\Classes\\nxdrive" update_win32_reg_key( reg, nxdrive_class_path, [ ("EditFlags", _winreg.REG_DWORD, 2), ("", _winreg.REG_SZ, "URL:nxdrive Protocol"), ("URL Protocol", _winreg.REG_SZ, ""), ], ) # Create the nxdrive command key command_path = nxdrive_class_path + "\\shell\\open\\command" update_win32_reg_key(reg, command_path, [("", _winreg.REG_SZ, command)])
def register_protocol_handlers(controller): """Register ndrive as a protocol handler in the Registry""" import _winreg exe_path = find_exe_path() if exe_path is None: log.warning('Not a frozen windows exe: ' 'skipping protocol handler registration') return log.debug("Registering 'nxdrive' protocol handler to: %s", exe_path) reg = _winreg.ConnectRegistry(None, _winreg.HKEY_CURRENT_USER) # Register Nuxeo Drive as a software as a protocol command provider command = '"' + exe_path + '" "%1"' update_win32_reg_key( reg, 'Software\\Nuxeo Drive', [('', _winreg.REG_SZ, 'Nuxeo Drive')], ) # TODO: add an icon for Nuxeo Drive too update_win32_reg_key( reg, 'Software\\Nuxeo Drive\\Protocols\\nxdrive', [('URL Protocol', _winreg.REG_SZ, '')], ) # TODO: add an icon for the nxdrive protocol too update_win32_reg_key( reg, 'Software\\Nuxeo Drive\\Protocols\\nxdrive\\shell\\open\\command', [('', _winreg.REG_SZ, command)], ) # Create the nxdrive protocol key nxdrive_class_path = 'Software\\Classes\\nxdrive' update_win32_reg_key( reg, nxdrive_class_path, [ ('EditFlags', _winreg.REG_DWORD, 2), ('', _winreg.REG_SZ, 'URL:nxdrive Protocol'), ('URL Protocol', _winreg.REG_SZ, ''), ], ) # Create the nxdrive command key command_path = nxdrive_class_path + '\\shell\\open\\command' update_win32_reg_key( reg, command_path, [('', _winreg.REG_SZ, command)], )
def register_startup_win32(): """Register ndrive as a startup application in the Registry""" import _winreg reg_key = 'Software\\Microsoft\\Windows\\CurrentVersion\\Run' app_name = 'Nuxeo Drive' exe_path = find_exe_path() if exe_path is None: log.warning('Not a frozen windows exe: ' 'skipping startup application registration') return log.debug("Registering '%s' application %s to registry key %s", app_name, exe_path, reg_key) reg = _winreg.ConnectRegistry(None, _winreg.HKEY_CURRENT_USER) update_win32_reg_key( reg, reg_key, [(app_name, _winreg.REG_SZ, exe_path)], )
def register_startup_darwin(): """Register the Nuxeo Drive.app as a user Launch Agent http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html """ agents_folder = os.path.expanduser('~/Library/LaunchAgents') agent_filepath = os.path.join(agents_folder, NDRIVE_AGENT_FILENAME) exe_path = find_exe_path() log.debug("Registering '%s' for startup in: '%s'", exe_path, agent_filepath) if not os.path.exists(agents_folder): log.debug("Making launch agent folder %s", agents_folder) os.makedirs(agents_folder) if not os.path.exists(agent_filepath): log.debug("Writing launch agent file %s", agent_filepath) with open(agent_filepath, 'wb') as f: f.write(NDRIVE_AGENT_TEMPLATE % exe_path)
def register_contextual_menu_win32(): """Register ndrive as a Windows explorer contextual menu entry""" import _winreg # TODO: better understand why / how this works. # See https://jira.nuxeo.com/browse/NXDRIVE-120 app_name = "None" args = " metadata --file \"%1\"" exe_path = find_exe_path() + args if exe_path is None: log.warning('Not a frozen windows exe: ' 'skipping startup application registration') return log.debug("Registering '%s' application %s to registry key %s", app_name, exe_path, REG_KEY) reg = _winreg.ConnectRegistry(None, _winreg.HKEY_CURRENT_USER) update_win32_reg_key( reg, REG_KEY, [(app_name, _winreg.REG_SZ, exe_path)], )