Skip to content

Commit

Permalink
Mgr: Allow existing to retrieve images or other items from the Intern…
Browse files Browse the repository at this point in the history
…et even if network activity is suspended. (But client won't get new notices.)
  • Loading branch information
Charlie Fenton authored and Oliver Bock committed Mar 4, 2013
1 parent a31f4df commit 9254469
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 54 deletions.
4 changes: 4 additions & 0 deletions checkin_notes
Original file line number Diff line number Diff line change
Expand Up @@ -7859,5 +7859,9 @@ David 21 Dec 2012
Charlie 22 Dec 2012
- Mgr: When removing entries from our hash table, delete data to avoid memory
leaks.
-Mgr: Allow existing to retrieve images or other items from the Internet even
if network activity is suspended. (But client won't get new notices.)

clientgui/
BOINCInternetFSHandler.cpp
ViewNotices.cpp,.h
35 changes: 3 additions & 32 deletions clientgui/BOINCInternetFSHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,40 +524,11 @@ wxFSFile* CBOINCInternetFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wx
wxURL url(right);
if (url.GetError() == wxURL_NOERR)
{
CC_STATUS status;
CMainDocument* pDoc = wxGetApp().GetDocument();
int retval = pDoc->GetCoreClientStatus(status);

#ifdef __WXMSW__
// 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];
DWORD len = sizeof(cache_info);
if (!GetUrlCacheEntryInfo(right.c_str(),
(LPINTERNET_CACHE_ENTRY_INFO)cache_info,
&len)
) {
CanUseWinInet = false;
}
}

if (CanUseWinInet) {
wxWinINetURL * winURL = new wxWinINetURL;
m_InputStream = winURL->GetInputStream(&url);
} else {
m_InputStream = NULL;
}
wxWinINetURL * winURL = new wxWinINetURL;
m_InputStream = winURL->GetInputStream(&url);
#else
// Mac OS does not cache BOINC's Internet accesses
// so just check if network activity os suspended
// TODO: Does Linux OS cache BOINC's Internet accesses?
if (retval || status.network_suspend_reason) {
m_InputStream = NULL;
} else {
m_InputStream = url.GetInputStream();
}
m_InputStream = url.GetInputStream();
#endif
strMIME = url.GetProtocol().GetContentType();
if (strMIME == wxEmptyString) {
Expand Down
26 changes: 5 additions & 21 deletions clientgui/ViewNotices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ CViewNotices::CViewNotices(wxNotebook* pNotebook) :
wxFlexGridSizer* itemReloadButtonSizer = new wxFlexGridSizer(1, 2, 0, 0);
itemReloadButtonSizer->AddGrowableCol(1);

m_ReloadNoticesText = new wxStaticText(
this, wxID_ANY, wxEmptyString,
wxDefaultPosition, wxDefaultSize, 0
);
m_ReloadNoticesText = new wxStaticText(this, wxID_ANY,
_("One or more items failed to load from the Internet."),
wxDefaultPosition, wxDefaultSize, 0
);

itemReloadButtonSizer->Add(m_ReloadNoticesText, 1, wxALL, 5);

Expand Down Expand Up @@ -102,7 +102,6 @@ CViewNotices::CViewNotices(wxNotebook* pNotebook) :
m_ReloadNoticesButton->Hide();

m_bMissingItems = false;
m_bNetworkSuspended = -1;
}


Expand Down Expand Up @@ -186,26 +185,11 @@ void CViewNotices::OnListRender(wxTimerEvent& WXUNUSED(event)) {
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)
) {
if (bMissingItems != m_bMissingItems) {
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);
Expand Down
1 change: 0 additions & 1 deletion clientgui/ViewNotices.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class CViewNotices : public CBOINCBaseView {
wxStaticText* m_FetchingNoticesText;
wxStaticText* m_NoNoticesText;
bool m_bMissingItems;
int m_bNetworkSuspended;

virtual bool OnSaveState( wxConfigBase* pConfig );
virtual bool OnRestoreState( wxConfigBase* pConfig );
Expand Down

0 comments on commit 9254469

Please sign in to comment.