Skip to content

Commit

Permalink
- Introduction of proxy usage support.
Browse files Browse the repository at this point in the history
  • Loading branch information
aarnt committed Jan 17, 2020
1 parent 6500cb9 commit 2250904
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
16 changes: 15 additions & 1 deletion helper/octopihelper.cpp
Expand Up @@ -31,6 +31,7 @@
#include <QTcpSocket>
#include <QDataStream>
#include <QFile>
#include <QSettings>

QFile *OctopiHelper::m_temporaryFile = nullptr;

Expand Down Expand Up @@ -149,6 +150,15 @@ QProcessEnvironment OctopiHelper::getProcessEnvironment()
return env;
}

/*
* Retrieves Proxy_Settings config from "/root/.config/octopi/octopi.conf"
*/
QString OctopiHelper::getProxySettings()
{
QSettings settings(QSettings::UserScope, ctn_ORGANIZATION, ctn_APPLICATION);
return (settings.value(ctn_KEY_PROXY_SETTINGS, "").toString());
}

/*
* Checks if Octopi/Octopi-notifier, cache-cleaner, etc is being executed
*/
Expand Down Expand Up @@ -180,7 +190,6 @@ bool OctopiHelper::isOctoToolRunning(const QString &octoToolName)
options << "/usr/bin/octopi -sysupgrade";

if (out == "/usr/bin/" + octoToolName || (options.indexOf(out)!=-1)) res=true;

}
return res;
}
Expand Down Expand Up @@ -450,6 +459,11 @@ int OctopiHelper::executePkgTransactionWithSharedMem()
//Let's construct the root owned execution file
QFile *ftemp = generateTemporaryFile();
QTextStream out(ftemp);

QString proxySettings = getProxySettings();
if (!proxySettings.isEmpty())
out << "export http_proxy=" + proxySettings + "\n";

out << "unalias -a\n" << contents;
out.flush();
ftemp->close();
Expand Down
2 changes: 2 additions & 0 deletions helper/octopihelper.h
Expand Up @@ -41,6 +41,8 @@ Q_OBJECT

static QFile *m_temporaryFile;

static QString getProxySettings();

static QFile* generateTemporaryFile(){
quint32 gen = QRandomGenerator::global()->generate();
m_temporaryFile = new QFile(ctn_TEMP_ACTIONS_FILE + QString::number(gen));
Expand Down
1 change: 1 addition & 0 deletions src/constants.h
Expand Up @@ -117,6 +117,7 @@ const QString ctn_KEY_PACKAGE_REPOSITORY_COLUMN_WIDTH("Package_Repository_Column
const QString ctn_KEY_SU_TOOL("SU_Tool_Name");
const QString ctn_KEY_TERMINAL("Terminal");
const QString ctn_KEY_INSTANT_SEARCH("Instant_Search");
const QString ctn_KEY_PROXY_SETTINGS("Proxy_Settings");
const QString ctn_AUTOMATIC("automatic");

//SettingsManager - Notifier related
Expand Down
15 changes: 15 additions & 0 deletions src/settingsmanager.cpp
Expand Up @@ -460,6 +460,12 @@ QString SettingsManager::getAURPassword()
return decryptedValue;
}

QString SettingsManager::getProxySettings()
{
SettingsManager p_instance;
return (p_instance.getSYSsettings()->value(ctn_KEY_PROXY_SETTINGS, ""));
}

bool SettingsManager::getUseAlternateRowColor()
{
SettingsManager p_instance;
Expand Down Expand Up @@ -766,6 +772,15 @@ void SettingsManager::setAURPassword(const QString &newValue)
instance()->getSYSsettings()->sync();
}

void SettingsManager::setProxySettings(const QString &newValue)
{
if (!newValue.isEmpty())
{
instance()->getSYSsettings()->setValue(ctn_KEY_PROXY_SETTINGS, newValue);
instance()->getSYSsettings()->sync();
}
}

void SettingsManager::setUseAlternateRowColor(bool newValue)
{
instance()->getSYSsettings()->setValue(ctn_KEY_USE_ALTERNATE_ROW_COLOR, newValue);
Expand Down
2 changes: 2 additions & 0 deletions src/settingsmanager.h
Expand Up @@ -81,6 +81,7 @@ class SettingsManager
static bool getEnableAURVoting();
static QString getAURUserName();
static QString getAURPassword();
static QString getProxySettings();
static bool getUseAlternateRowColor();
static bool getEnableConfirmationDialogInSysUpgrade();
static bool getEnableInternetChecking();
Expand Down Expand Up @@ -158,6 +159,7 @@ class SettingsManager
static void setEnableAURVoting(bool newValue);
static void setAURUserName(const QString& newValue);
static void setAURPassword(const QString& newValue);
static void setProxySettings(const QString& newValue);
static void setUseAlternateRowColor(bool newValue);
static void setEnableConfirmationDialogInSysUpgrade(bool newValue);
static void setEnableInternetChecking(bool newValue);
Expand Down

3 comments on commit 2250904

@aarnt
Copy link
Owner Author

@aarnt aarnt commented on 2250904 Jan 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, indeed It seems so.
Sad news is I broke my right wrist saturday... :-(

@aarnt
Copy link
Owner Author

@aarnt aarnt commented on 2250904 Jan 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to disable internet tests on options/general.

@aarnt
Copy link
Owner Author

@aarnt aarnt commented on 2250904 Jan 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, probably easy to fix.
Just have to see how easy using just my left arm and hand.

Please sign in to comment.