Changeset View
Changeset View
Standalone View
Standalone View
kioslave/remote/kdedmodule/remotedirnotify.cpp
Show All 35 Lines | 35 | QDBusConnection::sessionBus().connect(QString(), QString(), QStringLiteral("org.kde.KDirNotify"), | |||
---|---|---|---|---|---|
36 | QStringLiteral("FilesRemoved"), this, SLOT(FilesRemoved(QStringList))); | 36 | QStringLiteral("FilesRemoved"), this, SLOT(FilesRemoved(QStringList))); | ||
37 | QDBusConnection::sessionBus().connect(QString(), QString(), QStringLiteral("org.kde.KDirNotify"), | 37 | QDBusConnection::sessionBus().connect(QString(), QString(), QStringLiteral("org.kde.KDirNotify"), | ||
38 | QStringLiteral("FilesChanged"), this, SLOT(FilesChanged(QStringList))); | 38 | QStringLiteral("FilesChanged"), this, SLOT(FilesChanged(QStringList))); | ||
39 | } | 39 | } | ||
40 | 40 | | |||
41 | QUrl RemoteDirNotify::toRemoteURL(const QUrl &url) | 41 | QUrl RemoteDirNotify::toRemoteURL(const QUrl &url) | ||
42 | { | 42 | { | ||
43 | qCDebug(KIOREMOTE_LOG) << "RemoteDirNotify::toRemoteURL(" << url << ")"; | 43 | qCDebug(KIOREMOTE_LOG) << "RemoteDirNotify::toRemoteURL(" << url << ")"; | ||
44 | if ( m_baseURL.isParentOf(url) ) | 44 | if (m_baseURL.isParentOf(url)) { | ||
45 | { | | |||
46 | QString path = QDir(m_baseURL.path()).relativeFilePath(url.path()); | 45 | QString path = QDir(m_baseURL.path()).relativeFilePath(url.path()); | ||
47 | QUrl result; | 46 | QUrl result; | ||
48 | result.setScheme(QStringLiteral("remote")); | 47 | result.setScheme(QStringLiteral("remote")); | ||
49 | result.setPath(path); | 48 | result.setPath(path); | ||
50 | result.setPath(QDir::cleanPath(result.path())); | 49 | result.setPath(QDir::cleanPath(result.path())); | ||
51 | qCDebug(KIOREMOTE_LOG) << "result => " << result; | 50 | qCDebug(KIOREMOTE_LOG) << "result => " << result; | ||
52 | return result; | 51 | return result; | ||
53 | } | 52 | } | ||
Show All 16 Lines | |||||
70 | } | 69 | } | ||
71 | 70 | | |||
72 | void RemoteDirNotify::FilesAdded(const QString &directory) | 71 | void RemoteDirNotify::FilesAdded(const QString &directory) | ||
73 | { | 72 | { | ||
74 | qCDebug(KIOREMOTE_LOG) << "RemoteDirNotify::FilesAdded"; | 73 | qCDebug(KIOREMOTE_LOG) << "RemoteDirNotify::FilesAdded"; | ||
75 | 74 | | |||
76 | QUrl new_dir = toRemoteURL(QUrl::fromLocalFile(directory)); | 75 | QUrl new_dir = toRemoteURL(QUrl::fromLocalFile(directory)); | ||
77 | 76 | | |||
78 | if (new_dir.isValid()) | 77 | if (new_dir.isValid()) { | ||
79 | { | | |||
80 | org::kde::KDirNotify::emitFilesAdded(new_dir); | 78 | org::kde::KDirNotify::emitFilesAdded(new_dir); | ||
81 | } | 79 | } | ||
82 | } | 80 | } | ||
83 | 81 | | |||
84 | // This hack is required because of the way we manage .desktop files with | 82 | // This hack is required because of the way we manage .desktop files with | ||
85 | // Forwarding Slaves, their URL is out of the ioslave (most remote:/ files | 83 | // Forwarding Slaves, their URL is out of the ioslave (most remote:/ files | ||
86 | // have a file:/ based UDS_URL so that they are executed correctly. | 84 | // have a file:/ based UDS_URL so that they are executed correctly. | ||
87 | // Hence, FilesRemoved and FilesChanged does nothing... We're forced to use | 85 | // Hence, FilesRemoved and FilesChanged does nothing... We're forced to use | ||
88 | // FilesAdded to re-list the modified directory. | 86 | // FilesAdded to re-list the modified directory. | ||
89 | inline void evil_hack(const QList<QUrl> &list) | 87 | inline void evil_hack(const QList<QUrl> &list) | ||
90 | { | 88 | { | ||
91 | QList<QUrl> notified; | 89 | QList<QUrl> notified; | ||
92 | 90 | | |||
93 | QList<QUrl>::const_iterator it = list.begin(); | 91 | QList<QUrl>::const_iterator it = list.begin(); | ||
94 | QList<QUrl>::const_iterator end = list.end(); | 92 | QList<QUrl>::const_iterator end = list.end(); | ||
95 | 93 | | |||
96 | for (; it!=end; ++it) | 94 | for (; it != end; ++it) { | ||
97 | { | | |||
98 | QUrl url = KIO::upUrl(*it); | 95 | QUrl url = KIO::upUrl(*it); | ||
99 | 96 | | |||
100 | if (!notified.contains(url)) | 97 | if (!notified.contains(url)) { | ||
101 | { | | |||
102 | org::kde::KDirNotify::emitFilesAdded(url); | 98 | org::kde::KDirNotify::emitFilesAdded(url); | ||
103 | notified.append(url); | 99 | notified.append(url); | ||
104 | } | 100 | } | ||
105 | } | 101 | } | ||
106 | } | 102 | } | ||
107 | 103 | | |||
108 | | ||||
109 | void RemoteDirNotify::FilesRemoved(const QStringList &fileList) | 104 | void RemoteDirNotify::FilesRemoved(const QStringList &fileList) | ||
110 | { | 105 | { | ||
111 | qCDebug(KIOREMOTE_LOG) << "RemoteDirNotify::FilesRemoved"; | 106 | qCDebug(KIOREMOTE_LOG) << "RemoteDirNotify::FilesRemoved"; | ||
112 | 107 | | |||
113 | QList<QUrl> new_list = toRemoteURLList(fileList); | 108 | QList<QUrl> new_list = toRemoteURLList(fileList); | ||
114 | 109 | | |||
115 | if (!new_list.isEmpty()) | 110 | if (!new_list.isEmpty()) { | ||
116 | { | | |||
117 | //KDirNotify_stub notifier("*", "*"); | 111 | //KDirNotify_stub notifier("*", "*"); | ||
118 | //notifier.FilesRemoved( new_list ); | 112 | //notifier.FilesRemoved( new_list ); | ||
119 | evil_hack(new_list); | 113 | evil_hack(new_list); | ||
120 | } | 114 | } | ||
121 | } | 115 | } | ||
122 | 116 | | |||
123 | void RemoteDirNotify::FilesChanged(const QStringList &fileList) | 117 | void RemoteDirNotify::FilesChanged(const QStringList &fileList) | ||
124 | { | 118 | { | ||
125 | qCDebug(KIOREMOTE_LOG) << "RemoteDirNotify::FilesChanged"; | 119 | qCDebug(KIOREMOTE_LOG) << "RemoteDirNotify::FilesChanged"; | ||
126 | 120 | | |||
127 | QList<QUrl> new_list = toRemoteURLList(fileList); | 121 | QList<QUrl> new_list = toRemoteURLList(fileList); | ||
128 | 122 | | |||
129 | if (!new_list.isEmpty()) | 123 | if (!new_list.isEmpty()) { | ||
130 | { | | |||
131 | //KDirNotify_stub notifier("*", "*"); | 124 | //KDirNotify_stub notifier("*", "*"); | ||
132 | //notifier.FilesChanged( new_list ); | 125 | //notifier.FilesChanged( new_list ); | ||
133 | evil_hack(new_list); | 126 | evil_hack(new_list); | ||
134 | } | 127 | } | ||
135 | } | 128 | } | ||
136 | |