diff --git a/src/preferences/time/Jamfile b/src/preferences/time/Jamfile index 25eb8a7004..43e27b0828 100644 --- a/src/preferences/time/Jamfile +++ b/src/preferences/time/Jamfile @@ -39,6 +39,7 @@ DoCatalogs Time : : DateTimeView.cpp NetworkTimeView.cpp + ntp.cpp Time.cpp TimeWindow.cpp ZoneView.cpp diff --git a/src/preferences/time/NetworkTimeView.cpp b/src/preferences/time/NetworkTimeView.cpp index f284e42273..445918ca6c 100644 --- a/src/preferences/time/NetworkTimeView.cpp +++ b/src/preferences/time/NetworkTimeView.cpp @@ -31,6 +31,7 @@ #undef B_TRANSLATE_CONTEXT #define B_TRANSLATE_CONTEXT "Time" + Settings::Settings() : fMessage(kMsgNetworkTimeSettings) @@ -293,13 +294,13 @@ NetworkTimeView::MessageReceived(BMessage* message) _UpdateServerList(); Looper()->PostMessage(new BMessage(kMsgChange)); break; - + case kMsgResetServerList: fSettings.ResetServersToDefaults(); _UpdateServerList(); Looper()->PostMessage(new BMessage(kMsgChange)); break; - + case kMsgTryAllServers: fSettings.SetTryAllServers( fTryAllServersCheckBox->Value()); @@ -325,7 +326,7 @@ NetworkTimeView::MessageReceived(BMessage* message) BMessenger* messenger = new BMessenger(this); update_time(fSettings, messenger, &fUpdateThread); - fSynchronizeButton->SetLabel("Stop"); + fSynchronizeButton->SetLabel(B_TRANSLATE("Stop")); fSynchronizeButton->Message()->what = kMsgStopSynchronization; break; } @@ -341,21 +342,22 @@ NetworkTimeView::MessageReceived(BMessage* message) const char* errorString; message->FindString("error string", &errorString); char buffer[256]; - + int32 errorCode; if (message->FindInt32("error code", &errorCode) == B_OK) snprintf(buffer, sizeof(buffer), - "The following error occured " - "while synchronizing:\r\n%s: %s", + B_TRANSLATE("The following error occured " + "while synchronizing:\r\n%s: %s"), errorString, strerror(errorCode)); else snprintf(buffer, sizeof(buffer), - "The following error occured " - "while synchronizing:\r\n%s", + B_TRANSLATE("The following error occured " + "while synchronizing:\r\n%s"), errorString); - (new BAlert("Time", buffer, "OK"))->Go(); + (new BAlert(B_TRANSLATE("Time"), buffer, + B_TRANSLATE("OK")))->Go(); } break; } @@ -409,19 +411,20 @@ NetworkTimeView::_InitView() BScrollView* scrollView = new BScrollView("serverScrollView", fServerListView, B_FRAME_EVENTS | B_WILL_DRAW, false, true); _UpdateServerList(); - + fTryAllServersCheckBox = new BCheckBox("tryAllServers", B_TRANSLATE("Try all servers"), new BMessage(kMsgTryAllServers)); fTryAllServersCheckBox->SetValue(fSettings.GetTryAllServers()); - - fSynchronizeAtBootCheckBox = new BCheckBox("autoUpdate", - B_TRANSLATE("Synchronize at boot"), new BMessage(kMsgSynchronizeAtBoot)); + + fSynchronizeAtBootCheckBox = new BCheckBox("autoUpdate", + B_TRANSLATE("Synchronize at boot"), + new BMessage(kMsgSynchronizeAtBoot)); fSynchronizeAtBootCheckBox->SetValue(fSettings.GetSynchronizeAtBoot()); - fSynchronizeButton = new BButton("update", B_TRANSLATE("Synchronize now"), + fSynchronizeButton = new BButton("update", B_TRANSLATE("Synchronize"), new BMessage(kMsgSynchronize)); fSynchronizeButton->SetExplicitAlignment( BAlignment(B_ALIGN_RIGHT, B_ALIGN_BOTTOM)); - + const float kInset = be_control_look->DefaultItemSpacing(); BLayoutBuilder::Group<>(this) .AddGroup(B_HORIZONTAL) @@ -480,7 +483,7 @@ update_time(const Settings& settings, const char** errorString, status_t status = B_ENTRY_NOT_FOUND; const char* server = settings.GetServer(defaultServer); - + if (server != NULL) status = ntp_update_time(server, errorString, errorCode); @@ -497,7 +500,7 @@ update_time(const Settings& settings, const char** errorString, break; } } - + return status; } @@ -519,7 +522,7 @@ update_thread(void* params) if (errorCode != 0) result.AddInt32("error code", errorCode); messenger->SendMessage(&result); - + delete messenger; return B_OK; } diff --git a/src/preferences/time/ntp.cpp b/src/preferences/time/ntp.cpp index 8690140477..f2e7a2afce 100644 --- a/src/preferences/time/ntp.cpp +++ b/src/preferences/time/ntp.cpp @@ -17,6 +17,12 @@ #include +#include + + +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "Time" + /* This structure and its data fields are described in RFC 1305 * "Network Time Protocol (Version 3)" in appendix A. @@ -112,7 +118,7 @@ ntp_update_time(const char* hostname, const char** errorString, if (server == NULL) { - *errorString = "Could not contact server"; + *errorString = B_TRANSLATE("Could not contact server"); return B_ENTRY_NOT_FOUND; } @@ -133,7 +139,7 @@ ntp_update_time(const char* hostname, const char** errorString, int connection = socket(AF_INET, SOCK_DGRAM, 0); if (connection < 0) { - *errorString = "Could not create socket"; + *errorString = B_TRANSLATE("Could not create socket"); *errorCode = errno; return B_ERROR; } @@ -145,7 +151,7 @@ ntp_update_time(const char* hostname, const char** errorString, if (sendto(connection, (char *)&message, sizeof(ntp_data), 0, (struct sockaddr *)&address, sizeof(address)) < 0) { - *errorString = "Sending request failed"; + *errorString = B_TRANSLATE("Sending request failed"); *errorCode = errno; return B_ERROR; } @@ -160,7 +166,7 @@ ntp_update_time(const char* hostname, const char** errorString, // we'll wait 3 seconds for the answer if (select(connection + 1, &waitForReceived, NULL, NULL, &timeout) <= 0) { - *errorString = "Waiting for answer failed"; + *errorString = B_TRANSLATE("Waiting for answer failed"); *errorCode = errno; return B_ERROR; } @@ -170,7 +176,7 @@ ntp_update_time(const char* hostname, const char** errorString, socklen_t addressSize = sizeof(address); if (recvfrom(connection, (char *)&message, sizeof(ntp_data), 0, (sockaddr *)&address, &addressSize) < (ssize_t)sizeof(ntp_data)) { - *errorString = "Message receiving failed"; + *errorString = B_TRANSLATE("Message receiving failed"); *errorCode = errno; close(connection); return B_ERROR; @@ -179,7 +185,7 @@ ntp_update_time(const char* hostname, const char** errorString, close(connection); if (message.transmit_timestamp.Integer() == 0) { - *errorString = "Received invalid time"; + *errorString = B_TRANSLATE("Received invalid time"); return B_BAD_VALUE; }