Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Port from KStandardDirs to QStandardPaths

Summary: --kdelibs4suupport

Test Plan: Tested importing a config file, has been imported to same path as before.

Reviewers: jgrulich

Reviewed By: jgrulich

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D13818
parent c8a29ae8
......@@ -23,7 +23,6 @@ target_link_libraries(plasmanetworkmanagement_openvpnui
KF5::I18n
KF5::WidgetsAddons
KF5::CoreAddons
KF5::KDELibs4Support # KStandardDirs
)
install(TARGETS plasmanetworkmanagement_openvpnui DESTINATION ${KDE_INSTALL_PLUGINDIR})
......
......@@ -25,10 +25,11 @@
#include <QLatin1Char>
#include <QStringBuilder>
#include <QStandardPaths>
#include <KPluginFactory>
#include <KLocalizedString>
#include <KMessageBox>
#include <KStandardDirs>
#include <NetworkManagerQt/Connection>
#include <NetworkManagerQt/VpnSetting>
......@@ -86,6 +87,12 @@ K_PLUGIN_FACTORY_WITH_JSON(OpenVpnUiPluginFactory, "plasmanetworkmanagement_open
#define PROC_TYPE_TAG "Proc-Type: 4,ENCRYPTED"
#define PKCS8_TAG "-----BEGIN ENCRYPTED PRIVATE KEY-----"
QString localCertPath()
{
return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) +
QLatin1String("/networkmanagement/certificates/");
}
QString unQuote(QString &certVal, const QString &fileName)
{
/* Unquote according to openvpn rules
......@@ -187,7 +194,7 @@ NMVariantMapMap OpenVpnUiPlugin::importConnectionSettings(const QString &fileNam
bool copyCertificates;
KMessageBox::ButtonCode buttonCode;
if (KMessageBox::shouldBeShownYesNo(QLatin1String("copyCertificatesDialog"), buttonCode)) {
copyCertificates = KMessageBox::questionYesNo(nullptr, i18n("Do you want to copy your certificates to %1?", KStandardDirs::locateLocal("data", "networkmanagement/certificates/")),
copyCertificates = KMessageBox::questionYesNo(nullptr, i18n("Do you want to copy your certificates to %1?", localCertPath()),
i18n("Copy certificates"), KStandardGuiItem::yes(), KStandardGuiItem::no(), QLatin1String("copyCertificatesDialog")) == KMessageBox::Yes;
} else {
copyCertificates = buttonCode == KMessageBox::Yes;
......@@ -660,7 +667,7 @@ NMVariantMapMap OpenVpnUiPlugin::importConnectionSettings(const QString &fileNam
QString OpenVpnUiPlugin::saveFile(QTextStream &in, const QString &endTag, const QString &connectionName, const QString &fileName)
{
const QString certificatesDirectory = KStandardDirs::locateLocal("data", "networkmanagement/certificates/" + connectionName);
const QString certificatesDirectory = localCertPath() + connectionName;
const QString absoluteFilePath = certificatesDirectory + '/' + fileName;
QFile outFile(absoluteFilePath);
......@@ -687,7 +694,7 @@ QString OpenVpnUiPlugin::saveFile(QTextStream &in, const QString &endTag, const
QString OpenVpnUiPlugin::tryToCopyToCertificatesDirectory(const QString &connectionName, const QString &sourceFilePath)
{
const QString certificatesDirectory = KStandardDirs::locateLocal("data", "networkmanagement/certificates/");
const QString certificatesDirectory = localCertPath();
const QString absoluteFilePath = certificatesDirectory + connectionName + '_' + QFileInfo(sourceFilePath).fileName();
QFile sourceFile(sourceFilePath);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment