Modified additional field
[platform/upstream/iotivity.git] / service / easy-setup / mediator / richsdk / inc / ESSCCommon.h
index 1df7cb6..d52cd26 100644 (file)
@@ -33,8 +33,11 @@ using namespace std;
 #define SC_RSRVD_ES_VENDOR_LOCATION             "x.com.samsung.location"
 #define SC_RSRVD_ES_VENDOR_CLIENTID             "x.com.samsung.clientid"
 #define SC_RSRVD_ES_VENDOR_ACCOUNT              "x.com.samsung.account"
-#define SC_RSRVD_ES_VENDOR_SSO_LIST            "x.com.samsung.ssolist"
+#define SC_RSRVD_ES_VENDOR_SSO_LIST             "x.com.samsung.ssolist"
 #define SC_RSRVD_ES_VENDOR_ADDITIONAL_AUTH_CODE "x.com.samsung.aac"
+#define SC_RSRVD_ES_VENDOR_SA_API_SERVER        "x.com.samsung.saapiserver"
+#define SC_RSRVD_ES_VENDOR_SA_AUTH_SERVER       "x.com.samsung.saauthserver"
+#define SC_RSRVD_ES_VENDOR_SA_DEVICE_SECURITY_CODE "x.com.samsung.sadsc"
 #define SC_RSRVD_ES_VENDOR_ACCESS_TOKEN         "x.com.samsung.accesstoken"
 #define SC_RSRVD_ES_VENDOR_REFRESH_TOKEN        "x.com.samsung.refreshtoken"
 #define SC_RSRVD_ES_VENDOR_UTC_DATE_TIME        "x.com.samsung.datetime"
@@ -54,7 +57,21 @@ using namespace std;
 #define SC_RSRVD_ES_VENDOR_COUNTRY              "x.com.samsung.country"
 #define SC_RSRVD_ES_VENDOR_GPSLOCATION          "x.com.samsung.gpslocation"
 #define SC_RSRVD_ES_VENDOR_ES_PROTOCOL_VERSION  "x.com.samsung.espv"
-
+#define SC_RSRVD_ES_VENDOR_MODEL_NUMBER_OLD     "mnmo"
+#define SC_RSRVD_ES_VENDOR_LANGUAGE_OLD         "lang"
+#define SC_RSRVD_ES_VENDOR_COUNTRY_OLD          "ctry"
+#define SC_RSRVD_ES_VENDOR_GPSLOCATION_OLD      "loc"
+#define SC_RSRVD_ES_VENDOR_SERVER_ID            "x.com.samsung.serverid"
+#define SC_RSRVD_ES_VENDOR_TIMEZONE_ID          "x.com.samsung.timezoneid"
+#define SC_RSRVD_ES_VENDOR_HIDDEN               "x.com.samsung.hidden"
+#define SC_RSRVD_ES_VENDOR_HUB_ID               "x.com.samsung.hubid"
+#define SC_RSRVD_ES_VENDOR_DEPLOY_ENVIRONMENT   "x.com.samsung.deployenv"
+#define SC_RSRVD_ES_VENDOR_IATT                 "x.com.samsung.iatt"
+#define SC_RSRVD_ES_VENDOR_CANDIDATEAPS         "x.com.samsung.candidateaps"
+#define SC_RSRVD_ES_VENDOR_CANDIDATE_SSID       "ssid"
+#define SC_RSRVD_ES_VENDOR_CANDIDATE_PASSPHRASE "passphrase"
+#define SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL    "channel"
+#define SC_RSRVD_ES_VENDOR_CANDIDATE_BSSID      "bssid"
 
 namespace OIC
 {
@@ -84,6 +101,14 @@ namespace OIC
             TC_STATUS_TIMEOUT_TO_AGREE
         } TC_STATUS;
 
+        typedef struct SCCandidateAPInfo
+        {
+            std::string ssid;
+            std::string passphrase;
+            int channel;
+            std::string bssid;
+        } SCCandidateAPInfo;
+
         /**
          * @brief Properties of provisioning resource. It includes a provisioning status and last
          *        error code.
@@ -149,6 +174,11 @@ namespace OIC
                 m_rep.setValue(SC_RSRVD_ES_VENDOR_LANGUAGE, language);
                 m_rep.setValue(SC_RSRVD_ES_VENDOR_COUNTRY, country);
                 m_rep.setValue(SC_RSRVD_ES_VENDOR_GPSLOCATION, location);
+
+               /* [CONPRO-888] Support backward compatibility */
+                m_rep.setValue(SC_RSRVD_ES_VENDOR_LANGUAGE_OLD, language);
+                m_rep.setValue(SC_RSRVD_ES_VENDOR_COUNTRY_OLD, country);
+                m_rep.setValue(SC_RSRVD_ES_VENDOR_GPSLOCATION_OLD, location);
             }
 
             /**
@@ -163,6 +193,10 @@ namespace OIC
                 {
                     return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_LANGUAGE);
                 }
+                else if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_LANGUAGE_OLD))
+                {
+                    return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_LANGUAGE_OLD);
+                }
                 return std::string("");
             }
 
@@ -178,6 +212,10 @@ namespace OIC
                 {
                     return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_COUNTRY);
                 }
+                else if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_COUNTRY_OLD))
+                {
+                    return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_COUNTRY_OLD);
+                }
                 return std::string("");
             }
 
@@ -192,6 +230,10 @@ namespace OIC
                 {
                     return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_GPSLOCATION);
                 }
+                else if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_GPSLOCATION_OLD))
+                {
+                    return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_GPSLOCATION_OLD);
+                }
                 return std::string("");
             }
 
@@ -363,6 +405,116 @@ namespace OIC
                 }
                 return {};
             }
+
+             /**
+             * Set Candidate AP information which is stored.
+             *
+             * @param clientID - Client service ID
+             */
+            void setCandidateAPList(SCCandidateAPInfo *candidateInfo,int numCandidateAP)
+            {
+                std::vector<OC::OCRepresentation> candidateAPList;
+                for (int i=0;i<numCandidateAP;i++)
+                {
+                            OCRepresentation candidateListInfo;
+                            candidateListInfo.setValue(SC_RSRVD_ES_VENDOR_CANDIDATE_BSSID, candidateInfo[i].bssid);
+                            candidateListInfo.setValue(SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL, candidateInfo[i].channel);
+                            candidateListInfo.setValue(SC_RSRVD_ES_VENDOR_CANDIDATE_PASSPHRASE, candidateInfo[i].passphrase);
+                            candidateListInfo.setValue(SC_RSRVD_ES_VENDOR_CANDIDATE_SSID, candidateInfo[i].ssid);
+                            candidateAPList.push_back(candidateListInfo);
+                }
+                m_rep.setValue(SC_RSRVD_ES_VENDOR_CANDIDATEAPS, candidateAPList);
+            }
+
+             /**
+             * Get Candidate AP information which is registered in device.
+             *
+             * @return SCCandidateAPInfo list.
+             */
+            std::vector<SCCandidateAPInfo> getCandidateAPList()
+            {
+                if (m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATEAPS))
+                {
+                    std::vector<OC::OCRepresentation> candidateInfo=
+                                m_rep.getValue<std::vector<OC::OCRepresentation>>(SC_RSRVD_ES_VENDOR_CANDIDATEAPS);
+                    std::vector<SCCandidateAPInfo> postcandidateInfo;
+                    for(std::vector<OC::OCRepresentation>::iterator it = candidateInfo.begin();
+                              it != candidateInfo.end(); ++it)
+                    {
+                        OC::OCRepresentation rep = *it;
+                        SCCandidateAPInfo candidateInfotemp;
+                        if (rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_SSID))
+                        {
+                            candidateInfotemp.ssid=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_CANDIDATE_SSID);
+                        }
+                        if (rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_PASSPHRASE))
+                        {
+                            candidateInfotemp.passphrase=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_CANDIDATE_PASSPHRASE);
+                        }
+                        if (rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL))
+                        {
+                            candidateInfotemp.channel=rep.getValue<int>(SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL);
+
+                        }
+                        if (rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_BSSID))
+                        {
+                            candidateInfotemp.bssid=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_CANDIDATE_BSSID);
+                        }
+                        postcandidateInfo.push_back(candidateInfotemp);
+                    }
+                    return postcandidateInfo;
+                }
+                return {};
+            }
+
+            /**
+             * Set time zone for location based services when easy-setup is done
+             *
+             * @param Name of timeZone
+             */
+            void setTimeZoneId(const std::string &timeZoneId)
+            {
+                m_rep.setValue(SC_RSRVD_ES_VENDOR_TIMEZONE_ID, timeZoneId);
+            }
+
+            /**
+             * Get the Name of TimeZone
+             *
+             * @return Name of timeZone
+             */
+            std::string getTimeZoneId()
+            {
+                if (m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_TIMEZONE_ID))
+                {
+                    return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_TIMEZONE_ID);
+                }
+                return {};
+            }
+
+            /**
+             * Sets the hidden property of wifi
+             * if the Value is true, wifi is a hidden wifi, otherwise it is not
+             *
+             * @param isHidden: value indicating whether the wifi is hidden or not
+             */
+            void setHiddenProperty(bool isHidden)
+            {
+                m_rep.setValue(SC_RSRVD_ES_VENDOR_HIDDEN, isHidden);
+            }
+
+            /**
+             * Gets the property of the wifi whether it is hidden or not
+             *
+             * @return hidden value indicating whether the wifi is hidden or not
+             */
+            bool getHiddenProperty()
+            {
+                if (m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_HIDDEN))
+                {
+                    return m_rep.getValue<bool>(SC_RSRVD_ES_VENDOR_HIDDEN);
+                }
+                return false;
+            }
         };
 
         class SCCloudProp : public CloudProp
@@ -403,6 +555,126 @@ namespace OIC
             }
 
             /**
+             * Set samsung-specific additional Api provider to be delivered to Enrollee (for devices(TV/AV, Lux) sign up SSO)
+             *
+             * @param additionalApiProvider - additional Api Provider
+             */
+            void setAdditionalApiProvider(const std::string &additionalApiProvider)
+            {
+                m_rep.setValue(SC_RSRVD_ES_VENDOR_SA_API_SERVER, additionalApiProvider);
+            }
+
+            /**
+             * Get samsung-specific additional Api provider (for devices(TV/AV, Lux) sign up SSO)
+             *
+             * @return additionalApiProvider - additional Api Provider
+             */
+            std::string getAdditionalApiProvider()
+            {
+                if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_SA_API_SERVER))
+                {
+                    return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_SA_API_SERVER);
+                }
+                return {};
+            }
+
+            /**
+             * Set samsung-specific additional Auth provider to be delivered to Enrollee (for devices(TV/AV, Lux) sign up SSO)
+             *
+             * @param additionalAuthProvider - additional Auth Provider
+             */
+            void setAdditionalAuthProvider(const std::string &additionalAuthProvider)
+            {
+                m_rep.setValue(SC_RSRVD_ES_VENDOR_SA_AUTH_SERVER, additionalAuthProvider);
+            }
+
+            /**
+             * Get samsung-specific additional Auth provider (for devices(TV/AV, Lux) sign up SSO)
+             *
+             * @return additionalAuthProvider - additional Auth Provider
+             */
+            std::string getAdditionalAuthProvider()
+            {
+                if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_SA_AUTH_SERVER))
+                {
+                    return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_SA_AUTH_SERVER);
+                }
+                return {};
+            }
+
+            /**
+             * Set samsung-specific additional device security code to be delivered to Enrollee (for devices(TV/AV, Lux) sign up SSO)
+             *
+             * @param additionalDeviceSecCode - additional DeviceSecurityCode (for devices(TV/AV, Lux) sign up VD SSO)
+             */
+            void setAdditionalDeviceSecCode(const std::string &additionalDeviceSecCode)
+            {
+                m_rep.setValue(SC_RSRVD_ES_VENDOR_SA_DEVICE_SECURITY_CODE, additionalDeviceSecCode);
+            }
+
+            /**
+             * Get samsung-specific additional device security code
+             *
+             * @return additionalDeviceSecCode - additional DeviceSecurityCode
+             */
+            std::string getAdditionalDeviceSecCode()
+            {
+                if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_SA_DEVICE_SECURITY_CODE))
+                {
+                    return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_SA_DEVICE_SECURITY_CODE);
+                }
+                return {};
+            }
+
+            /**
+             * Set current deployment environment which IoT Server is operating such as "PRD" "STG"
+             *
+             * @param serverDeploymentEnv - current server Deployment Environment
+             */
+            void setServerDeploymentEnv(const std::string &serverDeploymentEnv)
+            {
+                m_rep.setValue(SC_RSRVD_ES_VENDOR_DEPLOY_ENVIRONMENT, serverDeploymentEnv);
+            }
+
+            /**
+             * Get current server deployment environment which IoT Server is operating such as "PRD", "STG" etc
+             *
+             * @return serverDeploymentEnv - current server deployment environment
+             */
+            std::string getServerDeploymentEnv()
+            {
+                if (m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_DEPLOY_ENVIRONMENT))
+                {
+                    return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_DEPLOY_ENVIRONMENT);
+                }
+                return {};
+            }
+
+            /**
+             * Set Access token type.
+             *
+             * @param type - Access token type
+             */
+            void setAccessTokenType(const int type)
+            {
+                m_rep.setValue(SC_RSRVD_ES_VENDOR_IATT, type);
+            }
+
+            /**
+             * Get Access token type.
+             *
+             * @return Access token type.
+             */
+            int getAccessTokenType(void)
+            {
+                if (m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_IATT))
+                {
+                    return m_rep.getValue<int>(SC_RSRVD_ES_VENDOR_IATT);
+                }
+                return 0;
+            }
+
+            /**
              * Set samsung-specific refresh token property to be delivered to Enrollee
              *
              * @param refreshtoken - Refresh token.
@@ -474,6 +746,30 @@ namespace OIC
                 }
                 return {};
             }
+
+            /**
+             * Set samsung-specific client service ID property to be delivered to Enrollee
+             *
+             * @param clientID - Client service ID
+             */
+            void setServerId(const std::string &serverId)
+            {
+                m_rep.setValue(SC_RSRVD_ES_VENDOR_SERVER_ID, serverId);
+            }
+
+            /**
+             * Get samsung-specific client service ID property.
+             *
+             * @return Client service ID.
+             */
+            std::string getServerId()
+            {
+                if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_SERVER_ID))
+                {
+                    return m_rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_SERVER_ID);
+                }
+                return {};
+            }
         };
 
         /**
@@ -515,6 +811,10 @@ namespace OIC
                         {
                             return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_MODEL_NUMBER);
                         }
+                        else if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_MODEL_NUMBER_OLD))
+                        {
+                            return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_MODEL_NUMBER_OLD);
+                        }
                     }
                 }
                 return std::string("");
@@ -619,6 +919,59 @@ namespace OIC
             }
 
             /**
+            * Get Candidate AP information which is registered in device.
+            *
+            * @return SCCandidateAPInfo list.
+            */
+            std::vector<SCCandidateAPInfo> getCandidateAPList() const
+            {
+                std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
+                for(auto child = children.begin(); child != children.end(); ++child)
+                {
+                    if(child->getUri().find(OC_RSRVD_ES_URI_WIFICONF) != std::string::npos)
+                    {
+                        OCRepresentation rep;
+                        if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
+                        {
+                            rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
+                        }
+
+                        if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATEAPS))
+                        {
+                            std::vector<OC::OCRepresentation> candidateInfo=rep.getValue<std::vector<OC::OCRepresentation>>(SC_RSRVD_ES_VENDOR_CANDIDATEAPS);
+                            std::vector<SCCandidateAPInfo> postcandidateInfo;
+                            for(std::vector<OC::OCRepresentation>::iterator it = candidateInfo.begin();
+                                      it != candidateInfo.end(); ++it)
+                            {
+                                OC::OCRepresentation rep = *it;
+                                SCCandidateAPInfo candidateInfotemp;
+                                if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_SSID))
+                                {
+                                    candidateInfotemp.ssid=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_CANDIDATE_SSID);
+                                }
+                                if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_PASSPHRASE))
+                                {
+                                    candidateInfotemp.passphrase=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_CANDIDATE_PASSPHRASE);
+                                }
+                                if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL))
+                                {
+                                    candidateInfotemp.channel=rep.getValue<int>(SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL);
+
+                                }
+                                if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_BSSID))
+                                {
+                                    candidateInfotemp.bssid=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_CANDIDATE_BSSID);
+                                }
+                                postcandidateInfo.push_back(candidateInfotemp);
+                            }
+                            return postcandidateInfo;
+                        }
+                    }
+                }
+                return {};
+            }
+
+            /**
              * Get network provisioning information for the device.
              * Mediator can use this information to enquire & validate registration status with corresponding Network Vendor.
              * The format is in JSON. The key indicates the meaning of value and the value is a
@@ -935,7 +1288,7 @@ namespace OIC
              * Mediator can use this API to differentiate between Easy Setup Protcol supported by
              * Samsung Enrollee Devices.
              *
-             * Example: Version Value for Tizen4.0: [\932.0\94]
+             * Example: Version Value for Tizen4.0: [Â\932.0Â\94]
              *
              * @return Easy Setup Protocol Version String.
              */
@@ -965,6 +1318,69 @@ namespace OIC
                 return std::string("");
             }
 
+            /**
+             * Gets the ISO country code of the device
+             * (ISO 3166-1 Alpha-2)
+             *
+             * @return the ISO Country code of the device
+             */
+            std::string getCountry() const
+            {
+                std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
+                for(auto child = children.begin(); child != children.end(); ++child)
+                {
+                    if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
+                    {
+                        OCRepresentation rep;
+                        if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
+                        {
+                            rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
+                        }
+                        else
+                        {
+                            return std::string("");
+                        }
+
+                        if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_COUNTRY))
+                        {
+                            return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_COUNTRY);
+                        }
+                    }
+                }
+                return std::string("");
+            }
+
+            /**
+             * Gets the HubId of the device
+             *
+             * @return hubId of the device
+             */
+            std::string getHubId() const
+            {
+                std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
+                for(auto child = children.begin(); child != children.end(); ++child)
+                {
+                    if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
+                    {
+                        OCRepresentation rep;
+                        if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
+                        {
+                            rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
+                        }
+                        else
+                        {
+                            return std::string("");
+                        }
+
+                        if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_HUB_ID))
+                        {
+                            return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_HUB_ID);
+                        }
+                    }
+                }
+                return std::string("");
+            }
+
         };
     }
 }