View | Details | Raw Unified | Return to bug 29171
Collapse All | Expand All

(-)a/gvfs/monitor/proxy/gvfsproxyvolumemonitordaemon.c (-1 / +81 lines)
Lines 45-50 static gboolean always_call_mount = FALSE; Link Here
45
45
46
static GVfsRemoteVolumeMonitor *monitor_daemon = NULL;
46
static GVfsRemoteVolumeMonitor *monitor_daemon = NULL;
47
47
48
static GDBusProxy *session_active_proxy = NULL;
49
48
#define DEBUG_ENABLED
50
#define DEBUG_ENABLED
49
51
50
#ifdef DEBUG_ENABLED
52
#ifdef DEBUG_ENABLED
Lines 1750-1756 emit_signal (GVfsRemoteVolumeMonitor *instance, MonitorSignalFunc signal_func, v Link Here
1750
{
1752
{
1751
  char *id;
1753
  char *id;
1752
  GVariant *val;
1754
  GVariant *val;
1753
  
1755
  GVariant *res, *inner = NULL;
1756
  GError *error = NULL;
1757
  gchar *state;
1758
1759
  if (session_active_proxy != NULL) {
1760
	  res = g_dbus_proxy_call_sync (session_active_proxy , "Get",
1761
								g_variant_new( "(ss)",
1762
						"org.freedesktop.login1.Session",
1763
						"State"),
1764
								G_DBUS_CALL_FLAGS_NONE,
1765
								-1,
1766
								NULL,
1767
								&error
1768
								);
1769
1770
1771
	  if (error == NULL && res != NULL) {
1772
		 g_variant_get(res, "(v)", &inner );
1773
		 state = g_variant_get_string(inner,NULL);
1774
	  } else if (error != NULL ) {
1775
		print_debug ("Error in dbus - %s", error->message);
1776
		g_error_free (error);
1777
	  }
1778
1779
	  if (inner != NULL)
1780
		  g_variant_unref (inner);
1781
	  if (res != NULL)
1782
		  g_variant_unref (res);
1783
  }
1784
  if (session_active_proxy == NULL || g_strcmp0(state,"active") == 0) {
1785
1754
  print_debug ("emit_signal: %p", object);
1786
  print_debug ("emit_signal: %p", object);
1755
  
1787
  
1756
  id = g_strdup_printf ("%p", object);
1788
  id = g_strdup_printf ("%p", object);
Lines 1759-1764 emit_signal (GVfsRemoteVolumeMonitor *instance, MonitorSignalFunc signal_func, v Link Here
1759
  signal_func (instance, the_dbus_name, id, val);
1791
  signal_func (instance, the_dbus_name, id, val);
1760
1792
1761
  g_free (id);
1793
  g_free (id);
1794
  }
1795
  else  print_debug ("inactive session\n");
1796
1762
}
1797
}
1763
1798
1764
static void
1799
static void
Lines 1980-1985 g_vfs_proxy_volume_monitor_daemon_main (int argc, Link Here
1980
                                        GType volume_monitor_type)
2015
                                        GType volume_monitor_type)
1981
{
2016
{
1982
  guint name_owner_id;
2017
  guint name_owner_id;
2018
  GDBusProxy *logind_proxy;
2019
  GVariant *res;
2020
  GError *error = NULL;
2021
  gchar *session_obj_path;
1983
2022
1984
  name_owner_id = 0;
2023
  name_owner_id = 0;
1985
2024
Lines 1994-1999 g_vfs_proxy_volume_monitor_daemon_main (int argc, Link Here
1994
  the_dbus_name = dbus_name;
2033
  the_dbus_name = dbus_name;
1995
  unique_names_being_watched = g_hash_table_new_full (g_str_hash, g_int_equal, g_free, NULL);
2034
  unique_names_being_watched = g_hash_table_new_full (g_str_hash, g_int_equal, g_free, NULL);
1996
2035
2036
  logind_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
2037
		 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
2038
		 NULL,
2039
		 "org.freedesktop.login1",
2040
		 "/org/freedesktop/login1",
2041
		 "org.freedesktop.login1.Manager",
2042
		 NULL,
2043
		 &error );
2044
  if (logind_proxy == NULL) {
2045
    print_debug("Error creating proxy - %s", error->message);
2046
    g_error_free (error);
2047
  } else {
2048
	  res = g_dbus_proxy_call_sync (logind_proxy, "GetSessionByPID",
2049
			  g_variant_new( "(u)", getpid() ),
2050
			  G_DBUS_CALL_FLAGS_NONE,
2051
			  -1,
2052
			  NULL,
2053
			  &error
2054
			  );
2055
2056
	  if (error == NULL && res != NULL) {
2057
			g_variant_get(res,"(o)", &session_obj_path);
2058
	  }
2059
	  else {
2060
		print_debug( "Error getting session - %s", error->message);
2061
	  }
2062
2063
	   g_object_unref(logind_proxy);
2064
	   session_active_proxy =  g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
2065
			 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
2066
			 NULL,
2067
			 "org.freedesktop.login1",
2068
			 session_obj_path,
2069
			 "org.freedesktop.DBus.Properties",
2070
			 NULL,
2071
			 &error );
2072
	  if (session_active_proxy == NULL) {
2073
		  g_error_free (error);
2074
	  }
2075
  }
2076
1997
  /* try and create the monitor */
2077
  /* try and create the monitor */
1998
  monitor_try_create ();
2078
  monitor_try_create ();
1999
2079

Return to bug 29171