Branch: master

9ea35022 2014-11-23 15:18:27 Timothy Pearson
Fix compositing manager detection
Add advanced option to allow a DCOP call to bypass the local call-->send translation shortcut
M dcop/dcopclient.cpp
M dcop/dcopclient.h
M tdecore/kdetcompmgr.cpp
diff --git a/dcop/dcopclient.cpp b/dcop/dcopclient.cpp
index 40cfd41..cfa9123 100644
--- a/dcop/dcopclient.cpp
+++ b/dcop/dcopclient.cpp
@@ -1737,7 +1737,7 @@
                       TQCString& replyType, TQByteArray &replyData,
                       bool useEventLoop)
 {
-    return call( remApp, remObjId, remFun, data, replyType, replyData, useEventLoop, -1 );
+    return call( remApp, remObjId, remFun, data, replyType, replyData, useEventLoop, -1, false );
 }
 
 bool DCOPClient::call(const TQCString &remApp, const TQCString &remObjId,
@@ -1745,23 +1745,31 @@
                       TQCString& replyType, TQByteArray &replyData,
                       bool useEventLoop, int timeout)
 {
+    return call( remApp, remObjId, remFun, data, replyType, replyData, useEventLoop, timeout, false );
+}
+
+bool DCOPClient::call(const TQCString &remApp, const TQCString &remObjId,
+                      const TQCString &remFun, const TQByteArray &data,
+                      TQCString& replyType, TQByteArray &replyData,
+                      bool useEventLoop, int timeout, bool forceRemote)
+{
     if (remApp.isEmpty())
         return false;
     DCOPClient *localClient = findLocalClient( remApp );
 
-    if ( localClient ) {
+    if ( localClient && !forceRemote ) {
         bool saveTransaction = d->transaction;
         TQ_INT32 saveTransactionId = d->transactionId;
         TQCString saveSenderId = d->senderId;
 
         d->senderId = 0; // Local call
         bool b = localClient->receive(  remApp, remObjId, remFun, data, replyType, replyData );
-        
+
         TQ_INT32 id = localClient->transactionId();
         if (id) {
            // Call delayed. We have to wait till it has been processed.
            do {
-              TQApplication::eventLoop()->processEvents( TQEventLoop::WaitForMore);
+              TQApplication::eventLoop()->processEvents(TQEventLoop::WaitForMore);
            } while( !localClient->isLocalTransactionFinished(id, replyType, replyData));
            b = true;
         }
diff --git a/dcop/dcopclient.h b/dcop/dcopclient.h
index 8421c7b..4cb4b2f 100644
--- a/dcop/dcopclient.h
+++ b/dcop/dcopclient.h
@@ -292,12 +292,25 @@
    * @param useEventLoop if true the event loop will be started when
    *         the call blocks too long
    * @param timeout timeout for the call in miliseconds, or -1 for no timeout
+   * @param forceRemote if set do not allow calls within the current application
+   *         to bypass the remote call mechanism
    * @return true if successful, false otherwise
    *
    * @since 3.2
    *
    * @see send()
    */
+
+  bool call(const TQCString &remApp, const TQCString &remObj,
+	    const TQCString &remFun, const TQByteArray &data,
+	    TQCString& replyType, TQByteArray &replyData,
+	    bool useEventLoop/*=false*/, int timeout/*=-1*/,
+	    bool forceRemote/*=false*/);
+
+  /**
+   * @deprecated
+   */
+  // KDE4 merge with above
   bool call(const TQCString &remApp, const TQCString &remObj,
 	    const TQCString &remFun, const TQByteArray &data,
 	    TQCString& replyType, TQByteArray &replyData,
diff --git a/tdecore/kdetcompmgr.cpp b/tdecore/kdetcompmgr.cpp
index 694d60b..b5640c6 100644
--- a/tdecore/kdetcompmgr.cpp
+++ b/tdecore/kdetcompmgr.cpp
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2011 Timothy Pearson <kb9vqf@...>      *
+ *   Copyright (C) 2011-2014 Timothy Pearson <kb9vqf@...> *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -44,7 +44,7 @@
 int main(int argc, char **argv)
 {
     TDEAboutData about("kdetcompmgr", I18N_NOOP("kdetcompmgr"), version, description,
-		     TDEAboutData::License_GPL, "(C) 2011 Timothy Pearson", 0, 0, "kb9vqf@...");
+		     TDEAboutData::License_GPL, "(C) 2011-2014 Timothy Pearson", 0, 0, "kb9vqf@...");
     about.addAuthor( "Timothy Pearson", 0, "kb9vqf@..." );
     TDECmdLineArgs::init(argc, argv, &about);
     TDECmdLineArgs::addCmdLineOptions( options );
@@ -54,21 +54,19 @@
     TDEConfig config("twinrc", true);
     config.setGroup( "Notification Messages" );
     if (!config.readBoolEntry("UseTranslucency",false)) {
-        // Attempt to load the kompmgr pid file
-        const char *home;
-        struct passwd *p;
-        p = getpwuid(getuid());
-        if (p)
-            home = p->pw_dir;
-        else
-            home = getenv("HOME");
+        // Attempt to load the compton-tde pid file
         char *filename;
-        const char *configfile = "/.kompmgr.pid";
-        int n = strlen(home)+strlen(configfile)+1;
-        filename = (char*)malloc(n*sizeof(char));
+        const char *pidfile = "compton-tde.pid";
+        char uidstr[sizeof(uid_t)*8+1];
+        sprintf(uidstr, "%d", getuid());
+        int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
+        filename = (char*)malloc(n*sizeof(char)+1);
         memset(filename,0,n);
-        strcat(filename, home);
-        strcat(filename, configfile);
+        strcat(filename, P_tmpdir);
+        strcat(filename, "/.");
+        strcat(filename, uidstr);
+        strcat(filename, "-");
+        strcat(filename, pidfile);
 
         // Now that we did all that by way of introduction...read the file!
         FILE *pFile;
@@ -76,7 +74,7 @@
         pFile = fopen(filename, "r");
         int kompmgrpid = 0;
         if (pFile) {
-            printf("[kdetcompmgr] Using '%s' as kompmgr pidfile\n", filename);
+            printf("[kdetcompmgr] Using '%s' as compton-tde pidfile\n", filename);
             // obtain file size
             fseek (pFile , 0 , SEEK_END);
             unsigned long lSize = ftell (pFile);