Exemplo n.º 1
0
//--------------------------------------------------------------------------
//	功能:读取以前的的登陆选择
//--------------------------------------------------------------------------
void KLogin::LoadLoginChoice()
{
	if (m_Choices.bLoaded)
		return;
	memset(&m_Choices, 0, sizeof(m_Choices));
	ClearAccountPassword(true, true);

	m_Choices.bLoaded = true;

	KIniFile* pSetting = g_UiBase.GetCommSettingFile();
	char	szAccount[32];
    KSG_PASSWORD Password;
	if (pSetting)
	{
		pSetting->GetInteger($LOGIN, "SelServerRegion", 0, &m_Choices.nServerRegionIndex);
		pSetting->GetString($LOGIN, "LastGameServer", "", m_Choices.AccountServer.Title, sizeof(m_Choices.AccountServer.Title));

		szAccount[0] = 0;
		pSetting->GetStruct($LOGIN, $LAST_ACCOUNT, szAccount, sizeof(szAccount));
		if (szAccount[0])
		{
			EDOneTimePad_Decipher(szAccount, strlen(szAccount));
			m_Choices.bRememberAccount = true;
			SetAccountPassword(szAccount, NULL);

			Password.szPassword[0] = '\0';
			pSetting->GetStruct($LOGIN, $LAST_PASSWORD, Password.szPassword, sizeof(Password.szPassword));
			if (Password.szPassword[0])
			{
				EDOneTimePad_Decipher(Password.szPassword, strlen(Password.szPassword));
				m_Choices.bRememberAll = true;
				SetAccountPassword(NULL, &Password);
				memset(&Password, 0, sizeof(Password));
			}
		}

		if (szAccount[0])
		{
			KIniFile* pPrivate = g_UiBase.GetPrivateSettingFile();
			if (pPrivate)
			{
				if (pPrivate->GetString("Main", "LastSelCharacter", "",
					m_Choices.szProcessingRoleName, sizeof(m_Choices.szProcessingRoleName)))
				{
					EDOneTimePad_Decipher(m_Choices.szProcessingRoleName, strlen(m_Choices.szProcessingRoleName));
				}
			}
			g_UiBase.ClosePrivateSettingFile(false);
		}

		g_UiBase.CloseCommSettingFile(false);
	}
}
Exemplo n.º 2
0
bool CWizardAttach::SyncToAccountManager() {
    ACCT_MGR_INFO ami;
    CMainDocument* pDoc = wxGetApp().GetDocument();

    wxASSERT(pDoc);
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));

    IsAttachToProjectWizard = false;
    IsAccountManagerWizard = true;

    pDoc->rpc.acct_mgr_info(ami);

    if (ami.acct_mgr_url.size()) {
        SetProjectName(wxString(ami.acct_mgr_name.c_str(), wxConvUTF8));
        SetProjectURL(wxString(ami.acct_mgr_url.c_str(), wxConvUTF8));

        SetCredentialsCached(ami.have_credentials);
        SetCookieRequired(ami.cookie_required);
        SetCookieFailureURL(wxString(ami.cookie_failure_url.c_str(), wxConvUTF8));
        if (IsCredentialsCached()) {
            IsAccountManagerUpdateWizard = true;
        }
    }

    if (ami.acct_mgr_url.size() && !m_bCredentialsCached) {
        std::string login;
        std::string password_hash;
        std::string return_url;

        if (detect_account_manager_credentials(ami.acct_mgr_url, login, password_hash, return_url)) {
            wxString strLogin;
            wxString strPasswordHash;
            wxString strReturnURL;

            strLogin = wxURL::Unescape(wxString(login.c_str(), wxConvUTF8));
            strPasswordHash = wxURL::Unescape(wxString(password_hash.c_str(), wxConvUTF8));
            strReturnURL = wxURL::Unescape(wxString(return_url.c_str(), wxConvUTF8));

            SetCredentialsDetected(true);
            SetReturnURL(strReturnURL);
            SetAccountEmailAddress(strLogin);
            SetAccountUsername(strLogin);
            SetAccountPassword(
                wxString(_T("hash:")) + strPasswordHash
            );
        }
    }

    if (m_AccountManagerInfoPage || m_AccountManagerPropertiesPage) {
        IsAttachToProjectWizard = false;
        IsAccountManagerWizard = true;
        if (!ami.acct_mgr_url.size()) {
            return RunWizard(m_AccountManagerInfoPage);
        } else {
            return RunWizard(m_AccountManagerPropertiesPage);
        }
    }

    return FALSE;
}
Exemplo n.º 3
0
//--------------------------------------------------------------------------
//	功能:传入帐号密码,账号登陆
//	状态切换:成功 LL_S_WAIT_INPUT_ACCOUNT -> LL_S_ACCOUNT_CONFIRMING
//			  失败 状态保持
//--------------------------------------------------------------------------
int	KLogin::AccountLogin(const char* pszAccount, const KSG_PASSWORD& crPassword, bool bOrignPassword)
{
	int nRet;
	if (m_Status == LL_S_WAIT_INPUT_ACCOUNT &&
		pszAccount && 
		Request(pszAccount, &crPassword, LOGIN_A_LOGIN))
	{
        if (bOrignPassword)
        {
    		SetAccountPassword(pszAccount, &crPassword);
        }
		m_Status = LL_S_ACCOUNT_CONFIRMING;
		m_Result = LL_R_NOTHING;
		nRet = true;
	}
	else
	{
		if (m_bInAutoProgress)
			m_bInAutoProgress = false;
		m_Result = LL_R_CONNECT_FAILED;
		nRet = false;
	}
	return nRet;
}