From 0b5e1ce2f0aafecaaf855b1f81d52821862f6526 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 5 Aug 2010 12:38:26 +0200 Subject: add empathy_dbus_error_name_get_default_message Reuse existing errors for now. --- libempathy/empathy-utils.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'libempathy/empathy-utils.c') diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index 49df14b41..367b6aa9b 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -321,6 +321,50 @@ empathy_status_reason_get_default_message (TpConnectionStatusReason reason) } } +static GHashTable * +create_errors_to_message_hash (void) +{ + GHashTable *errors; + + errors = g_hash_table_new (g_str_hash, g_str_equal); + g_hash_table_insert (errors, TP_ERROR_STR_NETWORK_ERROR, _("Network error")); + g_hash_table_insert (errors, TP_ERROR_STR_AUTHENTICATION_FAILED, + _("Authentication failed")); + g_hash_table_insert (errors, TP_ERROR_STR_ENCRYPTION_ERROR, + _("Encryption error")); + g_hash_table_insert (errors, TP_ERROR_STR_CERT_NOT_PROVIDED, + _("Certificate not provided")); + g_hash_table_insert (errors, TP_ERROR_STR_CERT_UNTRUSTED, + _("Certificate untrusted")); + g_hash_table_insert (errors, TP_ERROR_STR_CERT_EXPIRED, + _("Certificate expired")); + g_hash_table_insert (errors, TP_ERROR_STR_CERT_NOT_ACTIVATED, + _("Certificate not activated")); + g_hash_table_insert (errors, TP_ERROR_STR_CERT_HOSTNAME_MISMATCH, + _("Certificate hostname mismatch")); + g_hash_table_insert (errors, TP_ERROR_STR_CERT_FINGERPRINT_MISMATCH, + _("Certificate fingerprint mismatch")); + g_hash_table_insert (errors, TP_ERROR_STR_CERT_SELF_SIGNED, + _("Certificate self-signed")); + + return errors; +} + +const gchar * +empathy_dbus_error_name_get_default_message (const gchar *error) +{ + static GHashTable *errors_to_message = NULL; + + if (error == NULL) + return NULL; + + if (G_UNLIKELY (errors_to_message == NULL)) { + errors_to_message = create_errors_to_message_hash (); + } + + return g_hash_table_lookup (errors_to_message, error); +} + gchar * empathy_file_lookup (const gchar *filename, const gchar *subdir) { -- cgit v1.2.3