/*! \brief Loads session data. \details Attempts to load session data using the \a Name and \a Domain from the constructor. The session file for the various platforms is as follows: - Win32 \$(HOME)/\$(Domain)/\$(Name).xml - MacOS ~/Library/Preferences/\$(Domain)/\$(Name).xml - Linux ~/.\$(Domain)/\$(Name).xml \return Returns dmz::True if the session data was read successfully. */ dmz::Boolean dmz::ApplicationiPhone::load_session () { Boolean result (True); _state.sessionDir = dmz_get_document_directory (); if (_state.sessionDir) { _state.sessionFile << "session.xml"; _state.sessionPath = format_path (_state.sessionDir + "/" + _state.sessionFile); if (is_valid_path (_state.sessionPath)) { Config data ("global"); if (xml_to_config (_state.sessionPath, data, &(_state.log))) { if (!_state.quiet) { _state.log.info << "Loaded session file: " << _state.sessionPath << endl; } Config session; _state.rt.get_session_config (session); if (data.lookup_all_config_merged (session.get_name (), session)) { const String DefaultDir (config_to_string (DefaultDirName, session)); if (DefaultDir && is_valid_path (DefaultDir)) { _state.appState.set_default_directory (DefaultDir); } else { _state.appState.set_default_directory (dmz_get_main_bundle_directory ()); } _state.rt.set_session_config (session); } } else { _state.log.error << "Failed parsing session file: " << _state.sessionPath << endl; } } else if (!_state.quiet) { _state.log.info << "Session file: " << _state.sessionPath << " does not exist" << endl; result = False; } } return result; }
/*! \ingroup Foundation \brief converts an XML file to a Version */ dmz::Boolean dmz::xml_to_version (const String &FileName, Version &value, Log *log) { Config data ("global"); Boolean result = xml_to_config (FileName, data, log); if (result) { Version tmp (data); value = tmp; } return result; }
/*! \brief Process the command line. \details Loads all XML configuration files specified by the command line. \param[in] CL CommandLine object to process. \return Returns dmz::True if command line was successfully processed. Returns dmz::False if there was an error parsing the XML configuration files. */ dmz::Boolean dmz::ApplicationiPhone::load_config (const PathContainer &Files) { String file; _state.error = False; while (Files.get_next (file) && !_state.error) { if (!xml_to_config (file, _state.global, &(_state.log))) { _state.errorMsg.flush () << "Unable to load config: " << file; _state.log.error << _state.errorMsg << endl; _state.error = True; } } if (!_state.error) { _state.cache.configure (_state.global); } return !_state.error; }
/*! \brief Loads session data. \details Attempts to load session data using the \a Name and \a Domain from the constructor. The session file for the various platforms is as follows: - Win32 \$(HOME)/\$(Domain)/\$(Name).xml - MacOS ~/Library/Preferences/\$(Domain)/\$(Name).xml - Linux ~/.\$(Domain)/\$(Name).xml \return Returns dmz::True if the session data was read successfully. */ dmz::Boolean dmz::Application::load_session () { Boolean result (True); _state.sessionDir = get_home_directory (); if (is_valid_path (_state.sessionDir)) { #if defined (_WIN32) if (_state.Domain) { _state.sessionDir << "/" << _state.Domain; } else { _state.sessionDir << "/dmz"; } #elif defined (__APPLE__) || defined (MACOSX) _state.sessionDir << "/Library/Preferences"; if (_state.Domain) { _state.sessionDir << "/" << _state.Domain; } else { _state.sessionDir << "/dmz"; } #else if (_state.Domain) { _state.sessionDir << "/." << _state.Domain; } else { _state.sessionDir << "/.dmz"; } #endif } else { result = False; } if (_state.sessionDir) { if (_state.Name) { _state.sessionFile << _state.Name << ".xml"; } else { _state.sessionFile << "session.xml"; } _state.sessionPath = format_path (_state.sessionDir + "/" + _state.sessionFile); if (is_valid_path (_state.sessionPath)) { Config data ("global"); if (xml_to_config (_state.sessionPath, data, &(_state.log))) { if (!_state.quiet) { _state.log.info << "Loaded session file: " << _state.sessionPath << endl; } Config session; _state.rt.get_session_config (session); if (data.lookup_all_config_merged (session.get_name (), session)) { const String DefaultDir (config_to_string (DefaultDirName, session)); if (DefaultDir && is_valid_path (DefaultDir)) { _state.appState.set_default_directory (DefaultDir); } else { _state.appState.set_default_directory (get_home_directory ()); } _state.rt.set_session_config (session); } } else { _state.log.error << "Failed parsing session file: " << _state.sessionPath << endl; } } else if (!_state.quiet) { _state.log.info << "Session file: " << _state.sessionPath << " does not exist" << endl; result = False; } } return result; }