Changeset c760fc9 in nscp
- Timestamp:
- 01/11/11 07:07:30 (2 years ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2
- Children:
- 1f24a1c
- Parents:
- 58ee653
- Files:
-
- 3 added
- 29 edited
- 2 moved
-
CMakeLists.txt (modified) (4 diffs)
-
files/old-settings.map (added)
-
include/breakpad/exception_handler_win32.cpp (modified) (1 diff)
-
include/config.h.in (modified) (1 diff)
-
include/nscapi/nscapi_plugin_wrapper.hpp (modified) (2 diffs)
-
include/nscapi/plugin.hpp (modified) (1 diff)
-
include/nscapi/settings_proxy.hpp (added)
-
include/settings/client/settings_client.cpp (moved) (moved from include/nscapi/settings.cpp) (1 diff)
-
include/settings/client/settings_client.hpp (moved) (moved from include/nscapi/settings.hpp) (17 diffs)
-
include/settings/client/settings_proxy.hpp (added)
-
include/settings/settings_handler_impl.hpp (modified) (1 diff)
-
include/settings/settings_interface_impl.hpp (modified) (1 diff)
-
include/settings/settings_old.hpp (modified) (2 diffs)
-
modules/CheckDisk/CheckDisk.cpp (modified) (1 diff)
-
modules/CheckEventLog/CheckEventLog.cpp (modified) (1 diff)
-
modules/CheckExternalScripts/CheckExternalScripts.cpp (modified) (1 diff)
-
modules/CheckNSCP/CheckNSCP.cpp (modified) (4 diffs)
-
modules/CheckNSCP/CheckNSCP.h (modified) (1 diff)
-
modules/CheckSystem/CheckSystem.cpp (modified) (1 diff)
-
modules/FileLogger/FileLogger.cpp (modified) (1 diff)
-
modules/LUAScript/LUAScript.cpp (modified) (1 diff)
-
modules/NRPEClient/NRPEClient.cpp (modified) (1 diff)
-
modules/NRPEClient/NRPEClient.h (modified) (1 diff)
-
modules/NRPEServer/NRPEServer.cpp (modified) (1 diff)
-
modules/NSCAAgent/NSCAAgent.cpp (modified) (1 diff)
-
modules/NSCAAgent/NSCAAgent.h (modified) (1 diff)
-
modules/Scheduler/Scheduler.cpp (modified) (2 diffs)
-
service/CMakeLists.txt (modified) (5 diffs)
-
service/NSClient++.cpp (modified) (10 diffs)
-
service/NSClient++.h (modified) (1 diff)
-
service/core_api.cpp (modified) (1 diff)
-
service/settings_manager_impl.cpp (modified) (3 diffs)
-
service/settings_manager_impl.h (modified) (2 diffs)
-
service/simple_client.hpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
CMakeLists.txt
r87cf3c4 rc760fc9 57 57 # TODO 58 58 ENDIF(WIN32 AND MSVC) 59 60 61 #SET(BREAKPAD_EXCEPTION_HANDLER_LIBRARIES "${INC_GOOGLE_BREAKPAD}/src" CACHE PATH "Path to Google breakpad include folder")62 59 63 60 # ### ### ### ### … … 143 140 ENDIF(WIN32) 144 141 145 FIND_PACKAGE(GoogleBreakpad COMPONENTS common exception_handler crash_report_sender )142 FIND_PACKAGE(GoogleBreakpad COMPONENTS common exception_handler crash_report_sender crash_generation_client) 146 143 if(BREAKPAD_FOUND) 147 144 MESSAGE(STATUS "Found google breakpad") … … 241 238 ${NSCP_INCLUDEDIR}/nscapi/nscapi_plugin_wrapper.cpp 242 239 ${NSCP_INCLUDEDIR}/nscapi/nscapi_core_wrapper.cpp 243 ${NSCP_INCLUDEDIR}/ nscapi/settings.cpp240 ${NSCP_INCLUDEDIR}/settings/client/settings_client.cpp 244 241 ) 245 242 … … 253 250 ${NSCP_INCLUDEDIR}/nscapi/nscapi_plugin_wrapper.hpp 254 251 ${NSCP_INCLUDEDIR}/nscapi/nscapi_core_wrapper.hpp 255 ${NSCP_INCLUDEDIR}/nscapi/settings.hpp 252 ${NSCP_INCLUDEDIR}/settings/client/settings_client.hpp 253 ${NSCP_INCLUDEDIR}/nscapi/settings_proxy.hpp 256 254 ${NSCP_INCLUDEDIR}/nscapi/macros.hpp 257 255 ) -
include/breakpad/exception_handler_win32.cpp
r1ecd26f rc760fc9 172 172 static bool MinidumpCallback(const wchar_t *minidump_folder, const wchar_t *minidump_id, void *context, EXCEPTION_POINTERS *exinfo, MDRawAssertionInfo *assertion, bool succeeded) { 173 173 ExceptionManager* this_ptr = reinterpret_cast<ExceptionManager*>(context); 174 report_info(_T("Detected crash...")); 174 175 175 176 wchar_t minidump_path[MAX_PATH]; -
include/config.h.in
r57a86f3 rc760fc9 73 73 #define DATE_FORMAT _T("%#c") 74 74 75 #define CRASH_SUBMIT_URL _T("http://crash.nsclient.org/submit") 76 #define CRASH_ARCHIVE_FOLDER _T("${shared-path}/crash-dumps") 75 77 76 78 #ifdef WIN32 -
include/nscapi/nscapi_plugin_wrapper.hpp
r1ecd26f rc760fc9 32 32 #include <unicode_char.hpp> 33 33 #include <strEx.h> 34 #include <nscapi/settings_proxy.hpp> 34 35 35 36 #include "../libs/protobuf/plugin.proto.h" … … 176 177 return nscapi::plugin_singleton->get_core(); 177 178 } 179 inline boost::shared_ptr<nscapi::settings_proxy> get_settings_proxy() { 180 return boost::shared_ptr<nscapi::settings_proxy>(new nscapi::settings_proxy(nscapi::plugin_singleton->get_core())); 181 } 178 182 }; 179 183 -
include/nscapi/plugin.hpp
r497b779 rc760fc9 2 2 3 3 #include <nscapi/macros.hpp> 4 #include <nscapi/settings .hpp>4 #include <nscapi/settings_proxy.hpp> 5 5 #include <nscapi/nscapi_helper.hpp> 6 6 #include <nscapi/nscapi_plugin_wrapper.hpp> -
include/settings/client/settings_client.cpp
r497b779 rc760fc9 1 1 #pragma once 2 2 3 #include < nscapi/settings.hpp>3 #include <settings/client/settings_client.hpp> 4 4 5 5 namespace nscapi { -
include/settings/client/settings_client.hpp
r1ecd26f rc760fc9 12 12 namespace settings_helper { 13 13 14 class settings_impl_interface { 15 public: 16 typedef std::list<std::wstring> string_list; 17 18 ////////////////////////////////////////////////////////////////////////// 19 /// Register a path with the settings module. 20 /// A registered key or path will be nicely documented in some of the settings files when converted. 21 /// 22 /// @param path The path to register 23 /// @param title The title to use 24 /// @param description the description to use 25 /// @param advanced advanced options will only be included if they are changed 26 /// 27 /// @author mickem 28 virtual void register_path(std::wstring path, std::wstring title, std::wstring description, bool advanced) = 0; 29 30 ////////////////////////////////////////////////////////////////////////// 31 /// Register a key with the settings module. 32 /// A registered key or path will be nicely documented in some of the settings files when converted. 33 /// 34 /// @param path The path to register 35 /// @param key The key to register 36 /// @param type The type of value 37 /// @param title The title to use 38 /// @param description the description to use 39 /// @param defValue the default value 40 /// @param advanced advanced options will only be included if they are changed 41 /// 42 /// @author mickem 43 virtual void register_key(std::wstring path, std::wstring key, int type, std::wstring title, std::wstring description, std::wstring defValue, bool advanced) = 0; 44 45 ////////////////////////////////////////////////////////////////////////// 46 /// Get a string value if it does not exist the default value will be returned 47 /// 48 /// @param path the path to look up 49 /// @param key the key to lookup 50 /// @param def the default value to use when no value is found 51 /// @return the string value 52 /// 53 /// @author mickem 54 virtual std::wstring get_string(std::wstring path, std::wstring key, std::wstring def) = 0; 55 ////////////////////////////////////////////////////////////////////////// 56 /// Set or update a string value 57 /// 58 /// @param path the path to look up 59 /// @param key the key to lookup 60 /// @param value the value to set 61 /// 62 /// @author mickem 63 virtual void set_string(std::wstring path, std::wstring key, std::wstring value) = 0; 64 65 ////////////////////////////////////////////////////////////////////////// 66 /// Get an integer value if it does not exist the default value will be returned 67 /// 68 /// @param path the path to look up 69 /// @param key the key to lookup 70 /// @param def the default value to use when no value is found 71 /// @return the string value 72 /// 73 /// @author mickem 74 virtual int get_int(std::wstring path, std::wstring key, int def) = 0; 75 ////////////////////////////////////////////////////////////////////////// 76 /// Set or update an integer value 77 /// 78 /// @param path the path to look up 79 /// @param key the key to lookup 80 /// @param value the value to set 81 /// 82 /// @author mickem 83 virtual void set_int(std::wstring path, std::wstring key, int value) = 0; 84 85 ////////////////////////////////////////////////////////////////////////// 86 /// Get a boolean value if it does not exist the default value will be returned 87 /// 88 /// @param path the path to look up 89 /// @param key the key to lookup 90 /// @param def the default value to use when no value is found 91 /// @return the string value 92 /// 93 /// @author mickem 94 virtual bool get_bool(std::wstring path, std::wstring key, bool def) = 0; 95 ////////////////////////////////////////////////////////////////////////// 96 /// Set or update a boolean value 97 /// 98 /// @param path the path to look up 99 /// @param key the key to lookup 100 /// @param value the value to set 101 /// 102 /// @author mickem 103 virtual void set_bool(std::wstring path, std::wstring key, bool value) = 0; 104 105 // Meta Functions 106 ////////////////////////////////////////////////////////////////////////// 107 /// Get all (sub) sections (given a path). 108 /// If the path is empty all root sections will be returned 109 /// 110 /// @param path The path to get sections from (if empty root sections will be returned) 111 /// @return a list of sections 112 /// 113 /// @author mickem 114 virtual string_list get_sections(std::wstring path) = 0; 115 ////////////////////////////////////////////////////////////////////////// 116 /// Get all keys for a path. 117 /// 118 /// @param path The path to get keys under 119 /// @return a list of keys 120 /// 121 /// @author mickem 122 virtual string_list get_keys(std::wstring path) = 0; 123 124 125 virtual std::wstring expand_path(std::wstring key) = 0; 126 127 ////////////////////////////////////////////////////////////////////////// 128 /// Log an ERROR message. 129 /// 130 /// @param file the file where the event happened 131 /// @param line the line where the event happened 132 /// @param message the message to log 133 /// 134 /// @author mickem 135 virtual void err(std::string file, int line, std::wstring message) = 0; 136 ////////////////////////////////////////////////////////////////////////// 137 /// Log an WARNING message. 138 /// 139 /// @param file the file where the event happened 140 /// @param line the line where the event happened 141 /// @param message the message to log 142 /// 143 /// @author mickem 144 virtual void warn(std::string file, int line, std::wstring message) = 0; 145 ////////////////////////////////////////////////////////////////////////// 146 /// Log an INFO message. 147 /// 148 /// @param file the file where the event happened 149 /// @param line the line where the event happened 150 /// @param message the message to log 151 /// 152 /// @author mickem 153 virtual void info(std::string file, int line, std::wstring message) = 0; 154 ////////////////////////////////////////////////////////////////////////// 155 /// Log an DEBUG message. 156 /// 157 /// @param file the file where the event happened 158 /// @param line the line where the event happened 159 /// @param message the message to log 160 /// 161 /// @author mickem 162 virtual void debug(std::string file, int line, std::wstring message) = 0; 163 }; 164 165 typedef boost::shared_ptr<settings_impl_interface> settings_impl_interface_ptr; 14 166 15 167 class key_interface { … … 17 169 virtual NSCAPI::settings_type get_type() const = 0; 18 170 virtual std::wstring get_default_as_string() const = 0; 19 virtual void notify( nscapi::core_wrapper*core_, std::wstring path, std::wstring key) const = 0;20 virtual void notify( nscapi::core_wrapper*core_, std::wstring parent, std::wstring path, std::wstring key) const = 0;171 virtual void notify(settings_impl_interface_ptr core_, std::wstring path, std::wstring key) const = 0; 172 virtual void notify(settings_impl_interface_ptr core_, std::wstring parent, std::wstring path, std::wstring key) const = 0; 21 173 }; 22 174 template<class T> … … 47 199 return NSCAPI::key_string; 48 200 } 49 virtual void notify( nscapi::core_wrapper*core_, std::wstring path, std::wstring key) const {50 T value = boost::lexical_cast<T>(core_->get SettingsString(path, key, typed_key<T>::default_value_as_text_));201 virtual void notify(settings_impl_interface_ptr core_, std::wstring path, std::wstring key) const { 202 T value = boost::lexical_cast<T>(core_->get_string(path, key, typed_key<T>::default_value_as_text_)); 51 203 update_target(&value); 52 204 } 53 virtual void notify( nscapi::core_wrapper*core_, std::wstring parent, std::wstring path, std::wstring key) const {54 std::wstring default_value = core_->get SettingsString(parent, key, typed_key<T>::default_value_as_text_);55 T value = boost::lexical_cast<T>(core_->get SettingsString(path, key, default_value));205 virtual void notify(settings_impl_interface_ptr core_, std::wstring parent, std::wstring path, std::wstring key) const { 206 std::wstring default_value = core_->get_string(parent, key, typed_key<T>::default_value_as_text_); 207 T value = boost::lexical_cast<T>(core_->get_string(path, key, default_value)); 56 208 update_target(&value); 57 209 } … … 64 216 return NSCAPI::key_string; 65 217 } 66 virtual void notify( nscapi::core_wrapper*core_, std::wstring path, std::wstring key) const {67 std::wstring val = core_->get SettingsString(path, key, typed_key<T>::default_value_as_text_);218 virtual void notify(settings_impl_interface_ptr core_, std::wstring path, std::wstring key) const { 219 std::wstring val = core_->get_string(path, key, typed_key<T>::default_value_as_text_); 68 220 T value = boost::lexical_cast<T>(core_->expand_path(val)); 69 221 update_target(&value); 70 222 } 71 virtual void notify( nscapi::core_wrapper*core_, std::wstring parent, std::wstring path, std::wstring key) const {72 std::wstring def_val = core_->get SettingsString(parent, key, typed_key<T>::default_value_as_text_);73 std::wstring val = core_->get SettingsString(path, key, def_val);223 virtual void notify(settings_impl_interface_ptr core_, std::wstring parent, std::wstring path, std::wstring key) const { 224 std::wstring def_val = core_->get_string(parent, key, typed_key<T>::default_value_as_text_); 225 std::wstring val = core_->get_string(path, key, def_val); 74 226 T value = boost::lexical_cast<T>(core_->expand_path(val)); 75 227 update_target(&value); … … 88 240 return NSCAPI::key_integer; 89 241 } 90 virtual void notify( nscapi::core_wrapper*core_, std::wstring path, std::wstring key) const {91 T value = static_cast<T>(core_->get SettingsInt(path, key, default_value_as_int_));242 virtual void notify(settings_impl_interface_ptr core_, std::wstring path, std::wstring key) const { 243 T value = static_cast<T>(core_->get_int(path, key, default_value_as_int_)); 92 244 update_target(&value); 93 245 } 94 virtual void notify( nscapi::core_wrapper*core_, std::wstring parent, std::wstring path, std::wstring key) const {95 T default_value = static_cast<T>(core_->get SettingsInt(parent, key, default_value_as_int_));96 T value = static_cast<T>(core_->get SettingsInt(path, key, default_value));246 virtual void notify(settings_impl_interface_ptr core_, std::wstring parent, std::wstring path, std::wstring key) const { 247 T default_value = static_cast<T>(core_->get_int(parent, key, default_value_as_int_)); 248 T value = static_cast<T>(core_->get_int(path, key, default_value)); 97 249 update_target(&value); 98 250 } … … 107 259 return NSCAPI::key_bool; 108 260 } 109 virtual void notify( nscapi::core_wrapper*core_, std::wstring path, std::wstring key) const {110 T value = static_cast<T>(core_->get SettingsBool(path, key, typed_int_value<T>::default_value_as_int_==1));261 virtual void notify(settings_impl_interface_ptr core_, std::wstring path, std::wstring key) const { 262 T value = static_cast<T>(core_->get_bool(path, key, typed_int_value<T>::default_value_as_int_==1)); 111 263 update_target(&value); 112 264 } 113 virtual void notify( nscapi::core_wrapper*core_, std::wstring parent, std::wstring path, std::wstring key) const {114 T default_value = static_cast<T>(core_->get SettingsBool(parent, key, typed_int_value<T>::default_value_as_int_==1));115 T value = static_cast<T>(core_->get SettingsBool(path, key, default_value));265 virtual void notify(settings_impl_interface_ptr core_, std::wstring parent, std::wstring path, std::wstring key) const { 266 T default_value = static_cast<T>(core_->get_bool(parent, key, typed_int_value<T>::default_value_as_int_==1)); 267 T value = static_cast<T>(core_->get_bool(path, key, default_value)); 116 268 update_target(&value); 117 269 } … … 176 328 class path_interface { 177 329 public: 178 virtual void notify( nscapi::core_wrapper*core_, std::wstring path) const = 0;330 virtual void notify(settings_impl_interface_ptr core_, std::wstring path) const = 0; 179 331 }; 180 332 … … 184 336 typed_path_map(T* store_to) : store_to_(store_to) {} 185 337 186 virtual void notify( nscapi::core_wrapper*core_, std::wstring path) const {338 virtual void notify(settings_impl_interface_ptr core_, std::wstring path) const { 187 339 if (store_to_) { 188 std::list<std::wstring> list = core_->get SettingsSection(path);340 std::list<std::wstring> list = core_->get_keys(path); 189 341 T result; 190 342 BOOST_FOREACH(std::wstring key, list) { 191 result[key] = core_->get SettingsString(path, key, _T(""));343 result[key] = core_->get_string(path, key, _T("")); 192 344 } 193 345 *store_to_ = result; … … 203 355 typed_path_list(std::list<std::wstring>* store_to) : store_to_(store_to) {} 204 356 205 virtual void notify( nscapi::core_wrapper*core_, std::wstring path) const {357 virtual void notify(settings_impl_interface_ptr core_, std::wstring path) const { 206 358 if (store_to_) { 207 *store_to_ = core_->get SettingsSection(path);359 *store_to_ = core_->get_keys(path); 208 360 } 209 361 } … … 217 369 typed_path_fun_value(boost::function<void (std::wstring, std::wstring)> callback) : callback_(callback) {} 218 370 219 virtual void notify( nscapi::core_wrapper*core_, std::wstring path) const {371 virtual void notify(settings_impl_interface_ptr core_, std::wstring path) const { 220 372 if (callback_) { 221 std::list<std::wstring> list = core_->get SettingsSection(path);373 std::list<std::wstring> list = core_->get_keys(path); 222 374 BOOST_FOREACH(std::wstring key, list) { 223 std::wstring val = core_->get SettingsString(path, key, _T(""));375 std::wstring val = core_->get_string(path, key, _T("")); 224 376 callback_(key, val); 225 377 } … … 235 387 typed_path_fun(boost::function<void (std::wstring)> callback) : callback_(callback) {} 236 388 237 virtual void notify( nscapi::core_wrapper*core_, std::wstring path) const {389 virtual void notify(settings_impl_interface_ptr core_, std::wstring path) const { 238 390 if (callback_) { 239 std::list<std::wstring> list = core_->get SettingsSection(path);391 std::list<std::wstring> list = core_->get_keys(path); 240 392 BOOST_FOREACH(std::wstring key, list) { 241 393 callback_(key); … … 504 656 key_list keys_; 505 657 path_list paths_; 506 nscapi::core_wrapper*core_;658 settings_impl_interface_ptr core_; 507 659 std::wstring alias_; 508 660 public: 509 settings_registry( nscapi::core_wrapper*core) : core_(core) {}661 settings_registry(settings_impl_interface_ptr core) : core_(core) {} 510 662 void add(boost::shared_ptr<key_info> info) { 511 663 keys_.push_back(info); … … 521 673 return settings_keys_easy_init(path, this); 522 674 } 675 settings_keys_easy_init add_key_to_settings(std::wstring path) { 676 return settings_keys_easy_init(_T("/settings/") + path, this); 677 } 523 678 settings_paths_easy_init add_path() { 524 679 return settings_paths_easy_init(this); 680 } 681 settings_paths_easy_init add_path_to_settings() { 682 return settings_paths_easy_init(_T("/settings"), this); 525 683 } 526 684 … … 556 714 if (v->has_parent()) { 557 715 desc += _T(" Parent element can be found under: ") + v->parent; 558 core_-> settings_register_key(v->parent, v->key_name, v->key->get_type(), v->description.title, desc, v->key->get_default_as_string(), v->description.advanced);716 core_->register_key(v->parent, v->key_name, v->key->get_type(), v->description.title, desc, v->key->get_default_as_string(), v->description.advanced); 559 717 } 560 core_-> settings_register_key(v->path, v->key_name, v->key->get_type(), v->description.title, desc, v->key->get_default_as_string(), v->description.advanced);718 core_->register_key(v->path, v->key_name, v->key->get_type(), v->description.title, desc, v->key->get_default_as_string(), v->description.advanced); 561 719 } 562 720 } 563 721 BOOST_FOREACH(path_list::value_type v, paths_) { 564 core_-> settings_register_path(v->path_name, v->description.title, v->description.description, v->description.advanced);722 core_->register_path(v->path_name, v->description.title, v->description.description, v->description.advanced); 565 723 } 566 724 } … … 576 734 } 577 735 } catch (...) { 578 core_-> Message(NSCAPI::error,__FILE__, __LINE__, _T("Failed to register: ") + v->key_name);736 core_->err(__FILE__, __LINE__, _T("Failed to register: ") + v->key_name); 579 737 } 580 738 } … … 584 742 v->path->notify(core_, v->path_name); 585 743 } catch (...) { 586 core_-> Message(NSCAPI::error,__FILE__, __LINE__, _T("Failed to register: ") + v->path_name);744 core_->err(__FILE__, __LINE__, _T("Failed to register: ") + v->path_name); 587 745 } 588 746 } … … 590 748 } 591 749 }; 592 // class simple_alias_settings_registry : public settings_registry {593 // private:594 // std::wstring alias_;595 //596 // public:597 // simple_alias_settings_registry(nscapi::core_wrapper* core) : settings_registry(core) {}598 //599 // settings_keys_easy_init add_key_to_path_w_alias(std::wstring path) {600 // return settings_keys_easy_init(path + _T("/") + alias_, this);601 // }602 // settings_keys_easy_init add_key_to_settings(std::wstring path = _T("")) {603 // return settings_keys_easy_init(get_settings_path(path), this);604 // }605 // settings_paths_easy_init add_path_w_alias(std::wstring path) {606 // return settings_paths_easy_init(path + _T("/") + alias_, this);607 // }608 // settings_paths_easy_init add_path_to_settings(std::wstring path = _T("")) {609 // if (path.empty())610 // return settings_paths_easy_init(_T("/settings/") + alias_, this);611 // return settings_paths_easy_init(_T("/settings/") + alias_ + _T("/") + path, this);612 // }613 // static std::wstring get_settings_path(std::wstring alias, std::wstring path) {614 // if (path.empty())615 // return _T("/settings/") + alias;616 // return _T("/settings/") + alias + _T("/") + path;617 // }618 // std::wstring get_settings_path(std::wstring path) {619 // if (path.empty())620 // return _T("/settings/") + alias_;621 // return _T("/settings/") + alias_ + _T("/") + path;622 // }623 // void set_alias(std::wstring cur, std::wstring def) {624 // if (cur.empty())625 // alias_ = def;626 // else627 // alias_ = cur;628 // }629 // void set_alias(std::wstring prefix, std::wstring cur, std::wstring def) {630 // if (!prefix.empty())631 // prefix += _T("/");632 // if (cur.empty())633 // alias_ = prefix + def;634 // else635 // alias_ = prefix + cur;636 // }637 //638 // };639 750 } 640 751 } -
include/settings/settings_handler_impl.hpp
r1ecd26f rc760fc9 59 59 set_logger(NULL); 60 60 } 61 62 virtual std::wstring expand_path(std::wstring key) = 0; 61 63 62 64 ////////////////////////////////////////////////////////////////////////// -
include/settings/settings_interface_impl.hpp
r1ecd26f rc760fc9 125 125 return core_; 126 126 } 127 logger_interface* get_logger() const { 128 if (core_ == NULL) 129 throw settings_exception(_T("FATAL ERROR: Settings subsystem not initialized")); 130 return core_->get_logger(); 131 } 127 132 128 133 void add_child(std::wstring context) { -
include/settings/settings_old.hpp
r1ecd26f rc760fc9 6 6 #include <simpleini/SimpleIni.h> 7 7 #include <settings/macros.h> 8 9 #define MAIN_MODULES_SECTION_OLD _T("modules") 10 #define MAIN_SECTION_TITLE _T("Settings") 11 #define MAIN_STRING_LENGTH _T("string_length") 8 #include <iostream> 9 #include <fstream> 10 11 12 //#define MAIN_MODULES_SECTION_OLD _T("modules") 13 //#define MAIN_SECTION_TITLE _T("Settings") 14 //#define MAIN_STRING_LENGTH _T("string_length") 12 15 13 16 namespace settings { … … 16 19 public: 17 20 OLDSettings(settings::settings_core *core, std::wstring context) : settings::SettingsInterfaceImpl(core, context) { 18 add_mapping(MAIN_MODULES_SECTION, MAIN_MODULES_SECTION_OLD); 19 add_mapping(setting_keys::settings_def::PAYLOAD_LEN_PATH, setting_keys::settings_def::PAYLOAD_LEN, MAIN_SECTION_TITLE, MAIN_STRING_LENGTH); 20 21 #define SETTINGS_MAP_KEY_A(name, section, key) \ 22 add_mapping(setting_keys::name ## _PATH, setting_keys::name, section, key); 23 #define SETTINGS_MAP_SECTION_A(name, section) \ 24 add_mapping(setting_keys::name ## _PATH, section); 25 26 27 #define EXTSCRIPT_SECTION_TITLE _T("External Script") 28 #define EXTSCRIPT_SETTINGS_ALLOW_ARGUMENTS _T("allow_arguments") 29 #define EXTSCRIPT_SETTINGS_ALLOW_NASTY_META _T("allow_nasty_meta_chars") 30 #define EXTSCRIPT_SETTINGS_TIMEOUT _T("command_timeout") 31 #define EXTSCRIPT_SETTINGS_SCRIPTDIR _T("script_dir") 32 #define EXTSCRIPT_SCRIPT_SECTION_TITLE _T("External Scripts") 33 #define EXTSCRIPT_ALIAS_SECTION_TITLE _T("External Alias") 34 35 SETTINGS_MAP_KEY_A(external_scripts::TIMEOUT, EXTSCRIPT_SECTION_TITLE, EXTSCRIPT_SETTINGS_TIMEOUT); 36 SETTINGS_MAP_KEY_A(external_scripts::SCRIPT_PATH, EXTSCRIPT_SECTION_TITLE, EXTSCRIPT_SETTINGS_SCRIPTDIR); 37 SETTINGS_MAP_KEY_A(external_scripts::ALLOW_ARGS, EXTSCRIPT_SECTION_TITLE, EXTSCRIPT_SETTINGS_ALLOW_ARGUMENTS); 38 SETTINGS_MAP_KEY_A(external_scripts::ALLOW_NASTY, EXTSCRIPT_SECTION_TITLE, EXTSCRIPT_SETTINGS_ALLOW_NASTY_META); 39 40 SETTINGS_MAP_SECTION_A(external_scripts::SCRIPT_SECTION,EXTSCRIPT_SCRIPT_SECTION_TITLE); 41 SETTINGS_MAP_SECTION_A(external_scripts::ALIAS_SECTION,EXTSCRIPT_ALIAS_SECTION_TITLE); 42 43 #define LOG_SECTION_TITLE _T("log") 44 #define LOG_FILENAME _T("file") 45 #define LOG_DATEMASK _T("date_mask") 46 47 SETTINGS_MAP_KEY_A(log::FILENAME, LOG_SECTION_TITLE, LOG_FILENAME); 48 SETTINGS_MAP_KEY_A(log::DATEMASK, LOG_SECTION_TITLE, LOG_DATEMASK); 49 SETTINGS_MAP_KEY_A(log::DEBUG_LOG, LOG_SECTION_TITLE, _T("debug")); 50 51 #define EVENTLOG_SECTION_TITLE _T("Eventlog") 52 #define EVENTLOG_DEBUG _T("debug") 53 #define EVENTLOG_SYNTAX _T("syntax") 54 SETTINGS_MAP_KEY_A(event_log::DEBUG_KEY, EVENTLOG_SECTION_TITLE, EVENTLOG_DEBUG); 55 SETTINGS_MAP_KEY_A(event_log::SYNTAX, EVENTLOG_SECTION_TITLE, EVENTLOG_SYNTAX); 56 57 58 #define LUA_SCRIPT_SECTION_TITLE _T("LUA Scripts") 59 SETTINGS_MAP_SECTION_A(lua::SECTION, LUA_SCRIPT_SECTION_TITLE); 60 61 #define NRPE_SECTION_TITLE _T("NRPE") 62 #define NRPE_SETTINGS_READ_TIMEOUT _T("socket_timeout") 63 #define NRPE_SETTINGS_PORT _T("port") 64 #define NRPE_SETTINGS_BINDADDR _T("bind_to_address") 65 #define NRPE_SETTINGS_LISTENQUE _T("socket_back_log") 66 #define NRPE_SETTINGS_USE_SSL _T("use_ssl") 67 #define NRPE_SETTINGS_STRLEN _T("string_length") 68 #define NRPE_SETTINGS_PERFDATA _T("performance_data") 69 #define NRPE_HANDLER_SECTION_TITLE _T("NRPE Handlers") 70 #define NRPE_SETTINGS_SCRIPTDIR _T("script_dir") 71 #define NRPE_SETTINGS_TIMEOUT _T("command_timeout") 72 #define NRPE_SETTINGS_ALLOW_ARGUMENTS _T("allow_arguments") 73 #define NRPE_SETTINGS_ALLOW_NASTY_META _T("allow_nasty_meta_chars") 74 75 SETTINGS_MAP_KEY_A(nrpe::PORT, NRPE_SECTION_TITLE, NRPE_SETTINGS_PORT); 76 SETTINGS_MAP_KEY_A(nrpe::BINDADDR, NRPE_SECTION_TITLE, NRPE_SETTINGS_BINDADDR); 77 SETTINGS_MAP_KEY_A(nrpe::LISTENQUE, NRPE_SECTION_TITLE, NRPE_SETTINGS_LISTENQUE); 78 SETTINGS_MAP_KEY_A(nrpe::READ_TIMEOUT, NRPE_SECTION_TITLE, NRPE_SETTINGS_READ_TIMEOUT); 79 SETTINGS_MAP_KEY_A(nrpe::KEYUSE_SSL, NRPE_SECTION_TITLE, NRPE_SETTINGS_USE_SSL); 80 SETTINGS_MAP_KEY_A(nrpe::PAYLOAD_LENGTH,NRPE_SECTION_TITLE, NRPE_SETTINGS_STRLEN); 81 SETTINGS_MAP_KEY_A(nrpe::ALLOW_PERFDATA,NRPE_SECTION_TITLE, NRPE_SETTINGS_PERFDATA); 82 SETTINGS_MAP_KEY_A(nrpe::CMD_TIMEOUT, NRPE_SECTION_TITLE, NRPE_SETTINGS_TIMEOUT); 83 SETTINGS_MAP_KEY_A(nrpe::ALLOW_ARGS, NRPE_SECTION_TITLE, NRPE_SETTINGS_ALLOW_ARGUMENTS); 84 SETTINGS_MAP_KEY_A(nrpe::ALLOW_NASTY, NRPE_SECTION_TITLE, NRPE_SETTINGS_ALLOW_NASTY_META); 85 86 #define NSCA_AGENT_SECTION_TITLE _T("NSCA Agent") 87 #define NSCA_CMD_SECTION_TITLE _T("NSCA Commands") 88 89 #define NSCA_INTERVAL _T("interval") 90 #define NSCA_HOSTNAME _T("hostname") 91 #define NSCA_SERVER _T("nsca_host") 92 #define NSCA_PORT _T("nsca_port") 93 #define NSCA_ENCRYPTION _T("encryption_method") 94 #define NSCA_PASSWORD _T("password") 95 #define NSCA_DEBUG_THREADS _T("debug_threads") 96 #define NSCA_CACHE_HOST _T("cache_hostname") 97 98 SETTINGS_MAP_KEY_A(nsca::INTERVAL, NSCA_AGENT_SECTION_TITLE, NSCA_INTERVAL); 99 SETTINGS_MAP_KEY_A(nsca::HOSTNAME, NSCA_AGENT_SECTION_TITLE, NSCA_HOSTNAME); 100 SETTINGS_MAP_KEY_A(nsca::SERVER_HOST, NSCA_AGENT_SECTION_TITLE, NSCA_SERVER); 101 SETTINGS_MAP_KEY_A(nsca::SERVER_PORT, NSCA_AGENT_SECTION_TITLE, NSCA_PORT); 102 SETTINGS_MAP_KEY_A(nsca::ENCRYPTION, NSCA_AGENT_SECTION_TITLE, NSCA_ENCRYPTION); 103 SETTINGS_MAP_KEY_A(nsca::PASSWORD, NSCA_AGENT_SECTION_TITLE, NSCA_PASSWORD); 104 SETTINGS_MAP_KEY_A(nsca::THREADS, NSCA_AGENT_SECTION_TITLE, NSCA_DEBUG_THREADS); 105 SETTINGS_MAP_KEY_A(nsca::CACHE_HOST, NSCA_AGENT_SECTION_TITLE, NSCA_CACHE_HOST); 106 107 SETTINGS_MAP_SECTION_A(nsca::CMD_SECTION, NSCA_CMD_SECTION_TITLE); 108 109 #define NSCLIENT_SECTION_TITLE _T("NSClient") 110 #define NSCLIENT_SETTINGS_PORT _T("port") 111 #define NSCLIENT_SETTINGS_VERSION _T("version") 112 #define NSCLIENT_SETTINGS_BINDADDR _T("bind_to_address") 113 #define NSCLIENT_SETTINGS_LISTENQUE _T("socket_back_log") 114 #define NSCLIENT_SETTINGS_READ_TIMEOUT _T("socket_timeout") 115 116 SETTINGS_MAP_KEY_A(nsclient::PORT, NSCLIENT_SECTION_TITLE, NSCLIENT_SETTINGS_PORT); 117 SETTINGS_MAP_KEY_A(nsclient::VERSION, NSCLIENT_SECTION_TITLE, NSCLIENT_SETTINGS_VERSION); 118 SETTINGS_MAP_KEY_A(nsclient::BINDADDR, NSCLIENT_SECTION_TITLE, NSCLIENT_SETTINGS_BINDADDR); 119 SETTINGS_MAP_KEY_A(nsclient::LISTENQUE, NSCLIENT_SECTION_TITLE, NSCLIENT_SETTINGS_LISTENQUE); 120 SETTINGS_MAP_KEY_A(nsclient::READ_TIMEOUT, NSCLIENT_SECTION_TITLE, NSCLIENT_SETTINGS_READ_TIMEOUT); 121 122 } 21 std::wstring fname = core->find_file(_T("${exe-path}/old-settings.map"), _T("old-settings.map")); 22 read_map_file(fname); 23 } 24 void read_map_file(std::wstring file) { 25 get_logger()->debug(__FILE__, __LINE__, _T("Reading MAP file: ") + file); 26 27 std::ifstream in(strEx::wstring_to_string(file).c_str()); 28 if(!in) { 29 get_logger()->err(__FILE__, __LINE__, _T("Failed to read MAP file: ") + file); 30 return; 31 } 32 in.exceptions(std::ifstream::eofbit | std::ifstream::failbit | std::ifstream::badbit); 33 34 try{ 35 std::string tmp; 36 while(true) { 37 std::getline(in,tmp); 38 parse_line(to_wstring(tmp)); 39 } 40 } 41 catch(std::ifstream::failure e){ 42 if(!in.eof()) 43 cerr << e.what() <<'\n'; 44 } 45 } 46 void parse_line(std::wstring line) { 47 int pos = line.find('#'); 48 if (pos != -1) 49 line = line.substr(0, pos); 50 pos = line.find_first_not_of(_T(" \t")); 51 if (pos == -1) 52 return; 53 line = line.substr(pos); 54 pos = line.find('='); 55 if (pos == -1) { 56 get_logger()->err(__FILE__, __LINE__, _T("Invalid syntax: ") + line); 57 return; 58 } 59 std::pair<std::wstring,std::wstring> old_key = split_key(line.substr(0, pos)); 60 std::pair<std::wstring,std::wstring> new_key = split_key(line.substr(pos+1)); 61 if (old_key.second == _T("*") || old_key.second.empty()) { 62 add_mapping(new_key.first, old_key.first); 63 get_logger()->debug(__FILE__, __LINE__, _T("Adding: ") + old_key.first + _T(" >> ") + new_key.first); 64 } else { 65 add_mapping(new_key.first, new_key.second, old_key.first, old_key.second); 66 get_logger()->debug(__FILE__, __LINE__, _T("Adding: ") + old_key.first + _T(":") + old_key.second + _T(" >> ") + new_key.first + _T(":") + new_key.second); 67 } 68 69 } 70 std::pair<std::wstring,std::wstring> split_key(std::wstring key) { 71 std::pair<std::wstring,std::wstring> ret; 72 int pos = key.find_last_of('/'); 73 if (pos == -1) 74 return std::pair<std::wstring,std::wstring>(key, _T("")); 75 return std::pair<std::wstring,std::wstring>(key.substr(0, pos), key.substr(pos+1)); 76 } 77 123 78 typedef std::map<std::wstring,std::wstring> path_map; 124 79 typedef std::map<settings_core::key_path_type,settings_core::key_path_type> key_map; -
modules/CheckDisk/CheckDisk.cpp
rf7663c9 rc760fc9 51 51 get_core()->registerCommand(_T("CheckFile2"), _T("Check various aspects of a file and/or folder.")); 52 52 53 sh::settings_registry settings( nscapi::plugin_singleton->get_core());53 sh::settings_registry settings(get_settings_proxy()); 54 54 settings.set_alias(_T("NRPE"), alias, _T("server")); 55 55 -
modules/CheckEventLog/CheckEventLog.cpp
r1ecd26f rc760fc9 69 69 get_core()->registerCommand(_T("CheckEventLog"), _T("Check for errors in the event logger!")); 70 70 71 sh::settings_registry settings( nscapi::plugin_singleton->get_core());71 sh::settings_registry settings(get_settings_proxy()); 72 72 settings.set_alias(_T("CheckEventlog"), alias); 73 73 -
modules/CheckExternalScripts/CheckExternalScripts.cpp
rc015acc rc760fc9 73 73 try { 74 74 75 sh::settings_registry settings( nscapi::plugin_singleton->get_core());75 sh::settings_registry settings(get_settings_proxy()); 76 76 settings.set_alias(alias, _T("external scripts")); 77 77 -
modules/CheckNSCP/CheckNSCP.cpp
r1ecd26f rc760fc9 32 32 namespace sh = nscapi::settings_helper; 33 33 34 CheckNSCP::CheckNSCP() {35 }36 CheckNSCP::~CheckNSCP() {37 }38 39 34 bool CheckNSCP::loadModule() { 40 35 return false; 41 36 } 42 37 bool CheckNSCP::loadModuleEx(std::wstring alias, NSCAPI::moduleLoadMode mode) { 43 //std::wstring appRoot = file_helpers::folders::get_local_appdata_folder(SZAPPNAME);44 38 try { 45 39 46 sh::settings_registry settings( nscapi::plugin_singleton->get_core());40 sh::settings_registry settings(get_settings_proxy()); 47 41 settings.set_alias(_T("crash"), alias); 48 42 … … 52 46 53 47 settings.alias().add_key_to_settings() 54 (_T("archive "), sh::wstring_key(&crashFolder),55 _T("ARCHIVE FOLDER"), _T("The archive folder for crash dunpes."))48 (_T("archive folder"), sh::wstring_key(&crashFolder, CRASH_ARCHIVE_FOLDER), 49 CRASH_ARCHIVE_FOLDER_KEY, _T("The archive folder for crash dunpes.")) 56 50 ; 57 51 … … 60 54 61 55 get_core()->registerCommand(_T("check_nscp"), _T("Check the internal healt of NSClient++.")); 62 //crashFolder = NSCModuleHelper::getSettingsString(CRASH_SECTION_TITLE, CRASH_ARCHIVE_FOLDER, file_helpers::folders::get_subfolder(appRoot, _T("crash dumps")));63 64 65 56 } catch (nscapi::nscapi_exception &e) { 66 57 NSC_LOG_ERROR_STD(_T("Failed to register command: ") + e.msg_); … … 68 59 NSC_LOG_ERROR_STD(_T("Failed to register command.")); 69 60 } 70 71 61 return true; 72 62 } -
modules/CheckNSCP/CheckNSCP.h
r1ecd26f rc760fc9 30 30 error_list errors_; 31 31 public: 32 CheckNSCP();33 virtual ~CheckNSCP();34 32 // Module calls 35 33 bool loadModule(); -
modules/CheckSystem/CheckSystem.cpp
r87cf3c4 rc760fc9 70 70 bool default_counters; 71 71 72 sh::settings_registry settings(get_ core());72 sh::settings_registry settings(get_settings_proxy()); 73 73 settings.set_alias(_T("check"), alias, _T("system/windows")); 74 74 -
modules/FileLogger/FileLogger.cpp
r1ecd26f rc760fc9 93 93 std::wstring log_mask, file, root; 94 94 95 sh::settings_registry settings( nscapi::plugin_singleton->get_core());95 sh::settings_registry settings(get_settings_proxy()); 96 96 settings.set_alias(_T("log"), alias); 97 97 -
modules/LUAScript/LUAScript.cpp
r87cf3c4 rc760fc9 44 44 try { 45 45 46 sh::settings_registry settings( nscapi::plugin_singleton->get_core());46 sh::settings_registry settings(get_settings_proxy()); 47 47 settings.set_alias(alias, _T("lua")); 48 48 -
modules/NRPEClient/NRPEClient.cpp
r1ecd26f rc760fc9 51 51 52 52 //"/settings/NRPE/client/handlers" 53 sh::settings_registry settings( nscapi::plugin_singleton->get_core());53 sh::settings_registry settings(get_settings_proxy()); 54 54 settings.set_alias(_T("NRPE"), alias, _T("client")); 55 55 -
modules/NRPEClient/NRPEClient.h
r1ecd26f rc760fc9 25 25 26 26 27 class NRPEClient : public nscapi::impl::SimpleCommand {27 class NRPEClient : public nscapi::impl::SimpleCommand, nscapi::impl::simple_plugin { 28 28 private: 29 29 typedef enum { -
modules/NRPEServer/NRPEServer.cpp
rf7663c9 rc760fc9 59 59 try { 60 60 61 sh::settings_registry settings( nscapi::plugin_singleton->get_core());61 sh::settings_registry settings(get_settings_proxy()); 62 62 settings.set_alias(_T("NRPE"), alias, _T("server")); 63 63 -
modules/NSCAAgent/NSCAAgent.cpp
rf7663c9 rc760fc9 59 59 60 60 try { 61 sh::settings_registry settings( nscapi::plugin_singleton->get_core());61 sh::settings_registry settings(get_settings_proxy()); 62 62 settings.set_alias(_T("NSCA"), alias, _T("agent")); 63 63 -
modules/NSCAAgent/NSCAAgent.h
r5e12ba6 rc760fc9 24 24 NSC_WRAPPERS_CHANNELS(); 25 25 26 class NSCAAgent : public nscapi::impl::SimpleNotificationHandler {26 class NSCAAgent : public nscapi::impl::SimpleNotificationHandler, public nscapi::impl::simple_plugin { 27 27 private: 28 28 -
modules/Scheduler/Scheduler.cpp
rc015acc rc760fc9 40 40 typedef std::map<std::wstring,std::wstring> schedule_map; 41 41 schedule_map schedules; 42 sh::settings_registry settings( nscapi::plugin_singleton->get_core());42 sh::settings_registry settings(get_settings_proxy()); 43 43 settings.set_alias(_T("scheduler"), alias); 44 44 … … 96 96 std::wstring report, duration; 97 97 98 sh::settings_registry settings( nscapi::plugin_singleton->get_core());98 sh::settings_registry settings(get_settings_proxy()); 99 99 100 100 settings.path(path).add_path() -
service/CMakeLists.txt
r87cf3c4 rc760fc9 7 7 LINK_DIRECTORIES(${BOOST_LIB_DIRS}) 8 8 #INCLUDE_DIRECTORIES(${NSCP_INCLUDEDIR}) 9 10 ADD_DEFINITIONS(${NSCP_GLOBAL_DEFINES})11 9 12 10 SET(VERSION_HPP ${CMAKE_CURRENT_SOURCE_DIR}/version.hpp) … … 30 28 31 29 ${NSCP_INCLUDEDIR}/nscapi/nscapi_helper.cpp 30 ${NSCP_INCLUDEDIR}/settings/client/settings_client.cpp 32 31 33 32 ${NSCP_INCLUDEDIR}/simpleini/ConvertUTF.c … … 70 69 ${NSCP_INCLUDEDIR}/settings/settings_handler_impl.hpp 71 70 ${NSCP_INCLUDEDIR}/settings/settings_interface_impl.hpp 71 ${NSCP_INCLUDEDIR}/settings/client/settings_client.hpp 72 72 ${NSCP_INCLUDEDIR}/com_helpers.hpp 73 73 ${NSCP_INCLUDEDIR}/dll/dll.hpp … … 89 89 ENDIF(WIN32) 90 90 IF(BREAKPAD_FOUND) 91 SET(EXTRA_LIBS ${BREAKPAD_COMMON_LIBRARY}) 91 SET(service_SRCS ${service_SRCS} ${NSCP_INCLUDEDIR}/breakpad/exception_handler_win32.cpp) 92 IF(WIN32) 93 SET(service_SRCS ${service_SRCS} ${NSCP_INCLUDEDIR}/breakpad/exception_handler_win32.hpp) 94 ENDIF(WIN32) 95 SET(EXTRA_LIBS ${BREAKPAD_COMMON_LIBRARY} ${BREAKPAD_EXCEPTION_HANDLER_LIBRARY} ${BREAKPAD_CRASH_GENERATION_CLIENT_LIBRARY}) 96 ADD_DEFINITIONS(-DUSE_BREAKPAD) 92 97 ENDIF(BREAKPAD_FOUND) 93 98 … … 95 100 add_executable (${TARGET} ${service_SRCS}) 96 101 add_dependencies(${TARGET} ${TARGET}_VERSION) 102 103 MESSAGE(STATUS "Extra: ${EXTRA_LIBS}") 97 104 98 105 target_link_libraries(${TARGET} -
service/NSClient++.cpp
r1ecd26f rc760fc9 39 39 #include "service_manager.hpp" 40 40 #include <nscapi/nscapi_helper.hpp> 41 #include <settings/client/settings_client.hpp> 41 42 #include "cli_parser.hpp" 42 43 43 44 #include "../libs/protobuf/plugin.proto.h" 45 46 #ifdef USE_BREAKPAD 47 #include <breakpad/exception_handler_win32.hpp> 48 // Used for breakpad crash handling 49 static ExceptionManager *g_exception_manager = NULL; 50 #endif 44 51 45 52 NSClient mainClient(SZSERVICENAME); // Global core instance. … … 54 61 #define LOG_DEBUG_CORE_STD(msg) LOG_DEBUG_CORE(std::wstring(msg)) 55 62 56 57 #define SETTINGS_GET_BOOL_CORE(key) \58 settings_manager::get_settings()->get_bool(setting_keys::key ## _PATH, setting_keys::key, setting_keys::key ## _DEFAULT)59 60 #define SETTINGS_GET_STRING_CORE(key) \61 settings_manager::get_settings()->get_string(setting_keys::key ## _PATH, setting_keys::key, setting_keys::key ## _DEFAULT)62 /*63 #define SETTINGS_SET_STRING_CORE(key, value) \64 settings::get_settings()->set_string(setting_keys::key ## _PATH, setting_keys::key, value);65 */66 63 /** 67 64 * START OF Tray starter MERGE HELPER … … 98 95 } 99 96 100 static bool start(unsigned long dwSessionId) { 101 boost::filesystem::wpath program = mainClient.getBasePath() / SETTINGS_GET_STRING_CORE(settings_def::SYSTRAY_EXE); 102 std::wstring cmdln = _T("\"") + program.string() + _T("\" -channel __") + strEx::itos(dwSessionId) + _T("__"); 103 return tray_starter::startTrayHelper(dwSessionId, program.string(), cmdln); 97 static bool start(std::wstring command, unsigned long dwSessionId) { 98 std::wstring cmdln = _T("\"") + command + _T("\" -channel __") + strEx::itos(dwSessionId) + _T("__"); 99 return tray_starter::startTrayHelper(dwSessionId, command, cmdln); 104 100 } 105 101 … … 204 200 */ 205 201 206 #define XNSC_DEFINE_SETTING_KEY(name, tag) \207 name ## _SECTION \208 209 /**210 * RANDOM JUNK (MERGE HELP)211 */212 213 void display(std::wstring title, std::wstring message) {214 #ifdef WIN32215 ::MessageBox(NULL, message.c_str(), title.c_str(), MB_OK|MB_ICONERROR);216 #endif217 std::wcout << title << std::endl << message << std::endl;218 }219 220 221 202 bool is_module(boost::filesystem::wpath file ) 222 203 { … … 440 421 BOOST_FOREACH(std::wstring key, list) { 441 422 std::wstring val = settings_manager::get_settings()->get_string(MAIN_MODULES_SECTION, key); 423 if ((key.length() > 4) && (key.substr(key.length()-4) == _T(".dll")) ) 424 key = key.substr(0, key.length()-4); 442 425 if (val.empty() || val == _T("enabled")) { 443 426 ret.insert(plugin_alias_list_type::value_type(_T(""), key)); … … 561 544 // Service functions 562 545 546 namespace sh = nscapi::settings_helper; 547 563 548 /** 564 549 * Initialize the program … … 574 559 return false; 575 560 } 576 LOG_INFO_CORE(_T("Got settings subsystem...")); 561 LOG_INFO_CORE(_T("Booted settings subsystem...")); 562 563 bool crash_submit = false; 564 bool crash_archive = false; 565 bool crash_restart = false; 566 std::wstring crash_url, crash_folder, crash_target, log_level; 577 567 try { 578 if (debug_) 579 settings_manager::get_settings()->set_int(_T("log"), _T("debug"), 1); 580 settings_manager::get_settings()->set_int(_T("Settings"), _T("shared_Session"), 1); 581 enable_shared_session_ = false; //SETTINGS_GET_BOOL_CORE(settings_def::SHARED_SESSION); 568 569 sh::settings_registry settings(settings_manager::get_proxy()); 570 571 settings.add_path_to_settings() 572 (_T("log"), _T("LOG SETTINGS"), _T("Section for configuring the log handling.")) 573 (_T("shared session"), _T("SHRED SESSION"), _T("Section for configuring the shared session.")) 574 (_T("crash"), _T("CRASH HANDLER"), _T("Section for configuring the crash handler.")) 575 ; 576 577 settings.add_key_to_settings(_T("log")) 578 (_T("level"), sh::wstring_key(&log_level, _T("INFO")), 579 _T("LOG LEVEL"), _T("Log level to use")) 580 ; 581 582 settings.add_key_to_settings(_T("shared session")) 583 (_T("enabled"), sh::bool_key(&enable_shared_session_ , false), 584 _T("LOG LEVEL"), _T("Log level to use")) 585 ; 586 587 settings.add_key_to_settings(_T("crash")) 588 (_T("submit"), sh::bool_key(&crash_submit, false), 589 _T("SUBMIT CRASHREPORTS"), _T("Submit crash reports to nsclient.org (or your configured submission server)")) 590 591 (_T("archive"), sh::bool_key(&crash_archive, true), 592 _T("ARCHIVE CRASHREPORTS"), _T("Archive crash reports in the archive folder")) 593 594 (_T("restart"), sh::bool_key(&crash_restart, true), 595 _T("RESTART"), _T("Submit crash reports to nsclient.org (or your configured submission server)")) 596 597 (_T("restart target"), sh::wstring_key(&crash_target, SZSERVICENAME), 598 _T("RESTART SERVICE NAME"), _T("The url to submit crash reports to")) 599 600 (_T("submit url"), sh::wstring_key(&crash_url, CRASH_SUBMIT_URL), 601 _T("SUBMISSION URL"), _T("The url to submit crash reports to")) 602 603 (_T("archive folder"), sh::wpath_key(&crash_folder, CRASH_ARCHIVE_FOLDER), 604 CRASH_ARCHIVE_FOLDER_KEY, _T("The folder to archive crash dumps in")) 605 ; 606 607 settings.register_all(); 608 settings.notify(); 609 582 610 } catch (settings::settings_exception e) { 583 611 LOG_ERROR_CORE_STD(_T("Could not find settings: ") + e.getMessage()); 584 612 } 613 614 #ifdef USE_BREAKPAD 615 616 if (!g_exception_manager) { 617 g_exception_manager = new ExceptionManager(false); 618 619 g_exception_manager->setup_app(to_wstring(SZSERVICENAME), to_wstring(STRPRODUCTVER), to_wstring(STRPRODUCTDATE)); 620 621 if (crash_restart) { 622 LOG_DEBUG_CORE(_T("On crash: restart: ") + crash_target); 623 g_exception_manager->setup_restart(crash_target); 624 } 625 626 bool crashHandling = false; 627 if (crash_submit) { 628 g_exception_manager->setup_submit(false, crash_url); 629 LOG_DEBUG_CORE(_T("Submitting crash dumps to central server: ") + crash_url); 630 crashHandling = true; 631 } 632 if (crash_archive) { 633 g_exception_manager->setup_archive(crash_folder); 634 LOG_DEBUG_CORE(_T("Archiving crash dumps in: ") + crash_folder); 635 crashHandling = true; 636 } 637 if (!crashHandling) { 638 LOG_ERROR_CORE(_T("No crash handling configured")); 639 } else { 640 g_exception_manager->StartMonitoring(); 641 } 642 } 643 #else 644 LOG_ERROR_CORE(_T("Warning Not compiled with google breakpad support!")); 645 #endif 646 585 647 586 648 if (enable_shared_session_) { … … 801 863 // return; 802 864 // } 803 LOG_DEBUG_CORE_STD(_T("Got session change: ") + strEx::itos(dwSessionId));804 if (!logon) {805 LOG_DEBUG_CORE_STD(_T("Not a logon event: ") + strEx::itos(dwEventType));806 return;807 }808 tray_starter::start(dwSessionId);865 // LOG_DEBUG_CORE_STD(_T("Got session change: ") + strEx::itos(dwSessionId)); 866 // if (!logon) { 867 // LOG_DEBUG_CORE_STD(_T("Not a logon event: ") + strEx::itos(dwEventType)); 868 // return; 869 // } 870 // tray_starter::start(dwSessionId); 809 871 } 810 872 … … 856 918 } 857 919 858 /** 859 * Load a list of plug-ins 860 * @param plugins A list with plug-ins (DLL files) to load 861 */ 862 // void NSClientT::addPlugins(const std::list<std::wstring> plugins) { 863 // boost::shared_lock<boost::shared_mutex> readLock(m_mutexRW, boost::get_system_time() + boost::posix_time::seconds(10)); 864 // if (!readLock.owns_lock()) { 865 // LOG_ERROR_CORE(_T("FATAL ERROR: Could not get read-mutex (002).")); 866 // return; 867 // } 868 // std::list<std::wstring>::const_iterator it; 869 // for (it = plugins.begin(); it != plugins.end(); ++it) { 870 // loadPlugin(*it); 871 // } 872 // } 920 873 921 /** 874 922 * Unload all plug-ins (in reversed order) … … 1015 1063 void NSClientT::registerCommand(unsigned int id, std::wstring cmd, std::wstring desc) { 1016 1064 return commands_.register_command(id, cmd, desc); 1017 }1018 1019 unsigned int NSClientT::getBufferLength() {1020 static unsigned int len = 0;1021 if (len == 0) {1022 try {1023 len = settings_manager::get_settings()->get_int(SETTINGS_KEY(settings_def::PAYLOAD_LEN));1024 } catch (settings::settings_exception &e) {1025 LOG_DEBUG_CORE_STD(_T("Failed to get length: ") + e.getMessage());1026 return setting_keys::settings_def::PAYLOAD_LEN_DEFAULT;1027 } catch (...) {1028 LOG_ERROR_CORE(_T("Failed to get length: :("));1029 return setting_keys::settings_def::PAYLOAD_LEN_DEFAULT;1030 }1031 }1032 return len;1033 1065 } 1034 1066 -
service/NSClient++.h
r1ecd26f rc760fc9 171 171 std::list<std::wstring> getAllCommandNames(); 172 172 void registerCommand(unsigned int id, std::wstring cmd, std::wstring desc); 173 unsigned int getBufferLength();174 173 void startTrayIcons(); 175 174 void startTrayIcon(DWORD dwSessionId); -
service/core_api.cpp
r1ecd26f rc760fc9 20 20 #include <msvc_wrappers.h> 21 21 #include <arrayBuffer.h> 22 //#include <settings/settings_ini.hpp>23 //#include <settings/settings_registry.hpp>24 //#include <settings/settings_old.hpp>25 22 #include <settings/settings_core.hpp> 26 23 #include "settings_manager_impl.h" -
service/settings_manager_impl.cpp
r1ecd26f rc760fc9 2 2 3 3 #include "settings_manager_impl.h" 4 #include <settings/client/settings_proxy.hpp> 5 #include <settings/client/settings_client.hpp> 4 6 #include <config.h> 5 7 #include "NSClient++.h" … … 12 14 namespace settings_manager { 13 15 // Alias to make handling "compatible" with old syntax 16 nscapi::settings_helper::settings_impl_interface_ptr get_proxy() { 17 return nscapi::settings_helper::settings_impl_interface_ptr(new settings_client::settings_proxy(SettingsHandler::getInstance())); 18 } 14 19 settings::instance_ptr get_settings() { 15 20 return SettingsHandler::getInstance()->get(); … … 31 36 return mainClient.expand_path(file); 32 37 } 38 std::wstring NSCSettingsImpl::expand_path(std::wstring file) { 39 return mainClient.expand_path(file); 40 } 41 33 42 34 43 ////////////////////////////////////////////////////////////////////////// -
service/settings_manager_impl.h
r291548e rc760fc9 4 4 #include <settings/settings_core.hpp> 5 5 #include <settings/settings_ini.hpp> 6 #include <settings/client/settings_client.hpp> 6 7 #ifdef WIN32 7 8 #include <settings/settings_old.hpp> … … 47 48 // Alias to make handling "compatible" with old syntax 48 49 settings::instance_ptr get_settings(); 49 settings::instance_ptr get_settings_no_wait();50 settings::instance_ptr get_settings_no_wait(); 50 51 settings::settings_core* get_core(); 52 nscapi::settings_helper::settings_impl_interface_ptr get_proxy(); 51 53 void destroy_settings(); 52 54 bool init_settings(std::wstring context = _T("")); -
service/simple_client.hpp
r497b779 rc760fc9 52 52 core_->startTrayIcon(0); 53 53 } else if (s == _T("assert")) { 54 int *foo = 0; 55 *foo = 0; 54 56 throw "test"; 55 57 } else {
Note: See TracChangeset
for help on using the changeset viewer.








