diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2011-03-28 11:03:38 +0100 |
---|---|---|
committer | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2011-03-28 11:16:44 +0100 |
commit | 707c20abb25a78991dc846130d6ad62553ccb982 (patch) | |
tree | fc4dd3d79ac903e21c808ee672c5ad0c9435b388 | |
parent | 56cf9781fb2bcfb2d7f92255e74ec2e2bdb1facc (diff) |
base-connection: make change_status debug message prettierchange-status-you-say
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r-- | telepathy-glib/base-connection.c | 72 |
1 files changed, 70 insertions, 2 deletions
diff --git a/telepathy-glib/base-connection.c b/telepathy-glib/base-connection.c index c7152148e..fb535bd35 100644 --- a/telepathy-glib/base-connection.c +++ b/telepathy-glib/base-connection.c @@ -2774,6 +2774,32 @@ tp_base_connection_disconnect_with_dbus_error (TpBaseConnection *self, g_hash_table_destroy (dup_); } +static const gchar *connection_statuses[] = { + "CONNECTED", + "CONNECTING", + "DISCONNECTED" +}; + +static const gchar *connection_status_reasons[] = { + "NONE_SPECIFIED", + "REQUESTED", + "NETWORK_ERROR", + "AUTHENTICATION_FAILED", + "ENCRYPTION_ERROR", + "NAME_IN_USE", + "CERT_NOT_PROVIDED", + "CERT_UNTRUSTED", + "CERT_EXPIRED", + "CERT_NOT_ACTIVATED", + "CERT_HOSTNAME_MISMATCH", + "CERT_FINGERPRINT_MISMATCH", + "CERT_SELF_SIGNED", + "CERT_OTHER_ERROR", + "CERT_REVOKED", + "CERT_INSECURE", + "CERT_LIMIT_EXCEEDED", +}; + /** * tp_base_connection_change_status: * @self: The connection @@ -2840,7 +2866,36 @@ tp_base_connection_change_status (TpBaseConnection *self, reason); } - DEBUG("was %u, now %u, for reason %u", self->status, status, reason); +#ifdef DEBUGGING + if (status < G_N_ELEMENTS (connection_statuses) + && reason < G_N_ELEMENTS (connection_status_reasons)) + { + const gchar *oldstatus = NULL; + + if (self->status < G_N_ELEMENTS (connection_statuses)) + oldstatus = connection_statuses[self->status]; + else if (self->status == TP_INTERNAL_CONNECTION_STATUS_NEW) + oldstatus = "NEW"; + + /* known old status */ + if (oldstatus != NULL) + { + DEBUG ("was %s, now %s, for reason %s", oldstatus, + connection_statuses[status], connection_status_reasons[reason]); + } + /* unknown old status */ + else + { + DEBUG ("was %u, now %s, for reason %s", self->status, + connection_statuses[status], connection_status_reasons[reason]); + } + } + else + { + DEBUG ("was %u, now %u, for reason %u", self->status, status, reason); + } +#endif /* DEBUGGING */ + g_return_if_fail (status != TP_INTERNAL_CONNECTION_STATUS_NEW); if (self->status == status) @@ -2894,7 +2949,20 @@ tp_base_connection_change_status (TpBaseConnection *self, tp_base_connection_close_all_channels (self); } - DEBUG("emitting status-changed to %u, for reason %u", status, reason); +#ifdef DEBUGGING + /* both known status and reason */ + if (status < G_N_ELEMENTS (connection_statuses) + && reason < G_N_ELEMENTS (connection_status_reasons)) + { + DEBUG ("emitting status-changed to %s, for reason %s", + connection_statuses[status], connection_status_reasons[reason]); + } + else + { + DEBUG ("emitting status-changed to %u, for reason %u", status, reason); + } +#endif /* DEBUGGING */ + tp_svc_connection_emit_status_changed (self, status, reason); /* tell subclass and factories about the state change. In the case of |