xref: /haiku/src/apps/networkstatus/NetworkStatusView.h (revision 204dee708a999d5a71d0cb9497650ee7cef85d0a)
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 
20 class BMessageRunner;
21 class BNetworkInterface;
22 
23 
24 enum {
25 	kStatusUnknown = 0,
26 	kStatusNoLink,
27 	kStatusLinkNoConfig,
28 	kStatusConnecting,
29 	kStatusReady,
30 
31 	kStatusCount
32 };
33 
34 
35 class NetworkStatusView : public BView {
36 	public:
37 		NetworkStatusView(BRect frame, int32 resizingMode,
38 			bool inDeskbar = false);
39 		NetworkStatusView(BMessage* archive);
40 		virtual	~NetworkStatusView();
41 
42 		static	NetworkStatusView* Instantiate(BMessage* archive);
43 		virtual	status_t Archive(BMessage* archive, bool deep = true) const;
44 
45 		virtual	void	AttachedToWindow();
46 		virtual	void	DetachedFromWindow();
47 
48 		virtual	void	MessageReceived(BMessage* message);
49 		virtual void	FrameResized(float width, float height);
50 		virtual	void	MouseDown(BPoint where);
51 		virtual	void	Draw(BRect updateRect);
52 
53 	private:
54 		void			_AboutRequested();
55 		void			_Quit();
56 		void			_Init();
57 		void			_UpdateBitmaps();
58 		void			_ShowConfiguration(BMessage* message);
59 		bool			_PrepareRequest(struct ifreq& request,
60 							const char* name);
61 		int32			_DetermineInterfaceStatus(
62 							const BNetworkInterface& interface);
63 		void			_Update(bool force = false);
64 		void			_OpenNetworksPreferences();
65 
66 		std::map<BString, int32>
67 						fInterfaceStatuses;
68 		bool			fInDeskbar;
69 		BBitmap*		fTrayIcons[kStatusCount];
70 		BBitmap*		fNotifyIcons[kStatusCount];
71 };
72 
73 #endif	// NETWORK_STATUS_VIEW_H
74