RDK Documentation (Open Sourced RDK Components)
x_rdk_profile.cpp
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2022 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 /**
21  * @file X_rdk_profile.cpp
22  * @brief This source file contains the APIs for getting bluetooth device information.
23  */
24 
25 /**
26  * @file X_rdk_profile.cpp
27  *
28  * @brief DeviceInfo X_rdk_profile API Implementation.
29  *
30  * This is the implementation of the DeviceInfo API.
31  *
32  * @par Document
33  * TBD Relevant design or API documentation.
34  *
35  */
36 
37 
38 /*****************************************************************************
39  * STANDARD INCLUDE FILES
40  *****************************************************************************/
41 
42 
43 /**
44 * @defgroup tr69hostif
45 * @{
46 * @defgroup hostif
47 * @{
48 **/
49 
50 #include "x_rdk_profile.h"
51 std::mutex X_rdk_profile::m;
52 XBSStore* X_rdk_profile::m_bsStore;
53 
54 X_rdk_profile* X_rdk_profile::m_instance = NULL;
55 
56 X_rdk_profile* X_rdk_profile::getInstance()
57 {
58  if(!m_instance)
59  {
60  try {
61  m_instance = new X_rdk_profile();
62  } catch(const std::exception& e)
63  {
64  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s:%d] X_rdk_profile: Caught exception \" %s\"\n", __FUNCTION__, __LINE__, e.what());
65  }
66  }
67  return m_instance;
68 }
69 
70 
71 void X_rdk_profile::closeInstance()
72 {
73  if(m_instance)
74  {
75  delete m_instance;
76  }
77 }
78 
79 
80 /**
81  * @brief Class default Constructor.
82  */
84 {
85  m_bsStore = XBSStore::getInstance();
86 }
87 
88 /**
89  * @brief This function set the bluetooth profile attributes
90  *
91  *
92  * @param[in] stMsgData HostIf Message Request param contains the attribute value.
93  *
94  * @return Returns an Integer value.
95  * @ingroup DEVICE_X_rdk_profile_API
96  */
98 {
99  int ret = OK;
100  const char* paramName = NULL;
101 
102  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%d]X_rdk_profile: Entering... \n", __FUNCTION__, __LINE__);
103 
104  try {
105 
106  paramName = stMsgData->paramName;
107 
108  if(NULL == paramName) {
109  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%d]X_rdk_profile: Failed : Parameter is NULL.\n", __FUNCTION__, __LINE__);
110  return ret;
111  }
112  if (strncasecmp(paramName, X_RDK_WebPA_DNSText_URL_STRING, strlen(X_RDK_WebPA_DNSText_URL_STRING)) == 0)
113  {
114  return set_WebPA_DNSText_URL(stMsgData);
115  }
116  else
117  {
118  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%d]X_rdk_profile: Parameter \'%s\' is Not Supported \n", __FUNCTION__, __LINE__, paramName);
119  stMsgData->faultCode = fcInvalidParameterName;
120  ret = NOK;
121  }
122  }
123  catch (const std::exception& e )
124  {
125  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%d]X_rdk_profile: Exception caught %s \n", __FUNCTION__, __LINE__, e.what());
126  stMsgData->faultCode = fcInternalError;
127  return NOK;
128  }
129 
130  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%d]X_rdk_profile: Exiting..\n", __FUNCTION__, __LINE__);
131 
132  return ret;
133 }
134 
135 /**
136  * @brief This function get the bluetooth attributes such as name, profile, count and others
137  * for paired and connected devices..
138  *
139  * @param[in] stMsgData HostIf Message Request param contains the external SD Card attribute value.
140  *
141  * @return Returns an Integer value.
142  * @retval 0 If successfully get the attribute values.
143  * @retval -1 If failed and Not able to get.
144  * @retval -2 If Not handle the requested attribute.
145  * @ingroup X_rdk_profile_API
146  */
148 {
149  int ret = NOT_HANDLED;
150  const char* paramName = NULL;
151 
152  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%d]X_rdk_profile: Entering... \n", __FUNCTION__, __LINE__);
153 
154  try {
155 
156  paramName = stMsgData->paramName;
157 
158  if(NULL == paramName) {
159  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%d]X_rdk_profile: Failed : Parameter is NULL.\n", __FUNCTION__, __LINE__);
160  return ret;
161  }
162 
163  if (strncasecmp(paramName, X_RDK_WebPA_SERVER_URL_STPRING, strlen(X_RDK_WebPA_SERVER_URL_STPRING)) == 0)
164  {
165  ret = get_WebPA_Server_URL(stMsgData);
166  }
167  else if (strncasecmp(paramName, X_RDK_WebPA_TokenServer_URL_STRING, strlen(X_RDK_WebPA_TokenServer_URL_STRING)) == 0)
168  {
169  ret = get_WebPA_TokenServer_URL(stMsgData);
170  }
171  else if (strncasecmp(paramName, X_RDK_WebPA_DNSText_URL_STRING, strlen(X_RDK_WebPA_DNSText_URL_STRING)) == 0)
172  {
173  ret = get_WebPA_DNSText_URL(stMsgData);
174  }
175  else
176  {
177  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%d]X_rdk_profile: Parameter \'%s\' is Not Supported \n", __FUNCTION__, __LINE__, paramName);
178  stMsgData->faultCode = fcInvalidParameterName;
179  ret = NOK;
180  }
181  }
182  catch (const std::exception& e )
183  {
184  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%d]X_rdk_profile: Exception caught %s \n", __FUNCTION__, __LINE__, e.what());
185  stMsgData->faultCode = fcInternalError;
186  return NOK;
187  }
188  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%d]X_rdk_profile: Exiting..\n", __FUNCTION__, __LINE__);
189  return ret;
190 }
191 
192 
193 
194 /************************************************************
195  * Description : Get the 'Device.X_RDK_WebPA_Server.URL' status.
196  * 'true(1)' if enabled or 'false(0)'
197  * Precondition : partner_default.json should be present.
198  * Input :
199 
200  * Return : OK -> Success
201  NOK -> Failure
202  value -> 0: false
203  -> 1: true
204 ************************************************************/
205 int X_rdk_profile::get_WebPA_Server_URL(HOSTIF_MsgData_t *stMsgData)
206 {
207  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%d]Entering..\n", __FUNCTION__, __LINE__);
208 
209  try {
210  m_bsStore->getValue(stMsgData);
211  } catch (const std::exception& e) {
212  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s:%d] Exception : %s\r\n",__FUNCTION__, __LINE__, e.what());
213  return NOK;
214  }
215  stMsgData->paramtype=hostIf_StringType;
216  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%d] The param name [ %s ], and value [ %s ] \r\n",__FUNCTION__, __LINE__,
217  stMsgData->paramName,stMsgData->paramValue );
218  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%d] Exiting..\n", __FUNCTION__, __LINE__);
219  return OK;
220 }
221 
222 
223 /************************************************************
224  * Description : Get the 'Device.X_RDK_WebPA_TokenServer.URL' status.
225  * 'true(1)' if enabled or 'false(0)'
226  * Precondition : partner_default.json should be present.
227  * Input :
228 
229  * Return : OK -> Success
230  NOK -> Failure
231  value -> 0: false
232  -> 1: true
233 ************************************************************/
234 int X_rdk_profile::get_WebPA_TokenServer_URL(HOSTIF_MsgData_t *stMsgData)
235 {
236  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%d]Entering..\n", __FUNCTION__, __LINE__);
237 
238  try {
239  m_bsStore->getValue(stMsgData);
240  } catch (const std::exception& e) {
241  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s:%d]Exception : %s\r\n",__FUNCTION__, __LINE__, e.what());
242  return NOK;
243  }
244  stMsgData->paramtype=hostIf_StringType;
245  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%d] The param name [ %s ], and value [ %s ] \r\n",__FUNCTION__, __LINE__,
246  stMsgData->paramName,stMsgData->paramValue );
247 
248  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%d] Exiting..\n", __FUNCTION__, __LINE__);
249  return OK;
250 }
251 
252 /************************************************************
253  * Description : Get the 'Device.X_RDK_WebPA_DNSText.URL' status.
254  * 'true(1)' if enabled or 'false(0)'
255  * Precondition : partner_default.json should be present.
256  * Input :
257 
258  * Return : OK -> Success
259  NOK -> Failure
260  value -> 0: false
261  -> 1: true
262 ************************************************************/
263 int X_rdk_profile::get_WebPA_DNSText_URL(HOSTIF_MsgData_t *stMsgData)
264 {
265  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%d]Entering..\n", __FUNCTION__, __LINE__);
266 
267  try {
268  m_bsStore->getValue(stMsgData);
269  } catch (const std::exception& e) {
270  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s:%d] Exception : %s\r\n",__FUNCTION__, __LINE__, e.what());
271  return NOK;
272  }
273  stMsgData->paramtype=hostIf_StringType;
274  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%d] The param name [ %s ], and value [ %s ] \r\n",__FUNCTION__, __LINE__,
275  stMsgData->paramName,stMsgData->paramValue );
276 
277  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%d] Exiting..\n", __FUNCTION__, __LINE__);
278  return OK;
279 }
280 
281 
282 int X_rdk_profile::set_WebPA_DNSText_URL(HOSTIF_MsgData_t * stMsgData)
283 {
284  m_bsStore->overrideValue(stMsgData);
285  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%d] The [ %s ] Set Successfully value as [ %s ]. \n",__FUNCTION__, __LINE__,
286  stMsgData->paramName, stMsgData->paramValue);
287  return OK;
288 }
289 
290 
291 /* End of doxygen group */
292 /**
293  * @}
294  */
295 
296 /* End of file xxx_api.c. */
297 
298 
299 /** @} */
300 /** @} */
XBSStore
Definition: XrdkCentralComBSStore.h:33
x_rdk_profile.h
The header file provides components Xrdk SDCard information APIs.
_HostIf_MsgData_t
Definition: hostIf_tr69ReqHandler.h:170
X_rdk_profile::handleSetMsg
int handleSetMsg(HOSTIF_MsgData_t *)
This function set the bluetooth profile attributes.
Definition: x_rdk_profile.cpp:97
_HostIf_MsgData_t::paramtype
HostIf_ParamType_t paramtype
Definition: hostIf_tr69ReqHandler.h:177
RDK_LOG
#define RDK_LOG
Definition: rdk_debug.h:258
_HostIf_MsgData_t::faultCode
faultCode_t faultCode
Definition: hostIf_tr69ReqHandler.h:179
_HostIf_MsgData_t::paramName
char paramName[(4 *1024)]
Definition: hostIf_tr69ReqHandler.h:171
_HostIf_MsgData_t::paramValue
char paramValue[(4 *1024)]
Definition: hostIf_tr69ReqHandler.h:172
X_rdk_profile
This class provides the TR-069 components Bluetooth devices information.
Definition: x_rdk_profile.h:59
X_rdk_profile::handleGetMsg
int handleGetMsg(HOSTIF_MsgData_t *)
This function get the bluetooth attributes such as name, profile, count and others for paired and con...
Definition: x_rdk_profile.cpp:147
X_rdk_profile::X_rdk_profile
X_rdk_profile()
Class default Constructor.
Definition: x_rdk_profile.cpp:83