Update sc_enrollee.c
[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                 return {};
744             }
745
746             /**
747              * Get network provisioning information for the device.
748              * Mediator can use this information to enquire & validate registration status with corresponding Network Vendor.
749              * The format is in JSON. The key indicates the meaning of value and the value is a
750              * corresponding information. Supported keys include: IMEI (IMEI Number), IMSI (IMSI Number),
751              * MCC_MNC(MCC & MNC Number), SN(Serial Number)
752              *
753              * @return Network Provisioning Information String.
754              */
755             std::string getNetworkProvisioningInfo() const
756             {
757                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
758                 for(auto child = children.begin(); child != children.end(); ++child)
759                 {
760                     if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
761                     {
762                         OCRepresentation rep;
763                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
764                         {
765                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
766                         }
767                         else
768                         {
769                             return std::string("");
770                         }
771
772                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_NETWORK_PROV_INFO))
773                         {
774                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_NETWORK_PROV_INFO);
775                         }
776                     }
777                 }
778                 return std::string("");
779             }
780
781             /**
782              * Get SSO List information for the device.
783              * The format is in JSON. The key indicates the meaning of value and the value is a
784              * corresponding information. Supported keys include: Available Count , Registered Count,
785              * Account List
786              *
787              * @return SSo List Information String.
788              */
789             std::string getSSOList() const
790             {
791                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
792                 for(auto child = children.begin(); child != children.end(); ++child)
793                 {
794                     if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
795                     {
796                         OCRepresentation rep;
797                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
798                         {
799                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
800                         }
801                         else
802                         {
803                             return std::string("");
804                         }
805
806                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_SSO_LIST))
807                         {
808                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_SSO_LIST);
809                         }
810                     }
811                 }
812                 return std::string("");
813             }
814
815             /**
816              * Get T&C status
817              * Indicates T&C is already agreed or not.
818              *
819              * @return T&C Status
820              *
821              * @see TC_STATUS
822              */
823             TC_STATUS getTCStatus()
824             {
825                 OCRepresentation rep;
826                 if(m_EasySetupRep.hasAttribute(OC_RSRVD_REPRESENTATION))
827                 {
828                     rep = m_EasySetupRep.getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
829                 }
830                 else
831                 {
832                     return TC_STATUS::TC_STATUS_NOT_SUPPORTED;
833                 }
834
835                 if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_TC_STATUS))
836                 {
837                     return static_cast<TC_STATUS>
838                             (rep.getValue<int>(SC_RSRVD_ES_VENDOR_TC_STATUS));
839                 }
840
841                 return TC_STATUS::TC_STATUS_NOT_SUPPORTED;
842             }
843
844             /**
845              * Get T&C Header
846              * T&C Header Information in json format
847              *
848              * @return T&C Header
849              */
850             std::string getTCHeader()
851             {
852                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
853                 for(auto child = children.begin(); child != children.end(); ++child)
854                 {
855                     if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
856                     {
857                         OCRepresentation rep;
858                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
859                         {
860                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
861                         }
862                         else
863                         {
864                             return std::string("");
865                         }
866
867                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_TC_HEADER))
868                         {
869                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_TC_HEADER);
870                         }
871                     }
872                 }
873                 return std::string("");
874             }
875
876             /**
877              * Get T&C Version
878              *
879              * @return T&C Version
880              */
881             std::string getTCVersion()
882             {
883                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
884                 for(auto child = children.begin(); child != children.end(); ++child)
885                 {
886                     if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
887                     {
888                         OCRepresentation rep;
889                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
890                         {
891                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
892                         }
893                         else
894                         {
895                             return std::string("");
896                         }
897
898                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_TC_VERSION))
899                         {
900                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_TC_VERSION);
901                         }
902                     }
903                 }
904                 return std::string("");
905             }
906
907             /**
908              * Get PnP Pin
909              *
910              * @return PnP Pin
911              */
912             std::string getPnpPin() const
913             {
914                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
915                 for(auto child = children.begin(); child != children.end(); ++child)
916                 {
917                     if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
918                     {
919                         OCRepresentation rep;
920                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
921                         {
922                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
923                         }
924                         else
925                         {
926                             return std::string("");
927                         }
928
929                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_PNP_PIN))
930                         {
931                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_PNP_PIN);
932                         }
933                     }
934                 }
935                 return std::string("");
936             }
937
938             /**
939              * Get a network connection state property of Enrollee.
940              *
941              * @return a network connection state property of Enrollee.
942              */
943             NETCONNECTION_STATE getNetConnectionState() const
944             {
945                 OCRepresentation rep;
946                 if(m_EasySetupRep.hasAttribute(OC_RSRVD_REPRESENTATION))
947                 {
948                     rep = m_EasySetupRep.getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
949                 }
950                 else
951                 {
952                     return NETCONNECTION_STATE::NET_STATE_INIT;
953                 }
954
955                 if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_NETCONNECTION_STATE))
956                 {
957                     return static_cast<NETCONNECTION_STATE>
958                                     (rep.getValue<int>(SC_RSRVD_ES_VENDOR_NETCONNECTION_STATE));
959                 }
960
961                 return NETCONNECTION_STATE::NET_STATE_INIT;
962             }
963
964             /**
965              * Get a BSSID of Enroller
966              *
967              * @return a BSSID of enroller
968              */
969             std::string getBSSID() const
970             {
971                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
972                 for(auto child = children.begin(); child != children.end(); ++child)
973                 {
974                     if(child->getUri().find(OC_RSRVD_ES_URI_WIFICONF) != std::string::npos)
975                     {
976                         OCRepresentation rep;
977                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
978                         {
979                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
980                         }
981                         else
982                         {
983                             return std::string("");
984                         }
985
986                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_BSSID))
987                         {
988                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_BSSID);
989                         }
990                     }
991                 }
992                 return {};
993             }
994
995             /**
996              * Get UTC date time
997              *
998              * @return UTC date time
999              */
1000             std::string getUTCDatetime() const
1001             {
1002                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
1003                 for(auto child = children.begin(); child != children.end(); ++child)
1004                 {
1005                     if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
1006                     {
1007                         OCRepresentation rep;
1008                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
1009                         {
1010                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
1011                         }
1012                         else
1013                         {
1014                             return std::string("");
1015                         }
1016
1017                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_UTC_DATE_TIME))
1018                         {
1019                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_UTC_DATE_TIME);
1020                         }
1021                     }
1022                 }
1023                 return {};
1024             }
1025
1026             /**
1027              * Get regional date time
1028              *
1029              * @return date time
1030              */
1031             std::string getRegionalDatetime() const
1032             {
1033                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
1034                 for(auto child = children.begin(); child != children.end(); ++child)
1035                 {
1036                     if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
1037                     {
1038                         OCRepresentation rep;
1039                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
1040                         {
1041                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
1042                         }
1043                         else
1044                         {
1045                             return std::string("");
1046                         }
1047
1048                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_REGIONAL_DATE_TIME))
1049                         {
1050                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_REGIONAL_DATE_TIME);
1051                         }
1052                     }
1053                 }
1054                 return {};
1055             }
1056
1057             /**
1058              * Get Samsung Easy Setup Protocol Version.
1059              *
1060              * Mediator can use this API to differentiate between Easy Setup Protcol supported by
1061              * Samsung Enrollee Devices.
1062              *
1063              * Example: Version Value for Tizen4.0: [\932.0\94]
1064              *
1065              * @return Easy Setup Protocol Version String.
1066              */
1067             std::string getESProtocolVersion() const
1068             {
1069                 std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
1070                 for(auto child = children.begin(); child != children.end(); ++child)
1071                 {
1072                     if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
1073                     {
1074                         OCRepresentation rep;
1075                         if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
1076                         {
1077                             rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
1078                         }
1079                         else
1080                         {
1081                             return std::string("");
1082                         }
1083
1084                         if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_ES_PROTOCOL_VERSION))
1085                         {
1086                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_ES_PROTOCOL_VERSION);
1087                         }
1088                     }
1089                 }
1090                 return std::string("");
1091             }
1092
1093         };
1094     }
1095 }
1096
1097 #endif //ESSC_COMMON_RICH_H_