| 1 | /**************************************************************************
|
|---|
| 2 | * Copyright (C) 2004-2007 by Michael Medin <michael@medin.name> *
|
|---|
| 3 | * *
|
|---|
| 4 | * This code is part of NSClient++ - http://trac.nakednuns.org/nscp *
|
|---|
| 5 | * *
|
|---|
| 6 | * This program is free software; you can redistribute it and/or modify *
|
|---|
| 7 | * it under the terms of the GNU General Public License as published by *
|
|---|
| 8 | * the Free Software Foundation; either version 2 of the License, or *
|
|---|
| 9 | * (at your option) any later version. *
|
|---|
| 10 | * *
|
|---|
| 11 | * This program is distributed in the hope that it will be useful, *
|
|---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|---|
| 14 | * GNU General Public License for more details. *
|
|---|
| 15 | * *
|
|---|
| 16 | * You should have received a copy of the GNU General Public License *
|
|---|
| 17 | * along with this program; if not, write to the *
|
|---|
| 18 | * Free Software Foundation, Inc., *
|
|---|
| 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|---|
| 20 | ***************************************************************************/
|
|---|
| 21 | #pragma once
|
|---|
| 22 | #include <string>
|
|---|
| 23 | #include <list>
|
|---|
| 24 | #include <nsclient_session.hpp>
|
|---|
| 25 | #include <file_logger.hpp>
|
|---|
| 26 |
|
|---|
| 27 | #define WM_ICON_NOTIFY WM_USER+1
|
|---|
| 28 | #define WM_MY_CLOSE WM_USER+2
|
|---|
| 29 |
|
|---|
| 30 | class IconWidget : public nsclient_session::session_handler_interface {
|
|---|
| 31 | public:
|
|---|
| 32 | struct log_entry {
|
|---|
| 33 | log_entry(std::wstring category_, std::wstring file_, int line_, std::wstring message_) : category(category_), file(file_), line(line_), message(message_) {
|
|---|
| 34 |
|
|---|
| 35 | }
|
|---|
| 36 | std::wstring category;
|
|---|
| 37 | std::wstring file;
|
|---|
| 38 | int line;
|
|---|
| 39 | std::wstring message;
|
|---|
| 40 | };
|
|---|
| 41 | typedef std::list<log_entry> log_type;
|
|---|
| 42 |
|
|---|
| 43 | private:
|
|---|
| 44 | std::auto_ptr<nsclient_session::shared_client_session> shared_client_;
|
|---|
| 45 | log_type log_;
|
|---|
| 46 | MutexHandler logLock;
|
|---|
| 47 | HWND hDlgWnd;
|
|---|
| 48 | HWND hLogWnd;
|
|---|
| 49 | std::wstring channel_id_;
|
|---|
| 50 |
|
|---|
| 51 | public:
|
|---|
| 52 | IconWidget(std::wstring cmdLine);
|
|---|
| 53 | ~IconWidget();
|
|---|
| 54 | void createDialog(HINSTANCE hInstance);
|
|---|
| 55 | log_type getLog();
|
|---|
| 56 | void connectService();
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 | public: // Shared session interface:
|
|---|
| 60 | void log(std::wstring category, const TCHAR* file, const int line, std::wstring message);
|
|---|
| 61 | void session_error(std::wstring file, unsigned int line, std::wstring msg);
|
|---|
| 62 | void session_log_message(int msgType, const TCHAR* file, const int line, std::wstring message);
|
|---|
| 63 | int session_inject(std::wstring command, std::wstring arguments, std::wstring splitter, bool escape, std::wstring &msg, std::wstring & perf) {
|
|---|
| 64 | return -1;
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 | void setLogWindow(HWND hWnd) { hLogWnd = hWnd; }
|
|---|
| 69 | HWND getLogWindow() const { return hLogWnd; }
|
|---|
| 70 | int inject(std::wstring command, std::wstring arguments, std::wstring splitter, bool escape, std::wstring &msg, std::wstring & perf);
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 | };
|
|---|
| 74 |
|
|---|
| 75 | namespace TrayIcon
|
|---|
| 76 | {
|
|---|
| 77 | INT_PTR CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam);
|
|---|
| 78 | INT_PTR CALLBACK InjectDialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam);
|
|---|
| 79 | INT_PTR CALLBACK LogDialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam);
|
|---|
| 80 | void setupUI();
|
|---|
| 81 |
|
|---|
| 82 | void removeIcon(HWND hWnd);
|
|---|
| 83 | void addIcon(HWND hWnd);
|
|---|
| 84 | } |
|---|