mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-09-19 23:03:53 +00:00
106 lines
3.9 KiB
Ruby
106 lines
3.9 KiB
Ruby
# Helper for launcher frontend to safely communicate with launcher backend
|
|
|
|
module W3DHubLauncher
|
|
class Worker
|
|
class Api
|
|
# downloads requested resource, returns raw string
|
|
def self.fetch_url
|
|
end
|
|
|
|
# downloads requested resource, periodically reporting progress until completion, returning path for file on disk
|
|
def self.download_url(url, path, method = :get, headers = nil, body = nil, &block)
|
|
Worker::Request.new(:download_url, { url: url, path: path, method: method, headers: headers, body: body }, &block)
|
|
end
|
|
|
|
def self.ico_to_png(ico_path:, png_path:, &block)
|
|
Worker::Request.new(:ico_to_png, { ico_path: ico_path, png_path: png_path }, &block)
|
|
end
|
|
|
|
def self.server_map_image(server, &block)
|
|
Worker::Request.new(:server_map_image, { server: { address: server.address, port: server.port, map: server.current_map } }, &block)
|
|
end
|
|
|
|
def self.dns_resolution(&block)
|
|
Worker::Request.new(:dns_resolution, "", &block)
|
|
end
|
|
|
|
# returns user account data
|
|
#
|
|
# automatically handles signing in / refreshing token (DOES NOT remove account data if failed to refresh token due to network timeout)
|
|
def self.account
|
|
end
|
|
|
|
# returns launcher settings
|
|
def self.settings
|
|
end
|
|
|
|
# returns raw json of launcher settings
|
|
def self.load_settings(&block)
|
|
Worker::Request.new(:load_settings, "", &block)
|
|
end
|
|
|
|
# write updated launcher settings
|
|
def self.update_settings(settings, &block)
|
|
Worker::Request.new(:update_settings, settings.to_json, &block)
|
|
end
|
|
|
|
# returns list of available applications
|
|
#
|
|
# if updated list is requested, return cached version immediately and then the updated list later.
|
|
def self.applications(&block)
|
|
W3DHubLauncher::Worker::Request.new(:w3dhub_api_call, { call: :fetch_applications }, &block)
|
|
end
|
|
|
|
# returns current list of servers as reported from GSH / cache
|
|
def self.servers(&block)
|
|
Worker::Request.new(:servers, "", &block)
|
|
end
|
|
|
|
# returns news for application
|
|
def self.news(category = "launcher-home", &block)
|
|
W3DHubLauncher::Worker::Request.new(:w3dhub_api_call, { call: :fetch_news, arguments: [category] }, &block)
|
|
end
|
|
|
|
# returns news for application
|
|
def self.events(category, &block)
|
|
W3DHubLauncher::Worker::Request.new(:w3dhub_api_call, { call: :fetch_events, arguments: [category] }, &block)
|
|
end
|
|
|
|
# request installation of application
|
|
#
|
|
# periodically reports progress until completion
|
|
def self.install_application(app_id, channel_id, &block)
|
|
Worker::Request.new(:task_install_application, { app_id: app_id, channel_id: channel_id }, &block)
|
|
end
|
|
|
|
# request update of application
|
|
#
|
|
# periodically reports progress until completion
|
|
def self.update_application(app_id, channel_id, &block)
|
|
Worker::Request.new(:task_update_application, { app_id: app_id, channel_id: channel_id }, &block)
|
|
end
|
|
|
|
# request repair of application
|
|
#
|
|
# periodically reports progress until completion
|
|
def self.repair_application(app_id, channel_id, &block)
|
|
Worker::Request.new(:task_repair_application, { app_id: app_id, channel_id: channel_id }, &block)
|
|
end
|
|
|
|
# request relocation of application
|
|
#
|
|
# periodically reports progress until completion
|
|
def self.move_application(app_id, channel_id, target_directory, &block)
|
|
Worker::Request.new(:task_move_application, { app_id: app_id, channel_id: channel_id, target_directory: target_directory }, &block)
|
|
end
|
|
|
|
# request removal of application
|
|
#
|
|
# periodically reports progress until completion
|
|
def self.uninstall_application(app_id, channel_id, &block)
|
|
Worker::Request.new(:task_uninstall_application, { app_id: app_id, channel_id: channel_id }, &block)
|
|
end
|
|
end
|
|
end
|
|
end
|