rendered paste body--- bus/activation.c+++ bus/activation.c@@ -248,6 +248,10 @@ bus_activation_entry_unref (BusActivationEntry *entry) dbus_free (entry); } +#ifdef DBUS_WIN+const char *_dbus_windows_replace_prefix (const char *configure_time_path);+#endif+ static dbus_bool_t update_desktop_file_entry (BusActivation *activation, BusServiceDirectory *s_dir,@@ -255,7 +259,7 @@ update_desktop_file_entry (BusActivation *activation, BusDesktopFile *desktop_file, DBusError *error) {- char *name, *exec, *user;+ char *name, *exec, *user, *exec_tmp; BusActivationEntry *entry; DBusStat stat_buf; DBusString file_path;@@ -266,6 +270,7 @@ update_desktop_file_entry (BusActivation *activation, name = NULL; exec = NULL; user = NULL;+ exec_tmp = NULL; entry = NULL; dbus_error_init (&tmp_error);@@ -300,7 +305,7 @@ update_desktop_file_entry (BusActivation *activation, if (!bus_desktop_file_get_string (desktop_file, DBUS_SERVICE_SECTION, DBUS_SERVICE_EXEC,- &exec,+ &exec_tmp, error)) goto failed; @@ -329,6 +334,12 @@ update_desktop_file_entry (BusActivation *activation, entry = _dbus_hash_table_lookup_string (s_dir->entries, _dbus_string_get_const_data (filename));+#ifdef DBUS_WIN+ exec = strdup (_dbus_windows_replace_prefix (exec_tmp));+#else+ exec = strdup (exec_tmp);+#endif+ if (entry == NULL) /* New file */ { /* FIXME we need a better-defined algorithm for which service file to@@ -417,7 +428,7 @@ update_desktop_file_entry (BusActivation *activation, failed: dbus_free (name);- dbus_free (exec);+ dbus_free (exec_tmp); dbus_free (user); _dbus_string_free (&file_path); --- configure.in+++ configure.in@@ -1284,6 +1284,7 @@ AC_MSG_RESULT(yes) #### find the actual value for $prefix that we'll end up with ## (I know this is broken and should be done in the Makefile, but ## that's a major pain and almost nobody actually seems to care)+AS_AC_EXPAND(EXPANDED_PREFIX, "$prefix") AS_AC_EXPAND(EXPANDED_LOCALSTATEDIR, "$localstatedir") AS_AC_EXPAND(EXPANDED_SYSCONFDIR, "$sysconfdir") AS_AC_EXPAND(EXPANDED_BINDIR, "$bindir")@@ -1379,6 +1380,11 @@ fi AC_SUBST(DBUS_USER) AC_DEFINE_UNQUOTED(DBUS_USER,"$DBUS_USER", [User for running the system BUS daemon]) +#### Prefix to install into+DBUS_PREFIX=$EXPANDED_PREFIX+AC_SUBST(DBUS_PREFIX)+AC_DEFINE_UNQUOTED(DBUS_PREFIX,"$DBUS_PREFIX", [Prefix for installing DBUS])+ #### Direcotry to install data files into DBUS_DATADIR=$EXPANDED_DATADIR AC_SUBST(DBUS_DATADIR)@@ -1530,7 +1536,7 @@ echo " D-Bus $VERSION ============== - prefix: ${prefix}+ prefix: ${EXPANDED_PREFIX} exec_prefix: ${exec_prefix} libdir: ${EXPANDED_LIBDIR} libexecdir: ${EXPANDED_LIBEXECDIR}--- dbus/dbus-sysdeps-win.c+++ dbus/dbus-sysdeps-win.c@@ -2062,6 +2062,93 @@ _dbus_delete_file (const DBusString *filename, return TRUE; } +/**+ * return the absolute path of the dbus installation+ *+ * @param s buffer for installation path+ * @param len length of buffer+ * @returns #FALSE on failure+ */+static dbus_bool_t+_dbus_get_install_root(char *prefix, int len)+{+ //To find the prefix, we cut the filename and also \bin\ if present+ char* p = 0;+ int i;+ DWORD pathLength;+ char *lastSlash;+ SetLastError( 0 );+ pathLength = GetModuleFileName(_dbus_win_get_dll_hmodule(), prefix, len);+ if ( pathLength == 0 || GetLastError() != 0 ) {+ *prefix = '\0';+ return FALSE;+ }+ lastSlash = _mbsrchr(prefix, '\\');+ if (lastSlash == NULL) {+ *prefix = '\0';+ return FALSE;+ }+ //cut off binary name+ lastSlash[1] = 0;++ /* cut possible "\\bin"+ */++ /* this fails if we are in a double-byte system codepage and the+ * folder's name happens to end with the *bytes*+ * "\\bin"... (I.e. the second byte of some Han character and then+ * the Latin "bin", but that is not likely I think...+ */+ if (lastSlash - prefix >= 4 && strnicmp(lastSlash - 4, "\\bin", 4) == 0)+ lastSlash[-3] = 0;+ else if (lastSlash - prefix >= 10 && strnicmp(lastSlash - 10, "\\bin\\debug", 10) == 0)+ lastSlash[-9] = 0;+ else if (lastSlash - prefix >= 12 && strnicmp(lastSlash - 12, "\\bin\\release", 12) == 0)+ lastSlash[-11] = 0;++ return TRUE;+}++/* Prototype to silence GCC */+const char *_dbus_windows_replace_prefix (const char *configure_time_path);++const char *+_dbus_windows_replace_prefix (const char *configure_time_path)+{+ static char retval[1000];+#ifndef DBUS_PREFIX+ strcat (retval, configure_time_path);+#else+ static char runtime_prefix[1000];+ int len = 1000;+ int i;++ if (!configure_time_path)+ return NULL;++ if ((!_dbus_get_install_root(runtime_prefix, len) ||+ strncmp (configure_time_path, DBUS_PREFIX "/",+ strlen (DBUS_PREFIX) + 1))) {+ strcat (retval, configure_time_path);+ return retval;+ }++ strcpy (retval, runtime_prefix);+ strcat (retval, configure_time_path + strlen (DBUS_PREFIX) + 1);++ /* Somehow, in some situations, backslashes get collapsed in the string.+ * Since windows C library accepts both forward and backslashes as+ * path separators, convert all backslashes to forward slashes.+ */++ for(i = 0; retval[i] != '\0'; i++) {+ if(retval[i] == '\\')+ retval[i] = '/';+ }+#endif+ return retval;+}+ #if !defined (DBUS_DISABLE_ASSERT) || defined(DBUS_BUILD_TESTS) #ifdef _MSC_VER@@ -2667,6 +2754,21 @@ _dbus_make_file_world_readable(const DBusString *filename, return TRUE; } +/**+ * return the relocated DATADIR+ *+ * @returns relocated DATADIR static string+ */++static const char *+_dbus_windows_get_datadir (void)+{+ return _dbus_windows_replace_prefix(DBUS_DATADIR);+}++#undef DBUS_DATADIR+#define DBUS_DATADIR _dbus_windows_get_datadir ()+ #define DBUS_STANDARD_SESSION_SERVICEDIR "/dbus-1/services" #define DBUS_STANDARD_SYSTEM_SERVICEDIR "/dbus-1/system-services"@@ -2681,7 +2783,7 @@ _dbus_make_file_world_readable(const DBusString *filename, * * and *- * DBUS_DATADIR+ * relocated DBUS_DATADIR * * @param dirs the directory list we are returning * @returns #FALSE on OOM @@ -2696,8 +2798,11 @@ _dbus_get_standard_session_servicedirs (DBusList **dirs) if (!_dbus_string_init (&servicedir_path)) return FALSE; - if (!_dbus_string_append (&servicedir_path, DBUS_DATADIR _DBUS_PATH_SEPARATOR))- goto oom;+ if (!_dbus_string_append (&servicedir_path, DBUS_DATADIR))+ goto oom;++ if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR))+ goto oom; common_progs = _dbus_getenv ("CommonProgramFiles"); @@ -2806,51 +2911,6 @@ _dbus_get_is_errno_eagain_or_ewouldblock (void) return errno == WSAEWOULDBLOCK; } -/**- * return the absolute path of the dbus installation - *- * @param s buffer for installation path- * @param len length of buffer- * @returns #FALSE on failure- */-static dbus_bool_t-_dbus_get_install_root(char *prefix, int len)-{- //To find the prefix, we cut the filename and also \bin\ if present- char* p = 0;- int i;- DWORD pathLength;- char *lastSlash;- SetLastError( 0 );- pathLength = GetModuleFileName(_dbus_win_get_dll_hmodule(), prefix, len);- if ( pathLength == 0 || GetLastError() != 0 ) {- *prefix = '\0';- return FALSE;- }- lastSlash = _mbsrchr(prefix, '\\');- if (lastSlash == NULL) {- *prefix = '\0';- return FALSE;- }- //cut off binary name- lastSlash[1] = 0;-- //cut possible "\\bin"-- //this fails if we are in a double-byte system codepage and the- //folder's name happens to end with the *bytes*- //"\\bin"... (I.e. the second byte of some Han character and then- //the Latin "bin", but that is not likely I think...- if (lastSlash - prefix >= 4 && strnicmp(lastSlash - 4, "\\bin", 4) == 0)- lastSlash[-3] = 0;- else if (lastSlash - prefix >= 10 && strnicmp(lastSlash - 10, "\\bin\\debug", 10) == 0)- lastSlash[-9] = 0;- else if (lastSlash - prefix >= 12 && strnicmp(lastSlash - 12, "\\bin\\release", 12) == 0)- lastSlash[-11] = 0;-- return TRUE;-}- /** find config file either from installation or build root according to the following path layout