tcp: Fix 64 bit build with debugging features enabled.
[haiku.git] / src / preferences / time / Time.cpp
blob21a65eabd5b516012931ff024f213cf87ebddb77
1 /*
2 * Copyright 2002-2011, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Andrew McCall <mccall@digitalparadise.co.uk>
7 * Mike Berg <mike@berg-net.us>
8 * Julun <host.haiku@gmx.de>
9 * Hamish Morrison <hamish@lavabit.com>
13 #include "Time.h"
15 #include <locale.h>
16 #include <stdio.h>
17 #include <unistd.h>
19 #include <Alert.h>
20 #include <Catalog.h>
22 #include "NetworkTimeView.h"
23 #include "TimeMessages.h"
24 #include "TimeWindow.h"
27 #undef B_TRANSLATION_CONTEXT
28 #define B_TRANSLATION_CONTEXT "Time"
31 const char* kAppSignature = "application/x-vnd.Haiku-Time";
34 TimeApplication::TimeApplication()
36 BApplication(kAppSignature),
37 fWindow(NULL)
39 fWindow = new TTimeWindow();
43 TimeApplication::~TimeApplication()
48 void
49 TimeApplication::ReadyToRun()
51 fWindow->Show();
55 void
56 TimeApplication::AboutRequested()
58 BAlert* alert = new BAlert(B_TRANSLATE("about"),
59 B_TRANSLATE(
60 "Time & Date, written by:\n\n\tAndrew Edward McCall\n\tMike Berg\n\t"
61 "Julun\n\tPhilippe Saint-Pierre\n\nCopyright 2004-2012, Haiku."),
62 B_TRANSLATE("OK"));
63 alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
64 alert->Go();
68 void
69 TimeApplication::MessageReceived(BMessage* message)
71 switch (message->what) {
72 case kSelectClockTab:
73 case kShowHideTime:
74 fWindow->PostMessage(message);
75 break;
77 default:
78 BApplication::MessageReceived(message);
79 break;
84 int
85 main(int argc, char** argv)
87 if (argc > 1) {
88 if (strcmp(argv[1], "--update") != 0)
89 return 0;
91 Settings settings;
92 if (!settings.GetSynchronizeAtBoot())
93 return 0;
95 const char* errorString = NULL;
96 int32 errorCode = 0;
97 if (update_time(settings, &errorString, &errorCode) == B_OK) {
98 printf("Synchronization successful\r\n");
99 } else if (errorCode != 0) {
100 printf("The following error occured "
101 "while synchronizing:\r\n%s: %s\r\n",
102 errorString, strerror(errorCode));
103 } else {
104 printf("The following error occured while synchronizing:\r\n%s\r\n",
105 errorString);
107 } else {
108 setlocale(LC_ALL, "");
110 TimeApplication app;
111 setuid(0);
112 app.Run();
115 return 0;