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