Codebase list ktp-filetransfer-handler / a021abc
Initial port to KF5 REVIEW: 120804 David Edmundson 9 years ago
8 changed file(s) with 43 addition(s) and 115 deletion(s). Raw diff Collapse all Expand all
00 project (ktp-filetransfer-handler)
1
2 cmake_minimum_required(VERSION 2.8.12)
13
24 set(KTP_FILETRANSFER_HANDLER_VERSION "0.8.80")
35
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})
68
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)
912
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)
2718
2819 add_subdirectory(src)
20
21 feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
+0
-22
cmake/modules/COPYING-CMAKE-SCRIPTS less more
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
-38
cmake/modules/FindKTp.cmake less more
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
02 set(ktp_filetransfer_handler_SRCS
13 main.cpp
24 filetransfer-handler.cpp
79
810 configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
911
10 kde4_add_executable(ktp-filetransfer-handler ${ktp_filetransfer_handler_SRCS})
12 add_executable(ktp-filetransfer-handler ${ktp_filetransfer_handler_SRCS})
1113
1214 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
1817 )
1918
2019 configure_file(org.freedesktop.Telepathy.Client.KTp.FileTransferHandler.service.in
4848 QString downloadDirectory;
4949 bool askForDownloadDirectory;
5050 QFile* file;
51 KUrl url, partUrl;
51 QUrl url, partUrl;
5252 qulonglong offset;
5353 bool isResuming;
5454 QWeakPointer<KIO::RenameDialog> renameDialog;
176176 if (askForDownloadDirectory) {
177177 url = KFileDialog::getSaveUrl(KUrl(QLatin1String("kfiledialog:///FileTransferLastDirectory/") + channel->fileName()),
178178 QString(), 0, QString(), KFileDialog::ConfirmOverwrite);
179 partUrl = url.directory();
180 partUrl.addPath(url.fileName() + QLatin1String(".part"));
179
180 partUrl.setPath(url.path() + QLatin1String(".part"));
181181 partUrl.setScheme(QLatin1String("file"));
182182
183183 checkPartFile();
191191 {
192192 Q_Q(HandleIncomingFileTransferChannelJob);
193193
194 url = downloadDirectory;
195 url.addPath(channel->fileName());
194 url = downloadDirectory + QLatin1Char('/') + channel->fileName();
196195 url.setScheme(QLatin1String("file"));
197196
198 partUrl = url.directory();
199 partUrl.addPath(url.fileName() + QLatin1String(".part"));
197 partUrl = url.path() + QLatin1String(".part");
200198 partUrl.setScheme(QLatin1String("file"));
201199
202200 QFileInfo fileInfo(url.toLocalFile()); // TODO check if it is a dir?
203201 if (fileInfo.exists()) {
204202 renameDialog = new KIO::RenameDialog(0,
205203 i18n("Incoming file exists"),
206 KUrl(), //TODO
204 QUrl(), //TODO
207205 url,
208 KIO::M_OVERWRITE,
206 KIO::RenameDialog_Overwrite,
209207 fileInfo.size(),
210208 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());
215213
216214 q->connect(q, SIGNAL(finished(KJob*)),
217215 renameDialog.data(), SLOT(reject()));
280278 if (fileInfo.exists()) {
281279 renameDialog = new KIO::RenameDialog(0,
282280 i18n("Would you like to resume partial download?"),
283 KUrl(), //TODO
281 QUrl(),
284282 partUrl,
285 KIO::RenameDialog_Mode(KIO::M_RESUME),
283 KIO::RenameDialog_Resume,
286284 fileInfo.size(),
287285 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());
292290
293291 q->connect(q, SIGNAL(finished(KJob*)),
294292 renameDialog.data(), SLOT(reject()));
527525 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
528526 }
529527
530
531 #include "handle-incoming-file-transfer-channel-job.moc"
528 #include "moc_handle-incoming-file-transfer-channel-job.cpp"
309309 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
310310 }
311311
312
313 #include "handle-outgoing-file-transfer-channel-job.moc"
312 #include "moc_handle-outgoing-file-transfer-channel-job.cpp"
1919
2020 #include <KTp/telepathy-handler-application.h>
2121
22 #include <KAboutData>
22 #include <K4AboutData>
2323 #include <KCmdLineArgs>
2424 #include <KDebug>
2525 #include <TelepathyQt/ClientRegistrar>
2828
2929 int main(int argc, char* argv[])
3030 {
31 KAboutData aboutData("ktp-filetransfer-handler",
31 K4AboutData aboutData("ktp-filetransfer-handler",
3232 "ktp-filetransfer-handler",
3333 ki18n("Telepathy File Transfer Handler"),
3434 KTP_FILETRANSFER_HANDLER_VERSION,
3535 ki18n("Handles your Telepathy file transfers"),
36 KAboutData::License_GPL_V2,
36 K4AboutData::License_GPL_V2,
3737 ki18n("Copyright (C) 2010, 2011, 2012 Daniele E. Domenichelli <daniele.domenichelli@gmail.com>"));
3838 aboutData.addAuthor(ki18n("Daniele E. Domenichelli"),
3939 ki18n("Developer"),
5656 aboutData.setHomepage("http://community.kde.org/KTp");
5757
5858 KCmdLineArgs::init(argc, argv, &aboutData);
59 KTp::TelepathyHandlerApplication app;
59 KTp::TelepathyHandlerApplication app(argc, argv);
6060
6161 Tp::AccountFactoryPtr accountFactory = Tp::AccountFactory::create(QDBusConnection::sessionBus());
6262
135135 q->emitResult();
136136 }
137137
138 #include "telepathy-base-job.moc"
138 #include "moc_telepathy-base-job.cpp"