Skip to content

Commit

Permalink
- MGR: If the simple GUI received a notification event,
Browse files Browse the repository at this point in the history
        display the messages dialog.
    - MGR: The simple GUI wasn't restoring state properly
        thereby causing the reminder frequency to be set to
        zero and preventing any reminders from being displayed.
    - MGR: Rework the notices code so the document doesn't
        make any assumtions about the UI.
    - MGR: Fix a bug in the Linux notification window code.
        Synchronize event behavior with Windows.

    clientgui/
        AdvancedFrame.cpp, .h
        BOINCBaseFrame.cpp
        BOINCTaskBar.cpp, .h
        MainDocument.cpp, .h
        sg_BoincSimpleGUI.cpp, .h
        sg_DlgMessages.cpp
        sg_ProjectsComponent.cpp, .h
        ViewNotices.cpp
    clientgui/gtk/
        taskbarex.cpp

svn path=/trunk/boinc/; revision=22040
  • Loading branch information
romw committed Jul 22, 2010
1 parent fac7537 commit 371c53e
Show file tree
Hide file tree
Showing 15 changed files with 150 additions and 129 deletions.
23 changes: 23 additions & 0 deletions checkin_notes
Original file line number Diff line number Diff line change
Expand Up @@ -5463,3 +5463,26 @@ David 22 Jul 2010

David 22 Jul 2010
- rename cal.h to cal_boinc.h to avoid name conflict

Rom 22 July 2010
- MGR: If the simple GUI received a notification event,
display the messages dialog.
- MGR: The simple GUI wasn't restoring state properly
thereby causing the reminder frequency to be set to
zero and preventing any reminders from being displayed.
- MGR: Rework the notices code so the document doesn't
make any assumtions about the UI.
- MGR: Fix a bug in the Linux notification window code.
Synchronize event behavior with Windows.

clientgui/
AdvancedFrame.cpp, .h
BOINCBaseFrame.cpp
BOINCTaskBar.cpp, .h
MainDocument.cpp, .h
sg_BoincSimpleGUI.cpp, .h
sg_DlgMessages.cpp
sg_ProjectsComponent.cpp, .h
ViewNotices.cpp
clientgui/gtk/
taskbarex.cpp
48 changes: 17 additions & 31 deletions clientgui/AdvancedFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,32 +769,6 @@ bool CAdvancedFrame::CreateNotebookPage( CBOINCBaseView* pwndNewNotebookPage) {
}


void CAdvancedFrame::UpdateNoticesTabText() {
wxWindow* pwndNotebookPage = NULL;
CBOINCBaseView* pView = NULL;
wxString strTabText;
CMainDocument* pDoc = wxGetApp().GetDocument();

wxASSERT(pDoc);
wxASSERT(wxDynamicCast(pDoc, CMainDocument));

wxASSERT(m_pNotebook);
pwndNotebookPage = m_pNotebook->GetPage(ID_ADVNOTICESVIEW - ID_ADVVIEWBASE);
wxASSERT(pwndNotebookPage);
pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView);
wxASSERT(pView);

int count = pDoc->GetUnreadNoticeCount();
if (count) {
strTabText.Printf(wxT("%s (%d)"), pView->GetViewDisplayName().c_str(), count);
} else {
strTabText = pView->GetViewDisplayName();
}

m_pNotebook->SetPageText(ID_ADVNOTICESVIEW - ID_ADVVIEWBASE, strTabText);
}


bool CAdvancedFrame::CreateStatusbar() {
wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::CreateStatusbar - Function Begin"));

Expand Down Expand Up @@ -1670,18 +1644,30 @@ void CAdvancedFrame::OnRefreshView(CFrameEvent& WXUNUSED(event)) {
wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnRefreshView - Function Begin"));

if (IsShown()) {
wxWindow* pwndNotebookPage = NULL;
CMainDocument* pDoc = wxGetApp().GetDocument();
CBOINCBaseView* pView = NULL;
wxTimerEvent timerEvent;
wxString strTabTitle = wxEmptyString;
int iCount = 0;

wxASSERT(m_pNotebook);
wxASSERT(pDoc);
wxASSERT(wxDynamicCast(pDoc, CMainDocument));

pwndNotebookPage = m_pNotebook->GetPage(m_pNotebook->GetSelection());
wxASSERT(pwndNotebookPage);
// Force update the notice tab text
pView = wxDynamicCast(m_pNotebook->GetPage(ID_ADVNOTICESVIEW - ID_ADVVIEWBASE), CBOINCBaseView);
iCount = pDoc->GetUnreadNoticeCount();
if (iCount) {
strTabTitle.Printf(wxT("%s (%d)"), pView->GetViewDisplayName().c_str(), iCount);
} else {
strTabTitle = pView->GetViewDisplayName();
}

m_pNotebook->SetPageText(ID_ADVNOTICESVIEW - ID_ADVVIEWBASE, strTabTitle);

pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView);
wxASSERT(pView);

// Update current tab contents
pView = wxDynamicCast(m_pNotebook->GetPage(m_pNotebook->GetSelection()), CBOINCBaseView);
pView->FireOnListRender(timerEvent);
}

Expand Down
1 change: 0 additions & 1 deletion clientgui/AdvancedFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ class CAdvancedFrame : public CBOINCBaseFrame
bool RepopulateNotebook();
bool CreateNotebookPage( CBOINCBaseView* pwndNewNotebookPage );
bool DeleteNotebook();
void UpdateNoticesTabText();
bool CreateStatusbar();
bool DeleteStatusbar();

Expand Down
4 changes: 2 additions & 2 deletions clientgui/BOINCBaseFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ bool CBOINCBaseFrame::SaveState() {
pConfig->SetPath(strBaseConfigLocation);

pConfig->Write(wxT("Language"), m_iSelectedLanguage);
pConfig->Write(wxT("ReminderFrequency"), m_iReminderFrequency);
pConfig->Write(wxT("ReminderFrequencyV2"), m_iReminderFrequency);

pConfig->Write(wxT("NetworkDialupConnectionName"), m_strNetworkDialupConnectionName);

Expand Down Expand Up @@ -752,7 +752,7 @@ bool CBOINCBaseFrame::RestoreState() {
pConfig->SetPath(strBaseConfigLocation);

pConfig->Read(wxT("Language"), &m_iSelectedLanguage, 0L);
pConfig->Read(wxT("ReminderFrequency"), &m_iReminderFrequency, 60L);
pConfig->Read(wxT("ReminderFrequencyV2"), &m_iReminderFrequency, 60L);

pConfig->Read(wxT("NetworkDialupConnectionName"), &m_strNetworkDialupConnectionName, wxEmptyString);

Expand Down
17 changes: 16 additions & 1 deletion clientgui/BOINCTaskBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ BEGIN_EVENT_TABLE(CTaskBarIcon, wxTaskBarIconEx)
EVT_TASKBAR_RIGHT_DOWN(CTaskBarIcon::OnRButtonDown)
EVT_TASKBAR_RIGHT_UP(CTaskBarIcon::OnRButtonUp)
EVT_TASKBAR_CONTEXT_USERCLICK(CTaskBarIcon::OnNotificationClick)
EVT_TASKBAR_BALLOON_TIMEOUT(CTaskBarIcon::OnNotificationTimeout)
#endif
EVT_MENU(ID_OPENBOINCMANAGER, CTaskBarIcon::OnOpen)
EVT_MENU(ID_OPENWEBSITE, CTaskBarIcon::OnOpenWebsite)
Expand Down Expand Up @@ -168,6 +169,20 @@ void CTaskBarIcon::OnNotificationClick(wxTaskBarIconExEvent& WXUNUSED(event)) {
}


void CTaskBarIcon::OnNotificationTimeout(wxTaskBarIconExEvent& WXUNUSED(event)) {
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnNotificationTimeout - Function Begin"));

CMainDocument* pDoc = wxGetApp().GetDocument();
wxASSERT(pDoc);
wxASSERT(wxDynamicCast(pDoc, CMainDocument));

ResetTaskBar();
pDoc->UpdateUnreadNoticeState();

wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnNotificationTimeout - Function End"));
}


void CTaskBarIcon::OnOpen(wxCommandEvent& WXUNUSED(event)) {
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnOpen - Function Begin"));

Expand Down Expand Up @@ -741,7 +756,7 @@ void CTaskBarIcon::UpdateNoticeStatus() {
) {

if (pDoc->GetUnreadNoticeCount()) {
#ifdef __WXMAC__
#ifdef __WXMAC__
// Delay notification while user is inactive
// NOTE: This API requires OS 10.4 or later
double idleTime = CGEventSourceSecondsSinceLastEventType (
Expand Down
1 change: 1 addition & 0 deletions clientgui/BOINCTaskBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class CTaskBarIcon : public wxTaskBarIconEx {
void OnReloadSkin(CTaskbarEvent& event);

void OnNotificationClick(wxTaskBarIconExEvent& event);
void OnNotificationTimeout(wxTaskBarIconExEvent& event);
void OnShutdown(wxTaskBarIconExEvent& event);
void OnLButtonDClick(wxTaskBarIconEvent& event);
void OnRButtonDown(wxTaskBarIconEvent& event);
Expand Down
107 changes: 42 additions & 65 deletions clientgui/MainDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,10 @@ CMainDocument::CMainDocument() : rpc(this) {
m_fProjectTotalResourceShare = 0.0;

m_iMessageSequenceNumber = 0;

m_iNoticeSequenceNumber = 0;
m_iLastReadNoticeSequenceNumber = -1;
m_iLastReadNoticeArrivalTime = 0.0;
m_iNumberUnreadNotices = 0;
m_dLastReadNoticeArrivalTime = 0.0;

m_dtCachedStateTimestamp = wxDateTime((time_t)0);
m_iGet_state_rpc_result = 0;
Expand Down Expand Up @@ -1789,9 +1789,6 @@ int CMainDocument::WorkAbort(char* url, char* name) {
// CMainDocument::HandleCompletedRPC() .
int CMainDocument::CachedNoticeUpdate() {
static bool in_this_func = false;
int unread = 0;
double lastReadArrivalTime = 0.0;
int i, n = GetNoticeCount();

if (in_this_func) return 0;
in_this_func = true;
Expand All @@ -1809,55 +1806,16 @@ int CMainDocument::CachedNoticeUpdate() {
goto done;
}

if (GetNoticeCount() > 0) {
if (notices.notices.size() > 0) {
m_iNoticeSequenceNumber = notices.notices[0]->seqno;

if (m_iLastReadNoticeSequenceNumber < 0) {
m_iLastReadNoticeSequenceNumber = 0; // Do this only once
RestoreUnreadNoticeInfo();
}

CBOINCBaseFrame* pFrame = wxGetApp().GetFrame();
if (!pFrame) goto done;
wxASSERT(wxDynamicCast(pFrame, CBOINCBaseFrame));

int currentTabView = pFrame->GetCurrentViewPage();
// Consider all notices as having been read if Notices tab is open
if ((currentTabView & (VW_NOTIF | VW_SMSG)) && wxGetApp().IsActive()) {
if (m_iLastReadNoticeSequenceNumber != m_iNoticeSequenceNumber) {
m_iLastReadNoticeSequenceNumber = m_iNoticeSequenceNumber;
m_iLastReadNoticeArrivalTime = notices.notices[0]->arrival_time;
SaveUnreadNoticeInfo();
}

} else { // Notices tab is not currently open

// Repeated / duplicate notices may be replaced with same sequence
// number, or they may be deleted and replaced with a higher
// sequence number. But they always have newer arrival times.
// Vector is in descending order of arrival times and sequence numbers.
for (i=0; i<n; ++i) {
if (notices.notices[i]->arrival_time <= m_iLastReadNoticeArrivalTime) {
m_iLastReadNoticeSequenceNumber = notices.notices[i]->seqno;
lastReadArrivalTime = notices.notices[i]->arrival_time;
break;
} else {
++unread;
}
}

if (lastReadArrivalTime != m_iLastReadNoticeArrivalTime) {
m_iLastReadNoticeArrivalTime = lastReadArrivalTime;
SaveUnreadNoticeInfo();
}
}

if (m_iNumberUnreadNotices != unread) {
m_iNumberUnreadNotices = unread;
pFrame->UpdateNoticesTabText();
}
}
}

done:
in_this_func = false;
return 0;
Expand All @@ -1868,31 +1826,29 @@ void CMainDocument::SaveUnreadNoticeInfo() {
wxString strBaseConfigLocation = wxString(wxT("/Notices/"));
wxConfigBase* pConfig = wxConfigBase::Get(FALSE);
wxString strDomainName = wxString(host.domain_name, wxConvUTF8, strlen(host.domain_name));
wxString strHostName = strDomainName.AfterLast(wxFileName::GetPathSeparator());
wxString arrivalTime;
wxString strArrivalTime = wxEmptyString;

pConfig->SetPath(strBaseConfigLocation + strHostName);
arrivalTime.Printf(wxT("%f"), m_iLastReadNoticeArrivalTime);
pConfig->Write(wxT("lastReadNoticeTime"), arrivalTime);
pConfig->SetPath(strBaseConfigLocation + strDomainName);
strArrivalTime.Printf(wxT("%f"), m_dLastReadNoticeArrivalTime);
pConfig->Write(wxT("LastReadNoticeTime"), strArrivalTime);
}


void CMainDocument::RestoreUnreadNoticeInfo() {
wxString strBaseConfigLocation = wxString(wxT("/Notices/"));
wxConfigBase* pConfig = wxConfigBase::Get(FALSE);
wxString arrivalTime = wxEmptyString;
wxString strArrivalTime = wxEmptyString;
wxString strDomainName = wxString(host.domain_name, wxConvUTF8, strlen(host.domain_name));
wxString strHostName = strDomainName.AfterLast(wxFileName::GetPathSeparator());
double lastReadNoticeTime;
int i, n = GetNoticeCount();

pConfig->SetPath(strBaseConfigLocation + strHostName);
if (pConfig->Read(wxT("lastReadNoticeTime"), &arrivalTime)) {
arrivalTime.ToDouble(&lastReadNoticeTime);
double dLastReadNoticeTime;
int i, n = (int)notices.notices.size();

pConfig->SetPath(strBaseConfigLocation + strDomainName);
if (pConfig->Read(wxT("LastReadNoticeTime"), &strArrivalTime)) {
strArrivalTime.ToDouble(&dLastReadNoticeTime);
for (i=0; i<n; ++i) {
if (notices.notices[i]->arrival_time >= lastReadNoticeTime) {
if (notices.notices[i]->arrival_time >= dLastReadNoticeTime) {
m_iLastReadNoticeSequenceNumber = notices.notices[i]->seqno;
m_iLastReadNoticeArrivalTime = notices.notices[i]->arrival_time;
m_dLastReadNoticeArrivalTime = notices.notices[i]->arrival_time;
return;
}
}
Expand Down Expand Up @@ -1930,13 +1886,33 @@ int CMainDocument::GetNoticeCount() {
}


int CMainDocument::GetUnreadNoticeCount() {
int iCount = 0;
if (!notices.notices.empty()) {
for (unsigned int i = 0; i < notices.notices.size(); i++) {
if (notices.notices[i]->arrival_time > m_dLastReadNoticeArrivalTime) {
iCount++;
}
}
}
return iCount;
}


void CMainDocument::UpdateUnreadNoticeState() {
if (!notices.notices.empty()) {
m_iLastReadNoticeSequenceNumber = notices.notices[0]->seqno;
m_dLastReadNoticeArrivalTime = notices.notices[0]->arrival_time;
SaveUnreadNoticeInfo();
}
}


int CMainDocument::ResetNoticeState() {
notices.clear();
m_iNoticeSequenceNumber = 0;
m_iLastReadNoticeSequenceNumber = -1;
m_iLastReadNoticeArrivalTime = 0.0;
m_iNumberUnreadNotices = 0;

m_dLastReadNoticeArrivalTime = 0.0;
return 0;
}

Expand All @@ -1954,7 +1930,7 @@ int CMainDocument::CachedMessageUpdate() {

if (IsConnected()) {
// rpc.get_messages is now called from RunPeriodicRPCs()
// retval = rpc.get_messages(m_iMessageSequenceNumber, messages);
// retval = rpc.get_messages(m_iMessageSequenceNumber, messages);
if (m_iGet_messages_rpc_result) {
wxLogTrace(wxT("Function Status"), wxT("CMainDocument::CachedMessageUpdate - Get Messages Failed '%d'"), m_iGet_messages_rpc_result);
m_pNetworkConnection->SetStateDisconnected();
Expand All @@ -1965,6 +1941,7 @@ int CMainDocument::CachedMessageUpdate() {
m_iMessageSequenceNumber = messages.messages[last_ind]->seqno;
}
}

done:
in_this_func = false;
return 0;
Expand Down
10 changes: 6 additions & 4 deletions clientgui/MainDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,20 +286,22 @@ class CMainDocument : public wxObject {

int m_iNoticeSequenceNumber;
int m_iLastReadNoticeSequenceNumber;
double m_iLastReadNoticeArrivalTime;
int m_iNumberUnreadNotices;
double m_dLastReadNoticeArrivalTime;

public:
NOTICES notices;
int m_iGet_notices_rpc_result;

NOTICE* notice(unsigned int);
int CachedNoticeUpdate();

int GetNoticeCount();
int GetUnreadNoticeCount();

void SaveUnreadNoticeInfo();
void RestoreUnreadNoticeInfo();
int GetNoticeCount();
int GetUnreadNoticeCount() { return m_iNumberUnreadNotices; };

void UpdateUnreadNoticeState();
int ResetNoticeState();


Expand Down
5 changes: 5 additions & 0 deletions clientgui/ViewNotices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,11 @@ void CViewNotices::OnListRender(wxTimerEvent& WXUNUSED(event)) {
wxLogTrace(wxT("Function Start/End"), wxT("CViewNotices::OnListRender - Function Begin"));

static bool s_bInProgress = false;
CMainDocument* pDoc = wxGetApp().GetDocument();

wxASSERT(pDoc);
wxASSERT(m_pHtmlListPane);
wxASSERT(wxDynamicCast(pDoc, CMainDocument));

if (s_bInProgress) return;
s_bInProgress = true;
Expand All @@ -144,6 +147,8 @@ void CViewNotices::OnListRender(wxTimerEvent& WXUNUSED(event)) {
m_pHtmlListPane->UpdateUI();
m_pHtmlListPane->Thaw();

pDoc->UpdateUnreadNoticeState();

s_bInProgress = false;

wxLogTrace(wxT("Function Start/End"), wxT("CViewNotices::OnListRender - Function End"));
Expand Down
Loading

0 comments on commit 371c53e

Please sign in to comment.