Message of the day and user session check on startup
This commit is contained in:
parent
08b4e5553a
commit
5d3d1d4916
@ -24,6 +24,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
#include "Format.h"
|
||||||
#include "Client.h"
|
#include "Client.h"
|
||||||
#include "MD5.h"
|
#include "MD5.h"
|
||||||
#include "graphics/Graphics.h"
|
#include "graphics/Graphics.h"
|
||||||
@ -129,7 +130,12 @@ void Client::Initialise(std::string proxyString)
|
|||||||
stampsLib.close();
|
stampsLib.close();
|
||||||
|
|
||||||
//Begin version check
|
//Begin version check
|
||||||
versionCheckRequest = http_async_req_start(NULL, SERVER "/Download/Version.json", NULL, 0, 1);
|
versionCheckRequest = http_async_req_start(NULL, SERVER "/Startup.json", NULL, 0, 1);
|
||||||
|
|
||||||
|
if(authUser.ID)
|
||||||
|
{
|
||||||
|
http_auth_headers(versionCheckRequest, (char *)format::NumberToString<int>(authUser.ID).c_str(), NULL, (char *)authUser.SessionID.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::DoInstallation()
|
bool Client::DoInstallation()
|
||||||
@ -485,6 +491,17 @@ std::vector<unsigned char> Client::ReadFile(std::string filename)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Client::SetMessageOfTheDay(std::string message)
|
||||||
|
{
|
||||||
|
messageOfTheDay = message;
|
||||||
|
notifyMessageOfTheDay();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Client::GetMessageOfTheDay()
|
||||||
|
{
|
||||||
|
return messageOfTheDay;
|
||||||
|
}
|
||||||
|
|
||||||
void Client::Tick()
|
void Client::Tick()
|
||||||
{
|
{
|
||||||
//Check thumbnail queue
|
//Check thumbnail queue
|
||||||
@ -512,9 +529,24 @@ void Client::Tick()
|
|||||||
json::Object objDocument;
|
json::Object objDocument;
|
||||||
json::Reader::Read(objDocument, dataStream);
|
json::Reader::Read(objDocument, dataStream);
|
||||||
|
|
||||||
json::Object stableVersion = objDocument["Stable"];
|
//Check session
|
||||||
json::Object betaVersion = objDocument["Beta"];
|
json::Boolean sessionStatus = objDocument["Session"];
|
||||||
json::Object snapshotVersion = objDocument["Snapshot"];
|
if(!sessionStatus.Value())
|
||||||
|
{
|
||||||
|
authUser = User(0, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
//MOTD
|
||||||
|
json::String messageOfTheDay = objDocument["MessageOfTheDay"];
|
||||||
|
this->messageOfTheDay = messageOfTheDay.Value();
|
||||||
|
notifyMessageOfTheDay();
|
||||||
|
|
||||||
|
//Check for updates
|
||||||
|
json::Object versions = objDocument["Updates"];
|
||||||
|
|
||||||
|
json::Object stableVersion = versions["Stable"];
|
||||||
|
json::Object betaVersion = versions["Beta"];
|
||||||
|
json::Object snapshotVersion = versions["Snapshot"];
|
||||||
|
|
||||||
json::Number stableMajor = stableVersion["Major"];
|
json::Number stableMajor = stableVersion["Major"];
|
||||||
json::Number stableMinor = stableVersion["Minor"];
|
json::Number stableMinor = stableVersion["Minor"];
|
||||||
@ -580,6 +612,14 @@ void Client::notifyUpdateAvailable()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Client::notifyMessageOfTheDay()
|
||||||
|
{
|
||||||
|
for (std::vector<ClientListener*>::iterator iterator = listeners.begin(), end = listeners.end(); iterator != end; ++iterator)
|
||||||
|
{
|
||||||
|
(*iterator)->NotifyMessageOfTheDay(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Client::notifyAuthUserChanged()
|
void Client::notifyAuthUserChanged()
|
||||||
{
|
{
|
||||||
for (std::vector<ClientListener*>::iterator iterator = listeners.begin(), end = listeners.end(); iterator != end; ++iterator)
|
for (std::vector<ClientListener*>::iterator iterator = listeners.begin(), end = listeners.end(); iterator != end; ++iterator)
|
||||||
|
@ -46,6 +46,8 @@ class ThumbnailListener;
|
|||||||
class ClientListener;
|
class ClientListener;
|
||||||
class Client: public Singleton<Client> {
|
class Client: public Singleton<Client> {
|
||||||
private:
|
private:
|
||||||
|
std::string messageOfTheDay;
|
||||||
|
|
||||||
void * versionCheckRequest;
|
void * versionCheckRequest;
|
||||||
bool updateAvailable;
|
bool updateAvailable;
|
||||||
UpdateInfo updateInfo;
|
UpdateInfo updateInfo;
|
||||||
@ -71,6 +73,7 @@ private:
|
|||||||
static vector<std::string> explodePropertyString(std::string property);
|
static vector<std::string> explodePropertyString(std::string property);
|
||||||
void notifyUpdateAvailable();
|
void notifyUpdateAvailable();
|
||||||
void notifyAuthUserChanged();
|
void notifyAuthUserChanged();
|
||||||
|
void notifyMessageOfTheDay();
|
||||||
|
|
||||||
//Config file handle
|
//Config file handle
|
||||||
json::Object configDocument;
|
json::Object configDocument;
|
||||||
@ -90,6 +93,9 @@ public:
|
|||||||
|
|
||||||
std::vector<unsigned char> ReadFile(std::string filename);
|
std::vector<unsigned char> ReadFile(std::string filename);
|
||||||
|
|
||||||
|
void SetMessageOfTheDay(std::string message);
|
||||||
|
std::string GetMessageOfTheDay();
|
||||||
|
|
||||||
void Initialise(std::string proxyString);
|
void Initialise(std::string proxyString);
|
||||||
void SetProxy(std::string proxy);
|
void SetProxy(std::string proxy);
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ public:
|
|||||||
|
|
||||||
virtual void NotifyUpdateAvailable(Client * sender) {}
|
virtual void NotifyUpdateAvailable(Client * sender) {}
|
||||||
virtual void NotifyAuthUserChanged(Client * sender) {}
|
virtual void NotifyAuthUserChanged(Client * sender) {}
|
||||||
|
virtual void NotifyMessageOfTheDay(Client * sender) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ SearchView::SearchView():
|
|||||||
previousButton = new ui::Button(ui::Point(1, YRES+MENUSIZE-18), ui::Point(50, 16), "\x96 Prev");
|
previousButton = new ui::Button(ui::Point(1, YRES+MENUSIZE-18), ui::Point(50, 16), "\x96 Prev");
|
||||||
infoLabel = new ui::Label(ui::Point(51, YRES+MENUSIZE-18), ui::Point(XRES+BARSIZE-102, 16), "Loading...");
|
infoLabel = new ui::Label(ui::Point(51, YRES+MENUSIZE-18), ui::Point(XRES+BARSIZE-102, 16), "Loading...");
|
||||||
tagsLabel = new ui::Label(ui::Point(51, YRES+MENUSIZE-18), ui::Point(XRES+BARSIZE-102, 16), "\boPopular Tags:");
|
tagsLabel = new ui::Label(ui::Point(51, YRES+MENUSIZE-18), ui::Point(XRES+BARSIZE-102, 16), "\boPopular Tags:");
|
||||||
|
motdLabel = new ui::Label(ui::Point(51, YRES+MENUSIZE-18), ui::Point(XRES+BARSIZE-102, 16), Client::Ref().GetMessageOfTheDay());
|
||||||
|
|
||||||
class SearchAction : public ui::TextboxAction
|
class SearchAction : public ui::TextboxAction
|
||||||
{
|
{
|
||||||
@ -215,6 +216,11 @@ SearchView::SearchView():
|
|||||||
CheckAccess();
|
CheckAccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SearchView::NotifyMessageOfTheDay(Client * sender)
|
||||||
|
{
|
||||||
|
motdLabel->SetText(sender->GetMessageOfTheDay());
|
||||||
|
}
|
||||||
|
|
||||||
void SearchView::doSearch()
|
void SearchView::doSearch()
|
||||||
{
|
{
|
||||||
c->DoSearch(searchField->GetText());
|
c->DoSearch(searchField->GetText());
|
||||||
@ -383,6 +389,9 @@ void SearchView::NotifySaveListChanged(SearchModel * sender)
|
|||||||
vector<pair<string, int> > tags = sender->GetTagList();
|
vector<pair<string, int> > tags = sender->GetTagList();
|
||||||
//string messageOfTheDay = sender->GetMessageOfTheDay();
|
//string messageOfTheDay = sender->GetMessageOfTheDay();
|
||||||
|
|
||||||
|
RemoveComponent(motdLabel);
|
||||||
|
motdLabel->SetParentWindow(NULL);
|
||||||
|
|
||||||
RemoveComponent(tagsLabel);
|
RemoveComponent(tagsLabel);
|
||||||
tagsLabel->SetParentWindow(NULL);
|
tagsLabel->SetParentWindow(NULL);
|
||||||
|
|
||||||
@ -460,6 +469,9 @@ void SearchView::NotifySaveListChanged(SearchModel * sender)
|
|||||||
|
|
||||||
AddComponent(tagsLabel);
|
AddComponent(tagsLabel);
|
||||||
tagsLabel->Position.Y = tagYOffset-16;
|
tagsLabel->Position.Y = tagYOffset-16;
|
||||||
|
|
||||||
|
AddComponent(motdLabel);
|
||||||
|
motdLabel->Position.Y = tagYOffset-28;
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonWidth = (buttonAreaWidth/savesX) - buttonPadding*2;
|
buttonWidth = (buttonAreaWidth/savesX) - buttonPadding*2;
|
||||||
|
@ -28,6 +28,7 @@ private:
|
|||||||
ui::Textbox * searchField;
|
ui::Textbox * searchField;
|
||||||
ui::Label * infoLabel;
|
ui::Label * infoLabel;
|
||||||
ui::Label * tagsLabel;
|
ui::Label * tagsLabel;
|
||||||
|
ui::Label * motdLabel;
|
||||||
ui::Button * sortButton;
|
ui::Button * sortButton;
|
||||||
ui::Button * ownButton;
|
ui::Button * ownButton;
|
||||||
ui::Spinner * loadingSpinner;
|
ui::Spinner * loadingSpinner;
|
||||||
@ -46,6 +47,7 @@ public:
|
|||||||
void NotifyShowOwnChanged(SearchModel * sender);
|
void NotifyShowOwnChanged(SearchModel * sender);
|
||||||
void NotifyShowFavouriteChanged(SearchModel * sender);
|
void NotifyShowFavouriteChanged(SearchModel * sender);
|
||||||
void NotifyAuthUserChanged(Client * sender);
|
void NotifyAuthUserChanged(Client * sender);
|
||||||
|
void NotifyMessageOfTheDay(Client * sender);
|
||||||
void CheckAccess();
|
void CheckAccess();
|
||||||
virtual void OnTryOkay(OkayMethod method);
|
virtual void OnTryOkay(OkayMethod method);
|
||||||
SearchView();
|
SearchView();
|
||||||
|
Loading…
Reference in New Issue
Block a user