@@ -45,6 +45,14 @@ OptionsQmlModel::OptionsQmlModel(interfaces::Node& node, bool is_onboarded)
45
45
m_upnp = SettingToBool (m_node.getPersistentSetting (" upnp" ), DEFAULT_UPNP);
46
46
47
47
m_dataDir = getDefaultDataDirString ();
48
+
49
+ m_proxy_address = QString::fromStdString (SettingToString (m_node.getPersistentSetting (" proxy" ), " " ));
50
+
51
+ m_is_proxy_set = evaluateIfProxyIsSet ();
52
+
53
+ m_tor_proxy_address = QString::fromStdString (SettingToString (m_node.getPersistentSetting (" onion" ), " " ));
54
+
55
+ m_is_tor_proxy_set = evaluateIfTorProxyIsSet ();
48
56
}
49
57
50
58
void OptionsQmlModel::setDbcacheSizeMiB (int new_dbcache_size_mib)
@@ -225,5 +233,95 @@ void OptionsQmlModel::onboard()
225
233
if (m_upnp) {
226
234
m_node.updateRwSetting (" upnp" , m_upnp);
227
235
}
236
+ if (m_is_proxy_set && !m_proxy_address.isEmpty () && m_node.validateProxyAddress (m_proxy_address.toStdString ())) {
237
+ m_node.updateRwSetting (" proxy" , m_proxy_address.toStdString ());
238
+ }
239
+ if (m_is_tor_proxy_set && !m_tor_proxy_address.isEmpty () && m_node.validateProxyAddress (m_tor_proxy_address.toStdString ())) {
240
+ m_node.updateRwSetting (" onion" , m_tor_proxy_address.toStdString ());
241
+ }
228
242
m_onboarded = true ;
229
243
}
244
+
245
+ void OptionsQmlModel::setProxyAddress (QString new_proxy_address)
246
+ {
247
+ if (new_proxy_address != m_proxy_address) {
248
+ m_proxy_address = new_proxy_address;
249
+ if (m_onboarded && m_node.validateProxyAddress (new_proxy_address.toStdString ())) {
250
+ m_node.updateRwSetting (" proxy" , new_proxy_address.toStdString ());
251
+ }
252
+ Q_EMIT proxyAddressChanged (new_proxy_address);
253
+ }
254
+ }
255
+
256
+ void OptionsQmlModel::setIsProxySet (bool is_set)
257
+ {
258
+ if (is_set != m_is_proxy_set) {
259
+ m_is_proxy_set = is_set;
260
+ if (m_onboarded && m_is_proxy_set && m_node.validateProxyAddress (m_proxy_address.toStdString ())) {
261
+ m_node.updateRwSetting (" proxy" , m_proxy_address.toStdString ());
262
+ }
263
+ if (!m_is_proxy_set) {
264
+ m_node.updateRwSetting (" proxy" , {});
265
+ }
266
+ Q_EMIT isProxySetChanged (is_set);
267
+ }
268
+ }
269
+
270
+ bool OptionsQmlModel::evaluateIfProxyIsSet ()
271
+ {
272
+ bool proxyHasBeenSet;
273
+
274
+ if (!m_proxy_address.isEmpty ()) {
275
+ if (!m_node.validateProxyAddress (m_proxy_address.toStdString ())) {
276
+ m_proxy_address = " " ;
277
+ }
278
+ }
279
+
280
+ proxyHasBeenSet = !m_proxy_address.isEmpty ();
281
+ if (!proxyHasBeenSet) {
282
+ m_proxy_address = QString::fromStdString (m_node.defaultProxyAddress ());
283
+ }
284
+ return proxyHasBeenSet;
285
+ }
286
+
287
+ void OptionsQmlModel::setTorProxyAddress (QString new_proxy_address)
288
+ {
289
+ if (new_proxy_address != m_tor_proxy_address) {
290
+ m_tor_proxy_address = new_proxy_address;
291
+ if (m_onboarded && m_node.validateProxyAddress (new_proxy_address.toStdString ())) {
292
+ m_node.updateRwSetting (" onion" , new_proxy_address.toStdString ());
293
+ }
294
+ Q_EMIT torProxyAddressChanged (new_proxy_address);
295
+ }
296
+ }
297
+
298
+ void OptionsQmlModel::setIsTorProxySet (bool is_set)
299
+ {
300
+ if (is_set != m_is_tor_proxy_set) {
301
+ m_is_tor_proxy_set = is_set;
302
+ if (m_onboarded && m_is_proxy_set && m_node.validateProxyAddress (m_tor_proxy_address.toStdString ())) {
303
+ m_node.updateRwSetting (" onion" , m_tor_proxy_address.toStdString ());
304
+ }
305
+ if (!m_is_proxy_set) {
306
+ m_node.updateRwSetting (" onion" , {});
307
+ }
308
+ Q_EMIT isTorProxySetChanged (is_set);
309
+ }
310
+ }
311
+
312
+ bool OptionsQmlModel::evaluateIfTorProxyIsSet ()
313
+ {
314
+ bool proxyHasBeenSet;
315
+
316
+ if (!m_tor_proxy_address.isEmpty ()) {
317
+ if (!m_node.validateProxyAddress (m_tor_proxy_address.toStdString ())) {
318
+ m_tor_proxy_address = " " ;
319
+ }
320
+ }
321
+
322
+ proxyHasBeenSet = !m_tor_proxy_address.isEmpty ();
323
+ if (!proxyHasBeenSet) {
324
+ m_tor_proxy_address = QString::fromStdString (m_node.defaultProxyAddress ());
325
+ }
326
+ return proxyHasBeenSet;
327
+ }
0 commit comments