Commit cc2b4654 authored by Nong Hoang Tu's avatar Nong Hoang Tu
Browse files

Make threading works with functions

parent c04a5849
Pipeline #3765 canceled with stages
import gintro / gtk
# import .. / cores / ansurf_types
import .. / cores / ansurf_types
type
......@@ -33,7 +33,12 @@ type
isDNSPort*: bool
isSocksPort*: bool
isTransPort*: bool
# AnsurfStartArgs* = tuple[cb_kill_apps: callback_kill_apps, cb_send_msg: callback_send_messenger]
var
# ansurf_start_stop_workers*: Thread[string, callback_kill_apps, callback_send_messenger]
# ansurf_workers_common_sudo*: Thread[string, callback_send_messenger]
ansurf_workers_common*: Thread[callback_send_messenger]
# worker*: Thread[void]
# MyIP* = object
# thisAddr*: string
# isUnderTor*: string
......@@ -41,3 +46,6 @@ type
# var
# worker*: system.Thread[void]
# channel*: Channel[MyIP]
# var
# retCode*: Channel[int]
import gintro / gtk
import .. / .. / cores / handle_activities
import .. / .. / cores / handle_killapps
import .. / ansurf_objects
let cb_kill_apps = init_gtk_askkill()
proc do_anonsurf_start(cb_send_msg: proc) {.gcsafe.} =
ansurf_acts_handle_start("gksudo", cb_kill_apps, cb_send_msg)
proc do_anonsurf_stop(cb_send_msg: proc) {.gcsafe.} =
ansurf_acts_handle_stop("gksudo", cb_kill_apps, cb_send_msg)
proc do_anonsurf_restart(cb_send_msg: proc) {.gcsafe.} =
ansurf_acts_handle_restart("gksudo", cb_send_msg)
proc do_anonsurf_changeid(cb_send_msg: proc) {.gcsafe.} =
ansurf_acts_handle_changeID(cb_send_msg)
proc do_anonsurf_checkip(cb_send_msg: proc) {.gcsafe.} =
ansurf_acts_handle_checkIP(cb_send_msg)
proc ansurf_gtk_do_start_stop*(b: Button, cb_send_msg: proc) =
if b.label == "Start":
ansurf_acts_handle_start("gksudo", cb_kill_apps, cb_send_msg)
createThread(ansurf_workers_common, do_anonsurf_start, cb_send_msg)
# createThread(ansurf_start_stop_workers, ansurf_acts_handle_start, ("gksudo", cb_kill_apps, cb_send_msg))
# ansurf_acts_handle_start("gksudo", cb_kill_apps, cb_send_msg)
else:
ansurf_acts_handle_stop("gksudo", cb_kill_apps, cb_send_msg)
createThread(ansurf_workers_common, do_anonsurf_stop, cb_send_msg)
# ansurf_acts_handle_stop("gksudo", cb_kill_apps, cb_send_msg)
# createThread(ansurf_start_stop_workers, ansurf_acts_handle_stop, "gksudo", cb_kill_apps, cb_send_msg)
ansurf_workers_common.joinThread()
proc ansurf_gtk_do_restart*(b: Button, cb_send_msg: proc) =
ansurf_acts_handle_restart("gksudo", cb_send_msg)
createThread(ansurf_workers_common, do_anonsurf_restart, cb_send_msg)
ansurf_workers_common.joinThread()
# createThread(ansurf_workers_common_sudo, ansurf_acts_handle_restart, ("gksudo", cb_send_msg))
# ansurf_acts_handle_restart("gksudo", cb_send_msg)
proc ansurf_gtk_do_myip*(b: Button, cb_send_msg: proc) =
ansurf_acts_handle_checkIP(cb_send_msg)
# ansurf_acts_handle_checkIP(cb_send_msg)
createThread(ansurf_workers_common, do_anonsurf_checkip, (cb_send_msg))
proc ansurf_gtk_do_changeid*(b: Button, cb_send_msg: proc) =
ansurf_acts_handle_changeID(cb_send_msg)
# ansurf_acts_handle_changeID(cb_send_msg)
createThread(ansurf_workers_common, do_anonsurf_changeid, (cb_send_msg))
proc ansurf_gtk_do_status*() =
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment