From 96900dbce3aaa1fcac74a07a71482c5c6fcd3cab Mon Sep 17 00:00:00 2001 From: tpearson Date: Thu, 2 Sep 2010 21:21:15 +0000 Subject: * Large set of SuSE patches to fix bugs and add functionality * kdemm is included but not used by knotify as it does not work out of the box git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1171141 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kded/Makefile.am | 6 +++++- kded/khostname.cpp | 28 ++++++++++++++++++---------- kded/kmimelist.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 11 deletions(-) create mode 100644 kded/kmimelist.cpp (limited to 'kded') 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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +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 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 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 it2(ol.begin()); + for (; it2 != ol.end(); ++it2) { + if ((*it2).allowAsDefault()) + printf( " %s", (*it2).service()->desktopEntryPath().ascii() ); + + } + printf( "\n" ); + } + } +} + -- cgit v1.2.3