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_channel64.png</file>
<file>images/add_channel24.png</file> <file>images/add_channel24.png</file>
<file>images/add_channel32.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_group22.png</file>
<file>images/user/add_group256.png</file> <file>images/user/add_group256.png</file>
<file>images/avatarstatus_bg.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. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
#include <QMessageBox>
#include <iostream> #include <iostream>
#include <rshare.h> #include <rshare.h>
#include "retroshare/rsinit.h" #include "retroshare/rsinit.h"
@ -33,14 +34,22 @@
GeneralPage::GeneralPage(QWidget * parent, Qt::WFlags flags) GeneralPage::GeneralPage(QWidget * parent, Qt::WFlags flags)
: ConfigPage(parent, flags) : ConfigPage(parent, flags)
{ {
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
/* Hide platform specific features */ /* Hide platform specific features */
#ifndef Q_WS_WIN #ifdef Q_WS_WIN
ui.chkRunRetroshareAtSystemStartup->setVisible(false); if (Settings->canSetRetroShareProtocol() == false) {
ui.chkRunRetroshareAtSystemStartupMinimized->setVisible(false); ui.enableRetroShareProtocol->setEnabled(false);
ui.enableRetroShareProtocol->setVisible(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 #endif
} }
@ -60,7 +69,13 @@ bool GeneralPage::save(QString &/*errmsg*/)
Settings->setRunRetroshareOnBoot(ui.chkRunRetroshareAtSystemStartup->isChecked(), ui.chkRunRetroshareAtSystemStartupMinimized->isChecked()); Settings->setRunRetroshareOnBoot(ui.chkRunRetroshareAtSystemStartup->isChecked(), ui.chkRunRetroshareAtSystemStartupMinimized->isChecked());
if (ui.enableRetroShareProtocol->isChecked() != Settings->getRetroShareProtocol()) { 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 #endif

View file

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>373</width> <width>397</width>
<height>400</height> <height>400</height>
</rect> </rect>
</property> </property>
@ -609,11 +609,37 @@
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QCheckBox" name="enableRetroShareProtocol"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="text"> <item>
<string>Register retroshare:// as url protocol (Restart required)</string> <widget class="QCheckBox" name="enableRetroShareProtocol">
</property> <property name="minimumSize">
</widget> <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> </item>
</layout> </layout>
</widget> </widget>
@ -662,6 +688,8 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<resources/> <resources>
<include location="../images.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>

View file

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

View file

@ -118,10 +118,12 @@ public:
/** Set whether to run RetroShare on system boot. */ /** Set whether to run RetroShare on system boot. */
void setRunRetroshareOnBoot(bool run, bool minimized); 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 */ /** Returns true if retroshare:// is registered as protocol */
bool getRetroShareProtocol(); bool getRetroShareProtocol();
/** Register retroshare:// as protocl */ /** Register retroshare:// as protocl */
void setRetroShareProtocol(bool value); bool setRetroShareProtocol(bool value);
/* Get the destination log file. */ /* Get the destination log file. */
QString getLogFile(); 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> <translation>Nicht in den Systemabschnitt minimieren</translation>
</message> </message>
<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> <source> seconds</source>
<translation>Sekunden</translation> <translation>Sekunden</translation>
</message> </message>
<message> <message>
<location line="-115"/> <location line="-141"/>
<source>Start minimized</source> <source>Start minimized</source>
<translation>Minimiert starten</translation> <translation>Minimiert starten</translation>
</message> </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> <translation>Starte RetroShare mit dem System</translation>
</message> </message>
<message> <message>
<location line="+99"/> <location line="+107"/>
<source>Register retroshare:// as url protocol (Restart required)</source> <source>Register retroshare:// as url protocol (Restart required)</source>
<translation>Registriere retroshare:// als Protokoll (Neustart erforderlich)</translation> <translation>Registriere retroshare:// als Protokoll (Neustart erforderlich)</translation>
</message> </message>
<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> <source>Idle</source>
<translation>Untätig</translation> <translation>Untätig</translation>
</message> </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> <source>Idle Time</source>
<translation>Zeit bis zur Untätigkeit</translation> <translation>Zeit bis zur Untätigkeit</translation>
</message> </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>
<context> <context>
<name>GetStartedDialog</name> <name>GetStartedDialog</name>
@ -11029,17 +11054,17 @@ p, li { white-space: pre-wrap; }
<context> <context>
<name>SearchDialog</name> <name>SearchDialog</name>
<message> <message>
<location filename="../gui/SearchDialog.ui" line="+1380"/> <location filename="../gui/SearchDialog.ui" line="+1161"/>
<source>Sources</source> <source>Sources</source>
<translation>Quellen</translation> <translation>Quellen</translation>
</message> </message>
<message> <message>
<location line="-164"/> <location line="-170"/>
<source>Results</source> <source>Results</source>
<translation>Ergebnisse</translation> <translation>Ergebnisse</translation>
</message> </message>
<message> <message>
<location line="-145"/> <location line="+319"/>
<location filename="../gui/SearchDialog.cpp" line="+291"/> <location filename="../gui/SearchDialog.cpp" line="+291"/>
<source>Download</source> <source>Download</source>
<translation>Herunterladen</translation> <translation>Herunterladen</translation>
@ -11098,7 +11123,7 @@ p, li { white-space: pre-wrap; }
<translation>Neu(e) RetroShare Link(s)</translation> <translation>Neu(e) RetroShare Link(s)</translation>
</message> </message>
<message> <message>
<location filename="../gui/SearchDialog.ui" line="-479"/> <location filename="../gui/SearchDialog.ui" line="-718"/>
<source>Any</source> <source>Any</source>
<translation>Alle</translation> <translation>Alle</translation>
</message> </message>
@ -11118,12 +11143,12 @@ p, li { white-space: pre-wrap; }
<translation>Gib einen Suchbegriff ein</translation> <translation>Gib einen Suchbegriff ein</translation>
</message> </message>
<message> <message>
<location line="+510"/> <location line="+285"/>
<source>Filter Search Result</source> <source>Filter Search Result</source>
<translation>Filter Suchergebnis</translation> <translation>Filter Suchergebnis</translation>
</message> </message>
<message> <message>
<location line="+111"/> <location line="+117"/>
<source>Filename</source> <source>Filename</source>
<translation>Dateiname</translation> <translation>Dateiname</translation>
</message> </message>
@ -11138,7 +11163,7 @@ p, li { white-space: pre-wrap; }
<translation>Prüfsumme</translation> <translation>Prüfsumme</translation>
</message> </message>
<message> <message>
<location line="-184"/> <location line="-190"/>
<source>KeyWords</source> <source>KeyWords</source>
<translation>Schlüsselwörter</translation> <translation>Schlüsselwörter</translation>
</message> </message>
@ -11170,7 +11195,7 @@ p, li { white-space: pre-wrap; }
<translation>Diese Funktion ist noch nicht eingebaut.</translation> <translation>Diese Funktion ist noch nicht eingebaut.</translation>
</message> </message>
<message> <message>
<location filename="../gui/SearchDialog.ui" line="+154"/> <location filename="../gui/SearchDialog.ui" line="+160"/>
<source>Size</source> <source>Size</source>
<translation>Grösse</translation> <translation>Grösse</translation>
</message> </message>
@ -11180,7 +11205,7 @@ p, li { white-space: pre-wrap; }
<translation>Typ</translation> <translation>Typ</translation>
</message> </message>
<message> <message>
<location line="-784"/> <location line="-565"/>
<source>Archive</source> <source>Archive</source>
<translation>Archiv</translation> <translation>Archiv</translation>
</message> </message>
@ -11220,7 +11245,7 @@ p, li { white-space: pre-wrap; }
<translation>Suchen</translation> <translation>Suchen</translation>
</message> </message>
<message> <message>
<location line="+417"/> <location line="+192"/>
<source>Clear Filter</source> <source>Clear Filter</source>
<translation>Filter leeren</translation> <translation>Filter leeren</translation>
</message> </message>
@ -11235,7 +11260,7 @@ p, li { white-space: pre-wrap; }
<translation>Dateigröße</translation> <translation>Dateigröße</translation>
</message> </message>
<message> <message>
<location line="-393"/> <location line="+71"/>
<source>Close all Search Resullts</source> <source>Close all Search Resullts</source>
<translation>Schließe alle Suchergebnisse</translation> <translation>Schließe alle Suchergebnisse</translation>
</message> </message>
@ -11282,7 +11307,7 @@ p, li { white-space: pre-wrap; }
<translation>Begrenze Anzahl der Resultate auf :</translation> <translation>Begrenze Anzahl der Resultate auf :</translation>
</message> </message>
<message> <message>
<location line="-374"/> <location line="-613"/>
<source>Reset</source> <source>Reset</source>
<translation>Zurücksetzen</translation> <translation>Zurücksetzen</translation>
</message> </message>
@ -11297,7 +11322,7 @@ p, li { white-space: pre-wrap; }
<translation>Erweitert</translation> <translation>Erweitert</translation>
</message> </message>
<message> <message>
<location line="+55"/> <location line="+294"/>
<source>Close All Search Results</source> <source>Close All Search Results</source>
<translation>Schließe alle Suchergebnisse</translation> <translation>Schließe alle Suchergebnisse</translation>
</message> </message>
@ -11807,7 +11832,7 @@ p, li { white-space: pre-wrap; }
<translation>Freigabe entfernen</translation> <translation>Freigabe entfernen</translation>
</message> </message>
<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> <source>If checked, the share is anonymously shared to anybody.</source>
<translation>Wenn aktiviert, dann ist dieser Ordner anonym feigegeben.</translation> <translation>Wenn aktiviert, dann ist dieser Ordner anonym feigegeben.</translation>
</message> </message>