Changeset 6533c1a in nscp for include


Ignore:
Timestamp:
04/17/12 17:56:20 (13 months ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2
Children:
308ae18
Parents:
682ccd2
Message:
  • Fixed so keys with parents are advanced (in favour of the parent)
  • Fixed so NSClientServer uses the correct default path for its parents (ie. /settings/default)
Location:
include
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • include/nsclient/base_logger_impl.hpp

    r440c0cb r6533c1a  
    1616      NSCAPI::log_level::level level_; 
    1717      bool console_log_; 
     18      bool is_running_; 
    1819    public: 
    19       logging_interface_impl() : level_(NSCAPI::log_level::info), console_log_(false) {} 
     20      logging_interface_impl() : level_(NSCAPI::log_level::info), console_log_(false), is_running_(false) {} 
     21      virtual ~logging_interface_impl() {} 
    2022 
    2123 
     
    6668      virtual void do_log(const std::string &data) = 0; 
    6769      virtual void configure() = 0; 
    68       virtual bool shutdown() = 0; 
    69       virtual bool startup() = 0; 
     70      virtual bool shutdown() { 
     71        is_running_ = false; 
     72        return true; 
     73      } 
     74      virtual bool startup() { 
     75        is_running_ = true; 
     76        return true; 
     77      } 
     78 
     79      bool is_started() const { 
     80        return is_running_; 
     81      } 
     82       
    7083    }; 
    7184    typedef boost::shared_ptr<nsclient::logging::logging_interface_impl> log_impl_type; 
  • include/settings/client/settings_client.hpp

    r83c2453 r6533c1a  
    6565        std::wstring data = core_->get_string(path, key, dummy); 
    6666        if (typed_key<T>::has_default_ || data != dummy) { 
    67           T value = boost::lexical_cast<T>(data); 
    68           update_target(&value); 
     67          try { 
     68            T value = boost::lexical_cast<T>(data); 
     69            update_target(&value); 
     70          } catch (const std::exception &e) { 
     71            core_->err(__FILE__, __LINE__, _T("Failed to parse key: ") + path + _T("/") + key + _T(": ") + utf8::to_unicode(e.what())); 
     72          } 
    6973        } 
    7074      } 
     
    7882        data = core_->get_string(path, key, dummy); 
    7983        if (typed_key<T>::has_default_ || data != dummy) { 
    80           T value = boost::lexical_cast<T>(data); 
    81           update_target(&value); 
     84          try { 
     85            T value = boost::lexical_cast<T>(data); 
     86            update_target(&value); 
     87          } catch (const std::exception &e) { 
     88            core_->err(__FILE__, __LINE__, _T("Failed to parse key: ") + path + _T("/") + key + _T(": ") + utf8::to_unicode(e.what())); 
     89          } 
    8290        } 
    8391      } 
     
    96104        std::wstring data = core_->get_string(path, key, dummy); 
    97105        if (typed_key<T>::has_default_ || data != dummy) { 
    98           T value = boost::lexical_cast<T>(core_->expand_path(data)); 
    99           update_target(&value); 
     106          try { 
     107            T value = boost::lexical_cast<T>(core_->expand_path(data)); 
     108            update_target(&value); 
     109          } catch (const std::exception &e) { 
     110            core_->err(__FILE__, __LINE__, _T("Failed to parse key: ") + path + _T("/") + key + _T(": ") + utf8::to_unicode(e.what())); 
     111          } 
    100112        } 
    101113      } 
     
    109121        data = core_->get_string(path, key, dummy); 
    110122        if (typed_key<T>::has_default_ || data != dummy) { 
    111           T value = boost::lexical_cast<T>(core_->expand_path(data)); 
    112           update_target(&value); 
     123          try { 
     124            T value = boost::lexical_cast<T>(core_->expand_path(data)); 
     125            update_target(&value); 
     126          } catch (const std::exception &e) { 
     127            core_->err(__FILE__, __LINE__, _T("Failed to parse key: ") + path + _T("/") + key + _T(": ") + utf8::to_unicode(e.what())); 
     128          } 
    113129        } 
    114130      } 
     
    676692          if (v->key) { 
    677693            //std::wcout << _T("Setting: ") << v->key_name << _T(" ===> ") << v->parent << std::endl; 
    678             std::wstring desc = v->description.description; 
    679694            if (v->has_parent()) { 
    680               desc += _T(" Parent element can be found under: ") + v->parent; 
    681               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); 
     695              core_->register_key(v->parent, v->key_name, v->key->get_type(), v->description.title, v->description.description, v->key->get_default_as_string(), v->description.advanced); 
     696              std::wstring desc = v->description.description + _T(" parent for this key is found under: ") + v->parent + _T(" this is marked as advanced in favour of the parent."); 
     697              core_->register_key(v->path, v->key_name, v->key->get_type(), v->description.title, desc, v->key->get_default_as_string(), true); 
     698            } else { 
     699              core_->register_key(v->path, v->key_name, v->key->get_type(), v->description.title, v->description.description, v->key->get_default_as_string(), v->description.advanced); 
    682700            } 
    683             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); 
    684701          } 
    685702        } 
  • include/settings/settings_handler_impl.hpp

    r8d89d7a r6533c1a  
    125125              else if (desc.type == key_bool) 
    126126                get()->set_bool(path, key, settings::settings_interface::string_to_bool(desc.defValue)); 
    127               else if (desc.type == key_integer) 
    128                 get()->set_int(path, key, strEx::stoi(desc.defValue)); 
    129               else 
     127              else if (desc.type == key_integer) { 
     128                try { 
     129                  get()->set_int(path, key, strEx::stoi(desc.defValue)); 
     130                } catch (const std::exception &e) { 
     131                  get_logger()->error(__FILE__, __LINE__, _T("invalid default value for: ") + path + _T(".") + key); 
     132                } 
     133              } else 
    130134                get_logger()->error(__FILE__, __LINE__, _T("Unknown keytype for: ") + path + _T(".") + key); 
    131135            } else { 
  • include/settings/settings_interface_impl.hpp

    r8d89d7a r6533c1a  
    6868      } 
    6969      int get_int() const { 
    70         if (type==settings_core::key_string) 
    71           return strEx::stoi(string_val); 
    72         if (type==settings_core::key_integer) 
    73           return int_val; 
    74         if (type==settings_core::key_bool) 
    75           return int_val==1?1:0; 
    76         return -1; 
     70        try { 
     71          if (type==settings_core::key_string) 
     72            return strEx::stoi(string_val); 
     73          if (type==settings_core::key_integer) 
     74            return int_val; 
     75          if (type==settings_core::key_bool) 
     76            return int_val==1?1:0; 
     77          return -1; 
     78        } catch (std::exception &e) { 
     79          return -1; 
     80        } 
    7781      } 
    7882      bool get_bool() const { 
     
    388392    virtual string_list get_sections(std::wstring path) { 
    389393      MUTEX_GUARD(); 
    390       nsclient::logging::logger::get_logger()->debug(__FILE__, __LINE__, std::wstring(_T("Get sections for: ")) + path); 
     394      //nsclient::logging::logger::get_logger()->debug(__FILE__, __LINE__, std::wstring(_T("Get sections for: ")) + path); 
    391395      string_list ret; 
    392396      get_cached_sections_unsafe(path, ret); 
Note: See TracChangeset for help on using the changeset viewer.