Commit c312dfd6 authored by Charlie Fenton's avatar Charlie Fenton Committed by Oliver Bock

Mgr: Add code to reload notices with images / items missing due to problems accessing their URLs

parent b37c7206
......@@ -7808,6 +7808,8 @@ Charlie 20 Dec 2012
- Mgr: Display "Fetching notices..." instead of "There are no notices"
while getting notices. Display "There are no notices" only if we
have actually determined there are no notices.
- Mgr: Add code to reload notices with images / items missing due to
problems accessing their URLs.
clientgui/
MainDocument.cpp,.h
......
......@@ -26,7 +26,7 @@
class MemFSHashObj : public wxObject
{
public:
MemFSHashObj(wxInputStream* stream, const wxString& mime)
MemFSHashObj(wxInputStream* stream, const wxString& mime, const wxString& key)
{
if (stream) {
wxMemoryOutputStream out;
......@@ -38,6 +38,7 @@ public:
m_Len = 0;
m_Data = NULL;
}
m_Key = key;
m_MimeType = mime;
m_Time = wxDateTime::Now();
}
......@@ -51,6 +52,7 @@ public:
size_t m_Len;
wxString m_MimeType;
wxDateTime m_Time;
wxString m_Key;
DECLARE_NO_COPY_CLASS(MemFSHashObj)
};
......@@ -451,6 +453,7 @@ CBOINCInternetFSHandler::CBOINCInternetFSHandler() : wxFileSystemHandler()
{
m_InputStream = NULL;
b_ShuttingDown = false;
m_bMissingItems = false;
if (!m_Hash)
{
......@@ -533,7 +536,7 @@ wxFSFile* CBOINCInternetFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wx
strMIME = GetMimeTypeFromExt(strLocation);
}
obj = new MemFSHashObj(m_InputStream, strMIME);
obj = new MemFSHashObj(m_InputStream, strMIME, strLocation);
delete m_InputStream;
m_InputStream = NULL;
......@@ -542,6 +545,7 @@ wxFSFile* CBOINCInternetFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wx
// If we couldn't read image, then return NULL so
// image tag handler displays "broken image" bitmap
if (obj->m_Len == 0) {
m_bMissingItems = true;
return NULL;
}
......@@ -590,6 +594,21 @@ bool CBOINCInternetFSHandler::CheckHash(const wxString& strLocation)
}
void CBOINCInternetFSHandler::UnchacheMissingItems() {
m_Hash->BeginFind();
wxHashTable::Node* node = m_Hash->Next();
for(;;) {
if (node == NULL) return;
MemFSHashObj* obj = (MemFSHashObj*)node->GetData();
// We must get next node before deleting this one
node = m_Hash->Next();
if (obj->m_Len == 0) {
m_Hash->Delete(obj->m_Key);
}
}
}
void CBOINCInternetFSHandler::ShutDown() {
b_ShuttingDown = true;
#ifdef __WXMSW__
......
......@@ -30,12 +30,16 @@ public:
virtual bool CanOpen(const wxString& strLocation);
virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& strLocation);
void UnchacheMissingItems();
void ShutDown();
protected:
static bool CheckHash(const wxString& strLocation);
static wxHashTable *m_Hash;
wxInputStream *m_InputStream;
private:
bool m_bMissingItems;
};
#endif // _WX_FS_CACHEDINTERNET_H_
......
......@@ -27,6 +27,7 @@
#include "BOINCTaskCtrl.h"
#include "ViewNotices.h"
#include "NoticeListCtrl.h"
#include "BOINCInternetFSHandler.h"
#include "Events.h"
#include "error_numbers.h"
......@@ -160,3 +161,11 @@ void CViewNotices::OnLinkClicked( NoticeListCtrlEvent& event ) {
}
}
void CViewNotices::ReloadNotices() {
wxFileSystemHandler *internetFSHandler = wxGetApp().GetInternetFSHandler();
if (internetFSHandler) {
((CBOINCInternetFSHandler*)internetFSHandler)->UnchacheMissingItems();
m_pHtmlListPane->Clear();
}
}
\ No newline at end of file
......@@ -44,6 +44,7 @@ public:
virtual const char** GetViewIcon();
virtual const int GetViewRefreshRate();
virtual const int GetViewCurrentViewPage();
void ReloadNotices();
protected:
CNoticeListCtrl* m_pHtmlListPane;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment