89 lines
2.9 KiB
GDScript
89 lines
2.9 KiB
GDScript
class_name BugbotServerAPI
|
|
extends Resource
|
|
|
|
enum BugbotServerError { OK, THREAD_NULL, THREAD_BUSY, API_RESPONSE_ERROR }
|
|
enum BugbotTagArray { VERSION, HARDWARE, OS, COMPONENT, SEVERITY, MAX }
|
|
|
|
var __bugbot_server_thread : Thread
|
|
|
|
|
|
func _init():
|
|
__bugbot_server_thread = Thread.new()
|
|
|
|
|
|
func _return_list_of_bugs(callback:Callable) -> int:
|
|
print("Insert list of ", _current_server_api(), " bugs here.")
|
|
return BugbotServerError.OK
|
|
|
|
func _prepare_form(callback:Callable) -> int:
|
|
print("Prepare ", _current_server_api(), " form here.")
|
|
return BugbotServerError.OK
|
|
|
|
func _send_form_data(callback:Callable) -> int:
|
|
print("Send ", _current_server_api(), " form data here.")
|
|
return BugbotServerError.OK
|
|
|
|
|
|
static func _create_new_server_api() -> BugbotServerAPI:
|
|
match ProjectSettings.get_setting("bugbot/reporting/bug_report_platform", -1):
|
|
BugReportPlatform.BUGZILLA: return BugbotServerAPI.new()
|
|
BugReportPlatform.GITEA: return BugbotServerGiteaAPI.new()
|
|
BugReportPlatform.JIRA: return BugbotServerAPI.new()
|
|
return BugbotServerAPI.new()
|
|
|
|
static func _hide_markers(marker_root:Node):
|
|
var markers : Array = marker_root.get_children()
|
|
for marker:Node3D in markers:
|
|
marker.queue_free()
|
|
|
|
|
|
func __connect_to_server(http_client:HTTPClient, default_server:String) -> int:
|
|
var full_server : String = ProjectSettings.get_setting("bugbot/reporting/gitea/server", default_server)
|
|
var server_and_port : PackedStringArray = full_server.rsplit(":",true,1)
|
|
var server : String = server_and_port[0]
|
|
var port : int = int(server_and_port[1])
|
|
http_client.connect_to_host(server if port > 0 else full_server, port if port > 0 else -1)
|
|
|
|
while http_client.get_status() == HTTPClient.STATUS_CONNECTING or http_client.get_status() == HTTPClient.STATUS_RESOLVING:
|
|
http_client.poll()
|
|
return http_client.get_status()
|
|
|
|
func __get_http_client_chunk_response(http_client:HTTPClient) -> String:
|
|
if http_client.has_response():
|
|
var response_body : PackedByteArray = PackedByteArray()
|
|
while http_client.get_status() == HTTPClient.STATUS_BODY:
|
|
http_client.poll()
|
|
var chunk : PackedByteArray = http_client.read_response_body_chunk()
|
|
if chunk.size() > 0:
|
|
response_body = response_body + chunk
|
|
return response_body.get_string_from_utf8()
|
|
return ""
|
|
|
|
func __start_thread_with_callback(thread_function:Callable) -> int:
|
|
if not __bugbot_server_thread:
|
|
printerr("Server thread is null.")
|
|
return BugbotServerError.THREAD_NULL
|
|
if __bugbot_server_thread.is_started():
|
|
printerr("Server thread is currently busy.")
|
|
return BugbotServerError.THREAD_BUSY;
|
|
__bugbot_server_thread = Thread.new()
|
|
__bugbot_server_thread.start(thread_function)
|
|
return BugbotServerError.OK
|
|
|
|
func __validate_server_response(_response:Variant) -> int:
|
|
return Error.OK
|
|
|
|
|
|
func _current_server_api() -> String:
|
|
return ""
|
|
|
|
func __build_url_string(_api_suffix:String) -> String:
|
|
return ""
|
|
|
|
func __create_header_data(content_length:int = -1) -> Array:
|
|
return []
|
|
|
|
|
|
func __return_list_of_bugs_thread(callback:Callable) -> void:
|
|
pass
|