void restore(T &s, const char * filename) { // open the archive std::_tifstream ifs(filename); if (ifs.good()) { try { boost::archive::xml__tiarchive ia(ifs); // restore the schedule from the archive ia >> BOOST_SERIALIZATION_NVP(s); s.UpdateID(); } catch (boost::archive::archive_exception & e) { _DBGLOG(LEVEL_WARNING, e.what()); ATLASSERT(false); //boost::filesystem::remove(); } catch (std::exception & e) { _DBGLOG(LEVEL_WARNING, e.what()); ATLASSERT(false); } } else {
void save(const T &s, const char * filename) { boost::filesystem::path filePath(filename, boost::filesystem::native); if ((boost::posix_time::second_clock::local_time() - g_lastBackupTime) > boost::posix_time::time_duration(boost::posix_time::seconds(BACKUP_EVERY))) { g_lastBackupTime = boost::posix_time::second_clock::local_time(); for (int i = 9; i > 0; --i) { boost::filesystem::path bakFilepath = filePath; bakFilepath.replace_extension((boost::format("bak00%1%") % i).str()); boost::filesystem::path prevBakFilepath = filePath; if (i > 1) prevBakFilepath.replace_extension((boost::format("bak00%1%") % (i - 1)).str()); if (boost::filesystem::exists(bakFilepath)) { try { boost::filesystem::remove(bakFilepath); } catch (const boost::filesystem::filesystem_error & ex) { _DBGLOG(LEVEL_WARNING, ex.what()); _DBGLOG(LEVEL_WARNING, pathToWString(bakFilepath).c_str()); } } if (boost::filesystem::exists(prevBakFilepath)) { try { boost::filesystem::rename(prevBakFilepath, bakFilepath); } catch (const boost::filesystem::filesystem_error & ex) { _DBGLOG(LEVEL_WARNING, ex.what()); } } } } // make an archive std::_tofstream ofs(filename); if (ofs.good()) { try { boost::archive::xml__toarchive oa(ofs); oa << BOOST_SERIALIZATION_NVP(s); } catch (boost::archive::archive_exception & e) { _DBGLOG(LEVEL_WARNING, e.what()); ATLASSERT(false); // TODO: Why is there an infrequent exception. } catch (std::exception & e) { _DBGLOG(LEVEL_WARNING, e.what()); ATLASSERT(false); // TODO: Why is there an infrequent exception. } ofs.flush(); ofs.close(); } else { _DBGLOG(LEVEL_WARNING, (boost::format("Faileed to open %1% for writing.") % filename).str().c_str()); } }
/*! Constructor */ VmbxCpGroup::VmbxCpGroup( CpItemDataHelper &itemDataHelper) : CpSettingFormItemData(HbDataFormModelItem::GroupItem, hbTrId("txt_phone_subhead_call_mbx"), NULL), mUiEngine(NULL), mDefaultMailboxEditor(NULL), mCsVoice1Editor(NULL), mCsVideo1Editor(NULL), mItemHelper(itemDataHelper) { _DBGLOG("VmbxCpGroup::VmbxCpGroup >") // Localization file loading QTranslator translator; QString lang = QLocale::system().name(); QString path = "z:/resource/qt/translations/"; bool translatorLoaded = translator.load(path + "telephone_cp_" + lang); _DBGLOG("VmbxCpGroup::VmbxCpGroup translator loaded") if (translatorLoaded && qApp) { qApp->installTranslator(&translator); _DBGLOG("VmbxCpGroup::VmbxCpGroup translator installed") }