Added check for administrator rights to add/remove the retroshare:// protocol.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4570 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2011-08-17 00:06:44 +00:00
parent 0f51b7d72f
commit d349204a63
11 changed files with 137 additions and 37 deletions
retroshare-gui/src/gui/settings

View file

@ -506,25 +506,51 @@ bool RshareSettings::getRetroShareProtocol()
return false;
}
/** Returns true if the user can set retroshare as protocol */
bool RshareSettings::canSetRetroShareProtocol()
{
#if defined(Q_WS_WIN)
QSettings retroshare("HKEY_CLASSES_ROOT\\retroshare", QSettings::NativeFormat);
return retroshare.isWritable();
#else
return false;
#endif
}
/** Register retroshare:// as protocl */
void RshareSettings::setRetroShareProtocol(bool value)
bool RshareSettings::setRetroShareProtocol(bool value)
{
#if defined(Q_WS_WIN)
if (value) {
QSettings retroshare("HKEY_CLASSES_ROOT\\retroshare", QSettings::NativeFormat);
retroshare.setValue("Default", "URL: RetroShare protocol");
QSettings::Status state = retroshare.status();
if (state == QSettings::AccessError) {
return false;
}
retroshare.setValue("URL Protocol", "");
retroshare.setValue("Profile", QString::fromStdString(rsPeers->getOwnId()));
QSettings command("HKEY_CLASSES_ROOT\\retroshare\\shell\\open\\command", QSettings::NativeFormat);
command.setValue("Default", getAppPathForProtocol());
state = command.status();
} else {
QSettings retroshare("HKEY_CLASSES_ROOT", QSettings::NativeFormat);
retroshare.remove("retroshare");
QSettings::Status state = retroshare.status();
if (state == QSettings::AccessError) {
return false;
}
}
return true;
#else
/* Platforms othe rthan windows aren't supported yet */
/* Platforms other than windows aren't supported yet */
Q_UNUSED(value);
return false;
#endif
}
@ -690,4 +716,4 @@ void RshareSettings::setMaxTimeBeforeIdle(uint nValue)
{
m_maxTimeBeforeIdle = nValue;
setValue("maxTimeBeforeIdle", nValue);
}
}