122 lines
3.3 KiB
C++
122 lines
3.3 KiB
C++
#include <remotepsapp/optnsreg.hpp>
|
|
#include <common/stdio.hpp>
|
|
|
|
bool OptionsReg::setGroup(Group &group)
|
|
{
|
|
RegKey regKey(RegKey::CurrentUser);
|
|
String strIndex;
|
|
|
|
if(group.groupName().isNull()||!group.size())return false;
|
|
if(!regKey.openKey(mOptionsKeyName+mOptionsKeyGroupsPostfix+String("\\")+group.groupName()))
|
|
{
|
|
regKey.createKey(mOptionsKeyName+mOptionsKeyGroupsPostfix+String("\\")+group.groupName(),"");
|
|
regKey.openKey(mOptionsKeyName+mOptionsKeyGroupsPostfix+String("\\")+group.groupName());
|
|
}
|
|
for(int index=0;index<group.size();index++)
|
|
{
|
|
::sprintf(strIndex,"E%d",index);
|
|
regKey.setValue(strIndex,group[index]);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool OptionsReg::getGroup(Group &group)
|
|
{
|
|
RegKey regKey(RegKey::CurrentUser);
|
|
DWORD index(0);
|
|
String strGroupEntry;
|
|
String strIndex;
|
|
|
|
group.remove();
|
|
if(group.groupName().isNull())return false;
|
|
if(!regKey.openKey(mOptionsKeyName+mOptionsKeyGroupsPostfix+String("\\")+group.groupName()))return false;
|
|
while(true)
|
|
{
|
|
::sprintf(strIndex,"E%d",index);
|
|
if(!regKey.enumValue(index++,strIndex,strGroupEntry))break;
|
|
group.insert(&strGroupEntry);
|
|
}
|
|
return group.size()?true:false;
|
|
}
|
|
|
|
bool OptionsReg::getGroupNames(Block<String> &groupNames)
|
|
{
|
|
RegKey regKey(RegKey::CurrentUser);
|
|
DWORD index(0);
|
|
String strGroupName;
|
|
|
|
groupNames.remove();
|
|
if(!regKey.openKey(mOptionsKeyName+mOptionsKeyGroupsPostfix))return false;
|
|
while(true)
|
|
{
|
|
if(!regKey.enumKey(index++,strGroupName))break;
|
|
groupNames.insert(&strGroupName);
|
|
}
|
|
return groupNames.size()?true:false;
|
|
}
|
|
|
|
bool OptionsReg::getConnections(Block<String> &connectionNames)
|
|
{
|
|
RegKey regKey(RegKey::CurrentUser);
|
|
String strConnectionName;
|
|
String strIndex;
|
|
DWORD index;
|
|
|
|
index=0;
|
|
connectionNames.remove();
|
|
if(!regKey.openKey(mOptionsKeyName+mOptionsKeyConnectionsPostfix))return false;
|
|
while(true)
|
|
{
|
|
::sprintf(strIndex,"C%d",index++);
|
|
if(!regKey.queryValue(strIndex,strConnectionName))break;
|
|
connectionNames.insert(&strConnectionName);
|
|
}
|
|
return connectionNames.size()?true:false;
|
|
}
|
|
|
|
void OptionsReg::setConnections(Block<String> &connectionNames)
|
|
{
|
|
RegKey regKey(RegKey::CurrentUser);
|
|
String strConnectionEntry;
|
|
String strIndex;
|
|
|
|
if(!regKey.openKey(mOptionsKeyName+mOptionsKeyConnectionsPostfix))
|
|
{
|
|
regKey.createKey(mOptionsKeyName+mOptionsKeyConnectionsPostfix,"");
|
|
regKey.openKey(mOptionsKeyName+mOptionsKeyConnectionsPostfix);
|
|
}
|
|
for(int index=0;index<connectionNames.size();index++)
|
|
{
|
|
String &strConnection=connectionNames[index];
|
|
strConnection.lower();
|
|
::sprintf(strIndex,"C%d",index);
|
|
regKey.setValue(strIndex,strConnection);
|
|
}
|
|
return;
|
|
}
|
|
|
|
void OptionsReg::insertConnection(const String &strConnection)
|
|
{
|
|
RegKey regKey(RegKey::CurrentUser);
|
|
Block<String> strConnections;
|
|
String cpyConnection;
|
|
String strIndex;
|
|
|
|
if(!regKey.openKey(mOptionsKeyName+mOptionsKeyConnectionsPostfix))
|
|
{
|
|
regKey.createKey(mOptionsKeyName+mOptionsKeyConnectionsPostfix,"");
|
|
regKey.openKey(mOptionsKeyName+mOptionsKeyConnectionsPostfix);
|
|
}
|
|
if(strConnection.isNull())return;
|
|
cpyConnection=strConnection;
|
|
cpyConnection.lower();
|
|
getConnections(strConnections);
|
|
for(int index=0;index<strConnections.size();index++)
|
|
{
|
|
String &connectionName=strConnections[index];
|
|
if(cpyConnection==connectionName)return;
|
|
}
|
|
::sprintf(strIndex,"C%d",strConnections.size());
|
|
regKey.setValue(strIndex,cpyConnection);
|
|
}
|