Skip to content

Commit 5404b76

Browse files
committed
save proxy settings when setting them
1 parent 1cd29d0 commit 5404b76

File tree

6 files changed

+38
-16
lines changed

6 files changed

+38
-16
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,5 @@ doc/codeattributions.qdoc
9696
/src/sdk/installerbase.qrc
9797
/src/sdk/translations/untranslated.ts
9898
/src/sdk/translations/ifw_en.ts
99+
100+
package/*

src/libs/installer/commandlineparser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ CommandLineParser::CommandLineParser()
122122

123123
// Starting mode options
124124
addOption(QCommandLineOption(QStringList()
125-
<< CommandLineOptions::scManualProxyShort << CommandLineOptions::scManualProxyLong,
125+
<< CommandLineOptions::scCustomProxyShort << CommandLineOptions::scCustomProxyLong,
126126
QLatin1String("Use manual proxy.")));
127127

128128
// Custom Proxy options

src/libs/installer/constants.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ static const QLatin1String scSystemProxyShort("sp");
235235
static const QLatin1String scSystemProxyLong("system-proxy");
236236
static const QLatin1String scNoProxyShort("np");
237237
static const QLatin1String scNoProxyLong("no-proxy");
238-
static const QLatin1String scManualProxyShort("mp");
239-
static const QLatin1String scManualProxyLong("manual-proxy");
238+
static const QLatin1String scCustomProxyShort("cpr");
239+
static const QLatin1String scCustomProxyLong("custom-proxy");
240240

241241
// Custom Proxy options
242242
static const QLatin1String scHttpProxyHostNameShort("hph");

src/libs/installer/packagemanagercore.cpp

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3862,7 +3862,7 @@ QString PackageManagerCore::getProxyMode() const
38623862
return QStringLiteral("system");
38633863
break;
38643864
case Settings::UserDefinedProxy:
3865-
return QStringLiteral("manual");
3865+
return QStringLiteral("custom");
38663866
break;
38673867
}
38683868
}
@@ -3877,15 +3877,14 @@ void PackageManagerCore::setProxyMode(const QString &proxyType)
38773877
{
38783878
d->m_data.settings().setProxyType(QInstaller::Settings::SystemProxy);
38793879
}
3880-
else if(proxyType == QStringLiteral("manual"))
3880+
else if(proxyType == QStringLiteral("custom"))
38813881
{
38823882
d->m_data.settings().setProxyType(QInstaller::Settings::UserDefinedProxy);
38833883
}
38843884
else
38853885
{
38863886
qWarning() << "proxy mode does not exist";
38873887
}
3888-
38893888
}
38903889

38913890
QString PackageManagerCore::getHttpProxyHost() const
@@ -3900,6 +3899,7 @@ void PackageManagerCore::setHttpProxyHost(const QString &hostName)
39003899
{
39013900
QNetworkProxy proxy = d->m_data.settings().httpProxy();
39023901
proxy.setHostName(hostName);
3902+
d->m_data.settings().setHttpProxy(proxy);
39033903
qInfo() << "set proxy hostname" << proxy.hostName();
39043904
}
39053905

@@ -3916,7 +3916,16 @@ void PackageManagerCore::setHttpProxyPort(const QString &port)
39163916
QNetworkProxy proxy = d->m_data.settings().httpProxy();
39173917
bool boolVal;
39183918
proxy.setPort(port.toInt(&boolVal));
3919-
qInfo() << "set proxy port" << proxy.port();
3919+
if (boolVal)
3920+
{
3921+
d->m_data.settings().setHttpProxy(proxy);
3922+
qInfo() << "set proxy port" << proxy.port();
3923+
}
3924+
else
3925+
{
3926+
qWarning() << "unable to convert string to port: " << port;
3927+
}
3928+
39203929
}
39213930

39223931
QString PackageManagerCore::getHttpProxyUser() const
@@ -3931,7 +3940,7 @@ void PackageManagerCore::setHttpProxyUser(const QString &userName)
39313940
{
39323941
QNetworkProxy proxy = d->m_data.settings().httpProxy();
39333942
proxy.setUser(userName);
3934-
qInfo() << "set proxy port" << proxy.user();
3943+
d->m_data.settings().setHttpProxy(proxy);
39353944
}
39363945

39373946
QString PackageManagerCore::getHttpProxyPwd() const
@@ -3946,7 +3955,7 @@ void PackageManagerCore::setHttpProxyPwd(const QString &password)
39463955
{
39473956
QNetworkProxy proxy = d->m_data.settings().httpProxy();
39483957
proxy.setPassword(password);
3949-
qInfo() << "set proxy port" << proxy.password();
3958+
d->m_data.settings().setHttpProxy(proxy);
39503959
}
39513960

39523961
bool PackageManagerCore::getHttpProxyAuth() const
@@ -3976,12 +3985,14 @@ void PackageManagerCore::setFtpProxyHost(const QString &hostName)
39763985
{
39773986
QNetworkProxy proxy = d->m_data.settings().ftpProxy();
39783987
proxy.setHostName(hostName);
3988+
d->m_data.settings().setFtpProxy(proxy);
39793989
qInfo() << "set proxy hostname" << proxy.hostName();
39803990
}
39813991

39823992
QString PackageManagerCore::getFtpProxyPort() const
39833993
{
39843994
QNetworkProxy proxy = d->m_data.settings().ftpProxy();
3995+
39853996
qInfo() << "installer value: proxy port" << proxy.port();
39863997

39873998
return QString::number(proxy.port());
@@ -3992,7 +4003,15 @@ void PackageManagerCore::setFtpProxyPort(const QString &port)
39924003
QNetworkProxy proxy = d->m_data.settings().ftpProxy();
39934004
bool boolVal;
39944005
proxy.setPort(port.toInt(&boolVal));
3995-
qInfo() << "set proxy port" << proxy.port();
4006+
if (boolVal)
4007+
{
4008+
d->m_data.settings().setFtpProxy(proxy);
4009+
qInfo() << "set proxy port" << proxy.port();
4010+
}
4011+
else
4012+
{
4013+
qWarning() << "unable to convert string to port: " << port;
4014+
}
39964015
}
39974016

39984017
QString PackageManagerCore::getFtpProxyUser() const
@@ -4007,6 +4026,7 @@ void PackageManagerCore::setFtpProxyUser(const QString &userName)
40074026
{
40084027
QNetworkProxy proxy = d->m_data.settings().ftpProxy();
40094028
proxy.setUser(userName);
4029+
d->m_data.settings().setFtpProxy(proxy);
40104030
qInfo() << "set proxy port" << proxy.user();
40114031
}
40124032

@@ -4022,6 +4042,7 @@ void PackageManagerCore::setFtpProxyPwd(const QString &password)
40224042
{
40234043
QNetworkProxy proxy = d->m_data.settings().ftpProxy();
40244044
proxy.setPassword(password);
4045+
d->m_data.settings().setFtpProxy(proxy);
40254046
qInfo() << "set proxy port" << proxy.password();
40264047
}
40274048

src/sdk/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ int main(int argc, char *argv[])
321321
QNetworkProxyFactory::setUseSystemConfiguration(false);
322322
}
323323

324-
if ((parser.isSet(CommandLineOptions::scNoProxyLong)) || (parser.isSet(CommandLineOptions::scManualProxyLong)))
324+
if ((parser.isSet(CommandLineOptions::scNoProxyLong)) || (parser.isSet(CommandLineOptions::scCustomProxyLong)))
325325
QNetworkProxyFactory::setUseSystemConfiguration(false);
326326

327327
const SelfRestarter restarter(argc, argv);

src/sdk/sdkapp.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,7 @@ class SDKApp : public T
269269
if (m_parser.isSet(CommandLineOptions::scNoProxyLong)) {
270270
m_core->settings().setProxyType(QInstaller::Settings::NoProxy);
271271
KDUpdater::FileDownloaderFactory::instance().setProxyFactory(m_core->proxyFactory());
272-
} else if (QNetworkProxyFactory::usesSystemConfiguration()) {
273-
m_core->settings().setProxyType(QInstaller::Settings::SystemProxy);
274-
KDUpdater::FileDownloaderFactory::instance().setProxyFactory(m_core->proxyFactory());
275-
} else if(m_parser.isSet(CommandLineOptions::scManualProxyLong)) {
272+
} else if(m_parser.isSet(CommandLineOptions::scCustomProxyLong)) {
276273
m_core->settings().setProxyType(QInstaller::Settings::UserDefinedProxy);
277274
// get proxy type, name, port
278275
if ((m_parser.isSet(CommandLineOptions::scHttpProxyHostNameLong)) && (m_parser.isSet(CommandLineOptions::scPortIdLong))) {
@@ -336,7 +333,9 @@ class SDKApp : public T
336333
errorMessage = QObject::tr("Manual proxy name and portId need to be specifed.");
337334
return false;
338335
}
339-
336+
} else if (QNetworkProxyFactory::usesSystemConfiguration()) {
337+
m_core->settings().setProxyType(QInstaller::Settings::SystemProxy);
338+
KDUpdater::FileDownloaderFactory::instance().setProxyFactory(m_core->proxyFactory());
340339
}
341340

342341
if (m_parser.isSet(CommandLineOptions::scLocalCachePathLong)) {

0 commit comments

Comments
 (0)