mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-09-20 07:13:52 +00:00
Initial work on implementing tasks
This commit is contained in:
@@ -65,7 +65,7 @@ module W3DHubLauncher
|
|||||||
@game_content_container.clear do
|
@game_content_container.clear do
|
||||||
flow(fill: true, height: 1.0, scroll: true, tag: :hi_mom) do |e|
|
flow(fill: true, height: 1.0, scroll: true, tag: :hi_mom) do |e|
|
||||||
@games.each do |app|
|
@games.each do |app|
|
||||||
image safe_get_image("#{ROOT_PATH}/media/co1oqw.png"), aspect_ratio: 3 / 4.0, width: 1.0 / game_cover_width_ratio(e), margin_left: HALF_PADDING, margin_right: HALF_PADDING, margin_bottom: PADDING, tip: app.name
|
image safe_get_image("#{ROOT_PATH}/media/default_game_cover.png"), aspect_ratio: 3 / 4.0, width: 1.0 / game_cover_width_ratio(e), margin_left: HALF_PADDING, margin_right: HALF_PADDING, margin_bottom: PADDING, tip: app.name
|
||||||
end
|
end
|
||||||
|
|
||||||
e.subscribe(:size_changed) do |e|
|
e.subscribe(:size_changed) do |e|
|
||||||
@@ -184,7 +184,9 @@ module W3DHubLauncher
|
|||||||
elsif @current_app.servicable?
|
elsif @current_app.servicable?
|
||||||
# pp @current_app
|
# pp @current_app
|
||||||
button "Import", enabled: false, tip: "Import existing application installation", fill: true, height: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_LEFT, **CTA_BUTTON_THEME
|
button "Import", enabled: false, tip: "Import existing application installation", fill: true, height: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_LEFT, **CTA_BUTTON_THEME
|
||||||
button "Download", tip: "Download and install application", fill: true, height: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_RIGHT, **CTA_BUTTON_THEME
|
button "Download", tip: "Download and install application", fill: true, height: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_RIGHT, **CTA_BUTTON_THEME do
|
||||||
|
Worker::Api.install_application(@current_app.id, @current_channel.id)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
button "Import", enabled: false, tip: "Import existing application installation", fill: true, height: 1.0, **CTA_BUTTON_THEME
|
button "Import", enabled: false, tip: "Import existing application installation", fill: true, height: 1.0, **CTA_BUTTON_THEME
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ module W3DHubLauncher
|
|||||||
|
|
||||||
Response = Data.define(:status, :request_id, :result)
|
Response = Data.define(:status, :request_id, :result)
|
||||||
|
|
||||||
|
attr_reader :w3dhub_api
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -29,6 +31,7 @@ module W3DHubLauncher
|
|||||||
def init_server
|
def init_server
|
||||||
@threads = []
|
@threads = []
|
||||||
@requests = []
|
@requests = []
|
||||||
|
@tasks = []
|
||||||
|
|
||||||
@client = nil
|
@client = nil
|
||||||
|
|
||||||
@@ -369,19 +372,32 @@ module W3DHubLauncher
|
|||||||
deliver_response(response.result, query)
|
deliver_response(response.result, query)
|
||||||
end
|
end
|
||||||
|
|
||||||
def install_application(query)
|
def task_install_application(query)
|
||||||
|
application = @w3dhub_api.applications.find { |app| app.id == query.data["app_id"] }
|
||||||
|
channel = application.channels.find { |chan| chan.id == query.data["channel_id"] }
|
||||||
|
|
||||||
|
@tasks << Task::InstallApplication.new(
|
||||||
|
request_id: query.request_id,
|
||||||
|
application: application,
|
||||||
|
channel: channel,
|
||||||
|
installed_version: nil,
|
||||||
|
target_version: channel.version
|
||||||
|
)
|
||||||
|
@tasks.last.start(self)
|
||||||
|
|
||||||
|
Response.new(Request::STATUS_PENDING, query.request_id, CyberarmEngine::Result.new(data: true))
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_application(query)
|
def task_update_application(query)
|
||||||
end
|
end
|
||||||
|
|
||||||
def repair_application(query)
|
def task_repair_application(query)
|
||||||
end
|
end
|
||||||
|
|
||||||
def move_application(query)
|
def task_move_application(query)
|
||||||
end
|
end
|
||||||
|
|
||||||
def uninstall_application(query)
|
def task_uninstall_application(query)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -65,31 +65,36 @@ module W3DHubLauncher
|
|||||||
# request installation of application
|
# request installation of application
|
||||||
#
|
#
|
||||||
# periodically reports progress until completion
|
# periodically reports progress until completion
|
||||||
def self.install_application(app_id, channel_id)
|
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
|
end
|
||||||
|
|
||||||
# request update of application
|
# request update of application
|
||||||
#
|
#
|
||||||
# periodically reports progress until completion
|
# periodically reports progress until completion
|
||||||
def self.update_application(app_id, channel_id)
|
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
|
end
|
||||||
|
|
||||||
# request repair of application
|
# request repair of application
|
||||||
#
|
#
|
||||||
# periodically reports progress until completion
|
# periodically reports progress until completion
|
||||||
def self.repair_application(app_id, channel_id)
|
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
|
end
|
||||||
|
|
||||||
# request relocation of application
|
# request relocation of application
|
||||||
#
|
#
|
||||||
# periodically reports progress until completion
|
# periodically reports progress until completion
|
||||||
def self.move_application(app_id, channel_id)
|
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
|
end
|
||||||
|
|
||||||
# request removal of application
|
# request removal of application
|
||||||
#
|
#
|
||||||
# periodically reports progress until completion
|
# periodically reports progress until completion
|
||||||
def self.uninstall_application(app_id, channel_id)
|
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
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,84 @@
|
|||||||
module W3DHubLauncher
|
module W3DHubLauncher
|
||||||
class Task
|
class Task
|
||||||
|
attr_reader :request_id, :application, :channel, :installed_version, :target_version
|
||||||
|
|
||||||
|
def initialize(request_id:, application:, channel:, installed_version:, target_version:)
|
||||||
|
@request_id = request_id
|
||||||
|
@application = application
|
||||||
|
@channel = channel
|
||||||
|
@installed_version = installed_version
|
||||||
|
@target_version = target_version
|
||||||
|
|
||||||
|
pp self
|
||||||
|
|
||||||
|
setup
|
||||||
|
end
|
||||||
|
|
||||||
|
def setup
|
||||||
|
end
|
||||||
|
|
||||||
|
def start(worker)
|
||||||
|
@worker = worker
|
||||||
|
|
||||||
|
execute
|
||||||
|
end
|
||||||
|
|
||||||
|
def fetch_manifests(version = @target_version)
|
||||||
|
result = fetch_manifest(version)
|
||||||
|
if result.okay?
|
||||||
|
pp result
|
||||||
|
else
|
||||||
|
pp [:error, result]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def fetch_manifest(version)
|
||||||
|
@worker.w3dhub_api.fetch_package_details([{category: "games", subcategory: @application.id, name: "manifest.xml", version: version }])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def execute_task
|
||||||
|
show_application_taskbar
|
||||||
|
|
||||||
|
fail_fast
|
||||||
|
return false if failed?
|
||||||
|
|
||||||
|
fetch_manifests
|
||||||
|
return false if failed?
|
||||||
|
|
||||||
|
build_package_list
|
||||||
|
return false if failed?
|
||||||
|
|
||||||
|
remove_deleted_files
|
||||||
|
return false if failed?
|
||||||
|
|
||||||
|
verify_files
|
||||||
|
return false if failed?
|
||||||
|
|
||||||
|
fetch_packages
|
||||||
|
return false if failed?
|
||||||
|
|
||||||
|
verify_packages
|
||||||
|
return false if failed?
|
||||||
|
|
||||||
|
unpack_packages
|
||||||
|
return false if failed?
|
||||||
|
|
||||||
|
create_wine_prefix
|
||||||
|
return false if failed?
|
||||||
|
|
||||||
|
install_dependencies
|
||||||
|
return false if failed?
|
||||||
|
|
||||||
|
write_paths_ini
|
||||||
|
return false if failed?
|
||||||
|
|
||||||
|
mark_application_installed
|
||||||
|
return false if failed?
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
hide_application_taskbar
|
||||||
|
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
module W3DHubLauncher
|
||||||
|
class Task
|
||||||
|
class InstallApplication < Task
|
||||||
|
def setup
|
||||||
|
end
|
||||||
|
|
||||||
|
def execute
|
||||||
|
# TODO:
|
||||||
|
# fail_fast
|
||||||
|
|
||||||
|
# fetch manifests for currently installed version
|
||||||
|
# AND the target version so we can detect files that need to be removed
|
||||||
|
# between versions
|
||||||
|
manifests_result = fetch_manifests
|
||||||
|
abort_task!(manifests_result) unless manifests_result.okay?
|
||||||
|
|
||||||
|
package_list_result = build_package_list(manifests_result)
|
||||||
|
abort_task!(package_list_result) unless package_list_result.okay?
|
||||||
|
|
||||||
|
# remove_deleted_files
|
||||||
|
|
||||||
|
verify_files
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@@ -6,9 +6,13 @@ module W3DHubLauncher
|
|||||||
PRIMARY_W3DHUB_API_ENDPOINT = "https://secure.w3dhub.com".freeze
|
PRIMARY_W3DHUB_API_ENDPOINT = "https://secure.w3dhub.com".freeze
|
||||||
ALTERNATIVE_W3DHUB_API_ENDPOINT = "https://backend.w3d.cyberarm.dev".freeze
|
ALTERNATIVE_W3DHUB_API_ENDPOINT = "https://backend.w3d.cyberarm.dev".freeze
|
||||||
|
|
||||||
|
attr_reader :applications
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@access_token = nil
|
@access_token = nil
|
||||||
|
|
||||||
|
@applications = []
|
||||||
|
|
||||||
@http_clients = {}
|
@http_clients = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -33,7 +37,7 @@ module W3DHubLauncher
|
|||||||
Sync do |task|
|
Sync do |task|
|
||||||
task.with_timeout(API_TIMEOUT) do
|
task.with_timeout(API_TIMEOUT) do
|
||||||
Async::HTTP::Internet.send(method, url, headers, body) do |response|
|
Async::HTTP::Internet.send(method, url, headers, body) do |response|
|
||||||
# pp [method, url, headers, body]
|
pp [method, url, headers, body, response]
|
||||||
if response.success?
|
if response.success?
|
||||||
result.data = response.read
|
result.data = response.read
|
||||||
else
|
else
|
||||||
@@ -104,23 +108,31 @@ module W3DHubLauncher
|
|||||||
primary_result = @access_token ? fetch("#{PRIMARY_W3DHUB_API_ENDPOINT}/apis/launcher/1/get-applications") : CyberarmEngine::Result.new(error: true)
|
primary_result = @access_token ? fetch("#{PRIMARY_W3DHUB_API_ENDPOINT}/apis/launcher/1/get-applications") : CyberarmEngine::Result.new(error: true)
|
||||||
alternate_result = fetch("#{ALTERNATIVE_W3DHUB_API_ENDPOINT}/apis/launcher/1/get-applications")
|
alternate_result = fetch("#{ALTERNATIVE_W3DHUB_API_ENDPOINT}/apis/launcher/1/get-applications")
|
||||||
|
|
||||||
|
single_source = false
|
||||||
|
|
||||||
# We've failed to retrieve data
|
# We've failed to retrieve data
|
||||||
if primary_result.error? && alternate_result.error?
|
if primary_result.error? && alternate_result.error?
|
||||||
return result
|
return result
|
||||||
# We've only gotten data back from the primary backend
|
# We've only gotten data back from the primary backend
|
||||||
elsif primary_result.okay? && alternate_result.error?
|
elsif primary_result.okay? && alternate_result.error?
|
||||||
result.data = primary_result.data
|
result.data = primary_result.data
|
||||||
return result
|
single_source = true
|
||||||
# We've only gotten data back from the alternate backend
|
# We've only gotten data back from the alternate backend
|
||||||
elsif primary_result.error? && alternate_result.okay?
|
elsif primary_result.error? && alternate_result.okay?
|
||||||
result.data = alternate_result.data
|
result.data = alternate_result.data
|
||||||
return result
|
single_source = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unless single_source
|
||||||
|
puts "FIXME: merge applications source"
|
||||||
# We've gotten data back from both backends, merge them.
|
# We've gotten data back from both backends, merge them.
|
||||||
# pp [primary_result, alternate_result]
|
# pp [primary_result, alternate_result]
|
||||||
|
|
||||||
# FIXME: Merge primary and alternate results
|
# FIXME: Merge primary and alternate results
|
||||||
|
end
|
||||||
|
|
||||||
|
@applications = JSON.parse(result.data)["applications"]&.map { |app| W3DHubLauncher::Worker::Api::Application.new(app) } || []
|
||||||
|
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -140,15 +152,12 @@ module W3DHubLauncher
|
|||||||
result = CyberarmEngine::Result.new
|
result = CyberarmEngine::Result.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_manifests()
|
def fetch_package_details(packages)
|
||||||
result = CyberarmEngine::Result.new
|
body = URI.encode_www_form("data": JSON.dump({ packages: packages }))
|
||||||
|
fetch("#{@access_token ? PRIMARY_W3DHUB_API_ENDPOINT : ALTERNATIVE_W3DHUB_API_ENDPOINT}/apis/launcher/1/get-package-details", method: :post, body: body, headers: headers(form_encoded: true))
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_package_details()
|
def download_package()
|
||||||
result = CyberarmEngine::Result.new
|
|
||||||
end
|
|
||||||
|
|
||||||
def fetch_package()
|
|
||||||
download()
|
download()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
BIN
media/default_map_preview.png
Normal file
BIN
media/default_map_preview.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
Reference in New Issue
Block a user