blob: 966db12e17619f8283d934a693c245e970dea5d7 [file] [log] [blame]
Alexander Afanasyevb6392e32014-05-12 23:43:50 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2013-2014, Regents of the University of California,
4 *
5 * This file is part of NFD Control Center. See AUTHORS.md for complete list of NFD
6 * authors and contributors.
7 *
8 * NFD Control Center is free software: you can redistribute it and/or modify it under the
9 * terms of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
11 *
12 * NFD Control Center is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with NFD
17 * Control Center, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * \author Ilya Moiseenko <iliamo@ucla.edu>
20 */
21
22#ifndef NCC_QT_TRAY_MENU_H
23#define NCC_QT_TRAY_MENU_H
24
25#include <QMainWindow>
26#include <QWidget>
27#include <QSystemTrayIcon>
28#include <QMenu>
29#include <QTimer>
30#include <QProcess>
31#include <QThread>
32#include <QStandardItemModel>
33#include <QtXml>
34#include <QThread>
35#include <QSettings>
36#include <QNetworkAccessManager>
37#include <QNetworkRequest>
38#include <QNetworkReply>
39
40// #include "fib-input-dialog.hpp"
41#include "quit-dialog.hpp"
42#include "network-manager.hpp"
43
44#define ALLOW_SOFTWARE_UPDATES "AllowAutomaticUpdates"
45#define ENABLE_HUB_DISCOVERY "EnableHubDiscovery"
46#define ENABLE_START_ON_LOGIN "enableStartOnLogin"
47#define SHUTDOWN_ON_EXIT "ShutdownOnExit"
48
49#define AUTOSTART_DIRECTORY "/.config/autostart/"
50#define SHORTCUT_FILE "ndnxcontrolcenter.desktop"
51#define STATUS_XSLT_FILE "status.xslt"
52#define FIB_XSLT_FILE "status-to-fib.xslt"
53
54namespace Ui {
55class TrayMenu;
56}
57
58class TrayMenu : public QMainWindow
59{
60 Q_OBJECT
61
62public:
63 explicit TrayMenu(QWidget *parent = 0);
64 ~TrayMenu();
65
66private:
67 Ui::TrayMenu *ui;
68
69 void createTrayIcon();
70 void setIcon(bool isConnected);
71 void createToolbar();
72 void createTableView();
73 void closeEvent(QCloseEvent *); // Overriding the window's close event
74 void showEvent(QShowEvent * event); //Overriding the window's show event
75
76 void loadSettings();
77 void makeAutostartDirectory();
78
79 void resizeEvent (QResizeEvent * event);
80
81 bool daemonStarted;
82
83 QSettings *persistentSettings;
84
85 QSystemTrayIcon *trayIcon;
86 QMenu *trayIconMenu;
87
88 QTimer *daemonStatusTimer;
89 QThread *statusUpdateThread;
90
91 QProcess *processLookup;
92 QProcess *applyStatusXslt;
93 QProcess *applyFibXslt;
94
95 QString statusXml;
96 QString fibContentsXml;
97
98 QStandardItemModel *model;
99 int selectedRow;
100 int scrollPosition;
101
102 QAction *statusIndicator;
103 QAction *displayStatus;
104 QAction *interestSentRecv;
105 QAction *dataSentRecv;
106 QAction *open;
107 QAction *close;
108 QAction *openGeneralSettings;
109 QAction *openForwardingSettings;
110 QAction *openSecuritySettings;
111
112 // FibInputDialog *dialog;
113
114 bool enableHubDiscovery;
115 bool enableStartOnLogin;
116
117 NetworkManager *networkManager;
118 QNetworkAccessManager *urlManager;
119
120private slots:
121 void trayIconClicked(QSystemTrayIcon::ActivationReason);
122 void generalSettingsClicked();
123 void forwardingSettingsClicked();
124 void securitySettingsClicked();
125 void openTrafficMap();
126 void openRoutingStatus();
127 void openCertificationPage();
128 void displayPopup();
129 // void confirmQuit();
130 void showFibInputDialog();
131 // void terminateDaemonAndClose();
132 void addFibEntry();
133 // void daemonStatusUpdate();
134 void selectTableRow();
135 // void deleteFibEntry();
136 void changeHubDiscovery();
137 void changeLoginStart();
138 void copyFile();
139 // void runXmlProc(QNetworkReply *reply);
140 // void parseStatusXml();
141 // void parseFibXml();
142 void parseProcessLookup();
143};
144
145#endif // NCC_QT_TRAY_MENU_H