Browse Source

kdelibs update to Trinity v3.5.11

git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1061230 283d02a7-25f6-0310-bc7c-ecb5cbfe19
tpearson 9 years ago
parent
commit
865f314dd5
100 changed files with 1146 additions and 652 deletions
  1. 1
    1
      Makefile.am.in
  2. 1
    1
      arts/kde/Makefile.am
  3. 1
    1
      arts/knotify/Makefile.am
  4. 4
    2
      configure.in.in
  5. 1
    1
      dcop/Makefile.am
  6. 4
    3
      dcop/dcopidlng/dcopidlng
  7. 2
    2
      dnssd/Makefile.am
  8. 3
    4
      dnssd/README
  9. 14
    35
      dnssd/configure.in.in
  10. 45
    30
      dnssd/domainbrowser.cpp
  11. 121
    71
      dnssd/publicservice.cpp
  12. 5
    0
      dnssd/publicservice.h
  13. 89
    43
      dnssd/query.cpp
  14. 53
    52
      dnssd/remoteservice.cpp
  15. 33
    42
      dnssd/responder.cpp
  16. 14
    20
      dnssd/responder.h
  17. 4
    5
      dnssd/sdevent.h
  18. 1
    1
      dnssd/servicebase.cpp
  19. 7
    18
      dnssd/servicebrowser.cpp
  20. 1
    1
      interfaces/kimproxy/library/Makefile.am
  21. 1
    1
      interfaces/kmediaplayer/Makefile.am
  22. 1
    1
      interfaces/kmediaplayer/kfileaudiopreview/Makefile.am
  23. 1
    1
      interfaces/kscript/Makefile.am
  24. 1
    1
      interfaces/kscript/sample/Makefile.am
  25. 1
    1
      interfaces/ktexteditor/Makefile.am
  26. 2
    0
      interfaces/terminal/kde_terminal_interface.h
  27. 1
    1
      kabc/Makefile.am
  28. 1
    1
      kabc/formats/Makefile.am
  29. 2
    2
      kabc/plugins/dir/Makefile.am
  30. 2
    2
      kabc/plugins/file/Makefile.am
  31. 2
    2
      kabc/plugins/ldapkio/Makefile.am
  32. 1
    1
      kabc/vcard/Makefile.am
  33. 5
    1
      kate/data/Makefile.am
  34. 1
    1
      kate/interfaces/Makefile.am
  35. 1
    1
      kate/part/Makefile.am
  36. 22
    10
      kate/part/katesearch.cpp
  37. 1
    1
      kate/plugins/insertfile/Makefile.am
  38. 1
    1
      kate/plugins/isearch/Makefile.am
  39. 1
    1
      kate/plugins/kdatatool/Makefile.am
  40. 1
    1
      kate/plugins/wordcompletion/Makefile.am
  41. 1
    1
      kcert/Makefile.am
  42. 1
    1
      kcmshell/Makefile.am
  43. 1
    1
      kconf_update/Makefile.am
  44. 9
    3
      kdecore/Makefile.am
  45. 3
    0
      kdecore/kaccel.cpp
  46. 51
    0
      kdecore/kconfigbackend.cpp
  47. 6
    0
      kdecore/kconfigbackend.h
  48. 1
    1
      kdecore/kcrash.cpp
  49. 2
    1
      kdecore/kdebug.cpp
  50. 1
    1
      kdecore/kdebugrc
  51. 2
    2
      kdecore/kdeversion.h
  52. 36
    15
      kdecore/kglobalsettings.cpp
  53. 148
    0
      kdecore/kiconeffect.cpp
  54. 1
    0
      kdecore/kiconeffect.h
  55. 1
    1
      kdecore/kicontheme.cpp
  56. 13
    4
      kdecore/klocale.cpp
  57. 114
    78
      kdecore/kpty.cpp
  58. 10
    0
      kdecore/kpty.h
  59. 9
    3
      kdecore/kstandarddirs.cpp
  60. 37
    1
      kdecore/kstartupinfo.cpp
  61. 24
    0
      kdecore/kstartupinfo.h
  62. 14
    3
      kdecore/netwm.cpp
  63. 1
    0
      kdecore/netwm_def.h
  64. 0
    3
      kdecore/network/kresolverworkerbase.cpp
  65. 3
    3
      kded/Makefile.am
  66. 20
    64
      kded/applications.menu
  67. 1
    1
      kded/kbuildservicefactory.cpp
  68. 15
    0
      kded/kded.cpp
  69. 3
    1
      kded/vfolder_menu.cpp
  70. 1
    1
      kdefx/Makefile.am
  71. 52
    0
      kdefx/kstyle.cpp
  72. 3
    3
      kdelibs.lsm
  73. 2
    2
      kdeprint/Makefile.am
  74. 3
    2
      kdeprint/configure.in.in
  75. 1
    1
      kdeprint/cups/Makefile.am
  76. 1
    1
      kdeprint/cups/cupsdconf2/Makefile.am
  77. 7
    7
      kdeprint/cups/cupsdconf2/cupsd.conf.template
  78. 3
    3
      kdeprint/cups/cupsdconf2/cupsdconf.cpp
  79. 3
    8
      kdeprint/cups/cupsdconf2/cupsddialog.cpp
  80. 1
    1
      kdeprint/cups/kmcupsmanager.cpp
  81. 1
    1
      kdeprint/ext/Makefile.am
  82. 9
    0
      kdeprint/filters/psnup.xml
  83. 1
    1
      kdeprint/kprinter.cpp
  84. 1
    1
      kdeprint/lpdunix/Makefile.am
  85. 2
    1
      kdeprint/lpr/Makefile.am
  86. 3
    3
      kdeprint/management/Makefile.am
  87. 8
    0
      kdeprint/management/kmmainview.cpp
  88. 1
    0
      kdeprint/management/kmmainview.h
  89. 9
    11
      kdeprint/management/smbview.cpp
  90. 1
    1
      kdeprint/rlpr/Makefile.am
  91. 1
    1
      kdeprint/tools/escputil/Makefile.am
  92. 2
    2
      kdesu/Makefile.am
  93. 3
    3
      kdeui/Makefile.am
  94. 2
    2
      kdeui/kaboutapplication.cpp
  95. 25
    27
      kdeui/kaboutkde.cpp
  96. 16
    14
      kdeui/kbugreport.cpp
  97. 1
    1
      kdeui/kbugreport.h
  98. 1
    1
      kdeui/kdetrayproxy/Makefile.am
  99. 1
    1
      kdeui/khelpmenu.cpp
  100. 0
    0
      kdeui/kiconview.cpp

+ 1
- 1
Makefile.am.in View File

@@ -18,7 +18,7 @@
18 18
 #    Boston, MA 02110-1301, USA.
19 19
 
20 20
 
21
-COMPILE_FIRST = dcop libltdl kdefx kdecore kunittest kdeui kdesu kjs kwallet kio
21
+COMPILE_FIRST = dcop libltdl kdefx kdecore kunittest kdeui kdesu kjs kwallet kio kded kded_post
22 22
 COMPILE_BEFORE_doc = kdoctools
23 23
 COMPILE_AFTER_kparts = kspell2 kmdi kdeprint kinit kate interfaces kcert khtml
24 24
 COMPILE_AFTER_kdeprint = kate khtml

+ 1
- 1
arts/kde/Makefile.am View File

@@ -8,7 +8,7 @@ libartskde_la_SOURCES = artskde.cc kioinputstream_impl.cpp kplayobject.cc \
8 8
                         kartsserver.cpp kdatarequest_impl.cpp kaudioconverter.cc \
9 9
                         kvideowidget.cpp kplayobjectcreator.cc \
10 10
                         kaudiomanagerplay.cpp
11
-libartskde_la_LIBADD = $(LIB_KIO) -lqtmcop -lsoundserver_idl
11
+libartskde_la_LIBADD = $(LIB_KIO) -lqtmcop -lsoundserver_idl -lartsflow_idl -lmcop $(LIB_QT) $(LIB_KDECORE) -lkmedia2_idl -lartsflow $(LIB_KDEUI) $(LIB_X11)
12 12
 libartskde_la_LDFLAGS = $(all_libraries) -no-undefined -version-info 3:0:2
13 13
 libartskde_la_METASOURCES = AUTO
14 14
 libartskde_la_COMPILE_FIRST = artskde.h

+ 1
- 1
arts/knotify/Makefile.am View File

@@ -7,7 +7,7 @@ kde_module_LTLIBRARIES = knotify.la
7 7
 
8 8
 knotify_la_SOURCES	= knotify.cpp knotify.skel
9 9
 if include_ARTS
10
-knotify_la_LIBADD	= -lsoundserver_idl -lqtmcop $(LIB_KDEUI) $(top_builddir)/arts/kde/libartskde.la
10
+knotify_la_LIBADD	= -lsoundserver_idl $(LIB_KDEUI) $(top_builddir)/arts/kde/libartskde.la $(LIB_QT) $(top_builddir)/dcop/libDCOP.la $(LIB_KDECORE) -lartsflow_idl -lmcop
11 11
 endif
12 12
 knotify_la_LDFLAGS = $(all_libraries) -module -avoid-version
13 13
 knotify_la_METASOURCES = AUTO

+ 4
- 2
configure.in.in View File

@@ -19,6 +19,8 @@ AC_ARG_PROGRAM
19 19
 dnl Automake doc recommends to do this only here. (Janos)
20 20
 AM_INIT_AUTOMAKE(@MODULENAME@, @VERSION@) dnl searches for some needed programs
21 21
 
22
+AM_MAINTAINER_MODE
23
+
22 24
 AC_PROG_INSTALL
23 25
 
24 26
 dnl generate the config header
@@ -46,7 +48,7 @@ dnl Checks for header files.
46 48
 KDE_CHECK_STL
47 49
 AC_HEADER_DIRENT
48 50
 AC_HEADER_STDC
49
-AC_CHECK_HEADERS(sys/param.h sys/mman.h sys/time.h sysent.h strings.h sys/stat.h sys/select.h paths.h malloc.h limits.h sys/soundcard.h dlfcn.h termios.h)
51
+AC_CHECK_HEADERS(sys/param.h sys/mman.h sys/time.h sysent.h strings.h sys/stat.h sys/select.h paths.h malloc.h limits.h sys/soundcard.h dlfcn.h termios.h sys/prctl.h)
50 52
 
51 53
 AC_ARG_WITH(acl,
52 54
   [AC_HELP_STRING(--with-acl,
@@ -162,7 +164,7 @@ AC_CHECK_RANDOM
162 164
 AC_CHECK_MKSTEMPS
163 165
 AC_CHECK_MKSTEMP
164 166
 AC_CHECK_MKDTEMP
165
-AC_CHECK_FUNCS(strtoll socket seteuid setegid strfmon stpcpy gettimeofday readdir_r setpriority)
167
+AC_CHECK_FUNCS(strtoll socket seteuid setegid strfmon stpcpy gettimeofday readdir_r setpriority tcgetattr tcsetattr)
166 168
 
167 169
 AH_BOTTOM([
168 170
 /* provide a definition for a 32 bit entity, usable as a typedef, possibly

+ 1
- 1
dcop/Makefile.am View File

@@ -46,7 +46,7 @@ libDCOP_la_SOURCES = dcopstub.cpp dcopref.cpp dcopobject.cpp dcopclient.cpp
46 46
 kdeinit_LTLIBRARIES = dcopserver.la
47 47
 dcopserver_la_LDFLAGS = -module -avoid-version $(all_libraries)
48 48
 dcopserver_la_SOURCES = dcopserver.cpp dcopsignals.cpp
49
-dcopserver_la_LIBADD  = libDCOP.la
49
+dcopserver_la_LIBADD  = libDCOP.la $(LIB_QT)
50 50
 
51 51
 dcopserver_shutdown_SOURCES = dcopserver_shutdown.c
52 52
 

+ 4
- 3
dcop/dcopidlng/dcopidlng View File

@@ -1,15 +1,16 @@
1 1
 #!/bin/sh
2 2
 
3
-trap "rm -f dcopidlng.stderr.$$" 0 1 2 15
3
+tmpfile=`mktemp -t dcopidlng.XXXXXX` || { echo "$0: Cannot create temporary file" >&2; exit 1;  }
4
+trap " [ -f \"$tmpfile\" ] && /bin/rm -f -- \"$tmpfile\"" 0 1 2 3 13 15
4 5
 
5 6
 if test -z "$KDECONFIG"; then
6 7
     KDECONFIG=kde-config
7 8
 fi
8 9
 LIBDIR="`$KDECONFIG --install data --expandvars`/dcopidlng"
9
-perl -I"$LIBDIR" "$LIBDIR/kalyptus" --allow_k_dcop_accessors -f dcopidl $1 2> dcopidlng.stderr.$$
10
+perl -I"$LIBDIR" "$LIBDIR/kalyptus" --allow_k_dcop_accessors -f dcopidl $1 2> $tmpfile
10 11
 RET=$?
11 12
 if [ $RET -ne 0 ]
12 13
 then
13
-   cat dcopidlng.stderr.$$ >&2
14
+   cat $tmpfile >&2
14 15
 fi
15 16
 exit $RET

+ 2
- 2
dnssd/Makefile.am View File

@@ -1,5 +1,5 @@
1 1
 # set the include path for X, qt and KDE
2
-INCLUDES = -I$(top_srcdir) $(all_includes)
2
+INCLUDES = -I$(top_srcdir) $(all_includes) $(AVAHI_CFLAGS)
3 3
 
4 4
 # these are the headers for your project
5 5
 noinst_HEADERS = sdevent.h
@@ -14,7 +14,7 @@ libkdnssd_la_SOURCES = remoteservice.cpp responder.cpp servicebase.cpp \
14 14
 dnssdincludedir = $(includedir)/dnssd
15 15
 dnssdinclude_HEADERS = domainbrowser.h query.h remoteservice.h \
16 16
 	publicservice.h servicebase.h servicebrowser.h settings.h
17
-libkdnssd_la_LIBADD = ../kdecore/libkdecore.la $(LIB_DNSSD)
17
+libkdnssd_la_LIBADD = ../kdecore/libkdecore.la $(AVAHI_LIBS) $(LIB_QT)
18 18
 libkdnssd_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -version-info 1:0
19 19
 
20 20
 #kde_kcfg_DATA = kcm_kdnssd.kcfg

+ 3
- 4
dnssd/README View File

@@ -1,12 +1,11 @@
1 1
 Checklist to ensure that zeroconf will work:
2 2
 
3
-1) Install Apple's mdnsd, at least version 85
4
-2) kdelibs (and kdebase for ksysguard) should be configured and compiled with dns_sd sdk (part
5
-of mdnsd installation) present - config.h should contain '#define HAVE_DNSSD 1'
3
+1) Install Avahi, at least version 0.3
4
+2) compile kdnssd-avahi and install it to replace 'stub' libkdnssd.so provided by kdelibs
6 5
 3) check /etc/nsswitch.conf and ensure that there is 'mdns' before 'dns' in
7 6
 line starting with 'host:'. It should be something like:
8 7
 host: files mdns dns
9
-4) ensure that mdnsd is being started in initscripts
8
+4) ensure that avahi-daemon is being started in initscripts
10 9
 5) for testing: use kpf kicker applet to publish a directory, then open 'zeroconf:/'
11 10
 URL in konqueror. You should be able to see a local webserver with that published dir.
12 11
 

+ 14
- 35
dnssd/configure.in.in View File

@@ -1,38 +1,17 @@
1 1
 #MIN_CONFIG
2 2
 
3
-AC_ARG_ENABLE(dnssd, [  --disable-dnssd     don't require libdns_sd (browsing and publishing DNS-SD services will not be possible) ],  with_dnssd=$enableval, with_dnssd=yes)
4
-if test "$with_dnssd" = "yes"; then
5
-AC_MSG_CHECKING(for DNS-SD support)
6
-save_dnssdtest_LIBS="$LIBS"
7
-save_dnssdtest_LDFLAGS="$LDFLAGS"
8
-save_dnssdtest_CPPFLAGS="$CPPFLAGS"
9
-LDFLAGS="$all_libraries $LDFLAGS"
10
-CPPFLAGS="$CPPFLAGS $all_includes"
11
-case $host_os in
12
-  darwin*) LIBS="" ;;
13
-  *) LIBS="-ldns_sd" ;;
14
-esac
15
-have_libdns_sd="no"
16
-AC_TRY_LINK(	[
17
-			#include <dns_sd.h>
18
-		],[
19
-			DNSServiceRefDeallocate( (DNSServiceRef) 0);
20
-			TXTRecordDeallocate( (TXTRecordRef*) 0);
21
-		],[
22
-			AC_DEFINE(HAVE_DNSSD,1,[Define if dns-sd is available])
23
-			case $host_os in
24
-				darwin*) LIB_DNSSD="" ;;
25
-				*) LIB_DNSSD="-ldns_sd" ;;
26
-			esac
27
-			have_libdns_sd="yes"
28
-			AC_MSG_RESULT(yes)
29
-		],[
30
-			AC_MSG_RESULT(no)
31
-                        LIB_DNSSD=""
32
-])
33
-CPPFLAGS=$save_dnssdtest_CPPFLAGS
34
-LDFLAGS=$save_dnssdtest_LDFLAGS
35
-LIBS=$save_dnssdtest_LIBS
3
+# Check for pkg-config manually first, as if its not installed the
4
+# PKG_PROG_PKG_CONFIG macro won't be defined.
5
+m4_pattern_allow(PKG_CONFIG_MIN_VERSION)
6
+AC_CHECK_PROG(have_pkg_config, pkg-config, yes, no)
7
+
8
+if test x"$have_pkg_config" == xno; then
9
+    AC_MSG_ERROR(pkg-config is required to install this program)
36 10
 fi
37
-AC_SUBST(LIB_DNSSD)
38
-AM_CONDITIONAL(HAVE_DNSSD, test "$have_libdns_sd" = "yes")
11
+
12
+PKG_PROG_PKG_CONFIG
13
+
14
+PKG_CHECK_MODULES( AVAHI, [ avahi-qt3 >= 0.4 , avahi-client >= 0.4 ])
15
+AC_SUBST(AVAHI_CFLAGS)
16
+AC_SUBST(AVAHI_LIBS)
17
+PKG_CHECK_EXISTS( [ avahi-client >= 0.6], AC_DEFINE(AVAHI_API_0_6,1,[Avahi API 0.6] ) )

+ 45
- 30
dnssd/domainbrowser.cpp View File

@@ -27,46 +27,56 @@
27 27
 #include "query.h"
28 28
 #include "servicebrowser.h"
29 29
 #include <kapplication.h>
30
+#ifdef AVAHI_API_0_6
31
+#include <avahi-client/lookup.h>
32
+#endif
30 33
 
31 34
 namespace DNSSD
32 35
 {
33 36
 
34
-#ifdef HAVE_DNSSD
35
-void domain_callback(DNSServiceRef, DNSServiceFlags flags, uint32_t, DNSServiceErrorType errorCode, 
36
-	const char *replyDomain, void *context);
37
+#ifdef AVAHI_API_0_6
38
+void domains_callback(AvahiDomainBrowser*,  AvahiIfIndex, AvahiProtocol, AvahiBrowserEvent event, const char* replyDomain,
39
+     AvahiLookupResultFlags, void* context);
40
+#else
41
+void domains_callback(AvahiDomainBrowser*,  AvahiIfIndex, AvahiProtocol, AvahiBrowserEvent event, const char* replyDomain,
42
+     void* context);
37 43
 #endif
38 44
 
39
-class DomainBrowserPrivate : public Responder
45
+
46
+class DomainBrowserPrivate 
40 47
 {
41 48
 public:
42
-	DomainBrowserPrivate(DomainBrowser* owner) : Responder(), m_browseLAN(false), m_started(false), m_owner(owner) {}
49
+	DomainBrowserPrivate(DomainBrowser* owner) : m_browseLAN(false), m_started(false), 
50
+	    m_browser(0), m_owner(owner) {}
51
+	~DomainBrowserPrivate() { if (m_browser) avahi_domain_browser_free(m_browser); }
43 52
 	QStringList m_domains;
44 53
 	virtual void customEvent(QCustomEvent* event);
45 54
 	bool m_browseLAN;
46 55
 	bool m_started;
56
+	AvahiDomainBrowser* m_browser;
47 57
 	DomainBrowser* m_owner;
48 58
 };		
49 59
 
50 60
 void DomainBrowserPrivate::customEvent(QCustomEvent* event)
51 61
 {
52
-	if (event->type()==QEvent::User+SD_ERROR) stop();
53 62
 	if (event->type()==QEvent::User+SD_ADDREMOVE) {
54 63
 		AddRemoveEvent *aev = static_cast<AddRemoveEvent*>(event);
55 64
 		if (aev->m_op==AddRemoveEvent::Add) m_owner->gotNewDomain(aev->m_domain);
56 65
 			else m_owner->gotRemoveDomain(aev->m_domain);
57 66
 	}
58 67
 }
68
+
59 69
 	
60 70
 DomainBrowser::DomainBrowser(QObject *parent) : QObject(parent)
61 71
 {
62 72
 	d = new DomainBrowserPrivate(this);
63
-	d->m_domains = Configuration::domainList();
73
+ 	d->m_domains = Configuration::domainList();
64 74
 	if (Configuration::browseLocal()) {
65 75
 		d->m_domains+="local.";
66 76
 		d->m_browseLAN=true;
67 77
 	}
68
-	connect(KApplication::kApplication(),SIGNAL(kipcMessage(int,int)),this,
69
-	        SLOT(domainListChanged(int,int)));
78
+ 	connect(KApplication::kApplication(),SIGNAL(kipcMessage(int,int)),this,
79
+ 	        SLOT(domainListChanged(int,int)));
70 80
 }
71 81
 
72 82
 DomainBrowser::DomainBrowser(const QStringList& domains, bool recursive, QObject *parent) : QObject(parent)
@@ -88,14 +98,15 @@ void DomainBrowser::startBrowse()
88 98
 	if (d->m_started) return;
89 99
 	d->m_started=true;
90 100
 	if (ServiceBrowser::isAvailable()!=ServiceBrowser::Working) return;
91
-	QStringList::const_iterator itEnd = d->m_domains.end();
101
+ 	QStringList::const_iterator itEnd = d->m_domains.end();
92 102
 	for (QStringList::const_iterator it=d->m_domains.begin(); it!=itEnd; ++it ) emit domainAdded(*it);
93
-#ifdef HAVE_DNSSD		
94
-	if (d->m_browseLAN) {
95
-		DNSServiceRef ref;
96
-		if (DNSServiceEnumerateDomains(&ref,kDNSServiceFlagsBrowseDomains,0,domain_callback,
97
-		reinterpret_cast<void*>(d))==kDNSServiceErr_NoError) d->setRef(ref);
98
-	}
103
+	if (d->m_browseLAN) 
104
+#ifdef AVAHI_API_0_6
105
+	    d->m_browser = avahi_domain_browser_new(Responder::self().client(), AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC,
106
+		"local.", AVAHI_DOMAIN_BROWSER_BROWSE, (AvahiLookupFlags)0, domains_callback, this);
107
+#else
108
+	    d->m_browser = avahi_domain_browser_new(Responder::self().client(), AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC,
109
+		"local.", AVAHI_DOMAIN_BROWSER_BROWSE, domains_callback, this);
99 110
 #endif
100 111
 }
101 112
 
@@ -115,9 +126,14 @@ void DomainBrowser::gotRemoveDomain(const QString& domain)
115 126
 void DomainBrowser::domainListChanged(int message,int)
116 127
 {
117 128
 	if (message!=KIPCDomainsChanged) return;
129
+
118 130
 	bool was_started = d->m_started;
119
-	if (d->isRunning()) d->stop(); // LAN query
131
+	if (d->m_browser) { 
132
+	    avahi_domain_browser_free(d->m_browser);  // LAN query
133
+	    d->m_browser=0;
134
+	}
120 135
 	d->m_started = false;
136
+
121 137
 	// remove all domains and resolvers
122 138
 	if (was_started) {
123 139
 		QStringList::const_iterator itEnd = d->m_domains.end();
@@ -129,7 +145,7 @@ void DomainBrowser::domainListChanged(int message,int)
129 145
 	Configuration::self()->readConfig();
130 146
 	d->m_browseLAN = Configuration::browseLocal();
131 147
 	d->m_domains = Configuration::domainList();
132
-	if (Configuration::browseLocal()) d->m_domains+="local.";
148
+	if (Configuration::browseLocal()) d->m_domains+="local";
133 149
 	// this will emit domainAdded() for every domain if necessary
134 150
 	if (was_started) startBrowse();
135 151
 }
@@ -147,22 +163,21 @@ bool DomainBrowser::isRunning() const
147 163
 void DomainBrowser::virtual_hook(int, void*)
148 164
 {}
149 165
 
150
-#ifdef HAVE_DNSSD
151
-void domain_callback(DNSServiceRef, DNSServiceFlags flags, uint32_t, DNSServiceErrorType errorCode, 
152
-	const char *replyDomain, void *context)
166
+#ifdef AVAHI_API_0_6
167
+void domains_callback(AvahiDomainBrowser*,  AvahiIfIndex, AvahiProtocol, AvahiBrowserEvent event, const char* replyDomain,
168
+     AvahiLookupResultFlags,void* context)
169
+#else
170
+void domains_callback(AvahiDomainBrowser*,  AvahiIfIndex, AvahiProtocol, AvahiBrowserEvent event, const char* replyDomain,
171
+     void* context)
172
+#endif
153 173
 {
154 174
 	QObject *obj = reinterpret_cast<QObject*>(context);
155
-	if (errorCode != kDNSServiceErr_NoError) {
156
-		ErrorEvent err;
157
-		QApplication::sendEvent(obj, &err);
158
-	} else {
159
-		AddRemoveEvent arev((flags & kDNSServiceFlagsAdd) ? AddRemoveEvent::Add :
175
+	AddRemoveEvent* arev=new AddRemoveEvent((event==AVAHI_BROWSER_NEW) ? AddRemoveEvent::Add :
160 176
 			AddRemoveEvent::Remove, QString::null, QString::null, 
161
-			DNSToDomain(replyDomain), !(flags & kDNSServiceFlagsMoreComing));
162
-		QApplication::sendEvent(obj, &arev);
163
-	}
177
+			DNSToDomain(replyDomain));
178
+		QApplication::postEvent(obj, arev);
164 179
 }
165
-#endif
180
+
166 181
 
167 182
 }
168 183
 #include "domainbrowser.moc"

+ 121
- 71
dnssd/publicservice.cpp View File

@@ -30,6 +30,12 @@
30 30
 #include <network/ksocketaddress.h>
31 31
 #include <kurl.h>
32 32
 #include <unistd.h>
33
+#include <avahi-client/client.h>
34
+#ifdef AVAHI_API_0_6
35
+#include <avahi-client/publish.h>
36
+#endif
37
+#include <avahi-common/alternative.h>
38
+#include <avahi-common/strlst.h>
33 39
 #include "sdevent.h"
34 40
 #include "responder.h"
35 41
 #include "servicebrowser.h"
@@ -38,16 +44,23 @@
38 44
 namespace DNSSD
39 45
 {
40 46
 static unsigned long publicIP();
41
-#ifdef HAVE_DNSSD
42
-void publish_callback (DNSServiceRef, DNSServiceFlags, DNSServiceErrorType errorCode, const char *name,
43
-		       const char*, const char*, void *context);
44
-#endif
45
-class PublicServicePrivate : public Responder
47
+
48
+void publish_callback (AvahiEntryGroup*, AvahiEntryGroupState s,  void *context);
49
+
50
+class PublicServicePrivate 
46 51
 {
47 52
 public:
48
-	PublicServicePrivate() : m_published(false)
53
+	PublicServicePrivate() : m_published(false), m_running(false), m_collision(false), m_group(false)
49 54
 	{}
50 55
 	bool m_published;
56
+	bool m_running;
57
+	bool m_collision;
58
+	AvahiEntryGroup* m_group;
59
+	void commit()
60
+	{
61
+	    if (!m_collision) avahi_entry_group_commit(m_group);
62
+	}    
63
+	
51 64
 };
52 65
 
53 66
 PublicService::PublicService(const QString& name, const QString& type, unsigned int port,
@@ -55,6 +68,10 @@ PublicService::PublicService(const QString& name, const QString& type, unsigned
55 68
   		: QObject(), ServiceBase(name, type, QString::null, domain, port)
56 69
 {
57 70
 	d = new PublicServicePrivate;
71
+	if (Responder::self().client()) { 
72
+		d->m_group = avahi_entry_group_new(Responder::self().client(), publish_callback,this);
73
+		connect(&Responder::self(),SIGNAL(stateChanged(AvahiClientState)),this,SLOT(clientState(AvahiClientState)));
74
+	}
58 75
 	if (domain.isNull())
59 76
 		if (Configuration::publishType()==Configuration::EnumPublishType::LAN) m_domain="local.";
60 77
 		else m_domain=Configuration::publishDomain();
@@ -63,114 +80,148 @@ PublicService::PublicService(const QString& name, const QString& type, unsigned
63 80
 
64 81
 PublicService::~PublicService()
65 82
 {
66
-	stop();
83
+	if (d->m_group) avahi_entry_group_free(d->m_group);
67 84
 	delete d;
68 85
 }
69 86
 
87
+void PublicService::tryApply()
88
+{
89
+    if (fillEntryGroup()) d->commit();
90
+    else {
91
+	stop();
92
+	emit published(false);
93
+    }
94
+}
95
+
70 96
 void PublicService::setServiceName(const QString& serviceName)
71 97
 {
72 98
 	m_serviceName = serviceName;
73
-	if (d->isRunning()) {
74
-		stop();
75
-		publishAsync();
76
-	}
99
+	if (d->m_running) {
100
+	    avahi_entry_group_reset(d->m_group);
101
+	    tryApply();
102
+	} 
77 103
 }
78 104
 
79 105
 void PublicService::setDomain(const QString& domain)
80 106
 {
81 107
 	m_domain = domain;
82
-	if (d->isRunning()) {
83
-	stop();
84
-	publishAsync();
85
-	}
108
+	if (d->m_running) {
109
+	    avahi_entry_group_reset(d->m_group);
110
+	    tryApply();
111
+	} 
86 112
 }
87 113
 
88 114
 
89 115
 void PublicService::setType(const QString& type)
90 116
 {
91 117
 	m_type = type;
92
-	if (d->isRunning()) {
93
-		stop();
94
-		publishAsync();
95
-	}
118
+	if (d->m_running) {
119
+	    avahi_entry_group_reset(d->m_group);
120
+	    tryApply();
121
+	} 
96 122
 }
97 123
 
98 124
 void PublicService::setPort(unsigned short port)
99 125
 {
100 126
 	m_port = port;
101
-	if (d->isRunning()) {
102
-		stop();
103
-		publishAsync();
104
-	}
127
+	if (d->m_running) {
128
+	    avahi_entry_group_reset(d->m_group);
129
+	    tryApply();
130
+    	} 
105 131
 }
106 132
 
107
-bool PublicService::isPublished() const
133
+void PublicService::setTextData(const QMap<QString,QString>& textData)
108 134
 {
109
-	return d->m_published;
135
+	m_textData = textData;
136
+	if (d->m_running) {
137
+	    avahi_entry_group_reset(d->m_group);
138
+	    tryApply();
139
+	} 
110 140
 }
111 141
 
112
-void PublicService::setTextData(const QMap<QString,QString>& textData)
142
+bool PublicService::isPublished() const
113 143
 {
114
-	m_textData = textData;
115
-	if (d->isRunning()) {
116
-		stop();
117
-		publishAsync();
118
-	}
144
+	return d->m_published;
119 145
 }
120 146
 
121 147
 bool PublicService::publish()
122 148
 {
123 149
 	publishAsync();
124
-	while (d->isRunning() && !d->m_published) d->process();
150
+	while (d->m_running && !d->m_published) Responder::self().process();
125 151
 	return d->m_published;
126 152
 }
127 153
 
128 154
 void PublicService::stop()
129 155
 {
130
-	d->stop();
131
-	d->m_published = false;
156
+    if (d->m_group) avahi_entry_group_reset(d->m_group);
157
+    d->m_published = false;
158
+}
159
+bool PublicService::fillEntryGroup()
160
+{
161
+    AvahiStringList *s=0;
162
+    QMap<QString,QString>::ConstIterator itEnd = m_textData.end();
163
+    for (QMap<QString,QString>::ConstIterator it = m_textData.begin(); it!=itEnd ; ++it) 
164
+	s = avahi_string_list_add_pair(s, it.key().utf8(),it.data().utf8());
165
+#ifdef AVAHI_API_0_6
166
+    bool res = (!avahi_entry_group_add_service_strlst(d->m_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, (AvahiPublishFlags)0, 
167
+	m_serviceName.isNull() ? avahi_client_get_host_name(Responder::self().client()) : m_serviceName.utf8().data(),
168
+	m_type.ascii(),domainToDNS(m_domain),m_hostName.utf8(),m_port,s));
169
+#else
170
+    bool res = (!avahi_entry_group_add_service_strlst(d->m_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 
171
+	m_serviceName.isNull() ? avahi_client_get_host_name(Responder::self().client()) : m_serviceName.utf8().data(),
172
+	m_type.ascii(),m_domain.utf8(),m_hostName.utf8(),m_port,s));
173
+#endif
174
+    avahi_string_list_free(s);
175
+    return res;
132 176
 }
133 177
 
178
+void PublicService::clientState(AvahiClientState s)
179
+{
180
+    if (!d->m_running) return;
181
+    switch (s) {
182
+#ifdef AVAHI_API_0_6
183
+	case AVAHI_CLIENT_FAILURE:
184
+#else
185
+	case AVAHI_CLIENT_S_INVALID:
186
+	case AVAHI_CLIENT_DISCONNECTED:
187
+#endif
188
+	    stop();
189
+	    emit published(false);
190
+	    break;
191
+	case AVAHI_CLIENT_S_REGISTERING:
192
+	case AVAHI_CLIENT_S_COLLISION:
193
+	    avahi_entry_group_reset(d->m_group);
194
+	    d->m_collision=true;
195
+	    break;
196
+	case AVAHI_CLIENT_S_RUNNING:
197
+	    if (d->m_collision) {
198
+		d->m_collision=false;
199
+		tryApply();
200
+	    }
201
+    }
202
+}				    
203
+
134 204
 void PublicService::publishAsync()
135 205
 {
136
-	if (d->isRunning()) stop();
137
-#ifdef HAVE_DNSSD
138
-	if (ServiceBrowser::isAvailable()==ServiceBrowser::Working) {
139
-		TXTRecordRef txt;
140
-		TXTRecordCreate(&txt,0,0);
141
-		QMap<QString,QString>::ConstIterator itEnd = m_textData.end();
142
-		for (QMap<QString,QString>::ConstIterator it = m_textData.begin(); it!=itEnd ; ++it) {
143
-			QCString value = it.data().utf8();
144
-			if (TXTRecordSetValue(&txt,it.key().utf8(),value.length(),value)!=kDNSServiceErr_NoError) {
145
-				TXTRecordDeallocate(&txt);
146
-				emit published(false);
147
-				return;
148
-			}
149
-		}
150
-		DNSServiceRef ref;
151
-		if (DNSServiceRegister(&ref,0,0,m_serviceName.utf8(),m_type.ascii(),domainToDNS(m_domain),NULL,
152
-		    htons(m_port),TXTRecordGetLength(&txt),TXTRecordGetBytesPtr(&txt),publish_callback,
153
-		    reinterpret_cast<void*>(this)) == kDNSServiceErr_NoError) d->setRef(ref);
154
-		TXTRecordDeallocate(&txt);
206
+	if (d->m_running) stop();
207
+	
208
+	if (!d->m_group) {
209
+	    emit published(false);
210
+	    return;
155 211
 	}
156
-#endif
157
-	if (!d->isRunning()) emit published(false);
212
+	AvahiClientState s=Responder::self().state();
213
+	d->m_running=true; 
214
+	d->m_collision=true; // make it look like server is getting out of collision to force registering
215
+	clientState(s);
158 216
 }
159 217
 
160
-#ifdef HAVE_DNSSD
161
-void publish_callback (DNSServiceRef, DNSServiceFlags, DNSServiceErrorType errorCode, const char *name,
162
-		       const char*, const char*, void *context)
218
+void publish_callback (AvahiEntryGroup*, AvahiEntryGroupState s,  void *context)
163 219
 {
164 220
 	QObject *obj = reinterpret_cast<QObject*>(context);
165
-	if (errorCode != kDNSServiceErr_NoError) {
166
-		ErrorEvent err;
167
-		QApplication::sendEvent(obj, &err);
168
-	} else {
169
-		PublishEvent pev(QString::fromUtf8(name));
170
-		QApplication::sendEvent(obj, &pev);
171
-	}
221
+	if (s!=AVAHI_ENTRY_GROUP_ESTABLISHED && s!=AVAHI_ENTRY_GROUP_COLLISION) return;
222
+	PublishEvent* pev=new PublishEvent(s==AVAHI_ENTRY_GROUP_ESTABLISHED);
223
+	QApplication::postEvent(obj, pev);
172 224
 }
173
-#endif
174 225
 
175 226
 const KURL PublicService::toInvitation(const QString& host)
176 227
 {
@@ -194,14 +245,13 @@ const KURL PublicService::toInvitation(const QString& host)
194 245
 
195 246
 void PublicService::customEvent(QCustomEvent* event)
196 247
 {
197
-	if (event->type()==QEvent::User+SD_ERROR) {
198
-		stop();
199
-		emit published(false);
200
-	}
201 248
 	if (event->type()==QEvent::User+SD_PUBLISH) {
249
+		if (!static_cast<PublishEvent*>(event)->m_ok) {
250
+		    setServiceName(QString::fromUtf8(avahi_alternative_service_name(m_serviceName.utf8())));
251
+		    return;
252
+		}
202 253
 		d->m_published=true;
203 254
 		emit published(true);
204
-		m_serviceName = static_cast<PublishEvent*>(event)->m_name;
205 255
 	}
206 256
 }
207 257
 

+ 5
- 0
dnssd/publicservice.h View File

@@ -23,6 +23,7 @@
23 23
 
24 24
 #include <qobject.h>
25 25
 #include <dnssd/servicebase.h>
26
+#include <avahi-client/client.h>
26 27
 
27 28
 class KURL;
28 29
 namespace DNSSD
@@ -137,6 +138,10 @@ signals:
137 138
 	void published(bool);
138 139
 private:
139 140
 	PublicServicePrivate *d;
141
+	bool fillEntryGroup();
142
+	void tryApply();
143
+private slots:
144
+	void clientState(AvahiClientState);
140 145
 
141 146
 protected:
142 147
 	virtual void customEvent(QCustomEvent* event);

+ 89
- 43
dnssd/query.cpp View File

@@ -22,26 +22,46 @@
22 22
 #include "responder.h"
23 23
 #include "remoteservice.h"
24 24
 #include "sdevent.h"
25
-#include <kdebug.h>
25
+#include <qdatetime.h>
26 26
 #include <qapplication.h>
27 27
 #include <qtimer.h>
28 28
 
29
-#define TIMEOUT_WAN 2000
29
+#include <avahi-client/client.h>
30
+#ifdef AVAHI_API_0_6
31
+#include <avahi-client/lookup.h>
32
+#endif
33
+
30 34
 #define TIMEOUT_LAN 200
31 35
 
32 36
 namespace DNSSD
33 37
 {
34
-#ifdef HAVE_DNSSD  
35
-void query_callback (DNSServiceRef, DNSServiceFlags flags, uint32_t, DNSServiceErrorType errorCode,
36
-		     const char *serviceName, const char *regtype, const char *replyDomain, void *context);
38
+#ifdef AVAHI_API_0_6
39
+
40
+void services_callback(AvahiServiceBrowser*, AvahiIfIndex, AvahiProtocol, AvahiBrowserEvent event, const char* name,
41
+    const char* regtype, const char* domain, AvahiLookupResultFlags, void* context);
42
+void types_callback(AvahiServiceTypeBrowser*, AvahiIfIndex, AvahiProtocol, AvahiBrowserEvent event, const char* regtype,
43
+    const char* replyDomain, AvahiLookupResultFlags, void* context);
44
+#else
45
+void services_callback(AvahiServiceBrowser*, AvahiIfIndex, AvahiProtocol, AvahiBrowserEvent event, const char* name,
46
+    const char* regtype, const char* domain, void* context);
47
+void types_callback(AvahiServiceTypeBrowser*, AvahiIfIndex, AvahiProtocol, AvahiBrowserEvent event, const char* regtype,
48
+    const char* replyDomain, void* context);
49
+void domains_callback(AvahiDomainBrowser*,  AvahiIfIndex, AvahiProtocol, AvahiBrowserEvent event, const char* replyDomain,
50
+     void* context);
37 51
 #endif
38
-class QueryPrivate : public Responder
52
+
53
+enum BrowserType { Types, Services };
54
+
55
+class QueryPrivate 
39 56
 {
40 57
 public:
41
-	QueryPrivate(const QString& type, const QString& domain) : Responder(), m_finished(false),
42
-	m_domain(domain), m_type(type)
43
-	{};
58
+	QueryPrivate(const QString& type, const QString& domain) : m_finished(false), m_browser(0),
59
+	m_running(false), m_domain(domain), m_type(type) {}
60
+
44 61
 	bool m_finished;
62
+	BrowserType m_browserType;
63
+	void* m_browser;
64
+	bool m_running;
45 65
 	QString m_domain;
46 66
 	QTimer timeout;
47 67
 	QString m_type;
@@ -56,12 +76,18 @@ Query::Query(const QString& type, const QString& domain)
56 76
 
57 77
 Query::~Query()
58 78
 {
79
+	if (d->m_browser) {
80
+	    switch (d->m_browserType) {
81
+		case Services: avahi_service_browser_free((AvahiServiceBrowser*)d->m_browser); break;
82
+		case Types: avahi_service_type_browser_free((AvahiServiceTypeBrowser*)d->m_browser); break;
83
+	    }
84
+	}		    
59 85
 	delete d;
60 86
 }
61 87
 
62 88
 bool Query::isRunning() const
63 89
 {
64
-	return d->isRunning();
90
+	return d->m_running;
65 91
 }
66 92
 
67 93
 bool Query::isFinished() const
@@ -76,16 +102,31 @@ const QString& Query::domain() const
76 102
 
77 103
 void Query::startQuery()
78 104
 {
79
-	if (d->isRunning()) return;
105
+	if (d->m_running) return;
80 106
 	d->m_finished = false;
81
-#ifdef HAVE_DNSSD
82
-	DNSServiceRef ref;
83
-	if (DNSServiceBrowse(&ref,0,0, d->m_type.ascii(), 
84
-	    domainToDNS(d->m_domain),query_callback,reinterpret_cast<void*>(this))
85
-		   == kDNSServiceErr_NoError) d->setRef(ref);
107
+	if (d->m_type=="_services._dns-sd._udp") {
108
+	    d->m_browserType = Types;
109
+#ifdef AVAHI_API_0_6
110
+	    d->m_browser = avahi_service_type_browser_new(Responder::self().client(), AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC,
111
+		domainToDNS(d->m_domain), (AvahiLookupFlags)0, types_callback, this);
112
+#else
113
+	    d->m_browser = avahi_service_type_browser_new(Responder::self().client(), AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC,
114
+		d->m_domain.utf8(), types_callback, this);
86 115
 #endif
87
-	if (!d->isRunning()) emit finished();
88
-		else d->timeout.start(domainIsLocal(d->m_domain) ? TIMEOUT_LAN : TIMEOUT_WAN,true);
116
+	} else {
117
+	    d->m_browserType = Services;
118
+#ifdef AVAHI_API_0_6
119
+	    d->m_browser = avahi_service_browser_new(Responder::self().client(), AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC,
120
+	    d->m_type.ascii(),domainToDNS(d->m_domain),  (AvahiLookupFlags)0, services_callback,this);
121
+#else
122
+	    d->m_browser = avahi_service_browser_new(Responder::self().client(), AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC,
123
+	    d->m_type.ascii(),d->m_domain.utf8(),services_callback,this);
124
+#endif
125
+	}
126
+	if (d->m_browser) {
127
+		d->m_running=true;
128
+		d->timeout.start(TIMEOUT_LAN,true);
129
+	} else emit finished();
89 130
 }
90 131
 void Query::virtual_hook(int, void*)
91 132
 {
@@ -93,24 +134,15 @@ void Query::virtual_hook(int, void*)
93 134
 
94 135
 void Query::customEvent(QCustomEvent* event)
95 136
 {
96
-	if (event->type()==QEvent::User+SD_ERROR) {
97
-		d->stop();
98
-		d->m_finished=false;
99
-		emit finished();
100
-	}
101 137
 	if (event->type()==QEvent::User+SD_ADDREMOVE) {
102
-		RemoteService* svr;
138
+		d->timeout.start(TIMEOUT_LAN,true);
139
+		d->m_finished=false;
103 140
 		AddRemoveEvent *aev = static_cast<AddRemoveEvent*>(event);
104 141
 		// m_type has useless trailing dot
105
-		QString type=aev->m_type.left(aev->m_type.length()-1);
106
-		// label is badly splitted here - _http   _tcp.local. . - rely on decode()
107
-		if (d->m_type=="_services._dns-sd._udp") svr = new RemoteService(aev->m_name+"."+
108
-			type+"."+aev->m_domain);
109
-		else svr = new RemoteService(aev->m_name, type, aev->m_domain);
142
+		RemoteService*  svr = new RemoteService(aev->m_name,
143
+		    	aev->m_type,aev->m_domain);
110 144
 		if (aev->m_op==AddRemoveEvent::Add) emit serviceAdded(svr);
111 145
 			else emit serviceRemoved(svr);
112
-		d->m_finished = aev->m_last;
113
-		if (d->m_finished) emit finished();
114 146
 	}
115 147
 }
116 148
 
@@ -119,22 +151,36 @@ void Query::timeout()
119 151
 	d->m_finished=true;
120 152
 	emit finished();
121 153
 }
122
-#ifdef HAVE_DNSSD
123
-void query_callback (DNSServiceRef, DNSServiceFlags flags, uint32_t, DNSServiceErrorType errorCode,
124
-		     const char *serviceName, const char *regtype, const char *replyDomain,
125
-		     void *context)
154
+
155
+#ifdef AVAHI_API_0_6
156
+void services_callback (AvahiServiceBrowser*, AvahiIfIndex, AvahiProtocol, AvahiBrowserEvent event, 
157
+    const char* serviceName, const char* regtype, const char* replyDomain, AvahiLookupResultFlags, void* context)
158
+#else
159
+void services_callback (AvahiServiceBrowser*, AvahiIfIndex, AvahiProtocol, AvahiBrowserEvent event, 
160
+    const char* serviceName, const char* regtype, const char* replyDomain, void* context)
161
+#endif
126 162
 {
127 163
 	QObject *obj = reinterpret_cast<QObject*>(context);
128
-	if (errorCode != kDNSServiceErr_NoError) {
129
-		ErrorEvent err;
130
-		QApplication::sendEvent(obj, &err);
131
-	} else {
132
-		AddRemoveEvent arev((flags & kDNSServiceFlagsAdd) ? AddRemoveEvent::Add :
164
+	AddRemoveEvent* arev = new AddRemoveEvent((event==AVAHI_BROWSER_NEW) ? AddRemoveEvent::Add :
133 165
 			AddRemoveEvent::Remove, QString::fromUtf8(serviceName), regtype, 
134
-			DNSToDomain(replyDomain), !(flags & kDNSServiceFlagsMoreComing));
135
-		QApplication::sendEvent(obj, &arev);
136
-	}
166
+			DNSToDomain(replyDomain));
167
+		QApplication::postEvent(obj, arev);
137 168
 }
169
+
170
+#ifdef AVAHI_API_0_6
171
+void types_callback(AvahiServiceTypeBrowser*, AvahiIfIndex, AvahiProtocol, AvahiBrowserEvent event, const char* regtype,
172
+    const char* replyDomain, AvahiLookupResultFlags, void* context)
173
+#else
174
+void types_callback(AvahiServiceTypeBrowser*, AvahiIfIndex, AvahiProtocol, AvahiBrowserEvent event, const char* regtype,
175
+    const char* replyDomain, void* context)
138 176
 #endif
177
+{
178
+	QObject *obj = reinterpret_cast<QObject*>(context);
179
+	AddRemoveEvent* arev = new AddRemoveEvent((event==AVAHI_BROWSER_NEW) ? AddRemoveEvent::Add :
180
+			AddRemoveEvent::Remove, QString::null, regtype, 
181
+			DNSToDomain(replyDomain));
182
+		QApplication::postEvent(obj, arev);
183
+}
184
+
139 185
 }
140 186
 #include "query.moc"

+ 53
- 52
dnssd/remoteservice.cpp View File

@@ -27,33 +27,39 @@
27 27
 #include <sys/types.h>
28 28
 #endif
29 29
 #include <netinet/in.h>
30
+#include <avahi-client/client.h>
31
+#include <avahi-common/strlst.h>
32
+#ifdef AVAHI_API_0_6
33
+#include <avahi-client/lookup.h>
34
+#endif
30 35
 #include "remoteservice.h"
31 36
 #include "responder.h"
32 37
 #include "sdevent.h"
33
-#include <kdebug.h>
34 38
 
35 39
 namespace DNSSD
36 40
 {
37
-#ifdef HAVE_DNSSD
38
-void resolve_callback    (    DNSServiceRef,
39
-				DNSServiceFlags,
40
-				uint32_t,
41
-				DNSServiceErrorType                 errorCode,
42
-				const char*,
43
-				const char                          *hosttarget,
44
-				uint16_t                            port,
45
-				uint16_t                            txtLen,
46
-				const unsigned char                 *txtRecord,
47
-				void                                *context
48
-			 );
49
-
41
+#ifdef AVAHI_API_0_6
42
+void resolve_callback(AvahiServiceResolver*, AvahiIfIndex, AvahiProtocol proto, AvahiResolverEvent e,
43
+    const char* name, const char* type, const char* domain, const char* hostname, const AvahiAddress* a,
44
+    uint16_t port, AvahiStringList* txt, AvahiLookupResultFlags, void* context);
45
+#else
46
+void resolve_callback(AvahiServiceResolver*, AvahiIfIndex, AvahiProtocol proto, AvahiResolverEvent e,
47
+    const char* name, const char* type, const char* domain, const char* hostname, const AvahiAddress* a,
48
+    uint16_t port, AvahiStringList* txt, void* context);
50 49
 #endif
50
+
51 51
 class RemoteServicePrivate : public Responder
52 52
 {
53 53
 public:
54
-	RemoteServicePrivate() : Responder(), m_resolved(false)
55
-	{};
54
+	RemoteServicePrivate() :  m_resolved(false), m_running(false), m_resolver(0) {}
56 55
 	bool m_resolved;
56
+	bool m_running;
57
+	AvahiServiceResolver* m_resolver;
58
+	void stop() {
59
+	    m_running = false;
60
+	    if (m_resolver) avahi_service_resolver_free(m_resolver);
61
+	    m_resolver=0;
62
+	}
57 63
 };
58 64
 
59 65
 RemoteService::RemoteService(const QString& label)
@@ -83,29 +89,33 @@ RemoteService::RemoteService(const KURL& url)
83 89
 
84 90
 RemoteService::~RemoteService()
85 91
 {
92
+	if (d->m_resolver) avahi_service_resolver_free(d->m_resolver);
86 93
 	delete d;
87 94
 }
88 95
 
89 96
 bool RemoteService::resolve()
90 97
 {
91 98
 	resolveAsync();
92
-	while (d->isRunning() && !d->m_resolved) d->process();
99
+	while (d->m_running && !d->m_resolved) Responder::self().process();
93 100
 	d->stop();
94 101
 	return d->m_resolved;
95 102
 }
96 103
 
97 104
 void RemoteService::resolveAsync()
98 105
 {
99
-	if (d->isRunning()) return;
106
+	if (d->m_running) return;
100 107
 	d->m_resolved = false;
101
-	kdDebug() << this << ":Starting resolve of : " << m_serviceName << " " << m_type << " " << m_domain << "\n";
102
-#ifdef HAVE_DNSSD
103
-	DNSServiceRef ref;
104
-	if (DNSServiceResolve(&ref,0,0,m_serviceName.utf8(), m_type.ascii(), 
105
-		domainToDNS(m_domain),(DNSServiceResolveReply)resolve_callback,reinterpret_cast<void*>(this))
106
-		== kDNSServiceErr_NoError) d->setRef(ref);
108
+	// FIXME: first protocol should be set?
109
+#ifdef AVAHI_API_0_6
110
+	d->m_resolver = avahi_service_resolver_new(Responder::self().client(),AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC,
111
+	    m_serviceName.utf8(), m_type.ascii(), domainToDNS(m_domain), AVAHI_PROTO_UNSPEC, AVAHI_LOOKUP_NO_ADDRESS,
112
+	    resolve_callback, this);
113
+#else
114
+	d->m_resolver = avahi_service_resolver_new(Responder::self().client(),AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC,
115
+	    m_serviceName.utf8(), m_type.ascii(), m_domain.utf8(), AVAHI_PROTO_UNSPEC, resolve_callback, this);
107 116
 #endif
108
-	if (!d->isRunning()) emit resolved(false);
117
+	if (d->m_resolver) d->m_running=true;
118
+	    else  emit resolved(false);
109 119
 }
110 120
 
111 121
 bool RemoteService::isResolved() const
@@ -154,42 +164,33 @@ QDataStream & operator>> (QDataStream & s, RemoteService & a)
154 164
 	return s;
155 165
 }
156 166
 
157
-
158
-#ifdef HAVE_DNSSD
159
-void resolve_callback    (    DNSServiceRef,
160
-			      DNSServiceFlags,
161
-			      uint32_t,
162
-			      DNSServiceErrorType                 errorCode,
163
-			      const char*,
164
-			      const char                          *hosttarget,
165
-			      uint16_t                            port,
166
-			      uint16_t                            txtLen,
167
-			      const unsigned char                 *txtRecord,
168
-			      void                                *context
169
-			 )
167
+#ifdef AVAHI_API_0_6
168
+void resolve_callback(AvahiServiceResolver*, AvahiIfIndex, AvahiProtocol, AvahiResolverEvent e,
169
+    const char*, const char*, const char*, const char* hostname, const AvahiAddress*,
170
+    uint16_t port, AvahiStringList* txt, AvahiLookupResultFlags, void* context)
171
+#else
172
+void resolve_callback(AvahiServiceResolver*, AvahiIfIndex, AvahiProtocol, AvahiResolverEvent e,
173
+    const char*, const char*, const char*, const char* hostname, const AvahiAddress*,
174
+    uint16_t port, AvahiStringList* txt, void* context)
175
+#endif
170 176
 {
171 177
 	QObject *obj = reinterpret_cast<QObject*>(context);
172
-	if (errorCode != kDNSServiceErr_NoError) {
178
+	if (e != AVAHI_RESOLVER_FOUND) {
173 179
 		ErrorEvent err;
174 180
 		QApplication::sendEvent(obj, &err);	
175 181
 		return;
176 182
 	}
177
-	char key[256];
178
-	int index=0;
179
-	unsigned char valueLen;
180
-	kdDebug() << "Resolve callback\n";
181 183
 	QMap<QString,QString> map;
182
-        const void *voidValue = 0;
183
-	while (TXTRecordGetItemAtIndex(txtLen,txtRecord,index++,256,key,&valueLen,
184
-		&voidValue) == kDNSServiceErr_NoError)  
185
-        {
186
-		if (voidValue) map[QString::fromUtf8(key)]=QString::fromUtf8((const char*)voidValue,valueLen);
187
-			else map[QString::fromUtf8(key)]=QString::null;
188
-        }
189
-	ResolveEvent rev(DNSToDomain(hosttarget),ntohs(port),map);
184
+	while (txt) {
185
+	    char *key, *value;
186
+	    size_t size;
187
+	    if (avahi_string_list_get_pair(txt,&key,&value,&size)) break;
188
+	    map[QString::fromUtf8(key)]=(value) ? QString::fromUtf8(value) : QString::null;
189
+	    txt = txt->next;
190
+	}
191
+	ResolveEvent rev(DNSToDomain(hostname),port,map);
190 192
 	QApplication::sendEvent(obj, &rev);
191 193
 }
192
-#endif
193 194
 
194 195
 
195 196
 }

+ 33
- 42
dnssd/responder.cpp View File

@@ -20,62 +20,61 @@
20 20
 
21 21
 #include "responder.h"
22 22
 #include <qapplication.h>
23
+#include <qeventloop.h>
24
+#include <kstaticdeleter.h>
23 25
 #include <kidna.h>
26
+#include <kdebug.h>
27
+#include <avahi-qt3/qt-watch.h>
24 28
 
25
-// dns_sd.h API should care about proper encoding of non-latin1 characters
26
-// but for now it does not
27
-#define IDN_BROKEN_IN_MDNSRESPONDER
28 29
 
29 30
 namespace DNSSD
30 31
 {
31 32
 
32
-Responder::Responder(DNSServiceRef ref,QObject *parent, const char *name)
33
-		: QObject(parent, name), m_ref(0), m_socket(0)
33
+static KStaticDeleter<Responder> responder_sd;
34
+Responder* Responder::m_self = 0;
35
+
36
+void client_callback(AvahiClient *, AvahiClientState s, void* u) 
34 37
 {
35
-	setRef(ref);
38
+    Responder *r = reinterpret_cast<Responder*>(u);    
39
+    emit (r->stateChanged(s));
36 40
 }
37
- 
38
-void Responder::setRef(DNSServiceRef ref)
41
+
42
+
43
+Responder::Responder()
39 44
 {
40
-	if (m_socket || m_ref) stop();	
41
-	m_running = false;
42
-	m_ref = ref;
43
-	if (m_ref == 0 ) return;
44
-#ifdef HAVE_DNSSD
45
-	int fd = DNSServiceRefSockFD(ref);
46
-	if (fd == -1) return;
47
-	m_socket = new QSocketNotifier(fd,QSocketNotifier::Read,this);
48
-	connect(m_socket,SIGNAL(activated(int)),this,SLOT(process()));
49
-	m_running = true;
45
+    int error;
46
+    const AvahiPoll* poll = avahi_qt_poll_get();
47
+#ifdef AVAHI_API_0_6
48
+    m_client = avahi_client_new(poll, AVAHI_CLIENT_IGNORE_USER_CONFIG,client_callback, this,  &error);
49
+#else
50
+    m_client = avahi_client_new(poll, client_callback, this,  &error);
50 51
 #endif
52
+    if (!m_client) kdWarning() << "Failed to create avahi client" << endl;
51 53
 }
54
+ 
52 55
 Responder::~Responder()
53 56
 {
54
-	stop();
57
+    if (m_client) avahi_client_free(m_client);
55 58
 }
56 59
 
57
-void Responder::stop()
60
+Responder& Responder::self()
58 61
 {
59
-	if (m_socket) delete m_socket;
60
-	m_socket = 0;
61
-#ifdef HAVE_DNSSD
62
-	if (m_ref) DNSServiceRefDeallocate(m_ref);
63
-#endif
64
-	m_ref = 0;
65
-	m_running = false;
66
-}	
67
-
62
+    if (!m_self) responder_sd.setObject(m_self, new Responder);
63
+    return *m_self;
64
+}
68 65
 
69 66
 void Responder::process()
70 67
 {
71
-#ifdef HAVE_DNSSD
72
-	if ( DNSServiceProcessResult(m_ref) != kDNSServiceErr_NoError) stop();
73
-#endif
68
+    qApp->eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
74 69
 }
75 70
 
76
-bool Responder::isRunning() const
71
+AvahiClientState Responder::state() const
77 72
 {
78
-	return m_running;
73
+#ifdef AVAHI_API_0_6
74
+	return (m_client) ? (avahi_client_get_state(m_client)) : AVAHI_CLIENT_FAILURE;
75
+#else
76
+	return (m_client) ? (avahi_client_get_state(m_client)) : AVAHI_CLIENT_DISCONNECTED;
77
+#endif
79 78
 }
80 79
 
81 80
 bool domainIsLocal(const QString& domain)
@@ -85,22 +84,14 @@ bool domainIsLocal(const QString& domain)
85 84
 
86 85
 QCString domainToDNS(const QString &domain)
87 86
 {
88
-#ifdef IDN_BROKEN_IN_MDNSRESPONDER
89 87
 	if (domainIsLocal(domain)) return domain.utf8();
90 88
 		else return KIDNA::toAsciiCString(domain);
91
-#else
92
-	return domain.utf8();       
93
-#endif
94 89
 }
95 90
 
96 91
 QString DNSToDomain(const char* domain)
97 92
 {
98
-#ifdef IDN_BROKEN_IN_MDNSRESPONDER
99 93
 	if (domainIsLocal(domain)) return QString::fromUtf8(domain);
100 94
 		else return KIDNA::toUnicode(domain);
101
-#else
102
-	return QString::fromUtf8(domain);
103
-#endif
104 95
 }
105 96
 
106 97
 

+ 14
- 20
dnssd/responder.h View File

@@ -25,12 +25,7 @@
25 25
 #include <qsocketnotifier.h>
26 26
 #include <qsignal.h>
27 27
 #include <config.h>
28
-#ifdef HAVE_DNSSD
29
-#include <dns_sd.h>
30
-#else
31
-#define DNSServiceRef void*
32
-#endif
33
-
28
+#include <avahi-client/client.h>
34 29
 namespace DNSSD
35 30
 {
36 31
 
@@ -38,30 +33,28 @@ namespace DNSSD
38 33
 This class should not be used directly.
39 34
  
40 35
 @author Jakub Stachowski
41
-@short Internal class wrapping dns_sd.h interface
36
+@short Internal class wrapping avahi client
42 37
  */
43 38
 class Responder : public QObject
44 39
 {
45 40
 	Q_OBJECT
46 41
 
47 42
 public:
48
-	Responder(DNSServiceRef ref=0,QObject *parent = 0, const char *name = 0);
43
+	Responder();
49 44
 
50 45
 	~Responder();
51 46
 
52
-	/**
53
-	Returns true if it is possible to use mDNS service publishing and discovery. 
54
-	It needs mDNSResponder running.
55
-	 */
56
-	bool isRunning() const;
57
-	void setRef(DNSServiceRef ref);
58
-	void stop();
59
-public slots:
47
+	static Responder& self();
48
+	AvahiClientState state() const;
49
+	AvahiClient* client() const { return m_client; }
60 50
 	void process();
61
-protected:
62
-	DNSServiceRef m_ref;
63
-	bool m_running;
64
-	QSocketNotifier *m_socket;
51
+signals:
52
+	void stateChanged(AvahiClientState);
53
+private:
54
+	AvahiClient* m_client;
55
+	static Responder* m_self;
56
+	friend void client_callback(AvahiClient*, AvahiClientState, void*);
57
+
65 58
 };
66 59
 
67 60
 /* Utils functions */
@@ -71,6 +64,7 @@ bool domainIsLocal(const QString& domain);
71 64
 QCString domainToDNS(const QString &domain);
72 65
 QString DNSToDomain(const char* domain);
73 66
 
67
+
74 68
 }
75 69
 
76 70
 #endif

+ 4
- 5
dnssd/sdevent.h View File

@@ -41,24 +41,23 @@ class AddRemoveEvent : public QCustomEvent
41 41
 public:
42 42
 	enum Operation { Add, Remove };
43 43
 	AddRemoveEvent(Operation op,const QString& name,const QString& type,
44
-		const QString& domain, bool last) : QCustomEvent(QEvent::User+SD_ADDREMOVE),
45
-	m_op(op), m_name(name), m_type(type), m_domain(domain), m_last(last) 
44
+		const QString& domain) : QCustomEvent(QEvent::User+SD_ADDREMOVE),
45
+	m_op(op), m_name(name), m_type(type), m_domain(domain) 
46 46
 	{}
47 47
 
48 48
 	const Operation m_op;
49 49
 	const QString m_name;
50 50
 	const QString m_type;
51 51
 	const QString m_domain;
52
-	const bool m_last;
53 52
 };
54 53
 
55 54
 class PublishEvent : public QCustomEvent
56 55
 {
57 56
 public:
58
-	PublishEvent(const QString& name) : QCustomEvent(QEvent::User+SD_PUBLISH), m_name(name)
57
+	PublishEvent(bool ok) : QCustomEvent(QEvent::User+SD_PUBLISH), m_ok(ok)
59 58
 	{}
60 59
 
61
-	const QString m_name;
60
+	bool m_ok;
62 61
 };
63 62
 
64 63
 class ResolveEvent : public QCustomEvent

+ 1
- 1
dnssd/servicebase.cpp View File

@@ -34,7 +34,7 @@ ServiceBase::~ServiceBase()
34 34
 
35 35
 QString ServiceBase::encode()
36 36
 {
37
-	return  m_serviceName.replace("\\","\\\\").replace(".","\\.") + QString(".") + m_type +
37
+	return  m_serviceName.replace(".","\\.").replace("\\","\\\\") + QString(".") + m_type +
38 38
 			 QString(".") + m_domain;
39 39
 }
40 40
 

+ 7
- 18
dnssd/servicebrowser.cpp View File

@@ -23,14 +23,11 @@
23 23
 #include <qstringlist.h>
24 24
 #include <qfile.h>
25 25
 #include "domainbrowser.h"
26
+#include "responder.h"
26 27
 #include "query.h"
27 28
 #include "servicebrowser.h"
29
+#include <avahi-client/client.h>
28 30
 #include <config.h>
29
-#ifdef HAVE_DNSSD
30
-#include <dns_sd.h>
31
-#endif
32
-
33
-#define MDNSD_PID "/var/run/mdnsd.pid"
34 31
 
35 32
 namespace DNSSD
36 33
 {
@@ -85,20 +82,12 @@ ServiceBrowser::ServiceBrowser(const QString& type,const QString& domain,int fla
85 82
 
86 83
 const ServiceBrowser::State ServiceBrowser::isAvailable()
87 84
 {
88
-#ifdef HAVE_DNSSD
89
-	QFile f(MDNSD_PID);
90
-	if (!f.open(IO_ReadOnly)) return Stopped; // no pidfile
91
-	QString line;
92
-	if (f.readLine(line,16)<1) return Stopped;
93
-	unsigned int pid = line.toUInt();
94
-	if (pid==0) return Stopped;           // not a pid
95
-	return (kill(pid,0)==0 || errno==EPERM) ? Working : Stopped; 
96
-	// signal 0 only checks if process is running, mdnsd is probably owned by 'nobody' so we will
97
-	// get EPERM, if mdnsd is not running error will be ESRCH
98
-	
85
+	AvahiClientState s = Responder::self().state();
86
+#ifdef AVAHI_API_0_6
87
+	return (s==AVAHI_CLIENT_FAILURE) ? Stopped : Working;
99 88
 #else
100
-	return Unsupported;
101
-#endif
89
+	return (s==AVAHI_CLIENT_S_INVALID || s==AVAHI_CLIENT_DISCONNECTED) ? Stopped : Working;
90
+#endif 
102 91
 }
103 92
 ServiceBrowser::~ ServiceBrowser()
104 93
 {

+ 1
- 1
interfaces/kimproxy/library/Makefile.am View File

@@ -16,7 +16,7 @@ kimproxyinclude_HEADERS = kimproxy.h kimproxyiface.h
16 16
 
17 17
 lib_LTLIBRARIES =  libkimproxy.la
18 18
 libkimproxy_la_LDFLAGS = -no-undefined $(all_libraries)
19
-libkimproxy_la_LIBADD = $(LIB_KIO)
19
+libkimproxy_la_LIBADD = $(LIB_KIO) $(LIB_QT) $(LIB_KDECORE) $(top_builddir)/dcop/libDCOP.la $(LIB_KDEUI)
20 20
 libkimproxy_la_SOURCES = kimproxy.cpp kimiface.stub kimproxyiface.skel
21 21
 
22 22
 kimiface_DIR = $(top_srcdir)/interfaces/kimproxy/interface

+ 1
- 1
interfaces/kmediaplayer/Makefile.am View File

@@ -9,7 +9,7 @@ lib_LTLIBRARIES = libkmediaplayer.la
9 9
 
10 10
 libkmediaplayer_la_SOURCES = player.cpp playerdcopobject.skel view.cpp
11 11
 libkmediaplayer_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -no-undefined
12
-libkmediaplayer_la_LIBADD = $(LIB_KPARTS)
12
+libkmediaplayer_la_LIBADD = $(LIB_KPARTS) $(LIB_QT) $(top_builddir)/dcop/libDCOP.la $(LIB_KDEUI) $(LIB_KDECORE)
13 13
 libkmediaplayer_la_METASOURCES = AUTO
14 14
 
15 15
 kmediaplayerinclude_HEADERS = player.h playerdcopobject.h view.h

+ 1
- 1
interfaces/kmediaplayer/kfileaudiopreview/Makefile.am View File

@@ -5,7 +5,7 @@ kde_module_LTLIBRARIES = kfileaudiopreview.la
5 5
 
6 6
 kfileaudiopreview_la_SOURCES = kfileaudiopreview.cpp
7 7
 kfileaudiopreview_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -module -avoid-version -no-undefined
8
-kfileaudiopreview_la_LIBADD = $(top_builddir)/interfaces/kmediaplayer/libkmediaplayer.la $(top_builddir)/arts/kde/libartskde.la $(LIB_KIO)
8
+kfileaudiopreview_la_LIBADD = $(top_builddir)/interfaces/kmediaplayer/libkmediaplayer.la $(top_builddir)/arts/kde/libartskde.la $(LIB_KIO) $(LIB_QT) $(LIB_KDECORE)
9 9
 
10 10
 noinst_HEADERS = kfileaudiopreview.h
11 11
 

+ 1
- 1
interfaces/kscript/Makefile.am View File

@@ -10,7 +10,7 @@ lib_LTLIBRARIES = libkscript.la
10 10
 
11 11
 libkscript_la_SOURCES = scriptmanager.cpp
12 12
 libkscript_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -no-undefined
13
-libkscript_la_LIBADD = $(LIB_KIO)
13
+libkscript_la_LIBADD = $(LIB_KIO) $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI)
14 14
 
15 15
 kscriptinclude_HEADERS = scriptinterface.h scriptclientinterface.h scriptmanager.h
16 16
 kscriptincludedir = $(includedir)

+ 1
- 1
interfaces/kscript/sample/Makefile.am View File

@@ -4,7 +4,7 @@ kde_module_LTLIBRARIES = libshellscript.la
4 4
 
5 5
 libshellscript_la_SOURCES = shellscript.cpp
6 6
 libshellscript_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) -no-undefined -avoid-version
7
-libshellscript_la_LIBADD = ../libkscript.la
7
+libshellscript_la_LIBADD = ../libkscript.la $(LIB_QT) $(LIB_KDECORE) $(top_builddir)/dcop/libDCOP.la
8 8
 
9 9
 
10 10
 METASOURCES = AUTO

+ 1
- 1
interfaces/ktexteditor/Makefile.am View File

@@ -23,7 +23,7 @@ libktexteditor_la_SOURCES = ktexteditor.cpp \
23 23
 
24 24
 
25 25
 libktexteditor_la_LDFLAGS = $(all_libraries) $(KDE_RPATH)
26
-libktexteditor_la_LIBADD = $(LIB_KPARTS) $(top_builddir)/dcop/libDCOP.la $(top_builddir)/kabc/libkabc.la
26
+libktexteditor_la_LIBADD = $(LIB_KPARTS) $(top_builddir)/dcop/libDCOP.la $(LIB_KABC) $(LIB_KDECORE) $(LIB_QT) $(LIB_KFILE) $(LIB_KDEUI)
27 27
 
28 28
 ktexteditorinclude_HEADERS = document.h view.h editor.h plugin.h editinterface.h undointerface.h \
29 29
                              selectioninterface.h cursorinterface.h \

+ 2
- 0
interfaces/terminal/kde_terminal_interface.h View File

@@ -163,6 +163,8 @@ public:
163 163
      start another program instead or close it yourself.
164 164
   */
165 165
   virtual void setAutoDestroy(bool enabled) = 0;
166
+
167
+  virtual bool setPtyFd(int master_pty) = 0;
166 168
 };
167 169
 
168 170
 #endif

+ 1
- 1
kabc/Makefile.am View File

@@ -22,7 +22,7 @@ CLEANFILES = addressee.h addressee.cpp field.cpp
22 22
 lib_LTLIBRARIES = libkabc.la
23 23
 libkabc_la_LDFLAGS = $(KDE_RPATH) $(all_libraries) -version-info 3:0:2 -no-undefined
24 24
 libkabc_la_LIBADD = vcard/libvcard.la vcardparser/libvcards.la $(LIB_KIO) \
25
-                    $(top_builddir)/kresources/libkresources.la
25
+                    $(top_builddir)/kresources/libkresources.la $(LIB_QT) $(top_builddir)/dcop/libDCOP.la $(LIB_KDEUI) $(LIB_KDECORE)
26 26
 libkabc_la_COMPILE_FIRST = addressee.h
27 27
 
28 28
 libkabc_la_SOURCES = \

+ 1
- 1
kabc/formats/Makefile.am View File

@@ -5,7 +5,7 @@ kde_module_LTLIBRARIES = kabcformat_binary.la
5 5
 kabcformat_binary_la_SOURCES = binaryformat.cpp
6 6
 kabcformat_binary_la_LDFLAGS =  -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) \
7 7
                                 -no-undefined
8
-kabcformat_binary_la_LIBADD  = $(top_builddir)/kabc/libkabc.la
8
+kabcformat_binary_la_LIBADD  = $(LIB_KABC) $(LIB_QT) $(LIB_KDECORE)
9 9
 kabcformat_binary_la_COMPILE_FIRST = $(top_builddir)/kabc/addressee.h
10 10
 
11 11
 # these are the headers for your project

+ 2
- 2
kabc/plugins/dir/Makefile.am View File

@@ -6,13 +6,13 @@ noinst_HEADERS = resourcedirconfig.h
6 6
 lib_LTLIBRARIES = libkabc_dir.la
7 7
 libkabc_dir_la_SOURCES = resourcedir.cpp resourcedirconfig.cpp
8 8
 libkabc_dir_la_LDFLAGS = $(KDE_RPATH) $(all_libraries) -version-info 1:0:0 -no-undefined 
9
-libkabc_dir_la_LIBADD = $(LIB_KABC)
9
+libkabc_dir_la_LIBADD = $(LIB_KABC) $(LIB_QT) $(top_builddir)/kresources/libkresources.la $(LIB_KDECORE) $(LIB_KFILE) $(LIB_KDEUI)
10 10
 libkabc_dir_la_COMPILE_FIRST = $(top_builddir)/kabc/addressee.h
11 11
 
12 12
 kde_module_LTLIBRARIES = kabc_dir.la
13 13
 kabc_dir_la_SOURCES = resourcedirplugin.cpp
14 14
 kabc_dir_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) -no-undefined
15
-kabc_dir_la_LIBADD = libkabc_dir.la
15
+kabc_dir_la_LIBADD = libkabc_dir.la $(LIB_QT) $(LIB_KDECORE)
16 16
 
17 17
 METASOURCES = AUTO
18 18
 

+ 2
- 2
kabc/plugins/file/Makefile.am View File

@@ -6,14 +6,14 @@ noinst_HEADERS   = resourcefileconfig.h
6 6
 lib_LTLIBRARIES = libkabc_file.la
7 7
 libkabc_file_la_SOURCES = resourcefile.cpp resourcefileconfig.cpp
8 8
 libkabc_file_la_LDFLAGS = $(KDE_RPATH) $(all_libraries) -version-info 1:0:0 -no-undefined
9
-libkabc_file_la_LIBADD = $(LIB_KABC)
9
+libkabc_file_la_LIBADD = $(LIB_KABC) $(LIB_QT) $(top_builddir)/kresources/libkresources.la $(LIB_KFILE) $(LIB_KDECORE) $(LIB_KDEUI)
10 10
 libkabc_file_la_COMPILE_FIRST = $(top_builddir)/kabc/addressee.h
11 11
 
12 12
 
13 13
 kde_module_LTLIBRARIES = kabc_file.la
14 14
 kabc_file_la_SOURCES = resourcefileplugin.cpp
15 15
 kabc_file_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) -no-undefined
16
-kabc_file_la_LIBADD = libkabc_file.la
16
+kabc_file_la_LIBADD = libkabc_file.la $(LIB_QT) $(LIB_KDECORE)
17 17
 kabc_file_la_COMPILE_FIRST = $(top_builddir)/kabc/addressee.h
18 18
 
19 19
 METASOURCES = AUTO

+ 2
- 2
kabc/plugins/ldapkio/Makefile.am View File

@@ -6,13 +6,13 @@ noinst_HEADERS = resourceldapkioconfig.h
6 6
 lib_LTLIBRARIES = libkabc_ldapkio.la
7 7
 libkabc_ldapkio_la_SOURCES = resourceldapkio.cpp resourceldapkioconfig.cpp
8 8
 libkabc_ldapkio_la_LDFLAGS = $(KDE_RPATH) $(all_libraries) -version-info 1:0:0 -no-undefined
9
-libkabc_ldapkio_la_LIBADD	= $(top_builddir)/kabc/libkabc.la $(LIB_KIO)
9
+libkabc_ldapkio_la_LIBADD	= $(LIB_KABC) $(LIB_KIO) $(LIB_QT) $(top_builddir)/kresources/libkresources.la $(LIB_KDEUI) $(LIB_KDECORE)
10 10
 libkabc_ldapkio_la_COMPILE_FIRST = $(top_builddir)/kabc/addressee.h
11 11
 
12 12
 kde_module_LTLIBRARIES = kabc_ldapkio.la
13 13
 kabc_ldapkio_la_SOURCES = resourceldapkioplugin.cpp
14 14
 kabc_ldapkio_la_LDFLAGS	= $(all_libraries) -module $(KDE_PLUGIN)
15
-kabc_ldapkio_la_LIBADD	= libkabc_ldapkio.la
15
+kabc_ldapkio_la_LIBADD	= libkabc_ldapkio.la $(LIB_QT) $(LIB_KDECORE)
16 16
 
17 17
 METASOURCES = AUTO
18 18
 

+ 1
- 1
kabc/vcard/Makefile.am View File

@@ -8,7 +8,7 @@ lib_LTLIBRARIES = libvcard.la
8 8
 
9 9
 libvcard_la_SOURCES = vCard-all.cpp
10 10
 libvcard_la_LDFLAGS = $(all_libraries)
11
-libvcard_la_LIBADD = $(LIB_KDECORE)
11
+libvcard_la_LIBADD = $(LIB_KDECORE) $(LIB_QT)
12 12
 
13 13
 check_PROGRAMS = testwrite testread
14 14
 

+ 5
- 1
kate/data/Makefile.am View File

@@ -19,7 +19,11 @@ syntaxkate_DATA = language.dtd syntax.template cpp.xml c.xml html.xml kbasic.xml
19 19
                 cg.xml html-php.xml css-php.xml javascript-php.xml ahdl.xml ansic89.xml tibasic.xml \
20 20
                 purebasic.xml mips.xml logtalk.xml txt2tags.xml xslt.xml stata.xml glsl.xml \
21 21
                 lilypond.xml abc.xml asp.xml asm-avr.xml rib.xml cmake.xml octave.xml javadoc.xml cgis.xml \
22
-                spice.xml nasm.xml mediawiki.xml apache.xml m3u.xml ini.xml fstab.xml actionscript.xml
22
+                spice.xml nasm.xml mediawiki.xml apache.xml m3u.xml ini.xml fstab.xml actionscript.xml \
23
+		abap.xml ansys.xml asn1.xml asterisk.xml bmethod.xml ddoc.xml djangotemplate.xml \
24
+                doxygenlua.xml dtd.xml email.xml erlang.xml freebasic.xml gap.xml json.xml maxima.xml \
25
+                mergetagtext.xml modelica.xml monobasic.xml nemerle.xml noweb.xml objectivecpp.xml opal.xml \
26
+                pgn.xml rapidq.xml scala.xml sisu.xml systemc.xml texinfo.xml xorg.xml xul.xml yaml.xml zonnon.xml
23 27
 
24 28
 partrcdir   = $(kde_confdir)
25 29
 partrc_DATA = katesyntaxhighlightingrc katefiletyperc

+ 1
- 1
kate/interfaces/Makefile.am View File

@@ -3,7 +3,7 @@ METASOURCES = document.moc view.moc
3 3
 lib_LTLIBRARIES = libkatepartinterfaces.la
4 4
 
5 5
 libkatepartinterfaces_la_SOURCES = interfaces.cpp katecmd.cpp
6
-libkatepartinterfaces_la_LIBADD   = $(top_builddir)/interfaces/ktexteditor/libktexteditor.la
6
+libkatepartinterfaces_la_LIBADD   = $(top_builddir)/interfaces/ktexteditor/libktexteditor.la $(LIB_QT) $(LIB_KDEUI) $(LIB_KPARTS) $(LIB_KDECORE)
7 7
 libkatepartinterfaces_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -no-undefined
8 8
 
9 9
 kateinclude_HEADERS = document.h view.h

+ 1
- 1
kate/part/Makefile.am View File

@@ -16,7 +16,7 @@ libkate_la_SOURCES = katesearch.cpp katebuffer.cpp katecmds.cpp \
16 16
 
17 17
 libkatepart_la_SOURCES = dummy.cpp
18 18
 
19
-libkatepart_la_LIBADD = libkate.la ../interfaces/libkatepartinterfaces.la $(top_builddir)/kdeprint/libkdeprint.la $(top_builddir)/kutils/libkutils.la $(top_builddir)/kjs/libkjs.la $(LUA_LIBS)
19
+libkatepart_la_LIBADD = libkate.la ../interfaces/libkatepartinterfaces.la $(LIB_KDEPRINT) $(top_builddir)/kutils/libkutils.la $(top_builddir)/kjs/libkjs.la $(LUA_LIBS) $(LIB_QT) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_KPARTS) $(top_builddir)/interfaces/ktexteditor/libktexteditor.la $(LIB_KFILE) $(top_builddir)/dcop/libDCOP.la
20 20
 
21 21
 libkatepart_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
22 22
 

+ 22
- 10
kate/part/katesearch.cpp View File

@@ -377,23 +377,35 @@ void KateSearch::replaceOne()
377 377
 {
378 378
   QString replaceWith = m_replacement;
379 379
   if ( s.flags.regExp && s.flags.useBackRefs ) {
380
-    // replace each "(?!\)\d+" with the corresponding capture
381
-    QRegExp br("\\\\(\\d+)");
380
+    // Replace each "\0"..."\9" with the corresponding capture,
381
+    // "\n" and "\t" with newline and tab,
382
+    // "\\" with "\",
383
+    // and remove the "\" for any other sequence.
384
+    QRegExp br("\\\\(.)");
382 385
     int pos = br.search( replaceWith );
383 386
     int ncaps = m_re.numCaptures();
384 387
     while ( pos >= 0 ) {
385
-      QString sc;
386
-      if ( !pos ||  replaceWith.at( pos-1) != '\\' ) {
387
-        int ccap = br.cap(1).toInt();
388
+      QString substitute;
389
+      QChar argument = br.cap(1).at(0);
390
+      if ( argument.isDigit() ) {
391
+        // the second character is a digit, this is a backreference
392
+        int ccap = argument.digitValue();
388 393
         if (ccap <= ncaps ) {
389
-          sc = m_re.cap( ccap );
390
-          replaceWith.replace( pos, br.matchedLength(), sc );
391
-        }
392
-        else {
394
+          substitute = m_re.cap( ccap );
395
+        } else {
393 396
           kdDebug()<<"KateSearch::replaceOne(): you don't have "<<ccap<<" backreferences in regexp '"<<m_re.pattern()<<"'"<<endl;
397
+          break;
394 398
         }
399
+      } else if ( argument == 'n' ) {
400
+        substitute = '\n';
401
+      } else if ( argument == 't' ) {
402
+        substitute = '\t';
403
+      } else {
404
+        // handle a validly escaped backslash, or an invalid escape.
405
+        substitute = argument;
395 406
       }
396
-      pos = br.search( replaceWith, pos + (int)sc.length() );
407
+      replaceWith.replace( pos, br.matchedLength(), substitute );
408
+      pos = br.search( replaceWith, pos + substitute.length() );
397 409
     }
398 410
   }
399 411
 

+ 1
- 1
kate/plugins/insertfile/Makefile.am View File

@@ -5,7 +5,7 @@ METASOURCES = AUTO
5 5
 kde_module_LTLIBRARIES = ktexteditor_insertfile.la
6 6
 
7 7
 ktexteditor_insertfile_la_SOURCES = insertfileplugin.cpp
8
-ktexteditor_insertfile_la_LIBADD = $(top_builddir)/interfaces/ktexteditor/libktexteditor.la
8
+ktexteditor_insertfile_la_LIBADD = $(top_builddir)/interfaces/ktexteditor/libktexteditor.la $(LIB_QT) $(LIB_KDECORE) $(LIB_KFILE) $(LIB_KDEUI)
9 9
 ktexteditor_insertfile_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
10 10
           
11 11
 insertfiledatadir = $(kde_datadir)/ktexteditor_insertfile

+ 1
- 1
kate/plugins/isearch/Makefile.am View File

@@ -5,7 +5,7 @@ METASOURCES = AUTO
5 5
 kde_module_LTLIBRARIES = ktexteditor_isearch.la
6 6
 
7 7
 ktexteditor_isearch_la_SOURCES = ISearchPlugin.cpp
8
-ktexteditor_isearch_la_LIBADD = $(top_builddir)/interfaces/ktexteditor/libktexteditor.la
8
+ktexteditor_isearch_la_LIBADD = $(top_builddir)/interfaces/ktexteditor/libktexteditor.la $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI)
9 9
 ktexteditor_isearch_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
10 10
           
11 11
 isearchdatadir = $(kde_datadir)/ktexteditor_isearch

+ 1
- 1
kate/plugins/kdatatool/Makefile.am View File

@@ -5,7 +5,7 @@ METASOURCES = AUTO
5 5
 kde_module_LTLIBRARIES = ktexteditor_kdatatool.la
6 6
 
7 7
 ktexteditor_kdatatool_la_SOURCES = kate_kdatatool.cpp
8
-ktexteditor_kdatatool_la_LIBADD = $(top_builddir)/interfaces/ktexteditor/libktexteditor.la
8
+ktexteditor_kdatatool_la_LIBADD = $(top_builddir)/interfaces/ktexteditor/libktexteditor.la $(LIB_QT) $(LIB_KDECORE) $(LIB_KFILE) $(LIB_KDEUI)
9 9
 ktexteditor_kdatatool_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
10 10
 
11 11
 kdatatooldatadir = $(kde_datadir)/ktexteditor_kdatatool

+ 1
- 1
kate/plugins/wordcompletion/Makefile.am View File

@@ -5,7 +5,7 @@ METASOURCES = AUTO
5 5
 kde_module_LTLIBRARIES = ktexteditor_docwordcompletion.la
6 6
 
7 7
 ktexteditor_docwordcompletion_la_SOURCES = docwordcompletion.cpp
8
-ktexteditor_docwordcompletion_la_LIBADD = $(top_builddir)/interfaces/ktexteditor/libktexteditor.la
8
+ktexteditor_docwordcompletion_la_LIBADD = $(top_builddir)/interfaces/ktexteditor/libktexteditor.la $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI)
9 9
 ktexteditor_docwordcompletion_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
10 10
 
11 11
 docwordcompletiondatadir = $(kde_datadir)/ktexteditor_docwordcompletion

+ 1
- 1
kcert/Makefile.am View File

@@ -5,7 +5,7 @@ kde_module_LTLIBRARIES = libkcertpart.la
5 5
 libkcertpart_la_SOURCES	= kcertpart.cc
6 6
 
7 7
 libkcertpart_la_LDFLAGS = $(KDE_PLUGIN) $(all_libraries)
8
-libkcertpart_la_LIBADD = $(LIB_KPARTS)
8
+libkcertpart_la_LIBADD = $(LIB_KPARTS) $(LIB_QT) $(LIB_KDEUI) $(LIB_KFILE) $(LIB_KDECORE)
9 9
 libkcertpart_la_DEPENDENCIES = $(LIB_KPARTS)
10 10
 
11 11
 libkcertpart_la_METASOURCES = AUTO

+ 1
- 1
kcmshell/Makefile.am View File

@@ -26,7 +26,7 @@ bin_PROGRAMS =
26 26
 kdeinit_LTLIBRARIES = kcmshell.la
27 27
 
28 28
 kcmshell_la_SOURCES = main.cpp main.skel
29
-kcmshell_la_LIBADD = ../kutils/libkutils.la
29
+kcmshell_la_LIBADD = ../kutils/libkutils.la $(LIB_QT) $(LIB_KDEUI) $(top_builddir)/dcop/libDCOP.la $(LIB_KDECORE) $(LIB_KFILE)
30 30
 kcmshell_la_LDFLAGS = $(all_libraries) -module -avoid-version
31 31
 
32 32
 noinst_HEADERS = main.h

+ 1
- 1
kconf_update/Makefile.am View File

@@ -23,7 +23,7 @@ lib_LTLIBRARIES =
23 23
 kdeinit_LTLIBRARIES = kconf_update.la
24 24
 
25 25
 kconf_update_la_SOURCES = kconf_update.cpp
26
-kconf_update_la_LIBADD = $(LIB_KDECORE)
26
+kconf_update_la_LIBADD = $(LIB_KDECORE) $(LIB_QT)
27 27
 kconf_update_la_LDFLAGS = $(all_libraries) -module -avoid-version
28 28
 
29 29
 METASOURCES = AUTO

+ 9
- 3
kdecore/Makefile.am View File

@@ -34,7 +34,7 @@ SUBDIRS = malloc network $(SVGICONS) . kconfig_compiler tests
34 34
 AM_LDFLAGS = $(LDFLAGS_AS_NEEDED) $(LDFLAGS_NEW_DTAGS)
35 35
 
36 36
 lib_LTLIBRARIES = libkdefakes.la libkdecore.la
37
-lib_LIBRARIES = libkdefakes_nonpic.a
37
+lib_LIBRARIES = libkdefakes_nonpic.a libkdefakes_pic.a
38 38
 
39 39
 include_HEADERS = kconfig.h kconfigskeleton.h \
40 40
 	kconfigdata.h ksimpleconfig.h kconfigdialogmanager.h \
@@ -75,6 +75,12 @@ vsnprintf_nonpic.c:  $(srcdir)/vsnprintf.c
75 75
 	-rm -f vsnprintf_nonpic.c
76 76
 	$(LN_S) $(srcdir)/vsnprintf.c vsnprintf_nonpic.c
77 77
 
78
+libkdefakes_pic.a: libkdefakes.la
79
+	-rm -f libkdefakes_pic.a fakes_pic.o vsnprintf_pic.o
80
+	cp -f .libs/fakes.o fakes_pic.o; cp -f .libs/vsnprintf.o vsnprintf_pic.o
81
+	ar cru libkdefakes_pic.a fakes_pic.o vsnprintf_pic.o
82
+	ranlib libkdefakes_pic.a
83
+
78 84
 noinst_HEADERS = kaccelaction.h kaccelbase.h kaccelprivate.h kckey.h \
79 85
 	kcompletion_private.h netwm_p.h \
80 86
 	kglobalaccel_x11.h kglobalaccel_win.h kkeyserver_x11.h kkeyserver.h \
@@ -116,7 +122,8 @@ libkdecore_la_SOURCES = libintl.cpp kapplication.cpp \
116 122
 	kqiodevicegzip_p.cpp ktimezones.cpp
117 123
 
118 124
 libkdecore_la_LDFLAGS = $(QT_LDFLAGS) $(KDE_RPATH) $(KDE_MT_LDFLAGS) $(X_LDFLAGS) $(USER_LDFLAGS) -version-info 6:0:2 -no-undefined
119
-libkdecore_la_LIBADD = malloc/libklmalloc.la network/libkdecorenetwork.la $(SVGICON_LIB) ../dcop/libDCOP.la ../libltdl/libltdlc.la $(LIB_XEXT) $(LIBRESOLV) $(LIBUTIL) $(LIBART_LIBS) $(LIB_IDN) ../kdefx/libkdefx.la
125
+libkdecore_la_LIBADD = malloc/libklmalloc.la network/libkdecorenetwork.la $(SVGICON_LIB) ../dcop/libDCOP.la ../libltdl/libltdlc.la \
126
+	$(LIBART_LIBS) $(LIB_IDN) $(top_builddir)/kdefx/libkdefx.la $(LIB_QT) $(LIBSM) $(LIB_X11) $(LIBZ) $(LIBDL)
120 127
 libkdecore_la_NMCHECK = $(srcdir)/libkdecore.nmcheck
121 128
 libkdecore_la_NMCHECKWEAK = $(srcdir)/libkdecore_weak.nmcheck $(srcdir)/libqt-mt_weak.nmcheck \
122 129
 	$(top_srcdir)/dcop/libDCOP_weak.nmcheck $(top_srcdir)/kdecore/standard_weak.nmcheck
@@ -170,7 +177,6 @@ kde_config_LDFLAGS = $(KDE_RPATH) $(KDE_MT_LDFLAGS)
170 177
 kgrantpty_SOURCES = kgrantpty.c
171 178
 kgrantpty_CFLAGS= $(KDE_USE_FPIE)
172 179
 kgrantpty_LDFLAGS = $(KDE_USE_PIE) $(KDE_RPATH) $(all_libraries)
173
-kgrantpty_LDADD = ./libkdefakes.la
174 180
 
175 181
 # kgrantpty needs to be installed setuid root
176 182
 install-exec-hook:

+ 3
- 0
kdecore/kaccel.cpp View File

@@ -127,7 +127,10 @@ bool KAccelEventHandler::x11Event( XEvent* pEvent )
127 127
 	        return false;
128 128
 
129 129
 	if( pEvent->type == XKeyPress ) {
130
+		unsigned int tmp = pEvent->xkey.state;
131
+		pEvent->xkey.state &= ~0x2000;
130 132
 		KKeyNative keyNative( pEvent );
133
+		pEvent->xkey.state = tmp;
131 134
 		KKey key( keyNative );
132 135
 		key.simplify();
133 136
 		int keyCodeQt = key.keyCodeQt();

+ 51
- 0
kdecore/kconfigbackend.cpp View File

@@ -505,6 +505,8 @@ qWarning("SIGBUS while reading %s", rFile.name().latin1());
505 505
    bool fileOptionImmutable = false;
506 506
    bool groupOptionImmutable = false;
507 507
    bool groupSkip = false;
508
+   bool foundGettextDomain = false;
509
+   QCString gettextDomain;
508 510
 
509 511
    int line = 0;
510 512
    for(; s < eof; s++)
@@ -596,6 +598,7 @@ qWarning("SIGBUS while reading %s", rFile.name().latin1());
596 598
       if (groupSkip && !bDefault)
597 599
         goto sktoeol; // Skip entry
598 600
 
601
+
599 602
       bool optionImmutable = groupOptionImmutable;
600 603
       bool optionDeleted = false;
601 604
       bool optionExpand = false;
@@ -695,6 +698,11 @@ qWarning("SIGBUS while reading %s", rFile.name().latin1());
695 698
       QCString val = printableToString(st, s - st);
696 699
       //qDebug("found key '%s' with value '%s'", key.data(), val.data());
697 700
 
701
+      if (QString(key.data()) == "X-Ubuntu-Gettext-Domain") {
702
+	gettextDomain = val.data();
703
+	foundGettextDomain = true;
704
+      }
705
+
698 706
       KEntryKey aEntryKey(aCurrentGroup, decodeKey(key));
699 707
       aEntryKey.bLocal = (locale != 0);
700 708
       aEntryKey.bDefault = bDefault;
@@ -718,6 +726,34 @@ qWarning("SIGBUS while reading %s", rFile.name().latin1());
718 726
          pConfig->putData(aEntryKey, aEntry, false);
719 727
       }
720 728
    }
729
+   // Look up translations using KLocale
730
+   // https://launchpad.net/distros/ubuntu/+spec/langpacks-desktopfiles-kde
731
+   // This calls KLocale up to 10 times for each config file (and each KConfig has up to 4 files)
732
+   // so I'll see how much of a performance hit it is
733
+   // it also only acts on the last group in a file
734
+   // Ideas: only translate most important fields, only translate "Desktop Entry" files,
735
+   //        do translation per KConfig not per single file
736
+   if (!pWriteBackMap) {
737
+     QFile file("file.txt");
738
+     if (foundGettextDomain) {
739
+
740
+       KLocale locale(gettextDomain);
741
+
742
+       QString language = locale.language();
743
+       translateKey(locale, aCurrentGroup, QCString("Name"));
744
+       translateKey(locale, aCurrentGroup, QCString("Comment"));
745
+       translateKey(locale, aCurrentGroup, QCString("Language"));
746
+       translateKey(locale, aCurrentGroup, QCString("Keywords"));
747
+       translateKey(locale, aCurrentGroup, QCString("About"));
748
+       translateKey(locale, aCurrentGroup, QCString("Description"));
749
+       translateKey(locale, aCurrentGroup, QCString("GenericName"));
750
+       translateKey(locale, aCurrentGroup, QCString("Query"));
751
+       translateKey(locale, aCurrentGroup, QCString("ExtraNames"));
752
+       translateKey(locale, aCurrentGroup, QCString("X-KDE-Submenu"));
753
+     }
754
+   }
755
+
756
+
721 757
    if (fileOptionImmutable)
722 758
       bFileImmutable = true;
723 759
 
@@ -732,6 +768,21 @@ qWarning("SIGBUS while reading %s", rFile.name().latin1());
732 768
 #endif
733 769
 }
734 770
 
771
+void KConfigINIBackEnd::translateKey(KLocale& locale, QCString currentGroup, QCString key) {
772
+  KEntryKey entryKey = KEntryKey(currentGroup, key);
773
+  KEntry entry = pConfig->lookupData(entryKey);
774
+  if (QString(entry.mValue) != "") {
775
+    QString orig = key + "=" + entry.mValue;
776
+    QString translate = locale.translate(key + "=" + entry.mValue);
777
+    if (QString::compare(orig, translate) != 0) {
778
+      translate = translate.mid(key.length() + 1);
779
+      entry.mValue = translate.utf8();
780
+      entryKey.bLocal = true;
781
+      entry.bNLS = true;
782
+      pConfig->putData(entryKey, entry, false);
783
+    }
784
+  }
785
+}
735 786
 
736 787
 void KConfigINIBackEnd::sync(bool bMerge)
737 788
 {

+ 6
- 0
kdecore/kconfigbackend.h View File

@@ -25,6 +25,7 @@
25 25
 #include "kconfigdata.h"
26 26
 #include <kconfigbase.h>
27 27
 #include <klockfile.h>
28
+#include <klocale.h>
28 29
 #include "kdelibs_export.h"
29 30
 
30 31
 class QFile;
@@ -250,6 +251,11 @@ protected:
250 251
   void parseSingleConfigFile(QFile& rFile, KEntryMap *pWriteBackMap = 0L,
251 252
 			     bool bGlobal = false, bool bDefault = false);
252 253
 
254
+  // Kubuntu patch, 2006-08-03
255
+  // looks up a key in with KLocale
256
+  // see https://launchpad.net/distros/ubuntu/+spec/langpacks-desktopfiles-kde
257
+  void translateKey(KLocale& locale, QCString currentGroup, QCString key);
258
+
253 259
   /**
254 260
    * Writes configuration file back.
255 261
    *

+ 1
- 1
kdecore/kcrash.cpp View File

@@ -441,7 +441,7 @@ static int openSocket()
441 441
 
442 442
   if (!kde_home || !kde_home[0])
443 443
   {
444
-     kde_home = "~/.kde/";
444
+     kde_home = "~/.kde3/";
445 445
   }
446 446
 
447 447
   if (kde_home[0] == '~')

+ 2
- 1
kdecore/kdebug.cpp View File

@@ -238,7 +238,8 @@ static void kDebugBackend( unsigned short nLevel, unsigned int nArea, const char
238 238
       break;
239 239
   }
240 240
 
241
-  short nOutput = kDebug_data->config ? kDebug_data->config->readNumEntry(key, 2) : 2;
241
+  // if no output mode is specified default to no debug output
242
+  short nOutput = kDebug_data->config ? kDebug_data->config->readNumEntry(key, 4) : 4;
242 243
 
243 244
   // If the application doesn't have a QApplication object it can't use
244 245
   // a messagebox.

+ 1
- 1
kdecore/kdebugrc View File

@@ -86,7 +86,7 @@ InfoOutput=4
86 86
 
87 87
 # KMail
88 88
 [5006]
89
-InfoOutput=2
89
+InfoOutput=4
90 90
 
91 91
 # KitchenSync (Syncing Algorithm)
92 92
 [5250]

+ 2
- 2
kdecore/kdeversion.h View File

@@ -22,10 +22,10 @@
22 22
 
23 23
 #include "kdelibs_export.h"
24 24
 
25
-#define KDE_VERSION_STRING "3.5.10"
25
+#define KDE_VERSION_STRING "3.5.11 [Trinity]"
26 26
 #define KDE_VERSION_MAJOR 3
27 27
 #define KDE_VERSION_MINOR 5
28
-#define KDE_VERSION_RELEASE 10
28
+#define KDE_VERSION_RELEASE 11
29 29
 #define KDE_MAKE_VERSION( a,b,c ) (((a) << 16) | ((b) << 8) | (c))
30 30
 
31 31
 #define KDE_VERSION \

+ 36
- 15
kdecore/kglobalsettings.cpp View File

@@ -50,6 +50,10 @@ static QRgb qt_colorref2qrgb(COLORREF col)
50 50
 #include <stdlib.h>
51 51
 #include <kprotocolinfo.h>
52 52
 
53
+#include <qtextcodec.h>
54
+#include <qtextstream.h>
55
+#include <qfile.h>
56
+
53 57
 #ifdef Q_WS_X11
54 58
 #include <X11/Xlib.h>
55 59
 #endif
@@ -77,6 +81,31 @@ QColor *KGlobalSettings::alternateColor = 0;
77 81
 
78 82
 KGlobalSettings::KMouseSettings *KGlobalSettings::s_mouseSettings = 0;
79 83
 
84
+// helper function for reading xdg user dirs: it is required in order to take 
85
+// care of locale stuff
86
+void readXdgUserDirs(QString *desktop, QString *documents)
87
+{
88
+	QFile f( QDir::homeDirPath() + "/.config/user-dirs.dirs" );
89
+
90
+	if (!f.open(IO_ReadOnly))
91
+		return;
92
+
93
+	// set the codec for the current locale
94
+	QTextStream s(&f);
95
+	s.setCodec( QTextCodec::codecForLocale() );
96
+
97
+	QString line = s.readLine();
98
+	while (!line.isNull())
99
+	{
100
+		if (line.startsWith("XDG_DESKTOP_DIR="))
101
+			*desktop = line.remove("XDG_DESKTOP_DIR=").remove("\"").replace("$HOME", QDir::homeDirPath());
102
+		else if (line.startsWith("XDG_DOCUMENTS_DIR="))
103
+			*documents = line.remove("XDG_DOCUMENTS_DIR=").remove("\"").replace("$HOME", QDir::homeDirPath());
104
+
105
+		line = s.readLine();
106
+	}
107
+}
108
+
80 109
 int KGlobalSettings::dndEventDelay()
81 110
 {
82 111
     KConfigGroup g( KGlobal::config(), "General" );
@@ -483,13 +512,17 @@ void KGlobalSettings::initStatic() // should be called initPaths(). Don't put an
483 512
 
484 513
     KConfigGroup g( KGlobal::config(), "Paths" );
485 514
 
486
-    // Desktop Path
487
-    *s_desktopPath = QDir::homeDirPath() + "/Desktop/";
488
-    *s_desktopPath = g.readPathEntry( "Desktop", *s_desktopPath);
515
+	// Read desktop and documents path using XDG_USER_DIRS
516
+	readXdgUserDirs(s_desktopPath, s_documentPath);
517
+	
489 518
     *s_desktopPath = QDir::cleanDirPath( *s_desktopPath );
490 519
     if ( !s_desktopPath->endsWith("/") )
491 520
       s_desktopPath->append('/');
492 521
 
522
+    *s_documentPath = QDir::cleanDirPath( *s_documentPath );
523
+    if ( !s_documentPath->endsWith("/"))
524
+      s_documentPath->append('/');
525
+
493 526
     // Trash Path - TODO remove in KDE4 (kio_trash can't use it for interoperability reasons)
494 527
     *s_trashPath = *s_desktopPath + i18n("Trash") + "/";
495 528
     *s_trashPath = g.readPathEntry( "Trash" , *s_trashPath);
@@ -510,18 +543,6 @@ void KGlobalSettings::initStatic() // should be called initPaths(). Don't put an
510 543
     if ( !s_autostartPath->endsWith("/") )
511 544
       s_autostartPath->append('/');
512 545
 
513
-    // Document Path
514
-    *s_documentPath = g.readPathEntry( "Documents", 
515
-#ifdef Q_WS_WIN
516
-        getWin32ShellFoldersPath("Personal")
517
-#else
518
-        QDir::homeDirPath()
519
-#endif
520
-    );
521
-    *s_documentPath = QDir::cleanDirPath( *s_documentPath );
522
-    if ( !s_documentPath->endsWith("/"))
523
-      s_documentPath->append('/');
524
-
525 546
     // Make sure this app gets the notifications about those paths
526 547
     if (kapp)
527 548
         kapp->addKipcEventMask(KIPC::SettingsChanged);

+ 148
- 0
kdecore/kiconeffect.cpp View File

@@ -24,6 +24,9 @@
24 24
 #include <qwidget.h>
25 25
 #include <qpainter.h>
26 26
 #include <qpen.h>
27
+#include <qapplication.h>
28
+#include <qpoint.h>
29
+#include <qrect.h>
27 30
 
28 31
 #include <kdebug.h>
29 32
 #include <kglobal.h>
@@ -768,3 +771,148 @@ KIconEffect::visualActivate(QWidget * widget, QRect rect)
768 771
     }
769 772
 }
770 773
 
774
+void
775
+KIconEffect::visualActivate(QWidget * widget, QRect rect, QPixmap *pixmap)
776
+{
777
+    if (!KGlobalSettings::visualActivate())
778
+        return;
779
+
780
+    // Image too big to display smoothly
781
+    if ((rect.width() > 160) || (rect.height() > 160)) {
782
+	visualActivate(widget, rect); // call old effect
783
+	return;
784
+    }
785
+
786
+    uint actSpeed = KGlobalSettings::visualActivateSpeed();
787
+    uint actCount = QMIN(rect.width(), rect.height()) / 4;
788
+
789
+
790
+    // Clip actCount to range 1..10.
791
+    if (actCount < 1)
792
+        actCount = 1;
793
+
794
+    else if (actCount > 10)
795
+        actCount = 10;
796
+
797
+    // Clip actSpeed to range 1..100.
798
+    if (actSpeed < 1)
799
+        actSpeed = 1;
800
+
801
+    else if (actSpeed > 100)
802
+        actSpeed = 100;
803
+
804
+    // actSpeed needs to be converted to actDelay.
805
+    // actDelay is inversely proportional to actSpeed and needs to be
806
+    // divided up into actCount portions.
807
+    // We also convert the us value to ms.
808
+
809
+    unsigned int actDelay = (1000 * (100 - actSpeed)) / actCount;
810
+
811
+    unsigned int deltaX = rect.width() / actCount * 1.5;
812
+    unsigned int deltaY = rect.height() / actCount * 1.5;
813
+
814
+    QPoint c = rect.center();
815
+    QRect maxRect(c.x() - (actCount * 2) * deltaX /2,
816
+	          c.y() - (actCount * 2) * deltaY /2,
817
+		  actCount * 2 * deltaX,
818
+		  actCount * 2 * deltaY);
819
+
820
+    // convert rect to global coordinates if needed
821
+    if ((widget->rect().width() <= maxRect.width())
822
+       || (widget->rect().height() <= maxRect.height()))
823
+    {
824
+	QPoint topLeft(rect.x(), rect.y());
825
+	rect.moveLeft(widget->mapToGlobal(topLeft).x());
826
+	rect.moveTop(widget->mapToGlobal(topLeft).y());
827
+	c = rect.center();
828
+	maxRect.setRect(c.x() - (actCount * 2) * deltaX /2,
829
+	        	c.y() - (actCount * 2) * deltaY /2,
830
+			actCount * 2 * deltaX,
831
+			actCount * 2 * deltaY);
832
+    }
833
+
834
+    QPainter *p;
835
+    QImage img = pixmap->convertToImage();
836
+    QPixmap pix;
837
+    QPixmap composite(maxRect.width(), maxRect.height(), -1, QPixmap::BestOptim);
838
+    QPainter cPainter(&composite);
839
+    QPoint cComposite = composite.rect().center();
840
+
841
+    // enable alpha blending
842
+    img.setAlphaBuffer(true);
843
+    
844
+    // Ugly hack... Get "Screenshot" to blt into and even do that on the
845
+    // root window if the display area of <widget> is too small
846
+    if ((widget->rect().width() <= maxRect.width())
847
+       || (widget->rect().height() <= maxRect.height()))
848
+    {
849
+        p = new QPainter(QApplication::desktop()->screen( -1 ), TRUE);
850
+	pix = QPixmap::grabWindow((QApplication::desktop()->screen( -1 ))->winId(),
851
+		    		      maxRect.x(),
852
+				      maxRect.y(),
853
+				      maxRect.width(),
854
+				      maxRect.height());
855
+    } else
856
+    {
857
+	// not as ugly as drawing directly to the screen
858
+	p = new QPainter(widget);
859
+	pix = QPixmap::grabWidget(widget,
860
+			              maxRect.x(),
861
+				      maxRect.y(),
862
+				      maxRect.width(),
863
+				      maxRect.height());
864
+    }
865
+    uchar deltaAlpha = 255 / (actCount * 1.2);
866
+    
867
+    // Activate effect like MacOS X
868
+    for (unsigned int i = actCount; i < actCount * 2; i++) {
869
+
870
+        int w = i * deltaX;
871
+        int h = i * deltaY;
872
+
873
+        rect.setRect(cComposite.x() - w / 2, cComposite.y() - h / 2, w, h);
874
+
875
+	// draw offscreen
876
+	cPainter.drawPixmap(0, 0, pix, 0, 0, pix.width(), pix.height());
877
+	cPainter.drawImage(rect, img);
878
+	cPainter.flush();
879
+
880
+	// put onscreen
881
+	p->drawPixmap(maxRect, composite);
882
+        p->flush();
883
+
884
+	// Fade out Icon a bit more
885
+        int x, y;
886
+        if ((img.depth() == 32) && qt_use_xrender && qt_has_xft)
887
+        {
888
+    	    int width  = img.width();
889
+	    int height = img.height();
890
+	
891
+	    for (y=0; y<height; y++)
892
+	    {
893
+#ifdef WORDS_BIGENDIAN
894
+		uchar *line = (uchar*) img.scanLine(y);
895
+#else
896
+		uchar *line = (uchar*) img.scanLine(y) + 3;
897
+#endif
898
+		for (x=0; x<width; x++)
899
+		{
900
+		    *line = (*line < deltaAlpha) ? 0 : *line - deltaAlpha;
901
+		    line += 4;
902
+		}
903
+	    }
904
+	}
905
+        usleep(actDelay*3);
906
+    }
907
+
908
+    // remove traces of the effect
909
+    if ((widget->rect().width() <= maxRect.width())
910
+       || (widget->rect().height() <= maxRect.height()))
911
+	p->drawPixmap(maxRect, pix);
912
+    else {
913
+	 p->drawPixmap(maxRect, pix);
914
+        widget->update(rect);
915
+    }
916
+
917
+    delete p;
918
+}

+ 1
- 0
kdecore/kiconeffect.h View File

@@ -152,6 +152,7 @@ public:
152 152
      * @param rect This rectangle defines the effect's borders
153 153
      */
154 154
     static void visualActivate(QWidget *widget, QRect rect);
155
+    static void visualActivate(QWidget *widget, QRect rect, QPixmap *pixmap);
155 156
 
156 157
     /**
157 158
      * Tints an image gray.

+ 1
- 1
kdecore/kicontheme.cpp View File

@@ -408,7 +408,7 @@ KIcon KIconTheme::iconPath(const QString& name, int size, KIcon::MatchType match
408 408
              it's a downscale, and we only had upscales befores.
409 409
              This is to avoid scaling up unless we have to,
410 410
              since that looks very ugly */
411
-          if ((abs(dw) >= abs(delta)) ||
411
+          if (/*(abs(dw) >= abs(delta)) ||*/
412 412
               (delta > 0 && dw < 0))
413 413
             continue;
414 414
         }

+ 13
- 4
kdecore/klocale.cpp View File

@@ -76,6 +76,7 @@ public:
76 76
 #ifdef Q_WS_WIN
77 77
   char win32SystemEncoding[3+7]; //"cp " + lang ID
78 78
 #endif
79
+  bool useMainCatalogue;
79 80
 };
80 81
 
81 82
 static KLocale *this_klocale = 0;
@@ -118,8 +119,13 @@ void KLocale::initMainCatalogues(const QString & catalog)
118 119
 {
119 120
   // Use the first non-null string.
120 121
   QString mainCatalogue = catalog;
121
-  if (maincatalogue)
122
-    mainCatalogue = QString::fromLatin1(maincatalogue);
122
+
123
+  // don't use main catalogue if we're looking up .desktop translations
124
+  if (mainCatalogue.contains("desktop") == 0 || mainCatalogue.contains("kdesktop") == 1) {
125
+    if (maincatalogue) {
126
+      mainCatalogue = QString::fromLatin1(maincatalogue);
127
+    }
128
+  }
123 129
 
124 130
   if (mainCatalogue.isEmpty()) {
125 131
     kdDebug(173) << "KLocale instance created called without valid "
@@ -129,8 +135,11 @@ void KLocale::initMainCatalogues(const QString & catalog)
129 135
   else {
130 136
     // do not use insertCatalogue here, that would already trigger updateCatalogs
131 137
     d->catalogNames.append( mainCatalogue );   // application catalog
132
-    d->catalogNames.append( SYSTEM_MESSAGES ); // always include kdelibs.mo
133
-    d->catalogNames.append( "kio" );            // always include kio.mo
138
+    if (mainCatalogue.contains("desktop") == 0 || mainCatalogue.contains("kdesktop") == 1) { //don't bother if we're looking up desktop translations
139
+      d->catalogNames.append( SYSTEM_MESSAGES ); // always include kdelibs.mo
140
+      d->catalogNames.append( "kio" );            // always include kio.mo
141
+      d->catalogNames.append( "xdg-user-dirs" );
142
+    }
134 143
     updateCatalogues(); // evaluate this for all languages
135 144
   }
136 145
 }

+ 114
- 78
kdecore/kpty.cpp View File

@@ -95,24 +95,24 @@ extern "C" {
95 95
 # endif
96 96
 #endif
97 97
 
98
-#if defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__bsdi__) || defined(__APPLE__) || defined (__DragonFly__)
98
+#if defined(HAVE_TCGETATTR)
99
+# define _tcgetattr(fd, ttmode) tcgetattr(fd, ttmode)
100
+#elif defined(TIOCGETA)
99 101
 # define _tcgetattr(fd, ttmode) ioctl(fd, TIOCGETA, (char *)ttmode)
102
+#elif defined(TCGETS)
103
+# define _tcgetattr(fd, ttmode) ioctl(fd, TCGETS, (char *)ttmode)
100 104
 #else
101
-# if defined(_HPUX_SOURCE) || defined(__Lynx__) || defined (__CYGWIN__)
102
-#  define _tcgetattr(fd, ttmode) tcgetattr(fd, ttmode)
103
-# else
104
-#  define _tcgetattr(fd, ttmode) ioctl(fd, TCGETS, (char *)ttmode)
105
-# endif
105
+# error
106 106
 #endif
107 107
 
108
-#if defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__bsdi__) || defined(__APPLE__) || defined (__DragonFly__)
108
+#if defined(HAVE_TCSETATTR) && defined(TCSANOW)
109
+# define _tcsetattr(fd, ttmode) tcsetattr(fd, TCSANOW, ttmode)
110
+#elif defined(TIOCSETA)
109 111
 # define _tcsetattr(fd, ttmode) ioctl(fd, TIOCSETA, (char *)ttmode)
112
+#elif defined(TCSETS)
113
+# define _tcsetattr(fd, ttmode) ioctl(fd, TCSETS, (char *)ttmode)
110 114
 #else
111
-# if defined(_HPUX_SOURCE) || defined(__CYGWIN__)
112
-#  define _tcsetattr(fd, ttmode) tcsetattr(fd, TCSANOW, ttmode) 
113
-# else
114
-#  define _tcsetattr(fd, ttmode) ioctl(fd, TCSETS, (char *)ttmode)
115
-# endif
115
+# error
116 116
 #endif
117 117
 
118 118
 #if defined (_HPUX_SOURCE)
@@ -201,87 +201,37 @@ KPty::~KPty()
201 201
   delete d;
202 202
 }
203 203
 
204
-bool KPty::open()
204
+bool KPty::setPty(int pty_master)
205 205
 {
206
-  if (d->masterFd >= 0)
207
-    return true;
206
+   kdWarning(175)
207
+      << "setPty()" << endl;
208
+   // a pty is already open
209
+   if(d->masterFd >= 0) {
210
+      kdWarning(175)
211
+	 << "d->masterFd >= 0" << endl;
212
+      return false;
213
+   }
214
+   d->masterFd = pty_master;
215
+   return _attachPty(pty_master);
216
+}
208 217
 
218
+bool KPty::_attachPty(int pty_master)
219
+{
209 220
   QCString ptyName;
210 221
 
211
-  // Find a master pty that we can open ////////////////////////////////
212
-
213
-  // Because not all the pty animals are created equal, they want to
214
-  // be opened by several different methods.
215
-
216
-  // We try, as we know them, one by one.
217
-
222
+    kdWarning(175)
223
+       << "_attachPty() " << pty_master << endl;
218 224
 #if defined(HAVE_PTSNAME) && defined(HAVE_GRANTPT)
219
-#ifdef _AIX
220
-  d->masterFd = ::open("/dev/ptc",O_RDWR);
221
-#else
222
-  d->masterFd = ::open("/dev/ptmx",O_RDWR);
223
-#endif
224
-  if (d->masterFd >= 0)
225
-  {
226 225
     char *ptsn = ptsname(d->masterFd);
227 226
     if (ptsn) {
228 227
         grantpt(d->masterFd);
229 228
         d->ttyName = ptsn;
230
-        goto gotpty;
231 229
     } else {
232 230
        ::close(d->masterFd);
233 231
        d->masterFd = -1;
234 232
     }
235
-  }
236 233
 #endif
237 234
 
238
-  // Linux device names, FIXME: Trouble on other systems?
239
-  for (const char* s3 = "pqrstuvwxyzabcdefghijklmno"; *s3; s3++)
240
-  {
241
-    for (const char* s4 = "0123456789abcdefghijklmnopqrstuvwxyz"; *s4; s4++)
242
-    {
243
-      ptyName.sprintf("/dev/pty%c%c", *s3, *s4);
244
-      d->ttyName.sprintf("/dev/tty%c%c", *s3, *s4);
245
-
246
-      d->masterFd = ::open(ptyName.data(), O_RDWR);
247
-      if (d->masterFd >= 0)
248
-      {
249
-#ifdef __sun
250
-        /* Need to check the process group of the pty.
251
-         * If it exists, then the slave pty is in use,
252
-         * and we need to get another one.
253
-         */
254
-        int pgrp_rtn;
255
-        if (ioctl(d->masterFd, TIOCGPGRP, &pgrp_rtn) == 0 || errno != EIO) {
256
-          ::close(d->masterFd);
257
-          d->masterFd = -1;
258
-          continue;
259
-        }
260
-#endif /* sun */
261
-        if (!access(d->ttyName.data(),R_OK|W_OK)) // checks availability based on permission bits
262
-        {
263
-          if (!geteuid())
264
-          {
265
-            struct group* p = getgrnam(TTY_GROUP);
266
-            if (!p)
267
-              p = getgrnam("wheel");
268
-            gid_t gid = p ? p->gr_gid : getgid ();
269
-
270
-            chown(d->ttyName.data(), getuid(), gid);
271
-            chmod(d->ttyName.data(), S_IRUSR|S_IWUSR|S_IWGRP);
272
-          }
273
-          goto gotpty;
274
-        }
275
-        ::close(d->masterFd);
276
-        d->masterFd = -1;
277
-      }
278
-    }
279
-  }
280
-
281
-  kdWarning(175) << "Can't open a pseudo teletype" << endl;
282
-  return false;
283
-
284
- gotpty:
285 235
   struct stat st;
286 236
   if (stat(d->ttyName.data(), &st))
287 237
     return false; // this just cannot happen ... *cough*  Yeah right, I just
@@ -354,6 +304,92 @@ bool KPty::open()
354 304
   return true;
355 305
 }
356 306
 
307
+bool KPty::open()
308
+{
309
+  if (d->masterFd >= 0)
310
+    return true;
311
+
312
+  QCString ptyName;
313
+
314
+  // Find a master pty that we can open ////////////////////////////////
315
+
316
+  // Because not all the pty animals are created equal, they want to
317
+  // be opened by several different methods.
318
+
319
+  // We try, as we know them, one by one.
320
+
321
+#if defined(HAVE_PTSNAME) && defined(HAVE_GRANTPT)
322
+#ifdef _AIX
323
+  d->masterFd = ::open("/dev/ptc",O_RDWR);
324
+#else
325
+  d->masterFd = ::open("/dev/ptmx",O_RDWR);
326
+#endif
327
+  if (d->masterFd >= 0)
328
+  {
329
+    char *ptsn = ptsname(d->masterFd);
330
+    if (ptsn) {
331
+        grantpt(d->masterFd);
332
+        d->ttyName = ptsn;
333
+        goto gotpty;
334
+    } else {
335
+       ::close(d->masterFd);
336
+       d->masterFd = -1;
337
+    }
338
+  }
339
+#endif
340
+
341
+  // Linux device names, FIXME: Trouble on other systems?
342
+  for (const char* s3 = "pqrstuvwxyzabcdefghijklmno"; *s3; s3++)
343
+  {
344
+    for (const char* s4 = "0123456789abcdefghijklmnopqrstuvwxyz"; *s4; s4++)
345
+    {
346
+      ptyName.sprintf("/dev/pty%c%c", *s3, *s4);
347
+      d->ttyName.sprintf("/dev/tty%c%c", *s3, *s4);
348
+
349
+      d->masterFd = ::open(ptyName.data(), O_RDWR);
350
+      if (d->masterFd >= 0)
351
+      {
352
+#ifdef __sun
353
+        /* Need to check the process group of the pty.
354
+         * If it exists, then the slave pty is in use,
355
+         * and we need to get another one.
356
+         */
357
+        int pgrp_rtn;
358
+        if (ioctl(d->masterFd, TIOCGPGRP, &pgrp_rtn) == 0 || errno != EIO) {
359
+          ::close(d->masterFd);
360
+          d->masterFd = -1;
361
+          continue;
362
+        }
363
+#endif /* sun */
364
+        if (!access(d->ttyName.data(),R_OK|W_OK)) // checks availability based on permission bits
365
+        {
366
+          if (!geteuid())
367
+          {
368
+            struct group* p = getgrnam(TTY_GROUP);
369
+            if (!p)
370
+              p = getgrnam("wheel");
371
+            gid_t gid = p ? p->gr_gid : getgid ();
372
+
373
+            chown(d->ttyName.data(), getuid(), gid);
374
+            chmod(d->ttyName.data(), S_IRUSR|S_IWUSR|S_IWGRP);
375
+          }
376
+          goto gotpty;
377
+        }
378
+        ::close(d->masterFd);
379
+        d->masterFd = -1;
380
+      }
381
+    }
382
+  }
383
+
384
+  kdWarning(175) << "Can't open a pseudo teletype" << endl;
385
+  return false;
386
+
387
+ gotpty:
388
+  return  _attachPty(d->masterFd);
389
+
390
+  return true;
391
+}
392
+
357 393
 void KPty::close()
358 394
 {
359 395
    if (d->masterFd < 0)

+ 10
- 0
kdecore/kpty.h View File

@@ -61,6 +61,13 @@ public:
61 61
    */
62 62
   bool open();
63 63
 
64
+  /** 
65
+   * Attach a existing pty master 
66
+   *
67
+   * @return true if the pty was successfully added
68
+   */ 
69
+  bool setPty(int pty_master);
70
+
64 71
   /**
65 72
    * Close the pty master/slave pair.
66 73
    */
@@ -138,6 +145,9 @@ public:
138 145
    */
139 146
   int slaveFd() const;
140 147
 
148
+protected:
149
+  bool _attachPty(int pty_master);
150
+
141 151
 private:
142 152
   bool chownpty(bool grant);
143 153
 

+ 9
- 3
kdecore/kstandarddirs.cpp View File

@@ -834,6 +834,10 @@ QStringList KStandardDirs::resourceDirs(const char *type) const
834 834
                     if ((local || testdir.exists()) && !candidates->contains(path))
835 835
                         candidates->append(path);
836 836
                 }
837
+		// UGLY HACK - Chris CHeney
838
+		if (local && (!strcmp("config", type)))
839
+		  candidates->append("/etc/kde3/");
840
+		//
837 841
                 local = false;
838 842
             }
839 843
         }
@@ -1021,7 +1025,7 @@ QString KStandardDirs::kde_default(const char *type) {
1021 1025
     if (!strcmp(type, "data"))