summaryrefslogtreecommitdiffstats
path: root/kded
diff options
context:
space:
mode:
Diffstat (limited to 'kded')
-rw-r--r--kded/Makefile.am6
-rw-r--r--kded/khostname.cpp28
-rw-r--r--kded/kmimelist.cpp54
3 files changed, 77 insertions, 11 deletions
diff --git a/kded/Makefile.am b/kded/Makefile.am
index 8437919f0..d8ebac458 100644
--- a/kded/Makefile.am
+++ b/kded/Makefile.am
@@ -36,12 +36,16 @@ kbuildsycoca_la_SOURCES = kbuildsycoca.cpp kbuildservicetypefactory.cpp \
kctimefactory.cpp \
vfolder_menu.cpp
-bin_PROGRAMS = kdontchangethehostname kde-menu
+bin_PROGRAMS = kdontchangethehostname kde-menu kmimelist
kdontchangethehostname_LDFLAGS = $(all_libraries) $(KDE_RPATH)
kdontchangethehostname_LDADD = $(LIB_KDECORE)
kdontchangethehostname_SOURCES = khostname.cpp
+kmimelist_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+kmimelist_LDADD = ../kio/libkio.la
+kmimelist_SOURCES = kmimelist.cpp
+
kde_menu_LDFLAGS = $(all_libraries) $(KDE_RPATH)
kde_menu_LDADD = $(LIB_KIO)
kde_menu_SOURCES = kde-menu.cpp
diff --git a/kded/khostname.cpp b/kded/khostname.cpp
index e38c88f53..0fa837a2c 100644
--- a/kded/khostname.cpp
+++ b/kded/khostname.cpp
@@ -111,7 +111,8 @@ static QCStringList split(const TQCString &str)
void KHostName::changeX()
{
- TQString cmd = "xauth list";
+ const char* xauthlocalhostname = getenv("XAUTHLOCALHOSTNAME");
+ TQString cmd = "xauth -n list";
FILE *xFile = popen(TQFile::encodeName(cmd), "r");
if (!xFile)
{
@@ -123,6 +124,7 @@ void KHostName::changeX()
char buf[1024+1];
while (!feof(xFile))
{
+ buf[1024]='\0';
TQCString line = fgets(buf, 1024, xFile);
if (line.length())
line.truncate(line.length()-1); // Strip LF.
@@ -157,12 +159,17 @@ void KHostName::changeX()
TQCString newNetId = newName+netId.mid(i);
TQCString oldNetId = netId.left(i);
- if(oldNetId != oldName)
- continue;
+ if(oldNetId != oldName
+ && (!xauthlocalhostname || strcmp(xauthlocalhostname, oldNetId.data()) != 0))
+ continue;
- cmd = "xauth remove "+KProcess::quote(netId);
- system(TQFile::encodeName(cmd));
- cmd = "xauth add ";
+ // don't nuke the xauth when XAUTHLOCALHOSTNAME points to it
+ if (!xauthlocalhostname || oldNetId != xauthlocalhostname)
+ {
+ cmd = "xauth -n remove "+KProcess::quote(netId);
+ system(TQFile::encodeName(cmd));
+ }
+ cmd = "xauth -n add ";
cmd += KProcess::quote(newNetId);
cmd += " ";
cmd += KProcess::quote(authName);
@@ -276,7 +283,10 @@ void KHostName::changeDcop()
}
}
- // Remove old entries
+ // Remove old entries, but only if XAUTHLOCALHOSTNAME doesn't point
+ // to it
+ char* xauthlocalhostname = getenv("XAUTHLOCALHOSTNAME");
+ if (!xauthlocalhostname || !oldNetId.contains(xauthlocalhostname))
{
TQString cmd = "iceauth remove "+KProcess::quote("netid="+oldNetId);
system(TQFile::encodeName(cmd));
@@ -368,9 +378,7 @@ int main(int argc, char **argv)
KHostName hn;
- if(!getenv("XAUTHLOCALHOSTNAME"))
- hn.changeX();
-
+ hn.changeX();
hn.changeDcop();
hn.changeStdDirs("socket");
hn.changeStdDirs("tmp");
diff --git a/kded/kmimelist.cpp b/kded/kmimelist.cpp
new file mode 100644
index 000000000..a08484bc6
--- /dev/null
+++ b/kded/kmimelist.cpp
@@ -0,0 +1,54 @@
+#include <ktrader.h>
+#include <kservice.h>
+#include <kmimetype.h>
+#include <assert.h>
+#include <kstandarddirs.h>
+#include <kservicegroup.h>
+#include <kimageio.h>
+#include <kuserprofile.h>
+#include <kprotocolinfo.h>
+
+#include <kapplication.h>
+
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ KApplication k(argc,argv,"blurb",false);
+
+ KMimeType::List mtl = KMimeType::allMimeTypes( );
+ assert( mtl.count() );
+ qDebug( "Found %d mime types.", mtl.count() );
+ TQValueListIterator<KMimeType::Ptr> it(mtl.begin());
+ KServiceTypeProfile::OfferList ol;
+
+ for (; it != mtl.end(); ++it)
+ {
+ {
+ // Application
+ printf( "APP:%s:", (*it)->name().latin1() );
+ ol = KServiceTypeProfile::offers((*it)->name(), "Application");
+ TQValueListIterator<KServiceOffer> it2(ol.begin());
+ for (; it2 != ol.end(); ++it2) {
+ if ((*it2).allowAsDefault())
+ printf( " %s", (*it2).service()->desktopEntryPath().ascii() );
+
+ }
+ printf( "\n" );
+ }
+
+ {
+ // Embedded
+ printf( "PART:%s:", (*it)->name().latin1() );
+ ol = KServiceTypeProfile::offers((*it)->name(), "KParts/ReadOnlyPart");
+ TQValueListIterator<KServiceOffer> it2(ol.begin());
+ for (; it2 != ol.end(); ++it2) {
+ if ((*it2).allowAsDefault())
+ printf( " %s", (*it2).service()->desktopEntryPath().ascii() );
+
+ }
+ printf( "\n" );
+ }
+ }
+}
+