Changeset 231
- Timestamp:
- 01/07/10 08:11:39 (2 years ago)
- Location:
- trunk/service
- Files:
-
- 2 edited
-
NSClient++.cpp (modified) (1 diff)
-
NSClient++.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/service/NSClient++.cpp
r230 r231 523 523 } 524 524 525 void NSClientT::HandleSettingsCLI(wchar_t* arg, int argc, wchar_t* argv[]) {526 std::wstring sarg = arg;527 try {528 if (sarg == _T("migrate")) {529 if (argc == 0) {530 LOG_ERROR_CORE_STD(_T("In correct syntax: nsclient++ -settings migrate <to>"));531 return;532 }533 std::wstring to = argv[0];534 LOG_DEBUG_STD(_T("Migrating to: ") + to);535 try {536 settings_manager::get_core()->migrate_to(Settings::SettingsCore::string_to_type(to));537 } catch (SettingsException e) {538 LOG_CRITICAL_STD(_T("Failed to migrate settings: ") + e.getError());539 }540 } else if (sarg == _T("generate")) {541 if (argc == 0) {542 LOG_ERROR_CORE_STD(_T("In correct syntax: nsclient++ -settings generate <what>"));543 LOG_ERROR_CORE_STD(_T(" where <what> is one of ths following:"));544 LOG_ERROR_CORE_STD(_T(" trac"));545 LOG_ERROR_CORE_STD(_T(" default"));546 LOG_ERROR_CORE_STD(_T(" <type>"));547 return;548 }549 std::wstring arg1 = argv[0];550 if (arg1 == _T("default")) {551 try {552 load_all_plugins(NSCAPI::dontStart);553 settings_manager::get_core()->update_defaults();554 settings_manager::get_core()->get()->save();555 } catch (SettingsException e) {556 LOG_CRITICAL_STD(_T("Failed to migrate settings: ") + e.getError());557 }558 } else if (arg1 == _T("trac")) {559 try {560 load_all_plugins(NSCAPI::dontStart);561 562 Settings::string_list s = settings_manager::get_core()->get_reg_sections();563 for (Settings::string_list::const_iterator cit = s.begin(); cit != s.end(); ++cit) {564 std::wcout << _T("== ") << (*cit) << _T(" ==") << std::endl;565 Settings::string_list k = settings_manager::get_core()->get_reg_keys(*cit);566 bool first = true;567 for (Settings::string_list::const_iterator citk = k.begin(); citk != k.end(); ++citk) {568 Settings::SettingsCore::key_description desc = settings_manager::get_core()->get_registred_key(*cit, *citk);569 if (!desc.advanced) {570 if (first)571 std::wcout << _T("'''Normal settings'''") << std::endl;572 first = false;573 std::wcout << _T("||") << (*citk) << _T("||") << desc.defValue << _T("||") << desc.title << _T(": ") << desc.description574 << std::endl;575 }576 }577 first = true;578 for (Settings::string_list::const_iterator citk = k.begin(); citk != k.end(); ++citk) {579 Settings::SettingsCore::key_description desc = settings_manager::get_core()->get_registred_key(*cit, *citk);580 if (desc.advanced) {581 if (first)582 std::wcout << _T("'''Advanced settings'''") << std::endl;583 first = false;584 std::wcout << _T("||") << (*citk) << _T("||") << desc.defValue << _T("||") << desc.title << _T(": ") << desc.description585 << std::endl;586 }587 }588 }589 } catch (SettingsException e) {590 LOG_CRITICAL_STD(_T("Failed to migrate settings: ") + e.getError());591 }592 } else {593 try {594 Settings::SettingsCore::settings_type type = settings_manager::get_core()->string_to_type(arg1);595 load_all_plugins(NSCAPI::dontStart);596 settings_manager::get_core()->update_defaults();597 settings_manager::get_core()->get(type)->save();598 } catch (SettingsException e) {599 LOG_CRITICAL_STD(_T("Failed to migrate settings: ") + e.getError());600 }601 }602 } else {603 LOG_ERROR_CORE_STD(_T("In correct syntax: nsclient++ -settings <keyword>"));604 LOG_ERROR_CORE_STD(_T(" <keyword> : "));605 LOG_ERROR_CORE_STD(_T(" migrate - migrate to a new setings subsystem"));606 LOG_ERROR_CORE_STD(_T(" copy - copy settings from one subsystem to another"));607 LOG_ERROR_CORE_STD(_T(" set - Set a setting system as the default store"));608 }609 610 611 } catch (SettingsException e) {612 LOG_CRITICAL_STD(_T("Failed to initialize settings: ") + e.getError());613 } catch (...) {614 LOG_CRITICAL(_T("FATAL ERROR IN SETTINGS SUBSYTEM"));615 }616 617 }618 619 525 void NSClientT::session_error(std::wstring file, unsigned int line, std::wstring msg) { 620 526 NSAPIMessage(NSCAPI::error, file.c_str(), line, msg.c_str()); -
trunk/service/NSClient++.h
r230 r231 178 178 void registerCommand(unsigned int id, std::wstring cmd, std::wstring desc); 179 179 unsigned int getBufferLength(); 180 void HandleSettingsCLI(wchar_t* arg, int argc, wchar_t* argv[]);181 180 void startTrayIcons(); 182 181 void startTrayIcon(DWORD dwSessionId);
Note: See TracChangeset
for help on using the changeset viewer.







