summaryrefslogtreecommitdiff
path: root/NSCmpts/EncryptData.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'NSCmpts/EncryptData.cpp')
-rw-r--r--NSCmpts/EncryptData.cpp105
1 files changed, 105 insertions, 0 deletions
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;
+}