quick-settings: cache D-Bus proxies in network tiles

parent c5372594
...@@ -15,6 +15,10 @@ namespace XimperShellNotificationCenter.Widgets { ...@@ -15,6 +15,10 @@ namespace XimperShellNotificationCenter.Widgets {
private Gtk.Box ?current_submenu = null; private Gtk.Box ?current_submenu = null;
private bool updating_submenu = false; private bool updating_submenu = false;
private bool connecting = false; private bool connecting = false;
private Gee.HashMap<string, NMActiveConnDBus> active_proxy_cache =
new Gee.HashMap<string, NMActiveConnDBus> ();
private Gee.HashMap<string, NMSettingsConnDBus> conn_proxy_cache =
new Gee.HashMap<string, NMSettingsConnDBus> ();
~VpnTile () { ~VpnTile () {
if (sync_timeout != 0) { if (sync_timeout != 0) {
...@@ -104,11 +108,17 @@ namespace XimperShellNotificationCenter.Widgets { ...@@ -104,11 +108,17 @@ namespace XimperShellNotificationCenter.Widgets {
foreach (var ac_path foreach (var ac_path
in nm.active_connections) { in nm.active_connections) {
try { try {
var ac = yield Bus.get_proxy string key = (string) ac_path;
<NMActiveConnDBus> ( NMActiveConnDBus ?ac =
BusType.SYSTEM, active_proxy_cache.get (key);
"org.freedesktop.NetworkManager", if (ac == null) {
ac_path); ac = yield Bus.get_proxy
<NMActiveConnDBus> (
BusType.SYSTEM,
"org.freedesktop.NetworkManager",
ac_path);
active_proxy_cache.set (key, ac);
}
if (ac.vpn && ac.state == 2) { if (ac.vpn && ac.state == 2) {
active_vpns.set ( active_vpns.set (
(string) ac.connection, (string) ac.connection,
...@@ -132,11 +142,17 @@ namespace XimperShellNotificationCenter.Widgets { ...@@ -132,11 +142,17 @@ namespace XimperShellNotificationCenter.Widgets {
foreach (var conn_path foreach (var conn_path
in settings.list_connections ()) { in settings.list_connections ()) {
try { try {
var conn = yield Bus.get_proxy string key = (string) conn_path;
<NMSettingsConnDBus> ( NMSettingsConnDBus ?conn =
BusType.SYSTEM, conn_proxy_cache.get (key);
"org.freedesktop.NetworkManager", if (conn == null) {
conn_path); conn = yield Bus.get_proxy
<NMSettingsConnDBus> (
BusType.SYSTEM,
"org.freedesktop.NetworkManager",
conn_path);
conn_proxy_cache.set (key, conn);
}
var s = conn.get_settings (); var s = conn.get_settings ();
var conn_s = s.lookup ("connection"); var conn_s = s.lookup ("connection");
if (conn_s == null) continue; if (conn_s == null) continue;
...@@ -149,7 +165,6 @@ namespace XimperShellNotificationCenter.Widgets { ...@@ -149,7 +165,6 @@ namespace XimperShellNotificationCenter.Widgets {
string name = id_var != null string name = id_var != null
? id_var.get_string () : "VPN"; ? id_var.get_string () : "VPN";
string key = (string) conn_path;
if (seen.contains (key)) continue; if (seen.contains (key)) continue;
seen.add (key); seen.add (key);
......
...@@ -22,6 +22,10 @@ namespace XimperShellNotificationCenter.Widgets { ...@@ -22,6 +22,10 @@ namespace XimperShellNotificationCenter.Widgets {
private bool connecting = false; private bool connecting = false;
private bool updating_submenu = false; private bool updating_submenu = false;
private Gtk.Revealer ?open_password_revealer = null; private Gtk.Revealer ?open_password_revealer = null;
private Gee.HashMap<string, NMAccessPointDBus> ap_proxy_cache =
new Gee.HashMap<string, NMAccessPointDBus> ();
private Gee.HashMap<string, NMSettingsConnDBus> saved_proxy_cache =
new Gee.HashMap<string, NMSettingsConnDBus> ();
~WifiTile () { ~WifiTile () {
if (sync_timeout != 0) { if (sync_timeout != 0) {
...@@ -200,11 +204,17 @@ namespace XimperShellNotificationCenter.Widgets { ...@@ -200,11 +204,17 @@ namespace XimperShellNotificationCenter.Widgets {
foreach (var ap_path in ap_paths) { foreach (var ap_path in ap_paths) {
try { try {
var ap = string key = (string) ap_path;
yield Bus.get_proxy<NMAccessPointDBus> ( NMAccessPointDBus ?ap =
BusType.SYSTEM, ap_proxy_cache.get (key);
"org.freedesktop.NetworkManager", if (ap == null) {
ap_path); ap = yield Bus.get_proxy
<NMAccessPointDBus> (
BusType.SYSTEM,
"org.freedesktop.NetworkManager",
ap_path);
ap_proxy_cache.set (key, ap);
}
string ssid = string ssid =
NetworkManagerProxy.ssid_to_string ( NetworkManagerProxy.ssid_to_string (
ap.ssid); ap.ssid);
...@@ -281,11 +291,17 @@ namespace XimperShellNotificationCenter.Widgets { ...@@ -281,11 +291,17 @@ namespace XimperShellNotificationCenter.Widgets {
foreach (var conn_path foreach (var conn_path
in settings.list_connections ()) { in settings.list_connections ()) {
try { try {
var conn = string key = (string) conn_path;
yield Bus.get_proxy<NMSettingsConnDBus> ( NMSettingsConnDBus ?conn =
BusType.SYSTEM, saved_proxy_cache.get (key);
"org.freedesktop.NetworkManager", if (conn == null) {
conn_path); conn = yield Bus.get_proxy
<NMSettingsConnDBus> (
BusType.SYSTEM,
"org.freedesktop.NetworkManager",
conn_path);
saved_proxy_cache.set (key, conn);
}
var s = conn.get_settings (); var s = conn.get_settings ();
var wifi_s = s.lookup ( var wifi_s = s.lookup (
"802-11-wireless"); "802-11-wireless");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment