12 #ifndef NETWORK_CONTENT_H 13 #define NETWORK_CONTENT_H 18 #if defined(ENABLE_NETWORK) 85 virtual bool Receive_SERVER_INFO(
Packet *p);
86 virtual bool Receive_SERVER_CONTENT(
Packet *p);
98 void OnReceiveData(
const char *data,
size_t length);
100 bool BeforeDownload();
101 void AfterDownload();
103 void DownloadSelectedContentHTTP(
const ContentIDList &content);
104 void DownloadSelectedContentFallback(
const ContentIDList &content);
107 static const int IDLE_TIMEOUT = 60 * 1000;
117 void RequestContentList(uint count,
const ContentID *content_ids);
118 void RequestContentList(
ContentVector *cv,
bool send_md5sum =
true);
120 void DownloadSelectedContent(uint &files, uint &bytes,
bool fallback =
false);
125 void SelectUpgrade();
Helper to mark the end of the types.
ContentVector infos
All content info we received.
const ContentInfo *const * ConstContentIterator
Iterator for the constant content vector.
SmallVector< ContentInfo *, 16 > ContentVector
Vector with content info.
ConstContentIterator Begin() const
Get the begin of the content inf iterator.
Basic functions to receive and send HTTP TCP packets.
Internal entity of a packet.
Socket handler for the content server connection.
SmallVector< char, 1024 > http_response
The HTTP response to the requests we've been doing.
virtual void OnFailure()
Callback for when the connection attempt failed.
Base socket handler for all Content TCP sockets.
Callbacks for notifying others about incoming data.
void ShowNetworkContentListWindow(ContentVector *cv=NULL, ContentType type1=CONTENT_TYPE_END, ContentType type2=CONTENT_TYPE_END)
Show the content list window with a given set of content.
const T * Begin() const
Get the pointer to the first item (const)
SmallVector< ContentCallback *, 2 > callbacks
Callbacks to notify "the world".
ContentID
Unique identifier for the content.
const T * End() const
Get the pointer behind the last valid item (const)
SmallVector< ContentID, 4 > ContentIDList
List of content IDs to (possibly) select.
bool isConnecting
Whether we're connecting.
void ShowMissingContentWindow(const GRFConfig *list)
Show the content list window with all missing grfs from the given list.
virtual void OnDisconnect()
Callback for when the connection got disconnected.
void AddCallback(ContentCallback *cb)
Add a callback to this class.
ConstContentIterator End() const
Get the end of the content inf iterator.
uint Length() const
Get the number of items in the list.
Information about GRF, used in the game and (part of it) in savegames.
uint32 lastActivity
The last time there was network activity.
virtual void OnDownloadProgress(const ContentInfo *ci, int bytes)
We have progress in the download of a file.
ConstContentIterator Get(uint32 index) const
Get the nth position of the content inf iterator.
virtual ~ContentCallback()
Silentium.
ContentIDList requested
ContentIDs we already requested (so we don't do it again)
SmallVector< const ContentInfo *, 16 > ConstContentVector
Vector with constant content info.
Connect to the content server.
const T * Find(const T &item) const
Search for the first occurrence of an item.
Basic functions to receive and send TCP packets to/from the content server.
ContentInfo ** ContentIterator
Iterator for the content vector.
uint Length() const
Get the number of content items we know locally.
ContentType
The values in the enum are important; they are used as database 'keys'.
void RemoveCallback(ContentCallback *cb)
Remove a callback.
Callback for when the HTTP handler has something to tell us.
bool Include(const T &item)
Tests whether a item is present in the vector, and appends it to the end if not.
void Erase(T *item)
Removes given item from this vector.
virtual void OnReceiveContentInfo(const ContentInfo *ci)
We received a content info.
ContentInfo * curInfo
Information about the currently downloaded file.
virtual void OnConnect(bool success)
Callback for when the connection has finished.
int http_response_index
Where we are, in the response, with handling it.
virtual void OnDownloadComplete(ContentID cid)
We have finished downloading a file.
const T * Get(uint index) const
Get the pointer to item "number" (const)
void Connect()
The actual connection function.
ClientNetworkContentSocketHandler _network_content_client
The client we use to connect to the server.
FILE * curFile
Currently downloaded file.
Container for all important information about a piece of content.