Changeset View
Changeset View
Standalone View
Standalone View
samba/filepropertiesplugin/sambausershareplugin.cpp
Show All 34 Lines | |||||
35 | 35 | | |||
36 | #include "sambausershareplugin.h" | 36 | #include "sambausershareplugin.h" | ||
37 | #include "model.h" | 37 | #include "model.h" | ||
38 | #include "delegate.h" | 38 | #include "delegate.h" | ||
39 | 39 | | |||
40 | K_PLUGIN_FACTORY(SambaUserSharePluginFactory, registerPlugin<SambaUserSharePlugin>();) | 40 | K_PLUGIN_FACTORY(SambaUserSharePluginFactory, registerPlugin<SambaUserSharePlugin>();) | ||
41 | K_EXPORT_PLUGIN(SambaUserSharePluginFactory("fileshare_propsdlgplugin")) | 41 | K_EXPORT_PLUGIN(SambaUserSharePluginFactory("fileshare_propsdlgplugin")) | ||
42 | 42 | | |||
43 | // copied from kio/src/core/ksambashare.cpp, KSambaSharePrivate::isSambaInstalled() | 43 | // copied from kio/src/core/ksambashare.cpp, KSambaSharePrivate::isSambaInstalled() | ||
bruns: see here ^
`net` is not checked for at all, it just tries to execute it using `QProcess::start… | |||||
44 | static bool isSambaInstalled() | 44 | static bool isSambaInstalled() | ||
45 | { | 45 | { | ||
46 | if (QFile::exists(QStringLiteral("/usr/sbin/smbd")) | 46 | if (QFile::exists(QStringLiteral("/usr/sbin/smbd")) | ||
47 | || QFile::exists(QStringLiteral("/usr/local/sbin/smbd"))) { | 47 | || QFile::exists(QStringLiteral("/usr/local/sbin/smbd"))) { | ||
48 | return true; | 48 | return true; | ||
49 | } | 49 | } | ||
50 | 50 | | |||
51 | //qDebug() << "Samba is not installed!"; | 51 | //qDebug() << "Samba is not installed!"; | ||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | |||||
141 | SambaUserSharePlugin::~SambaUserSharePlugin() | 141 | SambaUserSharePlugin::~SambaUserSharePlugin() | ||
142 | { | 142 | { | ||
143 | } | 143 | } | ||
144 | 144 | | |||
145 | #ifdef SAMBA_INSTALL | 145 | #ifdef SAMBA_INSTALL | ||
146 | void SambaUserSharePlugin::installSamba() | 146 | void SambaUserSharePlugin::installSamba() | ||
147 | { | 147 | { | ||
148 | QString package = QStringLiteral(SAMBA_PACKAGE_NAME); | 148 | QString package = QStringLiteral(SAMBA_PACKAGE_NAME); | ||
149 | PackageKit::Transaction *transaction = PackageKit::Daemon::resolve(package, | 149 | QStringList distroSambaPackages = package.split(QLatin1Char(',')); | ||
150 | PackageKit::Transaction::FilterArch); | 150 | | ||
151 | connect(transaction, | 151 | PackageKit::Transaction *transaction = PackageKit::Daemon::resolve(distroSambaPackages, PackageKit::Transaction::FilterArch); | ||
152 | SIGNAL(package(PackageKit::Transaction::Info,QString,QString)), | 152 | | ||
153 | SLOT(packageInstall(PackageKit::Transaction::Info,QString,QString))); | 153 | QSharedPointer<QStringList> pkgids(new QStringList); | ||
154 | | ||||
155 | connect(transaction, &PackageKit::Transaction::package, | ||||
156 | this, [pkgids] (PackageKit::Transaction::Info /*info*/, const QString& packageId, const QString& /*summary*/) { pkgids->append(packageId); }); | ||||
157 | | ||||
158 | connect(transaction, &PackageKit::Transaction::finished, | ||||
159 | this, [this, pkgids] (PackageKit::Transaction::Exit exit) { | ||||
160 | if (exit != PackageKit::Transaction::ExitSuccess) { return; } | ||||
161 | auto installTransaction = PackageKit::Daemon::installPackages(*pkgids); | ||||
162 | connect(installTransaction, &PackageKit::Transaction::finished, | ||||
163 | this, &SambaUserSharePlugin::packageFinished); | ||||
164 | } | ||||
165 | ); | ||||
This is a bit weird now, because you'll be getting N packages, and when they all finish installing they will all call "packageFinished" which I could expect to break in different ways. It would look something like: PackageKit::Transaction *transaction = PackageKit::Daemon::resolve(distroSambaPackages, PackageKit::Transaction::FilterArch); QSharedPointer<QStringList> pkgids(new QStringList); connect(transaction, &PackageKit::Transaction::package, [pkgids] (PackageKit::Transaction::Info info, const QString& packageId, const QString& summary) { pkgids.append(packageId); }); connect(t, &PackageKit::Transaction::finished, [pkgids] (PackageKit::Transaction::Exit exit) { if (exit != PackageKit::Transaction::ExitSuccess) return; auto t = PackageKit::Daemon::installPackage(*pkgids); //t.... }) apol: This is a bit weird now, because you'll be getting N packages, and when they all finish… | |||||
154 | 166 | | |||
155 | m_sambaStatusMessage->setText(i18n("Installing Samba...")); | 167 | m_sambaStatusMessage->setText(i18n("Installing Samba...")); | ||
156 | m_installProgress->setMaximum(0); | 168 | m_installProgress->setMaximum(0); | ||
157 | m_installProgress->setMinimum(0); | 169 | m_installProgress->setMinimum(0); | ||
158 | m_installProgress->show(); | 170 | m_installProgress->show(); | ||
159 | m_installSambaButton->hide(); | 171 | m_installSambaButton->hide(); | ||
160 | } | 172 | } | ||
161 | 173 | | |||
162 | void SambaUserSharePlugin::packageInstall(PackageKit::Transaction::Info info, | | |||
163 | const QString &packageId, | | |||
164 | const QString &summary) | | |||
165 | { | | |||
166 | Q_UNUSED(info); | | |||
167 | Q_UNUSED(summary); | | |||
168 | PackageKit::Transaction *installTransaction = PackageKit::Daemon::installPackage(packageId); | | |||
169 | connect(installTransaction, | | |||
170 | SIGNAL(finished(PackageKit::Transaction::Exit, uint)), | | |||
171 | SLOT(packageFinished(PackageKit::Transaction::Exit, uint))); | | |||
172 | } | | |||
173 | | ||||
174 | void SambaUserSharePlugin::packageFinished(PackageKit::Transaction::Exit status, uint runtime) | 174 | void SambaUserSharePlugin::packageFinished(PackageKit::Transaction::Exit status, uint runtime) | ||
175 | { | 175 | { | ||
176 | Q_UNUSED(runtime); | 176 | Q_UNUSED(runtime); | ||
177 | if (status == PackageKit::Transaction::ExitSuccess) { | 177 | if (status == PackageKit::Transaction::ExitSuccess) { | ||
178 | m_installSambaWidgets->hide(); | 178 | m_installSambaWidgets->hide(); | ||
179 | m_failedSambaWidgets->hide(); | 179 | m_failedSambaWidgets->hide(); | ||
180 | m_shareWidgets->show(); | 180 | m_shareWidgets->show(); | ||
181 | } else { | 181 | } else { | ||
▲ Show 20 Lines • Show All 119 Lines • Show Last 20 Lines |
see here ^
net is not checked for at all, it just tries to execute it using QProcess::start("net", args)