zeitgeist team mailing list archive
-
zeitgeist team
-
Mailing list archive
-
Message #04374
[Branch ~zeitgeist/zeitgeist/bluebird] Rev 340: Cleanup some stuff.
------------------------------------------------------------
revno: 340
committer: Siegfried-Angel Gevatter Pujals <siegfried@xxxxxxxxxxxx>
branch nick: bluebird
timestamp: Sun 2011-12-04 23:14:33 +0100
message:
Cleanup some stuff.
modified:
extensions/storage-monitor.vala
src/engine.vala
--
lp:zeitgeist
https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird
Your team Zeitgeist Framework Team is subscribed to branch lp:zeitgeist.
To unsubscribe from this branch go to https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird/+edit-subscription
=== modified file 'extensions/storage-monitor.vala'
--- extensions/storage-monitor.vala 2011-12-03 14:22:39 +0000
+++ extensions/storage-monitor.vala 2011-12-04 22:14:33 +0000
@@ -37,13 +37,13 @@
[DBus (signature = "a{sv}")] Variant storage_description);
public signal void storage_unavailable (string storage_id);
}
-
+
private interface NetworkMonitor: Object
- {
+ {
// This method emits the on_network_up/on_network_up signals
// basing on the initial state of the network.
public abstract void setup ();
-
+
public signal void on_network_up ();
public signal void on_network_down ();
}
@@ -108,7 +108,7 @@
private Sqlite.Statement store_storage_medium_stmt;
private Sqlite.Statement insert_unavailable_medium_stmt;
private Sqlite.Statement update_medium_state_stmt;
-
+
private NetworkMonitor network;
private uint watch_connman;
private uint watch_nm;
@@ -152,40 +152,40 @@
}
// Dynamically decide whether to use Connman or NetworkManager
- watch_connman = Bus.watch_name (BusType.SYSTEM,
- "net.connman",
+ watch_connman = Bus.watch_name (BusType.SYSTEM,
+ "net.connman",
BusNameWatcherFlags.NONE,
name_appeared_handler,
null);
- watch_nm = Bus.watch_name (BusType.SYSTEM,
- "org.freedesktop.NetworkManager",
+ watch_nm = Bus.watch_name (BusType.SYSTEM,
+ "org.freedesktop.NetworkManager",
BusNameWatcherFlags.NONE,
name_appeared_handler,
null);
}
-
+
private void name_appeared_handler (DBusConnection connection, string name, string name_owner)
{
if (this.network != null)
return;
-
+
if (name == "net.connman")
this.network = new ConnmanNetworkMonitor ();
else if (name == "org.freedesktop.NetworkManager")
this.network = new NMNetworkMonitor ();
-
- this.network.on_network_up.connect (() =>
+
+ this.network.on_network_up.connect (() =>
this.add_storage_medium ("net", "stock_internet", "Internet"));
- this.network.on_network_down.connect (() =>
+ this.network.on_network_down.connect (() =>
this.remove_storage_medium ("net"));
-
+
this.network.setup ();
-
+
Bus.unwatch_name (watch_connman);
- Bus.unwatch_name (watch_nm);
+ Bus.unwatch_name (watch_nm);
}
-
+
public override void unload ()
{
// FIXME: move all this D-Bus stuff to some shared
@@ -377,8 +377,8 @@
}
/*
- * Monitor the availability of working network connections using Network Manager
- * (requires 0.8 or later).
+ * Monitor the availability of working network connections using
+ * Network Manager (requires 0.8 or later).
* See http://projects.gnome.org/NetworkManager/developers/spec-08.html
*/
class NMNetworkMonitor : Object, NetworkMonitor
@@ -387,17 +387,17 @@
private const string NM_IFACE = "org.freedesktop.NetworkManager";
private const string NM_OBJECT_PATH = "/org/freedesktop/NetworkManager";
- //NM 0.9 broke API so we have to check for two possible values for the state
+ // NM 0.9 broke API so we have to check for two possible values for the state
private const int NM_STATE_CONNECTED_PRE_09 = 3;
private const int NM_STATE_CONNECTED_POST_09 = 70;
-
+
private NetworkManagerDBus proxy;
-
+
public NMNetworkMonitor ()
{
Object ();
}
-
+
public void setup ()
{
debug ("Creating NetworkManager network monitor");
@@ -407,7 +407,7 @@
NM_BUS_NAME,
NM_OBJECT_PATH);
proxy.state_changed.connect (this.on_state_changed);
-
+
uint32 state = proxy.state ();
this.on_state_changed (state);
}
@@ -416,46 +416,46 @@
warning ("%s", e.message);
}
}
-
+
private void on_state_changed(uint32 state)
{
debug ("NetworkManager network state: %u", state);
- if (state == NMNetworkMonitor.NM_STATE_CONNECTED_PRE_09 ||
+ if (state == NMNetworkMonitor.NM_STATE_CONNECTED_PRE_09 ||
state == NMNetworkMonitor.NM_STATE_CONNECTED_POST_09)
on_network_up ();
else
on_network_down ();
}
}
-
+
class ConnmanNetworkMonitor : Object, NetworkMonitor
{
private const string CM_BUS_NAME = "net.connman";
private const string CM_IFACE = "net.connman.Manager";
private const string CM_OBJECT_PATH = "/";
-
+
private ConnmanManagerDBus proxy;
-
+
public ConnmanNetworkMonitor ()
{
Object ();
}
-
+
public void setup ()
{
debug ("Creating ConnmanNetworkManager network monitor");
try
{
- proxy = Bus.get_proxy_sync<ConnmanManagerDBus> (BusType.SYSTEM,
- CM_BUS_NAME,
- CM_OBJECT_PATH);
-
- // There is a bug in some Connman versions causing it to not emit the
- // net.connman.Manager.StateChanged signal. We take our chances this
- // instance is working properly :-)
+ proxy = Bus.get_proxy_sync<ConnmanManagerDBus> (
+ BusType.SYSTEM, CM_BUS_NAME, CM_OBJECT_PATH);
+
+ // There is a bug in some Connman versions causing it
+ // to not emit the net.connman.Manager.StateChanged
+ // signal. We take our chances this instance is working
+ // properly :-)
proxy.state_changed.connect (this.on_state_changed);
-
+
string state = proxy.get_state ();
this.on_state_changed (state);
}
@@ -464,7 +464,7 @@
warning ("%s", e.message);
}
}
-
+
private void on_state_changed(string state)
{
debug ("ConnmanNetworkMonitor network state: %s", state);
=== modified file 'src/engine.vala'
--- src/engine.vala 2011-10-29 10:48:26 +0000
+++ src/engine.vala 2011-12-04 22:14:33 +0000
@@ -1050,14 +1050,6 @@
WhereClause subwhere = new WhereClause(
WhereClause.Type.OR, negated);
- /*
- FIXME: what is this?
- foreach (unowned string uri in symbols)
- {
- subwhere.add_match_condition (table_name,
- lookup_table.get_id (uri));
- }
- */
if (symbols.length () == 1)
{
subwhere.add_match_condition (table_name,
@@ -1066,7 +1058,7 @@
else
{
var sb = new StringBuilder ();
- foreach (string uri in symbols)
+ foreach (unowned string uri in symbols)
{
sb.append_printf ("%d,", lookup_table.get_id (uri));
}