Codebase list ktp-filetransfer-handler / 4542634
Imported Upstream version 15.12.3 Automatic packaging 8 years ago
25 changed file(s) with 2736 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 *.directory
1 *~
2 .*.sw[p,o]
3 /build
4 tags
5 .swp.*
6 .kdev4/
7 *.kdev4
0 REVIEWBOARD_URL = 'https://git.reviewboard.kde.org'
1 REPOSITORY = 'git://anongit.kde.org/ktp-filetransfer-handler'
0 Daniele E. Domenichelli (drdanz) <daniele.domenichelli@gmail.com>
1
2 Contributors:
3 George Kiagiadakis (gkiagia) <george.kiagiadakis@collabora.com>
4 David Edmundson (d_ed) <kde@davidedmundson.co.uk>
5 Dario Freddi (drf__) <dario.freddi@collabora.com>
6 Dominik Cermak (xerdomii) <d.cermak@arcor.de>
7 Alin M Elena (alin) <alinm.elena@gmail.com>
8 Martin Klapetek (mck182) <martin.klapetek@gmail.com>
9 Andrea Scarpino (ascarpino) <andrea@archlinux.org>
10 Dan Vrátil (dvratil) <dvratil@redhat.com>
0 project (ktp-filetransfer-handler)
1
2 cmake_minimum_required(VERSION 2.8.12)
3
4 # KDE Application Version, managed by release script
5 set(KDE_APPLICATIONS_VERSION_MAJOR "15")
6 set(KDE_APPLICATIONS_VERSION_MINOR "12")
7 set(KDE_APPLICATIONS_VERSION_MICRO "3")
8 set(KTP_FILETRANSFER_HANDLER_VERSION "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATIONS_VERSION_MINOR}.${KDE_APPLICATIONS_VERSION_MICRO}")
9
10 find_package(ECM 1.3.0 REQUIRED NO_MODULE)
11 set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_MODULE_PATH})
12
13 find_package (KF5 REQUIRED COMPONENTS CoreAddons I18n KIO Config)
14 find_package (Qt5 REQUIRED COMPONENTS Core DBus Widgets)
15 find_package (KTp REQUIRED)
16
17 include(KDEInstallDirs)
18 include(KDECMakeSettings)
19 include(KDECompilerSettings)
20 include(ECMSetupVersion)
21 include(FeatureSummary)
22
23 add_subdirectory(src)
24
25 feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
0 GNU GENERAL PUBLIC LICENSE
1 Version 2, June 1991
2
3 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
4 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
5 Everyone is permitted to copy and distribute verbatim copies
6 of this license document, but changing it is not allowed.
7
8 Preamble
9
10 The licenses for most software are designed to take away your
11 freedom to share and change it. By contrast, the GNU General Public
12 License is intended to guarantee your freedom to share and change free
13 software--to make sure the software is free for all its users. This
14 General Public License applies to most of the Free Software
15 Foundation's software and to any other program whose authors commit to
16 using it. (Some other Free Software Foundation software is covered by
17 the GNU Library General Public License instead.) You can apply it to
18 your programs, too.
19
20 When we speak of free software, we are referring to freedom, not
21 price. Our General Public Licenses are designed to make sure that you
22 have the freedom to distribute copies of free software (and charge for
23 this service if you wish), that you receive source code or can get it
24 if you want it, that you can change the software or use pieces of it
25 in new free programs; and that you know you can do these things.
26
27 To protect your rights, we need to make restrictions that forbid
28 anyone to deny you these rights or to ask you to surrender the rights.
29 These restrictions translate to certain responsibilities for you if you
30 distribute copies of the software, or if you modify it.
31
32 For example, if you distribute copies of such a program, whether
33 gratis or for a fee, you must give the recipients all the rights that
34 you have. You must make sure that they, too, receive or can get the
35 source code. And you must show them these terms so they know their
36 rights.
37
38 We protect your rights with two steps: (1) copyright the software, and
39 (2) offer you this license which gives you legal permission to copy,
40 distribute and/or modify the software.
41
42 Also, for each author's protection and ours, we want to make certain
43 that everyone understands that there is no warranty for this free
44 software. If the software is modified by someone else and passed on, we
45 want its recipients to know that what they have is not the original, so
46 that any problems introduced by others will not reflect on the original
47 authors' reputations.
48
49 Finally, any free program is threatened constantly by software
50 patents. We wish to avoid the danger that redistributors of a free
51 program will individually obtain patent licenses, in effect making the
52 program proprietary. To prevent this, we have made it clear that any
53 patent must be licensed for everyone's free use or not licensed at all.
54
55 The precise terms and conditions for copying, distribution and
56 modification follow.
57
58 GNU GENERAL PUBLIC LICENSE
59 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
60
61 0. This License applies to any program or other work which contains
62 a notice placed by the copyright holder saying it may be distributed
63 under the terms of this General Public License. The "Program", below,
64 refers to any such program or work, and a "work based on the Program"
65 means either the Program or any derivative work under copyright law:
66 that is to say, a work containing the Program or a portion of it,
67 either verbatim or with modifications and/or translated into another
68 language. (Hereinafter, translation is included without limitation in
69 the term "modification".) Each licensee is addressed as "you".
70
71 Activities other than copying, distribution and modification are not
72 covered by this License; they are outside its scope. The act of
73 running the Program is not restricted, and the output from the Program
74 is covered only if its contents constitute a work based on the
75 Program (independent of having been made by running the Program).
76 Whether that is true depends on what the Program does.
77
78 1. You may copy and distribute verbatim copies of the Program's
79 source code as you receive it, in any medium, provided that you
80 conspicuously and appropriately publish on each copy an appropriate
81 copyright notice and disclaimer of warranty; keep intact all the
82 notices that refer to this License and to the absence of any warranty;
83 and give any other recipients of the Program a copy of this License
84 along with the Program.
85
86 You may charge a fee for the physical act of transferring a copy, and
87 you may at your option offer warranty protection in exchange for a fee.
88
89 2. You may modify your copy or copies of the Program or any portion
90 of it, thus forming a work based on the Program, and copy and
91 distribute such modifications or work under the terms of Section 1
92 above, provided that you also meet all of these conditions:
93
94 a) You must cause the modified files to carry prominent notices
95 stating that you changed the files and the date of any change.
96
97 b) You must cause any work that you distribute or publish, that in
98 whole or in part contains or is derived from the Program or any
99 part thereof, to be licensed as a whole at no charge to all third
100 parties under the terms of this License.
101
102 c) If the modified program normally reads commands interactively
103 when run, you must cause it, when started running for such
104 interactive use in the most ordinary way, to print or display an
105 announcement including an appropriate copyright notice and a
106 notice that there is no warranty (or else, saying that you provide
107 a warranty) and that users may redistribute the program under
108 these conditions, and telling the user how to view a copy of this
109 License. (Exception: if the Program itself is interactive but
110 does not normally print such an announcement, your work based on
111 the Program is not required to print an announcement.)
112
113 These requirements apply to the modified work as a whole. If
114 identifiable sections of that work are not derived from the Program,
115 and can be reasonably considered independent and separate works in
116 themselves, then this License, and its terms, do not apply to those
117 sections when you distribute them as separate works. But when you
118 distribute the same sections as part of a whole which is a work based
119 on the Program, the distribution of the whole must be on the terms of
120 this License, whose permissions for other licensees extend to the
121 entire whole, and thus to each and every part regardless of who wrote it.
122
123 Thus, it is not the intent of this section to claim rights or contest
124 your rights to work written entirely by you; rather, the intent is to
125 exercise the right to control the distribution of derivative or
126 collective works based on the Program.
127
128 In addition, mere aggregation of another work not based on the Program
129 with the Program (or with a work based on the Program) on a volume of
130 a storage or distribution medium does not bring the other work under
131 the scope of this License.
132
133 3. You may copy and distribute the Program (or a work based on it,
134 under Section 2) in object code or executable form under the terms of
135 Sections 1 and 2 above provided that you also do one of the following:
136
137 a) Accompany it with the complete corresponding machine-readable
138 source code, which must be distributed under the terms of Sections
139 1 and 2 above on a medium customarily used for software interchange; or,
140
141 b) Accompany it with a written offer, valid for at least three
142 years, to give any third party, for a charge no more than your
143 cost of physically performing source distribution, a complete
144 machine-readable copy of the corresponding source code, to be
145 distributed under the terms of Sections 1 and 2 above on a medium
146 customarily used for software interchange; or,
147
148 c) Accompany it with the information you received as to the offer
149 to distribute corresponding source code. (This alternative is
150 allowed only for noncommercial distribution and only if you
151 received the program in object code or executable form with such
152 an offer, in accord with Subsection b above.)
153
154 The source code for a work means the preferred form of the work for
155 making modifications to it. For an executable work, complete source
156 code means all the source code for all modules it contains, plus any
157 associated interface definition files, plus the scripts used to
158 control compilation and installation of the executable. However, as a
159 special exception, the source code distributed need not include
160 anything that is normally distributed (in either source or binary
161 form) with the major components (compiler, kernel, and so on) of the
162 operating system on which the executable runs, unless that component
163 itself accompanies the executable.
164
165 If distribution of executable or object code is made by offering
166 access to copy from a designated place, then offering equivalent
167 access to copy the source code from the same place counts as
168 distribution of the source code, even though third parties are not
169 compelled to copy the source along with the object code.
170
171 4. You may not copy, modify, sublicense, or distribute the Program
172 except as expressly provided under this License. Any attempt
173 otherwise to copy, modify, sublicense or distribute the Program is
174 void, and will automatically terminate your rights under this License.
175 However, parties who have received copies, or rights, from you under
176 this License will not have their licenses terminated so long as such
177 parties remain in full compliance.
178
179 5. You are not required to accept this License, since you have not
180 signed it. However, nothing else grants you permission to modify or
181 distribute the Program or its derivative works. These actions are
182 prohibited by law if you do not accept this License. Therefore, by
183 modifying or distributing the Program (or any work based on the
184 Program), you indicate your acceptance of this License to do so, and
185 all its terms and conditions for copying, distributing or modifying
186 the Program or works based on it.
187
188 6. Each time you redistribute the Program (or any work based on the
189 Program), the recipient automatically receives a license from the
190 original licensor to copy, distribute or modify the Program subject to
191 these terms and conditions. You may not impose any further
192 restrictions on the recipients' exercise of the rights granted herein.
193 You are not responsible for enforcing compliance by third parties to
194 this License.
195
196 7. If, as a consequence of a court judgment or allegation of patent
197 infringement or for any other reason (not limited to patent issues),
198 conditions are imposed on you (whether by court order, agreement or
199 otherwise) that contradict the conditions of this License, they do not
200 excuse you from the conditions of this License. If you cannot
201 distribute so as to satisfy simultaneously your obligations under this
202 License and any other pertinent obligations, then as a consequence you
203 may not distribute the Program at all. For example, if a patent
204 license would not permit royalty-free redistribution of the Program by
205 all those who receive copies directly or indirectly through you, then
206 the only way you could satisfy both it and this License would be to
207 refrain entirely from distribution of the Program.
208
209 If any portion of this section is held invalid or unenforceable under
210 any particular circumstance, the balance of the section is intended to
211 apply and the section as a whole is intended to apply in other
212 circumstances.
213
214 It is not the purpose of this section to induce you to infringe any
215 patents or other property right claims or to contest validity of any
216 such claims; this section has the sole purpose of protecting the
217 integrity of the free software distribution system, which is
218 implemented by public license practices. Many people have made
219 generous contributions to the wide range of software distributed
220 through that system in reliance on consistent application of that
221 system; it is up to the author/donor to decide if he or she is willing
222 to distribute software through any other system and a licensee cannot
223 impose that choice.
224
225 This section is intended to make thoroughly clear what is believed to
226 be a consequence of the rest of this License.
227
228 8. If the distribution and/or use of the Program is restricted in
229 certain countries either by patents or by copyrighted interfaces, the
230 original copyright holder who places the Program under this License
231 may add an explicit geographical distribution limitation excluding
232 those countries, so that distribution is permitted only in or among
233 countries not thus excluded. In such case, this License incorporates
234 the limitation as if written in the body of this License.
235
236 9. The Free Software Foundation may publish revised and/or new versions
237 of the General Public License from time to time. Such new versions will
238 be similar in spirit to the present version, but may differ in detail to
239 address new problems or concerns.
240
241 Each version is given a distinguishing version number. If the Program
242 specifies a version number of this License which applies to it and "any
243 later version", you have the option of following the terms and conditions
244 either of that version or of any later version published by the Free
245 Software Foundation. If the Program does not specify a version number of
246 this License, you may choose any version ever published by the Free Software
247 Foundation.
248
249 10. If you wish to incorporate parts of the Program into other free
250 programs whose distribution conditions are different, write to the author
251 to ask for permission. For software which is copyrighted by the Free
252 Software Foundation, write to the Free Software Foundation; we sometimes
253 make exceptions for this. Our decision will be guided by the two goals
254 of preserving the free status of all derivatives of our free software and
255 of promoting the sharing and reuse of software generally.
256
257 NO WARRANTY
258
259 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
260 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
261 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
262 PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
263 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
264 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
265 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
266 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
267 REPAIR OR CORRECTION.
268
269 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
270 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
271 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
272 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
273 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
274 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
275 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
276 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
277 POSSIBILITY OF SUCH DAMAGES.
278
279 END OF TERMS AND CONDITIONS
280
281
282 How to Apply These Terms to Your New Programs
283
284 If you develop a new program, and you want it to be of the greatest
285 possible use to the public, the best way to achieve this is to make it
286 free software which everyone can redistribute and change under these terms.
287
288 To do so, attach the following notices to the program. It is safest
289 to attach them to the start of each source file to most effectively
290 convey the exclusion of warranty; and each file should have at least
291 the "copyright" line and a pointer to where the full notice is found.
292
293 <one line to give the program's name and a brief idea of what it does.>
294 Copyright (C) 19yy <name of author>
295
296 This program is free software; you can redistribute it and/or modify
297 it under the terms of the GNU General Public License as published by
298 the Free Software Foundation; either version 2 of the License, or
299 (at your option) any later version.
300
301 This program is distributed in the hope that it will be useful,
302 but WITHOUT ANY WARRANTY; without even the implied warranty of
303 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 GNU General Public License for more details.
305
306 You should have received a copy of the GNU General Public License
307 along with this program; if not, write to the Free Software
308 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
309
310
311 Also add information on how to contact you by electronic and paper mail.
312
313 If the program is interactive, make it output a short notice like this
314 when it starts in an interactive mode:
315
316 Gnomovision version 69, Copyright (C) 19yy name of author
317 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
318 This is free software, and you are welcome to redistribute it
319 under certain conditions; type `show c' for details.
320
321 The hypothetical commands `show w' and `show c' should show the appropriate
322 parts of the General Public License. Of course, the commands you use may
323 be called something other than `show w' and `show c'; they could even be
324 mouse-clicks or menu items--whatever suits your program.
325
326 You should also get your employer (if you work as a programmer) or your
327 school, if any, to sign a "copyright disclaimer" for the program, if
328 necessary. Here is a sample; alter the names:
329
330 Yoyodyne, Inc., hereby disclaims all copyright interest in the program
331 `Gnomovision' (which makes passes at compilers) written by James Hacker.
332
333 <signature of Ty Coon>, 1 April 1989
334 Ty Coon, President of Vice
335
336 This General Public License does not permit incorporating your program into
337 proprietary programs. If your program is a subroutine library, you may
338 consider it more useful to permit linking proprietary applications with the
339 library. If this is what you want to do, use the GNU Library General
340 Public License instead of this License.
341
342
343 ================================================================================
344
345
346 GNU LESSER GENERAL PUBLIC LICENSE
347 Version 2.1, February 1999
348
349 Copyright (C) 1991, 1999 Free Software Foundation, Inc.
350 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
351 Everyone is permitted to copy and distribute verbatim copies
352 of this license document, but changing it is not allowed.
353
354 [This is the first released version of the Lesser GPL. It also counts
355 as the successor of the GNU Library Public License, version 2, hence
356 the version number 2.1.]
357
358 Preamble
359
360 The licenses for most software are designed to take away your
361 freedom to share and change it. By contrast, the GNU General Public
362 Licenses are intended to guarantee your freedom to share and change
363 free software--to make sure the software is free for all its users.
364
365 This license, the Lesser General Public License, applies to some
366 specially designated software packages--typically libraries--of the
367 Free Software Foundation and other authors who decide to use it. You
368 can use it too, but we suggest you first think carefully about whether
369 this license or the ordinary General Public License is the better
370 strategy to use in any particular case, based on the explanations
371 below.
372
373 When we speak of free software, we are referring to freedom of use,
374 not price. Our General Public Licenses are designed to make sure that
375 you have the freedom to distribute copies of free software (and charge
376 for this service if you wish); that you receive source code or can get
377 it if you want it; that you can change the software and use pieces of
378 it in new free programs; and that you are informed that you can do
379 these things.
380
381 To protect your rights, we need to make restrictions that forbid
382 distributors to deny you these rights or to ask you to surrender these
383 rights. These restrictions translate to certain responsibilities for
384 you if you distribute copies of the library or if you modify it.
385
386 For example, if you distribute copies of the library, whether gratis
387 or for a fee, you must give the recipients all the rights that we gave
388 you. You must make sure that they, too, receive or can get the source
389 code. If you link other code with the library, you must provide
390 complete object files to the recipients, so that they can relink them
391 with the library after making changes to the library and recompiling
392 it. And you must show them these terms so they know their rights.
393
394 We protect your rights with a two-step method: (1) we copyright the
395 library, and (2) we offer you this license, which gives you legal
396 permission to copy, distribute and/or modify the library.
397
398 To protect each distributor, we want to make it very clear that
399 there is no warranty for the free library. Also, if the library is
400 modified by someone else and passed on, the recipients should know
401 that what they have is not the original version, so that the original
402 author's reputation will not be affected by problems that might be
403 introduced by others.
404
405 Finally, software patents pose a constant threat to the existence of
406 any free program. We wish to make sure that a company cannot
407 effectively restrict the users of a free program by obtaining a
408 restrictive license from a patent holder. Therefore, we insist that
409 any patent license obtained for a version of the library must be
410 consistent with the full freedom of use specified in this license.
411
412 Most GNU software, including some libraries, is covered by the
413 ordinary GNU General Public License. This license, the GNU Lesser
414 General Public License, applies to certain designated libraries, and
415 is quite different from the ordinary General Public License. We use
416 this license for certain libraries in order to permit linking those
417 libraries into non-free programs.
418
419 When a program is linked with a library, whether statically or using
420 a shared library, the combination of the two is legally speaking a
421 combined work, a derivative of the original library. The ordinary
422 General Public License therefore permits such linking only if the
423 entire combination fits its criteria of freedom. The Lesser General
424 Public License permits more lax criteria for linking other code with
425 the library.
426
427 We call this license the "Lesser" General Public License because it
428 does Less to protect the user's freedom than the ordinary General
429 Public License. It also provides other free software developers Less
430 of an advantage over competing non-free programs. These disadvantages
431 are the reason we use the ordinary General Public License for many
432 libraries. However, the Lesser license provides advantages in certain
433 special circumstances.
434
435 For example, on rare occasions, there may be a special need to
436 encourage the widest possible use of a certain library, so that it
437 becomes a de-facto standard. To achieve this, non-free programs must
438 be allowed to use the library. A more frequent case is that a free
439 library does the same job as widely used non-free libraries. In this
440 case, there is little to gain by limiting the free library to free
441 software only, so we use the Lesser General Public License.
442
443 In other cases, permission to use a particular library in non-free
444 programs enables a greater number of people to use a large body of
445 free software. For example, permission to use the GNU C Library in
446 non-free programs enables many more people to use the whole GNU
447 operating system, as well as its variant, the GNU/Linux operating
448 system.
449
450 Although the Lesser General Public License is Less protective of the
451 users' freedom, it does ensure that the user of a program that is
452 linked with the Library has the freedom and the wherewithal to run
453 that program using a modified version of the Library.
454
455 The precise terms and conditions for copying, distribution and
456 modification follow. Pay close attention to the difference between a
457 "work based on the library" and a "work that uses the library". The
458 former contains code derived from the library, whereas the latter must
459 be combined with the library in order to run.
460
461 GNU LESSER GENERAL PUBLIC LICENSE
462 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
463
464 0. This License Agreement applies to any software library or other
465 program which contains a notice placed by the copyright holder or
466 other authorized party saying it may be distributed under the terms of
467 this Lesser General Public License (also called "this License").
468 Each licensee is addressed as "you".
469
470 A "library" means a collection of software functions and/or data
471 prepared so as to be conveniently linked with application programs
472 (which use some of those functions and data) to form executables.
473
474 The "Library", below, refers to any such software library or work
475 which has been distributed under these terms. A "work based on the
476 Library" means either the Library or any derivative work under
477 copyright law: that is to say, a work containing the Library or a
478 portion of it, either verbatim or with modifications and/or translated
479 straightforwardly into another language. (Hereinafter, translation is
480 included without limitation in the term "modification".)
481
482 "Source code" for a work means the preferred form of the work for
483 making modifications to it. For a library, complete source code means
484 all the source code for all modules it contains, plus any associated
485 interface definition files, plus the scripts used to control
486 compilation and installation of the library.
487
488 Activities other than copying, distribution and modification are not
489 covered by this License; they are outside its scope. The act of
490 running a program using the Library is not restricted, and output from
491 such a program is covered only if its contents constitute a work based
492 on the Library (independent of the use of the Library in a tool for
493 writing it). Whether that is true depends on what the Library does
494 and what the program that uses the Library does.
495
496 1. You may copy and distribute verbatim copies of the Library's
497 complete source code as you receive it, in any medium, provided that
498 you conspicuously and appropriately publish on each copy an
499 appropriate copyright notice and disclaimer of warranty; keep intact
500 all the notices that refer to this License and to the absence of any
501 warranty; and distribute a copy of this License along with the
502 Library.
503
504 You may charge a fee for the physical act of transferring a copy,
505 and you may at your option offer warranty protection in exchange for a
506 fee.
507
508 2. You may modify your copy or copies of the Library or any portion
509 of it, thus forming a work based on the Library, and copy and
510 distribute such modifications or work under the terms of Section 1
511 above, provided that you also meet all of these conditions:
512
513 a) The modified work must itself be a software library.
514
515 b) You must cause the files modified to carry prominent notices
516 stating that you changed the files and the date of any change.
517
518 c) You must cause the whole of the work to be licensed at no
519 charge to all third parties under the terms of this License.
520
521 d) If a facility in the modified Library refers to a function or a
522 table of data to be supplied by an application program that uses
523 the facility, other than as an argument passed when the facility
524 is invoked, then you must make a good faith effort to ensure that,
525 in the event an application does not supply such function or
526 table, the facility still operates, and performs whatever part of
527 its purpose remains meaningful.
528
529 (For example, a function in a library to compute square roots has
530 a purpose that is entirely well-defined independent of the
531 application. Therefore, Subsection 2d requires that any
532 application-supplied function or table used by this function must
533 be optional: if the application does not supply it, the square
534 root function must still compute square roots.)
535
536 These requirements apply to the modified work as a whole. If
537 identifiable sections of that work are not derived from the Library,
538 and can be reasonably considered independent and separate works in
539 themselves, then this License, and its terms, do not apply to those
540 sections when you distribute them as separate works. But when you
541 distribute the same sections as part of a whole which is a work based
542 on the Library, the distribution of the whole must be on the terms of
543 this License, whose permissions for other licensees extend to the
544 entire whole, and thus to each and every part regardless of who wrote
545 it.
546
547 Thus, it is not the intent of this section to claim rights or contest
548 your rights to work written entirely by you; rather, the intent is to
549 exercise the right to control the distribution of derivative or
550 collective works based on the Library.
551
552 In addition, mere aggregation of another work not based on the Library
553 with the Library (or with a work based on the Library) on a volume of
554 a storage or distribution medium does not bring the other work under
555 the scope of this License.
556
557 3. You may opt to apply the terms of the ordinary GNU General Public
558 License instead of this License to a given copy of the Library. To do
559 this, you must alter all the notices that refer to this License, so
560 that they refer to the ordinary GNU General Public License, version 2,
561 instead of to this License. (If a newer version than version 2 of the
562 ordinary GNU General Public License has appeared, then you can specify
563 that version instead if you wish.) Do not make any other change in
564 these notices.
565
566 Once this change is made in a given copy, it is irreversible for
567 that copy, so the ordinary GNU General Public License applies to all
568 subsequent copies and derivative works made from that copy.
569
570 This option is useful when you wish to copy part of the code of
571 the Library into a program that is not a library.
572
573 4. You may copy and distribute the Library (or a portion or
574 derivative of it, under Section 2) in object code or executable form
575 under the terms of Sections 1 and 2 above provided that you accompany
576 it with the complete corresponding machine-readable source code, which
577 must be distributed under the terms of Sections 1 and 2 above on a
578 medium customarily used for software interchange.
579
580 If distribution of object code is made by offering access to copy
581 from a designated place, then offering equivalent access to copy the
582 source code from the same place satisfies the requirement to
583 distribute the source code, even though third parties are not
584 compelled to copy the source along with the object code.
585
586 5. A program that contains no derivative of any portion of the
587 Library, but is designed to work with the Library by being compiled or
588 linked with it, is called a "work that uses the Library". Such a
589 work, in isolation, is not a derivative work of the Library, and
590 therefore falls outside the scope of this License.
591
592 However, linking a "work that uses the Library" with the Library
593 creates an executable that is a derivative of the Library (because it
594 contains portions of the Library), rather than a "work that uses the
595 library". The executable is therefore covered by this License.
596 Section 6 states terms for distribution of such executables.
597
598 When a "work that uses the Library" uses material from a header file
599 that is part of the Library, the object code for the work may be a
600 derivative work of the Library even though the source code is not.
601 Whether this is true is especially significant if the work can be
602 linked without the Library, or if the work is itself a library. The
603 threshold for this to be true is not precisely defined by law.
604
605 If such an object file uses only numerical parameters, data
606 structure layouts and accessors, and small macros and small inline
607 functions (ten lines or less in length), then the use of the object
608 file is unrestricted, regardless of whether it is legally a derivative
609 work. (Executables containing this object code plus portions of the
610 Library will still fall under Section 6.)
611
612 Otherwise, if the work is a derivative of the Library, you may
613 distribute the object code for the work under the terms of Section 6.
614 Any executables containing that work also fall under Section 6,
615 whether or not they are linked directly with the Library itself.
616
617 6. As an exception to the Sections above, you may also combine or
618 link a "work that uses the Library" with the Library to produce a
619 work containing portions of the Library, and distribute that work
620 under terms of your choice, provided that the terms permit
621 modification of the work for the customer's own use and reverse
622 engineering for debugging such modifications.
623
624 You must give prominent notice with each copy of the work that the
625 Library is used in it and that the Library and its use are covered by
626 this License. You must supply a copy of this License. If the work
627 during execution displays copyright notices, you must include the
628 copyright notice for the Library among them, as well as a reference
629 directing the user to the copy of this License. Also, you must do one
630 of these things:
631
632 a) Accompany the work with the complete corresponding
633 machine-readable source code for the Library including whatever
634 changes were used in the work (which must be distributed under
635 Sections 1 and 2 above); and, if the work is an executable linked
636 with the Library, with the complete machine-readable "work that
637 uses the Library", as object code and/or source code, so that the
638 user can modify the Library and then relink to produce a modified
639 executable containing the modified Library. (It is understood
640 that the user who changes the contents of definitions files in the
641 Library will not necessarily be able to recompile the application
642 to use the modified definitions.)
643
644 b) Use a suitable shared library mechanism for linking with the
645 Library. A suitable mechanism is one that (1) uses at run time a
646 copy of the library already present on the user's computer system,
647 rather than copying library functions into the executable, and (2)
648 will operate properly with a modified version of the library, if
649 the user installs one, as long as the modified version is
650 interface-compatible with the version that the work was made with.
651
652 c) Accompany the work with a written offer, valid for at least
653 three years, to give the same user the materials specified in
654 Subsection 6a, above, for a charge no more than the cost of
655 performing this distribution.
656
657 d) If distribution of the work is made by offering access to copy
658 from a designated place, offer equivalent access to copy the above
659 specified materials from the same place.
660
661 e) Verify that the user has already received a copy of these
662 materials or that you have already sent this user a copy.
663
664 For an executable, the required form of the "work that uses the
665 Library" must include any data and utility programs needed for
666 reproducing the executable from it. However, as a special exception,
667 the materials to be distributed need not include anything that is
668 normally distributed (in either source or binary form) with the major
669 components (compiler, kernel, and so on) of the operating system on
670 which the executable runs, unless that component itself accompanies
671 the executable.
672
673 It may happen that this requirement contradicts the license
674 restrictions of other proprietary libraries that do not normally
675 accompany the operating system. Such a contradiction means you cannot
676 use both them and the Library together in an executable that you
677 distribute.
678
679 7. You may place library facilities that are a work based on the
680 Library side-by-side in a single library together with other library
681 facilities not covered by this License, and distribute such a combined
682 library, provided that the separate distribution of the work based on
683 the Library and of the other library facilities is otherwise
684 permitted, and provided that you do these two things:
685
686 a) Accompany the combined library with a copy of the same work
687 based on the Library, uncombined with any other library
688 facilities. This must be distributed under the terms of the
689 Sections above.
690
691 b) Give prominent notice with the combined library of the fact
692 that part of it is a work based on the Library, and explaining
693 where to find the accompanying uncombined form of the same work.
694
695 8. You may not copy, modify, sublicense, link with, or distribute
696 the Library except as expressly provided under this License. Any
697 attempt otherwise to copy, modify, sublicense, link with, or
698 distribute the Library is void, and will automatically terminate your
699 rights under this License. However, parties who have received copies,
700 or rights, from you under this License will not have their licenses
701 terminated so long as such parties remain in full compliance.
702
703 9. You are not required to accept this License, since you have not
704 signed it. However, nothing else grants you permission to modify or
705 distribute the Library or its derivative works. These actions are
706 prohibited by law if you do not accept this License. Therefore, by
707 modifying or distributing the Library (or any work based on the
708 Library), you indicate your acceptance of this License to do so, and
709 all its terms and conditions for copying, distributing or modifying
710 the Library or works based on it.
711
712 10. Each time you redistribute the Library (or any work based on the
713 Library), the recipient automatically receives a license from the
714 original licensor to copy, distribute, link with or modify the Library
715 subject to these terms and conditions. You may not impose any further
716 restrictions on the recipients' exercise of the rights granted herein.
717 You are not responsible for enforcing compliance by third parties with
718 this License.
719
720 11. If, as a consequence of a court judgment or allegation of patent
721 infringement or for any other reason (not limited to patent issues),
722 conditions are imposed on you (whether by court order, agreement or
723 otherwise) that contradict the conditions of this License, they do not
724 excuse you from the conditions of this License. If you cannot
725 distribute so as to satisfy simultaneously your obligations under this
726 License and any other pertinent obligations, then as a consequence you
727 may not distribute the Library at all. For example, if a patent
728 license would not permit royalty-free redistribution of the Library by
729 all those who receive copies directly or indirectly through you, then
730 the only way you could satisfy both it and this License would be to
731 refrain entirely from distribution of the Library.
732
733 If any portion of this section is held invalid or unenforceable under
734 any particular circumstance, the balance of the section is intended to
735 apply, and the section as a whole is intended to apply in other
736 circumstances.
737
738 It is not the purpose of this section to induce you to infringe any
739 patents or other property right claims or to contest validity of any
740 such claims; this section has the sole purpose of protecting the
741 integrity of the free software distribution system which is
742 implemented by public license practices. Many people have made
743 generous contributions to the wide range of software distributed
744 through that system in reliance on consistent application of that
745 system; it is up to the author/donor to decide if he or she is willing
746 to distribute software through any other system and a licensee cannot
747 impose that choice.
748
749 This section is intended to make thoroughly clear what is believed to
750 be a consequence of the rest of this License.
751
752 12. If the distribution and/or use of the Library is restricted in
753 certain countries either by patents or by copyrighted interfaces, the
754 original copyright holder who places the Library under this License
755 may add an explicit geographical distribution limitation excluding those
756 countries, so that distribution is permitted only in or among
757 countries not thus excluded. In such case, this License incorporates
758 the limitation as if written in the body of this License.
759
760 13. The Free Software Foundation may publish revised and/or new
761 versions of the Lesser General Public License from time to time.
762 Such new versions will be similar in spirit to the present version,
763 but may differ in detail to address new problems or concerns.
764
765 Each version is given a distinguishing version number. If the Library
766 specifies a version number of this License which applies to it and
767 "any later version", you have the option of following the terms and
768 conditions either of that version or of any later version published by
769 the Free Software Foundation. If the Library does not specify a
770 license version number, you may choose any version ever published by
771 the Free Software Foundation.
772
773 14. If you wish to incorporate parts of the Library into other free
774 programs whose distribution conditions are incompatible with these,
775 write to the author to ask for permission. For software which is
776 copyrighted by the Free Software Foundation, write to the Free
777 Software Foundation; we sometimes make exceptions for this. Our
778 decision will be guided by the two goals of preserving the free status
779 of all derivatives of our free software and of promoting the sharing
780 and reuse of software generally.
781
782 NO WARRANTY
783
784 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
785 WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
786 EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
787 OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
788 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
789 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
790 PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
791 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
792 THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
793
794 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
795 WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
796 AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
797 FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
798 CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
799 LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
800 RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
801 FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
802 SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
803 DAMAGES.
804
805 END OF TERMS AND CONDITIONS
806
807 How to Apply These Terms to Your New Libraries
808
809 If you develop a new library, and you want it to be of the greatest
810 possible use to the public, we recommend making it free software that
811 everyone can redistribute and change. You can do so by permitting
812 redistribution under these terms (or, alternatively, under the terms
813 of the ordinary General Public License).
814
815 To apply these terms, attach the following notices to the library.
816 It is safest to attach them to the start of each source file to most
817 effectively convey the exclusion of warranty; and each file should
818 have at least the "copyright" line and a pointer to where the full
819 notice is found.
820
821
822 <one line to give the library's name and a brief idea of what it does.>
823 Copyright (C) <year> <name of author>
824
825 This library is free software; you can redistribute it and/or
826 modify it under the terms of the GNU Lesser General Public
827 License as published by the Free Software Foundation; either
828 version 2.1 of the License, or (at your option) any later version.
829
830 This library is distributed in the hope that it will be useful,
831 but WITHOUT ANY WARRANTY; without even the implied warranty of
832 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
833 Lesser General Public License for more details.
834
835 You should have received a copy of the GNU Lesser General Public
836 License along with this library; if not, write to the Free Software
837 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
838
839 Also add information on how to contact you by electronic and paper mail.
840
841 You should also get your employer (if you work as a programmer) or
842 your school, if any, to sign a "copyright disclaimer" for the library,
843 if necessary. Here is a sample; alter the names:
844
845 Yoyodyne, Inc., hereby disclaims all copyright interest in the
846 library `Frob' (a library for tweaking knobs) written by James
847 Random Hacker.
848
849 <signature of Ty Coon>, 1 April 1990
850 Ty Coon, President of Vice
851
852 That's all there is to it!
853
854
0 #!bin/sh
1 $EXTRACTRC `find . -name \*.rc -o -name \*.ui -o -name \*.kcfg` >> rc.cpp
2 $XGETTEXT `find . -name \*.cc -o -name \*.cpp -o -name \*.h` -o $podir/ktp-filetransfer-handler.pot
3 rm -f rc.cpp
+137
-0
NEWS less more
0 kde-telepathy filetransfer-handler (UNRELEASED) 0.7.0
1 =====================================================
2
3 * Add 'Always Ask' option for filetransfer destination directory
4 (dvratil)
5
6 kde-telepathy filetransfer-handler (2013-08-07) 0.6.3
7 =====================================================
8
9 ---
10
11 kde-telepathy filetransfer-handler (2013-05-20) 0.6.2
12 =====================================================
13
14 ---
15
16 kde-telepathy filetransfer-handler (2012-08-25) 0.6.1
17 =====================================================
18
19 ---
20
21 kde-telepathy filetransfer-handler (2012-04-01) 0.6.0
22 =====================================================
23
24 * Update CMake policy (d_ed)
25
26 kde-telepathy filetransfer-handler (2013-02-17) 0.5.3
27 =====================================================
28
29 * Do not delete the old file when the sender cancel the transfer and you
30 are in the rename dialog (ascarpino)
31 * Be sure the part file exists (ascarpino)
32 * Fix call to non-existent signal (ascarpino)
33
34 kde-telepathy filetransfer-handler (2012-12-17) 0.5.2
35 =====================================================
36
37 * Cleanup cmake stuff (drdanz)
38 * Update homepage (drdanz)
39
40 kde-telepathy filetransfer-handler (2012-10-05) 0.5.1
41 =====================================================
42
43 ---
44
45 kde-telepathy filetransfer-handler (2012-08-25) 0.5.0
46 =====================================================
47
48 ---
49
50 kde-telepathy filetransfer-handler (2012-07-25) 0.4.1
51 =====================================================
52
53 * Do not translate string for MC (drdanz)
54 * Do not set context error if URI is not set for outgoing ft channels (drdanz)
55 * Use Tp::SharedPtr::qObjectCast instead of dynamicCast (drdanz)
56 * Return after context finishes with error (drdanz)
57 * Do not assert that channels.size() == 1 (drdanz)
58
59 kde-telepathy filetransfer-handler (2012-06-04) 0.4.0
60 =====================================================
61
62 * Bump TelepathyQt4 required version to 0.9.1 (drdanz)
63 * Fix error name (drdanz)
64 * Normalize signal/slot signatures (mck182)
65 * Set version in using CMake instead of hardcoding in main.cpp (drdanz)
66
67 kde-telepathy filetransfer-handler (2012-01-25) 0.3.0
68 =====================================================
69
70 * Port to new KTelepathy internal library (drf__)
71 * Port to TelepathyQt4 0.9 (drf__)
72 * Unregister jobs when killed (drdanz)
73 * Do not set error when user kills the jobs, set it on file transfer cancelled
74 instead (drdanz)
75 * Support resuming file transfer (drdanz)
76 * Non modal rename dialog (drdanz/xerdomii)
77 * Less unuseful asynchronous calls (drdanz)
78 * Update names according to the new scheme (alin)
79
80 kde-telepathy filetransfer-handler (2011-11-18) 0.2.0
81 =====================================================
82
83 * Do not exit if setUri fails (drdanz)
84 * Increment initial timeout time (drdanz/d_ed)
85 * Exit File Transfer Handler if DBus name is already taken (drdanz)
86 * Install DBus activated binary in libexec (drdanz)
87 * Use KTp::TelepathyHandlerApplication instead of KApplication (drdanz)
88 * Enable KDebug DBus interface for TelepathyHandlerApplication if debug is
89 enabled (drdanz)
90 * Make FileTransferJobs killable (drdanz)
91 * Show a progressbar for the file transferred (drdanz)
92 * Let the jobs register by themselves (drdanz)
93 * Add a description for the KJob (drdanz)
94 * Handle other states in incoming file transfer (drdanz)
95 * Don't use event loop for methods that don't need it (drdanz)
96 * Redirect Telepathy-Qt4 output to KDebug (drdanz)
97 * Bump TelepathyQt4 min version to 0.7.3 (drdanz)
98 * Use common submodule (drdanz)
99 * Rename DBus services, fix .client and .service files (drdanz)
100
101 kde-telepathy filetransfer-handler (2011-07-27) 0.1.0
102 ======================================================
103
104 * Update FindTelepathyQt4.cmake and search for Tp-Qt4 >= 0.7.1 (drdanz)
105 * Better error handling (drdanz)
106 * Don't exit when the last window is closed (drdanz)
107 * Use KUrl::isLocalFile() instead of comparing scheme (drdanz)
108 * Make ft-handler a KApplication instead of a KUniqueApplication (drdanz/d_ed)
109
110 kde-telepathy filetransfer-handler (2011-06-08) UNRELEASED
111 ===========================================================
112
113 * Add --debug and --persist command line options (drdanz)
114 * Exit after 2 seconds if no channels are received (drdanz)
115 * Show an overwrite/rename dialog on incoming file transfers if the file
116 already exists. (drdanz)
117 * Don't stop the jobs before the file transfer has actually finished (gkiagia)
118
119 kde-telepathy filetransfer-handler (2011-06-06) UNRELEASED
120 ===========================================================
121
122 First real commit
123
124 This is the KDE Telepathy file transfer handler
125
126 WARNING: At the moment it just works for incoming file transfers and will
127 overwrite any file in the $HOME/Download directory which has the same
128 name as the file that you are receiving, so please ensure that you
129 don't have any valuable file there.
130
131 You can modify the download directory by adding in your
132 .kde/share/config/ktelepathyrc file in the section [File Transfers] the
133 variable downloadDirectory
134
135 [File Transfers]
136 downloadDirectory=<download path>
0 This is the Telepathy-KDE file transfer handler
1
2 It basically does 2 thigs
3 * Send files to your contact
4 * Receive files from your contact
5
6 It doesn't set any filter on the mime type, therefore, it should catch all the
7 file transfer channels that aren't received by any other handler filtering
8 on mimetype.
9
10
11 To compile it you will need at least Telepathy-Qt4 >= 0.7.3 or the latest
12 git version.
13
14
15 You can modify the default download directory from telepathy-kded-module or by
16 adding in your .kde/share/config/ktelepathyrc file in the section
17 [File Transfers] the variable downloadDirectory
18
19 [File Transfers]
20 downloadDirectory=<download path>
0 General:
1 * Use Nepomuk describeResource and storeResource to send somehow an additional
2 trig or rdf file.
3 * Investigate if channels are closed channels when transfer ends/fails
4 * Save metadata about sender and receiver
5 * Send multiple files in a tarball and extract them on the other side
6 * Send single files compressed to save bandwidth and extract on the other side
7
8 Incoming file transfers
9 * Close window if file transfer is cancelled
10 * Ensure that when the file transfer fails or is cancelled the empty file is
11 deleted and the .part file is left
12
13 Outgoing file transfers
0 include_directories(${CMAKE_BINARY_DIR})
1
2 set(ktp_filetransfer_handler_SRCS
3 main.cpp
4 filetransfer-handler.cpp
5 telepathy-base-job.cpp
6 handle-incoming-file-transfer-channel-job.cpp
7 handle-outgoing-file-transfer-channel-job.cpp
8 ktp-fth-debug.cpp
9 )
10
11 configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
12
13 add_executable(ktp-filetransfer-handler ${ktp_filetransfer_handler_SRCS})
14
15 target_link_libraries(ktp-filetransfer-handler
16 KTp::CommonInternals
17 KF5::CoreAddons
18 KF5::I18n
19 KF5::KIOWidgets
20 KF5::ConfigCore
21 Qt5::Core
22 Qt5::DBus
23 Qt5::Widgets
24 )
25
26 configure_file(org.freedesktop.Telepathy.Client.KTp.FileTransferHandler.service.in
27 ${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.Telepathy.Client.KTp.FileTransferHandler.service)
28
29 install(TARGETS ktp-filetransfer-handler DESTINATION ${LIBEXEC_INSTALL_DIR})
30 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.Telepathy.Client.KTp.FileTransferHandler.service
31 DESTINATION ${DBUS_SERVICES_INSTALL_DIR})
32 install(FILES KTp.FileTransferHandler.client DESTINATION ${SHARE_INSTALL_PREFIX}/telepathy/clients/)
33
0 [org.freedesktop.Telepathy.Client]
1 Interfaces=org.freedesktop.Telepathy.Client.Handler
2
3 [org.freedesktop.Telepathy.Client.Handler.HandlerChannelFilter 0]
4 org.freedesktop.Telepathy.Channel.ChannelType s=org.freedesktop.Telepathy.Channel.Type.FileTransfer
5 org.freedesktop.Telepathy.Channel.TargetHandleType u=1
0 /*
1 * Copyright (C) 2010, 2011 Daniele E. Domenichelli <daniele.domenichelli@gmail.com>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 #include "filetransfer-handler.h"
18
19 #include "handle-incoming-file-transfer-channel-job.h"
20 #include "handle-outgoing-file-transfer-channel-job.h"
21 #include "ktp-fth-debug.h"
22
23 #include <KTp/telepathy-handler-application.h>
24
25 #include <TelepathyQt/ChannelClassSpecList>
26 #include <TelepathyQt/IncomingFileTransferChannel>
27 #include <TelepathyQt/OutgoingFileTransferChannel>
28
29 #include <KSharedConfig>
30 #include <KConfigGroup>
31 #include <KLocalizedString>
32 #include <KJob>
33
34 #include <QDebug>
35
36
37 FileTransferHandler::FileTransferHandler(QObject *parent)
38 : QObject(parent),
39 Tp::AbstractClientHandler(Tp::ChannelClassSpecList() << Tp::ChannelClassSpec::incomingFileTransfer()
40 << Tp::ChannelClassSpec::outgoingFileTransfer())
41 {
42 }
43
44 FileTransferHandler::~FileTransferHandler()
45 {
46 }
47
48 bool FileTransferHandler::bypassApproval() const
49 {
50 return false;
51 }
52
53 void FileTransferHandler::handleChannels(const Tp::MethodInvocationContextPtr<> &context,
54 const Tp::AccountPtr &account,
55 const Tp::ConnectionPtr &connection,
56 const QList<Tp::ChannelPtr> &channels,
57 const QList<Tp::ChannelRequestPtr> &requestsSatisfied,
58 const QDateTime &userActionTime,
59 const Tp::AbstractClientHandler::HandlerInfo &handlerInfo)
60 {
61 Q_UNUSED(account);
62 Q_UNUSED(connection);
63 Q_UNUSED(requestsSatisfied);
64 Q_UNUSED(userActionTime);
65 Q_UNUSED(handlerInfo);
66
67 Q_FOREACH(const Tp::ChannelPtr &channel, channels) {
68 if (KTp::TelepathyHandlerApplication::newJob() < 0) {
69 context->setFinishedWithError(QLatin1String("org.freedesktop.Telepathy.KTp.FileTransferHandler.Exiting"),
70 QLatin1String("File transfer handler is exiting. Cannot start job"));
71 return;
72 }
73
74 KJob* job = NULL;
75
76 if (!channel->isRequested()) {
77 Tp::IncomingFileTransferChannelPtr incomingFileTransferChannel = Tp::IncomingFileTransferChannelPtr::qObjectCast(channel);
78 Q_ASSERT(incomingFileTransferChannel);
79
80 qCDebug(KTP_FTH_MODULE) << incomingFileTransferChannel->immutableProperties();
81
82 KSharedConfigPtr config = KSharedConfig::openConfig(QLatin1String("ktelepathyrc"));
83 KConfigGroup filetransferConfig = config->group(QLatin1String("File Transfers"));
84
85 const bool alwaysAsk = filetransferConfig.readEntry(QLatin1String("alwaysAsk"), false);
86 QString downloadDirectory;
87 if (!alwaysAsk) {
88 downloadDirectory = filetransferConfig.readPathEntry(QLatin1String("downloadDirectory"),
89 QDir::homePath() + QLatin1String("/") + i18nc("This is the download directory in user's home", "Downloads"));
90 }
91 qCDebug(KTP_FTH_MODULE) << "Download directory:" << downloadDirectory << "\t Always Ask:" << alwaysAsk;
92 // TODO Check if directory exists
93
94 job = new HandleIncomingFileTransferChannelJob(incomingFileTransferChannel, downloadDirectory, alwaysAsk, this);
95 } else {
96 Tp::OutgoingFileTransferChannelPtr outgoingFileTransferChannel = Tp::OutgoingFileTransferChannelPtr::qObjectCast(channel);
97 Q_ASSERT(outgoingFileTransferChannel);
98
99 qCDebug(KTP_FTH_MODULE) << outgoingFileTransferChannel->immutableProperties();
100
101 if (outgoingFileTransferChannel->uri().isEmpty()) {
102 qCWarning(KTP_FTH_MODULE) << "Cannot handle outgoing file transfer without URI";
103 KTp::TelepathyHandlerApplication::jobFinished();
104 continue;
105 }
106
107 job = new HandleOutgoingFileTransferChannelJob(outgoingFileTransferChannel, this);
108 }
109
110 if (job) {
111 connect(job,
112 SIGNAL(infoMessage(KJob*, QString, QString)),
113 SLOT(onInfoMessage(KJob*, QString, QString)));
114 connect(job,
115 SIGNAL(result(KJob*)),
116 SLOT(handleResult(KJob*)));
117 job->start();
118 }
119 }
120
121 context->setFinished();
122 }
123
124 void FileTransferHandler::onInfoMessage(KJob* job, const QString &plain, const QString &rich)
125 {
126 Q_UNUSED(job);
127 Q_UNUSED(rich);
128 qCDebug(KTP_FTH_MODULE) << plain;
129 }
130
131 void FileTransferHandler::handleResult(KJob* job)
132 {
133 qCDebug(KTP_FTH_MODULE);
134 if (job->error()) {
135 qCWarning(KTP_FTH_MODULE) << job->errorString();
136 // TODO do something;
137 }
138
139 KTp::TelepathyHandlerApplication::jobFinished();
140 }
0 /*
1 * Copyright (C) 2010, 2011 Daniele E. Domenichelli <daniele.domenichelli@gmail.com>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 #ifndef TELEPATHY_KDE_FILETRANSFER_HANDLER_H
18 #define TELEPATHY_KDE_FILETRANSFER_HANDLER_H
19
20 #include <TelepathyQt/AbstractClientHandler>
21 #include <TelepathyQt/Types>
22
23 class KJob;
24 namespace Tp
25 {
26 class PendingOperation;
27 }
28
29 class FileTransferHandler : public QObject, public Tp::AbstractClientHandler
30 {
31 Q_OBJECT
32 Q_DISABLE_COPY(FileTransferHandler);
33
34 public:
35 explicit FileTransferHandler(QObject* parent = 0);
36 virtual ~FileTransferHandler();
37
38 virtual bool bypassApproval() const;
39 void handleChannels(const Tp::MethodInvocationContextPtr<> &context,
40 const Tp::AccountPtr &account,
41 const Tp::ConnectionPtr &connection,
42 const QList<Tp::ChannelPtr> &channels,
43 const QList<Tp::ChannelRequestPtr> &requestsSatisfied,
44 const QDateTime &userActionTime,
45 const Tp::AbstractClientHandler::HandlerInfo &handlerInfo);
46
47 private Q_SLOTS:
48 void onInfoMessage(KJob* job, const QString &plain, const QString &rich);
49 void handleResult(KJob* job);
50 };
51
52 #endif // TELEPATHY_KDE_FILETRANSFER_HANDLER_H
0 /*
1 * Copyright (C) 2010, 2011 Daniele E. Domenichelli <daniele.domenichelli@gmail.com>
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17
18
19 #include "handle-incoming-file-transfer-channel-job.h"
20 #include "telepathy-base-job_p.h"
21 #include "ktp-fth-debug.h"
22
23 #include <QTimer>
24 #include <QUrl>
25 #include <QPointer>
26 #include <QDebug>
27 #include <QFileDialog>
28
29 #include <KLocalizedString>
30 #include <kio/renamedialog.h>
31 #include <kio/global.h>
32 #include <kjobtrackerinterface.h>
33
34 #include <TelepathyQt/IncomingFileTransferChannel>
35 #include <TelepathyQt/PendingReady>
36 #include <TelepathyQt/PendingOperation>
37 #include <TelepathyQt/Contact>
38
39
40 class HandleIncomingFileTransferChannelJobPrivate : public KTp::TelepathyBaseJobPrivate
41 {
42 Q_DECLARE_PUBLIC(HandleIncomingFileTransferChannelJob)
43
44 public:
45 HandleIncomingFileTransferChannelJobPrivate();
46 virtual ~HandleIncomingFileTransferChannelJobPrivate();
47
48 Tp::IncomingFileTransferChannelPtr channel;
49 QString downloadDirectory;
50 bool askForDownloadDirectory;
51 QFile* file;
52 QUrl url, partUrl;
53 qulonglong offset;
54 bool isResuming;
55 QPointer<KIO::RenameDialog> renameDialog;
56
57 void init();
58 void start();
59 bool kill();
60 void checkFileExists();
61 void checkPartFile();
62 void receiveFile();
63
64 void __k__onRenameDialogFinished(int result);
65 void __k__onResumeDialogFinished(int result);
66 void __k__onSetUriOperationFinished(Tp::PendingOperation* op);
67 void __k__onInitialOffsetDefined(qulonglong offset);
68 void __k__onFileTransferChannelStateChanged(Tp::FileTransferState state, Tp::FileTransferStateChangeReason reason);
69 void __k__onFileTransferChannelTransferredBytesChanged(qulonglong count);
70 void __k__acceptFile();
71 void __k__onAcceptFileFinished(Tp::PendingOperation* op);
72 void __k__onCancelOperationFinished(Tp::PendingOperation* op);
73 void __k__onInvalidated();
74 };
75
76 HandleIncomingFileTransferChannelJob::HandleIncomingFileTransferChannelJob(Tp::IncomingFileTransferChannelPtr channel,
77 const QString downloadDirectory,
78 bool askForDownloadDirectory,
79 QObject* parent)
80 : TelepathyBaseJob(*new HandleIncomingFileTransferChannelJobPrivate(), parent)
81 {
82 qCDebug(KTP_FTH_MODULE);
83 Q_D(HandleIncomingFileTransferChannelJob);
84
85 d->channel = channel;
86 d->downloadDirectory = downloadDirectory;
87 d->askForDownloadDirectory = askForDownloadDirectory;
88 d->init();
89 }
90
91 HandleIncomingFileTransferChannelJob::~HandleIncomingFileTransferChannelJob()
92 {
93 qCDebug(KTP_FTH_MODULE);
94 KIO::getJobTracker()->unregisterJob(this);
95 }
96
97 void HandleIncomingFileTransferChannelJob::start()
98 {
99 qCDebug(KTP_FTH_MODULE);
100 Q_D(HandleIncomingFileTransferChannelJob);
101 d->start();
102 }
103
104 bool HandleIncomingFileTransferChannelJob::doKill()
105 {
106 qCDebug(KTP_FTH_MODULE) << "Incoming file transfer killed.";
107 Q_D(HandleIncomingFileTransferChannelJob);
108 return d->kill();
109 }
110
111 HandleIncomingFileTransferChannelJobPrivate::HandleIncomingFileTransferChannelJobPrivate()
112 : askForDownloadDirectory(true),
113 file(0),
114 offset(0),
115 isResuming(false)
116 {
117 qCDebug(KTP_FTH_MODULE);
118 }
119
120 HandleIncomingFileTransferChannelJobPrivate::~HandleIncomingFileTransferChannelJobPrivate()
121 {
122 qCDebug(KTP_FTH_MODULE);
123 }
124
125 void HandleIncomingFileTransferChannelJobPrivate::init()
126 {
127 qCDebug(KTP_FTH_MODULE);
128 Q_Q(HandleIncomingFileTransferChannelJob);
129
130 if (channel.isNull()) {
131 qCritical() << "Channel cannot be NULL";
132 q->setError(KTp::NullChannel);
133 q->setErrorText(i18n("Invalid channel"));
134 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
135 return;
136 }
137
138 Tp::Features features = Tp::Features() << Tp::FileTransferChannel::FeatureCore;
139 if (!channel->isReady(Tp::Features() << Tp::FileTransferChannel::FeatureCore)) {
140 qCritical() << "Channel must be ready with Tp::FileTransferChannel::FeatureCore";
141 q->setError(KTp::FeatureNotReady);
142 q->setErrorText(i18n("Channel is not ready"));
143 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
144 return;
145 }
146
147 q->setCapabilities(KJob::Killable);
148 q->setTotalAmount(KJob::Bytes, channel->size());
149 q->setProcessedAmountAndCalculateSpeed(0);
150
151 q->connect(channel.data(),
152 SIGNAL(invalidated(Tp::DBusProxy*,QString,QString)),
153 SLOT(__k__onInvalidated()));
154 q->connect(channel.data(),
155 SIGNAL(initialOffsetDefined(qulonglong)),
156 SLOT(__k__onInitialOffsetDefined(qulonglong)));
157 q->connect(channel.data(),
158 SIGNAL(stateChanged(Tp::FileTransferState,Tp::FileTransferStateChangeReason)),
159 SLOT(__k__onFileTransferChannelStateChanged(Tp::FileTransferState,Tp::FileTransferStateChangeReason)));
160 q->connect(channel.data(),
161 SIGNAL(transferredBytesChanged(qulonglong)),
162 SLOT(__k__onFileTransferChannelTransferredBytesChanged(qulonglong)));
163 }
164
165 void HandleIncomingFileTransferChannelJobPrivate::start()
166 {
167 qCDebug(KTP_FTH_MODULE);
168 Q_Q(HandleIncomingFileTransferChannelJob);
169
170 Q_ASSERT(!q->error());
171 if (q->error()) {
172 qCWarning(KTP_FTH_MODULE) << "Job was started in error state. Something wrong happened." << q->errorString();
173 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
174 return;
175 }
176
177 if (askForDownloadDirectory) {
178 url = QFileDialog::getSaveFileUrl(0, QString(), QUrl(QLatin1String("kfiledialog:///FileTransferLastDirectory/") + channel->fileName()));
179
180 partUrl.setPath(url.path() + QLatin1String(".part"));
181 partUrl.setScheme(QLatin1String("file"));
182
183 checkPartFile();
184 return;
185 }
186
187 checkFileExists();
188 }
189
190 void HandleIncomingFileTransferChannelJobPrivate::checkFileExists()
191 {
192 Q_Q(HandleIncomingFileTransferChannelJob);
193
194 url = downloadDirectory + QLatin1Char('/') + channel->fileName();
195 url.setScheme(QLatin1String("file"));
196
197 partUrl = url.path() + QLatin1String(".part");
198 partUrl.setScheme(QLatin1String("file"));
199
200 QFileInfo fileInfo(url.toLocalFile()); // TODO check if it is a dir?
201 if (fileInfo.exists()) {
202 renameDialog = new KIO::RenameDialog(0,
203 i18n("Incoming file exists"),
204 QUrl(), //TODO
205 url,
206 KIO::RenameDialog_Overwrite,
207 fileInfo.size(),
208 channel->size(),
209 fileInfo.created(),
210 QDateTime(),
211 fileInfo.lastModified(),
212 channel->lastModificationTime());
213
214 q->connect(q, SIGNAL(finished(KJob*)),
215 renameDialog.data(), SLOT(reject()));
216
217 q->connect(renameDialog.data(),
218 SIGNAL(finished(int)),
219 SLOT(__k__onRenameDialogFinished(int)));
220
221 renameDialog.data()->show();
222 return;
223 }
224
225 checkPartFile();
226 }
227
228 void HandleIncomingFileTransferChannelJobPrivate::__k__onRenameDialogFinished(int result)
229 {
230 qCDebug(KTP_FTH_MODULE);
231 Q_Q(HandleIncomingFileTransferChannelJob);
232
233 if (!renameDialog) {
234 qCWarning(KTP_FTH_MODULE) << "Rename dialog was deleted during event loop.";
235 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
236 return;
237 }
238
239 Q_ASSERT(renameDialog.data()->result() == result);
240
241 switch (result) {
242 case KIO::R_CANCEL:
243 // TODO Cancel file transfer and close channel
244 channel->cancel();
245 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
246 return;
247 case KIO::R_RENAME:
248 url = renameDialog.data()->newDestUrl();
249 break;
250 case KIO::R_OVERWRITE:
251 {
252 // Delete the old file if exists
253 QFile oldFile(url.toLocalFile(), 0);
254 if (oldFile.exists()) {
255 oldFile.remove();
256 }
257 }
258 break;
259 default:
260 qCWarning(KTP_FTH_MODULE) << "Unknown Error";
261 q->setError(KTp::KTpError);
262 q->setErrorText(i18n("Unknown Error"));
263 renameDialog.data()->deleteLater();
264 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
265 return;
266 }
267 renameDialog.data()->deleteLater();
268 renameDialog.clear();
269 checkPartFile();
270 }
271
272 void HandleIncomingFileTransferChannelJobPrivate::checkPartFile()
273 {
274 qCDebug(KTP_FTH_MODULE);
275 Q_Q(HandleIncomingFileTransferChannelJob);
276
277 QFileInfo fileInfo(partUrl.toLocalFile());
278 if (fileInfo.exists()) {
279 renameDialog = new KIO::RenameDialog(0,
280 i18n("Would you like to resume partial download?"),
281 QUrl(),
282 partUrl,
283 KIO::RenameDialog_Resume,
284 fileInfo.size(),
285 channel->size(),
286 fileInfo.created(),
287 QDateTime(),
288 fileInfo.lastModified(),
289 channel->lastModificationTime());
290
291 q->connect(q, SIGNAL(finished(KJob*)),
292 renameDialog.data(), SLOT(reject()));
293
294 q->connect(renameDialog.data(),
295 SIGNAL(finished(int)),
296 SLOT(__k__onResumeDialogFinished(int)));
297
298 renameDialog.data()->show();
299 return;
300 }
301 receiveFile();
302 }
303
304
305 void HandleIncomingFileTransferChannelJobPrivate::__k__onResumeDialogFinished(int result)
306 {
307 qCDebug(KTP_FTH_MODULE);
308 Q_Q(HandleIncomingFileTransferChannelJob);
309
310 if (!renameDialog) {
311 qCWarning(KTP_FTH_MODULE) << "Rename dialog was deleted during event loop.";
312 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
313 return;
314 }
315
316 Q_ASSERT(renameDialog.data()->result() == result);
317
318 switch (result) {
319 case KIO::R_RESUME:
320 {
321 QFileInfo fileInfo(partUrl.toLocalFile());
322 offset = fileInfo.size();
323 isResuming = true;
324 break;
325 }
326 case KIO::R_RENAME:
327 // If the user hits rename, we use the new name as the .part file
328 partUrl = renameDialog.data()->newDestUrl();
329 break;
330 case KIO::R_CANCEL:
331 // If user hits cancel .part file will be overwritten
332 default:
333 break;
334 }
335
336 receiveFile();
337 }
338
339 void HandleIncomingFileTransferChannelJobPrivate::receiveFile()
340 {
341 qCDebug(KTP_FTH_MODULE);
342 Q_Q(HandleIncomingFileTransferChannelJob);
343
344 // Open the .part file in append mode
345 file = new QFile(partUrl.toLocalFile(), q->parent());
346 file->open(isResuming ? QIODevice::Append : QIODevice::WriteOnly);
347
348 // Create an empty file with the definitive file name
349 QFile realFile(url.toLocalFile(), 0);
350 realFile.open(QIODevice::WriteOnly);
351
352 Tp::PendingOperation* setUriOperation = channel->setUri(url.url());
353 q->connect(setUriOperation,
354 SIGNAL(finished(Tp::PendingOperation*)),
355 SLOT(__k__onSetUriOperationFinished(Tp::PendingOperation*)));
356 }
357
358 bool HandleIncomingFileTransferChannelJobPrivate::kill()
359 {
360 qCDebug(KTP_FTH_MODULE);
361 Q_Q(HandleIncomingFileTransferChannelJob);
362
363 if (channel->state() != Tp::FileTransferStateCancelled) {
364 Tp::PendingOperation *cancelOperation = channel->cancel();
365 q->connect(cancelOperation,
366 SIGNAL(finished(Tp::PendingOperation*)),
367 SLOT(__k__onCancelOperationFinished(Tp::PendingOperation*)));
368 } else {
369 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
370 }
371
372 return true;
373 }
374
375 void HandleIncomingFileTransferChannelJobPrivate::__k__onSetUriOperationFinished(Tp::PendingOperation* op)
376 {
377 qCDebug(KTP_FTH_MODULE);
378 Q_Q(HandleIncomingFileTransferChannelJob);
379
380 if (op->isError()) {
381 // We do not want to exit if setUri failed, but we try to send the file
382 // anyway. Anyway we print a message for debugging purposes.
383 qCWarning(KTP_FTH_MODULE) << "Unable to set the URI -" << op->errorName() << ":" << op->errorMessage();
384 }
385
386 KIO::getJobTracker()->registerJob(q);
387 // KWidgetJobTracker has an internal timer of 500 ms, if we don't wait here
388 // when the job description is emitted it won't be ready
389 // We set the description here and then whe update it if path is changed.
390
391 QTimer::singleShot(500, q, SLOT(__k__acceptFile()));
392 }
393
394 void HandleIncomingFileTransferChannelJobPrivate::__k__acceptFile()
395 {
396 qCDebug(KTP_FTH_MODULE);
397 Q_Q(HandleIncomingFileTransferChannelJob);
398
399 Q_EMIT q->description(q, i18n("Incoming file transfer"),
400 qMakePair<QString, QString>(i18n("From"), channel->targetContact()->alias()),
401 qMakePair<QString, QString>(i18n("Filename"), url.toLocalFile()));
402
403 Tp::PendingOperation* acceptFileOperation = channel->acceptFile(offset, file);
404 q->connect(acceptFileOperation,
405 SIGNAL(finished(Tp::PendingOperation*)),
406 SLOT(__k__onAcceptFileFinished(Tp::PendingOperation*)));
407 }
408
409 void HandleIncomingFileTransferChannelJobPrivate::__k__onInitialOffsetDefined(qulonglong offset)
410 {
411 qCDebug(KTP_FTH_MODULE) << "__k__onInitialOffsetDefined" << offset;
412 Q_Q(HandleIncomingFileTransferChannelJob);
413
414 // Some protocols do not support resuming file transfers, therefore we need
415 // to use to this method to set the real offset
416 if (isResuming && offset == 0) {
417 qCDebug(KTP_FTH_MODULE) << "Impossible to resume file. Restarting.";
418 Q_EMIT q->infoMessage(q, i18n("Impossible to resume file transfer. Restarting."));
419 }
420
421 this->offset = offset;
422
423 file->seek(offset);
424 q->setProcessedAmountAndCalculateSpeed(offset);
425 }
426
427 void HandleIncomingFileTransferChannelJobPrivate::__k__onFileTransferChannelStateChanged(Tp::FileTransferState state,
428 Tp::FileTransferStateChangeReason stateReason)
429 {
430 qCDebug(KTP_FTH_MODULE);
431 Q_Q(HandleIncomingFileTransferChannelJob);
432
433 qCDebug(KTP_FTH_MODULE) << "Incoming file transfer channel state changed to" << state << "with reason" << stateReason;
434
435 switch (state) {
436 case Tp::FileTransferStateNone:
437 // This is bad
438 qCWarning(KTP_FTH_MODULE) << "An unknown error occurred.";
439 q->setError(KTp::TelepathyErrorError);
440 q->setErrorText(i18n("An unknown error occurred"));
441 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
442 break;
443 case Tp::FileTransferStateCompleted:
444 {
445 QFileInfo fileinfo(url.toLocalFile());
446 if (fileinfo.exists()) {
447 QFile::remove(url.toLocalFile());
448 }
449 file->rename(url.toLocalFile());
450 file->flush();
451 file->close();
452 qCDebug(KTP_FTH_MODULE) << "Incoming file transfer completed, saved at" << file->fileName();
453 Q_EMIT q->infoMessage(q, i18n("Incoming file transfer")); // [Finished] is added automatically to the notification
454 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
455 break;
456 }
457 case Tp::FileTransferStateCancelled:
458 {
459 q->setError(KTp::FileTransferCancelled);
460 q->setErrorText(i18n("Incoming file transfer was canceled."));
461 // Close .part file if open
462 if (file && file->isOpen()) {
463 file->close();
464 }
465 q->kill(KJob::Quietly);
466 break;
467 }
468 case Tp::FileTransferStateAccepted:
469 case Tp::FileTransferStatePending:
470 case Tp::FileTransferStateOpen:
471 default:
472 break;
473 }
474 }
475
476 void HandleIncomingFileTransferChannelJobPrivate::__k__onFileTransferChannelTransferredBytesChanged(qulonglong count)
477 {
478 qCDebug(KTP_FTH_MODULE);
479 Q_Q(HandleIncomingFileTransferChannelJob);
480
481 qCDebug(KTP_FTH_MODULE).nospace() << "Receiving " << channel->fileName() << " - "
482 << "transferred bytes" << " = " << offset + count << " ("
483 << ((int)(((double)(offset + count) / channel->size()) * 100)) << "% done)";
484 q->setProcessedAmountAndCalculateSpeed(offset + count);
485 }
486
487 void HandleIncomingFileTransferChannelJobPrivate::__k__onAcceptFileFinished(Tp::PendingOperation* op)
488 {
489 // This method is called when the "acceptFile" operation is finished,
490 // therefore the file was not received yet.
491 qCDebug(KTP_FTH_MODULE);
492 Q_Q(HandleIncomingFileTransferChannelJob);
493
494 if (op->isError()) {
495 qCWarning(KTP_FTH_MODULE) << "Unable to accept file -" << op->errorName() << ":" << op->errorMessage();
496 q->setError(KTp::AcceptFileError);
497 q->setErrorText(i18n("Unable to accept file"));
498 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
499 }
500 }
501
502 void HandleIncomingFileTransferChannelJobPrivate::__k__onCancelOperationFinished(Tp::PendingOperation* op)
503 {
504 qCDebug(KTP_FTH_MODULE);
505 Q_Q(HandleIncomingFileTransferChannelJob);
506
507 if (op->isError()) {
508 qCWarning(KTP_FTH_MODULE) << "Unable to cancel file transfer - " << op->errorName() << ":" << op->errorMessage();
509 q->setError(KTp::CancelFileTransferError);
510 q->setErrorText(i18n("Cannot cancel incoming file transfer"));
511 }
512
513 qCDebug(KTP_FTH_MODULE) << "File transfer cancelled";
514 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
515 }
516
517 void HandleIncomingFileTransferChannelJobPrivate::__k__onInvalidated()
518 {
519 qCDebug(KTP_FTH_MODULE);
520 Q_Q(HandleIncomingFileTransferChannelJob);
521
522 qCWarning(KTP_FTH_MODULE) << "File transfer invalidated!" << channel->invalidationMessage() << "reason" << channel->invalidationReason();
523 Q_EMIT q->infoMessage(q, i18n("File transfer invalidated. %1", channel->invalidationMessage()));
524
525 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
526 }
527
528 #include "moc_handle-incoming-file-transfer-channel-job.cpp"
0 /*
1 * Copyright (C) 2010, 2011 Daniele E. Domenichelli <daniele.domenichelli@gmail.com>
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17
18 #ifndef HANDLE_INCOMING_FILE_TRANSFER_CHANNEL_JOB_H
19 #define HANDLE_INCOMING_FILE_TRANSFER_CHANNEL_JOB_H
20
21 #include <telepathy-base-job.h>
22
23 #include <TelepathyQt/Constants>
24 #include <TelepathyQt/Types>
25
26 namespace Tp {
27 class PendingOperation;
28 }
29
30
31 class HandleIncomingFileTransferChannelJobPrivate;
32 class HandleIncomingFileTransferChannelJob : public KTp::TelepathyBaseJob
33 {
34 Q_OBJECT
35 Q_DISABLE_COPY(HandleIncomingFileTransferChannelJob)
36 Q_DECLARE_PRIVATE(HandleIncomingFileTransferChannelJob)
37
38 // Our Q_PRIVATE_SLOTS who perform the real job
39 Q_PRIVATE_SLOT(d_func(), void __k__onRenameDialogFinished(int result))
40 Q_PRIVATE_SLOT(d_func(), void __k__onResumeDialogFinished(int result))
41 Q_PRIVATE_SLOT(d_func(), void __k__onSetUriOperationFinished(Tp::PendingOperation* op))
42 Q_PRIVATE_SLOT(d_func(), void __k__onInitialOffsetDefined(qulonglong offset))
43 Q_PRIVATE_SLOT(d_func(), void __k__onFileTransferChannelStateChanged(Tp::FileTransferState state, Tp::FileTransferStateChangeReason reason))
44 Q_PRIVATE_SLOT(d_func(), void __k__onFileTransferChannelTransferredBytesChanged(qulonglong count))
45 Q_PRIVATE_SLOT(d_func(), void __k__acceptFile())
46 Q_PRIVATE_SLOT(d_func(), void __k__onAcceptFileFinished(Tp::PendingOperation* op))
47 Q_PRIVATE_SLOT(d_func(), void __k__onCancelOperationFinished(Tp::PendingOperation* op))
48 Q_PRIVATE_SLOT(d_func(), void __k__onInvalidated())
49
50 public:
51 HandleIncomingFileTransferChannelJob(Tp::IncomingFileTransferChannelPtr channel,
52 const QString downloadDirectory,
53 bool askForDownloadDirectory,
54 QObject* parent = 0);
55 virtual ~HandleIncomingFileTransferChannelJob();
56
57 virtual void start();
58 virtual bool doKill();
59 };
60
61
62 #endif // HANDLE_INCOMING_FILE_TRANSFER_CHANNEL_JOB_H
0 /*
1 * Copyright (C) 2010, 2011 Daniele E. Domenichelli <daniele.domenichelli@gmail.com>
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17
18
19 #include "handle-outgoing-file-transfer-channel-job.h"
20 #include "telepathy-base-job_p.h"
21 #include "ktp-fth-debug.h"
22
23 #include <QTimer>
24 #include <QDebug>
25 #include <QUrl>
26
27 #include <KLocalizedString>
28 #include <kio/global.h>
29 #include <kjobtrackerinterface.h>
30
31 #include <TelepathyQt/OutgoingFileTransferChannel>
32 #include <TelepathyQt/PendingReady>
33 #include <TelepathyQt/PendingOperation>
34 #include <TelepathyQt/Contact>
35
36 class HandleOutgoingFileTransferChannelJobPrivate : public KTp::TelepathyBaseJobPrivate
37 {
38 Q_DECLARE_PUBLIC(HandleOutgoingFileTransferChannelJob)
39
40 public:
41 HandleOutgoingFileTransferChannelJobPrivate();
42 virtual ~HandleOutgoingFileTransferChannelJobPrivate();
43
44 Tp::OutgoingFileTransferChannelPtr channel;
45 QFile* file;
46 QUrl uri;
47 qulonglong offset;
48
49 void init();
50 bool kill();
51 void provideFile();
52
53 void __k__start();
54 void __k__onInitialOffsetDefined(qulonglong offset);
55 void __k__onFileTransferChannelStateChanged(Tp::FileTransferState state, Tp::FileTransferStateChangeReason reason);
56 void __k__onFileTransferChannelTransferredBytesChanged(qulonglong count);
57 void __k__onProvideFileFinished(Tp::PendingOperation* op);
58 void __k__onCancelOperationFinished(Tp::PendingOperation* op);
59 void __k__onInvalidated();
60 };
61
62 HandleOutgoingFileTransferChannelJob::HandleOutgoingFileTransferChannelJob(Tp::OutgoingFileTransferChannelPtr channel,
63 QObject* parent)
64 : TelepathyBaseJob(*new HandleOutgoingFileTransferChannelJobPrivate(), parent)
65 {
66 qCDebug(KTP_FTH_MODULE);
67 Q_D(HandleOutgoingFileTransferChannelJob);
68
69 d->channel = channel;
70 d->init();
71 }
72
73 HandleOutgoingFileTransferChannelJob::~HandleOutgoingFileTransferChannelJob()
74 {
75 KIO::getJobTracker()->unregisterJob(this);
76 qCDebug(KTP_FTH_MODULE);
77 }
78
79 void HandleOutgoingFileTransferChannelJob::start()
80 {
81 qCDebug(KTP_FTH_MODULE);
82 KIO::getJobTracker()->registerJob(this);
83 // KWidgetJobTracker has an internal timer of 500 ms, if we don't wait here
84 // when the job description is emitted it won't be ready
85 QTimer::singleShot(500, this, SLOT(__k__start()));
86 }
87
88 bool HandleOutgoingFileTransferChannelJob::doKill()
89 {
90 qCDebug(KTP_FTH_MODULE) << "Outgoing file transfer killed.";
91 Q_D(HandleOutgoingFileTransferChannelJob);
92 return d->kill();
93 }
94
95 HandleOutgoingFileTransferChannelJobPrivate::HandleOutgoingFileTransferChannelJobPrivate()
96 : file(0),
97 offset(0)
98 {
99 qCDebug(KTP_FTH_MODULE);
100 }
101
102 HandleOutgoingFileTransferChannelJobPrivate::~HandleOutgoingFileTransferChannelJobPrivate()
103 {
104 qCDebug(KTP_FTH_MODULE);
105 }
106
107 void HandleOutgoingFileTransferChannelJobPrivate::init()
108 {
109 qCDebug(KTP_FTH_MODULE);
110 Q_Q(HandleOutgoingFileTransferChannelJob);
111
112 if (channel.isNull()) {
113 qCritical() << "Channel cannot be NULL";
114 q->setError(KTp::NullChannel);
115 q->setErrorText(i18n("Invalid channel"));
116 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
117 return;
118 }
119
120 Tp::Features features = Tp::Features() << Tp::FileTransferChannel::FeatureCore;
121 if (!channel->isReady(Tp::Features() << Tp::FileTransferChannel::FeatureCore)) {
122 qCritical() << "Channel must be ready with Tp::FileTransferChannel::FeatureCore";
123 q->setError(KTp::FeatureNotReady);
124 q->setErrorText(i18n("Channel is not ready"));
125 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
126 return;
127 }
128
129 uri = QUrl(channel->uri());
130 if (uri.isEmpty()) {
131 qCWarning(KTP_FTH_MODULE) << "URI property missing";
132 q->setError(KTp::UriPropertyMissing);
133 q->setErrorText(i18n("URI property is missing"));
134 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
135 return;
136 }
137 if (!uri.isLocalFile()) {
138 // TODO handle this!
139 qCWarning(KTP_FTH_MODULE) << "Not a local file";
140 q->setError(KTp::NotALocalFile);
141 q->setErrorText(i18n("This is not a local file"));
142 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
143 return;
144 }
145
146 q->setCapabilities(KJob::Killable);
147 q->setTotalAmount(KJob::Bytes, channel->size());
148 q->setProcessedAmountAndCalculateSpeed(0);
149
150 q->connect(channel.data(),
151 SIGNAL(invalidated(Tp::DBusProxy*,QString,QString)),
152 SLOT(__k__onInvalidated()));
153 q->connect(channel.data(),
154 SIGNAL(initialOffsetDefined(qulonglong)),
155 SLOT(__k__onInitialOffsetDefined(qulonglong)));
156 q->connect(channel.data(),
157 SIGNAL(stateChanged(Tp::FileTransferState,Tp::FileTransferStateChangeReason)),
158 SLOT(__k__onFileTransferChannelStateChanged(Tp::FileTransferState,Tp::FileTransferStateChangeReason)));
159 q->connect(channel.data(),
160 SIGNAL(transferredBytesChanged(qulonglong)),
161 SLOT(__k__onFileTransferChannelTransferredBytesChanged(qulonglong)));
162 }
163
164 void HandleOutgoingFileTransferChannelJobPrivate::__k__start()
165 {
166 qCDebug(KTP_FTH_MODULE);
167 Q_Q(HandleOutgoingFileTransferChannelJob);
168
169 Q_ASSERT(!q->error());
170 if (q->error()) {
171 qCWarning(KTP_FTH_MODULE) << "Job was started in error state. Something wrong happened." << q->errorString();
172 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
173 return;
174 }
175
176 Q_EMIT q->description(q, i18n("Outgoing file transfer"),
177 qMakePair<QString, QString>(i18n("To"), channel->targetContact()->alias()),
178 qMakePair<QString, QString>(i18n("Filename"), channel->uri()));
179
180 if (channel->state() == Tp::FileTransferStateAccepted) {
181 provideFile();
182 }
183 }
184
185 bool HandleOutgoingFileTransferChannelJobPrivate::kill()
186 {
187 qCDebug(KTP_FTH_MODULE);
188 Q_Q(HandleOutgoingFileTransferChannelJob);
189
190 if (channel->state() != Tp::FileTransferStateCancelled) {
191 Tp::PendingOperation *cancelOperation = channel->cancel();
192 q->connect(cancelOperation,
193 SIGNAL(finished(Tp::PendingOperation*)),
194 SLOT(__k__onCancelOperationFinished(Tp::PendingOperation*)));
195 } else {
196 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
197 }
198
199 return true;
200 }
201
202 void HandleOutgoingFileTransferChannelJobPrivate::__k__onInitialOffsetDefined(qulonglong offset)
203 {
204 qCDebug(KTP_FTH_MODULE);
205 Q_Q(HandleOutgoingFileTransferChannelJob);
206
207 this->offset = offset;
208 q->setProcessedAmountAndCalculateSpeed(offset);
209 }
210
211 void HandleOutgoingFileTransferChannelJobPrivate::__k__onFileTransferChannelStateChanged(Tp::FileTransferState state,
212 Tp::FileTransferStateChangeReason stateReason)
213 {
214 qCDebug(KTP_FTH_MODULE);
215 Q_Q(HandleOutgoingFileTransferChannelJob);
216
217 qCDebug(KTP_FTH_MODULE) << "Outgoing file transfer channel state changed to" << state << "with reason" << stateReason;
218
219 switch (state) {
220 case Tp::FileTransferStateNone:
221 // This is bad
222 qCWarning(KTP_FTH_MODULE) << "An unknown error occurred.";
223 q->setError(KTp::TelepathyErrorError);
224 q->setErrorText(i18n("An unknown error occurred"));
225 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
226 break;
227 case Tp::FileTransferStateCompleted:
228 qCDebug(KTP_FTH_MODULE) << "Outgoing file transfer completed";
229 Q_EMIT q->infoMessage(q, i18n("Outgoing file transfer")); // [Finished] is added automatically to the notification
230 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
231 break;
232 case Tp::FileTransferStateCancelled:
233 q->setError(KTp::FileTransferCancelled);
234 q->setErrorText(i18n("Outgoing file transfer was canceled."));
235 q->kill(KJob::Quietly);
236 break;
237 case Tp::FileTransferStateAccepted:
238 provideFile();
239 break;
240 case Tp::FileTransferStatePending:
241 case Tp::FileTransferStateOpen:
242 default:
243 break;
244 }
245 }
246
247 void HandleOutgoingFileTransferChannelJobPrivate::provideFile()
248 {
249 qCDebug(KTP_FTH_MODULE);
250 Q_Q(HandleOutgoingFileTransferChannelJob);
251
252 file = new QFile(uri.toLocalFile(), q->parent());
253 qCDebug(KTP_FTH_MODULE) << "Providing file" << file->fileName();
254
255 Tp::PendingOperation* provideFileOperation = channel->provideFile(file);
256 q->connect(provideFileOperation,
257 SIGNAL(finished(Tp::PendingOperation*)),
258 SLOT(__k__onProvideFileFinished(Tp::PendingOperation*)));
259 }
260
261 void HandleOutgoingFileTransferChannelJobPrivate::__k__onFileTransferChannelTransferredBytesChanged(qulonglong count)
262 {
263 qCDebug(KTP_FTH_MODULE);
264 Q_Q(HandleOutgoingFileTransferChannelJob);
265
266 qCDebug(KTP_FTH_MODULE).nospace() << "Sending " << channel->fileName() << " - "
267 << "Transferred bytes = " << offset + count << " ("
268 << ((int)(((double)(offset + count) / channel->size()) * 100)) << "% done)";
269 q->setProcessedAmountAndCalculateSpeed(offset + count);
270 }
271
272 void HandleOutgoingFileTransferChannelJobPrivate::__k__onProvideFileFinished(Tp::PendingOperation* op)
273 {
274 // This method is called when the "provideFile" operation is finished,
275 // therefore the file was not sent yet.
276 qCDebug(KTP_FTH_MODULE);
277 Q_Q(HandleOutgoingFileTransferChannelJob);
278
279 if (op->isError()) {
280 qCWarning(KTP_FTH_MODULE) << "Unable to provide file - " << op->errorName() << ":" << op->errorMessage();
281 q->setError(KTp::ProvideFileError);
282 q->setErrorText(i18n("Cannot provide file"));
283 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
284 }
285 }
286
287 void HandleOutgoingFileTransferChannelJobPrivate::__k__onCancelOperationFinished(Tp::PendingOperation* op)
288 {
289 qCDebug(KTP_FTH_MODULE);
290 Q_Q(HandleOutgoingFileTransferChannelJob);
291
292 if (op->isError()) {
293 qCWarning(KTP_FTH_MODULE) << "Unable to cancel file transfer - " << op->errorName() << ":" << op->errorMessage();
294 q->setError(KTp::CancelFileTransferError);
295 q->setErrorText(i18n("Cannot cancel outgoing file transfer"));
296 }
297
298 qCDebug(KTP_FTH_MODULE) << "File transfer cancelled";
299 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
300 }
301
302 void HandleOutgoingFileTransferChannelJobPrivate::__k__onInvalidated()
303 {
304 qCDebug(KTP_FTH_MODULE);
305 Q_Q(HandleOutgoingFileTransferChannelJob);
306
307 qCWarning(KTP_FTH_MODULE) << "File transfer invalidated!" << channel->invalidationMessage() << "reason" << channel->invalidationReason();
308 Q_EMIT q->infoMessage(q, i18n("File transfer invalidated. %1", channel->invalidationMessage()));
309
310 QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
311 }
312
313 #include "moc_handle-outgoing-file-transfer-channel-job.cpp"
0 /*
1 * Copyright (C) 2010, 2011 Daniele E. Domenichelli <daniele.domenichelli@gmail.com>
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17
18 #ifndef HANDLE_OUTGOING_FILE_TRANSFER_CHANNEL_JOB_H
19 #define HANDLE_OUTGOING_FILE_TRANSFER_CHANNEL_JOB_H
20
21 #include <telepathy-base-job.h>
22
23 #include <TelepathyQt/Constants>
24 #include <TelepathyQt/Types>
25
26 namespace Tp {
27 class PendingOperation;
28 }
29
30
31 class HandleOutgoingFileTransferChannelJobPrivate;
32 class HandleOutgoingFileTransferChannelJob : public KTp::TelepathyBaseJob
33 {
34 Q_OBJECT
35 Q_DISABLE_COPY(HandleOutgoingFileTransferChannelJob)
36 Q_DECLARE_PRIVATE(HandleOutgoingFileTransferChannelJob)
37
38 // // Our Q_PRIVATE_SLOTS who perform the real job
39 Q_PRIVATE_SLOT(d_func(), void __k__start())
40 Q_PRIVATE_SLOT(d_func(), void __k__onInitialOffsetDefined(qulonglong offset))
41 Q_PRIVATE_SLOT(d_func(), void __k__onFileTransferChannelStateChanged(Tp::FileTransferState state, Tp::FileTransferStateChangeReason reason))
42 Q_PRIVATE_SLOT(d_func(), void __k__onFileTransferChannelTransferredBytesChanged(qulonglong count))
43 Q_PRIVATE_SLOT(d_func(), void __k__onProvideFileFinished(Tp::PendingOperation* op))
44 Q_PRIVATE_SLOT(d_func(), void __k__onCancelOperationFinished(Tp::PendingOperation* op))
45 Q_PRIVATE_SLOT(d_func(), void __k__onInvalidated())
46
47
48 public:
49 explicit HandleOutgoingFileTransferChannelJob(Tp::OutgoingFileTransferChannelPtr channel,
50 QObject* parent = 0);
51 virtual ~HandleOutgoingFileTransferChannelJob();
52
53 virtual void start();
54 virtual bool doKill();
55 };
56
57
58 #endif // HANDLE_OUTGOING_FILE_TRANSFER_CHANNEL_JOB_H
0 /* This file is part of the KDE project
1 Copyright (C) 2014 Martin Klapetek <mklapetek@kde.org>
2
3 This library is free software; you can redistribute it and/or
4 modify it under the terms of the GNU Library General Public
5 License as published by the Free Software Foundation; either
6 version 2 of the License, or (at your option) any later version.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17 */
18
19 #include "ktp-fth-debug.h"
20 Q_LOGGING_CATEGORY(KTP_FTH_MODULE, "ktp-fth-module")
0 /* This file is part of the KDE project
1 Copyright (C) 2014 Martin Klapetek <mklapetek@kde.org>
2
3 This library is free software; you can redistribute it and/or
4 modify it under the terms of the GNU Library General Public
5 License as published by the Free Software Foundation; either
6 version 2 of the License, or (at your option) any later version.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17 */
18
19 #ifndef KTP_FTH_DEBUG_H
20 #define KTP_FTH_DEBUG_H
21
22 #include <QLoggingCategory>
23 Q_DECLARE_LOGGING_CATEGORY(KTP_FTH_MODULE)
24
25 #endif
0 /*
1 * Copyright (C) 2010, 2011 Daniele E. Domenichelli <daniele.domenichelli@gmail.com>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 #include "filetransfer-handler.h"
18 #include "version.h"
19
20 #include <KTp/telepathy-handler-application.h>
21
22 #include <KAboutData>
23 #include <KLocalizedString>
24
25 #include <QDebug>
26 #include <QIcon>
27
28 #include <TelepathyQt/ClientRegistrar>
29 #include <TelepathyQt/FileTransferChannel>
30
31
32 int main(int argc, char* argv[])
33 {
34 KAboutData aboutData("ktp-filetransfer-handler",
35 i18n("Telepathy File Transfer Handler"),
36 KTP_FILETRANSFER_HANDLER_VERSION,
37 i18n("Handles your Telepathy file transfers"),
38 KAboutLicense::GPL_V2,
39 i18n("Copyright (C) 2010, 2011, 2012 Daniele E. Domenichelli <daniele.domenichelli@gmail.com>"));
40 aboutData.addAuthor(i18n("Daniele E. Domenichelli"),
41 i18n("Developer"),
42 "daniele.domenichelli@gmail.com",
43 "http://blogs.fsfe.org/drdanz/",
44 "drdanz");
45 aboutData.addCredit(i18n("Alin M Elena"), i18n("Contributor"), "alinm.elena@gmail.com");
46 aboutData.addCredit(i18n("Dario Freddi"), i18n("Contributor"), "dario.freddi@collabora.com");
47 aboutData.addCredit(i18n("David Edmundson"), i18n("Contributor"), "kde@davidedmundson.co.uk");
48 aboutData.addCredit(i18n("George Kiagiadakis"), i18n("Contributor"), "george.kiagiadakis@collabora.com");
49 aboutData.addCredit(i18n("Martin Klapetek"), i18n("Contributor"), "martin.klapetek@gmail.com");
50 aboutData.addCredit(i18n("Andrea Scarpino"), i18n("Contributor"), "andrea@archlinux.org");
51 aboutData.addCredit(i18n("Dan Vrátil"), i18n("Contributor"), "dvratil@redhat.com");
52
53
54 aboutData.setProductName("telepathy/filetransfer");
55 aboutData.setHomepage("http://community.kde.org/KTp");
56
57 KAboutData::setApplicationData(aboutData);
58
59 // This is a very very very ugly hack that attempts to solve the following problem:
60 // D-Bus service activated applications inherit the environment of dbus-daemon.
61 // Normally, in KDE, startkde sets these environment variables. However, the session's
62 // dbus-daemon is started before this happens, which means that dbus-daemon does NOT
63 // have these variables in its environment and therefore all service-activated UIs
64 // think that they are not running in KDE. This causes Qt not to load the KDE platform
65 // plugin, which leaves the UI in a sorry state, using a completely wrong theme,
66 // wrong colors, etc...
67 // See also:
68 // - https://bugs.kde.org/show_bug.cgi?id=269861
69 // - https://bugs.kde.org/show_bug.cgi?id=267770
70 // - https://git.reviewboard.kde.org/r/102194/
71 // Here we are just going to assume that kde-telepathy is always used in KDE and
72 // not anywhere else. This is probably the best that we can do.
73 setenv("KDE_FULL_SESSION", "true", 0);
74 setenv("KDE_SESSION_VERSION", "5", 0);
75 KTp::TelepathyHandlerApplication app(argc, argv);
76 app.setWindowIcon(QIcon::fromTheme(QStringLiteral("telepathy-kde")));
77
78 Tp::AccountFactoryPtr accountFactory = Tp::AccountFactory::create(QDBusConnection::sessionBus());
79
80 Tp::ConnectionFactoryPtr connectionFactory = Tp::ConnectionFactory::create(QDBusConnection::sessionBus());
81
82 Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());
83 channelFactory->addCommonFeatures(Tp::Channel::FeatureCore);
84 channelFactory->addFeaturesForIncomingFileTransfers(Tp::FileTransferChannel::FeatureCore);
85 channelFactory->addFeaturesForOutgoingFileTransfers(Tp::FileTransferChannel::FeatureCore);
86
87 Tp::ContactFactoryPtr contactFactory = Tp::ContactFactory::create();
88 contactFactory->addFeature(Tp::Contact::FeatureAlias);
89
90 Tp::ClientRegistrarPtr registrar = Tp::ClientRegistrar::create(accountFactory,
91 connectionFactory,
92 channelFactory,
93 contactFactory);
94
95 Tp::SharedPtr<FileTransferHandler> fth = Tp::SharedPtr<FileTransferHandler>(new FileTransferHandler(&app));
96 if (!registrar->registerClient(Tp::AbstractClientPtr(fth), QLatin1String("KTp.FileTransferHandler"))) {
97 qWarning() << "File Transfer Handler already running. Exiting";
98 return 1;
99 }
100
101 return app.exec();
102 }
0 [D-BUS Service]
1 Name=org.freedesktop.Telepathy.Client.KTp.FileTransferHandler
2 Exec=@CMAKE_INSTALL_FULL_LIBEXECDIR@/ktp-filetransfer-handler
0 /*
1 * Copyright (C) 2009-2010 Collabora Ltd. <info@collabora.co.uk>
2 * @Author Dario Freddi <dario.freddi@collabora.co.uk>
3 * Copyright (C) 2011 Daniele E. Domenichelli <daniele.domenichelli@gmail.com>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #include "telepathy-base-job_p.h"
21 #include "ktp-fth-debug.h"
22
23 #include <TelepathyQt/PendingOperation>
24
25 #include <KLocalizedString>
26 #include <QDebug>
27
28 using namespace KTp;
29
30 TelepathyBaseJobPrivate::TelepathyBaseJobPrivate()
31 : q_ptr(0)
32 , alreadyProcessed(0)
33 {
34 }
35
36 TelepathyBaseJobPrivate::~TelepathyBaseJobPrivate()
37 {
38 }
39
40 void TelepathyBaseJobPrivate::addOperation(Tp::PendingOperation *op)
41 {
42 Q_Q(TelepathyBaseJob);
43
44 // Add the operation to the list
45 operations << op;
46
47 // Attach the operation to our listener
48 q->connect(op, SIGNAL(finished(Tp::PendingOperation*)), q, SLOT(__k__tpOperationFinished(Tp::PendingOperation*)));
49 }
50
51 TelepathyBaseJob::TelepathyBaseJob(TelepathyBaseJobPrivate& dd, QObject* parent)
52 : KJob(parent)
53 , d_ptr(&dd)
54 {
55 d_ptr->q_ptr = this;
56 }
57
58 TelepathyBaseJob::~TelepathyBaseJob()
59 {
60 delete d_ptr;
61 }
62
63 void TelepathyBaseJob::setProcessedAmountAndCalculateSpeed(qulonglong amount)
64 {
65 qCDebug(KTP_FTH_MODULE) << amount;
66 Q_D(TelepathyBaseJob);
67
68 //If the transfer is starting
69 if (amount == 0) {
70 d->time = QTime::currentTime();
71 }
72
73 //If a least 1 second has passed since last update
74 int secondsSinceLastTime = d->time.secsTo(QTime::currentTime());
75 if (secondsSinceLastTime > 0) {
76 float speed = (amount - d->alreadyProcessed) / secondsSinceLastTime;
77 emitSpeed(speed);
78
79 d->time = QTime::currentTime();
80 d->alreadyProcessed = amount;
81 }
82 setProcessedAmount(Bytes, amount);
83 }
84
85 void TelepathyBaseJobPrivate::__k__tpOperationFinished(Tp::PendingOperation* op)
86 {
87 // First of all check if the operation is in our list
88 if (!operations.contains(op)) {
89 // WTF?
90 // TODO: This should never happen, should we do something?
91 return;
92 }
93
94 if (op->isError()) {
95 // Ouch. Add it to the error roster
96 telepathyErrors << qMakePair(op->errorName(), op->errorMessage());
97 }
98
99 // Remove it from the list
100 operations.removeOne(op);
101
102 // Ok, are we done yet?
103 if (operations.isEmpty()) {
104 // It looks like we are. Let's pass the ball to doEmitResult.
105 __k__doEmitResult();
106 }
107 }
108
109 void TelepathyBaseJobPrivate::__k__doEmitResult()
110 {
111 qCDebug(KTP_FTH_MODULE);
112 Q_Q(TelepathyBaseJob);
113
114 // Before streaming out: are there any telepathy errors?
115 if (!telepathyErrors.isEmpty()) {
116 // Hmm, bad stuff. Let's handle them here.
117 // FIXME: Maybe there's a better formatting for this specific error string?
118
119 QString errorMessage = i18np("Telepathy reported an error while performing the requested operation:",
120 "Telepathy reported %1 errors while performing the requested operation:",
121 telepathyErrors.size());
122
123 QList< QPair< QString, QString > >::const_iterator i;
124 for (i = telepathyErrors.constBegin(); i != telepathyErrors.constEnd(); ++i) {
125 errorMessage.append(QLatin1Char('\n'));
126 errorMessage.append(i18nc("The following format is: ' - <error name>: <error message>'", " - %1: %2",
127 (*i).first, (*i).second));
128 }
129
130 // Ok, let's set the errors now
131 q->setError(KTp::TelepathyErrorError);
132 q->setErrorText(errorMessage);
133 }
134
135 // The job has been finished
136 q->emitResult();
137 }
138
139 #include "moc_telepathy-base-job.cpp"
0 /*
1 * Copyright (C) 2009-2010 Collabora Ltd. <info@collabora.co.uk>
2 * @Author Dario Freddi <dario.freddi@collabora.co.uk>
3 * Copyright (C) 2011 Daniele E. Domenichelli <daniele.domenichelli@gmail.com>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #ifndef LIBKTP_TELEPATHY_BASE_JOB_H
21 #define LIBKTP_TELEPATHY_BASE_JOB_H
22
23 #include <KJob>
24
25 namespace KTp
26 {
27
28 /**
29 * This enum defines the error code for a job spawned by one of the functions inside \c TelepathyBridge
30 */
31 enum JobError {
32 /** Taken from KJob. No errors occurred */
33 NoError = 0,
34 /** Taken from KJob. The job was killed */
35 KilledJobError = 1,
36 /** The operation supplied is invalid. This, most of the times, represents an error internal to TelepathyBridge */
37 InvalidOperationError = 101,
38 /**
39 * This error means that there has been one or more errors while mapping Nepomuk resources to Telepathy contacts.
40 * For specific operations, this means that:
41 * <ul>
42 * <li>If the operation is being done upon a contact, the Nepomuk resource provided could not be
43 * mapped to an existing Tp::Contact.
44 * </li>
45 * <li>If the operation is being done upon a metacontact, none of the \c PersonContact belonging to the metacontact
46 * could be mapped to an existing Tp::Contact.
47 * </li>
48 * </ul>
49 */
50 NoContactsFoundError = 102,
51 /** None of the specified \c RemovalModes were available for the contact(s) in question */
52 NoRemovalModesAvailableError = 103,
53 /** No valid Telepathy accounts were found to match the specified contacts and/or resources */
54 NoAccountsFoundError = 104,
55 /** The protocol of the account on which the request is being done is not capable to carry on the requested action */
56 ProtocolNotCapableError = 105,
57 /** The operation requested the account to be online, but it is not */
58 AccountNotOnlineError = 106,
59 /** An operation attempted to create a nepomuk resource which already exists */
60 ResourceAlreadyExistsError = 107,
61 /** A channel is null */
62 NullChannel = 108,
63 /** A required Tp::Feature is not ready */
64 FeatureNotReady = 109,
65 /** Cannot accept file */
66 AcceptFileError = 111,
67 /** File transfer cancelled */
68 FileTransferCancelled = 112,
69 /** URI Property is missing */
70 UriPropertyMissing = 113,
71 /** Non a local file */
72 NotALocalFile = 114,
73 /** Cannot provide file */
74 ProvideFileError = 115,
75 /** Cannot cancel file transfer */
76 CancelFileTransferError = 116,
77 /** Telepathy triggered an error */
78 TelepathyErrorError = 200,
79 /** KTp Error */
80 KTpError = 300
81 };
82
83 class TelepathyBaseJobPrivate;
84 class TelepathyBaseJob : public KJob
85 {
86 Q_OBJECT
87 Q_DISABLE_COPY(TelepathyBaseJob)
88 Q_DECLARE_PRIVATE(TelepathyBaseJob)
89
90 Q_PRIVATE_SLOT(d_func(), void __k__tpOperationFinished(Tp::PendingOperation*))
91 Q_PRIVATE_SLOT(d_func(), void __k__doEmitResult())
92
93 protected:
94 explicit TelepathyBaseJob(TelepathyBaseJobPrivate &dd, QObject *parent = 0);
95 virtual ~TelepathyBaseJob();
96
97 void setProcessedAmountAndCalculateSpeed(qulonglong amount);
98
99 TelepathyBaseJobPrivate * const d_ptr;
100 };
101
102 } // namespace KTp
103
104 #endif // LIBKTP_TELEPATHY_BASE_JOB_H
0 /*
1 * Copyright (C) 2009-2010 Collabora Ltd. <info@collabora.co.uk>
2 * @Author Dario Freddi <dario.freddi@collabora.co.uk>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #ifndef LIBKTP_TELEPATHY_BASE_JOB_P_H
20 #define LIBKTP_TELEPATHY_BASE_JOB_P_H
21
22 #include "telepathy-base-job.h"
23
24 #include <QTime>
25
26 namespace Tp
27 {
28 class PendingOperation;
29 }
30
31 namespace KTp
32 {
33
34 class TelepathyBaseJobPrivate
35 {
36 Q_DECLARE_PUBLIC(TelepathyBaseJob)
37
38 protected:
39 TelepathyBaseJob* q_ptr;
40
41 public:
42 TelepathyBaseJobPrivate();
43 virtual ~TelepathyBaseJobPrivate();
44
45 QTime time;
46 qulonglong alreadyProcessed;
47 QList< Tp::PendingOperation* > operations;
48 QList< QPair< QString, QString > > telepathyErrors;
49
50 void addOperation(Tp::PendingOperation* op);
51
52 // Operation Q_PRIVATE_SLOTS
53 void __k__tpOperationFinished(Tp::PendingOperation* op);
54 void __k__doEmitResult();
55 };
56
57 } // namespace KTp
58
59 #endif // LIBKTP_TELEPATHY_BASE_JOB_P_H
0 #define KTP_FILETRANSFER_HANDLER_VERSION "@KTP_FILETRANSFER_HANDLER_VERSION@"