Commit 73c1889d authored by dmknght's avatar dmknght

Add ask user to kill app and clear cache

parent 04e1cd23
Pipeline #1189 failed with stages
......@@ -2,9 +2,9 @@ import strutils
import osproc
import os
import displays / noti
import modules / [myip, changeid, cleaner]
import modules / [myip, changeid]
import .. / utils / services
import cli / [cores, help]
import cli / [cores, help, killapp]
proc checkIP() =
......@@ -37,7 +37,7 @@ proc killApps() =
sendNotify("AnonSurf", "Killed dangerous application", "security-high")
else:
echo "[*] Killed dangerous applications"
else:
elif killResult != -1:
if isDesktop:
sendNotify("AnonSurf", "Error while trying to kill applications", "security-medium")
else:
......
import .. / cli / cores
import .. / displays / askKill
import .. / modules / cleaner
proc doKillAppsFromCli*(): int =
#[
Ask if user want to kill dangerous applications.
If user has DE: Create a pop up with standalone
gtk application
Else: create a while loop to ask Y/N question
This module is for CLI only
]#
if not isDesktop:
if cliUserAsk():
return doKillApp()
else:
initAskDialog()
return -1
import gintro / [gtk, gobject]
import noti
import .. / modules / cleaner
proc onExit*(w: Window) =
mainQuit()
proc onClickYes(b: Button) =
let killResult = doKillApp()
if killResult == 0:
sendNotify("AnonSurf", "Killed dangerous application", "security-high")
elif killResult != -1:
sendNotify("AnonSurf", "Error while trying to kill applications", "security-medium")
mainQuit()
proc onClickNo(b: Button) =
mainQuit()
proc boxAskKillApps*(): Box =
let
retBox = newBox(Orientation.vertical, 3)
boxButtons = newBox(Orientation.horizontal, 3)
labelAsk = newLabel("Do you want to kill dangerous applications?")
btnYes = newButton("Yes")
btnNo = newButton("No")
btnYes.connect("clicked", onClickYes)
btnNo.connect("clicked", onClickNo)
boxButtons.packEnd(btnYes, false, true, 3)
boxButtons.packEnd(btnNo, false, true, 3)
retBox.add(labelAsk)
retBox.add(boxButtons)
return retBox
proc initAskDialog*() =
gtk.init()
let
mainBoard = newWindow()
boxMainWindow = boxAskKillApps()
mainBoard.setResizable(false)
mainBoard.title = "Kill dangerous application"
mainBoard.setPosition(WindowPosition.center)
mainBoard.add(boxMainWindow)
mainBoard.setBorderWidth(3)
mainBoard.showAll()
mainBoard.connect("destroy", onExit)
gtk.main()
import osproc
import .. / cli / cores
# import .. / cli / cores
# import .. / displays / askKill
proc askUser(): bool =
if not isDesktop:
return cliUserAsk()
else:
discard # TODO use select box of question here
proc doKillAppsFromCli*(): int =
#[
Ask if user want to kill dangerous applications.
If user has DE: Create a pop up with standalone
gtk application
Else: create a while loop to ask Y/N question
This module is for CLI only
]#
proc doKillApp*(): int =
const
killCommand = "killall -q chrome dropbox skype icedove thunderbird firefox firefox-esr chromium xchat hexchat transmission steam firejail /usr/lib/firefox/firefox"
cacheCommand = "bleachbit -c adobe_reader.cache chromium.cache chromium.current_session chromium.history elinks.history emesene.cache epiphany.cache firefox.url_history flash.cache flash.cookies google_chrome.cache google_chrome.history links2.history opera.cache opera.search_history opera.url_history &> /dev/null"
if askUser():
let
killResult = execCmd(killCommand)
cacheResult = execCmd(cacheCommand)
return killResult + cacheResult
proc doKillAppsFromGUI*(): int =
#[
Ask if user want to kill dangerous applications.
This module for GUI (AnonSurfGTK)
]#
discard
let
killResult = execCmd(killCommand)
cacheResult = execCmd(cacheCommand)
return killResult + cacheResult
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