Changeset 4bf9740 in nscp


Ignore:
Timestamp:
09/17/08 21:10:18 (5 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2, stable
Children:
08f0346
Parents:
7e74e2c
Message:

2008-09-17 MickeM - 0.3.4 RC-6

  • Fixed issue on all filters so == takes the "usual" 2 equalsigns (old still works).
  • Added so tray icon can get "propper" name from core for "description".

2008-09-16 MickeM - 0.3.4 RC-5

  • Fixed an issue with the session launcher
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • AutoBuild.h

    rc37e58f r4bf9740  
    33// change the FALSE to TRUE for autoincrement of build number 
    44#define INCREMENT_VERSION TRUE 
    5 #define FILEVER        0,3,4,28 
    6 #define PRODUCTVER     0,3,4,28 
    7 #define STRFILEVER     _T("0.3.4.28") 
    8 #define STRPRODUCTVER  _T("0.3.4.28") 
    9 #define STRPRODUCTDATE  _T("2008-09-14") 
     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") 
    1010#endif // AUTOBUILD_H 
  • NSClient++-2005.sln

    r7e74e2c r4bf9740  
    12461246    {D367E76D-9485-4DCB-A9D0-3D3C0E190648}.Nightly|Mixed Platforms.Build.0 = Release|Win32 
    12471247    {D367E76D-9485-4DCB-A9D0-3D3C0E190648}.Nightly|Win32.ActiveCfg = Release|Win32 
    1248     {D367E76D-9485-4DCB-A9D0-3D3C0E190648}.Nightly|Win32.Build.0 = Release|Win32 
    12491248    {D367E76D-9485-4DCB-A9D0-3D3C0E190648}.Nightly|x64.ActiveCfg = Release|Win32 
    12501249    {D367E76D-9485-4DCB-A9D0-3D3C0E190648}.Release|Any CPU.ActiveCfg = Release|Win32 
  • NSClient++.cpp

    r41d25b1 r4bf9740  
    275275      } 
    276276      if (server) 
    277         mainClient.startTrayIcon(0); 
     277        mainClient.startTrayIcons(); 
    278278      LOG_MESSAGE_STD(_T("Using settings from: ") + Settings::getInstance()->getActiveType()); 
    279279      LOG_MESSAGE(_T("Enter command to inject or exit to terminate...")); 
     
    350350} 
    351351 
     352void 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 
    352356 
    353357 
     
    503507    LOG_DEBUG_STD(_T("Found ") + strEx::itos(count) + _T(" sessions")); 
    504508    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)); 
    506510      if (list[i].State == remote_processes::_WTS_CONNECTSTATE_CLASS::WTSActive) { 
    507511        startTrayIcon(list[i].SessionId); 
     
    609613} 
    610614DWORD 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)); 
    612615  return mainClient.service_ctrl_ex(dwControl, dwEventType, lpEventData, lpContext); 
    613616} 
     
    618621 */ 
    619622void WINAPI NSClientT::service_ctrl_dispatch(DWORD dwCtrlCode) { 
    620   LOG_DEBUG_STD(_T("service_ctrl_dispatch dispatching event: ") + strEx::itos(dwCtrlCode)); 
    621623  mainClient.service_ctrl_ex(dwCtrlCode, NULL, NULL, NULL); 
    622624} 
     
    624626 
    625627void NSClientT::service_on_session_changed(DWORD dwSessionId, bool logon, DWORD dwEventType) { 
    626   if (shared_server_.get() != NULL) { 
     628  if (shared_server_.get() == NULL) { 
    627629    LOG_DEBUG_STD(_T("No shared session: ignoring change event!")); 
    628630    return; 
  • NSClient++.h

    rbc97cd8 r4bf9740  
    149149  // Shared session interface: 
    150150  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); 
    151152  void session_log_message(int msgType, const TCHAR* file, const int line, std::wstring message) { 
    152153    reportMessage(msgType, file, line, message); 
     
    154155  int session_inject(std::wstring command, std::wstring arguments, TCHAR splitter, bool escape, std::wstring &msg, std::wstring & perf) { 
    155156    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); 
    156160  } 
    157161 
  • changelog

    r41d25b1 r4bf9740  
    55 * Improved socket performance (would be nice if we could be used as a "hub") 
    66 
     72008-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 
     112008-09-16 MickeM - 0.3.4 RC-5 
     12 * Fixed an issue with the session launcher 
     13 
    7142008-09-15 MickeM 
    815 * Fixed so NSCLient++ can load with "broken plugins" (before it printed an error and exited) 
    916 + Added a very basic simple .net plugin (and a wrapper) 
     17 
     182008-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) 
    1021 
    11222008-09-14 MickeM - 0.3.4 RC-4 
  • helpers/systray_helper/TrayWidget.cpp

    ra34b229 r4bf9740  
    5050typedef BOOL (WINAPI *LPFN_CHANGEWINDOWMESSAGEFILTER) (UINT, DWORD); 
    5151LPFN_CHANGEWINDOWMESSAGEFILTER fnChangeWindowMessageFilter = NULL; 
    52 BOOL ChangeWindowMessageFilter(UINT message, DWORD what) 
     52BOOL ChangeWindowMessageFilter_(UINT message, DWORD what) 
    5353{ 
    5454  if (fnChangeWindowMessageFilter == NULL) { 
     
    8585  LOG_MESSAGE_TRAY(_T("Attempting to launch system tray module for ") + channel_id_); 
    8686  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   } 
    9487} 
    9588TrayWidget::~TrayWidget() { 
     
    111104  try { 
    112105    shared_client_.reset(new nsclient_session::shared_client_session(channel_id_, this)); 
    113     if (shared_client_.get() != NULL) 
     106    if (shared_client_.get() != NULL) { 
    114107      shared_client_->attach_to_session(channel_id_); 
     108      TrayIcon::addIcon(hDlgWnd); 
     109    } 
    115110  } catch (nsclient_session::session_exception e) { 
    116111    LOG_ERROR_TRAY(_T("Failed to attach to shared session: ") + e.what()); 
     
    124119  return shared_client_->inject(command, arguments, splitter, escape, msg, perf); 
    125120} 
     121std::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} 
    126128 
    127129 
     
    131133  LOG_MESSAGE_TRAY(_T("Creating dialog...")); 
    132134  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 //  } 
    137135 
    138136  WNDCLASSEX wndclass; 
     
    149147  wndclass.lpszClassName=_T("NSClient_pp_TrayClass"); 
    150148  wndclass.style=0; 
    151   // register task bar restore event after crash 
    152   //WM_TASKBARCREATED=RegisterWindowMessage(TEXT("TaskbarCreated")); 
    153   //MyChangeWindowMessageFilter(WM_TASKBARCREATED, MSGFLT_ADD);  
    154149 
    155150  UINT UDM_TASKBARCREATED = RegisterWindowMessage(_T("TaskbarCreated")); 
     
    157152    LOG_ERROR_TRAY(_T("Failed to register 'TaskbarCreated': ") + error::lookup::last_error()); 
    158153  } 
    159   if (!ChangeWindowMessageFilter(UDM_TASKBARCREATED, MSGFLT_ADD)) { 
     154  if (!ChangeWindowMessageFilter_(UDM_TASKBARCREATED, MSGFLT_ADD)) { 
    160155    LOG_ERROR_TRAY(_T("Failed to cchange window filter: ") + error::lookup::last_error()); 
    161156  } 
     
    185180  } 
    186181  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 exit 
    200       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   */ 
    209182} 
    210183 
    211184void TrayWidget::session_error(std::wstring file, unsigned int line, std::wstring msg) { 
    212185  log(_T("error"), file.c_str(), line, msg); 
     186} 
     187void TrayWidget::session_info(std::wstring file, unsigned int line, std::wstring msg) { 
     188  log(_T("info"), file.c_str(), line, msg); 
    213189} 
    214190 
     
    353329      SetDlgItemText(hWnd, IDC_MSG, msg.c_str()); 
    354330      SetDlgItemText(hWnd, IDC_PERF, perf.c_str()); 
     331    } else if (cmd == _T("connect-service")) { 
     332      gTrayInstance->connectService(); 
    355333    } 
    356334    return 0; 
     
    364342  } 
    365343 
     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  } 
    366348  static void updateServiceStatus(HMENU hMenu) { 
    367349    Thread<worker_thread> *pThread = new Thread<worker_thread>(_T("tray-worker-thread")); 
     
    586568  if (uMsg == UDM_TASKBARCREATED) { 
    587569    addIcon(hwndDlg); 
    588     LOG_MESSAGE_TO_TRAY(_T("UDM_TASKBARCREATED")); 
    589570  } 
    590571 
     
    600581  case WM_CREATE: 
    601582  case WM_INITDIALOG: 
    602     LOG_MESSAGE_TO_TRAY(_T("WM_INITDIALOG")); 
    603  
    604  
    605583    UDM_TASKBARCREATED = RegisterWindowMessage(_T("TaskbarCreated")); 
    606584    if (UDM_TASKBARCREATED == 0) { 
    607585      LOG_MESSAGE_TO_TRAY(_T("Failed to register 'TaskbarCreated': ") + error::lookup::last_error()); 
    608586    } 
    609     if (!ChangeWindowMessageFilter(UDM_TASKBARCREATED, MSGFLT_ADD)) { 
     587    if (!ChangeWindowMessageFilter_(UDM_TASKBARCREATED, MSGFLT_ADD)) { 
    610588      LOG_MESSAGE_TO_TRAY(_T("Failed to cchange window filter: ") + error::lookup::last_error()); 
    611589    } 
    612590 
    613591    addIcon(hwndDlg); 
     592    worker_thread::connectService(); 
    614593    break; 
    615594 
     
    619598      { 
    620599      case ID_POPUP_CONNECT: 
    621         gTrayInstance->connectService(); 
     600        worker_thread::connectService(); 
    622601        break; 
    623602      case ID_POPUP_CLOSE: 
     
    680659  ndata.uCallbackMessage=WM_ICON_NOTIFY; 
    681660  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; 
    683663  wcsncpy_s(ndata.szTip, 64, title.c_str(), min(64, title.size())); 
    684664  Shell_NotifyIcon(NIM_ADD,&ndata); 
  • helpers/systray_helper/TrayWidget.h

    ra34b229 r4bf9740  
    6060  void log(std::wstring category, const TCHAR* file, const int line, std::wstring message); 
    6161  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); 
    6263  void session_log_message(int msgType, const TCHAR* file, const int line, std::wstring message); 
    6364  int session_inject(std::wstring command, std::wstring arguments, TCHAR splitter, bool escape, std::wstring &msg, std::wstring & perf) { 
    6465    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("")); 
    6569  } 
    6670 
     
    6973  HWND getLogWindow() const { return hLogWnd; } 
    7074  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(); 
    7176 
    7277 
  • include/filter_framework.hpp

    r367bf20 r4bf9740  
    266266        throw parse_exception(_T("Regular expression support not enabled!") + value); 
    267267#endif 
     268      } else if (t.first.length() > 1 && t.first[0] == L'=') { 
     269        exact = t.first.substr(1); 
    268270      } else { 
    269271        exact = t.first; 
  • include/nsclient_session.hpp

    ra34b229 r4bf9740  
    1212    std::wstring what_; 
    1313  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) {} 
    1815    std::wstring what() { 
    1916      return what_; 
     
    2421  public: 
    2522    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; 
    2624    virtual void session_log_message(int msgType, const TCHAR* file, const int line, std::wstring message) = 0; 
    2725    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; 
    2827  }; 
    2928 
     
    4039  const static std::wstring message_log = _T("core_log"); 
    4140  const static std::wstring message_inject = _T("core_inject"); 
     41  const static std::wstring message_get_name = _T("core_get_name"); 
    4242  const static std::wstring message_master_shutdown = _T("core_master_shutdown"); 
    4343  const static std::wstring message_master_attach = _T("core_master_attach"); 
     
    6969    shared_memory_handler shared_memory; 
    7070    std::wstring channel_name_; 
    71  
    72     //static const std::wstring channel_prefix; 
    7371 
    7472  public: 
     
    367365    void info(std::wstring file, unsigned int line, std::wstring msg) { 
    368366      if (handler_) 
    369         handler_->session_error(file, line, msg); 
     367        handler_->session_info(file, line, msg); 
    370368    } 
    371369 
     
    647645    } 
    648646 
     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    } 
    649656    int inject(std::wstring command, std::wstring arguments, TCHAR splitter, bool escape, std::wstring &message, std::wstring & perf) { 
    650657      remote_channel::local_message_type msg; 
     
    708715 
    709716  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) {} 
    711718    virtual ~shared_server_session() { 
    712719      if (!detached_channels_.empty()) { 
     
    777784        if (msg.arguments.size() == 4) { 
    778785          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]); 
    782786            ret = handler_->session_inject(msg.arguments[0], msg.arguments[1], strEx::stoc(msg.arguments[2]), msg.arguments[3]==_T("1"), message, perf); 
    783787          } catch (...) { 
     
    793797        response.arguments.push_back(message); 
    794798        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); 
    795819        send_client(msg.sender, response); 
    796820      } else { 
  • modules/SampleManagedPlugin/SampleManagedPlugin.vcproj

    r41d25b1 r4bf9740  
    118118      <Tool 
    119119        Name="VCCLCompilerTool" 
     120        AdditionalIncludeDirectories="../include;../../include" 
    120121        PreprocessorDefinitions="WIN32;NDEBUG" 
    121122        RuntimeLibrary="2" 
  • modules/SysTray/TrayIcon.cpp

    rc0522cd r4bf9740  
    4646 
    4747LPFN_CHANGEWINDOWMESSAGEFILTER fnChangeWindowMessageFilter = NULL; 
    48 BOOL ChangeWindowMessageFilter(UINT message, DWORD what) 
     48BOOL ChangeWindowMessageFilter_(UINT message, DWORD what) 
    4949{ 
    5050  if (fnChangeWindowMessageFilter == NULL) 
     
    127127    NSC_LOG_ERROR_STD(_T("Failed to register 'TaskbarCreated': ") + error::lookup::last_error()); 
    128128  } 
    129   if (!ChangeWindowMessageFilter(UDM_TASKBARCREATED, MSGFLT_ADD)) { 
     129  if (!ChangeWindowMessageFilter_(UDM_TASKBARCREATED, MSGFLT_ADD)) { 
    130130    NSC_LOG_ERROR_STD(_T("Failed to cchange window filter: ") + error::lookup::last_error()); 
    131131  } 
Note: See TracChangeset for help on using the changeset viewer.