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

View File

@ -42,6 +42,10 @@
<file>images/add_channel64.png</file>
<file>images/add_channel24.png</file>
<file>images/add_channel32.png</file>
<file>images/admin-16.png</file>
<file>images/admin-32.png</file>
<file>images/admin-24.png</file>
<file>images/admin-48.png</file>
<file>images/user/add_group22.png</file>
<file>images/user/add_group256.png</file>
<file>images/avatarstatus_bg.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 899 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -19,6 +19,7 @@
* Boston, MA 02110-1301, USA.
****************************************************************/
#include <QMessageBox>
#include <iostream>
#include <rshare.h>
#include "retroshare/rsinit.h"
@ -33,14 +34,22 @@
GeneralPage::GeneralPage(QWidget * parent, Qt::WFlags flags)
: ConfigPage(parent, flags)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
/* Hide platform specific features */
#ifndef Q_WS_WIN
ui.chkRunRetroshareAtSystemStartup->setVisible(false);
ui.chkRunRetroshareAtSystemStartupMinimized->setVisible(false);
ui.enableRetroShareProtocol->setVisible(false);
/* Hide platform specific features */
#ifdef Q_WS_WIN
if (Settings->canSetRetroShareProtocol() == false) {
ui.enableRetroShareProtocol->setEnabled(false);
} else {
ui.adminLabel->setEnabled(false);
ui.adminLabel->setToolTip("");
}
#else
ui.chkRunRetroshareAtSystemStartup->setVisible(false);
ui.chkRunRetroshareAtSystemStartupMinimized->setVisible(false);
ui.enableRetroShareProtocol->setVisible(false);
ui.adminLabel->setVisible(false);
#endif
}
@ -60,7 +69,13 @@ bool GeneralPage::save(QString &/*errmsg*/)
Settings->setRunRetroshareOnBoot(ui.chkRunRetroshareAtSystemStartup->isChecked(), ui.chkRunRetroshareAtSystemStartupMinimized->isChecked());
if (ui.enableRetroShareProtocol->isChecked() != Settings->getRetroShareProtocol()) {
Settings->setRetroShareProtocol(ui.enableRetroShareProtocol->isChecked());
if (Settings->setRetroShareProtocol(ui.enableRetroShareProtocol->isChecked()) == false) {
if (ui.enableRetroShareProtocol->isChecked()) {
QMessageBox::critical(this, tr("Error"), tr("Could not add retroshare:// as protocol."));
} else {
QMessageBox::critical(this, tr("Error"), tr("Could not remove retroshare:// protocol."));
}
}
}
#endif

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>373</width>
<width>397</width>
<height>400</height>
</rect>
</property>
@ -609,11 +609,37 @@
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="enableRetroShareProtocol">
<property name="text">
<string>Register retroshare:// as url protocol (Restart required)</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="enableRetroShareProtocol">
<property name="minimumSize">
<size>
<width>0</width>
<height>16</height>
</size>
</property>
<property name="text">
<string>Register retroshare:// as url protocol (Restart required)</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="adminLabel">
<property name="minimumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="toolTip">
<string>You need administrator rights to change this option.</string>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/admin-16.png</pixmap>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
@ -662,6 +688,8 @@
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

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);
}
}

View File

@ -118,10 +118,12 @@ public:
/** Set whether to run RetroShare on system boot. */
void setRunRetroshareOnBoot(bool run, bool minimized);
/** Returns true if the user can set retroshare as protocol */
bool canSetRetroShareProtocol();
/** Returns true if retroshare:// is registered as protocol */
bool getRetroShareProtocol();
/** Register retroshare:// as protocl */
void setRetroShareProtocol(bool value);
bool setRetroShareProtocol(bool value);
/* Get the destination log file. */
QString getLogFile();

View File

@ -5042,12 +5042,16 @@ Gib Dein GPG Passwort wenn Du gefragt wirst ein, um Deinen neuen Schlüssel zu u
<translation>Nicht in den Systemabschnitt minimieren</translation>
</message>
<message>
<location line="+40"/>
<source>You need administrator rights to set this option.</source>
<translation type="obsolete">Du benötigst Administratorrechte zum aktivieren der Einstellung.</translation>
</message>
<message>
<location line="+66"/>
<source> seconds</source>
<translation>Sekunden</translation>
</message>
<message>
<location line="-115"/>
<location line="-141"/>
<source>Start minimized</source>
<translation>Minimiert starten</translation>
</message>
@ -5057,12 +5061,17 @@ Gib Dein GPG Passwort wenn Du gefragt wirst ein, um Deinen neuen Schlüssel zu u
<translation>Starte RetroShare mit dem System</translation>
</message>
<message>
<location line="+99"/>
<location line="+107"/>
<source>Register retroshare:// as url protocol (Restart required)</source>
<translation>Registriere retroshare:// als Protokoll (Neustart erforderlich)</translation>
</message>
<message>
<location line="+10"/>
<location line="+13"/>
<source>You need administrator rights to change this option.</source>
<translation>Du benötigst Administratorrechte zum ändern dieser Einstellung.</translation>
</message>
<message>
<location line="+15"/>
<source>Idle</source>
<translation>Untätig</translation>
</message>
@ -5071,6 +5080,22 @@ Gib Dein GPG Passwort wenn Du gefragt wirst ein, um Deinen neuen Schlüssel zu u
<source>Idle Time</source>
<translation>Zeit bis zur Untätigkeit</translation>
</message>
<message>
<location filename="../gui/settings/GeneralPage.cpp" line="+74"/>
<location line="+2"/>
<source>Error</source>
<translation>Fehler</translation>
</message>
<message>
<location line="-2"/>
<source>Could not add retroshare:// as protocol.</source>
<translation>Konnte retroshare:// nicht als Protokoll hinzufügen.</translation>
</message>
<message>
<location line="+2"/>
<source>Could not remove retroshare:// protocol.</source>
<translation>Konnte retroshare:// Protokoll nicht entfernen.</translation>
</message>
</context>
<context>
<name>GetStartedDialog</name>
@ -11029,17 +11054,17 @@ p, li { white-space: pre-wrap; }
<context>
<name>SearchDialog</name>
<message>
<location filename="../gui/SearchDialog.ui" line="+1380"/>
<location filename="../gui/SearchDialog.ui" line="+1161"/>
<source>Sources</source>
<translation>Quellen</translation>
</message>
<message>
<location line="-164"/>
<location line="-170"/>
<source>Results</source>
<translation>Ergebnisse</translation>
</message>
<message>
<location line="-145"/>
<location line="+319"/>
<location filename="../gui/SearchDialog.cpp" line="+291"/>
<source>Download</source>
<translation>Herunterladen</translation>
@ -11098,7 +11123,7 @@ p, li { white-space: pre-wrap; }
<translation>Neu(e) RetroShare Link(s)</translation>
</message>
<message>
<location filename="../gui/SearchDialog.ui" line="-479"/>
<location filename="../gui/SearchDialog.ui" line="-718"/>
<source>Any</source>
<translation>Alle</translation>
</message>
@ -11118,12 +11143,12 @@ p, li { white-space: pre-wrap; }
<translation>Gib einen Suchbegriff ein</translation>
</message>
<message>
<location line="+510"/>
<location line="+285"/>
<source>Filter Search Result</source>
<translation>Filter Suchergebnis</translation>
</message>
<message>
<location line="+111"/>
<location line="+117"/>
<source>Filename</source>
<translation>Dateiname</translation>
</message>
@ -11138,7 +11163,7 @@ p, li { white-space: pre-wrap; }
<translation>Prüfsumme</translation>
</message>
<message>
<location line="-184"/>
<location line="-190"/>
<source>KeyWords</source>
<translation>Schlüsselwörter</translation>
</message>
@ -11170,7 +11195,7 @@ p, li { white-space: pre-wrap; }
<translation>Diese Funktion ist noch nicht eingebaut.</translation>
</message>
<message>
<location filename="../gui/SearchDialog.ui" line="+154"/>
<location filename="../gui/SearchDialog.ui" line="+160"/>
<source>Size</source>
<translation>Grösse</translation>
</message>
@ -11180,7 +11205,7 @@ p, li { white-space: pre-wrap; }
<translation>Typ</translation>
</message>
<message>
<location line="-784"/>
<location line="-565"/>
<source>Archive</source>
<translation>Archiv</translation>
</message>
@ -11220,7 +11245,7 @@ p, li { white-space: pre-wrap; }
<translation>Suchen</translation>
</message>
<message>
<location line="+417"/>
<location line="+192"/>
<source>Clear Filter</source>
<translation>Filter leeren</translation>
</message>
@ -11235,7 +11260,7 @@ p, li { white-space: pre-wrap; }
<translation>Dateigröße</translation>
</message>
<message>
<location line="-393"/>
<location line="+71"/>
<source>Close all Search Resullts</source>
<translation>Schließe alle Suchergebnisse</translation>
</message>
@ -11282,7 +11307,7 @@ p, li { white-space: pre-wrap; }
<translation>Begrenze Anzahl der Resultate auf :</translation>
</message>
<message>
<location line="-374"/>
<location line="-613"/>
<source>Reset</source>
<translation>Zurücksetzen</translation>
</message>
@ -11297,7 +11322,7 @@ p, li { white-space: pre-wrap; }
<translation>Erweitert</translation>
</message>
<message>
<location line="+55"/>
<location line="+294"/>
<source>Close All Search Results</source>
<translation>Schließe alle Suchergebnisse</translation>
</message>
@ -11807,7 +11832,7 @@ p, li { white-space: pre-wrap; }
<translation>Freigabe entfernen</translation>
</message>
<message>
<location filename="../gui/ShareManager.cpp" line="+130"/>
<location filename="../gui/ShareManager.cpp" line="+127"/>
<source>If checked, the share is anonymously shared to anybody.</source>
<translation>Wenn aktiviert, dann ist dieser Ordner anonym feigegeben.</translation>
</message>