/// <summary> /// This method must be called when the HTTP or KMOD query has /// completed. /// </summary> private void OnQueryCompletion() { // Bail out if there is still a pending query. if (m_httpQuery != null || m_kmodQuery != null) { return; } // The tbxsosd registration succeeded. Ignore the result of the // HTTP query, it is irrelevant. if (m_kmodResCode == EAnpRegisterKpsCode.OK) { // Update the registry. KwmCfg cfg = KwmCfg.Spawn(); UpdateRegistryObject(cfg); cfg.Commit(); } // Use the error code set by the HTTP query. else if (m_httpResCode != EAnpRegisterKpsCode.OK) { ResCode = m_httpResCode; ResMsg = ErrorCodeToMsg(ResCode, m_httpEx); } // Use the error provided by KMOD/tbxsosd. else { ResCode = m_kmodResCode; ResMsg = ErrorCodeToMsg(ResCode, m_kmodEx); } // We're done. Complete(); }
/// <summary> /// Initialize the application on startup. /// </summary> private static void AppInit() { // Somehow this call doesn't make the output visible in cygwin // bash. It works for cmd.exe. KSyscalls.AttachConsole(KSyscalls.ATTACH_PARENT_PROCESS); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); MsgWindow = new WmMsgWindow(); KBase.InvokeUiControl = new Control(); KBase.InvokeUiControl.CreateControl(); KBase.HandleErrorCallback = WmUi.HandleError; Application.ThreadException += HandleUnhandledException; KwmCfg.Cur = KwmCfg.Spawn(); KLogging.Logger = KwmLogger.Logger; KwmLogger.SetLoggingLevel(KwmCfg.Cur.KwmDebuggingFlag ? KwmLoggingLevel.Normal : KwmLoggingLevel.Debug); }
public override void Start() { // Update the registry. We set the host and login name and clear // the other login-related fields. KwmCfg cfg = KwmCfg.Spawn(); UpdateRegistryObject(cfg); cfg.Commit(); // Start the queries. if (FreemiumFlag) { SubmitHttpQuery(); } SubmitKmodLoginQuery(); }
/// <summary> /// Update the values of the registry based on the results of the /// query, if required. /// </summary> public void UpdateRegistry() { if (Res == WmLoginTicketQueryRes.MiscError) { return; } KwmCfg reg = KwmCfg.Spawn(); if (Res == WmLoginTicketQueryRes.InvalidCfg) { reg.KpsLoginToken = ""; reg.KpsUserPower = 0; reg.KpsKcdAddr = ""; } else if (Res == WmLoginTicketQueryRes.OK) { reg.KpsKcdAddr = Ticket.KcdAddr; reg.KpsUserPower = 0; } reg.Commit(); }