Update ESSCCommon.h
[platform/upstream/iotivity.git] / service / easy-setup / mediator / richsdk / inc / ESSCCommon.h
1 //******************************************************************
2 //
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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 #ifndef ESSC_COMMON_RICH_H_
22 #define ESSC_COMMON_RICH_H_
23
24 #include "ESRichCommon.h"
25
26 using namespace OC;
27 using namespace std;
28
29 #define SC_RSRVD_ES_VENDOR_NETCONNECTION_STATE  "x.com.samsung.ncs"
30 #define SC_RSRVD_ES_VENDOR_DISCOVERY_CHANNEL    "x.com.samsung.chn"
31 #define SC_RSRVD_ES_VENDOR_DEVICE_TYPE          "x.com.samsung.dt"
32 #define SC_RSRVD_ES_VENDOR_DEVICE_SUBTYPE       "x.com.samsung.sdt"
33 #define SC_RSRVD_ES_VENDOR_LOCATION             "x.com.samsung.location"
34 #define SC_RSRVD_ES_VENDOR_CLIENTID             "x.com.samsung.clientid"
35 #define SC_RSRVD_ES_VENDOR_ACCOUNT              "x.com.samsung.account"
36 #define SC_RSRVD_ES_VENDOR_SSO_LIST            "x.com.samsung.ssolist"
37 #define SC_RSRVD_ES_VENDOR_ADDITIONAL_AUTH_CODE "x.com.samsung.aac"
38 #define SC_RSRVD_ES_VENDOR_ACCESS_TOKEN         "x.com.samsung.accesstoken"
39 #define SC_RSRVD_ES_VENDOR_REFRESH_TOKEN        "x.com.samsung.refreshtoken"
40 #define SC_RSRVD_ES_VENDOR_UTC_DATE_TIME        "x.com.samsung.datetime"
41 #define SC_RSRVD_ES_VENDOR_REGIONAL_DATE_TIME   "x.com.samsung.regionaldatetime"
42 #define SC_RSRVD_ES_VENDOR_BSSID                "x.com.samsung.bssid"
43 #define SC_RSRVD_ES_VENDOR_USERID               "x.com.samsung.uid"
44 #define SC_RSRVD_ES_VENDOR_REGISTER_MOBILE_DEV  "x.com.samsung.rmd"
45 #define SC_RSRVD_ES_VENDOR_REGISTER_SET_DEV     "x.com.samsung.rsd"
46 #define SC_RSRVD_ES_VENDOR_NETWORK_PROV_INFO    "x.com.samsung.npi"
47 #define SC_RSRVD_ES_VENDOR_TC_STATUS            "x.com.samsung.tcstatus"
48 #define SC_RSRVD_ES_VENDOR_TC_HEADER            "x.com.samsung.tcheader"
49 #define SC_RSRVD_ES_VENDOR_TC_VERSION           "x.com.samsung.tcversion"
50 #define SC_RSRVD_ES_VENDOR_TC_RESULT            "x.com.samsung.tcresult"
51 #define SC_RSRVD_ES_VENDOR_PNP_PIN              "x.com.samsung.pnppin"
52 #define SC_RSRVD_ES_VENDOR_MODEL_NUMBER         "x.com.samsung.modelnumber"
53 #define SC_RSRVD_ES_VENDOR_LANGUAGE             "x.com.samsung.language"
54 #define SC_RSRVD_ES_VENDOR_COUNTRY              "x.com.samsung.country"
55 #define SC_RSRVD_ES_VENDOR_GPSLOCATION          "x.com.samsung.gpslocation"
56 #define SC_RSRVD_ES_VENDOR_ES_PROTOCOL_VERSION  "x.com.samsung.espv"
57 #define SC_RSRVD_ES_VENDOR_CANDIDATEAPS         "x.com.samsung.candidateaps"
58 #define SC_RSRVD_ES_VENDOR_SSID                 "x.com.samsung.ssid"
59 #define SC_RSRVD_ES_VENDOR_PASSPHRASE           "x.com.samsung.passphrase"
60 #define SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL    "x.com.samsung.channel"
61
62 namespace OIC
63 {
64     namespace Service
65     {
66
67         #define INVALID_DISCOVERY_CHANNEL -1
68
69         typedef enum
70         {
71             NET_STATE_INIT = -1,                /**< Init state **/
72             NET_STATE_WIRED_CONNECTED = 0,      /**< Wired connected **/
73             NET_STATE_WIRELESS_CONNECTED,       /**< Wireless connected **/
74             NET_STATE_NOT_CONNECTED             /**< Not connected, at all **/
75         } NETCONNECTION_STATE;
76
77         typedef enum
78         {
79             TC_STATUS_NOT_SUPPORTED = 0,
80             TC_STATUS_ALREADY_AGREED,
81             TC_STATUS_NEED_TO_AGREE,
82             TC_STATUS_DOWNLOADING_TC,
83             TC_STATUS_SUCCESS_TO_DOWNLOAD_TC,
84             TC_STATUS_FAIL_TO_DOWNLOAD_TC,
85             TC_STATUS_DISAGREED_WITH_TC,
86             TC_STATUS_GEO_BLOCKED,
87             TC_STATUS_TIMEOUT_TO_AGREE
88         } TC_STATUS;
89
90         typedef struct SCCandidateAPInfo
91         {
92             std::string ssid;
93             std::string passphrase;
94             int channel;
95             std::string bssid;
96         } SCCandidateAPInfo;
97
98         /**
99          * @brief Properties of provisioning resource. It includes a provisioning status and last
100          *        error code.
101          */
102         class SCEnrolleeStatus : public EnrolleeStatus
103         {
104         public:
105             SCEnrolleeStatus(const EnrolleeStatus&& parent) : EnrolleeStatus(parent)
106             {
107             }
108
109             /**
110              * Get a network connection state property of Enrollee.
111              *
112              * @return a network connection state property of Enrollee.
113              */
114             NETCONNECTION_STATE getNetConnectionState() const
115             {
116                 if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_NETCONNECTION_STATE))
117                 {
118                     return static_cast<NETCONNECTION_STATE>
119                                     (m_rep.getValue<int>(SC_RSRVD_ES_VENDOR_NETCONNECTION_STATE));
120                 }
121                 return NETCONNECTION_STATE::NET_STATE_INIT;
122             }
123
124             /**
125              * Get T&C status
126              *
127              * @return T&C Status
128              *
129              * @see TC_STATUS
130              */
131             TC_STATUS getTCStatus()
132             {
133                 if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_TC_STATUS))
134                 {
135                     return static_cast<TC_STATUS>
136                             (m_rep.getValue<int>(SC_RSRVD_ES_VENDOR_TC_STATUS));
137                 }
138
139                 return TC_STATUS::TC_STATUS_NOT_SUPPORTED;
140             }
141         };
142
143         /**
144          * @brief Data class stored for Device property provisioning which includes a WiFi
145          *        and device configuration provisioning
146          */
147         class SCDeviceProp : public DeviceProp
148         {
149         public:
150
151             /**
152              * Set DevConf resource properties to be delivered to Enrollee
153              *
154              * @param language IETF language tag using ISO 639X
155              * @param country ISO Country Code (ISO 3166-1 Alpha-2)
156              * @param location location information
157              */
158             void setDevConfProp(string language, string country, string location)
159             {
160                 m_rep.setValue(SC_RSRVD_ES_VENDOR_LANGUAGE, language);
161                 m_rep.setValue(SC_RSRVD_ES_VENDOR_COUNTRY, country);
162                 m_rep.setValue(SC_RSRVD_ES_VENDOR_GPSLOCATION, location);
163             }
164
165             /**
166              * Get a language to be set. A language is expressed in IETF language tag
167              * using ISO 639X.
168              *
169              * @return a language to be set
170              */
171             std::string getLanguage() const
172             {
173                 if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_LANGUAGE))
174                 {
175                     return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_LANGUAGE);
176                 }
177                 return std::string("");
178             }
179
180             /**
181              * Get a country to be set. A country is expressed in ISO Country Code
182              * (ISO 3166-1 Alpha-2)
183              *
184              * @return a country to be set
185              */
186             std::string getCountry() const
187             {
188                 if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_COUNTRY))
189                 {
190                     return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_COUNTRY);
191                 }
192                 return std::string("");
193             }
194
195             /**
196              * Get a location to be set. A location is GPS information
197              *
198              * @return a country to be set
199              */
200             std::string getLocation() const
201             {
202                 if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_GPSLOCATION))
203                 {
204                     return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_GPSLOCATION);
205                 }
206                 return std::string("");
207             }
208
209             /**
210              * Set discoveryChannel properties to be delivered to Enrollee
211              *
212              * @param discoveryChannel Channel of the Enroller for fast discover
213              */
214             void setDiscoveryChannel(int discoveryChannel)
215             {
216                 m_rep.setValue(SC_RSRVD_ES_VENDOR_DISCOVERY_CHANNEL, discoveryChannel);
217             }
218
219             /**
220              * Get an channel of Enroller
221              *
222              * @return an channel of enroller
223              */
224             int getDiscoveryChannel()
225             {
226                 if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_DISCOVERY_CHANNEL))
227                 {
228                     return m_rep.getValue<int>(SC_RSRVD_ES_VENDOR_DISCOVERY_CHANNEL);
229                 }
230                 return INVALID_DISCOVERY_CHANNEL;
231             }
232
233             /**
234              * Set samsung-specific location property to be delivered to Enrollee
235              *
236              * @param locations a set of location information
237              */
238             void setSCLocation(const std::vector<std::string> &locations)
239             {
240                 m_rep.setValue(SC_RSRVD_ES_VENDOR_LOCATION, locations);
241             }
242
243             /**
244              * Set samsung account property to be delivered to Enrollee (for TV)
245              *
246              * @param account a samsung account ID information (for TV)
247              */
248             void setSCAccount(const std::string &account)
249             {
250                 m_rep.setValue(SC_RSRVD_ES_VENDOR_ACCOUNT, account);
251             }
252
253             /**
254              * Set UTC date time property to be delivered to Enrollee.
255              * The format is "[yyyy]-[mm]-[dd]T[hh]:[mm]:[ss]Z"
256              *
257              * @param datetime UTC date time
258              */
259             void setUTCDatetime(const std::string &datetime)
260             {
261                 m_rep.setValue(SC_RSRVD_ES_VENDOR_UTC_DATE_TIME, datetime);
262             }
263
264             /**
265              * Get UTC date time property
266              *
267              * @return UTC date time
268              */
269             std::string getUTCDatetime()
270             {
271                 if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_UTC_DATE_TIME))
272                 {
273                     return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_UTC_DATE_TIME);
274                 }
275                 return {};
276             }
277
278             /**
279              * Set regional date time property to be delivered to Enrollee.
280              * The format is "[yyyy]-[mm]-[dd]T[hh]:[mm]:[ss]Z"
281              *
282              * @param datetime Regional date time
283              */
284             void setRegionalDatetime(const std::string &datetime)
285             {
286                 m_rep.setValue(SC_RSRVD_ES_VENDOR_REGIONAL_DATE_TIME, datetime);
287             }
288
289             /**
290              * Get regional date time property
291              *
292              * @return Date time
293              */
294             std::string getRegionalDatetime()
295             {
296                 if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_REGIONAL_DATE_TIME))
297                 {
298                     return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_REGIONAL_DATE_TIME);
299                 }
300                 return {};
301             }
302
303             /**
304              * Set Mobile device information used for 'register TV'
305              * The format is in json. The key indicates the meaning of value and the value is a
306              * corresponding information. Supported keys include: wm(Wifi MAC), pm(P2P MAC),
307              * bm(BT MAC), dn(device name), dt(device type), it(icon type).
308              *
309              * @param regMobileDev register mobile device
310              */
311             void setRegisterMobileDevice(const std::string &regMobileDev)
312             {
313                 m_rep.setValue(SC_RSRVD_ES_VENDOR_REGISTER_MOBILE_DEV, regMobileDev);
314             }
315
316             /**
317              * Get Mobile device information used for 'register TV'
318              *
319              * @return register mobile device
320              */
321             std::string getRegisterMobileDevice()
322             {
323                 if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_REGISTER_MOBILE_DEV))
324                 {
325                     return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_REGISTER_MOBILE_DEV);
326                 }
327                 return {};
328             }
329
330             /**
331              * Set a BSSID of Enroller
332              *
333              * @param a BSSID of enroller
334              */
335             void setBSSID(const std::string &bssid)
336             {
337                 m_rep.setValue(SC_RSRVD_ES_VENDOR_BSSID, bssid);
338             }
339
340             /**
341              * Get a BSSID of Enroller
342              *
343              * @return a BSSID of enroller
344              */
345             std::string getBSSID()
346             {
347                 if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_BSSID))
348                 {
349                     return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_BSSID);
350                 }
351                 return {};
352             }
353
354             /**
355              * Set SSO list information
356              *
357              * @param  SSO list
358              */
359             void setSSOList(const std::string &ssoList)
360             {
361                 m_rep.setValue(SC_RSRVD_ES_VENDOR_SSO_LIST, ssoList);
362             }
363
364             /**
365              * Get SSO List information which is registered in device
366              *
367              * @return SSO List
368              */
369             std::string getSSOList()
370             {
371                 if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_SSO_LIST))
372                 {
373                     return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_SSO_LIST);
374                 }
375                 return {};
376             }
377
378              /**
379              * Set Candidate AP information which is stored.
380              *
381              * @param clientID - Client service ID
382              */
383             void setCandidateAPList(SCCandidateAPInfo *candidateInfo,int numCandidateAP)
384             {
385                 std::vector<OC::OCRepresentation> candidateAPList;
386                 for (int i=0;i<numCandidateAP;i++)
387                 {
388                             OCRepresentation candidateListInfo;
389                             candidateListInfo.setValue(SC_RSRVD_ES_VENDOR_BSSID, candidateInfo[i].bssid);
390                             candidateListInfo.setValue(SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL, candidateInfo[i].channel);
391                             candidateListInfo.setValue(SC_RSRVD_ES_VENDOR_PASSPHRASE, candidateInfo[i].passphrase);
392                             candidateListInfo.setValue(SC_RSRVD_ES_VENDOR_SSID, candidateInfo[i].ssid);
393                             candidateAPList.push_back(candidateListInfo);
394                 }
395                 m_rep.setValue(SC_RSRVD_ES_VENDOR_CANDIDATEAPS, candidateAPList);
396             }
397
398              /**
399              * Get Candidate AP information which is registered in device.
400              *
401              * @return SCCandidateAPInfo list.
402              */
403             std::vector<SCCandidateAPInfo> getCandidateAPList()
404             {
405                 if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATEAPS))
406                 {
407                     std::vector<OC::OCRepresentation> candidateInfo=
408                                 m_rep.getValue<std::vector<OC::OCRepresentation>>(SC_RSRVD_ES_VENDOR_CANDIDATEAPS);
409                     std::vector<SCCandidateAPInfo> postcandidateInfo;
410                     for(std::vector<OC::OCRepresentation>::iterator it = candidateInfo.begin();
411                               it != candidateInfo.end(); ++it)
412                     {
413                         OC::OCRepresentation rep = *it;
414                         SCCandidateAPInfo candidateInfotemp;
415                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_SSID))
416                         {
417                             candidateInfotemp.ssid=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_SSID);
418                         }
419                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_PASSPHRASE))
420                         {
421                             candidateInfotemp.passphrase=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_PASSPHRASE);
422                         }
423                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL))
424                         {
425                             candidateInfotemp.channel=rep.getValue<int>(SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL);
426
427                         }
428                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_BSSID))
429                         {
430                             candidateInfotemp.bssid=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_BSSID);
431                         }
432                         postcandidateInfo.push_back(candidateInfotemp);
433                     }
434                     return postcandidateInfo;
435                 }
436                 return {};
437             }
438         };
439
440         class SCCloudProp : public CloudProp
441         {
442             public:
443             /**
444              * Set samsung-specific client service ID property to be delivered to Enrollee
445              *
446              * @param clientID - Client service ID
447              */
448             void setClientID(const std::string &clientID)
449             {
450                 m_rep.setValue(SC_RSRVD_ES_VENDOR_CLIENTID, clientID);
451             }
452
453             /**
454              * Get samsung-specific client service ID property.
455              *
456              * @return Client service ID.
457              */
458             std::string getClientID()
459             {
460                 if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_CLIENTID))
461                 {
462                     return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_CLIENTID);
463                 }
464                 return {};
465             }
466
467             /**
468              * Set samsung-specific additional AuthCode property to be delivered to Enrollee (for TV/AV sign up VD SSO)
469              *
470              * @param additionalAuthcode - additional AuthCode (for TV/AV sign up VD SSO)
471              */
472             void setAdditionalAuthCode(const std::string &additionalAuthcode)
473             {
474                 m_rep.setValue(SC_RSRVD_ES_VENDOR_ADDITIONAL_AUTH_CODE, additionalAuthcode);
475             }
476
477             /**
478              * Set samsung-specific refresh token property to be delivered to Enrollee
479              *
480              * @param refreshtoken - Refresh token.
481              */
482             void setRefreshToken(const std::string &refreshtoken)
483             {
484                 m_rep.setValue(SC_RSRVD_ES_VENDOR_REFRESH_TOKEN, refreshtoken);
485             }
486
487             /**
488              * Get samsung-specific refresh token property.
489              *
490              * @return refreshtoken - Refresh token.
491              */
492             std::string getRefreshToken()
493             {
494                 if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_REFRESH_TOKEN))
495                 {
496                     return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_REFRESH_TOKEN);
497                 }
498                 return {};
499             }
500
501             /**
502              * Set samsung-specific user ID property to be delivered to Enrollee
503              *
504              * @param uid - user ID.
505              */
506             void setUserID(const std::string &uid)
507             {
508                 m_rep.setValue(SC_RSRVD_ES_VENDOR_USERID, uid);
509             }
510
511             /**
512              * Get samsung-specific user ID property
513              *
514              * @return uid - user ID.
515              */
516             std::string getUserID()
517             {
518                 if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_USERID))
519                 {
520                     return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_USERID);
521                 }
522                 return {};
523             }
524
525             /**
526              * Set T&C Result
527              * Indicates T&C result by mobile user in json format.
528              *
529              * @param uid - user ID.
530              */
531             void setTCResult(const std::string &result)
532             {
533                 m_rep.setValue(SC_RSRVD_ES_VENDOR_TC_RESULT, result);
534             }
535
536             /**
537              * Get T&C Result
538              *
539              * @return uid - user ID.
540              */
541             std::string getTCResult()
542             {
543                 if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_TC_RESULT))
544                 {
545                     return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_TC_RESULT);
546                 }
547                 return {};
548             }
549         };
550
551         /**
552          * @breif This provide a set of getter APIs from received response for getConfiguration().
553          *        Received information includes a device name, WiFi supported mode, and frequency.
554          *        Additionally, you can know if Enrollee can be access to cloud server with this
555          *        object.
556          */
557         class SCEnrolleeConf : public EnrolleeConf
558         {
559         public:
560             SCEnrolleeConf(const EnrolleeConf&& parent) : EnrolleeConf(parent)
561             {
562             }
563
564             /**
565              * Get a model number of Enrollee.
566              *
567              * @return a model number of Enrollee
568              */
569             std::string getModelNumber() const
570             {
571                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
572                 for(auto child = children.begin(); child != children.end(); ++child)
573                 {
574                     if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
575                     {
576                         OCRepresentation rep;
577                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
578                         {
579                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
580                         }
581                         else
582                         {
583                             return std::string("");
584                         }
585
586                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_MODEL_NUMBER))
587                         {
588                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_MODEL_NUMBER);
589                         }
590                     }
591                 }
592                 return std::string("");
593             }
594
595             /**
596              * Get a device type of Enrollee.
597              * It is Device's human-friendly name like device model name.
598              *
599              * @return a device type of Enrollee
600              */
601             std::string getDeviceType() const
602             {
603                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
604                 for(auto child = children.begin(); child != children.end(); ++child)
605                 {
606                     if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
607                     {
608                         OCRepresentation rep;
609                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
610                         {
611                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
612                         }
613                         else
614                         {
615                             return std::string("");
616                         }
617
618                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_DEVICE_TYPE))
619                         {
620                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_DEVICE_TYPE);
621                         }
622                     }
623                 }
624                 return std::string("");
625             }
626
627             /**
628              * Get a device sub-type of Enrollee.
629              * It is Device's human-friendly name like device model name.
630              *
631              * @return a device sub-type of Enrollee
632              */
633             std::string getDeviceSubType() const
634             {
635                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
636                 for(auto child = children.begin(); child != children.end(); ++child)
637                 {
638                     if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
639                     {
640                         OCRepresentation rep;
641                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
642                         {
643                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
644                         }
645                         else
646                         {
647                             return std::string("");
648                         }
649
650                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_DEVICE_SUBTYPE))
651                         {
652                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_DEVICE_SUBTYPE);
653                         }
654                     }
655                 }
656                 return std::string("");
657             }
658
659             /**
660              * Get Set device information used for 'register TV'
661              * The format is in json. The key indicates the meaning of value and the value is a
662              * corresponding information. Supported keys include: wm(Wifi MAC), pm(P2P MAC),
663              * bm(BT MAC), rt(Remote Type)
664              *
665              * @return Register Set Device
666              */
667             std::string getRegisterSetDevice() const
668             {
669                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
670                 for(auto child = children.begin(); child != children.end(); ++child)
671                 {
672                     if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
673                     {
674                         OCRepresentation rep;
675                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
676                         {
677                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
678                         }
679                         else
680                         {
681                             return std::string("");
682                         }
683
684                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_REGISTER_SET_DEV))
685                         {
686                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_REGISTER_SET_DEV);
687                         }
688                     }
689                 }
690                 return std::string("");
691             }
692
693             /**
694             * Get Candidate AP information which is registered in device.
695             *
696             * @return SCCandidateAPInfo list.
697             */
698             std::vector<SCCandidateAPInfo> getCandidateAPList() const
699             {
700                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
701                 for(auto child = children.begin(); child != children.end(); ++child)
702                 {
703                     if(child->getUri().find(OC_RSRVD_ES_URI_WIFICONF) != std::string::npos)
704                     {
705                         OCRepresentation rep;
706                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
707                         {
708                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
709                         }
710
711                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATEAPS))
712                         {
713                             std::vector<OC::OCRepresentation> candidateInfo=rep.getValue<std::vector<OC::OCRepresentation>>(SC_RSRVD_ES_VENDOR_CANDIDATEAPS);
714                             std::vector<SCCandidateAPInfo> postcandidateInfo;
715                             for(std::vector<OC::OCRepresentation>::iterator it = candidateInfo.begin();
716                                       it != candidateInfo.end(); ++it)
717                             {
718                                 OC::OCRepresentation rep = *it;
719                                 SCCandidateAPInfo candidateInfotemp;
720                                 if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_SSID))
721                                 {
722                                     candidateInfotemp.ssid=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_SSID);
723                                 }
724                                 if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_PASSPHRASE))
725                                 {
726                                     candidateInfotemp.passphrase=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_PASSPHRASE);
727                                 }
728                                 if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL))
729                                 {
730                                     candidateInfotemp.channel=rep.getValue<int>(SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL);
731
732                                 }
733                                 if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_BSSID))
734                                 {
735                                     candidateInfotemp.bssid=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_BSSID);
736                                 }
737                                 postcandidateInfo.push_back(candidateInfotemp);
738                             }
739                             return postcandidateInfo;
740                         }
741                     }
742                 }
743             }
744
745             /**
746              * Get network provisioning information for the device.
747              * Mediator can use this information to enquire & validate registration status with corresponding Network Vendor.
748              * The format is in JSON. The key indicates the meaning of value and the value is a
749              * corresponding information. Supported keys include: IMEI (IMEI Number), IMSI (IMSI Number),
750              * MCC_MNC(MCC & MNC Number), SN(Serial Number)
751              *
752              * @return Network Provisioning Information String.
753              */
754             std::string getNetworkProvisioningInfo() const
755             {
756                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
757                 for(auto child = children.begin(); child != children.end(); ++child)
758                 {
759                     if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
760                     {
761                         OCRepresentation rep;
762                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
763                         {
764                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
765                         }
766                         else
767                         {
768                             return std::string("");
769                         }
770
771                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_NETWORK_PROV_INFO))
772                         {
773                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_NETWORK_PROV_INFO);
774                         }
775                     }
776                 }
777                 return std::string("");
778             }
779
780             /**
781              * Get SSO List information for the device.
782              * The format is in JSON. The key indicates the meaning of value and the value is a
783              * corresponding information. Supported keys include: Available Count , Registered Count,
784              * Account List
785              *
786              * @return SSo List Information String.
787              */
788             std::string getSSOList() const
789             {
790                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
791                 for(auto child = children.begin(); child != children.end(); ++child)
792                 {
793                     if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
794                     {
795                         OCRepresentation rep;
796                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
797                         {
798                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
799                         }
800                         else
801                         {
802                             return std::string("");
803                         }
804
805                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_SSO_LIST))
806                         {
807                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_SSO_LIST);
808                         }
809                     }
810                 }
811                 return std::string("");
812             }
813
814             /**
815              * Get T&C status
816              * Indicates T&C is already agreed or not.
817              *
818              * @return T&C Status
819              *
820              * @see TC_STATUS
821              */
822             TC_STATUS getTCStatus()
823             {
824                 OCRepresentation rep;
825                 if(m_EasySetupRep.hasAttribute(OC_RSRVD_REPRESENTATION))
826                 {
827                     rep = m_EasySetupRep.getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
828                 }
829                 else
830                 {
831                     return TC_STATUS::TC_STATUS_NOT_SUPPORTED;
832                 }
833
834                 if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_TC_STATUS))
835                 {
836                     return static_cast<TC_STATUS>
837                             (rep.getValue<int>(SC_RSRVD_ES_VENDOR_TC_STATUS));
838                 }
839
840                 return TC_STATUS::TC_STATUS_NOT_SUPPORTED;
841             }
842
843             /**
844              * Get T&C Header
845              * T&C Header Information in json format
846              *
847              * @return T&C Header
848              */
849             std::string getTCHeader()
850             {
851                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
852                 for(auto child = children.begin(); child != children.end(); ++child)
853                 {
854                     if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
855                     {
856                         OCRepresentation rep;
857                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
858                         {
859                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
860                         }
861                         else
862                         {
863                             return std::string("");
864                         }
865
866                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_TC_HEADER))
867                         {
868                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_TC_HEADER);
869                         }
870                     }
871                 }
872                 return std::string("");
873             }
874
875             /**
876              * Get T&C Version
877              *
878              * @return T&C Version
879              */
880             std::string getTCVersion()
881             {
882                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
883                 for(auto child = children.begin(); child != children.end(); ++child)
884                 {
885                     if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
886                     {
887                         OCRepresentation rep;
888                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
889                         {
890                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
891                         }
892                         else
893                         {
894                             return std::string("");
895                         }
896
897                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_TC_VERSION))
898                         {
899                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_TC_VERSION);
900                         }
901                     }
902                 }
903                 return std::string("");
904             }
905
906             /**
907              * Get PnP Pin
908              *
909              * @return PnP Pin
910              */
911             std::string getPnpPin() const
912             {
913                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
914                 for(auto child = children.begin(); child != children.end(); ++child)
915                 {
916                     if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
917                     {
918                         OCRepresentation rep;
919                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
920                         {
921                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
922                         }
923                         else
924                         {
925                             return std::string("");
926                         }
927
928                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_PNP_PIN))
929                         {
930                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_PNP_PIN);
931                         }
932                     }
933                 }
934                 return std::string("");
935             }
936
937             /**
938              * Get a network connection state property of Enrollee.
939              *
940              * @return a network connection state property of Enrollee.
941              */
942             NETCONNECTION_STATE getNetConnectionState() const
943             {
944                 OCRepresentation rep;
945                 if(m_EasySetupRep.hasAttribute(OC_RSRVD_REPRESENTATION))
946                 {
947                     rep = m_EasySetupRep.getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
948                 }
949                 else
950                 {
951                     return NETCONNECTION_STATE::NET_STATE_INIT;
952                 }
953
954                 if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_NETCONNECTION_STATE))
955                 {
956                     return static_cast<NETCONNECTION_STATE>
957                                     (rep.getValue<int>(SC_RSRVD_ES_VENDOR_NETCONNECTION_STATE));
958                 }
959
960                 return NETCONNECTION_STATE::NET_STATE_INIT;
961             }
962
963             /**
964              * Get a BSSID of Enroller
965              *
966              * @return a BSSID of enroller
967              */
968             std::string getBSSID() const
969             {
970                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
971                 for(auto child = children.begin(); child != children.end(); ++child)
972                 {
973                     if(child->getUri().find(OC_RSRVD_ES_URI_WIFICONF) != std::string::npos)
974                     {
975                         OCRepresentation rep;
976                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
977                         {
978                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
979                         }
980                         else
981                         {
982                             return std::string("");
983                         }
984
985                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_BSSID))
986                         {
987                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_BSSID);
988                         }
989                     }
990                 }
991                 return {};
992             }
993
994             /**
995              * Get UTC date time
996              *
997              * @return UTC date time
998              */
999             std::string getUTCDatetime() const
1000             {
1001                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
1002                 for(auto child = children.begin(); child != children.end(); ++child)
1003                 {
1004                     if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
1005                     {
1006                         OCRepresentation rep;
1007                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
1008                         {
1009                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
1010                         }
1011                         else
1012                         {
1013                             return std::string("");
1014                         }
1015
1016                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_UTC_DATE_TIME))
1017                         {
1018                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_UTC_DATE_TIME);
1019                         }
1020                     }
1021                 }
1022                 return {};
1023             }
1024
1025             /**
1026              * Get regional date time
1027              *
1028              * @return date time
1029              */
1030             std::string getRegionalDatetime() const
1031             {
1032                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
1033                 for(auto child = children.begin(); child != children.end(); ++child)
1034                 {
1035                     if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
1036                     {
1037                         OCRepresentation rep;
1038                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
1039                         {
1040                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
1041                         }
1042                         else
1043                         {
1044                             return std::string("");
1045                         }
1046
1047                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_REGIONAL_DATE_TIME))
1048                         {
1049                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_REGIONAL_DATE_TIME);
1050                         }
1051                     }
1052                 }
1053                 return {};
1054             }
1055
1056             /**
1057              * Get Samsung Easy Setup Protocol Version.
1058              *
1059              * Mediator can use this API to differentiate between Easy Setup Protcol supported by
1060              * Samsung Enrollee Devices.
1061              *
1062              * Example: Version Value for Tizen4.0: [\932.0\94]
1063              *
1064              * @return Easy Setup Protocol Version String.
1065              */
1066             std::string getESProtocolVersion() const
1067             {
1068                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
1069                 for(auto child = children.begin(); child != children.end(); ++child)
1070                 {
1071                     if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
1072                     {
1073                         OCRepresentation rep;
1074                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
1075                         {
1076                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
1077                         }
1078                         else
1079                         {
1080                             return std::string("");
1081                         }
1082
1083                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_ES_PROTOCOL_VERSION))
1084                         {
1085                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_ES_PROTOCOL_VERSION);
1086                         }
1087                     }
1088                 }
1089                 return std::string("");
1090             }
1091
1092         };
1093     }
1094 }
1095
1096 #endif //ESSC_COMMON_RICH_H_