target_os = env.get('TARGET_OS')
if target_os not in ['arduino','darwin', 'ios', 'windows']:
- # Build things manager project
- SConscript('things-manager/SConscript')
-
# Build resource-hosting project
SConscript('resource-hosting/SConscript')
+++ /dev/null
-IDE/VS2010_TEST/Simulator/Debug/
-IDE/VS2010_TEST/GroupManager/Debug/
-IDE/VS2010_TEST/Debug/
-IDE/VS2010_TEST/GroupManager/GroupManager.sdf
-IDE/VS2010_TEST/GroupManager/GroupManager.sln.docstates.suo
-IDE/VS2010_TEST/Simulation.opensdf
-IDE/VS2010_TEST/Simulation.sln.docstates.suo
-IDE/VS2010_TEST/Simulation.suo
-IDE/VS2010_TEST/Simulationv11.sln
-IDE/VS2010_TEST/Simulator/Simulator.vcxproj.user
-IDE/VS2010_TEST/ipch/groupmanager-b37860cb/2.ipch
-IDE/VS2010_TEST/ipch/simulator-d2ec10fb/1.ipch
-IDE/VS2010_TEST/Simulation.sdf
-IDE/VS2010_TEST/ipch/
-*.ipch
-IDE/VS2010_TEST/GroupManager/GroupManager.vcxproj.user
-
-
-
-IDE/VS2010/GroupManager/GroupManager.vcxproj.user
-TestApp/InProcClientWrapper.o
-TestApp/InProcServerWrapper.o
-TestApp/OCLib.a
-TestApp/OCPlatform.o
-TestApp/OCReflect.o
-TestApp/OCResource.o
-TestApp/tgmclient
-TestApp/tgmclient.o
-TestApp/tgmserver
-TestApp/tgmserver.o
-SourceCode/tgmtest
-IDE/LINUX_TEST/tgmtest
-inc4.7/
-.settings/
-TestApp/introspection/tgmclient
-TestApp/introspection/introspectionServer
\ No newline at end of file
+++ /dev/null
-/******************************************************************
-*
-* Copyright 2014 Samsung Electronics All Rights Reserved.
-*
-*
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-******************************************************************/
-
-
-===============================================================================
-== How to Build Things Manager ==
-===============================================================================
-
-Once the source code is downloaded in your local specific folder, you may follow
-the steps to build and execute Things Manager and its applications.
-In this context, we assume that the code was downloaded into 'oic' folder.
-
-=======================================
-1. Download source code
-=======================================
-
-From the url, you can download Things Manager source code;
-https://www.iotivity.org/downloads
-
-Once you download the codes, and Make sure that the downloaded code structure is as follows;
-Four directories for oic; extlib, resource, service, and tools.
-
-oic/extlib
-oic/resource
-oic/service
-oic/tools
-
-The path for Things Manager is as following;
-
-oic/service/things-manager
-
-The things-manager directory includes following sub directories;
-
-Directories Description
-oic/service/things-manager/sdk : The SDK APIs for applications is located.
- The main functionality of this SDK is to provide
- developer-friendly APIs of Things manager component
- to application developers.
-oic/service/things-manager/sampleapp : It is the sample application on Ubuntu.
- Basically, the input and output of application
- on Ubuntu are displayed in the console.
-oic/service/things-manager/build : Whole library files and binary files would be made
- in this folder
-
-
-
-=======================================
-2. Build
-=======================================
-Simply, type "make" to build things manager as follows;
-
-/oic/service/things-manager/build/linux$ make
-
-=======================================
-3. Build the API reference documentation
-=======================================
-To build the API reference documentation:
-a. Navigate to oic-resource/docs folder using the terminal window.
-b. Run the following command:
-
- $ doxygen
-
-This command builds the API reference documentation in the output directory.
-
-The output directory for this command is oic-resource/docs/html/index.html.
-
+++ /dev/null
-#******************************************************************
-#
-# Copyright 2014 Samsung Electronics All Rights Reserved.
-#
-#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-##
-# things_manager project build script
-##
-import os
-Import('env')
-
-# Add third party libraries
-lib_env = env.Clone()
-SConscript('#service/third_party_libs.scons', exports = 'lib_env')
-
-things_manager_env = lib_env.Clone()
-target_os = env.get('TARGET_OS')
-######################################################################
-# Build flags
-######################################################################
-things_manager_env.AppendUnique(CPPPATH = ['../../extlibs/timer', 'sdk/inc', 'sdk/src'])
-
-things_manager_env.PrependUnique(LIBS = ['oc', 'octbstack'])
-
-if target_os not in ['windows']:
- things_manager_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
- if target_os != 'android':
- things_manager_env.AppendUnique(CXXFLAGS = ['-pthread'])
- things_manager_env.AppendUnique(LIBS = ['pthread'])
-
-if target_os not in ['darwin', 'ios', 'windows']:
- things_manager_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
-
-if target_os == 'android':
- things_manager_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
- things_manager_env.PrependUnique(LIBS = ['gnustl_shared'])
-
-######################################################################
-# Source files and Targets
-######################################################################
-
-tgm_src = env.Glob('sdk/src/*.cpp', '../../extlibs/timer/timer.c')
-tgmsdk_static = things_manager_env.StaticLibrary('TGMSDKLibrary', tgm_src)
-tgmsdk_shared = things_manager_env.SharedLibrary('TGMSDKLibrary', tgm_src)
-
-things_manager_env.InstallTarget([tgmsdk_static,tgmsdk_shared], 'libTGMSDK')
-things_manager_env.UserInstallTargetLib([tgmsdk_static,tgmsdk_shared], 'libTGMSDK')
-things_manager_env.UserInstallTargetHeader('sdk/inc/ActionSet.h', 'service/things-manager', 'ActionSet.h')
-things_manager_env.UserInstallTargetHeader('sdk/inc/GroupManager.h', 'service/things-manager', 'GroupManager.h')
-things_manager_env.UserInstallTargetHeader('sdk/inc/ThingsConfiguration.h', 'service/things-manager', 'ThingsConfiguration.h')
-things_manager_env.UserInstallTargetHeader('sdk/inc/ThingsMaintenance.h', 'service/things-manager', 'ThingsMaintenance.h')
-
-# Build JNI layer
-#if target_os == 'android':
-# SConscript(os.path.join('sdk', 'java', 'jni', 'SConscript'))
-
-#Go to build sample apps
-SConscript('sampleapp/SConscript')
-
-######################################################################
-# Build UnitTests Things Manager
-################################################ ######################
-if target_os in ['linux']:
- SConscript('unittests/SConscript')
-
+++ /dev/null
-#******************************************************************
-#
-# Copyright 2014 Samsung Electronics All Rights Reserved.
-#
-#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-##
-# sampleapp build script
-##
-
-Import('env')
-
-# Add third party libraries
-lib_env = env.Clone()
-SConscript('#service/third_party_libs.scons', 'lib_env')
-sample_env = lib_env.Clone()
-target_os = env.get('TARGET_OS')
-
-######################################################################
-# Build flags
-######################################################################
-
-######################################################################
-# Source files and Targets
-######################################################################
-if target_os in ['linux']:
- # Build linux sample app
- SConscript('linux/configuration/SConscript')
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
- <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
- <classpathentry kind="output" path="bin/classes"/>
-</classpath>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>Sample</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.ApkBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.tm.sample"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk
- android:minSdkVersion="8"
- android:targetSdkVersion="21" />
-
- <uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
-
- <application
- android:allowBackup="true"
- android:icon="@drawable/iot"
- android:label="@string/app_name"
- android:theme="@style/AppTheme" >
- <activity
- android:name=".MainActivity"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- <activity
- android:name=".GroupApiActivity"
- android:label="@string/app_name" >
- </activity>
- <activity
- android:name=".ConfigurationApiActivity"
- android:label="@string/app_name" >
- </activity>
- </application>
-
-</manifest>
+++ /dev/null
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-# Project target.
-target=android-20
-android.library.reference.1=../../../sdk/java
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <ListView
- android:id="@+id/list"
- android:layout_height="wrap_content"
- android:layout_width="match_parent">
- </ListView>
-</RelativeLayout>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <ListView
- android:id="@+id/configApisList"
- android:layout_width="wrap_content"
- android:layout_height="320dp" >
-
- </ListView>
-
-
- <EditText
- android:id="@+id/EditText"
- android:layout_width="fill_parent"
- android:layout_height="250dp"
- android:layout_alignParentLeft="true"
- android:layout_below="@+id/configApisList"
- android:layout_marginTop="15dp"
- android:ems="10"
- android:editable="false" >
-
- <requestFocus />
- </EditText>
-
-</RelativeLayout>
-
-
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
-
- <DatePicker
- android:id="@+id/datePicker1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" >
- </DatePicker>
-
- <TimePicker
- android:id="@+id/timePicker1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_below="@+id/datePicker1"
- android:layout_marginTop="63dp" />
-
- <Button
- android:id="@+id/ok"
- android:layout_width="200px"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_below="@+id/timePicker1"
- android:layout_marginLeft="16dp"
- android:layout_marginTop="53dp"
- android:text="OK" />
-
- <Button
- android:id="@+id/cancel"
- android:layout_width="200px"
- android:layout_height="wrap_content"
- android:layout_alignBaseline="@+id/ok"
- android:layout_alignBottom="@+id/ok"
- android:layout_alignParentRight="true"
- android:layout_marginRight="34dp"
- android:text="Cancel" />
-
-</RelativeLayout>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_alignParentTop="true"
- android:text="Find Group" />
-
-
- <ListView
- android:id="@+id/groupaApiList"
- android:layout_width="match_parent"
- android:layout_height="300dp"
- android:layout_below="@id/button1">
- </ListView>
-
- <EditText
- android:id="@+id/EditText"
- android:layout_width="fill_parent"
- android:layout_height="250dp"
- android:layout_alignParentLeft="true"
- android:layout_below="@+id/groupaApiList"
- android:layout_marginTop="15dp"
- android:ems="10"
- android:editable="false" >
-
- <requestFocus />
- </EditText>
-
-
-</RelativeLayout>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <EditText
- android:id="@+id/region"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_centerHorizontal="true"
- android:layout_marginTop="28dp"
- android:ems="10"
- android:hint="Enter the Region Value" />
-
- <Button
- android:id="@+id/ok"
- android:layout_width="150dp"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_below="@+id/region"
- android:layout_marginTop="101dp"
- android:text="OK" />
-
- <Button
- android:id="@+id/cancel"
- android:layout_width="150dp"
- android:layout_height="wrap_content"
- android:layout_alignBaseline="@+id/ok"
- android:layout_alignBottom="@+id/ok"
- android:layout_alignParentRight="true"
- android:text="Cancel" />
-
-</RelativeLayout>
+++ /dev/null
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
-
- <item
- android:id="@+id/action_settings"
- android:orderInCategory="100"
- android:showAsAction="never"
- android:title="@string/action_settings"/>
-
-</menu>
+++ /dev/null
-<resources>
-
- <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
- </style>
-
-</resources>
+++ /dev/null
- <resources>
-
- <style name="AppBaseTheme" parent="android:Theme.Light">
- </style>
-
- <style name="AppTheme" parent="AppBaseTheme">
- </style>
-
-</resources>
+++ /dev/null
-<resources>
-
- <!--
- Example customization of dimensions originally defined in res/values/dimens.xml
- (such as screen margins) for screens with more than 820dp of available width. This
- would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
- -->
- <dimen name="activity_horizontal_margin">64dp</dimen>
-
-</resources>
+++ /dev/null
-<resources>
-
- <!-- Default screen margins, per the Android Design guidelines. -->
- <dimen name="activity_horizontal_margin">16dp</dimen>
- <dimen name="activity_vertical_margin">16dp</dimen>
-
-</resources>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
- <string name="app_name">TMSample</string>
- <string name="hello_world">Hello world!</string>
- <string name="action_settings">Settings</string>
-
-</resources>
+++ /dev/null
-<resources>
-
- <style name="AppBaseTheme" parent="android:Theme.Light">
-
- </style>
-
- <!-- Application theme. -->
- <style name="AppTheme" parent="AppBaseTheme">
-
- </style>
-
-</resources>
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-package com.tm.sample;
-
-import java.util.Vector;
-
-import org.iotivity.base.OcHeaderOption;
-import org.iotivity.base.OcRepresentation;
-import org.iotivity.service.tm.Action;
-import org.iotivity.service.tm.ActionSet;
-import org.iotivity.service.tm.Capability;
-import org.iotivity.service.tm.GroupManager.*;
-
-import android.os.Message;
-import android.util.Log;
-
-/*
- * For getting the put,get,observe and post Callback and updating
- * the UI i.e. logMessage(TextBox) of GroupApiActivity.
- */
-public class ActionListener implements IActionListener {
-
- private final String LOG_TAG = "[TMSample] "
- + this.getClass()
- .getSimpleName();
- private static Message msg;
- private String logMessage;
- private GroupApiActivity groupApiActivityObj = null;
-
- @Override
- public void onPostResponseCallback(Vector<OcHeaderOption> headerOptions,
- OcRepresentation rep, int errorValue) {
- Log.i(LOG_TAG, "Got Callback : onPostResponseCallback");
-
- groupApiActivityObj = GroupApiActivity.getGroupApiActivityObj();
- logMessage = "API Result : SUCCESS" + "\n";
- logMessage += "Recieved Callback for called API (OnPostCallback)"
- + "\n";
-
- // sending message to handler of GroupApiActivity to Update the UI
- GroupApiActivity.setMessageLog(logMessage);
- msg = Message.obtain();
- msg.what = 1;
- groupApiActivityObj.getHandler().sendMessage(msg);
- }
-
- @Override
- public void onGetResponseCallback(Vector<OcHeaderOption> headerOptions,
- OcRepresentation rep, int errorValue) {
- Log.i(LOG_TAG, "Got Callback : onGetResponseCallback");
-
- String actionSetStr = rep.getValueString("ActionSet");
- groupApiActivityObj = GroupApiActivity.getGroupApiActivityObj();
- logMessage = "Recieved Callback for called API (onGetResponseCallback)"
- + "\n" + "ActionSet:" + actionSetStr;
-
- GroupApiActivity.setMessageLog(logMessage);
- // sending message to handler of GroupApiActivity to Update the UI
- msg = Message.obtain();
- msg.what = 1;
- groupApiActivityObj.getHandler().sendMessage(msg);
-
- if (actionSetStr != null) {
- ActionSet actionSet = ActionSet.toActionSet(actionSetStr);
- if (actionSet != null) {
- System.out.println("ActionSet Name : "
- + actionSet.actionsetName);
- for (int i = 0; i < actionSet.listOfAction.size(); i++) {
- Action action = actionSet.listOfAction.get(i);
- System.out.println("Target : " + action.target);
-
- Vector<Capability> listOfCapability = action.listOfCapability;
- for (int j = 0; j < listOfCapability.size(); j++) {
- Capability capability = listOfCapability.get(j);
- System.out.println("Capability : "
- + capability.capability);
- System.out.println("Status : " + capability.status);
- }
- }
- }
- }
-
- groupApiActivityObj = GroupApiActivity.getGroupApiActivityObj();
- GroupApiActivity.setMessageLog(logMessage);
- msg = Message.obtain();
- msg.what = 1;
- groupApiActivityObj.getHandler().sendMessage(msg);
- }
-
- @Override
- public void onPutResponseCallback(Vector<OcHeaderOption> headerOptions,
- OcRepresentation rep, int errorValue) {
- Log.i(LOG_TAG, "Got Callback : onPutResponseCallback");
-
- groupApiActivityObj = GroupApiActivity.getGroupApiActivityObj();
- logMessage = "API Result : SUCCESS" + "\n";
- logMessage += "Recieved Callback for called API (onPutResponseCallback)"
- + "\n";
- GroupApiActivity.setMessageLog(logMessage);
- // sending message to handler of GroupApiActivity to Update the UI
- msg = Message.obtain();
- msg.what = 1;
- groupApiActivityObj.getHandler().sendMessage(msg);
- }
-}
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-package com.tm.sample;
-
-import java.util.ArrayList;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import org.iotivity.base.OcException;
-import org.iotivity.base.OcHeaderOption;
-import org.iotivity.base.OcPlatform;
-import org.iotivity.base.OcRepresentation;
-import org.iotivity.base.OcResource;
-import org.iotivity.base.OcResourceHandle;
-import org.iotivity.base.ResourceProperty;
-import org.iotivity.service.tm.OCStackResult;
-import org.iotivity.service.tm.GroupManager;
-import org.iotivity.service.tm.ThingsMaintenance;
-import org.iotivity.service.tm.GroupManager.*;
-import org.iotivity.service.tm.ThingsConfiguration;
-import org.iotivity.service.tm.ThingsConfiguration.*;
-import org.iotivity.service.tm.ThingsMaintenance.*;
-
-import android.app.Activity;
-import android.app.Dialog;
-import android.content.Context;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.util.Log;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemClickListener;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.ListView;
-import android.widget.Toast;
-
-/*
- * Activity for Handling all Configuration Apis as per user's selection on the UI.
- * and updating of UI
- */
-public class ConfigurationApiActivity extends Activity {
-
- private class ResourceInformation {
- OcResource resource = null;
- OcResourceHandle resourceHandle = null;
- }
-
- private final String LOG_TAG = "[TMSample] "
- + this.getClass()
- .getSimpleName();
-
- private final String CONFIGURATION_COLLECTION_RESOURCE_URI = "/core/configuration/resourceset";
- private final String CONFIGURATION_COLLECTION_RESOURCE_TYPE = "core.configuration.resourceset";
- private final String CONFIGURATION_RESOURCE_TYPE = "oic.wk.con";
- private final String MAINTENANCE_COLLECTION_RESOURCE_URI = "/core/maintenance/resourceset";
- private final String MAINTENANCE_COLLECTION_RESOURCE_TYPE = "core.maintenance.resourceset";
- private final String MAINTENANCE_RESOURCE_TYPE = "oic.wk.mnt";
- private final String FACTORYSET_COLLECTION_RESOURCE_URI = "/core/factoryset/resourceset";
- private final String FACTORYSET_COLLECTION_RESOURCE_TYPE = "core.factoryset.resourceset";
- private final String FACTORYSET_RESOURCE_TYPE = "factoryset";
-
- private final String CONFIGURATION_RESOURCE_URI = "/oic/con";
- private final String MAINTENANCE_RESOURCE_URI = "/oic/mnt";
- private final String FACTORYSET_RESOURCE_URI = "/factoryset";
-
- private ListView list;
- private ArrayAdapter<String> configurationApis;
- private ArrayList<String> configurationApisList;
-
- private static int messageCount = 0;
- private static EditText logs;
- private static String logMessage = "";
- private static Handler mHandler;
- private static Message msg;
-
- private GroupManager groupManager = null;
- private ThingsConfiguration thingsConfiguration = null;
- private ThingsMaintenance thingsMaintenance = null;
- private Map<String, ResourceInformation> resourceList = null;
- private Map<String, ResourceInformation> collectionList = null;
-
- public boolean configurationResourceFlag = false;
- public boolean factorysetResourceFlag = false;
- public boolean maintenanceResourceFlag = false;
-
- public static Context mcontext;
- public String region = "";
- public boolean findGroupPressedFlag = false;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.configapis);
-
- mcontext = this;
- groupManager = new GroupManager();
- thingsConfiguration = ThingsConfiguration.getInstance();
- thingsMaintenance = ThingsMaintenance.getInstance();
-
- // set the listeners
- setResourceListener();
- setConfigurationListener();
- setMaintenanceListener();
-
- // Create API menu list
- configurationApisList = new ArrayList<String>();
-
- logs = (EditText) findViewById(R.id.EditText);
-
- list = (ListView) findViewById(R.id.configApisList);
- configurationApisList.add("Find All Groups");
- configurationApisList.add("Find All Resources");
- configurationApisList.add("Get a Configuration Resource");
- configurationApisList.add("Update Attribute (Region)");
- configurationApisList.add("Factory Reset");
- configurationApisList.add("Reboot");
- configurationApisList.add("Get Supported Configuration Units");
- configurationApis = new ArrayAdapter<String>(this,
- android.R.layout.simple_list_item_1, configurationApisList);
- list.setAdapter(configurationApis);
-
- // setting the Listener for calling the APIs as per User selection
- list.setOnItemClickListener(new OnItemClickListener() {
-
- @Override
- public void onItemClick(AdapterView<?> parent, View view,
- int position, long id) {
-
- // Find All Groups
- if (position == 0) {
- Vector<String> resourceTypes = new Vector<String>();
- resourceTypes.add(CONFIGURATION_COLLECTION_RESOURCE_TYPE);
- findCandidateResources(resourceTypes);
-
- logMessage = "";
- messageCount = 0;
- messageCount++;
-
- resourceTypes.clear();
- resourceTypes.add(MAINTENANCE_COLLECTION_RESOURCE_TYPE);
- findCandidateResources(resourceTypes);
-
- messageCount++;
-
- resourceTypes.clear();
- resourceTypes.add(FACTORYSET_COLLECTION_RESOURCE_TYPE);
- findCandidateResources(resourceTypes);
-
- messageCount++;
-
- } else if (position == 1) { // Find All Resources
- if (false == findGroupPressedFlag) {
- displayToastMessage("Configuration collection resource does not exist!");
- } else {
- Vector<String> resourceTypes = new Vector<String>();
- resourceTypes.add(CONFIGURATION_RESOURCE_TYPE);
- findCandidateResources(resourceTypes);
-
- logMessage = "";
- messageCount = 0;
- messageCount++;
-
- resourceTypes.clear();
- resourceTypes.add(MAINTENANCE_RESOURCE_TYPE);
- findCandidateResources(resourceTypes);
-
- messageCount++;
-
- resourceTypes.clear();
- resourceTypes.add(FACTORYSET_RESOURCE_TYPE);
- findCandidateResources(resourceTypes);
-
- messageCount++;
- }
- } else if (position == 2) { // Get Configuration
- getConfiguration();
- } else if (position == 3) { // Update Attribute (Region)
- userInputDialog();
- } else if (position == 4) { // Factory Reset
- factoryReset();
- } else if (position == 5) { // Reboot
- reboot();
- } else if (position == 6) { // Get Supported Configuration Units
- String configurationUnits;
- configurationUnits = getListOfSupportedConfigurationUnits();
- Log.i(LOG_TAG, "Configuration Units:" + configurationUnits);
- logMessage = configurationUnits;
- logs.setText("");
- logs.setText(logMessage);
-
- }
- }
- });
-
- resourceList = new HashMap<String, ResourceInformation>();
- collectionList = new HashMap<String, ResourceInformation>();
-
- try {
- createResourceCollection(CONFIGURATION_COLLECTION_RESOURCE_URI,
- CONFIGURATION_COLLECTION_RESOURCE_TYPE);
- createResourceCollection(MAINTENANCE_COLLECTION_RESOURCE_URI,
- MAINTENANCE_COLLECTION_RESOURCE_TYPE);
- createResourceCollection(FACTORYSET_COLLECTION_RESOURCE_URI,
- FACTORYSET_COLLECTION_RESOURCE_TYPE);
- } catch (OcException e) {
- Log.e(LOG_TAG, "OcException occured! " + e.toString());
- }
-
- // handler for updating the UI i.e. LogMessage TextBox
- mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case 0:
- logs.setText("");
- logs.setText(logMessage);
- Log.i(LOG_TAG, logMessage);
- }
- }
- };
-
- }
-
- private void userInputDialog() {
-
- ResourceInformation configurationCollection = collectionList
- .get(CONFIGURATION_COLLECTION_RESOURCE_URI);
- if (null == configurationCollection
- || null == configurationCollection.resource) {
- displayToastMessage("Configuration collection resource does not exist!");
- }
- if (false == configurationResourceFlag) {
- displayToastMessage("Configuration resource does not exist!");
- } else {
- final Dialog dialog = new Dialog(mcontext);
- dialog.setContentView(R.layout.userinputforregionvalue);
- dialog.setTitle("Enter the Region Value");
-
- dialog.setCancelable(false);
- dialog.show();
- Button ok = (Button) dialog.findViewById(R.id.ok);
- Button cancel = (Button) dialog.findViewById(R.id.cancel);
-
- ok.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
-
- EditText regionValue = (EditText) dialog
- .findViewById(R.id.region);
- region = regionValue.getText().toString();
- if (region.equalsIgnoreCase("")) {
- String toastmessage = "Please enter the Region Value";
- displayToastMessage(toastmessage);
- } else {
- dialog.dismiss();
- updateConfiguration(region);
- }
- }
- });
- cancel.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog.dismiss();
- }
- });
- }
- }
-
- @Override
- public void onBackPressed() {
- super.onBackPressed();
-
- // unregistering resource from the platform
- deleteResources();
- resourceList.clear();
- resourceList = null;
- collectionList.clear();
- collectionList = null;
- }
-
- private void setResourceListener() {
- groupManager
- .setFindCandidateResourceListener(new IFindCandidateResourceListener() {
-
- @Override
- public void onResourceFoundCallback(
- Vector<OcResource> resources) {
- // TODO Auto-generated method stub
- Log.i(LOG_TAG, "onResourceCallback: enter");
- for (int i = 0; i < resources.size(); i++) {
- OcResource resource = resources.get(i);
- String uri = resource.getUri();
- String host = resource.getHost();
-
- // Display resource information
- Log.i(LOG_TAG, "Resource URI:" + uri);
- Log.i(LOG_TAG, "Resource HOST: " + host);
- Log.i(LOG_TAG, "Resource types: ");
- logMessage += "Resource URI : " + uri + "\n";
- logMessage += "Resource Host : " + host + "\n";
-
- List<String> resourcetypes = resource
- .getResourceTypes();
- for (int j = 0; j < resourcetypes.size(); j++) {
- Log.i(LOG_TAG, resourcetypes.get(j));
- logMessage += "ResourceType " + (j + 1) + " : "
- + resourcetypes.get(j) + "\n";
- }
-
- Log.i(LOG_TAG, "Interface types: ");
- List<String> interfacetypes = resource
- .getResourceInterfaces();
- for (int j = 0; j < interfacetypes.size(); j++) {
- Log.i(LOG_TAG, interfacetypes.get(j));
- logMessage += "interfacetype " + (j + 1)
- + " : " + interfacetypes.get(j) + "\n";
- }
-
- try {
- if (true == uri.contains("/resourceset")) {
- collectionFound(resource);
- } else {
- resourceFound(resource);
- }
- } catch (OcException e) {
- Log.e(LOG_TAG,
- "OcExcepion occured! " + e.toString());
- }
- }
- if (messageCount == 3) {
- msg = Message.obtain();
- msg.what = 0;
- mHandler.sendMessage(msg);
- }
- }
- });
- }
-
- private void setConfigurationListener() {
- thingsConfiguration
- .setConfigurationListener(new IConfigurationListener() {
- @Override
- public void onBootStrapCallback(
- Vector<OcHeaderOption> headerOptions,
- OcRepresentation rep, int errorValue) {
- Log.i(LOG_TAG, "onBootStrapCallback: enter");
- }
-
- @Override
- public void onUpdateConfigurationsCallback(
- Vector<OcHeaderOption> headerOptions,
- OcRepresentation rep, int errorValue) {
- Log.i(LOG_TAG, "onUpdateConfigurationsCallback: enter");
- Log.i(LOG_TAG, "Resource URI: " + rep.getUri());
- if (rep.hasAttribute("n")) {
- logMessage += "Device Name : "
- + rep.getValueString("n") + "\n";
- }
- if (rep.hasAttribute("loc")) {
- logMessage += "Location : "
- + rep.getValueString("loc") + "\n";
- }
- if (rep.hasAttribute("locn")) {
- logMessage += "Location Name : "
- + rep.getValueString("locn") + "\n";
- }
- if (rep.hasAttribute("r")) {
- logMessage += "Region : " + rep.getValueString("r")
- + "\n";
- }
- if (rep.hasAttribute("c")) {
- logMessage += "Currency : "
- + rep.getValueString("c") + "\n";
- }
- }
-
- @Override
- public void onGetConfigurationsCallback(
- Vector<OcHeaderOption> headerOptions,
- OcRepresentation rep, int errorValue) {
- Log.i(LOG_TAG, "onGetConfigurationsCallback: enter");
- Log.i(LOG_TAG, "Resource URI: " + rep.getUri());
- logMessage += "Resource URI : " + rep.getUri() + "\n";
-
- if (rep.hasAttribute("n")) {
- logMessage += "Device Name : "
- + rep.getValueString("n") + "\n";
- }
- if (rep.hasAttribute("loc")) {
- logMessage += "Location : "
- + rep.getValueString("loc") + "\n";
- }
- if (rep.hasAttribute("locn")) {
- logMessage += "Location Name : "
- + rep.getValueString("locn") + "\n";
- }
- if (rep.hasAttribute("r")) {
- logMessage += "Region : " + rep.getValueString("r")
- + "\n";
- }
- if (rep.hasAttribute("c")) {
- logMessage += "Currency : "
- + rep.getValueString("c") + "\n";
- }
-
- msg = Message.obtain();
- msg.what = 0;
- mHandler.sendMessage(msg);
- }
- });
- }
-
- private void setMaintenanceListener() {
- thingsMaintenance
- .setThingsMaintenanceListener(new IThingsMaintenanceListener() {
-
- @Override
- public void onRebootCallback(
- Vector<OcHeaderOption> headerOptions,
- OcRepresentation rep, int errorValue) {
- // TODO Auto-generated method stu
- }
-
- @Override
- public void onFactoryResetCallback(
- Vector<OcHeaderOption> headerOptions,
- OcRepresentation rep, int errorValue) {
- // TODO Auto-generated method stub
-
- }
- });
- }
-
- /**
- * This method find the resources available in network.
- */
- private void findCandidateResources(Vector<String> resourceTypes) {
- OCStackResult result = groupManager.findCandidateResources(
- resourceTypes, 5);
- if (OCStackResult.OC_STACK_OK != result) {
- Log.e(LOG_TAG, "Error while calling findCandidateResources");
- String toastmessage = "findCandidateResources API returned error! ["
- + result + "]";
- displayToastMessage(toastmessage);
- }
- if (messageCount == 1)
- logMessage += "API RESULT : " + result.toString() + "\n";
- }
-
- /**
- * This method gets the configuration data from con-server.
- */
- private void getConfiguration() {
- Log.i(LOG_TAG, "There are " + resourceList.size()
- + " servers present in network");
- ResourceInformation configurationCollection = collectionList
- .get(CONFIGURATION_COLLECTION_RESOURCE_URI);
- if (null == configurationCollection
- || null == configurationCollection.resource) {
- displayToastMessage("Configuration collection resource does not exist!");
- return;
- }
- if (false == configurationResourceFlag) {
-
- displayToastMessage("Configuration resource does not exist!");
- return;
- }
-
- String name = "all";
- Vector<String> configs = new Vector<String>();
- configs.add(name);
-
- OCStackResult result = OCStackResult.OC_STACK_ERROR;
- try {
- result = thingsConfiguration.getConfigurations(
- configurationCollection.resource, configs);
- } catch (OcException e) {
- e.printStackTrace();
- }
-
- if (OCStackResult.OC_STACK_OK != result) {
- Log.e(LOG_TAG, "getConfigurations failed!");
- String toastmessage = "getConfigurations API returned error! ["
- + result + "]";
- displayToastMessage(toastmessage);
- }
- logMessage = "API RESULT : " + result.toString() + "\n";
- msg = Message.obtain();
- msg.what = 0;
- mHandler.sendMessage(msg);
- }
-
- /**
- * This method update the configuration resource region attribute to given
- * value.
- *
- * @param region
- */
- private void updateConfiguration(String region) {
- ResourceInformation configurationCollection = collectionList
- .get(CONFIGURATION_COLLECTION_RESOURCE_URI);
- String name = "r";
- Map<String, String> configurations = new HashMap<String, String>();
-
- try {
- configurations.put(name, region);
- } catch (Exception e) {
- Log.e(LOG_TAG, "Exception occured! " + e.toString());
- }
-
- OCStackResult result = OCStackResult.OC_STACK_ERROR;
- try {
- result = thingsConfiguration.updateConfigurations(
- configurationCollection.resource, configurations);
- } catch (OcException e) {
- e.printStackTrace();
- }
- if (OCStackResult.OC_STACK_OK != result) {
- Log.e(LOG_TAG, "updateConfigurations failed!");
- String toastmessage = "updateConfigurations API returned error! ["
- + result + "]";
- displayToastMessage(toastmessage);
- }
- logMessage = "API RESULT : " + result.toString() + "\n";
- logMessage += "Updating region to " + region;
- msg = Message.obtain();
- msg.what = 0;
- mHandler.sendMessage(msg);
- }
-
- /**
- * This method send request to reset all the configuration attribute values
- * to default.
- */
- private void factoryReset() {
- ResourceInformation MaintenanceCollection = collectionList
- .get(MAINTENANCE_COLLECTION_RESOURCE_URI);
- if (null == MaintenanceCollection
- || null == MaintenanceCollection.resource) {
- displayToastMessage("Maintenance collection does not exist!");
- return;
- }
-
- if (false == maintenanceResourceFlag) {
- displayToastMessage("Maintenance resource does not exist!");
- return;
- }
-
- OCStackResult result = OCStackResult.values()[30];
-
- try {
- result = thingsMaintenance
- .factoryReset(MaintenanceCollection.resource);
- } catch (OcException e) {
- e.printStackTrace();
- }
-
- if (OCStackResult.OC_STACK_OK != result) {
- Log.e(LOG_TAG, "factoryReset failed!");
- String toastmessage = "factoryReset API returned error! [" + result
- + "]";
- displayToastMessage(toastmessage);
-
- }
- logMessage = "API RESULT : " + result.toString() + "\n";
- msg = Message.obtain();
- msg.what = 0;
- mHandler.sendMessage(msg);
- }
-
- /**
- * This method send request to reboot server.
- */
- private void reboot() {
- ResourceInformation MaintenanceCollection = collectionList
- .get(MAINTENANCE_COLLECTION_RESOURCE_URI);
- if (null == MaintenanceCollection
- || null == MaintenanceCollection.resource) {
- displayToastMessage("Maintenance collection does not exist!");
- return;
- }
- if (false == maintenanceResourceFlag) {
- displayToastMessage("Maintenance resource does not exist!");
- return;
- }
-
- OCStackResult result = OCStackResult.OC_STACK_ERROR;
- try {
- result = thingsMaintenance.reboot(MaintenanceCollection.resource);
- } catch (OcException e) {
- e.printStackTrace();
- }
-
- if (OCStackResult.OC_STACK_OK != result) {
- Log.e(LOG_TAG, "reboot failed!");
- String toastmessage = "reboot API returned error! [" + result + "]";
- displayToastMessage(toastmessage);
- }
- logMessage = "API RESULT : " + result.toString() + "\n";
- msg = Message.obtain();
- msg.what = 0;
- mHandler.sendMessage(msg);
- }
-
- /**
- * This method is for getting list of all supported configuration values.
- * Response will be in JSON format (key-value pair).
- */
- private String getListOfSupportedConfigurationUnits() {
- return thingsConfiguration.getListOfSupportedConfigurationUnits();
- }
-
- private void displayToastMessage(String message) {
- Toast toast = Toast.makeText(this, message, Toast.LENGTH_SHORT);
- toast.show();
- Log.i(LOG_TAG, message);
- }
-
- private void collectionFound(OcResource resource) {
- String uri = resource.getUri();
- ResourceInformation resourceInfo = collectionList.get(uri);
- if (null == resourceInfo) {
- Log.e(LOG_TAG, "Collection is not created!");
- return;
- }
-
- if (null != resourceInfo.resource) {
- Log.e(LOG_TAG, "Collection resource already updated!");
- return;
- }
-
- resourceInfo.resource = resource;
- if (3 == messageCount) {
- findGroupPressedFlag = true;
- }
- }
-
- /**
- * This callback will be invoked when the interested resource discovered in
- * network.
- */
- private void resourceFound(OcResource resource) throws OcException {
- String uri = resource.getUri();
- String host = resource.getHost();
-
- // Check if the resource already exist in the map table
- ResourceInformation resourceInfo = resourceList.get(uri + host);
- if (null != resourceInfo) {
- Log.e(LOG_TAG, "Resource already exists!");
- return;
- }
-
- // Create resource
- resourceInfo = new ResourceInformation();
- resourceInfo.resource = resource;
- if (uri.equalsIgnoreCase("/oic/con")) {
- ResourceInformation collectionResource = collectionList
- .get(CONFIGURATION_COLLECTION_RESOURCE_URI);
- if (null == collectionResource
- || null == collectionResource.resourceHandle) {
- Log.e(LOG_TAG, "Invalid Configuration collection!");
- return;
- }
-
- ResourceInformation resourceInfoCollection;
- resourceInfoCollection = collectionList
- .get(CONFIGURATION_COLLECTION_RESOURCE_URI);
- OcResourceHandle handle;
- handle = resourceInfoCollection.resourceHandle;
- resourceInfo.resourceHandle = handle;
- resourceInfo.resourceHandle = groupManager.bindResourceToGroup(
- resource, handle);
-
- resourceList.put(uri + host, resourceInfo);
- configurationResourceFlag = true;
- } else if (uri.equalsIgnoreCase("/oic/mnt")) {
- ResourceInformation maintenanceResource = collectionList
- .get(MAINTENANCE_COLLECTION_RESOURCE_URI);
- if (null == maintenanceResource
- || null == maintenanceResource.resourceHandle) {
- Log.e(LOG_TAG, "Invalid Configuration collection!");
- return;
- }
-
- ResourceInformation resourceInfoCollection;
- resourceInfoCollection = collectionList
- .get(MAINTENANCE_COLLECTION_RESOURCE_URI);
- OcResourceHandle handle;
- handle = resourceInfoCollection.resourceHandle;
- resourceInfo.resourceHandle = handle;
- resourceInfo.resourceHandle = groupManager.bindResourceToGroup(
- resource, handle);
-
- resourceList.put(uri + host, resourceInfo);
- maintenanceResourceFlag = true;
- } else if (uri.equalsIgnoreCase("/factoryset")) {
- ResourceInformation factorysetResource = collectionList
- .get(FACTORYSET_COLLECTION_RESOURCE_URI);
- if (null == factorysetResource
- || null == factorysetResource.resourceHandle) {
- Log.e(LOG_TAG, "Invalid Configuration collection!");
- return;
- }
-
- ResourceInformation resourceInfoCollection;
- resourceInfoCollection = collectionList
- .get(FACTORYSET_COLLECTION_RESOURCE_URI);
- OcResourceHandle handle;
- handle = resourceInfoCollection.resourceHandle;
- resourceInfo.resourceHandle = handle;
- resourceInfo.resourceHandle = groupManager.bindResourceToGroup(
- resource, handle);
-
- resourceList.put(uri + host, resourceInfo);
- factorysetResourceFlag = true;
- } else {
- Log.e(LOG_TAG, "Resource is of different type: " + uri);
- return;
- }
- }
-
- private void createResourceCollection(String uri, String typename)
- throws OcException {
-
- Map<String, OcResourceHandle> groupList = new HashMap<String, OcResourceHandle>();
-
- Log.i(LOG_TAG, "createGroup: " + typename);
- // Check if the resource collection is already created
- if (null != collectionList.get(uri)) {
- Log.e(LOG_TAG, "Collection is already exist!");
- return;
- }
-
- OcResourceHandle resourceHandle = null;
-
- try {
- resourceHandle = OcPlatform.registerResource(uri, typename,
- OcPlatform.BATCH_INTERFACE, null,
- EnumSet.of(ResourceProperty.DISCOVERABLE));
- } catch (OcException e) {
- Log.e(LOG_TAG, "go exception");
- Log.e(LOG_TAG, "RegisterResource error. " + e.getMessage());
- }
- try {
- OcPlatform.bindInterfaceToResource(resourceHandle,
- OcPlatform.GROUP_INTERFACE);
- } catch (OcException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- try {
- OcPlatform.bindInterfaceToResource(resourceHandle,
- OcPlatform.DEFAULT_INTERFACE);
- } catch (OcException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- if (null == resourceHandle) {
- Log.e(LOG_TAG, " createResourceCollection : resourceHandle is NULL");
-
- }
- // Add the collection resource to map table
- ResourceInformation resourceInfo = new ResourceInformation();
- resourceInfo.resourceHandle = resourceHandle;
- collectionList.put(uri, resourceInfo);
- Log.i(LOG_TAG, "size of collectionList : " + collectionList.size());
- }
-
- private void deleteResources() {
- Log.i(LOG_TAG, "deleteResources: enter");
- try {
- // unregister all resources
- for (ResourceInformation resource : resourceList.values()) {
- if (null != resource.resourceHandle) {
- if (resource.resource.getUri().equalsIgnoreCase(
- CONFIGURATION_RESOURCE_URI)) {
- ResourceInformation collectionResource = collectionList
- .get(CONFIGURATION_COLLECTION_RESOURCE_URI);
- if (null != collectionResource
- && null != collectionResource.resourceHandle) {
- OcPlatform
- .unregisterResource(resource.resourceHandle);
- Log.i(LOG_TAG, "unregistered resource"
- + CONFIGURATION_COLLECTION_RESOURCE_URI);
-
- }
- } else if (resource.resource.getUri().equalsIgnoreCase(
- MAINTENANCE_RESOURCE_URI)) {
- ResourceInformation maintenanceResource = collectionList
- .get(MAINTENANCE_COLLECTION_RESOURCE_URI);
- if (null != maintenanceResource
- && null != maintenanceResource.resourceHandle) {
- OcPlatform
- .unregisterResource(resource.resourceHandle);
- Log.i(LOG_TAG, "unregistered resource"
- + CONFIGURATION_COLLECTION_RESOURCE_URI);
- }
- } else if (resource.resource.getUri().equalsIgnoreCase(
- FACTORYSET_RESOURCE_URI)) {
- ResourceInformation factorysetResource = collectionList
- .get(FACTORYSET_COLLECTION_RESOURCE_URI);
- if (null != factorysetResource
- && null != factorysetResource.resourceHandle) {
- OcPlatform
- .unregisterResource(resource.resourceHandle);
- Log.i(LOG_TAG, "unregistered resource"
- + CONFIGURATION_COLLECTION_RESOURCE_URI);
- }
- }
- }
- }
-
- } catch (OcException e) {
- Log.e(LOG_TAG, "OcException occured! " + e.toString());
- }
- }
-}
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-package com.tm.sample;
-
-import java.util.Vector;
-
-import org.iotivity.base.OcHeaderOption;
-import org.iotivity.base.OcRepresentation;
-import org.iotivity.service.tm.ThingsConfiguration;
-import org.iotivity.service.tm.ThingsConfiguration.*;
-
-import android.util.Log;
-
-/*
- * For receiving configuration APIs callback : Update and Get
- */
-public class ConfigurationListener implements IConfigurationListener {
-
- private final String LOG_TAG = "[TMSample] "
- + this.getClass().getSimpleName();
-
- @Override
- public void onBootStrapCallback(Vector<OcHeaderOption> headerOptions,
- OcRepresentation rep, int errorValue) {
- Log.i(LOG_TAG, "Got Callback : onBootStrapCallback");
- }
-
- @Override
- public void onUpdateConfigurationsCallback(
- Vector<OcHeaderOption> headerOptions, OcRepresentation rep,
- int errorValue) {
- Log.i(LOG_TAG, "Got Callback : onUpdateConfigurationsCallback");
-
- }
-
- @Override
- public void onGetConfigurationsCallback(
- Vector<OcHeaderOption> headerOptions, OcRepresentation rep,
- int errorValue) {
- Log.i(LOG_TAG, "Got Callback : onGetConfigurationsCallback");
-
- }
-}
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-package com.tm.sample;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-
-import android.app.Activity;
-import android.app.Dialog;
-import android.content.Context;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.util.Log;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemClickListener;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.DatePicker;
-import android.widget.DatePicker.OnDateChangedListener;
-import android.widget.EditText;
-import android.widget.ListView;
-import android.widget.TimePicker;
-import android.widget.TimePicker.OnTimeChangedListener;
-import android.widget.Toast;
-
-/*
- * Activity for handling user's selection on UI for GroupApis.
- * & for updating UI.
- */
-public class GroupApiActivity extends Activity {
-
- private ListView list;
- private Button findGroup;
- private ArrayAdapter<String> groupApis;
- private ArrayList<String> groupApisList;
- private static GroupApiActivity groupApiActivityObj;
- private GroupClient groupClientObj;
- private static Handler mHandler;
-
- private static EditText logs;
- private static String logMessage;
-
- // For Scheduled ActionSet
- public static Context mcontext;
- public static Calendar scheduleTime;
-
- private final String LOG_TAG = "[TMSample] "
- + this.getClass()
- .getSimpleName(); ;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.groupapis);
-
- groupApiActivityObj = this;
- mcontext = this;
-
- groupClientObj = new GroupClient();
- groupApisList = new ArrayList<String>();
- list = (ListView) findViewById(R.id.groupaApiList);
- findGroup = (Button) findViewById(R.id.button1);
- logs = (EditText) findViewById(R.id.EditText);
-
- // adding the item to list that will be displayed on the UI.
- groupApisList.add("1. Create ActionSet (ALLBULBON & ALLBULBOFF)");
- groupApisList.add("2. Execute ActionSet (ALLBULBON)");
- groupApisList.add("3. Execute ActionSet (AllBULBOFF)");
-
- // Recursive GroupAction
- groupApisList.add("4. Create ActionSet (Recursive_ALLBULBON)");
- groupApisList.add(" 4.1 Execute ActionSet");
- groupApisList.add(" 4.2 Cancel ActionSet");
-
- // scheduled GroupAction
- groupApisList.add("5. Create ActionSet (Scheduled_ALLBULBOFF)");
- groupApisList.add(" 5.1 Execute ActionSet");
- groupApisList.add(" 5.2 Cancel ActionSet");
-
- groupApisList.add("6. Get ActionSet(ALLBULBOFF)");
- groupApisList.add("7. Delete ActionSet(ALLBULBOFF)");
- groupApisList.add("8. Find BookMark to Observe");
-
- // handler for updating the UI i.e. MessageLog (TextBox) & ListView
- mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case 0:
- groupApis = new ArrayAdapter<String>(
- groupApiActivityObj,
- android.R.layout.simple_list_item_1,
- groupApisList);
- list.setAdapter(groupApis);
- list.bringToFront();
- break;
- case 1:
- logs.setText("");
- logs.setText(logMessage);
- Log.i(LOG_TAG, logMessage);
- }
- }
- };
- setHandler(mHandler);
-
- // find group Button Listener
- findGroup.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- groupClientObj.findGroup();
- }
- });
-
- // Listener for item clicked by the user on the UI
- list.setOnItemClickListener(new OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> parent, View view,
- int position, long id) {
- if (position == 0) {
- groupClientObj.createActionSetBulbOn();
- groupClientObj.createActionSetBulbOff();
- } else if (position == 1) {
- groupClientObj.executeActionSetBulbOn(0);
- } else if (position == 2) {
- groupClientObj.executeActionSetBulbOff(0);
- } else if (position == 3) {
- groupClientObj.createRecursiveActionSetBulbOn();
- } else if (position == 4) {
- groupClientObj.executeRecursiveActionSetBulbOn(0);
- } else if (position == 5) {
- groupClientObj.cancelRecursiveActionSetBulbOn();
- } else if (position == 6) {
- showDateAndTimeDialog();
- } else if (position == 7) {
- groupClientObj.executeScheduledActionSetBulbOff(0);
- } else if (position == 8) {
- groupClientObj.cancelScheduledActionSetBulbOff();
- } else if (position == 9) {
- groupClientObj.getActionSetBulbOff();
- } else if (position == 10) {
- groupClientObj.deleteActionSetBulbOff();
- } else if (position == 11) {
- groupClientObj.findBookMarkResources();
- }
- }
- });
-
- // creating group and find light resources
- groupClientObj.createGroup();
- groupClientObj.findLightResources();
- }
-
- public void showDateAndTimeDialog() {
- // for scheduled actionSet
- scheduleTime = Calendar.getInstance();
-
- final Dialog dialog = new Dialog(mcontext);
- dialog.setContentView(R.layout.custom_dialog);
- dialog.setTitle("Choose date and time for Secheduling");
-
- TimePicker tp = (TimePicker) dialog.findViewById(R.id.timePicker1);
- DatePicker dp = (DatePicker) dialog.findViewById(R.id.datePicker1);
- Button ok = (Button) dialog.findViewById(R.id.ok);
- Button cancel = (Button) dialog.findViewById(R.id.cancel);
-
- dialog.setCancelable(false);
- dialog.show();
- tp.setOnTimeChangedListener(new OnTimeChangedListener() {
- @Override
- public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
- scheduleTime.set(Calendar.HOUR_OF_DAY, hourOfDay);
- scheduleTime.set(Calendar.MINUTE, minute);
- }
- });
- dp.init(dp.getYear(), dp.getMonth(), dp.getDayOfMonth(),
- new OnDateChangedListener() {
- @Override
- public void onDateChanged(DatePicker arg0, int arg1,
- int arg2, int arg3) {
- scheduleTime.set(arg1, arg2, arg3);
- }
- });
- ok.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog.dismiss();
-
- // Calculate the time difference in delay
- Calendar localTime = Calendar.getInstance();
- if (scheduleTime.compareTo(localTime) != 1) {
- groupApiActivityObj
- .displayToastMessage("Invalid set time!");
- return;
- }
-
- long delay = scheduleTime.getTimeInMillis()
- - localTime.getTimeInMillis();
- delay /= 1000;
-
- groupClientObj.createScheduledActionSetBulbOff(delay);
- }
- });
- cancel.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog.dismiss();
- }
- });
- }
-
- public static void setMessageLog(String message) {
- logMessage = message;
- }
-
- @Override
- public void onBackPressed() {
- super.onBackPressed();
- }
-
- // for update UI these functions will be called from GroupClient Class
- public static GroupApiActivity getGroupApiActivityObj() {
- return groupApiActivityObj;
- }
-
- public Handler getHandler() {
- return mHandler;
- }
-
- public void setHandler(Handler mHandler) {
- GroupApiActivity.mHandler = mHandler;
- }
-
- public void displayToastMessage(String message) {
- Toast toast = Toast.makeText(this, message, Toast.LENGTH_SHORT);
- toast.show();
- Log.i(LOG_TAG, message);
- }
-}
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-package com.tm.sample;
-
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import org.iotivity.base.ObserveType;
-import org.iotivity.base.OcException;
-import org.iotivity.base.OcHeaderOption;
-import org.iotivity.base.OcPlatform;
-import org.iotivity.base.OcRepresentation;
-import org.iotivity.base.OcResource;
-import org.iotivity.base.ResourceProperty;
-import org.iotivity.base.OcResource.OnObserveListener;
-import org.iotivity.base.OcResourceHandle;
-import org.iotivity.service.tm.Action;
-import org.iotivity.service.tm.ActionSet;
-import org.iotivity.service.tm.Capability;
-import org.iotivity.service.tm.OCStackResult;
-import org.iotivity.service.tm.GroupManager;
-import org.iotivity.service.tm.GroupManager.*;
-import org.iotivity.service.tm.Time.ActionSetType;
-
-import android.os.Message;
-import android.util.Log;
-
-/**
- * For calling the group APIs as per user selection on UI and for updating the
- * UI
- */
-public class GroupClient {
-
- private static final String LOG_TAG = "[TMSample] GroupClient";
- private static Message msg;
- public String logMessage;
-
- private final String groupResourceType = "b.collection";
- private final String groupResourceURI = "/b/collection";
-
- private final GroupManager groupManagerObj;
- private final ActionListener actionListener;
- private final ObserveListener observeListener;
- private OcResource groupResource;
- private OcResourceHandle groupResourceHandle;
- private OcResourceHandle foundLightHandle;
- private static GroupApiActivity groupApiActivityObj = null;
- public static Vector<String> lights = new Vector<String>();
- public static Vector<String> bookmarks = new Vector<String>();
- public static boolean groupFound = false;
-
- /**
- * Listener for receiving observe notifications.
- */
- private class ObserveListener implements OnObserveListener {
- @Override
- public void onObserveCompleted(List<OcHeaderOption> headerOptionList,
- OcRepresentation ocRepresentation, int sequenceNumber) {
- Log.i(LOG_TAG, "onObserveCompleted invoked");
- if (0 == ocRepresentation.getValueInt("level")) {
- createActionSetBulbOn();
- executeActionSetBulbOn(0);
- } else if (5 == ocRepresentation.getValueInt("level")) {
- createActionSetBulbOff();
- executeActionSetBulbOff(0);
- }
- }
-
- @Override
- public void onObserveFailed(Throwable arg0) {
- }
- }
-
- /**
- * Listener for receiving group resource , Light resource and Observe resources discovered in
- * network.
- */
- private class FindCadidateResourceListener implements
- IFindCandidateResourceListener {
-
- @Override
- public void onResourceFoundCallback(Vector<OcResource> resources) {
- // TODO Auto-generated method stub
- Log.i(LOG_TAG, "onResourceCallback invoked");
-
- if (resources != null) {
- for (int i = 0; i < resources.size(); i++) {
- Log.d(LOG_TAG, "Resource information");
- OcResource ocResource = resources.get(i);
- String resourceURI = ocResource.getUri();
- String hostAddress = ocResource.getHost();
-
- logMessage = "API RESULT : " + "OC_STACK_OK" + "\n";
- logMessage += "URI: " + resourceURI + "\n";
- logMessage += "Host:" + hostAddress;
- GroupApiActivity.setMessageLog(logMessage);
- msg = Message.obtain();
- msg.what = 1;
- groupApiActivityObj.getHandler().sendMessage(msg);
- if (resourceURI.equals("/b/collection") == true) {
-
- if(!groupFound)
- {
- Log.d(LOG_TAG, "Group Found URI : " + resourceURI);
- Log.d(LOG_TAG, "Group Foundk HOST : " + hostAddress);
-
- groupResource = ocResource;
- groupFound = true;
- Message msg = Message.obtain();
- msg.what = 0;
- groupApiActivityObj.getHandler().sendMessage(msg);
-
- logMessage = "onGroupFind" + "\n";
- logMessage += "URI : " + resourceURI + "\n";
- logMessage += "Host :" + hostAddress;
- GroupApiActivity.setMessageLog(logMessage);
- msg = Message.obtain();
- msg.what = 1;
- groupApiActivityObj.getHandler().sendMessage(msg);
- }else{
- Log.d(LOG_TAG, "Group Already found ");
- }
-
- }else if (resourceURI.equals("/a/light") == true) {
- if (lights.contains((hostAddress + resourceURI)) == false) {
- lights.add((hostAddress + resourceURI));
- if (groupApiActivityObj != null) {
-
- logMessage = "API RESULT : " + "OC_STACK_OK"
- + "\n";
- logMessage += "URI: " + resourceURI + "\n";
- logMessage += "Host:" + hostAddress;
- GroupApiActivity.setMessageLog(logMessage);
- msg = Message.obtain();
- msg.what = 1;
- groupApiActivityObj.getHandler().sendMessage(
- msg);
- try {
- foundLightHandle = OcPlatform.registerResource(ocResource);
- Log.d(LOG_TAG, "Platform registeration done");
- } catch (OcException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- try {
- OcPlatform.bindResource(groupResourceHandle, foundLightHandle);
- Log.d(LOG_TAG, "Bind resource done");
- } catch (OcException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- } else {
- Log.i(LOG_TAG, "Resource is already registered!");
- }
- } else if (resourceURI.equalsIgnoreCase("/core/bookmark")) {
- if (bookmarks.contains((hostAddress + resourceURI)) == false) {
- bookmarks.add((hostAddress + resourceURI));
- if (groupApiActivityObj != null) {
- logMessage = "API RESULT : " + "OC_STACK_OK"
- + "\n";
- logMessage += "URI: " + resourceURI + "\n";
- logMessage += "Host:" + hostAddress;
- GroupApiActivity.setMessageLog(logMessage);
- msg = Message.obtain();
- msg.what = 1;
- groupApiActivityObj.getHandler().sendMessage(
- msg);
-
- }
- observe(ocResource);
- }
- }
- }
- }
-
- }
- };
-
- private final FindCadidateResourceListener findCandidateResourceListener;
-
- public GroupClient() {
- groupManagerObj = new GroupManager();
- actionListener = new ActionListener();
- observeListener = new ObserveListener();
- findCandidateResourceListener = new FindCadidateResourceListener();
-
- groupManagerObj
- .setFindCandidateResourceListener(findCandidateResourceListener);
- groupManagerObj.setActionListener(actionListener);
-
- groupApiActivityObj = GroupApiActivity.getGroupApiActivityObj();
- }
-
- /**
- * This method creates group of the type "b.collection" handling light
- * resources.
- */
- public void createGroup() {
- groupFound = false;
- try {
- groupResourceHandle = OcPlatform.registerResource(
- groupResourceURI,
- groupResourceType,
- OcPlatform.BATCH_INTERFACE, null, EnumSet.of(
- ResourceProperty.DISCOVERABLE));
- } catch (OcException e) {
- Log.e(LOG_TAG, "go exception");
- Log.e(LOG_TAG, "RegisterResource error. " + e.getMessage());
- }
-
- try {
- OcPlatform.bindInterfaceToResource(groupResourceHandle, OcPlatform.GROUP_INTERFACE);
- } catch (OcException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- try {
- OcPlatform.bindInterfaceToResource(groupResourceHandle, OcPlatform.DEFAULT_INTERFACE);
- } catch (OcException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- /**
- * This method finds the group of type "b.collection".
- */
- public void findGroup() {
- Log.d(LOG_TAG, "finding group");
-
- Vector<String> types = new Vector<String>();
- types.add(groupResourceType);
- OCStackResult result = groupManagerObj.findCandidateResources(types, 5);
- if (OCStackResult.OC_STACK_OK != result) {
- Log.e(LOG_TAG,
- "findCandidateResources returned error: " + result.name());
- }
-
- logMessage = "API RESULT : " + result.toString();
- GroupApiActivity.setMessageLog(logMessage);
- logMessage = "";
- if (groupApiActivityObj != null) {
- msg = Message.obtain();
- msg.what = 1;
- groupApiActivityObj.getHandler().sendMessage(msg);
- }
- }
-
- /**
- * This method finds the light resources of type "core.light".
- */
- public void findLightResources() {
- Log.d(LOG_TAG, "finding light resources");
-
- Vector<String> types = new Vector<String>();
- types.add("core.light");
- OCStackResult result = groupManagerObj.findCandidateResources(types, 5);
- if (OCStackResult.OC_STACK_OK != result) {
- Log.e(LOG_TAG,
- "findCandidateResources returned error: " + result.name());
- }
- }
-
- /**
- * This method finds the bookmark resources of type "core.bookmark".
- */
- public void findBookMarkResources() {
- Log.d(LOG_TAG, "finding bookmark resources");
-
- Vector<String> types = new Vector<String>();
- types.add("core.bookmark");
- OCStackResult result = groupManagerObj.findCandidateResources(types, 5);
- if (OCStackResult.OC_STACK_OK != result) {
- Log.e(LOG_TAG,
- "findCandidateResources returned error: " + result.name());
- }
- }
-
- /**
- * This method creates the action set for bulb on action.
- */
- public void createActionSetBulbOn() {
- Log.i(LOG_TAG, "creating action set for bulb on action");
-
- if (lights.size() == 0) {
- groupApiActivityObj
- .displayToastMessage("No Light server found in network!");
- return;
- }
-
- ActionSet actionSet = new ActionSet();
- actionSet.actionsetName = "AllBulbOn";
-
- // Create actions list
- for (int i = 0; i < lights.size(); i++) {
- Action action = new Action();
- action.target = lights.get(i);
-
- Capability capability = new Capability();
- capability.capability = "power";
- capability.status = "on";
-
- action.listOfCapability.add(capability);
- actionSet.listOfAction.add(action);
- }
-
- try {
- OCStackResult result = groupManagerObj.addActionSet(groupResource,
- actionSet);
- if (OCStackResult.OC_STACK_OK != result) {
- Log.e(LOG_TAG, "addActionSet returned error: " + result.name());
- return;
- }
- } catch (OcException e) {
- e.printStackTrace();
- return;
- }
- }
-
- /**
- * This method creates the action set for bulb off action.
- */
- public void createActionSetBulbOff() {
- Log.i(LOG_TAG, "creating action set for bulb off action");
-
- if (lights.size() == 0) {
- groupApiActivityObj
- .displayToastMessage("No Light server found in network!");
- return;
- }
-
- ActionSet actionSet = new ActionSet();
- actionSet.actionsetName = "AllBulbOff";
-
- // Create actions list
- for (int i = 0; i < lights.size(); i++) {
- Action action = new Action();
- action.target = lights.get(i);
-
- Capability capability = new Capability();
- capability.capability = "power";
- capability.status = "off";
-
- action.listOfCapability.add(capability);
- actionSet.listOfAction.add(action);
- }
-
- try {
- OCStackResult result = groupManagerObj.addActionSet(groupResource,
- actionSet);
- if (OCStackResult.OC_STACK_OK != result) {
- Log.e(LOG_TAG, "addActionSet returned error: " + result.name());
- return;
- }
- } catch (OcException e) {
- e.printStackTrace();
- return;
- }
- }
-
- /**
- * This method creates the recursive action set for bulb on action.
- */
- public void createRecursiveActionSetBulbOn() {
- Log.i(LOG_TAG, "creating recursive action set for bulb on action");
-
- if (lights.size() == 0) {
- groupApiActivityObj
- .displayToastMessage("No Light server found in network!");
- return;
- }
-
- ActionSet actionSet = new ActionSet();
- actionSet.actionsetName = "AllBulbOnRecursive";
- actionSet.setType(ActionSetType.RECURSIVE);
- actionSet.mYear = 0;
- actionSet.mMonth = 0;
- actionSet.mDay = 0;
- actionSet.mHour = 0;
- actionSet.mMin = 0;
- actionSet.mSec = 5;
- actionSet.setDelay(actionSet.getSecAbsTime());
-
- // Create actions list
- for (int i = 0; i < lights.size(); i++) {
- Action action = new Action();
- action.target = lights.get(i);
-
- Capability capability = new Capability();
- capability.capability = "power";
- capability.status = "on";
-
- action.listOfCapability.add(capability);
- actionSet.listOfAction.add(action);
- }
-
- try {
- OCStackResult result = groupManagerObj.addActionSet(groupResource,
- actionSet);
- if (OCStackResult.OC_STACK_OK != result) {
- Log.e(LOG_TAG, "addActionSet returned error: " + result.name());
- return;
- }
- } catch (OcException e) {
- e.printStackTrace();
- return;
- }
- }
-
- /**
- * This method creates the scheduled action set for bulb off action.
- */
- public void createScheduledActionSetBulbOff(long delay) {
- Log.i(LOG_TAG, "creating scheduled action set for bulb off action");
-
- if (lights.size() == 0) {
- groupApiActivityObj
- .displayToastMessage("No Light server found in network!");
- return;
- }
-
- ActionSet actionSet = new ActionSet();
- actionSet.actionsetName = "AllBulbOffScheduled";
- actionSet.setType(ActionSetType.SCHEDULED);
- actionSet.setDelay(delay);
- Log.i(LOG_TAG, "Set the delay of " + delay + " seconds");
-
- // Create actions list
- for (int i = 0; i < lights.size(); i++) {
- Action action = new Action();
- action.target = lights.get(i);
-
- Capability capability = new Capability();
- capability.capability = "power";
- capability.status = "off";
-
- action.listOfCapability.add(capability);
- actionSet.listOfAction.add(action);
- }
-
- try {
- OCStackResult result = groupManagerObj.addActionSet(groupResource,
- actionSet);
- if (OCStackResult.OC_STACK_OK != result) {
- Log.e(LOG_TAG, "addActionSet returned error: " + result.name());
- return;
- }
- } catch (OcException e) {
- e.printStackTrace();
- return;
- }
- }
-
- /**
- * This method is for executing the action Set "AllBulbOn".
- */
- public void executeActionSetBulbOn(long delay) {
- Log.i(LOG_TAG, "executing the action set of bulb on action");
-
- if (lights.size() == 0) {
- groupApiActivityObj
- .displayToastMessage("No Light server found in network!");
- return;
- }
-
- executeActionSet("AllBulbOn", delay);
- }
-
- /**
- * This method is for executing the action Set "AllBulbOff".
- */
- public void executeActionSetBulbOff(long delay) {
- Log.i(LOG_TAG, "executing the action set of bulb off action");
-
- if (lights.size() == 0) {
- groupApiActivityObj
- .displayToastMessage("No Light server found in network!");
- return;
- }
-
- executeActionSet("AllBulbOff", delay);
- }
-
- /**
- * This method is for executing the recursive action Set
- * "AllBulbOnRecursive".
- */
- public void executeRecursiveActionSetBulbOn(long delay) {
- Log.i(LOG_TAG, "executing the recursive action set of bulb on action");
-
- if (lights.size() == 0) {
- groupApiActivityObj
- .displayToastMessage("No Light server found in network!");
- return;
- }
-
- executeActionSet("AllBulbOnRecursive", delay);
- }
-
- /**
- * This method is for executing the schedule action Set
- * "AllBulbOffScheduled".
- */
- public void executeScheduledActionSetBulbOff(long delay) {
- Log.i(LOG_TAG, "executing the schedule action set of bulb off action");
-
- if (lights.size() == 0) {
- groupApiActivityObj
- .displayToastMessage("No Light server found in network!");
- return;
- }
-
- executeActionSet("AllBulbOffScheduled", delay);
- }
-
- /**
- * This method is for canceling the action Set "AllBulbOn".
- */
- public void cancelActionSetBulbOn() {
- Log.i(LOG_TAG, "cancelling the action set of bulb on action");
-
- if (lights.size() == 0) {
- groupApiActivityObj
- .displayToastMessage("No Light server found in network!");
- return;
- }
-
- cancelActionSet("AllBulbOn");
- }
-
- /**
- * This method is for canceling the action Set "AllBulbOff".
- */
- public void cancelActionSetBulbOff() {
- Log.i(LOG_TAG, "cancelling the action set of bulb off action");
-
- if (lights.size() == 0) {
- groupApiActivityObj
- .displayToastMessage("No Light server found in network!");
- return;
- }
-
- cancelActionSet("AllBulbOff");
- }
-
- /**
- * This method is for canceling the recursive action Set
- * "AllBulbOnRecursive".
- */
- public void cancelRecursiveActionSetBulbOn() {
- Log.i(LOG_TAG, "cancelling the recursive action set of bulb on action");
-
- if (lights.size() == 0) {
- groupApiActivityObj
- .displayToastMessage("No Light server found in network!");
- return;
- }
-
- cancelActionSet("AllBulbOnRecursive");
- }
-
- /**
- * This method is for canceling the scheduled action Set
- * "AllBulbOffScheduled".
- */
- public void cancelScheduledActionSetBulbOff() {
- Log.i(LOG_TAG, "cancelling the scheduled action set of bulb off action");
-
- if (lights.size() == 0) {
- groupApiActivityObj
- .displayToastMessage("No Light server found in network!");
- return;
- }
-
- cancelActionSet("AllBulbOffScheduled");
- }
-
- /**
- * This method is for getting the action Set "AllBulbOn".
- */
- public void getActionSetBulbOn() {
- Log.i(LOG_TAG, "getting the action set of bulb on action");
-
- try {
- OCStackResult result = groupManagerObj.getActionSet(groupResource,
- "AllBulbOn");
- if (OCStackResult.OC_STACK_OK != result) {
- Log.e(LOG_TAG,
- "getActionSetOn returned error: " + result.name());
- return;
- }
- } catch (OcException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * This method is for getting the action Set "AllBulbOff".
- */
- public void getActionSetBulbOff() {
- Log.i(LOG_TAG, "getting the action set of bulb off action");
-
- try {
- OCStackResult result = groupManagerObj.getActionSet(groupResource,
- "AllBulbOff");
- if (OCStackResult.OC_STACK_OK != result) {
- Log.e(LOG_TAG,
- "getActionSetOn returned error: " + result.name());
- return;
- }
- } catch (OcException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * This method is for deleting the action Set "AllBulbOn".
- */
- public void deleteActionSetBulbOn() {
- Log.i(LOG_TAG, "deleting the action set of bulb on action");
-
- try {
- OCStackResult result = groupManagerObj.deleteActionSet(
- groupResource, "AllBulbOn");
- if (OCStackResult.OC_STACK_OK != result) {
- Log.e(LOG_TAG,
- "deleteActionSet returned error : " + result.name());
- return;
- }
- } catch (OcException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * This method is for deleting the action Set "AllBulbOff".
- */
- public void deleteActionSetBulbOff() {
- Log.i(LOG_TAG, "deleting the action set of bulb off action");
-
- try {
- OCStackResult result = groupManagerObj.deleteActionSet(
- groupResource, "AllBulbOff");
- if (OCStackResult.OC_STACK_OK != result) {
- Log.e(LOG_TAG,
- "deleteActionSet returned error : " + result.name());
- return;
- }
- } catch (OcException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * This method is for observing the bulb on/off status.
- */
- public void observe(OcResource resource) {
- Log.i(LOG_TAG, "Registering observer for bookmark resources status");
-
- Map<String, String> queryMap = new HashMap<String, String>();
- try {
- resource.observe(ObserveType.OBSERVE, queryMap, observeListener);
- } catch (OcException e) {
- e.printStackTrace();
- }
- }
-
- private void executeActionSet(String actonSetName, long delay) {
- try {
- OCStackResult result = groupManagerObj.executeActionSet(
- groupResource, actonSetName, delay);
- if (OCStackResult.OC_STACK_OK != result) {
- Log.e(LOG_TAG,
- "executeActionSet retuned error : " + result.name());
- return;
- }
- } catch (OcException e) {
- e.printStackTrace();
- }
- }
-
- private void cancelActionSet(String actionSetName) {
- try {
- OCStackResult result = groupManagerObj.cancelActionSet(
- groupResource, actionSetName);
- if (OCStackResult.OC_STACK_OK != result) {
- Log.e(LOG_TAG,
- "cancelActionSet returned error : " + result.name());
- return;
- }
- } catch (OcException e) {
- e.printStackTrace();
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-package com.tm.sample;
-
-import java.util.ArrayList;
-
-import org.iotivity.base.ModeType;
-import org.iotivity.base.OcPlatform;
-import org.iotivity.base.PlatformConfig;
-import org.iotivity.base.QualityOfService;
-import org.iotivity.base.ServiceType;
-import org.iotivity.service.tm.GroupManager;
-import org.iotivity.service.tm.GroupManager.*;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.DialogInterface;
-import android.content.DialogInterface.OnClickListener;
-import android.content.Intent;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemClickListener;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-
-/**
- * Starting Activity of the application responsible for configuring the
- * OcPlatform and redirecting to other activity according to user's selection on
- * UI.
- */
-public class MainActivity extends Activity {
-
- private static MainActivity activityObj;
- private ArrayAdapter<String> apis;
- private ArrayList<String> apisList;
- private ListView list;
- private final String LOG_TAG = "[TMSample] "
- + this.getClass()
- .getSimpleName();
- public GroupManager groupManagerObj = new GroupManager();
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- activityObj = this;
-
- list = (ListView) findViewById(R.id.list);
- apisList = new ArrayList<String>();
-
- // adding the item to list that will be displayed on the UI.
- apisList.add("GROUP APIS");
- apisList.add("CONFIGURATION APIS");
- apis = new ArrayAdapter<String>(activityObj,
- android.R.layout.simple_list_item_1, apisList);
- list.setAdapter(apis);
-
- // handling user's selection on the UI
- list.setOnItemClickListener(new OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> parent, View view,
- int position, long id) {
-
- if (position == 0) {
- Intent intent = new Intent(activityObj,
- GroupApiActivity.class);
- startActivity(intent);
- } else if (position == 1) {
- Intent intent = new Intent(activityObj,
- ConfigurationApiActivity.class);
- startActivity(intent);
- }
- }
- });
-
- // calling the method to check the Wi-fi connectivity and configuring
- // the OcPlatform
- configurePlatform();
- }
-
- @Override
- public void onBackPressed() {
- apisList.clear();
- super.onBackPressed();
- }
-
- private void configurePlatform() {
- // local Variables
- ConnectivityManager connManager;
- NetworkInfo wifi;
- AlertDialog dialog;
- PlatformConfig platformConfigObj;
-
- // Check the wifi connectivity
- connManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
- wifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
- if (false == wifi.isConnected()) {
- // WiFi is not connected close the application
- AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
- dialogBuilder.setTitle("Error");
- dialogBuilder
- .setMessage("WiFi is not enabled/connected! Please connect the WiFi and start application again...");
- dialogBuilder.setCancelable(false);
- dialogBuilder.setPositiveButton("OK", new OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- // Closing the application
- activityObj.finish();
- }
- });
-
- dialog = dialogBuilder.create();
- dialog.show();
- Log.i(LOG_TAG,
- "WiFi is not enabled/connected! Please connect the WiFi and start application again...");
- return;
- }
- // If wifi is connected calling the configure method for configuring the
- // OcPlatform
- platformConfigObj = new PlatformConfig(getApplicationContext(),
- ServiceType.IN_PROC, ModeType.CLIENT_SERVER, "0.0.0.0", 0,
- QualityOfService.LOW);
-
- Log.i(LOG_TAG, "Before Calling Configure of ocPlatform");
- OcPlatform.Configure(platformConfigObj);
- Log.i(LOG_TAG, "Configuration done Successfully");
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
- <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
- <classpathentry kind="output" path="bin/classes"/>
-</classpath>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>con-server</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.ApkBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.con_server"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk
- android:minSdkVersion="8"
- android:targetSdkVersion="21" />
- <uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
-
- <application
- android:allowBackup="true"
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:theme="@style/AppTheme" >
- <activity
- android:name="com.example.con_server.MainActivity"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
+++ /dev/null
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-# Project target.
-target=android-20
-
-android.library.reference.1=../../../sdk/java
+++ /dev/null
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingBottom="@dimen/activity_vertical_margin"
- android:paddingLeft="@dimen/activity_horizontal_margin"
- android:paddingRight="@dimen/activity_horizontal_margin"
- android:paddingTop="@dimen/activity_vertical_margin"
- tools:context="com.example.con_server.MainActivity" >
-
-
- <Button
- android:id="@+id/button1"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_centerHorizontal="true"
- android:text="doBootStrap" />
-
- <Button
- android:id="@+id/button2"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_below="@+id/button1"
- android:text="Create Configuration Resources" />
-
- <EditText
- android:id="@+id/EditText"
- android:layout_width="fill_parent"
- android:layout_height="300dp"
- android:layout_alignParentLeft="true"
- android:layout_below="@+id/button2"
- android:layout_marginTop="15dp"
- android:ems="10"
- android:editable="false">
-
- <requestFocus />
- </EditText>
-
-</RelativeLayout>
+++ /dev/null
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
-
- <item
- android:id="@+id/action_settings"
- android:orderInCategory="100"
- android:showAsAction="never"
- android:title="@string/action_settings"/>
-
-</menu>
\ No newline at end of file
+++ /dev/null
-<resources>
-
- <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
- </style>
-
-</resources>
\ No newline at end of file
+++ /dev/null
-<resources>
-
- <style name="AppBaseTheme" parent="android:Theme.Light">
- </style>
-
- <style name="AppTheme" parent="AppBaseTheme">
- </style>
-
-</resources>
\ No newline at end of file
+++ /dev/null
-<resources>
-
- <!--
- Example customization of dimensions originally defined in res/values/dimens.xml
- (such as screen margins) for screens with more than 820dp of available width. This
- would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
- -->
- <dimen name="activity_horizontal_margin">64dp</dimen>
-
-</resources>
+++ /dev/null
-<resources>
-
- <!-- Default screen margins, per the Android Design guidelines. -->
- <dimen name="activity_horizontal_margin">16dp</dimen>
- <dimen name="activity_vertical_margin">16dp</dimen>
-
-</resources>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
- <string name="app_name">con-server</string>
- <string name="hello_world">Hello world!</string>
- <string name="action_settings">Settings</string>
-
-</resources>
+++ /dev/null
-<resources>
-
- <style name="AppBaseTheme" parent="android:Theme.Light">
-
- </style>
-
- <!-- Application theme. -->
- <style name="AppTheme" parent="AppBaseTheme">
-
- </style>
-
-</resources>
\ No newline at end of file
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-package com.example.con_server;
-
-import java.util.EnumSet;
-import java.util.Vector;
-
-import org.iotivity.base.OcException;
-import org.iotivity.base.OcPlatform;
-import org.iotivity.base.OcRepresentation;
-import org.iotivity.base.OcResourceHandle;
-import org.iotivity.base.ResourceProperty;
-
-import android.util.Log;
-
-//For creating/deleting the configuration Resource
-public class ConfigurationResource {
- private final String LOG_TAG = "[CON-SERVER]"
- + this.getClass()
- .getSimpleName();
- // Configuration resource members
- protected String configurationUri;
- protected String deviceName;
- protected String location;
- protected String locationName;
- protected String currency;
- protected String region;
- protected Vector<String> configurationTypes = new Vector<String>();
- protected Vector<String> configurationInterfaces = new Vector<String>();
- protected OcRepresentation configurationRep = new OcRepresentation();
- protected OcResourceHandle configurationHandle;
-
- // constructors
- public ConfigurationResource() {
- Log.i(LOG_TAG, "ConfigurationResource: enter");
-
- deviceName = ConfigurationDefaultValues.defaultDeviceName;
- location = ConfigurationDefaultValues.defaultLocation;
- locationName = ConfigurationDefaultValues.defaultLocationName;
- currency = ConfigurationDefaultValues.defaultCurrency;
- region = ConfigurationDefaultValues.defaultRegion;
-
- configurationUri = ConfigurationDefaultValues.ConURIPrefix;
- configurationTypes
- .add(ConfigurationDefaultValues.ConResourceTypePrefix);
- configurationInterfaces.add(OcPlatform.DEFAULT_INTERFACE);
-
- configurationRep.setValueString("n", deviceName);
- configurationRep.setValueString("loc", location);
- configurationRep.setValueString("locn", locationName);
- configurationRep.setValueString("c", currency);
- configurationRep.setValueString("r", region);
-
- configurationRep.setUri(configurationUri);
- configurationRep.setResourceTypes(configurationTypes);
- configurationRep.setResourceInterfaces(configurationInterfaces);
- }
-
- // For creating Configuration Resource
- public void createResource(OcPlatform.EntityHandler listener)
- throws OcException {
- Log.i(LOG_TAG, "createResource(configuration): enter");
- EnumSet<ResourceProperty> propertySet = EnumSet.of(
- ResourceProperty.DISCOVERABLE, ResourceProperty.OBSERVABLE);
-
- // Register configuration resource
- configurationHandle = OcPlatform.registerResource(configurationUri,
- configurationTypes.elementAt(0),
- configurationInterfaces.elementAt(0), listener, propertySet);
-
- Log.i(LOG_TAG, "createResource(configuration): exit");
- }
-
- // Setters and Getters methods for Configuration resource
- public void setConfigurationRepresentation(OcRepresentation rep) {
- Log.i(LOG_TAG, "setConfigurationRepresentation: enter");
-
- String dName = rep.getValueString("n");
- String loc = rep.getValueString("loc");
- String locn = rep.getValueString("locn");
- String cur = rep.getValueString("c");
- String reg = rep.getValueString("r");
-
- if (!(dName.equalsIgnoreCase(""))) {
- deviceName = dName;
- Log.i(LOG_TAG,
- "setConfigurationRepresentation: New value(deviceName): "
- + deviceName);
- }
- if (!(loc.equalsIgnoreCase(""))) {
- location = loc;
- Log.i(LOG_TAG,
- "setConfigurationRepresentation: New value(location): "
- + location);
- }
- if (!(locn.equalsIgnoreCase(""))) {
- locationName = locn;
- Log.i(LOG_TAG,
- "setConfigurationRepresentation: New value(locationName): "
- + locationName);
- }
- if (!(cur.equalsIgnoreCase(""))) {
- currency = cur;
- Log.i(LOG_TAG,
- "setConfigurationRepresentation: New value(currency): "
- + currency);
- }
- if (!(reg.equalsIgnoreCase(""))) {
- region = reg;
- Log.i(LOG_TAG,
- "setConfigurationRepresentation: New value(region): "
- + region);
- }
-
- Log.i(LOG_TAG, "setConfigurationRepresentation: exit");
- }
-
- public OcRepresentation getConfigurationRepresentation() {
-
- configurationRep.setValueString("n", deviceName);
- configurationRep.setValueString("loc", location);
- configurationRep.setValueString("locn", locationName);
- configurationRep.setValueString("c", currency);
- configurationRep.setValueString("r", region);
- return configurationRep;
- }
-
- public String getUri() {
- return configurationUri;
- }
-
- // For resetting the default values to configuration Resource
- public void factoryReset() {
-
- deviceName = ConfigurationDefaultValues.defaultDeviceName;
- location = ConfigurationDefaultValues.defaultLocation;
- locationName = ConfigurationDefaultValues.defaultLocationName;
- currency = ConfigurationDefaultValues.defaultCurrency;
- region = ConfigurationDefaultValues.defaultRegion;
- Log.i(LOG_TAG, "ConfiguartionResource: factoryReset done");
- }
-
- // Deleting all the resources, that we have created using createResources()
- public void deleteResource() {
- try {
- if (null != configurationHandle) {
- // Unregister the Configuration resource
- OcPlatform.unregisterResource(configurationHandle);
- }
-
- } catch (OcException e) {
- Log.e(LOG_TAG, "OcException occured! " + e.toString());
- }
- }
-}
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-package com.example.con_server;
-
-import java.util.EnumSet;
-import java.util.Vector;
-
-import org.iotivity.base.EntityHandlerResult;
-import org.iotivity.base.OcException;
-import org.iotivity.base.OcHeaderOption;
-import org.iotivity.base.OcPlatform;
-import org.iotivity.base.OcRepresentation;
-import org.iotivity.base.OcResourceRequest;
-import org.iotivity.base.OcResourceResponse;
-import org.iotivity.base.RequestHandlerFlag;
-import org.iotivity.base.RequestType;
-import org.iotivity.service.tm.OCStackResult;
-import org.iotivity.service.tm.GroupManager;
-import org.iotivity.service.tm.ThingsConfiguration;
-import org.iotivity.service.tm.ThingsConfiguration.*;
-import org.iotivity.service.tm.ThingsMaintenance;
-import org.iotivity.service.tm.ThingsMaintenance.*;
-
-import android.os.Message;
-import android.util.Log;
-
-/*
- * For Creating the Resources [configuration, Maintenance & FactoryRest] &
- * for Handling of the Client's Request
- */
-public class ConfigurationServer {
- private final String LOG_TAG = "[CON-SERVER]"
- + this.getClass()
- .getSimpleName();
- private GroupManager groupmanager = null;
- private ThingsConfiguration thingsconfig = null;
- private ThingsMaintenance thingsmnt = null;
- private ConfigurationResource conResource = null;
- private MaintenanceResource mntResource = null;
- private FactorySetResource factorysetResource = null;
-
- private final ThingsConfigurationListener thingConfigurationListener;
- private final ThingsMaintenanceListener thingsMaintenanceListener;
- private final RequestHandler requestHandler;
-
- // constructor
- public ConfigurationServer() {
- groupmanager = new GroupManager();
- thingsconfig = ThingsConfiguration.getInstance();
- thingsmnt = ThingsMaintenance.getInstance();
- thingConfigurationListener = new ThingsConfigurationListener();
- thingsMaintenanceListener = new ThingsMaintenanceListener();
- requestHandler = new RequestHandler();
-
- thingsconfig.setConfigurationListener(thingConfigurationListener);
- thingsmnt.setThingsMaintenanceListener(thingsMaintenanceListener);
-
- }
-
- // Creating resources : configuration, maintenance, factoryReset
- public void CreateConfigurationResource() {
- Log.i(LOG_TAG, "CreateConfigurationResource: enter");
-
- try {
- conResource = new ConfigurationResource();
- conResource.createResource(requestHandler);
-
- mntResource = new MaintenanceResource();
- mntResource.createResource(requestHandler);
-
- factorysetResource = new FactorySetResource();
- factorysetResource.createResource(requestHandler);
- } catch (OcException e) {
- Log.e(LOG_TAG, "OcException occured: " + e.toString());
- }
-
- Log.i(LOG_TAG, "CreateConfigurationResource: exit");
-
- String message = "Resources Created Successfully(Server is Ready)";
-
- Message msg = Message.obtain();
- msg.what = 0;
- MainActivity mainActivityObj = MainActivity.getMainActivityObject();
- MainActivity.setmessage(message);
- mainActivityObj.getmHandler().sendMessage(msg);
- }
-
- public void DoBootStrap() {
- Log.i(LOG_TAG, "DoBootStrap: enter");
-
- OCStackResult result = thingsconfig.doBootstrap();
- if (OCStackResult.OC_STACK_ERROR == result) {
- Log.e(LOG_TAG, "doBootStrap returned error: "
- + OCStackResult.OC_STACK_ERROR.name());
- }
- Log.i(LOG_TAG, "DoBootStrap: exit");
- }
-
- private class ThingsConfigurationListener implements IConfigurationListener {
-
- @Override
- public void onBootStrapCallback(Vector<OcHeaderOption> headerOptions,
- OcRepresentation rep, int errorValue) {
-
- String message;
- Log.i(LOG_TAG, "onBootStrapCallback");
-
- // setting the default values received from bootstrap Server
- ConfigurationDefaultValues.defaultDeviceName = rep
- .getValueString("n");
- ConfigurationDefaultValues.defaultLocation = rep
- .getValueString("loc");
- ConfigurationDefaultValues.defaultLocationName = rep
- .getValueString("locn");
- ConfigurationDefaultValues.defaultCurrency = rep
- .getValueString("c");
- ConfigurationDefaultValues.defaultRegion = rep.getValueString("r");
-
- // forming the message to display on UI
- message = "URI : " + rep.getUri() + "\n";
- message += "Device Name : "
- + ConfigurationDefaultValues.defaultDeviceName + "\n";
- message += "Location : "
- + ConfigurationDefaultValues.defaultLocation + "\n";
- message += "Location Name : "
- + ConfigurationDefaultValues.defaultLocationName + "\n";
- message += "Currency : "
- + ConfigurationDefaultValues.defaultCurrency + "\n";
- message += "Region : " + ConfigurationDefaultValues.defaultRegion
- + "\n";
-
- Log.i(LOG_TAG, "Resource URI: " + rep.getUri());
- Log.i(LOG_TAG, "Region: "
- + ConfigurationDefaultValues.defaultRegion);
- Log.i(LOG_TAG, "Device Name: "
- + ConfigurationDefaultValues.defaultDeviceName);
- Log.i(LOG_TAG, "Location: "
- + ConfigurationDefaultValues.defaultLocation);
- Log.i(LOG_TAG, "Location Name: "
- + ConfigurationDefaultValues.defaultLocationName);
- Log.i(LOG_TAG, "Currency: "
- + ConfigurationDefaultValues.defaultCurrency);
-
- // showing the formed message on the UI
- Message msg = Message.obtain();
- msg.what = 0;
- MainActivity mainActivityObj = MainActivity.getMainActivityObject();
- MainActivity.setmessage(message);
- mainActivityObj.getmHandler().sendMessage(msg);
- // TODO Auto-generated method stub
- }
-
- @Override
- public void onUpdateConfigurationsCallback(
- Vector<OcHeaderOption> headerOptions, OcRepresentation rep,
- int errorValue) {
- Log.i(LOG_TAG, "onUpdateConfigurationsCallback");
- }
-
- @Override
- public void onGetConfigurationsCallback(
- Vector<OcHeaderOption> headerOptions, OcRepresentation rep,
- int errorValue) {
- Log.i(LOG_TAG, "onGetConfigurationsCallback");
- }
- }
-
- private class ThingsMaintenanceListener implements
- IThingsMaintenanceListener {
-
- // Callback Function for Reboot
- @Override
- public void onRebootCallback(Vector<OcHeaderOption> headerOptions,
- OcRepresentation rep, int errorValue) {
- Log.i(LOG_TAG, "onRebootCallback");
- }
-
- // Callback Function for FactoryReset
- @Override
- public void onFactoryResetCallback(
- Vector<OcHeaderOption> headerOptions, OcRepresentation rep,
- int errorValue) {
- Log.i(LOG_TAG, "onFactoryResetCallback");
- }
- }
-
- // For deleting all the resources
- public void deleteResources() {
- if (null != conResource)
- conResource.deleteResource();
- if (null != mntResource)
- mntResource.deleteResource();
- if (null != factorysetResource)
- factorysetResource.deleteResource();
- }
-
- private class RequestHandler implements OcPlatform.EntityHandler {
-
- @Override
- public EntityHandlerResult handleEntity(OcResourceRequest request) {
- Log.i(LOG_TAG, "handleEntity: enter");
-
- EntityHandlerResult result = EntityHandlerResult.ERROR;
- if (null == request) {
- Log.e(LOG_TAG, "handleEntity: Invalid OcResourceRequest!");
- return result;
- }
-
- RequestType requestType = request.getRequestType();
- EnumSet<RequestHandlerFlag> requestHandlerFlag = request
- .getRequestHandlerFlagSet();
- Log.i(LOG_TAG, "prepareResponseForResource: request type: "
- + requestType.name());
- Log.i(LOG_TAG, "prepareResponseForResource: request for resource: "
- + request.getResourceUri());
-
- if (requestHandlerFlag.contains(RequestHandlerFlag.REQUEST)) {
- if (RequestType.GET == requestType) {
- sendResponse(request);
- } else if (RequestType.PUT == requestType) {
- OcRepresentation rep = request.getResourceRepresentation();
- if (null == rep) {
- Log.e(LOG_TAG,
- "handleEntity: Invalid resource representation!");
- return result;
- }
-
- if (request.getResourceUri().equalsIgnoreCase(
- conResource.getUri())) {
- conResource.setConfigurationRepresentation(rep);
- } else if (request.getResourceUri().equalsIgnoreCase(
- mntResource.getUri())) {
-
- String factorysetAtt = rep.getValueString("fr");
- if (factorysetAtt.equalsIgnoreCase("true")) {
- conResource.factoryReset();
- }
- mntResource.setDiagnosticsRepresentation(rep);
- }
- sendResponse(request);
- }
- }
-
- Log.i(LOG_TAG, "handleEntity: exit");
- return result;
- }
- }
-
- // For sending response to the client
- private void sendResponse(OcResourceRequest request) {
- Log.i(LOG_TAG, "sendResponse: enter");
-
- OcResourceResponse response = new OcResourceResponse();
- OcRepresentation rep = null;
-
- response.setRequestHandle(request.getRequestHandle());
- response.setResourceHandle(request.getResourceHandle());
-
- if (request.getResourceUri().equalsIgnoreCase(conResource.getUri())) {
- rep = conResource.getConfigurationRepresentation();
- } else if (request.getResourceUri().equalsIgnoreCase(
- mntResource.getUri())) {
- rep = mntResource.getDiagnosticsRepresentation();
- }
- response.setResourceRepresentation(rep, OcPlatform.DEFAULT_INTERFACE);
-
- try {
- OcPlatform.sendResponse(response);
- } catch (OcException e) {
- Log.e(LOG_TAG, "sendResponse: OcException occured: " + e.toString());
- }
- Log.i(LOG_TAG, "sendResponse: exit");
- }
-}
-
-// Default values for Resources
-class ConfigurationDefaultValues {
-
- // configuration Resource default values
-
- public static String defaultDeviceName = new String();
- public static String defaultLocation = new String();
- public static String defaultLocationName = new String();
- public static String defaultCurrency = new String();
- public static String defaultRegion = new String();
-
- public static String ConURIPrefix = "/oic/con";
- public static String ConResourceTypePrefix = "oic.wk.con";
-
- // Diagnostics Resource default values
- public static String diagURIPrefix = "/oic/mnt";
- public static String diagResourceTypePrefix = "oic.wk.mnt";
- public static String diagnosticsValue = "false";
- public static String defaultFactoryReset = "false";
- public static String defaultReboot = "false";
- public static String defaultStartCollection = "false";
-}
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-package com.example.con_server;
-
-import java.util.EnumSet;
-
-import org.iotivity.base.OcException;
-import org.iotivity.base.OcPlatform;
-import org.iotivity.base.OcRepresentation;
-import org.iotivity.base.ResourceProperty;
-
-import android.util.Log;
-
-// For creating & deleting the FactorySet Resource
-public class FactorySetResource extends ConfigurationResource {
- private final String LOG_TAG = "[CON-SERVER]"
- + this.getClass().getSimpleName();
-
- // constructor
- public FactorySetResource() {
- Log.i(LOG_TAG, "FactorySetCollection: enter");
-
- configurationUri = "/factoryset"; // uri of the resource
- configurationTypes.clear();
- configurationTypes.add("factoryset");
- configurationRep.setUri(configurationUri);
- configurationRep.setResourceTypes(configurationTypes);
- }
-
- // for creating FactoryReset Resource
- public void createResource(OcPlatform.EntityHandler listener)
- throws OcException {
- Log.i(LOG_TAG, "createResource(Factory Set): enter");
- EnumSet<ResourceProperty> propertySet = EnumSet.of(
- ResourceProperty.DISCOVERABLE, ResourceProperty.OBSERVABLE);
- if (null == listener) {
- Log.i(LOG_TAG, "CallBack Should be binded");
- return;
- }
-
- // Register factoryset resource
- configurationHandle = OcPlatform.registerResource(configurationUri,
- configurationTypes.elementAt(0),
- configurationInterfaces.elementAt(0), listener, propertySet);
- if (null == configurationHandle) {
- Log.e(LOG_TAG, "registerResource failed!");
- return;
- }
- Log.i(LOG_TAG, "createResource (Factory Set): exit");
- }
-
- // getters and Setters Methods for FacoryReset Resource
- public void setFactorySetRepresentation(OcRepresentation rep) {
- Log.i(LOG_TAG, "setFactorySetRepresentation: enter");
-
- String dName = rep.getValueString("n");
- String loc = rep.getValueString("loc");
- String locn = rep.getValueString("locn");
- String cur = rep.getValueString("c");
- String reg = rep.getValueString("r");
-
- if (!(dName.equalsIgnoreCase(""))) {
- deviceName = dName;
- Log.i(LOG_TAG,
- "setConfigurationRepresentation: New value(deviceName): "
- + deviceName);
- }
- if (!(loc.equalsIgnoreCase(""))) {
- location = loc;
- Log.i(LOG_TAG,
- "setConfigurationRepresentation: New value(location): "
- + location);
- }
- if (!(locn.equalsIgnoreCase(""))) {
- locationName = locn;
- Log.i(LOG_TAG,
- "setConfigurationRepresentation: New value(locationName): "
- + locationName);
- }
- if (!(cur.equalsIgnoreCase(""))) {
- currency = cur;
- Log.i(LOG_TAG,
- "setConfigurationRepresentation: New value(currency): "
- + currency);
- }
- if (!(reg.equalsIgnoreCase(""))) {
- region = reg;
- Log.i(LOG_TAG,
- "setConfigurationRepresentation: New value(region): "
- + region);
- }
- Log.i(LOG_TAG, "setFactorySetRepresentation: exit");
- }
-
- OcRepresentation getFactorySetRepresentation() {
-
- configurationRep.setValueString("n", deviceName);
- configurationRep.setValueString("loc", location);
- configurationRep.setValueString("locn", locationName);
- configurationRep.setValueString("c", currency);
- configurationRep.setValueString("r", region);
- return configurationRep;
- }
-
- public String getUri() {
- return configurationUri;
- }
-
- // For deletingFactorySet Resource
- public void deleteResource() {
- try {
- if (null != configurationHandle) {
- // Unregister the collection resource
- OcPlatform.unregisterResource(configurationHandle);
- }
- } catch (OcException e) {
- Log.e(LOG_TAG, "OcException occured! " + e.toString());
- }
- }
-}
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-package com.example.con_server;
-
-import org.iotivity.base.ModeType;
-import org.iotivity.base.OcPlatform;
-import org.iotivity.base.PlatformConfig;
-import org.iotivity.base.QualityOfService;
-import org.iotivity.base.ServiceType;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.ProgressDialog;
-import android.content.DialogInterface;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.util.Log;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.Button;
-import android.widget.EditText;
-
-/*
- * Starting Activity of the application responsible for
- * configuring the OcPlatform and for handling user's selection on UI.
- */
-public class MainActivity extends Activity {
-
- private final String LOG_TAG = "[CON-SERVER]"
- + this.getClass()
- .getSimpleName();
- private Handler mHandler;
- private static MainActivity mainActivityObj;
- private ConfigurationServer conServerObj;
- private static String message;
- private EditText editText;
- public static ProgressDialog dialog;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
-
- mainActivityObj = this;
- Button doBootStrap = (Button) findViewById(R.id.button1);
- final Button createConfig = (Button) findViewById(R.id.button2);
- createConfig.setEnabled(false);
- editText = (EditText) findViewById(R.id.EditText);
- conServerObj = new ConfigurationServer();
-
- // handler for updating the UI i.e. MessageLog (TextBox)
- mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case 0:
- editText.setText(message);
- Log.i(LOG_TAG, message);
- }
- }
- };
- setmHandler(mHandler);
-
- // listener for doBootStrap Button
- doBootStrap.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- conServerObj.DoBootStrap();
- createConfig.setEnabled(true);
- }
- });
-
- // listener for createConfiguration Resource Button
- createConfig.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- conServerObj.CreateConfigurationResource();
- createConfig.setEnabled(false);
- }
- });
-
- // calling the method to check the Wi-fi connectivity and configuring
- // the OcPlatform
- configurePlatform();
- }
-
- private void configurePlatform() {
-
- // Check the wi-fi connectivity
- ConnectivityManager connmanager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
- NetworkInfo wifi = connmanager
- .getNetworkInfo(ConnectivityManager.TYPE_WIFI);
- if (false == wifi.isConnected()) {
- // WiFi is not connected close the application
- AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
- dialogBuilder.setTitle("Error");
- dialogBuilder
- .setMessage("WiFi is not enabled/connected! Please connect the WiFi and start application again...");
- dialogBuilder.setCancelable(false);
- dialogBuilder.setPositiveButton("OK",
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- // Closing the application
- mainActivityObj.finish();
- }
- });
-
- AlertDialog dialog = dialogBuilder.create();
- dialog.show();
- Log.i(LOG_TAG,
- "WiFi is not enabled/connected! Please connect the WiFi and start application again...");
- return;
- }
-
- // If wifi is connected calling the configure method for configuring the
- // ocPlatform
- PlatformConfig cfg = new PlatformConfig(getApplicationContext(),
- ServiceType.IN_PROC, ModeType.CLIENT_SERVER, "0.0.0.0", 0,
- QualityOfService.LOW);
- OcPlatform.Configure(cfg);
- Log.i(LOG_TAG, "Configuration done Successfully");
- }
-
- @Override
- public void onBackPressed() {
- super.onBackPressed();
-
- // deleting all the resources that we have created.
- if (null != conServerObj)
- conServerObj.deleteResources();
- }
-
- @SuppressWarnings("unused")
- private Handler handler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- dialog.dismiss();
- }
- };
-
- // Function called when receive a reboot Request
- public static void reboot() throws InterruptedException {
-
- dialog = new ProgressDialog(mainActivityObj);
- dialog.setMessage("Rebooting..");
- dialog.setTitle("Please wait ...");
- dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
- dialog.setProgress(0);
- dialog.setMax(100);
- dialog.show();
- // Log.i(LOG_TAG, "Rebooting.. Please wait ...");
- Thread thread = new Thread() {
- @Override
- public void run() {
- try {
- sleep(5000);
- dialog.dismiss();
-
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- };
- thread.start();
- }
-
- // Functions required for updating the UI
-
- public Handler getmHandler() {
- return mHandler;
- }
-
- public void setmHandler(Handler mHandler) {
- this.mHandler = mHandler;
- }
-
- public static MainActivity getMainActivityObject() {
- return mainActivityObj;
- }
-
- public static void setmessage(String msg) {
- message = msg;
- }
-}
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-package com.example.con_server;
-
-import java.util.EnumSet;
-import java.util.Vector;
-
-import org.iotivity.base.OcException;
-import org.iotivity.base.OcPlatform;
-import org.iotivity.base.OcRepresentation;
-import org.iotivity.base.OcResourceHandle;
-import org.iotivity.base.ResourceProperty;
-
-import android.util.Log;
-
-//For creating/deleting the Diagnostics Resource
-public class MaintenanceResource {
- private final String LOG_TAG = "[CON-SERVER]"
- + this.getClass()
- .getSimpleName();
- // maintenance members
- private String m_maintenanceUri;
- private String m_factoryReset;
- private String m_reboot;
- private String m_startCollection;
- private Vector<String> m_maintenanceTypes = new Vector<String>();
- private Vector<String> m_maintenanceInterfaces = new Vector<String>();
- private OcResourceHandle m_maintenanceHandle = null;
- private OcRepresentation m_maintenanceRep = new OcRepresentation();
-
- // constructor
- public MaintenanceResource() {
- Log.i(LOG_TAG, "MaintenanceResource: enter");
-
- m_factoryReset = ConfigurationDefaultValues.defaultFactoryReset;
- m_reboot = ConfigurationDefaultValues.defaultReboot;
- m_startCollection = ConfigurationDefaultValues.defaultStartCollection;
-
- m_maintenanceUri = ConfigurationDefaultValues.diagURIPrefix;
- m_maintenanceTypes
- .add(ConfigurationDefaultValues.diagResourceTypePrefix);
- m_maintenanceInterfaces.add(OcPlatform.DEFAULT_INTERFACE);
- m_maintenanceRep.setValueString("fr", m_factoryReset);
- m_maintenanceRep.setValueString("rb", m_reboot);
- m_maintenanceRep.setValueString("ssc", m_startCollection);
- m_maintenanceRep.setUri(m_maintenanceUri);
- m_maintenanceRep.setResourceTypes(m_maintenanceTypes);
- m_maintenanceRep.setResourceInterfaces(m_maintenanceInterfaces);
- }
-
- // for creating Diagnostic Resource
- public void createResource(OcPlatform.EntityHandler listener)
- throws OcException {
- Log.i(LOG_TAG, "createResource(Maintenance): enter");
- EnumSet<ResourceProperty> propertySet = EnumSet.of(
- ResourceProperty.DISCOVERABLE, ResourceProperty.OBSERVABLE);
- if (null == listener) {
- Log.i(LOG_TAG, "CallBack Should be binded");
- return;
- }
-
- // Register diagnostic resource
- m_maintenanceHandle = OcPlatform.registerResource(m_maintenanceUri,
- m_maintenanceTypes.get(0), m_maintenanceInterfaces.get(0),
- listener, propertySet);
- if (null == m_maintenanceHandle) {
- Log.e(LOG_TAG, "registerResource failed!");
- return;
- }
-
- Thread thread = new Thread() {
- @Override
- public void run() {
- try {
- while (true) {
- // Put this thread for sleep for 1 sec.
- // Sleep value can be changed as per the developer
- // convenience.
- Thread.sleep(1000);
- if (m_reboot.equalsIgnoreCase("true")) {
- Log.i(LOG_TAG, "Reboot will be soon...");
- MainActivity mainActivityObj = MainActivity
- .getMainActivityObject();
- if (null == mainActivityObj) {
- Log.e(LOG_TAG,
- "Mainactivity object is invalid!");
- return;
- }
- try {
- mainActivityObj.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- try {
- MainActivity.reboot();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- });
- } catch (Exception e) {
- Log.e(LOG_TAG, "InterruptedException occured: "
- + e.toString());
- continue;
- }
- m_reboot = ConfigurationDefaultValues.defaultReboot;
- }
- if (m_factoryReset.equalsIgnoreCase("true")) {
- m_factoryReset = ConfigurationDefaultValues.defaultFactoryReset;
- factoryReset();
- }
- }
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- };
- thread.start();
- Log.i(LOG_TAG, "createResource(Diagnostics): exit");
- }
-
- // getters and Setters Methods for diagnostics Resource
- public void setDiagnosticsRepresentation(OcRepresentation rep) {
- Log.i(LOG_TAG, "setDiagnosticsRepresentation: enter");
-
- String fr = rep.getValueString("fr");
- String rb = rep.getValueString("rb");
- String ssc = rep.getValueString("ssc");
-
- if (!(fr.equalsIgnoreCase(""))) {
- m_factoryReset = fr;
- Log.i(LOG_TAG,
- "setConfigurationRepresentation: New value(FactoryReset): "
- + fr);
- }
- if (!(rb.equalsIgnoreCase(""))) {
- m_reboot = rb;
- Log.i(LOG_TAG, "setDiagnosticsRepresentation: new value:(reboot) "
- + rb);
- }
-
- if (!(ssc.equalsIgnoreCase(""))) {
- m_startCollection = ssc;
- Log.i(LOG_TAG,
- "setDiagnosticsRepresentation: new value:(startcollection) "
- + ssc);
- }
- Log.i(LOG_TAG, "setDiagnosticsRepresentation: exit");
- }
-
- OcRepresentation getDiagnosticsRepresentation() {
- m_maintenanceRep.setValueString("fr", m_factoryReset);
- m_maintenanceRep.setValueString("rb", m_reboot);
- m_maintenanceRep.setValueString("ssc", m_startCollection);
- return m_maintenanceRep;
- }
-
- public String getUri() {
- return m_maintenanceUri;
- }
-
- // For Resetting diagnostics Resource attributes to their default values
- public void factoryReset() {
- m_factoryReset = ConfigurationDefaultValues.defaultFactoryReset;
- m_reboot = ConfigurationDefaultValues.defaultReboot;
- m_startCollection = ConfigurationDefaultValues.defaultStartCollection;
- }
-
- // For Deleting diagnostic resource
- public void deleteResource() {
- try {
- if (null != m_maintenanceHandle) {
- // Unregister the collection resource
- OcPlatform.unregisterResource(m_maintenanceHandle);
- }
- } catch (OcException e) {
- Log.e(LOG_TAG, "OcException occured! " + e.toString());
- }
- }
-}
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-///
-/// This sample shows how one could create a resource (collection) with children.
-///
-
-#include <functional>
-#include <thread>
-#include <string.h>
-
-#include "OCPlatform.h"
-#include "OCApi.h"
-#include "ConfigurationCollection.h"
-
-using namespace OC;
-using namespace std;
-
-/// This function internally calls registerResource API.
-void ConfigurationResource::createResources(ResourceEntityHandler callback)
-{
- using namespace OC::OCPlatform;
-
- if (callback == NULL)
- {
- std::cout << "callback should be binded\t";
- return;
- }
-
- // This will internally create and register the resource.
- OCStackResult result = registerResource(m_configurationHandle, m_configurationUri,
- m_configurationTypes[0], m_configurationInterfaces[0], callback,
- OC_DISCOVERABLE | OC_OBSERVABLE);
-
- if (OC_STACK_OK != result)
- {
- std::cout << "Resource creation (configuration) was unsuccessful\n";
- }
-
- std::cout << "Configuration Resource is Created!(URI: " << m_configurationUri << ") \n";
-}
-
-void ConfigurationResource::setConfigurationRepresentation(OCRepresentation& rep)
-{
- string value;
-
- if (rep.getValue("n", value))
- {
- m_deviceName = value;
- std::cout << "\t\t\t\t" << "m_deviceName: " << m_deviceName << std::endl;
- }
-
- if (rep.getValue("loc", value))
- {
- m_location = value;
- std::cout << "\t\t\t\t" << "m_location: " << m_location << std::endl;
- }
-
- if (rep.getValue("locn", value))
- {
- m_locationName = value;
- std::cout << "\t\t\t\t" << "m_locationName: " << m_locationName << std::endl;
- }
-
- if (rep.getValue("c", value))
- {
- m_currency = value;
- std::cout << "\t\t\t\t" << "m_currency: " << m_currency << std::endl;
- }
-
- if (rep.getValue("r", value))
- {
- m_region = value;
- std::cout << "\t\t\t\t" << "m_region: " << m_region << std::endl;
- }
-}
-
-OCRepresentation ConfigurationResource::getConfigurationRepresentation()
-{
- m_configurationRep.setValue("n", m_deviceName);
- m_configurationRep.setValue("loc", m_location);
- m_configurationRep.setValue("locn", m_locationName);
- m_configurationRep.setValue("c", m_currency);
- m_configurationRep.setValue("r", m_region);
-
- return m_configurationRep;
-}
-
-std::string ConfigurationResource::getUri()
-{
- return m_configurationUri;
-}
-
-void ConfigurationResource::factoryReset()
-{
- m_deviceName = defaultDeviceName;
- m_location = defaultLocation;
- m_locationName = defaultLocationName;
- m_currency = defaultCurrency;
- m_region = defaultRegion;
-}
-
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-///
-/// This sample shows how one could create a resource (collection) with children.
-///
-
-#include <functional>
-#include <thread>
-
-#include "OCPlatform.h"
-#include "OCApi.h"
-
-#pragma once
-
-using namespace OC;
-
-typedef std::function<
- OCEntityHandlerResult(std::shared_ptr< OCResourceRequest > request) > ResourceEntityHandler;
-
-static std::string defaultConURI = "/oic/con";
-static std::string defaultConResourceType = "oic.wk.con";
-
-extern std::string defaultDeviceName;
-extern std::string defaultLocation;
-extern std::string defaultLocationName;
-extern std::string defaultCurrency;
-extern std::string defaultRegion;
-
-class ConfigurationResource
-{
-public:
- // Configuration members
- std::string m_configurationUri;
- std::string m_deviceName;
- std::string m_location;
- std::string m_locationName;
- std::string m_currency;
- std::string m_region;
- std::vector< std::string > m_configurationTypes;
- std::vector< std::string > m_configurationInterfaces;
- OCResourceHandle m_configurationHandle;
- OCRepresentation m_configurationRep;
-
-public:
- /// Constructor
- ConfigurationResource() :
- m_deviceName(defaultDeviceName), m_location(defaultLocation),
- m_locationName(defaultLocationName), m_currency(defaultCurrency),
- m_region(defaultRegion)
- {
- m_configurationUri = defaultConURI; // URI of the resource
- m_configurationTypes.push_back(defaultConResourceType); // resource type name.
- m_configurationInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
- m_configurationRep.setValue("st", m_deviceName);
- m_configurationRep.setValue("loc", m_location);
- m_configurationRep.setValue("locn", m_locationName);
- m_configurationRep.setValue("c", m_currency);
- m_configurationRep.setValue("r", m_region);
- m_configurationRep.setUri(m_configurationUri);
- m_configurationRep.setResourceTypes(m_configurationTypes);
- m_configurationRep.setResourceInterfaces(m_configurationInterfaces);
- m_configurationHandle = NULL;
- }
- ;
-
- ~ConfigurationResource()
- {
-
- }
-
- /// This function internally calls registerResource API.
- void createResources(ResourceEntityHandler callback);
- void setConfigurationRepresentation(OCRepresentation& rep);
- OCRepresentation getConfigurationRepresentation();
- std::string getUri();
-
- void factoryReset();
-
-};
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-///
-/// This sample shows how one could create a resource (collection) with children.
-///
-
-#include <functional>
-#include <thread>
-#include <string.h>
-
-#include "OCPlatform.h"
-#include "OCApi.h"
-#include "FactorySetCollection.h"
-
-using namespace OC;
-using namespace std;
-
-FactorySetResource::FactorySetResource()
-{
- m_configurationUri = "/factoryset"; // URI of the resource
- m_configurationTypes.clear();
- m_configurationTypes.push_back("factoryset"); // resource type name.
- m_configurationRep.setUri(m_configurationUri);
- m_configurationRep.setResourceTypes(m_configurationTypes);
-}
-
-FactorySetResource::~FactorySetResource()
-{
-}
-
-/// This function internally calls registerResource API.
-void FactorySetResource::createResources(ResourceEntityHandler callback)
-{
- using namespace OC::OCPlatform;
-
- if (callback == NULL)
- {
- std::cout << "callback should be binded\t";
- return;
- }
-
- // This will internally create and register the resource.
- OCStackResult result = registerResource(m_configurationHandle, m_configurationUri,
- m_configurationTypes[0], m_configurationInterfaces[0], callback,
- OC_DISCOVERABLE | OC_OBSERVABLE);
-
- if (OC_STACK_OK != result)
- {
- std::cout << "Resource creation (configuration) was unsuccessful\n";
- }
-
- std::cout << "FactorySet Resource is Created!\n";
-}
-
-void FactorySetResource::setFactorySetRepresentation(OCRepresentation& rep)
-{
- string value;
-
- if (rep.getValue("n", value))
- {
- m_deviceName = value;
- std::cout << "\t\t\t\t" << "m_deviceName: " << m_deviceName << std::endl;
- }
-
- if (rep.getValue("loc", value))
- {
- m_location = value;
- std::cout << "\t\t\t\t" << "m_location: " << m_location << std::endl;
- }
-
- if (rep.getValue("locn", value))
- {
- m_locationName = value;
- std::cout << "\t\t\t\t" << "m_locationName: " << m_locationName << std::endl;
- }
-
- if (rep.getValue("c", value))
- {
- m_currency = value;
- std::cout << "\t\t\t\t" << "m_currency: " << m_currency << std::endl;
- }
-
- if (rep.getValue("r", value))
- {
- m_region = value;
- std::cout << "\t\t\t\t" << "m_region: " << m_region << std::endl;
- }
-}
-
-OCRepresentation FactorySetResource::getFactorySetRepresentation()
-{
- m_configurationRep.setValue("n", m_deviceName);
- m_configurationRep.setValue("loc", m_location);
- m_configurationRep.setValue("locn", m_locationName);
- m_configurationRep.setValue("c", m_currency);
- m_configurationRep.setValue("r", m_region);
-
- return m_configurationRep;
-}
-
-std::string FactorySetResource::getUri()
-{
- return m_configurationUri;
-}
-
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-///
-/// This sample shows how one could create a resource (collection) with children.
-///
-
-#include <functional>
-#include <thread>
-
-#include "OCPlatform.h"
-#include "OCApi.h"
-//#include "ThingsManager.h"
-#include "ConfigurationCollection.h"
-
-#pragma once
-
-using namespace OC;
-
-typedef std::function<
- OCEntityHandlerResult(std::shared_ptr< OCResourceRequest > request) > ResourceEntityHandler;
-
-class FactorySetResource : public ConfigurationResource
-{
-public:
- /// Constructor
- FactorySetResource();
-
- ~FactorySetResource();
-
- /// This function internally calls registerResource API.
- void createResources(ResourceEntityHandler callback);
- void setFactorySetRepresentation(OCRepresentation& rep);
- OCRepresentation getFactorySetRepresentation();
-
- std::string getUri();
-};
-
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-///
-/// This sample shows how one could create a resource (collection) with children.
-///
-
-#include <functional>
-#include <thread>
-#include <string.h>
-
-#include "OCPlatform.h"
-#include "OCApi.h"
-#include "MaintenanceCollection.h"
-
-using namespace OC;
-using namespace std;
-
-/// This function internally calls registerResource API.
-void MaintenanceResource::createResources(ResourceEntityHandler callback)
-{
- using namespace OC::OCPlatform;
-
- if (callback == NULL)
- {
- std::cout << "callback should be binded\t";
- return;
- }
-
- // This will internally create and register the resource.
- OCStackResult result = registerResource(m_maintenanceHandle, m_maintenanceUri,
- m_maintenanceTypes[0], m_maintenanceInterfaces[0], callback,
- OC_DISCOVERABLE | OC_OBSERVABLE);
-
- if (OC_STACK_OK != result)
- {
- std::cout << "Resource creation (maintenance) was unsuccessful\n";
- }
-
- thread exec(
- std::function< void(int second) >(
- std::bind(&MaintenanceResource::maintenanceMonitor, this,
- std::placeholders::_1)), 10); // every 10 seconds
- exec.detach();
-
- std::cout << "maintenance Resource is Created!\n";
-}
-
-void MaintenanceResource::setMaintenanceRepresentation(OCRepresentation& rep)
-{
- string value;
-
- if (rep.getValue("fr", value))
- {
- m_factoryReset = value;
- std::cout << "\t\t\t\t" << "m_factoryReset: " << m_factoryReset << std::endl;
- }
-
- if (rep.getValue("rb", value))
- {
- m_reboot = value;
- std::cout << "\t\t\t\t" << "m_reboot: " << m_reboot << std::endl;
- }
-
- if (rep.getValue("ssc", value))
- {
- m_startStatCollection = value;
- std::cout << "\t\t\t\t" << "m_startStatCollection: " << m_startStatCollection << std::endl;
- }
-}
-
-OCRepresentation MaintenanceResource::getMaintenanceRepresentation()
-{
- m_maintenanceRep.setValue("fr", m_factoryReset);
- m_maintenanceRep.setValue("rb", m_reboot);
- m_maintenanceRep.setValue("ssc", m_startStatCollection);
-
- return m_maintenanceRep;
-}
-
-std::string MaintenanceResource::getUri()
-{
- return m_maintenanceUri;
-}
-
-void MaintenanceResource::maintenanceMonitor(int second)
-{
- while (1)
- {
- sleep(second);
-
- if (m_reboot == "true")
- {
- int res;
- std::cout << "Reboot will be soon..." << std::endl;
- m_reboot = defaultReboot;
- res = system("/usr/bin/sudo /etc/init.d/reboot"); // System reboot for linux
-
- std::cout << "return: " << res << std::endl;
-
- }
- else if (m_factoryReset == "true")
- {
- std::cout << "Factory Reset will be soon..." << std::endl;
- m_factoryReset = defaultFactoryReset;
- factoryReset();
- }
- }
-}
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-///
-/// This sample shows how one could create a resource (collection) with children.
-///
-
-#include <functional>
-#include <thread>
-
-#include "OCPlatform.h"
-#include "OCApi.h"
-
-#pragma once
-
-using namespace OC;
-
-typedef std::function<
- OCEntityHandlerResult(std::shared_ptr< OCResourceRequest > request) > ResourceEntityHandler;
-
-static std::string defaultMntURI = "/oic/mnt";
-static std::string defaultMntResourceType = "oic.wk.mnt";
-
-static std::string defaultFactoryReset = "false";
-static std::string defaultReboot = "false";
-static std::string defaultStartStatCollection = "false";
-
-class MaintenanceResource
-{
-public:
-
- // Maintenance members
- std::string m_maintenanceUri;
- std::string m_factoryReset;
- std::string m_reboot;
- std::string m_startStatCollection;
- std::vector< std::string > m_maintenanceTypes;
- std::vector< std::string > m_maintenanceInterfaces;
- OCResourceHandle m_maintenanceHandle;
- OCRepresentation m_maintenanceRep;
-
-public:
- /// Constructor
- MaintenanceResource() :
- m_factoryReset(defaultFactoryReset), m_reboot(defaultReboot),
- m_startStatCollection(defaultStartStatCollection)
- {
- m_maintenanceUri = defaultMntURI; // URI of the resource
- m_maintenanceTypes.push_back(defaultMntResourceType); // resource type name.
- m_maintenanceInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
- m_maintenanceRep.setValue("fr", m_factoryReset);
- m_maintenanceRep.setValue("rb", m_reboot);
- m_maintenanceRep.setValue("ssc", m_startStatCollection);
- m_maintenanceRep.setUri(m_maintenanceUri);
- m_maintenanceRep.setResourceTypes(m_maintenanceTypes);
- m_maintenanceRep.setResourceInterfaces(m_maintenanceInterfaces);
- m_maintenanceHandle = NULL;
- }
- ;
-
- /// This function internally calls registerResource API.
- void createResources(ResourceEntityHandler callback);
-
- void setMaintenanceRepresentation(OCRepresentation& rep);
-
- OCRepresentation getMaintenanceRepresentation();
-
- std::string getUri();
-
- void maintenanceMonitor(int second);
-
- std::function< void() > factoryReset;
-};
-
+++ /dev/null
-#******************************************************************
-#
-# Copyright 2014 Samsung Electronics All Rights Reserved.
-#
-#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-##
-# linux sample app build script
-##
-
-Import('env')
-
-# Add third party libraries
-lib_env = env.Clone()
-SConscript('#service/third_party_libs.scons', 'lib_env')
-linux_sample_env = lib_env.Clone()
-rd_mode = env.get('RD_MODE')
-
-######################################################################
-# Build flags
-######################################################################
-linux_sample_env.AppendUnique(CPPPATH = ['include'])
-linux_sample_env.AppendUnique(CPPPATH = ['../../../../../extlibs/timer'])
-linux_sample_env.AppendUnique(CPPPATH = ['../../../sdk/inc'])
-linux_sample_env.AppendUnique(CPPPATH = ['../../../sdk/src'])
-linux_sample_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
-linux_sample_env.AppendUnique(CPPDEFINES = ['LINUX'])
-linux_sample_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-linux_sample_env.PrependUnique(LIBS = ['coap'])
-linux_sample_env.AppendUnique(LIBS = ['connectivity_abstraction'])
-linux_sample_env.AppendUnique(LIBS = ['oc_logger'])
-linux_sample_env.AppendUnique(LIBS = ['octbstack'])
-linux_sample_env.AppendUnique(LIBS = ['oc'])
-linux_sample_env.AppendUnique(LIBS = ['libTGMSDKLibrary'])
-linux_sample_env.AppendUnique(LIBS = ['dl'])
-linux_sample_env.AppendUnique(LIBS = ['pthread'])
-
-if env.get('SECURED') == '1':
- linux_sample_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509', 'mbedcrypto'])
-
-# On some platforms link order can miss functions so librt needs to be
-# re-scanned at the end if present. gcc 4.6 is one with this issue.
-if 'rt' in linux_sample_env.get('LIBS'):
- linux_sample_env.Append(LIBS = ['rt'])
-
-if 'CLIENT' in rd_mode or 'SERVER' in rd_mode:
- linux_sample_env.AppendUnique(LIBS = ['resource_directory'])
-######################################################################
-#build sampleapp
-######################################################################
-conserver = linux_sample_env.Program('con-server', ['ConfigurationCollection.cpp', 'MaintenanceCollection.cpp', 'FactorySetCollection.cpp', 'con-server.cpp'])
-conclient = linux_sample_env.Program('con-client', 'con-client.cpp')
-bootstrapserver = linux_sample_env.Program('bootstrapserver', 'bootstrapserver.cpp')
-Alias("ConServerApp", conserver)
-Alias("ConClientApp", conclient)
-Alias("BootstrapServerApp", bootstrapserver)
-env.AppendTarget('ConServerApp')
-env.AppendTarget('ConClientApp')
-env.AppendTarget('BootstrapServerApp')
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-///
-/// This sample shows how one could create a resource (collection) with children.
-///
-
-#include <functional>
-
-#include <pthread.h>
-
-#include "OCPlatform.h"
-#include "OCApi.h"
-
-using namespace OC;
-using namespace std;
-
-// Forward declaring the entityHandler (bootstrap)
-bool prepareResponse(std::shared_ptr< OCResourceRequest > request);
-OCStackResult sendResponse(std::shared_ptr< OCResourceRequest > pRequest);
-OCEntityHandlerResult entityHandlerBootstrap(std::shared_ptr< OCResourceRequest > request);
-
-#define DefaultDeviceName "Legacy Device"
-#define DefaultLocation "37.256616, 127.052806"
-#define DefaultLocationName "Living Room"
-#define DefaultCurrency "Won"
-#define DefaultRegion "Seoul, Korea"
-
-class BootstrapResource
-{
-public:
- // Room members
- std::string m_bootstrapUri;
- std::vector< std::string > m_bootstrapTypes;
- std::vector< std::string > m_bootstrapInterfaces;
- OCResourceHandle m_bootstrapHandle;
- OCRepresentation m_bootstrapRep;
-
-public:
- /// Constructor
- BootstrapResource()
- {
- m_bootstrapUri = "/bootstrap"; // URI of the resource
- m_bootstrapTypes.push_back("bootstrap"); // resource type name. In this case, it is light
- m_bootstrapInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
- m_bootstrapRep.setUri(m_bootstrapUri);
- m_bootstrapRep.setResourceTypes(m_bootstrapTypes);
- m_bootstrapRep.setResourceInterfaces(m_bootstrapInterfaces);
- m_bootstrapHandle = NULL;
- }
-
- /// This function internally calls registerResource API.
- void createResources()
- {
- using namespace OC::OCPlatform;
- // This will internally create and register the resource.
- OCStackResult result = registerResource(m_bootstrapHandle, m_bootstrapUri,
- m_bootstrapTypes[0], m_bootstrapInterfaces[0], entityHandlerBootstrap,
- OC_DISCOVERABLE | OC_OBSERVABLE);
-
- if (OC_STACK_OK != result)
- {
- cout << "Resource creation (room) was unsuccessful\n";
- }
- }
-
- void setBootstrapRepresentation(OCRepresentation& /*rep*/)
- {
- // Not allowed
- }
-
- OCRepresentation getBootstrapRepresentation()
- {
- m_bootstrapRep.setValue< std::string >("n", DefaultDeviceName);
- m_bootstrapRep.setValue< std::string >("loc", DefaultLocation);
- m_bootstrapRep.setValue< std::string >("locn", DefaultLocationName);
- m_bootstrapRep.setValue< std::string >("c", DefaultCurrency);
- m_bootstrapRep.setValue< std::string >("r", DefaultRegion);
-
- return m_bootstrapRep;
- }
-};
-
-// Create the instance of the resource class (in this case instance of class 'RoomResource').
-BootstrapResource myBootstrapResource;
-
-// This function prepares a response for any incoming request to Light resource.
-bool prepareResponse(std::shared_ptr< OCResourceRequest > request)
-{
- cout << "\tIn Server CPP prepareResponse:\n";
- bool result = false;
- if (request)
- {
- // Get the request type and request flag
- std::string requestType = request->getRequestType();
- int requestFlag = request->getRequestHandlerFlag();
-
- if (requestFlag == RequestHandlerFlag::RequestFlag)
- {
- cout << "\t\trequestFlag : Request\n";
-
- // If the request type is GET
- if (requestType == "GET")
- {
- cout << "\t\t\trequestType : GET\n";
- // GET operations are directly handled while sending the response
- // in the sendLightResponse function
- result = true;
- }
- else if (requestType == "PUT")
- {
- cout << "\t\t\trequestType : PUT\n";
-
- OCRepresentation rep = request->getResourceRepresentation();
-
- // Do related operations related to PUT request
- myBootstrapResource.setBootstrapRepresentation(rep);
- result = true;
- }
- else if (requestType == "POST")
- {
- // POST request operations
- }
- else if (requestType == "DELETE")
- {
- // DELETE request operations
- }
- }
- else if (requestFlag == RequestHandlerFlag::ObserverFlag)
- {
- cout << "\t\trequestFlag : Observer\n";
- }
- }
- else
- {
- std::cout << "Request invalid" << std::endl;
- }
-
- return result;
-}
-
-OCStackResult sendResponse(std::shared_ptr< OCResourceRequest > pRequest)
-{
- auto pResponse = std::make_shared< OC::OCResourceResponse >();
- pResponse->setRequestHandle(pRequest->getRequestHandle());
- pResponse->setResourceHandle(pRequest->getResourceHandle());
- pResponse->setResourceRepresentation(myBootstrapResource.getBootstrapRepresentation());
- pResponse->setResponseResult(OC_EH_OK);
-
- return OCPlatform::sendResponse(pResponse);
-}
-
-OCEntityHandlerResult entityHandlerBootstrap(std::shared_ptr< OCResourceRequest > request)
-{
- cout << "\tIn Server CPP (entityHandlerBootstrap) entity handler:\n";
- OCEntityHandlerResult ehResult = OC_EH_ERROR;
-
- if (prepareResponse(request))
- {
- if (OC_STACK_OK == sendResponse(request))
- {
- ehResult = OC_EH_OK;
- }
- else
- {
- std::cout << "sendResponse failed." << std::endl;
- }
- }
- else
- {
- std::cout << "PrepareResponse failed." << std::endl;
- }
- return ehResult;
-}
-
-int main()
-{
- // Create PlatformConfig object
- PlatformConfig cfg
- { OC::ServiceType::InProc, OC::ModeType::Server, "0.0.0.0",
- // By setting to "0.0.0.0", it binds to all available interfaces
- 0,// Uses randomly available port
- OC::QualityOfService::LowQos };
-
- OCPlatform::Configure(cfg);
- try
- {
-
- myBootstrapResource.createResources();
-
- // Perform app tasks
- while (true)
- {
- // some tasks
- }
- }
- catch (OCException e)
- {
- std::cout << "Exception in main: " << e.what();
- }
-
- // No explicit call to stop the platform.
- // When OCPlatform destructor is invoked, internally we do platform cleanup
-}
-
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-// OCClient.cpp : Defines the entry point for the console application.
-//
-#include <string>
-#include <cstdlib>
-#include <pthread.h>
-#include <map>
-#include <vector>
-#include "OCPlatform.h"
-#include "OCApi.h"
-#include "ThingsConfiguration.h"
-#include "ThingsMaintenance.h"
-#include "GroupManager.h"
-
-using namespace OC;
-using namespace OIC;
-
-int g_Steps = 0;
-int isWaiting = 0; //0: none to wait, 1: wait for the response of "getConfigurationValue"
-pthread_mutex_t mutex_lock = PTHREAD_MUTEX_INITIALIZER;
-
-const int SUCCESS_RESPONSE = 0;
-
-static GroupManager* g_groupmanager;
-static ThingsConfiguration* g_thingsConf;
-static ThingsMaintenance* g_thingsMnt;
-
-OCResourceHandle configurationCollectionHandle;
-std::shared_ptr< OCResource > g_configurationCollection; // for a group of multiple resources
-std::shared_ptr< OCResource > g_configurationResource; // For a single resource
-
-OCResourceHandle maintenanceCollectionHandle;
-std::shared_ptr< OCResource > g_maintenanceCollection; // for a group of multiple resources
-std::shared_ptr< OCResource > g_maintenanceResource; // For a single resource
-
-OCResourceHandle setCollectionHandle;
-std::shared_ptr< OCResource > g_setCollection; // for a group of multiple resources
-std::shared_ptr< OCResource > g_setResource; // For a single resource
-
-std::map< std::string, std::shared_ptr< OCResource > > resourceTable;
-std::vector< OCResourceHandle > resourceHandleVector;
-
-typedef std::string ConfigurationName;
-typedef std::string ConfigurationValue;
-
-void timeCheck(int timeSec)
-{
- sleep(timeSec);
- pthread_mutex_lock(&mutex_lock);
- isWaiting = 0;
- pthread_mutex_unlock(&mutex_lock);
-}
-
-void onReboot(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode)
-{
- pthread_mutex_lock(&mutex_lock);
- isWaiting = 0;
- pthread_mutex_unlock(&mutex_lock);
-
- if (eCode != SUCCESS_RESPONSE)
- {
- return ;
- }
-
- std::cout << "\tResource URI: " << rep.getUri() << std::endl;
- std::cout << "\t\tReboot:" << rep.getValue< std::string >("value") << std::endl;
-}
-
-void onFactoryReset(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode)
-{
- pthread_mutex_lock(&mutex_lock);
- isWaiting = 0;
- pthread_mutex_unlock(&mutex_lock);
-
- if (eCode != SUCCESS_RESPONSE)
- {
- return ;
- }
-
- std::cout << "\tResource URI: " << rep.getUri() << std::endl;
- std::cout << "\t\tFactoryReset:" << rep.getValue< std::string >("value") << std::endl;
-}
-
-void onUpdate(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode)
-{
- pthread_mutex_lock(&mutex_lock);
- isWaiting = 0;
- pthread_mutex_unlock(&mutex_lock);
-
- if (eCode != SUCCESS_RESPONSE)
- {
- return ;
- }
-
- std::cout << "\tResource URI: " << rep.getUri() << std::endl;
-
- if (rep.hasAttribute("n"))
- {
- std::cout << "\t\tDeviceName:" << rep.getValue< std::string >("n") << std::endl;
- }
- if (rep.hasAttribute("loc"))
- {
- std::cout << "\t\tLocation:" << rep.getValue< std::string >("loc") << std::endl;
- }
- if (rep.hasAttribute("locn"))
- {
- std::cout << "\t\tLocationName:" << rep.getValue< std::string >("locn") << std::endl;
- }
- if (rep.hasAttribute("c"))
- {
- std::cout << "\t\tCurrency:" << rep.getValue< std::string >("c") << std::endl;
- }
- if (rep.hasAttribute("r"))
- {
- std::cout << "\t\tRegion:" << rep.getValue< std::string >("r") << std::endl;
- }
-}
-
-void onGet(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode)
-{
- pthread_mutex_lock(&mutex_lock);
- isWaiting = 0;
- pthread_mutex_unlock(&mutex_lock);
-
- if (eCode != SUCCESS_RESPONSE)
- {
- return ;
- }
-
- std::cout << "\tResource URI: " << rep.getUri() << std::endl;
-
- if (rep.hasAttribute("n"))
- {
- std::cout << "\t\tDeviceName:" << rep.getValue< std::string >("n") << std::endl;
- }
- if (rep.hasAttribute("loc"))
- {
- std::cout << "\t\tLocation:" << rep.getValue< std::string >("loc") << std::endl;
- }
- if (rep.hasAttribute("locn"))
- {
- std::cout << "\t\tLocationName:" << rep.getValue< std::string >("locn") << std::endl;
- }
- if (rep.hasAttribute("c"))
- {
- std::cout << "\t\tCurrency:" << rep.getValue< std::string >("c") << std::endl;
- }
- if (rep.hasAttribute("r"))
- {
- std::cout << "\t\tRegion:" << rep.getValue< std::string >("r") << std::endl;
- }
-}
-
-// Callback to found collection resource
-void onFoundCollectionResource(std::vector< std::shared_ptr< OCResource > > resources)
-{
- std::string resourceURI;
- std::string hostAddress;
- try
- {
- // Do some operations with resource object.
- for (unsigned int i = 0; i < resources.size(); ++i)
- {
- std::shared_ptr< OCResource > resource = resources.at(i);
-
- if (resource)
- {
- if (resource->uri() == "/core/a/configuration/resourceset")
- {
- g_configurationCollection = resource;
- }
- else if (resource->uri() == "/core/a/maintenance/resourceset")
- {
- g_maintenanceCollection = resource;
- }
- else if (resource->uri() == "/core/a/factoryset/resourceset")
- {
- g_setCollection = resource;
- }
- else
- {
- pthread_mutex_lock(&mutex_lock);
- isWaiting = 0;
- pthread_mutex_unlock(&mutex_lock);
- return;
- }
- }
- else
- {
- // Resource is invalid
- std::cout << "Resource is invalid" << std::endl;
- }
- }
-
- }
- catch (std::exception& e)
- {
- std::cout << "Exception: " << e.what() << std::endl;
- }
-
- pthread_mutex_lock(&mutex_lock);
- isWaiting = 0;
- pthread_mutex_unlock(&mutex_lock);
-}
-
-// Callback to found resources
-void onFoundCandidateResource(std::vector< std::shared_ptr< OCResource > > resources)
-{
- std::string resourceURI;
- std::string hostAddress;
-
- try
- {
- // Do some operations with resource object.
- for (unsigned int i = 0; i < resources.size(); ++i)
- {
- std::shared_ptr< OCResource > resource = resources.at(i);
-
- if (resource)
- {
- // Check if the resource is new one. If so, store it.
-
- std::map< std::string, std::shared_ptr< OCResource > >::iterator iter =
- resourceTable.find(resource->host() + resource->uri());
-
- if (iter == resourceTable.end()) // new one
- {
- resourceTable[resource->host() + resource->uri()] = resource;
-
- OCResourceHandle foundResourceHandle = NULL;
- OCStackResult result = OCPlatform::registerResource(foundResourceHandle,
- resource);
- std::cout << "\tResource ( " << resource->host() << " ) is registed!\t"
- << std::endl;
- if (result == OC_STACK_OK)
- {
- if (resource->uri() == "/oic/con")
- {
- OCPlatform::bindResource(configurationCollectionHandle,
- foundResourceHandle);
- if (g_configurationResource == NULL)
- {
- g_configurationResource = resource;
- }
- }
- else if (resource->uri() == "/oic/mnt")
- {
- OCPlatform::bindResource(maintenanceCollectionHandle,
- foundResourceHandle);
- if (g_maintenanceResource == NULL)
- {
- g_maintenanceResource = resource;
- }
- }
- else if (resource->uri() == "/factoryset")
- {
- OCPlatform::bindResource(setCollectionHandle, foundResourceHandle);
- if (g_setResource == NULL)
- {
- g_setResource = resource;
- }
- }
-
- resourceHandleVector.push_back(foundResourceHandle);
- }
- else
- {
- cout << "\tresource Error!" << endl;
- }
-
- }
-
- }
- else
- {
- // Resource is invalid
- std::cout << "Resource is invalid" << std::endl;
- }
- }
-
- }
- catch (std::exception& e)
- {
- std::cout << "Exception: " << e.what() << std::endl;
- }
-
- pthread_mutex_lock(&mutex_lock);
- isWaiting = 0;
- pthread_mutex_unlock(&mutex_lock);
-}
-
-int main()
-{
- std::string str_steps;
-
- try
- {
- //**************************************************************
- // STEP 0
- PlatformConfig cfg
- { OC::ServiceType::InProc, OC::ModeType::Both, "0.0.0.0", 0, OC::QualityOfService::LowQos };
-
- OCPlatform::Configure(cfg);
- //g_thingsmanager = new ThingsManager();
- g_thingsConf = new ThingsConfiguration();
- g_thingsMnt = new ThingsMaintenance();
- g_groupmanager = new GroupManager();
-
- //**************************************************************
-
- while (true)
- {
- pthread_mutex_lock(&mutex_lock);
- if (isWaiting > 0)
- {
- pthread_mutex_unlock(&mutex_lock);
- continue;
- }
-
- isWaiting = 0;
- pthread_mutex_unlock(&mutex_lock);
-
- cout << endl << endl << "(0) Quit" << std::endl;
- cout << "(1) Find all resources(URI: /oic/con, /oic/mnt, /factoryset)" << std::endl;
- cout << "(2) Find all groups" << std::endl;
- cout << "(3) Get a Configuration resource" << std::endl;
- cout << "(4) Update a device name attribute value" << std::endl;
- cout << "(5) FactoryReset (for the group)" << std::endl;
- cout << "(6) Reboot (for the group)" << std::endl;
- cout << "(10) Show Configuration Units" << std::endl;
-
- try
- {
- std::getline (std::cin, str_steps);
-
- if(str_steps == "")
- {
- continue;
- }
- else
- {
- g_Steps = std::stoi(str_steps);
- }
- }
- catch(std::invalid_argument&)
- {
- std::cout << "Please put a digit, not string" << std::endl;
- continue;
- }
- catch(std::out_of_range&)
- {
- std::cout << "Please put a number within the supported range" << std::endl;
- continue;
- }
-
- if (g_Steps == 0)
- {
- break;
- }
- else if (g_Steps == 1)
- {
- std::vector< std::string > types;
-
- // For Registering a collection resource for configuration resources
- if (configurationCollectionHandle == NULL)
- {
- string resourceURI = "/core/a/configuration/resourceset";
- string resourceTypeName = "core.configuration.resourceset";
- string resourceInterface = BATCH_INTERFACE;
-
- OCPlatform::registerResource(configurationCollectionHandle, resourceURI,
- resourceTypeName, resourceInterface, NULL,
- //&entityHandler, // entityHandler
- OC_DISCOVERABLE);
-
- OCPlatform::bindInterfaceToResource(configurationCollectionHandle, GROUP_INTERFACE);
- OCPlatform::bindInterfaceToResource(configurationCollectionHandle,
- DEFAULT_INTERFACE);
- }
-
- // For Registering a collection resource for maintenance resources
- if (maintenanceCollectionHandle == NULL)
- {
- string resourceURI = "/core/a/maintenance/resourceset";
- string resourceTypeName = "core.maintenance.resourceset";
- string resourceInterface = BATCH_INTERFACE;
-
- OCPlatform::registerResource(maintenanceCollectionHandle, resourceURI,
- resourceTypeName, resourceInterface, NULL,
- //&entityHandler, // entityHandler
- OC_DISCOVERABLE);
-
- OCPlatform::bindInterfaceToResource(maintenanceCollectionHandle, GROUP_INTERFACE);
- OCPlatform::bindInterfaceToResource(maintenanceCollectionHandle, DEFAULT_INTERFACE);
- }
-
- // For Registering a collection resource for set resources
- if (setCollectionHandle == NULL)
- {
- string resourceURI = "/core/a/factoryset/resourceset";
- string resourceTypeName = "core.factoryset.resourceset";
- string resourceInterface = BATCH_INTERFACE;
-
- OCPlatform::registerResource(setCollectionHandle, resourceURI, resourceTypeName,
- resourceInterface, NULL,
- //&entityHandler, // entityHandler
- OC_DISCOVERABLE);
-
- OCPlatform::bindInterfaceToResource(setCollectionHandle, GROUP_INTERFACE);
- OCPlatform::bindInterfaceToResource(setCollectionHandle, DEFAULT_INTERFACE);
- }
-
- types.push_back("oic.wk.con");
- types.push_back("oic.wk.mnt");
- types.push_back("factoryset");
-
- std::cout << "Finding Configuration Resource... " << std::endl;
- std::cout << "Finding Maintenance Resource... " << std::endl;
- std::cout << "Finding Set Resource... " << std::endl;
-
- g_groupmanager->findCandidateResources(types, &onFoundCandidateResource, 5);
-
- pthread_mutex_lock(&mutex_lock);
- isWaiting = 1;
- pthread_mutex_unlock(&mutex_lock);
-
- thread t(&timeCheck, 5);
- t.join(); // After 5 seconds, isWaiting value will be 0.
- }
- else if (g_Steps == 2) // make a group with found things
- {
- std::vector< std::string > types;
- types.push_back("core.configuration.resourceset");
- types.push_back("core.maintenance.resourceset");
- types.push_back("core.factoryset.resourceset");
-
- g_groupmanager->findCandidateResources(types, &onFoundCollectionResource, 5);
-
- std::cout << "Finding Collection resource... " << std::endl;
-
- pthread_mutex_lock(&mutex_lock);
- isWaiting = 1;
- pthread_mutex_unlock(&mutex_lock);
-
- thread t(&timeCheck, 5);
- t.join(); // After 5 seconds, isWaiting value will be 0.
- }
- else if (g_Steps == 3)
- {
- // get a value
-
- ConfigurationName name = "all";
-
- std::cout << "For example, get configuration resources's value" << std::endl;
-
- std::vector< ConfigurationName > configurations;
-
- configurations.push_back(name);
-
- if (g_thingsConf->getConfigurations(g_configurationCollection, configurations, &onGet)
- != OC_STACK_ERROR)
- {
- pthread_mutex_lock(&mutex_lock);
- isWaiting = 0;
- pthread_mutex_unlock(&mutex_lock);
- }
- }
- else if (g_Steps == 4)
- {
- ConfigurationName name = "n";
- ConfigurationValue value = "OIC Device";
-
- if(g_configurationCollection == NULL)
- {
- std::cout<<"Note that you first create a group to use this command." << std::endl;
- continue;
- }
-
- std::cout << "For example, change a device name" << std::endl;
- std::cout << g_configurationCollection->uri() << std::endl;
-
- std::map< ConfigurationName, ConfigurationValue > configurations;
-
- configurations.insert(std::make_pair(name, value));
-
- if (g_thingsConf->updateConfigurations(g_configurationCollection, configurations,
- &onUpdate) != OC_STACK_ERROR)
- {
- pthread_mutex_lock(&mutex_lock);
- isWaiting = 0;
- pthread_mutex_unlock(&mutex_lock);
- }
- }
- else if (g_Steps == 5)
- {
- // factory reset
- if(g_maintenanceCollection == NULL)
- {
- std::cout<<"Note that you first create a group to use this command." << std::endl;
- continue;
- }
-
- if (g_thingsMnt->factoryReset(g_maintenanceCollection, &onFactoryReset)
- != OC_STACK_ERROR)
- {
- pthread_mutex_lock(&mutex_lock);
- isWaiting = 0;
- pthread_mutex_unlock(&mutex_lock);
- }
- }
- else if (g_Steps == 6)
- {
- // reboot
- if(g_maintenanceCollection == NULL)
- {
- std::cout<<"Note that you first create a group to use this command." << std::endl;
- continue;
- }
-
- try
- {
- if (g_thingsMnt->reboot(g_maintenanceCollection, &onReboot) != OC_STACK_ERROR)
- {
- pthread_mutex_lock(&mutex_lock);
- isWaiting = 0;
- pthread_mutex_unlock(&mutex_lock);
- }
- }
- catch(...)
- {
- std::cout<<"Reboot fail." << std::endl;
- }
- }
- else if (g_Steps == 10)
- {
- std::cout << g_thingsConf->getListOfSupportedConfigurationUnits() << std::endl;
-
- }
- }
- }
- catch (OCException e)
- {
- std::cout << "Exception in main: " << e.what();
- }
-
- return 0;
-}
-
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-///
-/// This sample shows how one could create a resource (collection) with children.
-///
-
-#include <functional>
-#include <pthread.h>
-
-#include "OCPlatform.h"
-#include "OCApi.h"
-#include "ThingsConfiguration.h"
-#include "ThingsMaintenance.h"
-#include "ConfigurationCollection.h"
-#include "MaintenanceCollection.h"
-#include "FactorySetCollection.h"
-
-using namespace OC;
-using namespace OIC;
-
-const int SUCCESS_RESPONSE = 0;
-int g_Steps = 0;
-int isWaiting = 0;
-pthread_mutex_t mutex_lock = PTHREAD_MUTEX_INITIALIZER;
-
-// Default system configuration value's variables
-// The variable's names should be same as the names of "extern" variables defined in
-// "ConfigurationResource.h"
-
-std::string defaultDeviceName;
-std::string defaultLocation;
-std::string defaultLocationName;
-std::string defaultRegion;
-std::string defaultCurrency;
-
-static ThingsConfiguration* g_thingsConf;
-
-// Forward declaring the entityHandler (Configuration)
-bool prepareResponseForResource(std::shared_ptr< OCResourceRequest > request);
-OCStackResult sendResponseForResource(std::shared_ptr< OCResourceRequest > pRequest);
-OCEntityHandlerResult entityHandlerForResource(std::shared_ptr< OCResourceRequest > request);
-
-ConfigurationResource *myConfigurationResource;
-MaintenanceResource *myMaintenanceResource;
-FactorySetResource *myFactorySetResource;
-
-typedef std::function< void(OCRepresentation&) > putFunc;
-typedef std::function< OCRepresentation(void) > getFunc;
-
-getFunc getGetFunction(std::string uri)
-{
- getFunc res = NULL;
-
- if (uri == myConfigurationResource->getUri())
- {
- res = std::bind(&ConfigurationResource::getConfigurationRepresentation,
- myConfigurationResource);
- }
- else if (uri == myMaintenanceResource->getUri())
- {
- res = std::bind(&MaintenanceResource::getMaintenanceRepresentation,
- myMaintenanceResource);
- }
-
- return res;
-}
-
-putFunc getPutFunction(std::string uri)
-{
- putFunc res = NULL;
-
- if (uri == myConfigurationResource->getUri())
- {
- res = std::bind(&ConfigurationResource::setConfigurationRepresentation,
- myConfigurationResource, std::placeholders::_1);
- }
- else if (uri == myMaintenanceResource->getUri())
- {
- res = std::bind(&MaintenanceResource::setMaintenanceRepresentation,
- myMaintenanceResource, std::placeholders::_1);
- }
-
- return res;
-}
-
-// This function prepares a response for any incoming request to Light resource.
-bool prepareResponseForResource(std::shared_ptr< OCResourceRequest > request)
-{
- std::cout << "\tIn Server CPP prepareResponseForResource:\n";
- bool result = false;
- if (request)
- {
- // Get the request type and request flag
- std::string requestType = request->getRequestType();
- int requestFlag = request->getRequestHandlerFlag();
-
- if (requestFlag == RequestHandlerFlag::RequestFlag)
- {
- std::cout << "\t\trequestFlag : Request\n";
-
- // If the request type is GET
- if (requestType == "GET")
- {
- std::cout << "\t\t\trequestType : GET\n";
- // GET operations are directly handled while sending the response
- // in the sendLightResponse function
- result = true;
- }
- else if (requestType == "PUT")
- {
- std::cout << "\t\t\trequestType : PUT\n";
- putFunc putFunction;
- OCRepresentation rep = request->getResourceRepresentation();
-
- putFunction = getPutFunction(request->getResourceUri());
-
- // Do related operations related to PUT request
- putFunction(rep);
- result = true;
- }
- else if (requestType == "POST")
- {
- // POST request operations
- }
- else if (requestType == "DELETE")
- {
- // DELETE request operations
- }
- }
- else if (requestFlag == RequestHandlerFlag::ObserverFlag)
- {
- std::cout << "\t\trequestFlag : Observer\n";
- }
- }
- else
- {
- std::cout << "Request invalid" << std::endl;
- }
-
- return result;
-}
-
-OCStackResult sendResponseForResource(std::shared_ptr< OCResourceRequest > pRequest)
-{
- auto pResponse = std::make_shared< OC::OCResourceResponse >();
-
- // Check for query params (if any)
- QueryParamsMap queryParamsMap = pRequest->getQueryParameters();
-
- pResponse->setRequestHandle(pRequest->getRequestHandle());
- pResponse->setResourceHandle(pRequest->getResourceHandle());
-
- getFunc getFunction;
- getFunction = getGetFunction(pRequest->getResourceUri());
-
- OCRepresentation rep;
- rep = getFunction();
-
- auto findRes = queryParamsMap.find("if");
-
- if (findRes != queryParamsMap.end())
- {
- pResponse->setResourceRepresentation(rep, findRes->second);
- }
- else
- {
- pResponse->setResourceRepresentation(rep, DEFAULT_INTERFACE);
- }
-
- pResponse->setResponseResult(OC_EH_OK);
-
- return OCPlatform::sendResponse(pResponse);
-}
-
-OCEntityHandlerResult entityHandlerForResource(std::shared_ptr< OCResourceRequest > request)
-{
- std::cout << "\tIn Server CPP (entityHandlerForResource) entity handler:\n";
- OCEntityHandlerResult ehResult = OC_EH_ERROR;
-
- QueryParamsMap test = request->getQueryParameters();
-
- if (prepareResponseForResource(request))
- {
- if (OC_STACK_OK == sendResponseForResource(request))
- {
- ehResult = OC_EH_OK;
- }
- else
- {
- std::cout << "sendResponse failed." << std::endl;
- }
- }
- else
- {
- std::cout << "PrepareResponse failed." << std::endl;
- }
- return ehResult;
-}
-
-// callback handler on GET request
-void onBootstrap(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode)
-{
- pthread_mutex_lock(&mutex_lock);
- isWaiting = 0;
- pthread_mutex_unlock(&mutex_lock);
-
- if (eCode != SUCCESS_RESPONSE)
- {
- std::cout << "onGET Response error: " << eCode << std::endl;
- return ;
- }
-
- std::cout << "\n\nGET request was successful" << std::endl;
- std::cout << "\tResource URI: " << rep.getUri() << std::endl;
-
- defaultDeviceName = rep.getValue< std::string >("n");
- defaultLocation = rep.getValue< std::string >("loc");
- defaultLocationName = rep.getValue< std::string >("locn");
- defaultRegion = rep.getValue< std::string >("r");
- defaultCurrency = rep.getValue< std::string >("c");
-
- std::cout << "\tDeviceName : " << defaultDeviceName << std::endl;
- std::cout << "\tLocation : " << defaultLocation << std::endl;
- std::cout << "\tLocationName : " << defaultLocationName << std::endl;
- std::cout << "\tCurrency : " << defaultCurrency << std::endl;
- std::cout << "\tRegion : " << defaultRegion << std::endl;
-
-}
-
-int main()
-{
- //**************************************************************
- // STEP 0
- // Create PlatformConfig object
- PlatformConfig cfg
- { OC::ServiceType::InProc, OC::ModeType::Both, "0.0.0.0", 0, OC::QualityOfService::LowQos };
-
- OCPlatform::Configure(cfg);
- g_thingsConf = new ThingsConfiguration();
- //**************************************************************
-
- if (getuid() != 0)
- {
- std::cout << "NOTE: You may gain the root privilege (e.g, reboot)\n";
- std::cout << "NOTE: Now, you don't have it.\n";
- }
-
- try
- {
- // Perform app tasks
- while (true)
- {
- pthread_mutex_lock(&mutex_lock);
- if (isWaiting > 0)
- {
- pthread_mutex_unlock(&mutex_lock);
- continue;
- }
-
- isWaiting = 0;
- pthread_mutex_unlock(&mutex_lock);
-
- std::cout << endl << endl << "(0) Quit" << std::endl;
- std::cout << "(1) Bootstrap" << std::endl;
- std::cout << "(2) Create Configuration/Maintenance Resources" << std::endl;
-
- cin >> g_Steps;
-
- if (g_Steps == 0)
- {
- break;
- }
- else if (g_Steps == 1)
- {
- try
- {
- if( g_thingsConf->doBootstrap(&onBootstrap) == OC_STACK_OK)
- {
- pthread_mutex_lock(&mutex_lock);
- isWaiting = 1;
- pthread_mutex_unlock(&mutex_lock);
- }
- else
- {
- std::cout << "A callback pointer of the function is NULL." << std::endl;
- }
- }
- catch(...)
- {
- std::cout << "doBootstrap fail." << std::endl;
- }
- }
- else if (g_Steps == 2)
- {
- myConfigurationResource = new ConfigurationResource();
- myConfigurationResource->createResources(&entityHandlerForResource);
-
- myMaintenanceResource = new MaintenanceResource();
- myMaintenanceResource->createResources(&entityHandlerForResource);
-
- myFactorySetResource = new FactorySetResource();
- myFactorySetResource->createResources(&entityHandlerForResource);
- myMaintenanceResource->factoryReset = std::function < void()
- > (std::bind(&ConfigurationResource::factoryReset,
- myConfigurationResource));
-
- pthread_mutex_lock(&mutex_lock);
- isWaiting = 1;
- pthread_mutex_unlock(&mutex_lock);
- }
- }
- }
- catch (OCException e)
- {
- std::cout << "Exception in main: " << e.what();
- }
-
- // No explicit call to stop the platform.
- // When OCPlatform destructor is invoked, internally we do platform cleanup
- return 0;
-}
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
- <storageModule moduleId="org.eclipse.cdt.core.settings">
- <cconfiguration id="org.tizen.nativecore.config.sbi.gcc45.app.debug.879388275">
- <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.tizen.nativecore.config.sbi.gcc45.app.debug.879388275" moduleId="org.eclipse.cdt.core.settings" name="Debug">
- <externalSettings/>
- <extensions>
- <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
- <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
- <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
- <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
- <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
- <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
- <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
- </extensions>
- </storageModule>
- <storageModule moduleId="cdtBuildSystem" version="4.0.0">
- <configuration artifactName="conserverapp" buildArtefactType="org.tizen.nativecore.buildArtefactType.app" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.app,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.app.debug.879388275" name="Debug" parent="org.tizen.nativecore.config.sbi.gcc45.app.debug">
- <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.app.debug.879388275." name="/" resourcePath="">
- <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug.1732789683" name="Tizen Native Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug">
- <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.784108973" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
- <builder arguments="--eval="SHELL=cmd" -r" autoBuildTarget="all" buildPath="${workspace_loc:/ConServerApp}/Debug" enableAutoBuild="true" id="org.tizen.nativecore.target.sbi.gnu.builder.991141288" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/>
- <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.498617409" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
- <tool command="arm-linux-gnueabi-g++.exe" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.847181660" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
- <option id="gnu.cpp.compiler.option.optimization.level.1877648524" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
- <option id="sbi.gnu.cpp.compiler.option.debugging.level.core.30268440" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
- <option id="sbi.gnu.cpp.compiler.option.39285929" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
- <listOptionValue builtIn="false" value="mobile-2.3-device.core_gcc46.armel.core.app"/>
- </option>
- <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.1365166625" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath">
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/>
- <listOptionValue builtIn="false" value=""${SDK_PATH}/library""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/>
- </option>
- <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.195721954" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.core" valueType="stringList">
- <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
- <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
- <listOptionValue builtIn="false" value=" -fPIE"/>
- <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
- <listOptionValue builtIn="false" value="-mthumb"/>
- </option>
- <option id="gnu.cpp.compiler.option.include.paths.2031608880" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
- <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
- <listOptionValue builtIn="false" value=""..\..\..\..\sdk\inc""/>
- <listOptionValue builtIn="false" value=""..\..\..\..\sdk\src""/>
- <listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\include""/>
- <listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\c_common""/>
- <listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\csdk\stack\include""/>
- <listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\csdk\logger\include""/>
- <listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\csdk\occoap\include""/>
- <listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\csdk\ocrandom\include""/>
- <listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\csdk\ocsocket\include""/>
- <listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\oc_logger\include""/>
- <listOptionValue builtIn="false" value=""..\..\..\..\..\..\extlibs\timer""/>
- </option>
- <option id="sbi.gnu.cpp.compiler.option.frameworks.core.2019722103" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs">
- <listOptionValue builtIn="false" value="Native_API"/>
- </option>
- <option id="gnu.cpp.compiler.option.preprocessor.def.1628062174" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
- <listOptionValue builtIn="false" value="_DEBUG"/>
- </option>
- <option id="sbi.gnu.cpp.compiler.option.misc.pic.core.1552197767" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" value="true" valueType="boolean"/>
- <option id="gnu.cpp.compiler.option.other.other.1077700307" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -std=gnu++0x" valueType="string"/>
- <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.546425854" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
- </tool>
- <tool command="arm-linux-gnueabi-gcc.exe" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.1904769633" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
- <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.1301963388" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
- <option id="sbi.gnu.c.compiler.option.debugging.level.core.1501054876" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" value="gnu.c.debugging.level.max" valueType="enumerated"/>
- <option id="sbi.gnu.c.compiler.option.5248569" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
- <listOptionValue builtIn="false" value="mobile-2.3-device.core_gcc46.armel.core.app"/>
- </option>
- <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.916623032" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath">
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/>
- <listOptionValue builtIn="false" value=""${SDK_PATH}/library""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/>
- </option>
- <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.1523138456" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.core" valueType="stringList">
- <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
- <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
- <listOptionValue builtIn="false" value=" -fPIE"/>
- <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
- <listOptionValue builtIn="false" value="-mthumb"/>
- </option>
- <option id="gnu.c.compiler.option.include.paths.295281858" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
- <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
- </option>
- <option id="sbi.gnu.c.compiler.option.frameworks.core.1144492600" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs">
- <listOptionValue builtIn="false" value="Native_API"/>
- </option>
- <option id="gnu.c.compiler.option.preprocessor.def.symbols.1496533463" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
- <listOptionValue builtIn="false" value="_DEBUG"/>
- </option>
- <option id="gnu.c.compiler.option.misc.other.1752913740" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -std=gnu++0x" valueType="string"/>
- <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.183281612" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
- </tool>
- <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.1326307127" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
- <tool command="arm-linux-gnueabi-g++.exe" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.1156278367" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker">
- <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.387163191" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList">
- <listOptionValue builtIn="false" value="${TC_LINKER_MISC}"/>
- <listOptionValue builtIn="false" value="${RS_LINKER_MISC}"/>
- <listOptionValue builtIn="false" value="-pie -lpthread "/>
- <listOptionValue builtIn="false" value="-Xlinker -rpath="/home/developer/sdk_tools/lib""/>
- <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
- <listOptionValue builtIn="false" value="-Xlinker --version-script=${PROJ_PATH}/.exportMap"/>
- <listOptionValue builtIn="false" value="-L"${SBI_SYSROOT}/usr/lib""/>
- <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/>
- </option>
- <option id="gnu.cpp.link.option.paths.1160023692" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
- <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/>
- </option>
- <option id="gnu.cpp.link.option.libs.1981950125" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
- <listOptionValue builtIn="false" value="TGMSDKLibrary"/>
- <listOptionValue builtIn="false" value="oc"/>
- <listOptionValue builtIn="false" value="octbstack"/>
- <listOptionValue builtIn="false" value="oc_logger"/>
- <listOptionValue builtIn="false" value="connectivity_abstraction"/>
- <listOptionValue builtIn="false" value="uuid"/>
- </option>
- <option id="sbi.gnu.cpp.linker.option.shared_flag.core.1600357455" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" value="false" valueType="boolean"/>
- <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1548223100" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
- <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
- <additionalInput kind="additionalinput" paths="$(LIBS)"/>
- </inputType>
- <outputType id="cdt.managedbuild.tool.gnu.cpp.linker.output.so.1567998933" outputPrefix="" superClass="cdt.managedbuild.tool.gnu.cpp.linker.output.so"/>
- </tool>
- <tool command="arm-linux-gnueabi-as.exe" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.1801679035" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base">
- <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1012512773" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
- </tool>
- <tool id="org.tizen.nativecore.tool.fnmapgen.719506497" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/>
- <tool id="org.tizen.nativecore.tool.fnmapgen.cpp.1591459501" name="C++ FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen.cpp"/>
- <tool id="org.tizen.nativecore.tool.ast.483946980" name="C Static Analyzer" superClass="org.tizen.nativecore.tool.ast"/>
- <tool id="org.tizen.nativecore.tool.ast.cpp.539557992" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/>
- <tool id="org.tizen.nativecore.tool.sbi.po.compiler.1541244945" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/>
- <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.1328146458" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/>
- </toolChain>
- </folderInfo>
- <sourceEntries>
- <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
- <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="res"/>
- <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
- </sourceEntries>
- </configuration>
- </storageModule>
- <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
- </cconfiguration>
- <cconfiguration id="org.tizen.nativecore.config.sbi.gcc45.app.release.791116227">
- <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.tizen.nativecore.config.sbi.gcc45.app.release.791116227" moduleId="org.eclipse.cdt.core.settings" name="Release">
- <externalSettings/>
- <extensions>
- <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
- <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
- <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
- <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
- <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
- <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
- <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
- </extensions>
- </storageModule>
- <storageModule moduleId="cdtBuildSystem" version="4.0.0">
- <configuration artifactName="conserverapp" buildArtefactType="org.tizen.nativecore.buildArtefactType.app" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.app,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.app.release.791116227" name="Release" parent="org.tizen.nativecore.config.sbi.gcc45.app.release">
- <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.app.release.791116227." name="/" resourcePath="">
- <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.app.release.1806554459" name="Tizen Native Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.app.release">
- <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.1882260991" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
- <builder buildPath="${workspace_loc:/ConServerApp}/Release" id="org.tizen.nativecore.target.sbi.gnu.builder.1480786483" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/>
- <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.101665077" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
- <tool command="clang++.exe" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.906486264" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
- <option id="gnu.cpp.compiler.option.optimization.level.325943992" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
- <option id="sbi.gnu.cpp.compiler.option.debugging.level.core.819826799" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core"/>
- <option id="sbi.gnu.cpp.compiler.option.1888932227" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
- <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_llvm34.i386.core.app"/>
- </option>
- <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.911460631" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath">
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/>
- <listOptionValue builtIn="false" value=""${SDK_PATH}/library""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/>
- </option>
- <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.740263234" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.core" valueType="stringList">
- <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
- <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
- <listOptionValue builtIn="false" value=" -fPIE"/>
- <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
- </option>
- <option id="gnu.cpp.compiler.option.include.paths.1207714584" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
- <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
- </option>
- <option id="sbi.gnu.cpp.compiler.option.frameworks.core.1142433860" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs">
- <listOptionValue builtIn="false" value="Native_API"/>
- </option>
- <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1397777277" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
- </tool>
- <tool command="clang.exe" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.1731044300" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
- <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.option.optimization.level.225459286" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
- <option id="sbi.gnu.c.compiler.option.debugging.level.core.291907753" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core"/>
- <option id="sbi.gnu.c.compiler.option.1322971988" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
- <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_llvm34.i386.core.app"/>
- </option>
- <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.1895593459" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath">
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/>
- <listOptionValue builtIn="false" value=""${SDK_PATH}/library""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/>
- </option>
- <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.2053809161" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.core" valueType="stringList">
- <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
- <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
- <listOptionValue builtIn="false" value=" -fPIE"/>
- <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
- </option>
- <option id="gnu.c.compiler.option.include.paths.2104973765" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
- <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
- </option>
- <option id="sbi.gnu.c.compiler.option.frameworks.core.1764818276" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs">
- <listOptionValue builtIn="false" value="Native_API"/>
- </option>
- <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1553289120" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
- </tool>
- <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.1602883613" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
- <tool command="clang++.exe" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.1501052901" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker">
- <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.561516003" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList">
- <listOptionValue builtIn="false" value="${TC_LINKER_MISC}"/>
- <listOptionValue builtIn="false" value="${RS_LINKER_MISC}"/>
- <listOptionValue builtIn="false" value="-pie -lpthread "/>
- <listOptionValue builtIn="false" value="-Xlinker -rpath="/home/developer/sdk_tools/lib""/>
- <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
- <listOptionValue builtIn="false" value="-Xlinker --version-script=${PROJ_PATH}/.exportMap"/>
- <listOptionValue builtIn="false" value="-L"${SBI_SYSROOT}/usr/lib""/>
- <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/>
- </option>
- <option id="gnu.cpp.link.option.paths.973160572" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
- <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/>
- </option>
- <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.204670616" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
- <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
- <additionalInput kind="additionalinput" paths="$(LIBS)"/>
- </inputType>
- </tool>
- <tool command="i386-linux-gnueabi-as.exe" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.1928734833" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base">
- <inputType id="cdt.managedbuild.tool.gnu.assembler.input.326189069" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
- </tool>
- <tool id="org.tizen.nativecore.tool.fnmapgen.1298411328" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/>
- <tool id="org.tizen.nativecore.tool.fnmapgen.cpp.891775659" name="C++ FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen.cpp"/>
- <tool id="org.tizen.nativecore.tool.ast.706788156" name="C Static Analyzer" superClass="org.tizen.nativecore.tool.ast"/>
- <tool id="org.tizen.nativecore.tool.ast.cpp.2024368653" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/>
- <tool id="org.tizen.nativecore.tool.sbi.po.compiler.188711953" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/>
- <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.601836947" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/>
- </toolChain>
- </folderInfo>
- <sourceEntries>
- <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
- <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="res"/>
- <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
- </sourceEntries>
- </configuration>
- </storageModule>
- <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
- </cconfiguration>
- </storageModule>
- <storageModule moduleId="cdtBuildSystem" version="4.0.0">
- <project id="ConServerApp.org.tizen.nativecore.target.sbi.gcc45.app.2088063880" name="Tizen Native Application" projectType="org.tizen.nativecore.target.sbi.gcc45.app"/>
- </storageModule>
- <storageModule moduleId="scannerConfiguration">
- <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
- <scannerConfigBuildInfo instanceId="org.tizen.nativecore.config.sbi.gcc45.app.debug.879388275">
- <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
- </scannerConfigBuildInfo>
- <scannerConfigBuildInfo instanceId="org.tizen.nativecore.config.sbi.gcc45.app.release.791116227">
- <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
- </scannerConfigBuildInfo>
- </storageModule>
- <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
- <storageModule moduleId="refreshScope"/>
- <storageModule moduleId="com.samsung.tizen.nativeapp.projectInfo" version="1.0.0"/>
-</cproject>
+++ /dev/null
-{
- global: main;
- local: *;
-};
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>ConServerApp</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
- <triggers>full,incremental,</triggers>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.tizen.nativecore.apichecker.core.builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.cdt.core.cnature</nature>
- <nature>org.eclipse.cdt.core.ccnature</nature>
- <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
- <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
- <nature>org.tizen.nativecore.apichecker.core.tizenCppNature</nature>
- </natures>
- <filteredResources>
- <filter>
- <id>1424773747755</id>
- <name></name>
- <type>26</type>
- <matcher>
- <id>org.eclipse.ui.ide.multiFilter</id>
- <arguments>1.0-projectRelativePath-matches-false-false-*/.tpk</arguments>
- </matcher>
- </filter>
- </filteredResources>
-</projectDescription>
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-#ifndef CONFIGURATION_RESOURCE_H__
-#define CONFIGURATION_RESOURCE_H__
-
-#include <functional>
-
-#include "OCPlatform.h"
-#include "OCApi.h"
-
-#pragma once
-
-#define DEFAULT_DEVICENAME "n"
-#define DEFAULT_LOCATION "loc"
-#define DEFAULT_LOCATIONNAME "locn"
-#define DEFAULT_CURRENCY "c"
-#define DEFAULT_REGION "r"
-
-using namespace OC;
-
-typedef std::function<OCEntityHandlerResult(std::shared_ptr< OCResourceRequest > request)>
-ResourceEntityHandler;
-
-static std::string defaultConURI = "/oic/con";
-static std::string defaultConResourceType = "oic.wk.con";
-
-extern std::string defaultDeviceName;
-extern std::string defaultLocation;
-extern std::string defaultLocationName;
-extern std::string defaultCurrency;
-extern std::string defaultRegion;
-
-class ConfigurationResource
-{
- public:
- // Configuration members
- std::string m_configurationUri;
- std::string m_deviceName;
- std::string m_location;
- std::string m_locationName;
- std::string m_currency;
- std::string m_region;
- std::vector< std::string > m_configurationTypes;
- std::vector< std::string > m_configurationInterfaces;
- OCResourceHandle m_configurationHandle;
- OCRepresentation m_configurationRep;
-
- public:
-
- ConfigurationResource();
-
- void createResource(ResourceEntityHandler callback);
-
- void setConfigurationRepresentation(OCRepresentation &rep);
-
- OCRepresentation getConfigurationRepresentation();
-
- std::string getUri();
-
- void factoryReset();
-
- void deleteResource();
-};
-
-#endif // CONFIGURATION_RESOURCE_H__
\ No newline at end of file
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#ifndef CONSERVERAPP_H__
-#define CONSERVERAPP_H__
-
-#include <app.h>
-#include <Elementary.h>
-#include <system_settings.h>
-#include <efl_extension.h>
-#include <dlog.h>
-
-#include "OCPlatform.h"
-#include "OCApi.h"
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "conserverapp"
-
-#if !defined(PACKAGE)
-#define PACKAGE "org.tizen.conserverapp"
-#endif
-
-#define ELM_DEMO_EDJ "opt/usr/apps/org.tizen.conserverapp/res/ui_controls.edj"
-
-#endif // CONSERVERAPP_H__
\ No newline at end of file
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-#ifndef FACTORYSET_RESOURCE_H__
-#define FACTORYSET_RESOURCE_H__
-
-#include <functional>
-
-#include "OCPlatform.h"
-#include "OCApi.h"
-#include "configurationresource.h"
-
-#pragma once
-
-using namespace OC;
-
-typedef std::function<OCEntityHandlerResult(std::shared_ptr< OCResourceRequest > request)>
-ResourceEntityHandler;
-
-class FactorySetResource : public ConfigurationResource
-{
- public:
-
- FactorySetResource();
-
- ~FactorySetResource();
-
- void createResource(ResourceEntityHandler callback);
-
- void setFactorySetRepresentation(OCRepresentation &rep);
-
- OCRepresentation getFactorySetRepresentation();
-
- std::string getUri();
-
- void deleteResource();
-};
-
-#endif // FACTORYSET_RESOURCE_H__
\ No newline at end of file
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-#ifndef MAINTENANCE_RESOURCE_H__
-#define MAINTENANCE_RESOURCE_H__
-
-#include <functional>
-#include <thread>
-#include <string>
-
-#include "OCPlatform.h"
-#include "OCApi.h"
-
-#pragma once
-
-#define DEFAULT_REBOOT "rb"
-#define DEFAULT_FACTORYRESET "fr"
-#define DEFAULT_STARTCOLLECTION "ssc"
-
-using namespace OC;
-
-typedef std::function<OCEntityHandlerResult(std::shared_ptr< OCResourceRequest > request)>
-ResourceEntityHandler;
-
-static std::string defaultFactoryReset = "false";
-static std::string defaultReboot = "false";
-static std::string defaultStartStatCollection = "false";
-
-class MaintenanceResource
-{
- public:
- // Maintenance members
- std::string m_maintenanceUri;
- std::string m_factoryReset;
- std::string m_reboot;
- std::string m_startStatCollection;
- std::vector< std::string > m_maintenanceTypes;
- std::vector< std::string > m_maintenanceInterfaces;
- OCResourceHandle m_maintenanceHandle;
- OCRepresentation m_maintenanceRep;
-
- public:
-
- MaintenanceResource();
-
- void createResource(ResourceEntityHandler callback);
-
- void setMaintenanceRepresentation(OCRepresentation &rep);
-
- OCRepresentation getMaintenanceRepresentation();
-
- std::string getUri();
-
- void maintenanceMonitor(int second);
-
- std::function< void() > factoryReset;
-
- void deleteResource();
-};
-
-#endif // MAINTENANCE_RESOURCE_H__
\ No newline at end of file
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-collections
-{
- base_scale: 1.8;
- group
- {
- name: "mainpage_layout";
- parts
- {
- part
- {
- name: "bootstrap_button";
- type: SWALLOW;
- scale: 1;
- description
- {
- rel1.relative: 0.01 0.02;
- rel2.relative: 0.99 0.11;
- }
- }
- part
- {
- name: "create_conf_button";
- type: SWALLOW;
- scale: 1;
- description
- {
- rel1.relative: 0.01 0.13;
- rel2.relative: 0.99 0.22;
- }
- }
- part
- {
- name: "log_bg";
- type: RECT;
- scale: 1;
- description
- {
- state: "default" 0.0;
- rel1.relative: 0.01 0.23;
- rel2.relative: 0.99 0.99;
- color: 220 220 220 255;
- }
- }
- part
- {
- name: "log";
- type: SWALLOW;
- scale: 1;
- description
- {
- rel1.to: "log_bg";
- rel2.to: "log_bg";
- }
- }
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include "configurationresource.h"
-
-#include <functional>
-#include <dlog.h>
-
-#include "OCPlatform.h"
-#include "OCApi.h"
-
-using namespace OC;
-
-// Constructor
-ConfigurationResource::ConfigurationResource() :
- m_deviceName(defaultDeviceName), m_location(defaultLocation),
- m_locationName(defaultLocationName), m_currency(defaultCurrency),
- m_region(defaultRegion)
-{
- m_configurationUri = defaultConURI; // URI of the resource
- m_configurationTypes.push_back(defaultConResourceType); // resource type name
- m_configurationInterfaces.push_back(DEFAULT_INTERFACE); // resource interface
- m_configurationRep.setValue(DEFAULT_DEVICENAME, m_deviceName);
- m_configurationRep.setValue(DEFAULT_LOCATION, m_location);
- m_configurationRep.setValue(DEFAULT_LOCATIONNAME, m_locationName);
- m_configurationRep.setValue(DEFAULT_CURRENCY, m_currency);
- m_configurationRep.setValue(DEFAULT_REGION, m_region);
- m_configurationRep.setUri(m_configurationUri);
- m_configurationRep.setResourceTypes(m_configurationTypes);
- m_configurationRep.setResourceInterfaces(m_configurationInterfaces);
- m_configurationHandle = nullptr;
-}
-
-// Creates a ConfigurationResource
-void ConfigurationResource::createResource(ResourceEntityHandler callback)
-{
- using namespace OC::OCPlatform;
-
- if (NULL == callback)
- {
- dlog_print(DLOG_INFO, "ConfigurationResource", "#### Callback should be binded");
- return;
- }
-
- // This will internally create and register the resource
- OCStackResult result = registerResource(m_configurationHandle, m_configurationUri,
- m_configurationTypes[0], m_configurationInterfaces[0],
- callback, OC_DISCOVERABLE | OC_OBSERVABLE);
-
- if (OC_STACK_OK != result)
- {
- dlog_print(DLOG_INFO, "ConfigurationResource", "#### Resource creation"
- "(configuration) was unsuccessful");
- return;
- }
-
- dlog_print(DLOG_INFO, "ConfigurationResource", "#### Configuration Resource is Created");
-}
-
-void ConfigurationResource::setConfigurationRepresentation(OCRepresentation &rep)
-{
- std::string value;
-
- if (rep.getValue(DEFAULT_DEVICENAME, value))
- {
- m_deviceName = value;
- dlog_print(DLOG_INFO, "ConfigurationResource", "#### m_deviceName: %s",
- m_deviceName.c_str());
- }
-
- if (rep.getValue(DEFAULT_LOCATION, value))
- {
- m_location = value;
- dlog_print(DLOG_INFO, "ConfigurationResource", "#### m_location: %s",
- m_location.c_str());
- }
-
- if (rep.getValue(DEFAULT_LOCATIONNAME, value))
- {
- m_locationName = value;
- dlog_print(DLOG_INFO, "ConfigurationResource", "#### m_locationName: %s",
- m_locationName.c_str());
- }
-
- if (rep.getValue(DEFAULT_CURRENCY, value))
- {
- m_currency = value;
- dlog_print(DLOG_INFO, "ConfigurationResource", "#### m_currency: %s",
- m_currency.c_str());
- }
-
- if (rep.getValue(DEFAULT_REGION, value))
- {
- m_region = value;
- dlog_print(DLOG_INFO, "ConfigurationResource", "#### m_region: %s",
- m_region.c_str());
- }
-}
-
-OCRepresentation ConfigurationResource::getConfigurationRepresentation()
-{
- m_configurationRep.setValue(DEFAULT_DEVICENAME, m_deviceName);
- m_configurationRep.setValue(DEFAULT_LOCATION, m_location);
- m_configurationRep.setValue(DEFAULT_LOCATIONNAME, m_locationName);
- m_configurationRep.setValue(DEFAULT_CURRENCY, m_currency);
- m_configurationRep.setValue(DEFAULT_REGION, m_region);
-
- return m_configurationRep;
-}
-
-std::string ConfigurationResource::getUri()
-{
- return m_configurationUri;
-}
-
-// Assigns default values to all the attributes of the configuration resource
-void ConfigurationResource::factoryReset()
-{
- m_deviceName = defaultDeviceName;
- m_location = defaultLocation;
- m_locationName = defaultLocationName;
- m_currency = defaultCurrency;
- m_region = defaultRegion;
-}
-
-// Deletes the configuration resource which has been created using createResource()
-void ConfigurationResource::deleteResource()
-{
- // Unregister the resource
- if (nullptr != m_configurationHandle)
- {
- OCPlatform::unregisterResource(m_configurationHandle);
- }
-}
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include "conserverapp.h"
-
-#include <tizen.h>
-#include <pthread.h>
-
-#include "ThingsConfiguration.h"
-#include "ThingsMaintenance.h"
-#include "configurationresource.h"
-#include "maintenanceresource.h"
-#include "factorysetresource.h"
-
-using namespace OC;
-using namespace OIC;
-
-namespace PH = std::placeholders;
-
-/* Default system configuration value's variables
- The variable's names should be same as the names of "extern" variables defined in
- "configurationresource.h" */
-std::string defaultDeviceName;
-std::string defaultLocation;
-std::string defaultLocationName;
-std::string defaultRegion;
-std::string defaultCurrency;
-
-static ThingsConfiguration *g_thingsConf;
-
-const int SUCCESS_RESPONSE = 0;
-
-bool resources_created = false;
-
-// Forward declaring the entityHandler (Configuration)
-bool prepareResponseForResource(std::shared_ptr< OCResourceRequest > request);
-OCStackResult sendResponseForResource(std::shared_ptr< OCResourceRequest > pRequest);
-OCEntityHandlerResult entityHandlerForResource(std::shared_ptr< OCResourceRequest > request);
-
-ConfigurationResource *myConfigurationResource;
-MaintenanceResource *myMaintenanceResource;
-FactorySetResource *myFactorySetResource;
-
-typedef std::function< void(OCRepresentation &) > putFunc;
-typedef std::function< OCRepresentation(void) > getFunc;
-
-typedef struct appdata
-{
- Evas_Object *win;
- Evas_Object *conform;
- Evas_Object *naviframe;
- Evas_Object *scroller;
- Evas_Object *layout, *base_layout;
- Evas_Object *bootButton;
- Evas_Object *createConfButton;
-} appdata_s;
-
-Evas_Object *log_entry;
-
-std::string logMessage;
-
-getFunc getGetFunction(std::string uri)
-{
- getFunc res = NULL;
-
- if (uri == myConfigurationResource->getUri())
- {
- res = std::bind(&ConfigurationResource::getConfigurationRepresentation,
- myConfigurationResource);
- }
- else if (uri == myMaintenanceResource->getUri())
- {
- res = std::bind(&MaintenanceResource::getMaintenanceRepresentation,
- myMaintenanceResource);
- }
-
- return res;
-}
-
-putFunc getPutFunction(std::string uri)
-{
- putFunc res = NULL;
-
- if (uri == myConfigurationResource->getUri())
- {
- res = std::bind(&ConfigurationResource::setConfigurationRepresentation,
- myConfigurationResource, std::placeholders::_1);
- }
- else if (uri == myMaintenanceResource->getUri())
- {
- res = std::bind(&MaintenanceResource::setMaintenanceRepresentation,
- myMaintenanceResource, std::placeholders::_1);
- }
-
- return res;
-}
-
-// This function prepares a response for the incoming request
-bool prepareResponseForResource(std::shared_ptr< OCResourceRequest > request)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### In Server CPP prepareResponseForResource");
- bool result = false;
- if (request)
- {
- // Get the request type and request flag
- std::string requestType = request->getRequestType();
- int requestFlag = request->getRequestHandlerFlag();
-
- if (requestFlag == RequestHandlerFlag::RequestFlag)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### requestFlag : Request");
-
- // If the request type is GET
- if (requestType == "GET")
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### requestType : GET");
-
- // GET operations are directly handled while sending the response
- result = true;
- }
- else if (requestType == "PUT")
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### requestType : PUT");
- putFunc putFunction;
- OCRepresentation rep = request->getResourceRepresentation();
-
- // Get appropriate function to be called for the PUT request
- putFunction = getPutFunction(request->getResourceUri());
-
- // Do related operations related to PUT request
- putFunction(rep);
- result = true;
- }
- else if (requestType == "POST")
- {
- // POST request operations
- }
- else if (requestType == "DELETE")
- {
- // DELETE request operations
- }
- }
- else if (requestFlag == RequestHandlerFlag::ObserverFlag)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### requestFlag : Observer");
- }
- }
- else
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Request invalid");
- }
-
- return result;
-}
-
-// This function sends a response for the incoming request
-OCStackResult sendResponseForResource(std::shared_ptr< OCResourceRequest > pRequest)
-{
- auto pResponse = std::make_shared< OC::OCResourceResponse >();
-
- // Check for query params (if any)
- QueryParamsMap queryParamsMap = pRequest->getQueryParameters();
-
- pResponse->setRequestHandle(pRequest->getRequestHandle());
- pResponse->setResourceHandle(pRequest->getResourceHandle());
-
- getFunc getFunction;
- getFunction = getGetFunction(pRequest->getResourceUri());
-
- OCRepresentation rep;
- rep = getFunction();
-
- auto findRes = queryParamsMap.find("if");
-
- if (findRes != queryParamsMap.end())
- {
- pResponse->setResourceRepresentation(rep, findRes->second);
- }
- else
- {
- pResponse->setResourceRepresentation(rep, DEFAULT_INTERFACE);
- }
-
- pResponse->setResponseResult(OC_EH_OK);
-
- return OCPlatform::sendResponse(pResponse);
-}
-
-// This function handles the requests and sends the response
-OCEntityHandlerResult entityHandlerForResource(std::shared_ptr< OCResourceRequest > request)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### In Server CPP (entityHandlerForResource) entity"
- "handler:");
- OCEntityHandlerResult ehResult = OC_EH_ERROR;
-
- if (prepareResponseForResource(request))
- {
- if (OC_STACK_OK == sendResponseForResource(request))
- {
- ehResult = OC_EH_OK;
- dlog_print(DLOG_INFO, LOG_TAG, "#### sendResponse success.");
- }
- else
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### sendResponse failed.");
- }
- }
- else
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### PrepareResponse failed.");
- }
- return ehResult;
-}
-
-// Updates the log in the UI
-void *updateLog(void *data)
-{
- std::string *log = (std::string *)data;
-
- if (nullptr == log)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### No log !!!!");
- }
- else
- {
- //Show the log
- elm_entry_entry_append(log_entry, log->c_str());
- elm_entry_cursor_end_set(log_entry);
- dlog_print(DLOG_INFO, LOG_TAG, "%s", log->c_str());
- }
- dlog_print(DLOG_INFO, LOG_TAG, "#### updateLog exit!!!!");
- return NULL;
-}
-
-static void
-win_delete_request_cb(void *data , Evas_Object *obj , void *event_info)
-{
- ui_app_exit();
-}
-
-// Function to delete all the configuration resources which are created
-void deleteResources()
-{
- if (NULL != myConfigurationResource)
- myConfigurationResource->deleteResource();
- if (NULL != myMaintenanceResource)
- myMaintenanceResource->deleteResource();
- if (NULL != myFactorySetResource)
- myFactorySetResource->deleteResource();
-
- delete g_thingsConf;
-}
-
-static void
-win_back_cb(void *data, Evas_Object *obj, void *event_info)
-{
-
- deleteResources();
-
- ui_app_exit();
-}
-
-/* Callback Function to be called by the platform
- when response arrives from the BootStrap Server */
-void onBootStrapCallback(const HeaderOptions &headerOptions, const OCRepresentation &rep,
- const int eCode)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### onBootStrap entry");
-
- if (SUCCESS_RESPONSE != eCode)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### onBootStrap -- onGET Response error: %d", eCode);
- return ;
- }
-
- dlog_print(DLOG_INFO, LOG_TAG, "#### onBootStrap -- GET request was successful");
- dlog_print(DLOG_INFO, LOG_TAG, "#### onBootStrap -- Resource URI: %s", rep.getUri().c_str());
-
- logMessage = "----------------------------<br>";
- logMessage += "GET request was successful<br>";
- logMessage += "URI : " + rep.getUri() + "<br>";
-
- defaultRegion = rep.getValue< std::string >(DEFAULT_REGION);
- defaultCurrency = rep.getValue< std::string >(DEFAULT_CURRENCY);
- defaultLocation = rep.getValue< std::string >(DEFAULT_LOCATION);
- defaultLocationName = rep.getValue< std::string >(DEFAULT_LOCATIONNAME);
- defaultDeviceName = rep.getValue< std::string >(DEFAULT_DEVICENAME);
-
- logMessage += "Device Name : " + defaultDeviceName + "<br>";
- logMessage += "Location : " + defaultLocation + "<br>";
- logMessage += "Location Name : " + defaultLocationName + "<br>";
- logMessage += "currency : " + defaultCurrency + "<br>";
- logMessage += "Region : " + defaultRegion + "<br>";
-
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
-
- //Call updateLog in the thread safe mode
- ecore_main_loop_thread_safe_call_sync(updateLog, &logMessage);
-
-}
-
-// Function to be called when the doBootStrap UI button is clicked
-static void
-doBootStrap_cb(void *data , Evas_Object *obj , void *event_info)
-{
-
- if (NULL == g_thingsConf)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "#### doBootstrap returned g_thingsConf NULL check");
- return;
- }
-
- OCStackResult result = g_thingsConf->doBootstrap(&onBootStrapCallback);
-
- if (OC_STACK_OK == result)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### doBootstrap returned OC_STACK_OK");
- }
- else
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### doBootstrap failed");
- }
-}
-
-// Function to be called when Create Configuration Resources UI button is clicked
-static void
-createConfResource_cb(void *data , Evas_Object *obj , void *event_info)
-{
- logMessage = "----------------------------<br>";
- if (!resources_created)
- {
- resources_created = true;
- myConfigurationResource = new ConfigurationResource();
- myConfigurationResource->createResource(&entityHandlerForResource);
-
- myMaintenanceResource = new MaintenanceResource();
- myMaintenanceResource->createResource(&entityHandlerForResource);
-
- myFactorySetResource = new FactorySetResource();
- myFactorySetResource->createResource(&entityHandlerForResource);
-
- myMaintenanceResource->factoryReset = std::function < void()
- > (std::bind(&ConfigurationResource::factoryReset,
- myConfigurationResource));
-
- logMessage += "Resources Created Successfully!!! Server is Ready!!!<br>";
- }
- else
- {
- logMessage += "Resources were created already!!! <br>";
- }
-
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- // Show the log in the UI
- ecore_main_loop_thread_safe_call_sync(updateLog, &logMessage);
-}
-
-static void
-create_base_gui(appdata_s *ad)
-{
- // Window
- ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
- elm_win_autodel_set(ad->win, EINA_TRUE);
-
- if (elm_win_wm_rotation_supported_get(ad->win))
- {
- int rots[4] = { 0, 90, 180, 270 };
- elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
- }
-
- evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);
- eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad);
-
- // Conformant
- ad->conform = elm_conformant_add(ad->win);
- evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_win_resize_object_add(ad->win, ad->conform);
- evas_object_show(ad->conform);
-
- // Base Layout
- ad->base_layout = elm_layout_add(ad->conform);
- evas_object_size_hint_weight_set(ad->base_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_layout_theme_set(ad->base_layout, "layout", "application", "default");
- evas_object_show(ad->base_layout);
-
- elm_object_content_set(ad->conform, ad->base_layout);
-
- // naviframe
- ad->naviframe = elm_naviframe_add(ad->base_layout);
- elm_object_part_content_set(ad->base_layout, "elm.swallow.content", ad->naviframe);
-
- // Scroller
- ad->scroller = elm_scroller_add(ad->naviframe);
- elm_scroller_bounce_set(ad->scroller, EINA_FALSE, EINA_TRUE);
- elm_scroller_policy_set(ad->scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
-
- // layout
- ad->layout = elm_layout_add(ad->naviframe);
- evas_object_size_hint_weight_set(ad->layout, EVAS_HINT_EXPAND, 0.0);
- elm_layout_file_set(ad->layout, ELM_DEMO_EDJ, "mainpage_layout");
-
- elm_object_content_set(ad->scroller, ad->layout);
-
- ad->bootButton = elm_button_add(ad->layout);
- elm_object_text_set(ad->bootButton, "doBootStrap");
- evas_object_size_hint_weight_set(ad->bootButton, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(ad->bootButton, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_smart_callback_add(ad->bootButton, "clicked", doBootStrap_cb, ad);
- elm_object_part_content_set(ad->layout, "bootstrap_button", ad->bootButton);
-
- ad->createConfButton = elm_button_add(ad->layout);
- elm_object_text_set(ad->createConfButton, "Create Configuration Resources");
- evas_object_size_hint_weight_set(ad->createConfButton, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(ad->createConfButton, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_smart_callback_add(ad->createConfButton, "clicked", createConfResource_cb, ad);
- elm_object_part_content_set(ad->layout, "create_conf_button", ad->createConfButton);
-
- log_entry = elm_entry_add(ad->layout);
- elm_entry_scrollable_set(log_entry, EINA_TRUE);
- elm_entry_editable_set(log_entry, EINA_FALSE);
- elm_object_part_text_set(log_entry, "elm.guide", "Logs will be updated here!!!");
- evas_object_size_hint_weight_set(log_entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(log_entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_object_part_content_set(ad->layout, "log", log_entry);
-
- elm_naviframe_item_push(ad->naviframe, "Configuration Server", NULL, NULL, ad->scroller, NULL);
-
- // Show window after base gui is set up
- evas_object_show(ad->win);
-}
-
-// Function which configures the OCPlatform
-static void
-configure_platform()
-{
- try
- {
- PlatformConfig config
- { OC::ServiceType::InProc, ModeType::Both, "0.0.0.0", 0, OC::QualityOfService::LowQos };
-
- OCPlatform::Configure(config);
-
- dlog_print(DLOG_INFO, LOG_TAG, "#### Platform configuration done!!!!");
- }
- catch (OCException &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception occured! (%s)", e.what());
- }
-}
-
-
-static bool
-app_create(void *data)
-{
- /* Hook to take necessary actions before main event loop starts
- Initialize UI resources and application's data
- If this function returns true, the main loop of application starts
- If this function returns false, the application is terminated */
- appdata_s *ad = (appdata_s *)data;
-
- elm_app_base_scale_set(1.8);
-
- // Create and show the UI
- create_base_gui(ad);
-
- // Configure the OCPlatform
- configure_platform();
-
- g_thingsConf = new ThingsConfiguration();
-
- return true;
-}
-
-static void
-app_control(app_control_h app_control, void *data)
-{
- // Handle the launch request.
-}
-
-static void
-app_pause(void *data)
-{
- // Take necessary actions when application becomes invisible.
-}
-
-static void
-app_resume(void *data)
-{
- // Take necessary actions when application becomes visible.
-}
-
-static void
-app_terminate(void *data)
-{
- // Release all resources.
-}
-
-static void
-ui_app_lang_changed(app_event_info_h event_info, void *user_data)
-{
- // APP_EVENT_LANGUAGE_CHANGED
- char *locale = NULL;
- system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
- elm_language_set(locale);
- free(locale);
- return;
-}
-
-static void
-ui_app_orient_changed(app_event_info_h event_info, void *user_data)
-{
- // APP_EVENT_DEVICE_ORIENTATION_CHANGED
- return;
-}
-
-static void
-ui_app_region_changed(app_event_info_h event_info, void *user_data)
-{
- // APP_EVENT_REGION_FORMAT_CHANGED
-}
-
-static void
-ui_app_low_battery(app_event_info_h event_info, void *user_data)
-{
- // APP_EVENT_LOW_BATTERY
-}
-
-static void
-ui_app_low_memory(app_event_info_h event_info, void *user_data)
-{
- // APP_EVENT_LOW_MEMORY
-}
-
-int
-main(int argc, char *argv[])
-{
- appdata_s ad = {0,};
- int ret = 0;
-
- ui_app_lifecycle_callback_s event_callback = {0,};
- app_event_handler_h handlers[5] = {NULL, };
-
- event_callback.create = app_create;
- event_callback.terminate = app_terminate;
- event_callback.pause = app_pause;
- event_callback.resume = app_resume;
- event_callback.app_control = app_control;
-
- ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY,
- ui_app_low_battery, &ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY,
- ui_app_low_memory, &ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED],
- APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, &ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED,
- ui_app_lang_changed, &ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED],
- APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, &ad);
- ui_app_remove_event_handler(handlers[APP_EVENT_LOW_MEMORY]);
-
- ret = ui_app_main(argc, argv, &event_callback, &ad);
- if (APP_ERROR_NONE != ret)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "app_main() is failed. err = %d", ret);
- }
-
- return ret;
-}
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include "factorysetresource.h"
-
-#include <functional>
-#include <dlog.h>
-#include <string.h>
-
-#include "OCPlatform.h"
-#include "OCApi.h"
-#include "configurationresource.h"
-
-using namespace OC;
-
-FactorySetResource::FactorySetResource()
-{
- m_configurationUri = "/factoryset"; // URI of the resource
- m_configurationTypes.clear();
- m_configurationTypes.push_back("factoryset"); // resource type name.
- m_configurationRep.setUri(m_configurationUri);
- m_configurationRep.setResourceTypes(m_configurationTypes);
-}
-
-FactorySetResource::~FactorySetResource() {}
-
-// This function internally calls registerResource API.
-void FactorySetResource::createResource(ResourceEntityHandler callback)
-{
- using namespace OC::OCPlatform;
-
- if (NULL == callback)
- {
- dlog_print(DLOG_INFO, "FactorySetResource", "#### Callback should be binded");
- return;
- }
-
- // This will internally create and register the resource
- OCStackResult result = registerResource(m_configurationHandle, m_configurationUri,
- m_configurationTypes[0], m_configurationInterfaces[0],
- callback, OC_DISCOVERABLE | OC_OBSERVABLE);
-
- if (OC_STACK_OK != result)
- {
- dlog_print(DLOG_INFO, "FactorySetResource", "#### Resource creation"
- "(configuration) was unsuccessful");
- return;
- }
-
- dlog_print(DLOG_INFO, "FactorySetResource", "#### Configuration Resource is Created");
-}
-
-void FactorySetResource::setFactorySetRepresentation(OCRepresentation &rep)
-{
- std::string value;
-
- if (rep.getValue(DEFAULT_DEVICENAME, value))
- {
- m_deviceName = value;
- dlog_print(DLOG_INFO, "FactorySetResource", "#### m_deviceName: %s",
- m_deviceName.c_str());
- }
-
- if (rep.getValue(DEFAULT_LOCATION, value))
- {
- m_location = value;
- dlog_print(DLOG_INFO, "FactorySetResource", "#### m_location: %s",
- m_location.c_str());
- }
-
- if (rep.getValue(DEFAULT_LOCATIONNAME, value))
- {
- m_locationName = value;
- dlog_print(DLOG_INFO, "FactorySetResource", "#### m_locationName: %s",
- m_locationName.c_str());
- }
-
- if (rep.getValue(DEFAULT_CURRENCY, value))
- {
- m_currency = value;
- dlog_print(DLOG_INFO, "FactorySetResource", "#### m_currency: %s",
- m_currency.c_str());
- }
-
- if (rep.getValue(DEFAULT_REGION, value))
- {
- m_region = value;
- dlog_print(DLOG_INFO, "FactorySetResource", "#### m_region: %s",
- m_region.c_str());
- }
-}
-
-OCRepresentation FactorySetResource::getFactorySetRepresentation()
-{
- m_configurationRep.setValue(DEFAULT_DEVICENAME, m_deviceName);
- m_configurationRep.setValue(DEFAULT_LOCATION, m_location);
- m_configurationRep.setValue(DEFAULT_LOCATIONNAME, m_locationName);
- m_configurationRep.setValue(DEFAULT_CURRENCY, m_currency);
- m_configurationRep.setValue(DEFAULT_REGION, m_region);
-
- return m_configurationRep;
-}
-
-std::string FactorySetResource::getUri()
-{
- return m_configurationUri;
-}
-
-// Deletes the factoryset resource which has been created using createResource()
-void FactorySetResource::deleteResource()
-{
- // Unregister the Configuration resource
- if (NULL != m_configurationHandle)
- {
- OCPlatform::unregisterResource(m_configurationHandle);
- }
-}
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include "maintenanceresource.h"
-
-#include <functional>
-#include <dlog.h>
-#include <thread>
-#include <string>
-
-#include "conserverapp.h"
-#include "OCPlatform.h"
-#include "OCApi.h"
-
-using namespace OC;
-
-extern std::string logMessage;
-
-extern void *updateLog(void *);
-
-static std::string defaultMntURI = "/oic/mnt";
-static std::string defaultMntResourceType = "oic.wk.mnt";
-
-// Constructor
-MaintenanceResource::MaintenanceResource() :
- m_factoryReset(defaultFactoryReset), m_reboot(defaultReboot),
- m_startStatCollection(defaultStartStatCollection)
-{
- m_maintenanceUri = defaultMntURI; // URI of the resource
- m_maintenanceTypes.push_back(defaultMntResourceType); // resource type name
- m_maintenanceInterfaces.push_back(DEFAULT_INTERFACE); // resource interface
- m_maintenanceRep.setValue(DEFAULT_FACTORYRESET, m_factoryReset);
- m_maintenanceRep.setValue(DEFAULT_REBOOT, m_reboot);
- m_maintenanceRep.setValue(DEFAULT_STARTCOLLECTION, m_startStatCollection);
- m_maintenanceRep.setUri(m_maintenanceUri);
- m_maintenanceRep.setResourceTypes(m_maintenanceTypes);
- m_maintenanceRep.setResourceInterfaces(m_maintenanceInterfaces);
- m_maintenanceHandle = NULL;
-}
-
-// Creates a DiagnosticResource
-void MaintenanceResource::createResource(ResourceEntityHandler callback)
-{
- using namespace OC::OCPlatform;
-
- if (NULL == callback)
- {
- dlog_print(DLOG_INFO, "MaintenanceResource", "#### Callback should be binded");
- return;
- }
-
- // This will internally create and register the resource
- OCStackResult result = registerResource(m_maintenanceHandle, m_maintenanceUri,
- m_maintenanceTypes[0], m_maintenanceInterfaces[0],
- callback, OC_DISCOVERABLE | OC_OBSERVABLE);
-
- if (OC_STACK_OK != result)
- {
- dlog_print(DLOG_INFO, "MaintenanceResource", "#### Resource creation"
- "(maintenance) was unsuccessful");
- return;
- }
-
- std::thread exec(
- std::function< void(int second) >(
- std::bind(&MaintenanceResource::maintenanceMonitor, this,
- std::placeholders::_1)), 1);
- exec.detach();
-
- dlog_print(DLOG_INFO, "MaintenanceResource", "#### maintenance Resource is Created");
-}
-
-void MaintenanceResource::setMaintenanceRepresentation(OCRepresentation &rep)
-{
- std::string value;
-
- if (rep.getValue(DEFAULT_FACTORYRESET, value))
- {
- m_factoryReset = value;
- dlog_print(DLOG_INFO, "MaintenanceResource", "#### m_factoryReset: %s",
- m_factoryReset.c_str());
- }
-
- if (rep.getValue(DEFAULT_REBOOT, value))
- {
- m_reboot = value;
- dlog_print(DLOG_INFO, "MaintenanceResource", "#### m_reboot: %s", m_reboot.c_str());
- }
-
- if (rep.getValue(DEFAULT_STARTCOLLECTION, value))
- {
- m_startStatCollection = value;
- dlog_print(DLOG_INFO, "MaintenanceResource", "#### m_startStatCollection: %s",
- m_startStatCollection.c_str());
- }
-}
-
-OCRepresentation MaintenanceResource::getMaintenanceRepresentation()
-{
- m_maintenanceRep.setValue(DEFAULT_FACTORYRESET, m_factoryReset);
- m_maintenanceRep.setValue(DEFAULT_REBOOT, m_reboot);
- m_maintenanceRep.setValue(DEFAULT_STARTCOLLECTION, m_startStatCollection);
-
- return m_maintenanceRep;
-}
-
-std::string MaintenanceResource::getUri()
-{
- return m_maintenanceUri;
-}
-
-// Handles the Reboot and FactoryReset request
-void MaintenanceResource::maintenanceMonitor(int second)
-{
- while (1)
- {
- sleep(second);
-
- if (m_reboot == "true")
- {
- int res;
- dlog_print(DLOG_INFO, "MaintenanceResource", "#### Reboot will be soon...");
- m_reboot = defaultReboot;
- res = system("sudo reboot"); // System reboot
-
- dlog_print(DLOG_INFO, "MaintenanceResource", "#### return: %d", res);
-
- logMessage = "----------------------------<br>";
- logMessage += "*** System Reboot Success ***<br>";
-
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- //Show the log
- ecore_main_loop_thread_safe_call_sync(updateLog, &logMessage);
-
- }
- else if (m_factoryReset == "true")
- {
- dlog_print(DLOG_INFO, "MaintenanceResource", "#### Factory Reset will be soon...");
- m_factoryReset = defaultFactoryReset;
- factoryReset();
- }
- }
-}
-
-// Deletes the diagnostic resource which has been created using createResource()
-void MaintenanceResource::deleteResource()
-{
- // Unregister the resource
- if (NULL != m_maintenanceHandle)
- {
- OCPlatform::unregisterResource(m_maintenanceHandle);
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<manifest xmlns="http://tizen.org/ns/packages" api-version="2.3" package="org.tizen.conserverapp" version="1.0.0">
- <profile name="mobile"/>
- <ui-application appid="org.tizen.conserverapp" exec="conserverapp" multiple="false" nodisplay="false" taskmanage="true" type="capp">
- <label>conserverapp</label>
- <icon>conserverapp.png</icon>
- </ui-application>
- <privileges>
- <privilege>http://tizen.org/privilege/network.get</privilege>
- <privilege>http://tizen.org/privilege/internet</privilege>
- </privileges>
- <feature name="http://tizen.org/feature/network.wifi">true</feature>
-</manifest>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
- <storageModule moduleId="org.eclipse.cdt.core.settings">
- <cconfiguration id="org.tizen.nativecore.config.sbi.gcc45.app.debug.109194109">
- <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.tizen.nativecore.config.sbi.gcc45.app.debug.109194109" moduleId="org.eclipse.cdt.core.settings" name="Debug">
- <externalSettings/>
- <extensions>
- <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
- <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
- <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
- <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
- <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
- <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
- <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
- </extensions>
- </storageModule>
- <storageModule moduleId="cdtBuildSystem" version="4.0.0">
- <configuration artifactName="tmsampleapp" buildArtefactType="org.tizen.nativecore.buildArtefactType.app" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.app,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.app.debug.109194109" name="Debug" parent="org.tizen.nativecore.config.sbi.gcc45.app.debug">
- <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.app.debug.109194109." name="/" resourcePath="">
- <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug.266200202" name="Tizen Native Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug">
- <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.1788661429" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
- <builder arguments="--eval="SHELL=cmd" -r" autoBuildTarget="all" buildPath="${workspace_loc:/TMSampleApp}/Debug" enableAutoBuild="true" id="org.tizen.nativecore.target.sbi.gnu.builder.1749302123" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/>
- <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.345678603" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
- <tool command="arm-linux-gnueabi-g++.exe" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.1794187316" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
- <option id="gnu.cpp.compiler.option.optimization.level.719656926" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
- <option id="sbi.gnu.cpp.compiler.option.debugging.level.core.378028433" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
- <option id="sbi.gnu.cpp.compiler.option.831567474" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" useByScannerDiscovery="false" valueType="userObjs">
- <listOptionValue builtIn="false" value="mobile-2.3-device.core_gcc46.armel.core.app"/>
- </option>
- <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.1543030783" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" useByScannerDiscovery="false" valueType="includePath">
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/>
- <listOptionValue builtIn="false" value=""${SDK_PATH}/library""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/>
- </option>
- <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.1612037830" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.core" useByScannerDiscovery="false" valueType="stringList">
- <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
- <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
- <listOptionValue builtIn="false" value=" -fPIE"/>
- <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
- <listOptionValue builtIn="false" value="-mthumb"/>
- </option>
- <option id="gnu.cpp.compiler.option.include.paths.1501991974" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
- <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
- <listOptionValue builtIn="false" value=""..\..\..\..\sdk\inc""/>
- <listOptionValue builtIn="false" value=""..\..\..\..\sdk\src""/>
- <listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\include""/>
- <listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\c_common""/>
- <listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\csdk\stack\include""/>
- <listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\csdk\logger\include""/>
- <listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\csdk\occoap\include""/>
- <listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\csdk\ocrandom\include""/>
- <listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\csdk\ocsocket\include""/>
- <listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\oc_logger\include""/>
- <listOptionValue builtIn="false" value=""..\..\..\..\..\..\extlibs\timer""/>
- </option>
- <option id="sbi.gnu.cpp.compiler.option.frameworks.core.1095600730" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" useByScannerDiscovery="false" valueType="userObjs">
- <listOptionValue builtIn="false" value="Native_API"/>
- </option>
- <option id="gnu.cpp.compiler.option.preprocessor.def.371963530" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" useByScannerDiscovery="false" valueType="definedSymbols">
- <listOptionValue builtIn="false" value="_DEBUG"/>
- </option>
- <option id="gnu.cpp.compiler.option.dialect.std.1929207991" name="Language standard" superClass="gnu.cpp.compiler.option.dialect.std" value="gnu.cpp.compiler.dialect.default" valueType="enumerated"/>
- <option id="sbi.gnu.cpp.compiler.option.misc.pic.core.755649926" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" value="true" valueType="boolean"/>
- <option id="gnu.cpp.compiler.option.other.other.1760093561" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -std=c++0x" valueType="string"/>
- <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1956958926" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
- </tool>
- <tool command="arm-linux-gnueabi-gcc.exe" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.2072036030" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
- <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.1042898971" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" useByScannerDiscovery="false" valueType="enumerated"/>
- <option id="sbi.gnu.c.compiler.option.debugging.level.core.135607770" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
- <option id="sbi.gnu.c.compiler.option.571493571" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" useByScannerDiscovery="false" valueType="userObjs">
- <listOptionValue builtIn="false" value="mobile-2.3-device.core_gcc46.armel.core.app"/>
- </option>
- <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.107632308" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" useByScannerDiscovery="false" valueType="includePath">
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/>
- <listOptionValue builtIn="false" value=""${SDK_PATH}/library""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/>
- </option>
- <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.1275911900" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.core" useByScannerDiscovery="false" valueType="stringList">
- <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
- <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
- <listOptionValue builtIn="false" value=" -fPIE"/>
- <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
- <listOptionValue builtIn="false" value="-mthumb"/>
- </option>
- <option id="gnu.c.compiler.option.include.paths.109116980" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
- <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
- </option>
- <option id="sbi.gnu.c.compiler.option.frameworks.core.1552601669" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" useByScannerDiscovery="false" valueType="userObjs">
- <listOptionValue builtIn="false" value="Native_API"/>
- </option>
- <option id="gnu.c.compiler.option.preprocessor.def.symbols.2021130927" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
- <listOptionValue builtIn="false" value="_DEBUG"/>
- </option>
- <option id="sbi.gnu.c.compiler.option.misc.pic.core.1304419386" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" value="false" valueType="boolean"/>
- <option id="gnu.c.compiler.option.misc.other.2029079564" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -std=c++0x" valueType="string"/>
- <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1859092644" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
- </tool>
- <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.944066372" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
- <tool command="arm-linux-gnueabi-g++.exe" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.1667264058" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker">
- <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.1178784315" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList">
- <listOptionValue builtIn="false" value="${TC_LINKER_MISC}"/>
- <listOptionValue builtIn="false" value="${RS_LINKER_MISC}"/>
- <listOptionValue builtIn="false" value="-pie -lpthread "/>
- <listOptionValue builtIn="false" value="-Xlinker -rpath="/home/developer/sdk_tools/lib""/>
- <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
- <listOptionValue builtIn="false" value="-Xlinker --version-script=${PROJ_PATH}/.exportMap"/>
- <listOptionValue builtIn="false" value="-L"${SBI_SYSROOT}/usr/lib""/>
- <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/>
- </option>
- <option id="gnu.cpp.link.option.paths.1087248355" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
- <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/>
- </option>
- <option id="gnu.cpp.link.option.libs.2039500142" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
- <listOptionValue builtIn="false" value="TGMSDKLibrary"/>
- <listOptionValue builtIn="false" value="oc"/>
- <listOptionValue builtIn="false" value="octbstack"/>
- <listOptionValue builtIn="false" value="oc_logger"/>
- <listOptionValue builtIn="false" value="connectivity_abstraction"/>
- <listOptionValue builtIn="false" value="uuid"/>
- </option>
- <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.618645708" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
- <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
- <additionalInput kind="additionalinput" paths="$(LIBS)"/>
- </inputType>
- </tool>
- <tool command="arm-linux-gnueabi-as.exe" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.1585687908" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base">
- <inputType id="cdt.managedbuild.tool.gnu.assembler.input.89256350" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
- </tool>
- <tool id="org.tizen.nativecore.tool.fnmapgen.353447784" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/>
- <tool id="org.tizen.nativecore.tool.fnmapgen.cpp.734608698" name="C++ FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen.cpp"/>
- <tool id="org.tizen.nativecore.tool.ast.125567506" name="C Static Analyzer" superClass="org.tizen.nativecore.tool.ast"/>
- <tool id="org.tizen.nativecore.tool.ast.cpp.2107204356" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/>
- <tool id="org.tizen.nativecore.tool.sbi.po.compiler.1190161351" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/>
- <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.1621384631" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/>
- </toolChain>
- </folderInfo>
- <sourceEntries>
- <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
- <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="res"/>
- <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
- </sourceEntries>
- </configuration>
- </storageModule>
- <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
- </cconfiguration>
- <cconfiguration id="org.tizen.nativecore.config.sbi.gcc45.app.release.1584352396">
- <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.tizen.nativecore.config.sbi.gcc45.app.release.1584352396" moduleId="org.eclipse.cdt.core.settings" name="Release">
- <externalSettings/>
- <extensions>
- <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
- <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
- <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
- <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
- <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
- <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
- <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
- </extensions>
- </storageModule>
- <storageModule moduleId="cdtBuildSystem" version="4.0.0">
- <configuration artifactName="tmsampleapp" buildArtefactType="org.tizen.nativecore.buildArtefactType.app" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.app,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.app.release.1584352396" name="Release" parent="org.tizen.nativecore.config.sbi.gcc45.app.release">
- <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.app.release.1584352396." name="/" resourcePath="">
- <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.app.release.32000863" name="Tizen Native Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.app.release">
- <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.1750758769" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
- <builder buildPath="${workspace_loc:/TMSampleApp}/Release" id="org.tizen.nativecore.target.sbi.gnu.builder.2029564551" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/>
- <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.224082468" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
- <tool command="clang++.exe" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.1434486618" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
- <option id="gnu.cpp.compiler.option.optimization.level.1709393206" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
- <option id="sbi.gnu.cpp.compiler.option.debugging.level.core.221700213" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core"/>
- <option id="sbi.gnu.cpp.compiler.option.710876023" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
- <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_llvm34.i386.core.app"/>
- </option>
- <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.1622581330" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath">
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/>
- <listOptionValue builtIn="false" value=""${SDK_PATH}/library""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/>
- </option>
- <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.1695583788" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.core" valueType="stringList">
- <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
- <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
- <listOptionValue builtIn="false" value=" -fPIE"/>
- <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
- </option>
- <option id="gnu.cpp.compiler.option.include.paths.585301879" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
- <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
- </option>
- <option id="sbi.gnu.cpp.compiler.option.frameworks.core.708669314" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs">
- <listOptionValue builtIn="false" value="Native_API"/>
- </option>
- <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.2006056090" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
- </tool>
- <tool command="clang.exe" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.601285388" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
- <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.option.optimization.level.1778561828" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
- <option id="sbi.gnu.c.compiler.option.debugging.level.core.1695949408" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core"/>
- <option id="sbi.gnu.c.compiler.option.1422818783" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
- <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_llvm34.i386.core.app"/>
- </option>
- <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.1871683675" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath">
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/>
- <listOptionValue builtIn="false" value=""${SDK_PATH}/library""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/>
- </option>
- <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.371848582" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.core" valueType="stringList">
- <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
- <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
- <listOptionValue builtIn="false" value=" -fPIE"/>
- <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
- </option>
- <option id="gnu.c.compiler.option.include.paths.1254567673" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
- <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
- </option>
- <option id="sbi.gnu.c.compiler.option.frameworks.core.627340354" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs">
- <listOptionValue builtIn="false" value="Native_API"/>
- </option>
- <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.749706957" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
- </tool>
- <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.1794486202" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
- <tool command="clang++.exe" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.2579106" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker">
- <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.1582557344" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList">
- <listOptionValue builtIn="false" value="${TC_LINKER_MISC}"/>
- <listOptionValue builtIn="false" value="${RS_LINKER_MISC}"/>
- <listOptionValue builtIn="false" value="-pie -lpthread "/>
- <listOptionValue builtIn="false" value="-Xlinker -rpath="/home/developer/sdk_tools/lib""/>
- <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
- <listOptionValue builtIn="false" value="-Xlinker --version-script=${PROJ_PATH}/.exportMap"/>
- <listOptionValue builtIn="false" value="-L"${SBI_SYSROOT}/usr/lib""/>
- <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/>
- </option>
- <option id="gnu.cpp.link.option.paths.1396123174" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
- <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/>
- </option>
- <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.768667264" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
- <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
- <additionalInput kind="additionalinput" paths="$(LIBS)"/>
- </inputType>
- </tool>
- <tool command="i386-linux-gnueabi-as.exe" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.380499784" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base">
- <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1638213209" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
- </tool>
- <tool id="org.tizen.nativecore.tool.fnmapgen.1617359663" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/>
- <tool id="org.tizen.nativecore.tool.fnmapgen.cpp.759297757" name="C++ FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen.cpp"/>
- <tool id="org.tizen.nativecore.tool.ast.495578509" name="C Static Analyzer" superClass="org.tizen.nativecore.tool.ast"/>
- <tool id="org.tizen.nativecore.tool.ast.cpp.91235808" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/>
- <tool id="org.tizen.nativecore.tool.sbi.po.compiler.619869321" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/>
- <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.1045552473" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/>
- </toolChain>
- </folderInfo>
- <sourceEntries>
- <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
- <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="res"/>
- <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
- </sourceEntries>
- </configuration>
- </storageModule>
- <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
- </cconfiguration>
- </storageModule>
- <storageModule moduleId="cdtBuildSystem" version="4.0.0">
- <project id="TMSampleApp.org.tizen.nativecore.target.sbi.gcc45.app.278712545" name="Tizen Native Application" projectType="org.tizen.nativecore.target.sbi.gcc45.app"/>
- </storageModule>
- <storageModule moduleId="scannerConfiguration">
- <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
- <scannerConfigBuildInfo instanceId="org.tizen.nativecore.config.sbi.gcc45.app.release.1584352396">
- <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
- </scannerConfigBuildInfo>
- <scannerConfigBuildInfo instanceId="org.tizen.nativecore.config.sbi.gcc45.app.debug.109194109">
- <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
- </scannerConfigBuildInfo>
- </storageModule>
- <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
- <storageModule moduleId="refreshScope" versionNumber="2">
- <configuration configurationName="Debug">
- <resource resourceType="PROJECT" workspacePath="/TMSampleApp"/>
- </configuration>
- <configuration configurationName="Release">
- <resource resourceType="PROJECT" workspacePath="/TMSampleApp"/>
- </configuration>
- </storageModule>
- <storageModule moduleId="com.samsung.tizen.nativeapp.projectInfo" version="1.0.0"/>
-</cproject>
+++ /dev/null
-{
- global: main;
- local: *;
-};
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>TMSampleApp</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
- <triggers>full,incremental,</triggers>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.tizen.nativecore.apichecker.core.builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.cdt.core.cnature</nature>
- <nature>org.eclipse.cdt.core.ccnature</nature>
- <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
- <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
- <nature>org.tizen.nativecore.apichecker.core.tizenCppNature</nature>
- </natures>
- <filteredResources>
- <filter>
- <id>1424257681824</id>
- <name></name>
- <type>26</type>
- <matcher>
- <id>org.eclipse.ui.ide.multiFilter</id>
- <arguments>1.0-projectRelativePath-matches-false-false-*/.tpk</arguments>
- </matcher>
- </filter>
- </filteredResources>
-</projectDescription>
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#define POPUP_CONTENT_DEFAULT_PADDING_LEFT_MIN_INC 15
-#define POPUP_EDITFIELD_LAYOUT_MINMAX_HEIGHT_INC 96
-
-group
-{
- name: "configuration_layout";
- parts
- {
- part
- {
- name: "list";
- type: SWALLOW;
- scale: 1;
- description
- {
- rel1.relative: 0.01 0.01;
- rel2.relative: 0.99 0.6;
- }
- }
- part
- {
- name: "log_bg";
- type: RECT;
- scale: 1;
- description
- {
- state: "default" 0.0;
- rel1.relative: 0.01 0.61;
- rel2.relative: 0.98 1.0;
- color: 220 220 220 255;
- }
- }
- part
- {
- name: "log";
- type: SWALLOW;
- scale: 1;
- description
- {
- rel1.to: "log_bg";
- rel2.to: "log_bg";
- }
- }
- }
-}
-group
-{
- name: "popup_region_text";
- parts
- {
- part
- {
- name: "pad_l";
- type: SPACER;
- scale: 1;
- description
- {
- state: "default" 0.0;
- min: POPUP_CONTENT_DEFAULT_PADDING_LEFT_MIN_INC 0;
- fixed: 1 0;
- rel1.relative: 0.0 0.0;
- rel2.relative: 0.0 1.0;
- align: 0.0 0.0;
- }
- }
- part
- {
- name: "pad_r";
- type: SPACER;
- scale: 1;
- description
- {
- state: "default" 0.0;
- min: POPUP_CONTENT_DEFAULT_PADDING_LEFT_MIN_INC 0;
- fixed: 1 0;
- rel1.relative: 1.0 0.0;
- rel2.relative: 1.0 1.0;
- align: 1.0 0.0;
- }
- }
- part
- {
- name: "elm.swallow.content";
- type: SWALLOW;
- scale: 1;
- description
- {
- state: "default" 0.0;
- min: 0 POPUP_EDITFIELD_LAYOUT_MINMAX_HEIGHT_INC;
- max: -1 POPUP_EDITFIELD_LAYOUT_MINMAX_HEIGHT_INC;
- align: 0.5 0.5;
- rel1
- {
- relative: 1.0 0.0;
- to_x: "pad_l";
- }
- rel2
- {
- relative: 0.0 1.0;
- to_x: "pad_r";
- }
- }
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#define POPUP_CONTENT_DEFAULT_PADDING_LEFT_MIN_INC 15
-#define POPUP_EDITFIELD_LAYOUT_MINMAX_HEIGHT_INC 96
-
-group
-{
- name: "group_layout";
- parts
- {
- part
- {
- name: "find_button";
- type: SWALLOW;
- scale: 1;
- description
- {
- rel1.relative: 0.01 0.01;
- rel2.relative: 0.5 0.09;
- }
- }
- part
- {
- name: "list";
- type: SWALLOW;
- scale: 1;
- description
- {
- rel1.relative: 0.01 0.1;
- rel2.relative: 0.99 0.7;
- }
- }
- part
- {
- name: "log_bg";
- type: RECT;
- scale: 1;
- description
- {
- state: "default" 0.0;
- rel1.relative: 0.01 0.71;
- rel2.relative: 0.98 1.0;
- color: 220 220 220 255;
- }
- }
- part
- {
- name: "log";
- type: SWALLOW;
- scale: 1;
- description
- {
- rel1.to: "log_bg";
- rel2.to: "log_bg";
- }
- }
- }
-}
-
-group
-{
- name: "popup_datetime_text";
- parts
- {
- part
- {
- name: "pad_l";
- type: SPACER;
- scale: 1;
- description
- {
- state: "default" 0.0;
- min: POPUP_CONTENT_DEFAULT_PADDING_LEFT_MIN_INC 0;
- fixed: 1 0;
- rel1.relative: 0.0 0.0;
- rel2.relative: 0.0 1.0;
- align: 0.0 0.0;
- }
- }
- part
- {
- name: "pad_r";
- type: SPACER;
- scale: 1;
- description
- {
- state: "default" 0.0;
- min: POPUP_CONTENT_DEFAULT_PADDING_LEFT_MIN_INC 0;
- fixed: 1 0;
- rel1.relative: 1.0 0.0;
- rel2.relative: 1.0 1.0;
- align: 1.0 0.0;
- }
- }
- part
- {
- name: "elm.swallow.content";
- type: SWALLOW;
- scale: 1;
- description
- {
- state: "default" 0.0;
- min: 0 POPUP_EDITFIELD_LAYOUT_MINMAX_HEIGHT_INC;
- max: -1 POPUP_EDITFIELD_LAYOUT_MINMAX_HEIGHT_INC;
- align: 0.5 0.5;
- rel1
- {
- relative: 1.0 0.0;
- to_x: "pad_l";
- }
- rel2
- {
- relative: 0.0 1.0;
- to_x: "pad_r";
- }
- }
- }
- }
-}
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#ifndef TMSAMPLEAPP_H__
-#define TMSAMPLEAPP_H__
-
-#include <app.h>
-#include <Elementary.h>
-#include <system_settings.h>
-#include <efl_extension.h>
-#include <dlog.h>
-
-#include "OCPlatform.h"
-#include "OCApi.h"
-#include "GroupManager.h"
-#include "ThingsConfiguration.h"
-#include "ThingsMaintenance.h"
-
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "tmsampleapp"
-
-#if !defined(PACKAGE)
-#define PACKAGE "org.tizen.tmsampleapp"
-#endif
-
-#define ELM_DEMO_EDJ "opt/usr/apps/org.tizen.tmsampleapp/res/ui_controls.edj"
-
-#define FINDGROUP_TIMEOUT 5
-#define FINDRESOURCE_TIMEOUT 6
-
-#define DEFAULT_DEVICENAME "n"
-#define DEFAULT_LOCATION "loc"
-#define DEFAULT_LOCATIONNAME "locn"
-#define DEFAULT_CURRENCY "c"
-#define DEFAULT_REGION "r"
-
-void group_cb(void *data, Evas_Object *obj, void *event_info);
-void configuration_cb(void *data, Evas_Object *obj, void *event_info);
-
-#endif // TMSAMPLEAPP_H__
\ No newline at end of file
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include<iostream>
-
-using namespace std;
-
-#ifndef TMUTIL_H__
-#define TMUTIL_H__
-
-extern std::string getOCStackResultStringFromInt(int result);
-
-#endif // TMUTIL_H__
\ No newline at end of file
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-collections
-{
- base_scale: 1.8;
- #include "../edc_resource/configuration_control.edc"
- #include "../edc_resource/group_control.edc"
-}
\ No newline at end of file
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include "tmsampleapp.h"
-#include "tmutil.h"
-
-using namespace std;
-using namespace OC;
-using namespace OIC;
-
-int isWaiting = 0; // 0: none to wait, 1: wait for the response of "getConfigurationValue"
-const int SUCCESS_RESPONSE = 0;
-
-OCResourceHandle configurationCollectionHandle = NULL;
-OCResourceHandle configurationFoundHandle = NULL;
-std::shared_ptr< OCResource > g_configurationCollection; // For a group of multiple resources
-std::shared_ptr< OCResource > g_configurationResource; // For a single resource
-
-OCResourceHandle maintenanceCollectionHandle = NULL;
-OCResourceHandle maintenanceFoundHandle = NULL;
-std::shared_ptr< OCResource > g_maintenanceCollection; // For a group of multiple resources
-std::shared_ptr< OCResource > g_maintenanceResource; // For a single resource
-
-OCResourceHandle setCollectionHandle = NULL;
-OCResourceHandle setFoundHandle = NULL;
-std::shared_ptr< OCResource > g_setCollection; // For a group of multiple resources
-std::shared_ptr< OCResource > g_setResource; // For a single resource
-
-std::map< std::string, std::shared_ptr< OCResource > > resourceTable;
-std::vector< OCResourceHandle > configResourceHandleVector;
-
-typedef std::string ConfigurationName;
-typedef std::string ConfigurationValue;
-
-static Evas_Object *log_entry = NULL;
-
-string CONFIGURATION_COLLECTION_RESOURCE_URI = "/core/a/configuration/resourceset";
-string CONFIGURATION_COLLECTION_RESOURCE_TYPE = "core.configuration.resourceset";
-string MAINTENANCE_COLLECTION_RESOURCE_URI = "/core/a/maintenance/resourceset";
-string MAINTENANCE_COLLECTION_RESOURCE_TYPE = "core.maintenance.resourceset";
-string FACTORYSET_COLLECTION_RESOURCE_URI = "/core/a/factoryset/resourceset";
-string FACTORYSET_COLLECTION_RESOURCE_TYPE = "core.factoryset.resourceset";
-
-string CONFIGURATION_RESOURCE_URI = "/oic/con";
-string MAINTENANCE_RESOURCE_URI = "/oic/mnt";
-string FACTORYSET_RESOURCE_URI = "/factoryset";
-
-GroupManager *g_groupManager = nullptr;
-ThingsConfiguration *g_thingsConfig = nullptr;
-ThingsMaintenance *g_thingsMnt = nullptr;
-
-
-typedef struct region_popup
-{
- Evas_Object *popup;
- Evas_Object *entry;
-} region_popup_fields;
-
-void *updateConfigLog(void *data)
-{
- string *log = (string *)data;
- // Show the log
- elm_entry_entry_append(log_entry, (*log).c_str());
- elm_entry_cursor_end_set(log_entry);
- return NULL;
-}
-
-// Callback to found collection resource
-void onFoundCollectionResource(std::vector< std::shared_ptr< OCResource > > resources)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### onFoundCollectionResource ENTRY!!!!");
- try
- {
- // Do some operations with resource object.
- for (unsigned int i = 0; i < resources.size(); ++i)
- {
- string logMessage;
- std::shared_ptr< OCResource > resource = resources.at(i);
- if (resource)
- {
- string resourceURI = resource->host();
- string hostAddress = resource->uri();
- logMessage = "FoundHost: " + resource->host() + "<br>";
- logMessage += "FoundUri : " + resource->uri() + "<br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, "FoundHost: %s", resourceURI.c_str());
- dlog_print(DLOG_INFO, LOG_TAG, "FoundUri : %s", hostAddress.c_str());
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog,
- &logMessage);
-
- if (resource->uri() == CONFIGURATION_COLLECTION_RESOURCE_URI)
- g_configurationCollection = resource;
- else if (resource->uri() == MAINTENANCE_COLLECTION_RESOURCE_URI)
- g_maintenanceCollection = resource;
- else if (resource->uri() == FACTORYSET_COLLECTION_RESOURCE_URI)
- g_setCollection = resource;
- else
- {
- isWaiting = 0;
- return;
- }
- }
- else
- {
- // Resource is invalid
-
- logMessage = "Found Resource invalid!";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog,
- &logMessage);
- }
- }
- }
- catch (std::exception &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception occured! (%s)", e.what());
- }
- isWaiting = 0;
- dlog_print(DLOG_INFO, LOG_TAG, "#### onFoundCollectionResource EXIT!!!!");
-}
-
-// Callback to found candidate resources
-void onFoundCandidateResource(std::vector< std::shared_ptr< OCResource > > resources)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### onFoundCandidateCollection ENTRY!!!!");
- try
- {
- // Do some operations with resource object.
- for (unsigned int i = 0; i < resources.size(); ++i)
- {
- string logMessage;
- std::shared_ptr< OCResource > resource = resources.at(i);
- if (resource)
- {
- // Check if the resource is new one. If so, store it.
- std::map< std::string, std::shared_ptr< OCResource > >::iterator iter =
- resourceTable.find(resource->host() + resource->uri());
-
- if (iter == resourceTable.end()) // new one
- {
- resourceTable[resource->host() + resource->uri()] = resource;
-
- OCResourceHandle foundResourceHandle = NULL;
- OCStackResult result = OCPlatform::registerResource(foundResourceHandle,
- resource);
- // TODO: null check for foundResourceHandle
- dlog_print(DLOG_INFO, LOG_TAG, "#### (%s) REGISTERED",
- resource->host().c_str());
- if (OC_STACK_OK == result)
- {
- string resourceURI = resource->host();
- string hostAddress = resource->uri();
- logMessage = "FoundHost: " + resource->host() + "<br>";
- logMessage += "FoundUri: " + resource->uri()
- + " Registered <br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, "Host: %s", resourceURI.c_str());
- dlog_print(DLOG_INFO, LOG_TAG, "Uri : %s", hostAddress.c_str());
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog,
- &logMessage);
-
- if (resource->uri() == CONFIGURATION_RESOURCE_URI &&
- NULL != configurationCollectionHandle)
- {
- OCPlatform::bindResource(configurationCollectionHandle,
- foundResourceHandle);
- configurationFoundHandle = foundResourceHandle;
- if (NULL == g_configurationResource)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "g_configurationResource updated");
- g_configurationResource = resource;
- }
- else
- {
- dlog_print(DLOG_INFO, LOG_TAG,
- "g_configurationResource is not null");
- }
- }
- else if (resource->uri() == MAINTENANCE_RESOURCE_URI &&
- NULL != maintenanceCollectionHandle)
- {
- OCPlatform::bindResource(maintenanceCollectionHandle,
- foundResourceHandle);
- maintenanceFoundHandle = foundResourceHandle;
- if (NULL == g_maintenanceResource)
- {
- dlog_print(DLOG_INFO, LOG_TAG,
- "g_maintenanceResource updated");
- g_maintenanceResource = resource;
- }
- else
- {
- dlog_print(DLOG_INFO, LOG_TAG,
- "g_maintenanceResource is not null");
- }
- }
- else if (resource->uri() == FACTORYSET_RESOURCE_URI &&
- NULL != setCollectionHandle)
- {
- OCPlatform::bindResource(setCollectionHandle, foundResourceHandle);
- setFoundHandle = foundResourceHandle;
- if (NULL == g_setResource)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "g_setResource updated");
- g_setResource = resource;
- }
- else
- {
- dlog_print(DLOG_INFO, LOG_TAG, "g_setResource is not null");
- }
- }
- configResourceHandleVector.push_back(foundResourceHandle);
- }
- else
- {
- logMessage = "Resource Error!";
- dlog_print(DLOG_INFO, LOG_TAG, "Resource Error!");
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog,
- &logMessage);
- }
- }
- }
- else
- {
- // Resource is invalid
- logMessage = "Resource is invalid!";
- dlog_print(DLOG_INFO, LOG_TAG, "Resource is invalid!");
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog,
- &logMessage);
- }
- }
- }
- catch (std::exception &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception occured! (%s)", e.what());
- }
-
- isWaiting = 0;
- dlog_print(DLOG_INFO, LOG_TAG, "#### onFoundCandidateCollection EXIT!!!!");
-}
-
-// Callback to updateConfiguration
-static void onUpdateConfigurationsCallback(const HeaderOptions &headerOptions,
- const OCRepresentation &rep,
- const int eCode)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### onUpdateConfigurationsCallback: ENTRY!!!!");
- isWaiting = 0;
-
- if (SUCCESS_RESPONSE != eCode)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "#### onUpdateConfigurationsCallback: "
- "ERROR RESPONSE!!!!");
- return;
- }
-
- string logMessage = "Resource URI: " + rep.getUri() + "<br>";
- dlog_print(DLOG_INFO, LOG_TAG, "#### Resource URI: %s", rep.getUri().c_str());
-
- if (rep.hasAttribute(DEFAULT_DEVICENAME))
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Device Name : %s",
- rep.getValue< std::string >(DEFAULT_DEVICENAME).c_str());
- logMessage = logMessage + "Device Name : " +
- rep.getValue< std::string >(DEFAULT_DEVICENAME) + "<br>";
- }
- if (rep.hasAttribute(DEFAULT_LOCATION))
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Location : %s",
- rep.getValue< std::string >(DEFAULT_LOCATION).c_str());
- logMessage = logMessage + "Location : " +
- rep.getValue< std::string >(DEFAULT_LOCATION) + "<br>";
- }
- if (rep.hasAttribute(DEFAULT_LOCATIONNAME))
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Location Name : %s",
- rep.getValue< std::string >(DEFAULT_LOCATIONNAME).c_str());
- logMessage = logMessage + "Location Name: " +
- rep.getValue< std::string >(DEFAULT_LOCATIONNAME) + "<br>";
- }
- if (rep.hasAttribute(DEFAULT_CURRENCY))
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Currency : %s",
- rep.getValue< std::string >(DEFAULT_CURRENCY).c_str());
- logMessage = logMessage + "Currency : " +
- rep.getValue< std::string >(DEFAULT_CURRENCY) + "<br>";
- }
- if (rep.hasAttribute(DEFAULT_REGION))
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Region : %s",
- rep.getValue< std::string >(DEFAULT_REGION).c_str());
- logMessage = logMessage + "Region : " +
- rep.getValue< std::string >(DEFAULT_REGION) + "<br>";
- }
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog,
- &logMessage);
- dlog_print(DLOG_INFO, LOG_TAG, "#### onUpdateConfigurationsCallback: EXIT!!!!");
-}
-
-// Callback to getConfiguration
-static void onGetConfigurationsCallback(const HeaderOptions &headerOptions,
- const OCRepresentation &rep,
- const int eCode)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### onGetConfigurationsCallback: enter!!!!");
- isWaiting = 0;
-
- if (SUCCESS_RESPONSE != eCode)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "#### onGetConfigurationsCallback: "
- "ERROR RESPONSE!!!!");
- return ;
- }
-
- string logMessage = "Resource URI: " + rep.getUri() + "<br>";
- dlog_print(DLOG_INFO, LOG_TAG, "#### Resource URI: %s", rep.getUri().c_str());
-
- if (rep.hasAttribute(DEFAULT_DEVICENAME))
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Device Name : %s",
- rep.getValue< std::string >(DEFAULT_DEVICENAME).c_str());
- logMessage = logMessage + "Device Name : "
- + rep.getValue< std::string >(DEFAULT_DEVICENAME) + "<br>";
- }
- if (rep.hasAttribute(DEFAULT_LOCATION))
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Location : %s",
- rep.getValue< std::string >(DEFAULT_LOCATION).c_str());
- logMessage = logMessage + "Location : "
- + rep.getValue< std::string >(DEFAULT_LOCATION) + "<br>";
- }
- if (rep.hasAttribute(DEFAULT_LOCATIONNAME))
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Location Name : %s",
- rep.getValue< std::string >(DEFAULT_LOCATIONNAME).c_str());
- logMessage = logMessage + "Location Name : "
- + rep.getValue< std::string >(DEFAULT_LOCATIONNAME) + "<br>";
- }
- if (rep.hasAttribute(DEFAULT_CURRENCY))
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Currency : %s",
- rep.getValue< std::string >(DEFAULT_CURRENCY).c_str());
- logMessage = logMessage + "Currency : "
- + rep.getValue< std::string >(DEFAULT_CURRENCY) + "<br>";
- }
- if (rep.hasAttribute(DEFAULT_REGION))
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Region : %s",
- rep.getValue< std::string >(DEFAULT_REGION).c_str());
- logMessage = logMessage + "Region : "
- + rep.getValue< std::string >(DEFAULT_REGION) + "<br>";
- }
-
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog, &logMessage);
- dlog_print(DLOG_INFO, LOG_TAG, "#### onGetConfigurationsCallback: exit!!!!");
-}
-
-static void onFactoryReset(const HeaderOptions &headerOptions, const OCRepresentation &rep,
- const int eCode)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### onFactoryReset: enter!!!!");
- isWaiting = 0;
-
- if (SUCCESS_RESPONSE != eCode)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "#### onFactoryReset: ERROR RESPONSE!!!!");
- return ;
- }
-
- dlog_print(DLOG_INFO, LOG_TAG, "#### Resource URI: %s", rep.getUri().c_str());
- dlog_print(DLOG_INFO, LOG_TAG, "#### FactoryReset : %s",
- rep.getValue< std::string >("value").c_str());
- string logMessage = "Resource URI : " + rep.getUri() + "<br>";
- logMessage = logMessage + "FactoryReset : " +
- rep.getValue< std::string >("value") + "<br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog, &logMessage);
- dlog_print(DLOG_INFO, LOG_TAG, "#### onFactoryReset: exit!!!!");
-}
-
-static void onReboot(const HeaderOptions &headerOptions, const OCRepresentation &rep,
- const int eCode)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### onReboot: enter!!!!");
- isWaiting = 0;
-
- if (SUCCESS_RESPONSE != eCode)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "#### onReboot: ERROR RESPONSE!!!!");
- return ;
- }
-
- dlog_print(DLOG_INFO, LOG_TAG, "#### Resource URI: %s", rep.getUri().c_str());
- dlog_print(DLOG_INFO, LOG_TAG, "#### Reboot : %s",
- rep.getValue< std::string >("value").c_str());
- string logMessage = "Resource URI : " + rep.getUri() + "<br>";
- logMessage = logMessage + "Reboot : " +
- rep.getValue< std::string >("value") + "<br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog, &logMessage);
- dlog_print(DLOG_INFO, LOG_TAG, "#### onReboot: exit!!!!");
-}
-
-static void createResourceCollection(string uri, string typeName, OCResourceHandle &tempHandle)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### createResourceCollection: enter!!!!");
- if (NULL != tempHandle)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Resource already exists!!!!");
- return;
- }
-
- // Create resource collection
- OCPlatform::registerResource(tempHandle, uri, typeName, BATCH_INTERFACE, NULL,
- OC_DISCOVERABLE);
- OCPlatform::bindInterfaceToResource(tempHandle, GROUP_INTERFACE);
- OCPlatform::bindInterfaceToResource(tempHandle, DEFAULT_INTERFACE);
-
- dlog_print(DLOG_INFO, LOG_TAG, "#### Resource created : %s", typeName.c_str());
- string logMessage;
- logMessage = "Resource created : <br>" + typeName + "<br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog, &logMessage);
- dlog_print(DLOG_INFO, LOG_TAG, "#### createResourceCollection: exit!!!!");
-}
-
-// Unbinds and unregisters all resources
-static void deleteResource(OCResourceHandle &tempCollectionHandle,
- OCResourceHandle &tempResourceHandle)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### calling deleteResources ENTRY!!!!");
-
- if (NULL == tempCollectionHandle || NULL == tempResourceHandle)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Collection or resource does not exists");
- return;
- }
-
- try
- {
- OCPlatform::unbindResource(tempCollectionHandle, tempResourceHandle);
- dlog_print(DLOG_INFO, LOG_TAG, "#### unbindResource DONE!!!!");
- }
- catch (std::exception &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception Occured! (%s)", e.what());
- }
-
- try
- {
- OCPlatform::unregisterResource(tempResourceHandle);
- dlog_print(DLOG_INFO, LOG_TAG, "#### unregisterResource DONE!!!!");
- }
- catch (std::exception &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception Occured! (%s)", e.what());
- }
-
- dlog_print(DLOG_INFO, LOG_TAG, "#### calling deleteResources EXIT!!!!");
-}
-
-static void findAllGroups(void *data, Evas_Object *obj, void *event_info)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### calling findCandidateResources ENTRY!!!!");
- std::vector<string> resourceTypes;
- resourceTypes.push_back(CONFIGURATION_COLLECTION_RESOURCE_TYPE);
-
- if (NULL != g_groupManager)
- {
- g_groupManager->findCandidateResources(resourceTypes, &onFoundCollectionResource,
- FINDGROUP_TIMEOUT);
- }
-
- resourceTypes.clear();
- resourceTypes.push_back(MAINTENANCE_COLLECTION_RESOURCE_TYPE);
- if (NULL != g_groupManager)
- {
- g_groupManager->findCandidateResources(resourceTypes, &onFoundCollectionResource,
- FINDGROUP_TIMEOUT);
- }
-
- resourceTypes.clear();
- resourceTypes.push_back(FACTORYSET_COLLECTION_RESOURCE_TYPE);
- if (NULL != g_groupManager)
- {
- g_groupManager->findCandidateResources(resourceTypes, &onFoundCollectionResource,
- FINDGROUP_TIMEOUT);
- }
-
- dlog_print(DLOG_INFO, LOG_TAG, "#### calling findCandidateResources EXIT!!!!");
-}
-
-static void findAllResources(void *data, Evas_Object *obj, void *event_info)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### calling findCandidateResources ENTRY!!!!");
- std::vector<string> resourceTypes;
- resourceTypes.push_back("oic.wk.con");
- resourceTypes.push_back("oic.wk.mnt");
- resourceTypes.push_back("factoryset");
-
- if (NULL != g_groupManager)
- {
- g_groupManager->findCandidateResources(resourceTypes, &onFoundCandidateResource,
- FINDRESOURCE_TIMEOUT);
- }
-
- dlog_print(DLOG_INFO, LOG_TAG, "#### calling findCandidateResources EXIT!!!!");
-}
-
-static void getConfiguration(void *data, Evas_Object *obj, void *event_info)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### getConfiguration ENTRY!!!!");
- if (NULL == g_configurationCollection || NULL == g_configurationCollection.get())
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Note that you first create a group to use this command");
- string logMessage = "FIRST CREATE GROUP <br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog, &logMessage);
- return;
- }
-
- if (NULL == g_configurationResource)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "Configuration Resource not found.");
- string logMessage = "FIRST FIND CONFIGURATION RESOURCE <br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog, &logMessage);
- return;
- }
-
- ConfigurationName name = "all";
- std::vector< ConfigurationName > configurations;
- configurations.push_back(name);
-
- try
- {
- g_thingsConfig->getConfigurations(g_configurationCollection, configurations,
- &onGetConfigurationsCallback);
-
- isWaiting = 0;
- }
- catch (std::exception &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception is occured! (%s)", e.what());
- }
-
- isWaiting = 1;
- dlog_print(DLOG_INFO, LOG_TAG, "#### getConfiguration EXIT!!!!");
-}
-
-// Updates the configuration i.e. Device name to OIC Device
-static void updateConfiguration(std::string newDeviceName)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### updateConfiguration ENTRY!!!!");
- dlog_print(DLOG_INFO, LOG_TAG, "#### %s", newDeviceName.c_str());
-
- if (NULL == g_configurationCollection || NULL == g_configurationCollection.get())
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Note that you first create a group to use this command");
- string logMessage = "FIRST CREATE GROUP <br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog, &logMessage);
- return;
- }
-
- if (NULL == g_configurationResource)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "Configuration Resource not found.");
- string logMessage = "FIRST FIND CONFIGURATION RESOURCE <br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog, &logMessage);
- return;
- }
-
- OCStackResult result;
- ConfigurationName name = DEFAULT_DEVICENAME;
- ConfigurationValue value = newDeviceName;
-
- std::map< ConfigurationName, ConfigurationValue > configurations;
- configurations.insert(std::make_pair(name, value));
-
- try
- {
- result = g_thingsConfig->updateConfigurations(g_configurationCollection, configurations,
- &onUpdateConfigurationsCallback);
- }
- catch (std::exception &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception is occured! (%s)", e.what());
- }
-
- if (OC_STACK_OK == result)
- {
- string logMessage = "UpdateConfigurations called successfully<br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog, &logMessage);
- }
-
- dlog_print(DLOG_INFO, LOG_TAG, "#### updateConfiguration EXIT!!!!");
-}
-
-// This method will reset all the configuration attributes to their default values
-static void factoryReset(void *data, Evas_Object *obj, void *event_info)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### factoryReset ENTRY!!!!");
- if (NULL == g_maintenanceCollection || NULL == g_maintenanceCollection.get())
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Note that you first create a group to use this command");
- string logMessage = "FIRST CREATE GROUP <br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog, &logMessage);
- return;
- }
-
- if (NULL == g_maintenanceResource)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "Maintenance Resource not found.");
- string logMessage = "FIRST FIND MAINTENANCE RESOURCE <br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog, &logMessage);
- return;
- }
-
- OCStackResult result;
-
- try
- {
- result = g_thingsMnt->factoryReset(g_maintenanceCollection, &onFactoryReset);
- }
- catch (std::exception &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception is occured! (%s)", e.what());
- }
-
- if (OC_STACK_OK == result)
- {
- string logMessage = "FactoryReset called successfully<br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog, &logMessage);
- }
-
- dlog_print(DLOG_INFO, LOG_TAG, "#### factoryReset EXIT!!!!");
-}
-
-// Reboots the server
-static void reboot(void *data, Evas_Object *obj, void *event_info)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### reboot ENTRY!!!!");
- if (NULL == g_maintenanceCollection || NULL == g_maintenanceCollection.get())
- {
- dlog_print(DLOG_INFO, LOG_TAG, "Note that you first create a group to use this command");
- string logMessage = "FIRST CREATE GROUP <br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog, &logMessage);
- return;
- }
-
- if (NULL == g_maintenanceResource)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "Maintenance Resource not found.");
- string logMessage = "FIRST FIND MAINTENANCE RESOURCE <br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog, &logMessage);
- return;
- }
-
- OCStackResult result;
-
- try
- {
- result = g_thingsMnt->reboot(g_maintenanceCollection, &onReboot);
- }
- catch (std::exception &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception is occured! (%s)", e.what());
- }
-
- if (OC_STACK_OK == result)
- {
- string logMessage = "Reboot called successfully<br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog, &logMessage);
- }
- dlog_print(DLOG_INFO, LOG_TAG, "#### reboot EXIT!!!!");
-}
-
-/* For getting list of all supported configuration Values it will give all
- configuration in JSON format (key-value pair) */
-static void getListOfSupportedConfigurationUnits(void *data, Evas_Object *obj, void *event_info)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### getListOfSupportedConfigurationUnits ENTRY!!!!");
- string listOfSupportedConfigurationUnits =
- g_thingsConfig->getListOfSupportedConfigurationUnits();
- dlog_print(DLOG_INFO, LOG_TAG, "#### List : %s", listOfSupportedConfigurationUnits.c_str());
-
- string logMessage;
- logMessage = "Supported Configuration List :<br>" + listOfSupportedConfigurationUnits + "<br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog, &logMessage);
- dlog_print(DLOG_INFO, LOG_TAG, "#### getListOfSupportedConfigurationUnits EXIT!!!!");
-}
-
-// Creates all the resources
-static void onStartConfigure()
-{
- createResourceCollection(CONFIGURATION_COLLECTION_RESOURCE_URI,
- CONFIGURATION_COLLECTION_RESOURCE_TYPE,
- configurationCollectionHandle);
- createResourceCollection(MAINTENANCE_COLLECTION_RESOURCE_URI,
- MAINTENANCE_COLLECTION_RESOURCE_TYPE,
- maintenanceCollectionHandle);
- createResourceCollection(FACTORYSET_COLLECTION_RESOURCE_URI,
- FACTORYSET_COLLECTION_RESOURCE_TYPE,
- setCollectionHandle);
-
- g_groupManager = new GroupManager();
- g_thingsConfig = new ThingsConfiguration();
- g_thingsMnt = new ThingsMaintenance();
-}
-
-// Deletes all the resources
-static void onDestroyConfigure()
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### Destroy sequence called");
-
- deleteResource(setCollectionHandle, setFoundHandle);
-
- deleteResource(maintenanceCollectionHandle, maintenanceFoundHandle);
-
- deleteResource(configurationCollectionHandle, configurationFoundHandle);
-
- delete g_thingsMnt;
- delete g_thingsConfig;
- delete g_groupManager;
-
- dlog_print(DLOG_INFO, LOG_TAG, "#### Resources destroyed successfully");
-}
-
-static void
-popup_cancel_clicked_cb(void *data, Evas_Object *obj, void *event_info)
-{
- region_popup_fields *popup_fields = (region_popup_fields *)data;
- evas_object_del(popup_fields->popup);
- free(popup_fields);
-}
-
-static void
-popup_set_clicked_cb(void *data, Evas_Object *obj, void *event_info)
-{
- region_popup_fields *popup_fields = (region_popup_fields *)data;
- Evas_Object *entry = popup_fields->entry;
- const char *newRegionValue = elm_entry_entry_get(entry);
- if (NULL == newRegionValue || strlen(newRegionValue) < 1)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Read NULL RegionValue");
- string logMessage = "Region Value should not be NULL<br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog, &logMessage);
- }
- else
- {
- std::string regionValue = std::string(newRegionValue);
- updateConfiguration(regionValue);
- }
- evas_object_del(popup_fields->popup);
- free(popup_fields);
-}
-
-static void
-list_update_devicename_cb(void *data, Evas_Object *obj, void *event_info)
-{
- if (NULL == g_configurationCollection || NULL == g_configurationCollection.get())
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Note that you first create a group to use this command");
- string logMessage = "FIRST CREATE GROUP <br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateConfigLog, &logMessage);
- return;
- }
-
- Evas_Object *popup, *btn;
- Evas_Object *nf = (Evas_Object *)data;
- Evas_Object *entry;
- Evas_Object *layout;
-
- /* popup */
- popup = elm_popup_add(nf);
- elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
- eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
- evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_object_part_text_set(popup, "title,text", "Enter new device name to update");
-
- layout = elm_layout_add(popup);
- elm_layout_file_set(layout, ELM_DEMO_EDJ, "popup_region_text");
- evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_object_content_set(popup, layout);
-
- entry = elm_entry_add(layout);
- elm_entry_single_line_set(entry, EINA_TRUE);
- elm_entry_scrollable_set(entry, EINA_TRUE);
- evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
- eext_entry_selection_back_event_allow_set(entry, EINA_TRUE);
- elm_object_part_text_set(entry, "elm.guide", "e.g. OIC Device");
- elm_object_part_content_set(layout, "elm.swallow.content" , entry);
-
- region_popup_fields *popup_fields;
- popup_fields = (region_popup_fields *)malloc(sizeof(region_popup_fields));
- if (NULL == popup_fields)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Memory allocation failed");
- }
- else
- {
- popup_fields->popup = popup;
- popup_fields->entry = entry;
- }
-
- /* Cancel button */
- btn = elm_button_add(popup);
- elm_object_style_set(btn, "popup");
- elm_object_text_set(btn, "Cancel");
- elm_object_part_content_set(popup, "button1", btn);
- evas_object_smart_callback_add(btn, "clicked", popup_cancel_clicked_cb, popup_fields);
-
- /* Set button */
- btn = elm_button_add(popup);
- elm_object_style_set(btn, "popup");
- elm_object_text_set(btn, "Set");
- elm_object_part_content_set(popup, "button2", btn);
- evas_object_smart_callback_add(btn, "clicked", popup_set_clicked_cb, popup_fields);
-
- evas_object_show(popup);
-}
-
-static void
-list_selected_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Elm_Object_Item *it = (Elm_Object_Item *)event_info;
- elm_list_item_selected_set(it, EINA_FALSE);
-}
-
-void
-test_fn(void *data, Evas_Object *obj, void *event_info)
-{
- if (NULL != log_entry)
- {
- elm_entry_entry_append(log_entry, "First item selected");
- elm_entry_cursor_end_set(log_entry);
- }
- else
- {
- dlog_print(DLOG_ERROR, "test_fn", "log_entry object is NULL");
- }
-}
-
-static Eina_Bool
-naviframe_pop_cb(void *data, Elm_Object_Item *it)
-{
- onDestroyConfigure();
- resourceTable.clear();
- if (NULL != log_entry)
- {
- evas_object_del(log_entry);
- log_entry = NULL;
- }
- return EINA_TRUE;
-}
-
-// Method to be called when configuration API UI button is selected
-void
-configuration_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Evas_Object *layout;
- Evas_Object *scroller;
- Evas_Object *list;
- Evas_Object *nf = (Evas_Object *)data;
- Elm_Object_Item *nf_it;
-
- // Scroller
- scroller = elm_scroller_add(nf);
- elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE);
- elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
-
- // Layout
- layout = elm_layout_add(nf);
- elm_layout_file_set(layout, ELM_DEMO_EDJ, "configuration_layout");
- evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
- elm_object_content_set(scroller, layout);
-
- // List
- list = elm_list_add(layout);
- elm_list_mode_set(list, ELM_LIST_COMPRESS);
- evas_object_smart_callback_add(list, "selected", list_selected_cb, NULL);
- elm_object_part_content_set(layout, "list", list);
- elm_list_go(list);
-
- // log_entry - text area for log
- log_entry = elm_entry_add(layout);
- elm_entry_scrollable_set(log_entry, EINA_TRUE);
- elm_entry_editable_set(log_entry, EINA_FALSE);
- elm_object_part_text_set(log_entry, "elm.guide", "logs will be updated here!!!");
- evas_object_size_hint_weight_set(log_entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(log_entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_object_part_content_set(layout, "log", log_entry);
-
- nf_it = elm_naviframe_item_push(nf, "configuration APIs", NULL, NULL, scroller, NULL);
- elm_naviframe_item_pop_cb_set(nf_it, naviframe_pop_cb, NULL);
-
- onStartConfigure();
-
- // Shows the UI list of group APIs
- elm_list_item_append(list, "Find All Groups", NULL, NULL, findAllGroups, NULL);
- elm_list_item_append(list, "Find All Resources",
- NULL, NULL, findAllResources, NULL);
- elm_list_item_append(list, "Get a Configuration Resource", NULL, NULL, getConfiguration, NULL);
- elm_list_item_append(list, "Update Attribute (Device Name)", NULL, NULL,
- list_update_devicename_cb, nf);
- elm_list_item_append(list, "Factory Reset", NULL, NULL, factoryReset, NULL);
- elm_list_item_append(list, "Reboot", NULL, NULL, reboot, NULL);
- elm_list_item_append(list, "Get Supported Configuration Units", NULL, NULL,
- getListOfSupportedConfigurationUnits, NULL);
-
- elm_list_go(list);
-}
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include <algorithm>
-
-#include "tmsampleapp.h"
-#include "tmutil.h"
-
-using namespace std;
-using namespace OC;
-using namespace OIC;
-
-namespace PH = std::placeholders;
-
-static Evas_Object *log_entry = NULL;
-static Evas_Object *list = NULL;
-static Evas_Object *naviframe = NULL;
-
-string BULBOFF = "AllBulbOff";
-string BULBON = "AllBulbOn";
-string resourceURI = "/core/b/collection";
-string resourceTypeName = "b.collection";
-
-std::vector< OCResourceHandle > groupResourceHandleVector;
-OCResourceHandle resourceHandle = NULL;
-OCResourceHandle foundResourceHandle = NULL;
-shared_ptr< OCResource > g_resource ;
-std::vector< string > lights;
-
-GroupManager *groupMgr = NULL;
-
-typedef struct datetime_popup
-{
- Evas_Object *popup;
- Evas_Object *entry;
-} datetime_popup_fields;
-
-// Function to update the log in UI
-void *updateGroupLog(void *data)
-{
- string *log = (string *)data;
- // Show the log
- elm_entry_entry_append(log_entry, (*log).c_str());
- elm_entry_cursor_end_set(log_entry);
- return NULL;
-}
-
-void onPut(const HeaderOptions &headerOptions, const OCRepresentation &rep, const int eCode)
-{
- string logMessage;
- dlog_print(DLOG_INFO, LOG_TAG, "#### onPut Callback Received!!!!");
- logMessage += "API Result: Success<br>onPut Callback Received<br>";
- if (OC_STACK_OK == eCode)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Result is OK");
- }
- else
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Invalid Parameter");
- }
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog,
- &logMessage);
-}
-
-void onPost(const HeaderOptions &headerOptions, const OCRepresentation &rep, const int eCode)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### onPost callback received ENTRY!!!!");
- string logMessage;
- logMessage += "API Result: Success<br>onPost Callback Received<br>";
-
- if (rep.hasAttribute("ActionSet"))
- {
- string plainText;
- if (rep.getValue("ActionSet", plainText))
- {
- ActionSet *actionset = groupMgr->getActionSetfromString(plainText);
- if (NULL != actionset)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### ACTIONSET NAME :: (%s)",
- actionset->actionsetName.c_str());
- logMessage += "ACTIONSET NAME :: " + actionset->actionsetName + "<br>";
- for (auto actIter = actionset->listOfAction.begin();
- actIter != actionset->listOfAction.end(); ++actIter)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### TARGET :: (%s)",
- (*actIter)->target.c_str());
- logMessage += logMessage + "TARGET :: " + (*actIter)->target + "<br>";
- for (auto capaIter = (*actIter)->listOfCapability.begin();
- capaIter != (*actIter)->listOfCapability.end(); ++capaIter)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### POWER :: (%s)",
- (*capaIter)->status.c_str());
- logMessage += logMessage + "CAPABILITY :: " +
- (*capaIter)->status + "<br>";
- }
- }
- }
- delete actionset;
- }
- }
- else if (rep.hasAttribute("DoAction"))
- {
- string plainText;
- if (rep.getValue("DoAction", plainText))
- {
- logMessage += plainText + "<br>";
- dlog_print(DLOG_INFO, LOG_TAG, "#### DO ACTION :: (%s)", plainText.c_str());
-
- }
- }
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog,
- &logMessage);
- dlog_print(DLOG_INFO, LOG_TAG, "#### onPost callback received EXIT!!!!");
-}
-
-// Method for Creating the action Set AllBulbOff
-static void createActionSet_AllBulbOff()
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### createActionSet_AllBulbOff ENTRY");
-
- OIC::ActionSet *actionSet = new OIC::ActionSet();
- actionSet->actionsetName = BULBOFF;
- int size = lights.size();
-
- if (0 == size)
- {
- string logMessage = "NO LIGHTSERVER FOUND <br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, "#### NO LIGHT SERVER FOUND");
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog,
- &logMessage);
- delete actionSet;
- return;
- }
-
- for (int i = 0; i < size; i++)
- {
- OIC::Action *action = new OIC::Action();
- action->target = lights.at(i);
-
- OIC::Capability *capability = new OIC::Capability();
- capability->capability = "power";
- capability->status = "off";
-
- action->listOfCapability.push_back(capability);
- actionSet->listOfAction.push_back(action);
- }
- dlog_print(DLOG_INFO, LOG_TAG, "#### G_URI: %s", g_resource->uri().c_str());
- dlog_print(DLOG_INFO, LOG_TAG, "#### G_HOST: %S", g_resource->host().c_str());
-
- try
- {
- if (g_resource)
- {
- groupMgr->addActionSet(g_resource, actionSet, onPut);
- }
- }
- catch (std::exception &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception occured! (%s)", e.what());
- }
- delete actionSet;
-
- string logMessage = "Create actionset AllBulbOFF success <br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog, &logMessage);
- dlog_print(DLOG_INFO, LOG_TAG, "#### createActionSet_AllBulbOff EXIT");
-}
-
-/* Method for Creating the action Set AllBulbOn
- once we create the ActionSet we can execute Action Set using executeActionSetOn()
- or delete using deleteActionSetOn() */
-static void createActionSet_AllBulbOn()
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### createActionSet_AllBulbOn ENTRY");
-
- OIC::ActionSet *actionSet = new OIC::ActionSet();
- actionSet->actionsetName = BULBON;
- int size = lights.size();
-
- if (0 == size)
- {
- string logMessage = "NO LIGHTSERVER FOUND <br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, "#### NO LIGHT SERVER FOUND");
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog, &logMessage);
- delete actionSet;
- return;
- }
-
- for (int i = 0; i < size; i++)
- {
- OIC::Action *action = new OIC::Action();
- action->target = lights.at(i);
-
- OIC::Capability *capability = new OIC::Capability();
- capability->capability = "power";
- capability->status = "on";
-
- action->listOfCapability.push_back(capability);
- actionSet->listOfAction.push_back(action);
- }
- string URI = g_resource->uri();
- string host = g_resource->host();
- dlog_print(DLOG_INFO, LOG_TAG, "#### G_URI: %s", g_resource->uri().c_str());
- dlog_print(DLOG_INFO, LOG_TAG, "#### G_HOST: %S", g_resource->host().c_str());
-
- try
- {
- if (g_resource)
- {
- groupMgr->addActionSet(g_resource, actionSet, onPut);
- }
- }
- catch (std::exception &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception occured! (%s)", e.what());
- }
- delete actionSet;
-
- string logMessage = "Create actionset AllBulbON success <br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog, &logMessage);
- dlog_print(DLOG_INFO, LOG_TAG, "#### createActionSet_AllBulbOff OFF EXIT");
-}
-
-static void createRecursiveActionSet_AllBulbOn(void *data, Evas_Object *obj, void *event_info)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### createRecursiveActionSet_AllBulbOn ENTRY");
- string actionsetDesc;
- ActionSet *allBulbOn = new ActionSet();
- allBulbOn->type = OIC::ACTIONSET_TYPE::RECURSIVE;
-
- allBulbOn->actionsetName = "AllBulbOnRecursiveCall";
- allBulbOn->mTime.tm_year = 0;
- allBulbOn->mTime.tm_mon = 0;
- allBulbOn->mTime.tm_mday = 0;
- allBulbOn->mTime.tm_hour = 0;
- allBulbOn->mTime.tm_min = 0;
- allBulbOn->mTime.tm_sec = 5;
-
- allBulbOn->setDelay(allBulbOn->getSecAbsTime());
-
- for (auto iter = lights.begin(); iter != lights.end(); ++iter)
- {
- Action *action = new Action();
- action->target = (*iter);
-
- Capability *capa = new Capability();
- capa->capability = "power";
- capa->status = "on";
-
- action->listOfCapability.push_back(capa);
- allBulbOn->listOfAction.push_back(action);
- }
- if (g_resource)
- {
- groupMgr->addActionSet(g_resource, allBulbOn, onPut);
- }
-
- delete allBulbOn;
- dlog_print(DLOG_INFO, LOG_TAG, "#### createRecursiveActionSet_AllBulbOn EXIT");
-}
-
-static void createScheduledActionSet_AllBulbOff(int date, int month, int year,
- int hour, int minute, int second)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### createScheduledActionSet_AllBulbOff ENTRY");
- string actionsetDesc;
- ActionSet *allBulbOff = new ActionSet();
- allBulbOff->type = OIC::ACTIONSET_TYPE::SCHEDULED;
- allBulbOff->actionsetName = "AllBulbOffScheduledCall";
- allBulbOff->mTime.tm_year = year;
- allBulbOff->mTime.tm_mon = month;
- allBulbOff->mTime.tm_mday = date;
- allBulbOff->mTime.tm_hour = hour;
- allBulbOff->mTime.tm_min = minute;
- allBulbOff->mTime.tm_sec = second;
- dlog_print(DLOG_INFO, LOG_TAG, "#### allBulbOff->mTime.tm_year :: %ld",
- allBulbOff->mTime.tm_year);
- dlog_print(DLOG_INFO, LOG_TAG, "#### allBulbOff->mTime.tm_mon :: %ld",
- allBulbOff->mTime.tm_mon);
- dlog_print(DLOG_INFO, LOG_TAG, "#### allBulbOff->mTime.tm_mday :: %ld",
- allBulbOff->mTime.tm_mday);
- dlog_print(DLOG_INFO, LOG_TAG, "#### allBulbOff->mTime.tm_hour :: %ld",
- allBulbOff->mTime.tm_hour);
- dlog_print(DLOG_INFO, LOG_TAG, "#### allBulbOff->mTime.tm_min :: %ld",
- allBulbOff->mTime.tm_min);
- dlog_print(DLOG_INFO, LOG_TAG, "#### allBulbOff->mTime.tm_sec :: %ld",
- allBulbOff->mTime.tm_sec);
-
- allBulbOff->setDelay(allBulbOff->getSecondsFromAbsoluteTime());
-
- for (auto iter = lights.begin(); iter != lights.end(); ++iter)
- {
- Action *action = new Action();
- action->target = (*iter);
-
- Capability *capa = new Capability();
- capa->capability = "power";
- capa->status = "off";
-
- action->listOfCapability.push_back(capa);
- allBulbOff->listOfAction.push_back(action);
- }
- if (g_resource)
- {
- groupMgr->addActionSet(g_resource, allBulbOff, onPut);
- }
-
- delete allBulbOff;
- dlog_print(DLOG_INFO, LOG_TAG, "#### createScheduledActionSet_AllBulbOff EXIT");
-}
-
-static void scheduled_AllbulbOff(void *data, Evas_Object *obj, void *event_info)
-{
- groupMgr->executeActionSet(g_resource, "AllBulbOffScheduledCall", &onPost);
-}
-
-static void scheduled_AllbulbOffEx(void *data, Evas_Object *obj, void *event_info)
-{
- groupMgr->executeActionSet(g_resource, "AllBulbOffScheduledCall", 10, &onPost);
-}
-
-static void cancelScheduled_AllBulbOff(void *data, Evas_Object *obj, void *event_info)
-{
- groupMgr->cancelActionSet(g_resource, "AllBulbOffScheduledCall", &onPost);
-}
-
-static void recursive_allBulbOn(void *data, Evas_Object *obj, void *event_info)
-{
- groupMgr->executeActionSet(g_resource, "AllBulbOnRecursiveCall", &onPost);
-}
-
-static void recursive_allBulbOnEx(void *data, Evas_Object *obj, void *event_info)
-{
- groupMgr->executeActionSet(g_resource, "AllBulbOnRecursiveCall", 10, &onPost);
-}
-
-static void cancelRecursive_allBulbOn(void *data, Evas_Object *obj, void *event_info)
-{
-
- groupMgr->cancelActionSet(g_resource, "AllBulbOnRecursiveCall", &onPost);
-}
-
-/* Method for executing the action Set AllBulbOff that we have created using
- createActionSet_AllBulbOff() */
-static void executeActionSetOff(void *data, Evas_Object *obj, void *event_info)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### executeActionSetOff ENTRY");
- int size = lights.size();
-
- if (0 == size)
- {
- string logMessage = "NO LIGHTSERVER FOUND <br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, "#### NO LIGHT SERVER FOUND");
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog, &logMessage);
- return;
- }
-
- try
- {
- if (g_resource)
- {
- groupMgr->executeActionSet(g_resource, BULBOFF, &onPost);
- }
- }
- catch (std::exception &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception occured! (%s)", e.what());
- }
-
- string logMessage = "Actionset OFF called successfully <br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog, &logMessage);
- dlog_print(DLOG_INFO, LOG_TAG, "#### executeActionSetOff EXIT");
-}
-
-/* Method for executing the action Set AllBulbOn that we have created using
- createActionSet_AllBulbOn() */
-static void executeActionSetOn(void *data, Evas_Object *obj, void *event_info)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### executeActionSetOn ENTRY");
- int size = lights.size();
-
- if (0 == size)
- {
- string logMessage = "NO LIGHTSERVER FOUND <br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, "#### NO LIGHT SERVER FOUND");
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog, &logMessage);
- return;
- }
-
- try
- {
- if (g_resource)
- {
- groupMgr->executeActionSet(g_resource, BULBON, &onPost);
- }
- }
- catch (std::exception &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception occured! (%s)", e.what());
- }
-
- string logMessage = "Actionset ON called successfully <br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog, &logMessage);
- dlog_print(DLOG_INFO, LOG_TAG, "#### executeActionSetOn EXIT");
-}
-
-/* Method for getting the action Set AllBulbOff that we have created using
- createActionSet_AllBulbOff() */
-static void getActionSetOff(void *data, Evas_Object *obj, void *event_info)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### getActionSetOff ENTRY");
- int size = lights.size();
-
- if (0 == size)
- {
- string logMessage = "NO LIGHTSERVER FOUND <br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, "#### NO LIGHT SERVER FOUND");
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog, &logMessage);
- return;
- }
-
- try
- {
- if (g_resource)
- {
- groupMgr->getActionSet(g_resource, BULBOFF, &onPost);
- }
- }
- catch (std::exception &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception occured! (%s)", e.what());
- }
-
- dlog_print(DLOG_INFO, LOG_TAG, "#### getActionSetOff EXIT");
-}
-
-/* Method for getting the action Set AllBulbOn that we have created using
- createActionSet_AllBulbOn() */
-static void getActionSetOn(void *data, Evas_Object *obj, void *event_info)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### getActionSetOn ENTRY");
- int size = lights.size();
-
- if (0 == size)
- {
- string logMessage = "NO LIGHTSERVER FOUND <br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, "#### NO LIGHT SERVER FOUND");
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog, &logMessage);
- return;
- }
-
- try
- {
- if (g_resource)
- {
- groupMgr->getActionSet(g_resource, BULBON, &onPost);
- }
- }
- catch (std::exception &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception occured! (%s)", e.what());
- }
-
- dlog_print(DLOG_INFO, LOG_TAG, "#### getActionSetOn EXIT");
-}
-
-/* Method for deleting the action Set AllBulbOff that we have created using
- createActionSet_AllBulbOff() */
-static void deleteActionSetOff(void *data, Evas_Object *obj, void *event_info)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### deleteActionSetOff ENTRY");
- int size = lights.size();
-
- if (0 == size)
- {
- string logMessage = "NO LIGHTSERVER FOUND <br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, "#### NO LIGHT SERVER FOUND");
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog, &logMessage);
- return;
- }
-
- try
- {
- if (g_resource)
- {
- groupMgr->deleteActionSet(g_resource, BULBOFF, &onPost);
- }
- }
- catch (std::exception &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception occured! (%s)", e.what());
- }
-
- string logMessage = "Actionset OFF DELETED <br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog, &logMessage);
- dlog_print(DLOG_INFO, LOG_TAG, "#### deleteActionSetOff EXIT");
-}
-
-/* Method for deleting the action Set AllBulbOn that we have created using
- createActionSet_AllBulbOn() */
-static void deleteActionSetOn(void *data, Evas_Object *obj, void *event_info)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### deleteActionSetOn ENTRY");
- int size = lights.size();
-
- if (0 == size)
- {
- string logMessage = "NO LIGHTSERVER FOUND <br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, "#### NO LIGHT SERVER FOUND");
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog, &logMessage);
- return;
- }
-
- try
- {
- if (g_resource)
- {
- groupMgr->deleteActionSet(g_resource, BULBON, &onPost);
- }
- }
- catch (std::exception &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception occured! (%s)", e.what());
- }
-
- string logMessage = "Actionset ON DELETED <br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog, &logMessage);
- dlog_print(DLOG_INFO, LOG_TAG, "#### deleteActionSetOn EXIT");
-}
-
-void onObserve(const HeaderOptions headerOptions, const OCRepresentation &rep, const int &eCode,
- const int &sequenceNumber)
-{
- string logMessage;
- char *buf;
- if (OC_STACK_OK == eCode)
- {
- int level;
- buf = (char *)malloc(4 * sizeof(char));
- if (NULL == buf)
- {
- dlog_print(DLOG_INFO, LOG_TAG, " buf malloc failed");
- return;
- }
- sprintf(buf, "%d", sequenceNumber);
- logMessage = "OBSERVE RESULT <br>";
- logMessage += "Sequencenumber:" + string(buf) + "<br>";
-
- if (rep.getValue("level", level))
- {
- if (level == 0)
- {
- createActionSet_AllBulbOn();
- executeActionSetOn(NULL, NULL, NULL);
- }
- else
- {
- createActionSet_AllBulbOff();
- executeActionSetOff(NULL, NULL, NULL);
- }
- }
- sprintf(buf, "%d", level);
- logMessage += "level:" + string(buf) + "<br>";
- free(buf);
- }
- else
- {
- logMessage = "onObserve error!!!";
- }
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog,
- &logMessage);
-}
-
-// Callback to be called when resources are found in the network
-void foundResources(std::vector< std::shared_ptr< OC::OCResource > > listOfResource)
-{
- try
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### foundResources entry!!!!");
-
- for (auto rsrc = listOfResource.begin(); rsrc != listOfResource.end(); ++rsrc)
- {
- string resourceURI = (*rsrc)->uri();
- string hostAddress = (*rsrc)->host();
-
- dlog_print(DLOG_INFO, LOG_TAG, "#### found uri: %s", resourceURI.c_str());
- dlog_print(DLOG_INFO, LOG_TAG, "#### found host address: %s", hostAddress.c_str());
- string logMessage = "URI: " + resourceURI + "<br>";
- logMessage = logMessage + "Host:" + hostAddress + "<br>";
- logMessage += "----------------------<br>";
-
- if (resourceURI == "/a/light")
- {
- bool found;
- found = std::find(lights.begin(), lights.end(),
- hostAddress + resourceURI) != lights.end();
- if (found == false)
- {
- lights.push_back((hostAddress + resourceURI));
-
- try
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Registering Resource");
- OCStackResult result = OCPlatform::registerResource(foundResourceHandle,
- (*rsrc));
- dlog_print(DLOG_INFO, LOG_TAG, "#### %s REGISTERED", resourceURI.c_str());
- if (result == OC_STACK_OK)
- {
- OCPlatform::bindResource(resourceHandle, foundResourceHandle);
- dlog_print(DLOG_INFO, LOG_TAG, "#### Bind Resource Done");
- groupResourceHandleVector.push_back(foundResourceHandle);
- }
- else
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "#### Register Resource ERROR");
- }
- }
- catch (std::exception &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception occured! (%s)", e.what());
- }
- }
- }
- else if (resourceURI == "/core/bookmark")
- {
- logMessage += "OBSERVING : " + resourceURI + "<br>";
- logMessage += "----------------------<br>";
- (*rsrc)->observe(ObserveType::Observe, QueryParamsMap(), &onObserve);
- dlog_print(DLOG_INFO, LOG_TAG, "#### after calling observe() for bookmark!!!!");
- }
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog,
- &logMessage);
- }
-
- dlog_print(DLOG_INFO, LOG_TAG, "#### foundResources exit!!!!");
- }
- catch (...)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Exception caught in foundResources");
- }
-}
-
-static void create_group()
-{
-
- groupMgr = new GroupManager();
-
- if (NULL != groupMgr)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### calling findCandidateResources from "
- "create_group!!!!");
- vector< string > types;
- types.push_back("core.light");
- groupMgr->findCandidateResources(types, &foundResources, FINDRESOURCE_TIMEOUT);
- }
-
- try
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### calling registerResource from create_group!!!!");
- OCPlatform::registerResource(resourceHandle, resourceURI, resourceTypeName,
- BATCH_INTERFACE, NULL,
- OC_DISCOVERABLE | OC_OBSERVABLE);
-
- if (NULL != resourceHandle)
- dlog_print(DLOG_INFO, LOG_TAG, "#### Obtained resourceHandle from "
- "registerResource!!!!");
-
- dlog_print(DLOG_INFO, LOG_TAG, "#### calling bindInterfaceToResource from "
- "create_group!!!!");
- OCPlatform::bindInterfaceToResource(resourceHandle, GROUP_INTERFACE);
- OCPlatform::bindInterfaceToResource(resourceHandle, DEFAULT_INTERFACE);
- }
- catch (std::exception &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception occured! (%s)", e.what());
- }
-}
-
-// Method for Finding the Light Resource
-void findLightResource(void *data, Evas_Object *obj, void *event_info)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### findLightResource ENTRY");
- if (NULL != groupMgr)
- {
- vector< string > types;
- types.push_back("core.light");
- OCStackResult result = groupMgr->findCandidateResources(types, &foundResources,
- FINDRESOURCE_TIMEOUT);
- if (result == OC_STACK_OK)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### create_group -- findCandidateResources :: "
- "OC_STACK_OK!!!!");
- }
- else
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### create_group - findCandidateResources failed!!");
- }
- }
- dlog_print(DLOG_INFO, LOG_TAG, "#### findLightResource EXIT");
-}
-
-// Method for observing the Bookmark Resource
-void observeBookMark(void *data, Evas_Object *obj, void *event_info)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### observeBookMark ENTRY");
- if (NULL != groupMgr)
- {
- vector< string > types;
- types.push_back("core.bookmark");
- OCStackResult result = groupMgr->findCandidateResources(types, &foundResources,
- FINDRESOURCE_TIMEOUT);
- if (OC_STACK_OK == result)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### create_group - findCandidateResources :: "
- "OC_STACK_OK!!!!");
- }
- else
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### create_group - findCandidateResources failed!!");
- }
- }
- dlog_print(DLOG_INFO, LOG_TAG, "#### observeBookMark EXIT");
-}
-
-static void onDestroy()
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### Destroy sequence called");
-
- try
- {
- if (NULL != foundResourceHandle)
- {
- OCPlatform::unregisterResource(foundResourceHandle);
- dlog_print(DLOG_INFO, LOG_TAG, "#### Light Resource unregistered");
- lights.clear();
- }
- else
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### No resouceHandle found to unregister");
- }
- }
- catch (std::exception &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception occured! (%s)", e.what());
- }
-
- try
- {
- if (NULL != resourceHandle)
- {
- // Unbind Light resource
- if (NULL != foundResourceHandle)
- {
- OCPlatform::unbindResource(resourceHandle, foundResourceHandle);
- dlog_print(DLOG_INFO, LOG_TAG, "#### Resource Unbind Done");
- }
- OCPlatform::unregisterResource(resourceHandle);
- dlog_print(DLOG_INFO, LOG_TAG, "#### Group Unregistered");
- }
- else
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### foundResourceHandle is NULL");
- }
- }
- catch (std::exception &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception occured! (%s)", e.what());
- }
-
- delete groupMgr;
-}
-
-static void createActionSet(void *data, Evas_Object *obj, void *event_info)
-{
- createActionSet_AllBulbOff();
- createActionSet_AllBulbOn();
-}
-
-static void
-popup_cancel_clicked_cb(void *data, Evas_Object *obj, void *event_info)
-{
- datetime_popup_fields *popup_fields = (datetime_popup_fields *)data;
- evas_object_del(popup_fields->popup);
- free(popup_fields);
-}
-
-static int parseString(const char *str, int slen, int *beg, int what)
-{
- int i, val = 0, ch = '/';
- if (2 == what)
- {
- ch = ' ';
- }
- else if (3 <= what)
- {
- if (5 == what)
- {
- ch = '\0';
- }
- else
- {
- ch = ':';
- }
- }
- // Remove whitespaces(if any) at the beginning
- while (str[*beg] == ' ')
- {
- (*beg)++;
- }
- for (i = *beg; i < slen; i++)
- {
- if (str[i] != ch)
- {
- val = (val * 10) + (str[i] - 48);
- continue;
- }
- break;
- }
- (*beg) = i + 1;
- return val;
-}
-
-static bool validate(int date, int month, int year, int hour, int minute, int second)
-{
- if (date <= 0 || month <= 0 || year <= 0 || hour < 0 || minute < 0 || second < 0
- || month >= 13 || hour >= 24 || minute >= 60 || second >= 60)
- {
- return false;
- }
- return true;
-}
-
-static void
-popup_set_clicked_cb(void *data, Evas_Object *obj, void *event_info)
-{
- datetime_popup_fields *popup_fields = (datetime_popup_fields *)data;
- Evas_Object *entry = popup_fields->entry;
- const char *dateTimeValue = elm_entry_entry_get(entry);
- int len;
-
- if (NULL == dateTimeValue)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Read NULL DateTime Value");
- string logMessage = "DateTime should not be NULL<br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog, &logMessage);
- evas_object_del(popup_fields->popup);
- free(popup_fields);
- return;
- }
-
- len = strlen(dateTimeValue);
- if (1 > len)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Read NULL DateTime Value");
- string logMessage = "DateTime should not be NULL<br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog, &logMessage);
- }
- else
- {
- int date, month, year, hour, minute, second;
- int beg = 0;
- date = parseString(dateTimeValue, len, &beg, 0);
- month = parseString(dateTimeValue, len, &beg, 1);
- year = parseString(dateTimeValue, len, &beg, 2);
- hour = parseString(dateTimeValue, len, &beg, 3);
- minute = parseString(dateTimeValue, len, &beg, 4);
- second = parseString(dateTimeValue, len, &beg, 5);
-
- dlog_print(DLOG_INFO, LOG_TAG, "#### %d", date);
- dlog_print(DLOG_INFO, LOG_TAG, "#### %d", month);
- dlog_print(DLOG_INFO, LOG_TAG, "#### %d", year);
- dlog_print(DLOG_INFO, LOG_TAG, "#### %d", hour);
- dlog_print(DLOG_INFO, LOG_TAG, "#### %d", minute);
- dlog_print(DLOG_INFO, LOG_TAG, "#### %d", second);
- bool valid = validate(date, month, year, hour, minute, second);
- if (valid)
- {
- createScheduledActionSet_AllBulbOff(date, month, year, hour, minute, second);
- }
- else
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Incorrect date/time values");
- string logMessage = "Incorrect date/time value<br>";
- logMessage += "----------------------<br>";
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog,
- &logMessage);
- }
- }
- evas_object_del(popup_fields->popup);
- free(popup_fields);
-}
-
-static void
-list_scheduled_actionset_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Evas_Object *popup, *btn;
- Evas_Object *nf = naviframe;
- Evas_Object *entry;
- Evas_Object *layout;
-
- /* popup */
- popup = elm_popup_add(nf);
- elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
- eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
- evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_object_part_text_set(popup, "title,text", "Enter the date and time");
-
- layout = elm_layout_add(popup);
- elm_layout_file_set(layout, ELM_DEMO_EDJ, "popup_datetime_text");
- evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_object_content_set(popup, layout);
-
- entry = elm_entry_add(layout);
- elm_entry_single_line_set(entry, EINA_TRUE);
- elm_entry_scrollable_set(entry, EINA_TRUE);
- evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
- eext_entry_selection_back_event_allow_set(entry, EINA_TRUE);
- elm_object_part_text_set(entry, "elm.guide", "dd/mm/yyyy hh:mm:ss");
- elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_NUMBER);
- elm_object_part_content_set(layout, "elm.swallow.content", entry);
-
- datetime_popup_fields *popup_fields;
- popup_fields = (datetime_popup_fields *)malloc(sizeof(datetime_popup_fields));
- if (NULL == popup_fields)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### Memory allocation failed");
- }
- else
- {
- popup_fields->popup = popup;
- popup_fields->entry = entry;
- }
-
- /* Cancel button */
- btn = elm_button_add(popup);
- elm_object_style_set(btn, "popup");
- elm_object_text_set(btn, "Cancel");
- elm_object_part_content_set(popup, "button1", btn);
- evas_object_smart_callback_add(btn, "clicked", popup_cancel_clicked_cb, popup_fields);
-
- /* Set button */
- btn = elm_button_add(popup);
- elm_object_style_set(btn, "popup");
- elm_object_text_set(btn, "Set");
- elm_object_part_content_set(popup, "button2", btn);
- evas_object_smart_callback_add(btn, "clicked", popup_set_clicked_cb, popup_fields);
-
- evas_object_show(popup);
-}
-
-void *showGroupAPIs(void *data)
-{
- // Add items to the list only if the list is empty
- const Eina_List *eina_list = elm_list_items_get(list);
- int count = eina_list_count(eina_list);
- if (!count)
- {
- elm_list_item_append(list, "1. Create ActionSet<br>(ALLBULBON and ALLBULBOFF)", NULL, NULL,
- createActionSet, NULL);
-
- elm_list_item_append(list, "2. Execute ActionSet (ALLBULBON)", NULL, NULL,
- executeActionSetOn, NULL);
-
- elm_list_item_append(list, "3. Execute ActionSet (ALLBULBOFF)", NULL, NULL,
- executeActionSetOff, NULL);
-
- elm_list_item_append(list, "4. Create ActionSet<br>(Recursive_ALLBULBON)", NULL, NULL,
- createRecursiveActionSet_AllBulbOn, NULL);
-
- elm_list_item_append(list, " 4.1 Execute ActionSet", NULL, NULL,
- recursive_allBulbOn, NULL);
-
- elm_list_item_append(list, " 4.2 Cancel ActionSet", NULL, NULL,
- cancelRecursive_allBulbOn, NULL);
-
- elm_list_item_append(list, "5. Create ActionSet<br>(Scheduled_ALLBULBOFF)", NULL, NULL,
- list_scheduled_actionset_cb, NULL);
-
- elm_list_item_append(list, " 5.1 Execute ActionSet", NULL, NULL,
- scheduled_AllbulbOff, NULL);
-
- elm_list_item_append(list, " 5.2 Cancel ActionSet", NULL, NULL,
- cancelScheduled_AllBulbOff, NULL);
-
- elm_list_item_append(list, "6. Get ActionSet (All BULBOFF)", NULL, NULL,
- getActionSetOff, NULL);
-
- elm_list_item_append(list, "7. Delete ActionSet (All BULBOFF)", NULL, NULL,
- deleteActionSetOff, NULL);
-
- elm_list_item_append(list, "8. Find BookMark to Observe", NULL, NULL,
- observeBookMark, NULL);
-
- elm_list_go(list);
- }
- return NULL;
-}
-
-// Callback to be called when a resource is found in the network
-void foundResource(shared_ptr< OCResource > resource)
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### foundResource entry!!!!");
-
- if (resource)
- {
- string resourceURI = resource->uri();
- string hostAddress = resource->host();
- string logMessage;
- if (resourceURI == "/core/b/collection")
- {
- g_resource = resource;
- dlog_print(DLOG_INFO, LOG_TAG, "#### FOUND URI: %s", resourceURI.c_str());
- dlog_print(DLOG_INFO, LOG_TAG, "#### FOUND HOST: %s", hostAddress.c_str());
- logMessage = "FOUND RESOURCE URI <br>" + resourceURI + "<br>";
- logMessage += "FOUND RESOURCE HOST <br>" + hostAddress + "<br>";
- logMessage += "----------------------<br>";
- // Show the UI list of group APIs
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))showGroupAPIs, NULL);
-
- }
- dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog,
- &logMessage);
- }
-
- dlog_print(DLOG_INFO, LOG_TAG, "#### foundResource exit!!!!");
-}
-
-static void list_selected_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Elm_Object_Item *it = (Elm_Object_Item *)event_info;
- elm_list_item_selected_set(it, EINA_FALSE);
-}
-
-// Method for Finding the Group
-static void find_group()
-{
- dlog_print(DLOG_INFO, LOG_TAG, "#### findGroup ENTRY");
- std::string query = OC_RSRVD_WELL_KNOWN_URI;
- query.append("?rt=");
- query.append(resourceTypeName);
-
- OCPlatform::findResource("", query, CT_DEFAULT, &foundResource);
-
- dlog_print(DLOG_INFO, LOG_TAG, "#### findGroup EXIT");
-}
-
-// Method to be called when the Find Group UI Button is selected
-static void
-find_group_cb(void *data, Evas_Object *obj, void *event_info)
-{
- if (NULL != list)
- {
- find_group();
- }
- else
- {
- dlog_print(DLOG_ERROR, "find_group_cb", "list is NULL - So unable to add items!!!");
- }
-}
-
-static Eina_Bool
-naviframe_pop_cb(void *data, Elm_Object_Item *it)
-{
- onDestroy();
-
- if (NULL != log_entry)
- {
- evas_object_del(log_entry);
- log_entry = NULL;
- }
- if (NULL != list)
- {
- evas_object_del(list);
- list = NULL;
- }
- return EINA_TRUE;
-}
-
-// Method to be called when the Group APIs UI Button is selected
-void group_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Evas_Object *layout;
- Evas_Object *scroller;
- Evas_Object *nf = (Evas_Object *)data;
- Evas_Object *find_button;
- Elm_Object_Item *nf_it;
-
- naviframe = nf;
-
- // Scroller
- scroller = elm_scroller_add(nf);
- elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE);
- elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
-
- // Layout
- layout = elm_layout_add(nf);
- elm_layout_file_set(layout, ELM_DEMO_EDJ, "group_layout");
- evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
- elm_object_content_set(scroller, layout);
-
- // Button
- find_button = elm_button_add(layout);
- elm_object_part_content_set(layout, "find_button", find_button);
- elm_object_text_set(find_button, "Find Group");
- evas_object_smart_callback_add(find_button, "clicked", find_group_cb, NULL);
-
- // List
- list = elm_list_add(layout);
- elm_list_mode_set(list, ELM_LIST_COMPRESS);
- evas_object_smart_callback_add(list, "selected", list_selected_cb, NULL);
- elm_object_part_content_set(layout, "list", list);
- elm_list_go(list);
-
- // log_entry - textarea for log
- log_entry = elm_entry_add(layout);
- elm_entry_scrollable_set(log_entry, EINA_TRUE);
- elm_entry_editable_set(log_entry, EINA_FALSE);
- elm_object_part_text_set(log_entry, "elm.guide", "Logs will be updated here!!!");
- evas_object_size_hint_weight_set(log_entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(log_entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_object_part_content_set(layout, "log", log_entry);
-
- nf_it = elm_naviframe_item_push(nf, "Group APIs", NULL, NULL, scroller, NULL);
- elm_naviframe_item_pop_cb_set(nf_it, naviframe_pop_cb, NULL);
-
- create_group();
-}
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include "tmsampleapp.h"
-#include <tizen.h>
-
-typedef struct appdata
-{
- Evas_Object *win;
- Evas_Object *conform;
- Evas_Object *layout;
- Evas_Object *nf;
- Evas_Object *findButton;
- Evas_Object *logtext;
- Evas_Object *listview;
-} appdata_s;
-
-static void
-win_delete_request_cb(void *data , Evas_Object *obj , void *event_info)
-{
- ui_app_exit();
-}
-
-static void
-list_selected_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Elm_Object_Item *it = (Elm_Object_Item *)event_info;
- elm_list_item_selected_set(it, EINA_FALSE);
-}
-
-static Eina_Bool
-naviframe_pop_cb(void *data, Elm_Object_Item *it)
-{
- ui_app_exit();
- return EINA_FALSE;
-}
-
-static void
-create_list_view(appdata_s *ad)
-{
- Evas_Object *list;
- Evas_Object *btn;
- Evas_Object *nf = ad->nf;
- Elm_Object_Item *nf_it;
-
- // List
- list = elm_list_add(nf);
- elm_list_mode_set(list, ELM_LIST_COMPRESS);
- evas_object_smart_callback_add(list, "selected", list_selected_cb, NULL);
-
- // Main Menu Items Here
- elm_list_item_append(list, "Group APIs", NULL, NULL, group_cb, nf);
- elm_list_item_append(list, "Configuration APIs", NULL, NULL, configuration_cb, nf);
-
- elm_list_go(list);
-
- // This button is set for devices which doesn't have H/W back key.
- btn = elm_button_add(nf);
- elm_object_style_set(btn, "naviframe/end_btn/default");
- nf_it = elm_naviframe_item_push(nf, "Things Manager", btn, NULL, list, NULL);
- elm_naviframe_item_pop_cb_set(nf_it, naviframe_pop_cb, ad->win);
-}
-
-
-static void
-create_base_gui(appdata_s *ad)
-{
- // Window
- ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
- elm_win_conformant_set(ad->win, EINA_TRUE);
- elm_win_autodel_set(ad->win, EINA_TRUE);
-
- if (elm_win_wm_rotation_supported_get(ad->win))
- {
- int rots[4] = { 0, 90, 180, 270 };
- elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
- }
-
- evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);
-
- // Conformant
- ad->conform = elm_conformant_add(ad->win);
- evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_win_resize_object_add(ad->win, ad->conform);
- evas_object_show(ad->conform);
-
- // Base Layout
- ad->layout = elm_layout_add(ad->conform);
- evas_object_size_hint_weight_set(ad->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_layout_theme_set(ad->layout, "layout", "application", "default");
- evas_object_show(ad->layout);
-
- elm_object_content_set(ad->conform, ad->layout);
-
- // Naviframe
- ad->nf = elm_naviframe_add(ad->layout);
- create_list_view(ad);
- elm_object_part_content_set(ad->layout, "elm.swallow.content", ad->nf);
- eext_object_event_callback_add(ad->nf, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
- eext_object_event_callback_add(ad->nf, EEXT_CALLBACK_MORE, eext_naviframe_more_cb, NULL);
-
- // Show window after base gui is set up
- evas_object_show(ad->win);
-}
-
-// Configures the OCPlatform
-static void
-configure_platform()
-{
- try
- {
- PlatformConfig config
- { OC::ServiceType::InProc, ModeType::Both, "0.0.0.0", 0, OC::QualityOfService::LowQos };
-
- OCPlatform::Configure(config);
-
- dlog_print(DLOG_INFO, LOG_TAG, "#### Platform configuration done!!!!");
- }
- catch (OCException &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception occured! (%s)", e.what());
- }
-}
-
-static bool
-app_create(void *data)
-{
- /* Hook to take necessary actions before main event loop starts
- Initialize UI resources and application's data
- If this function returns true, the main loop of application starts
- If this function returns false, the application is terminated */
- appdata_s *ad = (appdata_s *)data;
-
- elm_app_base_scale_set(1.8);
-
- create_base_gui(ad);
-
- configure_platform();
-
- return true;
-}
-
-static void
-app_control(app_control_h app_control, void *data)
-{
- // Handle the launch request.
-}
-
-static void
-app_pause(void *data)
-{
- // Take necessary actions when application becomes invisible.
-}
-
-static void
-app_resume(void *data)
-{
- // Take necessary actions when application becomes visible.
-}
-
-static void
-app_terminate(void *data)
-{
- // Release all resources.
-}
-
-static void
-ui_app_lang_changed(app_event_info_h event_info, void *user_data)
-{
- // APP_EVENT_LANGUAGE_CHANGED
- char *locale = NULL;
- system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
- elm_language_set(locale);
- free(locale);
- return;
-}
-
-static void
-ui_app_orient_changed(app_event_info_h event_info, void *user_data)
-{
- // APP_EVENT_DEVICE_ORIENTATION_CHANGED
- return;
-}
-
-static void
-ui_app_region_changed(app_event_info_h event_info, void *user_data)
-{
- // APP_EVENT_REGION_FORMAT_CHANGED
-}
-
-static void
-ui_app_low_battery(app_event_info_h event_info, void *user_data)
-{
- // APP_EVENT_LOW_BATTERY
-}
-
-static void
-ui_app_low_memory(app_event_info_h event_info, void *user_data)
-{
- // APP_EVENT_LOW_MEMORY
-}
-
-int
-main(int argc, char *argv[])
-{
- appdata_s ad = {0,};
- int ret = 0;
-
- ui_app_lifecycle_callback_s event_callback = {0,};
- app_event_handler_h handlers[5] = {NULL, };
-
- event_callback.create = app_create;
- event_callback.terminate = app_terminate;
- event_callback.pause = app_pause;
- event_callback.resume = app_resume;
- event_callback.app_control = app_control;
-
- ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY,
- ui_app_low_battery, &ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY,
- ui_app_low_memory, &ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED],
- APP_EVENT_DEVICE_ORIENTATION_CHANGED,
- ui_app_orient_changed, &ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED],
- APP_EVENT_LANGUAGE_CHANGED,
- ui_app_lang_changed, &ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED],
- APP_EVENT_REGION_FORMAT_CHANGED,
- ui_app_region_changed, &ad);
- ui_app_remove_event_handler(handlers[APP_EVENT_LOW_MEMORY]);
-
- ret = ui_app_main(argc, argv, &event_callback, &ad);
- if (APP_ERROR_NONE != ret)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "app_main() is failed. err = %d", ret);
- }
- return ret;
-}
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include "tmutil.h"
-
-// Utility function to return the string equivalent of OCStackResult for the given integer value
-std::string getOCStackResultStringFromInt(int result)
-{
- string ocresultstr;
-
- switch (result)
- {
- case 0 :
- ocresultstr = "OC_STACK_OK";
- break;
- case 1 :
- ocresultstr = "OC_STACK_RESOURCE_CREATED";
- break;
- case 2 :
- ocresultstr = "OC_STACK_RESOURCE_DELETED";
- break;
- case 3 :
- ocresultstr = "OC_STACK_CONTINUE";
- break;
- case 20 :
- ocresultstr = "OC_STACK_INVALID_URI";
- break;
- case 21 :
- ocresultstr = "OC_STACK_INVALID_QUERY";
- break;
- case 22 :
- ocresultstr = "OC_STACK_INVALID_QUERY";
- break;
- case 23 :
- ocresultstr = "OC_STACK_INVALID_PORT";
- break;
- case 24 :
- ocresultstr = "OC_STACK_INVALID_CALLBACK";
- break;
- case 25 :
- ocresultstr = "OC_STACK_INVALID_METHOD";
- break;
- case 26 :
- ocresultstr = "OC_STACK_INVALID_PARAM";
- break;
- case 27 :
- ocresultstr = "OC_STACK_INVALID_OBSERVE_PARAM";
- break;
- case 28 :
- ocresultstr = "OC_STACK_NO_MEMORY";
- break;
- case 29 :
- ocresultstr = "OC_STACK_COMM_ERROR";
- break;
- case 30 :
- ocresultstr = "OC_STACK_NOTIMPL";
- break;
- case 31 :
- ocresultstr = "OC_STACK_NO_RESOURCE";
- break;
- case 32 :
- ocresultstr = "OC_STACK_RESOURCE_ERROR";
- break;
- case 33 :
- ocresultstr = "OC_STACK_SLOW_RESOURCE";
- break;
- case 34 :
- ocresultstr = "OC_STACK_DUPLICATE_REQUEST";
- break;
- case 35 :
- ocresultstr = "OC_STACK_NO_OBSERVERS";
- break;
- case 36 :
- ocresultstr = "OC_STACK_OBSERVER_NOT_FOUND";
- break;
- case 37 :
- ocresultstr = "OC_STACK_VIRTUAL_DO_NOT_HANDLE";
- break;
- case 38 :
- ocresultstr = "OC_STACK_INVALID_OPTION";
- break;
- case 39 :
- ocresultstr = "OC_STACK_MALFORMED_RESPONSE";
- break;
- case 40 :
- ocresultstr = "OC_STACK_PERSISTENT_BUFFER_REQUIRED";
- break;
- case 41 :
- ocresultstr = "OC_STACK_INVALID_REQUEST_HANDLE";
- break;
- case 42 :
- ocresultstr = "OC_STACK_INVALID_DEVICE_INFO";
- break;
- case 43 :
- ocresultstr = "OC_STACK_INVALID_JSON";
- break;
- case 128 :
- ocresultstr = "OC_STACK_PRESENCE_STOPPED";
- break;
- case 129 :
- ocresultstr = "OC_STACK_PRESENCE_TIMEOUT";
- break;
- case 130 :
- ocresultstr = "OC_STACK_PRESENCE_DO_NOT_HANDLE";
- break;
- case 255 :
- ocresultstr = "OC_STACK_ERROR";
- break;
- default :
- ocresultstr = "OC_STACK_ERROR";
- }
- return ocresultstr;
-}
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<manifest xmlns="http://tizen.org/ns/packages" api-version="2.3" package="org.tizen.tmsampleapp" version="1.0.0">
- <profile name="mobile"/>
- <ui-application appid="org.tizen.tmsampleapp" exec="tmsampleapp" multiple="false" nodisplay="false" taskmanage="true" type="capp">
- <label>tmsampleapp</label>
- <icon>tmsampleapp.png</icon>
- </ui-application>
- <privileges>
- <privilege>http://tizen.org/privilege/network.get</privilege>
- <privilege>http://tizen.org/privilege/internet</privilege>
- </privileges>
- <feature name="http://tizen.org/feature/network.wifi">true</feature>
-</manifest>
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#ifndef __OC_ACTIONSET__
-#define __OC_ACTIONSET__
-
-#include <string>
-#include <vector>
-#include <cstdio>
-#include <iostream>
-#include <ctime>
-#include <timer.h>
-
-using namespace std;
-
-namespace OIC
-{
-enum ACTIONSET_TYPE
-{
- NONE = 0, SCHEDULED, RECURSIVE
-};
-
-typedef tm OCTime;
-
-/**
- * @class Time
- * @brief This class provides time-related information used for scheduled/recursive group action
- * features. Along with time-related variables, it also provides various useful functionality
- * including translating time to second unit
- */
-class Time
-{
-public:
- /**
- * Constructor for Time
- */
- Time();
- /**
- * Virtual destructor for Time
- */
- ~Time();
-
- /** @brief a unit of second.*/
- long int mDelay;
- /** @brief time information in structure tm.*/
- OCTime mTime;
- /** @brief flag to indicate group action type(NONE, SCHEDULED, RECURSIVE).*/
- ACTIONSET_TYPE type;
-
- void setTime(OCTime t);
- void setTime(unsigned int yy, unsigned int mm, unsigned int dd,
- unsigned int h, unsigned int m, unsigned int s,
- int dayoftheweek);
- void setDayOfWeekForRecursive(int day);
- unsigned int getYear();
- unsigned int getMonth();
- unsigned int getDay();
- unsigned int getHour();
- unsigned int getMin();
- unsigned int getSec();
- long int getSecondsFromAbsoluteTime();
- long int getSecAbsTime();
- long int getSecondsForWeeklySchedule();
- void setDelay(long int seconds);
- std::string toString() const;
-};
-
-/**
- * @class Capability
- * @brief This class provides a structure to help developers to easily specify a unit of attribute
- * key-value pair which corresponds to action.
- */
-class Capability
-{
-public:
- /** @brief This corresponds with attribute key.*/
- std::string capability;
- /** @brief This corresponds with attribute value.*/
- std::string status;
-};
-
-/**
- * @class Action
- * @brief This class provides a structure to help developers to easily specify an action which a
- * target resource have to do for.
- */
-class Action
-{
-public:
- /**
- * Constructor for Action
- */
- Action();
- /**
- * Virtual destructor for Action
- */
- ~Action();
-
- /** @brief This is a target URL of this action. It includes IP address, port, and resource URI.*/
- std::string target;
- /** @brief This is a list of capabilites.*/
- std::vector<Capability*> listOfCapability;
-};
-
-/**
- * @class ActionSet
- * @brief This class provides a structure to help developers to easily specify group action.
- */
-class ActionSet: public Time
-{
-public:
- /**
- * Constructor for ActionSet
- */
- ActionSet();
- /**
- * Virtual destructor for ActionSet
- */
- ~ActionSet();
-
- /** @brief a name of group action */
- std::string actionsetName;
- /** @brief a list of actions composing group action */
- std::vector<Action*> listOfAction;
-};
-}
-#endif
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-/**
- * @file
- *
- * This file contains the declaration of classes and its members related to
- * GroupManager.
- */
-
-#ifndef __OC_GROUPMANAGER__
-#define __OC_GROUPMANAGER__
-
-#include <string>
-#include <vector>
-#include <map>
-#include <cstdlib>
-#include <ActionSet.h>
-#include "OCPlatform.h"
-#include "OCApi.h"
-
-using namespace OC;
-
-namespace OIC
-{
-typedef std::function< void(std::vector< std::shared_ptr< OCResource > >) > CandidateCallback;
-typedef std::function< void(std::string, OCStackResult) > CollectionPresenceCallback;
-
-typedef std::function< void(const HeaderOptions&, const OCRepresentation&, const int) > GetCallback;
-typedef std::function< void(const HeaderOptions&, const OCRepresentation&, const int) > PostCallback;
-typedef std::function< void(const HeaderOptions&, const OCRepresentation&, const int) > PutCallback;
-
-/**
- * This APIs provide functions for application to find appropriate devices (i.e. things) in network,
- * create a group of the devices, check a presence of member devices in the group, and actuate a
- * group action in a more convenient way.
- */
-class GroupManager
-{
-public:
- /**
- * Constructor for GroupManager. Constructs a new GroupManager
- */
- GroupManager(void);
-
- /**
- * Virtual destructor
- */
- ~GroupManager(void);
-
- /**
- * API for candidate resources discovery.
- * Callback only call when all resource types found.
- *
- * @param resourceTypes required resource types(called "candidate")
- * @param callback callback with OCResource vector.
- * @param waitsec time to wait to finish finding resources
- *
- * @return Returns ::OC_STACK_OK if success, some other value upon failure.
- *
- * @note OCStackResult is defined in ocstack.h.
- */
- OCStackResult findCandidateResources(std::vector< std::string > resourceTypes,
- CandidateCallback callback, int waitsec = -1);
-
- /**
- * API for Collection member's state subscribe.
- *
- * @note NOT IMPLEMENT YET
- */
- OCStackResult subscribeCollectionPresence(std::shared_ptr< OCResource > resource,
- CollectionPresenceCallback);
-
- OCStackResult bindResourceToGroup(OCResourceHandle& childHandle,
- std::shared_ptr< OCResource > resource, OCResourceHandle& collectionHandle);
-
-private:
-
- void onFoundResource(std::shared_ptr< OCResource > resource, int waitsec);
- void findPreparedRequest(std::map< std::vector< std::string >, CandidateCallback > &request);
- void lazyCallback(int second);
-
- void onGetForPresence(const HeaderOptions& headerOptions, const OCRepresentation& rep,
- const int eCode, CollectionPresenceCallback callback);
- void checkCollectionRepresentation(const OCRepresentation& rep,
- CollectionPresenceCallback callback);
- void collectionPresenceHandler(OCStackResult result, const unsigned int nonce,
- const std::string& hostAddress, std::string host, std::string uri);
-
- /**
- * API for Collection(Group) action.
- */
-
-public:
- /**
- * API for extracting an action set string from the ActionSet class instance
- *
- * @param newActionSet pointer of ActionSet class instance
- *
- * @return std::string return value of this API.
- * It returns an action set String.
- */
- std::string getStringFromActionSet(const ActionSet *newActionSet);
-
- /**
- * API for extracting ActionSet class instance from an action set string.
- *
- * @param desc description of an action set string
- *
- * @return ActionSet* return value of this API.
- * It returns pointer of ActionSet.
- */
- ActionSet* getActionSetfromString(std::string desc);
-
- /**
- * API for adding an action set.
- * Callback is called when the response of PUT operation arrives.
- *
- * @param resource resource pointer of the group resource
- * @param newActionSet pointer of ActionSet class instance
- * @param cb callback for PUT operation.
- *
- * @return Returns ::OC_STACK_OK if success, some other value upon failure.
- *
- * @note OCStackResult is defined in ocstack.h.
- */
- OCStackResult addActionSet(std::shared_ptr< OCResource > resource,
- const ActionSet* newActionSet, PutCallback cb);
-
- /**
- * API for executing an existing action set.
- * Callback is called when the response of POST operation arrives.
- *
- * @param resource resource pointer of the group resource
- * @param actionsetName the action set name for executing the action set
- * @param cb callback for POST operation.
- *
- * @return Returns ::OC_STACK_OK if success, some other value upon failure.
- * @note OCStackResult is defined in ocstack.h.
- */
- OCStackResult executeActionSet(std::shared_ptr< OCResource > resource,
- std::string actionsetName, PostCallback cb);
-
- /**
- * API for executing an existing action set.
- * Callback is called when the response of POST operation arrives.
- *
- * @param resource resource pointer of the group resource
- * @param actionsetName the action set name for executing the action set
- * @param delay waiting time for until the action set run.
- * @param cb callback for POST operation.
- *
- * @return Returns ::OC_STACK_OK if success, some other value upon failure.
- * @note OCStackResult is defined in ocstack.h.
- */
- OCStackResult executeActionSet(std::shared_ptr< OCResource > resource,
- std::string actionsetName, long int delay, PostCallback cb);
-
- /**
- * API for canceling an existing action set.
- * Callback is called when the response of POST operation arrives.
- *
- * @param resource resource pointer of the group resource
- * @param actionsetName the action set name for executing the action set
- * @param cb callback for POST operation.
- *
- * @return Returns ::OC_STACK_OK if success, some other value upon failure.
- * @note OCStackResult is defined in ocstack.h.
- */
- OCStackResult cancelActionSet(std::shared_ptr< OCResource > resource,
- std::string actionsetName, PostCallback cb);
-
- /**
- * API for reading an existing action set.
- * Callback is called when the response of GET operation arrives.
- *
- * @param resource resource pointer of the group resource
- * @param actionsetName the action set name for reading the action set
- * @param cb callback for GET operation.
- *
- * @return Returns ::OC_STACK_OK if success, some other value upon failure.
- * @note OCStackResult is defined in ocstack.h.
- */
- OCStackResult getActionSet(std::shared_ptr< OCResource > resource, std::string actionsetName,
- PostCallback cb);
-
- /**
- * API for removing an existing action set.
- * Callback is called when the response of POST operation arrives.
- *
- * @param resource resource pointer of the group resource
- * @param actionsetName the action set name for removing the action set
- * @param cb callback for POST operation.
- *
- * @return Returns ::OC_STACK_OK if success, some other value upon failure.
- * @note OCStackResult is defined in ocstack.h.
- */
- OCStackResult deleteActionSet(std::shared_ptr< OCResource > resource, std::string actionsetName,
- PostCallback cb);
-};
-}
-#endif /* __OC_GROUPMANAGER__*/
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-/**
- * @file
- *
- * This file contains the declaration of classes and its members related to
- * ThingsConfiguration.
- */
-
-#ifndef __OC_THINGSCONFIGURATION__
-#define __OC_THINGSCONFIGURATION__
-
-#include <string>
-#include <vector>
-#include <map>
-#include <cstdlib>
-#include "GroupManager.h"
-#include "OCPlatform.h"
-#include "OCApi.h"
-
-using namespace OC;
-
-namespace OIC
-{
-/// Declearation of Configuation Callback funtion type
- typedef std::function<
- void(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
- > ConfigurationCallback;
-
- typedef std::string ConfigurationName;
- typedef std::string ConfigurationValue;
-
- /**
- * The following class is used as a item stacking in request queue. The class stores a request
- * and referential information (e.g., a configuration name, a target resource object, a callback
- * function passed from the applications, and a update value). When the function for updating/
- * getting configuration value is called from applications, this class instance is created and
- * stored in the request queue. The queue is maintained in a std::map structure so if desiring
- * to find a specific request, you can find it by querying a configuration name.
- */
- class ConfigurationRequestEntry
- {
- public:
- ConfigurationRequestEntry(std::string ID, ConfigurationCallback callback,
- std::shared_ptr< OCResource > resource, std::string updateVal);
-
- // Configuration Name (used in key value in std::map structure)
- // e.g., time, network, security, and so on
- std::string m_ID;
- // Reference callback pointer
- ConfigurationCallback m_callback;
- // Reference resource object
- std::shared_ptr< OCResource > m_resource;
- // Update value only used for configuration update
- std::string m_updateVal;
- };
-
- /**
- * The following class is used to store providing configuration name and its relevant
- * information. The relevant information includes a brief description, uri, and attribute key.
- * Note that a developer only specifies a configuration name, not URI nor attribute key, to
- * update/get a value to a remote. Thus, using configuration name, we convert it to more
- * specific information (i.e. uri and attribute key) to send a request. This class is reponsible
- * to storing these information.
- */
- class ConfigurationUnitInfo
- {
- public:
-
- std::string m_name;
- std::string m_attribute;
- std::string m_uri;
-
- ConfigurationUnitInfo(std::string name, std::string attribute, std::string uri);
-
- // If a developer wants to know a list of configuration names, gives it in JSON format.
- std::string getJSON();
- };
-
-#define NUMCONFUNIT 6
- typedef std::string ConfigurationName;
- typedef std::string ConfigurationValue;
-
- /**
- * @par There are two main usages of this class:
- * -# On a server side, bootstrapping requisite information (i.e. system configuration parameters)
- * from a bootstrap server to access other IoT services,
- * -# On a client side, getting/updating the system configuration parameters from/to multiple remote things.
- * @par
- */
- class ThingsConfiguration
- {
- public:
- /**
- * Constructor for ThingsConfiguration. Constructs a new ThingsConfiguration
- */
- ThingsConfiguration(void);
-
- /**
- * Virtual destructor
- */
- ~ThingsConfiguration(void);
-
- static ThingsConfiguration *thingsConfigurationInstance;
- static ThingsConfiguration* getInstance();
-
- // TODO: deprecated
- void deleteInstance();
- void setGroupManager(GroupManager *groupmanager);
-
- /**
- * API for updating configuration value of multiple things of a target group or a single
- * thing.
- * Callback is called when a response arrives.
- * Before using the below function, a developer should acquire a resource pointer of
- * (collection) resource that he want to send a request by calling findResource() function
- * provided in OCPlatform. And he should also notice a "Configuration Name" term which
- * represents a nickname of a target attribute of a resource that he wants to update.
- * The base motivation to introduce the term is to avoid a usage of URI to access a resource
- * from a developer. Thus, a developer should know which configuration names are supported
- * by Things Configuration class and what the configuration name means.
- * To get a list of supported configuration names, use getListOfSupportedConfigurationUnits(
- * ) function, which provides the list in JSON format.
- *
- * NOTICE: A series of callback functions is called from updateConfigurations() function:
- * @par
- * -# For a collection resource
- * updateConfiguration()->onDeleteActionSet()->onGetChildInfoForUpdate()->onCreateActionSet(
- * )->...(CoAP msg. is transmitted)->OnExecuteForGroupAction()->callback function in APP.
- * -# For a simple resource
- * updateConfiguration()->...(CoAP msg. is transmitted)->OnPut()->callback function in APP.
- * @par
- *
- * @param resource resource pointer representing the target group or the single thing.
- * @param configurations ConfigurationUnit: an attribute key of target resource
- * (e.g., loc, st, c, r)
- * Value : a value to be updated
- * @param callback callback.
- *
- * @return Returns ::OC_STACK_OK if success, some other value upon failure.
- *
- * @note OCStackResult is defined in ocstack.h.
- */
- OCStackResult updateConfigurations(std::shared_ptr< OCResource > resource,
- std::map< ConfigurationName, ConfigurationValue > configurations,
- ConfigurationCallback callback);
-
- /**
- * API for getting configuration value of multiple things of a target group or a single
- * thing.
- * Callback is called when a response arrives.
- *
- * NOTICE: A series of callback functions is called from getConfigurations() function:
- * @par
- * -# For a collection resource
- * getConfigurations()->onGetChildInfoForGet()->...(CoAP msg. is transmitted)
- * ->callback function in APP.
- * -# For a simple resource
- * getConfigurations()->...(CoAP msg. is transmitted)->onGet()->callback function in APP.
- * @par
- *
- * @param resource resource pointer representing the target group or the single thing.
- * @param configurations ConfigurationUnit: an attribute key of target resource.
- * @param callback callback.
- *
- * @return Returns ::OC_STACK_OK if success, some other value upon failure.
- *
- * @note OCStackResult is defined in ocstack.h.
- */
- OCStackResult getConfigurations(std::shared_ptr< OCResource > resource,
- std::vector< ConfigurationName > configurations, ConfigurationCallback callback);
-
- /**
- * API to show a list of supported configuration units (configurable parameters)
- * Callback call when a response arrives.
- *
- * @return the list in JSON format
- */
- std::string getListOfSupportedConfigurationUnits();
-
- /**
- * API for bootstrapping functionality. Find a bootstrap server and get configuration
- * information from the bootstrap server. With the information, make a configuration
- * resource.
- *
- * @param callback callback.
- *
- * @return Returns ::OC_STACK_OK if success, some other value upon failure.
- *
- * @note OCStackResult is defined in ocstack.h.
- */
- OCStackResult doBootstrap(ConfigurationCallback callback);
-
- private:
-
- GroupManager *g_groupmanager;
-
- std::vector< ConfigurationUnitInfo > ConfigurationUnitTable;
-
- void onExecuteForGroupAction(const HeaderOptions& headerOptions,
- const OCRepresentation& rep, const int eCode, std::string conf);
- void onGetChildInfoForUpdate(const HeaderOptions& headerOptions,
- const OCRepresentation& rep, const int eCode, std::string conf);
- void onGetChildInfoForGet(const HeaderOptions& headerOptions, const OCRepresentation& rep,
- const int eCode, std::string conf);
- void onCreateActionSet(const HeaderOptions& headerOptions, const OCRepresentation& rep,
- const int eCode, std::string conf);
- void onGetActionSet(const HeaderOptions& headerOptions, const OCRepresentation& rep,
- const int eCode, std::string conf);
- void onDeleteActionSet(const HeaderOptions& headerOptions, const OCRepresentation& rep,
- const int eCode, std::string conf);
- void onGet(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode,
- std::string conf);
- void onPut(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode,
- std::string conf);
- static void onFoundBootstrapServer(std::vector< std::shared_ptr< OCResource > > resources);
- static void onGetBootstrapInformation(const HeaderOptions& headerOptions,
- const OCRepresentation& rep, const int eCode);
-
- std::shared_ptr< OCResource > getResource(std::string conf);
- ConfigurationCallback getCallback(std::string conf);
- std::string getUpdateVal(std::string conf);
- std::string getAttributeByConfigurationName(ConfigurationName name);
- std::string getUriByConfigurationName(ConfigurationName name);
-
- std::string getHostFromURI(std::string oldUri);
-
- bool isSimpleResource(std::shared_ptr< OCResource > resource);
- bool hasBatchInterface(std::shared_ptr< OCResource > resource);
-
- };
-}
-#endif /* __OC_THINGSCONFIGURATION__*/
-
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-/**
- * @file
- *
- * This file contains the declaration of classes and its members related to
- * ThingsMaintenance.
- */
-
-#ifndef __OC_THINGSMAINTENANCE__
-#define __OC_THINGSMAINTENANCE__
-
-#include <string>
-#include <vector>
-#include <map>
-#include <cstdlib>
-#include "OCPlatform.h"
-#include "OCApi.h"
-#include "GroupManager.h"
-
-using namespace OC;
-namespace OIC
-{
- /// Declearation of Maintenance Callback funtion type
- typedef std::function<
- void(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
- > MaintenanceCallback;
-
- /**
- * The following class is used as a item stacking in request queue. The class stores a request
- * and referential information (e.g., a maintenance name, a target resource object, a callback
- * function passed from the applications, and a update value). When the function for updating/
- * getting maintenance value is called from applications, this class instance is created and
- * stored in the request queue. The queue is maintained in a std::map structure so if desiring
- * to find a specific request, you can find it by querying a maintenance name.
- */
- class MaintenanceRequestEntry
- {
- public:
- MaintenanceRequestEntry(std::string ID, MaintenanceCallback callback,
- std::shared_ptr< OCResource > resource, std::string updateVal);
-
- // Maintenance Name (used in key value in std::map structure)
- // e.g., reboot and factoryset
- std::string m_ID;
-
- // Reference callback pointer
- MaintenanceCallback m_callback;
-
- // Reference resource object
- std::shared_ptr< OCResource > m_resource;
-
- // Update value only used for maintenance update (always "true")
- std::string m_updateVal;
- };
-
- /**
- * The following class is used to store providing maintenance name and its relevant information
- * The relevant information includes a brief description, uri, and attribute key.
- * Note that a developer only specifies a maintenance name, not URI nor attribute key, to
- * update a value to a remote. Thus, using maintenance name, we convert it to more specific
- * information (i.e. uri and attribute key) to send a request. This class is reponsible to
- * storing these information.
- */
- class MaintenanceUnitInfo
- {
- public:
- std::string m_name;
- std::string m_attribute;
- std::string m_uri;
-
- MaintenanceUnitInfo(std::string name, std::string attribute, std::string uri);
-
- // If a developer wants to know a list of configuration names, gives it in JSON format.
- std::string getJSON();
- };
-
-#define NUMDIAGUNIT 3
- typedef std::string MaintenanceName;
- typedef std::string MaintenanceValue;
-
- /**
- * There are two functionalities in Things Maintenance;
- * @par
- * -# FactoryReset to restore all configuration parameters to default one, and
- * -# Reboot to request a system rebooting.
- * @par
- *
- */
- class ThingsMaintenance
- {
- public:
- /**
- * Constructor for ThingsMaintenance. Constructs a new ThingsMaintenance
- */
- ThingsMaintenance(void);
-
- /**
- * Virtual destructor
- */
- ~ThingsMaintenance(void);
-
- static ThingsMaintenance *thingsMaintenanceInstance;
- static ThingsMaintenance* getInstance();
-
- // TODO: deprecated
- void deleteInstance();
- void setGroupManager(GroupManager *groupmanager);
-
- /**
- * API to make things reboot
- * Callback call when a response arrives.
- *
- * @param resource resource pointer representing the target group
- * @param callback callback.
- *
- * @return Returns ::OC_STACK_OK if success, some other value upon failure.
- *
- * @note OCStackResult is defined in ocstack.h.
- */
- OCStackResult reboot(std::shared_ptr< OCResource > resource, MaintenanceCallback callback);
-
- /**
- * API for factory reset on device
- * Callback call when a response arrives.
- *
- * @param resource resource pointer representing the target group
- * @param callback callback.
- *
- * @return Returns ::OC_STACK_OK if success, some other value upon failure.
- *
- * @note OCStackResult is defined in ocstack.h.
- */
-
- OCStackResult factoryReset(std::shared_ptr< OCResource > resource,
- MaintenanceCallback callback);
-
- /**
- * API to show a list of supported maintenance units
- * Callback call when a response arrives.
- *
- * @return the list in JSON format
- */
- std::string getListOfSupportedMaintenanceUnits();
-
- private:
-
- GroupManager *g_groupmanager;
-
- std::vector< MaintenanceUnitInfo > MaintenanceUnitTable;
-
- void onExecuteForGroupAction(const HeaderOptions& headerOptions,
- const OCRepresentation& rep, const int eCode, std::string conf);
- void onDeleteGroupAction(const HeaderOptions& headerOptions,
- const OCRepresentation& rep, const int eCode, std::string conf);
- void onGetChildInfoForUpdate(const HeaderOptions& headerOptions,
- const OCRepresentation& rep, const int eCode, std::string conf);
- void onCreateActionSet(const HeaderOptions& headerOptions, const OCRepresentation& rep,
- const int eCode, std::string conf);
- void onGet(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode,
- std::string conf);
- void onPut(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode,
- std::string conf);
-
- std::shared_ptr< OCResource > getResource(std::string conf);
- MaintenanceCallback getCallback(std::string conf);
- std::string getUpdateVal(std::string conf);
- std::string getAttributeByMaintenanceName(MaintenanceName name);
- std::string getUriByMaintenanceName(MaintenanceName name);
-
- std::string getHostFromURI(std::string oldUri);
-
- bool isSimpleResource(std::shared_ptr< OCResource > resource);
-
- };
-}
-#endif /* __OC_THINGSCONFIGURATION__*/
+++ /dev/null
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.iotivity.service.tm"
- android:versionCode="1"
- android:versionName="1.0" >
- <uses-sdk
- android:minSdkVersion="8"
- android:targetSdkVersion="21" />
-</manifest>
+++ /dev/null
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/release
-LOCAL_MODULE := android-oc_logger
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/liboc_logger.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/release
-LOCAL_MODULE := android-octbstack
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/liboctbstack.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/release
-LOCAL_MODULE := android-oc
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/liboc.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/release
-LOCAL_MODULE := android-connectivity_abstraction
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libconnectivity_abstraction.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../android/android_api/base/libs/$(TARGET_ARCH_ABI)
-LOCAL_MODULE := android-ocstack-jni
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libocstack-jni.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../android/android_api/base/libs/$(TARGET_ARCH_ABI)
-LOCAL_MODULE := android-ca-interface
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libca-interface.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/release
-LOCAL_MODULE := android-thingsmanager
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libTGMSDKLibrary.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_SRC_DIR := ../../../..
-LOCAL_MODULE := things-manager-jni
-
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/jniutil/inc \
- $(OIC_SRC_DIR)/android/android_api/base/jni \
- $(OIC_SRC_DIR)/resource/include \
- $(OIC_SRC_DIR)/resource/c_common \
- $(OIC_SRC_DIR)/resource/csdk/stack/include \
- $(OIC_SRC_DIR)/resource/oc_logger/include \
- $(OIC_SRC_DIR)/extlibs/boost/boost_1_58_0 \
- $(OIC_SRC_DIR)/extlibs/timer \
- $(OIC_SRC_DIR)/service/things-manager/sdk/inc \
- $(LOCAL_PATH)/tm/inc
-
-LOCAL_SRC_FILES += $(patsubst $(LOCAL_PATH)/%, %, $(wildcard $(LOCAL_PATH)/jniutil/src/*.cpp))
-LOCAL_SRC_FILES += $(patsubst $(LOCAL_PATH)/%, %, $(wildcard $(LOCAL_PATH)/tm/src/*.cpp))
-
-LOCAL_CPPFLAGS := -std=c++0x -frtti -fexceptions
-
-LOCAL_LDLIBS := -llog
-LOCAL_SHARED_LIBRARIES := android-ocstack-jni
-LOCAL_SHARED_LIBRARIES += android-thingsmanager
-LOCAL_SHARED_LIBRARIES += android-oc
-
-include $(BUILD_SHARED_LIBRARY)
+++ /dev/null
-NDK_TOOLCHAIN_VERSION := 4.9
-APP_STL := gnustl_shared
+++ /dev/null
-##
-# Things manager service JNI build script
-##
-
-import os
-Import('env')
-
-# Add third party libraries
-lib_env = env.Clone()
-SConscript('#service/third_party_libs.scons', exports = 'lib_env')
-
-tm_jni_env = lib_env.Clone()
-target_os = tm_jni_env.get('TARGET_OS')
-tm_sdk = tm_jni_env.get('SRC_DIR') + '/service/things-manager/sdk'
-base_jni = tm_jni_env.get('SRC_DIR') + '/android/android_api/base/jni'
-extlibs = tm_jni_env.get('SRC_DIR') + '/extlibs'
-
-######################################################################
-# Build flags
-######################################################################
-tm_jni_env.AppendUnique(CXXFLAGS = ['-Wall', '-DLINUX', '-DNDEBUG'])
-tm_jni_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions', '-std=c++0x'])
-tm_jni_env.AppendUnique(LIBPATH = [base_jni+'/../libs/'+tm_jni_env.get('TARGET_ARCH')])
-tm_jni_env.PrependUnique(LIBS = ['ocstack-jni', 'TGMSDKLibrary', 'oc', 'oc_logger', 'gnustl_shared', 'log'])
-
-tm_jni_env.AppendUnique(CPPPATH = [tm_sdk+'/inc'])
-tm_jni_env.AppendUnique(CPPPATH = [base_jni])
-tm_jni_env.AppendUnique(CPPPATH = ['tm/inc', 'jniutil/inc', extlibs+'/timer/'])
-
-if target_os not in ['darwin', 'ios', 'windows']:
- tm_jni_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
-
-######################################################################
-# Source files and Targets
-######################################################################
-tm_jni_src = [tm_jni_env.Glob('tm/src/*.cpp'), tm_jni_env.Glob('jniutil/src/*.cpp')]
-tm_jni = tm_jni_env.SharedLibrary('things-manager-jni', tm_jni_src)
-
-tm_jni_env.InstallTarget(tm_jni, 'libthings-manager-jni')
-
-# Install the libraries to /libs/<TARGET_ARCH> directory
-tm_jni_env.Install(tm_sdk+'/java/libs/'+tm_jni_env.get('TARGET_ARCH'),tm_jni_env.get('BUILD_DIR')+'/liboc_logger.so')
-tm_jni_env.Install(tm_sdk+'/java/libs/'+tm_jni_env.get('TARGET_ARCH'),tm_jni_env.get('BUILD_DIR')+'/liboctbstack.so')
-tm_jni_env.Install(tm_sdk+'/java/libs/'+tm_jni_env.get('TARGET_ARCH'),tm_jni_env.get('BUILD_DIR')+'/liboc.so')
-tm_jni_env.Install(tm_sdk+'/java/libs/'+tm_jni_env.get('TARGET_ARCH'),tm_jni_env.get('BUILD_DIR')+'/libconnectivity_abstraction.so')
-tm_jni_env.Install(tm_sdk+'/java/libs/'+tm_jni_env.get('TARGET_ARCH'),base_jni+'/../libs/'+tm_jni_env.get('TARGET_ARCH')+'/libocstack-jni.so')
-tm_jni_env.Install(tm_sdk+'/java/libs/'+tm_jni_env.get('TARGET_ARCH'),base_jni+'/../libs/'+tm_jni_env.get('TARGET_ARCH')+'/libca-interface.so')
-tm_jni_env.Install(tm_sdk+'/java/libs/'+tm_jni_env.get('TARGET_ARCH'),tm_jni_env.get('BUILD_DIR')+'/libTGMSDKLibrary.so')
-tm_jni_env.Install(tm_sdk+'/java/libs/'+tm_jni_env.get('TARGET_ARCH'),tm_jni)
-
-gnu_lib_paths = env.get('LIBPATH')
-for gnu_lib_path in gnu_lib_paths:
- gnu_lib_path = gnu_lib_path + '/libgnustl_shared.so'
- if os.path.exists(gnu_lib_path):
- tm_jni_env.Install(tm_sdk+'/java/libs/'+tm_jni_env.get('TARGET_ARCH'), gnu_lib_path)
- break
-
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-/**
- * @file
- * This file contains the JGetter class declarations and its functions required
- * for getting and setting basic data types in C++ and Java.
- */
-
-#ifndef JNI_GETTER_H_
-#define JNI_GETTER_H_
-
-#include <string>
-#include <jni.h>
-
-/**
- * This class provide utility for get/set basic data types in C++ and Java.
- */
-class JGetter
-{
- public:
- /**
- * This function is called to get String field from the C++ object.
- *
- * @param env
- * JNI Environment reference
- * @param object
- * JObject from which string field is expected
- * @param fieldName
- * Name of the field to be extracted from JObject
- * @param value
- * reference to string value mentioned in fieldName
- *
- * @return returns true on success and false on failer.
- */
- static bool getJStringField(JNIEnv *env, jobject &object, const char *fieldName,
- std::string &value);
-
- /**
- * This function is called to get Boolean field from the C++ object.
- *
- * @param env
- * JNI Environment reference
- * @param object
- * JObject from which boolean field is expected
- * @param fieldName
- * Name of the field to be extracted from JObject
- * @param value
- * reference to boolean value mentioned in fieldName
- *
- * @return returns true on success and false on failer.
- */
- static bool getJBoolField(JNIEnv *env, jobject &object, const char *fieldName,
- bool &value);
-
- /**
- * This function is called to get Integer field from the C++ object.
- *
- * @param env
- * JNI Environment reference
- * @param object
- * JObject from which integer field is expected
- * @param fieldName
- * Name of the field to be extracted from JObject
- * @param value
- * reference to integer value mentioned in fieldName
- *
- * @return returns true on success and false on failer.
- */
- static bool getJIntField(JNIEnv *env, jobject &object, const char *fieldName, int &value);
-
- /**
- * This function is called to get Object reference from the C++ object.
- *
- * @param env
- * JNI Environment reference
- * @param object
- * JObject from which Object reference is expected
- * @param fieldName
- * Name of the field to be extracted from JObject
- * @param fieldType
- * Type of the field to be extracted from JObject
- * @param value
- * reference to Object reference mentioned in fieldName
- *
- * @return returns true on success and false on failure
- */
- static bool getJObjectField(JNIEnv *env, jobject &object, const char *fieldName,
- const char *fieldType, jobject &value);
-};
-#endif //JNI_GETTER_H_
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-/**
- * @file
- * This file contains the JObject class declarations and its functions required
- * for getting and setting basic data types in C++ and Java.
- */
-
-#ifndef JNI_OBJECT_H_
-#define JNI_OBJECT_H_
-
-#include <jni.h>
-#include "JniOcResource.h"
-
-/**
- * This class provides a set of functions for JNI object.
- */
-class JObject
-{
- public:
- /**
- * constructor
- */
- JObject(JNIEnv *env);
-
- /**
- * constructor
- */
- JObject(JNIEnv *env, jobject obj);
-
- /**
- * constructor
- */
- JObject(JNIEnv *env, const char *classPath);
-
- /**
- * destructor
- */
- virtual ~JObject();
-
- /**
- * Function to get the jobject.
- *
- * @return jobject, returns a new JNI object or NULL otherwise.
- */
- virtual jobject getObject() const;
-
- /**
- * Function to detach the jobject.
- */
- void detachObject();
-
- protected:
- /**
- * JNI Environment Pointer
- */
- JNIEnv *m_pEnv;
- /**
- * Java Object
- */
- jobject m_pObject;
- /**
- * Java Class
- */
- jclass m_pClazz;
- /**
- * Boolean variable to check if an object is new.
- */
- bool m_fIsNewObject;
-};
-#endif //JNI_OBJECT_H_
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-/**
- * @file
- * This file contains the JSetter class declarations and and its functions required
- * to set data types in C++ object from Java object.
- */
-
-#ifndef JNI_SETTER_H_
-#define JNI_SETTER_H_
-
-#include <jni.h>
-
-/**
- * This class provide utility to set data types in C++ object from Java object.
- */
-class JSetter
-{
- public:
-
- /**
- * This function is called to set Integer field in to C++ object.
- *
- * @param env
- * JNI Environment reference
- * @param object
- * JObject to which integer field will be set.
- * @param fieldName
- * Name of the field to be set in JObject
- * @param value
- * integer value mentioned in fieldName
- *
- * @return returns true on success and false on failer.
- */
- static bool setJIntField(JNIEnv *env, jobject &object, const char *fieldName, int value);
-
- /**
- * This function is called to set Long field in to C++ object.
- *
- * @param env
- * JNI Environment reference
- * @param object
- * JObject to which Long field will be set.
- * @param fieldName
- * Name of the field to be set in JObject
- * @param value
- * Long value mentioned in fieldName
- *
- * @return returns true on success and false on failer.
- */
- static bool setJLongField(JNIEnv *env, jobject &object, const char *fieldName,
- jlong value);
-
- /**
- * This function is called to Set Boolean field to C++ object.
- *
- * @param env
- * JNI Environment reference
- * @param object
- * JObject to which boolean field has to be set
- * @param fieldName
- * Name of the field to be set in JObject
- * @param value
- * boolean value mentioned in fieldName
- *
- * @return returns true on success and false on failer.
- */
- static bool setJBoolField(JNIEnv *env, jobject &object, const char *fieldName, bool value);
- /**
- * This function is called to Set String field from the C++ object.
- *
- * @param env
- * JNI Environment reference
- * @param object
- * JObject in which string value has to be set
- * @param fieldName
- * Name of the field to be set in JObject
- * @param value
- * string value mentioned in fieldName
- *
- * @return returns true on success and false on failer.
- */
- static bool setJStringField(JNIEnv *env, jobject &object, const char *fieldName,
- const char *value);
-
- /**
- * This function is called to set Object reference in C++ object.
- *
- * @param env
- * JNI Environment reference
- * @param object
- * JObject to which Object reference is to be set.
- * @param fieldName
- * Name of the field to be set in JObject
- * @param fieldType
- * Type of the field to be set in JObject
- * @param value
- * value of Object mentioned in fieldName
- *
- * @return returns true on success and false on failer.
- */
- static bool setJObjectField(JNIEnv *env, jobject &object, const char *fieldName,
- const char *fieldType, const jobject value);
-};
-
-#endif //JNI_SETTER_H_
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-/**
- * @file
- * This file contains the declaration of JString class and its members related to JString.
- */
-
-#ifndef JNI_STRING_H_
-#define JNI_STRING_H_
-
-#include <string>
-
-#include "jni_object.h"
-
-/**
- * This class inherits JObject class and provides a set of functions for JNI String.
- */
-class JString : public JObject
-{
- public:
- /**
- * constructor
- */
- JString(JNIEnv *env, jstring value);
- /**
- * constructor
- */
- JString(JNIEnv *env, const char *value);
- /**
- * constructor
- */
- JString(JNIEnv *env, const std::string &value);
- /**
- * destructor
- */
- ~JString();
-
- /**
- * Function to get the string value and set it.
- *
- * @param value - String value to set to a private member variable.
- *
- * @return bool - true on success
- */
- bool getValue(std::string &value);
-
- /**
- * Function to get the private string value.
- *
- * @return C String value.
- */
- const char *c_str();
-
- private:
- std::string m_cstr;
-};
-#endif //JNI_STRING_H_
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-/**
- * @file
- * This file contains the essential declarations and functions required
- * for JNI implementation.
- */
-
-#ifndef JNI_THINGS_MANAGER_JVM_H_
-#define JNI_THINGS_MANAGER_JVM_H_
-
-#include <jni.h>
-#include <thread>
-#include <mutex>
-
-#define TM_SERVICE_GROUP_MANAGER_CLASS_PATH "org/iotivity/service/tm/GroupManager"
-#define TM_SERVICE_GROUP_MANAGER_CLASS_TYPE "Lorg/iotivity/service/tm/GroupManager;"
-
-#define TM_SERVICE_THINGS_CONFIGURATION_CLASS_PATH "org/iotivity/service/tm/ThingsConfiguration"
-#define TM_SERVICE_THINGS_CONFIGURATION_CLASS_TYPE "Lorg/iotivity/service/tm/ThingsConfigurationn;"
-
-#define TM_SERVICE_THINGS_MAINTENANCE_CLASS_PATH "org/iotivity/service/tm/ThingsMaintenance"
-#define TM_SERVICE_THINGS_MAINTENANCE_CLASS_TYPE "Lorg/iotivity/service/tm/ThingsMaintenance;"
-
-#define TM_SERVICE_PLATFORM_CLASS_PATH "org/iotivity/base/OcPlatform"
-#define TM_SERVICE_PLATFORM_CLASS_TYPE "Lorg/iotivity/base/OcPlatform;"
-
-#define TM_SERVICE_PLATFORM_CONFIG_CLASS_PATH "org/iotivity/base/PlatformConfig"
-#define TM_SERVICE_PLATFORM_CONFIG_CLASS_TYPE "Lorg/iotivity/base/PlatformConfig;"
-
-#define TM_SERVICE_CAPABILITY_PATH "org/iotivity/service/tm/Capability"
-#define TM_SERVICE_CAPABILITY_TYPE "Lorg/iotivity/service/tm/Capability;"
-
-#define TM_SERVICE_ACTION_PATH "org/iotivity/service/tm/Action"
-#define TM_SERVICE_ACTION_TYPE "Lorg/iotivity/service/tm/Action;"
-
-#define TM_SERVICE_ACTIONSET_PATH "org/iotivity/service/tm/ActionSet"
-#define TM_SERVICE_ACTIONSET_TYPE "Lorg/iotivity/service/tm/ActionSet;"
-
-#define TM_SERVICE_OCRESOURCE_PATH "org/iotivity/base/OcResource"
-#define TM_SERVICE_OCRESOURCE_TYPE "Lorg/iotivity/base/OcResource;"
-
-#define TM_SERVICE_HEADER_OPTION_PATH "org/iotivity/base/OcHeaderOption"
-#define TM_SERVICE_HEADER_OPTION_TYPE "Lorg/iotivity/base/OcHeaderOption;"
-
-#define TM_SERVICE_OCREPRESENTATION_PATH "org/iotivity/base/OcRepresentation"
-#define TM_SERVICE_OCREPRESENTATION_TYPE "Lorg/iotivity/base/OcRepresentation;"
-
-#define TM_SERVICE_OCRESOURCEHANDLE_PATH "org/iotivity/base/OcResourceHandle"
-#define TM_SERVICE_OCRESOURCEHANDLE_TYPE "Lorg/iotivity/base/OcResourceHandle;"
-
-#define TM_SERVICE_TIME_PATH "org/iotivity/service/tm/Time"
-
-#define TM_JAVA_VECTOR_CLASS_PATH "java/util/Vector"
-#define TM_JAVA_VECTOR_TYPE "Ljava/util/Vector;"
-
-#define TM_JAVA_STRING_TYPE "Ljava/lang/String;"
-
-/**
- * This class provides functions related to JNI Environment.
- */
-class ThingsManagerJVM
-{
- public:
- /**
- * destructor
- */
- ~ThingsManagerJVM() {};
-
- /**
- * Get JVM instance
- */
- static JNIEnv *getEnv();
-
- /**
- * Release aquired JVM instance.
- */
- static void releaseEnv();
-
- public:
- /**
- * Java VM pointer
- */
- static JavaVM *m_jvm;
-
- private:
- /**
- * constructor
- */
- ThingsManagerJVM();
-
- /**
- * Mutex for thread synchronization.
- */
- static std::mutex m_currentThreadMutex;
-};
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-jclass GetJClass(const char *szClassPath);
-jobject GetJObjectInstance(const char *szClassPath);
-#ifdef __cplusplus
-}
-#endif
-#endif //JNI_THINGS_MANAGER_JVM_H_
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include "jni_getter.h"
-
-#include <string>
-
-#include "JniOcResource.h"
-
-#define LOG_TAG "TM_JGetter"
-
-bool JGetter::getJStringField(JNIEnv *env, jobject &object, const char *fieldName,
- std::string &value)
-{
- if (NULL == env ||
- NULL == object ||
- NULL == fieldName)
- {
- LOGE("getJStringField invalid parameters");
- return false;
- }
-
- jclass clazz = env->GetObjectClass( object );
- if (NULL == clazz)
- {
- LOGE("GetObjectClass failed [%s]", fieldName);
- return false;
- }
-
- jfieldID fieldID = env->GetFieldID( clazz, fieldName, "Ljava/lang/String;" );
- if (0 == fieldID)
- {
- LOGE("GetFieldID failed [%s]", fieldName);
- env->DeleteLocalRef(clazz);
- return false;
- }
-
- jstring jValue = (jstring)env->GetObjectField( object, fieldID );
- if (NULL == jValue)
- {
- LOGE("GetObjectField failed [%s]", fieldName);
- env->DeleteLocalRef(clazz);
- return false;
- }
-
- const char *cstr = env->GetStringUTFChars(jValue, 0);
- if (cstr == NULL)
- {
- LOGE("GetStringUTFChars failed");
- }
- else
- {
- value = cstr;
- env->ReleaseStringUTFChars(jValue, cstr);
- }
-
- env->DeleteLocalRef(clazz);
- env->DeleteLocalRef(jValue);
-
- return true;
-}
-
-bool JGetter::getJBoolField(JNIEnv *env, jobject &object, const char *fieldName, bool &value)
-{
- if (NULL == env ||
- NULL == object ||
- NULL == fieldName)
- {
- LOGE("getJBoolField invalid parameters");
- return false;
- }
-
- jclass clazz = env->GetObjectClass( object );
- if (NULL == clazz)
- {
- LOGE("GetObjectClass failed");
- return false;
- }
-
- jfieldID fieldID = env->GetFieldID( clazz, fieldName, "Z" );
- if (0 == fieldID)
- {
- LOGE("GetFieldID failed [%s]", fieldName);
- env->DeleteLocalRef( clazz );
- return false;
- }
-
- value = env->GetBooleanField( object, fieldID );
-
- env->DeleteLocalRef(clazz);
-
- return true;
-}
-
-bool JGetter::getJIntField(JNIEnv *env, jobject &object, const char *fieldName, int &value)
-{
- if (NULL == env ||
- NULL == object ||
- NULL == fieldName)
- {
- LOGE("getJIntField invalid parameters");
- return false;
- }
-
- jclass clazz = env->GetObjectClass( object );
- if (NULL == clazz)
- {
- LOGE("GetObjectClass failed");
- return false;
- }
-
- jfieldID fieldID = env->GetFieldID( clazz, fieldName, "I" );
- if (0 == fieldID)
- {
- LOGE("GetFieldID failed [%s]", fieldName);
- env->DeleteLocalRef( clazz );
- return false;
- }
-
- value = env->GetIntField( object, fieldID );
-
- env->DeleteLocalRef(clazz);
-
- return true;
-}
-
-bool JGetter::getJObjectField(JNIEnv *env, jobject &object, const char *fieldName,
- const char *fieldType, jobject &value)
-{
- if (NULL == env ||
- NULL == object ||
- NULL == fieldName)
- {
- return false;
- }
-
- jclass clazz = env->GetObjectClass( object );
- if (NULL == clazz)
- {
- return false;
- }
-
- jfieldID fieldID = env->GetFieldID( clazz, fieldName, fieldType );
- if (0 == fieldID)
- {
- LOGE("GetFieldID failed [%s][%s]", fieldName, fieldType);
- return false;
- }
-
- value = env->GetObjectField( object, fieldID );
- if (NULL == value)
- {
- return false;
- }
-
- env->DeleteLocalRef(clazz);
-
- return true;
-}
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include "jni_object.h"
-
-#define LOG_TAG "TM_JObject"
-
-JObject::JObject(JNIEnv *env) : m_pEnv( env ),
- m_pObject(NULL),
- m_pClazz( NULL ),
- m_fIsNewObject(true)
-{
-}
-
-JObject::JObject(JNIEnv *env, jobject obj) : m_pEnv(NULL),
- m_pObject(NULL),
- m_pClazz(NULL),
- m_fIsNewObject(false)
-{
- if ( NULL == env || NULL == obj)
- {
- return;
- }
-
- m_pEnv = env;
- m_pObject = obj;
- m_pClazz = m_pEnv->GetObjectClass( obj );
-}
-
-JObject::JObject(JNIEnv *env, const char *classPath) : m_pEnv(NULL),
- m_pObject(NULL),
- m_pClazz(NULL),
- m_fIsNewObject(true)
-{
- if ( NULL == env || NULL == classPath)
- {
- LOGI("JObject Invalid parameters");
- return;
- }
-
- m_pEnv = env;
- //m_pClazz = GetJClass( classPath );
-
- if (NULL == m_pClazz)
- {
- LOGE( "GetJClass failed [%s]" , classPath);
- return;
- }
-
- jmethodID mid = env->GetMethodID(m_pClazz, "<init>", "()V");
- if (NULL == mid)
- {
- LOGE( "GetMethodID failed [%s]" , classPath);
- return;
- }
-
- m_pObject = env->NewObject(m_pClazz, mid);
-}
-
-JObject::~JObject()
-{
- if (m_pEnv)
- {
- if (m_pObject && m_fIsNewObject)
- {
- m_pEnv->DeleteLocalRef( m_pObject );
- }
-
- if (m_pClazz && !m_fIsNewObject)
- {
- m_pEnv->DeleteLocalRef( m_pClazz );
- }
- }
-}
-
-jobject JObject::getObject() const
-{
- return m_pObject;
-}
-
-
-void JObject::detachObject()
-{
- if (m_fIsNewObject)
- {
- m_fIsNewObject = false;
- m_pClazz = NULL;
- }
-}
-
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include "jni_setter.h"
-
-#include <string>
-
-#include "JniOcResource.h"
-
-#define LOG_TAG "TM_JSetter"
-
-bool JSetter::setJStringField(JNIEnv *env, jobject &object, const char *fieldName,
- const char *value)
-{
- if (NULL == env || NULL == fieldName)
- {
- LOGE("setJStringField invalid parameters");
- return false;
- }
-
- jclass clazz = env->GetObjectClass( object );
- if (NULL == clazz)
- {
- LOGE("GetObjectClass failed");
- return false;
- }
-
- jfieldID fieldID = env->GetFieldID( clazz, fieldName, "Ljava/lang/String;");
- if (0 == fieldID)
- {
- LOGE("GetFieldID failed [%s]", fieldName);
- env->DeleteLocalRef( clazz );
- return false;
- }
-
- jstring jvalue ;
- if (value != NULL && strlen(value) > 0)
- {
- jclass strClass = env->FindClass("java/lang/String");
- jmethodID ctorID = env->GetMethodID(strClass, "<init>", "([BLjava/lang/String;)V");
- jbyteArray bytes = env->NewByteArray(strlen(value));
- env->SetByteArrayRegion(bytes, 0, strlen(value), (jbyte *)value);
- jstring encoding = env->NewStringUTF("utf-8");
- jvalue = (jstring)env->NewObject(strClass, ctorID, bytes, encoding);
- env->DeleteLocalRef(strClass);
- env->DeleteLocalRef(bytes);
- env->DeleteLocalRef(encoding);
- }
- else
- {
- jvalue = env->NewStringUTF("");
- }
-
- env->SetObjectField(object, fieldID, jvalue);
-
- env->DeleteLocalRef(jvalue);
- env->DeleteLocalRef( clazz );
-
- return true;
-}
-
-bool JSetter::setJIntField(JNIEnv *env, jobject &object, const char *fieldName, int value)
-{
- if (NULL == env || NULL == fieldName)
- {
- LOGE("setJIntField invalid paramter");
- return false;
- }
-
- jclass clazz = env->GetObjectClass( object );
- if (NULL == clazz)
- {
- LOGE("GetObjectClass failed");
- return false;
- }
-
- jfieldID fieldID = env->GetFieldID( clazz, fieldName, "I");
- if (0 == fieldID)
- {
- LOGE("GetFieldID failed [%s]", fieldName);
- env->DeleteLocalRef( clazz );
- return false;
- }
- env->SetIntField(object, fieldID, value);
-
- env->DeleteLocalRef( clazz );
-
- return true;
-}
-
-bool JSetter::setJLongField(JNIEnv *env, jobject &object, const char *fieldName, jlong value)
-{
- if (NULL == env || NULL == fieldName)
- {
- LOGE("setJLongField invalid parameters");
- return false;
- }
-
- jclass clazz = env->GetObjectClass( object );
- if (NULL == clazz)
- {
- LOGE("GetObjectClass failed");
- return false;
- }
-
- jfieldID fieldID = env->GetFieldID( clazz, fieldName, "J");
- if (0 == fieldID)
- {
- LOGE("GetFieldID failed [%s]", fieldName);
- env->DeleteLocalRef( clazz );
- return false;
- }
- env->SetLongField(object, fieldID, value);
-
- env->DeleteLocalRef( clazz );
-
- return true;
-}
-
-bool JSetter::setJBoolField(JNIEnv *env, jobject &object, const char *fieldName, bool value)
-{
- if (NULL == env || NULL == fieldName)
- {
- LOGE("setJBoolField invalid parameters");
- return false;
- }
-
- jclass clazz = env->GetObjectClass( object );
- if (NULL == clazz)
- {
- LOGE("GetObjectClass failed");
- return false;
- }
-
- jfieldID fieldID = env->GetFieldID( clazz, fieldName, "Z");
- if (0 == fieldID)
- {
- LOGE("GetFieldID failed [%s]", fieldName);
- env->DeleteLocalRef( clazz );
- return false;
- }
- env->SetBooleanField(object, fieldID, value);
-
- env->DeleteLocalRef( clazz );
-
- return true;
-}
-
-bool JSetter::setJObjectField(JNIEnv *env, jobject &object, const char *fieldName,
- const char *fieldType, const jobject value)
-{
- if (NULL == env || NULL == fieldName)
- {
- LOGE("setJBoolField invalid parameters");
- return false;
- }
-
- jclass clazz = env->GetObjectClass( object );
- if (NULL == clazz)
- {
- LOGE("GetObjectClass failed");
- return false;
- }
-
- jfieldID fieldID = env->GetFieldID( clazz, fieldName, fieldType);
- if (0 == fieldID)
- {
- LOGE("GetFieldID failed [%s] [%s]", fieldName, fieldType);
- env->DeleteLocalRef( clazz );
- return false;
- }
- env->SetObjectField(object, fieldID, value);
-
- env->DeleteLocalRef( clazz );
-
- return true;
-}
-
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include "jni_string.h"
-
-#define LOG_TAG "TM_JString"
-
-JString::JString(JNIEnv *env, jstring value) : JObject(env, value)
-{
- const char *buff = env->GetStringUTFChars(value, 0);
-
- m_cstr = buff;
-
- env->ReleaseStringUTFChars(value, buff);
-}
-
-JString::JString(JNIEnv *env, const char *value) : JObject(env)
-{
- m_cstr = value;
-
- if (env)
- {
- m_pObject = env->NewStringUTF( value );
- }
-}
-
-JString::JString(JNIEnv *env, const std::string &value) : JObject(env)
-{
- m_cstr = value;
-
- if (env)
- {
- m_pObject = env->NewStringUTF( value.c_str() );
- }
-}
-
-JString::~JString()
-{
-}
-
-bool JString::getValue(std::string &value)
-{
- value = m_cstr;
- return true;
-}
-
-const char *JString::c_str()
-{
- return m_cstr.c_str();
-}
-
-
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include <string>
-
-#include "jni_things_manager_jvm.h"
-#include "jni_group_manager.h"
-#include "jni_things_configuration.h"
-#include "jni_things_maintenance.h"
-#include "jni_things_manager_util.h"
-#include "JniOcResource.h"
-
-#define TM_ERROR_JNI_FOUND_CLASS_FAILED -2005
-
-/**
- * This class provides functions for initializing the Java class path and Java class.
- */
-class JClassMap
-{
- public:
- /**
- * Java Class
- */
- jclass classRef;
- /**
- * Java Class Path
- */
- const char *szClassPath;
-
- /**
- * constructor
- */
- JClassMap(const char *path)
- : classRef(NULL)
- {
- szClassPath = path;
- }
-};
-
-/**
- * This class provides functions for initializing the Java Class path
- * and Java Class Object.
- */
-class JObjectMap
-{
- public:
- /**
- * Java Object
- */
- jobject object;
- /**
- * Java Class Path
- */
- const char *szClassPath;
-
- /**
- * @brief constructor
- */
- JObjectMap(const char *path)
- : object(NULL)
- {
- szClassPath = path;
- }
-};
-
-static JClassMap gJClassMapArray[] =
-{
- JClassMap(TM_SERVICE_GROUP_MANAGER_CLASS_PATH),
- JClassMap(TM_SERVICE_THINGS_CONFIGURATION_CLASS_PATH),
- JClassMap(TM_SERVICE_THINGS_MAINTENANCE_CLASS_PATH),
- JClassMap(TM_SERVICE_OCRESOURCE_PATH),
- JClassMap(TM_SERVICE_OCREPRESENTATION_PATH),
- JClassMap(TM_SERVICE_HEADER_OPTION_PATH),
- JClassMap(TM_SERVICE_ACTIONSET_PATH),
- JClassMap(TM_SERVICE_CAPABILITY_PATH),
- JClassMap(TM_SERVICE_ACTION_PATH),
- JClassMap(TM_SERVICE_PLATFORM_CLASS_PATH),
- JClassMap(TM_SERVICE_PLATFORM_CONFIG_CLASS_PATH),
- JClassMap(TM_SERVICE_OCRESOURCEHANDLE_PATH)
-};
-
-static JObjectMap gJObjectMapArray[] =
-{
- JObjectMap(TM_SERVICE_THINGS_CONFIGURATION_CLASS_PATH),
- JObjectMap(TM_SERVICE_THINGS_MAINTENANCE_CLASS_PATH)
-};
-
-static JNINativeMethod gGroupManagerMethodTable[] =
-{
- { "nativeFindCandidateResource", "(Ljava/util/Vector;I)I", (void *) JNIGroupManagerFindCandidateResource},
- { "nativeSubscribeCollectionPresence", "(Lorg/iotivity/base/OcResource;)I", (void *) JNIGroupManagerSubscribeCollectionPresence},
- { "nativeBindResourceToGroup", "(Lorg/iotivity/base/OcResource;Lorg/iotivity/base/OcResourceHandle;)Lorg/iotivity/base/OcResourceHandle;", (void *) JNIGroupManagerBindResourceToGroup},
- { "nativeAddActionSet", "(Lorg/iotivity/base/OcResource;Lorg/iotivity/service/tm/ActionSet;)I", (void *) JNIGroupManagerAddActionSet},
- { "nativeExecuteActionSet", "(Lorg/iotivity/base/OcResource;Ljava/lang/String;)I", (void *) JNIGroupManagerExecuteActionSet},
- { "nativeExecuteActionSetWithDelay", "(Lorg/iotivity/base/OcResource;Ljava/lang/String;J)I", (void *) JNIGroupManagerExecuteActionSetWithDelay},
- { "nativeCancelActionSet", "(Lorg/iotivity/base/OcResource;Ljava/lang/String;)I", (void *) JNIGroupManagerCancelActionSet},
- { "nativeGetActionSet", "(Lorg/iotivity/base/OcResource;Ljava/lang/String;)I", (void *) JNIGroupManagerGetActionSet},
- { "nativeDeleteActionSet", "(Lorg/iotivity/base/OcResource;Ljava/lang/String;)I", (void *) JNIGroupManagerDeleteActionSet}
-};
-
-static JNINativeMethod gThingsConfigurationMethodTable[] =
-{
- { "nativeUpdateConfigurations", "(Lorg/iotivity/base/OcResource;Ljava/util/Map;)I", (void *) JNIThingsConfigurationUpdateConfigurations},
- { "nativeGetConfigurations", "(Lorg/iotivity/base/OcResource;Ljava/util/Vector;)I", (void *) JNIThingsConfigurationGetConfigurations},
- { "nativeGetListOfSupportedConfigurationUnits", "()Ljava/lang/String;", (void *) JNIThingsConfigurationGetListOfSupportedConfigurationUnits},
- { "nativeDoBootstrap", "()I", (void *) JNIThingsConfigurationDoBootstrap},
-};
-
-static JNINativeMethod gThingsMaintenanceMethodTable[] =
-{
- { "nativeReboot", "(Lorg/iotivity/base/OcResource;)I", (void *) JNIThingsMaintenanceReboot},
- { "nativeFactoryReset", "(Lorg/iotivity/base/OcResource;)I", (void *) JNIThingsMaintenanceFactoryReset},
- { "nativeGetListOfSupportedMaintenanceUnits", "()Ljava/lang/String;", (void *) JNIThingsMaintenanceGetListOfSupportedConfigurationUnits}
-
-};
-
-static int gGroupManagerMethodTableSize = sizeof(gGroupManagerMethodTable) / sizeof(
- gGroupManagerMethodTable[0]);
-
-static int gThingsConfigurationMethodTableSize = sizeof(gThingsConfigurationMethodTable) / sizeof(
- gThingsConfigurationMethodTable[0]);
-
-static int gThingsMaintenanceMethodTableSize = sizeof(gThingsMaintenanceMethodTable) / sizeof(
- gThingsMaintenanceMethodTable[0]);
-
-
-int InitializeJClassMapArray(JNIEnv *env)
-{
- LOGI("InitializeJClassMapArray: Enter");
-
- unsigned int nLen = sizeof(gJClassMapArray) / sizeof(JClassMap);
-
- for (unsigned int i = 0; i < nLen; i++)
- {
- jclass classRef = env->FindClass(gJClassMapArray[i].szClassPath);
- if (NULL == classRef)
- {
- LOGE("FindClass failed for [%s]", gJClassMapArray[i].szClassPath);
- return -1;
- }
- gJClassMapArray[i].classRef = (jclass)env->NewGlobalRef(classRef);
- env->DeleteLocalRef(classRef);
- }
-
- LOGI("InitializeJClassMapArray: Exit");
- return 0;
-}
-
-jclass GetJClass(const char *szClassPath)
-{
- unsigned int nLen = sizeof(gJClassMapArray) / sizeof(JClassMap);
-
- jclass classRef = NULL;
-
- for (unsigned int i = 0; i < nLen; i++)
- {
- if (0 == strcmp(gJClassMapArray[i].szClassPath, szClassPath))
- {
- classRef = gJClassMapArray[i].classRef;
- break;
- }
- }
-
- return classRef;
-}
-
-void DeleteClassMapArray(JNIEnv *env)
-{
- LOGI("DeleteClassMapArray: Enter");
-
- unsigned int nLen = sizeof(gJClassMapArray) / sizeof(JClassMap);
- for (unsigned int i = 0; i < nLen; i++)
- {
- if (NULL != gJClassMapArray[i].classRef)
- {
- env->DeleteGlobalRef(gJClassMapArray[i].classRef);
- gJClassMapArray[i].classRef = NULL;
- }
- }
-
- LOGI("DeleteClassMapArray: Exit");
-}
-
-int InitializeJObjectMapArray(JNIEnv *env)
-{
- LOGI("InitializeJObjectMapArray: Enter");
-
- unsigned int nLen = sizeof(gJObjectMapArray) / sizeof(JObjectMap);
-
- for (unsigned int i = 0; i < nLen; i++)
- {
- jclass classRef = env->FindClass(gJObjectMapArray[i].szClassPath);
- if (NULL == classRef)
- {
- LOGE("InitializeJObjectMapArray: FindClass failed for [%s]", gJObjectMapArray[i].szClassPath);
- return -1;
- }
-
- std::string methodSignature = "()L";
- methodSignature.append(gJObjectMapArray[i].szClassPath);
- methodSignature.append(";");
-
- // Get the object form "getInstance"
- jmethodID methodid = env->GetStaticMethodID(classRef, "getInstance", methodSignature.c_str());
- if (NULL == methodid)
- {
- LOGE("InitializeJObjectMapArray: GetStaticMethodID failed for [%s]",
- gJObjectMapArray[i].szClassPath);
- return -1;
- }
-
- // Get the singleton object
- jobject objectRef = (jobject)env->CallStaticObjectMethod(classRef, methodid);
- if (NULL == objectRef)
- {
- LOGE("InitializeJObjectMapArray: CallStaticObjectMethod failed for [%s]",
- gJObjectMapArray[i].szClassPath);
- return -1;
- }
-
- gJObjectMapArray[i].object = (jobject)env->NewGlobalRef(objectRef);
- env->DeleteLocalRef(classRef);
- }
-
- LOGI("InitializeJObjectMapArray: Exit");
- return 0;
-}
-
-jobject GetJObjectInstance(const char *szClassPath)
-{
- unsigned int nLen = sizeof(gJObjectMapArray) / sizeof(JObjectMap);
-
- jobject object = NULL;
-
- for (unsigned int i = 0; i < nLen; i++)
- {
- if (0 == strcmp(gJObjectMapArray[i].szClassPath, szClassPath))
- {
- object = gJObjectMapArray[i].object;
- break;
- }
- }
-
- return object;
-}
-
-void DeleteObjectMapArray(JNIEnv *env)
-{
- LOGI("DeleteObjectMapArray: Enter");
-
- unsigned int nLen = sizeof(gJObjectMapArray) / sizeof(JObjectMap);
- for (unsigned int i = 0; i < nLen; i++)
- {
- if (NULL != gJObjectMapArray[i].object)
- {
- env->DeleteGlobalRef(gJObjectMapArray[i].object);
- gJObjectMapArray[i].object = NULL;
- }
- }
-
- LOGI("DeleteObjectMapArray: Exit");
-}
-
-JavaVM *ThingsManagerJVM::m_jvm = NULL;
-std::mutex ThingsManagerJVM::m_currentThreadMutex;
-JNIEnv *ThingsManagerJVM::getEnv()
-{
- std::unique_lock<std::mutex> scoped_lock(m_currentThreadMutex);
-
- if (NULL == m_jvm)
- {
- LOGE("Failed to get JVM");
- return NULL;
- }
-
- JNIEnv *env = NULL;
- jint ret = m_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION);
- switch (ret)
- {
- case JNI_OK:
- return env;
- case JNI_EDETACHED:
- if (0 > m_jvm->AttachCurrentThread(&env, NULL))
- {
- LOGE("Failed to attach current thread to env");
- return NULL;
- }
- return env;
- case JNI_EVERSION:
- LOGE("JNI version not supported");
- default:
- LOGE("Failed to get the environment");
- return NULL;
- }
-}
-
-void ThingsManagerJVM::releaseEnv()
-{
- std::unique_lock<std::mutex> scoped_lock(m_currentThreadMutex);
-
- if (0 == m_jvm)
- {
- LOGE("Failed to release JVM");
- return;
- }
-
- m_jvm->DetachCurrentThread();
-}
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
-{
- LOGD("JNI_OnLoad: Enter");
-
- if (!vm)
- {
- LOGE("JNI_OnLoad: vm is invalid");
- return JNI_ERR;
- }
-
- JNIEnv *env = NULL;
- if (JNI_OK != vm->GetEnv((void **) &env, JNI_CURRENT_VERSION))
- {
- LOGE("JNI_OnLoad: Version check is failed!");
- return JNI_ERR;
- }
-
- if (0 != InitializeJClassMapArray(env))
- {
- LOGE("JNI_OnLoad: Initialize JClass Array failed!");
- return JNI_ERR;
- }
-
- if (0 != InitializeJObjectMapArray(env))
- {
- LOGE("JNI_OnLoad: Initialize JObject Array failed!");
- return JNI_ERR;
- }
-
- // Group Manager
- jclass groupManagerClassRef = GetJClass(TM_SERVICE_GROUP_MANAGER_CLASS_PATH);
-
- if (NULL == groupManagerClassRef)
- {
- LOGE("JNI_OnLoad: GetJClass gThingsManagerClass failed !");
- return JNI_ERR;
- }
-
- env->RegisterNatives(groupManagerClassRef, gGroupManagerMethodTable,
- gGroupManagerMethodTableSize);
-
- //Things Configuration
- jclass thingsConfigurationClassRef = GetJClass(TM_SERVICE_THINGS_CONFIGURATION_CLASS_PATH);
-
- if (NULL == thingsConfigurationClassRef)
- {
- LOGE("JNI_OnLoad: GetJClass gThingsManagerClass failed !");
- return JNI_ERR;
- }
-
- env->RegisterNatives(thingsConfigurationClassRef, gThingsConfigurationMethodTable,
- gThingsConfigurationMethodTableSize);
-
- //Things Maintenance
- jclass thingsMaintenanceClassRef = GetJClass(TM_SERVICE_THINGS_MAINTENANCE_CLASS_PATH);
-
- if (NULL == thingsMaintenanceClassRef)
- {
- LOGE("JNI_OnLoad: GetJClass gThingsManagerClass failed !");
- return JNI_ERR;
- }
-
- env->RegisterNatives(thingsMaintenanceClassRef, gThingsMaintenanceMethodTable,
- gThingsMaintenanceMethodTableSize);
-
- ThingsManagerJVM::m_jvm = vm;
-
- LOGI("JNI_OnLoad: Exit");
- return JNI_CURRENT_VERSION;
-}
-
-JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)
-{
- LOGD("JNI_OnUnload: Enter");
-
- JNIEnv *env = NULL;
- if (JNI_OK != vm->GetEnv((void **)&env, JNI_CURRENT_VERSION))
- {
- LOGE("JNI_OnLoad: Version check is failed!");
- return;
- }
-
- // delete all class references
- DeleteClassMapArray(env);
-
- // delete all jobject
- DeleteObjectMapArray(env);
-
- LOGD("JNI_OnUnload: Exit");
-}
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-/**
- * @file
- * This file contains the declaration of JniAction class and
- * its members related to JniAction.
- */
-
-#ifndef JNI_ACTION_H_
-#define JNI_ACTION_H_
-
-#include <vector>
-#include <string>
-
-#include "jni_object.h"
-#include "jni_capability.h"
-
-/**
- * This class provides a set of functions to get and
- * set Action Class member variables.
- */
-class JniAction : public JObject
-{
- public:
- /**
- * constructor
- */
- JniAction(JNIEnv *env, jobject obj);
-
- /**
- * constructor
- */
- JniAction(JNIEnv *env);
-
- /**
- * destructor
- */
- ~JniAction();
-
- /**
- * Retrieves target value from JniAction class object.
- *
- * @param target - target value
- *
- * @return Boolean, true on success, otherwise false
- */
- bool getTarget(std::string &target);
-
- /**
- * Sets target value of JniAction class object.
- *
- * @param target - target value
- *
- * @return Boolean, true on success, otherwise false
- */
- bool setTarget(const std::string target);
-
- /**
- * Retrieves capability values from JniAction class object.
- *
- * @param capabilityList - capability list
- *
- * @return Boolean, true on success, otherwise false
- */
- bool getJniCapabilityValues(std::vector<OIC::Capability *> &capabilityList);
-
-};
-#endif //JNI_ACTION_H_
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-/**
- * @file
- * This file contains the declaration of JniActionSet class
- * and its members related to JniActionSet.
- */
-
-#ifndef JNI_ACTIONSET_H_
-#define JNI_ACTIONSET_H_
-
-#include <vector>
-#include <string>
-
-#include "GroupManager.h"
-#include "ActionSet.h"
-#include "jni_object.h"
-#include "jni_action.h"
-
-using namespace OC;
-using namespace OIC;
-
-/**
- * This class provides a set of functions to get and
- * set ActionSet Class member variables.
- */
-class JniActionSet : public JObject
-{
- public:
- /**
- * constructor
- */
- JniActionSet(JNIEnv *env, jobject obj);
-
- /**
- * constructor
- */
- JniActionSet(JNIEnv *env);
-
- /**
- * destructor
- */
- ~JniActionSet();
-
- /**
- * Retrieves target value from JniActionSet class object.
- *
- * @param name - ActionSet Name
- *
- * @return Boolean, true on success, otherwise false
- */
- bool getJniActionSetName(std::string &name);
-
- /**
- * Sets target value of JniActionSet class object
- *
- * @param name - ActionSet Name
- *
- * @return Boolean, true on success, otherwise false
- */
- bool setJniActionSetName(const std::string name);
-
- /**
- * Retrieves capability values from JniActionSet class object.
- *
- * @param actionList - List of Actions
- *
- * @return Boolean, true on success, otherwise false
- */
- bool getJniListOfActions(std::vector<OIC::Action *> &actionList);
-
- /**
- * Converts actionSet class from java to CPP.
- *
- * @param env - Default JNI Environment Pointer
- * @param jnewActionSet - action set
- *
- * @return OIC CPP ActionSet
- */
- ActionSet *getActionSet(JNIEnv *env, jobject jnewActionSet);
-
- /**
- * Converts Time class from java to CPP.
- *
- * @param env - Default JNI Environment Pointer
- * @param jnewActionSet - Java action set
- * @param pActionSet - CPP action set
- *
- * @return Boolean, true on success, otherwise false
- */
- bool setTimeInfo(JNIEnv *env, jobject jnewActionSet, OIC::ActionSet *pActionSet);
-};
-#endif //JNI_ACTIONSET_H_
-
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-/**
- * @file
- * This file contains the utility functions for conversions from java to CPP
- * and viceversa.
- */
-
-#ifndef JNI_CAPABILITY_H_
-#define JNI_CAPABILITY_H_
-
-#include <string>
-
-#include <ActionSet.h>
-#include "jni_object.h"
-
-/**
- * This class provides a set of functions to get and
- * set Capability Class member variables.
- */
-class JniCapability : public JObject
-{
- public:
- /**
- * constructor
- */
- JniCapability(JNIEnv *env, jobject obj);
-
- /**
- * constructor
- */
- JniCapability(JNIEnv *env);
-
- /**
- * destructor
- */
- ~JniCapability();
-
- /**
- * Retrieves Capability value from JniCapability class object.
- *
- * @param capability
- * [OUT] capability value
- *
- * @return Boolean, true on success, otherwise false
- */
- bool getJniCapabilityValue(std::string &capability);
-
- /**
- * Sets Capability value of JniCapability class object.
- *
- * @param capability
- * [IN] capability value
- *
- * @return Boolean, true on success, otherwise false
- */
- bool setJniCapabilityValue(const std::string capability);
-
- /**
- * Retrieves status of JniCapability class object.
- *
- * @param status
- * [OUT] status
- *
- * @return Boolean, true on success, otherwise false
- */
- bool getJniCapabilityStatus(std::string &status);
-
- /**
- * Sets status of JniCapability class object
- *
- * @param status
- * [IN] status
- *
- * @return Boolean, true on success, otherwise false.
- */
- bool setJniCapabilityStatus(const std::string status);
-};
-#endif //JNI_CAPABILITY_H_
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-/**
- * @file
- * This file contains the declaration of Group Manager APIs
- * for JNI implementation.
- */
-
-#ifndef JNI_GROUP_MANAGER_H_
-#define JNI_GROUP_MANAGER_H_
-
-#include <stdio.h>
-#include <string.h>
-
-#include <jni.h>
-#include <jni_string.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * API for discoverying candidate resources.
- *
- * @param resourceTypes - required resource types(called "candidate")
- * @param waitSec - Delay time in seconds to add before starting to find the resources in network.
- *
- * @return OCStackResult - return value of this API.
- * It returns OC_STACK_OK if success.
- *
- * NOTE: OCStackResult is defined in ocstack.h.
- */
-JNIEXPORT jint JNICALL JNIGroupManagerFindCandidateResource
-(JNIEnv *env, jobject interfaceObject, jobject resourceTypes, jint waitSec);
-
-/**
- * API for subscribing child's state.
- *
- * @param resource - collection resource for subscribing presence of all child resources.
- *
- * @return OCStackResult - return value of this API.
- * It returns OC_STACK_OK if success.
- *
- * NOTE: OCStackResult is defined in ocstack.h.
- */
-JNIEXPORT jint JNICALL JNIGroupManagerSubscribeCollectionPresence
-(JNIEnv *env, jobject interfaceObject, jobject resource);
-
-
-/**
- * API for register and bind resource to group.
- *
- * @param resource - resource for register and bind to group. It has all data.
- * @param collectionHandle - collection resource handle. It will be added child resource.
- *
- * @return childHandle - child resource handle.
- *
- * NOTE: OCStackResult is defined in ocstack.h.
- */
-JNIEXPORT jobject JNICALL JNIGroupManagerBindResourceToGroup
-(JNIEnv *env, jobject interfaceObject, jobject resource, jobject collectionHandle);
-
-/**
- * API for adding an Action Set.
- *
- * @param resource - resource type representing the target group
- * @param newActionSet - list of Action Set to be added
- *
- * @return OCStackResult - return value of this API.
- * It returns OC_STACK_OK if success.
- *
- * NOTE: OCStackResult is defined in ocstack.h.
- */
-
-JNIEXPORT jint JNICALL JNIGroupManagerAddActionSet
-(JNIEnv *env, jobject interfaceObject, jobject resource, jobject newActionSet);
-
-/**
- * API for executing the Action Set.
- *
- * @param resource - resource type representing the target group
- * @param actionSetName - Action Set name for executing the Action set
- *
- * @return OCStackResult - return value of this API.
- * It returns OC_STACK_OK if success.
- *
- * NOTE: OCStackResult is defined in ocstack.h.
- */
-JNIEXPORT jint JNICALL JNIGroupManagerExecuteActionSet
-(JNIEnv *env, jobject interfaceObject, jobject resource, jstring actionSetName);
-
-/**
- * API for executing the Action Set.
- *
- * @param resource - resource type representing the target group
- * @param actionSetName - Action Set name for executing the Action set
- * @param delay - waiting time for until action set run.
- *
- * @return OCStackResult - return value of this API.
- * It returns OC_STACK_OK if success.
- *
- * NOTE: OCStackResult is defined in ocstack.h.
- */
-JNIEXPORT jint JNICALL JNIGroupManagerExecuteActionSetWithDelay
-(JNIEnv *env, jobject interfaceObject, jobject resource, jstring actionSetName, jlong delay);
-
-/**
- * API for cancelling the Action Set.
- *
- * @param resource - resource type representing the target group
- * @param actionSetName - Action Set name for cancelling the Action set
- *
- * @return OCStackResult - return value of this API.
- * It returns OC_STACK_OK if success.
- *
- * NOTE: OCStackResult is defined in ocstack.h.
- */
-JNIEXPORT jint JNICALL JNIGroupManagerCancelActionSet
-(JNIEnv *env, jobject interfaceObject, jobject resource, jstring actionSetName);
-
-
-/**
- * API for reading the Action Set.
- *
- * @param resource - resource type representing the target group
- * @param actionSetName - Action Set name for reading the Action set
- *
- * @return OCStackResult - return value of this API.
- * It returns OC_STACK_OK if success.
- *
- * NOTE: OCStackResult is defined in ocstack.h.
- */
-JNIEXPORT jint JNICALL JNIGroupManagerGetActionSet
-(JNIEnv *env, jobject interfaceObject, jobject resource, jstring actionSetName);
-
-/**
- * API for removing the Action Set.
- *
- * @param resource - resource type representing the target group
- * @param actionSetName - Action Set name for removing the Action set
- *
- * @return OCStackResult - return value of this API.
- * It returns OC_STACK_OK if success.
- *
- * NOTE: OCStackResult is defined in ocstack.h.
- */
-JNIEXPORT jint JNICALL JNIGroupManagerDeleteActionSet
-(JNIEnv *env, jobject interfaceObject, jobject resource, jstring actionSetName);
-
-#ifdef __cplusplus
-}
-#endif
-#endif //JNI_GROUP_MANAGER_H_
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-/**
- * @file
- * This file contains the declaration of GroupManagerCallbacks class
- * and its members related to ThingsManagerCallbacks.
- */
-
-#ifndef JNI_GROUP_MANAGER_CALLBACKS_H_
-#define JNI_GROUP_MANAGER_CALLBACKS_H_
-
-#include <string>
-
-#include "GroupManager.h"
-
-/**
- *This class provides a set of callback functions for group management.
- */
-class GroupManagerCallbacks
-{
- public:
- GroupManagerCallbacks() {}
- virtual ~GroupManagerCallbacks() {}
-
- /**
- * This callback method is called when resources are discovered in network.
- *
- * @param resourceVector - List of resources discovered in the network
- */
- static void onFoundCandidateResource(std::vector< std::shared_ptr<OC::OCResource > >
- resourceVector);
-
- /**
- * This callback method is called for child resource presence status.
- *
- * @param resource - URI of resource.
- * @param result - error code.
- */
- static void onSubscribePresence(std::string resource, OCStackResult result);
-
- /**
- * This callback method is called when a response for the executeActionSet
- * or deleteActionSet request just arrives.
- *
- * @param headerOptions - It comprises of optionID and optionData as members.
- * @param rep - Configuration parameters are carried as a pair of attribute key and value
- * in a form of OCRepresentation instance.
- * @param eCode - error code.
- */
- static void onPostResponse(const OC::HeaderOptions &headerOptions,
- const OC::OCRepresentation &rep, const int eCode);
-
- /**
- * This callback method is called when a response for the addActionSet request
- * just arrives.
- *
- * @param headerOptions - It comprises of optionID and optionData as members.
- * @param rep - Configuration parameters are carried as a pair of attribute key and value
- * in a form of OCRepresentation instance.
- * @param eCode - error code.
- */
- static void onPutResponse(const OC::HeaderOptions &headerOptions,
- const OC::OCRepresentation &rep, const int eCode);
-
- /**
- * This callback method is called when a response for the getActionSet request
- * just arrives.
- *
- * @param headerOptions - It comprises of optionID and optionData as members.
- * @param rep - Configuration parameters are carried as a pair of attribute key and value
- * in a form of OCRepresentation instance.
- * @param eCode - error code.
- */
- static void onGetResponse(const OC::HeaderOptions &headerOptions,
- const OC::OCRepresentation &rep, const int eCode);
-
- /**
- * This method invokes the Callback function with particular name and signature.
- *
- * @param headerOptions - It comprises of optionID and optionData as members.
- * @param rep - Configuration parameters are carried as a pair of attribute key and value
- * in a form of OCRepresentation instance.
- * @param eCode - error code.
- * @param callbackName - callbackName to be invoked.
- * @param signature - Signature of the callback method to be called.
- */
- static void invokeCallback(const OC::HeaderOptions &headerOptions,
- const OC::OCRepresentation &rep, const int eCode,
- const char *callbackName, const char *signature);
-};
-#endif //JNI_GROUP_MANAGER_CALLBACKS_H_
-
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-/**
- * @file
- * This file contains the declaration of Things Configuration API's
- * for JNI implementation.
- */
-
-#ifndef JNI_THINGS_CONFIGURATION_H_
-#define JNI_THINGS_CONFIGURATION_H_
-
-#include <stdio.h>
-#include <string.h>
-
-#include <jni.h>
-#include <jni_string.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * API for updating configuration value of multiple things of a target group
- * or a single thing.
- * Before using the below function, a developer should acquire a resource pointer of
- * (collection) resource that he wants to send a request by calling findResource() function
- * provided in OCPlatform. And he should also notice a "Configuration Name" term which
- * represents a nickname of a target attribute of a resource that he wants to update.
- * The base motivation to introduce the term is to avoid a usage of URI to access a resource
- * from a developer. Thus, a developer should know which configuration names are supported
- * by Things Configuration class and what the configuration name means.
- * To get a list of supported configuration names, use getListOfSupportedConfigurationUnits()
- * function, which provides the list in JSON format.
- *
- * @param resource - resource pointer representing the target group or the single thing.
- * @param configurations - ConfigurationUnit: a nickname of attribute of target resource
- * (e.g., installedlocation, currency, (IP)address)
- * Value : a value to be updated
- *
- * @return OCStackResult - return value of this API.
- * It returns OC_STACK_OK if success.
- *
- * NOTE: OCStackResult is defined in ocstack.h.
- */
-JNIEXPORT jint JNICALL JNIThingsConfigurationUpdateConfigurations
-(JNIEnv *env, jobject interfaceObject, jobject resource, jobject configurations);
-
-/**
- * API for getting configuration value of multiple things of a target group
- * or a single thing.
- *
- * @param resource - resource pointer representing the target group or the single thing.
- * @param configurations - ConfigurationUnit: a nickname of attribute of target resource.
- *
- * @return OCStackResult - return value of this API.
- * It returns OC_STACK_OK if success.
- *
- * NOTE: OCStackResult is defined in ocstack.h.
- */
-JNIEXPORT jint JNICALL JNIThingsConfigurationGetConfigurations
-(JNIEnv *env, jobject interfaceObject, jobject resource, jobject configurations);
-
-/**
- * API for showing the list of supported configuration units (configurable parameters).
- *
- * @return std::string - return value of this API.
- * It returns the list in JSON format
- */
-JNIEXPORT jstring JNICALL JNIThingsConfigurationGetListOfSupportedConfigurationUnits
-(JNIEnv *env, jobject interfaceObject);
-
-/**
- * API for boostrapping system configuration parameters from a bootstrap server.
- *
- * @return OCStackResult - return value of this API.
- * It returns OC_STACK_OK if success.
- *
- * NOTE: OCStackResult is defined in ocstack.h.
- */
-JNIEXPORT jint JNICALL JNIThingsConfigurationDoBootstrap
-(JNIEnv *env, jobject interfaceObject);
-
-#ifdef __cplusplus
-}
-#endif
-#endif //JNI_THINGS_CONFIGURATION_H_
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-/**
- * @file
- * This file contains the declaration of ThingsConfigurationCallbacks class
- */
-
-#ifndef JNI_THINGS_CONFIGURATON_CALLBACKS_H_
-#define JNI_THINGS_CONFIGURATON_CALLBACKS_H_
-
-#include <string>
-
-#include "ThingsConfiguration.h"
-
-/**
- * This class provides a set of callback functions for things configuration.
- */
-class ThingsConfigurationCallbacks
-{
-
- public:
- ThingsConfigurationCallbacks() {}
- virtual ~ThingsConfigurationCallbacks() {}
-
- /**
- * This callback method is called when a response for the updateConfigurations request
- * just arrives.
- *
- * @param headerOptions - It comprises of optionID and optionData as members.
- * @param rep - Configuration parameters are carried as a pair of attribute key and value
- * in a form of OCRepresentation instance.
- * @param eCode - error code.
- */
- static void onUpdateConfigurationsResponse(const OC::HeaderOptions &headerOptions,
- const OC::OCRepresentation &rep, const int eCode);
-
- /**
- * This callback method is called when a response for the getConfigurations request
- * just arrives.
- *
- * @param headerOptions - It comprises of optionID and optionData as members.
- * @param rep - Configuration parameters are carried as a pair of attribute key and value
- * in a form of OCRepresentation instance.
- * @param eCode - error code.
- */
- static void onGetConfigurationsResponse(const OC::HeaderOptions &headerOptions,
- const OC::OCRepresentation &rep, const int eCode);
-
- /**
- * This callback method is called when a response for the doBootstrap request
- * just arrives.
- *
- * @param headerOptions - It comprises of optionID and optionData as members.
- * @param rep - Configuration parameters are carried as a pair of attribute key and value
- * in a form of OCRepresentation instance.
- * @param eCode - error code.
- */
- static void onBootStrapResponse(const OC::HeaderOptions &headerOptions,
- const OC::OCRepresentation &rep,
- const int eCode);
-
- /**
- * This method invokes the Callback function with particular name and signature.
- *
- * @param headerOptions - It comprises of optionID and optionData as members.
- * @param rep - Configuration parameters are carried as a pair of attribute key and value
- * in a form of OCRepresentation instance.
- * @param eCode - error code.
- * @param callbackName - callbackName to be invoked.
- * @param signature - Signature of the callback method to be called.
- */
- static void invokeCallback(const OC::HeaderOptions &headerOptions,
- const OC::OCRepresentation &rep, const int eCode, const char *callbackName,
- const char *signature);
-
-};
-#endif //JNI_GROUP_SYNCHRONIZATION_CALLBACKS_H_
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-/**
- * @file
- * This file contains the declaration of Things Maintenance API's
- * for JNI implementation.
- */
-
-#ifndef JNI_THINGS_MAINTENANCE_H_
-#define JNI_THINGS_MAINTENANCE_H_
-
-#include <stdio.h>
-#include <string.h>
-
-#include <jni.h>
-#include <jni_string.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * API to let thing(device) reboot.
- * The target thing could be a group of multiple things or a single thing.
- *
- * @param resource - resource type representing the target group
- *
- * @return OCStackResult - return value of this API.
- * It returns OC_STACK_OK if success.
- *
- * NOTE: OCStackResult is defined in ocstack.h.
- */
-JNIEXPORT jint JNICALL JNIThingsMaintenanceReboot
-(JNIEnv *env, jobject interfaceObject, jobject resource);
-
-/**
- * API for factory reset on thing(device).
- * The target thing could be a group of multiple things or a single thing.
- *
- * @param resource - resource type representing the target group
- *
- * @return OCStackResult - return value of this API.
- * It returns OC_STACK_OK if success.
- *
- * NOTE: OCStackResult is defined in ocstack.h.
- */
-JNIEXPORT jint JNICALL JNIThingsMaintenanceFactoryReset
-(JNIEnv *env, jobject interfaceObject, jobject resource);
-
-
-/**
- * API for showing the list of supported Maintenance units.
- *
- * @return std::string - return value of this API.
- * It returns the list in JSON format
- */
-JNIEXPORT jstring JNICALL JNIThingsMaintenanceGetListOfSupportedConfigurationUnits
-(JNIEnv *env, jobject interfaceObject);
-
-#ifdef __cplusplus
-}
-#endif
-#endif //JNI_THINGS_MAINTENANCE_H_
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-/**
- * @file
- * This file contains the declaration of ThingsMaintenanceCallbacks class.
- */
-
-#ifndef JNI_THINGS_MAINTENANCE_CALLBACKS_H_
-#define JNI_THINGS_MAINTENANCE_CALLBACKS_H_
-
-#include <string>
-
-#include "ThingsMaintenance.h"
-
-/**
- * This class provides a set of callback functions for things maintenance.
- */
-class ThingsMaintenanceCallbacks
-{
-
- public:
- ThingsMaintenanceCallbacks() {}
- virtual ~ThingsMaintenanceCallbacks() {}
-
- /**
- * This callback method is called when a response for the reboot request
- * just arrives.
- *
- * @param headerOptions - It comprises of optionID and optionData as members.
- * @param rep - Configuration parameters are carried as a pair of attribute key and value
- * in a form of OCRepresentation instance.
- * @param eCode - error code.
- */
- static void onRebootResponse(const OC::HeaderOptions &headerOptions,
- const OC::OCRepresentation &rep,
- const int eCode);
-
- /**
- * This callback method is called when a response for the factoryReset request
- * just arrives.
- *
- * @param headerOptions - It comprises of optionID and optionData as members.
- * @param rep - Configuration parameters are carried as a pair of attribute key and value
- * in a form of OCRepresentation instance.
- * @param eCode - error code.
- */
- static void onFactoryResetResponse(const OC::HeaderOptions &headerOptions,
- const OC::OCRepresentation &rep,
- const int eCode);
-
- /**
- * This method invokes the Callback function with particular name and signature.
- *
- * @param headerOptions - It comprises of optionID and optionData as members.
- * @param rep - Configuration parameters are carried as a pair of attribute key and value
- * in a form of OCRepresentation instance.
- * @param eCode - error code.
- * @param callbackName - callbackName to be invoked.
- * @param signature - Signature of the callback method to be called.
- */
- static void invokeCallback(const OC::HeaderOptions &headerOptions,
- const OC::OCRepresentation &rep, const int eCode,
- const char *callbackName, const char *signature);
-};
-#endif //JNI_THINGS_MAINTENANCE_CALLBACKS_H_
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-/**
- * @file
- * This file contains the utility functions for conversions from java to CPP
- * and viceversa.
- */
-
-#ifndef JNI_THINGS_MANAGER_UTILS_H_
-#define JNI_THINGS_MANAGER_UTILS_H_
-
-#include <vector>
-#include <map>
-#include "JniOcResource.h"
-#include "jni_things_manager_jvm.h"
-
-/**
- * Utility function for converting a Java Vector of Strings to CPP Vector of Strings.
- *
- * @param env - Default JNI Environment pointer
- * @param jVectorString - Java Vector of Strings
- */
-std::vector<std::string> convertStringVector(JNIEnv *env, jobject jVectorString);
-
-/**
- * Utility function for converting a Hash Map of Strings to CPP Map of Strings.
- *
- * @param env - Default JNI Environment pointer
- * @param jMapString - Java Map of Strings
- */
-std::map<std::string, std::string> convertStringMap(JNIEnv *env, jobject jMapString);
-
-/**
- * Utility function for converting ocResource Handle to java.
- * @param env - Default JNI Environment pointer
- * @param resourceHandle - Resource Handle
- */
-jobject ocResourceHandleToJava(JNIEnv *env, jlong resourceHandle);
-
-/**
- * Utility function for converting native ocResource to java ocResource.
- * @param env - Default JNI Environment pointer
- * @param resource - Native Resource
- */
-jobject OcResourceToJava(JNIEnv *env, jlong resource);
-
-/**
- * Utility function for converting native ocHeaderOption to java ocHeaderOption.
- * @param env - Default JNI Environment pointer
- * @param headerOption - Native headerOption
- */
-jobject OcHeaderOptionToJava(JNIEnv *env, OC::HeaderOption::OCHeaderOption headerOption);
-
-/**
- * Utility function for converting native ocRepresentation to java ocRepresentation.
- * @param env - Default JNI Environment pointer
- * @param ocRepresentation - Native ocRepresentation
- */
-jobject OcRepresentationToJava(JNIEnv *env, jlong ocRepresentation);
-
-#endif //JNI_THINGS_MANAGER_UTILS_H_
-
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include "jni_action.h"
-#include "jni_things_manager_jvm.h"
-#include "jni_getter.h"
-#include "jni_setter.h"
-
-#include <ActionSet.h>
-
-#define JACTION_TARGET ("target")
-#define JACTION_LISTOF_CAPABILITY ("listOfCapability")
-
-JniAction::JniAction(JNIEnv *env, jobject obj) : JObject(env, obj)
-{
-}
-
-JniAction::JniAction(JNIEnv *env) : JObject(env, TM_SERVICE_ACTION_PATH)
-{
-}
-
-JniAction::~JniAction()
-{
-}
-
-bool JniAction::getTarget(std::string &target)
-{
- //Retrieves target value from JniAction class object
- return JGetter::getJStringField(m_pEnv, m_pObject, JACTION_TARGET, target);
-}
-
-bool JniAction::setTarget(const std::string target)
-{
- //Sets target value of JniAction class object
- return JSetter::setJStringField(m_pEnv, m_pObject, JACTION_TARGET, target.c_str());
-}
-
-bool JniAction::getJniCapabilityValues(std::vector<OIC::Capability *> &capabilityList)
-{
- jclass jvectorClass = m_pEnv->FindClass(TM_JAVA_VECTOR_CLASS_PATH);
- jmethodID vectorMethodID = m_pEnv->GetMethodID(jvectorClass, "get", "(I)Ljava/lang/Object;");
- jmethodID vectorSizeMethodID = m_pEnv->GetMethodID(jvectorClass, "size", "()I");
-
- jobject jAttrList = NULL;
- bool res = JGetter::getJObjectField(m_pEnv, m_pObject,
- JACTION_LISTOF_CAPABILITY, TM_JAVA_VECTOR_TYPE, jAttrList);
-
- if (res == true)
- {
- capabilityList.clear();
- int attrCount = m_pEnv->CallIntMethod(jAttrList, vectorSizeMethodID);
- for (int i = 0; i < attrCount; i++)
- {
- JniCapability *attr_var = new JniCapability(m_pEnv,
- m_pEnv->CallObjectMethod(jAttrList, vectorMethodID, i));
-
- OIC::Capability *cap = new OIC::Capability();
- attr_var->getJniCapabilityValue(cap->capability);
- attr_var->getJniCapabilityStatus(cap->status);
- delete attr_var;
- capabilityList.push_back(cap);
- }
- }
- m_pEnv->DeleteLocalRef(jvectorClass);
- return res;
-}
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include "jni_action_set.h"
-#include "jni_things_manager_jvm.h"
-#include "jni_getter.h"
-#include "jni_setter.h"
-#include "JniOcResource.h"
-
-#define JACTIONSET_NAME ("actionsetName")
-#define JACTIONSET_LISTOF_ACTION ("listOfAction")
-
-JniActionSet::JniActionSet(JNIEnv *env, jobject obj) : JObject(env, obj)
-{
-}
-
-JniActionSet::JniActionSet(JNIEnv *env) : JObject(env, TM_SERVICE_ACTIONSET_PATH)
-{
-}
-
-JniActionSet::~JniActionSet()
-{
-}
-
-bool JniActionSet::getJniActionSetName(std::string &name)
-{
- //Retrieves target value from JniActionSet class object
- return JGetter::getJStringField(m_pEnv, m_pObject, JACTIONSET_NAME, name);
-}
-
-bool JniActionSet::setJniActionSetName(const std::string name)
-{
- //Sets target value of JniActionSet class object
- return JSetter::setJStringField(m_pEnv, m_pObject, JACTIONSET_NAME, name.c_str());
-}
-
-bool JniActionSet::getJniListOfActions(std::vector<OIC::Action *> &actionList)
-{
- jclass jvectorClass = m_pEnv->FindClass(TM_JAVA_VECTOR_CLASS_PATH);
- jmethodID vectorMethodID = m_pEnv->GetMethodID(jvectorClass, "get", "(I)Ljava/lang/Object;");
- jmethodID vectorSizeMethodID = m_pEnv->GetMethodID(jvectorClass, "size", "()I");
- jobject jAttrList = NULL;
- bool res = JGetter::getJObjectField(m_pEnv, m_pObject,
- JACTIONSET_LISTOF_ACTION, TM_JAVA_VECTOR_TYPE, jAttrList);
-
- if (res == true)
- {
- actionList.clear();
- int attrCount = m_pEnv->CallIntMethod(jAttrList, vectorSizeMethodID);
- for (int i = 0; i < attrCount; i++)
- {
- JniAction *attr_var = new JniAction(m_pEnv,
- m_pEnv->CallObjectMethod(jAttrList, vectorMethodID, i));
- OIC::Action *actionName = new OIC::Action();
- attr_var->getTarget(actionName->target);
- attr_var->getJniCapabilityValues(actionName->listOfCapability);
- delete attr_var;
- actionList.push_back(actionName);
- }
- }
- m_pEnv->DeleteLocalRef(jvectorClass);
- return true;
-}
-ActionSet *JniActionSet::getActionSet(JNIEnv *env, jobject jnewActionSet)
-{
- LOGI("getActionSet: Enter");
-
- if (NULL == jnewActionSet)
- {
- LOGE("getActionSet: jnewActionSet is NULL");
- return NULL;
- }
-
- std::string actionsetName;
- getJniActionSetName(actionsetName);
-
- std::vector<Action *> actionVector;
- getJniListOfActions(actionVector);
-
- OIC::ActionSet *pActionSet = new OIC::ActionSet();
- if (NULL == pActionSet)
- {
- LOGE("getActionSet: Failed to create newActionSet");
- return NULL;
- }
-
- pActionSet->actionsetName = actionsetName;
- pActionSet->listOfAction = actionVector;
- if (false == setTimeInfo(env, jnewActionSet, pActionSet))
- {
- LOGE("getActionSet: setTimeInfo failed!");
- delete pActionSet;
- return NULL;
- }
-
- LOGI("getActionSet: Exit");
- return pActionSet;
-}
-
-bool JniActionSet::setTimeInfo(JNIEnv *env, jobject jnewActionSet, OIC::ActionSet *pActionSet)
-{
- LOGI("setTimeInfo: Entry");
- if (NULL == jnewActionSet)
- {
- LOGE("setTimeInfo: jnewActionSet is NULL");
- return NULL;
- }
-
- jclass classTime = env->FindClass(TM_SERVICE_TIME_PATH);
- if (NULL == classTime)
- {
- LOGE("FindClass failed for [%s]", TM_SERVICE_TIME_PATH);
- return false;
- }
-
- jfieldID fieldID = env->GetFieldID(classTime, "mYear", "I");
- int year = env->GetIntField(jnewActionSet, fieldID);
-
- fieldID = env->GetFieldID(classTime, "mMonth", "I");
- int month = env->GetIntField(jnewActionSet, fieldID);
-
- fieldID = env->GetFieldID(classTime, "mDay", "I");
- int day = env->GetIntField(jnewActionSet, fieldID);
-
- fieldID = env->GetFieldID(classTime, "mHour", "I");
- int hour = env->GetIntField(jnewActionSet, fieldID);
-
- fieldID = env->GetFieldID(classTime, "mMin", "I");
- int min = env->GetIntField(jnewActionSet, fieldID);
-
- fieldID = env->GetFieldID(classTime, "mSec", "I");
- int sec = env->GetIntField(jnewActionSet, fieldID);
-
- fieldID = env->GetFieldID(classTime, "mDayOfWeek", "I");
- int wday = env->GetIntField(jnewActionSet, fieldID);
-
- fieldID = env->GetFieldID(classTime, "mDelay", "J");
- long delay = env->GetLongField(jnewActionSet, fieldID);
-
- fieldID = env->GetFieldID(classTime, "mType", "Lorg/iotivity/service/tm/Time$ActionSetType;");
- jobject actionSetTypeObj = env->GetObjectField(jnewActionSet, fieldID);
- if (NULL == actionSetTypeObj)
- {
- LOGE("setTimeInfo: actionSetTypeObj is NULL");
- return false;
- }
-
- jclass actionSetTypeClass = env->GetObjectClass(actionSetTypeObj);
- if (NULL == actionSetTypeClass)
- {
- LOGE("setTimeInfo: actionSetTypeClass is NULL");
- return false;
- }
-
- jmethodID actionSetTypeMethod = env->GetMethodID(actionSetTypeClass, "ordinal", "()I");
- if (NULL == actionSetTypeMethod)
- {
- LOGE("setTimeInfo: actionSetTypeMethod is NULL");
- return false;
- }
-
- int type = (int) env->CallIntMethod(actionSetTypeObj, actionSetTypeMethod);
- pActionSet->setTime(year, month, day, hour, min, sec, wday);
- pActionSet->type = static_cast<OIC::ACTIONSET_TYPE>(type);
- pActionSet->setDelay(delay);
-
- LOGI("setTimeInfo: Exit");
- return true;
-}
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include "jni_capability.h"
-#include "jni_things_manager_jvm.h"
-#include "jni_getter.h"
-#include "jni_setter.h"
-
-#define JCAPABILITY_STATUS ("status")
-#define JCAPABILITY_CAPABILITY ("capability")
-
-JniCapability::JniCapability(JNIEnv *env, jobject obj) : JObject(env, obj)
-{
-}
-
-JniCapability::JniCapability(JNIEnv *env) : JObject(env, TM_SERVICE_CAPABILITY_PATH)
-{
-}
-
-JniCapability::~JniCapability()
-{
-}
-
-bool JniCapability::getJniCapabilityValue(std::string &capability)
-{
- //Retrieves capability value from JniCapability class object
- return JGetter::getJStringField(m_pEnv, m_pObject, JCAPABILITY_CAPABILITY, capability);
-}
-
-bool JniCapability::setJniCapabilityValue(const std::string capability)
-{
- //Sets capability value of JniCapability class object
- return JSetter::setJStringField(m_pEnv, m_pObject, JCAPABILITY_CAPABILITY, capability.c_str());
-}
-
-bool JniCapability::getJniCapabilityStatus(std::string &status)
-{
- //Retrieves status from JniCapability class object
- return JGetter::getJStringField(m_pEnv, m_pObject, JCAPABILITY_STATUS, status);
-}
-
-bool JniCapability::setJniCapabilityStatus(const std::string status)
-{
- //Sets status of JniCapability class object
- return JSetter::setJStringField(m_pEnv, m_pObject, JCAPABILITY_STATUS, status.c_str());
-}
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include "jni_group_manager.h"
-#include "JniOcResource.h"
-#include "JniOcResourceHandle.h"
-#include "GroupManager.h"
-#include "ActionSet.h"
-#include "jni_things_manager_jvm.h"
-#include "jni_things_manager_util.h"
-#include "jni_group_manager_callbacks.h"
-#include "jni_action_set.h"
-
-/**
- * GroupManager static object
- */
-static GroupManager g_GroupManager;
-
-JNIEXPORT jint JNICALL JNIGroupManagerFindCandidateResource(JNIEnv *env, jobject interfaceObject,
- jobject jResourceTypes, jint waitSec)
-{
- LOGI("JNIGroupManagerFindCandidateResource: Enter");
-
- if (!jResourceTypes)
- {
- LOGE("JNIGroupManagerFindCandidateResource: jResourceTypes is NULL!");
- return OC_STACK_INVALID_PARAM;
- }
-
- OCStackResult ocResult = OC_STACK_ERROR;
- try
- {
- ocResult = g_GroupManager.findCandidateResources(convertStringVector(env, jResourceTypes),
- &GroupManagerCallbacks::onFoundCandidateResource, (int)waitSec);
-
- if (OC_STACK_OK != ocResult)
- {
- LOGE("JNIGroupManagerFindCandidateResource: findCandidateResources failed!");
- return ocResult;
- }
- }
- catch (InitializeException &e)
- {
- LOGE("JNIGroupManagerFindCandidateResource: Exception occurred! %s, %d", e.reason().c_str(),
- e.code());
- return ocResult;
- }
-
- LOGI("JNIGroupManagerFindCandidateResource: Exit");
- return ocResult;
-}
-
-JNIEXPORT jint JNICALL JNIGroupManagerSubscribeCollectionPresence(JNIEnv *env,
- jobject interfaceObject,
- jobject jResource)
-{
- LOGI("JNIGroupManagerSubscribeCollectionPresence: Enter");
-
- if (!jResource)
- {
- LOGE("JNIGroupManagerSubscribeCollectionPresence: jResource is NULL!");
- return OC_STACK_INVALID_PARAM;
- }
-
- OCStackResult ocResult = OC_STACK_ERROR;
-
- JniOcResource *jniOcResource = JniOcResource::getJniOcResourcePtr(env, jResource);
- if (NULL == jniOcResource)
- {
- LOGE("JNIGroupManagerSubscribeCollectionPresence: Failed to get jni OcResource!");
- return ocResult;
- }
-
- std::shared_ptr<OCResource> ocResource = jniOcResource->getOCResource();
- if (NULL == ocResource.get())
- {
- LOGE("JNIGroupManagerSubscribeCollectionPresence: Failed to get OCResource object!");
- return ocResult;
- }
-
- ocResult = g_GroupManager.subscribeCollectionPresence(ocResource,
- &GroupManagerCallbacks::onSubscribePresence);
- if (OC_STACK_OK != ocResult)
- {
- LOGE("JNIGroupManagerSubscribeCollectionPresence: subscribeCollectionPresence failed!");
- return ocResult;
- }
-
- LOGI("JNIGroupManagerSubscribeCollectionPresence: Exit");
- return ocResult;
-}
-
-JNIEXPORT jobject JNICALL JNIGroupManagerBindResourceToGroup(JNIEnv *env, jobject interfaceObject,
- jobject jResource, jobject jCollectionHandle)
-{
- LOGI("JNIGroupManagerBindResourceToGroup: Enter");
-
- if (!jResource || !jCollectionHandle)
- {
- LOGE("JNIGroupManagerBindResourceToGroup: Invalid parameter!");
- return NULL;
- }
-
- std::shared_ptr<OCResource> ocResource;
- JniOcResource *jniOcResource = JniOcResource::getJniOcResourcePtr(env, jResource);
- if (jniOcResource)
- {
- ocResource = jniOcResource->getOCResource();
- }
-
- if (NULL == ocResource.get())
- {
- LOGE("JNIGroupManagerBindResourceToGroup: Failed to get OCResource object!");
- return NULL;
- }
-
- JniOcResourceHandle *jniOcCollectionHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(env,
- jCollectionHandle);
- if (NULL == jniOcCollectionHandle)
- {
- LOGE("JNIGroupManagerBindResourceToGroup: collection handle is null!");
- return NULL;
- }
-
- jobject jResourceHandle = NULL;
- try
- {
- OCResourceHandle ocChildHandle = NULL;
- OCResourceHandle ocCollectionHandle = jniOcCollectionHandle->getOCResourceHandle();
- OCStackResult ocResult = g_GroupManager.bindResourceToGroup(ocChildHandle, ocResource,
- ocCollectionHandle);
- if (OC_STACK_OK != ocResult)
- {
- LOGE("JNIGroupManagerBindResourceToGroup: bindResourceToGroup failed!");
- return NULL;
- }
-
- // Convert OCResourceHandle to java type
- JniOcResourceHandle *jniHandle = new JniOcResourceHandle(ocChildHandle);
- jlong handle = reinterpret_cast<jlong>(jniHandle);
- jResourceHandle = env->NewObject(g_cls_OcResourceHandle, g_mid_OcResourceHandle_N_ctor, handle);
- if (env->ExceptionCheck())
- {
- LOGE("JNIGroupManagerBindResourceToGroup: Failed to create OcResourceHandle");
- delete jniHandle;
- return NULL;
- }
- }
- catch (InitializeException &e)
- {
- LOGE("JNIGroupManagerBindResourceToGroup: Exception occurred! %s, %d", e.reason().c_str(),
- e.code());
- return NULL;
- }
-
- LOGI("JNIGroupManagerBindResourceToGroup: Exit");
- return jResourceHandle;
-}
-
-JNIEXPORT jint JNICALL JNIGroupManagerAddActionSet(JNIEnv *env, jobject interfaceObject,
- jobject resource,
- jobject newActionSet)
-{
- LOGI("JNIGroupManagerAddActionSet: Entry");
-
- if ((!resource) || (!newActionSet))
- {
- LOGE("JNIGroupManagerAddActionSet: resource or newActionSet is NULL!");
- return OC_STACK_INVALID_PARAM;
- }
-
- OCStackResult ocResult = OC_STACK_ERROR;
-
- std::shared_ptr<OCResource> ocResource;
- JniOcResource *jniOcResource = JniOcResource::getJniOcResourcePtr(env, resource);
- if (jniOcResource)
- {
- ocResource = jniOcResource->getOCResource();
- }
-
- if (NULL == ocResource.get())
- {
- LOGE("JNIGroupManagerAddActionSet: Failed to get OCResource object!");
- return ocResult;
- }
-
- JniActionSet *jActionSet = new JniActionSet(env, newActionSet);
- ActionSet *pActionSet = jActionSet->getActionSet(env, newActionSet);
- if (NULL == pActionSet)
- {
- LOGE("JNIGroupManagerAddActionSet: Failed to convert ActionSet!");
- return ocResult;
- }
-
- ocResult = g_GroupManager.addActionSet(ocResource, pActionSet,
- &GroupManagerCallbacks::onPutResponse);
- if (OC_STACK_OK != ocResult)
- {
- LOGE("JNIGroupManagerAddActionSet: addActionSet is failed!");
- }
-
- delete pActionSet;
- LOGI("JNIGroupManagerAddActionSet: Exit");
- return ocResult;
-}
-
-JNIEXPORT jint JNICALL JNIGroupManagerExecuteActionSet(JNIEnv *env, jobject interfaceObject,
- jobject resource, jstring jActionSetName)
-{
- LOGI("JNIGroupManagerExecuteActionSet: Entry");
-
- if ((!resource) || (!jActionSetName))
- {
- LOGE("JNIGroupManagerExecuteActionSet: resource or jActionSetName is NULL!");
- return OC_STACK_INVALID_PARAM;
- }
-
- OCStackResult ocResult = OC_STACK_ERROR;
-
- std::shared_ptr<OCResource> ocResource;
- JniOcResource *jniOcResource = JniOcResource::getJniOcResourcePtr(env, resource);
- if (jniOcResource)
- {
- ocResource = jniOcResource->getOCResource();
- }
-
- if (NULL == ocResource.get())
- {
- LOGE("JNIGroupManagerExecuteActionSet: Failed to get OCResource object!");
- return ocResult;
- }
-
- const char *actionSetNamePointer = env->GetStringUTFChars(jActionSetName, 0);
- if (NULL == actionSetNamePointer)
- {
- LOGE("JNIGroupManagerExecuteActionSet: Failed to convert jstring to char string!");
- return OC_STACK_NO_MEMORY;
- }
-
- std::string actionSetName(actionSetNamePointer);
-
- ocResult = g_GroupManager.executeActionSet(ocResource, actionSetName,
- &GroupManagerCallbacks::onPostResponse);
- if (OC_STACK_OK != ocResult)
- {
- LOGE("JNIGroupManagerExecuteActionSet: executeActionSet is failed!");
- }
-
- env->ReleaseStringUTFChars(jActionSetName, actionSetNamePointer);
- LOGI("JNIGroupManagerExecuteActionSet: Exit");
- return ocResult;
-}
-
-JNIEXPORT jint JNICALL JNIGroupManagerExecuteActionSetWithDelay(JNIEnv *env,
- jobject interfaceObject,
- jobject resource, jstring jActionSetName, jlong delay)
-{
- LOGI("JNIGroupManagerExecuteActionSetWithDelay: Entry");
-
- if ((!resource) || (!jActionSetName))
- {
- LOGE("JNIGroupManagerExecuteActionSetWithDelay: resource or jActionSetName is NULL!");
- return OC_STACK_INVALID_PARAM;
- }
-
- OCStackResult ocResult = OC_STACK_ERROR;
-
- std::shared_ptr<OCResource> ocResource;
- JniOcResource *jniOcResource = JniOcResource::getJniOcResourcePtr(env, resource);
- if (jniOcResource)
- {
- ocResource = jniOcResource->getOCResource();
- }
-
- if (NULL == ocResource.get())
- {
- LOGE("JNIGroupManagerExecuteActionSetWithDelay: Failed to get OCResource object!");
- return ocResult;
- }
-
- const char *actionSetNamePointer = env->GetStringUTFChars(jActionSetName, 0);
- if (NULL == actionSetNamePointer)
- {
- LOGE("JNIGroupManagerExecuteActionSetWithDelay: Failed to convert jstring to char string!");
- return OC_STACK_NO_MEMORY;
- }
-
- std::string actionSetName(actionSetNamePointer);
- if (0 == delay)
- {
- ocResult = g_GroupManager.executeActionSet(ocResource, actionSetName,
- &GroupManagerCallbacks::onPostResponse);
- }
- else
- {
- ocResult = g_GroupManager.executeActionSet(ocResource, actionSetName,
- (long int)delay,
- &GroupManagerCallbacks::onPostResponse);
- }
- if (OC_STACK_OK != ocResult)
- {
- LOGE("JNIGroupManagerExecuteActionSetWithDelay: executeActionSet is failed!");
- }
-
- env->ReleaseStringUTFChars(jActionSetName, actionSetNamePointer);
- LOGI("JNIGroupManagerExecuteActionSetWithDelay: Exit");
- return ocResult;
-}
-
-JNIEXPORT jint JNICALL JNIGroupManagerCancelActionSet(JNIEnv *env, jobject interfaceObject,
- jobject resource, jstring jActionSetName)
-{
- LOGI("JNIGroupManagerCancelActionSet: Entry");
-
- if ((!resource) || (!jActionSetName))
- {
- LOGE("JNIGroupManagerCancelActionSet: resource or jActionSetName is NULL!");
- return OC_STACK_INVALID_PARAM;
- }
-
- OCStackResult ocResult = OC_STACK_ERROR;
-
- std::shared_ptr<OCResource> ocResource;
- JniOcResource *jniOcResource = JniOcResource::getJniOcResourcePtr(env, resource);
- if (jniOcResource)
- {
- ocResource = jniOcResource->getOCResource();
- }
-
- if (NULL == ocResource.get())
- {
- LOGE("JNIGroupManagerCancelActionSet: Failed to get OCResource object!");
- return ocResult;
- }
-
- const char *actionSetNamePointer = env->GetStringUTFChars(jActionSetName, 0);
- if (NULL == actionSetNamePointer)
- {
- LOGE("JNIGroupManagerCancelActionSet: Failed to get character sequence from jstring!");
- return OC_STACK_NO_MEMORY;
- }
-
- std::string actionSetName(actionSetNamePointer);
-
- ocResult = g_GroupManager.cancelActionSet(ocResource, actionSetName,
- &GroupManagerCallbacks::onPostResponse);
- if (OC_STACK_OK != ocResult)
- {
- LOGE("JNIGroupManagerCancelActionSet: cancelActionSet is failed!");
- }
-
- env->ReleaseStringUTFChars(jActionSetName, actionSetNamePointer);
- LOGI("JNIGroupManagerCancelActionSet: Exit");
- return ocResult;
-}
-
-JNIEXPORT jint JNICALL JNIGroupManagerGetActionSet(JNIEnv *env, jobject interfaceObject,
- jobject resource,
- jstring jActionSetName)
-{
- LOGI("JNIGroupManagerGetActionSet: Entry");
-
- if ((!resource) || (!jActionSetName))
- {
- LOGE("JNIGroupManagerGetActionSet: resource or jActionSetName is NULL!");
- return OC_STACK_INVALID_PARAM;
- }
-
- OCStackResult ocResult = OC_STACK_ERROR;
-
- std::shared_ptr<OCResource> ocResource;
- JniOcResource *jniOcResource = JniOcResource::getJniOcResourcePtr(env, resource);
- if (jniOcResource)
- {
- ocResource = jniOcResource->getOCResource();
- }
-
- if (NULL == ocResource.get())
- {
- LOGE("JNIGroupManagerGetActionSet: Failed to get OCResource object!");
- return ocResult;
- }
-
- const char *actionSetNamePointer = env->GetStringUTFChars(jActionSetName, 0);
- std::string actionSetName(actionSetNamePointer);
-
- ocResult = g_GroupManager.getActionSet(ocResource, actionSetName,
- &GroupManagerCallbacks::onGetResponse);
- if (OC_STACK_OK != ocResult)
- {
- LOGE("JNIGroupManagerGetActionSet: getActionSet is failed!");
- }
-
- env->ReleaseStringUTFChars(jActionSetName, actionSetNamePointer);
- LOGI("JNIGroupManagerGetActionSet: Exit");
- return ocResult;
-}
-
-JNIEXPORT jint JNICALL JNIGroupManagerDeleteActionSet(JNIEnv *env, jobject interfaceObject,
- jobject resource,
- jstring jActionSetName)
-{
- LOGI("JNIGroupManagerDeleteActionSet: Entry");
-
- if ((!resource) || (!jActionSetName))
- {
- LOGE("JNIGroupManagerDeleteActionSet: resource or jActionSetName is NULL!");
- return OC_STACK_INVALID_PARAM;
- }
-
- OCStackResult ocResult = OC_STACK_ERROR;
-
- std::shared_ptr<OCResource> ocResource;
- JniOcResource *jniOcResource = JniOcResource::getJniOcResourcePtr(env, resource);
- if (jniOcResource)
- {
- ocResource = jniOcResource->getOCResource();
- }
-
- if (NULL == ocResource.get())
- {
- LOGE("JNIGroupManagerDeleteActionSet: Failed to get OCResource object!");
- return ocResult;
- }
-
- const char *actionSetNamePointer = env->GetStringUTFChars(jActionSetName, 0);
- std::string actionSetName(actionSetNamePointer);
-
- ocResult = g_GroupManager.deleteActionSet(ocResource, actionSetName,
- &GroupManagerCallbacks::onPutResponse);
- if (OC_STACK_OK != ocResult)
- {
- LOGE("JNIGroupManagerDeleteActionSet: deleteActionSet is failed!");
- }
-
- env->ReleaseStringUTFChars(jActionSetName, actionSetNamePointer);
- LOGI("JNIGroupManagerDeleteActionSet: Exit");
- return ocResult;
-}
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include "jni_group_manager_callbacks.h"
-#include "JniOcResource.h"
-#include "GroupManager.h"
-#include "jni_things_manager_jvm.h"
-#include "jni_things_manager_util.h"
-#include "jni_string.h"
-
-#define LOG_TAG "GroupManagerCallbacks"
-
-#define METHOD_ONRESOURCE_CALLBACK "(" TM_JAVA_VECTOR_TYPE")V"
-#define METHOD_ONPRESENCE_CALLBACK "(" TM_JAVA_STRING_TYPE"I)V"
-#define METHOD_ONPOST_CALLBACK "(" TM_JAVA_VECTOR_TYPE TM_SERVICE_OCREPRESENTATION_TYPE"I)V"
-#define METHOD_ONPUT_CALLBACK "(" TM_JAVA_VECTOR_TYPE TM_SERVICE_OCREPRESENTATION_TYPE"I)V"
-#define METHOD_ONGET_CALLBACK "(" TM_JAVA_VECTOR_TYPE TM_SERVICE_OCREPRESENTATION_TYPE"I)V"
-
-void GroupManagerCallbacks::onFoundCandidateResource(
- std::vector< std::shared_ptr<OC::OCResource>> resources)
-{
- LOGI("onFoundCandidateResource : Enter");
-
- if (resources.size() == 0)
- {
- LOGE("onFoundCandidateResource : found resources zero");
- return;
- }
-
- JNIEnv *env = ThingsManagerJVM::getEnv();
- if (env == NULL)
- {
- LOGE("onFoundCandidateResource : Getting JNIEnv failed");
- return;
- }
-
- // Get GroupManagerCallback class reference
- jclass groupManagerCallbacks = GetJClass(TM_SERVICE_GROUP_MANAGER_CLASS_PATH);
-
- if (NULL == groupManagerCallbacks)
- {
- LOGE("onFoundCandidateResource : GetJClass TMServiceCallbackInterface failed");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- // Get onResourceCallback method reference
- jmethodID method_id = env->GetStaticMethodID(groupManagerCallbacks, "onResourceFoundCallback",
- METHOD_ONRESOURCE_CALLBACK);
- if (NULL == method_id)
- {
- LOGE("findCandidateResource: onResourceCallback : GetMethodID failed");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- if ((env)->ExceptionCheck())
- {
- LOGE("findCandidateResource : ExceptionCheck failed");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- jclass vectorCls = env->FindClass(TM_JAVA_VECTOR_CLASS_PATH);
- if (!vectorCls)
- {
- LOGE("findCandidateResource: failed to get %s class reference", TM_JAVA_VECTOR_CLASS_PATH);
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- jmethodID constr = env->GetMethodID(vectorCls, "<init>", "()V");
- if (!constr)
- {
- LOGE("findCandidateResource: failed to get %s constructor", TM_JAVA_VECTOR_CLASS_PATH);
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- jobject vectorObj = env->NewObject(vectorCls, constr);
- if (!vectorObj)
- {
- LOGE("findCandidateResource: failed to create a %s object", TM_JAVA_VECTOR_CLASS_PATH);
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- jmethodID addElement = env->GetMethodID(vectorCls, "addElement", "(Ljava/lang/Object;)V");
- if (NULL == addElement)
- {
- LOGE("findCandidateResource: failed to create a addElement method");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- // Convert to java OCResource object
- for (int i = 0; i < resources.size(); i++)
- {
- JniOcResource *jniOcResource = new JniOcResource(resources[i]);
- if (!jniOcResource)
- {
- LOGE("findCandidateResource: failed to create a JniOcResource");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- jobject resource = OcResourceToJava(env, reinterpret_cast<jlong>(jniOcResource));
- env->CallVoidMethod(vectorObj, addElement, resource);
- }
-
- env->CallStaticVoidMethod(groupManagerCallbacks, method_id, vectorObj);
-
- if ((env)->ExceptionCheck())
- {
- LOGE("findCandidateResource : CallVoidMethod failed");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- ThingsManagerJVM::releaseEnv();
- LOGI("findCandidateResource : Exit");
-}
-
-void GroupManagerCallbacks::onSubscribePresence(std::string resource, OCStackResult result)
-{
- LOGI("SubscribePresence : Entry");
-
- JNIEnv *env = ThingsManagerJVM::getEnv();
- if (env == NULL)
- {
- LOGE("SubscribePresence : Getting JNIEnv failed");
- return;
- }
-
- // Get GroupManagerCallback class reference
- jclass groupManagerCallbacks = GetJClass(TM_SERVICE_GROUP_MANAGER_CLASS_PATH);
-
- if (NULL == groupManagerCallbacks)
- {
- LOGE("SubscribePresence : GetJClass TMServiceCallbackInterface failed");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- jmethodID method_id = env->GetStaticMethodID(groupManagerCallbacks,
- "onPresenceCallback",
- METHOD_ONPRESENCE_CALLBACK);
- if (NULL == method_id)
- {
- LOGE("SubscribePresence : GetMethodID failed");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- if ((env)->ExceptionCheck())
- {
- LOGE("SubscribePresence : ExceptionCheck failed");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- JString *jresource = new JString(env, resource);
- if (jresource == NULL)
- {
- LOGE("resource value is invalid");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- env->CallStaticVoidMethod(groupManagerCallbacks, method_id, jresource->getObject(), (jint)result);
-
- delete jresource;
-
- if ((env)->ExceptionCheck())
- {
- LOGE("SubscribePresence : CallVoidMethod failed");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- LOGI("SubscribePresence : Exit");
-
-//METHOD_FAILURE:
- ThingsManagerJVM::releaseEnv();
-}
-
-void GroupManagerCallbacks::onPostResponse(const OC::HeaderOptions &headerOptions,
- const OC::OCRepresentation &rep, const int eCode)
-{
- LOGI("PostResponse : Enter");
-
- GroupManagerCallbacks::invokeCallback(headerOptions, rep, eCode, "onPostResponseCallback",
- METHOD_ONPOST_CALLBACK);
-
- LOGI("PostResponse : Exit");
-}
-
-void GroupManagerCallbacks::onPutResponse(const OC::HeaderOptions &headerOptions,
- const OC::OCRepresentation &rep, const int eCode)
-{
- LOGI("OnPutResponse : Enter");
-
- GroupManagerCallbacks::invokeCallback(headerOptions, rep, eCode, "onPutResponseCallback",
- METHOD_ONPUT_CALLBACK);
-
- LOGI("OnPutResponse : Exit");
-}
-
-void GroupManagerCallbacks::onGetResponse(const OC::HeaderOptions &headerOptions,
- const OC::OCRepresentation &rep, const int eCode)
-{
- LOGI("OnGetResponse : Enter");
-
- GroupManagerCallbacks::invokeCallback(headerOptions, rep, eCode, "onGetResponseCallback",
- METHOD_ONGET_CALLBACK);
-
- LOGI("OnGetResponse : Exit");
-}
-
-void GroupManagerCallbacks::invokeCallback(const OC::HeaderOptions &headerOptions,
- const OC::OCRepresentation &rep, const int eCode, const char *callbackName,
- const char *signature)
-{
- LOGI("InvokeCallback : Enter %s", callbackName);
-
- JNIEnv *env = ThingsManagerJVM::getEnv();
- if (env == NULL)
- {
- LOGE("InvokeCallback : Getting JNIEnv failed");
- return;
- }
-
- // Get ThingsManagerCallback class reference
- jclass groupManagerCallbacks = GetJClass(TM_SERVICE_GROUP_MANAGER_CLASS_PATH);
- if (NULL == groupManagerCallbacks)
- {
- LOGE("InvokeCallback : GetJClass TMServiceCallbackInterface failed");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- jmethodID method_id = env->GetStaticMethodID(groupManagerCallbacks, callbackName, signature);
- if (!method_id)
- {
- LOGE("InvokeCallback : GetMethodID failed");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- if ((env)->ExceptionCheck())
- {
- LOGE("InvokeCallback : ExceptionCheck failed");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- // Convert vector<OC:HeaderOption::OCHeaderOption> to java type
- jclass vectorCls = env->FindClass(TM_JAVA_VECTOR_CLASS_PATH);
- if (!vectorCls)
- {
- LOGE("InvokeCallback: failed to get %s class reference", TM_JAVA_VECTOR_CLASS_PATH);
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- jmethodID constr = env->GetMethodID(vectorCls, "<init>", "()V");
- if (!constr)
- {
- LOGE("InvokeCallback: failed to get %s constructor", TM_JAVA_VECTOR_CLASS_PATH);
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- jobject vectorObj = env->NewObject(vectorCls, constr);
- if (!vectorObj)
- {
- LOGE("InvokeCallback: failed to create a %s object", TM_JAVA_VECTOR_CLASS_PATH);
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- jmethodID addElement = env->GetMethodID(vectorCls, "addElement", "(Ljava/lang/Object;)V");
- if (NULL == addElement)
- {
- LOGE("InvokeCallback: failed to create a addElement method");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- jobject headerOptionTemp;
- for (int i = 0; i < headerOptions.size(); i++)
- {
- headerOptionTemp = OcHeaderOptionToJava(env, headerOptions[i]);
- env->CallVoidMethod(vectorObj, addElement, headerOptionTemp);
- }
-
- // Convert OCRepresentation to java type
- jobject jrepresentation = OcRepresentationToJava(env, (jlong) reinterpret_cast<jlong>(&rep));
- if (!jrepresentation)
- {
- LOGE("InvokeCallback : cannot create OCRepresentation class");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- env->CallStaticVoidMethod(groupManagerCallbacks, method_id, vectorObj, jrepresentation,
- (jint)eCode);
-
- if ((env)->ExceptionCheck())
- {
- LOGE("InvokeCallback : CallVoidMethod failed");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- ThingsManagerJVM::releaseEnv();
- LOGI("InvokeCallback : Exit %s", callbackName);
-}
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-#include "jni_things_configuration.h"
-#include "JniOcResource.h"
-#include "JniOcResourceHandle.h"
-#include "ThingsConfiguration.h"
-#include "ActionSet.h"
-#include "jni_things_manager_jvm.h"
-#include "jni_things_manager_util.h"
-#include "jni_things_configuration_callbacks.h"
-#include "jni_action_set.h"
-
-using namespace OC;
-using namespace OIC;
-
-/**
- * ThingsConfiguration static object
- */
-static ThingsConfiguration g_ThingsConfiguration;
-
-JNIEXPORT jint JNICALL JNIThingsConfigurationUpdateConfigurations(JNIEnv *env,
- jobject interfaceObject,
- jobject resource, jobject configurations)
-{
- LOGI("JNIThingsConfigurationUpdateConfigurations: Enter");
-
- if ((!resource) || (!configurations))
- {
- LOGE("JNIThingsConfigurationUpdateConfigurations: resource or configurations is NULL!");
- return OC_STACK_INVALID_PARAM;
- }
-
- OCStackResult ocResult = OC_STACK_ERROR;
-
- std::shared_ptr<OCResource> ocResource;
- JniOcResource *jniOcResource = JniOcResource::getJniOcResourcePtr(env, resource);
- if (jniOcResource)
- {
- ocResource = jniOcResource->getOCResource();
- }
-
- if (NULL == ocResource.get())
- {
- LOGE("JNIThingsConfigurationUpdateConfigurations: Failed to get OCResource object!");
- return ocResult;
- }
-
- std::map<std::string, std::string> configurationsMap;
- configurationsMap = convertStringMap(env, configurations);
- ocResult = g_ThingsConfiguration.updateConfigurations(ocResource, configurationsMap,
- &ThingsConfigurationCallbacks::onUpdateConfigurationsResponse);
- if (OC_STACK_OK != ocResult)
- {
- LOGE("JNIThingsConfigurationUpdateConfigurations: updateConfigurations failed!");
- return ocResult;
- }
-
- LOGI("JNIThingsConfigurationUpdateConfigurations: Exit");
- return ocResult;
-}
-
-JNIEXPORT jint JNICALL JNIThingsConfigurationGetConfigurations(JNIEnv *env, jobject interfaceObject,
- jobject resource, jobject configurations)
-{
- LOGI("JNIThingsConfigurationGetConfigurations: Enter");
-
- if ((!resource) || (!configurations))
- {
- LOGE("JNIThingsConfigurationGetConfigurations: resource or configurations is NULL!");
- return OC_STACK_INVALID_PARAM;
- }
-
- OCStackResult ocResult = OC_STACK_ERROR;
-
- std::shared_ptr<OCResource> ocResource;
- JniOcResource *jniOcResource = JniOcResource::getJniOcResourcePtr(env, resource);
- if (jniOcResource)
- {
- ocResource = jniOcResource->getOCResource();
- }
-
- if (NULL == ocResource.get())
- {
- LOGE("JNIThingsConfigurationGetConfigurations: Failed to get OCResource object!");
- return ocResult;
- }
-
- ocResult = g_ThingsConfiguration.getConfigurations(ocResource,
- (convertStringVector(env, configurations)),
- &ThingsConfigurationCallbacks::onGetConfigurationsResponse);
- if (OC_STACK_OK != ocResult)
- {
- LOGE("JNIThingsConfigurationGetConfigurations: getConfigurations failed!");
- return ocResult;
- }
-
- LOGI("JNIThingsConfigurationGetConfigurations: Exit");
- return ocResult;
-}
-
-JNIEXPORT jstring JNICALL JNIThingsConfigurationGetListOfSupportedConfigurationUnits(JNIEnv *env,
- jobject interfaceObject)
-{
- LOGI("JNIThingsConfigurationGetListOfSupportedConfigurationUnits: Enter");
-
- std::string configListString = g_ThingsConfiguration.getListOfSupportedConfigurationUnits();
- jstring jConfigListString = env->NewStringUTF(configListString.c_str());
-
- LOGI("JNIThingsConfigurationGetListOfSupportedConfigurationUnits: Exit");
- return jConfigListString;
-}
-
-JNIEXPORT jint JNICALL JNIThingsConfigurationDoBootstrap(JNIEnv *env, jobject interfaceObject)
-{
- LOGI("JNIThingsConfigurationDoBootstrap: Enter");
-
- OCStackResult ocResult = OC_STACK_ERROR;
- try
- {
- ocResult = g_ThingsConfiguration.doBootstrap(&ThingsConfigurationCallbacks::onBootStrapResponse);
- if (OC_STACK_OK != ocResult)
- {
- LOGE("JNIThingsConfigurationDoBootstrap: doBootstrap failed!");
- return ocResult;
- }
- }
- catch (InitializeException &e)
- {
- LOGE("JNIThingsConfigurationDoBootstrap: Exception occurred! %s, %d", e.reason().c_str(),
- e.code());
- return ocResult;
- }
-
- LOGI("JNIThingsConfigurationDoBootstrap: Exit");
- return ocResult;
-}
-
-
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include "jni_things_configuration_callbacks.h"
-#include "JniOcResource.h"
-#include "ThingsConfiguration.h"
-#include "jni_things_manager_jvm.h"
-#include "jni_things_manager_util.h"
-#include "jni_string.h"
-
-#define LOG_TAG "ThingsConfigurationCallbacks"
-
-#define METHOD_ONUPDATE_CONF_CALLBACK "(" TM_JAVA_VECTOR_TYPE TM_SERVICE_OCREPRESENTATION_TYPE"I)V"
-#define METHOD_ONGET_CONF_CALLBACK "(" TM_JAVA_VECTOR_TYPE TM_SERVICE_OCREPRESENTATION_TYPE"I)V"
-#define METHOD_ONBOOT_STRAP_CALLBACK "(" TM_JAVA_VECTOR_TYPE TM_SERVICE_OCREPRESENTATION_TYPE"I)V"
-
-void ThingsConfigurationCallbacks::onUpdateConfigurationsResponse(const OC::HeaderOptions
- &headerOptions,
- const OC::OCRepresentation &rep, const int eCode)
-{
- LOGI("UpdateConfigurations : Enter");
-
- ThingsConfigurationCallbacks::invokeCallback(headerOptions, rep, eCode,
- "onUpdateConfigurationsCallback",
- METHOD_ONUPDATE_CONF_CALLBACK);
-
- LOGI("UpdateConfigurations : Exit");
-}
-
-void ThingsConfigurationCallbacks::onGetConfigurationsResponse(const OC::HeaderOptions
- &headerOptions,
- const OC::OCRepresentation &rep, const int eCode)
-{
- LOGI("GetConfigurations : Enter");
-
- ThingsConfigurationCallbacks::invokeCallback(headerOptions, rep, eCode,
- "onGetConfigurationsCallback",
- METHOD_ONGET_CONF_CALLBACK);
-
- LOGI("GetConfigurations : Exit");
-}
-
-void ThingsConfigurationCallbacks::onBootStrapResponse(const OC::HeaderOptions &headerOptions,
- const OC::OCRepresentation &rep, const int eCode)
-{
- LOGI("BootStrap : Enter");
-
- ThingsConfigurationCallbacks::invokeCallback(headerOptions, rep, eCode, "onBootStrapCallback",
- METHOD_ONBOOT_STRAP_CALLBACK);
-
- LOGI("BootStrap : Exit");
-}
-
-void ThingsConfigurationCallbacks::invokeCallback(const OC::HeaderOptions &headerOptions,
- const OC::OCRepresentation &rep, const int eCode, const char *callbackName,
- const char *signature)
-{
- LOGI("InvokeCallback : Enter %s", callbackName);
-
- JNIEnv *env = ThingsManagerJVM::getEnv();
- if (env == NULL)
- {
- LOGE("InvokeCallback : Getting JNIEnv failed");
- return;
- }
-
- // Get ThingsManagerCallback class reference
- jclass thingsConfigurationCallbacks = GetJClass(TM_SERVICE_THINGS_CONFIGURATION_CLASS_PATH);
- if (NULL == thingsConfigurationCallbacks)
- {
- LOGE("InvokeCallback : GetJClass TMServiceCallbackInterface failed");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- // Get the ThingsManagerCallback class instance
- jobject jobjectCallback = GetJObjectInstance(TM_SERVICE_THINGS_CONFIGURATION_CLASS_PATH);
- if (NULL == jobjectCallback)
- {
- LOGE("InvokeCallback: getInstance( %s) failed!", TM_SERVICE_THINGS_CONFIGURATION_CLASS_PATH);
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- jmethodID method_id = env->GetMethodID(thingsConfigurationCallbacks, callbackName, signature);
- if (!method_id)
- {
- LOGE("InvokeCallback : GetMethodID failed");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- if ((env)->ExceptionCheck())
- {
- LOGE("InvokeCallback : ExceptionCheck failed");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- // Convert vector<OC:HeaderOption::OCHeaderOption> to java type
- jclass vectorCls = env->FindClass(TM_JAVA_VECTOR_CLASS_PATH);
- if (!vectorCls)
- {
- LOGE("InvokeCallback: failed to get %s class reference", TM_JAVA_VECTOR_CLASS_PATH);
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- jmethodID constr = env->GetMethodID(vectorCls, "<init>", "()V");
- if (!constr)
- {
- LOGE("InvokeCallback: failed to get %s constructor", TM_JAVA_VECTOR_CLASS_PATH);
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- jobject vectorObj = env->NewObject(vectorCls, constr);
- if (!vectorObj)
- {
- LOGE("InvokeCallback: failed to create a %s object", TM_JAVA_VECTOR_CLASS_PATH);
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- jmethodID addElement = env->GetMethodID(vectorCls, "addElement", "(Ljava/lang/Object;)V");
- if (NULL == addElement)
- {
- LOGE("InvokeCallback: failed to create a addElement method");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- jobject headerOptionTemp;
- for (int i = 0; i < headerOptions.size(); i++)
- {
- headerOptionTemp = OcHeaderOptionToJava(env, headerOptions[i]);
- env->CallVoidMethod(vectorObj, addElement, headerOptionTemp);
- }
-
- // Convert OCRepresentation to java type
- jobject jrepresentation = OcRepresentationToJava(env, (jlong) reinterpret_cast<jlong>(&rep));
- if (!jrepresentation)
- {
- LOGE("InvokeCallback : cannot create OCRepresentation class");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- env->CallVoidMethod(jobjectCallback, method_id, vectorObj, jrepresentation, (jint)eCode);
-
- if ((env)->ExceptionCheck())
- {
- LOGE("InvokeCallback : CallVoidMethod failed");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- ThingsManagerJVM::releaseEnv();
- LOGI("InvokeCallback : Exit %s", callbackName);
-}
-
-
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-#include "jni_things_maintenance.h"
-#include "JniOcResource.h"
-#include "JniOcResourceHandle.h"
-#include "ThingsMaintenance.h"
-#include "ActionSet.h"
-#include "jni_things_manager_jvm.h"
-#include "jni_things_manager_util.h"
-#include "jni_things_maintenance_callbacks.h"
-#include "jni_action_set.h"
-
-using namespace OC;
-using namespace OIC;
-
-/**
- * ThingsMaintenance static object
- */
-static ThingsMaintenance g_ThingsMaintenance;
-
-JNIEXPORT jint JNICALL JNIThingsMaintenanceReboot(JNIEnv *env, jobject interfaceObject,
- jobject resource)
-{
- LOGI("JNIThingsMaintenanceReboot: Enter");
-
- if (!resource)
- {
- LOGE("JNIThingsMaintenanceReboot: resource is NULL!");
- return OC_STACK_INVALID_PARAM;
- }
-
- OCStackResult ocResult = OC_STACK_ERROR;
-
- std::shared_ptr<OCResource> ocResource;
- JniOcResource *jniOcResource = JniOcResource::getJniOcResourcePtr(env, resource);
- if (jniOcResource)
- {
- ocResource = jniOcResource->getOCResource();
- }
-
- if (NULL == ocResource.get())
- {
- LOGE("JNIThingsMaintenanceReboot: Failed to get OCResource object!");
- return ocResult;
- }
-
- ocResult = g_ThingsMaintenance.reboot(ocResource, &ThingsMaintenanceCallbacks::onRebootResponse);
- if (OC_STACK_OK != ocResult)
- {
- LOGE("JNIThingsMaintenanceReboot: reboot failed!");
- return ocResult;
- }
-
- LOGI("JNIThingsMaintenanceReboot: Exit");
- return ocResult;
-}
-
-JNIEXPORT jint JNICALL JNIThingsMaintenanceFactoryReset(JNIEnv *env, jobject interfaceObject,
- jobject resource)
-{
- LOGI("JNIThingsMaintenanceFactoryReset: Enter");
-
- if (!resource)
- {
- LOGE("JNIThingsMaintenanceFactoryReset: resource is NULL!");
- return OC_STACK_INVALID_PARAM;
- }
-
- OCStackResult ocResult = OC_STACK_ERROR;
-
- std::shared_ptr<OCResource> ocResource;
- JniOcResource *jniOcResource = JniOcResource::getJniOcResourcePtr(env, resource);
- if (jniOcResource)
- {
- ocResource = jniOcResource->getOCResource();
- }
-
- if (NULL == ocResource.get())
- {
- LOGE("JNIThingsMaintenanceFactoryReset: Failed to get OCResource object!");
- return ocResult;
- }
-
- ocResult = g_ThingsMaintenance.factoryReset(ocResource,
- &ThingsMaintenanceCallbacks::onFactoryResetResponse);
- if (OC_STACK_OK != ocResult)
- {
- LOGE("JNIThingsMaintenanceFactoryReset: factoryReset failed!");
- return ocResult;
- }
-
- LOGI("JNIThingsMaintenanceFactoryReset: Exit");
- return ocResult;
-}
-
-JNIEXPORT jstring JNICALL JNIThingsMaintenanceGetListOfSupportedConfigurationUnits
-(JNIEnv *env, jobject interfaceObject)
-{
- LOGI("JNIThingsMaintenanceGetListOfSupportedConfigurationUnits: Enter");
-
- std::string configListString = g_ThingsMaintenance.getListOfSupportedMaintenanceUnits();
- jstring jConfigListString = env->NewStringUTF(configListString.c_str());
-
- LOGI("JNIThingsMaintenanceGetListOfSupportedConfigurationUnits: Exit");
- return jConfigListString;
-}
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include "jni_things_maintenance_callbacks.h"
-#include "JniOcResource.h"
-#include "ThingsMaintenance.h"
-#include "jni_things_manager_jvm.h"
-#include "jni_things_manager_util.h"
-#include "jni_string.h"
-
-#define LOG_TAG "ThingsMaintenanceCallbacks"
-
-#define METHOD_ONFACTORY_RESET_CALLBACK "(" TM_JAVA_VECTOR_TYPE TM_SERVICE_OCREPRESENTATION_TYPE"I)V"
-#define METHOD_ONREBOOT_CALLBACK "(" TM_JAVA_VECTOR_TYPE TM_SERVICE_OCREPRESENTATION_TYPE"I)V"
-
-void ThingsMaintenanceCallbacks::onRebootResponse(const OC::HeaderOptions &headerOptions,
- const OC::OCRepresentation &rep, const int eCode)
-{
- LOGI("OnReboot : Enter");
-
- ThingsMaintenanceCallbacks::invokeCallback(headerOptions, rep, eCode, "onRebootCallback",
- METHOD_ONREBOOT_CALLBACK);
-
- LOGI("OnReboot : Exit");
-}
-
-void ThingsMaintenanceCallbacks::onFactoryResetResponse(const OC::HeaderOptions &headerOptions,
- const OC::OCRepresentation &rep, const int eCode)
-{
- LOGI("OnFactoryReset : Enter");
-
- ThingsMaintenanceCallbacks::invokeCallback(headerOptions, rep, eCode, "onFactoryResetCallback",
- METHOD_ONFACTORY_RESET_CALLBACK);
-
- LOGI("OnFactoryReset : Exit");
-}
-
-void ThingsMaintenanceCallbacks::invokeCallback(const OC::HeaderOptions &headerOptions,
- const OC::OCRepresentation &rep, const int eCode, const char *callbackName,
- const char *signature)
-{
- LOGI("InvokeCallback : Enter %s", callbackName);
-
- JNIEnv *env = ThingsManagerJVM::getEnv();
- if (env == NULL)
- {
- LOGE("InvokeCallback : Getting JNIEnv failed");
- return;
- }
-
- // Get ThingsManagerCallback class reference
- jclass thingsMaintenanceCallbacks = GetJClass(TM_SERVICE_THINGS_MAINTENANCE_CLASS_PATH);
- if (NULL == thingsMaintenanceCallbacks)
- {
- LOGE("InvokeCallback : GetJClass TMServiceCallbackInterface failed");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- // Get the ThingsManagerCallback class instance
- jobject jobjectCallback = GetJObjectInstance(TM_SERVICE_THINGS_MAINTENANCE_CLASS_PATH);
- if (NULL == jobjectCallback)
- {
- LOGE("InvokeCallback: getInstance( %s) failed!", TM_SERVICE_THINGS_MAINTENANCE_CLASS_PATH);
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- jmethodID method_id = env->GetMethodID(thingsMaintenanceCallbacks, callbackName, signature);
- if (!method_id)
- {
- LOGE("InvokeCallback : GetMethodID failed");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- if ((env)->ExceptionCheck())
- {
- LOGE("InvokeCallback : ExceptionCheck failed");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- // Convert vector<OC:HeaderOption::OCHeaderOption> to java type
- jclass vectorCls = env->FindClass(TM_JAVA_VECTOR_CLASS_PATH);
- if (!vectorCls)
- {
- LOGE("InvokeCallback: failed to get %s class reference", TM_JAVA_VECTOR_CLASS_PATH);
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- jmethodID constr = env->GetMethodID(vectorCls, "<init>", "()V");
- if (!constr)
- {
- LOGE("InvokeCallback: failed to get %s constructor", TM_JAVA_VECTOR_CLASS_PATH);
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- jobject vectorObj = env->NewObject(vectorCls, constr);
- if (!vectorObj)
- {
- LOGE("InvokeCallback: failed to create a %s object", TM_JAVA_VECTOR_CLASS_PATH);
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- jmethodID addElement = env->GetMethodID(vectorCls, "addElement", "(Ljava/lang/Object;)V");
- if (NULL == addElement)
- {
- LOGE("InvokeCallback: failed to create a addElement method");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- jobject headerOptionTemp;
- for (int i = 0; i < headerOptions.size(); i++)
- {
- headerOptionTemp = OcHeaderOptionToJava(env, headerOptions[i]);
- env->CallVoidMethod(vectorObj, addElement, headerOptionTemp);
- }
-
- // Convert OCRepresentation to java type
- jobject jrepresentation = OcRepresentationToJava(env, (jlong) reinterpret_cast<jlong>(&rep));
- if (!jrepresentation)
- {
- LOGE("InvokeCallback : cannot create OCRepresentation class");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- env->CallVoidMethod(jobjectCallback, method_id, vectorObj, jrepresentation, (jint)eCode);
-
- if ((env)->ExceptionCheck())
- {
- LOGE("InvokeCallback : CallVoidMethod failed");
- ThingsManagerJVM::releaseEnv();
- return;
- }
-
- ThingsManagerJVM::releaseEnv();
- LOGI("InvokeCallback : Exit %s", callbackName);
-}
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include "jni_things_manager_util.h"
-#include "JniOcResource.h"
-#include "jni_string.h"
-
-jobject ocResourceHandleToJava(JNIEnv *env, jlong resourceHandle)
-{
- jclass resourceClass = GetJClass(TM_SERVICE_OCRESOURCEHANDLE_PATH);
- if (NULL == resourceClass)
- {
- LOGE("ocResourceHandleToJava : failed to find OCResourceHandle java class!");
- return NULL;
- }
-
- jmethodID constructor = env->GetMethodID(resourceClass, "<init>", "(J)V");
- if (NULL == constructor)
- {
- LOGE("ocResourceHandleToJava: Failed to get constructor method!");
- return NULL;
- }
-
- jobject resourceObj = (jobject) env->NewObject(resourceClass, constructor, resourceHandle);
- if (NULL == resourceObj)
- {
- LOGE("ocResourceHandleToJava: Failed to create OCResouceHandle java object!");
- return NULL;
- }
- return resourceObj;
-}
-
-jobject OcResourceToJava(JNIEnv *env, jlong resource)
-{
- jclass resourceClass = GetJClass(TM_SERVICE_OCRESOURCE_PATH);
- if (NULL == resourceClass)
- {
- LOGE("OcResourceToJava : failed to find OCResouce java class!");
- return NULL;
- }
-
- jmethodID constructor = env->GetMethodID(resourceClass, "<init>", "(J)V");
- if (NULL == constructor)
- {
- LOGE("OcResourceToJava: Failed to get constructor method!");
- return NULL;
- }
-
- jobject resourceObj = (jobject) env->NewObject(resourceClass, constructor, resource);
- if (NULL == resourceObj)
- {
- LOGE("OcResourceToJava: Failed to create OCResouce java object!");
- return NULL;
- }
- return resourceObj;
-}
-
-jobject OcHeaderOptionToJava(JNIEnv *env, OC::HeaderOption::OCHeaderOption headerOption)
-{
- JString *optionData = new JString(env, headerOption.getOptionData());
- if (!optionData)
- {
- LOGE("OcHeaderOptionToJava : failed to get JString!");
- return NULL;
- }
-
- jclass headerOptionClass = GetJClass(TM_SERVICE_HEADER_OPTION_PATH);
- if (NULL == headerOptionClass)
- {
- LOGE("OcHeaderOptionToJava : failed to find OCRepresentation java class!");
- return NULL;
- }
-
- jmethodID constructor = env->GetMethodID(headerOptionClass, "<init>", "(JLjava/lang/String;)V");
- if (NULL == constructor)
- {
- LOGE("OcHeaderOptionToJava: Failed to get constructor method!");
- return NULL;
- }
-
- jobject headerOptionObj = (jobject) env->NewObject(headerOptionClass, constructor,
- (jlong)headerOption.getOptionID(), optionData);
- if (NULL == headerOptionObj)
- {
- LOGE("OcHeaderOptionToJava: Failed to create OCRepresentation java object!");
- return NULL;
- }
- return headerOptionObj;
-}
-
-jobject OcRepresentationToJava(JNIEnv *env, jlong ocRepresentation)
-{
- jclass ocRepresentationClass = GetJClass(TM_SERVICE_OCREPRESENTATION_PATH);
- if (NULL == ocRepresentationClass)
- {
- LOGE("OcRepresentationToJava : failed to find OCRepresentation java class!");
- return NULL;
- }
-
- jmethodID constructor = env->GetMethodID(ocRepresentationClass, "<init>", "(J)V");
- if (NULL == constructor)
- {
- LOGE("OcRepresentationToJava: Failed to get constructor method!");
- return NULL;
- }
-
- jobject ocRepresentationObj = (jobject) env->NewObject(ocRepresentationClass, constructor,
- ocRepresentation);
- if (NULL == ocRepresentationObj)
- {
- LOGE("OcRepresentationToJava: Failed to create OCRepresentation java object!");
- return NULL;
- }
- return ocRepresentationObj;
-}
-
-std::vector<std::string> convertStringVector(JNIEnv *env, jobject jVectorString)
-{
- std::vector<std::string> vectorString;
-
- jclass vectorClass = env->FindClass(TM_JAVA_VECTOR_CLASS_PATH);
- if (!vectorClass)
- {
- LOGE("convertStringVector: Not able to find class %s", TM_JAVA_VECTOR_CLASS_PATH);
- return vectorString;
- }
-
- jmethodID size = env->GetMethodID(vectorClass, "size", "()I");
- if (NULL == size)
- {
- LOGE("convertStringVector: Failed to get method id for size");
- return vectorString;
- }
-
- jmethodID get = env->GetMethodID(vectorClass, "get", "(I)""Ljava/lang/Object;");
- if (NULL == get)
- {
- LOGE("convertStringVector: Failed to get method id for get");
- return vectorString;
- }
-
- jint jSize = env->CallIntMethod(jVectorString, size);
- int sizeOfVector = jSize;
-
- for (int index = 0; index < sizeOfVector; index++)
- {
- jint jIndex = index;
- jstring jContactInfoObj = (jstring)env->CallObjectMethod(jVectorString, get, jIndex);
- if (jContactInfoObj == NULL)
- {
- LOGE("convertStringVector: Failed on CallObjectMethod");
- return vectorString;
- }
- const char *buff = env->GetStringUTFChars(jContactInfoObj, 0);
- if (NULL != buff)
- {
- std::string tempString = buff;
- vectorString.push_back(tempString);
- }
-
- env->ReleaseStringUTFChars(jContactInfoObj, buff);
- }
- return vectorString;
-}
-
-std::map<std::string, std::string> convertStringMap(JNIEnv *env, jobject jMapString)
-{
- // Get reference to java/util/Map class
- jclass mapClass = env->GetObjectClass(jMapString);
- jmethodID sizeMethodId = env->GetMethodID(mapClass, "size", "()I");
- jmethodID entrySetMethodId = env->GetMethodID(mapClass, "entrySet", "()Ljava/util/Set;");
-
- // Get reference to java/util/Set class
- jclass setClass = env->FindClass("java/util/Set");
- jmethodID iteratorMethodId = env->GetMethodID(setClass, "iterator", "()Ljava/util/Iterator;");
-
- // Get reference to java/util/Iterator class
- jclass iteratorClass = env->FindClass("java/util/Iterator");
- jmethodID hasNextMethodId = env->GetMethodID(iteratorClass, "hasNext", "()Z");
- jmethodID nextMethodId = env->GetMethodID(iteratorClass, "next", "()Ljava/lang/Object;");
-
- // Get reference to java/util/Map/Entry class
- jclass mapEntryClass = env->FindClass("java/util/Map$Entry");
- jmethodID getKeyMethodId = env->GetMethodID(mapEntryClass, "getKey", "()Ljava/lang/Object;");
- jmethodID getValueMethodId = env->GetMethodID(mapEntryClass, "getValue", "()Ljava/lang/Object;");
-
- std::map<std::string, std::string> mapString;
- // Get entry set from map
- jobject entrySet = env->CallObjectMethod(jMapString, entrySetMethodId);
- if (!entrySet)
- {
- LOGE("convertStringMap: Failed to get entrySet");
- return mapString;
- }
-
- // Get iterator from set
- jobject iterator = env->CallObjectMethod(entrySet, iteratorMethodId);
- if (!iterator)
- {
- LOGE("convertStringMap: Failed to get iterator from set");
- return mapString;
- }
-
- if (JNI_TRUE == env->CallBooleanMethod(iterator, hasNextMethodId))
- {
- jobject entry = env->CallObjectMethod(iterator, nextMethodId);
- jstring jMapKeyStr = (jstring)env->CallObjectMethod(entry, getKeyMethodId);
- jstring jMapValueStr = (jstring)env->CallObjectMethod(entry, getValueMethodId);
-
- const char *key = env->GetStringUTFChars(jMapKeyStr, 0);
- const char *value = env->GetStringUTFChars(jMapValueStr, 0);
-
- if ((NULL != key) && (NULL != value))
- {
- std::string keyStr = key;
- std::string valueStr = value;
- mapString.insert(std::make_pair(keyStr, valueStr));
- }
- env->ReleaseStringUTFChars(jMapKeyStr, key);
- env->ReleaseStringUTFChars(jMapValueStr, value);
- }
- return mapString;
-}
+++ /dev/null
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-# Project target.
-target=android-20
-android.library=true
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-/**
- * @file
- * This file contains class which provides functions to retrieve the Action
- * details from a Segment.
- */
-
-package org.iotivity.service.tm;
-
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-import android.util.Log;
-
-/**
- * This class provides functions to retrieve the Action details from a Segment.
- */
-public class Action {
- private static final String LOG_TAG = "Action";
- /**
- * Sub Segment Value
- */
- public String target;
-
- /**
- * Capability instance stored in listOfCapability vector variable.
- */
- public Vector<Capability> listOfCapability = new Vector<Capability>();
-
- /**
- * This function generates an Action String (Example:
- * uri=coap://10.251.44.228:49858/a/light|power=10)
- *
- * @return String for a specific action.
- */
- public String toString() {
- StringBuilder result = new StringBuilder();
-
- result.append("uri=" + target + "|");
- for (int i = 0; i < listOfCapability.size(); i++) {
- if (i != 0)
- result.append('|');
- result.append(listOfCapability.elementAt(i).toString());
- }
-
- return result.toString();
- }
-
- /**
- * This function parses the Segment value to retrieve sub segments separated
- * by a vertical bar(|): URI and a pair of attribute key and value.
- *
- * @param actionString
- * Segment String
- *
- * @return Action needed by remote devices as members of a specific group
- */
- public static Action toAction(String actionString) {
- Action result = new Action();
- StringTokenizer tokenizer = new StringTokenizer(actionString, "|");
-
- boolean actionFlag = false;
- while (tokenizer.hasMoreTokens()) {
- String segment = tokenizer.nextToken();
- if (false == actionFlag) {
- // Parse the action string
- StringTokenizer targetTokenizer = new StringTokenizer(segment,
- "=");
- if (2 != targetTokenizer.countTokens()
- || false == targetTokenizer.nextToken()
- .equalsIgnoreCase("uri")) {
- Log.e(LOG_TAG, "Invalid action segment = " + segment);
- return null;
- }
-
- result.target = targetTokenizer.nextToken();
- actionFlag = true;
- } else {
- // Parse the capability string
- Capability capability = Capability.toCapability(segment);
- if (null == capability) {
- Log.e(LOG_TAG,
- "Failed to convert string to Capability class!");
- return null;
- }
-
- // Add the parsed capability to list
- result.listOfCapability.add(capability);
- }
- }
- return result;
- }
-}
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-/**
- * @file
- * This file contains class which provides functions to retrieve ActionSet from plain text.
- */
-package org.iotivity.service.tm;
-
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-import android.util.Log;
-
-/**
- * This class provides functions to retrieve ActionSet from plain text. An
- * ActionSet is a set of descriptions of actions needed by remote devices as
- * members of a specific group. To create an ActionSet, one needs to know the
- * Delimeter serialization.
- */
-public class ActionSet extends Time {
- /**
- * String Tag for Logging
- */
- private static final String LOG_TAG = "ActionSet";
- /**
- * A first segment before the first asterisk(*) in ActionSet string is an
- * actionset name
- */
- public String actionsetName;
- /**
- * Action instance stored in listOfAction vector variable.
- */
- public Vector<Action> listOfAction = new Vector<Action>();
-
- /**
- * This function generates an ActionSet String which contains ActionSet
- * name, delay in seconds, ActionSetType which can be 0(NONE), 1(SCHEDULED)
- * or 2(RECURSIVE) and a list of actions. (Example: movieTime*10
- * 1*uri=coap://10.251.44.228:49858/a/light|power=
- * OFF*uri=coap://10.251.44.228:49858). The first segment before the first
- * asterisk(*) is an ActionSet name. The second segment goes before the next
- * asterisk. In the above example, 10 is the second segment which signifies
- * time delay in seconds followed by a space and ActionSetType which
- * signifies whether an ActionSet has to be triggered Recursively(2) or
- * Scheduled manner(1) or immediately(0).
- * "uri=coap://10.251.44.228:49858/a/light|power=10" is the third segment.
- * This can be also divided into two sub segments by a vertical bar(|): URI
- * and a pair of attribute key and value.
- *
- * @return String for a specific action.
- */
- @Override
- public String toString() {
- StringBuilder result = new StringBuilder();
-
- // Append action name
- result.append(actionsetName + "*");
-
- // Append delay and type
- result.append(getDelay() + " " + getType().ordinal() + "*");
-
- // Append list of actions
- for (int i = 0; i < listOfAction.size(); i++) {
- if (i != 0)
- result.append('*');
- result.append(listOfAction.elementAt(i).toString());
- }
-
- return result.toString();
- }
-
- /**
- * This function extracts a list of Actions from plain text and constructs
- * an ActionSet.
- *
- * @param actionsetString
- * ActionSet in String format. (Example: movieTime*10
- * 1*uri=coap://10.251.44.228:49858/a/light|power=
- * OFF*uri=coap://10.251.44.228:49858). The first segment before
- * the first asterisk(*) is an ActionSet name. The second segment
- * goes before the next asterisk. In the above example, 10 is the
- * second segment which signifies time delay in seconds followed
- * by a space and ActionSetType which signifies whether an
- * ActionSet has to be triggered Recursively(2) or Scheduled
- * manner(1) or immediately(0).
- * "uri=coap://10.251.44.228:49858/a/light|power=10" is the third
- * segment. This can be also divided into two sub segments by a
- * vertical bar(|): URI and a pair of attribute key and value).
- *
- * @return ActionSet which is a set of descriptions of actions needed by
- * remote devices as members of a specific group.
- */
- public static ActionSet toActionSet(String actionsetString) {
- if (0 == actionsetString.length()) {
- return null;
- }
-
- ActionSet result = new ActionSet();
- StringTokenizer tokenizer = new StringTokenizer(actionsetString, "*");
- boolean actionNameFlag = false;
- while (tokenizer.hasMoreTokens()) {
- String segment = tokenizer.nextToken();
- if (false == actionNameFlag) {
- if (true == segment.contains("|")
- || true == segment.contains("=")) {
- Log.e(LOG_TAG, "Invalid actionset name string!");
- return null;
- }
-
- result.actionsetName = segment;
- actionNameFlag = true;
- } else {
- Action action = Action.toAction(segment);
- if (null == action) {
- Log.e(LOG_TAG, "Failed to convert string to Action class!");
- return null;
- }
-
- result.listOfAction.add(action);
- }
- }
- return result;
- }
-}
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-/**
- * @file
- * This file contains class which provides functions to specify an attribute key and value
- * of the target resource.
- *
- */
-
-package org.iotivity.service.tm;
-
-import java.util.StringTokenizer;
-
-import android.util.Log;
-
-/**
- * This class needs to be created to specify an attribute key and value of the
- * target resource. The attribute key and value are written in capability and
- * status variables of Capability instance class, respectively. After filling
- * the Capability instance, store it to listOfCapability vector variable of
- * Action instance.
- */
-public class Capability {
- /**
- * String Tag for Logging
- */
- private static final String LOG_TAG = "Capability";
- /**
- * Attribute Key of target resource
- */
- public String capability;
- /**
- * Attribute Value of target resource
- */
- public String status;
-
- /**
- * This function generates a Capability String.
- *
- * @return String for a specific Capability.
- */
- public String toString() {
- StringBuilder result = new StringBuilder();
- result.append(capability + "=" + status);
- return result.toString();
- }
-
- /**
- * This function parses the Capability String.
- *
- * @param capabilityString
- * Capability in String format.
- *
- * @return Capability class.
- */
- public static Capability toCapability(String capabilityString) {
- StringTokenizer tokenizer = new StringTokenizer(capabilityString, "=");
- if (2 != tokenizer.countTokens()) {
- Log.e(LOG_TAG, "Invalid capability string = " + capabilityString);
- return null;
- }
-
- Capability result = new Capability();
-
- result.capability = tokenizer.nextToken();
- result.status = tokenizer.nextToken();
- return result;
- }
-}
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-/**
- * @file
- * This file contains class which provides functions
- * for group management.
- */
-
-package org.iotivity.service.tm;
-
-import java.util.Vector;
-
-import org.iotivity.base.OcException;
-import org.iotivity.base.OcHeaderOption;
-import org.iotivity.base.OcRepresentation;
-import org.iotivity.base.OcResource;
-import org.iotivity.base.OcResourceHandle;
-
-import android.util.Log;
-
-/**
- * This class provides a set of APIs relating to Group Management.
- */
-public class GroupManager {
-
- private static IFindCandidateResourceListener s_resourceListener;
- private static ISubscribePresenceListener s_presenceListener;
- private static IActionListener actionListener;
-
- private final String LOG_TAG = this.getClass()
- .getSimpleName();
-
- // Native methods
- private static native int nativeFindCandidateResource(
- Vector<String> resourceTypes, int waitTime);
-
- private static native int nativeSubscribeCollectionPresence(
- OcResource resource);
-
- public static native OcResourceHandle nativeBindResourceToGroup(
- OcResource resource, OcResourceHandle collectionHandle);
-
- public static native int nativeAddActionSet(OcResource resource,
- ActionSet actionSet);
-
- public static native int nativeExecuteActionSet(OcResource resource,
- String actionsetName);
-
- public static native int nativeExecuteActionSetWithDelay(
- OcResource resource, String actionsetName, long delay);
-
- public static native int nativeCancelActionSet(OcResource resource,
- String actionsetName);
-
- public static native int nativeGetActionSet(OcResource resource,
- String actionsetName);
-
- public static native int nativeDeleteActionSet(OcResource resource,
- String actionsetName);
-
- static {
- System.loadLibrary("gnustl_shared");
- System.loadLibrary("oc_logger");
- System.loadLibrary("connectivity_abstraction");
- System.loadLibrary("ca-interface");
- System.loadLibrary("octbstack");
- System.loadLibrary("oc");
- System.loadLibrary("TGMSDKLibrary");
- System.loadLibrary("ocstack-jni");
- System.loadLibrary("things-manager-jni");
- }
-
- /**
- * Provides interface for getting notification when resources are discovered
- * in network.
- */
- public interface IFindCandidateResourceListener {
-
- /**
- * This callback method will be called whenever resource is discovered
- * in the network.
- *
- * @param resources
- * List of resources discovered in the network
- */
- public void onResourceFoundCallback(Vector<OcResource> resources);
- }
-
- /**
- * Provides interface for getting child resource presence status.
- */
- public interface ISubscribePresenceListener {
-
- /**
- * This callback method will be called for child resource presence
- * status.
- *
- * @param resource
- * URI of resource.
- * @param result
- * error code.
- */
- public void onPresenceCallback(String resource, int result);
- }
-
- /**
- * Provides interface for receiving the callback for the GET, PUT and POST
- * requested actions.
- */
- public interface IActionListener {
-
- /**
- * This callback method is called when a asynchronous response for the
- * getActionSet request is received.
- *
- * @param headerOptions
- * It comprises of optionID and optionData as members.
- * @param rep
- * Configuration parameters are carried as a pair of
- * attribute key and value in a form of OCRepresentation
- * instance.
- * @param errorValue
- * error code.
- */
- public void onGetResponseCallback(Vector<OcHeaderOption> headerOptions,
- OcRepresentation rep, int errorValue);
-
- /**
- * This callback method is called when a asynchronous response for the
- * addActionSet request is received.
- *
- * @param headerOptions
- * It comprises of optionID and optionData as members.
- * @param rep
- * Configuration parameters are carried as a pair of
- * attribute key and value in a form of OCRepresentation
- * instance.
- * @param errorValue
- * error code.
- */
- public void onPutResponseCallback(Vector<OcHeaderOption> headerOptions,
- OcRepresentation rep, int errorValue);
-
- /**
- * This callback method is called when a asynchronous response for the
- * executeActionSet or deleteActionSet request is received.
- *
- * @param headerOptions
- * It comprises of optionID and optionData as members.
- * @param rep
- * Configuration parameters are carried as a pair of
- * attribute key and value in a form of OCRepresentation
- * instance.
- * @param errorValue
- * error code.
- */
- public void onPostResponseCallback(
- Vector<OcHeaderOption> headerOptions, OcRepresentation rep,
- int errorValue);
- }
-
- /**
- * Set listener for receiving notification of resource discovery.
- *
- * @param listener
- * IFindCandidateResourceListener to receive the discovered
- * resources.
- */
- public void setFindCandidateResourceListener(
- IFindCandidateResourceListener listener) {
- s_resourceListener = listener;
- }
-
- /**
- * Set listener for receiving responses of Get, PUT and POST requests.
- *
- * @param listener
- * IActionListener to receive Get, PUT and POST request
- * responses.
- */
- public void setActionListener(IActionListener listener) {
- actionListener = listener;
- }
-
- /**
- * Set listener for receiving child resource presence notifications.
- *
- * @param listener
- * ISubscribePresenceListener to receive child resource presence
- * state.
- */
- public void setSubscribePresenceListener(ISubscribePresenceListener listener) {
- s_presenceListener = listener;
- }
-
- /**
- * API for discovering candidate resources with waiting delay. This
- * operation returns all resources of given type on the network service.
- * This operation is sent via multicast to all services. However, the filter
- * limits the responders to just those that support the resource type in the
- * query. Currently only exact matches are supported.
- * <p>
- * Listener should be set using setFindCandidateResourceListener API
- * <p>
- * Listener IFindCandidateResourceListener::onResourceCallback will be
- * notified when resource is discovered in network.
- *
- * @param resourceTypes
- * required resource types(called "candidate")
- * @param waitTime
- * Delay time to add in seconds before starting to find the
- * resources in network.
- *
- * @return OCStackResult - OC_STACK_OK on success, otherwise a failure error
- * code.
- */
- public OCStackResult findCandidateResources(Vector<String> resourceTypes,
- int waitTime) {
- OCStackResult result;
- if (null == s_resourceListener) {
- result = OCStackResult.OC_STACK_LISTENER_NOT_SET;
- } else {
- int ordinal = nativeFindCandidateResource(resourceTypes, waitTime);
- result = OCStackResult.conversion(ordinal);
- }
- return result;
- }
-
- /**
- * API for subscribing child's state. Listener
- * <p>
- * ISubscribePresenceListener::onPresenceCallback will be notified for
- * resource presence status
- * </p>
- *
- * @param resource
- * collection resource for subscribing presence of all child
- * resources
- *
- * @return OCStackResult - return value of this API. It returns OC_STACK_OK
- * if success.
- *
- * @throws OcException {@link OcException}
- */
- public OCStackResult subscribeCollectionPresence(OcResource resource)
- throws OcException {
- String LOG_TAG = this.getClass().getSimpleName();
-
- OCStackResult result;
- if (null == s_presenceListener) {
- result = OCStackResult.OC_STACK_LISTENER_NOT_SET;
- } else {
-
- int ordinal = nativeSubscribeCollectionPresence(resource);
- Log.i(LOG_TAG, "Ordinal value = : " + ordinal);
- result = OCStackResult.conversion(ordinal);
- }
- return result;
- }
-
- /**
- * API for register and bind resource to group.
- *
- * @param resource
- * resource for register and bind to group. It has all data.
- * @param collectionHandle
- * collection resource handle. It will be added child resource.
- *
- * @return OcResourceHandle - Child resource handle.
- *
- * @throws OcException {@link OcException}
- */
- public OcResourceHandle bindResourceToGroup(OcResource resource,
- OcResourceHandle collectionHandle) throws OcException {
- return nativeBindResourceToGroup(resource, collectionHandle);
- }
-
- /**
- * API for adding a new ActionSet onto a specific resource.
- *
- * <p>
- * Listener should be set using setActionListener API.
- * <p>
- * Listener IActionListener::onPutResponseCallback will be notified when the
- * response of PUT operation arrives.
- *
- * @param resource
- * resource pointer of the group resource
- * @param actionSet
- * pointer of ActionSet
- *
- * @return OCStackResult - OC_STACK_OK on success, otherwise a failure error
- * code.
- *
- * @throws OcException {@link OcException}
- */
- public OCStackResult addActionSet(OcResource resource, ActionSet actionSet)
- throws OcException {
- if (null == actionListener) {
- Log.e(LOG_TAG, "addActionSet: listener not set!");
- return OCStackResult.OC_STACK_LISTENER_NOT_SET;
- }
- int ordinal = nativeAddActionSet(resource, actionSet);
-
- return OCStackResult.conversion(ordinal);
- }
-
- /**
- * API for executing a specific ActionSet belonging to a specific resource.
- *
- * <p>
- * Listener should be set using setActionListener API.
- * <p>
- * Listener IActionListener::onPostResponseCallback will be notified when
- * the response of POST operation arrives.
- *
- * @param resource
- * resource pointer of the group resource
- * @param actionsetName
- * ActionSet name for removing the ActionSet
- *
- * @return OCStackResult - OC_STACK_OK on success, otherwise a failure error
- * code.
- *
- * @throws OcException {@link OcException}
- */
- public OCStackResult executeActionSet(OcResource resource,
- String actionsetName) throws OcException {
- if (null == actionListener) {
- Log.e(LOG_TAG, "executeActionSet: listener not set!");
- return OCStackResult.OC_STACK_LISTENER_NOT_SET;
- }
-
- int ordinal = nativeExecuteActionSet(resource, actionsetName);
-
- return OCStackResult.conversion(ordinal);
- }
-
- /**
- * API for executing a specific ActionSet belonging to a specific resource.
- *
- * <p>
- * Listener should be set using setActionListener API.
- * <p>
- * Listener IActionListener::onPostResponseCallback will be notified when
- * the response of POST operation arrives.
- *
- * @param resource
- * resource pointer of the group resource
- * @param actionsetName
- * ActionSet name for removing the ActionSet
- * @param delay
- * Wait time for the ActionSet execution
- *
- * @return OCStackResult - OC_STACK_OK on success, otherwise a failure error
- * code.
- *
- * @throws OcException {@link OcException}
- */
- public OCStackResult executeActionSet(OcResource resource,
- String actionsetName, long delay) throws OcException {
- if (null == actionListener) {
- Log.e(LOG_TAG, "executeActionSet: listener not set!");
- return OCStackResult.OC_STACK_LISTENER_NOT_SET;
- }
-
- OCStackResult result;
- int ordinal = nativeExecuteActionSetWithDelay(resource, actionsetName,
- delay);
- result = OCStackResult.conversion(ordinal);
-
- return result;
- }
-
- /**
- * API to cancel the existing ActionSet.
- *
- * <p>
- * Listener should be set using setActionListener API.
- * <p>
- * Listener IActionListener::onPostResponseCallback will be notified when
- * the response of POST operation arrives.
- *
- * @param resource
- * resource pointer of the group resource.
- * @param actionsetName
- * ActionSet name that has to be cancelled.
- *
- * @return OCStackResult - OC_STACK_OK on success, otherwise a failure error
- * code.
- *
- * @throws OcException {@link OcException}
- */
-
- public OCStackResult cancelActionSet(OcResource resource,
- String actionsetName) throws OcException {
- if (null == actionListener) {
- Log.e(LOG_TAG, "cancelActionSet: listener not set!");
- return OCStackResult.OC_STACK_LISTENER_NOT_SET;
- }
-
- OCStackResult result;
- int ordinal = nativeCancelActionSet(resource, actionsetName);
- result = OCStackResult.conversion(ordinal);
-
- return result;
- }
-
- /**
- * API to to get an existing ActionSet belonging to a specific resource.
- *
- * <p>
- * Listener should be set using setActionListener API.
- * <p>
- * Listener IActionListener::onPostResponseCallback will be notified when
- * the response of POST operation arrives.
- *
- * @param resource
- * resource pointer of the group resource
- * @param actionsetName
- * ActionSet name for removing the ActionSet
- *
- * @return OCStackResult - OC_STACK_OK on success, otherwise a failure error
- * code.
- *
- * @throws OcException {@link OcException}
- */
- public OCStackResult getActionSet(OcResource resource, String actionsetName)
- throws OcException {
- if (null == actionListener) {
- Log.e(LOG_TAG, "getActionSet: listener not set!");
- return OCStackResult.OC_STACK_LISTENER_NOT_SET;
- }
-
- OCStackResult result;
- int ordinal = nativeGetActionSet(resource, actionsetName);
- result = OCStackResult.conversion(ordinal);
-
- return result;
- }
-
- /**
- * API to delete an existing ActionSet belonging to a specific resource.
- *
- * <p>
- * Listener should be set using setActionListener API.
- * <p>
- * Listener IActionListener::onPutResponseCallback will be notified when the
- * response of PUT operation arrives.
- *
- * @param resource
- * resource pointer of the group resource
- * @param actionsetName
- * ActionSet name for removing the ActionSet
- *
- * @return OCStackResult - OC_STACK_OK on success, otherwise a failure error
- * code.
- *
- * @throws OcException {@link OcException}
- */
- public OCStackResult deleteActionSet(OcResource resource,
- String actionsetName) throws OcException {
- if (null == actionListener) {
- Log.e(LOG_TAG, "deleteActionSet: listener not set!");
- return OCStackResult.OC_STACK_LISTENER_NOT_SET;
- }
-
- OCStackResult result;
- int ordinal = nativeDeleteActionSet(resource, actionsetName);
- result = OCStackResult.conversion(ordinal);
-
- return result;
- }
-
- // ******** JNI UTILITY FUNCTIONS **********//
-
- /*
- * This callback method will be called from JNI whenever resource is
- * discovered in the network.
- */
- private static void onResourceFoundCallback(Vector<OcResource> resources) {
- if (null != s_resourceListener)
- s_resourceListener.onResourceFoundCallback(resources);
- }
-
- /*
- * This callback method is called from JNI for child resource presence
- * status.
- */
- private static void onPresenceCallback(String resource, int errorValue) {
- if (null != s_presenceListener) {
- Log.i("ThingsManagerCallback : onPresenceCallback",
- "Received Callback from JNI");
- s_presenceListener.onPresenceCallback(resource, errorValue);
- }
- }
-
- /*
- * This callback method is called from JNI when a response for the
- * executeActionSet or deleteActionSet request just arrives.
- */
- private static void onPostResponseCallback(
- Vector<OcHeaderOption> headerOptions, OcRepresentation rep,
- int errorValue) {
- if (null != actionListener)
- actionListener.onPostResponseCallback(headerOptions, rep,
- errorValue);
- }
-
- /*
- * This callback method is called from JNI when a response for the
- * addActionSet request just arrives.
- */
- private static void onPutResponseCallback(
- Vector<OcHeaderOption> headerOptions, OcRepresentation rep,
- int errorValue) {
- if (null != actionListener)
- actionListener
- .onPutResponseCallback(headerOptions, rep, errorValue);
- }
-
- /*
- * This callback method is called from JNI when a response for the
- * getActionSet request just arrives.
- */
- private static void onGetResponseCallback(
- Vector<OcHeaderOption> headerOptions, OcRepresentation rep,
- int errorValue) {
- if (null != actionListener)
- actionListener
- .onGetResponseCallback(headerOptions, rep, errorValue);
- }
-}
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-/**
- * @file
- * This file provides a Enum which contains Status codes
- * for Success and Errors
- */
-
-package org.iotivity.service.tm;
-
-/**
- * This Enum contains Status codes for Success and Errors
- */
-public enum OCStackResult {
-
- OC_STACK_OK,
- OC_STACK_RESOURCE_CREATED,
- OC_STACK_RESOURCE_DELETED,
- OC_STACK_CONTINUE,
- OC_STACK_INVALID_URI,
- OC_STACK_INVALID_QUERY,
- OC_STACK_INVALID_IP,
- OC_STACK_INVALID_PORT,
- OC_STACK_INVALID_CALLBACK,
- OC_STACK_INVALID_METHOD,
- OC_STACK_INVALID_PARAM,
- OC_STACK_INVALID_OBSERVE_PARAM,
- OC_STACK_NO_MEMORY,
- OC_STACK_COMM_ERROR,
- OC_STACK_NOTIMPL,
- OC_STACK_NO_RESOURCE,
- OC_STACK_RESOURCE_ERROR,
- OC_STACK_SLOW_RESOURCE,
- OC_STACK_REPEATED_REQUEST,
- OC_STACK_NO_OBSERVERS,
- OC_STACK_OBSERVER_NOT_FOUND,
- OC_STACK_VIRTUAL_DO_NOT_HANDLE,
- OC_STACK_INVALID_OPTION,
- OC_STACK_MALFORMED_RESPONSE,
- OC_STACK_PERSISTENT_BUFFER_REQUIRED,
- OC_STACK_INVALID_REQUEST_HANDLE,
- OC_STACK_INVALID_DEVICE_INFO,
- OC_STACK_INVALID_JSON,
- OC_STACK_PRESENCE_STOPPED,
- OC_STACK_PRESENCE_TIMEOUT,
- OC_STACK_PRESENCE_DO_NOT_HANDLE,
- OC_STACK_ERROR,
- OC_STACK_LISTENER_NOT_SET;
-
- public static OCStackResult conversion(int ordinal) {
-
- OCStackResult result = OCStackResult.values()[31];
-
- if (ordinal == 0)
- result = OCStackResult.values()[0];
- else if (ordinal == 1)
- result = OCStackResult.values()[1];
- else if (ordinal == 2)
- result = OCStackResult.values()[2];
- else if (ordinal == 3)
- result = OCStackResult.values()[3];
-
- else if (ordinal == 20)
- result = OCStackResult.values()[4];
- else if (ordinal == 21)
- result = OCStackResult.values()[5];
- else if (ordinal == 22)
- result = OCStackResult.values()[6];
- else if (ordinal == 23)
- result = OCStackResult.values()[7];
- else if (ordinal == 24)
- result = OCStackResult.values()[8];
- else if (ordinal == 25)
- result = OCStackResult.values()[9];
- else if (ordinal == 26)
- result = OCStackResult.values()[10];
- else if (ordinal == 27)
- result = OCStackResult.values()[11];
- else if (ordinal == 28)
- result = OCStackResult.values()[12];
- else if (ordinal == 29)
- result = OCStackResult.values()[13];
- else if (ordinal == 30)
- result = OCStackResult.values()[14];
- else if (ordinal == 31)
- result = OCStackResult.values()[15];
- else if (ordinal == 32)
- result = OCStackResult.values()[16];
- else if (ordinal == 33)
- result = OCStackResult.values()[17];
- else if (ordinal == 34)
- result = OCStackResult.values()[18];
- else if (ordinal == 35)
- result = OCStackResult.values()[19];
- else if (ordinal == 36)
- result = OCStackResult.values()[20];
- else if (ordinal == 37)
- result = OCStackResult.values()[21];
- else if (ordinal == 38)
- result = OCStackResult.values()[22];
- else if (ordinal == 39)
- result = OCStackResult.values()[23];
- else if (ordinal == 40)
- result = OCStackResult.values()[24];
- else if (ordinal == 41)
- result = OCStackResult.values()[25];
- else if (ordinal == 42)
- result = OCStackResult.values()[26];
- else if (ordinal == 43)
- result = OCStackResult.values()[27];
-
- else if (ordinal == 128)
- result = OCStackResult.values()[28];
- else if (ordinal == 129)
- result = OCStackResult.values()[29];
- else if (ordinal == 130)
- result = OCStackResult.values()[30];
-
- return result;
- }
-}
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-/**
- * @file
- * This file contains class which provides functions for
- * things configuration.
- */
-
-package org.iotivity.service.tm;
-
-import java.util.Map;
-import java.util.Vector;
-
-import org.iotivity.base.OcException;
-import org.iotivity.base.OcHeaderOption;
-import org.iotivity.base.OcRepresentation;
-import org.iotivity.base.OcResource;
-
-import android.util.Log;
-
-/**
- * This class provides a set of APIs relating to Things Configuration.
- */
-public class ThingsConfiguration {
-
- private IConfigurationListener configurationListener;
- private static ThingsConfiguration s_thingsConfigurationInstance;
- private final String LOG_TAG = this.getClass()
- .getSimpleName();
-
- // Native Methods
- private static native int nativeUpdateConfigurations(OcResource resource,
- Map<String, String> configurations);
-
- private static native int nativeGetConfigurations(OcResource resource,
- Vector<String> configurations);
-
- private static native String nativeGetListOfSupportedConfigurationUnits();
-
- private static native int nativeDoBootstrap();
-
- /**
- * Function for Getting instance of ThingsConfiguration object.
- *
- * @return ThingsConfiguration instance.
- *
- */
- public static ThingsConfiguration getInstance() {
- if (null == s_thingsConfigurationInstance) {
- s_thingsConfigurationInstance = new ThingsConfiguration();
- }
- return s_thingsConfigurationInstance;
- }
-
- /**
- * Provides interface for receiving asynchronous response for configuration
- * APIs.
- */
- public interface IConfigurationListener {
- /**
- * Asynchronous response callback for doBootstrap API.
- *
- * @param headerOptions
- * It comprises of optionID and optionData as members.
- * @param rep
- * Configuration parameters are carried as a pair of
- * attribute key and value in a form of OCRepresentation
- * instance.
- * @param errorValue
- * error code.
- */
- public void onBootStrapCallback(Vector<OcHeaderOption> headerOptions,
- OcRepresentation rep, int errorValue);
-
- /**
- * Asynchronous response callback for updateConfigurations API.
- *
- * @param headerOptions
- * It comprises of optionID and optionData as members.
- * @param rep
- * Configuration parameters are carried as a pair of
- * attribute key and value in a form of OCRepresentation
- * instance.
- * @param errorValue
- * error code.
- */
- public void onUpdateConfigurationsCallback(
- Vector<OcHeaderOption> headerOptions, OcRepresentation rep,
- int errorValue);
-
- /**
- * Asynchronous response callback for getConfigurations API.
- *
- * @param headerOptions
- * It comprises of optionID and optionData as members.
- * @param rep
- * Configuration parameters are carried as a pair of
- * attribute key and value in a form of OCRepresentation
- * instance.
- * @param errorValue
- * error code.
- */
- public void onGetConfigurationsCallback(
- Vector<OcHeaderOption> headerOptions, OcRepresentation rep,
- int errorValue);
- }
-
- /**
- * Set listener for receiving asynchronous response for configuration APIs.
- *
- * @param listener
- * IConfigurationListener to receive asynchronous response for
- * configuration APIs.
- */
- public void setConfigurationListener(IConfigurationListener listener) {
- configurationListener = listener;
- }
-
- /**
- * API for updating configuration value of multiple things of a target group
- * or a single thing to a resource server(s).
- *
- * <p>
- * Listener should be set using setConfigurationListener API.
- * <p>
- * Listener IConfigurationListener::onUpdateConfigurationsCallback will be
- * notified when the response of update configuration arrives.
- *
- * @param resource
- * resource representing the target group or the single thing. It
- * is a pointer of resource instance of Configuration resource.
- * The resource pointer can be acquired by performing
- * findResource() function with a dedicated resource type,
- * "oic.con". Note that, the resource pointer represents not only
- * a single simple resource but also a collection resource
- * composing multiple simple resources. In other words, using
- * these APIs, developers can send a series of requests to
- * multiple things by calling the corresponding function at once.
- * @param configurations
- * ConfigurationUnit: a nickname of attribute of target resource
- * (e.g., installed location, currency, (IP)address) Value : a
- * value to be updated. It represents an indicator of which
- * resource developers want to access and which value developers
- * want to update. Basically, developers could use a resource URI
- * to access a specific resource but a resource URI might be hard
- * for all developers to memorize lots of URIs, especially in the
- * case of long URIs. To relieve the problem, Things
- * Configuration introduces a easy-memorizing name, called
- * ConfigurationName, instead of URI. And ConfigurationValue used
- * in updateConfiguration() function indicates a value to be
- * updated. Note that, only one configuration parameter is
- * supported in this release. Multiple configuration parameters
- * will be supported in future release.
- *
- * @return OCStackResult - OC_STACK_OK on success, otherwise a failure error
- * code.
- *
- * @throws OcException {@link OcException}
- */
- public OCStackResult updateConfigurations(OcResource resource,
- Map<String, String> configurations) throws OcException {
- OCStackResult result;
- if (null == configurationListener) {
- result = OCStackResult.OC_STACK_LISTENER_NOT_SET;
- } else {
- int ordinal = nativeUpdateConfigurations(resource, configurations);
- result = OCStackResult.conversion(ordinal);
- }
- return result;
- }
-
- /**
- * API for getting configuration value of multiple things of a target group
- * or a single thing.To get a value, users need to know a Configuration Name
- * indicating the target resource. In this release, the Configuration Name
- * is "configuration".An update value is not needed. After that, users store
- * them in form of a Vector and then use a getConfigurations() function.
- *
- * @param resource
- * resource representing the target group or the single thing.
- * @param configurations
- * ConfigurationUnit: a nickname of attribute of target resource.
- *
- * @return OCStackResult - OC_STACK_OK on success, otherwise a failure error
- * code.
- *
- * @throws OcException {@link OcException}
- */
- public OCStackResult getConfigurations(OcResource resource,
- Vector<String> configurations) throws OcException {
- OCStackResult result;
- if (null == configurationListener) {
- result = OCStackResult.OC_STACK_LISTENER_NOT_SET;
- } else {
- int ordinal = nativeGetConfigurations(resource, configurations);
- result = OCStackResult.conversion(ordinal);
- }
- return result;
- }
-
- /**
- * API for getting the list of supported configuration units (configurable
- * parameters). It shows which Configuration Names are supported and their
- * brief descriptions. This information is provided in JSON format.
- *
- * @return Returns the configuration list in JSON format.
- */
- public String getListOfSupportedConfigurationUnits() {
- return nativeGetListOfSupportedConfigurationUnits();
- }
-
- /**
- * API for bootstrapping system configuration parameters from a bootstrap
- * server.
- * <p>
- * Listener should be set using setConfigurationListener API.
- * <p>
- * Listener IConfigurationListener::onBootStrapCallback will be notified
- * when the response arrives.
- *
- * @return OCStackResult - OC_STACK_OK on success, otherwise a failure error
- * code.
- */
- public OCStackResult doBootstrap() {
- if (null == configurationListener) {
- Log.e(LOG_TAG, "doBootstrap: listener not set!");
- return OCStackResult.OC_STACK_LISTENER_NOT_SET;
- }
-
- OCStackResult result;
- int ordinal = nativeDoBootstrap();
- result = OCStackResult.conversion(ordinal);
- return result;
- }
-
- // ******** JNI UTILITY FUNCTIONS **********//
-
- /*
- * This callback method is called from JNI when a response for the
- * updateConfigurations request just arrives.
- */
- public void onUpdateConfigurationsCallback(
- Vector<OcHeaderOption> headerOptions, OcRepresentation rep,
- int errorValue) {
- if (null != configurationListener)
- configurationListener.onUpdateConfigurationsCallback(headerOptions,
- rep, errorValue);
- }
-
- /*
- * This callback method is called from JNI when a response for the
- * getConfigurations request just arrives.
- */
- public void onGetConfigurationsCallback(
- Vector<OcHeaderOption> headerOptions, OcRepresentation rep,
- int errorValue) {
- if (null != configurationListener)
- configurationListener.onGetConfigurationsCallback(headerOptions,
- rep, errorValue);
- }
-
- /*
- * This callback method is called from JNI when a response for the
- * doBootstrap request just arrives.
- */
- public void onBootStrapCallback(Vector<OcHeaderOption> headerOptions,
- OcRepresentation rep, int errorValue) {
- if (null != configurationListener) {
- Log.i("ThingsManagerCallback : onBootStrapCallback",
- "Received Callback from JNI");
- configurationListener.onBootStrapCallback(headerOptions, rep,
- errorValue);
- }
- }
-}
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-/**
- * @file
- * This file contains class which provides functions
- * for things maintenance.
- */
-
-package org.iotivity.service.tm;
-
-import java.util.Vector;
-
-import org.iotivity.base.OcException;
-import org.iotivity.base.OcHeaderOption;
-import org.iotivity.base.OcRepresentation;
-import org.iotivity.base.OcResource;
-
-import android.util.Log;
-
-/**
- * This class provides a set of APIs relating to Things Maintenance.
- */
-public class ThingsMaintenance {
-
- private IThingsMaintenanceListener thingsMaintenanceListener;
- private static ThingsMaintenance s_thingsMaintenanceInstance;
- private final String LOG_TAG = this.getClass()
- .getSimpleName();
-
- // Native methods
- private static native int nativeReboot(OcResource resource);
-
- private static native int nativeFactoryReset(OcResource resource);
-
- private static native String nativeGetListOfSupportedMaintenanceUnits();
-
- /**
- * Function for Getting instance of ThingsMaintenance object.
- *
- * @return ThingsMaintenance instance.
- */
- public static ThingsMaintenance getInstance() {
- if (null == s_thingsMaintenanceInstance) {
- s_thingsMaintenanceInstance = new ThingsMaintenance();
- }
- return s_thingsMaintenanceInstance;
- }
-
- /**
- * Provides interface for receiving asynchronous response for Things
- * Maintenance feature APIs.
- */
- public interface IThingsMaintenanceListener {
- /**
- * Asynchronous response callback for reboot API.
- *
- * @param headerOptions
- * It comprises of optionID and optionData as members.
- * @param rep
- * Configuration parameters are carried as a pair of
- * attribute key and value in a form of OCRepresentation
- * instance.
- * @param errorValue
- * error code.
- */
- public void onRebootCallback(Vector<OcHeaderOption> headerOptions,
- OcRepresentation rep, int errorValue);
-
- /**
- * Asynchronous response callback for factoryReset API.
- *
- * @param headerOptions
- * It comprises of optionID and optionData as members.
- * @param rep
- * Configuration parameters are carried as a pair of
- * attribute key and value in a form of OCRepresentation
- * instance.
- * @param errorValue
- * error code.
- */
- public void onFactoryResetCallback(
- Vector<OcHeaderOption> headerOptions, OcRepresentation rep,
- int errorValue);
- }
-
- /**
- * Set listener for receiving asynchronous response for Things Maintenance
- * APIs.
- *
- * @param listener
- * IThingsMaintenanceListener to receive asynchronous response
- * for diagnostic feature APIs.
- */
- public void setThingsMaintenanceListener(IThingsMaintenanceListener listener) {
- thingsMaintenanceListener = listener;
- }
-
- /**
- * API to is used to send a request to a server(thing or device) to be
- * rebooted. On receiving the request, the server attempts to reboot itself
- * in a deterministic time. The target thing could be a group of multiple
- * things or a single thing.
- * <p>
- * Listener should be set using setDiagnosticsListener API.
- * <p>
- * Listener IThingsMaintenanceListener::onRebootCallback will be notified
- * when the response arrives.
- *
- * @param resource
- * resource pointer representing the target group
- *
- * @return OCStackResult - OC_STACK_OK on success, otherwise a failure error
- * code.
- *
- * @throws OcException {@link OcException}
- */
- public OCStackResult reboot(OcResource resource) throws OcException {
-
- OCStackResult result;
- if (null == thingsMaintenanceListener) {
- result = OCStackResult.OC_STACK_LISTENER_NOT_SET;
- } else {
- int ordinal = nativeReboot(resource);
- result = OCStackResult.conversion(ordinal);
- }
- return result;
- }
-
- /**
- * API to restore all configuration parameters to default one on
- * thing(device). All configuration parameters refers Configuration
- * resource, which they could have been modified for various reasons (e.g.,
- * for a request to update a value). If developers on the client want to
- * restore the parameters, just use the factoryReset function.The target
- * thing could be a group of multiple things or a single thing.
- *
- * <p>
- * Listener should be set using setDiagnosticsListener API.
- * <p>
- * Listener IThingsMaintenanceListener::onFactoryResetCallback will be
- * notified when the response arrives.
- *
- * @param resource
- * resource pointer representing the target group
- *
- * @return OCStackResult - OC_STACK_OK on success, otherwise a failure error
- * code.
- *
- * @throws OcException {@link OcException}
- */
- public OCStackResult factoryReset(OcResource resource) throws OcException {
-
- OCStackResult result;
- if (null == thingsMaintenanceListener) {
- result = OCStackResult.OC_STACK_LISTENER_NOT_SET;
- } else {
- int ordinal = nativeFactoryReset(resource);
- result = OCStackResult.conversion(ordinal);
- }
- return result;
- }
-
- /**
- * This callback method is called when a response for the reboot request
- * just arrives.
- *
- * @param headerOptions
- * It comprises of optionID and optionData as members.
- * @param rep
- * Configuration parameters are carried as a pair of attribute
- * key and value in a form of OCRepresentation instance.
- * @param errorValue
- * error code.
- */
- public void onRebootCallback(Vector<OcHeaderOption> headerOptions,
- OcRepresentation rep, int errorValue) {
- if (null != thingsMaintenanceListener) {
- Log.i("ThingsManagerCallback : onRebootCallback",
- "Received Callback from JNI");
- thingsMaintenanceListener.onRebootCallback(headerOptions, rep,
- errorValue);
- }
- }
-
- /**
- * This callback method is called when a response for the factoryReset
- * request just arrives.
- *
- * @param headerOptions
- * It comprises of optionID and optionData as members.
- * @param rep
- * Configuration parameters are carried as a pair of attribute
- * key and value in a form of OCRepresentation instance.
- * @param errorValue
- * error code.
- */
- public void onFactoryResetCallback(Vector<OcHeaderOption> headerOptions,
- OcRepresentation rep, int errorValue) {
- if (null != thingsMaintenanceListener) {
- Log.i("ThingsManagerCallback : onFactoryResetCallback",
- "Received Callback from JNI");
- thingsMaintenanceListener.onFactoryResetCallback(headerOptions,
- rep, errorValue);
- }
- }
-
- /**
- * API for getting the list of supported Maintenance units. It shows which
- * Maintenance Names are supported and their brief descriptions. This
- * information is provided in JSON format.
- *
- * @return Returns the configuration list in JSON format.
- */
- public String getListOfSupportedMaintenanceUnits() {
- return nativeGetListOfSupportedMaintenanceUnits();
- }
-}
+++ /dev/null
-/* *****************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-package org.iotivity.service.tm;
-
-import android.util.Log;
-
-/**
- * This class provides time-related information used for scheduled/recursive
- * group action features. Along with time-related variables, it also provides
- * various useful functionality including translating time to second unit
- */
-public class Time {
-
- public enum ActionSetType {
- NONE, SCHEDULED, RECURSIVE
- }
-
- public int mYear = 0;
- public int mMonth = 0;
- public int mDay = 0;
- public int mHour = 0;
- public int mMin = 0;
- public int mSec = 0;
- public int mDayOfWeek = 0;
-
- private ActionSetType mType = ActionSetType.NONE;
- private long mDelay = 0;
-
- private final String LOG_TAG = this.getClass().getSimpleName();
-
- /**
- * Set the time for executing ActionSet.
- *
- * @param year
- * Year to be set
- * @param month
- * Month of the year to be set
- * @param day
- * Day of the month to be set
- * @param hour
- * Hour to be set
- * @param min
- * Minute to be set
- * @param sec
- * Second to be set
- * @param dayOfTheWeek
- * Day of the week to be set
- */
- public void setTime(int year, int month, int day, int hour, int min,
- int sec, int dayOfTheWeek) {
- if (year < 0 || month < 0 || day < 0 || hour < 0 || min < 0 || sec < 0
- || dayOfTheWeek < 0) {
- Log.e(LOG_TAG, "Input time is invalid");
- return;
- }
-
- year -= 1900;
- month -= 1;
-
- mDelay = 0;
- mYear = year;
- mMonth = month;
- mDay = day;
- mHour = hour;
- mMin = month;
- mSec = sec;
- mDayOfWeek = dayOfTheWeek;
- mType = ActionSetType.NONE;
- }
-
- /**
- * Set type of ActionSet.
- *
- * @param type
- * Type of ActionSet
- */
- public void setType(ActionSetType type) {
- mType = type;
- }
-
- /**
- * Set day of the week for recursively executing ActionSet.
- *
- * @param day
- * day of the week
- */
- public void setDayOfWeekForRecursive(int day) {
- if (day != -1) {
- mType = ActionSetType.RECURSIVE;
- setTime(0, 0, 0, 0, 0, 0, day);
- }
- }
-
- /**
- * Set the time delay in seconds for executing ActionSet.
- *
- * @param seconds
- * time delay in seconds
- */
- public void setDelay(long seconds) {
- if (mType != ActionSetType.NONE) {
- mDelay = seconds;
- }
- }
-
- /**
- * Get absolute time in seconds.
- *
- * @return long - Absolute time in seconds.
- */
- public long getSecAbsTime() {
- long interval;
-
- interval = (mHour * 60 * 60);
- interval += (mMin * 60);
- interval += (mSec * 1);
-
- return interval;
- }
-
- /**
- * Get the type of ActionSet.
- *
- * @return ActionSetType - Type of ActionSet.
- */
- public ActionSetType getType() {
- return mType;
- }
-
- /**
- * Get the time delay in seconds set in the ActionSet.
- *
- * @return long - Delay in seconds.
- */
- public long getDelay() {
- return mDelay;
- }
-}
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#include "ActionSet.h"
-using namespace std;
-
-namespace OIC
-{
-Time::Time() : mTime()
-{
- setTime(0, 0, 0, 0, 0, 0, 0);
-}
-
-Time::~Time()
-{
-}
-
-void Time::setTime(OCTime t)
-{
- mTime = t;
-}
-void Time::setTime(unsigned int yy, unsigned int mm, unsigned int dd,
- unsigned int h, unsigned int m, unsigned int s,
- int dayoftheweek = 0)
-{
- mDelay = 0;
- mTime.tm_year = (int)yy - 1900;
- mTime.tm_mon = (int)mm - 1;
- mTime.tm_mday = dd;
-
- mTime.tm_hour = h;
- mTime.tm_min = m;
- mTime.tm_sec = s;
-
- mTime.tm_wday = (unsigned int) dayoftheweek;
- type = NONE;
-}
-void Time::setDayOfWeekForRecursive(int day)
-{
- if (day != -1)
- {
- type = RECURSIVE;
- }
- else
- {
- return;
- }
-
- setTime(0, 0, 0, 0, 0, 0, day);
-}
-unsigned int Time::getYear()
-{
- return mTime.tm_year;
-}
-unsigned int Time::getMonth()
-{
- return mTime.tm_mon;
-}
-unsigned int Time::getDay()
-{
- return mTime.tm_mday;
-}
-unsigned int Time::getHour()
-{
- return mTime.tm_hour;
-}
-unsigned int Time::getMin()
-{
- return mTime.tm_min;
-}
-unsigned int Time::getSec()
-{
- return mTime.tm_sec;
-}
-long int Time::getSecondsFromAbsoluteTime()
-{
- if (mTime.tm_year > 1900)
- {
- mTime.tm_year -= 1900;
- }
-
- mTime.tm_mon -= 1;
-
- return getSecondsFromAbsTime(&mTime);
-}
-long int Time::getSecAbsTime()
-{
- return getSeconds(&mTime);
-}
-long int Time::getSecondsForWeeklySchedule()
-{
- if (mTime.tm_year > 1900)
- {
- mTime.tm_year -= 1900;
- }
-
- mTime.tm_mon -= 1;
- return getRelativeIntervalOfWeek(&mTime);
-}
-
-void Time::setDelay(long int seconds)
-{
- if (type != NONE)
- {
- mDelay = seconds;
- }
-}
-
-std::string Time::toString() const
-{
- char temp[25] = { 0 };
- // It is shown format which required of scheduled/recursive group action time.
- // " [delay] [type of actionset] "
- snprintf(temp, sizeof(temp) / sizeof(char),
- "%ld %d", mDelay, (unsigned int) type);
- return std::string(temp);
-}
-
-
-
-
-
-
-
-
-
-
-Action::Action() :
- target("")
-{
-}
-Action::~Action()
-{
- listOfCapability.clear();
-}
-
-
-
-
-
-
-
-
-
-ActionSet::ActionSet() :
- actionsetName("")
-{
-}
-ActionSet::~ActionSet()
-{
- listOfAction.clear();
-}
-}
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-/**
- * @file
- *
- */
-
-#include <algorithm>
-#include <thread>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <string.h>
-
-#include "GroupManager.h"
-
-#define ACTION_DELIMITER "*"
-#define DESC_DELIMITER "|"
-#define ATTR_DELIMITER "="
-
-using namespace OC;
-using namespace OIC;
-
-std::map< std::vector< std::string >, CandidateCallback > candidateRequest;
-std::map< std::vector< std::string >, CandidateCallback > candidateRequestForTimer;
-std::map< std::string, std::map< std::string, std::shared_ptr< OCResource > > > rtForResourceList;
-std::vector< std::string > allFoundResourceTypes;
-std::mutex callbackLock;
-
-
-template< typename T >
-bool IsSubset(std::vector< T > full, std::vector< T > sub)
-{
- std::sort(full.begin(), full.end());
- std::sort(sub.begin(), sub.end());
- return std::includes(full.begin(), full.end(), sub.begin(), sub.end());
-}
-std::vector< std::string > &str_split(const std::string &s, char delim,
- std::vector< std::string > &elems)
-{
- std::stringstream ss(s);
- std::string item;
- while (std::getline(ss, item, delim))
- {
- elems.push_back(item);
- }
- return elems;
-}
-
-std::vector< std::string > str_split(const std::string &s, char delim)
-{
- std::vector< std::string > elems;
- str_split(s, delim, elems);
- return elems;
-}
-
-void GroupManager::onFoundResource(std::shared_ptr< OCResource > resource, int waitsec)
-{
-
- std::string resourceURI;
- std::string hostAddress;
- try
- {
- // Do some operations with resource object.
- if (resource)
- {
-
- std::cout << "DISCOVERED Resource:" << std::endl;
- // Get the resource URI
- resourceURI = resource->uri();
- std::cout << "\tURI of the resource: " << resourceURI << std::endl;
-
- // Get the resource host address
- hostAddress = resource->host();
- std::cout << "\tHost address of the resource: " << hostAddress << std::endl;
-
- // Get the resource types
- std::cout << "\tList of resource types: " << std::endl;
-
- hostAddress.append(resourceURI);
-
- for (auto &resourceTypes : resource->getResourceTypes())
- {
- std::cout << "\t\t" << resourceTypes << std::endl;
-
- if (std::find(allFoundResourceTypes.begin(), allFoundResourceTypes.end(),
- resourceTypes) == allFoundResourceTypes.end())
- {
- allFoundResourceTypes.push_back(resourceTypes);
- }
-
- rtForResourceList[resourceTypes][hostAddress] = resource;
- }
-
- // Get the resource interfaces
- std::cout << "\tList of resource interfaces: " << std::endl;
- for (auto &resourceInterfaces : resource->getResourceInterfaces())
- {
- std::cout << "\t\t" << resourceInterfaces << std::endl;
- }
-
- if (waitsec == -1)
- {
- findPreparedRequest(candidateRequest);
- }
- }
- else
- {
- // Resource is invalid
- std::cout << "Resource is invalid" << std::endl;
- }
-
- }
- catch (std::exception& e)
- {
- //log(e.what());
- }
-}
-
-GroupManager::GroupManager(void)
-{
- ;
-}
-
-/**
- * Virtual destructor
- */
-GroupManager::~GroupManager(void)
-{
- candidateRequest.clear();
- candidateRequestForTimer.clear();
- rtForResourceList.clear();
- allFoundResourceTypes.clear();
-}
-
-void GroupManager::findPreparedRequest(
- std::map< std::vector< std::string >, CandidateCallback > &request)
-{
- std::lock_guard<std::mutex> lock(callbackLock);
- std::vector< std::shared_ptr< OCResource > > resources;
-
- for (auto it = request.begin(); it != request.end();)
- {
-
- if (IsSubset(allFoundResourceTypes, it->first))
- {
- for (unsigned int i = 0; i < it->first.size(); ++i)
- {
-
- for (auto secondIt = rtForResourceList[it->first.at(i)].begin();
- secondIt != rtForResourceList[it->first.at(i)].end(); ++secondIt)
- {
- //insert resource related to request
- resources.push_back(secondIt->second);
- }
- }
-
- it->second(resources);
-
- //TODO : decide policy - callback only once
- request.erase(it++);
- }
- else
- {
- ++it;
- }
-
- }
-
-}
-
-void GroupManager::lazyCallback(int second)
-{
- sleep(second);
- findPreparedRequest(candidateRequestForTimer);
-
-}
-
-OCStackResult GroupManager::findCandidateResources(
- std::vector< std::string > resourceTypes,
- CandidateCallback callback, int waitsec)
-{
- if (resourceTypes.size() < 1)
- {
- return OC_STACK_ERROR;
- }
- if(callback == NULL)
- {
- return OC_STACK_ERROR;
- }
-
- std::sort(resourceTypes.begin(), resourceTypes.end());
- resourceTypes.erase(std::unique(resourceTypes.begin(), resourceTypes.end()),
- resourceTypes.end());
-
- if (waitsec >= 0)
- {
- candidateRequestForTimer.insert(std::make_pair(resourceTypes, callback));
- }
- else
- {
- candidateRequest.insert(std::make_pair(resourceTypes, callback));
- }
-
- for (unsigned int i = 0; i < resourceTypes.size(); ++i)
- {
- // std::cout << "resourceTypes : " << resourceTypes.at(i) << std::endl;
-
- std::string query = OC_RSRVD_WELL_KNOWN_URI;
- query.append("?rt=");
- query.append(resourceTypes.at(i));
-
- OCPlatform::findResource("",
- query,
- CT_DEFAULT,
- std::function < void(std::shared_ptr < OCResource > resource)
- > (std::bind(&GroupManager::onFoundResource, this, std::placeholders::_1,
- waitsec)));
- }
-
- if (waitsec >= 0)
- {
- std::thread exec(
- std::function< void(int second) >(
- std::bind(&GroupManager::lazyCallback, this, std::placeholders::_1)),
- waitsec);
- exec.detach();
- }
-
- return OC_STACK_OK;
-}
-
-
-OCStackResult GroupManager::bindResourceToGroup(OCResourceHandle& childHandle, std::shared_ptr< OCResource > resource, OCResourceHandle& collectionHandle)
-{
-
- OCStackResult result = OCPlatform::registerResource(childHandle, resource);
-
- cout << "\tresource registed!" << endl;
-
- if(result == OC_STACK_OK)
- {
- OCPlatform::bindResource(collectionHandle, childHandle);
- }
- else
- {
- cout << "\tresource Error!" << endl;
- }
-
- return result;
-}
-
-
-
-/*
- Presence Check
- */
-
-std::map< std::string, CollectionPresenceCallback > presenceCallbacks;
-
-// Callback to presence
-void GroupManager::collectionPresenceHandler(OCStackResult result, const unsigned int nonce,
- const std::string& /*hostAddress*/, std::string host, std::string uri)
-{
- std::cout << "uri : " << uri << std::endl;
- std::cout << "host : " << host << std::endl;
- std::cout << "result : " << result << std::endl;
- switch (result)
- {
- case OC_STACK_OK:
- std::cout << "Nonce# " << nonce << std::endl;
- break;
- case OC_STACK_PRESENCE_STOPPED:
- std::cout << "Presence Stopped\n";
- break;
- case OC_STACK_PRESENCE_DO_NOT_HANDLE:
- std::cout << "Presence do not handle\n";
- break;
- case OC_STACK_PRESENCE_TIMEOUT:
- std::cout << "Presence TIMEOUT\n";
- break;
- default:
- std::cout << "Error\n";
- break;
- }
-
- if (presenceCallbacks.find(uri) != presenceCallbacks.end())
- {
- (presenceCallbacks.find(uri)->second)(uri, result);
- }
-}
-
-void GroupManager::checkCollectionRepresentation(const OCRepresentation& rep,
- CollectionPresenceCallback callback)
-{
- std::cout << "\tResource URI: " << rep.getUri() << std::endl;
-
- std::vector< OCRepresentation > children = rep.getChildren();
- if(children.size() == 0 )
- {
- callback("", OC_STACK_ERROR);
- return;
- }
-
- for (auto oit = children.begin(); oit != children.end(); ++oit)
- {
- if(oit->getUri().find("coap://") == std::string::npos)
- {
- std::cout << "The resource with a URI " << oit->getUri() << " is not a remote resource."
- << " Thus, we ignore to send a request for presence check to the resource.\n";
-
- continue;
- }
-
- std::vector< std::string > hostAddressVector = str_split(oit->getUri(), '/');
- std::string hostAddress = "";
- for (unsigned int i = 0; i < hostAddressVector.size(); ++i)
- {
- if (i < 3)
- {
- hostAddress.append(hostAddressVector.at(i));
- if (i != 2)
- {
- hostAddress.append("/");
- }
- }
- }
-
- std::vector< std::string > resourceTypes = oit->getResourceTypes();
- // for (unsigned int i = 0; i < resourceTypes.size(); ++i)
- // {
- // std::cout << "\t\t\tresourcetype :" << resourceTypes.at(i) << std::endl;
- // }
-
- // std::string resourceType = "core.";
- // resourceType.append(str_split(oit->getUri(), '/').at(4));
- // std::cout << "\t\tconvertRT : " << resourceType << std::endl;
- // std::cout << "\t\tresource type front : " << resourceTypes.front() << endl;
- // std::cout << "\t\thost : " << hostAddress << std::endl;
- OCPlatform::OCPresenceHandle presenceHandle;
- OCStackResult result = OC_STACK_ERROR;
-
- try
- {
- result = OCPlatform::subscribePresence(presenceHandle, hostAddress,
- // resourceType,
- resourceTypes.front(),
- CT_DEFAULT,
- std::function<
- void(OCStackResult result, const unsigned int nonce,
- const std::string& hostAddress) >(
- std::bind(&GroupManager::collectionPresenceHandler, this,
- std::placeholders::_1, std::placeholders::_2,
- std::placeholders::_3, hostAddress, oit->getUri())));
- }
- catch(OCException& e)
- {
- std::cout<< "Exception in subscribePresence: "<< e.what() << std::endl;
- }
-
- if (result == OC_STACK_OK)
- {
- presenceCallbacks.insert(std::make_pair(oit->getUri(), callback));
- }
- else
- {
- callback("", OC_STACK_ERROR);
- }
- }
-}
-
-void GroupManager::onGetForPresence(const HeaderOptions& /*headerOptions*/,
- const OCRepresentation& rep, const int eCode, CollectionPresenceCallback callback)
-{
- if (eCode == OC_STACK_OK)
- {
- std::cout << "GET request was successful" << std::endl;
- std::cout << "Resource URI: " << rep.getUri() << std::endl;
-
- checkCollectionRepresentation(rep, callback);
-
- }
- else
- {
- std::cout << "onGET Response error: " << eCode << std::endl;
- callback("", OC_STACK_ERROR);
- }
-}
-
-OCStackResult GroupManager::subscribeCollectionPresence(
- std::shared_ptr< OCResource > collectionResource, CollectionPresenceCallback callback)
-{
- if(callback == NULL || collectionResource == NULL)
- {
- return OC_STACK_ERROR;
- }
-
- OCStackResult result = OC_STACK_OK;
- //callback("core.room",OC_STACK_OK);
-
- QueryParamsMap queryParam;
-
- //parameter 1 = resourceType
- collectionResource->get("", DEFAULT_INTERFACE, queryParam,
- std::function<
- void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
- const int eCode) >(
- std::bind(&GroupManager::onGetForPresence, this, std::placeholders::_1,
- std::placeholders::_2, std::placeholders::_3, callback)));
-
- return result;
-}
-
-/*
- Group Action
- */
-
-std::string GroupManager::getStringFromActionSet(const ActionSet *newActionSet)
-{
- std::string message = "";
-
- if(newActionSet == NULL)
- {
- return message;
- }
-
- message = newActionSet->actionsetName;
- message.append("*");
- message.append(newActionSet->toString());
- message.append("*");
- for (auto iterAction = newActionSet->listOfAction.begin();
- iterAction != newActionSet->listOfAction.end(); iterAction++)
- {
- message.append("uri=");
- message.append((*iterAction)->target);
- message.append("|");
-
- for (auto iterCapa = (*iterAction)->listOfCapability.begin();
- iterCapa != (*iterAction)->listOfCapability.end(); iterCapa++)
- {
- message.append((*iterCapa)->capability);
- message.append("=");
- message.append((*iterCapa)->status);
-
- if (iterCapa + 1 != (*iterAction)->listOfCapability.end())
- {
- message.append("|");
- }
- }
-
- if (iterAction + 1 != newActionSet->listOfAction.end())
- {
- message.append("*");
- }
- }
-
- return message;
-}
-
-#define DELETE(p) \
-{ \
- delete p; \
- p = NULL; \
-}
-
-#define DELETEARRAY(p) \
-{ \
- delete[] p; \
- p = NULL; \
-}
-
-ActionSet* GroupManager::getActionSetfromString(std::string description)
-{
- char *token = NULL;
- char *plainText = NULL;
- char *plainPtr = NULL;
- char *attr = NULL, *desc = NULL;
-
- Action *action = NULL;
- Capability *capa = NULL;
- ActionSet *actionset = new ActionSet();
-
- if(actionset == NULL)
- {
- goto exit;
- }
-
- if(description.empty())
- {
- goto exit;
- }
- else if(description.at(0) == '*')
- {
- goto exit;
- }
-
- plainText = new char[(description.length() + 1)];
- strncpy(plainText, description.c_str(), description.length()+1);
-
- // All tokens are seperated by "*" character.
- // First token means an actionset name
- token = strtok_r(plainText, ACTION_DELIMITER, &plainPtr);
-
- if (token != NULL)
- {
- actionset->actionsetName = std::string(token);
-
- if((actionset->actionsetName).empty())
- {
- goto exit;
- }
-
- // Find the second token
- token = strtok_r(NULL, ACTION_DELIMITER, &plainPtr);
- }
- else
- {
- goto exit;
- }
-
- if (token != NULL)
- {
- // The second token consists of two digits: time delay and actionset Type.
- // Time delay is used as a parameter to scheduled/recursive group action feature
- // And actionset type indicates if the actionset is scheduled or recursive group action.
- char *subText = NULL;
- char *subToken = NULL;
- char *subTextPtr = NULL;
-
- subText = new char[strlen(token)+1];
- strncpy(subText, token, strlen(token)+1);
-
- subToken = strtok_r(subText, " ", &subTextPtr);
- if(subToken == NULL)
- {
- DELETEARRAY(subText);
- goto exit;
- }
- actionset->mDelay = atol(subToken);
-
- subToken = strtok_r(NULL, " ", &subTextPtr);
- if(subToken == NULL)
- {
- DELETEARRAY(subText);
- goto exit;
- }
- actionset->type = (OIC::ACTIONSET_TYPE)atoi(subToken);
-
- DELETEARRAY(subText);
-
- // Find the third token
- token = strtok_r(NULL, ACTION_DELIMITER, &plainPtr);
- }
- else
- {
- goto exit;
- }
-
- while (token)
- {
- // The third token consists of two sub-segement: host address plus URI and attribute key/value pair.
- // These two segments can be divided by "|" character.
- // The third token can be repeatively appeared.
-
- char *descPtr = NULL;
- desc = new char[(strlen(token) + 1)];
-
- if (desc != NULL)
- {
- // copy a host address plus URI string from the third token
- strncpy(desc, token, (strlen(token) + 1));
-
- // Find "|" character to find key/value pair
- token = strtok_r(desc, DESC_DELIMITER, &descPtr);
-
- while (token != NULL)
- {
- char *attrPtr = NULL;
- attr = new char[(strlen(token) + 1)];
- // copy the host address plus URI string
- strcpy(attr, token);
-
- // Find "=" charactor to divide attribute key and value string.
- token = strtok_r(attr, ATTR_DELIMITER, &attrPtr);
- while (token != NULL)
- {
- if ( (action == NULL) && strcmp(token, "uri") == 0)
- {
- token = strtok_r(NULL, ATTR_DELIMITER, &attrPtr);
- if(token == NULL)
- {
- goto exit;
- }
-
- action = new Action();
- if (action != NULL)
- {
- action->target = std::string(token);
- }
- else
- {
- goto exit;
- }
- }
- else
- {
- capa = new Capability();
- capa->capability = std::string(token);
- token = strtok_r(NULL, ATTR_DELIMITER, &attrPtr);
-
- if( token == NULL )
- {
- goto exit;
- }
-
- capa->status = std::string(token);
-
- if (action != NULL)
- {
- action->listOfCapability.push_back(capa);
- }
- else
- {
- goto exit;
- }
- }
-
- token = strtok_r(NULL, ATTR_DELIMITER, &attrPtr);
- }
- DELETEARRAY(attr);
- token = strtok_r(NULL, DESC_DELIMITER, &descPtr);
- }
-
- if( action != NULL )
- {
- actionset->listOfAction.push_back(action);
- action = NULL;
- }
- else
- {
- goto exit;
- }
- //delete action;
- }
- else
- {
- goto exit;
- }
-
- DELETEARRAY(desc);
-
- token = strtok_r(NULL, ACTION_DELIMITER, &plainPtr);
- }
-
- DELETEARRAY(plainText);
- return actionset;
-
-exit:
- DELETE(action);
- DELETE(capa)
- DELETE(actionset)
- DELETEARRAY(attr);
- DELETEARRAY(plainText);
- DELETEARRAY(desc);
- return NULL;
-}
-
-OCStackResult GroupManager::addActionSet(std::shared_ptr< OCResource > resource,
- const ActionSet* newActionSet, PutCallback cb)
-{
- // BUILD message of ActionSet which it is included delimiter.
- if ((resource != NULL) && (newActionSet != NULL))
- {
- if(newActionSet->mDelay < 0)
- {
- return OC_STACK_INVALID_PARAM;
- }
-
- std::string message = getStringFromActionSet(newActionSet);
-
- OCRepresentation rep;
- rep.setValue("ActionSet", message);
- return resource->put(resource->getResourceTypes().front(), GROUP_INTERFACE, rep,
- QueryParamsMap(), cb);
- }
- else
- {
- return OC_STACK_ERROR;
- }
-}
-
-OCStackResult GroupManager::executeActionSet(std::shared_ptr< OCResource > resource,
- std::string actionsetName, PostCallback cb)
-{
- if (resource != NULL)
- {
- OCRepresentation rep;
-
- rep.setValue("DoAction", actionsetName);
- return resource->post(resource->getResourceTypes().front(), GROUP_INTERFACE, rep,
- QueryParamsMap(), cb);
- }
- else
- {
- return OC_STACK_ERROR;
- }
-}
-
-OCStackResult GroupManager::executeActionSet(std::shared_ptr< OCResource > resource,
- std::string actionsetName, long int delay, PostCallback cb)
-{
- if(delay <= 0 )
- {
- return OC_STACK_INVALID_PARAM;
- }
- if (resource != NULL)
- {
- std::string value = actionsetName;
- value.append("*");
- value.append(std::to_string(delay));
-
- OCRepresentation rep;
- rep.setValue("DoScheduledAction", value);
- return resource->post(resource->getResourceTypes().front(), GROUP_INTERFACE, rep,
- QueryParamsMap(), cb);
- }
- else
- {
- return OC_STACK_ERROR;
- }
-}
-
-OCStackResult GroupManager::cancelActionSet(std::shared_ptr< OCResource > resource,
- std::string actionsetName, PostCallback cb)
-{
- if (resource != NULL)
- {
- OCRepresentation rep;
-
- rep.setValue("CancelAction", actionsetName);
- return resource->post(resource->getResourceTypes().front(), GROUP_INTERFACE, rep,
- QueryParamsMap(), cb);
- }
- else
- {
- return OC_STACK_ERROR;
- }
-}
-
-OCStackResult GroupManager::getActionSet(std::shared_ptr< OCResource > resource,
- std::string actionsetName, PostCallback cb)
-{
- if (resource != NULL)
- {
- OCRepresentation rep;
-
- rep.setValue("GetActionSet", actionsetName);
-
- return resource->post(resource->getResourceTypes().front(), GROUP_INTERFACE, rep,
- QueryParamsMap(), cb);
- }
- else
- {
- return OC_STACK_ERROR;
- }
-}
-
-OCStackResult GroupManager::deleteActionSet(std::shared_ptr< OCResource > resource,
- std::string actionsetName, PutCallback cb)
-{
- if (resource != NULL)
- {
- OCRepresentation rep;
-
- rep.setValue("DelActionSet", actionsetName);
-
- return resource->put(resource->getResourceTypes().front(), GROUP_INTERFACE, rep,
- QueryParamsMap(), cb);
- }
- else
- {
- return OC_STACK_ERROR;
- }
-}
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-/**
- * @file
- *
- */
-
-#include <OCApi.h>
-#include <OCPlatform.h>
-#include <cstdlib>
-#include <algorithm>
-#include "ThingsConfiguration.h"
-
-using namespace OC;
-
-namespace OIC
-{
- int cnt = 0;
-
- std::map< std::string, ConfigurationRequestEntry > configurationRequestTable;
- ThingsConfiguration* ThingsConfiguration::thingsConfigurationInstance = NULL;
- ConfigurationCallback g_bootstrapCallback;
-
- ConfigurationRequestEntry::ConfigurationRequestEntry(std::string ID,
- ConfigurationCallback callback,
- std::shared_ptr< OCResource > resource,
- std::string updateVal)
- {
- m_ID = ID;
- m_callback = callback;
- m_resource = resource;
- m_updateVal = updateVal;
- }
-
- ConfigurationUnitInfo::ConfigurationUnitInfo(std::string name,
- std::string attribute,
- std::string uri)
- {
- m_name = name;
- m_attribute = attribute;
- m_uri = uri;
- }
-
- std::string ConfigurationUnitInfo::getJSON()
- {
- std::string res;
-
- res = "{\"name\":\"" + m_name + "\",\"property\":\"" + m_attribute + "\"}";
-
- return res;
- }
-
- ThingsConfiguration::ThingsConfiguration(void)
- {
- ConfigurationUnitInfo unit[] =
- {
- { "all", "All attributes", "/oic/con" },
- { "n", "Device Name", "/oic/con"},
- { "loc", "Location", "/oic/con"},
- { "locn", "Location Name", "/oic/con"},
- { "r", "Region", "/oic/con" },
- { "c","Currency", "/oic/con" } };
-
- for (int i = 0; i < NUMCONFUNIT; i++)
- {
- ConfigurationUnitTable.push_back(unit[i]);
- }
- }
-
- ThingsConfiguration::~ThingsConfiguration(void)
- {
- }
-
- void ThingsConfiguration::setGroupManager(GroupManager *groupmanager)
- {
- g_groupmanager = groupmanager;
- }
-
- ThingsConfiguration* ThingsConfiguration::getInstance()
- {
- if (thingsConfigurationInstance == NULL)
- {
- thingsConfigurationInstance = new ThingsConfiguration();
- }
- return thingsConfigurationInstance;
- }
-
- void ThingsConfiguration::deleteInstance()
- {
- if (thingsConfigurationInstance)
- {
- delete thingsConfigurationInstance;
- thingsConfigurationInstance = NULL;
- }
- }
-
- std::string ThingsConfiguration::getAttributeByConfigurationName(ConfigurationName name)
- {
- for (auto it = ConfigurationUnitTable.begin(); ConfigurationUnitTable.end() != it; it++)
- {
- if ((*it).m_name == name)
- {
- return (*it).m_attribute;
- }
- }
-
- return "";
- }
-
- std::string ThingsConfiguration::getUriByConfigurationName(ConfigurationName name)
- {
- for (auto it = ConfigurationUnitTable.begin(); ConfigurationUnitTable.end() != it; it++)
- {
- if ((*it).m_name == name)
- {
- return (*it).m_uri;
- }
- }
-
- return "";
- }
-
- std::string ThingsConfiguration::getUpdateVal(std::string conf)
- {
- std::map< std::string, ConfigurationRequestEntry >::iterator it =
- configurationRequestTable.find(conf);
-
- if (it == configurationRequestTable.end())
- {
- return NULL;
- }
- else
- {
- return it->second.m_updateVal;
- }
-
- }
- std::shared_ptr< OCResource > ThingsConfiguration::getResource(std::string conf)
- {
- std::map< std::string, ConfigurationRequestEntry >::iterator it =
- configurationRequestTable.find(conf);
-
- if (it == configurationRequestTable.end())
- {
- return NULL;
- }
- else
- {
- return it->second.m_resource;
- }
- }
-
- ConfigurationCallback ThingsConfiguration::getCallback(std::string conf)
- {
- std::map< std::string, ConfigurationRequestEntry >::iterator it =
- configurationRequestTable.find(conf);
-
- if (it == configurationRequestTable.end())
- {
- return NULL;
- }
- else
- {
- return it->second.m_callback;
- }
- }
-
- std::string ThingsConfiguration::getListOfSupportedConfigurationUnits()
- {
- std::string res;
-
- res = "{\"Configuration Units\":[";
-
- auto it = ConfigurationUnitTable.begin();
- while (1)
- {
- res = res + (*it).getJSON();
- it++;
-
- if (it == ConfigurationUnitTable.end())
- {
- break;
- }
- else
- {
- res += ",";
- }
- }
-
- res += "]}";
-
- return res;
- }
-
- std::string ThingsConfiguration::getHostFromURI(std::string oldUri)
- {
- size_t f;
- std::string newUri;
-
- if ((f = oldUri.find("/factoryset/oic/")) != string::npos)
- {
- newUri = oldUri.replace(f, oldUri.size(), "");
- }
- else if ((f = oldUri.find("/oic/")) != string::npos)
- {
- newUri = oldUri.replace(f, oldUri.size(), "");
- }
-
- return newUri;
- }
-
- void ThingsConfiguration::onDeleteActionSet(const HeaderOptions& /*headerOptions*/,
- const OCRepresentation& /*rep*/, const int /*eCode*/, std::string conf)
- {
- std::shared_ptr < OCResource > resource = getResource(conf);
-
- if (resource)
- {
- QueryParamsMap query;
-
- // After deletion of the left action set, find target child resource's URIs by sending
- // GET message. Note that, this resource is surely a collection resource which has child
- // resources.
- resource->get(resource->getResourceTypes().at(0), DEFAULT_INTERFACE, query,
- std::function<
- void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
- const int eCode) >(
- std::bind(&ThingsConfiguration::onGetChildInfoForUpdate, this,
- std::placeholders::_1, std::placeholders::_2,
- std::placeholders::_3, conf)));
- }
-
- }
-
- void ThingsConfiguration::onGetChildInfoForUpdate(const HeaderOptions& headerOptions,
- const OCRepresentation& rep, const int eCode, std::string conf)
- {
- if (eCode != OC_STACK_OK)
- {
- std::cout << "onPut Response error: " << eCode << std::endl;
- getCallback(conf)(headerOptions, rep, eCode);
- return ;
- }
-
- std::cout << "GET request was successful" << std::endl;
-
- std::cout << "\tResource URI: " << rep.getUri() << std::endl;
-
- std::vector < OCRepresentation > children = rep.getChildren();
- for (auto oit = children.begin(); oit != children.end(); ++oit)
- {
- std::cout << "\t\tChild Resource URI: " << oit->getUri() << std::endl;
- }
-
- // Get information by using configuration name(conf)
- std::shared_ptr < OCResource > resource = getResource(conf);
- std::string actionstring = conf;
- std::string uri = getUriByConfigurationName(conf);
- std::string attrKey = conf;
-
- if (uri == "")
- {
- return;
- }
-
- if (resource)
- {
- // In this nest, we create a new action set of which name is the configuration name.
- // Required information consists of a host address, URI, attribute key, and
- // attribute value.
- ActionSet *newActionSet = new ActionSet();
- newActionSet->actionsetName = conf;
-
- for (auto oit = children.begin(); oit != children.end(); ++oit)
- {
- Action *newAction = new Action();
-
- // oit->getUri() includes a host address as well as URI.
- // We should split these to each other and only use the host address to create
- // a child resource's URI. Note that the collection resource and its child
- // resource are located in same host.
- newAction->target = getHostFromURI(oit->getUri()) + uri;
-
- Capability *newCapability = new Capability();
- newCapability->capability = attrKey;
- newCapability->status = getUpdateVal(conf);
-
- newAction->listOfCapability.push_back(newCapability);
- newActionSet->listOfAction.push_back(newAction);
- }
-
- // Request to create a new action set by using the above actionSet
- g_groupmanager->addActionSet(resource, newActionSet,
- std::function<
- void(const HeaderOptions& headerOptions,
- const OCRepresentation& rep, const int eCode) >(
- std::bind(&ThingsConfiguration::onCreateActionSet, this,
- std::placeholders::_1, std::placeholders::_2,
- std::placeholders::_3, conf)));
-
- delete(newActionSet);
- }
- }
-
- void ThingsConfiguration::onGetChildInfoForGet(const HeaderOptions& headerOptions,
- const OCRepresentation& rep, const int eCode, std::string conf)
- {
- if (eCode != OC_STACK_OK)
- {
- std::cout << "onGet Response error: " << eCode << std::endl;
- getCallback(conf)(headerOptions, rep, eCode);
- return ;
- }
-
- std::cout << "GET request was successful" << std::endl;
- std::cout << "\tResource URI: " << rep.getUri() << std::endl;
-
- std::shared_ptr< OCResource > resource, tempResource;
- std::vector < std::shared_ptr< OCResource > > p_resources;
- std::vector < std::string > m_if;
- std::string uri = getUriByConfigurationName(conf);
-
- if (uri == "")
- {
- return;
- }
-
- if (uri == "/factoryset" || uri == "/factoryset/oic/con")
- {
- m_if.push_back(BATCH_INTERFACE);
- }
- else
- {
- m_if.push_back(DEFAULT_INTERFACE);
- }
-
- std::vector < OCRepresentation > children = rep.getChildren();
- for (auto oit = children.begin(); oit != children.end(); ++oit)
- {
- std::cout << "\t\tChild Resource URI: " << oit->getUri() << std::endl;
-
- // Using a host address and child URIs, we can dynamically create resource objects.
- // Note that the child resources have not found before, we have no resource objects.
- // For this reason, we create the resource objects.
-
- std::string host = getHostFromURI(oit->getUri());
-
- try
- {
- tempResource = OCPlatform::constructResourceObject(host, uri, CT_ADAPTER_IP, true,
- oit->getResourceTypes(), m_if);
-
- p_resources.push_back(tempResource);
- }
- catch (std::exception& e)
- {
- std::cout << "Exception: " << e.what() << std::endl;
- }
- }
-
- // Send GET messages to the child resources in turn.
- for (unsigned int i = 0; i < p_resources.size(); ++i)
- {
- resource = p_resources.at(i);
- if (resource)
- {
- try
- {
- QueryParamsMap test;
- resource->get(test, getCallback(conf));
- }
- catch (OCException& e)
- {
- std::cout << e.reason() << std::endl;
- }
-
- }
- }
- }
-
- void ThingsConfiguration::onCreateActionSet(const HeaderOptions& headerOptions,
- const OCRepresentation& rep, const int eCode, std::string conf)
- {
- if (eCode != OC_STACK_OK)
- {
- std::cout << "onPut Response error: " << eCode << std::endl;
- getCallback(conf)(headerOptions, rep, eCode);
- return ;
- }
-
- std::cout << "PUT request was successful" << std::endl;
-
- std::shared_ptr < OCResource > resource = getResource(conf);
- if (resource)
- {
- // Now, it is time to execute the action set.
- g_groupmanager->executeActionSet(resource, conf,
- std::function<
- void(const HeaderOptions& headerOptions,
- const OCRepresentation& rep, const int eCode) >(
- std::bind(&ThingsConfiguration::onExecuteForGroupAction, this,
- std::placeholders::_1, std::placeholders::_2,
- std::placeholders::_3, conf)));
- }
- }
-
- void ThingsConfiguration::onExecuteForGroupAction(const HeaderOptions& headerOptions,
- const OCRepresentation& rep, const int eCode, std::string conf)
- {
- if (eCode != OC_STACK_OK)
- {
- std::cout << "onPut Response error: " << eCode << std::endl;
- getCallback(conf)(headerOptions, rep, eCode);
- return ;
- }
-
- std::cout << "PUT request was successful" << std::endl;
-
- getCallback(conf)(headerOptions, rep, eCode);
- }
-
- bool ThingsConfiguration::isSimpleResource(std::shared_ptr< OCResource > resource)
- {
-
- for (unsigned int i = 0; i < resource->getResourceTypes().size(); ++i)
- {
- if (resource->getResourceTypes().at(i).find(".resourceset", 0) != std::string::npos)
- {
- return false;
- }
- }
-
- return true;
- }
-
- bool ThingsConfiguration::hasBatchInterface(std::shared_ptr< OCResource > resource)
- {
- for (unsigned int i = 0; i < resource->getResourceInterfaces().size(); ++i)
- {
- if (resource->getResourceInterfaces().at(i) == BATCH_INTERFACE)
- {
- return true;
- }
- }
-
- return false;
- }
-
- void ThingsConfiguration::onGet(const HeaderOptions& headerOptions, const OCRepresentation& rep,
- const int eCode, std::string conf)
- {
- if (eCode != OC_STACK_OK)
- {
- std::cout << "onGet Response error: " << eCode << std::endl;
- getCallback(conf)(headerOptions, rep, eCode);
- return ;
- }
-
- std::cout << "Get request was successful" << std::endl;
-
- getCallback(conf)(headerOptions, rep, eCode);
- }
-
- void ThingsConfiguration::onPut(const HeaderOptions& headerOptions, const OCRepresentation& rep,
- const int eCode, std::string conf)
- {
- if (eCode != OC_STACK_OK)
- {
- std::cout << "onPut Response error: " << eCode << std::endl;
- getCallback(conf)(headerOptions, rep, eCode);
- return;
- }
-
- std::cout << "PUT request was successful" << std::endl;
-
- getCallback(conf)(headerOptions, rep, eCode);
- }
-
- OCStackResult ThingsConfiguration::updateConfigurations(std::shared_ptr< OCResource > resource,
- std::map< ConfigurationName, ConfigurationValue > configurations,
- ConfigurationCallback callback)
- {
- // For M2, # of configurations is 1
- // First, mapping a semantic name(ConfigurationUnit) into resource's name(uri ...)
- if (configurations.size() == 0)
- {
- std::cout << "# of request configuration is 0" << std::endl;
- return OC_STACK_ERROR;
- }
-
- if (!resource)
- {
- std::cout << "resource is NULL\n";
- return OC_STACK_ERROR;
- }
-
- std::map< ConfigurationName, ConfigurationValue >::iterator it = configurations.begin();
- std::string conf = it->first; // configuration name
- std::transform(conf.begin(), conf.end(), conf.begin(), ::tolower); // to lower case
-
- // Check the request queue if a previous request is still left. If so, remove it.
- std::map< std::string, ConfigurationRequestEntry >::iterator iter =
- configurationRequestTable.find(conf);
- if (iter != configurationRequestTable.end())
- {
- configurationRequestTable.erase(iter);
- }
-
- // Create new request entry stored in the queue
- ConfigurationRequestEntry newCallback(conf, callback, resource, it->second);
- configurationRequestTable.insert(std::make_pair(conf, newCallback));
-
- OCRepresentation rep;
- QueryParamsMap query;
- if (isSimpleResource(resource))
- {
- // This resource does not need to use a group manager. Just send a PUT message
- rep.setValue(conf, getUpdateVal(conf));
- return resource->put(resource->getResourceTypes().at(0), DEFAULT_INTERFACE, rep, query,
- std::function<
- void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
- const int eCode) >(
- std::bind(&ThingsConfiguration::onGet, this, std::placeholders::_1,
- std::placeholders::_2, std::placeholders::_3, conf)));
- }
- else
- {
- // This resource is a collection resource which uses group manager functionalities.
- // First, delete an existing action set of which name is same as a current action set
- // name. As of now, the name is determined by "Configuration Name" which a user just
- // specifies.
- return g_groupmanager->deleteActionSet(resource, conf,
- std::function<
- void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
- const int eCode) >(
- std::bind(&ThingsConfiguration::onDeleteActionSet, this,
- std::placeholders::_1, std::placeholders::_2,
- std::placeholders::_3, conf)));
- }
- }
-
- OCStackResult ThingsConfiguration::getConfigurations(std::shared_ptr< OCResource > resource,
- std::vector< ConfigurationName > configurations, ConfigurationCallback callback)
- {
- // For M2, # of configurations is 1
- // First, mapping a semantic name(ConfigurationUnit) into resource's name(uri ...)
- if (configurations.size() == 0)
- {
- std::cout << "# of request configuration is 0" << std::endl;
- return OC_STACK_ERROR;
- }
- if (!resource)
- {
- std::cout << "resource is NULL\n";
- return OC_STACK_ERROR;
- }
-
- std::vector< ConfigurationName >::iterator it = configurations.begin();
- std::string conf = (*it); // configuration name
- std::transform(conf.begin(), conf.end(), conf.begin(), ::tolower); // to lower case
-
- // Check the request queue if a previous request is still left. If so, remove it.
- std::map< std::string, ConfigurationRequestEntry >::iterator iter =
- configurationRequestTable.find(conf);
- if (iter != configurationRequestTable.end())
- {
- configurationRequestTable.erase(iter);
- }
-
- // Create new request entry stored in the queue
- ConfigurationRequestEntry newCallback(conf, callback, resource, conf);
- configurationRequestTable.insert(std::make_pair(conf, newCallback));
-
- QueryParamsMap query;
- OCRepresentation rep;
-
- if (isSimpleResource(resource))
- {
- // This resource is a simple resource. Just send a PUT message
- std::string m_if = DEFAULT_INTERFACE;
-
- if (hasBatchInterface(resource))
- {
- m_if = BATCH_INTERFACE;
- }
-
- return resource->get(resource->getResourceTypes().at(0), m_if, query,
- std::function<
- void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
- const int eCode) >(
- std::bind(&ThingsConfiguration::onGet, this, std::placeholders::_1,
- std::placeholders::_2, std::placeholders::_3, conf)));
- }
- else
- {
- // This resource is a collection resource. On the contrary of a update, it does not use
- // group manager functionality. It just acquires child resource's URI and send GET
- // massages to the child resources in turn.
- // First, request the child resources's URI.
- return resource->get(resource->getResourceTypes().at(0), DEFAULT_INTERFACE, query,
- std::function<
- void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
- const int eCode) >(
- std::bind(&ThingsConfiguration::onGetChildInfoForGet, this,
- std::placeholders::_1, std::placeholders::_2,
- std::placeholders::_3, conf)));
- }
-
- }
-
-// callback handler on GET request
- void ThingsConfiguration::onGetBootstrapInformation(const HeaderOptions& headerOptions,
- const OCRepresentation& rep, const int eCode)
- {
- if (eCode != OC_STACK_OK)
- {
- std::cout << "onGET Response error: " << eCode << std::endl;
- g_bootstrapCallback(headerOptions, rep, eCode);
- return;
- }
-
- g_bootstrapCallback(headerOptions, rep, eCode);
- }
-
- void ThingsConfiguration::onFoundBootstrapServer(
- std::vector< std::shared_ptr< OCResource > > resources)
- {
- std::string resourceURI;
- std::string hostAddress;
-
- try
- {
- // Do some operations with resource object.
- for (unsigned int i = 0; i < resources.size(); ++i)
- {
- std::shared_ptr < OCResource > resource = resources.at(i);
-
- if (resource)
- { // Request configuration resources
-
- std::cout << "Getting bootstrap server representation on: " << DEFAULT_INTERFACE
- << std::endl;
-
- resource->get("bootstrap", DEFAULT_INTERFACE, QueryParamsMap(),
- &onGetBootstrapInformation);
-
- }
- else
- {
- // Resource is invalid
- std::cout << "Resource is invalid" << std::endl;
- }
- }
-
- }
- catch (std::exception& e)
- {
- //log(e.what());
- }
- }
-
- OCStackResult ThingsConfiguration::doBootstrap(ConfigurationCallback callback)
- {
- if(callback == NULL)
- {
- return OC_STACK_ERROR;
- }
- else
- {
- g_bootstrapCallback = callback;
- }
-
- // Find bootstrap server.
- std::vector < std::string > type;
- type.push_back("bootstrap");
-
- std::cout << "Finding Bootstrap Server resource... " << std::endl;
- return g_groupmanager->findCandidateResources(type, &onFoundBootstrapServer);
- }
-}
-
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-/**
- * @file
- *
- */
-
-#include <OCApi.h>
-#include <OCPlatform.h>
-#include <cstdlib>
-
-#include "ThingsMaintenance.h"
-
-using namespace OC;
-
-namespace OIC
-{
- std::map< std::string, MaintenanceRequestEntry > maintenanceRequestTable;
- ThingsMaintenance* ThingsMaintenance::thingsMaintenanceInstance = NULL;
-
- MaintenanceRequestEntry::MaintenanceRequestEntry(std::string ID, MaintenanceCallback callback,
- std::shared_ptr< OCResource > resource, std::string updateVal)
- {
- m_ID = ID;
- m_callback = callback;
- m_resource = resource;
- m_updateVal = updateVal;
- }
-
- MaintenanceUnitInfo::MaintenanceUnitInfo(std::string name,
- std::string attribute,
- std::string uri)
- {
- m_name = name;
- m_attribute = attribute;
- m_uri = uri;
- }
-
- std::string MaintenanceUnitInfo::getJSON()
- {
- std::string res;
-
- res = "{\"name\":\"" + m_name + "\",\"attribute\":\"" + m_attribute + "\"}";
-
- return res;
- }
-
- ThingsMaintenance::ThingsMaintenance()
- {
- MaintenanceUnitInfo unit[] =
- {
- { "rb", "Reboot", "/oic/mnt"},
- { "ssc", "StartStatCollection", "/oic/mnt"},
- { "fr", "Factory Reset", "/oic/mnt" } };
-
- for (int i = 0; i < NUMDIAGUNIT; i++)
- {
- MaintenanceUnitTable.push_back(unit[i]);
- }
- }
-
- ThingsMaintenance::~ThingsMaintenance()
- {
- }
-
- void ThingsMaintenance::setGroupManager(GroupManager *groupmanager)
- {
- g_groupmanager = groupmanager;
- }
-
- ThingsMaintenance* ThingsMaintenance::getInstance()
- {
- if (thingsMaintenanceInstance == NULL)
- {
- thingsMaintenanceInstance = new ThingsMaintenance();
- }
- return thingsMaintenanceInstance;
- }
-
- void ThingsMaintenance::deleteInstance()
- {
- if (thingsMaintenanceInstance)
- {
- delete thingsMaintenanceInstance;
- thingsMaintenanceInstance = NULL;
- }
- }
-
- std::string ThingsMaintenance::getAttributeByMaintenanceName(MaintenanceName name)
- {
- for (auto it = MaintenanceUnitTable.begin(); MaintenanceUnitTable.end() != it; it++)
- {
- if ((*it).m_name == name)
- {
- return (*it).m_attribute;
- }
- }
-
- return "";
- }
-
- std::string ThingsMaintenance::getUriByMaintenanceName(MaintenanceName name)
- {
- for (auto it = MaintenanceUnitTable.begin(); MaintenanceUnitTable.end() != it; it++)
- {
- if ((*it).m_name == name)
- {
- return (*it).m_uri;
- }
- }
-
- return "";
- }
-
- std::string ThingsMaintenance::getUpdateVal(std::string mnt)
- {
- std::map< std::string, MaintenanceRequestEntry >::iterator it =
- maintenanceRequestTable.find(mnt);
-
- if (it == maintenanceRequestTable.end())
- {
- return NULL;
- }
- else
- {
- return it->second.m_updateVal;
- }
-
- }
- std::shared_ptr< OCResource > ThingsMaintenance::getResource(std::string mnt)
- {
- std::map< std::string, MaintenanceRequestEntry >::iterator it =
- maintenanceRequestTable.find(mnt);
-
- if (it == maintenanceRequestTable.end())
- {
- return NULL;
- }
- else
- {
- return it->second.m_resource;
- }
- }
-
- MaintenanceCallback ThingsMaintenance::getCallback(std::string mnt)
- {
- std::map< std::string, MaintenanceRequestEntry >::iterator it =
- maintenanceRequestTable.find(mnt);
-
- if (it == maintenanceRequestTable.end())
- {
- return NULL;
- }
- else
- {
- return it->second.m_callback;
- }
- }
-
- std::string ThingsMaintenance::getHostFromURI(std::string oldUri)
- {
- size_t f;
- std::string newUri;
-
- if ((f = oldUri.find("/factoryset/oic/")) != string::npos)
- {
- newUri = oldUri.replace(f, oldUri.size(), "");
- }
- else if ((f = oldUri.find("/oic/")) != string::npos)
- {
- newUri = oldUri.replace(f, oldUri.size(), "");
- }
-
- return newUri;
- }
-
- std::string ThingsMaintenance::getListOfSupportedMaintenanceUnits()
- {
- std::string res;
-
- res = "{\"Maintenance Units\":[";
-
- auto it = MaintenanceUnitTable.begin();
- while (1)
- {
- res = res + (*it).getJSON();
- it++;
-
- if (it == MaintenanceUnitTable.end())
- {
- break;
- }
- else
- {
- res += ",";
- }
- }
-
- res += "]}";
-
- return res;
- }
-
- void ThingsMaintenance::onGetChildInfoForUpdate(const HeaderOptions& headerOptions,
- const OCRepresentation& rep, const int eCode, std::string mnt)
- {
- if (eCode != OC_STACK_OK)
- {
- std::cout << "onGet Response error: " << eCode << std::endl;
- getCallback(mnt)(headerOptions, rep, eCode);
- return ;
- }
-
- std::cout << "GET request was successful" << std::endl;
-
- std::cout << "\tResource URI: " << rep.getUri() << std::endl;
-
- std::vector < OCRepresentation > children = rep.getChildren();
- for (auto oit = children.begin(); oit != children.end(); ++oit)
- {
- std::cout << "\t\tChild Resource URI: " << oit->getUri() << std::endl;
- }
-
- // Get information by using maintenance name(mnt)
- std::shared_ptr < OCResource > resource = getResource(mnt);
- std::string actionstring = mnt;
- std::string uri = getUriByMaintenanceName(mnt);
- std::string attrKey = mnt;
-
- if (uri == "")
- {
- return;
- }
-
- if (resource)
- {
- // In this nest, we create a new action set of which name is the dignostics name.
- // Required information consists of a host address, URI, attribute key, and
- // attribute value.
- ActionSet *newActionSet = new ActionSet();
- newActionSet->actionsetName = mnt;
-
- for (auto oit = children.begin(); oit != children.end(); ++oit)
- {
- Action *newAction = new Action();
-
- // oit->getUri() includes a host address as well as URI.
- // We should split these to each other and only use the host address to create
- // a child resource's URI. Note that the collection resource and its child
- // resource are located in same host.
- newAction->target = getHostFromURI(oit->getUri()) + uri;
-
- Capability *newCapability = new Capability();
- newCapability->capability = attrKey;
- newCapability->status = getUpdateVal(mnt);
-
- newAction->listOfCapability.push_back(newCapability);
- newActionSet->listOfAction.push_back(newAction);
- }
-
- // Request to create a new action set by using the above actionSet
- g_groupmanager->addActionSet(resource, newActionSet,
- std::function<
- void(const HeaderOptions& headerOptions,
- const OCRepresentation& rep, const int eCode) >(
- std::bind(&ThingsMaintenance::onCreateActionSet, this,
- std::placeholders::_1, std::placeholders::_2,
- std::placeholders::_3, mnt)));
-
- delete(newActionSet);
-
- }
- }
-
- void ThingsMaintenance::onCreateActionSet(const HeaderOptions& headerOptions,
- const OCRepresentation& rep, const int eCode, std::string mnt)
- {
- if (eCode != OC_STACK_OK)
- {
- std::cout << "onPut Response error: " << eCode << std::endl;
- getCallback(mnt)(headerOptions, rep, eCode);
- return ;
- }
-
- std::cout << "PUT request was successful" << std::endl;
-
- std::shared_ptr < OCResource > resource = getResource(mnt);
- if (resource)
- {
- // Now, it is time to execute the action set.
- g_groupmanager->executeActionSet(resource, mnt,
- std::function<
- void(const HeaderOptions& headerOptions,
- const OCRepresentation& rep, const int eCode) >(
- std::bind(&ThingsMaintenance::onExecuteForGroupAction, this,
- std::placeholders::_1, std::placeholders::_2,
- std::placeholders::_3, mnt)));
- }
- }
-
- void ThingsMaintenance::onExecuteForGroupAction(const HeaderOptions& headerOptions,
- const OCRepresentation& rep, const int eCode, std::string mnt)
- {
- if (eCode != OC_STACK_OK)
- {
- std::cout << "onPut Response error: " << eCode << std::endl;
- getCallback(mnt)(headerOptions, rep, eCode);
- return ;
- }
-
- std::cout << "PUT request was successful" << std::endl;
- getCallback(mnt)(headerOptions, rep, eCode);
-
- // Delete the created actionset
- std::shared_ptr < OCResource > resource = getResource(mnt);
- if (resource)
- {
- g_groupmanager->deleteActionSet(resource, mnt,
- std::function<
- void(const HeaderOptions& headerOptions,
- const OCRepresentation& rep, const int eCode) >(
- std::bind(&ThingsMaintenance::onDeleteGroupAction, this,
- std::placeholders::_1, std::placeholders::_2,
- std::placeholders::_3, mnt)));
- }
- }
-
- void ThingsMaintenance::onDeleteGroupAction(const HeaderOptions& /*headerOptions*/,
- const OCRepresentation& /*rep*/, const int eCode, std::string mnt)
- {
- if (eCode != OC_STACK_OK)
- {
- std::cout << "Delete actionset returned with error: " << eCode << mnt << std::endl;
- return;
- }
-
- std::cout << "Deleted the actionset created!" << mnt<< std::endl;
- }
-
- void ThingsMaintenance::onPut(const HeaderOptions& headerOptions, const OCRepresentation& rep,
- const int eCode, std::string mnt)
- {
- if (eCode != OC_STACK_OK)
- {
- std::cout << "onPut Response error: " << eCode << std::endl;
- getCallback(mnt)(headerOptions, rep, eCode);
- return ;
- }
-
- std::cout << "PUT request was successful" << std::endl;
-
- getCallback(mnt)(headerOptions, rep, eCode);
-
- }
-
- bool ThingsMaintenance::isSimpleResource(std::shared_ptr< OCResource > resource)
- {
- for (unsigned int i = 0; i < resource->getResourceTypes().size(); ++i)
- {
- if (resource->getResourceTypes().at(0).find(".resourceset", 0) != std::string::npos)
- {
- return false;
- }
- }
-
- return true;
- }
-
- OCStackResult ThingsMaintenance::reboot(std::shared_ptr< OCResource > resource,
- MaintenanceCallback callback)
- {
- if (!resource)
- {
- std::cout << "resource is NULL\n";
- return OC_STACK_ERROR;
- }
-
- std::string mnt = "rb";
-
- // Check the request queue if a previous request is still left. If so, remove it.
- std::map< std::string, MaintenanceRequestEntry >::iterator iter =
- maintenanceRequestTable.find(mnt);
- if (iter != maintenanceRequestTable.end())
- {
- maintenanceRequestTable.erase(iter);
- }
-
- // Create new request entry stored in the queue
- MaintenanceRequestEntry newCallback(mnt, callback, resource, "true");
- maintenanceRequestTable.insert(std::make_pair(mnt, newCallback));
-
- QueryParamsMap query;
- OCRepresentation rep;
-
- if (isSimpleResource(resource))
- {
- // This resource is a simple resource. Just send a PUT message
- OCRepresentation rep;
- rep.setValue < std::string > (mnt, "true");
-
- return resource->put(resource->getResourceTypes().at(0), DEFAULT_INTERFACE, rep, query,
- std::function<
- void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
- const int eCode) >(
- std::bind(&ThingsMaintenance::onPut, this, std::placeholders::_1,
- std::placeholders::_2, std::placeholders::_3, mnt)));
- }
- else
- {
- // This resource is a collection resource. It just acquires child resource's URI and
- // send GET massages to the child resources in turn.
- // First, request the child resources's URI.
- // TODO: Add a deletion of actionset
- return resource->get(resource->getResourceTypes().at(0), DEFAULT_INTERFACE, query,
- std::function<
- void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
- const int eCode) >(
- std::bind(&ThingsMaintenance::onGetChildInfoForUpdate, this,
- std::placeholders::_1, std::placeholders::_2,
- std::placeholders::_3, mnt)));
- }
- }
-
- OCStackResult ThingsMaintenance::factoryReset(std::shared_ptr< OCResource > resource,
- MaintenanceCallback callback)
- {
- if (!resource)
- {
- std::cout << "resource is NULL\n";
- return OC_STACK_ERROR;
- }
-
- std::string mnt = "fr";
-
- // Check the request queue if a previous request is still left. If so, remove it.
- std::map< std::string, MaintenanceRequestEntry >::iterator iter =
- maintenanceRequestTable.find(mnt);
- if (iter != maintenanceRequestTable.end())
- {
- maintenanceRequestTable.erase(iter);
- }
-
- // Create new request entry stored in the queue
- MaintenanceRequestEntry newCallback(mnt, callback, resource, "true");
- maintenanceRequestTable.insert(std::make_pair(mnt, newCallback));
-
- QueryParamsMap query;
- OCRepresentation rep;
-
- if (isSimpleResource(resource))
- {
- // This resource is a simple resource. Just send a PUT message
- OCRepresentation rep;
- rep.setValue < std::string > ("value", "true");
-
- return resource->put(resource->getResourceTypes().at(0), DEFAULT_INTERFACE, rep, query,
- std::function<
- void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
- const int eCode) >(
- std::bind(&ThingsMaintenance::onPut, this, std::placeholders::_1,
- std::placeholders::_2, std::placeholders::_3, mnt)));
- }
- else
- {
- // This resource is a collection resource. It just acquires child resource's URI and
- // send GET massages to the child resources in turn.
- // First, request the child resources's URI.
- // TODO: Add a deletion of actionset
- return resource->get(resource->getResourceTypes().at(0), DEFAULT_INTERFACE, query,
- std::function<
- void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
- const int eCode) >(
- std::bind(&ThingsMaintenance::onGetChildInfoForUpdate, this,
- std::placeholders::_1, std::placeholders::_2,
- std::placeholders::_3, mnt)));
- }
- }
-}
-
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2015 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-///
-/// create a resource (collection) with children.
-///
-
-#include <functional>
-#include <thread>
-
-#include "OCPlatform.h"
-#include "OCApi.h"
-
-#pragma once
-
-using namespace OC;
-
-typedef std::function <
-OCEntityHandlerResult(std::shared_ptr< OCResourceRequest > request) > ResourceEntityHandler;
-
-static std::string defaultConURI = "/oic/con";
-static std::string defaultConResourceType = "oic.wk.con";
-
-extern std::string defaultDeviceName;
-extern std::string defaultLocation;
-extern std::string defaultLocationName;
-extern std::string defaultCurrency;
-extern std::string defaultRegion;
-
-class ConfigurationResource
-{
- public:
- // Configuration members
- std::string m_configurationUri;
- std::string m_deviceName;
- std::string m_location;
- std::string m_locationName;
- std::string m_currency;
- std::string m_region;
- std::vector< std::string > m_configurationTypes;
- std::vector< std::string > m_configurationInterfaces;
- OCResourceHandle m_configurationHandle;
- OCRepresentation m_configurationRep;
-
- public:
- /// Constructor
- ConfigurationResource() :
- m_deviceName(defaultDeviceName), m_location(defaultLocation),
- m_locationName(defaultLocationName), m_currency(defaultCurrency),
- m_region(defaultRegion)
- {
- m_configurationUri = defaultConURI; // URI of the resource
- m_configurationTypes.push_back(defaultConResourceType); // resource type name.
- m_configurationInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
- m_configurationRep.setValue("st", m_deviceName);
- m_configurationRep.setValue("loc", m_location);
- m_configurationRep.setValue("locn", m_locationName);
- m_configurationRep.setValue("c", m_currency);
- m_configurationRep.setValue("r", m_region);
- m_configurationRep.setUri(m_configurationUri);
- m_configurationRep.setResourceTypes(m_configurationTypes);
- m_configurationRep.setResourceInterfaces(m_configurationInterfaces);
- m_configurationHandle = NULL;
- }
- ;
-
- ~ConfigurationResource()
- {
-
- }
-
- /// This function internally calls registerResource API.
- void createResources(ResourceEntityHandler callback);
- void setConfigurationRepresentation(OCRepresentation &rep);
- OCRepresentation getConfigurationRepresentation();
- std::string getUri();
-
- void factoryReset();
-
-};
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2015 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-///
-/// create a resource (collection) with children.
-///
-
-#include <functional>
-#include <thread>
-
-#include "OCPlatform.h"
-#include "OCApi.h"
-#include "ConfigurationCollection.h"
-
-#pragma once
-
-using namespace OC;
-
-typedef std::function <
-OCEntityHandlerResult(std::shared_ptr< OCResourceRequest > request) > ResourceEntityHandler;
-
-class FactorySetResource : public ConfigurationResource
-{
- public:
- /// Constructor
- FactorySetResource();
-
- ~FactorySetResource();
-
- /// This function internally calls registerResource API.
- void createResources(ResourceEntityHandler callback);
- void setFactorySetRepresentation(OCRepresentation &rep);
- OCRepresentation getFactorySetRepresentation();
-
- std::string getUri();
-};
-
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2015 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-///
-/// create a resource (collection) with children.
-///
-
-#include <functional>
-#include <thread>
-
-#include "OCPlatform.h"
-#include "OCApi.h"
-
-#pragma once
-
-using namespace OC;
-
-typedef std::function <
-OCEntityHandlerResult(std::shared_ptr< OCResourceRequest > request) > ResourceEntityHandler;
-
-static std::string defaultMntURI = "/oic/mnt";
-static std::string defaultMntResourceType = "oic.wk.mnt";
-
-static std::string defaultFactoryReset = "false";
-static std::string defaultReboot = "false";
-static std::string defaultStartStatCollection = "false";
-
-class MaintenanceResource
-{
- public:
-
- // Maintenance members
- std::string m_maintenanceUri;
- std::string m_factoryReset;
- std::string m_reboot;
- std::string m_startStatCollection;
- std::vector< std::string > m_maintenanceTypes;
- std::vector< std::string > m_maintenanceInterfaces;
- OCResourceHandle m_maintenanceHandle;
- OCRepresentation m_maintenanceRep;
-
- public:
- /// Constructor
- MaintenanceResource() :
- m_factoryReset(defaultFactoryReset), m_reboot(defaultReboot),
- m_startStatCollection(defaultStartStatCollection)
- {
- m_maintenanceUri = defaultMntURI; // URI of the resource
- m_maintenanceTypes.push_back(defaultMntResourceType); // resource type name.
- m_maintenanceInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
- m_maintenanceRep.setValue("fr", m_factoryReset);
- m_maintenanceRep.setValue("rb", m_reboot);
- m_maintenanceRep.setValue("ssc", m_startStatCollection);
- m_maintenanceRep.setUri(m_maintenanceUri);
- m_maintenanceRep.setResourceTypes(m_maintenanceTypes);
- m_maintenanceRep.setResourceInterfaces(m_maintenanceInterfaces);
- m_maintenanceHandle = NULL;
- }
- ;
-
- /// This function internally calls registerResource API.
- void createResources(ResourceEntityHandler callback);
-
- void setMaintenanceRepresentation(OCRepresentation &rep);
-
- OCRepresentation getMaintenanceRepresentation();
-
- std::string getUri();
-
- void maintenanceMonitor(int second);
-
- std::function< void() > factoryReset;
-};
-
+++ /dev/null
-#******************************************************************
-#
-# Copyright 2015 Samsung Electronics All Rights Reserved.
-#
-#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-##
-# ThingsManager Unit Test build script
-##
-import os
-
-# SConscript file for Local PKI google tests
-gtest_env = SConscript('#extlibs/gtest/SConscript')
-lib_env = gtest_env.Clone()
-target_os = lib_env.get('TARGET_OS')
-
-if lib_env.get('RELEASE'):
- lib_env.AppendUnique(CCFLAGS = ['-Os'])
- lib_env.AppendUnique(CPPDEFINES = ['NDEBUG'])
-else:
- lib_env.AppendUnique(CCFLAGS = ['-g'])
-
-if lib_env.get('LOGGING'):
- lib_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
-
-# Add third party libraries
-SConscript('#service/third_party_libs.scons', 'lib_env')
-
-if target_os in ['linux']:
- # Verify that 'hippomocks' mocking code is installed.
- # If not, get it and install it
- SConscript('#extlibs/hippomocks.scons')
-
-ThingsManager_gtest_env = lib_env.Clone()
-
-######################################################################
-#unit test setting
-######################################################################
-src_dir = ThingsManager_gtest_env.get('SRC_DIR')
-
-######################################################################
-# Build flags
-######################################################################
-ThingsManager_gtest_env.AppendUnique(
- CPPPATH = [
- src_dir + '/extlibs/hippomocks-master',
- '../sdk/inc',
- '../../../extlibs/timer'
- ])
-
-ThingsManager_gtest_env.PrependUnique(LIBS = [
- 'libTGMSDKLibrary',
- 'coap',
- 'connectivity_abstraction',
- 'oc_logger',
- 'oc_logger_core',
- 'oc',
- 'octbstack'])
-
-if ThingsManager_gtest_env.get('SECURED') == '1':
- if ThingsManager_gtest_env.get('WITH_TCP') == True:
- ThingsManager_gtest_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509', 'mbedcrypto'])
-
-######################################################################
-# Build Test
-######################################################################
-ThingsManager_gtest_src = ThingsManager_gtest_env.Glob('./*.cpp')
-
-ThingsManagerTest = ThingsManager_gtest_env.Program('ThingsManagerTest', ThingsManager_gtest_src)
-Alias("ThingsManagerTest", ThingsManagerTest)
-ThingsManager_gtest_env.AppendTarget('ThingsManagerTest')
-
-if ThingsManager_gtest_env.get('TEST') == '1':
- if target_os in ['linux']:
- from tools.scons.RunTest import *
- run_test(ThingsManager_gtest_env, '',
- 'service/things-manager/unittests/ThingsManagerTest')
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2015 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#include "UnitTestHelper.h"
-#include "MaintenanceCollection.h"
-#include "ConfigurationCollection.h"
-#include "FactorySetCollection.h"
-
-#include "timer.h"
-#include "ActionSet.h"
-#include "GroupManager.h"
-#include "ThingsConfiguration.h"
-#include "ThingsMaintenance.h"
-#include "ocstack.h"
-#include "OCPlatform.h"
-#include "OCApi.h"
-
-#include <iostream>
-#include <functional>
-#include <pthread.h>
-#include <condition_variable>
-
-#define SUCCESS_RESPONSE 0
-constexpr int DEFAULT_WAITING_TIME_IN_MILLIS = 3000;
-
-using namespace OIC;
-using namespace OC;
-using namespace std;
-namespace PH = std::placeholders;
-
-int result = 0;
-bool isSlowResponse = false;
-
-std::string defaultDeviceName = "Legacy Device";
-std::string defaultLocation = "37.256616, 127.052806";
-std::string defaultLocationName = "Living Room";
-std::string defaultRegion = "Won";
-std::string defaultCurrency = "Seoul, Korea";
-
-OCResourceHandle resourceHandle;
-OCResourceHandle foundResourceHandle;
-
-std::shared_ptr< OCResource > g_resource;
-std::shared_ptr< OCResource > g_room_resource;
-std::shared_ptr< OCResource > g_light;
-std::shared_ptr< OCResource > configurationResource;
-std::vector< string > lights;
-std::vector< OCResourceHandle > resourceHandleVector;
-
-GroupManager *groupMgr = new GroupManager();
-ConfigurationResource *myConfigurationResource;
-MaintenanceResource *myMaintenanceResource;
-FactorySetResource *myFactorySetResource;
-
-std::condition_variable cv1;
-std::condition_variable cv2;
-std::condition_variable cv3;
-std::condition_variable cv4;
-std::condition_variable cv5;
-
-bool prepareResponseForResource(std::shared_ptr< OCResourceRequest > request);
-OCStackResult sendResponseForResource(std::shared_ptr< OCResourceRequest > pRequest);
-OCEntityHandlerResult entityHandlerForResource(std::shared_ptr< OCResourceRequest > request);
-OCEntityHandlerResult entityHandlerBootstrap(std::shared_ptr< OCResourceRequest > request);
-
-typedef std::function< void(OCRepresentation &) > putFunc;
-typedef std::function< OCRepresentation(void) > getFunc;
-
-void *ChangeLightRepresentation(void *param);
-void *handleSlowResponse(void *param, std::shared_ptr< OCResourceRequest > pRequest);
-
-/****** Light Resource [Required to gtestcases of GroupManager APIs] ******/
-
-class LightResource
-{
-public:
- std::string m_power;
- std::string testing;
- std::string m_lightUri;
- OCResourceHandle m_resourceHandle;
- OCRepresentation m_lightRep;
-
-public:
- LightResource() :
- m_power("on"), m_lightUri("/a/light"), m_resourceHandle(0)
- {
- m_lightRep.setUri(m_lightUri);
- m_lightRep.setValue("power", m_power);
- }
-
- void createResource()
- {
- std::string resourceURI = m_lightUri;
- std::string resourceTypeName = "core.light";
- std::string resourceInterface = DEFAULT_INTERFACE;
- EntityHandler cb = std::bind(&LightResource::entityHandler, this, PH::_1);
-
- OCStackResult result = OCPlatform::registerResource(m_resourceHandle, resourceURI,
- resourceTypeName, resourceInterface, cb, OC_DISCOVERABLE | OC_OBSERVABLE);
-
- if (OC_STACK_OK != result)
- {
- printf("\nLightResource : OC_STACK_OK != result...");
- }
- else
- {
- cv2.notify_all();
- std::mutex blocker;
- std::condition_variable cv;
- std::unique_lock < std::mutex > lock(blocker);
- cv.wait(lock);
- }
- }
-
- OCResourceHandle getHandle()
- {
- return m_resourceHandle;
- }
-
- void put(OCRepresentation &rep)
- {
- try
- {
- std::string test;
- if (rep.getValue < std::string > ("power", test))
- {
- cout << "\t\t\t\t" << "power: " << test << endl;
- }
- else
- {
- cout << "\t\t\t\t" << "power not found in the representation" << endl;
- }
- }
- catch (exception &e)
- {
- cout << e.what() << endl;
- }
- }
-
- OCRepresentation post(OCRepresentation &rep)
- {
- put(rep);
- return get();
- }
-
- OCRepresentation get()
- {
- m_lightRep.setValue("power", m_power);
-
- return m_lightRep;
- }
-
- void addType(const std::string &type) const
- {
- OCStackResult result = OCPlatform::bindTypeToResource(m_resourceHandle, type);
- if (OC_STACK_OK != result)
- {
- cout << "Binding TypeName to Resource was unsuccessful\n";
- }
- }
-
- void addInterface(const std::string &interface) const
- {
- OCStackResult result = OCPlatform::bindInterfaceToResource(m_resourceHandle, interface);
- if (OC_STACK_OK != result)
- {
- cout << "Binding TypeName to Resource was unsuccessful\n";
- }
- }
-
-private:
- OCEntityHandlerResult entityHandler(std::shared_ptr< OCResourceRequest > request)
- {
- cout << "\tIn Server CPP entity handler:\n";
- OCEntityHandlerResult ehResult = OC_EH_ERROR;
- if (request)
- {
- std::string requestType = request->getRequestType();
- int requestFlag = request->getRequestHandlerFlag();
-
- if (requestFlag & RequestHandlerFlag::RequestFlag)
- {
- cout << "\t\trequestFlag : Request\n";
- auto pResponse = std::make_shared< OC::OCResourceResponse >();
- pResponse->setRequestHandle(request->getRequestHandle());
- pResponse->setResourceHandle(request->getResourceHandle());
-
- if (requestType == "GET")
- {
- cout << "\t\t\trequestType : GET\n";
- if (isSlowResponse)
- {
- static int startedThread = 0;
- if (!startedThread)
- {
- std::thread t(handleSlowResponse, (void *) this, request);
- startedThread = 1;
- t.detach();
- }
- ehResult = OC_EH_SLOW;
- }
- else
- {
- pResponse->setResponseResult(OC_EH_OK);
- pResponse->setResourceRepresentation(get());
- if (OC_STACK_OK == OCPlatform::sendResponse(pResponse))
- {
- ehResult = OC_EH_OK;
- }
- }
- }
- else if (requestType == "PUT")
- {
- cout << "\t\t\trequestType : PUT\n";
- OCRepresentation rep = request->getResourceRepresentation();
- put(rep);
- pResponse->setResponseResult(OC_EH_OK);
- pResponse->setResourceRepresentation(rep);
- if (OC_STACK_OK == OCPlatform::sendResponse(pResponse))
- {
- ehResult = OC_EH_OK;
- }
- }
- else if (requestType == "POST")
- {
- cout << "\t\t\trequestType : POST\n";
-
- OCRepresentation rep = request->getResourceRepresentation();
- OCRepresentation rep_post = post(rep);
-
- pResponse->setResourceRepresentation(rep_post);
- if (rep_post.hasAttribute("createduri"))
- {
- pResponse->setResponseResult(OC_EH_RESOURCE_CREATED);
- pResponse->setNewResourceUri(
- rep_post.getValue < std::string > ("createduri"));
- }
-
- if (OC_STACK_OK == OCPlatform::sendResponse(pResponse))
- {
- ehResult = OC_EH_OK;
- }
- }
- else if (requestType == "DELETE")
- {
- }
- }
- }
- else
- {
- std::cout << "Request invalid" << std::endl;
- }
- return ehResult;
- }
-};
-
-void *handleSlowResponse(void *param, std::shared_ptr< OCResourceRequest > pRequest)
-{
- LightResource *lightPtr = (LightResource *) param;
- sleep(10);
-
- auto pResponse = std::make_shared< OC::OCResourceResponse >();
- pResponse->setRequestHandle(pRequest->getRequestHandle());
- pResponse->setResourceHandle(pRequest->getResourceHandle());
- pResponse->setResourceRepresentation(lightPtr->get());
- pResponse->setResponseResult(OC_EH_OK);
-
- isSlowResponse = false;
- OCPlatform::sendResponse(pResponse);
- return NULL;
-}
-
-/****** Configuration Resource ******/
-
-void ConfigurationResource::createResources(ResourceEntityHandler callback)
-{
- using namespace OC::OCPlatform;
-
- if (callback == NULL)
- {
- std::cout << "callback should be binded\t";
- return;
- }
-
- OCStackResult result = registerResource(m_configurationHandle, m_configurationUri,
- m_configurationTypes[0], m_configurationInterfaces[0], callback,
- OC_DISCOVERABLE | OC_OBSERVABLE);
-
- if (OC_STACK_OK != result)
- {
- std::cout << "Resource creation (configuration) was unsuccessful\n";
- }
- else
- {
- cv2.notify_all();
- std::mutex blocker;
- std::condition_variable cv;
- std::unique_lock < std::mutex > lock(blocker);
- cv.wait(lock);
- }
-}
-
-void ConfigurationResource::setConfigurationRepresentation(OCRepresentation &rep)
-{
- string value;
- if (rep.getValue("n", value))
- {
- m_deviceName = value;
- std::cout << "\t\t\t\t" << "m_deviceName: " << m_deviceName << std::endl;
- }
-
- if (rep.getValue("loc", value))
- {
- m_location = value;
- std::cout << "\t\t\t\t" << "m_location: " << m_location << std::endl;
- }
-
- if (rep.getValue("locn", value))
- {
- m_locationName = value;
- std::cout << "\t\t\t\t" << "m_locationName: " << m_locationName << std::endl;
- }
-
- if (rep.getValue("c", value))
- {
- m_currency = value;
- std::cout << "\t\t\t\t" << "m_currency: " << m_currency << std::endl;
- }
-
- if (rep.getValue("r", value))
- {
- m_region = value;
- std::cout << "\t\t\t\t" << "m_region: " << m_region << std::endl;
- }
-}
-
-OCRepresentation ConfigurationResource::getConfigurationRepresentation()
-{
- m_configurationRep.setValue("n", m_deviceName);
- m_configurationRep.setValue("loc", m_location);
- m_configurationRep.setValue("locn", m_locationName);
- m_configurationRep.setValue("c", m_currency);
- m_configurationRep.setValue("r", m_region);
-
- return m_configurationRep;
-}
-
-std::string ConfigurationResource::getUri()
-{
- return m_configurationUri;
-}
-
-void ConfigurationResource::factoryReset()
-{
- m_deviceName = defaultDeviceName;
- m_location = defaultLocation;
- m_locationName = defaultLocationName;
- m_currency = defaultCurrency;
- m_region = defaultRegion;
-}
-
-/****** FactorySet Resource ******/
-
-FactorySetResource::FactorySetResource()
-{
- m_configurationUri = "/factoryset"; // URI of the resource
- m_configurationTypes.clear();
- m_configurationTypes.push_back("factoryset"); // resource type name.
- m_configurationRep.setUri(m_configurationUri);
- m_configurationRep.setResourceTypes(m_configurationTypes);
-}
-
-FactorySetResource::~FactorySetResource()
-{
-}
-
-void FactorySetResource::createResources(ResourceEntityHandler callback)
-{
- using namespace OC::OCPlatform;
-
- if (callback == NULL)
- {
- std::cout << "callback should be binded\t";
- return;
- }
-
- OCStackResult result = registerResource(m_configurationHandle, m_configurationUri,
- m_configurationTypes[0], m_configurationInterfaces[0], callback,
- OC_DISCOVERABLE | OC_OBSERVABLE);
-
- if (OC_STACK_OK != result)
- {
- std::cout << "Resource creation (configuration) was unsuccessful\n";
- }
-
- else
- {
- cv4.notify_all();
- std::mutex blocker;
- std::condition_variable cv;
- std::unique_lock < std::mutex > lock(blocker);
- cv.wait(lock);
- }
-}
-
-void FactorySetResource::setFactorySetRepresentation(OCRepresentation &rep)
-{
- string value;
-
- if (rep.getValue("n", value))
- {
- m_deviceName = value;
- std::cout << "\t\t\t\t" << "m_deviceName: " << m_deviceName << std::endl;
- }
-
- if (rep.getValue("loc", value))
- {
- m_location = value;
- std::cout << "\t\t\t\t" << "m_location: " << m_location << std::endl;
- }
-
- if (rep.getValue("locn", value))
- {
- m_locationName = value;
- std::cout << "\t\t\t\t" << "m_locationName: " << m_locationName << std::endl;
- }
-
- if (rep.getValue("c", value))
- {
- m_currency = value;
- std::cout << "\t\t\t\t" << "m_currency: " << m_currency << std::endl;
- }
-
- if (rep.getValue("r", value))
- {
- m_region = value;
- std::cout << "\t\t\t\t" << "m_region: " << m_region << std::endl;
- }
-}
-
-OCRepresentation FactorySetResource::getFactorySetRepresentation()
-{
- m_configurationRep.setValue("n", m_deviceName);
- m_configurationRep.setValue("loc", m_location);
- m_configurationRep.setValue("locn", m_locationName);
- m_configurationRep.setValue("c", m_currency);
- m_configurationRep.setValue("r", m_region);
-
- return m_configurationRep;
-}
-
-std::string FactorySetResource::getUri()
-{
- return m_configurationUri;
-}
-
-/****** Maintenance Resource ********/
-
-void MaintenanceResource::createResources(ResourceEntityHandler callback)
-{
- using namespace OC::OCPlatform;
-
- if (callback == NULL)
- {
- std::cout << "callback should be binded\t";
- return;
- }
-
- OCStackResult result = registerResource(m_maintenanceHandle, m_maintenanceUri,
- m_maintenanceTypes[0], m_maintenanceInterfaces[0], callback,
- OC_DISCOVERABLE | OC_OBSERVABLE);
-
- if (OC_STACK_OK != result)
- {
- std::cout << "Resource creation (maintenance) was unsuccessful\n";
- }
-
- thread exec(
- std::function< void(int second) >(
- std::bind(&MaintenanceResource::maintenanceMonitor, this,
- std::placeholders::_1)), 10);
- exec.detach();
- cv3.notify_all();
- std::mutex blocker;
- std::condition_variable cv;
- std::unique_lock < std::mutex > lock(blocker);
- cv.wait(lock);
-
- std::cout << "maintenance Resource is Created!\n";
-}
-
-void MaintenanceResource::setMaintenanceRepresentation(OCRepresentation &rep)
-{
- string value;
-
- if (rep.getValue("fr", value))
- {
- m_factoryReset = value;
- std::cout << "\t\t\t\t" << "m_factoryReset: " << m_factoryReset << std::endl;
- }
-
- if (rep.getValue("rb", value))
- {
- m_reboot = value;
- std::cout << "\t\t\t\t" << "m_reboot: " << m_reboot << std::endl;
- }
-
- if (rep.getValue("ssc", value))
- {
- m_startStatCollection = value;
- std::cout << "\t\t\t\t" << "m_startStatCollection: " << m_startStatCollection << std::endl;
- }
-}
-
-OCRepresentation MaintenanceResource::getMaintenanceRepresentation()
-{
- m_maintenanceRep.setValue("fr", m_factoryReset);
- m_maintenanceRep.setValue("rb", m_reboot);
- m_maintenanceRep.setValue("ssc", m_startStatCollection);
-
- return m_maintenanceRep;
-}
-
-std::string MaintenanceResource::getUri()
-{
- return m_maintenanceUri;
-}
-
-void MaintenanceResource::maintenanceMonitor(int second)
-{
- while (1)
- {
- sleep(second);
-
- if (m_reboot == "true")
- {
- int res;
- std::cout << "Reboot will be soon..." << std::endl;
- m_reboot = defaultReboot;
- res = system("/usr/bin/sudo /etc/init.d/reboot");
-
- std::cout << "return: " << res << std::endl;
-
- }
- else if (m_factoryReset == "true")
- {
- std::cout << "Factory Reset will be soon..." << std::endl;
- m_factoryReset = defaultFactoryReset;
- factoryReset();
- }
- }
-}
-
-getFunc getGetFunction(std::string uri)
-{
- getFunc res = NULL;
-
- if (uri == myConfigurationResource->getUri())
- {
- res = std::bind(&ConfigurationResource::getConfigurationRepresentation,
- myConfigurationResource);
- }
- else if (uri == myMaintenanceResource->getUri())
- {
- res = std::bind(&MaintenanceResource::getMaintenanceRepresentation, myMaintenanceResource);
- }
- return res;
-}
-
-putFunc getPutFunction(std::string uri)
-{
- putFunc res = NULL;
-
- if (uri == myConfigurationResource->getUri())
- {
- res = std::bind(&ConfigurationResource::setConfigurationRepresentation,
- myConfigurationResource, std::placeholders::_1);
- }
- else if (uri == myMaintenanceResource->getUri())
- {
- res = std::bind(&MaintenanceResource::setMaintenanceRepresentation, myMaintenanceResource,
- std::placeholders::_1);
- }
- return res;
-}
-
-bool prepareResponseForResource(std::shared_ptr< OCResourceRequest > request)
-{
- std::cout << "\tIn Server CPP prepareResponseForResource:\n";
- bool result = false;
- if (request)
- {
- std::string requestType = request->getRequestType();
- int requestFlag = request->getRequestHandlerFlag();
-
- if (requestFlag == RequestHandlerFlag::RequestFlag)
- {
- std::cout << "\t\trequestFlag : Request\n";
- if (requestType == "GET")
- {
- std::cout << "\t\t\trequestType : GET\n";
- result = true;
- }
- else if (requestType == "PUT")
- {
- std::cout << "\t\t\trequestType : PUT\n";
- putFunc putFunction;
- OCRepresentation rep = request->getResourceRepresentation();
-
- putFunction = getPutFunction(request->getResourceUri());
- putFunction(rep);
- result = true;
- }
- else if (requestType == "POST")
- {
- }
- else if (requestType == "DELETE")
- {
- }
- }
- else if (requestFlag == RequestHandlerFlag::ObserverFlag)
- {
- std::cout << "\t\trequestFlag : Observer\n";
- }
- }
- else
- {
- std::cout << "Request invalid" << std::endl;
- }
-
- return result;
-}
-
-OCStackResult sendResponseForResource(std::shared_ptr< OCResourceRequest > pRequest)
-{
- auto pResponse = std::make_shared< OC::OCResourceResponse >();
- QueryParamsMap queryParamsMap = pRequest->getQueryParameters();
-
- pResponse->setRequestHandle(pRequest->getRequestHandle());
- pResponse->setResourceHandle(pRequest->getResourceHandle());
-
- getFunc getFunction;
- getFunction = getGetFunction(pRequest->getResourceUri());
-
- OCRepresentation rep;
- rep = getFunction();
-
- auto findRes = queryParamsMap.find("if");
-
- if (findRes != queryParamsMap.end())
- {
- pResponse->setResourceRepresentation(rep, findRes->second);
- }
- else
- {
- pResponse->setResourceRepresentation(rep, DEFAULT_INTERFACE);
- }
-
- pResponse->setResponseResult(OC_EH_OK);
-
- return OCPlatform::sendResponse(pResponse);
-}
-
-OCEntityHandlerResult entityHandlerForResource(std::shared_ptr< OCResourceRequest > request)
-{
- std::cout << "\tIn Server CPP (entityHandlerForResource) entity handler:\n";
- OCEntityHandlerResult ehResult = OC_EH_ERROR;
-
- QueryParamsMap test = request->getQueryParameters();
-
- if (prepareResponseForResource(request))
- {
- if (OC_STACK_OK == sendResponseForResource(request))
- {
- ehResult = OC_EH_OK;
- }
- else
- {
- std::cout << "sendResponse failed." << std::endl;
- }
- }
- else
- {
- std::cout << "PrepareResponse failed." << std::endl;
- }
- return ehResult;
-}
-
-/****** BootStrap Resource [Required for doBootstrap API of ThingsConfiguration class] ******/
-
-class BootstrapResource
-{
-public:
- std::string m_bootstrapUri;
- std::vector< std::string > m_bootstrapTypes;
- std::vector< std::string > m_bootstrapInterfaces;
- OCResourceHandle m_bootstrapHandle;
- OCRepresentation m_bootstrapRep;
-
-public:
- BootstrapResource()
- {
- m_bootstrapUri = "/bootstrap";
- m_bootstrapTypes.push_back("bootstrap");
- m_bootstrapInterfaces.push_back(DEFAULT_INTERFACE);
- m_bootstrapRep.setUri(m_bootstrapUri);
- m_bootstrapRep.setResourceTypes(m_bootstrapTypes);
- m_bootstrapRep.setResourceInterfaces(m_bootstrapInterfaces);
- m_bootstrapHandle = NULL;
- }
- void createResources()
- {
- using namespace OC::OCPlatform;
- OCStackResult result = registerResource(m_bootstrapHandle, m_bootstrapUri,
- m_bootstrapTypes[0], m_bootstrapInterfaces[0], entityHandlerBootstrap,
- OC_DISCOVERABLE | OC_OBSERVABLE);
-
- if (OC_STACK_OK != result)
- {
- cout << "Resource creation (room) was unsuccessful\n";
- }
-
- cv5.notify_all();
- std::mutex blocker;
- std::condition_variable cv;
- std::unique_lock < std::mutex > lock(blocker);
- cv.wait(lock);
- }
-
- void setBootstrapRepresentation(OCRepresentation& /*rep*/)
- {
- }
-
- OCRepresentation getBootstrapRepresentation()
- {
- m_bootstrapRep.setValue < std::string > ("n", defaultDeviceName);
- m_bootstrapRep.setValue < std::string > ("loc", defaultLocation);
- m_bootstrapRep.setValue < std::string > ("locn", defaultLocationName);
- m_bootstrapRep.setValue < std::string > ("c", defaultCurrency);
- m_bootstrapRep.setValue < std::string > ("r", defaultRegion);
-
- return m_bootstrapRep;
- }
-};
-
-BootstrapResource myBootstrapResource;
-
-bool prepareResponse(std::shared_ptr< OCResourceRequest > request)
-{
- cout << "\tIn Server CPP prepareResponse:\n";
- bool result = false;
- if (request)
- {
- std::string requestType = request->getRequestType();
- int requestFlag = request->getRequestHandlerFlag();
-
- if (requestFlag == RequestHandlerFlag::RequestFlag)
- {
- cout << "\t\trequestFlag : Request\n";
- if (requestType == "GET")
- {
- cout << "\t\t\trequestType : GET\n";
- result = true;
- }
- else if (requestType == "PUT")
- {
- cout << "\t\t\trequestType : PUT\n";
-
- OCRepresentation rep = request->getResourceRepresentation();
- myBootstrapResource.setBootstrapRepresentation(rep);
- result = true;
- }
- else if (requestType == "POST")
- {
- }
- else if (requestType == "DELETE")
- {
- }
- }
- else if (requestFlag == RequestHandlerFlag::ObserverFlag)
- {
- cout << "\t\trequestFlag : Observer\n";
- }
- }
- else
- {
- std::cout << "Request invalid" << std::endl;
- }
-
- return result;
-}
-
-OCStackResult sendResponse(std::shared_ptr< OCResourceRequest > pRequest)
-{
- auto pResponse = std::make_shared< OC::OCResourceResponse >();
- pResponse->setRequestHandle(pRequest->getRequestHandle());
- pResponse->setResourceHandle(pRequest->getResourceHandle());
- pResponse->setResourceRepresentation(myBootstrapResource.getBootstrapRepresentation());
- pResponse->setResponseResult(OC_EH_OK);
-
- return OCPlatform::sendResponse(pResponse);
-}
-
-OCEntityHandlerResult entityHandlerBootstrap(std::shared_ptr< OCResourceRequest > request)
-{
- cout << "\tIn Server CPP (entityHandlerBootstrap) entity handler:\n";
- OCEntityHandlerResult ehResult = OC_EH_ERROR;
-
- if (prepareResponse(request))
- {
- if (OC_STACK_OK == sendResponse(request))
- {
- ehResult = OC_EH_OK;
- }
- else
- {
- std::cout << "sendResponse failed." << std::endl;
- }
- }
- else
- {
- std::cout << "PrepareResponse failed." << std::endl;
- }
- return ehResult;
-}
-
-/****** gtest class ******/
-
-class ThingsManagerTest: public TestWithMock
-{
-public:
- void Proceed()
- {
- cond.notify_all();
- }
-
- void Wait(int waitingTime = DEFAULT_WAITING_TIME_IN_MILLIS)
- {
- std::unique_lock < std::mutex > lock
- { mutex };
- cond.wait_for(lock, std::chrono::milliseconds
- { waitingTime });
- }
-
-protected:
- void SetUp()
- {
- TestWithMock::SetUp();
- }
-
- void TearDown()
- {
- TestWithMock::TearDown();
- }
-
-private:
- std::condition_variable cond;
- std::mutex mutex;
-};
-
-//Callbacks
-void onUpdate(const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
-{
-}
-
-void onGetBootstrapInformation(const HeaderOptions& /*headerOptions*/,
- const OCRepresentation& /*rep*/, const int /*eCode*/)
-{
-}
-
-void onReboot(const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
-{
-}
-
-void onFactoryReset(const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
-{
-}
-
-void onGet(const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
-{
-}
-
-void onPut(const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
-{
-}
-
-void onPost(const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
-{
-}
-
-void foundResources(std::vector< std::shared_ptr< OC::OCResource > > listOfResource)
-{
- for (auto rsrc = listOfResource.begin(); rsrc != listOfResource.end(); ++rsrc)
- {
- if(((*rsrc)->connectivityType() & CT_ADAPTER_TCP) == CT_ADAPTER_TCP)
- {
- continue;
- }
-
- std::string resourceURI = (*rsrc)->uri();
- std::string hostAddress = (*rsrc)->host();
-
- if (resourceURI == "/a/light")
- {
- result = OCPlatform::registerResource(foundResourceHandle, (*rsrc));
- if (result == OC_STACK_OK)
- {
- OCPlatform::bindResource(resourceHandle, foundResourceHandle);
- resourceHandleVector.push_back(foundResourceHandle);
- }
- else
- {
- cout << "\tresource Error!" << endl;
- }
- lights.push_back((hostAddress + resourceURI));
-
- g_light = (*rsrc);
- cv2.notify_all();
- }
- else
- {
- configurationResource = (*rsrc);
- cv2.notify_all();
- }
- }
- cv2.notify_all();
-}
-
-void foundGroupResource(std::shared_ptr< OCResource > resource)
-{
- if((resource->connectivityType() & CT_ADAPTER_TCP) == CT_ADAPTER_TCP)
- {
- return ;
- }
-
- std::string resourceURI;
- resourceURI = resource->uri();
- if (resourceURI == "/core/a/collection")
- {
- g_resource = resource;
- }
- else
- {
- g_room_resource = resource;
- }
- cv1.notify_all();
-}
-
-//This test case is to create the lightserver , BootstrapServer & configuration sever
-TEST_F(ThingsManagerTest, testCreateResources)
-{
- PlatformConfig cfg
- { OC::ServiceType::InProc, OC::ModeType::Both, "0.0.0.0", 0, OC::QualityOfService::LowQos};
- OCPlatform::Configure(cfg);
-
- LightResource myLight;
- std::thread t1(&LightResource::createResource, &myLight);
- t1.detach();
- std::mutex blocker1;
- std::unique_lock < std::mutex > lock1(blocker1);
- cv2.wait(lock1);
-
- std::thread t2(&BootstrapResource::createResources, &myBootstrapResource);
- t2.detach();
- std::mutex blocker2;
- std::unique_lock < std::mutex > lock2(blocker2);
- cv5.wait(lock2);
-
- myConfigurationResource = new ConfigurationResource();
- std::thread t3(&ConfigurationResource::createResources, myConfigurationResource,
- &entityHandlerForResource);
-
- t3.detach();
- std::mutex blocker3;
- std::unique_lock < std::mutex > lock3(blocker3);
- cv2.wait(lock3);
-
- myMaintenanceResource = new MaintenanceResource();
- std::thread t4(&MaintenanceResource::createResources, myMaintenanceResource,
- &entityHandlerForResource);
- t4.detach();
-
- std::mutex blocker4;
- std::unique_lock < std::mutex > lock4(blocker4);
- cv3.wait(lock4);
-
- myFactorySetResource = new FactorySetResource();
- std::thread t5(&FactorySetResource::createResources, myFactorySetResource,
- &entityHandlerForResource);
- t5.detach();
-
- std::mutex blocker5;
- std::unique_lock < std::mutex > lock5(blocker5);
- cv4.wait(lock5);
-
- myMaintenanceResource->factoryReset = std::function < void()
- > (std::bind(&ConfigurationResource::factoryReset,
- myConfigurationResource));
-}
-
-//Check findCandidateResources
-TEST_F(ThingsManagerTest, testFindCandidateResources)
-{
-
- string resourceURI = "/core/a/collection";
- string resourceTypeName = "a.collection";
- string resourceInterface = BATCH_INTERFACE;
-
- OCStackResult res = OCPlatform::registerResource(resourceHandle, resourceURI,
- resourceTypeName, resourceInterface, NULL, OC_DISCOVERABLE);
-
- if ( res != OC_STACK_OK )
- {
- cout << "Resource registeration failed." << endl;
- }
-
- OCPlatform::bindInterfaceToResource(resourceHandle, GROUP_INTERFACE);
- OCPlatform::bindInterfaceToResource(resourceHandle, DEFAULT_INTERFACE);
-
- std::string query = OC_RSRVD_WELL_KNOWN_URI;
- query.append("?rt=");
- query.append(resourceTypeName);
-
- OCPlatform::findResource("", query, CT_DEFAULT, &foundGroupResource);
-
- std::mutex blocker1;
- std::unique_lock < std::mutex > lock1(blocker1);
- cv1.wait(lock1);
-
- GroupManager *instance = new GroupManager();
- vector<string> types;
- types.push_back("core.light");
-
- result = instance->findCandidateResources(types, &foundResources);
-
- std::mutex blocker2;
- std::unique_lock < std::mutex > lock2(blocker2);
- cv2.wait(lock2);
-}
-
-//Find Candidate Resource when no resources are specified
-TEST_F(ThingsManagerTest, testFindCandidateResourcesEmptyResourceType)
-{
- GroupManager *instance = new GroupManager();
- vector<string> types;
- result = instance->findCandidateResources(types, &foundResources);
- EXPECT_TRUE(result == OC_STACK_ERROR);
- delete instance;
-}
-
-//Find Candidate Resource when Callback is null
-TEST_F(ThingsManagerTest, testFindCandidateResourcesNullCallback)
-{
- GroupManager *instance = new GroupManager();
- vector<string> types;
- types.push_back("core.light");
- result = instance->findCandidateResources(types, NULL);
- EXPECT_TRUE(result == OC_STACK_ERROR);
- delete instance;
-}
-
-//test bind resource to group
-TEST_F(ThingsManagerTest, testBindResourceToGroup)
-{
- GroupManager *instance = new GroupManager();
- OCResourceHandle rHandle = NULL;
-
- string resourceURI = "/core/room-large";
- string resourceTypeName = "core.room-large";
- string resourceInterface = BATCH_INTERFACE;
-
- OCStackResult res = OCPlatform::registerResource(rHandle, resourceURI,
- resourceTypeName, resourceInterface, NULL, OC_DISCOVERABLE);
-
- if ( res != OC_STACK_OK )
- {
- cout << "Resource registeration failed." << endl;
- }
-
- OCPlatform::bindInterfaceToResource(rHandle, GROUP_INTERFACE);
- OCPlatform::bindInterfaceToResource(rHandle, DEFAULT_INTERFACE);
-
- std::string query = OC_RSRVD_WELL_KNOWN_URI;
- query.append("?rt=");
- query.append(resourceTypeName);
-
- OCPlatform::findResource("", query, CT_DEFAULT, &foundGroupResource);
-
- std::mutex blocker1;
- std::unique_lock < std::mutex > lock1(blocker1);
- cv1.wait(lock1);
-
- result = instance->bindResourceToGroup (resourceHandle, g_room_resource, rHandle);
-
- EXPECT_TRUE(result == OC_STACK_OK);
- delete instance;
-}
-
-//Add actionset
-TEST_F(ThingsManagerTest, testAddActionSetAllBulbOff)
-{
- string actionsetDesc;
- ActionSet *allBulbOff = new ActionSet();
- allBulbOff->actionsetName = "AllBulbOff";
-
- mocks.ExpectCallFunc(onPut).
- Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
- {
- Proceed();
- });
-
- for (auto iter = lights.begin(); iter != lights.end(); ++iter)
- {
- Action *action = new Action();
- action->target = (*iter);
-
- Capability *capa = new Capability();
- capa->capability = "power";
- capa->status = "off";
-
- action->listOfCapability.push_back(capa);
- allBulbOff->listOfAction.push_back(action);
- }
- if (g_resource)
- {
- result = groupMgr->addActionSet(g_resource, allBulbOff, &onPut);
- Wait();
- EXPECT_TRUE(result == OC_STACK_OK);
- result = 0;
- }
- delete allBulbOff;
-}
-
-//Add actionset with NULL resource
-TEST_F(ThingsManagerTest, testAddActionSetAllBulbOffResourceNull)
-{
- string actionsetDesc;
- ActionSet *allBulbOff = new ActionSet();
- allBulbOff->actionsetName = "AllBulbOff";
-
- for (auto iter = lights.begin(); iter != lights.end(); ++iter)
- {
- Action *action = new Action();
- action->target = (*iter);
-
- Capability *capa = new Capability();
- capa->capability = "power";
- capa->status = "off";
-
- action->listOfCapability.push_back(capa);
- allBulbOff->listOfAction.push_back(action);
- }
-
- result = groupMgr->addActionSet(NULL, allBulbOff, &onPut);
- Wait();
- EXPECT_TRUE(result == OC_STACK_ERROR);
- result = 0;
-
- delete allBulbOff;
-}
-
-//Add actionset with NULL ActionSet
-TEST_F(ThingsManagerTest, testAddActionSetAllBulbOffActionsetNull)
-{
- if (g_resource)
- {
- result = groupMgr->addActionSet(g_resource, NULL, &onPut);
- Wait();
- EXPECT_TRUE(result == OC_STACK_ERROR);
- result = 0;
- }
-}
-
-//Add actionset
-TEST_F(ThingsManagerTest, testAddActionSetAllBulbOn)
-{
- string actionsetDesc;
- ActionSet *allBulbON = new ActionSet();
- allBulbON->actionsetName = "AllBulbOn";
-
- mocks.ExpectCallFunc(onPut).
- Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
- {
- Proceed();
- });
-
- for (auto iter = lights.begin(); iter != lights.end(); ++iter)
- {
- Action *action = new Action();
- action->target = (*iter);
-
- Capability *capa = new Capability();
- capa->capability = "power";
- capa->status = "on";
-
- action->listOfCapability.push_back(capa);
- allBulbON->listOfAction.push_back(action);
- }
- if (g_resource)
- {
- result = groupMgr->addActionSet(g_resource, allBulbON, onPut);
- Wait();
- EXPECT_TRUE(result == OC_STACK_OK);
- result = 0;
- }
- delete allBulbON;
-}
-
-//Add actionset with NULL Resource
-TEST_F(ThingsManagerTest, testAddActionSetAllBulbOnResourceNull)
-{
- string actionsetDesc;
- ActionSet *allBulbON = new ActionSet();
- allBulbON->actionsetName = "AllBulbOn";
-
- for (auto iter = lights.begin(); iter != lights.end(); ++iter)
- {
- Action *action = new Action();
- action->target = (*iter);
-
- Capability *capa = new Capability();
- capa->capability = "power";
- capa->status = "on";
-
- action->listOfCapability.push_back(capa);
- allBulbON->listOfAction.push_back(action);
- }
-
- result = groupMgr->addActionSet(NULL, allBulbON, onPut);
- Wait();
- EXPECT_TRUE(result == OC_STACK_ERROR);
- result = 0;
-
- delete allBulbON;
-}
-
-//Add actionset with NULL ActionSet
-TEST_F(ThingsManagerTest, testAddActionSetAllBulbOnActionSetNull)
-{
- if (g_resource)
- {
- result = groupMgr->addActionSet(g_resource, NULL, onPut);
- Wait();
- EXPECT_TRUE(result == OC_STACK_ERROR);
- result = 0;
- }
-}
-
-//Execute actionset
-TEST_F(ThingsManagerTest, testExecuteActionSetAllBulbOn)
-{
- string actionsetDesc;
- ActionSet *allBulbON = new ActionSet();
- allBulbON->actionsetName = "AllBulbOn1";
-
- mocks.ExpectCallFunc(onPut).
- Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/) { Proceed();});
-
- for (auto iter = lights.begin(); iter != lights.end(); ++iter)
- {
- Action *action = new Action();
- action->target = (*iter);
-
- Capability *capa = new Capability();
- capa->capability = "power";
- capa->status = "on";
-
- action->listOfCapability.push_back(capa);
- allBulbON->listOfAction.push_back(action);
- }
- if (g_resource)
- {
- result = groupMgr->addActionSet(g_resource, allBulbON, onPut);
- Wait();
- EXPECT_TRUE(result == OC_STACK_OK);
- result = 0;
- }
-
- mocks.ExpectCallFunc(onPost).
- Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
- {
- Proceed();
- });
-
- if (g_resource)
- {
- result = groupMgr->executeActionSet(g_resource, "AllBulbOn", &onPost);
- Wait();
- EXPECT_TRUE(result == OC_STACK_OK);
- result = 0;
- }
- delete allBulbON;
-}
-
-//Execute actionset with NULL Resource
-TEST_F(ThingsManagerTest, testExecuteActionSetAllBulbOnResourceNull)
-{
- result = groupMgr->executeActionSet(NULL, "AllBulbOn", &onPost);
- Wait();
- EXPECT_TRUE(result == OC_STACK_ERROR);
- result = 0;
-}
-
-//Execute actionset
-TEST_F(ThingsManagerTest, testExecuteActionSetAllBulbOff)
-{
- mocks.ExpectCallFunc(onPost).
- Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
- {
- Proceed();
- });
-
- if (g_resource)
- {
- result = groupMgr->executeActionSet(g_resource, "AllBulbOff", &onPost);
- Wait();
- EXPECT_TRUE(result == OC_STACK_OK);
- result = 0;
- }
-}
-
-//Execute actionset with NULL resource
-TEST_F(ThingsManagerTest, testExecuteActionSetAllBulbOffResourceNull)
-{
- result = groupMgr->executeActionSet(NULL, "AllBulbOff", &onPost);
- Wait();
- EXPECT_TRUE(result == OC_STACK_ERROR);
- result = 0;
-}
-
-//Execute actionset with Delay
-TEST_F(ThingsManagerTest, testExcecuteActionSetWithDelay)
-{
- string actionsetDesc;
- ActionSet *allBulbON = new ActionSet();
- allBulbON->actionsetName = "AllBulbOnDelay";
- allBulbON->setDelay(1);
-
- mocks.ExpectCallFunc(onPut).
- Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
- {
- Proceed();
- });
-
- for (auto iter = lights.begin(); iter != lights.end(); ++iter)
- {
- Action *action = new Action();
- action->target = (*iter);
-
- Capability *capa = new Capability();
- capa->capability = "power";
- capa->status = "off";
-
- action->listOfCapability.push_back(capa);
- allBulbON->listOfAction.push_back(action);
- }
- if (g_resource)
- {
- result = groupMgr->addActionSet(g_resource, allBulbON, onPut);
- Wait();
- }
-
- mocks.ExpectCallFunc(onPost).
- Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
- {
- Proceed();
- });
-
- if (g_resource)
- {
- result = groupMgr->executeActionSet(g_resource, "AllBulbOnDelay", &onPost);
- Wait();
- EXPECT_TRUE(result == OC_STACK_OK);
- result = 0;
- }
-
- delete allBulbON;
-}
-
-//Execute actionset with Delay = 0
-TEST_F(ThingsManagerTest, testExcecuteActionSetWithDelayEqulasZero)
-{
- string actionsetDesc;
- ActionSet *allBulbON = new ActionSet();
- allBulbON->actionsetName = "AllBulbOnDelay";
-
- mocks.ExpectCallFunc(onPut).
- Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
- {
- Proceed();
- });
-
- for (auto iter = lights.begin(); iter != lights.end(); ++iter)
- {
- Action *action = new Action();
- action->target = (*iter);
-
- Capability *capa = new Capability();
- capa->capability = "power";
- capa->status = "off";
-
- action->listOfCapability.push_back(capa);
- allBulbON->listOfAction.push_back(action);
- }
- if (g_resource)
- {
- result = groupMgr->addActionSet(g_resource, allBulbON, onPut);
- Wait();
- }
-
- if (g_resource)
- {
- result = groupMgr->executeActionSet(g_resource, "AllBulbOnDelay", 0, &onPost);
- Wait();
- EXPECT_TRUE(result == OC_STACK_INVALID_PARAM);
- result = 0;
- }
-
- delete allBulbON;
-}
-
-//Execute actionset with invalid Delay
-TEST_F(ThingsManagerTest, testExcecuteActionSetWithInvalidDelay)
-{
- string actionsetDesc;
- ActionSet *allBulbON = new ActionSet();
- allBulbON->actionsetName = "AllBulbOnDelay";
-
- mocks.ExpectCallFunc(onPut).
- Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
- {
- Proceed();
- });
-
- for (auto iter = lights.begin(); iter != lights.end(); ++iter)
- {
- Action *action = new Action();
- action->target = (*iter);
-
- Capability *capa = new Capability();
- capa->capability = "power";
- capa->status = "off";
-
- action->listOfCapability.push_back(capa);
- allBulbON->listOfAction.push_back(action);
- }
- if (g_resource)
- {
- result = groupMgr->addActionSet(g_resource, allBulbON, onPut);
- Wait();
- }
-
- if (g_resource)
- {
- result = groupMgr->executeActionSet(g_resource, "AllBulbOnDelay", -10, &onPost);
- Wait();
- EXPECT_TRUE(result == OC_STACK_INVALID_PARAM);
- result = 0;
- }
-
- delete allBulbON;
-}
-
-//Execute actionset with delay on NULL Resource
-TEST_F(ThingsManagerTest, testExcecuteActionSetWithDelayWithResourceNull)
-{
- string actionsetDesc;
- ActionSet *allBulbON = new ActionSet();
- allBulbON->actionsetName = "AllBulbOnDelay";
- allBulbON->setDelay(5);
-
- mocks.ExpectCallFunc(onPut).
- Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
- {
- Proceed();
- });
-
- for (auto iter = lights.begin(); iter != lights.end(); ++iter)
- {
- Action *action = new Action();
- action->target = (*iter);
-
- Capability *capa = new Capability();
- capa->capability = "power";
- capa->status = "off";
-
- action->listOfCapability.push_back(capa);
- allBulbON->listOfAction.push_back(action);
- }
- if (g_resource)
- {
- result = groupMgr->addActionSet(g_resource, allBulbON, onPut);
- Wait();
- }
- result = groupMgr->executeActionSet(NULL, "AllBulbOnDelay", &onPost);
- EXPECT_TRUE(result == OC_STACK_ERROR);
- result = 0;
-
- delete allBulbON;
-}
-
-//Cancel ActionSet
-TEST_F(ThingsManagerTest, testCancelActionSet)
-{
- mocks.ExpectCallFunc(onPost).
- Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
- {
- Proceed();
- });
-
- if (g_resource)
- {
- result = groupMgr->cancelActionSet(g_resource, "AllBulbOff", &onPost);
- Wait();
- EXPECT_TRUE(result == OC_STACK_OK);
- result = 0;
- }
-}
-
-//Cancel ActionSet on NULL Resource
-TEST_F(ThingsManagerTest, testCancelActionSetResourceNull)
-{
- result = groupMgr->cancelActionSet(NULL, "AllBulbOff", &onPost);
- Wait();
- EXPECT_TRUE(result == OC_STACK_ERROR);
- result = 0;
-}
-
-//Delete ActionSet
-TEST_F(ThingsManagerTest, testDeleteActionSet)
-{
- mocks.ExpectCallFunc(onPut).
- Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
- {
- Proceed();
- });
-
- if (g_resource)
- {
- result = groupMgr->deleteActionSet(g_resource, "AllBulbOff", &onPut);
- Wait();
- EXPECT_TRUE(result == OC_STACK_OK);
- result = 0;
- }
-}
-
-//Delete ActionSet on NULL Resource
-TEST_F(ThingsManagerTest, testDeleteActionSetResourceNull)
-{
- result = groupMgr->deleteActionSet(NULL, "AllBulbOff", &onPut);
- Wait();
- EXPECT_TRUE(result == OC_STACK_ERROR);
- result = 0;
-}
-
-//Get ActionSet
-TEST_F(ThingsManagerTest, testGetActionSet)
-{
- mocks.ExpectCallFunc(onPost).
- Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
- {
- Proceed();
- });
-
- if (g_resource)
- {
- result = groupMgr->getActionSet(g_resource, "AllBulbOn", &onPost);
- Wait();
- EXPECT_TRUE(result == OC_STACK_OK);
- result = 0;
- }
-}
-
-//Get ActionSet on NULL Resource
-TEST_F(ThingsManagerTest, testGetActionSetResourceNull)
-{
- result = groupMgr->getActionSet(NULL, "AllBulbOn", &onPost);
- Wait();
- EXPECT_TRUE(result == OC_STACK_ERROR);
- result = 0;
-}
-
-//Get Configurations
-TEST_F(ThingsManagerTest, testGetConfigurations)
-{
- ConfigurationName name = "all";
-
- ThingsConfiguration *g_thingsConf = ThingsConfiguration::getInstance();
- std::vector< ConfigurationName > configurations;
-
- configurations.push_back(name);
-
- mocks.ExpectCallFunc(onGet).
- Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
- {
- Proceed();
- });
-
- vector<string> types;
- types.push_back("oic.wk.con");
-
- result = groupMgr->findCandidateResources(types, &foundResources, 3);
-
- std::mutex blocker;
- std::unique_lock < std::mutex > lock(blocker);
- cv2.wait(lock);
-
- if (result == OC_STACK_OK)
- {
- result = g_thingsConf->getConfigurations(configurationResource, configurations, &onGet);
- Wait();
- EXPECT_TRUE(result == OC_STACK_OK);
- result = 0;
- }
-}
-
-//Get Configurations with empty Configuration
-TEST_F(ThingsManagerTest, testGetConfigurationsEmptyConfiguration)
-{
- ThingsConfiguration *g_thingsConf = ThingsConfiguration::getInstance();
- std::vector< ConfigurationName > configurations;
-
- vector<string> types;
- types.push_back("oic.wk.con");
-
- result = groupMgr->findCandidateResources(types, &foundResources, 3);
-
- std::mutex blocker;
- std::unique_lock < std::mutex > lock(blocker);
- cv2.wait(lock);
-
- if (result == OC_STACK_OK)
- {
- result = g_thingsConf->getConfigurations(configurationResource, configurations, &onGet);
- Wait();
- EXPECT_TRUE(result == OC_STACK_ERROR);
- result = 0;
- }
-}
-
-//Get Configurations on NULL Resource
-TEST_F(ThingsManagerTest, testGetConfigurationsResourceNull)
-{
- ConfigurationName name = "all";
- ThingsConfiguration *g_thingsConf = ThingsConfiguration::getInstance();
- std::vector< ConfigurationName > configurations;
-
- configurations.push_back(name);
-
- result = g_thingsConf->getConfigurations(NULL, configurations, &onGet);
- Wait();
- EXPECT_TRUE(result == OC_STACK_ERROR);
- result = 0;
-}
-
-//Get all supported Configurations
-TEST_F(ThingsManagerTest, testGetallSupportedCOnfigurations)
-{
- ThingsConfiguration *g_thingsConf = ThingsConfiguration::getInstance();
- string retVal = g_thingsConf->getListOfSupportedConfigurationUnits();
- EXPECT_FALSE(retVal.size() == 0);
-}
-
-//DoBootstrap
-TEST_F(ThingsManagerTest, testDoBootstrap)
-{
- ThingsConfiguration *g_thingsConf = ThingsConfiguration::getInstance();
-
- mocks.ExpectCallFunc(onGetBootstrapInformation).
- Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
- {
- Proceed();
- });
- result = g_thingsConf->doBootstrap(&onGetBootstrapInformation);
- Wait();
- EXPECT_TRUE(result == OC_STACK_OK);
- result = 0;
-}
-
-//DoBootstrap with NULL callback
-TEST_F(ThingsManagerTest, testDoBootstrapCallBackNull)
-{
- ThingsConfiguration *g_thingsConf = ThingsConfiguration::getInstance();
-
- result = g_thingsConf->doBootstrap(NULL);
- Wait();
- EXPECT_TRUE(result == OC_STACK_ERROR);
- result = 0;
-}
-
-//Update Configuration
-TEST_F(ThingsManagerTest, testUpdateConfiguration)
-{
- ConfigurationName name = "r";
- ConfigurationValue value = "INDIA";
-
- std::map< ConfigurationName, ConfigurationValue > configurations;
- ThingsConfiguration *g_thingsConf = ThingsConfiguration::getInstance();
- configurations.insert(std::make_pair(name, value));
-
- mocks.ExpectCallFunc(onUpdate).
- Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
- {
- Proceed();
- });
-
- vector<string> types;
- types.push_back("oic.wk.con");
- result = groupMgr->findCandidateResources(types, &foundResources, 3);
-
- std::mutex blocker2;
- std::unique_lock < std::mutex > lock2(blocker2);
- cv2.wait(lock2);
-
- if (result == OC_STACK_OK)
- {
- result = g_thingsConf->updateConfigurations(configurationResource, configurations,
- &onUpdate);
- Wait();
- EXPECT_TRUE(result == OC_STACK_OK);
- result = 0;
- }
-}
-
-//Update Configuration with Empty Configuration
-TEST_F(ThingsManagerTest, testUpdateConfigurationEmptyConfiguration)
-{
- std::map< ConfigurationName, ConfigurationValue > configurations;
- ThingsConfiguration *g_thingsConf = ThingsConfiguration::getInstance();
-
- vector<string> types;
- types.push_back("oic.wk.con");
- result = groupMgr->findCandidateResources(types, &foundResources, 3);
-
- std::mutex blocker2;
- std::unique_lock < std::mutex > lock2(blocker2);
- cv2.wait(lock2);
-
- if (result == OC_STACK_OK)
- {
- result = g_thingsConf->updateConfigurations(configurationResource, configurations,
- &onUpdate);
- Wait();
- EXPECT_TRUE(result == OC_STACK_ERROR);
- result = 0;
- }
-}
-
-//Update Configuration on NULL Resource
-TEST_F(ThingsManagerTest, testUpdateConfigurationResourceNull)
-{
- ConfigurationName name = "r";
- ConfigurationValue value = "INDIA";
-
- std::map< ConfigurationName, ConfigurationValue > configurations;
- ThingsConfiguration *g_thingsConf = ThingsConfiguration::getInstance();
-
- configurations.insert(std::make_pair(name, value));
-
- result = g_thingsConf->updateConfigurations(NULL, configurations, &onUpdate);
- Wait();
- EXPECT_TRUE(result == OC_STACK_ERROR);
- result = 0;
-}
-
-//Reboot
-TEST_F(ThingsManagerTest, testReboot)
-{
- ThingsMaintenance *g_thingsMnt = ThingsMaintenance::getInstance();
-
- mocks.ExpectCallFunc(onReboot).
- Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
- {
- Proceed();
- });
-
- vector<string> types;
- types.push_back("oic.wk.mnt");
- result = groupMgr->findCandidateResources(types, &foundResources, 3);
-
- std::mutex blocker;
- std::unique_lock < std::mutex > lock(blocker);
- cv2.wait(lock);
-
- if (result == OC_STACK_OK)
- {
- result = g_thingsMnt->reboot(configurationResource, &onReboot);
- Wait();
- EXPECT_TRUE(result == OC_STACK_OK);
- result = 0;
- }
-}
-
-//Reboot on NULL Resource
-TEST_F(ThingsManagerTest, testRebootResourceNull)
-{
- ThingsMaintenance *g_thingsMnt = ThingsMaintenance::getInstance();
-
- result = g_thingsMnt->reboot(NULL, &onReboot);
- Wait();
- EXPECT_TRUE(result == OC_STACK_ERROR);
- result = 0;
-}
-
-//Factory Reset
-TEST_F(ThingsManagerTest, testFactoryReset)
-{
- ThingsMaintenance *g_thingsMnt = ThingsMaintenance::getInstance();
-
- mocks.ExpectCallFunc(onFactoryReset).
- Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
- const int /*eCode*/)
- {
- Proceed();
- });
-
- vector<string> types;
- types.push_back("oic.wk.mnt");
- result = groupMgr->findCandidateResources(types, &foundResources, 3);
-
- std::mutex blocker;
- std::unique_lock < std::mutex > lock(blocker);
- cv2.wait(lock);
-
- if (result == OC_STACK_OK)
- {
- result = g_thingsMnt->factoryReset(configurationResource, &onFactoryReset);
- Wait();
- EXPECT_TRUE(result == OC_STACK_OK);
- result = 0;
- }
-}
-
-//Factory Reset on NULL Resource
-TEST_F(ThingsManagerTest, testFactoryResetResourceNull)
-{
- ThingsMaintenance *g_thingsMnt = ThingsMaintenance::getInstance();
-
- result = g_thingsMnt->factoryReset(NULL, &onFactoryReset);
- Wait();
- EXPECT_TRUE(result == OC_STACK_ERROR);
- result = 0;
-}
-
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2015 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#ifndef COMMON_UTILS_UNITTESTHELPER_H
-#define COMMON_UTILS_UNITTESTHELPER_H
-
-#include <gtest/gtest.h>
-#include <HippoMocks/hippomocks.h>
-
-class TestWithMock: public testing::Test
-{
- public:
- MockRepository mocks;
-
- protected:
- virtual ~TestWithMock() noexcept(noexcept(std::declval<Test>().~Test())) {}
-
- virtual void TearDown()
- {
- try
- {
- mocks.VerifyAll();
- }
- catch (...)
- {
- mocks.reset();
- throw;
- }
- }
-};
-
-#endif // COMMON_UTILS_UNITTESTHELPER_H