tcp: Fix 64 bit build with debugging features enabled.
[haiku.git] / src / preferences / time / NetworkTimeView.h
blob6ab1ce8a8c6ba904c20b997f98f83f515b2e4a96
1 /*
2 * Copyright 2011-2014 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Axel Dörfler, axeld@pinc-software.de
7 * Hamish Morrison, hamish@lavabit.com
8 * John Scipione, jscipione@gmail.com
9 */
10 #ifndef NETWORK_TIME_VIEW_H
11 #define NETWORK_TIME_VIEW_H
14 #include <LayoutBuilder.h>
17 class BButton;
18 class BCheckBox;
19 class BListView;
20 class BMessage;
21 class BMessenger;
22 class BPath;
23 class BTextControl;
26 static const uint32 kMsgNetworkTimeSettings = 'ntst';
27 static const uint32 kMsgSetDefaultServer = 'setd';
28 static const uint32 kMsgServerEdited = 'sved';
29 static const uint32 kMsgAddServer = 'asrv';
30 static const uint32 kMsgRemoveServer = 'rsrv';
31 static const uint32 kMsgResetServerList = 'rstl';
32 static const uint32 kMsgTryAllServers = 'tras';
33 static const uint32 kMsgSynchronizeAtBoot = 'synb';
34 static const uint32 kMsgSynchronize = 'sync';
35 static const uint32 kMsgStopSynchronization = 'stps';
36 static const uint32 kMsgSynchronizationResult = 'syrs';
37 static const uint32 kMsgNetworkTimeChange = 'ntch';
40 class Settings {
41 public:
42 Settings();
43 ~Settings();
45 void AddServer(const char* server);
46 const char* GetServer(int32 index) const;
47 void RemoveServer(const char* server);
48 void SetDefaultServer(int32 index);
49 int32 GetDefaultServer() const;
50 void SetTryAllServers(bool boolean);
51 bool GetTryAllServers() const;
52 void SetSynchronizeAtBoot(bool boolean);
53 bool GetSynchronizeAtBoot() const;
55 void ResetServersToDefaults();
56 void ResetToDefaults();
57 void Revert();
58 bool SettingsChanged();
60 status_t Load();
61 status_t Save();
63 private:
64 int32 _GetStringByValue(const char* name,
65 const char* value);
66 status_t _GetPath(BPath& path);
68 BMessage fMessage;
69 BMessage fOldMessage;
70 bool fWasUpdated;
74 class NetworkTimeView : public BGroupView {
75 public:
76 NetworkTimeView(const char* name);
77 virtual ~NetworkTimeView();
79 virtual void MessageReceived(BMessage* message);
80 virtual void AttachedToWindow();
82 bool CheckCanRevert();
83 private:
84 void _InitView();
85 void _UpdateServerList();
86 void _DoneSynchronizing();
87 bool _IsValidServerName(const char* serverName);
89 Settings fSettings;
91 BTextControl* fServerTextControl;
92 BButton* fAddButton;
93 BButton* fRemoveButton;
94 BButton* fResetButton;
96 BListView* fServerListView;
97 BCheckBox* fTryAllServersCheckBox;
98 BCheckBox* fSynchronizeAtBootCheckBox;
99 BButton* fSynchronizeButton;
101 rgb_color fTextColor;
102 rgb_color fInvalidColor;
104 thread_id fUpdateThread;
108 int32
109 update_thread(void* params);
111 status_t
112 update_time(const Settings& settings, BMessenger* messenger,
113 thread_id* thread);
115 status_t
116 update_time(const Settings& settings, const char** errorString,
117 int32* errorCode);
120 #endif // NETWORK_TIME_VIEW_H