]> git.zerfleddert.de Git - proxmark3-svn/blame_incremental - client/proxgui.cpp
Comms refactor (prerequisite of libproxmark work) (#371)
[proxmark3-svn] / client / proxgui.cpp
... / ...
CommitLineData
1//-----------------------------------------------------------------------------
2// Copyright (C) 2009 Michael Gernoth <michael at gernoth.net>
3//
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
11#include "proxgui.h"
12#include "proxguiqt.h"
13#include "proxmark3.h"
14#include "uart.h"
15
16static ProxGuiQT *gui = NULL;
17static WorkerThread *main_loop_thread = NULL;
18
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)
23{
24}
25
26WorkerThread::~WorkerThread()
27{
28}
29
30void WorkerThread::run() {
31 main_loop(script_cmds_file, script_cmd, usb_present, sp);
32}
33
34extern "C" void ShowGraphWindow(void)
35{
36 if (!gui)
37 return;
38
39 gui->ShowGraphWindow();
40}
41
42extern "C" void HideGraphWindow(void)
43{
44 if (!gui)
45 return;
46
47 gui->HideGraphWindow();
48}
49
50extern "C" void RepaintGraphWindow(void)
51{
52 if (!gui)
53 return;
54
55 gui->RepaintGraphWindow();
56}
57
58extern "C" void MainGraphics(void)
59{
60 if (!gui)
61 return;
62
63 gui->MainLoop();
64}
65
66extern "C" void InitGraphics(int argc, char **argv, char *script_cmds_file,
67 char *script_cmd, bool usb_present,
68 serial_port* sp)
69{
70#ifdef Q_WS_X11
71 bool useGUI = getenv("DISPLAY") != 0;
72#else
73 bool useGUI = true;
74#endif
75 if (!useGUI)
76 return;
77
78 main_loop_thread = new WorkerThread(script_cmds_file, script_cmd, usb_present, sp);
79 gui = new ProxGuiQT(argc, argv, main_loop_thread);
80}
81
82extern "C" void ExitGraphics(void)
83{
84 if (!gui)
85 return;
86
87 gui->Exit();
88 gui = NULL;
89}
Impressum, Datenschutz