~ubuntu-branches/ubuntu/precise/boinc/precise

« back to all changes in this revision

Viewing changes to clientgui/ViewNotices.cpp

Tags: 6.12.8+dfsg-1
* New upstream release.
* Simplified debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// This file is part of BOINC.
 
2
// http://boinc.berkeley.edu
 
3
// Copyright (C) 2008 University of California
 
4
//
 
5
// BOINC is free software; you can redistribute it and/or modify it
 
6
// under the terms of the GNU Lesser General Public License
 
7
// as published by the Free Software Foundation,
 
8
// either version 3 of the License, or (at your option) any later version.
 
9
//
 
10
// BOINC is distributed in the hope that it will be useful,
 
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
13
// See the GNU Lesser General Public License for more details.
 
14
//
 
15
// You should have received a copy of the GNU Lesser General Public License
 
16
// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
 
17
 
 
18
#if defined(__GNUG__) && !defined(__APPLE__)
 
19
#pragma implementation "ViewNotices.h"
 
20
#endif
 
21
 
 
22
#include "stdwx.h"
 
23
#include "BOINCGUIApp.h"
 
24
#include "BOINCBaseFrame.h"
 
25
#include "MainDocument.h"
 
26
#include "AdvancedFrame.h"
 
27
#include "BOINCTaskCtrl.h"
 
28
#include "ViewNotices.h"
 
29
#include "NoticeListCtrl.h"
 
30
#include "Events.h"
 
31
#include "error_numbers.h"
 
32
 
 
33
 
 
34
#include "res/mess.xpm"
 
35
 
 
36
 
 
37
IMPLEMENT_DYNAMIC_CLASS(CViewNotices, CBOINCBaseView)
 
38
 
 
39
BEGIN_EVENT_TABLE (CViewNotices, CBOINCBaseView)
 
40
    EVT_NOTICELIST_ITEM_DISPLAY(CViewNotices::OnLinkClicked)
 
41
END_EVENT_TABLE ()
 
42
 
 
43
 
 
44
CViewNotices::CViewNotices()
 
45
{}
 
46
 
 
47
 
 
48
CViewNotices::CViewNotices(wxNotebook* pNotebook) :
 
49
    CBOINCBaseView(pNotebook)
 
50
{
 
51
    //
 
52
    // Setup View
 
53
    //
 
54
    wxFlexGridSizer* itemFlexGridSizer = new wxFlexGridSizer(2, 0, 0);
 
55
    wxASSERT(itemFlexGridSizer);
 
56
 
 
57
    itemFlexGridSizer->AddGrowableRow(0);
 
58
    itemFlexGridSizer->AddGrowableCol(1);
 
59
 
 
60
    m_pTaskPane = new CBOINCTaskCtrl(this, ID_TASK_NOTIFICATIONSVIEW, DEFAULT_TASK_FLAGS);
 
61
    wxASSERT(m_pTaskPane);
 
62
 
 
63
        m_pHtmlListPane = new CNoticeListCtrl(this);
 
64
        wxASSERT(m_pHtmlListPane);
 
65
 
 
66
    itemFlexGridSizer->Add(m_pTaskPane, 1, wxGROW|wxALL, 1);
 
67
    itemFlexGridSizer->Add(m_pHtmlListPane, 1, wxGROW|wxALL, 1);
 
68
 
 
69
    SetSizer(itemFlexGridSizer);
 
70
 
 
71
    Layout();
 
72
 
 
73
    // Create Task Pane Items
 
74
    m_pTaskPane->UpdateControls();
 
75
}
 
76
 
 
77
 
 
78
CViewNotices::~CViewNotices() {
 
79
}
 
80
 
 
81
 
 
82
wxString& CViewNotices::GetViewName() {
 
83
    static wxString strViewName(wxT("Notices"));
 
84
    return strViewName;
 
85
}
 
86
 
 
87
 
 
88
wxString& CViewNotices::GetViewDisplayName() {
 
89
    static wxString strViewName(_("Notices"));
 
90
    return strViewName;
 
91
}
 
92
 
 
93
 
 
94
const char** CViewNotices::GetViewIcon() {
 
95
    return mess_xpm;
 
96
}
 
97
 
 
98
 
 
99
const int CViewNotices::GetViewRefreshRate() {
 
100
    return 10;
 
101
}
 
102
 
 
103
const int CViewNotices::GetViewCurrentViewPage() {
 
104
     return VW_NOTIF;
 
105
}
 
106
 
 
107
 
 
108
bool CViewNotices::OnSaveState(wxConfigBase* WXUNUSED(pConfig)) {
 
109
    return true;
 
110
}
 
111
 
 
112
 
 
113
bool CViewNotices::OnRestoreState(wxConfigBase* WXUNUSED(pConfig)) {
 
114
    return true;
 
115
}
 
116
 
 
117
 
 
118
void CViewNotices::OnListRender(wxTimerEvent& WXUNUSED(event)) {
 
119
    wxLogTrace(wxT("Function Start/End"), wxT("CViewNotices::OnListRender - Function Begin"));
 
120
 
 
121
    static bool s_bInProgress = false;
 
122
    static wxString strLastMachineName = wxEmptyString;
 
123
    wxString strNewMachineName = wxEmptyString;
 
124
    CMainDocument* pDoc = wxGetApp().GetDocument();
 
125
 
 
126
    wxASSERT(pDoc);
 
127
        wxASSERT(m_pHtmlListPane);
 
128
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
 
129
 
 
130
    if (s_bInProgress) return;
 
131
    s_bInProgress = true;
 
132
 
 
133
    if (pDoc->IsConnected()) {
 
134
        pDoc->GetConnectedComputerName(strNewMachineName);
 
135
        if (strLastMachineName != strNewMachineName) {
 
136
            strLastMachineName = strNewMachineName;
 
137
            m_pHtmlListPane->Clear();
 
138
        }
 
139
    }
 
140
 
 
141
    // Don't call Freeze() / Thaw() here because it causes an unnecessary redraw
 
142
    m_pHtmlListPane->UpdateUI();
 
143
 
 
144
    pDoc->UpdateUnreadNoticeState();
 
145
 
 
146
    s_bInProgress = false;
 
147
 
 
148
    wxLogTrace(wxT("Function Start/End"), wxT("CViewNotices::OnListRender - Function End"));
 
149
}
 
150
 
 
151
 
 
152
void CViewNotices::OnLinkClicked( NoticeListCtrlEvent& event ) {
 
153
    if (event.GetURL().StartsWith(wxT("http://"))) {
 
154
                wxLaunchDefaultBrowser(event.GetURL());
 
155
    }
 
156
}
 
157