Initial port to KF5
REVIEW: 120804
David Edmundson
9 years ago
0 | 0 | project (ktp-filetransfer-handler) |
1 | ||
2 | cmake_minimum_required(VERSION 2.8.12) | |
1 | 3 | |
2 | 4 | set(KTP_FILETRANSFER_HANDLER_VERSION "0.8.80") |
3 | 5 | |
4 | set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH}) | |
5 | cmake_policy(SET CMP0002 OLD) | |
6 | find_package(ECM 1.3.0 REQUIRED NO_MODULE) | |
7 | set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_MODULE_PATH}) | |
6 | 8 | |
7 | set(IS_KTP_INTERNAL_MODULE TRUE) | |
8 | set(KDE_MIN_VERSION "4.6.0") | |
9 | find_package (KF5 REQUIRED COMPONENTS KDELibs4Support) | |
10 | find_package (Qt5 REQUIRED COMPONENTS Core) | |
11 | find_package (KTp REQUIRED) | |
9 | 12 | |
10 | find_package(KDE4 ${KDE_MIN_VERSION} REQUIRED) | |
11 | find_package(TelepathyQt4 0.9.1 REQUIRED) | |
12 | find_package(KTp REQUIRED) | |
13 | ||
14 | include(CheckIncludeFiles) | |
15 | include(KDE4Defaults) | |
16 | include(MacroLibrary) | |
17 | ||
18 | add_definitions(${KDE4_DEFINITIONS} | |
19 | -DQT_NO_CAST_FROM_ASCII | |
20 | -DQT_NO_KEYWORDS | |
21 | ) | |
22 | ||
23 | include_directories(${KDE4_INCLUDES} | |
24 | ${TELEPATHY_QT4_INCLUDE_DIR} | |
25 | ${KTP_INCLUDE_DIR} | |
26 | ) | |
13 | include(KDEInstallDirs) | |
14 | include(KDECMakeSettings) | |
15 | include(KDECompilerSettings) | |
16 | include(ECMSetupVersion) | |
17 | include(FeatureSummary) | |
27 | 18 | |
28 | 19 | add_subdirectory(src) |
20 | ||
21 | feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) |
0 | Redistribution and use in source and binary forms, with or without | |
1 | modification, are permitted provided that the following conditions | |
2 | are met: | |
3 | ||
4 | 1. Redistributions of source code must retain the copyright | |
5 | notice, this list of conditions and the following disclaimer. | |
6 | 2. Redistributions in binary form must reproduce the copyright | |
7 | notice, this list of conditions and the following disclaimer in the | |
8 | documentation and/or other materials provided with the distribution. | |
9 | 3. The name of the author may not be used to endorse or promote products | |
10 | derived from this software without specific prior written permission. | |
11 | ||
12 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
13 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
14 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
15 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
16 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
17 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
18 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
19 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
20 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
21 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
0 | # Try to find the KTp library | |
1 | # KTP_FOUND | |
2 | # KTP_INCLUDE_DIR | |
3 | # KTP_LIBRARIES | |
4 | # KTP_MODELS_LIBRARIES | |
5 | # KTP_WIDGETS_LIBRARIES | |
6 | ||
7 | # Copyright (c) 2011, Dario Freddi <drf@kde.org> | |
8 | # | |
9 | # Redistribution and use is allowed according to the terms of the BSD license. | |
10 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. | |
11 | ||
12 | if (NOT IS_KTP_INTERNAL_MODULE) | |
13 | message (FATAL_ERROR "KTp can be used just from internal components at this time") | |
14 | endif (NOT IS_KTP_INTERNAL_MODULE) | |
15 | ||
16 | SET (KTP_FIND_REQUIRED ${KTp_FIND_REQUIRED}) | |
17 | if (KTP_INCLUDE_DIRS AND KTP_LIBRARIES) | |
18 | # Already in cache, be silent | |
19 | set(KTP_FIND_QUIETLY TRUE) | |
20 | endif (KTP_INCLUDE_DIRS AND KTP_LIBRARIES) | |
21 | ||
22 | find_path(KTP_INCLUDE_DIR | |
23 | NAMES KTp/presence.h | |
24 | PATHS ${KDE4_INCLUDE_DIR} | |
25 | ) | |
26 | ||
27 | find_library(KTP_LIBRARIES NAMES ktpcommoninternalsprivate ) | |
28 | find_library(KTP_MODELS_LIBRARIES NAMES ktpmodelsprivate ) | |
29 | find_library(KTP_WIDGETS_LIBRARIES NAMES ktpwidgetsprivate ) | |
30 | ||
31 | include(FindPackageHandleStandardArgs) | |
32 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(KTp DEFAULT_MSG | |
33 | KTP_LIBRARIES | |
34 | KTP_MODELS_LIBRARIES | |
35 | KTP_INCLUDE_DIR) | |
36 | ||
37 | mark_as_advanced(KTP_INCLUDE_DIRS KTP_LIBRARIES) |
0 | include_directories(${CMAKE_BINARY_DIR}) | |
1 | ||
0 | 2 | set(ktp_filetransfer_handler_SRCS |
1 | 3 | main.cpp |
2 | 4 | filetransfer-handler.cpp |
7 | 9 | |
8 | 10 | configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h) |
9 | 11 | |
10 | kde4_add_executable(ktp-filetransfer-handler ${ktp_filetransfer_handler_SRCS}) | |
12 | add_executable(ktp-filetransfer-handler ${ktp_filetransfer_handler_SRCS}) | |
11 | 13 | |
12 | 14 | target_link_libraries(ktp-filetransfer-handler |
13 | ${KDE4_KDECORE_LIBS} | |
14 | ${KDE4_KDEUI_LIBS} | |
15 | ${KDE4_KIO_LIBS} | |
16 | ${TELEPATHY_QT4_LIBRARIES} | |
17 | ${KTP_LIBRARIES} | |
15 | KTp::CommonInternals | |
16 | KF5::KDELibs4Support | |
18 | 17 | ) |
19 | 18 | |
20 | 19 | configure_file(org.freedesktop.Telepathy.Client.KTp.FileTransferHandler.service.in |
48 | 48 | QString downloadDirectory; |
49 | 49 | bool askForDownloadDirectory; |
50 | 50 | QFile* file; |
51 | KUrl url, partUrl; | |
51 | QUrl url, partUrl; | |
52 | 52 | qulonglong offset; |
53 | 53 | bool isResuming; |
54 | 54 | QWeakPointer<KIO::RenameDialog> renameDialog; |
176 | 176 | if (askForDownloadDirectory) { |
177 | 177 | url = KFileDialog::getSaveUrl(KUrl(QLatin1String("kfiledialog:///FileTransferLastDirectory/") + channel->fileName()), |
178 | 178 | QString(), 0, QString(), KFileDialog::ConfirmOverwrite); |
179 | partUrl = url.directory(); | |
180 | partUrl.addPath(url.fileName() + QLatin1String(".part")); | |
179 | ||
180 | partUrl.setPath(url.path() + QLatin1String(".part")); | |
181 | 181 | partUrl.setScheme(QLatin1String("file")); |
182 | 182 | |
183 | 183 | checkPartFile(); |
191 | 191 | { |
192 | 192 | Q_Q(HandleIncomingFileTransferChannelJob); |
193 | 193 | |
194 | url = downloadDirectory; | |
195 | url.addPath(channel->fileName()); | |
194 | url = downloadDirectory + QLatin1Char('/') + channel->fileName(); | |
196 | 195 | url.setScheme(QLatin1String("file")); |
197 | 196 | |
198 | partUrl = url.directory(); | |
199 | partUrl.addPath(url.fileName() + QLatin1String(".part")); | |
197 | partUrl = url.path() + QLatin1String(".part"); | |
200 | 198 | partUrl.setScheme(QLatin1String("file")); |
201 | 199 | |
202 | 200 | QFileInfo fileInfo(url.toLocalFile()); // TODO check if it is a dir? |
203 | 201 | if (fileInfo.exists()) { |
204 | 202 | renameDialog = new KIO::RenameDialog(0, |
205 | 203 | i18n("Incoming file exists"), |
206 | KUrl(), //TODO | |
204 | QUrl(), //TODO | |
207 | 205 | url, |
208 | KIO::M_OVERWRITE, | |
206 | KIO::RenameDialog_Overwrite, | |
209 | 207 | fileInfo.size(), |
210 | 208 | channel->size(), |
211 | fileInfo.created().toTime_t(), | |
212 | time_t(-1), | |
213 | fileInfo.lastModified().toTime_t(), | |
214 | channel->lastModificationTime().toTime_t()); | |
209 | fileInfo.created(), | |
210 | QDateTime(), | |
211 | fileInfo.lastModified(), | |
212 | channel->lastModificationTime()); | |
215 | 213 | |
216 | 214 | q->connect(q, SIGNAL(finished(KJob*)), |
217 | 215 | renameDialog.data(), SLOT(reject())); |
280 | 278 | if (fileInfo.exists()) { |
281 | 279 | renameDialog = new KIO::RenameDialog(0, |
282 | 280 | i18n("Would you like to resume partial download?"), |
283 | KUrl(), //TODO | |
281 | QUrl(), | |
284 | 282 | partUrl, |
285 | KIO::RenameDialog_Mode(KIO::M_RESUME), | |
283 | KIO::RenameDialog_Resume, | |
286 | 284 | fileInfo.size(), |
287 | 285 | channel->size(), |
288 | fileInfo.created().toTime_t(), | |
289 | time_t(-1), | |
290 | fileInfo.lastModified().toTime_t(), | |
291 | channel->lastModificationTime().toTime_t()); | |
286 | fileInfo.created(), | |
287 | QDateTime(), | |
288 | fileInfo.lastModified(), | |
289 | channel->lastModificationTime()); | |
292 | 290 | |
293 | 291 | q->connect(q, SIGNAL(finished(KJob*)), |
294 | 292 | renameDialog.data(), SLOT(reject())); |
527 | 525 | QTimer::singleShot(0, q, SLOT(__k__doEmitResult())); |
528 | 526 | } |
529 | 527 | |
530 | ||
531 | #include "handle-incoming-file-transfer-channel-job.moc" | |
528 | #include "moc_handle-incoming-file-transfer-channel-job.cpp" |
309 | 309 | QTimer::singleShot(0, q, SLOT(__k__doEmitResult())); |
310 | 310 | } |
311 | 311 | |
312 | ||
313 | #include "handle-outgoing-file-transfer-channel-job.moc" | |
312 | #include "moc_handle-outgoing-file-transfer-channel-job.cpp" |
19 | 19 | |
20 | 20 | #include <KTp/telepathy-handler-application.h> |
21 | 21 | |
22 | #include <KAboutData> | |
22 | #include <K4AboutData> | |
23 | 23 | #include <KCmdLineArgs> |
24 | 24 | #include <KDebug> |
25 | 25 | #include <TelepathyQt/ClientRegistrar> |
28 | 28 | |
29 | 29 | int main(int argc, char* argv[]) |
30 | 30 | { |
31 | KAboutData aboutData("ktp-filetransfer-handler", | |
31 | K4AboutData aboutData("ktp-filetransfer-handler", | |
32 | 32 | "ktp-filetransfer-handler", |
33 | 33 | ki18n("Telepathy File Transfer Handler"), |
34 | 34 | KTP_FILETRANSFER_HANDLER_VERSION, |
35 | 35 | ki18n("Handles your Telepathy file transfers"), |
36 | KAboutData::License_GPL_V2, | |
36 | K4AboutData::License_GPL_V2, | |
37 | 37 | ki18n("Copyright (C) 2010, 2011, 2012 Daniele E. Domenichelli <daniele.domenichelli@gmail.com>")); |
38 | 38 | aboutData.addAuthor(ki18n("Daniele E. Domenichelli"), |
39 | 39 | ki18n("Developer"), |
56 | 56 | aboutData.setHomepage("http://community.kde.org/KTp"); |
57 | 57 | |
58 | 58 | KCmdLineArgs::init(argc, argv, &aboutData); |
59 | KTp::TelepathyHandlerApplication app; | |
59 | KTp::TelepathyHandlerApplication app(argc, argv); | |
60 | 60 | |
61 | 61 | Tp::AccountFactoryPtr accountFactory = Tp::AccountFactory::create(QDBusConnection::sessionBus()); |
62 | 62 |