From 3f95d417d9e623ac0c74df8ef11d7a01846392dd Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Wed, 17 Sep 2003 19:07:23 +0000 Subject: Initial Import --- NSCmpts/EncryptData.cpp | 105 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 NSCmpts/EncryptData.cpp (limited to 'NSCmpts/EncryptData.cpp') diff --git a/NSCmpts/EncryptData.cpp b/NSCmpts/EncryptData.cpp new file mode 100644 index 0000000..4c1660a --- /dev/null +++ b/NSCmpts/EncryptData.cpp @@ -0,0 +1,105 @@ +// EncryptData.cpp: implementation of the CEncryptData class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "EncryptData.h" + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +UINT CEncryptData::m_nExtensions = 0; +UINT CEncryptData::m_nPaths = 0; + + +UINT CEncryptData::LoadExtensions(string_array& asExt, const CPropertyBag& settings) +{ + int nCnt = 0; // Number of URLs from Registry + string sExt; + string sKeyName; + + // Format Key Name + sKeyName.format(NS_BACKUP_REG_EXT, nCnt++); + + while((sExt = settings.GetString(sKeyName, NS_NO_KEY)) != NS_NO_KEY) + { + asExt.push_back(sExt); + sKeyName.format(NS_BACKUP_REG_EXT, nCnt++); + } + + m_nExtensions = max(m_nExtensions, --nCnt); + return nCnt; +} + +UINT CEncryptData::SaveExtensions(const string_array& asExt, CPropertyBag& settings) +{ + UINT nCnt = 0; // Number of URLs from Registry + string sKeyName = _T(""); + + string_array::const_iterator iter = asExt.begin(); + for(; iter != asExt.end(); iter++) + { + sKeyName.format(NS_BACKUP_REG_EXT, nCnt++); + settings.WriteString(sKeyName, *iter); + } + + UINT nRet = nCnt - 1; + + for(; nCnt < m_nExtensions; nCnt++) + { + // Format Registry Key + sKeyName.format(NS_BACKUP_REG_EXT, nCnt); + settings.DeleteProperty(sKeyName); + } + + m_nExtensions = 0; + + return nRet; +} + +UINT CEncryptData::LoadPaths(file_array& aPaths, const CPropertyBag& settings) +{ + int nCnt = 0; + string sPath; + string sKeyName; + + // Format Key Name + sKeyName.format(NS_BACKUP_REG_SOURCE, nCnt++); + + // Add URLs to List Box + while((sPath = settings.GetString(sKeyName, NS_NO_KEY)) != NS_NO_KEY) + { + aPaths.push_back(sPath); + + // Format Key Name + sKeyName.format(NS_BACKUP_REG_SOURCE, nCnt++); + } + + return m_nPaths = --nCnt; + +} + +UINT CEncryptData::SavePaths(const file_array& aPaths, CPropertyBag& settings) +{ + UINT nCnt = 0; // Number of URLs from Registry + string sKeyName; + + file_array::const_iterator iter = aPaths.begin(); + for(; iter != aPaths.end(); iter++) + { + sKeyName.format(NS_BACKUP_REG_SOURCE, nCnt++); + settings.WriteString(sKeyName, *iter); + } + + UINT nRet = nCnt - 1; + + for(; nCnt < m_nPaths; nCnt++) + { + // Format Registry Key + sKeyName.format(NS_BACKUP_REG_SOURCE, nCnt); + settings.DeleteProperty(sKeyName); + } + + return nRet; +} -- cgit v1.2.3