~mardy/libsignon-glib/section-1639050

« back to all changes in this revision

Viewing changes to libsignon-glib/signon-identity.c

  • Committer: Bileto Bot
  • Date: 2016-07-18 07:43:24 UTC
  • mfrom: (160.1.3 unregistered-lp1593805)
  • Revision ID: ci-train-bot@canonical.com-20160718074324-8vi8mfj2wd3j86ow
* Merge from upstream proposed branch
  - Handle signond quitting on inactivity (LP: #1593805)

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * This file is part of libsignon-glib
5
5
 *
6
6
 * Copyright (C) 2009-2010 Nokia Corporation.
7
 
 * Copyright (C) 2012 Canonical Ltd.
 
7
 * Copyright (C) 2012-2016 Canonical Ltd.
8
8
 *
9
9
 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
10
10
 *
34
34
#include "signon-identity.h"
35
35
#include "signon-auth-session.h"
36
36
#include "signon-internals.h"
37
 
#include "signon-dbus-queue.h"
 
37
#include "signon-proxy.h"
38
38
#include "signon-utils.h"
39
39
#include "signon-errors.h"
40
40
#include "sso-auth-service.h"
41
41
#include "sso-identity-gen.h"
42
42
 
43
 
G_DEFINE_TYPE (SignonIdentity, signon_identity, G_TYPE_OBJECT);
 
43
static void signon_identity_proxy_if_init (SignonProxyInterface *iface);
 
44
 
 
45
G_DEFINE_TYPE_WITH_CODE (SignonIdentity, signon_identity, G_TYPE_OBJECT,
 
46
                         G_IMPLEMENT_INTERFACE (SIGNON_TYPE_PROXY,
 
47
                                                signon_identity_proxy_if_init))
44
48
 
45
49
enum
46
50
{
74
78
    gboolean removed;
75
79
    gboolean signed_out;
76
80
    gboolean updated;
 
81
    gboolean first_registration;
77
82
 
78
83
    guint id;
79
84
 
176
181
}
177
182
 
178
183
static void
 
184
signon_identity_proxy_setup (SignonProxy *proxy)
 
185
{
 
186
    identity_check_remote_registration (SIGNON_IDENTITY (proxy));
 
187
}
 
188
 
 
189
static void
 
190
signon_identity_proxy_if_init (SignonProxyInterface *iface)
 
191
{
 
192
    iface->setup = signon_identity_proxy_setup;
 
193
}
 
194
 
 
195
static void
179
196
signon_identity_set_property (GObject *object,
180
197
                              guint property_id,
181
198
                              const GValue *value,
230
247
    priv->removed = FALSE;
231
248
    priv->signed_out = FALSE;
232
249
    priv->updated = FALSE;
 
250
    priv->first_registration = TRUE;
233
251
}
234
252
 
235
253
static void
359
377
 
360
378
    DEBUG ("%s %d", G_STRFUNC, __LINE__);
361
379
 
362
 
    _signon_object_not_ready(self);
 
380
    signon_proxy_set_not_ready (self);
363
381
 
364
382
    priv->registration_state = NOT_REGISTERED;
365
383
 
437
455
 
438
456
        priv->updated = TRUE;
439
457
    }
 
458
    else if (error->domain == G_DBUS_ERROR &&
 
459
             error->code == G_DBUS_ERROR_SERVICE_UNKNOWN)
 
460
    {
 
461
        /* This can happen if signond quits and the GDBusProxy is not notified
 
462
         * about it -- typically because the main loop was not being run.
 
463
         * We try the registration once more.
 
464
         */
 
465
        if (priv->first_registration)
 
466
        {
 
467
            DEBUG ("Service unknown; retrying registration");
 
468
            g_error_free (error);
 
469
            priv->first_registration = FALSE;
 
470
            priv->registration_state = NOT_REGISTERED;
 
471
            identity_check_remote_registration (identity);
 
472
            return;
 
473
        }
 
474
        else
 
475
        {
 
476
            g_warning ("%s, second failure: %s", G_STRFUNC, error->message);
 
477
        }
 
478
    }
440
479
    else
441
480
        g_warning ("%s: %s", G_STRFUNC, error->message);
442
481
 
449
488
     * TODO: if we will add a new state for identity: "INVALID"
450
489
     * consider emission of another error, like "invalid"
451
490
     * */
452
 
    _signon_object_ready (identity, identity_object_quark (), error);
 
491
    signon_proxy_set_ready (identity, identity_object_quark (), error);
453
492
 
454
493
    /*
455
494
     * as the registration failed we do not
470
509
signon_identity_get_last_error (SignonIdentity *identity)
471
510
{
472
511
    g_return_val_if_fail (SIGNON_IS_IDENTITY (identity), NULL);
473
 
    return _signon_object_last_error(identity);
 
512
    return signon_proxy_get_last_error (identity);
474
513
}
475
514
 
476
515
static void
707
746
    operation_data->info_variant = signon_identity_info_to_variant (info);
708
747
    operation_data->cb_data = cb_data;
709
748
 
710
 
    identity_check_remote_registration (self);
711
 
    _signon_object_call_when_ready (self,
712
 
                                    identity_object_quark(),
713
 
                                    identity_store_credentials_ready_cb,
714
 
                                    operation_data);
 
749
    signon_proxy_call_when_ready (self,
 
750
                                  identity_object_quark(),
 
751
                                  identity_store_credentials_ready_cb,
 
752
                                  operation_data);
715
753
}
716
754
 
717
755
/**
963
1001
    operation_data->operation = operation;
964
1002
    operation_data->cb_data = cb_data;
965
1003
 
966
 
    identity_check_remote_registration (self);
967
 
    _signon_object_call_when_ready (self,
968
 
                                    identity_object_quark(),
969
 
                                    identity_verify_ready_cb,
970
 
                                    operation_data);
 
1004
    signon_proxy_call_when_ready (self,
 
1005
                                  identity_object_quark(),
 
1006
                                  identity_verify_ready_cb,
 
1007
                                  operation_data);
971
1008
}
972
1009
 
973
1010
/**
1309
1346
 
1310
1347
    IdentityVoidData *operation_data = g_slice_new0 (IdentityVoidData);
1311
1348
    operation_data->cb_data = cb_data;
1312
 
    _signon_object_call_when_ready (self,
1313
 
                                    identity_object_quark(),
1314
 
                                    identity_info_ready_cb,
1315
 
                                    operation_data);
 
1349
    signon_proxy_call_when_ready (self,
 
1350
                                  identity_object_quark(),
 
1351
                                  identity_info_ready_cb,
 
1352
                                  operation_data);
1316
1353
}
1317
1354
 
1318
1355
/**
1336
1373
 
1337
1374
    DEBUG ("%s %d", G_STRFUNC, __LINE__);
1338
1375
 
1339
 
    identity_check_remote_registration (self);
1340
 
    _signon_object_call_when_ready (self,
1341
 
                                    identity_object_quark(),
1342
 
                                    identity_remove_ready_cb,
1343
 
                                    cb_data);
 
1376
    signon_proxy_call_when_ready (self,
 
1377
                                  identity_object_quark(),
 
1378
                                  identity_remove_ready_cb,
 
1379
                                  cb_data);
1344
1380
}
1345
1381
 
1346
1382
/**
1364
1400
    cb_data->cb = (SignonIdentityVoidCb)cb;
1365
1401
    cb_data->user_data = user_data;
1366
1402
 
1367
 
    identity_check_remote_registration (self);
1368
 
    _signon_object_call_when_ready (self,
1369
 
                                    identity_object_quark(),
1370
 
                                    identity_signout_ready_cb,
1371
 
                                    cb_data);
 
1403
    signon_proxy_call_when_ready (self,
 
1404
                                  identity_object_quark(),
 
1405
                                  identity_signout_ready_cb,
 
1406
                                  cb_data);
1372
1407
}
1373
1408
 
1374
1409
/**
1435
1470
    cb_data->cb = cb;
1436
1471
    cb_data->user_data = user_data;
1437
1472
 
1438
 
    identity_check_remote_registration (self);
1439
1473
    identity_void_operation(self,
1440
1474
                            SIGNON_INFO,
1441
1475
                            cb_data);