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

parent c5372594
......@@ -15,6 +15,10 @@ namespace XimperShellNotificationCenter.Widgets {
private Gtk.Box ?current_submenu = null;
private bool updating_submenu = 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 () {
if (sync_timeout != 0) {
......@@ -104,11 +108,17 @@ namespace XimperShellNotificationCenter.Widgets {
foreach (var ac_path
in nm.active_connections) {
try {
var ac = yield Bus.get_proxy
<NMActiveConnDBus> (
BusType.SYSTEM,
"org.freedesktop.NetworkManager",
ac_path);
string key = (string) ac_path;
NMActiveConnDBus ?ac =
active_proxy_cache.get (key);
if (ac == null) {
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) {
active_vpns.set (
(string) ac.connection,
......@@ -132,11 +142,17 @@ namespace XimperShellNotificationCenter.Widgets {
foreach (var conn_path
in settings.list_connections ()) {
try {
var conn = yield Bus.get_proxy
<NMSettingsConnDBus> (
BusType.SYSTEM,
"org.freedesktop.NetworkManager",
conn_path);
string key = (string) conn_path;
NMSettingsConnDBus ?conn =
conn_proxy_cache.get (key);
if (conn == null) {
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 conn_s = s.lookup ("connection");
if (conn_s == null) continue;
......@@ -149,7 +165,6 @@ namespace XimperShellNotificationCenter.Widgets {
string name = id_var != null
? id_var.get_string () : "VPN";
string key = (string) conn_path;
if (seen.contains (key)) continue;
seen.add (key);
......
......@@ -22,6 +22,10 @@ namespace XimperShellNotificationCenter.Widgets {
private bool connecting = false;
private bool updating_submenu = false;
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 () {
if (sync_timeout != 0) {
......@@ -200,11 +204,17 @@ namespace XimperShellNotificationCenter.Widgets {
foreach (var ap_path in ap_paths) {
try {
var ap =
yield Bus.get_proxy<NMAccessPointDBus> (
BusType.SYSTEM,
"org.freedesktop.NetworkManager",
ap_path);
string key = (string) ap_path;
NMAccessPointDBus ?ap =
ap_proxy_cache.get (key);
if (ap == null) {
ap = yield Bus.get_proxy
<NMAccessPointDBus> (
BusType.SYSTEM,
"org.freedesktop.NetworkManager",
ap_path);
ap_proxy_cache.set (key, ap);
}
string ssid =
NetworkManagerProxy.ssid_to_string (
ap.ssid);
......@@ -281,11 +291,17 @@ namespace XimperShellNotificationCenter.Widgets {
foreach (var conn_path
in settings.list_connections ()) {
try {
var conn =
yield Bus.get_proxy<NMSettingsConnDBus> (
BusType.SYSTEM,
"org.freedesktop.NetworkManager",
conn_path);
string key = (string) conn_path;
NMSettingsConnDBus ?conn =
saved_proxy_cache.get (key);
if (conn == null) {
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 wifi_s = s.lookup (
"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