~ubuntu-branches/ubuntu/natty/nuapplet/natty

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
 ** Copyright 2004-2007 - INL
 ** Written by Eric Leblond <eric.leblond@inl.fr>
 **            Vincent Deffontaines <vincent@inl.fr>
 ** INL http://www.inl.fr/
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
 ** the Free Software Foundation, version 2 of the License.
 **
 ** This program is distributed in the hope that it will be useful,
 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ** GNU General Public License for more details.
 **
 ** You should have received a copy of the GNU General Public License
 ** along with this program; if not, write to the Free Software
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef __SYSTRAY__
#define __SYSTRAY__

#include <nuclient.h>
#include <QMainWindow>
#include <QtGui>
#include <QSystemTrayIcon>
#include "auth_dlg.h"
#include "logs.h"
#include "preferences.h"
#include "thread_session.h"

class NuAppSystray : public QSystemTrayIcon {
	Q_OBJECT

public:
	NuAppSystray();
	~NuAppSystray();

public slots:
	void onClick(QSystemTrayIcon::ActivationReason reason);
	void start_auth(QString _username, QString _password);
	void stop_auth();
	void popup_about();

	void tray_set_connected();
	void tray_set_stopped();
	void tray_set_trying();
	void tray_report_error();
	void tray_report_connected();
	void tray_report_disconnected();

signals:
	void showAuthDlg();

private:
	void createActions();
	void createTrayIcon();

	void parse_cmdline_options(int argc, char **argv);
	void usage();

	// Authentication related
	QSettings settings;
	QMenu *trayIconMenu;

	// GUI related
	QAction *exitAct;
	QAction *preferencesAct;
	QAction *logsAct;
	QAction *connectAct;
	QAction *disconnectAct;
	QAction *aboutAct;
	ThreadCheckConn timer;

	NuAppAuthDialog* auth_dlg;
	NuLogsWindow* logs_dlg;
	NuAppPreferences* pref_dlg;
};

#endif /* __SYSTRAY__ */