Skip to content

Commit

Permalink
Add register page to dlman
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-abram committed Feb 18, 2018
1 parent e2bf44f commit 154825e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/DownloadManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ DownloadManager::DownloadManager() {
}
CachePackList(packListURL);
RefreshLastVersion();
RefreshRegisterPage();
}

DownloadManager::~DownloadManager()
Expand Down Expand Up @@ -803,6 +804,17 @@ void DownloadManager::RefreshLastVersion()
};
SendRequest("client_version", vector<pair<string, string>>(), done, false, false, false);
}
void DownloadManager::RefreshRegisterPage()
{
function<void(HTTPRequest&)> done = [this](HTTPRequest& req) {
Json::Value json;
RString error;
if (!JsonUtil::LoadFromString(json, req.result, error) || (json.isObject() && json.isMember("error")))
return;
this->registerPage = json.get("link", "").asCString();
};
SendRequest("register_link", vector<pair<string, string>>(), done, false, false, false);
}
void DownloadManager::RefreshTop25(Skillset ss)
{
if (!LoggedIn())
Expand Down Expand Up @@ -1175,6 +1187,11 @@ class LunaDownloadManager : public Luna<DownloadManager>
lua_pushstring(L, DLMAN->lastVersion.c_str());
return 1;
}
static int GetRegisterPage(T* p, lua_State* L)
{
lua_pushstring(L, DLMAN->registerPage.c_str());
return 1;
}
static int GetTopSkillsetScore(T* p, lua_State* L)
{
int rank = IArg(1);
Expand Down Expand Up @@ -1315,6 +1332,7 @@ class LunaDownloadManager : public Luna<DownloadManager>
ADD_METHOD(GetTopChartScore);
ADD_METHOD(GetTopChartScoreCount);
ADD_METHOD(GetLastVersion);
ADD_METHOD(GetRegisterPage);
ADD_METHOD(Logout);
}
};
Expand Down
4 changes: 3 additions & 1 deletion src/DownloadManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ class DownloadManager
string sessionCookie{ "" }; // Entire session cookie string
string sessionUser{ "" }; // Currently logged in username
string sessionPass{ "" }; // Currently logged in password
string lastVersion{""}; // Last version according to server (Or current if non was obtained)
string lastVersion{ "" }; // Last version according to server (Or current if non was obtained)
string registerPage{ "" }; // Register page from server (Or empty if non was obtained)
map<string, vector<OnlineScore>> chartLeaderboards;
map<Skillset, int> sessionRanks; // Leaderboard ranks for logged in user by skillset
map<Skillset, double> sessionRatings;
Expand Down Expand Up @@ -184,6 +185,7 @@ class DownloadManager

void SendRequest(string requestName, vector<pair<string, string>> params, function<void(HTTPRequest&)> done, bool requireLogin = true, bool post = false, bool async = true);
void RefreshLastVersion();
void RefreshRegisterPage();
void RequestChartLeaderBoard(string chartkey);
void RefreshUserData();
void RefreshUserRank();
Expand Down

0 comments on commit 154825e

Please sign in to comment.