void VKUAuthConfig::Read() { String regPath(VKUApp::GetInstance()->GetAppDataPath() + L"auth.ini"); String authSection(L"auth"); Registry reg; reg.Construct(regPath, false); if(accessTokenValue != null) { delete accessTokenValue; } accessTokenValue = new String(); reg.GetValue(authSection, "access_token", *accessTokenValue); reg.GetValue(authSection, "expires_in", expiresInValue); reg.GetValue(authSection, "user_id", userIdValue); }
result UserProfileForm::OnInitializing(void) { BaseForm::OnInitializing(); AppResource* pAppResource = Application::GetInstance()->GetAppResource(); __pLeftItemBitmap = pAppResource->GetBitmapN(L"facebook_icon1.png"); ButtonItem buttonLeftItem; buttonLeftItem.Construct(BUTTON_ITEM_STYLE_ICON,NULL); buttonLeftItem.SetIcon(BUTTON_ITEM_STATUS_NORMAL, __pLeftItemBitmap); Header* pHeader = GetHeader(); pHeader->SetStyle(HEADER_STYLE_TITLE); pHeader->SetButton(BUTTON_POSITION_LEFT, buttonLeftItem); pHeader->SetTitleText(L"Your Profile Page"); result r = E_SUCCESS; //Read Access Token Registry reg; r = reg.Construct(L"/Home/FacebookReg.ini", false ); String token; String section = L"Facebook"; String entry = L"AccessToken"; r = reg.GetValue(section, entry , token); if(r == E_SUCCESS) AppLog("token is %ls",token.GetPointer()); else AppLog("Reading failed: %s", GetErrorMessage(r)); __accessToken =token; String profileurl; profileurl.Append(L"https://graph.facebook.com/me?"); profileurl.Append(L"access_token="); profileurl.Append(__accessToken); SendRequestGet(profileurl); return r; }
void VKUAuthConfig::Replace(const String &accessToken, const String &expiresIn, const String userId) { if(IsExists()) { Delete(); } String regPath(VKUApp::GetInstance()->GetAppDataPath() + L"auth.ini"); String authSection(L"auth"); Registry reg; reg.Construct(regPath, true); reg.AddSection(authSection); if(accessTokenValue != null) { delete accessTokenValue; } accessTokenValue = new String(accessToken); reg.AddValue(authSection, L"access_token", accessToken); Integer::Parse(expiresIn, expiresInValue); reg.AddValue(authSection, L"expires_in", expiresInValue); Integer::Parse(userId, userIdValue); reg.AddValue(authSection, L"user_id", userIdValue); reg.Flush(); }