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