Changeset View
Changeset View
Standalone View
Standalone View
plugins/share/shareplugin.cpp
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | |||||
64 | } | 64 | } | ||
65 | 65 | | |||
66 | static QString cleanFilename(const QString &filename) | 66 | static QString cleanFilename(const QString &filename) | ||
67 | { | 67 | { | ||
68 | int idx = filename.lastIndexOf(QLatin1Char('/')); | 68 | int idx = filename.lastIndexOf(QLatin1Char('/')); | ||
69 | return idx>=0 ? filename.mid(idx + 1) : filename; | 69 | return idx>=0 ? filename.mid(idx + 1) : filename; | ||
70 | } | 70 | } | ||
71 | 71 | | |||
72 | bool SharePlugin::receivePackage(const NetworkPackage& np) | 72 | bool SharePlugin::receivePacket(const NetworkPacket& np) | ||
73 | { | 73 | { | ||
74 | /* | 74 | /* | ||
75 | //TODO: Write a test like this | 75 | //TODO: Write a test like this | ||
76 | if (np.type() == PACKAGE_TYPE_PING) { | 76 | if (np.type() == PACKET_TYPE_PING) { | ||
77 | 77 | | |||
78 | qCDebug(KDECONNECT_PLUGIN_SHARE) << "sending file" << (QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/.bashrc"); | 78 | qCDebug(KDECONNECT_PLUGIN_SHARE) << "sending file" << (QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/.bashrc"); | ||
79 | 79 | | |||
80 | NetworkPackage out(PACKAGE_TYPE_SHARE_REQUEST); | 80 | NetworkPacket out(PACKET_TYPE_SHARE_REQUEST); | ||
81 | out.set("filename", mDestinationDir + "itworks.txt"); | 81 | out.set("filename", mDestinationDir + "itworks.txt"); | ||
82 | AutoClosingQFile* file = new AutoClosingQFile(QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/.bashrc"); //Test file to transfer | 82 | AutoClosingQFile* file = new AutoClosingQFile(QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/.bashrc"); //Test file to transfer | ||
83 | 83 | | |||
84 | out.setPayload(file, file->size()); | 84 | out.setPayload(file, file->size()); | ||
85 | 85 | | |||
86 | device()->sendPackage(out); | 86 | device()->sendPacket(out); | ||
87 | 87 | | |||
88 | return true; | 88 | return true; | ||
89 | 89 | | |||
90 | } | 90 | } | ||
91 | */ | 91 | */ | ||
92 | 92 | | |||
93 | qCDebug(KDECONNECT_PLUGIN_SHARE) << "File transfer"; | 93 | qCDebug(KDECONNECT_PLUGIN_SHARE) << "File transfer"; | ||
94 | 94 | | |||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | |||||
150 | 150 | | |||
151 | void SharePlugin::openDestinationFolder() | 151 | void SharePlugin::openDestinationFolder() | ||
152 | { | 152 | { | ||
153 | QDesktopServices::openUrl(destinationDir()); | 153 | QDesktopServices::openUrl(destinationDir()); | ||
154 | } | 154 | } | ||
155 | 155 | | |||
156 | void SharePlugin::shareUrl(const QUrl& url) | 156 | void SharePlugin::shareUrl(const QUrl& url) | ||
157 | { | 157 | { | ||
158 | NetworkPackage package(PACKAGE_TYPE_SHARE_REQUEST); | 158 | NetworkPacket packet(PACKET_TYPE_SHARE_REQUEST); | ||
159 | if(url.isLocalFile()) { | 159 | if(url.isLocalFile()) { | ||
160 | QSharedPointer<QIODevice> ioFile(new QFile(url.toLocalFile())); | 160 | QSharedPointer<QIODevice> ioFile(new QFile(url.toLocalFile())); | ||
161 | package.setPayload(ioFile, ioFile->size()); | 161 | packet.setPayload(ioFile, ioFile->size()); | ||
162 | package.set<QString>(QStringLiteral("filename"), QUrl(url).fileName()); | 162 | packet.set<QString>(QStringLiteral("filename"), QUrl(url).fileName()); | ||
163 | } else { | 163 | } else { | ||
164 | package.set<QString>(QStringLiteral("url"), url.toString()); | 164 | packet.set<QString>(QStringLiteral("url"), url.toString()); | ||
165 | } | 165 | } | ||
166 | sendPackage(package); | 166 | sendPacket(packet); | ||
167 | } | 167 | } | ||
168 | 168 | | |||
169 | QString SharePlugin::dbusPath() const | 169 | QString SharePlugin::dbusPath() const | ||
170 | { | 170 | { | ||
171 | return "/modules/kdeconnect/devices/" + device()->id() + "/share"; | 171 | return "/modules/kdeconnect/devices/" + device()->id() + "/share"; | ||
172 | } | 172 | } | ||
173 | 173 | | |||
174 | #include "shareplugin.moc" | 174 | #include "shareplugin.moc" |