/// <summary> /// Call the HTTP query event handler in UI context. /// </summary> private void FireOnHttpEvent(HttpQueryEventArgs ev) { KBase.ExecInUI(new KBase.EmptyDelegate(delegate() { if (OnHttpQueryEvent != null) OnHttpQueryEvent(this, ev); }), null); }
/// <summary> /// Called when the HTTP query results are available. /// </summary> private void HandleHttpQueryResult(Object sender, HttpQueryEventArgs args) { if (m_httpQuery == null) return; HttpQuery query = m_httpQuery; m_httpQuery = null; try { if (args.Type == HttpQueryEventType.Done) { if (query.Result == "confirm") m_httpResCode = EAnpRegisterKpsCode.EmailConfirm; // This shouldn't fail through here, but it did. else if (query.Result != "ok") throw new Exception(query.Result); } else if (args.Type == HttpQueryEventType.DnsError) throw new Exception(args.Ex.Message); else if (args.Type == HttpQueryEventType.HttpError) { // When the web services responds with a 403, the response // body is not an error string to display to the user. It // is a protocol response the can be safely used here for // exact match, to indicate the reason of failure of the // registration process. if (query.StatusCode != HttpStatusCode.Forbidden) throw new Exception(args.Ex.Message); String r = query.Result; if (r == "registration_disabled") m_httpResCode = EAnpRegisterKpsCode.NoAutoRegister; else if (r == "user_login_taken") m_httpResCode = EAnpRegisterKpsCode.LoginTaken; else if (r == "user_registration_locked") m_httpResCode = EAnpRegisterKpsCode.NoLicense; else throw new Exception("protocol error: " + r); } } catch (Exception ex) { m_httpResCode = EAnpRegisterKpsCode.Failure; m_httpEx = ex; } OnQueryCompletion(); }