diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-12-09 12:05:27 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-12-09 12:05:27 (GMT) |
| commit | 38862a78d119d4ac8cd8495436e75d00f3ee896e (patch) | |
| tree | ea1e21878adde1bda829454049c73e92f1cab513 /src/client/Client.cpp | |
| parent | 6478ed121ce17cf7d7beaab2deb1953da63d283d (diff) | |
| download | powder-38862a78d119d4ac8cd8495436e75d00f3ee896e.zip powder-38862a78d119d4ac8cd8495436e75d00f3ee896e.tar.gz | |
New Conversation notifications
Diffstat (limited to 'src/client/Client.cpp')
| -rw-r--r-- | src/client/Client.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/client/Client.cpp b/src/client/Client.cpp index e446f73..525de77 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -545,6 +545,17 @@ std::string Client::GetMessageOfTheDay() return messageOfTheDay; } +void Client::AddServerNotification(std::pair<std::string, std::string> notification) +{ + serverNotifications.push_back(notification); + notifyNewNotification(notification); +} + +std::vector<std::pair<std::string, std::string> > Client::GetServerNotifications() +{ + return serverNotifications; +} + void Client::Tick() { //Check thumbnail queue @@ -579,6 +590,18 @@ void Client::Tick() SetAuthUser(User(0, "")); } + //Notifications from server + json::Array notificationsArray = objDocument["Notifications"]; + for(int j = 0; j < notificationsArray.Size(); j++) + { + json::String notificationLink = notificationsArray[j]["Link"]; + json::String notificationText = notificationsArray[j]["Text"]; + + std::pair<std::string, std::string> item = std::pair<std::string, std::string>(notificationText.Value(), notificationLink.Value()); + AddServerNotification(item); + } + + //MOTD json::String messageOfTheDay = objDocument["MessageOfTheDay"]; this->messageOfTheDay = messageOfTheDay.Value(); @@ -673,6 +696,14 @@ void Client::notifyAuthUserChanged() } } +void Client::notifyNewNotification(std::pair<std::string, std::string> notification) +{ + for (std::vector<ClientListener*>::iterator iterator = listeners.begin(), end = listeners.end(); iterator != end; ++iterator) + { + (*iterator)->NotifyNewNotification(this, notification); + } +} + void Client::AddListener(ClientListener * listener) { listeners.push_back(listener); @@ -1090,6 +1121,17 @@ LoginStatus Client::Login(std::string username, std::string password, User & use json::String sessionIDTemp = objDocument["SessionID"]; json::String sessionKeyTemp = objDocument["SessionKey"]; json::String userElevationTemp = objDocument["Elevation"]; + + json::Array notificationsArray = objDocument["Notifications"]; + for(int j = 0; j < notificationsArray.Size(); j++) + { + json::String notificationLink = notificationsArray[j]["Link"]; + json::String notificationText = notificationsArray[j]["Text"]; + + std::pair<std::string, std::string> item = std::pair<std::string, std::string>(notificationText.Value(), notificationLink.Value()); + AddServerNotification(item); + } + user.Username = username; user.ID = userIDTemp.Value(); user.SessionID = sessionIDTemp.Value(); |
