18#ifndef HEADER_NEWS_MANAGER_HPP
19#define HEADER_NEWS_MANAGER_HPP
31#include "utils/can_be_deleted.hpp"
32#include "utils/synchronised.hpp"
59 NewsMessage(
const core::stringw &m,
int id,
bool important=
false)
104 std::thread m_download_thread;
108 const std::string &filename);
120 return m_news_manager;
123 static bool isRunning() {
return m_news_manager != NULL; }
125 static void deallocate()
129 delete m_news_manager;
130 m_news_manager = NULL;
138 void init(
bool force_refresh);
151 void joinDownloadThreadIfExit()
153 if (CanBeDeleted::canBeDeletedNow() && m_download_thread.joinable())
154 m_download_thread.join();
A simple class that a adds a function to wait with a timeout for a class to be ready to be deleted.
Definition: can_be_deleted.hpp:38
Definition: news_manager.hpp:47
const core::stringw & getNews() const
Returns the news message.
Definition: news_manager.hpp:67
int getDisplayCount() const
Returns the display count.
Definition: news_manager.hpp:73
bool m_important
True if this is an important (i.e.
Definition: news_manager.hpp:56
core::stringw m_news
The actual news message.
Definition: news_manager.hpp:49
int m_message_id
A message id used to store some information in the user config file.
Definition: news_manager.hpp:52
bool isImportant() const
Returns if this is an important message.
Definition: news_manager.hpp:77
int getMessageId() const
Returns the news id.
Definition: news_manager.hpp:71
void setDisplayCount(int n)
Sets the display count for this message.
Definition: news_manager.hpp:75
int m_display_count
Counts how often a message has been displayed.
Definition: news_manager.hpp:54
void increaseDisplayCount()
Increases how often this message was being displayed.
Definition: news_manager.hpp:69
Definition: news_manager.hpp:40
bool conditionFulfilled(const std::string &cond)
Checks if the given condition list are all fulfilled.
Definition: news_manager.cpp:448
static std::string m_news_filename
The name of the news file on the remote server.
Definition: news_manager.hpp:81
void checkRedirect(const XMLNode *xml)
Checks if a redirect is received, causing a new server to be used for downloading addons.
Definition: news_manager.cpp:223
core::stringw m_all_news_messages
A single string that concatenats all news messages, separated by " +++ ".
Definition: news_manager.hpp:91
int m_current_news_message
Index of the current news message that is being displayed.
Definition: news_manager.hpp:86
void setErrorMessage(const core::stringw &s)
Sets an error message that is displayed instead of any news message.
Definition: news_manager.hpp:143
Synchronised< core::stringw > m_error_message
A high priority error message that is shown instead of any news message (usually indicating connectio...
Definition: news_manager.hpp:99
std::vector< int > m_saved_display_count
Stores the news message display count from the user config file.
Definition: news_manager.hpp:95
const core::stringw getNextNewsMessage()
Returns the next loaded news message.
Definition: news_manager.cpp:404
void updateNews(const XMLNode *xml, const std::string &filename)
Updates the 'news' string to be displayed in the main menu.
Definition: news_manager.cpp:286
void init(bool force_refresh)
This function initialises the data for the news manager.
Definition: news_manager.cpp:79
void downloadNews()
This function submits request which will download the m_news_filename file if necessary.
Definition: news_manager.cpp:103
void clearErrorMessage()
Clears the error message.
Definition: news_manager.hpp:149
static NewsManager * get()
Singleton: if necessary create and get the news managers.
Definition: news_manager.hpp:116
const core::stringw getImportantMessage()
Returns the important message with the smallest id that has not been shown, or NULL if no important (...
Definition: news_manager.cpp:369
bool m_force_refresh
True when all .xml files should be re-downloaded.
Definition: news_manager.hpp:102
void addNewsMessage(const core::stringw &s)
Add a news message.
Definition: news_manager.cpp:357
A variable that is automatically synchronised using pthreads mutex.
Definition: synchronised.hpp:28
void setAtomic(const TYPE &v)
Sets the value of this variable using a mutex.
Definition: synchronised.hpp:59
utility class used to parse XML files
Definition: xml_node.hpp:48