Changeset 4bf9740 in nscp
- Timestamp:
- 09/17/08 21:10:18 (5 years ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2, stable
- Children:
- 08f0346
- Parents:
- 7e74e2c
- Files:
-
- 11 edited
-
AutoBuild.h (modified) (1 diff)
-
NSClient++-2005.sln (modified) (1 diff)
-
NSClient++.cpp (modified) (6 diffs)
-
NSClient++.h (modified) (2 diffs)
-
changelog (modified) (1 diff)
-
helpers/systray_helper/TrayWidget.cpp (modified) (14 diffs)
-
helpers/systray_helper/TrayWidget.h (modified) (2 diffs)
-
include/filter_framework.hpp (modified) (1 diff)
-
include/nsclient_session.hpp (modified) (9 diffs)
-
modules/SampleManagedPlugin/SampleManagedPlugin.vcproj (modified) (1 diff)
-
modules/SysTray/TrayIcon.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
AutoBuild.h
rc37e58f r4bf9740 3 3 // change the FALSE to TRUE for autoincrement of build number 4 4 #define INCREMENT_VERSION TRUE 5 #define FILEVER 0,3,4, 286 #define PRODUCTVER 0,3,4, 287 #define STRFILEVER _T("0.3.4. 28")8 #define STRPRODUCTVER _T("0.3.4. 28")9 #define STRPRODUCTDATE _T("2008-09-1 4")5 #define FILEVER 0,3,4,30 6 #define PRODUCTVER 0,3,4,30 7 #define STRFILEVER _T("0.3.4.30") 8 #define STRPRODUCTVER _T("0.3.4.30") 9 #define STRPRODUCTDATE _T("2008-09-16") 10 10 #endif // AUTOBUILD_H -
NSClient++-2005.sln
r7e74e2c r4bf9740 1246 1246 {D367E76D-9485-4DCB-A9D0-3D3C0E190648}.Nightly|Mixed Platforms.Build.0 = Release|Win32 1247 1247 {D367E76D-9485-4DCB-A9D0-3D3C0E190648}.Nightly|Win32.ActiveCfg = Release|Win32 1248 {D367E76D-9485-4DCB-A9D0-3D3C0E190648}.Nightly|Win32.Build.0 = Release|Win321249 1248 {D367E76D-9485-4DCB-A9D0-3D3C0E190648}.Nightly|x64.ActiveCfg = Release|Win32 1250 1249 {D367E76D-9485-4DCB-A9D0-3D3C0E190648}.Release|Any CPU.ActiveCfg = Release|Win32 -
NSClient++.cpp
r41d25b1 r4bf9740 275 275 } 276 276 if (server) 277 mainClient.startTrayIcon (0);277 mainClient.startTrayIcons(); 278 278 LOG_MESSAGE_STD(_T("Using settings from: ") + Settings::getInstance()->getActiveType()); 279 279 LOG_MESSAGE(_T("Enter command to inject or exit to terminate...")); … … 350 350 } 351 351 352 void NSClientT::session_info(std::wstring file, unsigned int line, std::wstring msg) { 353 NSAPIMessage(NSCAPI::log, file.c_str(), line, msg.c_str()); 354 } 355 352 356 353 357 … … 503 507 LOG_DEBUG_STD(_T("Found ") + strEx::itos(count) + _T(" sessions")); 504 508 for (DWORD i=0;i<count;i++) { 505 LOG_DEBUG_STD(_T("Found session ") + strEx::itos(list[i].SessionId) + _T(" state: ") + strEx::itos(list[i].State));509 LOG_DEBUG_STD(_T("Found session: ") + strEx::itos(list[i].SessionId) + _T(" state: ") + strEx::itos(list[i].State)); 506 510 if (list[i].State == remote_processes::_WTS_CONNECTSTATE_CLASS::WTSActive) { 507 511 startTrayIcon(list[i].SessionId); … … 609 613 } 610 614 DWORD WINAPI NSClientT::service_ctrl_dispatch_ex(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext) { 611 LOG_DEBUG_STD(_T("service_ctrl_dispatch_ex dispatching event: ") + strEx::itos(dwControl));612 615 return mainClient.service_ctrl_ex(dwControl, dwEventType, lpEventData, lpContext); 613 616 } … … 618 621 */ 619 622 void WINAPI NSClientT::service_ctrl_dispatch(DWORD dwCtrlCode) { 620 LOG_DEBUG_STD(_T("service_ctrl_dispatch dispatching event: ") + strEx::itos(dwCtrlCode));621 623 mainClient.service_ctrl_ex(dwCtrlCode, NULL, NULL, NULL); 622 624 } … … 624 626 625 627 void NSClientT::service_on_session_changed(DWORD dwSessionId, bool logon, DWORD dwEventType) { 626 if (shared_server_.get() != NULL) {628 if (shared_server_.get() == NULL) { 627 629 LOG_DEBUG_STD(_T("No shared session: ignoring change event!")); 628 630 return; -
NSClient++.h
rbc97cd8 r4bf9740 149 149 // Shared session interface: 150 150 void session_error(std::wstring file, unsigned int line, std::wstring msg); 151 void session_info(std::wstring file, unsigned int line, std::wstring msg); 151 152 void session_log_message(int msgType, const TCHAR* file, const int line, std::wstring message) { 152 153 reportMessage(msgType, file, line, message); … … 154 155 int session_inject(std::wstring command, std::wstring arguments, TCHAR splitter, bool escape, std::wstring &msg, std::wstring & perf) { 155 156 return inject(command, arguments, splitter, escape, msg, perf); 157 } 158 std::pair<std::wstring,std::wstring> session_get_name() { 159 return std::pair<std::wstring,std::wstring>(SZAPPNAME,SZVERSION); 156 160 } 157 161 -
changelog
r41d25b1 r4bf9740 5 5 * Improved socket performance (would be nice if we could be used as a "hub") 6 6 7 2008-09-17 MickeM - 0.3.4 RC-6 8 * Fixed issue on all filters so == takes the "usual" 2 equalsigns (old still works). 9 * Added so tray icon can get "propper" name from core for "description". 10 11 2008-09-16 MickeM - 0.3.4 RC-5 12 * Fixed an issue with the session launcher 13 7 14 2008-09-15 MickeM 8 15 * Fixed so NSCLient++ can load with "broken plugins" (before it printed an error and exited) 9 16 + Added a very basic simple .net plugin (and a wrapper) 17 18 2008-09-14 MickeM - 0.3.4 RC-4 19 * Fixed an issue with the session launcher 20 * Fixed an issue with the uninstaller (should not "fail" when problems uninstalling) 10 21 11 22 2008-09-14 MickeM - 0.3.4 RC-4 -
helpers/systray_helper/TrayWidget.cpp
ra34b229 r4bf9740 50 50 typedef BOOL (WINAPI *LPFN_CHANGEWINDOWMESSAGEFILTER) (UINT, DWORD); 51 51 LPFN_CHANGEWINDOWMESSAGEFILTER fnChangeWindowMessageFilter = NULL; 52 BOOL ChangeWindowMessageFilter (UINT message, DWORD what)52 BOOL ChangeWindowMessageFilter_(UINT message, DWORD what) 53 53 { 54 54 if (fnChangeWindowMessageFilter == NULL) { … … 85 85 LOG_MESSAGE_TRAY(_T("Attempting to launch system tray module for ") + channel_id_); 86 86 gTrayInstance = this; 87 try {88 shared_client_.reset(new nsclient_session::shared_client_session(channel_id_, this));89 if (shared_client_.get() != NULL)90 shared_client_->attach_to_session(channel_id_);91 } catch (nsclient_session::session_exception e) {92 LOG_ERROR_TRAY(_T("Failed to attach to shared session: ") + e.what());93 }94 87 } 95 88 TrayWidget::~TrayWidget() { … … 111 104 try { 112 105 shared_client_.reset(new nsclient_session::shared_client_session(channel_id_, this)); 113 if (shared_client_.get() != NULL) 106 if (shared_client_.get() != NULL) { 114 107 shared_client_->attach_to_session(channel_id_); 108 TrayIcon::addIcon(hDlgWnd); 109 } 115 110 } catch (nsclient_session::session_exception e) { 116 111 LOG_ERROR_TRAY(_T("Failed to attach to shared session: ") + e.what()); … … 124 119 return shared_client_->inject(command, arguments, splitter, escape, msg, perf); 125 120 } 121 std::pair<std::wstring,std::wstring> TrayWidget::get_client_name() { 122 if (shared_client_.get() == NULL) { 123 LOG_ERROR_TRAY(_T("No active shared instance!")); 124 return std::pair<std::wstring,std::wstring>(_T("NSClient++ system tray offline"), _T("")); 125 } 126 return shared_client_->get_client_name(); 127 } 126 128 127 129 … … 131 133 LOG_MESSAGE_TRAY(_T("Creating dialog...")); 132 134 ghInstance = hInstance; 133 //hDlgWnd = ::CreateDialog(hInstance,MAKEINTRESOURCE(IDD_NSTRAYDLG),NULL,TrayIcon::DialogProc);134 //if ((hDlgWnd == NULL)||!IsWindow(hDlgWnd)) {135 // LOG_ERROR_TRAY(_T("Failed to create windows: ") + error::lookup::last_error());136 // }137 135 138 136 WNDCLASSEX wndclass; … … 149 147 wndclass.lpszClassName=_T("NSClient_pp_TrayClass"); 150 148 wndclass.style=0; 151 // register task bar restore event after crash152 //WM_TASKBARCREATED=RegisterWindowMessage(TEXT("TaskbarCreated"));153 //MyChangeWindowMessageFilter(WM_TASKBARCREATED, MSGFLT_ADD);154 149 155 150 UINT UDM_TASKBARCREATED = RegisterWindowMessage(_T("TaskbarCreated")); … … 157 152 LOG_ERROR_TRAY(_T("Failed to register 'TaskbarCreated': ") + error::lookup::last_error()); 158 153 } 159 if (!ChangeWindowMessageFilter (UDM_TASKBARCREATED, MSGFLT_ADD)) {154 if (!ChangeWindowMessageFilter_(UDM_TASKBARCREATED, MSGFLT_ADD)) { 160 155 LOG_ERROR_TRAY(_T("Failed to cchange window filter: ") + error::lookup::last_error()); 161 156 } … … 185 180 } 186 181 return; 187 188 /*189 MSG Msg;190 BOOL bRet;191 while((bRet = ::GetMessage(&Msg, NULL, 0, 0)) != 0)192 {193 if (Msg.message == WM_MY_CLOSE) {194 ::DestroyWindow(hDlgWnd);195 } else if (Msg.message == UDM_TASKBARCREATED) {196 LOG_MESSAGE_TRAY(_T("Recreating systray icon..."));197 TrayIcon::addIcon(Msg.hwnd);198 } else if (bRet == -1) {199 // handle the error and possibly exit200 LOG_ERROR_TRAY(_T("Wonder what this is... please let me know..."));201 return;202 } else {203 //} else if (!::IsWindow(hDlgWnd) || !::IsDialogMessage(hDlgWnd, &Msg)) {204 ::TranslateMessage(&Msg);205 ::DispatchMessage(&Msg);206 }207 }208 */209 182 } 210 183 211 184 void TrayWidget::session_error(std::wstring file, unsigned int line, std::wstring msg) { 212 185 log(_T("error"), file.c_str(), line, msg); 186 } 187 void TrayWidget::session_info(std::wstring file, unsigned int line, std::wstring msg) { 188 log(_T("info"), file.c_str(), line, msg); 213 189 } 214 190 … … 353 329 SetDlgItemText(hWnd, IDC_MSG, msg.c_str()); 354 330 SetDlgItemText(hWnd, IDC_PERF, perf.c_str()); 331 } else if (cmd == _T("connect-service")) { 332 gTrayInstance->connectService(); 355 333 } 356 334 return 0; … … 364 342 } 365 343 344 static void connectService() { 345 Thread<worker_thread> *pThread = new Thread<worker_thread>(_T("tray-worker-thread")); 346 pThread->createThread(worker_thread::init(_T("connect-service"), NULL)); 347 } 366 348 static void updateServiceStatus(HMENU hMenu) { 367 349 Thread<worker_thread> *pThread = new Thread<worker_thread>(_T("tray-worker-thread")); … … 586 568 if (uMsg == UDM_TASKBARCREATED) { 587 569 addIcon(hwndDlg); 588 LOG_MESSAGE_TO_TRAY(_T("UDM_TASKBARCREATED"));589 570 } 590 571 … … 600 581 case WM_CREATE: 601 582 case WM_INITDIALOG: 602 LOG_MESSAGE_TO_TRAY(_T("WM_INITDIALOG"));603 604 605 583 UDM_TASKBARCREATED = RegisterWindowMessage(_T("TaskbarCreated")); 606 584 if (UDM_TASKBARCREATED == 0) { 607 585 LOG_MESSAGE_TO_TRAY(_T("Failed to register 'TaskbarCreated': ") + error::lookup::last_error()); 608 586 } 609 if (!ChangeWindowMessageFilter (UDM_TASKBARCREATED, MSGFLT_ADD)) {587 if (!ChangeWindowMessageFilter_(UDM_TASKBARCREATED, MSGFLT_ADD)) { 610 588 LOG_MESSAGE_TO_TRAY(_T("Failed to cchange window filter: ") + error::lookup::last_error()); 611 589 } 612 590 613 591 addIcon(hwndDlg); 592 worker_thread::connectService(); 614 593 break; 615 594 … … 619 598 { 620 599 case ID_POPUP_CONNECT: 621 gTrayInstance->connectService();600 worker_thread::connectService(); 622 601 break; 623 602 case ID_POPUP_CLOSE: … … 680 659 ndata.uCallbackMessage=WM_ICON_NOTIFY; 681 660 ndata.hIcon=::LoadIcon(ghInstance,MAKEINTRESOURCE(IDI_NSCP)); 682 std::wstring title = _T("NSClient++ SystemTray (TODO)"); //NSCModuleHelper::getApplicationName() + _T(" - ") + NSCModuleHelper::getApplicationVersionString(); 661 std::pair<std::wstring,std::wstring> version = gTrayInstance->get_client_name(); 662 std::wstring title = version.first + _T(" - ") + version.second; 683 663 wcsncpy_s(ndata.szTip, 64, title.c_str(), min(64, title.size())); 684 664 Shell_NotifyIcon(NIM_ADD,&ndata); -
helpers/systray_helper/TrayWidget.h
ra34b229 r4bf9740 60 60 void log(std::wstring category, const TCHAR* file, const int line, std::wstring message); 61 61 void session_error(std::wstring file, unsigned int line, std::wstring msg); 62 void session_info(std::wstring file, unsigned int line, std::wstring msg); 62 63 void session_log_message(int msgType, const TCHAR* file, const int line, std::wstring message); 63 64 int session_inject(std::wstring command, std::wstring arguments, TCHAR splitter, bool escape, std::wstring &msg, std::wstring & perf) { 64 65 return -1; 66 } 67 std::pair<std::wstring,std::wstring> session_get_name() { 68 return std::pair<std::wstring,std::wstring>(_T("NSClient++ systray"),_T("")); 65 69 } 66 70 … … 69 73 HWND getLogWindow() const { return hLogWnd; } 70 74 int inject(std::wstring command, std::wstring arguments, TCHAR splitter, bool escape, std::wstring &msg, std::wstring & perf); 75 std::pair<std::wstring,std::wstring> get_client_name(); 71 76 72 77 -
include/filter_framework.hpp
r367bf20 r4bf9740 266 266 throw parse_exception(_T("Regular expression support not enabled!") + value); 267 267 #endif 268 } else if (t.first.length() > 1 && t.first[0] == L'=') { 269 exact = t.first.substr(1); 268 270 } else { 269 271 exact = t.first; -
include/nsclient_session.hpp
ra34b229 r4bf9740 12 12 std::wstring what_; 13 13 public: 14 session_exception(std::wstring what) : what_(what) { 15 std::wcout << _T("e: ") << what << std::endl; 16 17 } 14 session_exception(std::wstring what) : what_(what) {} 18 15 std::wstring what() { 19 16 return what_; … … 24 21 public: 25 22 virtual void session_error(std::wstring file, unsigned int line, std::wstring msg) = 0; 23 virtual void session_info(std::wstring file, unsigned int line, std::wstring msg) = 0; 26 24 virtual void session_log_message(int msgType, const TCHAR* file, const int line, std::wstring message) = 0; 27 25 virtual int session_inject(std::wstring command, std::wstring arguments, TCHAR splitter, bool escape, std::wstring &msg, std::wstring & perf) = 0; 26 virtual std::pair<std::wstring,std::wstring> session_get_name() = 0; 28 27 }; 29 28 … … 40 39 const static std::wstring message_log = _T("core_log"); 41 40 const static std::wstring message_inject = _T("core_inject"); 41 const static std::wstring message_get_name = _T("core_get_name"); 42 42 const static std::wstring message_master_shutdown = _T("core_master_shutdown"); 43 43 const static std::wstring message_master_attach = _T("core_master_attach"); … … 69 69 shared_memory_handler shared_memory; 70 70 std::wstring channel_name_; 71 72 //static const std::wstring channel_prefix;73 71 74 72 public: … … 367 365 void info(std::wstring file, unsigned int line, std::wstring msg) { 368 366 if (handler_) 369 handler_->session_ error(file, line, msg);367 handler_->session_info(file, line, msg); 370 368 } 371 369 … … 647 645 } 648 646 647 std::pair<std::wstring,std::wstring> get_client_name() { 648 remote_channel::local_message_type msg; 649 msg.command = message_get_name; 650 unsigned int msg_id = send_server(msg); 651 remote_channel::local_message_type response = wait_reply(msg_id); 652 if (response.arguments.size() != 2) 653 return std::pair<std::wstring,std::wstring>(_T("Unknown: Failed to get service name"),_T("")); 654 return std::pair<std::wstring,std::wstring>(response.arguments[0],response.arguments[1]); 655 } 649 656 int inject(std::wstring command, std::wstring arguments, TCHAR splitter, bool escape, std::wstring &message, std::wstring & perf) { 650 657 remote_channel::local_message_type msg; … … 708 715 709 716 public: 710 shared_server_session(session_handler_interface *handler ) : shared_session(_T("server"), handler) {}717 shared_server_session(session_handler_interface *handler, std::wstring title = _T("server")) : shared_session(title, handler) {} 711 718 virtual ~shared_server_session() { 712 719 if (!detached_channels_.empty()) { … … 777 784 if (msg.arguments.size() == 4) { 778 785 try { 779 //error(__FILEW__, __LINE__, _T("arg1") + msg.arguments[1]);780 //error(__FILEW__, __LINE__, _T("arg2") + msg.arguments[2]);781 //error(__FILEW__, __LINE__, _T("arg3") + msg.arguments[3]);782 786 ret = handler_->session_inject(msg.arguments[0], msg.arguments[1], strEx::stoc(msg.arguments[2]), msg.arguments[3]==_T("1"), message, perf); 783 787 } catch (...) { … … 793 797 response.arguments.push_back(message); 794 798 response.arguments.push_back(perf); 799 send_client(msg.sender, response); 800 } else if (msg.command == message_get_name) { 801 std::wstring name; 802 std::wstring version; 803 if (msg.arguments.size() == 0) { 804 try { 805 std::pair<std::wstring,std::wstring> tmp = handler_->session_get_name(); 806 name = tmp.first; 807 version = tmp.second; 808 } catch (...) { 809 name = _T("Unknown exception!"); 810 } 811 } else { 812 name = _T("Failed to get name!"); 813 } 814 remote_channel::local_message_type response; 815 response.command = message_get_name; 816 response.message_id = msg.message_id; 817 response.arguments.push_back(name); 818 response.arguments.push_back(version); 795 819 send_client(msg.sender, response); 796 820 } else { -
modules/SampleManagedPlugin/SampleManagedPlugin.vcproj
r41d25b1 r4bf9740 118 118 <Tool 119 119 Name="VCCLCompilerTool" 120 AdditionalIncludeDirectories="../include;../../include" 120 121 PreprocessorDefinitions="WIN32;NDEBUG" 121 122 RuntimeLibrary="2" -
modules/SysTray/TrayIcon.cpp
rc0522cd r4bf9740 46 46 47 47 LPFN_CHANGEWINDOWMESSAGEFILTER fnChangeWindowMessageFilter = NULL; 48 BOOL ChangeWindowMessageFilter (UINT message, DWORD what)48 BOOL ChangeWindowMessageFilter_(UINT message, DWORD what) 49 49 { 50 50 if (fnChangeWindowMessageFilter == NULL) … … 127 127 NSC_LOG_ERROR_STD(_T("Failed to register 'TaskbarCreated': ") + error::lookup::last_error()); 128 128 } 129 if (!ChangeWindowMessageFilter (UDM_TASKBARCREATED, MSGFLT_ADD)) {129 if (!ChangeWindowMessageFilter_(UDM_TASKBARCREATED, MSGFLT_ADD)) { 130 130 NSC_LOG_ERROR_STD(_T("Failed to cchange window filter: ") + error::lookup::last_error()); 131 131 }
Note: See TracChangeset
for help on using the changeset viewer.








