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