aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c8
-rw-r--r--src/uccs-server.c28
-rw-r--r--src/uccs-server.h1
3 files changed, 19 insertions, 18 deletions
diff --git a/src/main.c b/src/main.c
index 7c0a806..1d53edc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -68,13 +68,17 @@ server_status_updated (Server * server, ServerState newstate, RemoteLogon * rl)
GVariantBuilder builder;
g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY);
- if (server_list_to_array(&builder, config_file_servers) > 0) {
+ gint servers = server_list_to_array(&builder, config_file_servers);
+ if (servers > 0) {
array = g_variant_builder_end(&builder);
} else {
g_variant_builder_clear(&builder);
array = g_variant_new_array(G_VARIANT_TYPE("(sssba(sbva{sv})a(si))"), NULL, 0);
}
+ g_debug ("%d server(s) available", servers);
+ g_debug ("Signalling state change to: %d", newstate);
+
remote_logon_emit_servers_updated(rl, array);
return;
}
@@ -167,6 +171,8 @@ handle_get_servers (RemoteLogon * rl, GDBusMethodInvocation * invocation, gpoint
array = g_variant_new_array(G_VARIANT_TYPE("(sssba(sbva{sv})a(si))"), NULL, 0);
}
+ g_debug ("handle_get_servers: returning %s", g_variant_print (array, FALSE));
+
g_dbus_method_invocation_return_value(invocation, g_variant_new_tuple(&array, 1));
return TRUE;
diff --git a/src/uccs-server.c b/src/uccs-server.c
index a87e4d1..db3cfdf 100644
--- a/src/uccs-server.c
+++ b/src/uccs-server.c
@@ -50,7 +50,6 @@ static void json_waiters_notify (UccsServer * server, gboolean unlocked);
static GVariant * get_cached_domains (Server * server);
static Server * find_uri (Server * server, const gchar * uri);
static void set_last_used_server (Server * server, const gchar * uri);
-static void evaluate_state (UccsServer * server);
static void nm_state_changed (NMClient *client, const GParamSpec *pspec, gpointer user_data);
typedef struct _json_callback_t json_callback_t;
@@ -136,22 +135,18 @@ uccs_server_init (UccsServer *self)
self->session = soup_session_sync_new();
nm_state_changed(self->nm_client, NULL, self);
- evaluate_state(self);
+ uccs_notify_state_change(self);
return;
}
-/* Small function to try and figure out the state of the server and set the
- status appropriately */
-static void
-evaluate_state (UccsServer * server)
+/* Small function to try and figure out the state of the server and notify of
+ status changes appropriately */
+void
+uccs_notify_state_change (UccsServer * server)
{
ServerState tempstate = SERVER_STATE_ALLGOOD;
- if (server->exec == NULL) {
- tempstate = SERVER_STATE_UNAVAILABLE;
- }
-
if (server->last_network < server->min_network) {
tempstate = SERVER_STATE_UNAVAILABLE;
}
@@ -318,7 +313,7 @@ verify_server_cb (SoupSession * session, SoupMessage * message, gpointer user_da
server->verified_server = FALSE;
}
- evaluate_state(server);
+ uccs_notify_state_change(server);
return;
}
@@ -362,7 +357,7 @@ nm_state_changed (NMClient *client, const GParamSpec *pspec, gpointer user_data)
verify_server(server);
}
- evaluate_state(server);
+ uccs_notify_state_change(server);
return;
}
@@ -400,13 +395,12 @@ uccs_server_set_exec (UccsServer * server, const gchar * exec)
g_return_val_if_fail(IS_UCCS_SERVER(server), NULL);
g_clear_pointer(&server->exec, g_free);
+ server->exec = g_find_program_in_path(exec);
- if (exec != NULL) {
- server->exec = g_find_program_in_path(exec);
+ if (server->exec == NULL) {
+ g_warning ("unable to find program %s", exec);
}
- evaluate_state(server);
-
return server->exec;
}
@@ -459,7 +453,7 @@ uccs_server_new_from_keyfile (GKeyFile * keyfile, const gchar * groupname)
server->verify_server = g_key_file_get_boolean(keyfile, groupname, CONFIG_UCCS_VERIFY, NULL);
}
- evaluate_state(server);
+ uccs_notify_state_change(server);
return SERVER(server);
}
diff --git a/src/uccs-server.h b/src/uccs-server.h
index 4603a6c..d9782af 100644
--- a/src/uccs-server.h
+++ b/src/uccs-server.h
@@ -76,6 +76,7 @@ Server * uccs_server_new_from_keyfile (GKeyFile * keyfile, const gchar * name);
void uccs_server_unlock (UccsServer * server, const gchar * address, const gchar * username, const gchar * password, gboolean allowcache, void (*callback) (UccsServer * server, gboolean unlocked, gpointer user_data), gpointer user_data);
GVariant * uccs_server_get_servers (UccsServer * server, const gchar * address);
const gchar *uccs_server_set_exec (UccsServer * server, const gchar * exec);
+void uccs_notify_state_change (UccsServer * server);
G_END_DECLS