Browse Source

* Added kgtk-qt3

* Slight kpowersave message cleanup


git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kgtk-qt3@1173604 283d02a7-25f6-0310-bc7c-ecb5cbfe19
tpearson 8 years ago
commit
c6ca83d07d
60 changed files with 8408 additions and 0 deletions
  1. 1
    0
      AUTHORS
  2. 82
    0
      CMakeLists.txt
  3. 340
    0
      COPYING
  4. 198
    0
      ChangeLog
  5. 124
    0
      README
  6. 1
    0
      TODO
  7. 86
    0
      cmake/FindMsgfmt.cmake
  8. 237
    0
      common/common.h
  9. 311
    0
      common/connect.h
  10. 11
    0
      config.h.cmake
  11. 86
    0
      debian/cdbs/buildvars.mk
  12. 109
    0
      debian/cdbs/debian-qt-kde.mk
  13. 97
    0
      debian/cdbs/kde.mk
  14. 16
    0
      debian/cdbs/team-members
  15. 29
    0
      debian/cdbs/uploaders.mk
  16. 19
    0
      debian/cdbs/versions.pl
  17. 11
    0
      debian/changelog
  18. 1
    0
      debian/compat
  19. 19
    0
      debian/control
  20. 37
    0
      debian/copyright
  21. 30
    0
      debian/rules
  22. 9
    0
      debian/rules.bkp
  23. 22
    0
      gtk2/CMakeLists.txt
  24. 33
    0
      gtk2/kgtk2-wrapper.cmake
  25. 2005
    0
      gtk2/kgtk2.c
  26. 27
    0
      kdialogd-wrapper
  27. 17
    0
      kdialogd3/CMakeLists.txt
  28. 721
    0
      kdialogd3/kdialogd.cpp
  29. 145
    0
      kdialogd3/kdialogd.h
  30. 41
    0
      kdialogd3/po/CMakeLists.txt
  31. 63
    0
      kdialogd3/po/cs.po
  32. 62
    0
      kdialogd3/po/de.po
  33. 60
    0
      kdialogd3/po/en_GB.po
  34. 57
    0
      kdialogd3/po/es.po
  35. 60
    0
      kdialogd3/po/fr.po
  36. 58
    0
      kdialogd3/po/kdialogd3.pot
  37. 60
    0
      kdialogd3/po/pt_BR.po
  38. 62
    0
      kdialogd3/po/ru.po
  39. 60
    0
      kdialogd3/po/zh_CN.po
  40. 16
    0
      kdialogd4/CMakeLists.txt
  41. 759
    0
      kdialogd4/kdialogd.cpp
  42. 146
    0
      kdialogd4/kdialogd.h
  43. 41
    0
      kdialogd4/po/CMakeLists.txt
  44. 61
    0
      kdialogd4/po/cs.po
  45. 62
    0
      kdialogd4/po/de.po
  46. 60
    0
      kdialogd4/po/en_GB.po
  47. 56
    0
      kdialogd4/po/es.po
  48. 60
    0
      kdialogd4/po/fr.po
  49. 58
    0
      kdialogd4/po/kdialogd4.pot
  50. 60
    0
      kdialogd4/po/pt_BR.po
  51. 62
    0
      kdialogd4/po/ru.po
  52. 60
    0
      kdialogd4/po/zh_CN.po
  53. 103
    0
      kgtk-wrapper
  54. 23
    0
      mangled.sh
  55. 24
    0
      qt3/CMakeLists.txt
  56. 29
    0
      qt3/kqt3-wrapper.cmake
  57. 671
    0
      qt3/kqt3.cpp
  58. 22
    0
      qt4/CMakeLists.txt
  59. 29
    0
      qt4/kqt4-wrapper.cmake
  60. 599
    0
      qt4/kqt4.cpp

+ 1
- 0
AUTHORS View File

@@ -0,0 +1 @@
1
+Craig Drummond <Craig.Drummond@lycos.co.uk>

+ 82
- 0
CMakeLists.txt View File

@@ -0,0 +1,82 @@
1
+project(KGtk)
2
+cmake_minimum_required(VERSION 2.4.0)
3
+
4
+set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
5
+set(CPACK_GENERATOR "TBZ2")
6
+set(CPACK_SOURCE_GENERATOR "TBZ2")
7
+set(CPACK_PACKAGE_VERSION_MAJOR "0")
8
+set(CPACK_PACKAGE_VERSION_MINOR "10")
9
+set(CPACK_PACKAGE_VERSION_PATCH "1")
10
+set(KGTK_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
11
+set(KGTK_VERSION_FULL "${KGTK_VERSION}.${CPACK_PACKAGE_VERSION_PATCH}")
12
+set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${KGTK_VERSION_FULL}")
13
+include(CPack)
14
+
15
+set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
16
+include(CheckFunctionExists)
17
+check_function_exists(getpeereid HAVE_GETPEEREID)
18
+
19
+# Cant compile Qt3/KDE3 at the same time as Qt4/KDE4...
20
+if ("${KGTK_KDE4}" MATCHES "true" OR "${KGTK_QT4}" MATCHES "true")
21
+    if (NOT "${KGTK_KDE3}" MATCHES "false" OR NOT "${KGTK_QT3}" MATCHES "false")
22
+        set(KGTK_KDE3 "false")
23
+        set(KGTK_QT3 "false")
24
+        message("** INFORMATION: Compiling Qt4/KDE4, Qt3/KDE3 disabled")
25
+    endif (NOT "${KGTK_KDE3}" MATCHES "false" OR NOT "${KGTK_QT3}" MATCHES "false")
26
+endif ("${KGTK_KDE4}" MATCHES "true" OR "${KGTK_QT4}" MATCHES "true")
27
+
28
+if (NOT "${KGTK_KDE3}" MATCHES "false")
29
+    add_subdirectory(kdialogd3)
30
+endif (NOT "${KGTK_KDE3}" MATCHES "false")
31
+
32
+if ("${KGTK_KDE4}" MATCHES "true")
33
+    add_subdirectory(kdialogd4)
34
+    # For some reason kdialogd4 does not install unless you cd into the kdialogd4 folder?
35
+    # ...hacky fix for this...
36
+    install(PROGRAMS ${CMAKE_BINARY_DIR}/kdialogd4/kdialogd4 DESTINATION bin)
37
+endif ("${KGTK_KDE4}" MATCHES "true")
38
+
39
+if (NOT "${KGTK_GTK2}" MATCHES "false")
40
+    # Check if we have dlvsym...
41
+    find_library(LIBDLVSYM_LIBRARY
42
+                 NAMES dl
43
+                 PATHS /lib /usr/lib /usr/X11R6/lib /usr/local/lib)
44
+
45
+    if(LIBDLVSYM_LIBRARY)
46
+        set(HAVE_DLVSYM 1)
47
+        # Determine version of dlsym...
48
+        find_library(LIBDL_LIBRARY
49
+                     NAMES dl
50
+                     PATHS /lib /usr/lib /usr/X11R6/lib /usr/local/lib)
51
+
52
+        if(LIBDL_LIBRARY)
53
+            execute_process(COMMAND objdump --dynamic-syms ${LIBDL_LIBRARY}
54
+                            COMMAND grep dlsym
55
+                            OUTPUT_VARIABLE DLSYM_DATA)
56
+            separate_arguments(DLSYM_DATA)
57
+            if (${CMAKE_MAJOR_VERSION} GREATER 2 OR ${CMAKE_MINOR_VERSION} GREATER 4)
58
+                cmake_policy(SET CMP0007 OLD)
59
+            endif (${CMAKE_MAJOR_VERSION} GREATER 2 OR ${CMAKE_MINOR_VERSION} GREATER 4)
60
+            list(GET DLSYM_DATA 4 KGTK_DLSYM_VERSION)
61
+        endif(LIBDL_LIBRARY)
62
+    else(LIBDLVSYM_LIBRARY)
63
+        message("** INFORMATION: You're libdl does not contain dlvsym - SWT apps will not be supported")
64
+    endif(LIBDLVSYM_LIBRARY)
65
+
66
+    add_subdirectory(gtk2)
67
+endif (NOT "${KGTK_GTK2}" MATCHES "false")
68
+
69
+if (NOT "${KGTK_QT3}" MATCHES "false")
70
+    add_subdirectory(qt3)
71
+endif (NOT "${KGTK_QT3}" MATCHES "false")
72
+
73
+if ("${KGTK_QT4}" MATCHES "true")
74
+    add_subdirectory(qt4)
75
+endif ("${KGTK_QT4}" MATCHES "true")
76
+
77
+
78
+install(PROGRAMS ${CMAKE_SOURCE_DIR}/kdialogd-wrapper DESTINATION bin)
79
+install(PROGRAMS ${CMAKE_SOURCE_DIR}/kgtk-wrapper DESTINATION bin)
80
+
81
+message("** INFORMATION: Using installation prefix: ${CMAKE_INSTALL_PREFIX}")
82
+configure_file (config.h.cmake ${CMAKE_BINARY_DIR}/config.h)

+ 340
- 0
COPYING View File

@@ -0,0 +1,340 @@
1
+		    GNU GENERAL PUBLIC LICENSE
2
+		       Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5
+                       59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+			    Preamble
10
+
11
+  The licenses for most software are designed to take away your
12
+freedom to share and change it.  By contrast, the GNU General Public
13
+License is intended to guarantee your freedom to share and change free
14
+software--to make sure the software is free for all its users.  This
15
+General Public License applies to most of the Free Software
16
+Foundation's software and to any other program whose authors commit to
17
+using it.  (Some other Free Software Foundation software is covered by
18
+the GNU Library General Public License instead.)  You can apply it to
19
+your programs, too.
20
+
21
+  When we speak of free software, we are referring to freedom, not
22
+price.  Our General Public Licenses are designed to make sure that you
23
+have the freedom to distribute copies of free software (and charge for
24
+this service if you wish), that you receive source code or can get it
25
+if you want it, that you can change the software or use pieces of it
26
+in new free programs; and that you know you can do these things.
27
+
28
+  To protect your rights, we need to make restrictions that forbid
29
+anyone to deny you these rights or to ask you to surrender the rights.
30
+These restrictions translate to certain responsibilities for you if you
31
+distribute copies of the software, or if you modify it.
32
+
33
+  For example, if you distribute copies of such a program, whether
34
+gratis or for a fee, you must give the recipients all the rights that
35
+you have.  You must make sure that they, too, receive or can get the
36
+source code.  And you must show them these terms so they know their
37
+rights.
38
+
39
+  We protect your rights with two steps: (1) copyright the software, and
40
+(2) offer you this license which gives you legal permission to copy,
41
+distribute and/or modify the software.
42
+
43
+  Also, for each author's protection and ours, we want to make certain
44
+that everyone understands that there is no warranty for this free
45
+software.  If the software is modified by someone else and passed on, we
46
+want its recipients to know that what they have is not the original, so
47
+that any problems introduced by others will not reflect on the original
48
+authors' reputations.
49
+
50
+  Finally, any free program is threatened constantly by software
51
+patents.  We wish to avoid the danger that redistributors of a free
52
+program will individually obtain patent licenses, in effect making the
53
+program proprietary.  To prevent this, we have made it clear that any
54
+patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+  The precise terms and conditions for copying, distribution and
57
+modification follow.
58
+
59
+		    GNU GENERAL PUBLIC LICENSE
60
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+  0. This License applies to any program or other work which contains
63
+a notice placed by the copyright holder saying it may be distributed
64
+under the terms of this General Public License.  The "Program", below,
65
+refers to any such program or work, and a "work based on the Program"
66
+means either the Program or any derivative work under copyright law:
67
+that is to say, a work containing the Program or a portion of it,
68
+either verbatim or with modifications and/or translated into another
69
+language.  (Hereinafter, translation is included without limitation in
70
+the term "modification".)  Each licensee is addressed as "you".
71
+
72
+Activities other than copying, distribution and modification are not
73
+covered by this License; they are outside its scope.  The act of
74
+running the Program is not restricted, and the output from the Program
75
+is covered only if its contents constitute a work based on the
76
+Program (independent of having been made by running the Program).
77
+Whether that is true depends on what the Program does.
78
+
79
+  1. You may copy and distribute verbatim copies of the Program's
80
+source code as you receive it, in any medium, provided that you
81
+conspicuously and appropriately publish on each copy an appropriate
82
+copyright notice and disclaimer of warranty; keep intact all the
83
+notices that refer to this License and to the absence of any warranty;
84
+and give any other recipients of the Program a copy of this License
85
+along with the Program.
86
+
87
+You may charge a fee for the physical act of transferring a copy, and
88
+you may at your option offer warranty protection in exchange for a fee.
89
+
90
+  2. You may modify your copy or copies of the Program or any portion
91
+of it, thus forming a work based on the Program, and copy and
92
+distribute such modifications or work under the terms of Section 1
93
+above, provided that you also meet all of these conditions:
94
+
95
+    a) You must cause the modified files to carry prominent notices
96
+    stating that you changed the files and the date of any change.
97
+
98
+    b) You must cause any work that you distribute or publish, that in
99
+    whole or in part contains or is derived from the Program or any
100
+    part thereof, to be licensed as a whole at no charge to all third
101
+    parties under the terms of this License.
102
+
103
+    c) If the modified program normally reads commands interactively
104
+    when run, you must cause it, when started running for such
105
+    interactive use in the most ordinary way, to print or display an
106
+    announcement including an appropriate copyright notice and a
107
+    notice that there is no warranty (or else, saying that you provide
108
+    a warranty) and that users may redistribute the program under
109
+    these conditions, and telling the user how to view a copy of this
110
+    License.  (Exception: if the Program itself is interactive but
111
+    does not normally print such an announcement, your work based on
112
+    the Program is not required to print an announcement.)
113
+
114
+These requirements apply to the modified work as a whole.  If
115
+identifiable sections of that work are not derived from the Program,
116
+and can be reasonably considered independent and separate works in
117
+themselves, then this License, and its terms, do not apply to those
118
+sections when you distribute them as separate works.  But when you
119
+distribute the same sections as part of a whole which is a work based
120
+on the Program, the distribution of the whole must be on the terms of
121
+this License, whose permissions for other licensees extend to the
122
+entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+Thus, it is not the intent of this section to claim rights or contest
125
+your rights to work written entirely by you; rather, the intent is to
126
+exercise the right to control the distribution of derivative or
127
+collective works based on the Program.
128
+
129
+In addition, mere aggregation of another work not based on the Program
130
+with the Program (or with a work based on the Program) on a volume of
131
+a storage or distribution medium does not bring the other work under
132
+the scope of this License.
133
+
134
+  3. You may copy and distribute the Program (or a work based on it,
135
+under Section 2) in object code or executable form under the terms of
136
+Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+    a) Accompany it with the complete corresponding machine-readable
139
+    source code, which must be distributed under the terms of Sections
140
+    1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+    b) Accompany it with a written offer, valid for at least three
143
+    years, to give any third party, for a charge no more than your
144
+    cost of physically performing source distribution, a complete
145
+    machine-readable copy of the corresponding source code, to be
146
+    distributed under the terms of Sections 1 and 2 above on a medium
147
+    customarily used for software interchange; or,
148
+
149
+    c) Accompany it with the information you received as to the offer
150
+    to distribute corresponding source code.  (This alternative is
151
+    allowed only for noncommercial distribution and only if you
152
+    received the program in object code or executable form with such
153
+    an offer, in accord with Subsection b above.)
154
+
155
+The source code for a work means the preferred form of the work for
156
+making modifications to it.  For an executable work, complete source
157
+code means all the source code for all modules it contains, plus any
158
+associated interface definition files, plus the scripts used to
159
+control compilation and installation of the executable.  However, as a
160
+special exception, the source code distributed need not include
161
+anything that is normally distributed (in either source or binary
162
+form) with the major components (compiler, kernel, and so on) of the
163
+operating system on which the executable runs, unless that component
164
+itself accompanies the executable.
165
+
166
+If distribution of executable or object code is made by offering
167
+access to copy from a designated place, then offering equivalent
168
+access to copy the source code from the same place counts as
169
+distribution of the source code, even though third parties are not
170
+compelled to copy the source along with the object code.
171
+
172
+  4. You may not copy, modify, sublicense, or distribute the Program
173
+except as expressly provided under this License.  Any attempt
174
+otherwise to copy, modify, sublicense or distribute the Program is
175
+void, and will automatically terminate your rights under this License.
176
+However, parties who have received copies, or rights, from you under
177
+this License will not have their licenses terminated so long as such
178
+parties remain in full compliance.
179
+
180
+  5. You are not required to accept this License, since you have not
181
+signed it.  However, nothing else grants you permission to modify or
182
+distribute the Program or its derivative works.  These actions are
183
+prohibited by law if you do not accept this License.  Therefore, by
184
+modifying or distributing the Program (or any work based on the
185
+Program), you indicate your acceptance of this License to do so, and
186
+all its terms and conditions for copying, distributing or modifying
187
+the Program or works based on it.
188
+
189
+  6. Each time you redistribute the Program (or any work based on the
190
+Program), the recipient automatically receives a license from the
191
+original licensor to copy, distribute or modify the Program subject to
192
+these terms and conditions.  You may not impose any further
193
+restrictions on the recipients' exercise of the rights granted herein.
194
+You are not responsible for enforcing compliance by third parties to
195
+this License.
196
+
197
+  7. If, as a consequence of a court judgment or allegation of patent
198
+infringement or for any other reason (not limited to patent issues),
199
+conditions are imposed on you (whether by court order, agreement or
200
+otherwise) that contradict the conditions of this License, they do not
201
+excuse you from the conditions of this License.  If you cannot
202
+distribute so as to satisfy simultaneously your obligations under this
203
+License and any other pertinent obligations, then as a consequence you
204
+may not distribute the Program at all.  For example, if a patent
205
+license would not permit royalty-free redistribution of the Program by
206
+all those who receive copies directly or indirectly through you, then
207
+the only way you could satisfy both it and this License would be to
208
+refrain entirely from distribution of the Program.
209
+
210
+If any portion of this section is held invalid or unenforceable under
211
+any particular circumstance, the balance of the section is intended to
212
+apply and the section as a whole is intended to apply in other
213
+circumstances.
214
+
215
+It is not the purpose of this section to induce you to infringe any
216
+patents or other property right claims or to contest validity of any
217
+such claims; this section has the sole purpose of protecting the
218
+integrity of the free software distribution system, which is
219
+implemented by public license practices.  Many people have made
220
+generous contributions to the wide range of software distributed
221
+through that system in reliance on consistent application of that
222
+system; it is up to the author/donor to decide if he or she is willing
223
+to distribute software through any other system and a licensee cannot
224
+impose that choice.
225
+
226
+This section is intended to make thoroughly clear what is believed to
227
+be a consequence of the rest of this License.
228
+
229
+  8. If the distribution and/or use of the Program is restricted in
230
+certain countries either by patents or by copyrighted interfaces, the
231
+original copyright holder who places the Program under this License
232
+may add an explicit geographical distribution limitation excluding
233
+those countries, so that distribution is permitted only in or among
234
+countries not thus excluded.  In such case, this License incorporates
235
+the limitation as if written in the body of this License.
236
+
237
+  9. The Free Software Foundation may publish revised and/or new versions
238
+of the General Public License from time to time.  Such new versions will
239
+be similar in spirit to the present version, but may differ in detail to
240
+address new problems or concerns.
241
+
242
+Each version is given a distinguishing version number.  If the Program
243
+specifies a version number of this License which applies to it and "any
244
+later version", you have the option of following the terms and conditions
245
+either of that version or of any later version published by the Free
246
+Software Foundation.  If the Program does not specify a version number of
247
+this License, you may choose any version ever published by the Free Software
248
+Foundation.
249
+
250
+  10. If you wish to incorporate parts of the Program into other free
251
+programs whose distribution conditions are different, write to the author
252
+to ask for permission.  For software which is copyrighted by the Free
253
+Software Foundation, write to the Free Software Foundation; we sometimes
254
+make exceptions for this.  Our decision will be guided by the two goals
255
+of preserving the free status of all derivatives of our free software and
256
+of promoting the sharing and reuse of software generally.
257
+
258
+			    NO WARRANTY
259
+
260
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
262
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
266
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
267
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+REPAIR OR CORRECTION.
269
+
270
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+POSSIBILITY OF SUCH DAMAGES.
279
+
280
+		     END OF TERMS AND CONDITIONS
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) <year>  <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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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) year 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.

+ 198
- 0
ChangeLog View File

@@ -0,0 +1,198 @@
1
+0.10.1
2
+------
3
+1. Fix 'kgtk-wrapper ./app' case.
4
+2. Set filename for KdialogD4's save as filedialog.
5
+3. Hacky fix for Firefox crashing when trying to save to a file that
6
+   already exists -> delete it first!
7
+4. When launching KDialogD, try todetermin which version is installed.
8
+5. Add some compile fixes from kde-apps
9
+
10
+0.10
11
+----
12
+1. Fix CMake bug at double definition of destantion dir for gmo.
13
+   - thanks to Yar Odin.
14
+2. When KDialogD is started, write its PID to a file. When each app
15
+   attempts to connect to KDialogD, it checks if the PID in the file
16
+   is still active - if not it starts KDialogD.
17
+3. KIO::NetAccess::mostLocalUrl fails if a file does not exist. If so,
18
+   then check if parent folder exists - and if so, append filename to
19
+   that.
20
+
21
+0.9.6
22
+-----
23
+1. Fix russion translation files - thanks to Yar Odin
24
+2. Fix some CMake 2.6 issues.
25
+
26
+0.9.5
27
+-----
28
+1. Fix detection of firefox. Treat xulrunner as Firefox.
29
+2. Quick hack for kino - always save as .kino
30
+3. Prevent dummy gtk window from appearing in KDE4's 'present windows'
31
+   window selector.
32
+4. Translations:
33
+       Brazillian Portuguese (pt_BR) Márcio Moraes
34
+       Russion (ru) Yar Odin
35
+5. Fix kdialogd4's file widget.
36
+6. Fix kgtk-wrapper script for relative paths - thanks to Ingo Müller.
37
+7. set G_BROKEN_FILENAMES=1 for non UTF8 locales.
38
+
39
+0.9.4
40
+-----
41
+1. Translations:
42
+       Spanish (es) Marco Antonio Blanco <mablanco@activasistemas.com>
43
+2. When saving with opera, show the suggested filename.
44
+
45
+0.9.3
46
+-----
47
+1. Translations:
48
+       German (de) jakuhr-linux@gmx.de
49
+       Czech  (cs) Marián Kyral <mkyral@email.cz>
50
+2. Fix firefox crash when overwriting an existing file.
51
+
52
+0.9.2
53
+-----
54
+1. Remove 'which gimp' from kgtk-wrapper - oops!
55
+2. In kgtk-wrapper, set opera to use qt3
56
+3. Fix opera crash.
57
+4. Use GLib's convert function to convert to/from utf8, and
58
+   to/from URIs
59
+5. Walk through Qt3's QFileDialog's children to locate combobox
60
+   containing filetypes, as opposed to using a copy of QFileDialogPrivate
61
+6. Translations:
62
+       Simplified Chinese (zh_CN) Liang Qi <cavendish.qi@gmail.com>
63
+       French             (fr)    Paul Thomas <pw1517@gmail.com>
64
+       British English	  (en_GB) Me!
65
+7. Implement over-riding of non statically called Qt4 QFileDialogs
66
+
67
+0.9.1
68
+-----
69
+1. Use cmake as build system.
70
+2. Fix recognition of gimp 2.4
71
+3. Fix translation of standard kde strings.
72
+4. Fix case where kgtk-wrapper is called via a symlink.
73
+
74
+0.9
75
+---
76
+1. Fix dialog parenting issues with Gtk folder picker combo/menu.
77
+2. Fix compilation issue for KDE < 3.4
78
+3. Treat Iceweasel and Swiftfox the same as firefox.
79
+4. Improve operation under beryl.
80
+5. Add KDE4 and Qt4 support.
81
+6. Reduce heavy CPU usage of kqt
82
+7. Fix some i18n issues.
83
+8. Place wrapper scripts into prefix/bin, and libraries into prefix/lib/kgtk
84
+9. kgtk-wrapper can now be called for Gtk2, Qt3, nd Qt4 apps. The app is checked
85
+   to determin which toolkit it is using. If this check fails, you may edit
86
+   ~/.kde/share/config/kgtkrc and add lines such as
87
+
88
+   [Apps]
89
+   eclipse=gtk2
90
+   scribus=qt3
91
+   abiword=x
92
+
93
+   Setting "abiword=x" disables kgtk for abiword (as it doesnt work!)
94
+
95
+0.8
96
+---
97
+1. Install scripts into $prefix/bin as opposed to hard-coding
98
+   /usr/local/bin
99
+2. Debug messages are disabled by default, to enable reconfigure
100
+   with --enable-debug-messages
101
+3. Work correctly for autopackage'd apps - e.g. Inkscape 0.44
102
+4. Fix inkscape 0.44's export bitmap file dialog appearing underneath
103
+   export dialog.
104
+5. Convert kdialogd to a KDE app. This app is started by Gtk/Qt apps,
105
+   and will self terminate 30 seconds after the last connected app
106
+   has disconnected. This timeout can be changed by editing kdialogdrc
107
+   and changing
108
+
109
+    [General]
110
+    Timeout=10
111
+
112
+6. Libraries installed to $KDEPREFIX/share/apps/kgtk
113
+7. Remove .sh extension from scripts
114
+8. When starting kdialogd, create the socket folder if it does not
115
+   already exist.
116
+
117
+**NOTE** You *MUST* remove any previous version of KGtk before using this
118
+version. i.e. you must delete the kded_kdialgd.la, kded_kdialgd.so, and the
119
+kdialogd.desktop files. KDE also must be restarted - to remove the KDED
120
+module.
121
+
122
+0.7
123
+---
124
+1. Bug fix in wrapper scripts, use "$@" and not $* - thanks to
125
+   Victor Fernandez Martinez
126
+2. Fix sending of UTF-8 characters from KDED module to app.
127
+
128
+0.6
129
+-----
130
+1. Check for existance $KDETMP, or $TMPDIR when creating socket.
131
+2. Use UTF-8 when talking to KDED module.
132
+
133
+0.5.1
134
+-----
135
+1. Compile fixes - 64bit, Gtk<2.6
136
+
137
+0.5
138
+---
139
+1. Make the KDED module a load-on-demand module, as opposed to always being
140
+   loaded. Module can be unloaded with:
141
+
142
+      dcop kded kded unloadModule kdialogd 
143
+
144
+2. Filters should now work for inkscape save - at least in inkscape 0.43
145
+3. Add ./configure check to ensure Gtk >= 2.4
146
+4. Added a ./configure check for dlvsym within libdl, if not found then
147
+   dlsym is not overriden - and SWT aps wont work :-(
148
+5. In ./configure try to determine version of dlsym.
149
+6. Try to load gtk_file_chooser_set/get_do_overwrite_confirmation's
150
+   from libgtk - if found then use, otherwise assume Gtk app will
151
+   do overwrite detection.
152
+7. Correctly handle empty selection in single-file open mode.
153
+8. Fix initial dir of non-statically called QFileDialogs
154
+9. Modify Scribus's save file filters to have a "Compressed Documents" entry
155
+   -- will break localisation of scribus :-(
156
+
157
+0.4
158
+---
159
+1. Support non-statically called QFileDialogs
160
+2. Fix compilation under KDE <3.5
161
+3. Save/restore PATH in wrapper scripts.
162
+4. Now works with eclipse 3.1 (and all SWT apps? Seems to also work with
163
+   Azureus)
164
+5. At start up Gtk app passes its name to KDialogD so that dialog settings
165
+   can be saved per-app.
166
+6. Remove patterns from filter combo strings - more KDE like.
167
+
168
+** NOTE: After installing v0.4, KDE (or at least kded) *must* be restarted -
169
+         due to changes in the communication off apps -> kdialogd.
170
+
171
+0.3
172
+---
173
+1. Don't show Gtk file-overwrite dialogs, handle the file exists case within 
174
+   KDE portion.
175
+2. Fix retrieval/display of file filters.
176
+3. Check for accessing of non-local URLs before dialog is closed.
177
+
178
+0.2.2
179
+-----
180
+1. Remove kgtk-wrapper.sh and kqt-wrapper.sh shell scripts from archive -
181
+   these should've been generated at make time. Hopefully they will now.
182
+
183
+0.2.1
184
+-----
185
+1. Fix qt compile issues.
186
+
187
+0.2
188
+---
189
+1. Convert kdialogd into a kded module.
190
+2. Make gtk library a LD_PRELOAD library
191
+3. Add a Qt library
192
+4. Try to convert KURL's into local files
193
+5. When performing a save as, etc, correctly set the current filename and path.
194
+6. Remove font and colour dialog support
195
+
196
+0.1
197
+---
198
+1. Initial version.

+ 124
- 0
README View File

@@ -0,0 +1,124 @@
1
+Introduction
2
+------------
3
+
4
+KGtk is a quick-n-dirty hack to allow some Gtk2, Qt3, and Qt4
5
+applications to use KDE3 or KDE4 file dialogs.
6
+
7
+KGtk is composed of the following pieces:
8
+
9
+1. An application called kdialogd. In this archive there are
10
+   two varieties of this - a KDE3 version, and a KDE4 version.
11
+2. LD_PRELOAD libraries that are used to override the Gtk2, Qt3,
12
+   and Qt4 file dialogs.
13
+
14
+If you start an application using the following command:
15
+    kgtk-wrapper gimp
16
+
17
+...the the following occurs:
18
+
19
+1. kgtk-wrapper determines whether the application is a Gtk2, Qt3,
20
+   or Qt4 application. It then sets the LD_PRELOAD environment
21
+   variable to point to the approriate KGtk library.
22
+2. When the application now starts, it checks for the
23
+   KDE_SESSION_VERSION environment variable. If this is not set,
24
+   or is less than 4, then the KDE3 version of kdialogd is started,
25
+   else the KDE4 version is started.
26
+3. When 'gimp' now tries to open a file dialog, the KGtk library
27
+   intercepts this, and asks kdialogd to open a file dialog instead.
28
+
29
+There will only ever be one instance of kdialogd, and all apps communicate with the same
30
+instance - and it termiantes itself 30 seconds after the last Gtk/Qt app has
31
+disconnected. This timeout can be changed by editing kdialogdrc and setting/changing
32
+
33
+    [General]
34
+    Timeout=10
35
+
36
+
37
+Installation
38
+------------
39
+As of v0.9.1, kgtk uses CMake in place of autotools.
40
+
41
+Because KGtk includes code for Qt3/KDE3 and Qt4/KDE4, you need
42
+to specify when building which variants you would like to build.
43
+This is accomplished as follows:
44
+
45
+1. mkdir build
46
+2. cd build
47
+3. cmake .. -DCMAKE_INSTALL_PREFIX=/usr
48
+4. make
49
+5. sudo make install
50
+
51
+* -DKGTK_KDE3=true instructs CMake to create makefiles for the KDE3
52
+  version of KDialogD. Defaults to "true", use -DKGTK_KDE3=false
53
+  to turn off. Turning this on, sets -DKGTK_KDE4=false and
54
+  -DKGTK_QT4=false
55
+
56
+* -DKGTK_KDE4=true would instruct CMake to create makefiles for
57
+  the KDE4 version of KDialogD. Defaults to "false".
58
+
59
+* -DKGTK_GTK2=true instructs CMake to create makefiles for the Gtk2
60
+  version of the LD_PRELOAD library. Defaults to "true", use
61
+  -DKGTK_GTK2=false to turn off.
62
+
63
+* -DKGTK_QT3=true instructs CMake to create makefiles for the Qt3
64
+  version of the LD_PRELOAD library. Defaults to "true", use
65
+  -DKGTK_QT3=false to turn off. Turning this on, sets
66
+  -DKGTK_KDE4=false and -DKGTK_QT4=false
67
+
68
+* -DKGTK_QT4=true instructs CMake to create makefiles for the Qt4
69
+  version of the LD_PRELOAD library. Defaults to "false".
70
+
71
+* For 64 bit systems, also append -DLIB_SUFFIX=64
72
+
73
+Mixing '-DKGTK_KDE3=true' and '-DKGTK_KDE4=true' wont work, so compile the Qt3/KDE3,
74
+and Qt4/KDE4 variants separately. Also, the 'build' folder *must* be cleaned before
75
+switching to/from Qt3/KDE3 from/to Qt4/KDE4
76
+
77
+
78
+So, to compile everything I suggest the following:
79
+
80
+ 1. mkdir build3
81
+ 2. cd build3
82
+ 3. cmake .. -DCMAKE_INSTALL_PREFIX=/usr
83
+    [ This will build KDialogD for KDE3, and create the LD_PRELOAD libraries for
84
+      Qt3 and Gtk2 ]
85
+ 4. make
86
+ 5. sudo make install
87
+
88
+ 6. set up Qt4/KDE4 env variables
89
+ 7. clean build folder
90
+
91
+ 8. mkdir build4
92
+ 9. cd build4
93
+10. cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DKGTK_KDE4=true -DKGTK_QT4=true -DKGTK_GTK2=false
94
+11. make
95
+12. sudo make install
96
+
97
+NOTE: If you have both KDE3 and KDE4 installed, when calling cmake for KDE3, set KDEDIR to be empty.
98
+      e.g. 
99
+        KDEDIR= cmake -DCMAKE_INSTALL_PREFIX=/usr -DKGTK_KDE4=false -DKGTK_QT4=false
100
+
101
+Notes
102
+-----
103
+
104
+The library has been tested with the following applications:
105
+
106
+Reported to work:
107
+
108
+  1. Firefox (1.5.x only, not 1.0.x)
109
+  2. Inkscape
110
+  3. GIMP
111
+  4. Kino
112
+  5. Eclipse
113
+  6. Azureus
114
+  7. Galde-2
115
+  8. Streamtuner
116
+  9. Avidemux2
117
+ 10. Scribus
118
+ 11. QComcBook
119
+ 12. Planner 0.14: works, but asks twice for open file
120
+
121
+Reported *not* working:
122
+
123
+  1. AbiWord
124
+

+ 1
- 0
TODO View File

@@ -0,0 +1 @@
1
+KDE4: File dialog history

+ 86
- 0
cmake/FindMsgfmt.cmake View File

@@ -0,0 +1,86 @@
1
+#
2
+# - Try to find the msgfmt executeable
3
+#
4
+# It will set the following variables:
5
+#
6
+#  MSGFMT_FOUND
7
+#  MSGFMT_EXECUTABLE
8
+#
9
+###################################################################
10
+#
11
+#  Copyright (c) 2006, Andreas Schneider <mail@cynapses.org>
12
+#
13
+# This program is free software; you can redistribute it and/or
14
+# modify it under the terms of the GNU General Public License
15
+# as published by the Free Software Foundation; either version 2
16
+# of the License, or (at your option) any later version.
17
+#
18
+# This program is distributed in the hope that it will be useful,
19
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
+# GNU General Public License for more details.
22
+#
23
+# You should have received a copy of the GNU General Public License
24
+# along with this program; if not, write to the Free Software
25
+# Foundation, Inc., 51 Franklin Street, Fifth Floor,
26
+# Boston, MA  02110-1301, USA.
27
+#
28
+###################################################################
29
+#
30
+#  Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
31
+#  All rights reserved.
32
+#
33
+# Redistribution and use in source and binary forms, with or without
34
+# modification, are permitted provided that the following conditions
35
+# are met:
36
+#
37
+# * Redistributions of source code must retain the above copyright
38
+#   notice, this list of conditions and the following disclaimer.
39
+#
40
+# * Redistributions in binary form must reproduce the above copyright
41
+#   notice, this list of conditions and the following disclaimer in
42
+#   the documentation and/or other materials provided with the
43
+#   distribution.
44
+#
45
+# * Neither the name of the cmake-modules nor the names of its
46
+#   contributors may be used to endorse or promote products derived
47
+#   from this software without specific prior written permission.
48
+#
49
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
50
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
51
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
52
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
53
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
54
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
55
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
56
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
57
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
59
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
60
+# POSSIBILITY OF SUCH DAMAGE.
61
+#
62
+
63
+IF (MSGFMT_EXECUTABLE)
64
+  # in cache alread?
65
+  SET(MSGFMT_FOUND TRUE)
66
+ELSE (MSGFMT_EXECUTABLE)
67
+  IF (UNIX)
68
+    FIND_PROGRAM(MSGFMT_EXECUTABLE
69
+      NAMES
70
+        msgfmt
71
+      PATHS
72
+        /usr/bin
73
+        /usr/local/bin
74
+    )
75
+
76
+    IF(MSGFMT_EXECUTABLE)
77
+      SET(MSGFMT_FOUND TRUE)
78
+    ELSE(MSGFMT_EXECUTABLE)
79
+      MESSAGE(FATAL_ERROR "msgfmt not found - po files can't be processed")
80
+    ENDIF(MSGFMT_EXECUTABLE)
81
+
82
+    MARK_AS_ADVANCED(MSGFMT_EXECUTABLE)
83
+  ENDIF(UNIX)
84
+ENDIF (MSGFMT_EXECUTABLE)
85
+
86
+# vim:et ts=2 sw=2 comments=\:\#

+ 237
- 0
common/common.h View File

@@ -0,0 +1,237 @@
1
+#ifndef __COMMON_H__
2
+#define __COMMON_H__
3
+
4
+#define KDIALOGD_APP
5
+
6
+#include <sys/types.h>
7
+#include <sys/stat.h>
8
+#include <stdlib.h>
9
+#include <unistd.h>
10
+#include <fcntl.h>
11
+#include <errno.h>
12
+#include <time.h>
13
+#include "config.h"
14
+
15
+#ifdef __KDIALOGD_H__
16
+#include <kstandarddirs.h>
17
+#endif
18
+
19
+typedef enum
20
+{
21
+    OP_NULL                = 0,
22
+    OP_FILE_OPEN           = 1,
23
+    OP_FILE_OPEN_MULTIPLE  = 2,
24
+    OP_FILE_SAVE           = 3,
25
+    OP_FOLDER              = 4
26
+} Operation;
27
+
28
+#define PID_DIR  "kde-"
29
+#define PID_NAME "kdialogd.pid"
30
+
31
+static const char * getPidFileName()
32
+{
33
+    static char *pidfile=NULL;
34
+
35
+    if(!pidfile)
36
+    {
37
+        char *user=getenv("USER");
38
+
39
+        if(!user)
40
+            user=getenv("LOGNAME");
41
+
42
+        if(user)
43
+        {
44
+            char *tmp=getenv("KDETMP");
45
+
46
+            if(!tmp || !tmp[0])
47
+                tmp=getenv("TMPDIR");
48
+
49
+            if(!tmp || !tmp[0])
50
+                tmp=(char *)"/tmp";
51
+
52
+            pidfile=(char *)malloc(strlen(tmp)+strlen(PID_DIR)+strlen(user)+strlen(PID_NAME)+1);
53
+            pidfile=(char *)malloc(strlen(tmp)+strlen("/")+strlen(PID_DIR)+strlen(user)+strlen("/")+strlen(PID_NAME)+1);
54
+
55
+#ifdef __KDIALOGD_H__
56
+            // We are kdialogd - so create socket folder if it does not exist...
57
+            sprintf(pidfile, "%s/%s%s", tmp, PID_DIR, user);
58
+            KStandardDirs::makeDir(QString::fromAscii(pidfile));
59
+#endif
60
+
61
+            /* CPD: TODO get dispaly number! */
62
+            sprintf(pidfile, "%s/%s%s/%s", tmp, PID_DIR, user, PID_NAME);
63
+        }
64
+    }
65
+
66
+    return pidfile;
67
+}
68
+
69
+#define SOCK_DIR  "ksocket-"
70
+#define SOCK_NAME "kdialogd"
71
+
72
+static const char * getSockName()
73
+{
74
+    static char *sock=NULL;
75
+
76
+    if(!sock)
77
+    {
78
+        char *user=getenv("USER");
79
+
80
+        if(!user)
81
+            user=getenv("LOGNAME");
82
+
83
+        if(user)
84
+        {
85
+            char *tmp=getenv("KDETMP");
86
+
87
+            if(!tmp || !tmp[0])
88
+                tmp=getenv("TMPDIR");
89
+
90
+            if(!tmp || !tmp[0])
91
+                tmp=(char *)"/tmp";
92
+
93
+            sock=(char *)malloc(strlen(tmp)+strlen("/")+strlen(SOCK_DIR)+strlen(user)+strlen("/")+strlen(SOCK_NAME)+strlen("18446744073709551616")+1);
94
+
95
+#ifdef __KDIALOGD_H__
96
+            // We are kdialogd - so create socket folder if it does not exist...
97
+            sprintf(sock, "%s/%s%s", tmp, SOCK_DIR, user);
98
+            KStandardDirs::makeDir(QString::fromAscii(sock));
99
+#endif
100
+
101
+            /* CPD: TODO get dispaly number! */
102
+            sprintf(sock, "%s/%s%s/%s-%d", tmp, SOCK_DIR, user, SOCK_NAME, 1); 
103
+        }
104
+    }
105
+
106
+    return sock;
107
+}
108
+
109
+static int readBlock(int fd, char* pData, int size)
110
+{
111
+    int bytesToRead=size;
112
+
113
+    do
114
+    {
115
+        fd_set fdSet;
116
+
117
+        FD_ZERO(&fdSet);
118
+        FD_SET(fd, &fdSet);
119
+
120
+        if(select(fd + 1, &fdSet, NULL, NULL, NULL)<0)
121
+            return 0;
122
+
123
+        if(FD_ISSET(fd, &fdSet))
124
+        {
125
+            int bytesRead=read(fd, &pData[size-bytesToRead], bytesToRead);
126
+
127
+            if (bytesRead>0)
128
+                bytesToRead-=bytesRead;
129
+            else
130
+                return 0;
131
+        }
132
+    }
133
+    while(bytesToRead>0);
134
+
135
+    return 1;
136
+}
137
+
138
+static int writeBlock(int fd, const char *pData, int size)
139
+{
140
+    int bytesToWrite=size;
141
+
142
+    do
143
+    {
144
+        fd_set fdSet;
145
+
146
+        FD_ZERO(&fdSet);
147
+        FD_SET(fd, &fdSet);
148
+
149
+        if(select(fd + 1, NULL, &fdSet, NULL, NULL)<0)
150
+            return 0;
151
+
152
+        if(FD_ISSET(fd, &fdSet))
153
+        {
154
+            int bytesWritten=write(fd, (char *)&pData[size-bytesToWrite], bytesToWrite);
155
+
156
+            if (bytesWritten>0)
157
+                bytesToWrite-=bytesWritten;
158
+            else
159
+                return 0;
160
+        }
161
+    }
162
+    while(bytesToWrite>0);
163
+
164
+    return 1;
165
+}
166
+
167
+#ifdef KDIALOGD_APP
168
+/*
169
+    So that kdailogd can terminate when the last app exits, need a way of synchronising the Gtk/Qt
170
+    apps that may wish to connect, and the removal of the socket.
171
+
172
+    To this en, a lockfile is created,and used to guard around the critical sections
173
+*/
174
+static int lockFd=-1;
175
+
176
+#define LOCK_EXT ".lock"
177
+
178
+const char * getLockName()
179
+{
180
+    static char *lockName=NULL;
181
+
182
+    if(!lockName)
183
+    {
184
+        const char *sock=getSockName();
185
+
186
+        if(sock)
187
+        {
188
+            lockName=(char *)malloc(strlen(sock)+strlen(LOCK_EXT)+1);
189
+            sprintf(lockName, "%s%s", sock, LOCK_EXT);
190
+        }
191
+    }
192
+
193
+    return lockName;
194
+}
195
+
196
+/* Lock is stale if it does not exist or is older than 2 seconds */
197
+static int isStale(const char *fname)
198
+{
199
+    struct stat stat_buf;
200
+
201
+    return 0!=stat(fname, &stat_buf) ||
202
+           abs(stat_buf.st_mtime-time(NULL))>2;
203
+}
204
+
205
+static int grabLock(int tries)
206
+{
207
+    do
208
+    {
209
+        lockFd=open(getLockName(), O_WRONLY | O_CREAT | O_EXCL, 0777);
210
+        if (lockFd<0 && errno==EEXIST)
211
+        {
212
+            /* Hmm, lock file already exists. Is it stale? */
213
+            if(isStale(getLockName()))
214
+            {
215
+                tries++;  /* Increment tries so that we try again... */
216
+                unlink(getLockName());
217
+            }
218
+            else if(tries)
219
+                usleep(100000);
220
+        }
221
+    }
222
+    while(lockFd<0 && --tries);
223
+
224
+    return lockFd;
225
+}
226
+
227
+static void releaseLock()
228
+{
229
+    if(lockFd>0)
230
+    {
231
+        close(lockFd);
232
+        unlink(getLockName());
233
+    }
234
+}
235
+#endif
236
+
237
+#endif

+ 311
- 0
common/connect.h View File

@@ -0,0 +1,311 @@
1
+#ifndef __CONNECT_H__
2
+#define __CONNECT_H__
3
+
4
+#include <string.h>
5
+#include <errno.h>
6
+#include <signal.h>
7
+#include <sys/wait.h>
8
+#include "config.h"
9
+#include <errno.h>
10
+#include <sys/types.h>
11
+#include <sys/socket.h>
12
+#include <sys/un.h>
13
+#include <sys/stat.h>
14
+
15
+#ifndef SUN_LEN
16
+#define SUN_LEN(ptr) ((socklen_t) (((struct sockaddr_un *) 0)->sun_path) \
17
+                     + strlen ((ptr)->sun_path))
18
+#endif
19
+
20
+#include "common.h"
21
+#include "config.h"
22
+
23
+#ifdef __cplusplus
24
+typedef bool     kgtk_bool;
25
+#define KGTK_TRUE true
26
+#define KGTK_FALSE false
27
+#else
28
+typedef gboolean kgtk_bool;
29
+#define KGTK_TRUE TRUE
30
+#define KGTK_FALSE FALSE
31
+#endif
32
+
33
+
34
+static int kdialogdSocket=-1;
35
+
36
+/* From kdelibs/kdesu */
37
+#ifdef KDIALOGD_APP
38
+static int createSocketConnectionReal()
39
+#else
40
+static int createSocketConnection()
41
+#endif
42
+{
43
+#ifdef KGTK_DEBUG
44
+    printf("KGTK::createSocketConnection A\n");
45
+#endif
46
+    int sockfd=-1;
47
+    const char *sock=getSockName();
48
+    struct sockaddr_un addr;
49
+
50
+    if (access(sock, R_OK|W_OK))
51
+    {
52
+#ifdef KGTK_DEBUG
53
+        printf("KGTK::createSocketConnection - Could not access socket, %s\n", sock);
54
+#endif
55
+        return -1;
56
+    }
57
+
58
+    sockfd = socket(PF_UNIX, SOCK_STREAM, 0);
59
+    if (sockfd < 0)
60
+    {
61
+#ifdef KGTK_DEBUG
62
+        printf("KGTK::createSocketConnection - Could not create socket, %d\n", errno);
63
+#endif
64
+        return -1;
65
+    }
66
+    addr.sun_family = AF_UNIX;
67
+    strcpy(addr.sun_path, sock);
68
+
69
+    if (connect(sockfd, (struct sockaddr *) &addr, SUN_LEN(&addr)) < 0)
70
+    {
71
+#ifdef KGTK_DEBUG
72
+        printf("KGTK::createSocketConnection - Could not connect socket, %d\n", errno);
73
+#endif
74
+        close(sockfd);
75
+        return -1;
76
+    }
77
+
78
+#if !defined(SO_PEERCRED) || !defined(HAVE_STRUCT_UCRED)
79
+# if defined(HAVE_GETPEEREID)
80
+    {
81
+    uid_t euid;
82
+    gid_t egid;
83
+    /* Security: if socket exists, we must own it */
84
+    if (getpeereid(sockfd, &euid, &egid) == 0)
85
+    {
86
+       if (euid != getuid())
87
+       {
88
+#ifdef KGTK_DEBUG
89
+            printf("KGTK::createSocketConnection - socket not owned by me! socket uid %d\n", euid);
90
+#endif
91
+            close(sockfd);
92
+            return -1;
93
+       }
94
+    }
95
+    }
96
+# else
97
+#  ifdef __GNUC__
98
+#   warning "Using sloppy security checks"
99
+#  endif
100
+    /* We check the owner of the socket after we have connected.
101
+       If the socket was somehow not ours an attacker will be able
102
+       to delete it after we connect but shouldn't be able to
103
+       create a socket that is owned by us. */
104
+    {
105
+    struct stat s;
106
+    if (lstat(sock, &s)!=0)
107
+    {
108
+#ifdef KGTK_DEBUG
109
+        printf("KGTK::createSocketConnection - stat failed %s\n", sock);
110
+#endif
111
+        close(sockfd);
112
+        return -1;
113
+    }
114
+    if (s.st_uid != getuid())
115
+    {
116
+#ifdef KGTK_DEBUG
117
+        printf("KGTK::createSocketConnection - socket not owned by me! socket uid %d\n", s.st_uid);
118
+#endif
119
+        close(sockfd);
120
+        return -1;
121
+    }
122
+    if (!S_ISSOCK(s.st_mode))
123
+    {
124
+#ifdef KGTK_DEBUG
125
+        printf("KGTK::createSocketConnection - socket is not a socket %s\n", sock);
126
+#endif
127
+        close(sockfd);
128
+        return -1;
129
+    }
130
+    }
131
+# endif
132
+#else
133
+    {
134
+    struct ucred cred;
135
+    socklen_t siz = sizeof(cred);
136
+
137
+    /* Security: if socket exists, we must own it */
138
+    if (getsockopt(sockfd, SOL_SOCKET, SO_PEERCRED, &cred, &siz) == 0)
139
+    {
140
+        if (cred.uid != getuid())
141
+        {
142
+#ifdef KGTK_DEBUG
143
+            printf("KGTK::createSocketConnection - socket not owned by me! socket uid %d\n", cred.uid);
144
+#endif
145
+            close(sockfd);
146
+            return -1;
147
+        }
148
+    }
149
+    }
150
+#endif
151
+
152
+#ifdef KGTK_DEBUG
153
+    printf("KGTK::createSocketConnection - sockfd:%d\n", sockfd);
154
+#endif
155
+    return sockfd;
156
+}
157
+
158
+#ifdef KDIALOGD_APP
159
+static int createSocketConnection()
160
+{
161
+    int rv=-1,
162
+        tries=0;
163
+
164
+    do
165
+    {
166
+        if(-1==(rv=createSocketConnectionReal()))
167
+            usleep(10000);
168
+    }
169
+    while(-1==rv && ++tries<50);
170
+
171
+    if(-1==rv)
172
+        fprintf(stderr, "ERROR: Could not talk to KDialogD!!!\n");
173
+    return rv;
174
+}
175
+#endif
176
+
177
+static int kdialogdPid=-1;
178
+
179
+static kgtk_bool processIsRunning()
180
+{
181
+#ifdef KGTK_DEBUG
182
+    printf("KGTK::processIsRunning\n");
183
+#endif
184
+
185
+    if(-1!=kdialogdPid && 0==kill(kdialogdPid, 0))
186
+    {
187
+#ifdef KGTK_DEBUG
188
+        printf("KGTK::processIsRunning (%d) YES\n", kdialogdPid);
189
+#endif
190
+        return KGTK_TRUE;
191
+    }
192
+    else
193
+    {
194
+        FILE *f=fopen(getPidFileName(), "r");
195
+
196
+        if(f)
197
+        {
198
+            int pid=0;
199
+
200
+            if(1==fscanf(f, "%d", &pid))
201
+            {
202
+                fclose(f);
203
+
204
+                if(-1!=kdialogdPid && kdialogdPid!=pid)
205
+                {
206
+#ifdef KGTK_DEBUG
207
+                    printf("KGTK::processIsRunning pid has changed from:%d to %d - need to reconnect\n", kdialogdPid, pid);
208
+#endif
209
+                    kdialogdPid=pid;
210
+                    return KGTK_FALSE;
211
+                }
212
+#ifdef KGTK_DEBUG
213
+                printf("KGTK::processIsRunning file has pid:%d\n", pid);
214
+#endif
215
+                if(0==kill(pid, 0))
216
+                {
217
+#ifdef KGTK_DEBUG
218
+                    printf("KGTK::processIsRunning (file:%d) YES\n", pid);
219
+#endif
220
+                    kdialogdPid=pid;
221
+                    return KGTK_TRUE;
222
+                }
223
+
224
+                kdialogdPid=-1; /* Process is not running! */
225
+            }
226
+        }
227
+    }
228
+#ifdef KGTK_DEBUG
229
+    printf("KGTK::processIsRunning NO\n");
230
+#endif
231
+    return KGTK_FALSE;
232
+}
233
+
234
+static void closeConnection()
235
+{
236
+#ifdef KGTK_DEBUG
237
+        printf("KGTK::closeConnection\n");
238
+#endif
239
+    close(kdialogdSocket);
240
+    kdialogdSocket=-1;
241
+}
242
+
243
+/* Note: Calling 'fork' seems to mess things up with eclipse! */
244
+#define KGTK_USE_SYSTEM_CALL
245
+
246
+static kgtk_bool connectToKDialogD(const char *appName)
247
+{
248
+#ifdef KGTK_DEBUG
249
+    printf("KGTK::connectToKDialogD %s\n", appName ? appName : "<null>");
250
+#endif
251
+    if(!processIsRunning())
252
+        closeConnection();
253
+
254
+    if(-1!=kdialogdSocket)
255
+        return KGTK_TRUE;
256
+    else
257
+    {
258
+        unsigned int slen=strlen(appName);
259
+        kgtk_bool    rv=KGTK_TRUE;
260
+
261
+        if(slen)
262
+            slen++;
263
+
264
+#ifdef KGTK_DEBUG
265
+        printf("KGTK::connectToKDialogD - start wrapper\n");
266
+#endif
267
+
268
+#ifdef KDIALOGD_APP
269
+        grabLock(5);
270
+#ifdef KGTK_USE_SYSTEM_CALL
271
+        system("kdialogd-wrapper &");
272
+#else
273
+        switch(fork())
274
+        {
275
+            case -1:
276
+                rv=KGTK_FALSE;
277
+                printf("ERROR: Could not start fork :-(\n");
278
+                break;
279
+            case 0:
280
+                execl(KDIALOGD_LOCATION"/kdialogd-wrapper", "kdialogd-wrapper", (char *)NULL);
281
+                break;
282
+            default:
283
+            {
284
+                int status=0;
285
+                wait(&status);
286
+            }
287
+        }
288
+#endif
289
+        releaseLock();
290
+#endif
291
+
292
+        if(!rv)
293
+            return rv;
294
+
295
+        rv=
296
+#ifdef KDIALOGD_APP
297
+           grabLock(3)>0 &&
298
+#else
299
+           0==system("dcop kded kded loadModule kdialogd") &&
300
+#endif
301
+           -1!=(kdialogdSocket=createSocketConnection()) &&
302
+           writeBlock(kdialogdSocket, (char *)&slen, 4) &&
303
+           (0==slen || writeBlock(kdialogdSocket, appName, slen));
304
+#ifdef KDIALOGD_APP
305
+        releaseLock();
306
+#endif
307
+        return rv;
308
+    }
309
+}
310
+
311
+#endif

+ 11
- 0
config.h.cmake View File

@@ -0,0 +1,11 @@
1
+/* Define to 1 if you have the `getpeereid' function. */
2
+#cmakedefine HAVE_GETPEEREID 1
3
+
4
+/* Define if you have the struct ucred */
5
+#cmakedefine HAVE_STRUCT_UCRED 1
6
+#cmakedefine HAVE_DLVSYM 1
7
+
8
+#define VERSION "@KGTK_VERSION_FULL@"
9
+
10
+#define KGTK_DLSYM_VERSION "@KGTK_DLSYM_VERSION@"
11
+

+ 86
- 0
debian/cdbs/buildvars.mk View File

@@ -0,0 +1,86 @@
1
+# -*- mode: makefile; coding: utf-8 -*-
2
+# Copyright © 2002,2003 Colin Walters <walters@debian.org>
3
+# Description: Defines some useful variables, but no rules
4
+#
5
+# This program is free software; you can redistribute it and/or
6
+# modify it under the terms of the GNU General Public License as
7
+# published by the Free Software Foundation; either version 2, or (at
8
+# your option) any later version.
9
+#
10
+# This program is distributed in the hope that it will be useful, but
11
+# WITHOUT ANY WARRANTY; without even the implied warranty of
12
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+# General Public License for more details.
14
+#
15
+# You should have received a copy of the GNU General Public License
16
+# along with this program; if not, write to the Free Software
17
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18
+# 02111-1307 USA.
19
+
20
+_cdbs_scripts_path ?= /usr/lib/cdbs
21
+_cdbs_rules_path ?= /usr/share/cdbs/1/rules
22
+_cdbs_class_path ?= /usr/share/cdbs/1/class
23
+
24
+ifndef _cdbs_rules_buildvars
25
+_cdbs_rules_buildvars = 1
26
+
27
+CDBS_VERSION = something
28
+
29
+# Common useful variables
30
+DEB_SOURCE_PACKAGE := $(strip $(shell egrep '^Source: ' debian/control | cut -f 2 -d ':'))
31
+DEB_VERSION := $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
32
+DEB_NOEPOCH_VERSION := $(shell echo $(DEB_VERSION) | cut -d: -f2-)
33
+DEB_UPSTREAM_VERSION := $(shell echo $(DEB_NOEPOCH_VERSION) | sed 's/-[^-]*$$//')
34
+DEB_ISNATIVE := $(shell dpkg-parsechangelog | egrep '^Version:' | perl -ne 'print if not /^Version:\s*.*-/;')
35
+
36
+# Split into arch/indep packages
37
+ifneq ($(DEB_INDEP_PACKAGES),cdbs)
38
+DEB_INDEP_PACKAGES := $(filter-out $(DONT_BUILD), $(strip $(shell $(_cdbs_scripts_path)/list-packages indep)))
39
+DEB_ARCH_PACKAGES := $(filter-out $(DONT_BUILD), $(filter-out $(DEB_INDEP_PACKAGES),$(strip $(shell $(_cdbs_scripts_path)/list-packages same))))
40
+endif
41
+# Split into normal and udeb packages
42
+ifeq ($(DEB_UDEB_PACKAGES),)
43
+DEB_PACKAGES = $(filter-out $(DONT_BUILD), $(filter-out %-udeb, $(DEB_ARCH_PACKAGES) $(DEB_INDEP_PACKAGES)))
44
+DEB_UDEB_PACKAGES = $(filter-out $(DONT_BUILD),$(filter %-udeb, $(DEB_ARCH_PACKAGES) $(DEB_INDEP_PACKAGES)))
45
+else
46
+DEB_PACKAGES = $(filter-out $(DONT_BUILD), $(filter-out $(DEB_UDEB_PACKAGES), $(DEB_ARCH_PACKAGES) $(DEB_INDEP_PACKAGES)))
47
+endif
48
+# Too much bother for now.  If someone complains we'll fix it.
49
+#DEB_ARCH_UDEB_PACKAGES = $(filter %-udeb, $(DEB_ARCH_PACKAGES))
50
+#DEB_INDEP_UDEB_PACKAGES = $(filter %-udeb, $(DEB_INDEP_PACKAGES))
51
+# A handy list of every package, udeb or not
52
+DEB_ALL_PACKAGES = $(filter-out $(DONT_BUILD),$(DEB_PACKAGES) $(DEB_UDEB_PACKAGES))
53
+DEB_INDEP_REGULAR_PACKAGES = $(filter-out $(DONT_BUILD), $(filter-out $(DEB_UDEB_PACKAGES),$(DEB_INDEP_PACKAGES)))
54
+DEB_ARCH_REGULAR_PACKAGES = $(filter-out $(DONT_BUILD), $(filter-out $(DEB_UDEB_PACKAGES),$(DEB_ARCH_PACKAGES)))
55
+
56
+DEB_DBG_PACKAGES = $(filter-out $(DONT_BUILD), $(filter %-dbg, $(DEB_ARCH_PACKAGES) $(DEB_INDEP_PACKAGES)))
57
+
58
+# Some support for srcdir != builddir builds.
59
+# These are relative to the root of the package
60
+DEB_SRCDIR ?= .
61
+DEB_BUILDDIR ?= $(strip $(DEB_SRCDIR))
62
+
63
+# Miscellaneous bits
64
+DEB_ARCH = $(shell dpkg --print-architecture)
65
+DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
66
+DEB_HOST_GNU_SYSTEM ?= $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM)
67
+DEB_HOST_GNU_CPU ?= $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
68
+DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
69
+DEB_HOST_ARCH_CPU ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)
70
+DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
71
+DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
72
+DEB_BUILD_GNU_SYSTEM ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_SYSTEM)
73
+DEB_BUILD_GNU_CPU ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_CPU)
74
+DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
75
+DEB_BUILD_ARCH_CPU ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH_CPU)
76
+DEB_BUILD_ARCH_OS ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS)
77
+
78
+ifeq ($(words $(DEB_ALL_PACKAGES)),1)
79
+	DEB_DESTDIR = $(CURDIR)/debian/$(strip $(DEB_ALL_PACKAGES))/
80
+else
81
+	DEB_DESTDIR = $(CURDIR)/debian/tmp/
82
+endif
83
+
84
+CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), cdbs (>= 0.4.23-1.1)
85
+
86
+endif

+ 109
- 0
debian/cdbs/debian-qt-kde.mk View File

@@ -0,0 +1,109 @@
1
+ifndef _cdbs_bootstrap
2
+_cdbs_scripts_path ?= /usr/lib/cdbs
3
+_cdbs_rules_path ?= /usr/share/cdbs/1/rules
4
+_cdbs_class_path ?= /usr/share/cdbs/1/class
5
+endif
6
+
7
+ifndef _cdbs_class_debian-qt-kde
8
+_cdbs_class_debian-qt-kde := 1
9
+
10
+# Note: This _must_ be included before autotools.mk, or it won't work.
11
+common-configure-arch common-configure-indep:: debian/stamp-cvs-make
12
+debian/stamp-cvs-make:
13
+	cp -Rp /usr/share/aclocal/libtool.m4 admin/libtool.m4.in
14
+	cp -Rp /usr/share/libtool/config/ltmain.sh admin/ltmain.sh
15
+	$(MAKE) -C $(DEB_SRCDIR) -f admin/Makefile.common dist;
16
+	touch debian/stamp-cvs-make
17
+
18
+include debian/cdbs/kde.mk$(_cdbs_makefile_suffix)
19
+include debian/cdbs/uploaders.mk
20
+
21
+DEB_PATCHDIRS := debian/patches/common debian/patches
22
+
23
+DEB_KDE_ENABLE_FINAL := yes
24
+DEB_INSTALL_DOCS_ALL :=
25
+
26
+DEB_DH_MAKESHLIBS_ARGS_ALL := -V
27
+DEB_SHLIBDEPS_INCLUDE = $(foreach p,$(PACKAGES_WITH_LIBS),debian/$(p)/usr/lib)
28
+
29
+ifeq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
30
+    cdbs_treat_me_gently_arches := arm m68k alpha ppc64 armel armeb
31
+    ifeq (,$(filter $(DEB_HOST_ARCH_CPU),$(cdbs_treat_me_gently_arches)))
32
+        cdbs_kde_enable_final = $(if $(DEB_KDE_ENABLE_FINAL),--enable-final,)
33
+    else
34
+        cdbs_kde_enable_final =
35
+    endif
36
+endif
37
+
38
+common-build-arch:: debian/stamp-man-pages
39
+debian/stamp-man-pages:
40
+	if ! test -d debian/man/out; then mkdir -p debian/man/out; fi
41
+	for f in $$(find debian/man -name '*.sgml'); do \
42
+		docbook-to-man $$f > debian/man/out/`basename $$f .sgml`.1; \
43
+	done
44
+	for f in $$(find debian/man -name '*.man'); do \
45
+		soelim -I debian/man $$f \
46
+		> debian/man/out/`basename $$f .man`.`head -n1 $$f | awk '{print $$NF}'`; \
47
+	done
48
+	touch debian/stamp-man-pages
49
+
50
+common-binary-indep::
51
+	( set -e; \
52
+	tmpf=`mktemp debian/versions.XXXXXX`; \
53
+	perl debian/cdbs/versions.pl >$$tmpf; \
54
+	for p in $(DEB_INDEP_PACKAGES); do \
55
+	    cat $$tmpf >>debian/$$p.substvars; \
56
+	done; \
57
+	rm -f $$tmpf )
58
+
59
+common-binary-arch::
60
+	( set -e; \
61
+	tmpf=`mktemp debian/versions.XXXXXX`; \
62
+	perl debian/cdbs/versions.pl >$$tmpf; \
63
+	for p in $(DEB_ARCH_PACKAGES); do \
64
+	    cat $$tmpf >>debian/$$p.substvars; \
65
+	done; \
66
+	rm -f $$tmpf )
67
+
68
+clean::
69
+	rm -rf debian/man/out
70
+	-rmdir debian/man
71
+	rm -f debian/stamp-man-pages
72
+	rm -rf debian/shlibs-check
73
+
74
+$(patsubst %,binary-install/%,$(DEB_PACKAGES)) :: binary-install/%:
75
+	if test -x /usr/bin/dh_desktop; then dh_desktop -p$(cdbs_curpkg) $(DEB_DH_DESKTOP_ARGS); fi
76
+	if test -e debian/$(cdbs_curpkg).lintian; then \
77
+		install -p -D -m644 debian/$(cdbs_curpkg).lintian \
78
+			debian/$(cdbs_curpkg)/usr/share/lintian/overrides/$(cdbs_curpkg); \
79
+	fi
80
+	if test -e debian/$(cdbs_curpkg).presubj; then \
81
+		install -p -D -m644 debian/$(cdbs_curpkg).presubj \
82
+			debian/$(cdbs_curpkg)/usr/share/bug/$(cdbs_curpkg)/presubj; \
83
+	fi
84
+
85
+binary-install/$(DEB_SOURCE_PACKAGE)-doc-html::
86
+	set -e; \
87
+	for doc in `cd $(DEB_DESTDIR)/opt/kde3/share/doc/kde/HTML/en; find . -name index.docbook`; do \
88
+		pkg=$${doc%/index.docbook}; pkg=$${pkg#./}; \
89
+		echo Building $$pkg HTML docs...; \
90
+		mkdir -p $(CURDIR)/debian/$(DEB_SOURCE_PACKAGE)-doc-html/opt/kde3/share/doc/kde/HTML/en/$$pkg; \
91
+		cd $(CURDIR)/debian/$(DEB_SOURCE_PACKAGE)-doc-html/opt/kde3/share/doc/kde/HTML/en/$$pkg; \
92
+		/opt/kde3/bin/meinproc $(DEB_DESTDIR)/opt/kde3/share/doc/kde/HTML/en/$$pkg/index.docbook; \
93
+	done
94
+	for pkg in $(DOC_HTML_PRUNE) ; do \
95
+	  rm -rf debian/$(DEB_SOURCE_PACKAGE)-doc-html/opt/kde3/share/doc/kde/HTML/en/$$pkg; \
96
+	done
97
+
98
+clean::
99
+	if test -n "$(DEB_KDE_CVS_MAKE)" && test -d $(DEB_SRCDIR); then \
100
+		cd $(DEB_SRCDIR); \
101
+		find . -name Makefile.in -print | \
102
+			xargs --no-run-if-empty rm -f; \
103
+		rm -f Makefile.am acinclude.m4 aclocal.m4 config.h.in \
104
+			configure configure.files configure.in stamp-h.in \
105
+			subdirs; \
106
+	fi
107
+	rm -f debian/stamp-cvs-make
108
+
109
+endif

+ 97
- 0
debian/cdbs/kde.mk View File

@@ -0,0 +1,97 @@
1
+# -*- mode: makefile; coding: utf-8 -*-
2
+# Copyright © 2003 Christopher L Cheney <ccheney@debian.org>
3
+# Description: A class for KDE packages; sets KDE environment variables, etc
4
+#
5
+# This program is free software; you can redistribute it and/or
6
+# modify it under the terms of the GNU General Public License as
7
+# published by the Free Software Foundation; either version 2, or (at
8
+# your option) any later version.
9
+#
10
+# This program is distributed in the hope that it will be useful, but
11
+# WITHOUT ANY WARRANTY; without even the implied warranty of
12
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+# General Public License for more details.
14
+#
15
+# You should have received a copy of the GNU General Public License
16
+# along with this program; if not, write to the Free Software
17
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18
+# 02111-1307 USA.
19
+
20
+_cdbs_scripts_path ?= /usr/lib/cdbs
21
+_cdbs_rules_path ?= /usr/share/cdbs/1/rules
22
+_cdbs_class_path ?= /usr/share/cdbs/1/class
23
+
24
+ifndef _cdbs_class_kde
25
+_cdbs_class_kde := 1
26
+
27
+# for dh_icons
28
+CDBS_BUILD_DEPENDS   := $(CDBS_BUILD_DEPENDS), debhelper (>= 5.0.7ubuntu4)
29
+
30
+include $(_cdbs_rules_path)/buildcore.mk$(_cdbs_makefile_suffix)
31
+
32
+ifdef _cdbs_tarball_dir
33
+DEB_BUILDDIR = $(_cdbs_tarball_dir)/obj-$(DEB_BUILD_GNU_TYPE)
34
+else
35
+DEB_BUILDDIR = obj-$(DEB_BUILD_GNU_TYPE)
36
+endif
37
+
38
+include $(_cdbs_class_path)/autotools.mk$(_cdbs_makefile_suffix)
39
+
40
+export kde_cgidir  = \$${libdir}/cgi-bin
41
+export kde_confdir = \$${sysconfdir}/kde3
42
+export kde_htmldir = \$${datadir}/doc/kde/HTML
43
+
44
+ifeq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
45
+	cdbs_kde_enable_final = $(if $(DEB_KDE_ENABLE_FINAL),--enable-final,)
46
+endif
47
+
48
+ifneq (,$(filter nostrip,$(DEB_BUILD_OPTIONS)))
49
+	cdbs_kde_enable_final =
50
+	cdbs_kde_enable_debug = --enable-debug=yes
51
+else
52
+	cdbs_kde_enable_debug = --disable-debug
53
+endif
54
+
55
+ifneq (,$(filter debug,$(DEB_BUILD_OPTIONS)))
56
+	cdbs_kde_enable_debug = --enable-debug=full
57
+endif
58
+
59
+cdbs_configure_flags += --with-qt-dir=/usr/share/qt3 --disable-rpath --with-xinerama $(cdbs_kde_enable_final) $(cdbs_kde_enable_debug)
60
+
61
+DEB_AC_AUX_DIR = $(DEB_SRCDIR)/admin
62
+DEB_CONFIGURE_INCLUDEDIR = "\$${prefix}/include/kde"
63
+DEB_COMPRESS_EXCLUDE = .dcl .docbook -license .tag .sty .el
64
+
65
+$(patsubst %,binary-install/%,$(DEB_PACKAGES)) :: binary-install/%:
66
+	if test -x /usr/bin/dh_icons; then dh_icons -p$(cdbs_curpkg) $(DEB_DH_ICONCACHE_ARGS); fi
67
+
68
+cleanbuilddir::
69
+	-$(if $(call cdbs_streq,$(DEB_BUILDDIR),$(DEB_SRCDIR)),,rm -rf $(DEB_BUILDDIR))
70
+
71
+common-build-arch common-build-indep:: debian/stamp-kde-apidox
72
+debian/stamp-kde-apidox:
73
+	$(if $(DEB_KDE_APIDOX),+$(DEB_MAKE_INVOKE) apidox)
74
+	touch $@
75
+
76
+common-install-prehook-impl::
77
+	mkdir -p po
78
+	-XGETTEXT=/usr/bin/kde-xgettext EXTRACTATTR=/opt/kde3/bin/extractattr sh $(DEB_SRCDIR)/admin/cvs.sh extract-messages	
79
+	-for file in po/*pot; do \
80
+		sed "s/charset=CHARSET/charset=UTF-8/" -i $$file; \
81
+	done
82
+
83
+common-install-arch common-install-indep:: common-install-kde-apidox
84
+common-install-kde-apidox::
85
+	$(if $(DEB_KDE_APIDOX),+$(DEB_MAKE_INVOKE) install-apidox DESTDIR=$(DEB_DESTDIR))
86
+
87
+clean::
88
+	rm -f debian/stamp-kde-apidox
89
+	rm -rf po/*.pot
90
+
91
+# This is a convenience target for calling manually.  It's not part of
92
+# the build process.
93
+buildprep: clean apply-patches
94
+	$(MAKE) -f admin/Makefile.common dist
95
+	debian/rules clean
96
+
97
+endif

+ 16
- 0
debian/cdbs/team-members View File

@@ -0,0 +1,16 @@
1
+Sune Vuorela <debian@pusling.com>
2
+Ana Beatriz Guerrero Lopez <ana@debian.org>
3
+Fathi Boudra <fboudra@free.fr>
4
+Modestas Vainius <geromanas@mailas.com>
5
+Josh Metzler <joshdeb@metzlers.org>
6
+Isaac Clerencia <isaac@debian.org>
7
+Adeodato Simó <dato@net.com.org.es>
8
+Adeodato Simo <dato@net.com.org.es>
9
+Christopher Martin <chrsmrtn@debian.org>
10
+Daniel Schepler <schepler@debian.org>
11
+Sarah Hobbs <hobbsee@ubuntu.com>
12
+Nacho Barrientos Arias <nacho@debian.org>
13
+Ricardo Javier Cardenes Medina <rcardenes@debian.org>
14
+Ricardo Cardenes <rcardenes@debian.org>
15
+Armin Berres <trigger+debian@space-based.de>
16
+Francesco Pedrini <francesco.pedrini@gmail.com>

+ 29
- 0
debian/cdbs/uploaders.mk View File

@@ -0,0 +1,29 @@
1
+
2
+MAINTAINER=Debian Qt/KDE Maintainers <debian-qt-kde@lists.debian.org>
3
+UPLOADERS=$(shell grep -e +++ -e "^ -- " debian/changelog  | grep -v "debian-qt-kde@lists.debian.org" | head -13 | /bin/sed 's/^\s*//;s/\s*$$//;s/^+++\? Changes by //;s/^+++\? //;s/-- //;s/:$$//;s/ <.*//' | sort -u | while read line ; do grep "$$line" debian/cdbs/team-members ; done | tr "\n" ", " | sed 's/,/, /g;s/, $$//')
4
+
5
+
6
+debian/control.tmp:
7
+	@if [ ! -e debian/control.in ] ; then  \
8
+		echo "this package is not yet prepared for using automatic update of uploaders"; \
9
+		echo "Please do so."; \
10
+		exit 1; \
11
+	fi
12
+	@sed  's/@@@UPLOADERS@@@/$(UPLOADERS)/;s#@@@MAINTAINER@@@#$(MAINTAINER)#' debian/control.in  > debian/control.tmp
13
+
14
+check-uploaders: debian/control.tmp
15
+	@if ! diff -q debian/control debian/control.tmp ; then \
16
+		echo "WARNING:: Control file differs from manually generated one" ; \
17
+		echo "WARNING:: Please update it manually and check it afterwards" ; \
18
+		echo "WARNING:: Uploaders are updated by debian/rules update-uploaders" ;\
19
+		echo "WARNING:: If this is a binNMU, NMU or security upload, just ignore" ;\
20
+	fi
21
+	
22
+
23
+clean:: 
24
+	rm -f debian/control.tmp
25
+
26
+update-uploaders: debian/control.tmp
27
+	@mv -f debian/control.tmp debian/control
28
+
29
+makebuilddir:: check-uploaders

+ 19
- 0
debian/cdbs/versions.pl View File

@@ -0,0 +1,19 @@
1
+#!/usr/bin/env perl
2
+
3
+use strict;
4
+use warnings;
5
+
6
+my $version = `dpkg-parsechangelog | awk '/^Version/ {print \$2}'`;
7
+my ($version3, $version3_next);
8
+my ($version2, $version2_next);
9
+
10
+($version3 = $version)  =~ s/-[^-]+$//;
11
+($version2 = $version3) =~ s/\.[^.]+$//;
12
+
13
+($version3_next = $version3) =~ s/(?<=\.)(\d+)[a-z]?$/($1+1)/e;
14
+($version2_next = $version2) =~ s/(?<=\.)(\d+)$/($1+1)/e;
15
+
16
+print "KDE-Version3=$version3\n";
17
+print "KDE-Version2=$version2\n";
18
+print "KDE-Next-Version3=$version3_next\n";
19
+print "KDE-Next-Version2=$version2_next\n";

+ 11
- 0
debian/changelog View File

@@ -0,0 +1,11 @@
1
+kgtk-qt3-kde3 (0.10.2-0ubuntu5) maverick; urgency=low
2
+
3
+  * Maverick build
4
+
5
+ -- Timothy Pearson <kb9vqf@pearsoncomputing.net>  Mon, 05 Apr 2010 13:20:00 -0600
6
+
7
+kgtk-qt3 (0.10.1-0ubuntu1~ppa1) jaunty; urgency=low
8
+
9
+  * Initial release
10
+
11
+ -- Anthony Mercatante <tonio@ubuntu.com>  Mon, 17 Mar 2009 01:24:08 +0100

+ 1
- 0
debian/compat View File

@@ -0,0 +1 @@
1
+7

+ 19
- 0
debian/control View File

@@ -0,0 +1,19 @@
1
+Source: kgtk-qt3-kde3
2
+Section: kde
3
+Priority: optional
4
+Maintainer: Timothy Pearson <kb9vqf@pearsoncomputing.net>
5
+Build-Depends: debhelper (>= 7), cdbs, kdelibs4-kde3-dev, libgtk2.0-dev, libqt3-mt-dev, cmake
6
+Standards-Version: 3.8.3
7
+Homepage: http://kde-apps.org/content/show.php/KGtk+(Use+KDE+Dialogs+in+Gtk+Apps)?content=36077
8
+
9
+Package: kgtk-qt3-kde3
10
+Architecture: any
11
+Depends: ${shlibs:Depends}
12
+Description: Use KDE dialogs in Gtk apps
13
+ This is a quick-and-dirty LD_PRELOAD hack that allows *some* Gtk
14
+ applications to use KDE's file dialogs when run under KDE.
15
+ .
16
+ The Gtk file chooser functions have been overridden to communicate
17
+ with this KDE module/application.
18
+ .
19
+ This package includes the kqt3-wrapper

+ 37
- 0
debian/copyright View File

@@ -0,0 +1,37 @@
1
+This package was debianized by:
2
+
3
+    Anthony Mercatante <tonio@ubuntu.com>
4
+
5
+It was downloaded from:
6
+
7
+    http://kde-apps.org/content/show.php/KGtk+(Use+KDE+Dialogs+in+Gtk+Apps)?content=36077
8
+
9
+Upstream Authors:
10
+
11
+    Craig Drummond <Craig.Drummond@lycos.co.uk>
12
+
13
+Copyright:
14
+    Copyright (C) Craig Drummond, 2006-2007
15
+
16
+License:
17
+    This program is free software; you can redistribute it and/or modify
18
+    it under the terms of the GNU General Public License as published by
19
+    the Free Software Foundation; either version 2 of the License, or
20
+    (at your option) any later version.
21
+
22
+    This program is distributed in the hope that it will be useful,
23
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
24
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25
+    GNU General Public License for more details.
26
+
27
+    You should have received a copy of the GNU General Public License along
28
+    with this program; if not, write to the Free Software Foundation, Inc.,
29
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30
+
31
+    On Debian systems, the complete text of the GNU General
32
+    Public License can be found in `/usr/share/common-licenses/GPL-2'.
33
+
34
+The Debian packaging is:
35
+
36
+    Copyright C) 2009, Anthony Mercatante <tonio@ubuntu.com>
37
+    and is licensed under the GPL-2, see above.

+ 30
- 0
debian/rules View File

@@ -0,0 +1,30 @@
1
+#!/usr/bin/make -f
2
+# -*- makefile -*-
3
+# Sample debian/rules that uses debhelper.
4
+# This file was originally written by Joey Hess and Craig Small.
5
+# As a special exception, when this file is copied by dh-make into a
6
+# dh-make output file, you may use that output file without restriction.
7
+# This special exception was added by Craig Small in version 0.37 of dh-make.
8
+
9
+include /usr/share/cdbs/1/rules/debhelper.mk
10
+include /usr/share/cdbs/1/rules/simple-patchsys.mk
11
+
12
+DEB_CONFIGURE_INCLUDEDIR := /opt/kde3/include/kde
13
+DEB_CONFIGURE_MANDIR := /opt/kde3/share/man
14
+DEB_CONFIGURE_PREFIX := /opt/kde3
15
+DEB_CONFIGURE_INFODIR := /opt/kde3/share/info
16
+DEB_CMAKE_CUSTOM_FLAGS := -DKGTK_KDE3=true -DKGTK_QT3=true
17
+
18
+cdbs_configure_flags := --with-qt-dir=/usr/share/qt3 --disable-rpath --with-xinerama $(cdbs_kde_enable_final) $(cdbs_kde_enable_debug)
19
+
20
+DEB_CONFIGURE_EXTRA_FLAGS := --prefix=/opt/kde3 --with-extra-libs=/opt/kde3/lib
21
+
22
+configure/kgtk-qt3-kde3::
23
+	env PATH=/opt/kde3/bin:$(PATH) CMAKE_LIBRARY_PATH=/opt/kde3/lib CMAKE_INCLUDE_PATH=/opt/kde3/include/kde cmake -D CMAKE_INSTALL_PREFIX=/opt/kde3 .
24
+
25
+build/kgtk-qt3-kde3::
26
+	env PATH=/opt/kde3/bin:$(PATH) CMAKE_LIBRARY_PATH=/opt/kde3/lib CMAKE_INCLUDE_PATH=/opt/kde3/include/kde $(MAKE)
27
+
28
+install/kgtk-qt3-kde3::
29
+	env PATH=/opt/kde3/bin:$(PATH) CMAKE_LIBRARY_PATH=/opt/kde3/lib CMAKE_INCLUDE_PATH=/opt/kde3/include/kde $(MAKE) install DESTDIR=$(CURDIR)/debian/kgtk-qt3-kde3
30
+

+ 9
- 0
debian/rules.bkp View File

@@ -0,0 +1,9 @@
1
+#!/usr/bin/make -f
2
+
3
+DEB_CMAKE_CUSTOM_FLAGS := -DKGTK_KDE3=true -DKGTK_QT3=true
4
+
5
+include debian/cdbs/kde.mk
6
+
7
+binary-install/kgtk-qt3::
8
+	rm -f debian/kgtk-qt3/usr/bin/kdialogd-wrapper                                                                                                                          
9
+	rm -f debian/kgtk-qt3/usr/bin/kgtk-wrapper                                                                                                                              

+ 22
- 0
gtk2/CMakeLists.txt View File

@@ -0,0 +1,22 @@
1
+include(FindPkgConfig)
2
+
3
+pkg_check_modules(GTK gtk+-2.0>=2.6)
4
+
5
+if (GTK_FOUND)
6
+    message("** INFORMATION: Gtk2 LD_PRELOAD library will be built.")
7
+
8
+    # set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
9
+    set(LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}  CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is /lib${LIB_SUFFIX})" FORCE)
10
+
11
+    include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/common ${CMAKE_BINARY_DIR} ${GTK_INCLUDE_DIRS})
12
+    set(kgtk2_SRCS kgtk2.c)
13
+    add_library(kgtk2 SHARED ${kgtk2_SRCS})
14
+    target_link_libraries(kgtk2 ${GTK_LDFLAGS} -lgthread-2.0 -lglib-2.0 -lc -ldl)
15
+
16
+    install(TARGETS kgtk2 LIBRARY DESTINATION ${LIB_INSTALL_DIR}/kgtk )
17
+
18
+    configure_file (kgtk2-wrapper.cmake ${CMAKE_CURRENT_BINARY_DIR}/kgtk2-wrapper @ONLY)
19
+    install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/kgtk2-wrapper DESTINATION bin)
20
+else (GTK_FOUND)
21
+    message("** ERROR      : Could not locate Gtk2 headers, Gtk2 LD_PRELOAD library will not be built.")
22
+endif (GTK_FOUND)

+ 33
- 0
gtk2/kgtk2-wrapper.cmake View File

@@ -0,0 +1,33 @@
1
+#!/bin/bash
2
+
3
+#
4
+# This script is part of the KGtk package.
5
+#
6
+# (C) Craig Drummond, 2007
7
+#
8
+# Craig.Drummond@lycos.co.uk
9
+#
10
+# --
11
+# Released under the GPL v2 or later
12
+# --
13
+#
14
+
15
+if [ "`locale | grep 'LANG=' | grep -i 'utf-8' | wc -l`" = "0" ] ; then
16
+    export G_BROKEN_FILENAMES=1
17
+fi
18
+
19
+app=`basename $0`
20
+
21
+if [ "$app" = "kgtk2-wrapper" ] ; then
22
+    LD_PRELOAD=@CMAKE_INSTALL_PREFIX@/lib/kgtk/libkgtk2.so:$LD_PRELOAD "$@"
23
+else
24
+    dir=`dirname $0`
25
+    oldPath=$PATH
26
+    PATH=`echo $PATH | sed s:$dir::g`
27
+    real=`which $app`
28
+    PATH=$oldPath
29
+
30
+    if [ "$real" != "" ] && [ "`dirname $real`" != "$dir" ] ; then
31
+        LD_PRELOAD=@CMAKE_INSTALL_PREFIX@/lib@LIB_SUFFIX@/kgtk/libkgtk2.so:$LD_PRELOAD $real "$@"
32
+    fi
33
+fi

+ 2005
- 0
gtk2/kgtk2.c
File diff suppressed because it is too large
View File


+ 27
- 0
kdialogd-wrapper View File

@@ -0,0 +1,27 @@
1
+#!/bin/bash
2
+
3
+#
4
+# This script is part of the KGtk package.
5
+#
6
+# (C) Craig Drummond, 2007
7
+#
8
+# Craig.Drummond@lycos.co.uk
9
+#
10
+# --
11
+# Released under the GPL v2 or later
12
+# --
13
+#
14
+# Wrapper script for kdialogd that removes any LD_PRELOAD. This stops
15
+# KDialogD from trying to connect to itself!
16
+#
17
+
18
+LD_PRELOAD=
19
+
20
+for app in $prefer kdialogd4 kdialogd3 ; do
21
+    which $app > /dev/null
22
+    if [ $? -eq 0 ] ; then
23
+        $app
24
+        break;
25
+    fi
26
+done
27
+

+ 17
- 0
kdialogd3/CMakeLists.txt View File

@@ -0,0 +1,17 @@
1
+set(QT_MT_REQUIRED TRUE)
2
+find_package(KDE3)
3
+find_package(Qt3)
4
+
5
+if (KDE3_INCLUDE_DIR)
6
+    message("** INFORMATION: KDialogD for KDE3 will be built.")
7
+    link_directories(${KDE3_LIB_DIR})
8
+    include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/common ${CMAKE_BINARY_DIR} ${KDE3_INCLUDE_DIR} ${QT_INCLUDE_DIR})
9
+    set(kdialogd3_SRCS kdialogd.cpp)
10
+    kde3_automoc(${kdialogd3_SRCS})
11
+    add_executable(kdialogd3 ${kdialogd3_SRCS})
12
+    target_link_libraries(kdialogd3 kdeui kio kdecore)
13
+    install_targets(/bin kdialogd3)
14
+    add_subdirectory(po)
15
+else (KDE3_INCLUDE_DIR)
16
+    message("** ERROR      : Could not locate Qt3/KDE3 headers, KDialogD for KDE3 will not be built.")
17
+endif (KDE3_INCLUDE_DIR)

+ 721
- 0
kdialogd3/kdialogd.cpp View File

@@ -0,0 +1,721 @@
1
+//#define USE_KWIN
2
+
3
+#include "kdialogd.h"
4
+#include <iostream>
5
+#include <kdiroperator.h>
6
+#include <kuniqueapplication.h>
7
+#include <qsocketnotifier.h>
8
+#include <kio/netaccess.h>
9
+#include <kmessagebox.h>
10
+#include <klocale.h>
11
+#include <kconfig.h>
12
+#include <kurlcombobox.h>
13
+#ifdef USE_KWIN
14
+#include <kwin.h>
15
+#else
16
+#include <X11/Xlib.h>
17
+#endif
18
+#include <sys/un.h>
19
+#include <sys/types.h>
20
+#include <sys/socket.h>
21
+#include <sys/errno.h>
22
+#include <ksockaddr.h>
23
+#include <kdebug.h>
24
+#include <kdeversion.h>
25
+#include <qtimer.h>
26
+#ifdef KDIALOGD_APP
27
+#include <kcmdlineargs.h>
28
+#include <kaboutdata.h>
29
+#endif
30
+#include <fstream>
31
+
32
+KConfig *KDialogD::theirConfig=NULL;
33
+
34
+#define CFG_KEY_DIALOG_SIZE "KDialogDSize"
35
+#define CFG_TIMEOUT_GROUP   "General"
36
+#ifdef KDIALOGD_APP
37
+#define CFG_TIMEOUT_KEY     "Timeout"
38
+#define DEFAULT_TIMEOUT     30
39
+#endif
40
+
41
+static QString groupName(const QString &app, bool fileDialog=true)
42
+{
43
+   return QString(fileDialog ? "KFileDialog " : "KDirSelectDialog ")+app;
44
+}
45
+
46
+// from kdebase/kdesu
47
+static int createSocket()
48
+{
49
+    int         sockitsFd;
50
+    ksocklen_t  addrlen;
51
+    struct stat s;
52
+    const char  *sock=getSockName();
53
+    int         stat_err=lstat(sock, &s);
54
+
55
+    if(!stat_err && S_ISLNK(s.st_mode))
56
+    {
57
+        kdWarning() << "Someone is running a symlink attack on you" << endl;
58
+        if(unlink(sock))
59
+        {
60
+            kdWarning() << "Could not delete symlink" << endl;
61
+            return -1;
62
+        }
63
+    }
64
+
65
+    if (!access(sock, R_OK|W_OK))
66
+    {
67
+        kdWarning() << "stale socket exists" << endl;
68
+        if (unlink(sock))
69
+        {
70
+            kdWarning() << "Could not delete stale socket" << endl;
71
+            return -1;
72
+        }
73
+    }
74
+
75
+    sockitsFd = socket(PF_UNIX, SOCK_STREAM, 0);
76
+    if (sockitsFd < 0)
77
+    {
78
+        kdError() << "socket(): " << errno << endl;
79
+        return -1;
80
+    }
81
+
82
+    struct sockaddr_un addr;
83
+    addr.sun_family = AF_UNIX;
84
+    strncpy(addr.sun_path, sock, sizeof(addr.sun_path)-1);
85
+    addr.sun_path[sizeof(addr.sun_path)-1] = '\000';
86
+    addrlen = SUN_LEN(&addr);
87
+    if (bind(sockitsFd, (struct sockaddr *)&addr, addrlen) < 0)
88
+    {
89
+        kdError() << "bind(): " << errno << endl;
90
+        return -1;
91
+    }
92
+
93
+    struct linger lin;
94
+    lin.l_onoff = lin.l_linger = 0;
95
+    if (setsockopt(sockitsFd, SOL_SOCKET, SO_LINGER, (char *) &lin, sizeof(linger)) < 0)
96
+    {
97
+        kdError() << "setsockopt(SO_LINGER): " << errno << endl;
98
+        return -1;
99
+    }
100
+
101
+    int opt = 1;
102
+    if (setsockopt(sockitsFd, SOL_SOCKET, SO_REUSEADDR, (char *) &opt, sizeof(opt)) < 0)
103
+    {
104
+        kdError() << "setsockopt(SO_REUSEADDR): " << errno << endl;
105
+        return -1;
106
+    }
107
+    opt = 1;
108
+    if (setsockopt(sockitsFd, SOL_SOCKET, SO_KEEPALIVE, (char *) &opt, sizeof(opt)) < 0)
109
+    {
110
+        kdError() << "setsockopt(SO_KEEPALIVE): " << errno << endl;
111
+        return -1;
112
+    }
113
+
114
+    if(::listen(sockitsFd, 1)<0)
115
+    {
116
+        kdError() << "listen(1): " << errno << endl;
117
+        return -1;
118
+    }
119
+
120
+    //chmod(sock, 0600);
121
+    return sockitsFd;
122
+}
123
+
124
+static void urls2Local(KURL::List &urls, QStringList &items, QWidget *parent)
125
+{
126
+    KURL::List::Iterator it(urls.begin()),
127
+                         end(urls.end());
128
+
129
+    for(; it!=end; ++it)
130
+        if((*it).isLocalFile())
131
+            items.append((*it).path());
132
+        else
133
+        {
134
+#if KDE_IS_VERSION(3, 5, 0)
135
+            KURL url(KIO::NetAccess::mostLocalURL(*it, parent));
136
+
137
+            if(url.isLocalFile())
138
+                items.append(url.path());
139
+            else
140
+                break;
141
+#else
142
+            break;
143
+#endif
144
+        }
145
+}
146
+
147
+KDialogD::KDialogD(QObject *parent)
148
+        : QObject(parent),
149
+#ifdef KDIALOGD_APP
150
+          itsTimer(NULL),
151
+          itsTimeoutVal(DEFAULT_TIMEOUT),
152
+#endif
153
+          itsFd(::createSocket()),
154
+          itsNumConnections(0)
155
+{
156
+    if(itsFd<0)
157
+    {
158
+        kdError() << "KDialogD could not create socket" << endl;
159
+#ifdef KDIALOGD_APP
160
+        kapp->exit();
161
+#endif
162
+    }
163
+    else
164
+    {
165
+        std::ofstream f(getPidFileName());
166
+
167
+        if(f)
168
+        {
169
+            f << getpid();
170
+            f.close();
171
+        }
172
+        if(!theirConfig)
173
+            theirConfig=new KConfig("kdialogdrc", false, false);
174
+
175
+        connect(new QSocketNotifier(itsFd, QSocketNotifier::Read, this),
176
+                SIGNAL(activated(int)), this, SLOT(newConnection()));
177
+
178
+#ifdef KDIALOGD_APP
179
+        if(theirConfig->hasGroup(CFG_TIMEOUT_GROUP))
180
+        {
181
+            theirConfig->setGroup(CFG_TIMEOUT_GROUP);
182
+            itsTimeoutVal=theirConfig->readNumEntry(CFG_TIMEOUT_KEY, DEFAULT_TIMEOUT);
183
+            if(itsTimeoutVal<0)
184
+                itsTimeoutVal=DEFAULT_TIMEOUT;
185
+            theirConfig->setGroup(QString::null);
186
+        }
187
+
188
+        kdDebug() << "Timeout:" << itsTimeoutVal << endl;
189
+        if(itsTimeoutVal)
190
+            connect(itsTimer=new QTimer(this), SIGNAL(timeout()), this, SLOT(timeout()));
191
+#endif
192
+    }
193
+}
194
+
195
+KDialogD::~KDialogD()
196
+{
197
+    if(-1!=itsFd)
198
+        close(itsFd);
199
+    if(theirConfig)
200
+        delete theirConfig;
201
+    theirConfig=NULL;
202
+}
203
+
204
+void KDialogD::newConnection()
205
+{
206
+    kdDebug() << "New connection" << endl;
207
+
208
+    ksocklen_t         addrlen = 64;
209
+    struct sockaddr_un clientname;
210
+    int                connectedFD;
211
+
212
+    if((connectedFD=::accept(itsFd, (struct sockaddr *) &clientname, &addrlen))>=0)
213
+    {
214
+        int appNameLen;
215
+
216
+        if(readBlock(connectedFD, (char *)&appNameLen, 4))
217
+        {
218
+            bool     ok=true;
219
+            QCString appName;
220
+
221
+            if(0==appNameLen)
222
+                appName="Generic";
223
+            else
224
+            {
225
+                appName.resize(appNameLen);
226
+                ok=readBlock(connectedFD, appName.data(), appNameLen);
227
+            }
228
+
229
+            if(ok)
230
+            {
231
+                itsNumConnections++;
232
+#ifdef KDIALOGD_APP
233
+                if(itsTimer)
234
+                    itsTimer->stop();
235
+#endif
236
+                connect(new KDialogDClient(connectedFD, appName, this),
237
+                        SIGNAL(error(KDialogDClient *)),
238
+                        this, SLOT(deleteConnection(KDialogDClient *)));
239
+            }
240
+        }
241
+    }
242
+}
243
+
244
+void KDialogD::deleteConnection(KDialogDClient *client)
245
+{
246
+    kdDebug() << "Delete client" << endl;
247
+    delete client;
248
+
249
+#ifdef KDIALOGD_APP
250
+    if(0==--itsNumConnections)
251
+        if(itsTimeoutVal)
252
+            itsTimer->start(itsTimeoutVal*1000, true);  // Only single shot...
253
+        else
254
+            timeout();
255
+#endif
256
+}
257
+
258
+void KDialogD::timeout()
259
+{
260
+#ifdef KDIALOGD_APP
261
+    if(0==itsNumConnections)
262
+        if(grabLock(0)>0)   // 0=> no wait...
263
+        {
264
+            kdDebug() << "Timeout occured, and no connections, so exit" << endl;
265
+            kapp->exit();
266
+        }
267
+        else     //...unlock lock file...
268
+        {
269
+            kdDebug() << "Timeout occured, but unable to grab lock file - app must be connecting" << endl;
270
+            releaseLock();
271
+        }
272
+#endif
273
+}
274
+
275
+KDialogDClient::KDialogDClient(int sock, const QString &an, QObject *parent)
276
+              : QObject(parent),
277
+                itsFd(sock),
278
+                itsDlg(NULL),
279
+                itsAccepted(false),
280
+                itsAppName(an)
281
+{
282
+    kdDebug() << "new client..." << itsAppName << " (" << itsFd << ")" << endl;
283
+    connect(new QSocketNotifier(itsFd, QSocketNotifier::Read, this), SIGNAL(activated(int)), this, SLOT(read()));
284
+    connect(new QSocketNotifier(itsFd, QSocketNotifier::Exception, this), SIGNAL(activated(int)), this, SLOT(close()));
285
+}
286
+
287
+KDialogDClient::~KDialogDClient()
288
+{
289
+    kdDebug() << "Deleted client" << endl;
290
+    if(-1!=itsFd)
291
+        ::close(itsFd);
292
+    if(KDialogD::config())
293
+        KDialogD::config()->sync();
294
+}
295
+
296
+void KDialogDClient::close()
297
+{
298
+    kdDebug() << "close " << itsFd << endl;
299
+
300
+    ::close(itsFd);
301
+    itsFd=-1;
302
+    if(itsDlg)
303
+    {
304
+        itsDlg->close();
305
+        itsDlg->delayedDestruct();
306
+        itsDlg=NULL;
307
+    }
308
+    emit error(this);
309
+}
310
+
311
+void KDialogDClient::read()
312
+{
313
+    kdDebug() << "read" << endl;
314
+
315
+    if(-1==itsFd)
316
+        return;
317
+
318
+    char         request;
319
+    QString      caption;
320
+    unsigned int xid=0;
321
+
322
+    if(!itsDlg && readData(&request, 1) && request>=(char)OP_FILE_OPEN && request<=(char)OP_FOLDER &&
323
+       readData((char *)&xid, 4) && readString(caption))
324
+    {
325
+        if("."==caption)
326
+            switch((Operation)request)
327
+            {
328
+                case OP_FILE_OPEN:
329
+                case OP_FILE_OPEN_MULTIPLE:
330
+                    caption=i18n("Open");
331
+                    break;
332
+                case OP_FILE_SAVE:
333
+                    caption=i18n("Save As");
334
+                    break;
335
+                case OP_FOLDER:
336
+                    caption=i18n("Select Folder");
337
+                    break;
338
+                default:
339
+                    break;
340
+            }
341
+
342
+        if(OP_FOLDER==(Operation)request)
343
+        {
344
+            QString intialFolder;
345
+
346
+            if(readString(intialFolder))
347
+            {
348
+                initDialog(caption, new KDialogDDirSelectDialog(itsAppName, intialFolder, true, NULL,
349
+                           "folderdialog", false), xid);
350
+                return;
351
+            }
352
+        }
353
+        else
354
+        {
355
+            QString intialFolder,
356
+                    filter;
357
+            char    overW=0;
358
+
359
+            if(readString(intialFolder) && readString(filter) &&
360
+               (OP_FILE_SAVE!=(Operation)request || readData(&overW, 1)))
361
+            {
362
+                initDialog(caption, new KDialogDFileDialog(itsAppName, (Operation)request, intialFolder,
363
+                                                           filter, overW ? true : false), xid);
364
+                return;
365
+            }
366
+        }
367
+    }
368
+
369
+    kdDebug() << "Comms error, closing connection..." << itsFd << endl;
370
+    // If we get here something was wrong, close connection...
371
+    close();
372
+}
373
+
374
+void KDialogDClient::finished()
375
+{
376
+    if(-1==itsFd)
377
+        return;
378
+
379
+    //
380
+    // * finished is emitted when a dialog is ok'ed/cancel'ed/closed
381
+    // * if the user just closes the dialog - neither ok nor cancel are emitted
382
+    // * the dir select dialog doesnt seem to set the QDialog result parameter
383
+    //   when it is accepted - so for this reason if ok is clicked we store an
384
+    //   'accepted' value there, and check for that after the dialog is finished.
385
+    kdDebug() << "finished" << endl;
386
+    if(itsDlg && !(itsAccepted || QDialog::Accepted==itsDlg->result()))
387
+        cancel();
388
+}
389
+
390
+void KDialogDClient::ok(const QStringList &items)
391
+{
392
+    kdDebug() << "ok" << endl;
393
+
394
+    int                        num=items.count();
395
+    QStringList::ConstIterator it(items.begin()),
396
+                               end(items.end());
397
+    bool                       error=!writeData((char *)&num, 4);
398
+
399
+    for(; !error && it!=end; ++it)
400
+        error=!writeString(*it);
401
+
402
+    if(error)
403
+        close();
404
+    else
405
+        itsAccepted=true;
406
+    if(itsDlg)
407
+        itsDlg->delayedDestruct();
408
+    itsDlg=NULL;
409
+}
410
+
411
+void KDialogDClient::cancel()
412
+{
413
+    if(itsDlg)
414
+    {
415
+        kdDebug() << "cancel" << endl;
416
+
417
+        int rv=0;
418
+
419
+        if(!writeData((char *)&rv, 4))
420
+            close();
421
+        if(itsDlg)
422
+            itsDlg->delayedDestruct();
423
+        itsDlg=NULL;
424
+    }
425
+}
426
+
427
+bool KDialogDClient::readData(QCString &buffer, int size)
428
+{
429
+    buffer.resize(size);
430
+    return ::readBlock(itsFd, buffer.data(), size);
431
+}
432
+
433
+bool KDialogDClient::readString(QString &str)
434
+{
435
+    int size;
436
+
437
+    if(!readData((char *)&size, 4))
438
+        return false;
439
+
440
+    QCString buffer;
441
+    buffer.resize(size);
442
+
443
+    if(!readData(buffer.data(), size))
444
+        return false;
445
+
446
+    str=QString::fromUtf8(buffer.data());
447
+    return true;
448
+}
449
+
450
+bool KDialogDClient::writeString(const QString &str)
451
+{
452
+    QCString utf8(str.utf8());
453
+
454
+    int size=utf8.length()+1;
455
+
456
+    return writeData((char *)&size, 4) && writeData(utf8.data(), size);
457
+}
458
+
459
+void KDialogDClient::initDialog(const QString &caption, KDialogBase *d, unsigned int xid)
460
+{
461
+    itsAccepted=false;
462
+    itsDlg=d;
463
+
464
+    if(!caption.isEmpty())
465
+        itsDlg->setPlainCaption(caption);
466
+
467
+    if(xid)
468
+    {
469
+#ifdef USE_KWIN
470
+        KWin::setMainWindow(itsDlg, xid);
471
+        KWin::setState(itsDlg->winId(), NET::Modal);
472
+
473
+        KWin::WindowInfo wi(KWin::windowInfo(xid, NET::WMGeometry, NET::WM2UserTime));
474
+        QRect            geom(wi.geometry());
475
+        int              rx=geom.x(),
476
+                         ry=geom.y();
477
+
478
+        rx=(rx+(geom.width()/2))-(itsDlg->width()/2);
479
+        if(rx<0)
480
+            rx=0;
481
+        ry=(ry+(geom.height()/2))-(itsDlg->height()/2);
482
+        if(ry<0)
483
+            ry=0;
484
+        itsDlg->move(rx, ry);
485
+#else
486
+        XWindowAttributes attr;
487
+        int               rx, ry;
488
+        Window            junkwin;
489
+
490
+        XSetTransientForHint(qt_xdisplay(), itsDlg->winId(), xid);
491
+        if(XGetWindowAttributes(qt_xdisplay(), xid, &attr))
492
+        {
493
+            XTranslateCoordinates(qt_xdisplay(), xid, attr.root,
494
+                                  -attr.border_width, -16,
495
+                                  &rx, &ry, &junkwin);
496
+
497
+            rx=(rx+(attr.width/2))-(itsDlg->width()/2);
498
+            if(rx<0)
499
+                rx=0;
500
+            ry=(ry+(attr.height/2))-(itsDlg->height()/2);
501
+            if(ry<0)
502
+                ry=0;
503
+            itsDlg->move(rx, ry);
504
+        }
505
+#endif
506
+    }
507
+
508
+    connect(itsDlg, SIGNAL(ok(const QStringList &)), this, SLOT(ok(const QStringList &)));
509
+    connect(itsDlg, SIGNAL(finished()), this, SLOT(finished()));
510
+    itsDlg->show();
511
+}
512
+
513
+KDialogDFileDialog::KDialogDFileDialog(QString &an, Operation op, const QString &startDir,
514
+                                       const QString &filter, bool confirmOw)
515
+                  : KFileDialog(startDir.isEmpty() || "~"==startDir ? QDir::homeDirPath() : startDir,
516
+                                filter, NULL, NULL, false),
517
+                    itsConfirmOw(confirmOw),
518
+                    itsAppName(an)
519
+{
520
+    kdDebug() << "startDir:" << startDir << endl;
521
+
522
+    switch(op)
523
+    {
524
+        case OP_FILE_OPEN:
525
+            setOperationMode(KFileDialog::Opening);
526
+            setMode((KFile::Mode)(KFile::File | KFile::ExistingOnly));
527
+            break;
528
+        case OP_FILE_OPEN_MULTIPLE:
529
+            setOperationMode(KFileDialog::Opening);
530
+            setMode((KFile::Mode)(KFile::Files | KFile::ExistingOnly));
531
+            break;
532
+        case OP_FILE_SAVE:
533
+            setOperationMode(KFileDialog::Saving);
534
+            setMode(KFile::File);
535
+            break;
536
+        default:
537
+            break;
538
+    }
539
+
540
+    if(KDialogD::config())
541
+    {
542
+        QString oldGrp(KDialogD::config()->group()),
543
+                grp(groupName(itsAppName));
544
+        QSize   defaultSize(600, 400);
545
+
546
+        readConfig(KDialogD::config(), grp);
547
+        KDialogD::config()->setGroup(grp);
548
+        resize(KDialogD::config()->readSizeEntry(CFG_KEY_DIALOG_SIZE, &defaultSize));
549
+        KDialogD::config()->setGroup(oldGrp);
550
+    }