mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-07-20 19:44:46 +01:00
TGUI NTOS - Total Conversion
This commit is contained in:
+90
-98
@@ -8,29 +8,34 @@
|
||||
size = 12
|
||||
requires_ntnet = 1
|
||||
available_on_ntnet = 1
|
||||
nanomodule_path = /datum/nano_module/email_administration
|
||||
tgui_id = "NtosEmailAdministration"
|
||||
required_access = access_network
|
||||
|
||||
|
||||
|
||||
|
||||
/datum/nano_module/email_administration/
|
||||
name = "Email Client"
|
||||
var/datum/computer_file/data/email_account/current_account = null
|
||||
var/datum/computer_file/data/email_message/current_message = null
|
||||
var/error = ""
|
||||
|
||||
/datum/nano_module/email_administration/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/datum/topic_state/state = default_state)
|
||||
var/list/data = host.initial_data()
|
||||
/datum/computer_file/program/email_administration/tgui_data(mob/user, datum/tgui/ui, datum/tgui_state/state)
|
||||
var/list/data = get_header_data()
|
||||
|
||||
if(error)
|
||||
data["error"] = error
|
||||
else if(istype(current_message))
|
||||
data["msg_title"] = current_message.title
|
||||
data["msg_body"] = pencode2html(current_message.stored_data)
|
||||
data["msg_timestamp"] = current_message.timestamp
|
||||
data["msg_source"] = current_message.source
|
||||
else if(istype(current_account))
|
||||
data["error"] = error
|
||||
|
||||
data["cur_title"] = null
|
||||
data["cur_body"] = null
|
||||
data["cur_timestamp"] = null
|
||||
data["cur_source"] = null
|
||||
|
||||
if(istype(current_message))
|
||||
data["cur_title"] = current_message.title
|
||||
data["cur_body"] = pencode2html(current_message.stored_data)
|
||||
data["cur_timestamp"] = current_message.timestamp
|
||||
data["cur_source"] = current_message.source
|
||||
|
||||
data["current_account"] = null
|
||||
data["cur_suspended"] = null
|
||||
data["messages"] = null
|
||||
|
||||
if(istype(current_account))
|
||||
data["current_account"] = current_account.login
|
||||
data["cur_suspended"] = current_account.suspended
|
||||
var/list/all_messages = list()
|
||||
@@ -42,103 +47,90 @@
|
||||
"uid" = message.uid
|
||||
)))
|
||||
data["messages"] = all_messages
|
||||
data["messagecount"] = all_messages.len
|
||||
else
|
||||
var/list/all_accounts = list()
|
||||
for(var/datum/computer_file/data/email_account/account in ntnet_global.email_accounts)
|
||||
if(!account.can_login)
|
||||
continue
|
||||
all_accounts.Add(list(list(
|
||||
"login" = account.login,
|
||||
"uid" = account.uid
|
||||
)))
|
||||
data["accounts"] = all_accounts
|
||||
data["accountcount"] = all_accounts.len
|
||||
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "email_administration.tmpl", "Email Administration Utility", 600, 450, state = state)
|
||||
if(host.update_layout())
|
||||
ui.auto_update_layout = 1
|
||||
ui.set_auto_update(1)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
var/list/all_accounts = list()
|
||||
for(var/datum/computer_file/data/email_account/account in ntnet_global.email_accounts)
|
||||
if(!account.can_login)
|
||||
continue
|
||||
all_accounts.Add(list(list(
|
||||
"login" = account.login,
|
||||
"uid" = account.uid
|
||||
)))
|
||||
data["accounts"] = all_accounts
|
||||
|
||||
return data
|
||||
|
||||
/datum/nano_module/email_administration/Topic(href, href_list)
|
||||
/datum/computer_file/program/email_administration/tgui_act(action, list/params, datum/tgui/ui)
|
||||
if(..())
|
||||
return 1
|
||||
|
||||
var/mob/user = usr
|
||||
if(!istype(user))
|
||||
return 1
|
||||
return TRUE
|
||||
|
||||
// High security - can only be operated when the user has an ID with access on them.
|
||||
var/obj/item/weapon/card/id/I = user.GetIdCard()
|
||||
var/obj/item/weapon/card/id/I = usr.GetIdCard()
|
||||
if(!istype(I) || !(access_network in I.access))
|
||||
return 1
|
||||
return TRUE
|
||||
|
||||
if(href_list["back"])
|
||||
if(error)
|
||||
error = ""
|
||||
else if(current_message)
|
||||
current_message = null
|
||||
else
|
||||
current_account = null
|
||||
return 1
|
||||
switch(action)
|
||||
if("back")
|
||||
if(error)
|
||||
error = ""
|
||||
else if(current_message)
|
||||
current_message = null
|
||||
else
|
||||
current_account = null
|
||||
return TRUE
|
||||
|
||||
if(href_list["ban"])
|
||||
if(!current_account)
|
||||
return 1
|
||||
if("ban")
|
||||
if(!current_account)
|
||||
return TRUE
|
||||
|
||||
current_account.suspended = !current_account.suspended
|
||||
ntnet_global.add_log_with_ids_check("EMAIL LOG: SA-EDIT Account [current_account.login] has been [current_account.suspended ? "" : "un" ]suspended by SA [I.registered_name] ([I.assignment]).")
|
||||
error = "Account [current_account.login] has been [current_account.suspended ? "" : "un" ]suspended."
|
||||
return 1
|
||||
current_account.suspended = !current_account.suspended
|
||||
ntnet_global.add_log_with_ids_check("EMAIL LOG: SA-EDIT Account [current_account.login] has been [current_account.suspended ? "" : "un" ]suspended by SA [I.registered_name] ([I.assignment]).")
|
||||
error = "Account [current_account.login] has been [current_account.suspended ? "" : "un" ]suspended."
|
||||
return TRUE
|
||||
|
||||
if(href_list["changepass"])
|
||||
if(!current_account)
|
||||
return 1
|
||||
if("changepass")
|
||||
if(!current_account)
|
||||
return TRUE
|
||||
|
||||
var/newpass = sanitize(input(user,"Enter new password for account [current_account.login]", "Password"), 100)
|
||||
if(!newpass)
|
||||
return 1
|
||||
current_account.password = newpass
|
||||
ntnet_global.add_log_with_ids_check("EMAIL LOG: SA-EDIT Password for account [current_account.login] has been changed by SA [I.registered_name] ([I.assignment]).")
|
||||
return 1
|
||||
var/newpass = sanitize(input(usr,"Enter new password for account [current_account.login]", "Password"), 100)
|
||||
if(!newpass)
|
||||
return TRUE
|
||||
current_account.password = newpass
|
||||
ntnet_global.add_log_with_ids_check("EMAIL LOG: SA-EDIT Password for account [current_account.login] has been changed by SA [I.registered_name] ([I.assignment]).")
|
||||
return TRUE
|
||||
|
||||
if(href_list["viewmail"])
|
||||
if(!current_account)
|
||||
return 1
|
||||
if("viewmail")
|
||||
if(!current_account)
|
||||
return TRUE
|
||||
|
||||
for(var/datum/computer_file/data/email_message/received_message in (current_account.inbox | current_account.spam | current_account.deleted))
|
||||
if(received_message.uid == text2num(href_list["viewmail"]))
|
||||
current_message = received_message
|
||||
break
|
||||
return 1
|
||||
for(var/datum/computer_file/data/email_message/received_message in (current_account.inbox | current_account.spam | current_account.deleted))
|
||||
if(received_message.uid == text2num(params["viewmail"]))
|
||||
current_message = received_message
|
||||
break
|
||||
return TRUE
|
||||
|
||||
if(href_list["viewaccount"])
|
||||
for(var/datum/computer_file/data/email_account/email_account in ntnet_global.email_accounts)
|
||||
if(email_account.uid == text2num(href_list["viewaccount"]))
|
||||
current_account = email_account
|
||||
break
|
||||
return 1
|
||||
if("viewaccount")
|
||||
for(var/datum/computer_file/data/email_account/email_account in ntnet_global.email_accounts)
|
||||
if(email_account.uid == text2num(params["viewaccount"]))
|
||||
current_account = email_account
|
||||
break
|
||||
return TRUE
|
||||
|
||||
if(href_list["newaccount"])
|
||||
var/newdomain = sanitize(input(user,"Pick domain:", "Domain name") as null|anything in using_map.usable_email_tlds)
|
||||
if(!newdomain)
|
||||
return 1
|
||||
var/newlogin = sanitize(input(user,"Pick account name (@[newdomain]):", "Account name"), 100)
|
||||
if(!newlogin)
|
||||
return 1
|
||||
if("newaccount")
|
||||
var/newdomain = sanitize(input(usr,"Pick domain:", "Domain name") as null|anything in using_map.usable_email_tlds)
|
||||
if(!newdomain)
|
||||
return TRUE
|
||||
var/newlogin = sanitize(input(usr,"Pick account name (@[newdomain]):", "Account name"), 100)
|
||||
if(!newlogin)
|
||||
return TRUE
|
||||
|
||||
var/complete_login = "[newlogin]@[newdomain]"
|
||||
if(ntnet_global.does_email_exist(complete_login))
|
||||
error = "Error creating account: An account with same address already exists."
|
||||
return 1
|
||||
var/complete_login = "[newlogin]@[newdomain]"
|
||||
if(ntnet_global.does_email_exist(complete_login))
|
||||
error = "Error creating account: An account with same address already exists."
|
||||
return TRUE
|
||||
|
||||
var/datum/computer_file/data/email_account/new_account = new/datum/computer_file/data/email_account()
|
||||
new_account.login = complete_login
|
||||
new_account.password = GenerateKey()
|
||||
error = "Email [new_account.login] has been created, with generated password [new_account.password]"
|
||||
return 1
|
||||
var/datum/computer_file/data/email_account/new_account = new/datum/computer_file/data/email_account()
|
||||
new_account.login = complete_login
|
||||
new_account.password = GenerateKey()
|
||||
error = "Email [new_account.login] has been created, with generated password [new_account.password]"
|
||||
return TRUE
|
||||
|
||||
@@ -6,19 +6,15 @@
|
||||
program_menu_icon = "wrench"
|
||||
extended_desc = "This program monitors the local NTNet network, provides access to logging systems, and allows for configuration changes"
|
||||
size = 12
|
||||
requires_ntnet = 1
|
||||
requires_ntnet = TRUE
|
||||
required_access = access_network
|
||||
available_on_ntnet = 1
|
||||
nanomodule_path = /datum/nano_module/computer_ntnetmonitor/
|
||||
available_on_ntnet = TRUE
|
||||
tgui_id = "NtosNetMonitor"
|
||||
|
||||
/datum/nano_module/computer_ntnetmonitor
|
||||
name = "NTNet Diagnostics and Monitoring"
|
||||
//available_to_ai = TRUE
|
||||
|
||||
/datum/nano_module/computer_ntnetmonitor/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/datum/topic_state/state = default_state)
|
||||
/datum/computer_file/program/ntnetmonitor/tgui_data(mob/user)
|
||||
if(!ntnet_global)
|
||||
return
|
||||
var/list/data = host.initial_data()
|
||||
var/list/data = get_header_data()
|
||||
|
||||
data["ntnetstatus"] = ntnet_global.check_function()
|
||||
data["ntnetrelays"] = ntnet_global.relays.len
|
||||
@@ -30,73 +26,68 @@
|
||||
data["config_communication"] = ntnet_global.setting_communication
|
||||
data["config_systemcontrol"] = ntnet_global.setting_systemcontrol
|
||||
|
||||
data["ntnetlogs"] = ntnet_global.logs
|
||||
data["ntnetmaxlogs"] = ntnet_global.setting_maxlogcount
|
||||
data["ntnetlogs"] = list()
|
||||
data["minlogs"] = MIN_NTNET_LOGS
|
||||
data["maxlogs"] = MAX_NTNET_LOGS
|
||||
|
||||
data["banned_nids"] = list(ntnet_global.banned_nids)
|
||||
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "ntnet_monitor.tmpl", "NTNet Diagnostics and Monitoring Tool", 575, 700, state = state)
|
||||
if(host.update_layout())
|
||||
ui.auto_update_layout = 1
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
for(var/i in ntnet_global.logs)
|
||||
data["ntnetlogs"] += list(list("entry" = i))
|
||||
data["ntnetmaxlogs"] = ntnet_global.setting_maxlogcount
|
||||
|
||||
/datum/nano_module/computer_ntnetmonitor/Topic(href, href_list, state)
|
||||
var/mob/user = usr
|
||||
return data
|
||||
|
||||
/datum/computer_file/program/ntnetmonitor/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state)
|
||||
if(..())
|
||||
return 1
|
||||
if(href_list["resetIDS"])
|
||||
if(ntnet_global)
|
||||
ntnet_global.resetIDS()
|
||||
return 1
|
||||
if(href_list["toggleIDS"])
|
||||
if(ntnet_global)
|
||||
ntnet_global.toggleIDS()
|
||||
return 1
|
||||
if(href_list["toggleWireless"])
|
||||
if(!ntnet_global)
|
||||
return 1
|
||||
return
|
||||
switch(action)
|
||||
if("resetIDS")
|
||||
if(ntnet_global)
|
||||
ntnet_global.resetIDS()
|
||||
return TRUE
|
||||
if("toggleIDS")
|
||||
if(ntnet_global)
|
||||
ntnet_global.toggleIDS()
|
||||
return TRUE
|
||||
if("toggleWireless")
|
||||
if(!ntnet_global)
|
||||
return
|
||||
|
||||
// NTNet is disabled. Enabling can be done without user prompt
|
||||
if(ntnet_global.setting_disabled)
|
||||
ntnet_global.setting_disabled = 0
|
||||
return 1
|
||||
// NTNet is disabled. Enabling can be done without user prompt
|
||||
if(ntnet_global.setting_disabled)
|
||||
ntnet_global.setting_disabled = FALSE
|
||||
return TRUE
|
||||
|
||||
// NTNet is enabled and user is about to shut it down. Let's ask them if they really want to do it, as wirelessly connected computers won't connect without NTNet being enabled (which may prevent people from turning it back on)
|
||||
if(!user)
|
||||
return 1
|
||||
var/response = alert(user, "Really disable NTNet wireless? If your computer is connected wirelessly you won't be able to turn it back on! This will affect all connected wireless devices.", "NTNet shutdown", "Yes", "No")
|
||||
if(response == "Yes")
|
||||
ntnet_global.setting_disabled = 1
|
||||
return 1
|
||||
if(href_list["purgelogs"])
|
||||
if(ntnet_global)
|
||||
ntnet_global.purge_logs()
|
||||
return 1
|
||||
if(href_list["updatemaxlogs"])
|
||||
var/logcount = text2num(input(user,"Enter amount of logs to keep in memory ([MIN_NTNET_LOGS]-[MAX_NTNET_LOGS]):"))
|
||||
if(ntnet_global)
|
||||
ntnet_global.update_max_log_count(logcount)
|
||||
return 1
|
||||
if(href_list["toggle_function"])
|
||||
if(!ntnet_global)
|
||||
return 1
|
||||
ntnet_global.toggle_function(href_list["toggle_function"])
|
||||
return 1
|
||||
if(href_list["ban_nid"])
|
||||
if(!ntnet_global)
|
||||
return 1
|
||||
var/nid = input(user,"Enter NID of device which you want to block from the network:", "Enter NID") as null|num
|
||||
if(nid && CanUseTopic(user, state))
|
||||
ntnet_global.banned_nids |= nid
|
||||
return 1
|
||||
if(href_list["unban_nid"])
|
||||
if(!ntnet_global)
|
||||
return 1
|
||||
var/nid = input(user,"Enter NID of device which you want to unblock from the network:", "Enter NID") as null|num
|
||||
if(nid && CanUseTopic(user, state))
|
||||
ntnet_global.banned_nids -= nid
|
||||
return 1
|
||||
var/response = alert(usr, "Really disable NTNet wireless? If your computer is connected wirelessly you won't be able to turn it back on! This will affect all connected wireless devices.", "NTNet shutdown", "Yes", "No")
|
||||
if(response == "Yes" && tgui_status(usr, state) == STATUS_INTERACTIVE)
|
||||
ntnet_global.setting_disabled = TRUE
|
||||
return TRUE
|
||||
if("purgelogs")
|
||||
if(ntnet_global)
|
||||
ntnet_global.purge_logs()
|
||||
return TRUE
|
||||
if("updatemaxlogs")
|
||||
var/logcount = params["new_number"]
|
||||
if(ntnet_global)
|
||||
ntnet_global.update_max_log_count(logcount)
|
||||
return TRUE
|
||||
if("toggle_function")
|
||||
if(!ntnet_global)
|
||||
return
|
||||
ntnet_global.toggle_function(text2num(params["id"]))
|
||||
return TRUE
|
||||
if("ban_nid")
|
||||
if(!ntnet_global)
|
||||
return
|
||||
var/nid = input(usr,"Enter NID of device which you want to block from the network:", "Enter NID") as null|num
|
||||
if(nid && tgui_status(usr, state) == STATUS_INTERACTIVE)
|
||||
ntnet_global.banned_nids |= nid
|
||||
return TRUE
|
||||
if("unban_nid")
|
||||
if(!ntnet_global)
|
||||
return
|
||||
var/nid = input(usr,"Enter NID of device which you want to unblock from the network:", "Enter NID") as null|num
|
||||
if(nid && tgui_status(usr, state) == STATUS_INTERACTIVE)
|
||||
ntnet_global.banned_nids -= nid
|
||||
return TRUE
|
||||
|
||||
Reference in New Issue
Block a user