1 #include "HTBP_Environment.h"
3 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
5 ACE::HTBP::Environment::Environment (ACE_Configuration
*config
,
7 const ACE_TCHAR
*persistent_file
)
10 own_config_ (config
!= 0)
12 initialize (using_registry
,
16 ACE::HTBP::Environment::~Environment ()
23 delete this->imp_exp_
;
27 ACE::HTBP::Environment::clear ()
30 this->config_
->remove_section (config_
->root_section (),
36 ACE::HTBP::Environment::initialize (int use_registry
,
37 const ACE_TCHAR
*persistent_file
)
39 if (this->config_
== 0)
43 result
= this->open_registry_config();
45 result
= this->open_persistent_config (persistent_file
);
48 ACE_ERROR_RETURN ((LM_ERROR
,
49 ACE_TEXT("(%P|%t) ACE::HTBP::Environment")
50 ACE_TEXT("::initialize ")
51 ACE_TEXT("Open Config failed")),
57 ACE_NEW_RETURN (this->imp_exp_
,
58 ACE_Ini_ImpExp (*this->config_
),
61 if (this->config_
->open_section (config_
->root_section (),
63 this->htbp_key_
) != 0)
64 ACE_ERROR_RETURN ((LM_ERROR
,
65 ACE_TEXT("(%P|%t) ACE::HTBP::Environment::initialize ")
66 ACE_TEXT("Open HTBP Section failed")),
72 ACE::HTBP::Environment::open_registry_config ()
74 #if defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_REGISTRY)
76 ACE_Configuration_Win32Registry::resolve_key
77 (HKEY_LOCAL_MACHINE
,ACE_TEXT("Software\\HTBP\\Environment"));
79 ACE_NEW_RETURN (this->config_
,
80 ACE_Configuration_Win32Registry (root
),
82 this->own_config_
= true;
87 #endif /* ACE_WIN32 && !ACE_LACKS_WIN32_REGISTRY */
91 ACE::HTBP::Environment::open_persistent_config (const ACE_TCHAR
*persistent_file
)
93 ACE_Configuration_Heap
*heap
;
95 ACE_Configuration_Heap
,
97 // do this before trying to open so it isn't leaked if the open fails.
99 this->own_config_
= true;
100 if (persistent_file
== 0)
103 if (heap
->open (persistent_file
) != 0)
104 ACE_ERROR_RETURN (( LM_ERROR
,
105 ACE_TEXT ("(%P|%t) ACE::HTBP::Environment::")
106 ACE_TEXT ("open_config: %p\n"),
113 ACE::HTBP::Environment::get_htid_url (ACE_TString
&htid_url
) const
115 return this->config_
->get_string_value (this->htbp_key_
,
116 ACE_TEXT("htid_url"),
121 ACE::HTBP::Environment::set_htid_url (const ACE_TCHAR
*htid_generator_url
)
123 return this->config_
->set_string_value (this->htbp_key_
,
124 ACE_TEXT("htid_url"),
130 ACE::HTBP::Environment::get_htid_via_proxy (int &via_proxy
) const
132 return this->config_
->get_integer_value (this->htbp_key_
,
133 ACE_TEXT("htid_via_proxy"),
138 ACE::HTBP::Environment::set_htid_via_proxy (int via_proxy
)
140 return this->config_
->set_integer_value (this->htbp_key_
,
141 ACE_TEXT("htid_via_proxy"),
146 ACE::HTBP::Environment::get_proxy_host (ACE_TString
&proxy_host
) const
148 return this->config_
->get_string_value (this->htbp_key_
,
149 ACE_TEXT("proxy_host"),
154 ACE::HTBP::Environment::set_proxy_host (const ACE_TCHAR
*proxy_host
)
156 return this->config_
->set_string_value (this->htbp_key_
,
157 ACE_TEXT("proxy_host"),
162 ACE::HTBP::Environment::get_proxy_port (unsigned int &proxy_port
) const
164 int result
= this->config_
->get_integer_value (this->htbp_key_
,
165 ACE_TEXT("proxy_port"),
169 ACE_TString port_str
;
170 result
= this->config_
->get_string_value (this->htbp_key_
,
171 ACE_TEXT("proxy_port"),
174 proxy_port
= ACE_OS::strtol(port_str
.c_str(),0,10);
180 ACE::HTBP::Environment::set_proxy_port (unsigned int proxy_port
)
182 return this->config_
->set_integer_value (this->htbp_key_
,
183 ACE_TEXT("proxy_port"),
188 ACE::HTBP::Environment::import_config (const ACE_TCHAR
*filename
)
190 return this->imp_exp_
->import_config (filename
);
194 ACE::HTBP::Environment::export_config (const ACE_TCHAR
*filename
)
196 return this->imp_exp_
->export_config (filename
);
199 ACE_END_VERSIONED_NAMESPACE_DECL