X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=src%2Fmoonshot-identity-request.vala;h=cc436ac4a16f6396d9d0792daa7c77aa6291a9bb;hb=a5a7ae76ecc654e74d22120bf6147507c9dc4a92;hp=048e47d3aa0316a660996d91fec5f30d6ad75204;hpb=cda6769722ddc6faa62d9277ddd43fe4a4eb0d68;p=moonshot-ui.git diff --git a/src/moonshot-identity-request.vala b/src/moonshot-identity-request.vala index 048e47d..cc436ac 100644 --- a/src/moonshot-identity-request.vala +++ b/src/moonshot-identity-request.vala @@ -1,31 +1,32 @@ -delegate void ReturnIdentityCallback (IdentityRequest request); +public delegate void ReturnIdentityCallback (IdentityRequest request); -class IdentityRequest : Object { +public class IdentityRequest : Object { public IdCard? id_card = null; public bool complete = false; public bool select_default = false; - private MainWindow main_window; - private string nai; - private string password; - private string service; + private IdentityManagerApp parent_app; + public string nai; + public string password; + public string service; + public SList candidates; ReturnIdentityCallback callback = null; - public IdentityRequest (MainWindow main_window, + public IdentityRequest (IdentityManagerApp app, string nai, string password, string service) { - this.main_window = main_window; + this.parent_app = app; this.nai = nai; this.password = password; this.service = service; } - public IdentityRequest.default (MainWindow main_window) + public IdentityRequest.default (IdentityManagerApp app) { - this.main_window = main_window; + this.parent_app = app; this.select_default = true; } @@ -39,7 +40,7 @@ class IdentityRequest : Object { } public bool execute () { - main_window.select_identity (this); + parent_app.select_identity (this); /* This function works as a GSourceFunc, so it can be passed to * the main loop from other threads @@ -48,11 +49,34 @@ class IdentityRequest : Object { } public void return_identity (IdCard? id_card) { - return_if_fail (callback != null); - this.id_card = id_card; this.complete = true; + /* update id_card service list */ + if (id_card != null && this.service != null && this.service != "") + { + bool duplicate_service = false; + + foreach (string service in id_card.services) + { + if (service == this.service) + duplicate_service = true; + } + if (duplicate_service == false) + { + string[] services = new string[id_card.services.length + 1]; + + for (int i = 0; i < id_card.services.length; i++) + services[i] = id_card.services[i]; + + services[id_card.services.length] = this.service; + id_card.services = services; + + this.id_card = this.parent_app.model.update_card (id_card); + } + } + + return_if_fail (callback != null); callback (this); }