Sophie

Sophie

distrib > Mandriva > current > i586 > media > contrib-release-src > by-pkgid > 1d7232883490418f44073bf391d9a3fe > files > 4

libxfcegui4-4.6.3-2mdv2010.1.src.rpm

From 27c2c721114a127d24fb3ad13ab44bbf693e82b2 Mon Sep 17 00:00:00 2001
From: David Mohr <david@mcbf.net>
Date: Wed, 17 Mar 2010 21:42:50 -0600
Subject: [PATCH] Replace the client id in commands if the SM returned a different one

---
 libxfcegui4/session-client.c |   44 +++++++++++++++++++++++++++++++++++------
 1 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/libxfcegui4/session-client.c b/libxfcegui4/session-client.c
index c9c1137..0fedb51 100644
--- a/libxfcegui4/session-client.c
+++ b/libxfcegui4/session-client.c
@@ -567,6 +567,7 @@ interact (SmcConn smc_conn, SmPointer client_data)
 
 #define APPEND 1
 #define REMOVE 2
+#define REPLACE 3
 
 static void
 set_property_from_command (SessionClient * session_client, char *command,
@@ -576,6 +577,7 @@ set_property_from_command (SessionClient * session_client, char *command,
     gchar **args;
     gint i;
     gint argc;
+    gboolean sm_id_next = FALSE;
 
     SmPropValue *vals;
 
@@ -588,7 +590,17 @@ set_property_from_command (SessionClient * session_client, char *command,
         if (alter_sm_id == APPEND &&
             !g_ascii_strncasecmp (*args, SM_ID_ARG, strlen (SM_ID_ARG)))
         {
-            alter_sm_id = FALSE;
+            if (session_client->client_id &&
+                strcmp (session_client->client_id, session_client->given_client_id) != 0)
+            {
+                /* A different clientid was handed to us from the SM.
+                 * Replace the existing one. */
+                alter_sm_id = REPLACE;
+            }
+            else
+            {
+                alter_sm_id = FALSE;
+            }
         }
         argc++;
     }
@@ -601,17 +613,34 @@ set_property_from_command (SessionClient * session_client, char *command,
     i = 0;
     while (*ptr)
     {
-        if (alter_sm_id == REMOVE &&
+        if ((alter_sm_id == REMOVE ||
+             alter_sm_id == REPLACE) &&
             !g_ascii_strncasecmp (*ptr, SM_ID_ARG, strlen (SM_ID_ARG)))
         {
-            /* skip the argument after SM_ID_ARG */
-            if (ptr[1] != NULL)
-                ptr++;
+            if (G_LIKELY (alter_sm_id == REMOVE))
+            {
+                /* skip the argument after SM_ID_ARG */
+                if (ptr[1] != NULL)
+                    ptr++;
+            }
+            else
+            {
+                sm_id_next = TRUE;
+            }
         }
         else
         {
-            vals[i].length = strlen (*ptr);
-            vals[i++].value = *ptr;
+            if (G_UNLIKELY (sm_id_next))
+            {
+                vals[i].length = strlen (session_client->given_client_id);
+                vals[i++].value = session_client->given_client_id;
+                sm_id_next = FALSE;
+            }
+            else
+            {
+                vals[i].length = strlen (*ptr);
+                vals[i++].value = *ptr;
+            }
         }
         ptr++;
     }
@@ -662,6 +691,7 @@ set_clone_restart_commands (SessionClient * session_client)
 
 #undef APPEND
 #undef REMOVE
+#undef REPLACE
 
 #endif
 
-- 
1.7.0