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//-----------------------------------------------------------------------
24// ConnectionOptionsAddon saves the loaded settings.
25// ConnectionOptionsView saves the current settings.
26//-----------------------------------------------------------------------
27
28#ifndef _CONNECTION_OPTIONS_ADDON__H
29#define _CONNECTION_OPTIONS_ADDON__H
30
31#include <DialUpAddon.h>
32
33#include <CheckBox.h>
34#include <RadioButton.h>
35
36class ConnectionOptionsView;
37
38
39class ConnectionOptionsAddon : public DialUpAddon {
40	public:
41		ConnectionOptionsAddon(BMessage *addons);
42		virtual ~ConnectionOptionsAddon();
43
44		bool IsNew() const
45			{ return fIsNew; }
46
47		bool DoesDialOnDemand() const
48			{ return fDoesDialOnDemand; }
49		bool AskBeforeDialing() const
50			{ return fAskBeforeDialing; }
51		bool DoesAutoRedial() const
52			{ return fDoesAutoRedial; }
53
54		BMessage *Settings() const
55			{ return fSettings; }
56		BMessage *Profile() const
57			{ return fProfile; }
58
59		virtual int32 Position() const
60			{ return 50; }
61		virtual bool LoadSettings(BMessage *settings, BMessage *profile, bool isNew);
62		virtual void IsModified(bool *settings, bool *profile) const;
63		virtual bool SaveSettings(BMessage *settings, BMessage *profile,
64			bool saveTemporary);
65		virtual bool GetPreferredSize(float *width, float *height) const;
66		virtual BView *CreateView(BPoint leftTop);
67
68	private:
69		bool fIsNew;
70		bool fDoesDialOnDemand, fAskBeforeDialing, fDoesAutoRedial;
71		BMessage *fSettings, *fProfile;
72			// saves last settings state
73		ConnectionOptionsView *fConnectionOptionsView;
74};
75
76
77class ConnectionOptionsView : public BView {
78	public:
79		ConnectionOptionsView(ConnectionOptionsAddon *addon, BRect frame);
80
81		ConnectionOptionsAddon *Addon() const
82			{ return fAddon; }
83		void Reload();
84
85		bool DoesDialOnDemand() const
86			{ return fDialOnDemand->Value(); }
87		bool AskBeforeDialing() const
88			{ return fAskBeforeDialing->Value(); }
89		bool DoesAutoRedial() const
90			{ return fAutoRedial->Value(); }
91
92		virtual void AttachedToWindow();
93		virtual void MessageReceived(BMessage *message);
94
95	private:
96		void UpdateControls();
97
98	private:
99		ConnectionOptionsAddon *fAddon;
100		BCheckBox *fDialOnDemand, *fAskBeforeDialing, *fAutoRedial;
101};
102
103
104#endif
105