Commit 7b931b52 authored by Charlie Fenton's avatar Charlie Fenton Committed by Oliver Bock

Mgr: Display a message and "Retry now" button if some images or other items...

Mgr: Display a message and "Retry now" button if some images or other items within notices failed to load from the Internet; if network activity is suspended, say so in the message
parent d95bf694
......@@ -7835,6 +7835,9 @@ Charlie 21 Dec 2012
notices unless they are already in our cache or in the Windows cache.
- Mgr: Clear our internal Internet cache when selecting a different computer;
when removing entries from hash table, delete data to avoid memory leaks.
- Mgr: Display a message and "Retry now" button if some images or other items
within notices failed to load from the Internet; if network activity is
suspended, say so in the message.
clientgui/
BOINCInternetFSHandler.cpp,.h
......
......@@ -529,8 +529,8 @@ wxFSFile* CBOINCInternetFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wx
int retval = pDoc->GetCoreClientStatus(status);
#ifdef __WXMSW__
// Use WinInet fucntions only if network activity not suspended
// or if the result is already in the Windows internet cache
// Use WinInet functions only if network activity not suspended
// or if the result is already in the Windows Internet cache
bool CanUseWinInet = true;
if ((!retval) && status.network_suspend_reason) {
unsigned char cache_info[2048];
......@@ -626,7 +626,7 @@ void CBOINCInternetFSHandler::UnchacheMissingItems() {
m_Hash->BeginFind();
wxHashTable::Node* node = m_Hash->Next();
for(;;) {
if (node == NULL) return; // End of cache
if (node == NULL) break; // End of cache
MemFSHashObj* obj = (MemFSHashObj*)node->GetData();
// We must get next node before deleting this one
node = m_Hash->Next();
......@@ -635,6 +635,7 @@ void CBOINCInternetFSHandler::UnchacheMissingItems() {
m_Hash->Delete(obj->m_Key);
}
}
m_bMissingItems = false;
}
......@@ -642,13 +643,14 @@ void CBOINCInternetFSHandler::ClearCache() {
m_Hash->BeginFind();
wxHashTable::Node* node = m_Hash->Next();
for(;;) {
if (node == NULL) return; // End of cache
if (node == NULL) break; // End of cache
MemFSHashObj* obj = (MemFSHashObj*)node->GetData();
// We must get next node before deleting this one
node = m_Hash->Next();
delete obj;
m_Hash->Delete(obj->m_Key);
}
m_bMissingItems = false;
}
......
......@@ -30,6 +30,7 @@ public:
virtual bool CanOpen(const wxString& strLocation);
virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& strLocation);
bool ItemsFailedToLoad() { return m_bMissingItems; }
void UnchacheMissingItems();
void ClearCache();
void ShutDown();
......
......@@ -103,6 +103,7 @@
#define ID_PIECTRL_RESOURCEUTILIZATIONVIEWTOTAL 7005
#define ID_LIST_STATISTICSVIEW 7006
#define ID_LIST_NOTIFICATIONSVIEW 7007
#define ID_LIST_RELOADNOTICES 7008
#define ID_TASK_BASE 8000
#define ID_TASK_NOTIFICATIONSVIEW 8000
#define ID_TASK_PROJECTSVIEW 8001
......
......@@ -412,11 +412,11 @@ bool CNoticeListCtrl::Create( wxWindow* parent )
#endif
////@end CNoticeListCtrl creation
// Display the fetching notices message until we have notices
// Display the fetching notices message until we have notices
// to display or have determined that there are no notices.
m_bDisplayFetchingNotices = false;
m_bDisplayEmptyNotice = true;
m_bComputerChanged = false;
m_bNeedsReloading = false;
return TRUE;
}
......@@ -540,7 +540,7 @@ wxString CNoticeListCtrl::OnGetItem(size_t i) const {
void CNoticeListCtrl::Clear() {
SetItemCount(0);
m_bComputerChanged = true;
m_bNeedsReloading = true;
UpdateUI();
Refresh();
}
......@@ -560,13 +560,13 @@ bool CNoticeListCtrl::UpdateUI()
// Call Freeze() / Thaw() only when actually needed;
// otherwise it causes unnecessary redraws
int noticeCount = pDoc->GetNoticeCount();
if ((noticeCount < 0) || (!pDoc->IsConnected()) || m_bComputerChanged) {
if ((noticeCount < 0) || (!pDoc->IsConnected()) || m_bNeedsReloading) {
if (GetItemCount()) {
SetItemCount(0);
}
m_bDisplayFetchingNotices = true;
m_bDisplayEmptyNotice = false;
m_bComputerChanged = false;
m_bNeedsReloading = false;
return true;
}
......@@ -576,7 +576,7 @@ bool CNoticeListCtrl::UpdateUI()
}
m_bDisplayFetchingNotices = false;
m_bDisplayEmptyNotice = true;
m_bComputerChanged = false;
m_bNeedsReloading = false;
return true;
}
......
......@@ -119,7 +119,7 @@ public:
bool m_bDisplayFetchingNotices;
bool m_bDisplayEmptyNotice;
private:
bool m_bComputerChanged;
bool m_bNeedsReloading;
#ifdef __WXMAC__
CNoticeListCtrlAccessible* m_accessible;
#endif
......
......@@ -39,6 +39,7 @@ IMPLEMENT_DYNAMIC_CLASS(CViewNotices, CBOINCBaseView)
BEGIN_EVENT_TABLE (CViewNotices, CBOINCBaseView)
EVT_NOTICELIST_ITEM_DISPLAY(CViewNotices::OnLinkClicked)
EVT_BUTTON( ID_LIST_RELOADNOTICES, CViewNotices::OnRetryButton )
END_EVENT_TABLE ()
......@@ -52,12 +53,32 @@ CViewNotices::CViewNotices(wxNotebook* pNotebook) :
//
// Setup View
//
wxFlexGridSizer* itemFlexGridSizer = new wxFlexGridSizer(1, 1, 0);
wxFlexGridSizer* itemReloadButtonSizer = new wxFlexGridSizer(1, 2, 0, 0);
itemReloadButtonSizer->AddGrowableCol(1);
m_ReloadNoticesText = new wxStaticText(
this, wxID_ANY, wxEmptyString,
wxDefaultPosition, wxDefaultSize, 0
);
itemReloadButtonSizer->Add(m_ReloadNoticesText, 1, wxALL, 5);
m_ReloadNoticesButton = new wxButton(
this, ID_LIST_RELOADNOTICES,
_("Retry now"),
wxDefaultPosition, wxDefaultSize, 0
);
itemReloadButtonSizer->Add(m_ReloadNoticesButton, 1, wxALL, 5);
wxFlexGridSizer* itemFlexGridSizer = new wxFlexGridSizer(2, 1, 1, 0);
wxASSERT(itemFlexGridSizer);
itemFlexGridSizer->AddGrowableRow(0);
itemFlexGridSizer->AddGrowableRow(1);
itemFlexGridSizer->AddGrowableCol(0);
itemFlexGridSizer->Add(itemReloadButtonSizer, 1, wxGROW|wxALL, 1);
m_pHtmlListPane = new CNoticeListCtrl(this);
wxASSERT(m_pHtmlListPane);
......@@ -77,6 +98,11 @@ CViewNotices::CViewNotices(wxNotebook* pNotebook) :
wxPoint(20, 20), wxDefaultSize, 0
);
m_NoNoticesText->Hide();
m_ReloadNoticesText->Hide();
m_ReloadNoticesButton->Hide();
m_bMissingItems = false;
m_bNetworkSuspended = -1;
}
......@@ -126,11 +152,15 @@ void CViewNotices::OnListRender(wxTimerEvent& WXUNUSED(event)) {
static bool s_bInProgress = false;
static wxString strLastMachineName = wxEmptyString;
wxString strNewMachineName = wxEmptyString;
bool bMissingItems;
CC_STATUS status;
CMainDocument* pDoc = wxGetApp().GetDocument();
wxFileSystemHandler *internetFSHandler = wxGetApp().GetInternetFSHandler();
wxASSERT(pDoc);
wxASSERT(m_pHtmlListPane);
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
wxASSERT(internetFSHandler);
if (s_bInProgress) return;
s_bInProgress = true;
......@@ -141,14 +171,43 @@ void CViewNotices::OnListRender(wxTimerEvent& WXUNUSED(event)) {
strLastMachineName = strNewMachineName;
m_FetchingNoticesText->Show();
m_NoNoticesText->Hide();
wxFileSystemHandler *internetFSHandler = wxGetApp().GetInternetFSHandler();
((CBOINCInternetFSHandler*)internetFSHandler)->ClearCache();
m_pHtmlListPane->Clear();
if (m_bMissingItems) {
m_ReloadNoticesText->Hide();
m_ReloadNoticesButton->Hide();
m_bMissingItems = false;
Layout();
}
}
}
// Don't call Freeze() / Thaw() here because it causes an unnecessary redraw
m_pHtmlListPane->UpdateUI();
bMissingItems = ((CBOINCInternetFSHandler*)internetFSHandler)->ItemsFailedToLoad();
if (bMissingItems) {
int retval = pDoc->GetCoreClientStatus(status);
if ((!retval) && (m_bNetworkSuspended != status.network_suspend_reason)) {
if (status.network_suspend_reason) {
m_ReloadNoticesText->SetLabel(_(
"One or more items failed to load from the Internet\nbecause Network activity is suspended."));
} else {
m_ReloadNoticesText->SetLabel(_("One or more items failed to load from the Internet."));
}
}
}
if ((bMissingItems != m_bMissingItems) ||
(m_bNetworkSuspended != status.network_suspend_reason)
) {
m_ReloadNoticesText->Show(bMissingItems);
m_ReloadNoticesButton->Show(bMissingItems);
Layout();
m_bMissingItems = bMissingItems;
m_bNetworkSuspended = status.network_suspend_reason;
}
m_FetchingNoticesText->Show(m_pHtmlListPane->m_bDisplayFetchingNotices);
m_NoNoticesText->Show(m_pHtmlListPane->m_bDisplayEmptyNotice);
pDoc->UpdateUnreadNoticeState();
......@@ -166,6 +225,15 @@ void CViewNotices::OnLinkClicked( NoticeListCtrlEvent& event ) {
}
void CViewNotices::OnRetryButton( wxCommandEvent& event ) {
m_ReloadNoticesText->Hide();
m_ReloadNoticesButton->Hide();
m_bMissingItems = false;
Layout();
ReloadNotices();
}
void CViewNotices::ReloadNotices() {
wxFileSystemHandler *internetFSHandler = wxGetApp().GetInternetFSHandler();
if (internetFSHandler) {
......
......@@ -47,15 +47,21 @@ public:
void ReloadNotices();
protected:
wxStaticText* m_ReloadNoticesText;
wxButton* m_ReloadNoticesButton;
CNoticeListCtrl* m_pHtmlListPane;
wxStaticText* m_FetchingNoticesText;
wxStaticText* m_NoNoticesText;
bool m_bMissingItems;
int m_bNetworkSuspended;
virtual bool OnSaveState( wxConfigBase* pConfig );
virtual bool OnRestoreState( wxConfigBase* pConfig );
virtual void OnListRender( wxTimerEvent& event );
void OnLinkClicked( NoticeListCtrlEvent& event );
void OnRetryButton( wxCommandEvent& event );
DECLARE_EVENT_TABLE()
};
......
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