Merge lp:~mardy/libsignon-glib/unregistered-lp1593805 into lp:libsignon-glib
- unregistered-lp1593805
- Merge into trunk
Proposed by
Alberto Mardegan
on 2016-06-22
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Approved by: | David Barth on 2016-07-21 | ||||
| Approved revision: | 163 | ||||
| Merged at revision: | 161 | ||||
| Proposed branch: | lp:~mardy/libsignon-glib/unregistered-lp1593805 | ||||
| Merge into: | lp:libsignon-glib | ||||
| Diff against target: |
1403 lines (+486/-330) 28 files modified
README.md (+1/-1) configure.ac (+6/-3) debian/changelog (+7/-0) docs/reference/Makefile.am (+0/-1) libsignon-glib/Makefile.am (+2/-2) libsignon-glib/signon-auth-service.c (+1/-1) libsignon-glib/signon-auth-service.h (+2/-1) libsignon-glib/signon-auth-session.c (+39/-34) libsignon-glib/signon-auth-session.h (+1/-1) libsignon-glib/signon-dbus-queue.c (+0/-169) libsignon-glib/signon-dbus-queue.h (+0/-45) libsignon-glib/signon-errors.c (+1/-1) libsignon-glib/signon-errors.h (+2/-1) libsignon-glib/signon-glib.h (+1/-1) libsignon-glib/signon-identity-info.c (+1/-1) libsignon-glib/signon-identity-info.h (+1/-1) libsignon-glib/signon-identity.c (+65/-31) libsignon-glib/signon-identity.h (+2/-1) libsignon-glib/signon-internals.h (+1/-1) libsignon-glib/signon-proxy.c (+219/-0) libsignon-glib/signon-proxy.h (+65/-0) libsignon-glib/signon-types.h (+1/-1) libsignon-glib/signon-utils.c (+1/-1) libsignon-glib/signon-utils.h (+1/-1) libsignon-glib/sso-auth-service.c (+1/-1) libsignon-glib/sso-auth-service.h (+1/-1) tests/check_signon.c (+59/-25) tests/signon-glib-test.sh (+5/-4) |
||||
| To merge this branch: | bzr merge lp:~mardy/libsignon-glib/unregistered-lp1593805 | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| PS Jenkins bot | continuous-integration | Pending | |
| Online Accounts | 2016-06-22 | Pending | |
|
Review via email:
|
|||
Commit Message
Description of the Change
Handle signond quitting on inactivity
This is a big diff; for a code review, I recommend reviewing the upstream commits one by one:
https:/
To post a comment you must log in.
lp:~mardy/libsignon-glib/unregistered-lp1593805
updated
on 2016-07-13
- 163. By Alberto Mardegan on 2016-07-13
-
Fix leak and authsession proxy creation
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
| 1 | === modified file 'README.md' |
| 2 | --- README.md 2016-05-19 15:13:07 +0000 |
| 3 | +++ README.md 2016-07-13 14:51:18 +0000 |
| 4 | @@ -1,7 +1,7 @@ |
| 5 | Single signon authentication library for GLib applications |
| 6 | ========================================================== |
| 7 | |
| 8 | -This project is a library for managing single signon credentilas which can be |
| 9 | +This project is a library for managing single signon credentials which can be |
| 10 | used from GLib applications. It is effectively a GLib binding for the D-Bus API |
| 11 | provided by [signond][]. |
| 12 | It is part of the accounts-sso project: |
| 13 | |
| 14 | === modified file 'configure.ac' |
| 15 | --- configure.ac 2016-05-19 15:28:09 +0000 |
| 16 | +++ configure.ac 2016-07-13 14:51:18 +0000 |
| 17 | @@ -63,17 +63,20 @@ |
| 18 | GTK_DOC_CHECK([1.14], [--flavour no-tmpl]) |
| 19 | |
| 20 | AC_ARG_ENABLE([cast-checks], |
| 21 | - [AS_HELP_STRING([--disable-cast-checks], [compile with GLib cast checks disabled])]) |
| 22 | + [AS_HELP_STRING([--disable-cast-checks], [compile with GLib cast checks disabled])], |
| 23 | + [], [enable_cast_checks=yes]) |
| 24 | AS_IF([test "x$enable_cast_checks" = "xno"], |
| 25 | [CFLAGS="$CFLAGS -DG_DISABLE_CAST_CHECKS"]) |
| 26 | |
| 27 | AC_ARG_ENABLE([asserts], |
| 28 | - [AS_HELP_STRING([--disable-asserts], [compile with GLib assertions disabled])]) |
| 29 | + [AS_HELP_STRING([--disable-asserts], [compile with GLib assertions disabled])], |
| 30 | + [], [enable_asserts=yes]) |
| 31 | AS_IF([test "x$enable_asserts" = "xno"], |
| 32 | [CFLAGS="$CFLAGS -DG_DISABLE_ASSERTS"]) |
| 33 | |
| 34 | AC_ARG_ENABLE([checks], |
| 35 | - [AS_HELP_STRING([--disable-checks], [compile with GLib checks disabled])]) |
| 36 | + [AS_HELP_STRING([--disable-checks], [compile with GLib checks disabled])], |
| 37 | + [], [enable_checks=yes]) |
| 38 | AS_IF([test "x$checks" = "xno"], |
| 39 | [CFLAGS="$CFLAGS -DG_DISABLE_CHECKS"]) |
| 40 | |
| 41 | |
| 42 | === modified file 'debian/changelog' |
| 43 | --- debian/changelog 2016-05-20 12:15:54 +0000 |
| 44 | +++ debian/changelog 2016-07-13 14:51:18 +0000 |
| 45 | @@ -1,3 +1,10 @@ |
| 46 | +libsignon-glib (1.14+16.10.20160520.1-0ubuntu2) UNRELEASED; urgency=medium |
| 47 | + |
| 48 | + * Merge from upstream proposed branch |
| 49 | + - Handle signond quitting on inactivity (LP: #1593805) |
| 50 | + |
| 51 | + -- Alberto Mardegan <alberto.mardegan@canonical.com> Wed, 22 Jun 2016 10:58:15 +0300 |
| 52 | + |
| 53 | libsignon-glib (1.14+16.10.20160520.1-0ubuntu1) yakkety; urgency=medium |
| 54 | |
| 55 | [ Alberto Mardegan ] |
| 56 | |
| 57 | === modified file 'docs/reference/Makefile.am' |
| 58 | --- docs/reference/Makefile.am 2013-06-05 11:05:29 +0000 |
| 59 | +++ docs/reference/Makefile.am 2016-07-13 14:51:18 +0000 |
| 60 | @@ -47,7 +47,6 @@ |
| 61 | signon-auth-session-client-glib-gen.h \ |
| 62 | signon-client-glib-gen.h \ |
| 63 | signon-identity-glib-gen.h \ |
| 64 | - signon-dbus-queue.h \ |
| 65 | signon-internals.h \ |
| 66 | signon-proxy.h \ |
| 67 | signon-utils.h \ |
| 68 | |
| 69 | === modified file 'libsignon-glib/Makefile.am' |
| 70 | --- libsignon-glib/Makefile.am 2016-05-18 10:23:00 +0000 |
| 71 | +++ libsignon-glib/Makefile.am 2016-07-13 14:51:18 +0000 |
| 72 | @@ -44,16 +44,16 @@ |
| 73 | signon-auth-service.h \ |
| 74 | signon-identity-info.h \ |
| 75 | signon-identity.h \ |
| 76 | - signon-dbus-queue.h \ |
| 77 | signon-auth-session.h \ |
| 78 | signon-internals.h \ |
| 79 | signon-auth-service.c \ |
| 80 | signon-identity-info.c \ |
| 81 | signon-identity.c \ |
| 82 | - signon-dbus-queue.c \ |
| 83 | signon-auth-session.c \ |
| 84 | signon-errors.h \ |
| 85 | signon-errors.c \ |
| 86 | + signon-proxy.c \ |
| 87 | + signon-proxy.h \ |
| 88 | signon-utils.h \ |
| 89 | signon-utils.c \ |
| 90 | signon-types.h \ |
| 91 | |
| 92 | === modified file 'libsignon-glib/signon-auth-service.c' |
| 93 | --- libsignon-glib/signon-auth-service.c 2016-05-04 09:21:44 +0000 |
| 94 | +++ libsignon-glib/signon-auth-service.c 2016-07-13 14:51:18 +0000 |
| 95 | @@ -4,7 +4,7 @@ |
| 96 | * This file is part of libsignon-glib |
| 97 | * |
| 98 | * Copyright (C) 2009-2010 Nokia Corporation. |
| 99 | - * Copyright (C) 2012 Canonical Ltd. |
| 100 | + * Copyright (C) 2012-2016 Canonical Ltd. |
| 101 | * |
| 102 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
| 103 | * |
| 104 | |
| 105 | === modified file 'libsignon-glib/signon-auth-service.h' |
| 106 | --- libsignon-glib/signon-auth-service.h 2012-01-27 10:24:27 +0000 |
| 107 | +++ libsignon-glib/signon-auth-service.h 2016-07-13 14:51:18 +0000 |
| 108 | @@ -4,8 +4,9 @@ |
| 109 | * This file is part of libsignon-glib |
| 110 | * |
| 111 | * Copyright (C) 2009-2010 Nokia Corporation. |
| 112 | + * Copyright (C) 2012-2016 Canonical Ltd. |
| 113 | * |
| 114 | - * Contact: Alberto Mardegan <alberto.mardegan@nokia.com> |
| 115 | + * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
| 116 | * |
| 117 | * This library is free software; you can redistribute it and/or |
| 118 | * modify it under the terms of the GNU Lesser General Public License |
| 119 | |
| 120 | === modified file 'libsignon-glib/signon-auth-session.c' |
| 121 | --- libsignon-glib/signon-auth-session.c 2016-05-18 09:17:09 +0000 |
| 122 | +++ libsignon-glib/signon-auth-session.c 2016-07-13 14:51:18 +0000 |
| 123 | @@ -4,7 +4,7 @@ |
| 124 | * This file is part of libsignon-glib |
| 125 | * |
| 126 | * Copyright (C) 2009-2010 Nokia Corporation. |
| 127 | - * Copyright (C) 2012 Canonical Ltd. |
| 128 | + * Copyright (C) 2012-2016 Canonical Ltd. |
| 129 | * |
| 130 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
| 131 | * |
| 132 | @@ -40,9 +40,9 @@ |
| 133 | |
| 134 | #include "signon-internals.h" |
| 135 | #include "signon-auth-session.h" |
| 136 | -#include "signon-dbus-queue.h" |
| 137 | #include "signon-errors.h" |
| 138 | #include "signon-marshal.h" |
| 139 | +#include "signon-proxy.h" |
| 140 | #include "signon-utils.h" |
| 141 | #include "sso-auth-service.h" |
| 142 | #include "sso-auth-session-gen.h" |
| 143 | @@ -50,7 +50,11 @@ |
| 144 | /* SignonAuthSessionState is defined in signoncommon.h */ |
| 145 | #include <signoncommon.h> |
| 146 | |
| 147 | -G_DEFINE_TYPE (SignonAuthSession, signon_auth_session, G_TYPE_OBJECT); |
| 148 | +static void signon_auth_session_proxy_if_init (SignonProxyInterface *iface); |
| 149 | + |
| 150 | +G_DEFINE_TYPE_WITH_CODE (SignonAuthSession, signon_auth_session, G_TYPE_OBJECT, |
| 151 | + G_IMPLEMENT_INTERFACE (SIGNON_TYPE_PROXY, |
| 152 | + signon_auth_session_proxy_if_init)) |
| 153 | |
| 154 | /* Signals */ |
| 155 | enum |
| 156 | @@ -266,6 +270,18 @@ |
| 157 | } |
| 158 | |
| 159 | static void |
| 160 | +signon_auth_session_proxy_setup (SignonProxy *proxy) |
| 161 | +{ |
| 162 | + auth_session_check_remote_object (SIGNON_AUTH_SESSION (proxy)); |
| 163 | +} |
| 164 | + |
| 165 | +static void |
| 166 | +signon_auth_session_proxy_if_init (SignonProxyInterface *iface) |
| 167 | +{ |
| 168 | + iface->setup = signon_auth_session_proxy_setup; |
| 169 | +} |
| 170 | + |
| 171 | +static void |
| 172 | signon_auth_session_init (SignonAuthSession *self) |
| 173 | { |
| 174 | self->priv = SIGNON_AUTH_SESSION_GET_PRIV (self); |
| 175 | @@ -287,6 +303,7 @@ |
| 176 | if (priv->cancellable) |
| 177 | { |
| 178 | g_cancellable_cancel (priv->cancellable); |
| 179 | + g_object_unref (priv->cancellable); |
| 180 | priv->cancellable = NULL; |
| 181 | } |
| 182 | |
| 183 | @@ -421,11 +438,10 @@ |
| 184 | |
| 185 | g_return_if_fail (id >= 0); |
| 186 | |
| 187 | - auth_session_check_remote_object(self); |
| 188 | - _signon_object_call_when_ready (self, |
| 189 | - auth_session_object_quark(), |
| 190 | - auth_session_set_id_ready_cb, |
| 191 | - GINT_TO_POINTER(id)); |
| 192 | + signon_proxy_call_when_ready (self, |
| 193 | + auth_session_object_quark(), |
| 194 | + auth_session_set_id_ready_cb, |
| 195 | + GINT_TO_POINTER(id)); |
| 196 | } |
| 197 | |
| 198 | /** |
| 199 | @@ -485,11 +501,10 @@ |
| 200 | operation_data->wanted_mechanisms = g_strdupv ((gchar **)wanted_mechanisms); |
| 201 | operation_data->cb_data = cb_data; |
| 202 | |
| 203 | - auth_session_check_remote_object(self); |
| 204 | - _signon_object_call_when_ready (self, |
| 205 | - auth_session_object_quark(), |
| 206 | - auth_session_query_available_mechanisms_ready_cb, |
| 207 | - operation_data); |
| 208 | + signon_proxy_call_when_ready (self, |
| 209 | + auth_session_object_quark(), |
| 210 | + auth_session_query_available_mechanisms_ready_cb, |
| 211 | + operation_data); |
| 212 | } |
| 213 | |
| 214 | /** |
| 215 | @@ -588,11 +603,10 @@ |
| 216 | |
| 217 | priv->busy = TRUE; |
| 218 | |
| 219 | - auth_session_check_remote_object(self); |
| 220 | - _signon_object_call_when_ready (self, |
| 221 | - auth_session_object_quark(), |
| 222 | - auth_session_process_ready_cb, |
| 223 | - res); |
| 224 | + signon_proxy_call_when_ready (self, |
| 225 | + auth_session_object_quark(), |
| 226 | + auth_session_process_ready_cb, |
| 227 | + res); |
| 228 | } |
| 229 | |
| 230 | /** |
| 231 | @@ -635,16 +649,14 @@ |
| 232 | |
| 233 | g_return_if_fail (priv != NULL); |
| 234 | |
| 235 | - auth_session_check_remote_object(self); |
| 236 | - |
| 237 | if (!priv->busy) |
| 238 | return; |
| 239 | |
| 240 | priv->canceled = TRUE; |
| 241 | - _signon_object_call_when_ready (self, |
| 242 | - auth_session_object_quark(), |
| 243 | - auth_session_cancel_ready_cb, |
| 244 | - NULL); |
| 245 | + signon_proxy_call_when_ready (self, |
| 246 | + auth_session_object_quark(), |
| 247 | + auth_session_cancel_ready_cb, |
| 248 | + NULL); |
| 249 | } |
| 250 | |
| 251 | static void |
| 252 | @@ -717,7 +729,7 @@ |
| 253 | |
| 254 | DEBUG ("Object path received: %s", object_path); |
| 255 | g_free (object_path); |
| 256 | - _signon_object_ready (self, auth_session_object_quark (), error); |
| 257 | + signon_proxy_set_ready (self, auth_session_object_quark (), error); |
| 258 | } |
| 259 | |
| 260 | static void |
| 261 | @@ -748,7 +760,7 @@ |
| 262 | if (priv->proxy) |
| 263 | destroy_proxy (priv); |
| 264 | |
| 265 | - _signon_object_not_ready(self); |
| 266 | + signon_proxy_set_not_ready (self); |
| 267 | } |
| 268 | |
| 269 | static gboolean |
| 270 | @@ -762,14 +774,7 @@ |
| 271 | priv->id = id; |
| 272 | priv->method_name = g_strdup (method_name); |
| 273 | |
| 274 | - priv->registering = TRUE; |
| 275 | - sso_auth_service_call_get_auth_session_object_path ( |
| 276 | - priv->auth_service_proxy, |
| 277 | - id, |
| 278 | - method_name, |
| 279 | - priv->cancellable, |
| 280 | - auth_session_get_object_path_reply, |
| 281 | - self); |
| 282 | + priv->registering = FALSE; |
| 283 | priv->busy = FALSE; |
| 284 | priv->canceled = FALSE; |
| 285 | return TRUE; |
| 286 | |
| 287 | === modified file 'libsignon-glib/signon-auth-session.h' |
| 288 | --- libsignon-glib/signon-auth-session.h 2012-11-30 07:38:19 +0000 |
| 289 | +++ libsignon-glib/signon-auth-session.h 2016-07-13 14:51:18 +0000 |
| 290 | @@ -4,7 +4,7 @@ |
| 291 | * This file is part of libsignon-glib |
| 292 | * |
| 293 | * Copyright (C) 2009-2010 Nokia Corporation. |
| 294 | - * Copyright (C) 2012 Canonical Ltd. |
| 295 | + * Copyright (C) 2012-2016 Canonical Ltd. |
| 296 | * |
| 297 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
| 298 | * |
| 299 | |
| 300 | === removed file 'libsignon-glib/signon-dbus-queue.c' |
| 301 | --- libsignon-glib/signon-dbus-queue.c 2016-05-03 14:34:14 +0000 |
| 302 | +++ libsignon-glib/signon-dbus-queue.c 1970-01-01 00:00:00 +0000 |
| 303 | @@ -1,169 +0,0 @@ |
| 304 | -/* vi: set et sw=4 ts=4 cino=t0,(0: */ |
| 305 | -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 306 | -/* |
| 307 | - * This file is part of libsignon-glib |
| 308 | - * |
| 309 | - * Copyright (C) 2009-2010 Nokia Corporation. |
| 310 | - * |
| 311 | - * Contact: Alberto Mardegan <alberto.mardegan@nokia.com> |
| 312 | - * |
| 313 | - * This library is free software; you can redistribute it and/or |
| 314 | - * modify it under the terms of the GNU Lesser General Public License |
| 315 | - * version 2.1 as published by the Free Software Foundation. |
| 316 | - * |
| 317 | - * This library is distributed in the hope that it will be useful, but |
| 318 | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 319 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 320 | - * Lesser General Public License for more details. |
| 321 | - * |
| 322 | - * You should have received a copy of the GNU Lesser General Public |
| 323 | - * License along with this library; if not, write to the Free Software |
| 324 | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 325 | - * 02110-1301 USA |
| 326 | - */ |
| 327 | - |
| 328 | -#include "signon-dbus-queue.h" |
| 329 | - |
| 330 | -typedef struct { |
| 331 | - SignonReadyCb callback; |
| 332 | - gpointer user_data; |
| 333 | -} SignonReadyCbData; |
| 334 | - |
| 335 | -typedef struct { |
| 336 | - gpointer self; |
| 337 | - GSList *callbacks; |
| 338 | -} SignonReadyData; |
| 339 | - |
| 340 | -static GQuark |
| 341 | -_signon_object_ready_quark() |
| 342 | -{ |
| 343 | - static GQuark quark = 0; |
| 344 | - |
| 345 | - if (!quark) |
| 346 | - quark = g_quark_from_static_string ("signon_object_ready_quark"); |
| 347 | - |
| 348 | - return quark; |
| 349 | -} |
| 350 | - |
| 351 | -static GQuark |
| 352 | -_signon_object_error_quark() |
| 353 | -{ |
| 354 | - static GQuark quark = 0; |
| 355 | - |
| 356 | - if (!quark) |
| 357 | - quark = g_quark_from_static_string ("signon_object_error_quark"); |
| 358 | - |
| 359 | - return quark; |
| 360 | -} |
| 361 | - |
| 362 | -static void |
| 363 | -signon_object_invoke_ready_callbacks (SignonReadyData *rd, const GError *error) |
| 364 | -{ |
| 365 | - GSList *list; |
| 366 | - |
| 367 | - for (list = rd->callbacks; list != NULL; list = list->next) |
| 368 | - { |
| 369 | - SignonReadyCbData *cb = list->data; |
| 370 | - |
| 371 | - cb->callback (rd->self, error, cb->user_data); |
| 372 | - g_slice_free (SignonReadyCbData, cb); |
| 373 | - } |
| 374 | - g_slist_free (rd->callbacks); |
| 375 | -} |
| 376 | - |
| 377 | -static void |
| 378 | -signon_ready_data_free (SignonReadyData *rd) |
| 379 | -{ |
| 380 | - if (rd->self) |
| 381 | - { |
| 382 | - //TODO: Signon error codes need be presented instead of 555 and 666 |
| 383 | - GError error = { 555, 666, "Object disposed" }; |
| 384 | - signon_object_invoke_ready_callbacks (rd, &error); |
| 385 | - } |
| 386 | - g_slice_free (SignonReadyData, rd); |
| 387 | -} |
| 388 | - |
| 389 | -void |
| 390 | -_signon_object_call_when_ready (gpointer object, GQuark quark, SignonReadyCb callback, |
| 391 | - gpointer user_data) |
| 392 | -{ |
| 393 | - SignonReadyData *rd; |
| 394 | - SignonReadyCbData *cb; |
| 395 | - |
| 396 | - g_return_if_fail (G_IS_OBJECT (object)); |
| 397 | - g_return_if_fail (quark != 0); |
| 398 | - g_return_if_fail (callback != NULL); |
| 399 | - |
| 400 | - if (GPOINTER_TO_INT (g_object_get_qdata((GObject *)object, |
| 401 | - _signon_object_ready_quark())) == TRUE) |
| 402 | - { |
| 403 | - //TODO: specify the last error in object initialization |
| 404 | - GError * err = g_object_get_qdata((GObject *)object, |
| 405 | - _signon_object_error_quark()); |
| 406 | - return (*callback)(object, err, user_data); |
| 407 | - } |
| 408 | - |
| 409 | - cb = g_slice_new (SignonReadyCbData); |
| 410 | - cb->callback = callback; |
| 411 | - cb->user_data = user_data; |
| 412 | - |
| 413 | - rd = g_object_get_qdata ((GObject *)object, quark); |
| 414 | - if (!rd) |
| 415 | - { |
| 416 | - rd = g_slice_new (SignonReadyData); |
| 417 | - rd->self = object; |
| 418 | - rd->callbacks = NULL; |
| 419 | - g_object_set_qdata_full ((GObject *)object, quark, rd, |
| 420 | - (GDestroyNotify)signon_ready_data_free); |
| 421 | - } |
| 422 | - |
| 423 | - rd->callbacks = g_slist_append (rd->callbacks, cb); |
| 424 | -} |
| 425 | - |
| 426 | -void |
| 427 | -_signon_object_ready (gpointer object, GQuark quark, GError *error) |
| 428 | -{ |
| 429 | - SignonReadyData *rd; |
| 430 | - |
| 431 | - g_object_set_qdata((GObject *)object, _signon_object_ready_quark(), GINT_TO_POINTER(TRUE)); |
| 432 | - |
| 433 | - if(error) |
| 434 | - g_object_set_qdata_full ((GObject *)object, _signon_object_error_quark(), |
| 435 | - error, |
| 436 | - (GDestroyNotify)g_error_free); |
| 437 | - |
| 438 | - /* steal the qdata so the callbacks won't be invoked again, even if the |
| 439 | - * object becomes ready or is finalized while still invoking them */ |
| 440 | - |
| 441 | - rd = g_object_steal_qdata ((GObject *)object, quark); |
| 442 | - if (!rd) return; |
| 443 | - |
| 444 | - g_object_ref (object); |
| 445 | - |
| 446 | - signon_object_invoke_ready_callbacks (rd, error); |
| 447 | - rd->self = NULL; /* so the callbacks won't be invoked again */ |
| 448 | - signon_ready_data_free (rd); |
| 449 | - |
| 450 | - g_object_unref (object); |
| 451 | - |
| 452 | - //TODO: set some sort of ready information |
| 453 | -} |
| 454 | - |
| 455 | -void |
| 456 | -_signon_object_not_ready (gpointer object) |
| 457 | -{ |
| 458 | - g_object_set_qdata ((GObject *)object, |
| 459 | - _signon_object_ready_quark(), |
| 460 | - GINT_TO_POINTER(FALSE)); |
| 461 | - |
| 462 | - g_object_set_qdata ((GObject *)object, |
| 463 | - _signon_object_error_quark(), |
| 464 | - NULL); |
| 465 | -} |
| 466 | - |
| 467 | -const GError * |
| 468 | -_signon_object_last_error (gpointer object) |
| 469 | -{ |
| 470 | - return g_object_get_qdata((GObject *)object, |
| 471 | - _signon_object_error_quark()); |
| 472 | -} |
| 473 | |
| 474 | === removed file 'libsignon-glib/signon-dbus-queue.h' |
| 475 | --- libsignon-glib/signon-dbus-queue.h 2016-05-03 14:34:14 +0000 |
| 476 | +++ libsignon-glib/signon-dbus-queue.h 1970-01-01 00:00:00 +0000 |
| 477 | @@ -1,45 +0,0 @@ |
| 478 | -/* vi: set et sw=4 ts=4 cino=t0,(0: */ |
| 479 | -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 480 | -/* |
| 481 | - * This file is part of libsignon-glib |
| 482 | - * |
| 483 | - * Copyright (C) 2009-2010 Nokia Corporation. |
| 484 | - * |
| 485 | - * Contact: Alberto Mardegan <alberto.mardegan@nokia.com> |
| 486 | - * |
| 487 | - * This library is free software; you can redistribute it and/or |
| 488 | - * modify it under the terms of the GNU Lesser General Public License |
| 489 | - * version 2.1 as published by the Free Software Foundation. |
| 490 | - * |
| 491 | - * This library is distributed in the hope that it will be useful, but |
| 492 | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 493 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 494 | - * Lesser General Public License for more details. |
| 495 | - * |
| 496 | - * You should have received a copy of the GNU Lesser General Public |
| 497 | - * License along with this library; if not, write to the Free Software |
| 498 | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 499 | - * 02110-1301 USA |
| 500 | - */ |
| 501 | - |
| 502 | -#ifndef SIGNONDBUSQUEUEDDATA_H |
| 503 | -#define SIGNONDBUSQUEUEDDATA_H |
| 504 | - |
| 505 | -#include <glib.h> |
| 506 | -#include <glib-object.h> |
| 507 | - |
| 508 | -G_BEGIN_DECLS |
| 509 | - |
| 510 | -typedef void (*SignonReadyCb) (gpointer object, const GError *error, |
| 511 | - gpointer user_data); |
| 512 | - |
| 513 | -void _signon_object_call_when_ready (gpointer object, GQuark quark, |
| 514 | - SignonReadyCb callback, gpointer user_data); |
| 515 | - |
| 516 | -void _signon_object_ready (gpointer object, GQuark quark, GError *error); |
| 517 | -void _signon_object_not_ready (gpointer object); |
| 518 | - |
| 519 | -const GError *_signon_object_last_error (gpointer object); |
| 520 | - |
| 521 | -G_END_DECLS |
| 522 | -#endif /* SIGNONDBUSQUEUEDDATA_H */ |
| 523 | |
| 524 | === modified file 'libsignon-glib/signon-errors.c' |
| 525 | --- libsignon-glib/signon-errors.c 2012-08-02 10:25:48 +0000 |
| 526 | +++ libsignon-glib/signon-errors.c 2016-07-13 14:51:18 +0000 |
| 527 | @@ -4,7 +4,7 @@ |
| 528 | * This file is part of libsignon-glib |
| 529 | * |
| 530 | * Copyright (C) 2009-2010 Nokia Corporation. |
| 531 | - * Copyright (C) 2012 Canonical Ltd. |
| 532 | + * Copyright (C) 2012-2016 Canonical Ltd. |
| 533 | * |
| 534 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
| 535 | * |
| 536 | |
| 537 | === modified file 'libsignon-glib/signon-errors.h' |
| 538 | --- libsignon-glib/signon-errors.h 2016-05-03 09:51:12 +0000 |
| 539 | +++ libsignon-glib/signon-errors.h 2016-07-13 14:51:18 +0000 |
| 540 | @@ -4,8 +4,9 @@ |
| 541 | * This file is part of libsignon-glib |
| 542 | * |
| 543 | * Copyright (C) 2009-2010 Nokia Corporation. |
| 544 | + * Copyright (C) 2012-2016 Canonical Ltd. |
| 545 | * |
| 546 | - * Contact: Alberto Mardegan <alberto.mardegan@nokia.com> |
| 547 | + * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
| 548 | * |
| 549 | * This library is free software; you can redistribute it and/or |
| 550 | * modify it under the terms of the GNU Lesser General Public License |
| 551 | |
| 552 | === modified file 'libsignon-glib/signon-glib.h' |
| 553 | --- libsignon-glib/signon-glib.h 2011-12-09 14:51:02 +0000 |
| 554 | +++ libsignon-glib/signon-glib.h 2016-07-13 14:51:18 +0000 |
| 555 | @@ -3,7 +3,7 @@ |
| 556 | /* |
| 557 | * This file is part of libsignon-glib |
| 558 | * |
| 559 | - * Copyright (C) 2011 Canonical Ltd. |
| 560 | + * Copyright (C) 2011-2016 Canonical Ltd. |
| 561 | * |
| 562 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
| 563 | * |
| 564 | |
| 565 | === modified file 'libsignon-glib/signon-identity-info.c' |
| 566 | --- libsignon-glib/signon-identity-info.c 2016-05-04 09:21:44 +0000 |
| 567 | +++ libsignon-glib/signon-identity-info.c 2016-07-13 14:51:18 +0000 |
| 568 | @@ -4,7 +4,7 @@ |
| 569 | * This file is part of libsignon-glib |
| 570 | * |
| 571 | * Copyright (C) 2009-2010 Nokia Corporation. |
| 572 | - * Copyright (C) 2011-2012 Canonical Ltd. |
| 573 | + * Copyright (C) 2011-2016 Canonical Ltd. |
| 574 | * |
| 575 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
| 576 | * |
| 577 | |
| 578 | === modified file 'libsignon-glib/signon-identity-info.h' |
| 579 | --- libsignon-glib/signon-identity-info.h 2012-01-27 10:24:27 +0000 |
| 580 | +++ libsignon-glib/signon-identity-info.h 2016-07-13 14:51:18 +0000 |
| 581 | @@ -4,7 +4,7 @@ |
| 582 | * This file is part of libsignon-glib |
| 583 | * |
| 584 | * Copyright (C) 2009-2010 Nokia Corporation. |
| 585 | - * Copyright (C) 2011 Canonical Ltd. |
| 586 | + * Copyright (C) 2011-2016 Canonical Ltd. |
| 587 | * |
| 588 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
| 589 | * |
| 590 | |
| 591 | === modified file 'libsignon-glib/signon-identity.c' |
| 592 | --- libsignon-glib/signon-identity.c 2016-05-18 09:17:09 +0000 |
| 593 | +++ libsignon-glib/signon-identity.c 2016-07-13 14:51:18 +0000 |
| 594 | @@ -4,7 +4,7 @@ |
| 595 | * This file is part of libsignon-glib |
| 596 | * |
| 597 | * Copyright (C) 2009-2010 Nokia Corporation. |
| 598 | - * Copyright (C) 2012 Canonical Ltd. |
| 599 | + * Copyright (C) 2012-2016 Canonical Ltd. |
| 600 | * |
| 601 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
| 602 | * |
| 603 | @@ -34,13 +34,17 @@ |
| 604 | #include "signon-identity.h" |
| 605 | #include "signon-auth-session.h" |
| 606 | #include "signon-internals.h" |
| 607 | -#include "signon-dbus-queue.h" |
| 608 | +#include "signon-proxy.h" |
| 609 | #include "signon-utils.h" |
| 610 | #include "signon-errors.h" |
| 611 | #include "sso-auth-service.h" |
| 612 | #include "sso-identity-gen.h" |
| 613 | |
| 614 | -G_DEFINE_TYPE (SignonIdentity, signon_identity, G_TYPE_OBJECT); |
| 615 | +static void signon_identity_proxy_if_init (SignonProxyInterface *iface); |
| 616 | + |
| 617 | +G_DEFINE_TYPE_WITH_CODE (SignonIdentity, signon_identity, G_TYPE_OBJECT, |
| 618 | + G_IMPLEMENT_INTERFACE (SIGNON_TYPE_PROXY, |
| 619 | + signon_identity_proxy_if_init)) |
| 620 | |
| 621 | enum |
| 622 | { |
| 623 | @@ -74,6 +78,7 @@ |
| 624 | gboolean removed; |
| 625 | gboolean signed_out; |
| 626 | gboolean updated; |
| 627 | + gboolean first_registration; |
| 628 | |
| 629 | guint id; |
| 630 | |
| 631 | @@ -176,6 +181,18 @@ |
| 632 | } |
| 633 | |
| 634 | static void |
| 635 | +signon_identity_proxy_setup (SignonProxy *proxy) |
| 636 | +{ |
| 637 | + identity_check_remote_registration (SIGNON_IDENTITY (proxy)); |
| 638 | +} |
| 639 | + |
| 640 | +static void |
| 641 | +signon_identity_proxy_if_init (SignonProxyInterface *iface) |
| 642 | +{ |
| 643 | + iface->setup = signon_identity_proxy_setup; |
| 644 | +} |
| 645 | + |
| 646 | +static void |
| 647 | signon_identity_set_property (GObject *object, |
| 648 | guint property_id, |
| 649 | const GValue *value, |
| 650 | @@ -230,6 +247,7 @@ |
| 651 | priv->removed = FALSE; |
| 652 | priv->signed_out = FALSE; |
| 653 | priv->updated = FALSE; |
| 654 | + priv->first_registration = TRUE; |
| 655 | } |
| 656 | |
| 657 | static void |
| 658 | @@ -359,7 +377,7 @@ |
| 659 | |
| 660 | DEBUG ("%s %d", G_STRFUNC, __LINE__); |
| 661 | |
| 662 | - _signon_object_not_ready(self); |
| 663 | + signon_proxy_set_not_ready (self); |
| 664 | |
| 665 | priv->registration_state = NOT_REGISTERED; |
| 666 | |
| 667 | @@ -437,6 +455,27 @@ |
| 668 | |
| 669 | priv->updated = TRUE; |
| 670 | } |
| 671 | + else if (error->domain == G_DBUS_ERROR && |
| 672 | + error->code == G_DBUS_ERROR_SERVICE_UNKNOWN) |
| 673 | + { |
| 674 | + /* This can happen if signond quits and the GDBusProxy is not notified |
| 675 | + * about it -- typically because the main loop was not being run. |
| 676 | + * We try the registration once more. |
| 677 | + */ |
| 678 | + if (priv->first_registration) |
| 679 | + { |
| 680 | + DEBUG ("Service unknown; retrying registration"); |
| 681 | + g_error_free (error); |
| 682 | + priv->first_registration = FALSE; |
| 683 | + priv->registration_state = NOT_REGISTERED; |
| 684 | + identity_check_remote_registration (identity); |
| 685 | + return; |
| 686 | + } |
| 687 | + else |
| 688 | + { |
| 689 | + g_warning ("%s, second failure: %s", G_STRFUNC, error->message); |
| 690 | + } |
| 691 | + } |
| 692 | else |
| 693 | g_warning ("%s: %s", G_STRFUNC, error->message); |
| 694 | |
| 695 | @@ -449,7 +488,7 @@ |
| 696 | * TODO: if we will add a new state for identity: "INVALID" |
| 697 | * consider emission of another error, like "invalid" |
| 698 | * */ |
| 699 | - _signon_object_ready (identity, identity_object_quark (), error); |
| 700 | + signon_proxy_set_ready (identity, identity_object_quark (), error); |
| 701 | |
| 702 | /* |
| 703 | * as the registration failed we do not |
| 704 | @@ -470,7 +509,7 @@ |
| 705 | signon_identity_get_last_error (SignonIdentity *identity) |
| 706 | { |
| 707 | g_return_val_if_fail (SIGNON_IS_IDENTITY (identity), NULL); |
| 708 | - return _signon_object_last_error(identity); |
| 709 | + return signon_proxy_get_last_error (identity); |
| 710 | } |
| 711 | |
| 712 | static void |
| 713 | @@ -707,11 +746,10 @@ |
| 714 | operation_data->info_variant = signon_identity_info_to_variant (info); |
| 715 | operation_data->cb_data = cb_data; |
| 716 | |
| 717 | - identity_check_remote_registration (self); |
| 718 | - _signon_object_call_when_ready (self, |
| 719 | - identity_object_quark(), |
| 720 | - identity_store_credentials_ready_cb, |
| 721 | - operation_data); |
| 722 | + signon_proxy_call_when_ready (self, |
| 723 | + identity_object_quark(), |
| 724 | + identity_store_credentials_ready_cb, |
| 725 | + operation_data); |
| 726 | } |
| 727 | |
| 728 | /** |
| 729 | @@ -963,11 +1001,10 @@ |
| 730 | operation_data->operation = operation; |
| 731 | operation_data->cb_data = cb_data; |
| 732 | |
| 733 | - identity_check_remote_registration (self); |
| 734 | - _signon_object_call_when_ready (self, |
| 735 | - identity_object_quark(), |
| 736 | - identity_verify_ready_cb, |
| 737 | - operation_data); |
| 738 | + signon_proxy_call_when_ready (self, |
| 739 | + identity_object_quark(), |
| 740 | + identity_verify_ready_cb, |
| 741 | + operation_data); |
| 742 | } |
| 743 | |
| 744 | /** |
| 745 | @@ -1309,10 +1346,10 @@ |
| 746 | |
| 747 | IdentityVoidData *operation_data = g_slice_new0 (IdentityVoidData); |
| 748 | operation_data->cb_data = cb_data; |
| 749 | - _signon_object_call_when_ready (self, |
| 750 | - identity_object_quark(), |
| 751 | - identity_info_ready_cb, |
| 752 | - operation_data); |
| 753 | + signon_proxy_call_when_ready (self, |
| 754 | + identity_object_quark(), |
| 755 | + identity_info_ready_cb, |
| 756 | + operation_data); |
| 757 | } |
| 758 | |
| 759 | /** |
| 760 | @@ -1336,11 +1373,10 @@ |
| 761 | |
| 762 | DEBUG ("%s %d", G_STRFUNC, __LINE__); |
| 763 | |
| 764 | - identity_check_remote_registration (self); |
| 765 | - _signon_object_call_when_ready (self, |
| 766 | - identity_object_quark(), |
| 767 | - identity_remove_ready_cb, |
| 768 | - cb_data); |
| 769 | + signon_proxy_call_when_ready (self, |
| 770 | + identity_object_quark(), |
| 771 | + identity_remove_ready_cb, |
| 772 | + cb_data); |
| 773 | } |
| 774 | |
| 775 | /** |
| 776 | @@ -1364,11 +1400,10 @@ |
| 777 | cb_data->cb = (SignonIdentityVoidCb)cb; |
| 778 | cb_data->user_data = user_data; |
| 779 | |
| 780 | - identity_check_remote_registration (self); |
| 781 | - _signon_object_call_when_ready (self, |
| 782 | - identity_object_quark(), |
| 783 | - identity_signout_ready_cb, |
| 784 | - cb_data); |
| 785 | + signon_proxy_call_when_ready (self, |
| 786 | + identity_object_quark(), |
| 787 | + identity_signout_ready_cb, |
| 788 | + cb_data); |
| 789 | } |
| 790 | |
| 791 | /** |
| 792 | @@ -1435,7 +1470,6 @@ |
| 793 | cb_data->cb = cb; |
| 794 | cb_data->user_data = user_data; |
| 795 | |
| 796 | - identity_check_remote_registration (self); |
| 797 | identity_void_operation(self, |
| 798 | SIGNON_INFO, |
| 799 | cb_data); |
| 800 | |
| 801 | === modified file 'libsignon-glib/signon-identity.h' |
| 802 | --- libsignon-glib/signon-identity.h 2014-12-05 07:15:03 +0000 |
| 803 | +++ libsignon-glib/signon-identity.h 2016-07-13 14:51:18 +0000 |
| 804 | @@ -4,8 +4,9 @@ |
| 805 | * This file is part of libsignon-glib |
| 806 | * |
| 807 | * Copyright (C) 2009-2010 Nokia Corporation. |
| 808 | + * Copyright (C) 2012-2016 Canonical Ltd. |
| 809 | * |
| 810 | - * Contact: Alberto Mardegan <alberto.mardegan@nokia.com> |
| 811 | + * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
| 812 | * |
| 813 | * This library is free software; you can redistribute it and/or |
| 814 | * modify it under the terms of the GNU Lesser General Public License |
| 815 | |
| 816 | === modified file 'libsignon-glib/signon-internals.h' |
| 817 | --- libsignon-glib/signon-internals.h 2012-08-02 10:25:48 +0000 |
| 818 | +++ libsignon-glib/signon-internals.h 2016-07-13 14:51:18 +0000 |
| 819 | @@ -4,7 +4,7 @@ |
| 820 | * This file is part of libsignon-glib |
| 821 | * |
| 822 | * Copyright (C) 2009-2010 Nokia Corporation. |
| 823 | - * Copyright (C) 2012 Canonical Ltd. |
| 824 | + * Copyright (C) 2012-2016 Canonical Ltd. |
| 825 | * |
| 826 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
| 827 | * |
| 828 | |
| 829 | === added file 'libsignon-glib/signon-proxy.c' |
| 830 | --- libsignon-glib/signon-proxy.c 1970-01-01 00:00:00 +0000 |
| 831 | +++ libsignon-glib/signon-proxy.c 2016-07-13 14:51:18 +0000 |
| 832 | @@ -0,0 +1,219 @@ |
| 833 | +/* vi: set et sw=4 ts=4 cino=t0,(0: */ |
| 834 | +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 835 | +/* |
| 836 | + * This file is part of libsignon-glib |
| 837 | + * |
| 838 | + * Copyright (C) 2009-2010 Nokia Corporation. |
| 839 | + * Copyright (C) 2012-2016 Canonical Ltd. |
| 840 | + * |
| 841 | + * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
| 842 | + * |
| 843 | + * This library is free software; you can redistribute it and/or |
| 844 | + * modify it under the terms of the GNU Lesser General Public License |
| 845 | + * version 2.1 as published by the Free Software Foundation. |
| 846 | + * |
| 847 | + * This library is distributed in the hope that it will be useful, but |
| 848 | + * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 849 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 850 | + * Lesser General Public License for more details. |
| 851 | + * |
| 852 | + * You should have received a copy of the GNU Lesser General Public |
| 853 | + * License along with this library; if not, write to the Free Software |
| 854 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 855 | + * 02110-1301 USA |
| 856 | + */ |
| 857 | + |
| 858 | +#include "signon-proxy.h" |
| 859 | +#include "signon-internals.h" |
| 860 | + |
| 861 | +G_DEFINE_INTERFACE (SignonProxy, signon_proxy, G_TYPE_OBJECT) |
| 862 | + |
| 863 | +typedef struct { |
| 864 | + SignonReadyCb callback; |
| 865 | + gpointer user_data; |
| 866 | +} SignonReadyCbData; |
| 867 | + |
| 868 | +typedef struct { |
| 869 | + gpointer self; |
| 870 | + GSList *callbacks; |
| 871 | + guint idle_id; |
| 872 | +} SignonReadyData; |
| 873 | + |
| 874 | +static void |
| 875 | +signon_proxy_default_init (SignonProxyInterface *iface) |
| 876 | +{ |
| 877 | + /* add properties and signals to the interface here */ |
| 878 | +} |
| 879 | + |
| 880 | +static GQuark |
| 881 | +_signon_proxy_ready_quark() |
| 882 | +{ |
| 883 | + static GQuark quark = 0; |
| 884 | + |
| 885 | + if (!quark) |
| 886 | + quark = g_quark_from_static_string ("signon_proxy_ready_quark"); |
| 887 | + |
| 888 | + return quark; |
| 889 | +} |
| 890 | + |
| 891 | +static GQuark |
| 892 | +_signon_proxy_error_quark() |
| 893 | +{ |
| 894 | + static GQuark quark = 0; |
| 895 | + |
| 896 | + if (!quark) |
| 897 | + quark = g_quark_from_static_string ("signon_proxy_error_quark"); |
| 898 | + |
| 899 | + return quark; |
| 900 | +} |
| 901 | + |
| 902 | +static void |
| 903 | +signon_proxy_invoke_ready_callbacks (SignonReadyData *rd, const GError *error) |
| 904 | +{ |
| 905 | + GSList *list; |
| 906 | + /* Make a copy of the callbacks list and erase the pointer in the |
| 907 | + * structure, to ensure that we won't invoke the same callback twice. */ |
| 908 | + GSList *callbacks = rd->callbacks; |
| 909 | + rd->callbacks = NULL; |
| 910 | + |
| 911 | + for (list = callbacks; list != NULL; list = list->next) |
| 912 | + { |
| 913 | + SignonReadyCbData *cb = list->data; |
| 914 | + |
| 915 | + cb->callback (rd->self, error, cb->user_data); |
| 916 | + g_slice_free (SignonReadyCbData, cb); |
| 917 | + } |
| 918 | + g_slist_free (callbacks); |
| 919 | +} |
| 920 | + |
| 921 | +static void |
| 922 | +signon_ready_data_free (SignonReadyData *rd) |
| 923 | +{ |
| 924 | + if (rd->self) |
| 925 | + { |
| 926 | + //TODO: Signon error codes need be presented instead of 555 and 666 |
| 927 | + GError error = { 555, 666, "Object disposed" }; |
| 928 | + signon_proxy_invoke_ready_callbacks (rd, &error); |
| 929 | + } |
| 930 | + if (rd->idle_id > 0) |
| 931 | + { |
| 932 | + g_source_remove (rd->idle_id); |
| 933 | + rd->idle_id = 0; |
| 934 | + } |
| 935 | + g_slice_free (SignonReadyData, rd); |
| 936 | +} |
| 937 | + |
| 938 | +static gboolean |
| 939 | +signon_proxy_call_when_ready_idle (SignonReadyData *rd) |
| 940 | +{ |
| 941 | + if (GPOINTER_TO_INT (g_object_get_qdata((GObject*)rd->self, |
| 942 | + _signon_proxy_ready_quark())) == TRUE) |
| 943 | + { |
| 944 | + //TODO: specify the last error in object initialization |
| 945 | + GError * err = g_object_get_qdata((GObject*)rd->self, |
| 946 | + _signon_proxy_error_quark()); |
| 947 | + signon_proxy_invoke_ready_callbacks (rd, err); |
| 948 | + } |
| 949 | + else |
| 950 | + { |
| 951 | + signon_proxy_setup (SIGNON_PROXY (rd->self)); |
| 952 | + } |
| 953 | + |
| 954 | + rd->idle_id = 0; |
| 955 | + return FALSE; |
| 956 | +} |
| 957 | + |
| 958 | +void |
| 959 | +signon_proxy_setup (gpointer self) |
| 960 | +{ |
| 961 | + SignonProxyInterface *iface; |
| 962 | + |
| 963 | + g_return_if_fail (SIGNON_IS_PROXY (self)); |
| 964 | + |
| 965 | + iface = SIGNON_PROXY_GET_IFACE (self); |
| 966 | + if (iface->setup != NULL) |
| 967 | + { |
| 968 | + iface->setup (self); |
| 969 | + } |
| 970 | +} |
| 971 | + |
| 972 | +void |
| 973 | +signon_proxy_call_when_ready (gpointer object, GQuark quark, SignonReadyCb callback, |
| 974 | + gpointer user_data) |
| 975 | +{ |
| 976 | + SignonReadyData *rd; |
| 977 | + SignonReadyCbData *cb; |
| 978 | + |
| 979 | + g_return_if_fail (SIGNON_IS_PROXY (object)); |
| 980 | + g_return_if_fail (quark != 0); |
| 981 | + g_return_if_fail (callback != NULL); |
| 982 | + |
| 983 | + cb = g_slice_new (SignonReadyCbData); |
| 984 | + cb->callback = callback; |
| 985 | + cb->user_data = user_data; |
| 986 | + |
| 987 | + rd = g_object_get_qdata ((GObject *)object, quark); |
| 988 | + if (!rd) |
| 989 | + { |
| 990 | + rd = g_slice_new (SignonReadyData); |
| 991 | + rd->self = object; |
| 992 | + rd->callbacks = NULL; |
| 993 | + rd->idle_id = 0; |
| 994 | + g_object_set_qdata_full ((GObject *)object, quark, rd, |
| 995 | + (GDestroyNotify)signon_ready_data_free); |
| 996 | + } |
| 997 | + |
| 998 | + rd->callbacks = g_slist_append (rd->callbacks, cb); |
| 999 | + if (rd->idle_id == 0) |
| 1000 | + { |
| 1001 | + rd->idle_id = |
| 1002 | + g_idle_add ((GSourceFunc)signon_proxy_call_when_ready_idle, rd); |
| 1003 | + } |
| 1004 | +} |
| 1005 | + |
| 1006 | +void |
| 1007 | +signon_proxy_set_ready (gpointer object, GQuark quark, GError *error) |
| 1008 | +{ |
| 1009 | + SignonReadyData *rd; |
| 1010 | + |
| 1011 | + g_return_if_fail (SIGNON_IS_PROXY (object)); |
| 1012 | + |
| 1013 | + g_object_set_qdata((GObject *)object, _signon_proxy_ready_quark(), GINT_TO_POINTER(TRUE)); |
| 1014 | + |
| 1015 | + if(error) |
| 1016 | + g_object_set_qdata_full ((GObject *)object, _signon_proxy_error_quark(), |
| 1017 | + error, |
| 1018 | + (GDestroyNotify)g_error_free); |
| 1019 | + |
| 1020 | + rd = g_object_get_qdata ((GObject *)object, quark); |
| 1021 | + if (!rd) return; |
| 1022 | + |
| 1023 | + g_object_ref (object); |
| 1024 | + |
| 1025 | + signon_proxy_invoke_ready_callbacks (rd, error); |
| 1026 | + |
| 1027 | + g_object_unref (object); |
| 1028 | +} |
| 1029 | + |
| 1030 | +void |
| 1031 | +signon_proxy_set_not_ready (gpointer object) |
| 1032 | +{ |
| 1033 | + g_return_if_fail (SIGNON_IS_PROXY (object)); |
| 1034 | + |
| 1035 | + g_object_set_qdata ((GObject *)object, |
| 1036 | + _signon_proxy_ready_quark(), |
| 1037 | + GINT_TO_POINTER(FALSE)); |
| 1038 | + |
| 1039 | + g_object_set_qdata ((GObject *)object, |
| 1040 | + _signon_proxy_error_quark(), |
| 1041 | + NULL); |
| 1042 | +} |
| 1043 | + |
| 1044 | +const GError * |
| 1045 | +signon_proxy_get_last_error (gpointer object) |
| 1046 | +{ |
| 1047 | + g_return_val_if_fail (SIGNON_IS_PROXY (object), NULL); |
| 1048 | + |
| 1049 | + return g_object_get_qdata((GObject *)object, |
| 1050 | + _signon_proxy_error_quark()); |
| 1051 | +} |
| 1052 | |
| 1053 | === added file 'libsignon-glib/signon-proxy.h' |
| 1054 | --- libsignon-glib/signon-proxy.h 1970-01-01 00:00:00 +0000 |
| 1055 | +++ libsignon-glib/signon-proxy.h 2016-07-13 14:51:18 +0000 |
| 1056 | @@ -0,0 +1,65 @@ |
| 1057 | +/* vi: set et sw=4 ts=4 cino=t0,(0: */ |
| 1058 | +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 1059 | +/* |
| 1060 | + * This file is part of libsignon-glib |
| 1061 | + * |
| 1062 | + * Copyright (C) 2009-2010 Nokia Corporation. |
| 1063 | + * Copyright (C) 2012-2016 Canonical Ltd. |
| 1064 | + * |
| 1065 | + * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
| 1066 | + * |
| 1067 | + * This library is free software; you can redistribute it and/or |
| 1068 | + * modify it under the terms of the GNU Lesser General Public License |
| 1069 | + * version 2.1 as published by the Free Software Foundation. |
| 1070 | + * |
| 1071 | + * This library is distributed in the hope that it will be useful, but |
| 1072 | + * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1073 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 1074 | + * Lesser General Public License for more details. |
| 1075 | + * |
| 1076 | + * You should have received a copy of the GNU Lesser General Public |
| 1077 | + * License along with this library; if not, write to the Free Software |
| 1078 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 1079 | + * 02110-1301 USA |
| 1080 | + */ |
| 1081 | + |
| 1082 | +#ifndef _SIGNON_PROXY_H_ |
| 1083 | +#define _SIGNON_PROXY_H_ |
| 1084 | + |
| 1085 | +#include <glib.h> |
| 1086 | +#include <glib-object.h> |
| 1087 | + |
| 1088 | +G_BEGIN_DECLS |
| 1089 | + |
| 1090 | +#define SIGNON_TYPE_PROXY (signon_proxy_get_type ()) |
| 1091 | +G_GNUC_INTERNAL |
| 1092 | +G_DECLARE_INTERFACE(SignonProxy, signon_proxy, SIGNON, PROXY, GObject) |
| 1093 | + |
| 1094 | +typedef void (*SignonReadyCb) (gpointer object, const GError *error, |
| 1095 | + gpointer user_data); |
| 1096 | + |
| 1097 | +struct _SignonProxyInterface |
| 1098 | +{ |
| 1099 | + GTypeInterface parent_iface; |
| 1100 | + |
| 1101 | + void (*setup) (SignonProxy *self); |
| 1102 | +}; |
| 1103 | + |
| 1104 | +G_GNUC_INTERNAL |
| 1105 | +void signon_proxy_setup (gpointer self); |
| 1106 | + |
| 1107 | +G_GNUC_INTERNAL |
| 1108 | +void signon_proxy_call_when_ready (gpointer self, GQuark quark, |
| 1109 | + SignonReadyCb callback, gpointer user_data); |
| 1110 | + |
| 1111 | +G_GNUC_INTERNAL |
| 1112 | +void signon_proxy_set_ready (gpointer self, GQuark quark, GError *error); |
| 1113 | + |
| 1114 | +G_GNUC_INTERNAL |
| 1115 | +void signon_proxy_set_not_ready (gpointer self); |
| 1116 | + |
| 1117 | +G_GNUC_INTERNAL |
| 1118 | +const GError *signon_proxy_get_last_error (gpointer self); |
| 1119 | + |
| 1120 | +G_END_DECLS |
| 1121 | +#endif /* _SIGNON_PROXY_H_ */ |
| 1122 | |
| 1123 | === modified file 'libsignon-glib/signon-types.h' |
| 1124 | --- libsignon-glib/signon-types.h 2012-11-30 07:38:19 +0000 |
| 1125 | +++ libsignon-glib/signon-types.h 2016-07-13 14:51:18 +0000 |
| 1126 | @@ -3,7 +3,7 @@ |
| 1127 | /* |
| 1128 | * This file is part of libsignon-glib |
| 1129 | * |
| 1130 | - * Copyright (C) 2012 Canonical Ltd. |
| 1131 | + * Copyright (C) 2012-2016 Canonical Ltd. |
| 1132 | * |
| 1133 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
| 1134 | * |
| 1135 | |
| 1136 | === modified file 'libsignon-glib/signon-utils.c' |
| 1137 | --- libsignon-glib/signon-utils.c 2016-05-04 09:21:44 +0000 |
| 1138 | +++ libsignon-glib/signon-utils.c 2016-07-13 14:51:18 +0000 |
| 1139 | @@ -4,7 +4,7 @@ |
| 1140 | * This file is part of libsignon-glib |
| 1141 | * |
| 1142 | * Copyright (C) 2009-2010 Nokia Corporation. |
| 1143 | - * Copyright (C) 2012 Canonical Ltd. |
| 1144 | + * Copyright (C) 2012-2016 Canonical Ltd. |
| 1145 | * |
| 1146 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
| 1147 | * |
| 1148 | |
| 1149 | === modified file 'libsignon-glib/signon-utils.h' |
| 1150 | --- libsignon-glib/signon-utils.h 2012-08-02 10:25:45 +0000 |
| 1151 | +++ libsignon-glib/signon-utils.h 2016-07-13 14:51:18 +0000 |
| 1152 | @@ -4,7 +4,7 @@ |
| 1153 | * This file is part of libsignon-glib |
| 1154 | * |
| 1155 | * Copyright (C) 2009-2010 Nokia Corporation. |
| 1156 | - * Copyright (C) 2012 Canonical Ltd. |
| 1157 | + * Copyright (C) 2012-2016 Canonical Ltd. |
| 1158 | * |
| 1159 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
| 1160 | * |
| 1161 | |
| 1162 | === modified file 'libsignon-glib/sso-auth-service.c' |
| 1163 | --- libsignon-glib/sso-auth-service.c 2016-05-04 09:21:44 +0000 |
| 1164 | +++ libsignon-glib/sso-auth-service.c 2016-07-13 14:51:18 +0000 |
| 1165 | @@ -3,7 +3,7 @@ |
| 1166 | /* |
| 1167 | * This file is part of libsignon-glib |
| 1168 | * |
| 1169 | - * Copyright (C) 2012 Canonical Ltd. |
| 1170 | + * Copyright (C) 2012-2016 Canonical Ltd. |
| 1171 | * |
| 1172 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
| 1173 | * |
| 1174 | |
| 1175 | === modified file 'libsignon-glib/sso-auth-service.h' |
| 1176 | --- libsignon-glib/sso-auth-service.h 2012-08-02 10:25:45 +0000 |
| 1177 | +++ libsignon-glib/sso-auth-service.h 2016-07-13 14:51:18 +0000 |
| 1178 | @@ -3,7 +3,7 @@ |
| 1179 | /* |
| 1180 | * This file is part of libsignon-glib |
| 1181 | * |
| 1182 | - * Copyright (C) 2012 Canonical Ltd. |
| 1183 | + * Copyright (C) 2012-2016 Canonical Ltd. |
| 1184 | * |
| 1185 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
| 1186 | * |
| 1187 | |
| 1188 | === modified file 'tests/check_signon.c' |
| 1189 | --- tests/check_signon.c 2016-05-04 09:22:30 +0000 |
| 1190 | +++ tests/check_signon.c 2016-07-13 14:51:18 +0000 |
| 1191 | @@ -3,7 +3,7 @@ |
| 1192 | * This file is part of libsignon-glib |
| 1193 | * |
| 1194 | * Copyright (C) 2009-2011 Nokia Corporation. |
| 1195 | - * Copyright (C) 2011-2012 Canonical Ltd. |
| 1196 | + * Copyright (C) 2011-2016 Canonical Ltd. |
| 1197 | * |
| 1198 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
| 1199 | * |
| 1200 | @@ -82,6 +82,23 @@ |
| 1201 | } |
| 1202 | } |
| 1203 | |
| 1204 | +static gboolean |
| 1205 | +quit_loop (gpointer user_data) |
| 1206 | +{ |
| 1207 | + GMainLoop *loop = user_data; |
| 1208 | + g_main_loop_quit (loop); |
| 1209 | + return FALSE; |
| 1210 | +} |
| 1211 | + |
| 1212 | +static void |
| 1213 | +run_main_loop_for_n_seconds(guint seconds) |
| 1214 | +{ |
| 1215 | + GMainLoop *loop = g_main_loop_new (NULL, FALSE); |
| 1216 | + g_timeout_add_seconds (seconds, quit_loop, loop); |
| 1217 | + g_main_loop_run (loop); |
| 1218 | + g_main_loop_unref (loop); |
| 1219 | +} |
| 1220 | + |
| 1221 | START_TEST(test_init) |
| 1222 | { |
| 1223 | g_debug("%s", G_STRFUNC); |
| 1224 | @@ -220,14 +237,6 @@ |
| 1225 | } |
| 1226 | END_TEST |
| 1227 | |
| 1228 | - |
| 1229 | -static gboolean |
| 1230 | -test_quit_main_loop_cb (gpointer data) |
| 1231 | -{ |
| 1232 | - g_main_loop_quit (main_loop); |
| 1233 | - return FALSE; |
| 1234 | -} |
| 1235 | - |
| 1236 | static void |
| 1237 | test_auth_session_query_mechanisms_cb (SignonAuthSession *self, |
| 1238 | gchar **mechanisms, |
| 1239 | @@ -920,7 +929,7 @@ |
| 1240 | /* Wait some time to ensure that the info-updated signals are |
| 1241 | * processed |
| 1242 | */ |
| 1243 | - g_timeout_add_seconds (2, test_quit_main_loop_cb, main_loop); |
| 1244 | + g_timeout_add_seconds (2, quit_loop, main_loop); |
| 1245 | } |
| 1246 | |
| 1247 | START_TEST(test_store_credentials_identity) |
| 1248 | @@ -949,7 +958,6 @@ |
| 1249 | &last_id); |
| 1250 | g_hash_table_destroy (methods); |
| 1251 | |
| 1252 | - g_timeout_add (1000, test_quit_main_loop_cb, idty); |
| 1253 | g_main_loop_run (main_loop); |
| 1254 | |
| 1255 | g_object_unref(idty); |
| 1256 | @@ -995,6 +1003,8 @@ |
| 1257 | gchar secret[] = "007"; |
| 1258 | gchar caption[] = "caption"; |
| 1259 | |
| 1260 | + main_loop = g_main_loop_new (NULL, FALSE); |
| 1261 | + |
| 1262 | signon_identity_store_credentials_with_args (idty, |
| 1263 | username, |
| 1264 | secret, |
| 1265 | @@ -1006,7 +1016,7 @@ |
| 1266 | 0, |
| 1267 | store_credentials_identity_cb, |
| 1268 | NULL); |
| 1269 | - main_loop = g_main_loop_new (NULL, FALSE); |
| 1270 | + g_main_loop_run (main_loop); |
| 1271 | |
| 1272 | signon_identity_verify_secret(idty, |
| 1273 | secret, |
| 1274 | @@ -1264,12 +1274,10 @@ |
| 1275 | signon_identity_remove(idty2, identity_remove_cb, NULL); |
| 1276 | g_main_loop_run (main_loop); |
| 1277 | |
| 1278 | - /* |
| 1279 | - * no main_loops required as |
| 1280 | - * the callback is executed immediately |
| 1281 | - * */ |
| 1282 | signon_identity_query_info (idty2, identity_info_cb, NULL); |
| 1283 | + g_main_loop_run (main_loop); |
| 1284 | signon_identity_query_info (idty, identity_info_cb, NULL); |
| 1285 | + g_main_loop_run (main_loop); |
| 1286 | |
| 1287 | signon_identity_info_free (info); |
| 1288 | g_object_unref (idty); |
| 1289 | @@ -1323,8 +1331,7 @@ |
| 1290 | SignonIdentity *idty2 = signon_identity_new_from_db (id); |
| 1291 | |
| 1292 | /* wait some more time to ensure that the object gets registered */ |
| 1293 | - g_timeout_add_seconds (2, test_quit_main_loop_cb, main_loop); |
| 1294 | - g_main_loop_run (main_loop); |
| 1295 | + run_main_loop_for_n_seconds(2); |
| 1296 | |
| 1297 | signon_identity_info_free (info); |
| 1298 | |
| 1299 | @@ -1389,7 +1396,7 @@ |
| 1300 | /* |
| 1301 | * give time to handle unregistered signal |
| 1302 | * */ |
| 1303 | - g_timeout_add_seconds (5, test_quit_main_loop_cb, main_loop); |
| 1304 | + //run_main_loop_for_n_seconds(5); |
| 1305 | |
| 1306 | signon_identity_query_info (idty, identity_info_cb, &info); |
| 1307 | g_main_loop_run (main_loop); |
| 1308 | @@ -1404,6 +1411,12 @@ |
| 1309 | |
| 1310 | START_TEST(test_unregistered_auth_session) |
| 1311 | { |
| 1312 | + GVariantBuilder builder; |
| 1313 | + GVariant *session_data; |
| 1314 | + GVariant *reply = NULL; |
| 1315 | + gchar *username; |
| 1316 | + gboolean ok; |
| 1317 | + |
| 1318 | g_debug("%s", G_STRFUNC); |
| 1319 | SignonIdentity *idty = signon_identity_new(); |
| 1320 | fail_unless (idty != NULL); |
| 1321 | @@ -1417,8 +1430,7 @@ |
| 1322 | "ssotest", |
| 1323 | &err); |
| 1324 | /* give time to register the objects */ |
| 1325 | - g_timeout_add_seconds (2, test_quit_main_loop_cb, main_loop); |
| 1326 | - g_main_loop_run (main_loop); |
| 1327 | + run_main_loop_for_n_seconds(2); |
| 1328 | |
| 1329 | /* |
| 1330 | * give the time for identity to became idle |
| 1331 | @@ -1426,12 +1438,32 @@ |
| 1332 | sleep(SIGNOND_IDLE_TIMEOUT); |
| 1333 | SignonIdentity *idty2 = signon_identity_new(); |
| 1334 | |
| 1335 | - /* |
| 1336 | - * give time to handle unregistered signal |
| 1337 | - * */ |
| 1338 | - g_timeout_add_seconds (5, test_quit_main_loop_cb, main_loop); |
| 1339 | + g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); |
| 1340 | + g_variant_builder_add (&builder, "{sv}", |
| 1341 | + SIGNON_SESSION_DATA_USERNAME, |
| 1342 | + g_variant_new_string ("test_username")); |
| 1343 | + g_variant_builder_add (&builder, "{sv}", |
| 1344 | + SIGNON_SESSION_DATA_SECRET, |
| 1345 | + g_variant_new_string ("test_pw")); |
| 1346 | + |
| 1347 | + session_data = g_variant_builder_end (&builder); |
| 1348 | + |
| 1349 | + signon_auth_session_process_async (as, |
| 1350 | + session_data, |
| 1351 | + "mech1", |
| 1352 | + NULL, |
| 1353 | + test_auth_session_process_async_cb, |
| 1354 | + &reply); |
| 1355 | g_main_loop_run (main_loop); |
| 1356 | |
| 1357 | + fail_unless (reply != NULL); |
| 1358 | + session_data = NULL; |
| 1359 | + |
| 1360 | + ok = g_variant_lookup (reply, SIGNON_SESSION_DATA_USERNAME, "&s", &username); |
| 1361 | + ck_assert (ok); |
| 1362 | + ck_assert_str_eq (username, "test_username"); |
| 1363 | + |
| 1364 | + g_variant_unref (reply); |
| 1365 | |
| 1366 | gchar* patterns[4]; |
| 1367 | patterns[0] = g_strdup("mech1"); |
| 1368 | @@ -1453,6 +1485,8 @@ |
| 1369 | g_free (patterns[1]); |
| 1370 | g_free (patterns[2]); |
| 1371 | g_free (patterns[3]); |
| 1372 | + |
| 1373 | + end_test (); |
| 1374 | } |
| 1375 | END_TEST |
| 1376 | |
| 1377 | |
| 1378 | === modified file 'tests/signon-glib-test.sh' |
| 1379 | --- tests/signon-glib-test.sh 2016-05-03 09:43:43 +0000 |
| 1380 | +++ tests/signon-glib-test.sh 2016-07-13 14:51:18 +0000 |
| 1381 | @@ -3,9 +3,9 @@ |
| 1382 | # Environment variables for the signon daemon |
| 1383 | export SSO_LOGGING_LEVEL=2 |
| 1384 | export SSO_STORAGE_PATH="/tmp" |
| 1385 | -export SSO_DAEMON_TIMEOUT=5 |
| 1386 | -export SSO_IDENTITY_TIMEOUT=5 |
| 1387 | -export SSO_AUTHSESSION_TIMEOUT=5 |
| 1388 | +export SSO_DAEMON_TIMEOUT=1 |
| 1389 | +export SSO_IDENTITY_TIMEOUT=3 |
| 1390 | +export SSO_AUTHSESSION_TIMEOUT=3 |
| 1391 | export SSO_EXTENSIONS_DIR="/tmp" # this disables all extensions |
| 1392 | |
| 1393 | #Environment variables for the test application |
| 1394 | @@ -25,7 +25,8 @@ |
| 1395 | # session |
| 1396 | if command -v dbus-test-runner > /dev/null ; then |
| 1397 | echo "Using dbus-test-runner" |
| 1398 | - dbus-test-runner -m 180 -t signond -r \ |
| 1399 | + dbus-test-runner -m 180 --keep-env \ |
| 1400 | + -t signond -r \ |
| 1401 | -t "$TEST_APP" -f com.google.code.AccountsSSO.SingleSignOn |
| 1402 | else |
| 1403 | echo "Using existing D-Bus session" |
