diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2010-03-30 10:35:34 +0200 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2010-03-30 10:58:30 +0200 |
commit | 61f372eca5241ebf95778eeb3a601976d834bc32 (patch) | |
tree | b3b25b4dbfc2ec063431997033b1df85008a167a | |
parent | 3b91cd4b299653233af36597cf788d309e990c6e (diff) |
Evolution backends: don't delay in open() unnecessarily
There was an intentional delay of 5 seconds in open() of both calendar
and contacts, followed by a retry of opening the database. This was
meant for the cases where a new database was created ("file://"
prefix) and couldn't be opened just yet, as seen in some older
Evolution releases (and perhaps still relevant today).
This delay hurts the sync-ui when it calls CheckSource() on the
defined, but non-existant "memo" database on MeeGo. This patch
avoids the delay and retry in that case.
-rw-r--r-- | src/backends/evolution/EvolutionCalendarSource.cpp | 14 | ||||
-rw-r--r-- | src/backends/evolution/EvolutionContactSource.cpp | 16 |
2 files changed, 21 insertions, 9 deletions
diff --git a/src/backends/evolution/EvolutionCalendarSource.cpp b/src/backends/evolution/EvolutionCalendarSource.cpp index 8c7a8b8e..9dff32d9 100644 --- a/src/backends/evolution/EvolutionCalendarSource.cpp +++ b/src/backends/evolution/EvolutionCalendarSource.cpp @@ -177,6 +177,7 @@ void EvolutionCalendarSource::open() string id = getDatabaseID(); ESource *source = findSource(sources, id); bool onlyIfExists = true; + bool created = false; if (!source) { // might have been special "<<system>>" or "<<default>>", try that and // creating address book from file:// URI before giving up @@ -187,6 +188,7 @@ void EvolutionCalendarSource::open() } else { throwError(string("not found: '") + id + "'"); } + created = true; onlyIfExists = false; } else { m_calendar.set(e_cal_new(source, m_type), m_typeName.c_str()); @@ -195,10 +197,14 @@ void EvolutionCalendarSource::open() e_cal_set_auth_func(m_calendar, eCalAuthFunc, this); if (!e_cal_open(m_calendar, onlyIfExists, &gerror)) { - // opening newly created address books often failed, perhaps that also applies to calendars - try again - g_clear_error(&gerror); - sleep(5); - if (!e_cal_open(m_calendar, onlyIfExists, &gerror)) { + if (created) { + // opening newly created address books often failed, perhaps that also applies to calendars - try again + g_clear_error(&gerror); + sleep(5); + if (!e_cal_open(m_calendar, onlyIfExists, &gerror)) { + throwError(string("opening ") + m_typeName, gerror ); + } + } else { throwError(string("opening ") + m_typeName, gerror ); } } diff --git a/src/backends/evolution/EvolutionContactSource.cpp b/src/backends/evolution/EvolutionContactSource.cpp index 4b59d47c..605fc1d7 100644 --- a/src/backends/evolution/EvolutionContactSource.cpp +++ b/src/backends/evolution/EvolutionContactSource.cpp @@ -156,6 +156,7 @@ void EvolutionContactSource::open() string id = getDatabaseID(); ESource *source = findSource(sources, id); bool onlyIfExists = true; + bool created = false; if (!source) { // might have been special "<<system>>" or "<<default>>", try that and // creating address book from file:// URI before giving up @@ -168,17 +169,22 @@ void EvolutionContactSource::open() } else { throwError(string(getName()) + ": no such address book: '" + id + "'"); } + created = true; onlyIfExists = false; } else { m_addressbook.set( e_book_new( source, &gerror ), "address book" ); } if (!e_book_open( m_addressbook, onlyIfExists, &gerror) ) { - // opening newly created address books often fails, try again once more - g_clear_error(&gerror); - sleep(5); - if (!e_book_open( m_addressbook, onlyIfExists, &gerror) ) { - throwError( "opening address book", gerror ); + if (created) { + // opening newly created address books often fails, try again once more + g_clear_error(&gerror); + sleep(5); + if (!e_book_open(m_addressbook, onlyIfExists, &gerror)) { + throwError("opening address book", gerror); + } + } else { + throwError("opening address book", gerror); } } |