diff --git a/checkin_notes b/checkin_notes
index 73a0604ebd..5f6529b2f8 100644
--- a/checkin_notes
+++ b/checkin_notes
@@ -5576,3 +5576,11 @@ David 23 Jul 2010
sched_send.cpp,h
sched_locality.cpp
sched_types.cpp
+
+Rom 23 July 2010
+ - MGR: Enable the manager to be able to deal with any size notice.
+
+ clientgui/
+ DlgEventLog.cpp
+ MainDocument.cpp, .h
+ NoticeListCtrl.cpp
diff --git a/clientgui/BOINCBaseFrame.cpp b/clientgui/BOINCBaseFrame.cpp
index 1af1641601..08160de151 100644
--- a/clientgui/BOINCBaseFrame.cpp
+++ b/clientgui/BOINCBaseFrame.cpp
@@ -305,7 +305,6 @@ void CBOINCBaseFrame::OnAlert(CFrameAlertEvent& event) {
void CBOINCBaseFrame::OnClose(wxCloseEvent& event) {
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::OnClose - Function Begin"));
-
if (!event.CanVeto() || IsIconized()) {
wxGetApp().FrameClosed();
Destroy();
diff --git a/clientgui/DlgEventLog.cpp b/clientgui/DlgEventLog.cpp
index fce2e5457f..df1958ff02 100644
--- a/clientgui/DlgEventLog.cpp
+++ b/clientgui/DlgEventLog.cpp
@@ -861,9 +861,10 @@ wxInt32 CDlgEventLog::FormatTime(wxInt32 item, wxString& strBuffer) const {
wxInt32 CDlgEventLog::FormatMessage(wxInt32 item, wxString& strBuffer) const {
MESSAGE* message = wxGetApp().GetDocument()->message(item);
-
+
if (message) {
- strBuffer = process_client_message(message->body.c_str());
+ strBuffer = wxString(message->body.c_str(), wxConvUTF8);
+ wxGetApp().GetDocument()->LocalizeNoticeText(strBuffer);
}
return 0;
diff --git a/clientgui/MainDocument.cpp b/clientgui/MainDocument.cpp
index 452da35065..e48b63fdee 100644
--- a/clientgui/MainDocument.cpp
+++ b/clientgui/MainDocument.cpp
@@ -1924,6 +1924,37 @@ int CMainDocument::ResetNoticeState() {
}
+// parse out the _(...)'s, and translate them
+//
+bool CMainDocument::LocalizeNoticeText(wxString& strMessage) {
+ wxString strBuffer = wxEmptyString;
+ wxString strStart = wxString(wxT("_(\""));
+ wxString strEnd = wxString(wxT("\")"));
+
+ // Replace CRLFs with HTML breaks.
+ strMessage.Replace(wxT("\r\n"), wxT("
"));
+
+ // Replace LFs with HTML breaks.
+ strMessage.Replace(wxT("\n"), wxT("
"));
+
+ // Localize translatable text
+ while (strMessage.Find(strStart.c_str()) != wxNOT_FOUND) {
+ strBuffer =
+ strMessage.SubString(
+ strMessage.Find(strStart.c_str()) + strStart.Length(),
+ strMessage.Find(strEnd.c_str()) - (strEnd.Length() - 1)
+ );
+
+ strMessage.Replace(
+ wxString(strStart + strBuffer + strEnd).c_str(),
+ wxGetTranslation(strBuffer.c_str())
+ );
+ }
+
+ return true;
+}
+
+
// Call this only when message buffer is stable
// Note: This must not call any rpcs.
// This is now called after each get_messages RPC from
@@ -2446,38 +2477,3 @@ wxString result_description(RESULT* result) {
return strBuffer;
}
-// parse out the _(...)'s, and translate them
-//
-wxString process_client_message(const char* msg) {
- wxString result;
- const char* START = "_(\"";
- const char* END = "\")";
- char buf[1024];
- char* p = buf, *q;
-
- strcpy(buf, msg);
- q = strchr(p, '\n');
- if (q) *q = 0;
- while (*p) {
- q = strstr(p, START);
- if (!q) {
- result += wxString(p, wxConvUTF8);
- break;
- }
- if (p != q) {
- *q = 0;
- result += wxString(p, wxConvUTF8);
- }
- p = q + strlen(START);
- if (!p) break; // paranoia
- q = strstr(p, END);
- if (!q) { // paranoia
- result += wxString(p, wxConvUTF8);
- break;
- }
- *q = 0;
- result += wxGetTranslation(wxString(p, wxConvUTF8));
- p = q + strlen(END);
- }
- return result;
-}
diff --git a/clientgui/MainDocument.h b/clientgui/MainDocument.h
index e333cc7584..3b25b963fc 100644
--- a/clientgui/MainDocument.h
+++ b/clientgui/MainDocument.h
@@ -303,6 +303,7 @@ public:
void UpdateUnreadNoticeState();
int ResetNoticeState();
+ bool LocalizeNoticeText(wxString& strMessage);
//
diff --git a/clientgui/NoticeListCtrl.cpp b/clientgui/NoticeListCtrl.cpp
index efaa6319f5..91732efc7a 100644
--- a/clientgui/NoticeListCtrl.cpp
+++ b/clientgui/NoticeListCtrl.cpp
@@ -60,7 +60,8 @@ wxAccStatus CNoticeListCtrlAccessible::GetName(int childId, wxString* name)
if (pDoc)
{
- strBuffer = wxString(process_client_message(pDoc->notice(childId-1)->title), wxConvUTF8);
+ strBuffer = wxString(pDoc->notice(childId-1)->title, wxConvUTF8);
+ pDoc->LocalizeNoticeText(strBuffer);
strBuffer = StripHTMLTags(strBuffer);
*name = strBuffer.c_str();
}
@@ -172,44 +173,27 @@ wxAccStatus CNoticeListCtrlAccessible::DoDefaultAction(int childId)
return wxACC_NOT_IMPLEMENTED;
}
-// WxWidget's HTML renderer gets messed up by \n's. change to
-//
-static void fix_html(const char* in, char* out) {
- while (*in) {
- switch (*in) {
- case '\n':
- strcpy(out, "
");
- out += 4;
- break;
- case '\r':
- break;
- default:
- *out++ = *in;
- }
- in++;
- }
- *out = 0;
-}
-
// Returns the description for this object or a child.
wxAccStatus CNoticeListCtrlAccessible::GetDescription(int childId, wxString* description)
{
CMainDocument* pDoc = wxGetApp().GetDocument();
static wxString strBuffer;
wxDateTime dtBuffer;
- wxString strDescription;
+ wxString strDescription = wxEmptyString;
wxString strProjectName = wxEmptyString;
wxString strArrivalTime = wxEmptyString;
if (pDoc && (childId != wxACC_SELF)) {
strBuffer = wxEmptyString;
- char buf[65000];
- fix_html(pDoc->notice(childId-1)->description.c_str(), buf);
- strDescription = process_client_message(buf);
strProjectName = wxString(pDoc->notice(childId-1)->project_name, wxConvUTF8);
+
+ strDescription = wxString(pDoc->notice(childId-1)->description.c_str(), wxConvUTF8);
+ pDoc->LocalizeNoticeText(strDescription);
+
dtBuffer.Set((time_t)pDoc->notice(childId-1)->arrival_time);
strArrivalTime = dtBuffer.Format();
+
if (strProjectName.IsEmpty()) {
strBuffer.Printf(_("%s; received on %s"), strDescription.c_str(), strArrivalTime.c_str());
} else {
@@ -531,7 +515,7 @@ void CNoticeListCtrl::OnLinkClicked( wxHtmlLinkEvent& event )
wxString CNoticeListCtrl::OnGetItem(size_t i) const
{
- CMainDocument* pDoc = wxGetApp().GetDocument();
+ CMainDocument* pDoc = wxGetApp().GetDocument();
wxString strTitle = wxEmptyString;
wxString strDescription = wxEmptyString;
wxString strProjectName = wxEmptyString;
@@ -548,10 +532,12 @@ wxString CNoticeListCtrl::OnGetItem(size_t i) const
strProjectName = wxString(np->project_name, wxConvUTF8);
strURL = wxString(np->link, wxConvUTF8);
- strTitle = wxString(process_client_message(np->title), wxConvUTF8);
- char buf[65000];
- fix_html(np->description.c_str(), buf);
- strDescription = process_client_message(buf);
+
+ strTitle = wxString(np->title, wxConvUTF8);
+ pDoc->LocalizeNoticeText(strTitle);
+
+ strDescription = wxString(np->description.c_str(), wxConvUTF8);
+ pDoc->LocalizeNoticeText(strDescription);
dtBuffer.Set((time_t)np->arrival_time);
strArrivalTime = dtBuffer.Format();