source: nscp/helpers/systray_helper/TrayWidget.h @ c0522cd

0.4.00.4.10.4.2stable
Last change on this file since c0522cd was c0522cd, checked in by Michael Medin <michael@…>, 5 years ago

2008-08-16 MickeM

  • *WARNING* THIS IS VERY VERY UNSTABEL (possibly)
  • *WARNING* A lot of new untested code here so dont run in production enviornments :) + Added shared session so system tray can communicate with master + Added new system tray handlig (via TS so FUS should work with it) + Added new option [System] / shared_session=0 (or 1) to enable / disable the new shared memory framework (it is for now disabled by default) If you want to try this remember to change that option but also beware! it is dagerous and not finnished and and also there is as of now no security at all.
  • Property mode set to 100644
File size: 3.5 KB
Line 
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
30class IconWidget : public nsclient_session::session_handler_interface {
31public:
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
43private:
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
51public:
52        IconWidget(std::wstring cmdLine);
53        ~IconWidget();
54        void createDialog(HINSTANCE hInstance);
55        log_type getLog();
56        void connectService();
57
58
59public: // 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
75namespace 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}
Note: See TracBrowser for help on using the repository browser.