~ubuntu-branches/ubuntu/saucy/geary/saucy-proposed

« back to all changes in this revision

Viewing changes to src/client/geary-application.vala

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2013-04-10 10:57:25 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20130410105725-f532n2cfre2sq6mf
Tags: 0.3.1-0ubuntu1
* New upstream bugfix version:
  - Reduced CPU and memory footprint
  - Account dialog bugs fixed
  - Stability improvements

Show diffs side-by-side

added added

removed removed

Lines of Context:
204
204
    // Returns null if we are done validating, or the revised account information if we should retry.
205
205
    private async Geary.AccountInformation? validate_or_retry_async(Geary.AccountInformation account_information,
206
206
        Cancellable? cancellable = null) {
207
 
        Geary.Engine.ValidationResult result = yield validate_async(account_information, cancellable);
 
207
        Geary.Engine.ValidationResult result = yield validate_async(account_information, true, cancellable);
208
208
        if (result == Geary.Engine.ValidationResult.OK)
209
209
            return null;
210
210
        
224
224
        return new_account_information;
225
225
    }
226
226
    
227
 
    // Attempts to validate and add an account.  Returns true on success, else false.
 
227
    // Attempts to validate and add an account.  Returns a result code indicating
 
228
    // success or one or more errors.
228
229
    public async Geary.Engine.ValidationResult validate_async(
229
 
        Geary.AccountInformation account_information, Cancellable? cancellable = null) {
 
230
        Geary.AccountInformation account_information, bool validate_connection,
 
231
        Cancellable? cancellable = null) {
230
232
        Geary.Engine.ValidationResult result = Geary.Engine.ValidationResult.OK;
231
233
        try {
232
234
            result = yield Geary.Engine.instance.validate_account_information_async(account_information,
233
 
                cancellable);
 
235
                validate_connection, cancellable);
234
236
        } catch (Error err) {
235
237
            debug("Error validating account: %s", err.message);
236
238
            exit(-1); // Fatal error
243
245
            if (account_information.is_copy()) {
244
246
                // We have a temporary copy of the account.  Find the "real" acct info object and
245
247
                // copy the new data into it.
246
 
                try {
247
 
                    real_account_information = Geary.Engine.instance.get_accounts().get(
248
 
                        account_information.email);
249
 
                    real_account_information.copy_from(account_information);
250
 
                } catch (Error e) {
251
 
                    error("Account information is out of sync: %s", e.message);
252
 
                }
 
248
                real_account_information = get_real_account_information(account_information);
 
249
                real_account_information.copy_from(account_information);
253
250
            }
254
251
            
255
252
            real_account_information.store_async.begin(cancellable);
262
259
        return result;
263
260
    }
264
261
    
 
262
    // Returns the "real" account info associated with a copy.  If it's not a copy, null is returned.
 
263
    public Geary.AccountInformation? get_real_account_information(
 
264
        Geary.AccountInformation account_information) {
 
265
        if (account_information.is_copy()) {
 
266
            try {
 
267
                 return Geary.Engine.instance.get_accounts().get(account_information.email);
 
268
            } catch (Error e) {
 
269
                error("Account information is out of sync: %s", e.message);
 
270
            }
 
271
        }
 
272
        
 
273
        return null;
 
274
    }
 
275
    
265
276
    // Prompt the user for a service, real name, username, and password, and try to start Geary.
266
277
    private Geary.AccountInformation? request_account_information(Geary.AccountInformation? old_info,
267
278
        Geary.Engine.ValidationResult result = Geary.Engine.ValidationResult.OK) {