]> git.zerfleddert.de Git - proxmark3-svn/blame - client/proxgui.cpp
Comms refactor (prerequisite of libproxmark work) (#371)
[proxmark3-svn] / client / proxgui.cpp
CommitLineData
a553f267 1//-----------------------------------------------------------------------------
212ef3a0 2// Copyright (C) 2009 Michael Gernoth <michael at gernoth.net>
3//
a553f267 4// This code is licensed to you under the terms of the GNU GPL, version 2 or,
5// at your option, any later version. See the LICENSE.txt file for the text of
6// the license.
7//-----------------------------------------------------------------------------
8// GUI functions
9//-----------------------------------------------------------------------------
10
6658905f 11#include "proxgui.h"
12#include "proxguiqt.h"
5acd195d 13#include "proxmark3.h"
afdcb8c1 14#include "uart.h"
6658905f 15
16static ProxGuiQT *gui = NULL;
5acd195d 17static WorkerThread *main_loop_thread = NULL;
18
afdcb8c1
MF
19WorkerThread::WorkerThread(char *script_cmds_file, char *script_cmd,
20 bool usb_present, serial_port* sp)
21 : script_cmds_file(script_cmds_file), script_cmd(script_cmd),
22 usb_present(usb_present), sp(sp)
5acd195d 23{
24}
25
26WorkerThread::~WorkerThread()
27{
28}
29
30void WorkerThread::run() {
afdcb8c1 31 main_loop(script_cmds_file, script_cmd, usb_present, sp);
5acd195d 32}
6658905f 33
34extern "C" void ShowGraphWindow(void)
35{
7fe9b0b7 36 if (!gui)
37 return;
38
39 gui->ShowGraphWindow();
6658905f 40}
41
42extern "C" void HideGraphWindow(void)
43{
7fe9b0b7 44 if (!gui)
45 return;
46
47 gui->HideGraphWindow();
6658905f 48}
49
50extern "C" void RepaintGraphWindow(void)
51{
7fe9b0b7 52 if (!gui)
53 return;
6658905f 54
7fe9b0b7 55 gui->RepaintGraphWindow();
6658905f 56}
57
58extern "C" void MainGraphics(void)
59{
5acd195d 60 if (!gui)
61 return;
6658905f 62
5acd195d 63 gui->MainLoop();
6658905f 64}
65
afdcb8c1
MF
66extern "C" void InitGraphics(int argc, char **argv, char *script_cmds_file,
67 char *script_cmd, bool usb_present,
68 serial_port* sp)
6658905f 69{
70#ifdef Q_WS_X11
5acd195d 71 bool useGUI = getenv("DISPLAY") != 0;
6658905f 72#else
5acd195d 73 bool useGUI = true;
6658905f 74#endif
5acd195d 75 if (!useGUI)
76 return;
6658905f 77
afdcb8c1 78 main_loop_thread = new WorkerThread(script_cmds_file, script_cmd, usb_present, sp);
aa757f71 79 gui = new ProxGuiQT(argc, argv, main_loop_thread);
6658905f 80}
81
82extern "C" void ExitGraphics(void)
83{
aa757f71
OM
84 if (!gui)
85 return;
7fe9b0b7 86
aa757f71
OM
87 gui->Exit();
88 gui = NULL;
6658905f 89}
Impressum, Datenschutz