1 public delegate void ReturnIdentityCallback (IdentityRequest request);
3 public class IdentityRequest : Object {
4 public IdCard? id_card = null;
5 public bool complete = false;
6 public bool select_default = false;
8 private IdentityManagerApp parent_app;
10 public string password;
11 public string service;
12 public SList<IdCard> candidates;
14 ReturnIdentityCallback callback = null;
16 public IdentityRequest (IdentityManagerApp app,
21 this.parent_app = app;
23 this.password = password;
24 this.service = service;
27 public IdentityRequest.default (IdentityManagerApp app)
29 this.parent_app = app;
30 this.select_default = true;
33 public void set_callback (owned ReturnIdentityCallback cb)
36 this.callback = ((owned) cb);
38 this.callback = ((IdCard) => cb (IdCard));
42 public bool execute () {
43 parent_app.select_identity (this);
45 /* This function works as a GSourceFunc, so it can be passed to
46 * the main loop from other threads
51 public void return_identity (IdCard? id_card) {
52 this.id_card = id_card;
55 /* update id_card service list */
56 if (id_card != null && this.service != null && this.service != "")
58 bool duplicate_service = false;
60 foreach (string service in id_card.services)
62 if (service == this.service)
63 duplicate_service = true;
65 if (duplicate_service == false)
67 string[] services = new string[id_card.services.length + 1];
69 for (int i = 0; i < id_card.services.length; i++)
70 services[i] = id_card.services[i];
72 services[id_card.services.length] = this.service;
73 id_card.services = services;
75 this.parent_app.model.update_card (id_card);
79 return_if_fail (callback != null);
84 /* For synchronisation between RPC thread and main loop. Because
85 * these objects are not refcounted, it's best to tie them to the
86 * lifecycle of the IdentityRequest object.