replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / service / easy-setup / mediator / richsdk / android / EasySetupCore / src / main / java / org / iotivity / service / easysetup / mediator / samsung / SCEnrolleeConf.java
1 /**
2  * ***************************************************************
3  *
4  * Copyright 2016 Samsung Electronics All Rights Reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * ****************************************************************
19  */
20
21 package org.iotivity.service.easysetup.mediator.samsung;
22
23 import android.util.Log;
24
25 import org.iotivity.base.OcException;
26 import org.iotivity.base.OcRepresentation;
27 import org.iotivity.service.easysetup.mediator.ESConstants;
28 import org.iotivity.service.easysetup.mediator.EnrolleeConf;
29
30 import java.util.List;
31
32 /**
33  * This class stores Enrollee's configuration including WiFi and Device configuration
34  * including supported WiFi frequency and device name
35  */
36 public class SCEnrolleeConf extends EnrolleeConf
37 {
38     private static final String TAG = SCEnrolleeConf.class.getName();
39
40     /**
41      * Constructor
42      *
43      * @param rep received properties in a form of OcRepresentation
44      */
45     public SCEnrolleeConf(EnrolleeConf enrolleeConf) {
46         super(enrolleeConf);
47     }
48
49     /**
50      * Get Device type property in DevConf resource
51      *
52      * @return device type
53      */
54     public String getDeviceType()
55     {
56         List<OcRepresentation> children = mEasySetupRep.getChildren();
57
58         for (OcRepresentation child : children) {
59             if(child.getUri().indexOf(ESConstants.OC_RSRVD_ES_URI_DEVCONF) != -1)
60             {
61                 try
62                 {
63                     if(child.hasAttribute(ESConstants.OC_RSRVD_ES_VENDOR_DEVTYPE)) {
64                         return (String) child.getValue(ESConstants.OC_RSRVD_ES_VENDOR_DEVTYPE);
65                     }
66                 } catch (OcException e) {
67                     Log.e(TAG, "getDeviceType is failed.");
68                 }
69             }
70         }
71         return new String("");
72     }
73
74     /**
75      * Get Device sub-type property in DevConf resource
76      *
77      * @return device sub-type
78      */
79     public String getDeviceSubType()
80     {
81         List<OcRepresentation> children = mEasySetupRep.getChildren();
82
83         for (OcRepresentation child : children) {
84             if(child.getUri().indexOf(ESConstants.OC_RSRVD_ES_URI_DEVCONF) != -1)
85             {
86                 try
87                 {
88                     if(child.hasAttribute(ESConstants.OC_RSRVD_ES_VENDOR_DEVSUBTYPE)) {
89                         return (String) child.getValue(ESConstants.OC_RSRVD_ES_VENDOR_DEVSUBTYPE);
90                     }
91                 } catch (OcException e) {
92                     Log.e(TAG, "getDeviceType is failed.");
93                 }
94             }
95         }
96         return new String("");
97     }
98 }
99
100