7 Commits

12 changed files with 274 additions and 128 deletions

View File

@@ -4,6 +4,7 @@ source "https://gem.coop"
gem "base64" gem "base64"
gem "rexml" gem "rexml"
gem "logger" gem "logger"
gem "json"
# "game" library gem # "game" library gem
gem "cyberarm_engine" gem "cyberarm_engine"

View File

@@ -7,7 +7,7 @@ GEM
io-event (~> 1.11) io-event (~> 1.11)
metrics (~> 0.12) metrics (~> 0.12)
traces (~> 0.18) traces (~> 0.18)
async-http (0.95.0) async-http (0.95.1)
async (>= 2.10.2) async (>= 2.10.2)
async-pool (~> 0.11) async-pool (~> 0.11)
io-endpoint (~> 0.14) io-endpoint (~> 0.14)
@@ -20,13 +20,13 @@ GEM
traces (~> 0.10) traces (~> 0.10)
async-pool (0.11.2) async-pool (0.11.2)
async (>= 2.0) async (>= 2.0)
async-websocket (0.30.0) async-websocket (0.30.1)
async-http (~> 0.76) async-http (~> 0.76)
protocol-http (~> 0.34) protocol-http (~> 0.34)
protocol-rack (~> 0.7) protocol-rack (~> 0.7)
protocol-websocket (~> 0.17) protocol-websocket (~> 0.17)
base64 (0.3.0) base64 (0.3.0)
console (1.34.3) console (1.36.0)
fiber-annotation fiber-annotation
fiber-local (~> 1.1) fiber-local (~> 1.1)
json json
@@ -41,10 +41,10 @@ GEM
fiber-storage (1.0.1) fiber-storage (1.0.1)
gosu (1.4.6) gosu (1.4.6)
io-endpoint (0.17.2) io-endpoint (0.17.2)
io-event (1.15.1) io-event (1.16.2)
io-stream (0.11.1) io-stream (0.13.1)
ircparser (1.0.0) ircparser (1.0.0)
json (2.19.4) json (2.19.9)
logger (1.7.0) logger (1.7.0)
metrics (0.15.0) metrics (0.15.0)
protocol-hpack (1.5.1) protocol-hpack (1.5.1)
@@ -59,12 +59,12 @@ GEM
protocol-http (~> 0.58) protocol-http (~> 0.58)
rack (>= 1.0) rack (>= 1.0)
protocol-url (0.4.0) protocol-url (0.4.0)
protocol-websocket (0.21.0) protocol-websocket (0.21.1)
protocol-http (~> 0.2) protocol-http (~> 0.2)
rack (3.2.6) rack (3.2.6)
rake (13.4.2) rake (13.4.2)
rexml (3.4.4) rexml (3.4.4)
rubyzip (3.2.2) rubyzip (3.4.0)
sdl2-bindings (0.2.3) sdl2-bindings (0.2.3)
ffi (~> 1.15) ffi (~> 1.15)
traces (0.18.2) traces (0.18.2)
@@ -80,6 +80,7 @@ DEPENDENCIES
cyberarm_engine cyberarm_engine
digest-crc digest-crc
ircparser ircparser
json
logger logger
rexml rexml
rubyzip rubyzip
@@ -87,11 +88,11 @@ DEPENDENCIES
CHECKSUMS CHECKSUMS
async (2.39.0) sha256=df18730073f2bbb45788077dfa20cb365ecc1b9453969f44de6796b5191a00aa async (2.39.0) sha256=df18730073f2bbb45788077dfa20cb365ecc1b9453969f44de6796b5191a00aa
async-http (0.95.0) sha256=08128cab255a48e41d1e856bfa9cbda001f1c57c88bafa3fa3a545ad795754aa async-http (0.95.1) sha256=0c3dd458c204c06d5c4b20b01bbec4794a1203db627fb2ce536e1799ec14786c
async-pool (0.11.2) sha256=0a43a17b02b04d9c451b7d12fafa9a50e55dc6dd00d4369aca00433f16a7e3ed async-pool (0.11.2) sha256=0a43a17b02b04d9c451b7d12fafa9a50e55dc6dd00d4369aca00433f16a7e3ed
async-websocket (0.30.0) sha256=55739954528ad8f87f7792d0452e1268d1ef2aa5b3719f79400a05a1a6202cdf async-websocket (0.30.1) sha256=54bb8a8f184e4aa64434c7a78ecc55850a67a3d1dcd02e3ae787376e2c673936
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
console (1.34.3) sha256=869fbd74697efc4c606f102d2812b0b008e4e7fd738a91c591e8577140ec0dcc console (1.36.0) sha256=45599ea906cf80a73d8941f03abf873fe66a6a954e0bac5bc1c01e2cdc406f07
cyberarm_engine (0.25.1) sha256=6f851a2ed0a32bdd25fc619172b546a8e26eefeb13a62c509f226337170d0efe cyberarm_engine (0.25.1) sha256=6f851a2ed0a32bdd25fc619172b546a8e26eefeb13a62c509f226337170d0efe
digest-crc (0.7.0) sha256=64adc23a26a241044cbe6732477ca1b3c281d79e2240bcff275a37a5a0d78c07 digest-crc (0.7.0) sha256=64adc23a26a241044cbe6732477ca1b3c281d79e2240bcff275a37a5a0d78c07
ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d
@@ -100,10 +101,10 @@ CHECKSUMS
fiber-storage (1.0.1) sha256=f48e5b6d8b0be96dac486332b55cee82240057065dc761c1ea692b2e719240e1 fiber-storage (1.0.1) sha256=f48e5b6d8b0be96dac486332b55cee82240057065dc761c1ea692b2e719240e1
gosu (1.4.6) sha256=80c7fa48cf61f4960ef067fdd1c000d98b4adc8e11faeaa486543d00908a5c15 gosu (1.4.6) sha256=80c7fa48cf61f4960ef067fdd1c000d98b4adc8e11faeaa486543d00908a5c15
io-endpoint (0.17.2) sha256=3feaf766c116b35839c11fac68b6aaadc47887bb488902a57bf8e1d288fb3338 io-endpoint (0.17.2) sha256=3feaf766c116b35839c11fac68b6aaadc47887bb488902a57bf8e1d288fb3338
io-event (1.15.1) sha256=c644cdcf48254015d63f558bf4492f35471f5bb204a42180ea49752be59b30cc io-event (1.16.2) sha256=9f9cb0a96ea5c3850a672606c65f27bc96d7621399ef6196acbfe2be0cd1279c
io-stream (0.11.1) sha256=fa5f551fcff99581c1757b9d1cee2c37b124f07d2ca4f40b756a05ab9bd21b87 io-stream (0.13.1) sha256=570d7c4dfb0fbd767480b4a222048a2be6d9b78febc1ec68258d0e0a4cde20de
ircparser (1.0.0) sha256=0d4598f691172e2ad078207c50ba62c0d3428ae841836b0a682e6cd01d62878d ircparser (1.0.0) sha256=0d4598f691172e2ad078207c50ba62c0d3428ae841836b0a682e6cd01d62878d
json (2.19.4) sha256=670a7d333fb3b18ca5b29cb255eb7bef099e40d88c02c80bd42a3f30fe5239ac json (2.19.9) sha256=9b9025b7cdddafa38d316eca0b2358488e42d417045c1b90d216a9fefe46b79a
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203 logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
metrics (0.15.0) sha256=61ded5bac95118e995b1bc9ed4a5f19bc9814928a312a85b200abbdac9039072 metrics (0.15.0) sha256=61ded5bac95118e995b1bc9ed4a5f19bc9814928a312a85b200abbdac9039072
protocol-hpack (1.5.1) sha256=6feca238b8078da1cd295677d6f306c6001af92d75fe0643d33e6956cbc3ad91 protocol-hpack (1.5.1) sha256=6feca238b8078da1cd295677d6f306c6001af92d75fe0643d33e6956cbc3ad91
@@ -112,11 +113,11 @@ CHECKSUMS
protocol-http2 (0.26.0) sha256=bac89cd78082b241ccd0cf7246f5160e4bb0c9c975fb4bf7deef5f88cc317486 protocol-http2 (0.26.0) sha256=bac89cd78082b241ccd0cf7246f5160e4bb0c9c975fb4bf7deef5f88cc317486
protocol-rack (0.22.1) sha256=1185d245927ef9849a603700d6991ca353bc89724fbf98efa4a4333ed62a9fc3 protocol-rack (0.22.1) sha256=1185d245927ef9849a603700d6991ca353bc89724fbf98efa4a4333ed62a9fc3
protocol-url (0.4.0) sha256=64d4c03b6b51ad815ac6fdaf77a1d91e5baf9220d26becb846c5459dacdea9e1 protocol-url (0.4.0) sha256=64d4c03b6b51ad815ac6fdaf77a1d91e5baf9220d26becb846c5459dacdea9e1
protocol-websocket (0.21.0) sha256=6e2ccc2adf7de1895b0f6548fdfacf5f9735c0d4deb56cd2bac1ae38a1952e93 protocol-websocket (0.21.1) sha256=34325e4325697f0956877e67784bcc838cfd51ebbf4f8e9e5201be292041ee61
rack (3.2.6) sha256=5ed78e1f73b2e25679bec7d45ee2d4483cc4146eb1be0264fc4d94cb5ef212c2 rack (3.2.6) sha256=5ed78e1f73b2e25679bec7d45ee2d4483cc4146eb1be0264fc4d94cb5ef212c2
rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701 rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
rexml (3.4.4) sha256=19e0a2c3425dfbf2d4fc1189747bdb2f849b6c5e74180401b15734bc97b5d142 rexml (3.4.4) sha256=19e0a2c3425dfbf2d4fc1189747bdb2f849b6c5e74180401b15734bc97b5d142
rubyzip (3.2.2) sha256=c0ed99385f0625415c8f05bcae33fe649ed2952894a95ff8b08f26ca57ea5b3c rubyzip (3.4.0) sha256=6de39bc9eba302b635a476d16c9e16b0872ad24517c2f98f2b3a7ea23caff57b
sdl2-bindings (0.2.3) sha256=878c0755a4bea1aed0fa85c01596effd1c2b7d1878141ceec5bef808038bd309 sdl2-bindings (0.2.3) sha256=878c0755a4bea1aed0fa85c01596effd1c2b7d1878141ceec5bef808038bd309
traces (0.18.2) sha256=80f1649cb4daace1d7174b81f3b3b7427af0b93047759ba349960cb8f315e214 traces (0.18.2) sha256=80f1649cb4daace1d7174b81f3b3b7427af0b93047759ba349960cb8f315e214

View File

@@ -1,5 +1,11 @@
module W3DHubLauncher module W3DHubLauncher
DIRECTORY_NAME = "w3d-hub-linux-launcher".freeze
ROOT_PATH = Dir.pwd ROOT_PATH = Dir.pwd
CONFIG_PATH = "#{Dir.home}/.config/#{DIRECTORY_NAME}".freeze
CACHE_PATH = "#{Dir.home}/.cache/#{DIRECTORY_NAME}".freeze
DEFAULT_PACKAGE_CACHE_PATH = "#{CACHE_PATH}/packages".freeze
DEFAULT_APPLICATIONS_PATH = "#{Dir.home}/.local/share/#{DIRECTORY_NAME}/applications".freeze
USER_AGENT = "#{NAME} v#{VERSION}".freeze USER_AGENT = "#{NAME} v#{VERSION}".freeze
end end

38
lib/dialogs/downloads.rb Normal file
View File

@@ -0,0 +1,38 @@
module W3DHubLauncher
class Dialog
class Downloads < W3DHubLauncher::Dialog
def setup
super
stack(width: 1.0, max_width: 600, height: 1.0, max_height: 600, h_align: :center, v_align: :center, background_nine_slice: NINE_SLICE_ROUNDED, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: ALPHA_BLACK) do
flow(width: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_TOP, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: ALPHA_GRAY) do
banner "Downloads", width: 1.0, text_align: :center
end
stack(width: 1.0, fill: true, scroll: true, padding_left: PADDING, padding_right: PADDING) do
50.times do
stack(width: 1.0, margin_top: HALF_PADDING, margin_bottom: HALF_PADDING) do
flow(width: 1.0) do
para "PACKAGE_NAME.mix"
flow(fill: true)
para ["Downloading...", "Pending...", "Done.", "Patching...", "Unpacking..."].sample
end
progress(width: 1.0, fraction: rand)
end
end
end
flow(width: 1.0, padding: PADDING, background_nine_slice: NINE_SLICE_ROUNDED_BOTTOM, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: ALPHA_GRAY) do
flow(fill: true)
button "Close" do
pop_state
end
flow(fill: true)
end
end
end
end
end
end

View File

@@ -15,23 +15,16 @@ module W3DHubLauncher
title "Initial Setup" title "Initial Setup"
caption "Please confirm launcher's default settings and make any desired tweaks.", font: FONT_REGULAR caption "Please confirm launcher's default settings and make any desired tweaks.", font: FONT_REGULAR
flow(width: 1.0, height: 40, margin_top: PADDING) do
tagline "Launcher data directory", height: 1.0, text_v_align: :center
edit_line format("%s/.local/share/W3D Hub", Dir.home), fill: true
button "Browse..."
end
inscription "Location where the launcher stores it's configuration files and cache interface data."
flow(width: 1.0, height: 40, margin_top: HALF_PADDING) do flow(width: 1.0, height: 40, margin_top: HALF_PADDING) do
tagline "Launcher package cache directory", height: 1.0, text_v_align: :center tagline "Launcher package cache directory", height: 1.0, text_v_align: :center
edit_line format("%s/.local/share/W3D Hub/package-cache", Dir.home), fill: true edit_line DEFAULT_PACKAGE_CACHE_PATH, fill: true
button "Browse..." button "Browse..."
end end
inscription "Location where the launcher will download application packages." inscription "Location where the launcher will download application packages."
flow(width: 1.0, height: 40, margin_top: HALF_PADDING) do flow(width: 1.0, height: 40, margin_top: HALF_PADDING) do
tagline "Application installation directory", height: 1.0, text_v_align: :center tagline "Application installation directory", height: 1.0, text_v_align: :center
edit_line format("%s/.local/share/W3D Hub/applications", Dir.home), fill: true edit_line DEFAULT_APPLICATIONS_PATH, fill: true
button "Browse..." button "Browse..."
end end
inscription "Location where the launcher will install new applications." inscription "Location where the launcher will install new applications."
@@ -53,8 +46,18 @@ module W3DHubLauncher
flow(width: 1.0, padding_top: PADDING) do flow(width: 1.0, padding_top: PADDING) do
flow(fill: true) flow(fill: true)
button "Accept" do button "Accept" do |btn|
btn.enabled = false
Worker::Api.update_settings({}) do |result|
if result.okay?
page(Page::Boot::StartUp) page(Page::Boot::StartUp)
else
btn.enabled = true
end
puts "NOW!"
end
end end
end end
end end

View File

@@ -7,9 +7,9 @@ module W3DHubLauncher
# root container - background image # root container - background image
stack(width: 1.0, height: 1.0, background_image: safe_get_image("/run/media/cyberarm/Storage/W3DHub/Launcher/package-cache/games/apb/background.png.package"), background_image_mode: :fill) do stack(width: 1.0, height: 1.0, background_image: safe_get_image("/run/media/cyberarm/Storage/W3DHub/Launcher/package-cache/games/apb/background.png.package"), background_image_mode: :fill) do
# root container - background image tint # root container - background image tint
flow(width: 1.0, height: 1.0, background: ALPHA_BLACK) do stack(width: 1.0, height: 1.0, background: ALPHA_BLACK) do
# content container # content container
stack(fill: true, height: 1.0, margin: PADDING, margin_right: LARGE_PADDING) do stack(width: 1.0, fill: true, margin: PADDING) do
# header bar container # header bar container
flow(width: 1.0, height: 80, margin_bottom: PADDING) do |c| flow(width: 1.0, height: 80, margin_bottom: PADDING) do |c|
# logo + menu button # logo + menu button
@@ -25,28 +25,33 @@ module W3DHubLauncher
end.show end.show
end end
# navigation bar container
stack(fill: true, height: 1.0) do stack(fill: true, height: 1.0) do
stack(fill: true) # stack(fill: true)
# navigation container
flow(width: 1.0) do flow(width: 1.0) do
link("GAMES", text_v_align: :center, font: FONT_BLACK, margin_left: PADDING) { page(Page::Games) } link("GAMES", text_v_align: :center, font: FONT_BLACK, margin_left: PADDING) { page(Page::Games) }
link("SERVERS", text_v_align: :center, font: FONT_BLACK, margin_left: PADDING) { page(Page::ServerBrowser) } link("SERVERS", text_v_align: :center, font: FONT_BLACK, margin_left: PADDING) { page(Page::ServerBrowser) }
stack(fill: true) stack(fill: true)
image safe_get_image("#{ROOT_PATH}/media/icons/import.png"), height: 40, color: 0xff_bbbbbb, tip: "Downloads" image safe_get_image("#{ROOT_PATH}/media/icons/import.png"), height: 40, color: 0xff_bbbbbb, tip: "Downloads" do |img|
dialog(Dialog::Downloads)
end
image safe_get_image("#{ROOT_PATH}/media/icons/information.png"), height: 40, color: 0xff_bbbbbb, tip: "Notifications" image safe_get_image("#{ROOT_PATH}/media/icons/information.png"), height: 40, color: 0xff_bbbbbb, tip: "Notifications"
end end
# application task status bar container
stack(width: 1.0, fill: true, margin_left: PADDING) do
flow(width: 1.0) do
para "Updating Red Alert: A Path Beyond (Release)"
stack(fill: true) stack(fill: true)
para "Fetching manifests..."
end
progress(width: 1.0, fraction: 0.75)
end end
end end
# page content container
@page_host = stack(width: 1.0, fill: true) do
end
end
# battleview/friends container
stack(width: 300, height: 1.0, margin: PADDING, margin_left: 0) do
# self account container # self account container
flow(width: 1.0, height: 80) do flow(width: 300, height: 80, margin_left: LARGE_PADDING) do
# self avatar container # self avatar container
stack(width: 80, height: 1.0, background_image: rounded_avatar(safe_get_image("#{ROOT_PATH}/media/default.png"))) do stack(width: 80, height: 1.0, background_image: rounded_avatar(safe_get_image("#{ROOT_PATH}/media/default.png"))) do
# self online state container # self online state container
@@ -70,9 +75,18 @@ module W3DHubLauncher
flow(fill: true) flow(fill: true)
end end
end end
end
# layout container
flow(width: 1.0, fill: true) do
# page host container
@page_host = stack(fill: true, height: 1.0) do
end
# battleview/friends container
@battleview_container = stack(width: 300, height: 1.0, margin_left: LARGE_PADDING, visible: true) do
# friend management container # friend management container
flow(width: 1.0, height: 60, margin_top: PADDING) do flow(width: 1.0, height: 60) do
flow(width: 1.0, v_align: :center) do flow(width: 1.0, v_align: :center) do
button safe_get_image("#{ROOT_PATH}/media/icons/singleplayer.png"), image_height: 1.0 button safe_get_image("#{ROOT_PATH}/media/icons/singleplayer.png"), image_height: 1.0
button safe_get_image("#{ROOT_PATH}/media/icons/gear.png"), image_height: 1.0, margin_left: HALF_PADDING button safe_get_image("#{ROOT_PATH}/media/icons/gear.png"), image_height: 1.0, margin_left: HALF_PADDING
@@ -109,9 +123,17 @@ module W3DHubLauncher
end end
end end
end end
end
end
page(Page::Games) page(Page::Games)
end end
def button_up(id)
super
@battleview_container.toggle if id == Gosu::KB_F8
end
end end
end end
end end

View File

@@ -4,12 +4,18 @@ module W3DHubLauncher
self.show_cursor = true self.show_cursor = true
self.caption = format("%s | v%s (%s)", NAME, VERSION, VERSION_NAME) # "Cyberarm's W3D Hub Linux Launcher | v2.0.0 alpha" self.caption = format("%s | v%s (%s)", NAME, VERSION, VERSION_NAME) # "Cyberarm's W3D Hub Linux Launcher | v2.0.0 alpha"
# push_state(States::Boot) push_state(States::Boot)
push_state(States::Interface) # push_state(States::Interface)
end end
def needs_redraw? def needs_redraw?
states.any?(&:needs_repaint?) states.any?(&:needs_repaint?)
end end
def update
super
sleep 0.001
end
end end
end end

View File

@@ -6,6 +6,8 @@ module W3DHubLauncher
@threads = [] @threads = []
@requests = [] @requests = []
@settings = # Settings.new
# next available request_id to assign incoming requests # next available request_id to assign incoming requests
@request_id = 0 @request_id = 0
@@ -26,17 +28,12 @@ module W3DHubLauncher
query = Ractor.receive query = Ractor.receive
pp query pp query
case query.type if respond_to?(query.type)
when Request::FETCH_URL
when Request::DOWNLOAD_URL
when Request::W3DHUB_API_CALL
Async do Async do
result = @w3dhub_api.send(query.data[:call], *(query.data[:arguments] || [])) send(query.type, query)
response = Response.new(result.okay? ? Request::STATUS_COMPLETE : Request::STATUS_ERROR, query.request_id, result)
Ractor.main.send(response)
end end
else else
raise "UNKNOWN REQUEST" raise "UNKNOWN REQUEST: #{query}"
end end
end end
end end
@@ -46,5 +43,48 @@ module W3DHubLauncher
def backend_websocket def backend_websocket
end end
#
# ------------ query / request handlers ------------
#
def fetch_url(query)
end
def download_url(query)
end
def w3dhub_api_call(query)
result = @w3dhub_api.send(query.data[:call], *(query.data[:arguments] || []))
pp result
response = Response.new(result.okay? ? Request::STATUS_COMPLETE : Request::STATUS_ERROR, query.request_id, result)
Ractor.main.send(response)
end
def update_settings(query)
result = CyberarmEngine::Result.new
FileUtils.mkdir_p(W3DHubLauncher::CONFIG_PATH) # FIXME: FAILABLE!
File.write("#{W3DHubLauncher::CONFIG_PATH}/settings.json", query.data) # FIXME: FAILABLE!
result.data = query.data
response = Response.new(result.okay? ? Request::STATUS_COMPLETE : Request::STATUS_ERROR, query.request_id, result)
Ractor.main.send(response)
end
def install_application(query)
end
def update_application(query)
end
def repair_application(query)
end
def move_application(query)
end
def uninstall_application(query)
end
end end
end end

View File

@@ -3,76 +3,77 @@
module W3DHubLauncher module W3DHubLauncher
class Worker class Worker
class Api class Api
Request = Data.define(:coming_soon)
def initialize
@requests = []
end
# downloads requested resource, returns raw string # downloads requested resource, returns raw string
def fetch_url def self.fetch_url
end end
# downloads requested resource, periodically reporting progress until completion, returning path for file on disk # downloads requested resource, periodically reporting progress until completion, returning path for file on disk
def download_url def self.download_url
end end
# returns user account data # returns user account data
# #
# automatically handles signing in / refreshing token (DOES NOT remove account data if failed to refresh token due to network timeout) # automatically handles signing in / refreshing token (DOES NOT remove account data if failed to refresh token due to network timeout)
def account def self.account
end end
# returns launcher settings # returns launcher settings
def settings def self.settings
end end
# write updated launcher settings # write updated launcher settings
def update_settings def self.update_settings(settings, &block)
Worker::Request.new(:update_settings, settings.to_json, &block)
end end
# returns list of available applications # returns list of available applications
# #
# if updated list is requested, return cached version immediately and then the updated list later. # if updated list is requested, return cached version immediately and then the updated list later.
def applications def self.applications
end end
# returns current list of servers as reported from GSH / cache # returns current list of servers as reported from GSH / cache
def servers def self.servers
end end
# returns news for application # returns news for application
def news def self.news(category = "launcher-home", &block)
Worker::Request.new(:news, category, &block)
end
# returns news for application
def self.events(app_id, &block)
Worker::Request.new(:events, app_id, &block)
end end
# request installation of application # request installation of application
# #
# periodically reports progress until completion # periodically reports progress until completion
def install_application def self.install_application(app_id, channel_id)
end end
# request update of application # request update of application
# #
# periodically reports progress until completion # periodically reports progress until completion
def update_application def self.update_application(app_id, channel_id)
end end
# request repair of application # request repair of application
# #
# periodically reports progress until completion # periodically reports progress until completion
def repair_application def self.repair_application(app_id, channel_id)
end end
# request relocation of application # request relocation of application
# #
# periodically reports progress until completion # periodically reports progress until completion
def move_application def self.move_application(app_id, channel_id)
end end
# request removal of application # request removal of application
# #
# periodically reports progress until completion # periodically reports progress until completion
def uninstall_application def self.uninstall_application(app_id, channel_id)
end end
end end
end end

View File

@@ -6,6 +6,8 @@ module W3DHubLauncher
FETCH_URL = 0 FETCH_URL = 0
DOWNLOAD_URL = 1 DOWNLOAD_URL = 1
W3DHUB_API_CALL = 10 W3DHUB_API_CALL = 10
LAUNCHER_SETTINGS = 1000
LAUNCHER_UPDATE_SETTINGS = 1001
STATUS_ERROR = -1 # request has failed STATUS_ERROR = -1 # request has failed
STATUS_PENDING = 0 # request has not yet started STATUS_PENDING = 0 # request has not yet started
@@ -53,9 +55,8 @@ module W3DHubLauncher
pp [event, data] pp [event, data]
case event case event
when STATUS_COMPLETE when STATUS_ERROR, STATUS_COMPLETE
Request.requests.delete(self) @callback&.call(data)
when STATUS_ERROR
Request.requests.delete(self) Request.requests.delete(self)
end end
end end

View File

@@ -8,9 +8,22 @@ module W3DHubLauncher
def initialize def initialize
@access_token = nil @access_token = nil
@http_clients = {}
end end
def headers(form_encoded: false) def headers(form_encoded: false)
array = [
["user-agent", W3DHubLauncher::USER_AGENT],
["accept", "application/json"],
]
array << ["content-type", "application/x-www-form-urlencoded"] if form_encoded
array << ["authorization", "Bearer #{@access_token}"] if @access_token
pp array
array
end end
# return raw response to requester # return raw response to requester
@@ -20,13 +33,19 @@ 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|
if response.success?
result.data = response.read result.data = response.read
else
result.error = true
end
end
rescue StandardError => e rescue StandardError => e
result.error = e result.error = e
end rescue Async::TimeoutError => e
rescue Async::TimeoutError
result.error = e result.error = e
end end
result
end end
result result
@@ -80,6 +99,13 @@ module W3DHubLauncher
def fetch_applications def fetch_applications
result = CyberarmEngine::Result.new result = CyberarmEngine::Result.new
primary_result = fetch("#{PRIMARY_W3DHUB_API_ENDPOINT}/apis/launcher/1/get-applications")
alternate_result = fetch("#{ALTERNATIVE_W3DHUB_API_ENDPOINT}/apis/launcher/1/get-applications")
pp [primary_result, alternate_result]
# FIXME: Merge primary and alternate results
result
end end
def fetch_news() def fetch_news()

View File

@@ -28,6 +28,7 @@ require_relative "lib/pages/boot/terms"
require_relative "lib/pages/boot/initial_setup" require_relative "lib/pages/boot/initial_setup"
require_relative "lib/pages/boot/start_up" require_relative "lib/pages/boot/start_up"
require_relative "lib/dialogs/about" require_relative "lib/dialogs/about"
require_relative "lib/dialogs/downloads"
require_relative "lib/states/boot" require_relative "lib/states/boot"
require_relative "lib/states/interface" require_relative "lib/states/interface"
require_relative "lib/window" require_relative "lib/window"
@@ -63,11 +64,11 @@ Thread.new do
end end
end end
10.times do # 10.times do
W3DHubLauncher::Worker::Request.new(W3DHubLauncher::Worker::Request::W3DHUB_API_CALL, { call: :fetch_applications }) do |result| W3DHubLauncher::Worker::Request.new(:w3dhub_api_call, { call: :fetch_applications }) do |result|
pp result pp result
end end
end # end
window = W3DHubLauncher::Window.new(width: 1280, height: 800, resizable: true) window = W3DHubLauncher::Window.new(width: 1280, height: 800, resizable: true)
# window = W3DHubLauncher::Window.new(width: 1920, height: 1080, resizable: true) # window = W3DHubLauncher::Window.new(width: 1920, height: 1080, resizable: true)