app: exit properly on eds connection failure

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=726733
This commit is contained in:
Erick Pérez Castellanos 2015-04-30 00:04:48 -04:00
parent a5320940c0
commit 71d02aa740
5 changed files with 15 additions and 7 deletions

View file

@ -254,7 +254,9 @@ public class Contacts.App : Gtk.Application {
} }
public override void startup () { public override void startup () {
ensure_eds_accounts (); if (!ensure_eds_accounts ())
quit ();
contacts_store = new Store (); contacts_store = new Store ();
base.startup (); base.startup ();

View file

@ -97,14 +97,14 @@ eds_source_credentials_required_cb (ESourceRegistry *registry,
ESourceRegistry *eds_source_registry = NULL; ESourceRegistry *eds_source_registry = NULL;
static ECredentialsPrompter *eds_credentials_prompter = NULL; static ECredentialsPrompter *eds_credentials_prompter = NULL;
void contacts_ensure_eds_accounts (void) gboolean contacts_ensure_eds_accounts (void)
{ {
ESourceCredentialsProvider *credentials_provider; ESourceCredentialsProvider *credentials_provider;
GList *list, *link; GList *list, *link;
GError *error = NULL; GError *error = NULL;
if (eds_source_registry) if (eds_source_registry)
return; return TRUE;
/* XXX This blocks while connecting to the D-Bus service. /* XXX This blocks while connecting to the D-Bus service.
* Maybe it should be created in the Contacts class * Maybe it should be created in the Contacts class
@ -114,7 +114,10 @@ void contacts_ensure_eds_accounts (void)
/* If this fails it's game over. */ /* If this fails it's game over. */
if (error != NULL) if (error != NULL)
g_error ("%s: %s", G_STRFUNC, error->message); {
g_error ("%s: %s", G_STRFUNC, error->message);
return FALSE;
}
eds_credentials_prompter = e_credentials_prompter_new (eds_source_registry); eds_credentials_prompter = e_credentials_prompter_new (eds_source_registry);
@ -154,6 +157,8 @@ void contacts_ensure_eds_accounts (void)
G_CALLBACK (eds_source_credentials_required_cb), eds_credentials_prompter); G_CALLBACK (eds_source_credentials_required_cb), eds_credentials_prompter);
e_credentials_prompter_process_awaiting_credentials (eds_credentials_prompter); e_credentials_prompter_process_awaiting_credentials (eds_credentials_prompter);
return TRUE;
} }
gboolean contacts_has_goa_account (void) gboolean contacts_has_goa_account (void)

View file

@ -1,7 +1,7 @@
#include <libebook/libebook.h> #include <libebook/libebook.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
void contacts_ensure_eds_accounts (void); gboolean contacts_ensure_eds_accounts (void);
const char *contacts_lookup_esource_name_by_uid (const char *uid); const char *contacts_lookup_esource_name_by_uid (const char *uid);
const char *contacts_lookup_esource_name_by_uid_for_contact (const char *uid); const char *contacts_lookup_esource_name_by_uid_for_contact (const char *uid);
gboolean contacts_esource_uid_is_google (const char *uid); gboolean contacts_esource_uid_is_google (const char *uid);

View file

@ -10,7 +10,8 @@ public class Contacts.SearchProvider : Object {
public SearchProvider (SearchProviderApp app) { public SearchProvider (SearchProviderApp app) {
this.app = app; this.app = app;
ensure_eds_accounts (); if (!ensure_eds_accounts ())
app.quit ();
store = new Store (); store = new Store ();
contacts_map = new Gee.HashMap<string, Contact> (); contacts_map = new Gee.HashMap<string, Contact> ();
next_id = 0; next_id = 0;

View file

@ -20,7 +20,7 @@ namespace Gnome {
[CCode (cprefix = "Contacts", lower_case_cprefix = "contacts_", cheader_filename = "contacts-esd-setup.h")] [CCode (cprefix = "Contacts", lower_case_cprefix = "contacts_", cheader_filename = "contacts-esd-setup.h")]
namespace Contacts { namespace Contacts {
[CCode (cname = "contacts_ensure_eds_accounts")] [CCode (cname = "contacts_ensure_eds_accounts")]
public static void ensure_eds_accounts (); public static bool ensure_eds_accounts ();
[CCode (cname = "contacts_lookup_esource_name_by_uid")] [CCode (cname = "contacts_lookup_esource_name_by_uid")]
public static unowned string? lookup_esource_name_by_uid (string uid); public static unowned string? lookup_esource_name_by_uid (string uid);
[CCode (cname = "contacts_lookup_esource_name_by_uid_for_contact")] [CCode (cname = "contacts_lookup_esource_name_by_uid_for_contact")]