[kioslave/remote] Port away from kdelibs4support

Differential Revision: https://phabricator.kde.org/D3243
wilder-5.14
Elvis Angelaccio 9 years ago
parent 43523918f1
commit 72e39f083a
  1. 2
      kioslave/remote/CMakeLists.txt
  2. 2
      kioslave/remote/kdedmodule/CMakeLists.txt
  3. 66
      kioslave/remote/kdedmodule/remotedirnotify.cpp
  4. 8
      kioslave/remote/kdedmodule/remotedirnotify.h
  5. 4
      kioslave/remote/kdedmodule/remotedirnotifymodule.cpp
  6. 12
      kioslave/remote/kio_remote.cpp
  7. 40
      kioslave/remote/remoteimpl.cpp
  8. 6
      kioslave/remote/remoteimpl.h

@ -14,7 +14,7 @@ ecm_qt_declare_logging_category(kio_remote_SRCS HEADER debug.h
DEFAULT_SEVERITY Info)
add_library(kio_remote MODULE ${kio_remote_SRCS})
target_link_libraries(kio_remote KF5::KIOCore KF5::KDELibs4Support)
target_link_libraries(kio_remote KF5::KIOCore KF5::I18n)
install(TARGETS kio_remote DESTINATION ${KDE_INSTALL_PLUGINDIR} )
install( FILES remote.protocol DESTINATION ${KDE_INSTALL_KSERVICES5DIR} )

@ -1,6 +1,6 @@
add_library(remotedirnotify MODULE remotedirnotify.cpp remotedirnotifymodule.cpp ../debug.cpp)
kcoreaddons_desktop_to_json(remotedirnotify remotedirnotify.desktop)
target_link_libraries(remotedirnotify KF5::DBusAddons KF5::KIOCore KF5::KDELibs4Support)
target_link_libraries(remotedirnotify KF5::DBusAddons KF5::KIOCore)
install(TARGETS remotedirnotify DESTINATION ${KDE_INSTALL_PLUGINDIR}/kf5/kded )

@ -19,19 +19,15 @@
#include "remotedirnotify.h"
#include "../debug.h"
#include <klocale.h>
#include <kglobal.h>
#include <kstandarddirs.h>
#include <kdesktopfile.h>
#include <kdirnotify.h>
#include <KIO/Global>
#include <QtDBus/QtDBus>
RemoteDirNotify::RemoteDirNotify()
{
KGlobal::dirs()->addResourceType("remote_entries", "data", "remoteview");
const QString path = KGlobal::dirs()->saveLocation("remote_entries");
const QString path = QStringLiteral("%1/remoteview").arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));
m_baseURL.setPath(path);
QDBusConnection::sessionBus().connect(QString(), QString(), QStringLiteral("org.kde.KDirNotify"),
@ -42,48 +38,42 @@ RemoteDirNotify::RemoteDirNotify()
QStringLiteral("FilesChanged"), this, SLOT(FilesChanged(QStringList)));
}
KUrl RemoteDirNotify::toRemoteURL(const KUrl &url)
QUrl RemoteDirNotify::toRemoteURL(const QUrl &url)
{
qCDebug(KIOREMOTE_LOG) << "RemoteDirNotify::toRemoteURL(" << url << ")";
if ( m_baseURL.isParentOf(url) )
{
QString path = KUrl::relativePath(m_baseURL.path(),
url.path());
KUrl result("remote:/"+path);
result.cleanPath();
QString path = QDir(m_baseURL.path()).relativeFilePath(url.path());
QUrl result;
result.setScheme(QStringLiteral("remote"));
result.setPath(path);
result.setPath(QDir::cleanPath(result.path()));
qCDebug(KIOREMOTE_LOG) << "result => " << result;
return result;
}
qCDebug(KIOREMOTE_LOG) << "result => KUrl()";
return KUrl();
qCDebug(KIOREMOTE_LOG) << "result => QUrl()";
return QUrl();
}
KUrl::List RemoteDirNotify::toRemoteURLList(const KUrl::List &list)
QList<QUrl> RemoteDirNotify::toRemoteURLList(const QStringList &list)
{
KUrl::List new_list;
KUrl::List::const_iterator it = list.begin();
KUrl::List::const_iterator end = list.end();
for (; it!=end; ++it)
{
KUrl url = toRemoteURL(*it);
if (url.isValid())
{
new_list.append(url);
}
}
return new_list;
QList<QUrl> urls;
for (const QString &file : list) {
QUrl url = toRemoteURL(QUrl::fromLocalFile(file));
if (url.isValid()) {
urls.append(url);
}
}
return urls;
}
void RemoteDirNotify::FilesAdded(const QString &directory)
{
qCDebug(KIOREMOTE_LOG) << "RemoteDirNotify::FilesAdded";
QUrl new_dir = toRemoteURL(directory);
QUrl new_dir = toRemoteURL(QUrl::fromLocalFile(directory));
if (new_dir.isValid())
{
@ -96,16 +86,16 @@ void RemoteDirNotify::FilesAdded(const QString &directory)
// have a file:/ based UDS_URL so that they are executed correctly.
// Hence, FilesRemoved and FilesChanged does nothing... We're forced to use
// FilesAdded to re-list the modified directory.
inline void evil_hack(const KUrl::List &list)
inline void evil_hack(const QList<QUrl> &list)
{
KUrl::List notified;
QList<QUrl> notified;
KUrl::List::const_iterator it = list.begin();
KUrl::List::const_iterator end = list.end();
QList<QUrl>::const_iterator it = list.begin();
QList<QUrl>::const_iterator end = list.end();
for (; it!=end; ++it)
{
QUrl url = (*it).upUrl();
QUrl url = KIO::upUrl(*it);
if (!notified.contains(url))
{
@ -120,7 +110,7 @@ void RemoteDirNotify::FilesRemoved(const QStringList &fileList)
{
qCDebug(KIOREMOTE_LOG) << "RemoteDirNotify::FilesRemoved";
KUrl::List new_list = toRemoteURLList(fileList);
QList<QUrl> new_list = toRemoteURLList(fileList);
if (!new_list.isEmpty())
{
@ -134,7 +124,7 @@ void RemoteDirNotify::FilesChanged(const QStringList &fileList)
{
qCDebug(KIOREMOTE_LOG) << "RemoteDirNotify::FilesChanged";
KUrl::List new_list = toRemoteURLList(fileList);
QList<QUrl> new_list = toRemoteURLList(fileList);
if (!new_list.isEmpty())
{

@ -19,7 +19,7 @@
#ifndef REMOTEDIRNOTIFY_H
#define REMOTEDIRNOTIFY_H
#include <kurl.h>
#include <QUrl>
#include <QtCore/QObject>
class RemoteDirNotify : public QObject
@ -35,9 +35,9 @@ private slots:
void FilesChanged (const QStringList &fileList);
private:
KUrl toRemoteURL(const KUrl &url);
KUrl::List toRemoteURLList(const KUrl::List &list);
KUrl m_baseURL;
QUrl toRemoteURL(const QUrl &url);
QList<QUrl> toRemoteURLList(const QStringList &list);
QUrl m_baseURL;
};
#endif

@ -18,10 +18,6 @@
#include "remotedirnotifymodule.h"
#include <kdebug.h>
#include <klocale.h>
#include <kglobal.h>
#include <kpluginfactory.h>
//#include <kpluginloader.h>

@ -61,14 +61,15 @@ void RemoteProtocol::listDir(const QUrl &url)
int second_slash_idx = url.path().indexOf( '/', 1 );
const QString root_dirname = url.path().mid( 1, second_slash_idx-1 );
KUrl target = m_impl.findBaseURL( root_dirname );
QUrl target = m_impl.findBaseURL( root_dirname );
qCDebug(KIOREMOTE_LOG) << "possible redirection target : " << target;
if( target.isValid() )
{
if ( second_slash_idx < 0 ) {
second_slash_idx = url.path().size();
}
target.addPath( url.path().remove(0, second_slash_idx) );
target = target.adjusted(QUrl::StripTrailingSlash);
target.setPath(target.path() + '/' + ( url.path().remove(0, second_slash_idx) ));
qCDebug(KIOREMOTE_LOG) << "complete redirection target : " << target;
redirection(target);
finished();
@ -149,7 +150,7 @@ void RemoteProtocol::stat(const QUrl &url)
}
else
{
KUrl target = m_impl.findBaseURL( root_dirname );
QUrl target = m_impl.findBaseURL( root_dirname );
qCDebug(KIOREMOTE_LOG) << "possible redirection target : " << target;
if ( target.isValid() )
{
@ -157,7 +158,8 @@ void RemoteProtocol::stat(const QUrl &url)
second_slash_idx = url.path().size();
}
qCDebug(KIOREMOTE_LOG) << "complete redirection target : " << target;
target.addPath( url.path().remove( 0, second_slash_idx ) );
target = target.adjusted(QUrl::StripTrailingSlash);
target.setPath(target.path() + '/' + ( url.path().remove( 0, second_slash_idx ) ));
redirection( target );
finished();
return;
@ -190,7 +192,7 @@ void RemoteProtocol::get(const QUrl &url)
if (!file.isEmpty())
{
KUrl desktop;
QUrl desktop;
desktop.setPath(file);
redirection(desktop);

@ -20,13 +20,10 @@
#include "remoteimpl.h"
#include "debug.h"
#include <kglobalsettings.h>
#include <kstandarddirs.h>
#include <kdesktopfile.h>
#include <kservice.h>
#include <kglobal.h>
#include <klocale.h>
#include <kconfiggroup.h>
#include <KLocalizedString>
#include <QDir>
#include <QFile>
@ -38,9 +35,7 @@
RemoteImpl::RemoteImpl()
{
KGlobal::dirs()->addResourceType("remote_entries", "data", "remoteview");
const QString path = KGlobal::dirs()->saveLocation("remote_entries");
const QString path = QStringLiteral("%1/remoteview").arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));
QDir dir = path;
if (!dir.exists())
@ -55,7 +50,7 @@ void RemoteImpl::listRoot(KIO::UDSEntryList &list) const
qCDebug(KIOREMOTE_LOG) << "RemoteImpl::listRoot";
QStringList names_found;
const QStringList dirList = KGlobal::dirs()->resourceDirs("remote_entries");
const QStringList dirList = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("remoteview"), QStandardPaths::LocateDirectory);
QStringList::ConstIterator dirpath = dirList.constBegin();
const QStringList::ConstIterator end = dirList.constEnd();
@ -90,7 +85,7 @@ bool RemoteImpl::findDirectory(const QString &filename, QString &directory) cons
{
qCDebug(KIOREMOTE_LOG) << "RemoteImpl::findDirectory";
const QStringList dirList = KGlobal::dirs()->resourceDirs("remote_entries");
const QStringList dirList = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("remoteview"), QStandardPaths::LocateDirectory);
QStringList::ConstIterator dirpath = dirList.constBegin();
const QStringList::ConstIterator end = dirList.constEnd();
@ -134,7 +129,7 @@ QString RemoteImpl::findDesktopFile(const QString &filename) const
return QString();
}
KUrl RemoteImpl::findBaseURL(const QString &filename) const
QUrl RemoteImpl::findBaseURL(const QString &filename) const
{
qCDebug(KIOREMOTE_LOG) << "RemoteImpl::findBaseURL";
@ -142,10 +137,10 @@ KUrl RemoteImpl::findBaseURL(const QString &filename) const
if (!file.isEmpty())
{
KDesktopFile desktop( file );
return desktop.readUrl();
return QUrl::fromLocalFile(desktop.readUrl());
}
return KUrl();
return QUrl();
}
@ -161,16 +156,15 @@ void RemoteImpl::createTopLevelEntry(KIO::UDSEntry &entry) const
entry.insert( KIO::UDSEntry::UDS_GROUP, QString::fromLatin1("root"));
}
static KUrl findWizardRealURL()
static QUrl findWizardRealURL()
{
KUrl url;
QUrl url;
KService::Ptr service = KService::serviceByDesktopName(WIZARD_SERVICE);
if (service && service->isValid())
{
url.setPath( KStandardDirs::locate("apps",
service->entryPath())
);
url.setPath(QStandardPaths::locate(QStandardPaths::ApplicationsLocation,
QStringLiteral("%1.desktop").arg(WIZARD_SERVICE)));
}
return url;
@ -180,7 +174,7 @@ bool RemoteImpl::createWizardEntry(KIO::UDSEntry &entry) const
{
entry.clear();
KUrl url = findWizardRealURL();
QUrl url = findWizardRealURL();
if (!url.isValid())
{
@ -198,9 +192,9 @@ bool RemoteImpl::createWizardEntry(KIO::UDSEntry &entry) const
return true;
}
bool RemoteImpl::isWizardURL(const KUrl &url) const
bool RemoteImpl::isWizardURL(const QUrl &url) const
{
return url==KUrl(WIZARD_URL);
return url==QUrl(WIZARD_URL);
}
@ -210,7 +204,11 @@ void RemoteImpl::createEntry(KIO::UDSEntry &entry,
{
qCDebug(KIOREMOTE_LOG) << "RemoteImpl::createEntry";
KDesktopFile desktop(directory+file);
QString dir = directory;
if (!dir.endsWith(QLatin1Char('/'))) {
dir += QLatin1Char('/');
}
KDesktopFile desktop(dir + file);
qCDebug(KIOREMOTE_LOG) << "path = " << directory << file;

@ -22,7 +22,7 @@
#include <kio/global.h>
#include <kio/job.h>
#include <kurl.h>
#include <QUrl>
@ -33,12 +33,12 @@ public:
void createTopLevelEntry(KIO::UDSEntry &entry) const;
bool createWizardEntry(KIO::UDSEntry &entry) const;
bool isWizardURL(const KUrl &url) const;
bool isWizardURL(const QUrl &url) const;
bool statNetworkFolder(KIO::UDSEntry &entry, const QString &filename) const;
void listRoot(KIO::UDSEntryList& list) const;
KUrl findBaseURL(const QString &filename) const;
QUrl findBaseURL(const QString &filename) const;
QString findDesktopFile(const QString &filename) const;
bool deleteNetworkFolder(const QString &filename) const;

Loading…
Cancel
Save