xref: /haiku/src/add-ons/network_settings/dialup/DialUpView.h (revision a325aa030fbd5c4ee84dce6b360a5dc8c0b313f5)
1 /* -----------------------------------------------------------------------
2  * Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  * ----------------------------------------------------------------------- */
22 
23 #ifndef _DIAL_UP_VIEW__H
24 #define _DIAL_UP_VIEW__H
25 
26 #include <Message.h>
27 #include <View.h>
28 
29 #include <PPPInterfaceListener.h>
30 
31 class GeneralAddon;
32 
33 
34 class DialUpView : public BView {
35 	public:
36 		DialUpView(BRect frame);
37 		virtual ~DialUpView();
38 
39 		virtual void AttachedToWindow();
40 		virtual void MessageReceived(BMessage *message);
41 
42 		void UpDownThread();
43 
44 		// used by ppp_up application
45 		bool SelectInterfaceNamed(const char *name);
46 		bool NeedsRequest() const;
47 		BView *AuthenticationView() const;
48 		BView *StatusView() const;
49 		BView *ConnectButton() const;
50 		bool SaveSettings(BMessage *settings, BMessage *profile, bool saveTemporary);
51 		bool SaveSettingsToFile();
52 
53 	private:
54 		void GetPPPDirectories(BDirectory *settingsDirectory,
55 			BDirectory *profileDirectory) const;
56 
57 		void HandleReportMessage(BMessage *message);
58 		void CreateTabs();
59 
60 		void UpdateStatus(int32 code);
61 		void WatchInterface(ppp_interface_id ID);
62 
63 		bool LoadSettings(bool isNew);
64 		void IsModified(bool *settings, bool *profile);
65 
66 		void LoadInterfaces();
67 		void LoadAddons();
68 
69 		void AddInterface(const char *name, bool isNew = false);
70 		void SelectInterface(int32 index, bool isNew = false);
71 		int32 CountInterfaces() const;
72 
73 		void UpdateControls();
74 
75 	private:
76 		PPPInterfaceListener fListener;
77 
78 		thread_id fUpDownThread;
79 
80 		BMessage fAddons, fSettings, fProfile;
81 		driver_settings *fDriverSettings;
82 		BMenuItem *fCurrentItem, *fDeleterItem;
83 		ppp_interface_id fWatching;
84 
85 		GeneralAddon *fGeneralAddon;
86 		bool fKeepLabel;
87 		BStringView *fStatusView;
88 		BButton *fConnectButton, *fCreateNewButton;
89 		BPopUpMenu *fInterfaceMenu;
90 		BMenuField *fMenuField;
91 		BStringView *fStringView;
92 			// shows "No interfaces found..." notice
93 		BTabView *fTabView;
94 };
95 
96 
97 #endif
98