xref: /haiku/src/apps/networkstatus/NetworkStatusView.h (revision 7a74a5df454197933bc6e80a542102362ee98703)
1 /*
2  * Copyright 2006-2009, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Axel Dörfler, axeld@pinc-software.de
7  *		Dario Casalinuovo
8  */
9 #ifndef NETWORK_STATUS_VIEW_H
10 #define NETWORK_STATUS_VIEW_H
11 
12 
13 #include <Notification.h>
14 #include <ObjectList.h>
15 #include <View.h>
16 
17 #include <map>
18 
19 class BMessageRunner;
20 class BNetworkInterface;
21 
22 
23 enum {
24 	kStatusUnknown = 0,
25 	kStatusNoLink,
26 	kStatusLinkNoConfig,
27 	kStatusConnecting,
28 	kStatusReady,
29 
30 	kStatusCount
31 };
32 
33 
34 class NetworkStatusView : public BView {
35 	public:
36 		NetworkStatusView(BRect frame, int32 resizingMode,
37 			bool inDeskbar = false);
38 		NetworkStatusView(BMessage* archive);
39 		virtual	~NetworkStatusView();
40 
41 		static	NetworkStatusView* Instantiate(BMessage* archive);
42 		virtual	status_t Archive(BMessage* archive, bool deep = true) const;
43 
44 		virtual	void	AttachedToWindow();
45 		virtual	void	DetachedFromWindow();
46 
47 		virtual	void	MessageReceived(BMessage* message);
48 		virtual void	FrameResized(float width, float height);
49 		virtual	void	MouseDown(BPoint where);
50 		virtual	void	Draw(BRect updateRect);
51 
52 	private:
53 		void			_AboutRequested();
54 		void			_Quit();
55 		void			_Init();
56 		void			_UpdateBitmaps();
57 		void			_ShowConfiguration(BMessage* message);
58 		bool			_PrepareRequest(struct ifreq& request,
59 							const char* name);
60 		int32			_DetermineInterfaceStatus(
61 							const BNetworkInterface& interface);
62 		void			_Update(bool force = false);
63 		void			_OpenNetworksPreferences();
64 
65 		std::map<BString, int32>
66 						fInterfaceStatuses;
67 		bool			fInDeskbar;
68 		BBitmap*		fTrayIcons[kStatusCount];
69 		BBitmap*		fNotifyIcons[kStatusCount];
70 };
71 
72 #endif	// NETWORK_STATUS_VIEW_H
73