target_os = env.get('TARGET_OS')
if target_os not in ['arduino','darwin', 'ios', 'windows']:
- # Build resource-hosting project
- SConscript('resource-hosting/SConscript')
-
# Build resource-encapsulation project
SConscript('resource-encapsulation/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.
-#
-#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-##
-# NotificationManager build script
-##
-
-Import('env')
-
-if env.get('RELEASE'):
- env.AppendUnique(CCFLAGS = ['-Os'])
- env.AppendUnique(CPPDEFINES = ['NDEBUG'])
-else:
- env.AppendUnique(CCFLAGS = ['-g'])
-
-if env.get('LOGGING'):
- env.AppendUnique(CPPDEFINES = ['TB_LOG'])
-
-lib_env = env.Clone()
-SConscript('#service/third_party_libs.scons', 'lib_env')
-resourcehosting_env = lib_env.Clone()
-
-target_os = env.get('TARGET_OS')
-######################################################################
-# Build flags
-######################################################################
-resourcehosting_env.AppendUnique(CPPPATH = ['include'])
-resourcehosting_env.AppendUnique(CPPPATH = ['../resource-encapsulation/include'])
-resourcehosting_env.AppendUnique(CPPPATH = ['../resource-encapsulation/src/common/primitiveResource/include'])
-
-resourcehosting_env.PrependUnique(LIBS = [
- 'rcs_client',
- 'rcs_server',
- 'rcs_common',
- 'oc',
- 'octbstack',
- 'oc_logger',
- 'connectivity_abstraction',
- 'libcoap'
- ])
-
-if target_os not in ['windows']:
- resourcehosting_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
-
-if target_os not in ['darwin', 'ios', 'windows']:
- resourcehosting_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
-
-if target_os in ['linux']:
- resourcehosting_env.AppendUnique(LIBS = ['pthread'])
-
-if target_os == 'android':
- resourcehosting_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
- resourcehosting_env.AppendUnique(LIBS = ['gnustl_shared','log'])
-
- if not env.get('RELEASE'):
- resourcehosting_env.AppendUnique(LIBS = ['log'])
-
-######################################################################
-# Source files and Targets
-######################################################################
-HOSTING_SRC_DIR = 'src/'
-resourcehosting_src = [
- HOSTING_SRC_DIR + 'Hosting.cpp',
- HOSTING_SRC_DIR + 'ResourceHosting.cpp',
- HOSTING_SRC_DIR + 'HostingObject.cpp',
- HOSTING_SRC_DIR + 'RequestObject.cpp'
- ]
-
-if target_os in ['tizen','android'] :
- resourcehostingsdk = resourcehosting_env.SharedLibrary('resource_hosting', resourcehosting_src)
-else :
- resourcehostingsdk = resourcehosting_env.StaticLibrary('resource_hosting', resourcehosting_src)
-
-resourcehosting_env.InstallTarget(resourcehostingsdk, 'resource_hosting')
-resourcehosting_env.UserInstallTargetLib(resourcehostingsdk, 'resource_hosting')
-resourcehosting_env.UserInstallTargetHeader('include/Hosting.h',\
- 'service/resource-hosting', 'Hosting.h')
-
-# Go to build Unit test
-#if target_os in ['linux']:
-# SConscript('unittest/SConscript')
-
-# Go to build sample apps
-SConscript('SampleApp/SConscript')
+++ /dev/null
-##
-# Examples build script
-##
-Import('env')
-
-target_os = env.get('TARGET_OS')
-if target_os in ['linux']:
- SConscript('linux/SConscript')
-elif target_os == 'arduino':
- SConscript('arduino/SConscript')
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry exported="true" 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="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
- <classpathentry kind="output" path="bin/classes"/>
-</classpath>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>SampleConsumer</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.sec.android.iot.sampleconsumer"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" />
-
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
- <uses-permission android:name="android.permission.READ_PHONE_STATE" />
- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
- <uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
- <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
- <uses-permission android:name="android.permission.GET_TASKS"/>
- <uses-permission android:name="com.samsung.wmanager.ENABLE_NOTIFICATION"/>
- <uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY"/>
-
- <application android:label="@string/app_name" >
- <activity
- android:name="com.example.sample.consumer.SampleConsumer"
- 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>
\ No newline at end of file
+++ /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-19
-android.library.reference.1=../../../android/resource_hosting
+++ /dev/null
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical"
- android:paddingBottom="5dp"
- android:paddingLeft="10dp"
- android:paddingRight="10dp"
- android:paddingTop="10dp" >
-
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
-
- <TextView
- android:id="@+id/tv_found_resource"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/found_resource"
- android:textAppearance="?android:attr/textAppearanceLarge" />
-
- <TextView
- android:id="@+id/tv_found_resource_result"
- android:layout_width="200dp"
- android:layout_height="wrap_content"
- android:layout_below="@+id/tv_found_resource"
- android:hint="@string/none" />
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal" >
-
- <Button
- android:id="@+id/btn_observe"
- android:layout_width="60dp"
- android:layout_height="50dp"
- android:layout_below="@+id/tv_found_resource_result"
- android:layout_marginLeft="5dp"
- android:layout_marginTop="5dp"
- android:text="@string/observe"
- android:textSize="12sp" />
-
- <Button
- android:id="@+id/btn_get"
- android:layout_width="60dp"
- android:layout_height="50dp"
- android:layout_alignBottom="@+id/btn_observe"
- android:layout_below="@+id/tv_found_resource_result"
- android:layout_marginLeft="5dp"
- android:layout_marginTop="5dp"
- android:text="@string/get"
- android:textSize="12sp" />
-
- <Button
- android:id="@+id/btn_put"
- android:layout_width="60dp"
- android:layout_height="50dp"
- android:layout_alignBottom="@+id/btn_observe"
- android:layout_below="@+id/tv_found_resource_result"
- android:layout_marginLeft="5dp"
- android:layout_marginTop="5dp"
- android:text="@string/put"
- android:textSize="12sp" />
-
- <Button
- android:id="@+id/btn_post"
- android:layout_width="60dp"
- android:layout_height="50dp"
- android:layout_alignBottom="@+id/btn_observe"
- android:layout_below="@+id/tv_found_resource_result"
- android:layout_marginLeft="5dp"
- android:layout_marginTop="5dp"
- android:text="@string/post"
- android:textSize="12sp" />
-
- <Button
- android:id="@+id/btn_delete"
- android:layout_width="60dp"
- android:layout_height="50dp"
- android:layout_alignBottom="@+id/btn_observe"
- android:layout_below="@+id/tv_found_resource_result"
- android:layout_marginLeft="5dp"
- android:layout_marginTop="5dp"
- android:text="@string/delete"
- android:textSize="12sp" />
- </LinearLayout>
-
- <TextView
- android:id="@+id/tv_selected_method_type"
- android:layout_width="200dp"
- android:layout_height="wrap_content"
- android:layout_below="@+id/btn_observe"
- android:layout_marginTop="10dp"
- android:hint="@string/select_method_type" />
-
- <TextView
- android:id="@+id/tv_receive"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_below="@+id/tv_selected_method_type"
- android:layout_marginLeft="10dp"
- android:layout_marginTop="10dp"
- android:text="@string/received"
- android:textAppearance="?android:attr/textAppearanceLarge" />
-
- <TextView
- android:id="@+id/tv_receive_result"
- android:layout_width="200dp"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_below="@+id/tv_receive"
- android:layout_marginLeft="10dp"
- android:layout_marginTop="10dp"
- android:hint="@string/none" />
-
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal" >
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical">
-
- <Button
- android:id="@+id/btn_clean"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/clean"
- android:textSize="18sp" />
-
- <ScrollView
- android:id="@+id/sclLog"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"
- android:fillViewport="true"
- >
-
- <TextView
- android:id="@+id/tv_current_log_result"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="bottom"
- android:text="@string/current_log"
- android:textSize="15sp" />
- </ScrollView>
- </LinearLayout>
- </LinearLayout>
- -
- </LinearLayout>
-
-</LinearLayout>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="app_name">SampleConsumer</string>
- <string name="observe">Obv</string>
- <string name="get">Get</string>
- <string name="put">Put</string>
- <string name="post">Post</string>
- <string name="delete">Del</string>
- <string name="select_method_type">Select Method Type</string>
- <string name="received">Received</string>
- <string name="current_log">Current Log</string>
- <string name="none">None</string>
- <string name="quit">Quit</string>
- <string name="clean">Clear Log</string>
- <string name="found_resource">Found Resource</string>
-</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.example.sample.consumer;
-
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.iotivity.base.ModeType;
-import org.iotivity.base.ObserveType;
-import org.iotivity.base.OcConnectivityType;
-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.OcResource.OnDeleteListener;
-import org.iotivity.base.OcResource.OnGetListener;
-import org.iotivity.base.OcResource.OnObserveListener;
-import org.iotivity.base.OcResource.OnPutListener;
-import org.iotivity.base.PlatformConfig;
-import org.iotivity.base.QualityOfService;
-import org.iotivity.base.ServiceType;
-
-import com.sec.android.iot.sampleconsumer.R;
-
-import android.app.Activity;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.widget.Button;
-import android.widget.TextView;
-import android.widget.Toast;
-
-public class SampleConsumer extends Activity implements View.OnClickListener,
- OcPlatform.OnResourceFoundListener, OnGetListener, OnDeleteListener,
- OnObserveListener, OnPutListener {
- private final String TAG = "NMConsumer : "
- + this.getClass()
- .getSimpleName();
-
- public static final int OC_STACK_OK = 0;
- public static final String OBSERVE = "Observe";
- public static final String GET = "Get";
- public static final String PUT = "Put";
- public static final String DELETE = "Delete";
- public static final String POST = "Post";
- public static final String MESSAGE = "message";
- public static String outputString = "";
-
- private Button btn_observe;
- private Button btn_get;
- private Button btn_put;
- private Button btn_post;
- private Button btn_delete;
- private Button btn_clean;
-
- public TextView tv_found_uri;
- public TextView tv_select_method_type;
- public TextView tv_receive_result;
- public TextView tv_current_log_result;
-
- public String current_log_result = "";
- public String found_uri = "";
- public String select_method_type = "";
- public String receive_result = "";
-
- public static OcResource curResource;
- public OcPlatform.OnResourceFoundListener OnResourceFoundListener;
-
- public static int oc = 0;
-
- /*
- * To initialize UI Function Setting To execute initOICStack for running
- * find resource
- */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- setContentView(R.layout.sampleconsumer_layout);
-
- btn_observe = (Button) findViewById(R.id.btn_observe);
- btn_get = (Button) findViewById(R.id.btn_get);
- btn_put = (Button) findViewById(R.id.btn_put);
- btn_post = (Button) findViewById(R.id.btn_post);
- btn_delete = (Button) findViewById(R.id.btn_delete);
- btn_clean = (Button) findViewById(R.id.btn_clean);
- tv_found_uri = (TextView) findViewById(R.id.tv_found_resource_result);
- tv_select_method_type = (TextView) findViewById(R.id.tv_selected_method_type);
- tv_receive_result = (TextView) findViewById(R.id.tv_receive_result);
- tv_current_log_result = (TextView) findViewById(R.id.tv_current_log_result);
- btn_observe.setOnClickListener(this);
- btn_get.setOnClickListener(this);
- btn_put.setOnClickListener(this);
- btn_post.setOnClickListener(this);
- btn_delete.setOnClickListener(this);
- btn_clean.setOnClickListener(this);
-
- initOICStack();
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- onStop();
- }
-
- /*
- * To reset text String is null for cleaning log
- */
- @Override
- protected void onStop() {
- super.onStop();
-
- tv_found_uri = null;
- tv_select_method_type = null;
- tv_receive_result = null;
- tv_current_log_result = null;
-
- current_log_result = "";
- found_uri = "";
- select_method_type = "";
- receive_result = "";
- btn_observe.setClickable(true);
- btn_get.setClickable(true);
- btn_put.setClickable(true);
- btn_delete.setClickable(true);
- }
-
- public void cleanLogString() {
- current_log_result = "";
- found_uri = "";
- select_method_type = "";
- receive_result = "";
-
- tv_current_log_result.setText(current_log_result);
- tv_found_uri.setText(found_uri);
- tv_select_method_type.setText(select_method_type);
- tv_receive_result.setText(receive_result);
- }
-
- public void initOICStack() {
- PlatformConfig cfg = new PlatformConfig(this, ServiceType.IN_PROC,
- ModeType.CLIENT, "0.0.0.0", 0, QualityOfService.LOW);
- OcPlatform.Configure(cfg);
- current_log_result += "Created Platform...\n";
- tv_current_log_result.setText(current_log_result);
- Log.i(TAG, current_log_result);
- findResourceCandidate();
- PRINT();
- }
-
- public void findResourceCandidate() {
- nmfindResource("", "/oic/res?rt=oic.r.resourcehosting");
- current_log_result += "Finding Resource... \n";
- tv_current_log_result.setText(current_log_result);
- Log.i(TAG, current_log_result);
- }
-
- public void nmfindResource(String host, String resourceName) {
- try {
- EnumSet<OcConnectivityType> propertySet = EnumSet
- .of(OcConnectivityType.CT_DEFAULT);
- OcPlatform.findResource(host, resourceName, propertySet, this);
-
- } catch (OcException e) {
- e.printStackTrace();
- current_log_result += e.getMessage() + "\n";
- tv_current_log_result.setText(current_log_result);
- Log.i(TAG, current_log_result);
- }
- }
-
- /*
- * No Use until Yet
- */
- public void getRepresentation(OcResource resource) {
- if (resource != null) {
- current_log_result += "Getting Light Representation...\n";
- tv_current_log_result.setText(current_log_result);
- Log.i(TAG, current_log_result);
- }
- }
-
- /*
- * No Use until Yet
- */
- public void getLightRepresentation(OcResource resource) {
- if (resource != null) {
- current_log_result += "Getting Light Representation...\n";
- tv_current_log_result.setText(current_log_result);
- Log.i(TAG, current_log_result);
-
- try {
- Map<String, String> queryParamsMap = new HashMap<String, String>();
- resource.get(queryParamsMap, this);
- } catch (OcException e) {
- e.printStackTrace();
- current_log_result += e.getMessage() + "\n";
- tv_current_log_result.setText(current_log_result);
- Log.i(TAG, current_log_result);
- }
- }
- }
-
- public void PRINT() {
- current_log_result += "********************************************\n";
- current_log_result += "* method Type : 1 - Observe *\n";
- current_log_result += "* method Type : 2 - Get *\n";
- current_log_result += "* method Type : 3 - Put *\n";
- current_log_result += "* method Type : 4 - Delete *\n";
- current_log_result += "********************************************\n";
- }
-
- public void startObserve(OcResource resource) {
- if (resource != null) {
- Map<String, String> queryParamsMap = new HashMap<String, String>();
- current_log_result += "startObserve\n";
- tv_current_log_result.setText(current_log_result);
- Log.i(TAG, current_log_result);
-
- try {
- resource.observe(ObserveType.OBSERVE, queryParamsMap, this);
- } catch (OcException e) {
- e.printStackTrace();
- current_log_result += e.getMessage() + "\n";
- tv_current_log_result.setText(current_log_result);
- Log.i(TAG, current_log_result);
- }
- }
- }
-
- public void startGet(OcResource resource) {
- if (resource != null) {
- Map<String, String> queryParamsMap = new HashMap<String, String>();
- current_log_result += "startGet\n";
- tv_current_log_result.setText(current_log_result);
- Log.i(TAG, current_log_result);
-
- try {
- resource.get(queryParamsMap, this);
- } catch (OcException e) {
- e.printStackTrace();
- current_log_result += e.getMessage() + "\n";
- tv_current_log_result.setText(current_log_result);
- Log.i(TAG, current_log_result);
- }
- }
- }
-
- public void startPut(OcResource resource) {
- if (resource != null) {
- curResource = resource;
- OcRepresentation rep = new OcRepresentation();
- rep.setValueInt("temperature", 25);
- rep.setValueInt("humidity", 10);
- Map<String, String> queryParamsMap = new HashMap<String, String>();
- current_log_result += "startPut\n";
- tv_current_log_result.setText(current_log_result);
- Log.i(TAG, current_log_result);
-
- try {
- resource.put(rep, queryParamsMap, this);
- } catch (OcException e) {
- e.printStackTrace();
- current_log_result += e.getMessage() + "\n";
- tv_current_log_result.setText(current_log_result);
- Log.i(TAG, current_log_result);
- }
- }
- }
-
- public void startDelete(OcResource resource) throws OcException {
- curResource = resource;
- if (resource != null) {
- resource.deleteResource(this);
- }
- }
-
- @Override
- public void onClick(View v) {
- switch (v.getId()) {
- case R.id.btn_observe:
- tv_select_method_type.setText(OBSERVE);
- Log.i(TAG, "Method: " + OBSERVE);
- startObserve(curResource);
- btn_observe.setClickable(false);
- break;
- case R.id.btn_get:
- tv_select_method_type.setText(GET);
- Log.i(TAG, "Method: " + GET);
- startGet(curResource);
- btn_get.setClickable(false);
- break;
- case R.id.btn_put:
- tv_select_method_type.setText(PUT);
- Log.i(TAG, "Method: " + PUT);
- startPut(curResource);
- btn_put.setClickable(false);
- break;
- case R.id.btn_post:
- tv_select_method_type.setText(POST);
- Toast.makeText(this, "Not Supported Yet", Toast.LENGTH_SHORT)
- .show();
- Log.i(TAG, "Method: " + POST);
- break;
- case R.id.btn_delete:
- tv_select_method_type.setText(DELETE);
- Log.i(TAG, "Method: " + DELETE);
- try {
- startDelete(curResource);
- } catch (OcException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- btn_delete.setClickable(false);
- break;
- case R.id.btn_clean:
- cleanLogString();
- Log.i(TAG, "Log textbox is cleared");
- break;
-
- default:
- break;
- }
-
- }
-
- protected static int observe_count() {
- return ++oc;
- }
-
- public void viewText() {
- SampleConsumer.this.runOnUiThread(new Runnable() {
- public void run() {
- if (receive_result != null) {
- tv_receive_result.setText(receive_result);
- Log.i(TAG, "Received: " + receive_result);
- }
- if (found_uri != null) {
- tv_found_uri.setText(found_uri);
- Log.i(TAG, "URI: " + found_uri);
- }
- if (current_log_result != null) {
- tv_current_log_result.setText(current_log_result);
- Log.i(TAG, current_log_result);
- }
-
- }
- });
- }
-
- @Override
- public synchronized void onResourceFound(OcResource resource) {
- // synchronized (this) {
- receive_result = "FoundResource";
- String resourceURI;
- String hostAddress;
- if (SampleConsumer.curResource != null) {
- current_log_result += "Found another resource, ignoring\n";
- }
- if (resource != null) {
- if (resource.getUri().equals("/a/TempHumSensor")) {
- current_log_result += "==============================\n";
- current_log_result += "DISCOVERED Resource(Consumer):\n";
- resourceURI = resource.getUri();
- hostAddress = resource.getHost();
- current_log_result += "URI of the resource: " + resourceURI
- + "\n";
- current_log_result += "Host address of the resource: "
- + hostAddress + "\n";
- SampleConsumer.curResource = resource;
- } else {
- current_log_result += "Uri is not correct.";
- }
- } else {
- current_log_result += "Resource is invalid\n";
- }
-
- viewText();
- }
-
- public String getCurrent_log_result() {
- return current_log_result;
- }
-
- public void setCurrent_log_result(String current_log_result) {
- this.current_log_result = current_log_result;
- }
-
- public String getFound_uri() {
- return found_uri;
- }
-
- public void setFound_uri(String found_uri) {
- this.found_uri = found_uri;
- }
-
- public String getSelect_method_type() {
- return select_method_type;
- }
-
- public void setSelect_method_type(String select_method_type) {
- this.select_method_type = select_method_type;
- }
-
- public String getReceive_result() {
- return receive_result;
- }
-
- public void setReceive_result(String recieve_result) {
- this.receive_result = recieve_result;
- }
-
- public class MessageReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- final String message = intent.getStringExtra(MESSAGE);
- tv_current_log_result.setText(message);
- Log.i(TAG, message);
- viewText();
- }
- }
-
- @Override
- public void onGetCompleted(List<OcHeaderOption> options,
- OcRepresentation rep) {
- setReceive_result("onGet");
- setCurrent_log_result(getCurrent_log_result()
- + "GET request was successful\n"
- + "GET request was successful\n" + "URI: " + rep.getUri()
- + "\n" + "Temperature: " + rep.getValueInt("temperature")
- + "\n" + "Humidity: " + rep.getValueInt("humidity") + "\n");
- viewText();
- btn_get.setClickable(true);
- }
-
- @Override
- public void onPutCompleted(List<OcHeaderOption> options,
- OcRepresentation rep) {
- setReceive_result("onPut");
- current_log_result += "PUT request was successful\n";
-
- int humidity;
- int temperature;
- humidity = rep.getValueInt("humidity");
- temperature = rep.getValueInt("temperature");
-
- setCurrent_log_result(getCurrent_log_result() + "temperature: "
- + temperature + "\n");
- setCurrent_log_result(getCurrent_log_result() + "humidity: " + humidity
- + "\n");
- viewText();
- btn_put.setClickable(true);
- }
-
- @Override
- public void onObserveCompleted(List<OcHeaderOption> options,
- OcRepresentation rep, int seqNum) {
- setReceive_result("onObserve");
- setCurrent_log_result(getCurrent_log_result() + "SequenceNumber : "
- + seqNum + "\n");
- setCurrent_log_result("========================================================\n"
- + "Receive OBSERVE RESULT:\n"
- + "URI: "
- + rep.getUri()
- + "\n"
- + "SequenceNumber: "
- + seqNum
- + "\n"
- + "Temperature: "
- + rep.getValueInt("temperature")
- + "\n"
- + "Humidity: "
- + rep.getValueInt("humidity") + "\n");
- if (SampleConsumer.observe_count() > 30) {
- setCurrent_log_result(getCurrent_log_result()
- + "Cancelling Observe...\n");
- try {
- SampleConsumer.curResource.cancelObserve();
- } catch (OcException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- setCurrent_log_result(getCurrent_log_result()
- + "Cancel result :" + e.getMessage() + "\n");
- }
- }
- viewText();
- }
-
- @Override
- public void onDeleteCompleted(List<OcHeaderOption> options) {
- setReceive_result("onDelete");
- viewText();
- btn_delete.setClickable(true);
- }
-
- @Override
- public void onPutFailed(Throwable arg0) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onObserveFailed(Throwable arg0) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onDeleteFailed(Throwable arg0) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onGetFailed(Throwable arg0) {
- // TODO Auto-generated method stub
-
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry exported="true" 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="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
- <classpathentry kind="output" path="bin/classes"/>
-</classpath>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>SampleProvider</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.sample.provider"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
- <uses-permission android:name="android.permission.READ_PHONE_STATE" />
- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
- <uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
- <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
- <uses-permission android:name="android.permission.GET_TASKS"/>
- <uses-permission android:name="com.samsung.wmanager.ENABLE_NOTIFICATION"/>
- <uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY"/>
-
- <application android:label="@string/app_name">
- <activity
- android:name="com.example.sample.provider.SampleProvider"
- 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>
\ No newline at end of file
+++ /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-19
-android.library.reference.1=../../../android/resource_hosting
+++ /dev/null
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical"
- android:paddingBottom="5dp"
- android:paddingLeft="10dp"
- android:paddingRight="10dp"
- android:paddingTop="10dp" >
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal" >
-
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginRight="20dp"
- android:paddingTop="10dp"
- android:orientation="horizontal">
-
- <TextView
- android:id="@+id/temperature"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="Temperature : "
- android:textSize="20sp"
- android:textStyle="bold" />
-
- <TextView
- android:id="@+id/temperatureValue"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="0"
- android:textSize="15sp"
- android:textStyle="bold" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal" >
-
- <Button
- android:id="@+id/btnTemperatureUP"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Up"
- android:textSize="18sp" />
-
- <Button
- android:id="@+id/btnTemperatureDown"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginRight="0dp"
- android:text="Down"
- android:textSize="18sp" />
- </LinearLayout>
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal" >
-
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginRight="20dp"
- android:paddingTop="10dp"
- android:orientation="horizontal">
-
- <TextView
- android:id="@+id/humidity"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="Humidity : "
- android:textSize="20sp"
- android:textStyle="bold" />
-
- <TextView
- android:id="@+id/humidityValue"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="0"
- android:textSize="15sp"
- android:textStyle="bold" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal" >
-
- <Button
- android:id="@+id/btnHumidityUP"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Up"
- android:textSize="18sp" />
-
- <Button
- android:id="@+id/btnHumidityDown"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginRight="0dp"
- android:text="Down"
- android:textSize="18sp" />
- </LinearLayout>
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:paddingTop="10dp" >
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Received Method Type : "
- android:textSize="15sp"
- android:textStyle="bold" />
-
- <TextView
- android:id="@+id/receivedMethodType"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="None"
- android:textSize="15sp"
- android:textStyle="bold" />
- </LinearLayout>
-
- <Space
- android:layout_width="match_parent"
- android:layout_height="10dp" />
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="5dp"
- android:background="#111111"
- android:orientation="vertical" >
- </LinearLayout>
-
- <Space
- android:layout_width="match_parent"
- android:layout_height="5dp" />
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:paddingTop="0dp" >
-
- <Button
- android:id="@+id/btnLogClear"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="CLEAR LOG"
- android:textSize="18sp" />
-
- <ScrollView
- android:id="@+id/sclLog"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <TextView
- android:id="@+id/txtLog"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_alignParentBottom="true"
- android:layout_alignParentLeft="true"
- android:textSize="15sp" />
- </ScrollView>
- </LinearLayout>
-
-</LinearLayout>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="app_name">SampleProvider</string>
- <string name="start">Start</string>
- <string name="stop">Stop</string>
- <string name="received">Received</string>
- <string name="current_log">Current Log</string>
- <string name="none">None</string>
- <string name="quit">Quit</string>
-</resources>
+++ /dev/null
-/*
- *******************************************************************
- *
- * Copyright 2015 Intel Corporation.
- *
- *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- *
- * 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.sample.provider;
-
-public interface IMessageLogger {
- public void logMessage(String 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.sample.provider;
-
-import org.iotivity.base.ModeType;
-import org.iotivity.base.OcException;
-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.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.support.v4.content.LocalBroadcastManager;
-import android.util.Log;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.ScrollView;
-import android.widget.TextView;
-
-public class SampleProvider extends Activity implements OnClickListener,
- IMessageLogger {
- private final static String TAG = "NMProvider : SampleProvider";
- private TextView mLogTextView;
- private TextView mTempValue;
- private TextView mHumValue;
- private TemperatureResource mySensor;
- private boolean isExecutePresence;
- private ScrollView sv_sclLog;
- private MessageReceiver mMessageReceiver = new MessageReceiver();
- private Handler mHandler;
- private static String message;
- private static SampleProvider sampleProviderObj;
- private String temp;
- private String hum;
-
- /*
- * To initialize UI Function Setting To execute initOICStack for running
- * find resource
- */
- @Override
- public void onCreate(Bundle savedInstanceState) {
-
- sampleProviderObj = this;
- super.onCreate(savedInstanceState);
- setContentView(R.layout.sampleprovider_layout);
- registerReceiver(mMessageReceiver, new IntentFilter(
- "com.example.sample.provider.SampleProvider"));
-
- mLogTextView = (TextView) findViewById(R.id.txtLog);
- mTempValue = (TextView) findViewById(R.id.temperatureValue);
- mHumValue = (TextView) findViewById(R.id.humidityValue);
-
- sv_sclLog = (ScrollView) findViewById(R.id.sclLog);
- sv_sclLog.fullScroll(View.FOCUS_DOWN);
- findViewById(R.id.btnTemperatureUP).setOnClickListener(this);
- findViewById(R.id.btnTemperatureDown).setOnClickListener(this);
- findViewById(R.id.btnHumidityUP).setOnClickListener(this);
- findViewById(R.id.btnHumidityDown).setOnClickListener(this);
- findViewById(R.id.btnLogClear).setOnClickListener(this);
-
- isExecutePresence = false;
- mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case 0:
- String[] tempHum = message.split(":");
- mTempValue.setText(tempHum[0]);
- mHumValue.setText(tempHum[1]);
- }
- }
- };
- setmHandler(mHandler);
- }
-
- private void initOICStack() {
- // create platform config
- PlatformConfig cfg = new PlatformConfig(this, ServiceType.IN_PROC,
- ModeType.SERVER, "0.0.0.0", // bind to all available interfaces
- 0, QualityOfService.LOW);
-
- OcPlatform.Configure(cfg);
-
- try {
- OcPlatform.startPresence(30);
- isExecutePresence = true;
- } catch (OcException e) {
- e.printStackTrace();
- }
-
- mySensor = new TemperatureResource(this);
- // create and register a resource
- mySensor.createResource();
- }
-
- /*
- * To execute initOICStack for running find resource
- */
- @Override
- protected void onStart() {
- super.onStart();
- initOICStack();
-
- }
-
- /*
- * To execute initOICStack for running find resource
- */
- @Override
- protected void onRestart() {
- super.onRestart();
- initOICStack();
-
- }
-
- /*
- * To terminate presence process and unregister messageHandler(to get
- * message from JNI Function)
- */
- @Override
- protected void onDestroy() {
- super.onDestroy();
-
- try {
- mySensor.destroyResource();
-
- if (isExecutePresence == true) {
- OcPlatform.stopPresence();
- isExecutePresence = false;
- }
- } catch (OcException e) {
- e.printStackTrace();
- }
- LocalBroadcastManager.getInstance(this).unregisterReceiver(
- mMessageReceiver);
- }
-
- public class MessageReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- final String message = intent
- .getStringExtra(StringConstants.MESSAGE);
- logMessage(message);
-
- }
- }
-
- public void logMessage(final String text) {
- runOnUiThread(new Runnable() {
- public void run() {
- final Message msg = new Message();
- msg.obj = text;
- mLogTextView.append("\n");
- mLogTextView.append(text);
- }
- });
- Log.i(TAG, text);
- }
-
- /*
- * To terminate presence process and unregister messagehandler(to get
- * message from JNI Function)
- */
- @Override
- protected void onStop() {
- super.onStop();
- try {
- mySensor.destroyResource();
-
- if (isExecutePresence == true) {
- OcPlatform.stopPresence();
- isExecutePresence = false;
- }
-
- } catch (OcException e) {
-
- e.printStackTrace();
- }
- LocalBroadcastManager.getInstance(this).unregisterReceiver(
- mMessageReceiver);
- }
-
- @Override
- public void onClick(View v) {
- int getId = v.getId();
-
- switch (getId) {
- case R.id.btnTemperatureUP:
- logMessage(TAG + "Click temerature up btn");
- mySensor.mtemp++;
- mySensor.notifyObserver();
- break;
- case R.id.btnTemperatureDown:
- logMessage(TAG + "Click temerature down btn");
- mySensor.mtemp--;
- mySensor.notifyObserver();
- break;
- case R.id.btnHumidityUP:
- logMessage(TAG + "Click Humidity up btn");
- mySensor.mhumidity++;
- mySensor.notifyObserver();
- break;
- case R.id.btnHumidityDown:
- logMessage(TAG + "Click Humidity down btn");
- mySensor.mhumidity--;
- mySensor.notifyObserver();
- break;
- case R.id.btnLogClear:
- mLogTextView.setText("");
- Log.i(TAG, "Log message cleared");
- break;
- }
-
- mTempValue.setText(String.valueOf(mySensor.getTemp()));
- mHumValue.setText(String.valueOf(mySensor.getHumidity()));
-
- }
-
- /*
- * To handle event about back button
- */
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK) {
- try {
- mySensor.destroyResource();
-
- if (isExecutePresence == true) {
- OcPlatform.stopPresence();
- isExecutePresence = false;
- }
- } catch (OcException e) {
-
- e.printStackTrace();
- }
- LocalBroadcastManager.getInstance(this).unregisterReceiver(
- mMessageReceiver);
- }
- return super.onKeyDown(keyCode, event);
- }
-
- public Handler getmHandler() {
- return mHandler;
- }
-
- public void setmHandler(Handler mHandler) {
- this.mHandler = mHandler;
- }
-
- public static SampleProvider getSampleProviderObject() {
- return sampleProviderObj;
- }
-
- public static void setmessage(String msg) {
- message = msg;
- }
-}
\ No newline at end of file
+++ /dev/null
-package com.example.sample.provider;
-
-import org.iotivity.base.OcPlatform;
-
-public class StringConstants {
- public static final String RESOURCE_URI = "/a/TempHumSensor/hosting";
- public static final String RESOURCE_TYPENAME = "oic.r.resourcehosting";
- public static final String RESOURCE_INTERFACE = OcPlatform.DEFAULT_INTERFACE; // resource interface
- public static final String HUMIDITY = "humidity";
- public static final String TEMPERATURE = "temperature";
- public static final String MESSAGE = "message";
- public static final int ERROR_CODE = 200;
-
-}
\ No newline at end of file
+++ /dev/null
-package com.example.sample.provider;
-
-import java.util.EnumSet;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.iotivity.base.EntityHandlerResult;
-import org.iotivity.base.ObservationInfo;
-import org.iotivity.base.OcException;
-import org.iotivity.base.OcPlatform;
-import org.iotivity.base.OcRepresentation;
-import org.iotivity.base.OcResourceHandle;
-import org.iotivity.base.OcResourceRequest;
-import org.iotivity.base.OcResourceResponse;
-import org.iotivity.base.RequestHandlerFlag;
-import org.iotivity.base.RequestType;
-import org.iotivity.base.ResourceProperty;
-
-import android.content.Context;
-import android.content.Intent;
-import android.os.Message;
-import android.util.Log;
-
-public class TemperatureResource implements IMessageLogger {
- private Context mContext;
- public int mtemp;
- public int mhumidity;
- private OcRepresentation mTempRep;
- private OcResourceHandle mResourceHandle;
- private List<Byte> mObservationIds;
-
- private static String TAG = "NMProvider : TemperatureResource";
-
- TemperatureResource(Context context) {
- mContext = context;
- mtemp = 0;
- mhumidity = 0;
- mResourceHandle = null;
- mObservationIds = new LinkedList<Byte>();
- mTempRep = new OcRepresentation();
- mTempRep.setValueInt(StringConstants.TEMPERATURE, mtemp);
- mTempRep.setValueInt(StringConstants.HUMIDITY, mhumidity);
- }
-
- // accessor methods
- protected int getTemp() {
- return mtemp;
- }
-
- protected void setTemp(int temp) {
- mtemp = temp;
- }
-
- protected int getHumidity() {
- return mhumidity;
- }
-
- protected void setHumidity(int humidity) {
- mhumidity = humidity;
- }
-
- protected OcResourceHandle getHandle() {
- return mResourceHandle;
- }
-
- protected OcResourceHandle destroyResource() {
- if (mResourceHandle != null) {
- try {
- OcPlatform.unregisterResource(mResourceHandle);
- } catch (OcException e) {
- e.printStackTrace();
- }
- mResourceHandle = null;
- }
- return null;
- }
-
- protected OcResourceHandle createResource() {
-
- OcPlatform.EntityHandler eh = new OcPlatform.EntityHandler() {
- @Override
- public EntityHandlerResult handleEntity(
- OcResourceRequest ocResourceRequest) {
- // this is where the main logic of simpleserver is handled as
- // different requests (GET, PUT, POST, OBSERVE, DELETE) are
- // handled
- return entityHandler(ocResourceRequest);
- }
- };
-
- try {
- Log.e(TAG, "before registerResource!");
- mResourceHandle = OcPlatform.registerResource(
- StringConstants.RESOURCE_URI,
- StringConstants.RESOURCE_TYPENAME,
- StringConstants.RESOURCE_INTERFACE, eh, EnumSet.of(
- ResourceProperty.DISCOVERABLE,
- ResourceProperty.OBSERVABLE));
- Log.e(TAG, "after regiterResource");
- } catch (OcException e) {
- Log.e(TAG, "go exception");
- logMessage(TAG + "RegisterResource error. " + e.getMessage());
- Log.e(TAG, "RegisterResource error. " + e.getMessage());
- }
-
- // logMessage(TAG + "Successfully registered resource");
- return mResourceHandle;
- }
-
- private void put(OcRepresentation rep) {
- mtemp = rep.getValueInt(StringConstants.TEMPERATURE);
- mhumidity = rep.getValueInt(StringConstants.HUMIDITY);
- logMessage(TAG + "PUT Request" + "temperature : " + mtemp
- + "humidity : " + mhumidity);
- notifyObserver();
- // " Power: " + mPower);
- String message = mtemp + ":" + mhumidity;
- Message msg = Message.obtain();
- msg.what = 0;
- SampleProvider mainActivityObj = SampleProvider
- .getSampleProviderObject();
- SampleProvider.setmessage(message);
- mainActivityObj.getmHandler().sendMessage(msg);
-
- }
-
- protected OcRepresentation get() {
- mTempRep.setValueInt(StringConstants.TEMPERATURE, mtemp);
- mTempRep.setValueInt(StringConstants.HUMIDITY, mhumidity);
- return mTempRep;
- }
-
- private EntityHandlerResult entityHandler(OcResourceRequest request) {
- EntityHandlerResult result = EntityHandlerResult.ERROR;
- if (null != request) {
- RequestType requestType = request.getRequestType();
- EnumSet<RequestHandlerFlag> requestFlag = request
- .getRequestHandlerFlagSet();
-
- if (requestFlag.contains(RequestHandlerFlag.INIT)) {
- logMessage(TAG + "Init");
- }
-
- if (requestFlag.contains(RequestHandlerFlag.REQUEST)) {
- try {
- logMessage(TAG + requestType + "Request");
- OcResourceResponse ocResourceResponse = new OcResourceResponse();
- ocResourceResponse.setRequestHandle(request
- .getRequestHandle());
- ocResourceResponse.setResourceHandle(request
- .getResourceHandle());
-
- switch (requestType) {
- // handle GET request
- case GET:
- logMessage("GET");
- ocResourceResponse
- .setResponseResult(EntityHandlerResult.OK);
- ocResourceResponse.setResourceRepresentation(get());
- OcPlatform.sendResponse(ocResourceResponse);
- break;
- // handle PUT request
- case PUT:
- logMessage(TAG + "PUT");
- OcRepresentation rep = request
- .getResourceRepresentation();
- put(rep);
- ocResourceResponse
- .setResponseResult(EntityHandlerResult.OK);
- ocResourceResponse.setResourceRepresentation(get());
- OcPlatform.sendResponse(ocResourceResponse);
- break;
- // handle POST request
- case POST:
- break;
- // handle DELETE request
- case DELETE:
- logMessage(TAG + "DELETE");
- OcPlatform.unregisterResource(getHandle());
- break;
-
- }
-
- result = EntityHandlerResult.OK;
- } catch (Exception e) {
- logMessage(TAG + "Error in Request " + e.getMessage());
- Log.e(TAG, e.getMessage());
- }
- }
- // handle OBSERVER request
- if (requestFlag.contains(RequestHandlerFlag.OBSERVER)) {
- logMessage(TAG + "OBSERVER");
- ObservationInfo observationInfo = request.getObservationInfo();
- switch (observationInfo.getObserveAction()) {
- case REGISTER:
- mObservationIds.add(observationInfo
- .getOcObservationId());
-
- break;
- case UNREGISTER:
- mObservationIds.remove(observationInfo
- .getOcObservationId());
- break;
- }
-
- result = EntityHandlerResult.OK;
- }
- }
- return result;
- }
-
- public void logMessage(String msg) {
- logMsg(msg);
- Log.i(TAG, msg);
- }
-
- public void logMsg(final String text) {
- Intent intent = new Intent("com.example.sample.provider.SampleProvider");
- intent.putExtra(StringConstants.MESSAGE, text);
- mContext.sendBroadcast(intent);
- }
-
- public void notifyObserver() {
- try {
- // if observationList is not empty, call notifyListOfObservers
- if (mObservationIds.size() > 0) {
- OcResourceResponse ocResourceResponse = new OcResourceResponse();
- ocResourceResponse.setResponseResult(EntityHandlerResult.OK);
- OcRepresentation r = get();
- ocResourceResponse.setResourceRepresentation(r,
- OcPlatform.DEFAULT_INTERFACE);
- OcPlatform.notifyListOfObservers(getHandle(), mObservationIds,
- ocResourceResponse);
- } else {
- // notify all observers if mObservationList is empty
- OcPlatform.notifyAllObservers(getHandle());
- }
- } catch (OcException e) {
- Log.e(TAG, e.getMessage());
- }
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.resourcehostingsampleapp"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk
- android:minSdkVersion="8"
- android:targetSdkVersion="19" />
-
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
- <uses-permission android:name="android.permission.READ_PHONE_STATE" />
- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
- <uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.INTERNET_ACCESS" />
- <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
- <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
- <uses-permission android:name="android.permission.GET_TASKS"/>
- <uses-permission android:name="com.samsung.wmanager.ENABLE_NOTIFICATION"/>
- <uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY"/>
-
- <application
- android:allowBackup="true"
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:theme="@style/AppTheme" >
- <activity
- android:name="com.example.resourcehostingsampleapp.ResourceHostingSampleApp"
- 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-19
-android.library.reference.1=../../../android/resource_hosting
+++ /dev/null
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical"
- android:paddingBottom="5dp"
- android:paddingLeft="10dp"
- android:paddingRight="10dp"
- android:paddingTop="10dp" >
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <Button
- android:id="@+id/btnStartHosting"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="startHosting"
- android:textSize="18sp" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <Button
- android:id="@+id/btnStopHosting"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="StopHosting"
- android:textSize="18sp" />
- </LinearLayout>
-
-
- <Space
- android:layout_width="match_parent"
- android:layout_height="10dp" />
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="5dp"
- android:orientation="vertical"
- android:background="#111111" >
- </LinearLayout>
-
- <Space
- android:layout_width="match_parent"
- android:layout_height="5dp" />
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:paddingTop="0dp" >
-
- <Button
- android:id="@+id/btLogClear"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="CLEAR LOG"
- android:textSize="18sp" />
-
- <ScrollView
- android:id="@+id/sclLog"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <TextView
- android:id="@+id/txtLog"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_alignParentBottom="true"
- android:layout_alignParentLeft="true"
- android:textSize="15sp" />
-
- </ScrollView>
-
- </LinearLayout>
-
-</LinearLayout>
\ No newline at end of file
+++ /dev/null
-<resources>
-
- <!--
- Base application theme for API 11+. This theme completely replaces
- AppBaseTheme from res/values/styles.xml on API 11+ devices.
- -->
- <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
- <!-- API 11 theme customizations can go here. -->
- </style>
-
-</resources>
+++ /dev/null
-<resources>
-
- <!--
- Base application theme for API 14+. This theme completely replaces
- AppBaseTheme from BOTH res/values/styles.xml and
- res/values-v11/styles.xml on API 14+ devices.
- -->
- <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
- <!-- API 14 theme customizations can go here. -->
- </style>
-
-</resources>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
- <string name="app_name">ResourceHostingSampleApp</string>
- <string name="hello_world">Hello world!</string>
-
-</resources>
+++ /dev/null
-<resources>
-
- <!--
- Base application theme, dependent on API level. This theme is replaced
- by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
- -->
- <style name="AppBaseTheme" parent="android:Theme.Light">
- <!--
- Theme customizations available in newer API levels can go in
- res/values-vXX/styles.xml, while customizations related to
- backward-compatibility can go here.
- -->
- </style>
-
- <!-- Application theme. -->
- <style name="AppTheme" parent="AppBaseTheme">
- <!-- All customizations that are NOT specific to a particular API-level can go here. -->
- </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.example.resourcehostingsampleapp;
-
-import java.lang.reflect.Method;
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.util.Enumeration;
-
-import org.iotivity.ResourceHosting.ResourceHosting;
-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.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.TextView;
-import android.widget.Toast;
-
-/**
- * To execute resource hosting function for android sample application .
- *
- * @author Copyright 2015 Samsung Electronics All Rights Reserved.
- * @see className class : ResourceHosting</br>
- *
- */
-
-public class ResourceHostingSampleApp extends Activity implements
- OnClickListener {
-
- private String TAG = "ResourceHosting";
- private String mIpAddress;
- private TextView mLogTextView;
- private String mLog = "";
- private ResourceHosting resourceHosting;
-
- /**
- * To initialize UI Function Setting.
- *
- * @see Class class :
- * com_example_resourcehostingsampleapp_ResourceHosting</br>
- * @see Method method : onCreate</br>
- */
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- mLogTextView = (TextView) findViewById(R.id.txtLog);
- findViewById(R.id.btnStartHosting).setOnClickListener(this);
- findViewById(R.id.btnStopHosting).setOnClickListener(this);
- findViewById(R.id.btLogClear).setOnClickListener(this);
-
- PlatformConfig platformConfigObj;
- resourceHosting = new ResourceHosting();
- platformConfigObj = new PlatformConfig(this, ServiceType.IN_PROC,
- ModeType.CLIENT_SERVER, "0.0.0.0", 0, QualityOfService.LOW);
-
- Log.i(TAG, "Before Calling Configure of ocPlatform");
- OcPlatform.Configure(platformConfigObj);
- Log.i(TAG, "Configuration done Successfully");
- }
-
- /**
- * To execute initOICStack for running Resource hosting.
- *
- * @see Class class :
- * com_example_resourcehostingsampleapp_ResourceHosting</br>
- * @see Method method : onStart</br>
- */
- @Override
- protected void onStart() {
- super.onStart();
- initOICStack();
- }
-
- /**
- * To terminate Resource hosting.
- *
- * @see Class class :
- * com_example_resourcehostingsampleapp_ResourceHosting</br>
- * @see Method method : onStop</br>
- */
- @Override
- protected void onStop() {
- super.onStop();
- int result;
- result = resourceHosting.ResourceHostingTerminate();
- Log.d(TAG, "ResourceHostingTerminate : " + result);
- }
-
- protected void onResume() {
- super.onResume();
- }
-
- /**
- * To execute initOICStack for running Resource hosting.
- *
- * @see Class class :
- * com_example_resourcehostingsampleapp_ResourceHosting</br>
- * @see Method method : onRestart</br>
- */
- @Override
- protected void onRestart() {
- super.onRestart();
- initOICStack();
- }
-
- /**
- * @see Class class :
- * com_example_resourcehostingsampleapp_ResourceHosting</br>
- * @see Method method : onDestroy</br>
- */
- protected void onDestroy() {
- super.onDestroy();
- }
-
- /**
- * get IpAddress and execute resourceHostingInit() method.
- *
- * @see Class class :
- * com_example_resourcehostingsampleapp_ResourceHosting</br>
- * @see Method method : initOICStack</br>
- */
- private void initOICStack() {
- try {
- mIpAddress = getIpAddress();
- int result = 0;
- result = resourceHosting.ResourceHostingInit(mIpAddress);
- Log.d(TAG, "ResourceHostingInit : " + result);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @see Class class :
- * com_example_resourcehostingsampleapp_ResourceHosting</br>
- * @see Method method : getIpAddress</br>
- */
- private String getIpAddress() {
- try {
- for (Enumeration<NetworkInterface> en = NetworkInterface
- .getNetworkInterfaces(); en.hasMoreElements();) {
- NetworkInterface intf = (NetworkInterface) en.nextElement();
- for (Enumeration<InetAddress> enumIpAddr = intf
- .getInetAddresses(); enumIpAddr.hasMoreElements();) {
- InetAddress inetAddress = (InetAddress) enumIpAddr
- .nextElement();
- if (!inetAddress.isLoopbackAddress()) {
- if (inetAddress instanceof Inet4Address)
- return inetAddress.getHostAddress().toString();
- }
- }
- }
- } catch (SocketException e) {
- e.printStackTrace();
- }
- return null;
- }
-
- /**
- * @see Class class :
- * com_example_resourcehostingsampleapp_ResourceHosting</br>
- * @see Method method : onClick</br>
- * @param v
- * view to choice
- */
- public void onClick(View v) {
- int getId = v.getId();
-
- switch (getId) {
- case R.id.btnStartHosting:
- try {
- int result;
- result = resourceHosting.OICCoordinatorStart();
- Log.d(TAG, "OICCoordinatorStart : " + result);
- } catch (Exception e) {
- Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT)
- .show();
- }
- break;
- case R.id.btnStopHosting:
- int result;
- result = resourceHosting.OICCoordinatorStop();
- Log.d(TAG, "OICCoordinatorStop : " + result);
- break;
- case R.id.btLogClear:
- default:
- break;
- }
- }
-}
+++ /dev/null
-##
-# NotificationManager build script
-##
-
-Import('env')
-
-lib_env = env.Clone()
-SConscript('#service/third_party_libs.scons', 'lib_env')
-resourcehosting_env = lib_env.Clone()
-rd_mode = lib_env.get('RD_MODE')
-
-######################################################################
-# Build flags
-######################################################################
-resourcehosting_env.AppendUnique(CPPPATH = ['../../include'])
-resourcehosting_env.AppendUnique(CPPPATH = ['../../../../extlibs/cjson'])
-resourcehosting_env.AppendUnique(CPPPATH = ['../../../../resource/csdk/connectivity/api'])
-resourcehosting_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
-resourcehosting_sample_env = resourcehosting_env.Clone()
-resourcehosting_env.AppendUnique(LIBS = [
- 'coap',
- 'connectivity_abstraction',
- 'oc_logger',
- 'octbstack',
- 'oc',
- 'resource_hosting',
- 'rcs_client',
- 'rcs_server',
- 'rcs_common',
- 'pthread'
- ])
-resourcehosting_sample_env.AppendUnique(LIBS = [
- 'connectivity_abstraction',
- 'coap',
- 'oc_logger',
- 'octbstack',
- 'oc',
- 'pthread'
- ])
-
-if env.get('SECURED') == '1':
- resourcehosting_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509', 'mbedcrypto'])
-
-if 'rt' in resourcehosting_env.get('LIBS'):
- resourcehosting_env.Append(LIBS = ['rt'])
-if 'rt' in resourcehosting_sample_env.get('LIBS'):
- resourcehosting_sample_env.Append(LIBS = ['rt'])
-
-if 'CLIENT' in rd_mode or 'SERVER' in rd_mode:
- resourcehosting_sample_env.AppendUnique(LIBS = ['resource_directory'])
- resourcehosting_env.AppendUnique(LIBS = ['resource_directory'])
-
-####################################################################
-# Source files and Targets
-######################################################################
-sampleprovider = resourcehosting_sample_env.Program('sampleprovider', 'sampleProvider/SampleProvider.cpp')
-sampleconsumer = resourcehosting_sample_env.Program('sampleconsumer', 'sampleConsumer/SampleConsumer.cpp')
-
-sampleresourcehosting = resourcehosting_env.Program('sampleresourcehosting', 'sampleResourceHosting/main.cpp')
-
-#resourcehosting_sample_env.InstallTarget(sampleprovider, 'sampleprovider')
-#resourcehosting_sample_env.InstallTarget(sampleconsumer, 'sampleconsumer')
-#resourcehosting_env.InstallTarget(sampleresourcehosting, 'sampleresourcehosting')
+++ /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 SampleConsumer.cpp
- * @brief Defines the entry point for the sample consumer application about Resource Hosting.
- */
-
-#include <string>
-#include <cstdlib>
-#include <pthread.h>
-#include "OCPlatform.h"
-#include "OCApi.h"
-#include <mutex>
-
-using namespace OC;
-
-const int SUCCESS_RESPONSE = OC_STACK_OK;
-
-#define OC_WELL_KNOWN_COORDINATING_QUERY "/oic/res?rt=oic.r.resourcehosting"
-
-#define OBSERVE 1
-#define GET 2
-#define POST 3
-#define DELETE 4
-
-std::shared_ptr< OCResource > g_curResource;
-std::shared_ptr< OCResource > g_curObserveResource;
-std::mutex curResourceLock;
-
-OCStackResult nmfindResource(const std::string &host , const std::string &resourceName);
-void onObserve(const HeaderOptions &headerOption , const OCRepresentation &rep , const int &eCode,
- const int &sequenceNumber);
-
-void onPost(const HeaderOptions &headerOption, const OCRepresentation &rep, const int eCode);
-void onGet(const HeaderOptions &headerOption , const OCRepresentation &rep , const int eCode);
-void onDelete(const HeaderOptions &headerOption , const int eCode);
-
-
-void findResourceCandidate()
-{
- try
- {
- nmfindResource("" , OC_WELL_KNOWN_COORDINATING_QUERY);
- std::cout << "Finding Resource... " << std::endl;
-
- }
- catch (OCException &e)
- {
- std::cout << "Exception for find resource : " << e.reason() << std::endl;
- }
-}
-
-void startObserve(std::shared_ptr< OCResource > resource)
-{
- if (resource == NULL)
- {
- std::cout << "startObserve() error : resource == null" << std::endl;
- return;
- }
-
- if(g_curObserveResource == NULL)
- {
- g_curObserveResource = resource;
- std::cout << "request for new observation" << std::endl;
- }
- else if(g_curObserveResource == g_curResource)
- {
- std::cout << "already registered same observation" << std::endl;
- return;
- }
- else
- {
- std::cout << "change observed resource" << std::endl;
- g_curObserveResource->cancelObserve();
- g_curObserveResource = resource;
- }
-
- QueryParamsMap test;
- if (OC_STACK_OK != resource->observe(ObserveType::Observe , test , &onObserve))
- {
- std::cout << "To Fail resource observe() process" << std::endl;
- }
-}
-
-void startGet(std::shared_ptr< OCResource > resource)
-{
-
- if (resource == NULL)
- {
- std::cout << "startObserve() error : resource == null" << std::endl;
- return;
- }
-
- QueryParamsMap test;
- std::cout << "URI :" << resource->uri() << std::endl;
- if (OC_STACK_OK != resource->get(test, &onGet))
- {
- std::cout << "To Fail resource get() process" << std::endl;
- }
-}
-
-void startPost(std::shared_ptr< OCResource > resource)
-{
- if (resource == NULL)
- {
- std::cout << "startObserve() error : resource == null" << std::endl;
- return;
- }
-
- g_curResource = resource;
- OCRepresentation rep;
- rep.setValue("temperature", 25);
- rep.setValue("humidity", 10);
-
- QueryParamsMap test;
- if (OC_STACK_OK != resource->post(rep, test, &onPost))
- {
- std::cout << "To Fail resource post() process" << std::endl;
- }
-}
-
-void startDelete(std::shared_ptr< OCResource > resource)
-{
- if (resource == NULL)
- {
- std::cout << "startObserve() error : resource == null" << std::endl;
- return;
- }
-
- g_curResource = resource;
- if (OC_STACK_OK != resource->deleteResource(&onDelete))
- {
- std::cout << "To Fail resource delete() process" << std::endl;
- }
-}
-
-int observe_count()
-{
- static int oc = 0;
- return ++oc;
-}
-
-void onObserve(const HeaderOptions &/*headerOption*/, const OCRepresentation &rep , const int &eCode,
- const int &sequenceNumber)
-{
- std::cout << "onObserve" << std::endl;
-
- if (eCode <= OC_STACK_OK)
- {
- std::cout << std::endl;
- std::cout << "========================================================" << std::endl;
- std::cout << "Receive OBSERVE RESULT:" << std::endl;
- std::cout << "\tUri: " << rep.getUri() << std::endl;
- std::cout << "\tSequenceNumber: " << sequenceNumber << std::endl;
- std::cout << "\tTemperature : " << rep.getValue<int>("temperature") << std::endl;
- std::cout << "\tHumidity : " << rep.getValue<int>("humidity") << std::endl;
-
- if (observe_count() > 30)
- {
- std::cout << "Cancelling Observe..." << std::endl;
- OCStackResult result = g_curResource->cancelObserve();
-
- std::cout << "Cancel result: " << result << std::endl;
- sleep(10);
- std::cout << "DONE" << std::endl;
- std::exit(0);
- }
- }
- else
- {
- std::cout << "onObserve Response error: " << eCode << std::endl;
- std::exit(-1);
- }
-}
-
-void foundResource(std::shared_ptr< OCResource > resource)
-{
- std::string resourceURI;
- std::string hostAddress;
-
- std::cout << "foundResource" << std::endl;
-
- try
- {
- std::cout << "mutex lock passed" << std::endl;
- if (resource)
- {
- std::cout << resource->uri() << std::endl;
- if (resource->uri() == "/a/TempHumSensor")
- {
- std::cout << std::endl;
- std::cout << "========================================================" << std::endl;
- std::cout << "DISCOVERED Resource(Consumer):" << std::endl;
-
- resourceURI = resource->uri();
- std::cout << "\tURI of the resource: " << resourceURI << std::endl;
-
- hostAddress = resource->host();
- std::cout << "\tHost address of the resource: " << hostAddress << std::endl;
-
- g_curResource = resource;
- }
- }
- else
- {
- std::cout << "Resource is invalid" << std::endl;
- }
-
- }
- catch (std::exception &e)
- {
- std::cout << "Exception: " << e.what() << " in foundResource" << std::endl;
- }
-}
-
-OCStackResult nmfindResource(const std::string &host , const std::string &resourceName)
-{
- return OCPlatform::findResource(host , resourceName , CT_DEFAULT, &foundResource);
-}
-
-void getRepresentation(std::shared_ptr< OCResource > resource)
-{
- if (resource)
- {
- std::cout << "Getting Light Representation..." << std::endl;
- }
-}
-
-void onPost(const HeaderOptions &/*headerOption*/, const OCRepresentation &rep, const int eCode)
-{
- try
- {
- if (eCode == OC_STACK_OK)
- {
- std::cout << "POST request was successful" << std::endl;
- int humidity;
- int temperature;
- rep.getValue("temperature", temperature);
- rep.getValue("humidity", humidity);
-
-
- std::cout << "\t temperature: " << temperature << std::endl;
- std::cout << "\t humidity: " << humidity << std::endl;
- }
- else
- {
- std::cout << "onPost Response error: " << eCode << std::endl;
- std::exit(-1);
- }
- }
- catch (std::exception &e)
- {
- std::cout << "Exception: " << e.what() << " in onPost" << std::endl;
- }
-}
-
-//callback hadnler on DELETE request
-void onDelete(const HeaderOptions &/*headerOption*/, const int eCode)
-{
- try
- {
- if (eCode == OC_STACK_RESOURCE_DELETED)
- {
- std::cout << "DELETE request was successful" << std::endl;
- }
- else
- {
- std::cout << "onDelete Response error: " << eCode << std::endl;
- std::exit(-1);
- }
- }
- catch (std::exception &e)
- {
- std::cout << "Exception: " << e.what() << " in onDelete" << std::endl;
- }
-}
-
-// callback handler on GET request
-void onGet(const HeaderOptions &/*headerOption*/, const OCRepresentation &rep , const int eCode)
-{
- std::cout << "GET request was successful1" << std::endl;
- if (eCode == SUCCESS_RESPONSE)
- {
- std::cout << "GET request was successful" << std::endl;
- std::cout << "Resource URI: " << rep.getUri().c_str() << std::endl;
- std::cout << "\tTemperature : " << rep.getValue<int>("temperature") << std::endl;
- std::cout << "\tHumidity : " << rep.getValue<int>("humidity") << std::endl;
- }
- else
- {
- std::cout << "onGET Response error: " << eCode << std::endl;
- std::exit(-1);
- }
-}
-
-void getLightRepresentation(std::shared_ptr< OCResource > resource)
-{
- if (resource)
- {
- std::cout << "Getting Light Representation..." << std::endl;
-
- QueryParamsMap test;
- resource->get(test , &onGet);
- }
-}
-
-void PrintUsage()
-{
- std::cout << std::endl;
- std::cout << "Usage : simpleclient <ObserveType>" << std::endl;
- std::cout << " ObserveType : 1 - Observe" << std::endl;
- std::cout << " ObserveType : 2 - ObserveAll" << std::endl;
-}
-
-void PRINT()
-{
- std::cout << std::endl;
- std::cout << "********************************************" << std::endl;
- std::cout << "* method Type : 1 - Observe *" << std::endl;
- std::cout << "* method Type : 2 - Get *" << std::endl;
- std::cout << "* method Type : 3 - Post *" << std::endl;
- std::cout << "********************************************" << std::endl;
- std::cout << std::endl;
-}
-
-int main()
-{
-
- int in;
- PlatformConfig cfg;
-
- OCPlatform::Configure(cfg);
-
- std::cout << "Created Platform..." << std::endl;
-
- g_curResource = NULL;
- g_curObserveResource = NULL;
-
- findResourceCandidate();
-
- while (1)
- {
- sleep(2);
- if(g_curResource == NULL)
- {
- continue;
- }
- PRINT();
-
- in = 0;
- std::cin >> in;
-
- if(std::cin.fail())
- {
- std::cin.clear();
- std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
- std::cout << "Invalid input type, please try again" << std::endl;
- continue;
- }
-
- try
- {
- switch ((int)in)
- {
- case OBSERVE:
- startObserve(g_curResource);
- break;
- case GET:
- startGet(g_curResource);
- break;
- case POST:
- startPost(g_curResource);
- break;
- default:
- std::cout << "Invalid input, please try again" << std::endl;
- break;
- }
- }
- catch(OCException & e)
- {
- std::cout<< "Caught OCException [Code: "<<e.code()<<" Reason: "<<e.reason()<<std::endl;
- }
- }
-
- return 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#include <functional>
-
-#include <pthread.h>
-#include <signal.h>
-
-#include "OCPlatform.h"
-#include "OCApi.h"
-#include "OCResourceResponse.h"
-
-#include <memory>
-
-using namespace OC;
-using namespace std;
-using namespace OC::OCPlatform;
-
-int g_Observation = 0;
-int gQuitFlag = 0;
-
-pthread_cond_t m_cond = PTHREAD_COND_INITIALIZER;
-pthread_mutex_t m_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-
-
-OCEntityHandlerResult entityHandler(std::shared_ptr< OCResourceRequest > request);
-
-class TempHumidResource
-{
- public:
-
- int m_temp;
- int m_humid;
- std::string m_uri;
- OCResourceHandle m_resourceHandle;
- ObservationIds m_interestedObservers;
- OCRepresentation m_Rep;
-
- public:
- TempHumidResource() :
- m_temp(0), m_humid(0), m_uri("/a/TempHumSensor"), m_resourceHandle(NULL)
- {
- }
-
- void createResource()
- {
- std::string resourceURI = "/a/TempHumSensor/hosting";
- std::string resourceTypeName = "oic.r.resourcehosting";
- std::string resourceInterface = DEFAULT_INTERFACE;
-
- m_uri = resourceURI;
-
- uint8_t resourceProperty = OC_DISCOVERABLE | OC_OBSERVABLE;
-
- OCStackResult result = OCPlatform::registerResource(m_resourceHandle , resourceURI ,
- resourceTypeName , resourceInterface , &entityHandler , resourceProperty);
-
- if (OC_STACK_OK != result)
- {
- cout << "Resource creation was unsuccessful\n";
- }
- }
-
- OCStackResult createResource1()
- {
- std::string resourceURI = "/a/NM/TempHumSensor1"; // URI of the resource
- std::string resourceTypeName =
- "oic.r.resourcehosting"; // resource type name.
- std::string resourceInterface = DEFAULT_INTERFACE; // resource interface.
-
- // OCResourceProperty is defined ocstack.h
- uint8_t resourceProperty = OC_DISCOVERABLE | OC_OBSERVABLE;
-
- OCResourceHandle resHandle;
-
- // This will internally create and register the resource.
- OCStackResult result = OCPlatform::registerResource(
- resHandle, resourceURI, resourceTypeName,
- resourceInterface, &entityHandler, resourceProperty);
-
- if (OC_STACK_OK != result)
- {
- cout << "Resource creation was unsuccessful\n";
- }
-
- return result;
- }
-
- OCResourceHandle getHandle()
- {
- return m_resourceHandle;
- }
-
- OCRepresentation post(OCRepresentation &rep)
- {
- static int first = 1;
- // for the first time it tries to create a resource
- if (first)
- {
- first = 0;
-
- if (OC_STACK_OK == createResource1())
- {
- OCRepresentation rep1;
- rep1.setValue("createduri", std::string("/a/light1"));
-
- return rep1;
- }
- }
-
- // from second time onwards it just puts
- put(rep);
- return get();
- }
-
- void put(OCRepresentation &rep)
- {
- try
- {
- if (rep.getValue("temperature", m_temp))
- {
- cout << "\t\t\t\t" << "temperature: " << m_temp << endl;
- }
- else
- {
- cout << "\t\t\t\t" << "temperature not found in the representation" << endl;
- }
-
- if (rep.getValue("humidity", m_humid))
- {
- cout << "\t\t\t\t" << "humidity: " << m_humid << endl;
- }
- else
- {
- cout << "\t\t\t\t" << "humidity not found in the representation" << endl;
- }
- }
- catch (exception &e)
- {
- cout << e.what() << endl;
- }
-
- }
-
- OCRepresentation get()
- {
- m_Rep.setValue("temperature", m_temp);
- m_Rep.setValue("humidity", m_humid);
- return m_Rep;
- }
- OCStackResult deleteDeviceResource()
- {
- OCStackResult result = OCPlatform::unregisterResource(m_resourceHandle);
- if (OC_STACK_OK != result)
- {
- throw std::runtime_error(
- std::string("Device Resource failed to unregister/delete") + std::to_string(result));
- }
- return result;
- }
-};
-
-TempHumidResource myResource;
-
-void *ChangeLightRepresentation(void */*param*/)
-{
- cout << "ChangeLigthRepresentation Enter\n";
- while (1)
- {
- cout << "pthread_cond_wait\n";
- pthread_cond_wait(&m_cond, &m_mutex);
- cout << "pthread_cond_start\n";
- if (g_Observation)
- {
-
- cout << endl;
- cout << "========================================================" << endl;
- cout << "HUMTepm updated to : " << myResource.m_temp << endl;
- cout << "Notifying observers with resource handle: " << myResource.getHandle() << endl;
-
- cout << endl;
- cout << "========================================================" << endl;
- cout << "Send data : \n";
- cout << "Attribute Name: Temp\tvalue: " << myResource.m_temp << endl;
- cout << "Attribute Name: Humid\tvalue: " << myResource.m_humid << endl;
-
- OCStackResult result = OCPlatform::notifyAllObservers(myResource.getHandle());
- cout << "Notify Success\n";
-
- if (OC_STACK_NO_OBSERVERS == result)
- {
- cout << "No More observers, stopping notifications" << endl;
- g_Observation = 0;
- }
- }
- cout << "ChangeLigthRepresentation Out\n";
-
- }
- return NULL;
-}
-
-OCEntityHandlerResult entityHandler(std::shared_ptr< OCResourceRequest > request)
-{
- cout << "Sample Provider entityHandler\n";
-
- OCEntityHandlerResult ehResult = OC_EH_ERROR;
- if (request)
- {
- cout << "flag : request\n";
- 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\trequestType : GET\n";
-
- pResponse->setResponseResult(OC_EH_OK);
- pResponse->setResourceRepresentation(myResource.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();
- myResource.put(rep);
-
- if (pResponse)
- {
- pResponse->setResourceRepresentation(myResource.get());
- }
- if (OC_STACK_OK == OCPlatform::sendResponse(pResponse))
- {
- ehResult = OC_EH_OK;
- }
- else
- {
- cout << "put request Error\n";
- }
- }
-
- else if (requestType == "POST")
- {
- cout << "\t\t\trequestType : POST\n";
- OCRepresentation rep = request->getResourceRepresentation();
- myResource.put(rep);
-
- if (pResponse)
- {
- pResponse->setResourceRepresentation(myResource.get());
- }
- if (OC_STACK_OK == OCPlatform::sendResponse(pResponse))
- {
- ehResult = OC_EH_OK;
- }
- else
- {
- cout << "post request Error\n";
- }
- }
-
- else if (requestType == "DELETE")
- {
- cout << "\t\trequestType : DELETE\n";
- cout << "DeviceResource Delete Request" << std::endl;
-
- if (myResource.deleteDeviceResource() == OC_STACK_OK)
- {
- cout << "\tSuccess DELETE\n";
- pResponse->setResponseResult(OC_EH_RESOURCE_DELETED);
- ehResult = OC_EH_OK;
- }
- else
- {
- pResponse->setResponseResult(OC_EH_ERROR);
- ehResult = OC_EH_ERROR;
- }
-
- OCPlatform::sendResponse(pResponse);
- }
- }
- if (requestFlag & RequestHandlerFlag::ObserverFlag)
- {
- pthread_t threadId;
-
- ObservationInfo observationInfo = request->getObservationInfo();
- if (ObserveAction::ObserveRegister == observationInfo.action)
- {
- myResource.m_interestedObservers.push_back(observationInfo.obsId);
- }
- else if (ObserveAction::ObserveUnregister == observationInfo.action)
- {
- myResource.m_interestedObservers.erase(std::remove(
- myResource.m_interestedObservers.begin(),
- myResource.m_interestedObservers.end(),
- observationInfo.obsId),
- myResource.m_interestedObservers.end());
- }
-
- cout << request->getResourceUri() << endl;
- cout << request->getResourceRepresentation().getUri() << endl;
-
- cout << "========================================================" << endl;
- cout << "Receive ObserverFlag : Start Observe\n";
- cout << "========================================================" << endl;
- g_Observation = 1;
-
- cout << "\t\trequestFlag : Observer\n";
- static int startedThread = 0;
- if (!startedThread)
- {
- cout << "\t\tpthrerad_create\n";
- pthread_create(&threadId , NULL , ChangeLightRepresentation , (void *) NULL);
- startedThread = 1;
- }
- ehResult = OC_EH_OK;
- }
- }
- else
- {
- std::cout << "Request invalid" << std::endl;
- }
-
- return ehResult;
-}
-
-void quitProcess()
-{
- unregisterResource(myResource.m_resourceHandle);
- stopPresence();
- exit(0);
-}
-
-void handleSigInt(int signum)
-{
- if (signum == SIGINT)
- {
- std::cout << " handleSigInt in" << std::endl;
- quitProcess();
- }
-}
-
-int main()
-{
- PlatformConfig cfg
- {
- OC::ServiceType::InProc,
- OC::ModeType::Server,
- "0.0.0.0",
- 0,
- OC::QualityOfService::LowQos
- };
-
- OCPlatform::Configure(cfg);
-
- int number = 0;
-
- try
- {
- startPresence(30);
-
- myResource.createResource();
-
- signal(SIGINT, handleSigInt);
- while (true)
- {
- bool end = false;
- cout << endl;
- cout << "========================================================" << endl;
- cout << "1. Temp is up" << endl;
- cout << "2. Temp is down" << endl;
- cout << "3. This Program will be ended." << endl;
- cout << "========================================================" << endl;
-
- cin >> number;
- if(std::cin.fail())
- {
- std::cin.clear();
- std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
- std::cout << "Invalid input type, please try again" << std::endl;
- continue;
- }
-
- switch (number)
- {
- case 1:
- {
- cout << "Temp is up!" << endl;
- myResource.m_temp += 10;
- pthread_cond_signal(&m_cond);
- cout << "ChangeLightRepresentation Done!" << endl;
- break;
- }
- case 2:
- {
- cout << "Temp is down!" << endl;
- myResource.m_temp -= 10;
- pthread_cond_signal(&m_cond);
- cout << "ChangeLightRepresentation Done!" << endl;
- break;
- }
- case 3:
- {
- cout << "Bye!" << endl;
- stopPresence();
- end = true;
- quitProcess();
- break;
- }
- default:
- {
- cout << "Invalid input. Please try again." << endl;
- break;
- }
- }
- if (end == true)
- {
- break;
- }
- }
- }
- catch (exception &e)
- {
- cout << "main exception : " << e.what() << endl;
- }
-
-
-}
+++ /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 <signal.h>
-#include <unistd.h>
-
-#include "Hosting.h"
-
-int g_quitFlag = 0;
-
-void handleSigInt(int signum);
-
-/*
-* This method is an entry point of Resource Hosting Manager.
-* This function should be run only on the device that it could be host device.
-*/
-int main()
-{
- printf("OCResourceHosting is starting...\n");
-
- if (OICStartCoordinate() != OC_STACK_OK)
- {
- printf("OICStartCoordinate fail\n");
- return 0;
- }
-
- printf("OCResourceHosting Started Successfully \n");
-
- signal(SIGINT, handleSigInt);
- while (!g_quitFlag)
- {
- sleep(2);
- }
-
- if (OICStopCoordinate() != OC_STACK_OK)
- {
- printf("OICStopCoordinate error\n");
- }
- else
- {
- printf("OICStopCoordinate success\n");
- }
-
- printf("Exiting occlient main loop...\n");
- return 0;
-
-}
-
-/*
-* This is a signal handling function for SIGINT(CTRL+C).
-* A Resource Coordinator handle the SIGINT signal for safe exit.
-*
-* @param[in] signal
-* signal number of caught signal.
-*/
-void handleSigInt(int signum)
-{
- if (signum == SIGINT)
- {
- g_quitFlag = 1;
- }
-}
+++ /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.53616310">
- <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.tizen.nativecore.config.sbi.gcc45.app.debug.53616310" 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="rhsampleapp" 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.53616310" name="Debug" parent="org.tizen.nativecore.config.sbi.gcc45.app.debug">
- <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.app.debug.53616310." name="/" resourcePath="">
- <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug.1603903371" 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.1811247058" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
- <builder arguments="--eval="SHELL=cmd" -r" autoBuildTarget="all" buildPath="${workspace_loc:/NMSampleApp}/Debug" enableAutoBuild="true" id="org.tizen.nativecore.target.sbi.gnu.builder.1744040274" 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.2000114756" 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.1193339560" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
- <option id="gnu.cpp.compiler.option.optimization.level.1925609872" 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.120324276" 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.1814902249" 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.1588081619" 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.1690699832" 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.1698435591" 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="../../../../../../extlibs/cjson"/>
- <listOptionValue builtIn="false" value="../../../../include"/>
- <listOptionValue builtIn="false" value="../../../../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""/>
- </option>
- <option id="sbi.gnu.cpp.compiler.option.frameworks.core.856851155" 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.31367874" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
- <listOptionValue builtIn="false" value="_DEBUG"/>
- </option>
- <option id="gnu.cpp.compiler.option.other.other.59986195" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -std=gnu++0x" valueType="string"/>
- <option id="sbi.gnu.cpp.compiler.option.misc.pic.core.515485991" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" value="true" valueType="boolean"/>
- <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.167437283" 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.2116336374" 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.10819828" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
- <option id="sbi.gnu.c.compiler.option.debugging.level.core.1243421357" 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.650844806" 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.513372299" 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.1836823633" 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.271406536" 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.330532772" 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.983787413" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
- <listOptionValue builtIn="false" value="_DEBUG"/>
- </option>
- <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1670474416" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
- </tool>
- <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.1173522371" 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.1477620595" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker">
- <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.1601334380" 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.973841668" 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.1032324584" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
- <listOptionValue builtIn="false" value="uuid"/>
- <listOptionValue builtIn="false" value="oc"/>
- <listOptionValue builtIn="false" value="octbstack"/>
- <listOptionValue builtIn="false" value="oc_logger"/>
- <listOptionValue builtIn="false" value="oc_logger_core"/>
- <listOptionValue builtIn="false" value="connectivity_abstraction"/>
- <listOptionValue builtIn="false" value="rcs_client"/>
- <listOptionValue builtIn="false" value="rcs_server"/>
- <listOptionValue builtIn="false" value="rcs_common"/>
- <listOptionValue builtIn="false" value="resource_hosting"/>
- </option>
- <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.361234161" 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.1357205409" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base">
- <inputType id="cdt.managedbuild.tool.gnu.assembler.input.61363116" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
- </tool>
- <tool id="org.tizen.nativecore.tool.fnmapgen.255372816" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/>
- <tool id="org.tizen.nativecore.tool.fnmapgen.cpp.1865899333" name="C++ FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen.cpp"/>
- <tool id="org.tizen.nativecore.tool.ast.333279395" name="C Static Analyzer" superClass="org.tizen.nativecore.tool.ast"/>
- <tool id="org.tizen.nativecore.tool.ast.cpp.75709762" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/>
- <tool id="org.tizen.nativecore.tool.sbi.po.compiler.1241676789" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/>
- <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.388758876" 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.1937068221">
- <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.tizen.nativecore.config.sbi.gcc45.app.release.1937068221" 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="rhsampleapp" 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.1937068221" name="Release" parent="org.tizen.nativecore.config.sbi.gcc45.app.release">
- <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.app.release.1937068221." name="/" resourcePath="">
- <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.app.release.695203103" 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.197043478" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
- <builder buildPath="${workspace_loc:/NMSampleApp}/Release" id="org.tizen.nativecore.target.sbi.gnu.builder.1996554881" 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.642020430" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
- <tool command="clang++.exe" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.1246939520" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
- <option id="gnu.cpp.compiler.option.optimization.level.1912726782" 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.219265095" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core"/>
- <option id="sbi.gnu.cpp.compiler.option.1675457058" 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.243679718" 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.49564857" 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.1495504815" 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.473269013" 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.965458948" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
- </tool>
- <tool command="clang.exe" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.1900937931" 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.266625395" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
- <option id="sbi.gnu.c.compiler.option.debugging.level.core.533032952" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core"/>
- <option id="sbi.gnu.c.compiler.option.861161124" 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.2063638314" 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.1268514055" 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.2089552115" 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.1115236395" 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.1549480707" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
- </tool>
- <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.1065101605" 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.1995759576" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker">
- <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.882356104" 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.470096082" 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.1260470197" 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.1113631268" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base">
- <inputType id="cdt.managedbuild.tool.gnu.assembler.input.36328338" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
- </tool>
- <tool id="org.tizen.nativecore.tool.fnmapgen.1226070046" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/>
- <tool id="org.tizen.nativecore.tool.fnmapgen.cpp.845522361" name="C++ FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen.cpp"/>
- <tool id="org.tizen.nativecore.tool.ast.512485616" name="C Static Analyzer" superClass="org.tizen.nativecore.tool.ast"/>
- <tool id="org.tizen.nativecore.tool.ast.cpp.1561842929" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/>
- <tool id="org.tizen.nativecore.tool.sbi.po.compiler.298210611" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/>
- <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.1166942225" 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="NMSampleApp.org.tizen.nativecore.target.sbi.gcc45.app.772584317" 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.53616310">
- <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
- </scannerConfigBuildInfo>
- <scannerConfigBuildInfo instanceId="org.tizen.nativecore.config.sbi.gcc45.app.release.1937068221">
- <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
- </scannerConfigBuildInfo>
- </storageModule>
- <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
- <storageModule moduleId="com.samsung.tizen.nativeapp.projectInfo" version="1.0.0"/>
- <storageModule moduleId="refreshScope"/>
-</cproject>
+++ /dev/null
-{
- global: main;
- local: *;
-};
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>RHSampleApp</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>1429160978568</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
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<tproject xmlns="http://www.tizen.org/tproject">
- <platforms>
- <platform>
- <name>mobile-2.3</name>
- </platform>
- </platforms>
- <package>
- <blacklist/>
- </package>
-</tproject>
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd 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.
- *
- */
-
-group { name: "group_layout";
- parts {
- part { name: "start_button";
- type: SWALLOW;
- scale: 1;
- description {
- rel1.relative: 0.01 0.01;
- rel2.relative: 0.5 0.09;
- }
- }
- part { name: "stop_button";
- type: SWALLOW;
- scale: 1;
- description {
- rel1.relative: 0.01 0.2;
- rel2.relative: 0.5 0.09;
- }
- }
- 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";
- }
- }
- }
-}
+++ /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 RHSAMPLEAPP_H__
-#define RHSAMPLEAPP_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 "resource-hosting"
-
-#if !defined(PACKAGE)
-#define PACKAGE "org.tizen.rhsampleapp"
-#endif
-
-#define ELM_DEMO_EDJ "opt/usr/apps/org.tizen.rhsampleapp/res/ui_controls.edj"
-
-void start_cb(void *data, Evas_Object *obj, void *event_info);
-
-void stop_cb(void *data, Evas_Object *obj, void *event_info);
-
-void stop_hosting();
-
-void *updateGroupLog(void *data);
-
-#endif // RHSAMPLEAPP_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<iostream>
-
-using namespace std;
-
-#ifndef RHUTIL_H_
-#define RHUTIL_H_
-
-#define LOGI(...) dlog_print(DLOG_INFO, LOG_TAG, __VA_ARGS__)
-#define LOGD(...) dlog_print(DLOG_DEBUG, LOG_TAG, __VA_ARGS__)
-#define LOGE(...) dlog_print(DLOG_ERROR, LOG_TAG, __VA_ARGS__)
-
-extern std::string getOCStackResultStringFromInt(int result);
-
-#endif // RHUTIL_H_
-
-
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd 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/hosting_control.edc"
-}
-
+++ /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 "rhsampleapp.h"
-#include "rhutil.h"
-#include <algorithm>
-#include <signal.h>
-#include "Hosting.h"
-
-using namespace std;
-using namespace OC;
-
-namespace PH = std::placeholders;
-
-static uint8_t interfaceName[] = "wlan0";
-int g_quitFlag = 0;
-
-static void printLog(int logType, string data)
-{
- (DLOG_ERROR == logType) ? LOGE(data.c_str()) : LOGI(data.c_str());
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog,
- &data);
-}
-
-// Method for Finding the resource and hosting it
-static void start_hosting(int seconds)
-{
- string logMessage = "OCResourceHosting started <br>";
- logMessage = logMessage + "Interface Name : " + reinterpret_cast<char *>(interfaceName) + "<br>";
- printLog(DLOG_INFO, logMessage);
-
- if (OICStartCoordinate() != OC_STACK_OK)
- {
- logMessage = "OICStartCoordinate FAILED <br>";
- printLog(DLOG_ERROR, logMessage);
- return;
- }
-
- g_quitFlag = 0;
- logMessage = "OICStartCoordinate done successfully <br>";
- printLog(DLOG_INFO, logMessage);
-
- while (!g_quitFlag)
- {
- if (OCProcess() != OC_STACK_OK)
- {
- OICStopCoordinate();
- logMessage = "OCStack process error <br>";
- printLog(DLOG_ERROR, logMessage);
- return;
- }
- sleep(seconds);
- }
-
- if (OICStopCoordinate() != OC_STACK_OK)
- {
- logMessage = "OICStopCoordinate FAILED <br>";
- printLog(DLOG_ERROR, logMessage);
- }
- logMessage = "OICStopCoordinate done successfully <br>";
- printLog(DLOG_INFO, logMessage);
- LOGI("start EXIT");
-}
-
-// Method for Finding the resource and hosting it
-void stop_hosting()
-{
- string logMessage = "Terminating Resource Hosting <br>";
- printLog(DLOG_INFO, logMessage);
-
- if(!g_quitFlag)
- {
- g_quitFlag = 1;
- }
- else
- {
- string logMessage = "Resource Hosting already terminated <br>";
- printLog(DLOG_INFO, logMessage);
- }
- LOGI("stop_hosting EXIT");
-}
-
-// Method to be called when the find and host UI Button is selected
-void start_cb(void *data, Evas_Object *obj, void *event_info)
-{
- std::thread exec(std::function< void(int second) >(start_hosting), 3);
- exec.detach();
-}
-
-// Method to be called when the find and host UI Button is selected
-void stop_cb(void *data, Evas_Object *obj, void *event_info)
-{
- LOGI("Stopping resource hosting");
- stop_hosting();
-}
+++ /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 "rhsampleapp.h"
-#include "rhutil.h"
-#include <tizen.h>
-
-using namespace std;
-using namespace OC;
-
-static Evas_Object *log_entry = NULL;
-static Evas_Object *list = NULL;
-static Evas_Object *naviframe = NULL;
-
-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;
-
-// 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;
-}
-
-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 void
-win_back_cb(void *data, Evas_Object *obj, void *event_info)
-{
- appdata_s *ad = (appdata_s *)data;
- // Let window go to hide state.
- elm_win_lower(ad->win);
-}
-
-static Eina_Bool
-naviframe_pop_cb(void *data, Elm_Object_Item *it)
-{
- stop_hosting();
- ui_app_exit();
- return EINA_FALSE;
-}
-
-static void
-create_list_view(appdata_s *ad)
-{
- Evas_Object *layout;
- Evas_Object *scroller;
- Evas_Object *nf = ad->nf;
- Evas_Object *start_button;
- Evas_Object *stop_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
- start_button = elm_button_add(layout);
- elm_object_part_content_set(layout, "start_button", start_button);
- elm_object_text_set(start_button, "Find and Host");
- evas_object_smart_callback_add(start_button, "clicked", start_cb, NULL);
-
- // button
- stop_button = elm_button_add(layout);
- elm_object_part_content_set(layout, "stop_button", stop_button);
- elm_object_text_set(stop_button, "Stop");
- evas_object_smart_callback_add(stop_button, "clicked", stop_cb, NULL);
-
- // 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, "Resource Hosting", NULL, NULL, scroller, NULL);
- elm_naviframe_item_pop_cb_set(nf_it, naviframe_pop_cb, NULL);
-}
-
-
-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_INFO, LOG_TAG, "#### Platform configuration Exception!!!!");
- dlog_print(DLOG_INFO, LOG_TAG, "#### (%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 (ret != APP_ERROR_NONE)
- {
- 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 "rhutil.h"
-
-// Utility function to return the string equivalent of OCStackResult for the given int 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;
-}
+++ /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.rhsampleapp" version="1.0.0">
- <profile name="mobile"/>
- <ui-application appid="org.tizen.rhsampleapp" exec="rhsampleapp" multiple="false" nodisplay="false" taskmanage="true" type="capp">
- <label>rhsampleapp</label>
- <icon>rhsampleapp.png</icon>
- </ui-application>
- <privileges>
- <privilege>http://tizen.org/privilege/network.get</privilege>
- <privilege>http://tizen.org/privilege/systemsettings</privilege>
- <privilege>http://tizen.org/privilege/network.set</privilege>
- <privilege>http://tizen.org/privilege/internet</privilege>
- <privilege>http://tizen.org/privilege/packagemanager.info</privilege>
- </privileges>
- <feature name="http://tizen.org/feature/network.wifi">true</feature>
-</manifest>
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Intel Corporation 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.
-//
-#define __GXX_EXPERIMENTAL_CXX0X__ 1
-
-#include <string>
-#include <cstdlib>
-#include "OCPlatform.h"
-#include "OCApi.h"
-#include "oicapp-utils.h"
-
-using namespace OC;
-
-#define ISFORLINUX 1
-#define ISFORTIZEN 0
-
-const int SUCCESS_RESPONSE = 0;
-static ObserveType OBSERVE_TYPE_TO_USE = ObserveType::Observe;
-
-const char *PREFIX_URI = "Uri : ";
-const char *PREFIX_HOST = "Host : ";
-
-OCPlatform *g_platform = nullptr;
-PlatformConfig g_cfg;
-
-std::shared_ptr< OCResource > g_curResource = nullptr;
-AttributeMap g_curAttributeMap;
-
-oicappData *g_oicappClientAd;
-oicappData *g_oicFindAd;
-oicappData *g_oicObserveAd;
-
-OCStackResult nmfindResource(const std::string &host , const std::string &resourceName);
-void onObserve(const OCRepresentation &rep , const int &eCode , const int &sequenceNumber);
-void onfound();
-void onobserve();
-
-void findResourceCandidate(oicappData *ad)
-{
- try
- {
- nmfindResource("" , "coap://224.0.1.187/oc/core?rt=notificationmanager.hosting");
- std::cout << "Finding Resource... " << std::endl;
-
- }
- catch (OCException &e)
- {
- ERR("findResourceCandidate exception: %s" , e.what().c_str());
- }
- g_oicFindAd = ad;
-}
-
-void startObserve(oicappData *ad)
-{
- if (g_curResource != nullptr)
- {
- g_oicObserveAd = ad;
- QueryParamsMap test;
- g_curResource->observe(ObserveType::Observe , test , &onObserve);
- }
-}
-
-void printAttributeMap(const AttributeMap attributeMap)
-{
- for (auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it)
- {
- DBG("\tAttribute name: %s" , it->first.c_str());
- for (auto valueItr = it->second.begin() ; valueItr != it->second.end() ; ++valueItr)
- {
- DBG("\t\tAttribute value: %s" , (*valueItr).c_str());
- }
- }
-}
-
-void updateAttribute(const AttributeMap attributeMap)
-{
- g_oicappClientAd->temp = std::stoi(attributeMap.at("temp")[0]);
- g_oicappClientAd->humid = std::stoi(attributeMap.at("humid")[0]);
-}
-
-void cancelObserve()
-{
- DBG("Cancelling Observe...");
-
- OCStackResult result = OC_STACK_ERROR;
-
- if (g_curResource != nullptr)
- {
- result = g_curResource->cancelObserve();
- }
-
- DBG("Cancel result: %d" , result);
-}
-
-void onObserve(const OCRepresentation &rep , const int &eCode , const int &sequenceNumber)
-{
-
- AttributeMap attributeMap = rep.getAttributeMap();
- if (eCode == SUCCESS_RESPONSE)
- {
- DBG("OBSERVE RESULT:");
- DBG("\tSequenceNumber: %d" , sequenceNumber);
-
- printAttributeMap(attributeMap);
-// updateAttribute(attributeMap);
- g_curAttributeMap = attributeMap;
- onobserve();
- }
- else
- {
- ERR("onObserve Response error: %d" , eCode);
- //std::exit(-1);
- }
-}
-
-// callback handler on PUT request
-void onPut(const OCRepresentation &rep , const int eCode)
-{
- AttributeMap attributeMap = rep.getAttributeMap();
- if (eCode == SUCCESS_RESPONSE)
- {
- DBG("PUT request was successful");
-
- printAttributeMap(attributeMap);
-
- if (OBSERVE_TYPE_TO_USE == ObserveType::Observe)
- INFO("Observe is used.");
- else if (OBSERVE_TYPE_TO_USE == ObserveType::ObserveAll)
- INFO("ObserveAll is used.");
-
- if (g_curResource != nullptr)
- {
- DBG("Observe Start");
- QueryParamsMap test;
- g_curResource->observe(ObserveType::Observe , test , &onObserve);
- }
- }
- else
- {
- ERR("onPut Response error: %d" , eCode);
- //std::exit(-1);
- }
-}
-
-// callback handler on GET request
-void onGet(const OCRepresentation &rep , const int eCode)
-{
-
- AttributeMap attributeMap = rep.getAttributeMap();
- if (eCode == SUCCESS_RESPONSE)
- {
- DBG("GET Succeeded:");
-
- printAttributeMap(attributeMap);
- updateAttribute(attributeMap);
- }
- else
- {
- ERR("onGet Response error: %d" , eCode);
- //std::exit(-1);
- }
-}
-
-// Local function to get representation of light resource
-void getLightRepresentation(std::shared_ptr< OCResource > resource)
-{
- if (resource)
- {
- DBG("Getting Light Representation...");
- // Invoke resource's get API with the callback parameter
- QueryParamsMap test;
- resource->get(test , &onGet);
- }
-}
-
-// Callback to found resources
-static void foundResource(std::shared_ptr< OCResource > resource)
-{
- try
- {
- if (resource)
- {
- DBG("DISCOVERED Resource:");
- DBG("\tURI of the resource: %s" , resource->uri().c_str());
- DBG("\tHost address of the resource: %s" , resource->host().c_str());
-
- if (resource->uri().find("/a/NM") != string::npos)
- {
-
- g_curResource = resource;
- onfound();
- }
- }
- else
- {
- ERR("Resource is invalid");
- }
-
- }
- catch (std::exception &e)
- {
- ERR("foundResource exception: %s" , e.what().c_str());
- }
-}
-
-OCStackResult nmfindResource(const std::string &host , const std::string &resourceName)
-{
- if (g_platform != nullptr)
- {
- return g_platform->findResource(host , resourceName , &foundResource);
- }
-
- return OC_STACK_ERROR;
-}
-
-int oicapp_client_start(oicappData *ad)
-{
- g_cfg.ipAddress = ad->ipAddr;
- g_cfg.port = 5683;
- g_cfg.mode = ModeType::Client;
- g_cfg.serviceType = ServiceType::InProc;
-
- retv_if(NULL != g_platform , -1);
-
- g_platform = new OCPlatform(g_cfg);
-
- g_oicappClientAd = ad;
-
- return 0;
-}
-
-void oicapp_client_stop()
-{
- if (g_curResource != nullptr)
- {
- cancelObserve();
- g_curResource = NULL;
- }
-
- if (g_platform)
- {
- delete (g_platform);
- g_platform = NULL;
- }
- g_oicappClientAd = NULL;
-}
-
-// Local function to put a different state for this resource
-int oicapp_client_put(int power , int level)
-{
- std::shared_ptr< OCResource > resource = g_curResource;
-
- retv_if(NULL == g_curResource , -1);
-
- DBG("Putting light representation...");
-
- AttributeMap attributeMap;
-
- AttributeValues tempVal;
- AttributeValues humidVal;
-
- tempVal.push_back(to_string(power));
- humidVal.push_back(to_string(level));
-
- attributeMap["temp"] = tempVal;
- attributeMap["humid"] = humidVal;
-
- // Create QueryParameters Map and add query params (if any)
- QueryParamsMap queryParamsMap;
-
- OCRepresentation rep;
- rep.setAttributeMap(attributeMap);
-
- // Invoke resource's pit API with attribute map, query map and the callback parameter
- resource->put(rep , queryParamsMap , &onPut);
-
- return 0;
-}
-
-void onfound()
-{
-
- if (g_curResource->uri().find("/a/NM/TempHumSensor/virtual") != string::npos)
- {
- oicappData *ad = g_oicFindAd;
-
- std::string tmpuri = PREFIX_URI + g_curResource->uri();
- std::string tmphost = PREFIX_HOST + g_curResource->host();
-
- DBG("OnFound Resource...");
- DBG("Resource Uri : %s" , tmpuri.c_str());
- DBG("Resource Host: %s" , tmphost.c_str());
-
- _gl_update_item(ad , tmphost.c_str() , ad->itemConsumerHost);
- _gl_update_item(ad , tmpuri.c_str() , ad->itemConsumerUri);
- }
-
-}
-void onobserve()
-{
-
- oicappData *ad = g_oicObserveAd;
-
- AttributeMap attributeMap = g_curAttributeMap;
-
- std::string tmpStr[2];
- int index = 0;
- for (auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it)
- {
- tmpStr[index] = it->first;
- tmpStr[index].append(" : ");
- for (auto value = it->second.begin() ; value != it->second.end() ; ++value)
- {
- tmpStr[index].append(*value);
- }
- index++;
- }
-
- DBG("%s" , tmpStr[0].c_str());
- DBG("%s" , tmpStr[1].c_str());
- _gl_update_item(ad , strdup(tmpStr[0].c_str()) , ad->itemConsumerTemp);
- _gl_update_item(ad , strdup(tmpStr[1].c_str()) , ad->itemConsumerHumid);
-}
+++ /dev/null
-/*
- * Copyright (c) 2010 Samsung Electronics, Inc.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information
- * of Samsung Electronics, Inc. ("Confidential Information"). You
- * shall not disclose such Confidential Information and shall use
- * it only in accordance with the terms of the license agreement
- * you entered into with Samsung Electronics.
- */
-#ifndef __OICAPP_LOG_H__
-#define __OICAPP_LOG_H__
-
-#define TIZEN_DEBUG_ENABLE
-#define LOG_TAG "OIC_TEST"
-#include <dlog.h>
-
-#define LOG_COLOR_RED "\033[0;31m"
-#define LOG_COLOR_BROWN "\033[0;33m"
-#define LOG_COLOR_BLUE "\033[0;34m"
-#define LOG_COLOR_END "\033[0;m"
-
-
-#if 1
-#define _DBG(fmt, arg...) SLOGD(fmt, ##arg)
-#define _INFO(fmt, arg...) SLOGI(fmt, ##arg)
-#define _WARN(fmt, arg...) SLOGW(fmt, ##arg)
-#define _ERR(fmt, arg...) SLOGE(fmt, ##arg)
-#else
-#define _DBG(fmt, arg...) \
- printf("[OIC_TEST]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
-#define _INFO(fmt, arg...) \
- printf("[OIC_TEST]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
-#define _WARN(fmt, arg...) \
- printf("[OIC_TEST]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
-#define _ERR(fmt, arg...) \
- printf("[OIC_TEST]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
-#endif
-
-#define DBG(fmt, arg...) _DBG(fmt, ##arg)
-#define WARN(fmt, arg...) _WARN(LOG_COLOR_BROWN fmt LOG_COLOR_END, ##arg)
-#define ERR(fmt, arg...) _ERR(LOG_COLOR_RED fmt LOG_COLOR_END, ##arg)
-#define INFO(fmt, arg...) _INFO(LOG_COLOR_BLUE fmt LOG_COLOR_END, ##arg)
-
-#define ret_if(expr) \
- do { \
- if (expr) { \
- ERR("(%s)", #expr); \
- return; \
- }\
- } while(0)
-#define retv_if(expr, val) \
- do {\
- if (expr) { \
- ERR("(%s)", #expr); \
- return (val); \
- } \
- } while(0)
-#define retm_if(expr, fmt, arg...) \
- do {\
- if (expr) { \
- ERR(fmt, ##arg); \
- return; \
- }\
- } while(0)
-#define retvm_if(expr, val, fmt, arg...) \
- do {\
- if (expr) { \
- ERR(fmt, ##arg); \
- return (val); \
- } \
- } while(0)
-#define warn_if(expr) \
- do { \
- if (expr) { \
- WARN("(%s)", #expr); \
- } \
- } while (0)
-
-
-#endif //__OICAPP_LOG_H__
-
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics, Inc.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information
- * of Samsung Electronics, Inc. ("Confidential Information"). You
- * shall not disclose such Confidential Information and shall use
- * it only in accordance with the terms of the license agreement
- * you entered into with Samsung Electronics.
- */
-
-#include <appcore-efl.h>
-#include <Ecore_X.h>
-#include <efl_assist.h>
-
-#include "oicapp-sampleConsumer.h"
-#include "oicapp-utils.h"
-
-char* OICAPP_STR_URI = "Uri : ";
-char* OICAPP_STR_HOST = "Host : ";
-
-const char* const OICAPP_STR_CONSUMER = "Consumer";
-
-void __gl_realized_cb(void *data , Evas_Object *obj , void *event_info)
-{
- Elm_Object_Item *item = event_info;
- elm_object_item_signal_emit(item , "elm,state,normal" , "");
-}
-
-static Elm_Object_Item* oicapp_append_separator(Evas_Object *genlist , oicappData *ad)
-{
- Elm_Object_Item *item = NULL;
-
- item = elm_genlist_item_append(genlist , &ad->itcSeperator , NULL , NULL ,
- ELM_GENLIST_ITEM_NONE , NULL , NULL);
- elm_genlist_item_select_mode_set(item , ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
-
- return item;
-}
-
-static Elm_Object_Item* _gl_append_item(oicappData *ad , Elm_Genlist_Item_Class *itc ,
- const char *title , Evas_Smart_Cb sel_func)
-{
- Elm_Object_Item *item;
- oicappItemData *it_data;
-
- it_data = calloc(1 , sizeof(oicappItemData));
- if (NULL == it_data)
- {
- DBG("calloc failed!!!!");
- return NULL;
- }
- it_data->title = title;
- it_data->ad = ad;
- item = elm_genlist_item_append(ad->genlist , itc , it_data , NULL , ELM_GENLIST_ITEM_NONE ,
- sel_func , ad);
-
- return item;
-}
-
-void _gl_update_item(oicappData *ad , const char *title , Elm_Object_Item *item)
-{
- oicappItemData *it_data;
-
- it_data = calloc(1 , sizeof(oicappItemData));
- if (NULL == it_data)
- {
- DBG("calloc failed!!!!");
- return;
- }
- it_data->title = title;
- it_data->ad = ad;
-
- elm_object_item_data_set(item , it_data);
- elm_genlist_item_update(item);
-}
-
-static Elm_Object_Item* _gl_append_btn(oicappData *ad , Elm_Genlist_Item_Class *itc)
-{
-
- DBG("btn create!!");
- Elm_Object_Item *item;
-
- item = elm_genlist_item_append(ad->genlist , itc , ad , NULL , ELM_GENLIST_ITEM_NONE , NULL ,
- NULL);
-
- elm_genlist_item_select_mode_set(item , ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
-
- return item;
-}
-
-static void consumerapp_append_contents(oicappData *ad)
-{
-
- Elm_Object_Item *item , *parent;
-
- parent = _gl_append_item(ad , &ad->itcTitle , OICAPP_STR_CONSUMER , NULL);
- elm_genlist_item_select_mode_set(parent , ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
-
- item = _gl_append_item(ad , &ad->itcText , OICAPP_STR_URI , NULL);
- ad->itemConsumerUri = item;
-
- item = _gl_append_item(ad , &ad->itcText , OICAPP_STR_HOST , NULL);
- ad->itemConsumerHost = item;
-
- _gl_append_btn(ad , &ad->itcBtnFindResoruce);
-
- item = _gl_append_item(ad , &ad->itcText , "" , NULL);
- ad->itemConsumerTemp = item;
-
- item = _gl_append_item(ad , &ad->itcText , "" , NULL);
- ad->itemConsumerHumid = item;
-
- _gl_append_btn(ad , &ad->itcBtnObserve);
-
- oicapp_append_separator(ad->genlist , ad);
-
-}
-
-static Evas_Object* consumerapp_create_genlist(Evas_Object *parent)
-{
- Evas_Object *genlist;
-
- genlist = elm_genlist_add(parent);
- if(NULL == genlist)
- {
- ERR("elm_genlist_add() Fail");
- return NULL;
- }
-
- elm_object_style_set(genlist , "dialogue");
- evas_object_size_hint_weight_set(genlist , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND);
- evas_object_show(genlist);
-
- evas_object_smart_callback_add(genlist , "realized" , __gl_realized_cb , NULL);
-
- return genlist;
-}
-
-static Eina_Bool _back_cb(void *data , Elm_Object_Item *item)
-{
- DBG("test _back_cb()");
- oicappData *ad = data;
-
- elm_genlist_item_update(ad->itemConsumer);
- elm_genlist_item_update(ad->itemConsumerHost);
- elm_genlist_item_update(ad->itemConsumerTemp);
- elm_genlist_item_update(ad->itemConsumerHumid);
- elm_genlist_item_update(ad->itemConsumerUri);
-
- elm_object_item_disabled_set(ad->itemConsumer , EINA_FALSE);
- elm_object_item_disabled_set(ad->itemConsumerHost , EINA_TRUE);
- elm_object_item_disabled_set(ad->itemConsumerTemp , EINA_TRUE);
- elm_object_item_disabled_set(ad->itemConsumerHumid , EINA_TRUE);
- elm_object_item_disabled_set(ad->itemConsumerUri , EINA_TRUE);
-
- elm_exit();
-
- return EINA_FALSE;
-}
-
-static void _win_del(void *data , Evas_Object *obj , void *event)
-{
- DBG("test _win_del()");
-
- elm_exit();
-}
-
-static Evas_Object* consumerapp_create_conform(Evas_Object *win)
-{
- Evas_Object *conform = NULL;
- conform = elm_conformant_add(win);
-
- evas_object_size_hint_weight_set(conform , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND);
- elm_win_resize_object_add(win , conform);
- evas_object_show(conform);
-
- Evas_Object *bg_indicator = elm_bg_add(conform);
- elm_object_style_set(bg_indicator , "indicator/headerbg");
- elm_object_part_content_set(conform , "elm.swallow.indicator_bg" , bg_indicator);
- evas_object_show(bg_indicator);
-
- return conform;
-}
-
-static Evas_Object* consumerapp_create_win(const char *name)
-{
- Evas_Object *eo;
- int w , h;
-
- eo = elm_win_add(NULL , name , ELM_WIN_BASIC);
- if(eo)
- {
- elm_win_title_set(eo , name);
- elm_win_borderless_set(eo , EINA_TRUE);
- evas_object_smart_callback_add(eo , "delete,request" , _win_del , NULL);
- ecore_x_window_size_get(ecore_x_window_root_first_get() , &w , &h);
- evas_object_resize(eo , w , h);
- elm_win_indicator_mode_set(eo , ELM_WIN_INDICATOR_SHOW);
- elm_win_indicator_opacity_set(eo , ELM_WIN_INDICATOR_OPAQUE);
- }
-
- evas_object_show(eo);
-
- return eo;
-}
-
-static Evas_Object* consumerapp_create_bg(Evas_Object *parent)
-{
- Evas_Object *bg;
-
- bg = elm_bg_add(parent);
- evas_object_size_hint_weight_set(bg , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND);
- elm_win_resize_object_add(parent , bg);
- evas_object_show(bg);
-
- return bg;
-}
-
-static Evas_Object* consumerapp_create_base_layout(Evas_Object *parent)
-{
- Evas_Object *base;
-
- base = elm_layout_add(parent);
- elm_layout_theme_set(base , "layout" , "application" , "default");
- evas_object_size_hint_weight_set(base , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND);
- evas_object_show(base);
-
- return base;
-}
-
-static void _btn_observe_clicked(void *data , Evas_Object *obj , void *event_info)
-{
- oicappData *ad = data;
-
- startObserve(ad);
-}
-
-static void _btn_findResource_clicked(void *data , Evas_Object *obj , void *event_info)
-{
- oicappData *ad = data;
-
- findResourceCandidate(ad);
-}
-
-static Evas_Object* _gl_btn_observe_content_get(void *data , Evas_Object *obj , const char *part)
-{
- Evas_Object *button;
- oicappData *ad = data;
-
- button = elm_button_add(obj);
- elm_object_part_text_set(button , NULL , "Observe");
- evas_object_propagate_events_set(button , EINA_FALSE);
- evas_object_smart_callback_add(button , "clicked" , _btn_observe_clicked , ad);
-
- return button;
-}
-
-static Evas_Object* _gl_btn_findResource_content_get(void *data , Evas_Object *obj ,
- const char *part)
-{
- Evas_Object *button;
- oicappData *ad = data;
-
- button = elm_button_add(obj);
- elm_object_part_text_set(button , NULL , "Find Resource");
- evas_object_propagate_events_set(button , EINA_FALSE);
- evas_object_smart_callback_add(button , "clicked" , _btn_findResource_clicked , ad);
-
- return button;
-}
-
-static void _gl_item_del(void *data , Evas_Object *obj)
-{
- if(data != NULL)
- free(data);
-}
-
-static char* _gl_text_get(void *data , Evas_Object *obj , const char *part)
-{
- oicappItemData *it_data = data;
- return strdup(it_data->title);
-}
-
-static inline void oicapp_init_itcs(oicappData *ad)
-{
- ad->itcSeperator.item_style = "dialogue/separator";
- ad->itcSeperator.func.text_get = NULL;
- ad->itcSeperator.func.content_get = NULL;
- ad->itcSeperator.func.state_get = NULL;
- ad->itcSeperator.func.del = NULL;
-
- ad->itcTitle.item_style = "dialogue/title";
- ad->itcTitle.func.text_get = _gl_text_get;
- ad->itcTitle.func.content_get = NULL;
- ad->itcTitle.func.state_get = NULL;
- ad->itcTitle.func.del = _gl_item_del;
-
- ad->itcText.item_style = "dialogue/1text";
- ad->itcText.func.text_get = _gl_text_get;
- ad->itcText.func.content_get = NULL;
- ad->itcText.func.state_get = NULL;
- ad->itcText.func.del = _gl_item_del;
-
- ad->itcBtnFindResoruce.item_style = "dialogue/1icon";
- ad->itcBtnFindResoruce.func.text_get = NULL;
- ad->itcBtnFindResoruce.func.content_get = _gl_btn_findResource_content_get;
- ad->itcBtnFindResoruce.func.state_get = NULL;
- ad->itcBtnFindResoruce.func.del = NULL;
-
- ad->itcBtnObserve.item_style = "dialogue/1icon";
- ad->itcBtnObserve.func.text_get = NULL;
- ad->itcBtnObserve.func.content_get = _gl_btn_observe_content_get;
- ad->itcBtnObserve.func.state_get = NULL;
- ad->itcBtnObserve.func.del = NULL;
-
-}
-
-static int oicapp_create(void *data)
-{
- oicappData *ad = data;
- Elm_Object_Item *it;
-
- oicapp_init_itcs(ad);
-
- /* create window */
- ad->win = consumerapp_create_win(PACKAGE);
- if(NULL == ad->win)
- return -1;
-
- ad->bg = consumerapp_create_bg(ad->win);
- if(NULL == ad->bg)
- return -1;
-
- ad->conform = consumerapp_create_conform(ad->win);
- if(NULL == ad->conform)
- return -1;
-
- /* create layout */
- ad->base = consumerapp_create_base_layout(ad->conform);
- if(NULL == ad->base)
- return -1;
- elm_object_content_set(ad->conform , ad->base);
-
- ad->navi = elm_naviframe_add(ad->base);
- elm_object_part_content_set(ad->base , "elm.swallow.content" , ad->navi);
- ea_object_event_callback_add(ad->navi , EA_CALLBACK_BACK , ea_naviframe_back_cb , NULL);
-
- ad->genlist = consumerapp_create_genlist(ad->navi);
-
- it = elm_naviframe_item_push(ad->navi , "IoT Notification Sample App" , NULL , NULL ,
- ad->genlist , NULL);
- elm_naviframe_item_pop_cb_set(it , _back_cb , ad);
-
- ad->ipAddr = oicapp_util_wifi();
- if(NULL == ad->ipAddr)
- {
- ERR("wifi is not connected");
- oicapp_fail_popup(ad , "Error" , "No WIFI connection" , 3);
- }
- else
- {
- INFO("IP Address = %s" , ad->ipAddr);
- }
-
- oicapp_client_start(ad);
-
- consumerapp_append_contents(ad);
-
- return 0;
-}
-
-static int oicapp_terminate(void *data)
-{
- DBG("test _terminate()!!");
- oicappData *ad = data;
-
- if(ad->win)
- {
- DBG("test_del evas object1");
- evas_object_del(ad->win);
- DBG("test_del evas object2");
- }
-
- free(ad->ipAddr);
- return 0;
-
-}
-
-static int oicapp_pause(void *data)
-{
- DBG("test _pause()!!!!");
- return 0;
-}
-
-static int oicapp_resume(void *data)
-{
- DBG("test_resume()");
- return 0;
-}
-
-static int oicapp_reset(bundle *b , void *data)
-{
- return 0;
-}
-
-int main(int argc , char *argv[])
-{
- oicappData ad;
- DBG("test_start()");
- struct appcore_ops ops =
- { .create = oicapp_create , .terminate = oicapp_terminate , .pause = oicapp_pause , .resume =
- oicapp_resume , .reset = oicapp_reset , };
-
- memset(&ad , 0x0 , sizeof(oicappData));
- ops.data = &ad;
-
- return appcore_efl_main(PACKAGE , &argc , &argv , &ops);
-}
+++ /dev/null
-/*
- * Copyright (c) 2010 Samsung Electronics, Inc.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information
- * of Samsung Electronics, Inc. ("Confidential Information"). You
- * shall not disclose such Confidential Information and shall use
- * it only in accordance with the terms of the license agreement
- * you entered into with Samsung Electronics.
- */
-
-#ifndef __OICAPP_TEST_H__
-#define __OICAPP_TEST_H__
-
-#include <Elementary.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include "oicapp-log.h"
-
-#if !defined(PACKAGE)
-# define PACKAGE "oicapp-test"
-#endif
-
-#if !defined(LOCALEDIR)
-# define LOCALEDIR "/usr/apps/com.samsung.oicapp-test/res/locale"
-#endif
-
-#if !defined(EDJDIR)
-# define EDJDIR "/usr/apps/com.samsung.oicapp-test/res/edje"
-#endif
-
-#define GRP_MAIN "main"
-
-enum
-{
- OICAPP_GENLIST_GRP_NONE = 0,
- OICAPP_GENLIST_GRP_TOP,
- OICAPP_GENLIST_GRP_CENTER,
- OICAPP_GENLIST_GRP_BOTTOM
-};
-
-typedef struct
-{
- Evas_Object *win;
- Evas_Object *base;
- Evas_Object *bg;
- Evas_Object *navi;
- Evas_Object *genlist;
- Evas_Object *popup;
- Evas_Object *conform;
-
- Elm_Object_Item *itemConsumer;
- Elm_Object_Item *itemConsumerUri;
- Elm_Object_Item *itemConsumerHost;
- Elm_Object_Item *itemConsumerTemp;
- Elm_Object_Item *itemConsumerHumid;
- Elm_Object_Item *itemFindResource;
- Elm_Object_Item *itemObserve;
- Elm_Object_Item *itemServer;
- Elm_Object_Item *itemServerTemp;
- Elm_Object_Item *itemServerHumid;
-
- Elm_Genlist_Item_Class itcSeperator;
- Elm_Genlist_Item_Class itcTitle;
- Elm_Genlist_Item_Class itcText;
- Elm_Genlist_Item_Class itcBtnFindResoruce;
- Elm_Genlist_Item_Class itcBtnObserve;
-
- char *ipAddr;
- //oicapp_mode mode;
- int clientOn;
- int serverOn;
- int power;
- int level;
-
- int temp;
- int humid;
-
- char *uri;
- char *host;
-
-} oicappData;
-
-extern void _gl_update_item(oicappData *ad , const char *title , Elm_Object_Item *item);
-
-typedef struct
-{
- oicappData *ad;
- const char *title;
- int group_style;
-
-} oicappItemData;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__OICAPP_TEST_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics, Inc.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information
- * of Samsung Electronics, Inc. ("Confidential Information"). You
- * shall not disclose such Confidential Information and shall use
- * it only in accordance with the terms of the license agreement
- * you entered into with Samsung Electronics.
- */
-#include <appcore-efl.h>
-#include <wifi.h>
-
-#include "oicapp-utils.h"
-
-static void _popup_timeout_cb(void *data , Evas_Object *obj , void *event_info)
-{
- oicappData *ad = data;
-
- ret_if(data == NULL);
-
- ad->popup = NULL;
-}
-
-void oicapp_fail_popup(oicappData *ad , char *title , char *text , int timeout)
-{
- if(ad->popup)
- {
- evas_object_del(ad->popup);
- ad->popup = NULL;
- }
-
- Evas_Object *popup = elm_popup_add(ad->win);
- evas_object_size_hint_weight_set(popup , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND);
-
- if(title)
- elm_object_part_text_set(popup , "title,text" , title);
-
- if(text)
- elm_object_text_set(popup , text);
-
- if(0 < timeout)
- elm_popup_timeout_set(popup , timeout);
- else
- elm_popup_timeout_set(popup , 3);
-
- evas_object_smart_callback_add(popup , "timeout" , _popup_timeout_cb , ad);
-
- evas_object_show(popup);
-
- ad->popup = popup;
-}
-
-void oicapp_util_update(oicappData *ad)
-{
-}
-
-char* oicapp_util_wifi()
-{
- int ret;
- wifi_ap_h ap;
- char *ip_addr = NULL;
-
- ret = wifi_initialize();
- if(WIFI_ERROR_NONE != ret)
- {
- ERR("wifi_initialize() Fail");
- return NULL;
- }
-
- ret = wifi_get_connected_ap(&ap);
- if(WIFI_ERROR_NONE != ret)
- {
- ERR("wifi_get_connected_ap() Fail");
- return NULL;
- }
-
- ret = wifi_ap_get_ip_address(ap , WIFI_ADDRESS_FAMILY_IPV4 , &ip_addr);
- if(WIFI_ERROR_NONE != ret)
- {
- ERR("wifi_ap_get_ip_address() Fail");
- return NULL;
- }
-
- return ip_addr;
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2010 Samsung Electronics, Inc.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information
- * of Samsung Electronics, Inc. ("Confidential Information"). You
- * shall not disclose such Confidential Information and shall use
- * it only in accordance with the terms of the license agreement
- * you entered into with Samsung Electronics.
- */
-#ifndef __OICAPP_UTILS_H__
-#define __OICAPP_UTILS_H__
-
-#include "oicapp-sampleConsumer.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-void oicapp_fail_popup(oicappData *ad , char *title , char *text , int timeout);
-void oicapp_util_update(oicappData *ad);
-char *oicapp_util_wifi();
-
-int oicapp_client_start(oicappData *ad);
-void oicapp_client_stop();
-int oicapp_client_put(int power , int level);
-
-int oicapp_server_start(oicappData *ad);
-void oicapp_server_stop();
-void oicapp_server_put(int power , int level);
-
-extern void *ChangeLightRepresentation(void *param);
-
-void findResourceCandidate(oicappData *ad);
-void startObserve(oicappData *ad);
-
-#ifdef __cplusplus
-}
-
-#endif
-
-#endif //__OICAPP_UTILS_H__
-
+++ /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>ResourceHosting</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
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.iotivity.ResourceHosting"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk
- android:minSdkVersion="8"
- android:targetSdkVersion="21" />
-
- <application
- android:allowBackup="true" >
- </application>
-
-</manifest>
+++ /dev/null
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../java/iotivity-android/build/native-libs/$(TARGET_ARCH_ABI)
-LOCAL_MODULE := 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 := ca
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libconnectivity_abstraction.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/release
-LOCAL_MODULE := oc_logger_core
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/liboc_logger_core.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/release
-LOCAL_MODULE := 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 := 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 := oc
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/liboc.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../java/iotivity-android/build/native-libs/$(TARGET_ARCH_ABI)
-LOCAL_MODULE := ocstack-jni
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libocstack-jni.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/release
-LOCAL_MODULE := rcsCommon
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/librcs_common.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/release
-LOCAL_MODULE := rcsClient
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/librcs_client.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/release
-LOCAL_MODULE := rcsServer
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/librcs_server.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/release
-LOCAL_MODULE := resourceHosting
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libresource_hosting.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := ResourceHosing_JNI
-LOCAL_CPPFLAGS := -std=c++0x -frtti -fexceptions
-
-LOCAL_STATIC_LIBRARIES := ca_interface
-LOCAL_STATIC_LIBRARIES += ca
-LOCAL_STATIC_LIBRARIES += oc_logger_core
-LOCAL_STATIC_LIBRARIES += oc_logger
-LOCAL_STATIC_LIBRARIES += octbstack
-LOCAL_STATIC_LIBRARIES += oc
-LOCAL_STATIC_LIBRARIES += ocstack-jni
-LOCAL_STATIC_LIBRARIES += rcsCommon
-LOCAL_STATIC_LIBRARIES += rcsClient
-LOCAL_STATIC_LIBRARIES += rcsServer
-LOCAL_STATIC_LIBRARIES += resourceHosting
-
-
-OIC_SRC_DIR := ../../../..
-
-LOCAL_C_INCLUDES := $(OIC_SRC_DIR)/resource/csdk/stack/include \
- $(OIC_SRC_DIR)/resource/csdk/logger/include \
- $(OIC_SRC_DIR)/resource/include \
- $(OIC_SRC_DIR)/resource/c_common \
- $(OIC_SRC_DIR)/resource/oc_logger/include \
- $(OIC_SRC_DIR)/extlibs/boost/boost_1_58_0 \
- $(OIC_SRC_DIR)/service/resource-encapsulation/include \
- $(OIC_SRC_DIR)/service/resource-hosting/include \
-
-LOCAL_SRC_FILES := ResourceHosing_JNI.cpp
-include $(BUILD_SHARED_LIBRARY)
+++ /dev/null
-APP_STL:=gnustl_shared
-NDK_TOOLCHAIN_VERSION := 4.9
+++ /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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-extern "C" {
-#include "Hosting.h"
-}
-#include "ResourceHosing_JNI.h"
-#include "OCAndroid.h"
-
-using namespace std;
-
-atomic_bool threadRun;
-thread ocProcessThread;
-/*
- * To execute OCProcess when threadRun value is only true
- */
-void ocProcessFunc()
-{
- while (threadRun)
- {
-
- if (OCProcess() != OC_STACK_OK)
- {
- return ;
- }
-
- sleep(2);
- }
-}
-
-/*
- * for Hosting Device Side
- */
-JNIEXPORT jint JNICALL Java_org_iotivity_ResourceHosting_ResourceHosting_OICCoordinatorStart
-(JNIEnv *env, jobject obj)
-{
- jint result = 0;
- if(threadRun==true)
- {
- result = (jint)HOSTING_THREAD_ERROR;
- return result;
- }
- else
- {
- result = (jint)OICStartCoordinate();
-
- threadRun = true;
- ocProcessThread = thread(ocProcessFunc);
- return result;
- }
-}
-
-JNIEXPORT jint JNICALL Java_org_iotivity_ResourceHosting_ResourceHosting_OICCoordinatorStop
-(JNIEnv *env, jobject obj)
-{
- jint result = 0;
- //terminate Thread
- if (ocProcessThread.joinable())
- {
- threadRun = false;
- ocProcessThread.join();
- }
- else
- {
- result = (jint)HOSTING_THREAD_ERROR;
- return result;
- }
- result = (jint)OICStopCoordinate();
-
- return result;
-}
-
-JNIEXPORT jint JNICALL Java_org_iotivity_ResourceHosting_ResourceHosting_ResourceHostingInit
-(JNIEnv *env, jobject obj,jstring j_addr)
-{
- if (NULL == j_addr)
- {
- return (jint)OCSTACK_ERROR;
- }
-
- if(OCInit1(OC_CLIENT_SERVER, OC_DEFAULT_FLAGS, OC_DEFAULT_FLAGS))
- {
- return (jint)OCSTACK_ERROR;
- }
-
- return (jint)OCSTACK_OK;
-}
-
-JNIEXPORT jint JNICALL Java_org_iotivity_ResourceHosting_ResourceHosting_ResourceHostingTerminate
-(JNIEnv *env, jobject obj)
-{
- if (OCStop() != OC_STACK_OK)
- {
- return (jint)OCSTACK_ERROR;
- }
- //terminate Thread
- if (ocProcessThread.joinable())
- {
- threadRun = false;
- ocProcessThread.join();
- }
-
- return (jint)OCSTACK_OK;
-}
+++ /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 RESOURCEHOSTING_JNI_H_
-#define RESOURCEHOSTING_JNI_H_
-
-#include <jni.h>
-#include <thread>
-#include <atomic>
-#include <unistd.h>
-
-#define TAG "OIC-JNI"
-
-#define JNI_CURRENT_VERSION JNI_VERSION_1_6
-#define OCSTACK_OK 0
-#define OCSTACK_ERROR 255
-#define HOSTING_THREAD_ERROR -2
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Class: org_iotivity_service_resourcehosting_ResourceHosting
- * Method: OICCoordinatorStart
- * Signature: ()V
- */
-JNIEXPORT jint JNICALL Java_org_iotivity_ResourceHosting_ResourceHosting_OICCoordinatorStart
-(JNIEnv *, jobject);
-/*
- * @Class: org_iotivity_service_resourcehosting_ResourceHosting
- * @Method: OICCoordinatorStop
- * @Signature: ()V
- */
-
-JNIEXPORT jint JNICALL Java_org_iotivity_ResourceHosting_ResourceHosting_OICCoordinatorStop
-(JNIEnv *, jobject);
-/*
- * Class: org_iotivity_service_resourcehosting_ResourceHosting
- * Method: ResourceHostingInit
- * Signature: ()V
- */
-JNIEXPORT jint JNICALL Java_org_iotivity_ResourceHosting_ResourceHosting_ResourceHostingInit
-(JNIEnv *env, jobject obj,jstring j_addr);
-/*
- * Class: org_iotivity_service_resourcehosting_ResourceHosting
- * Method: ResourceHostingTerminate
- * Signature: (Ljava/lang/String;)V
- */
-JNIEXPORT jint JNICALL Java_org_iotivity_ResourceHosting_ResourceHosting_ResourceHostingTerminate
-(JNIEnv *env, jobject obj);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* RESOURCEHOSTING_JNI_H_ */
+++ /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-22
-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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-package org.iotivity.ResourceHosting;
-import java.lang.System;
-import java.lang.String;
-
-/**
- * To execute resource hosting function for android sample application .
- *
- * @author Copyright 2015 Samsung Electronics All Rights Reserved.
- * @see className class : ResourceHosting
- *
- */
-
-public class ResourceHosting {
-
- /**
- * jni function - OicCorrdinatorstart() method.
- *
- * @see ResourceHosting
- */
- public native int OICCoordinatorStart();
-
- /**
- * jni function - OICCoordinatorStop() method.
- *
- * @see ResourceHosting
- */
- public native int OICCoordinatorStop();
-
- /**
- * jni function - ResourceHostingInit() method in order to execute
- * OICCoordinatorStart() method.
- *
- * @see ResourceHosting
- * @param addr
- * ipAddress
- */
- public native int ResourceHostingInit(String addr);
-
- /**
- * jni function - ResourceHostingTerminate() method in order to terminate
- * resource hosting
- *
- * @see ResourceHosting
- */
- public native int ResourceHostingTerminate();
-
- static {
- System.loadLibrary("connectivity_abstraction");
- System.loadLibrary("ca-interface");
- System.loadLibrary("oc_logger_core");
- System.loadLibrary("oc_logger");
- System.loadLibrary("octbstack");
- System.loadLibrary("oc");
- System.loadLibrary("ocstack-jni");
- System.loadLibrary("rcs_common");
- System.loadLibrary("rcs_client");
- System.loadLibrary("rcs_server");
- System.loadLibrary("resource_hosting");
- System.loadLibrary("ResourceHosing_JNI");
- }
-}
+++ /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 _HOSTING_H_
-#define _HOSTING_H_
-
-// Standard API
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-// Iotivity Base CAPI
-#include "ocstack.h"
-#include "logger.h"
-
-#define OC_TRANSPORT CT_ADAPTER_IP
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-
-#define HOSTING_TAG PCF("Hosting")
-
-/**
- * Start resource hosting.
- * This function will start the resource hosting and the discovery for remote resource which want to be hosted.
- *
- * @return ::OC_STACK_OK upon success, ::OC_STACK_ERROR is returned except the case that OC_STACK_SUCCESS is returned.
- */
-OCStackResult OICStartCoordinate();
-
-/**
- * Stop resource hosting.
- * This function will stop the resource hosting and delete all hosting resource.
- *
- * @return ::OC_STACK_OK upon success, ::OC_STACK_ERROR is returned except the case that OC_STACK_SUCCESS is returned.
- */
-OCStackResult OICStopCoordinate();
-
-#ifdef __cplusplus
-}
-#endif // __cplusplus
-
-#endif //_HOSTING_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 "Hosting.h"
-
-// Standard API
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <iostream>
-
-#include "octypes.h"
-#include "logger.h"
-#include "ResourceHosting.h"
-#include "HostingObject.h"
-
-OCStackResult OICStartCoordinate()
-{
- using namespace OIC::Service;
- OCStackResult retResult = OC_STACK_OK;
- try
- {
- ResourceHosting::getInstance()->startHosting();
- }catch(const RCSPlatformException &e)
- {
- OIC_HOSTING_LOG(DEBUG,
- "[OICStartCoordinate] platformException, reason:%s", e.what());
- retResult = OC_STACK_ERROR;
- }catch(const RCSInvalidParameterException &e)
- {
- OIC_HOSTING_LOG(DEBUG,
- "[OICStartCoordinate] InvalidParameterException, reason:%s", e.what());
- retResult = OC_STACK_ERROR;
- }catch(...)
- {
- OIC_HOSTING_LOG(DEBUG, "[OICStartCoordinate] Unknown Exception");
- retResult = OC_STACK_ERROR;
- }
- return retResult;
-}
-
-OCStackResult OICStopCoordinate()
-{
- OIC::Service::ResourceHosting::getInstance()->stopHosting();
- return OC_STACK_OK;
-}
+++ /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 "HostingObject.h"
-
-#include "RCSSeparateResponse.h"
-#include "RequestObject.h"
-
-namespace OIC
-{
- namespace Service
- {
-
- namespace
- {
- const auto sizeofHostingTag = strlen("/hosting");
- }
-
- HostingObject::HostingObject()
- : remoteObject(nullptr), mirroredServer(nullptr),
- pDataUpdateCB(nullptr), pDestroyCB(nullptr)
- {
- }
-
- HostingObject::~HostingObject()
- {
- pDataUpdateCB = {};
-
- if (remoteObject)
- {
- remoteObject->stopMonitoring();
- remoteObject->stopCaching();
- }
- }
-
- auto HostingObject::getRemoteResource() const -> RemoteObjectPtr
- {
- return remoteObject;
- }
-
- auto HostingObject::createHostingObject(const RemoteObjectPtr & rResource,
- DestroyedCallback destroyCB) -> Ptr
- {
- auto newObject = std::make_shared<HostingObject>();
-
- newObject->remoteObject = rResource;
- newObject->pDestroyCB = destroyCB;
-
- newObject->pDataUpdateCB = std::bind(&HostingObject::dataChangedCB, newObject,
- std::placeholders::_1);
-
- newObject->remoteObject->startMonitoring(
- std::bind(&HostingObject::stateChangedCB, newObject,
- std::placeholders::_1));
- newObject->remoteObject->startCaching(newObject->pDataUpdateCB);
-
- return newObject;
- }
-
- void HostingObject::destroyHostingObject()
- {
- if (pDestroyCB)
- {
- pDestroyCB();
- }
- }
-
- void HostingObject::stateChangedCB(ResourceState state)
- {
- switch (state)
- {
- case ResourceState::ALIVE:
- {
- if (!this->remoteObject->isCaching())
- {
- try
- {
- this->remoteObject->startCaching(pDataUpdateCB);
- } catch (const RCSException & e)
- {
- OIC_HOSTING_LOG(DEBUG,
- "[HostingObject::stateChangedCB]startCaching InvalidParameterException:%s",
- e.what());
- }
- }
- break;
- }
- case ResourceState::LOST_SIGNAL:
- case ResourceState::DESTROYED:
- {
- try
- {
- this->remoteObject->stopCaching();
- this->remoteObject->stopMonitoring();
- } catch (const RCSException & e)
- {
- OIC_HOSTING_LOG(DEBUG,
- "[HostingObject::stateChangedCB]stopWatching InvalidParameterException:%s",
- e.what());
- }
- mirroredServer.reset();
- destroyHostingObject();
- break;
- }
- default:
- {
- // not support of state
- break;
- }
- }
- }
-
- void HostingObject::dataChangedCB(const RCSResourceAttributes & attributes)
- {
- if (attributes.empty())
- {
- return;
- }
-
- std::unique_lock<std::mutex> lock(mutexForCB);
- if (mirroredServer == nullptr)
- {
- try
- {
- mirroredServer = createMirroredServer(this->remoteObject);
- } catch (const RCSException & e)
- {
- OIC_HOSTING_LOG(DEBUG,
- "[HostingObject::dataChangedCB]createMirroredServer Exception:%s",
- e.what());
- return;
- }
- }
- lock.unlock();
-
- RCSResourceObject::LockGuard guard(mirroredServer);
- mirroredServer->getAttributes() = std::move(attributes);
- }
-
- auto HostingObject::createMirroredServer(RemoteObjectPtr rObject) -> ResourceObjectPtr
- {
- if (rObject == nullptr)
- {
- throw RCSPlatformException(OC_STACK_ERROR);
- }
-
- std::string fulluri = rObject->getUri();
- std::string uri = fulluri.substr(0, fulluri.size() - sizeofHostingTag);
- std::vector<std::string> types = rObject->getTypes();
- std::vector<std::string> interfaces = rObject->getInterfaces();
- try
- {
- auto resourceBuild = RCSResourceObject::Builder(uri, types[0], interfaces[0]);
- for (unsigned int i = 1; i < types.size(); ++i)
- {
- resourceBuild.addType(types[i]);
- }
- for (unsigned int i = 1; i < interfaces.size(); ++i)
- {
- resourceBuild.addInterface(interfaces[i]);
- }
- auto retResource = resourceBuild.build();
-
- retResource->setAutoNotifyPolicy(RCSResourceObject::AutoNotifyPolicy::UPDATED);
- retResource->setSetRequestHandler(
- std::bind(&HostingObject::setRequestHandler, this,
- std::placeholders::_1, std::placeholders::_2));
- return retResource;
- }
- catch (...)
- {
- OIC_HOSTING_LOG(DEBUG, "[HostingObject::createMirroredServer] %s", "Exception");
- throw;
- }
- }
-
- RCSSetResponse HostingObject::setRequestHandler(const RCSRequest & primitiveRequest,
- RCSResourceAttributes & resourceAttibutes)
- {
- try
- {
- RequestObject::invokeRequest(getRemoteResource(),
- primitiveRequest, RequestObject::RequestMethod::Set, resourceAttibutes);
-
- }
- catch (const RCSPlatformException & e)
- {
- OIC_HOSTING_LOG(DEBUG,
- "[HostingObject::setRequestHandler] PlatformException:%s",
- e.what());
- throw;
- }
-
- return RCSSetResponse::separate();
- }
-
- } /* namespace Service */
-} /* namespace OIC */
+++ /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 RH_HOSTINGOBJECT_H_
-#define RH_HOSTINGOBJECT_H_
-
-#include "logger.h"
-
-#include "RCSRemoteResourceObject.h"
-#include "RCSResourceObject.h"
-
-#ifdef _MSC_VER
-#define OIC_HOSTING_LOG(level, fmt, ...) OIC_LOG_V((level), PCF("Hosting"), fmt, __VA_ARGS__)
-#else
-#define OIC_HOSTING_LOG(level, fmt, args...) OIC_LOG_V((level), PCF("Hosting"), fmt, ##args)
-#endif
-
-namespace OIC
-{
- namespace Service
- {
-
- class HostingObject
- {
- private:
- typedef RCSResourceObject::Ptr ResourceObjectPtr;
- typedef RCSRemoteResourceObject::Ptr RemoteObjectPtr;
-
- public:
- typedef std::shared_ptr<HostingObject> Ptr;
- typedef std::weak_ptr<HostingObject> wPtr;
-
- typedef std::function<void()> DestroyedCallback;
- typedef RCSRemoteResourceObject::StateChangedCallback BrokerCallback;
- typedef RCSRemoteResourceObject::CacheUpdatedCallback CacheCallback;
- typedef RCSResourceObject::SetRequestHandler SetRequestHandler;
-
- public:
- HostingObject();
- ~HostingObject();
-
- HostingObject(const HostingObject &) = delete;
- HostingObject & operator = (const HostingObject &) = delete;
-
- HostingObject(HostingObject &&) = delete;
- HostingObject & operator = (HostingObject &&) = delete;
-
- static HostingObject::Ptr createHostingObject(const RemoteObjectPtr & rResource,
- DestroyedCallback destroyCB);
-
- RemoteObjectPtr getRemoteResource() const;
-
- private:
- RemoteObjectPtr remoteObject;
- ResourceObjectPtr mirroredServer;
-
- CacheCallback pDataUpdateCB;
- DestroyedCallback pDestroyCB;
-
- std::mutex mutexForCB;
-
- ResourceObjectPtr createMirroredServer(RemoteObjectPtr rObject);
-
- RCSSetResponse setRequestHandler(
- const RCSRequest & request, RCSResourceAttributes & attributes);
-
- void destroyHostingObject();
-
- public:
- void stateChangedCB(ResourceState state);
- void dataChangedCB(const RCSResourceAttributes & attributes);
- };
-
- } /* namespace Service */
-} /* namespace OIC */
-
-#endif /* RH_HOSTINGOBJECT_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 "RequestObject.h"
-
-#include "RCSResourceObject.h"
-#include "RCSSeparateResponse.h"
-
-namespace OIC
-{
- namespace Service
- {
- void RequestObject::invokeRequest(RCSRemoteResourceObject::Ptr remoteObject,
- const RCSRequest & request, RequestMethod method,
- const RCSResourceAttributes & resourceAttibutes, SetRequestCallback setCB)
- {
- RequestObject::Ptr createdRequestObject = std::make_shared<RequestObject>();
-
- RCSRequest req(request.getResourceObject().lock(), request.getOCRequest());
- switch (method)
- {
- case RequestMethod::Set:
- {
- if (!setCB)
- {
- remoteObject->setRemoteAttributes(resourceAttibutes,
- std::bind(&RequestObject::setRequestCB, createdRequestObject,
- std::placeholders::_1, std::placeholders::_2,
- req, createdRequestObject));
- }
- else
- {
- remoteObject->setRemoteAttributes(resourceAttibutes,
- std::bind(std::move(setCB),
- std::placeholders::_1, std::placeholders::_2,
- req, createdRequestObject));
- }
- }
- break;
- case RequestMethod::Get:
- case RequestMethod::Delete:
- default:
- {
- // unknown type of method.
- break;
- }
- }
- }
-
- void RequestObject::setRequestCB(
- const RCSResourceAttributes & returnedAttributes, int /*eCode*/,
- const RCSRequest & request, RequestObject::Ptr /*this_ptr*/)
- {
- auto server = request.getResourceObject().lock();
- if (!server)
- {
- return;
- }
-
- RCSResourceObject::LockGuard guard(server);
- server->getAttributes() = RCSResourceAttributes(returnedAttributes);
-
- // TODO need to set error code.
- RCSSeparateResponse(request).set();
- }
-
- } /* namespace Service */
-} /* namespace OIC */
+++ /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 RH_REQUESTOBJECT_H_
-#define RH_REQUESTOBJECT_H_
-
-#include "RCSRemoteResourceObject.h"
-#include "RCSRequest.h"
-
-namespace OIC
-{
- namespace Service
- {
- class RequestObject
- {
- public:
- typedef std::shared_ptr<RequestObject> Ptr;
- typedef std::function<void(const RCSResourceAttributes &, int,
- const RCSRequest &, RequestObject::Ptr)> SetRequestCallback;
-
- enum class RequestMethod
- {
- Get = 0,
- Set,
- Post,
- Delete
- };
-
- private:
- typedef RCSRemoteResourceObject::Ptr RemoteObjectPtr;
-
- public:
- RequestObject() = default;
- ~RequestObject() = default;
-
- static void invokeRequest(RCSRemoteResourceObject::Ptr remoteObject,
- const RCSRequest & request, RequestMethod method,
- const RCSResourceAttributes & resourceAttibutes,
- SetRequestCallback setCB = nullptr);
-
- private:
- void setRequestCB(const RCSResourceAttributes & returnedAttributes, int eCode,
- const RCSRequest & request, RequestObject::Ptr this_ptr);
- };
-
- } /* namespace Service */
-} /* namespace OIC */
-
-#endif /* RH_REQUESTOBJECT_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 "ResourceHosting.h"
-
-#include "RCSDiscoveryManager.h"
-#include "RCSAddress.h"
-
-namespace OIC
-{
- namespace Service
- {
-
- namespace
- {
- const std::string HOSTING_TAG = "/hosting";
- const auto HOSTING_TAG_SIZE = HOSTING_TAG.size();
- const std::string HOSTING_RESOURSE_TYPE = "oic.r.resourcehosting";
- }
-
- ResourceHosting::ResourceHosting()
- : m_mutexForList(),
- m_isStartedHosting(false),
- m_hostingObjects(),
- m_discoveryTask()
- {
- }
-
- ResourceHosting * ResourceHosting::getInstance()
- {
- static ResourceHosting instance;
- return & instance;
- }
-
- void ResourceHosting::startHosting()
- {
- if (m_isStartedHosting)
- {
- return;
- }
- m_isStartedHosting = true;
- createDiscoveryListener();
- }
-
- void ResourceHosting::stopHosting()
- {
- if (!m_isStartedHosting)
- {
- return;
- }
-
- if (!m_discoveryTask->isCanceled())
- {
- m_discoveryTask->cancel();
- }
-
- m_isStartedHosting = false;
-
- RHLock lock(m_mutexForList);
- m_hostingObjects.clear();
- }
-
- void ResourceHosting::createDiscoveryListener()
- {
- m_discoveryTask = RCSDiscoveryManager::getInstance()->discoverResourceByType(
- RCSAddress::multicast(), OC_RSRVD_WELL_KNOWN_URI, HOSTING_RESOURSE_TYPE,
- std::bind(&ResourceHosting::discoveryHandler, this,
- std::placeholders::_1));
- }
-
- void ResourceHosting::discoveryHandler(RemoteObjectPtr remoteResource)
- {
- auto discoverdUri = remoteResource->getUri();
- if (discoverdUri.compare(
- discoverdUri.size()-HOSTING_TAG_SIZE, HOSTING_TAG_SIZE, HOSTING_TAG) != 0)
- {
- return;
- }
-
- auto foundHostingObject = findRemoteResource(remoteResource);
- if (foundHostingObject != nullptr)
- {
- return;
- }
-
- try
- {
- HostingObjectKey key = generateHostingObjectKey(remoteResource);
- foundHostingObject = HostingObject::createHostingObject(remoteResource,
- std::bind(&ResourceHosting::destroyedHostingObject, this, key));
-
- RHLock lock(m_mutexForList);
- m_hostingObjects.insert(std::make_pair(key, foundHostingObject));
-
- }
- catch (const RCSException & e)
- {
- OIC_HOSTING_LOG(DEBUG,
- "[ResourceHosting::discoverHandler]InvalidParameterException:%s", e.what());
- }
- }
-
- HostingObject::Ptr ResourceHosting::findRemoteResource(RemoteObjectPtr remoteResource)
- {
- RHLock lock(m_mutexForList);
-
- auto iter = m_hostingObjects.find(generateHostingObjectKey(remoteResource));
- if (iter != m_hostingObjects.end())
- {
- return iter->second;
- }
-
- return nullptr;
- }
-
- void ResourceHosting::destroyedHostingObject(const HostingObjectKey & key)
- {
- RHLock lock(m_mutexForList);
- m_hostingObjects.erase(key);
- }
-
- ResourceHosting::HostingObjectKey ResourceHosting::generateHostingObjectKey(
- std::string && address, std::string && uri)
- {
- return HostingObjectKey(address + uri);
- }
-
- ResourceHosting::HostingObjectKey ResourceHosting::generateHostingObjectKey(
- const std::string & address, const std::string & uri)
- {
- return generateHostingObjectKey(std::string(address), std::string(uri));
- }
- ResourceHosting::HostingObjectKey ResourceHosting::generateHostingObjectKey(
- RemoteObjectPtr rResource)
- {
- return generateHostingObjectKey(rResource->getAddress(), rResource->getUri());
- }
-
- } /* namespace Service */
-} /* namespace OIC */
+++ /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 RH_RESOURCEHOSTING_H_
-#define RH_RESOURCEHOSTING_H_
-
-#include <atomic>
-#include <functional>
-#include <list>
-#include <memory>
-#include <mutex>
-
-#include "RCSDiscoveryManager.h"
-#include "RCSRemoteResourceObject.h"
-#include "HostingObject.h"
-
-namespace OIC
-{
- namespace Service
- {
-
- class ResourceHosting
- {
- private:
- typedef RCSRemoteResourceObject::Ptr RemoteObjectPtr;
- typedef std::lock_guard<std::mutex> RHLock;
- typedef std::string HostingObjectKey;
-
- typedef std::function<void(RemoteObjectPtr)> DiscoveryCallback;
- typedef HostingObject::DestroyedCallback DestroyedCallback;
-
- public:
- void startHosting();
- void stopHosting();
-
- static ResourceHosting * getInstance();
-
- private:
- ResourceHosting();
- ~ResourceHosting() = default;
-
- ResourceHosting(const ResourceHosting&) = delete;
- ResourceHosting & operator = (const ResourceHosting &) = delete;
-
- ResourceHosting(ResourceHosting &&) = delete;
- ResourceHosting & operator = (ResourceHosting &&) = delete;
-
- std::mutex m_mutexForList;
- std::atomic_bool m_isStartedHosting;
-
- std::unordered_map<HostingObjectKey, HostingObject::Ptr> m_hostingObjects;
- RCSDiscoveryManager::DiscoveryTask::Ptr m_discoveryTask;
-
- void createDiscoveryListener();
- void discoveryHandler(RemoteObjectPtr remoteResource);
-
- HostingObjectKey generateHostingObjectKey(RemoteObjectPtr rResource);
- HostingObjectKey generateHostingObjectKey(std::string && address, std::string && uri);
- HostingObjectKey generateHostingObjectKey(
- const std::string & address, const std::string & uri);
-
- HostingObject::Ptr findRemoteResource(RemoteObjectPtr remoteResource);
-
- void destroyedHostingObject(const HostingObjectKey & key);
- };
-
- } /* namespace Service */
-} /* namespace OIC */
-
-#endif /* RH_RESOURCEHOSTING_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 <memory>
-
-#include "ResourceEncapsulationTestSimulator.h"
-#include "HostingObject.h"
-
-#include "RCSDiscoveryManager.h"
-
-using namespace testing;
-using namespace OIC::Service;
-
-namespace
-{
- const std::string HOSTING_RESOURCE_TYPE = "oic.r.resourcehosting";
- const std::string TEST_ATT_KEY = "Temperature";
-
- bool isStarted = false;
- bool isFinished = false;
-
- ResourceEncapsulationTestSimulator testObject;
- RCSRemoteResourceObject::Ptr remoteObject;
-
- HostingObject::Ptr instance;
- RCSRemoteResourceObject::Ptr discoveredResource;
-
- std::condition_variable responseCon;
-
- void onDestroy() { }
- void onDiscoveryResource(RCSRemoteResourceObject::Ptr){ }
- void onUpdatedCache(const RCSResourceAttributes &) { }
- void onSetAttributes(const RCSResourceAttributes &, int) { }
-
- void setup()
- {
- if(!isStarted)
- {
- testObject.defaultRunSimulator();
- remoteObject = testObject.getRemoteResource();
-
- instance = HostingObject::createHostingObject(
- remoteObject, &onDestroy);
-
- testObject.getResourceServer()->setAttribute(
- "Temperature", RCSResourceAttributes::Value((int)0));
-
- isStarted = true;
- }
- }
-
- void tearDown()
- {
- if(isFinished)
- {
- testObject.destroy();
- instance.reset();
- isStarted = false;
- }
- }
-}
-
-class HostingObjectTest : public TestWithMock
-{
-public:
- std::mutex mutexForCondition;
-
-protected:
-
- void SetUp()
- {
- TestWithMock::SetUp();
- setup();
- }
-
- void TearDown()
- {
- TestWithMock::TearDown();
- tearDown();
- }
-
-public:
- void waitForCondition(int waitingTime = 1000)
- {
- std::unique_lock< std::mutex > lock{ mutexForCondition };
- responseCon.wait_for(lock, std::chrono::milliseconds{ waitingTime });
- }
-
- void notifyCondition()
- {
- responseCon.notify_all();
- }
-
-};
-
-TEST_F(HostingObjectTest, startCachingAtInitialize)
-{
- EXPECT_TRUE(remoteObject->isCaching());
-}
-
-TEST_F(HostingObjectTest, startMonitoringAtInitialize)
-{
- ASSERT_TRUE(remoteObject->isMonitoring());
-}
-
-TEST_F(HostingObjectTest, getRemoteResourceisValid)
-{
- ASSERT_EQ(remoteObject->getUri(), instance->getRemoteResource()->getUri());
-}
-
-TEST_F(HostingObjectTest, createMirroredServer)
-{
- int waitForResponse = 1000;
- std::string uri = "";
-
- std::unique_ptr<RCSDiscoveryManager::DiscoveryTask> discoveryTask = { };
-
- waitForCondition(waitForResponse);
- mocks.OnCallFunc(onDiscoveryResource).Do(
- [this, &uri, &discoveryTask]
- (RCSRemoteResourceObject::Ptr ptr)
- {
- if(ptr->getUri() == testObject.getHostedServerUri())
- {
- uri = ptr->getUri();
- discoveredResource = ptr;
- discoveryTask->cancel();
- notifyCondition();
- }
- });
-
- discoveryTask = RCSDiscoveryManager::getInstance()->discoverResourceByType(
- RCSAddress::multicast(), "/oic/res", HOSTING_RESOURCE_TYPE, onDiscoveryResource);
- waitForCondition(waitForResponse);
-
- EXPECT_EQ(testObject.getHostedServerUri(), uri);
-}
-
-TEST_F(HostingObjectTest, UpdateCachedDataWhenChangedOriginResource)
-{
- int waitForResponse = 1000;
- RCSResourceAttributes::Value result = { };
-
- mocks.OnCallFunc(onUpdatedCache).Do(
- [this, &result](const RCSResourceAttributes & att)
- {
- result = att.at(TEST_ATT_KEY);
- notifyCondition();
- });
-
- discoveredResource->startCaching(onUpdatedCache);
- std::this_thread::sleep_for(std::chrono::milliseconds {waitForResponse});
-
- RCSResourceAttributes::Value settingValue = 10;
- testObject.getResourceServer()->setAttribute(TEST_ATT_KEY, settingValue);
- waitForCondition(waitForResponse);
-
- isFinished = true;
-
- EXPECT_EQ(result.toString(), settingValue.toString());
-
-}
-
-TEST_F(HostingObjectTest, SetDataToMirroredResource)
-{
- int waitForResponse = 1000;
- RCSResourceAttributes::Value result = { };
-
- mocks.ExpectCallFunc(onSetAttributes).Do(
- [this, & result](const RCSResourceAttributes &att, int)
- {
- result = att.at(TEST_ATT_KEY);
- notifyCondition();
- });
- RCSResourceAttributes setAttrs;
- RCSResourceAttributes::Value settingValue = 20;
- setAttrs[TEST_ATT_KEY] = settingValue;
- discoveredResource->setRemoteAttributes(setAttrs, onSetAttributes);
- waitForCondition(waitForResponse);
-
- EXPECT_EQ(result.toString(), settingValue.toString());
-}
-
-TEST_F(HostingObjectTest, ExpectCallOnDestroyWhenStopHostingObject)
-{
- int waitForResponse = 1000;
-
- mocks.ExpectCallFunc(onDestroy).Do(
- []()
- {
- responseCon.notify_all();
- });
-
- testObject.destroy();
- instance.reset();
- waitForCondition(waitForResponse);
-}
+++ /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 "ResourceEncapsulationTestSimulator.h"
-#include "RequestObject.h"
-
-using namespace testing;
-using namespace OIC::Service;
-
-namespace
-{
- bool isStarted = false;
- bool isFinished = false;
-
- ResourceEncapsulationTestSimulator testObject;
- RCSRemoteResourceObject::Ptr remoteObject;
-
- void setRequestCB(const RCSResourceAttributes &, int, const RCSRequest &, RequestObject::Ptr)
- {
- }
-
- void setup()
- {
- if(!isStarted)
- {
- testObject.defaultRunSimulator();
- remoteObject = testObject.getRemoteResource();
-
- isStarted = true;
- }
- }
-
- void tearDown()
- {
- if(isFinished)
- {
- testObject.destroy();
- isStarted = false;
- }
- }
-}
-
-class RequestObjectTest : public TestWithMock
-{
-public:
- std::mutex mutexForCondition;
- std::condition_variable responseCon;
-
-protected:
-
- void SetUp()
- {
- TestWithMock::SetUp();
- setup();
- }
-
- void TearDown()
- {
- TestWithMock::TearDown();
- tearDown();
- }
-
-public:
- void waitForCondition(int waitingTime = 1000)
- {
- std::unique_lock< std::mutex > lock{ mutexForCondition };
- responseCon.wait_for(lock, std::chrono::milliseconds{ waitingTime });
- }
-
- void notifyCondition()
- {
- responseCon.notify_all();
- }
-};
-
-TEST_F(RequestObjectTest, invokeRequestExpectCallwithSetter)
-{
- bool isCalled = false;
-
- mocks.ExpectCallFunc(setRequestCB).Do(
- [this, &isCalled](const RCSResourceAttributes &, int,
- const RCSRequest &, RequestObject::Ptr)
- {
- isCalled = true;
- notifyCondition();
- });
-
- RCSResourceAttributes att;
- std::shared_ptr<OC::OCResourceRequest> request;
- RequestObject::invokeRequest(remoteObject, RCSRequest(testObject.getResourceServer(), request),
- RequestObject::RequestMethod::Set, att, setRequestCB);
-
- waitForCondition();
-
- ASSERT_TRUE(isCalled);
-}
+++ /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 <memory>
-#include <mutex>
-#include <atomic>
-#include <condition_variable>
-
-#include "UnitTestHelper.h"
-
-#include "OCPlatform.h"
-#include "RCSDiscoveryManager.h"
-#include "RCSRemoteResourceObject.h"
-#include "RCSResourceObject.h"
-#include "RCSResourceAttributes.h"
-#include "RCSAddress.h"
-
-#include "RequestObject.h"
-
-using namespace testing;
-using namespace OIC::Service;
-
-class ResourceEncapsulationTestSimulator
-{
-public:
- RCSResourceObject::Ptr server;
- RCSRemoteResourceObject::Ptr remoteResource;
-
-private:
- std::mutex mutexForDiscovery;
- std::unique_ptr<RCSDiscoveryManager::DiscoveryTask> discoveryTask;
-
- std::string MULTICASTURI;
- std::string HOSTED_RESOURCEURI;
- std::string RESOURCEURI;
- std::string RESOURCETYPE;
- std::string RESOURCEINTERFACE;
- std::string ATTR_KEY;
- int ATTR_VALUE;
-
-public:
- ResourceEncapsulationTestSimulator()
- :server(nullptr), remoteResource(nullptr),
- mutexForDiscovery(),
- MULTICASTURI("/oic/res"),
- HOSTED_RESOURCEURI("/a/TempHumSensor"),
- RESOURCEURI("/a/TempHumSensor/hosting"),
- RESOURCETYPE("oic.r.resourcehosting"),
- RESOURCEINTERFACE("oic.if.baseline"),
- ATTR_KEY("Temperature"),
- ATTR_VALUE(0)
- { }
- ~ResourceEncapsulationTestSimulator()
- { }
-
-private:
- void onDiscoveryResource(RCSRemoteResourceObject::Ptr resourceObject)
- {
- if (remoteResource != nullptr)
- {
- return;
- }
-
- if (RESOURCEURI.compare(resourceObject->getUri()) != 0)
- {
- return;
- }
-
- remoteResource = resourceObject;
- discoveryTask->cancel();
- mutexForDiscovery.unlock();
- }
-
- void waitForDiscovery()
- {
- std::chrono::milliseconds interval(100);
- while(true)
- {
- if(mutexForDiscovery.try_lock())
- {
- mutexForDiscovery.unlock();
- return;
- }
- std::this_thread::sleep_for(interval);
- }
- }
- void WaitForPtrBeingUnique()
- {
- while((remoteResource && !remoteResource.unique()) || (server && !server.unique()))
- {
- std::this_thread::sleep_for(std::chrono::milliseconds{ 1000 });
- }
- }
-
-public:
- void destroy()
- {
- if(server.use_count()) server.reset();
- if(remoteResource.use_count()) remoteResource.reset();
- WaitForPtrBeingUnique();
- }
- void defaultRunSimulator()
- {
- createResource();
- discoveryResource();
- waitForDiscovery();
- }
-
- void createResource(std::string postUri = "")
- {
- HOSTED_RESOURCEURI = HOSTED_RESOURCEURI + postUri;
- server = RCSResourceObject::Builder(HOSTED_RESOURCEURI + "/hosting",
- RESOURCETYPE, RESOURCEINTERFACE).
- setDiscoverable(true).setObservable(true).build();
- server->setAttribute(ATTR_KEY, RCSResourceAttributes::Value(ATTR_VALUE));
- }
-
- void discoveryResource()
- {
- discoveryResource(RESOURCETYPE);
- }
-
- void discoveryResource(std::string & resourceType)
- {
- try
- {
- discoveryTask = RCSDiscoveryManager::getInstance()->discoverResourceByType(
- RCSAddress::multicast(), MULTICASTURI, resourceType,
- std::bind(
- &ResourceEncapsulationTestSimulator::onDiscoveryResource,
- this, std::placeholders::_1));
- mutexForDiscovery.lock();
- }
- catch(std::exception & e)
- {
- std::cout << "exception : " << e.what() << std::endl;
- }
- }
-
- std::string getServerUri() const
- {
- return RESOURCEURI;
- }
-
- std::string getHostedServerUri() const
- {
- return HOSTED_RESOURCEURI;
- }
-
- RCSResourceObject::Ptr getResourceServer() const
- {
- return server;
- }
-
- RCSRemoteResourceObject::Ptr getRemoteResource() const
- {
- return remoteResource;
- }
-};
+++ /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 <memory>
-
-#include "ResourceEncapsulationTestSimulator.h"
-
-#include "ResourceHosting.h"
-
-using namespace testing;
-using namespace OIC::Service;
-
-namespace
-{
- bool isStarted = false;
- bool isFinished = false;
-
- ResourceEncapsulationTestSimulator testObject;
-
- void onDiscoveryResource(RCSRemoteResourceObject::Ptr) { }
-}
-
-class ResourceHostingTest : public TestWithMock
-{
-public:
- std::mutex mutexForCondition;
- std::condition_variable responseCon;
- std::unique_ptr<RCSDiscoveryManager::DiscoveryTask> discoveryTask;
-
-protected:
-
- void SetUp()
- {
- TestWithMock::SetUp();
- if(!isStarted)
- {
- testObject.createResource("1");
-
- isStarted = true;
- }
- }
-
- void TearDown()
- {
- TestWithMock::TearDown();
-
- if(isFinished)
- {
- testObject.destroy();
- isStarted = false;
- }
- }
-
-public:
- void waitForCondition(int waitingTime = 1000)
- {
- std::unique_lock< std::mutex > lock{ mutexForCondition };
- responseCon.wait_for(lock, std::chrono::milliseconds{ waitingTime });
- }
-
- void notifyCondition()
- {
- responseCon.notify_all();
- }
-
-};
-
-TEST(ResourceHostingSTATICMethodTest, getInstanceAllwaysSameReturnInstance)
-{
- EXPECT_EQ(ResourceHosting::getInstance(), ResourceHosting::getInstance());
-}
-
-TEST_F(ResourceHostingTest, startHosting)
-{
- try
- {
- ResourceHosting::getInstance()->startHosting();
- } catch (...)
- {
- FAIL() << "Non-Expected Exception";
- }
-}
-
-TEST_F(ResourceHostingTest, HostingFoundBeforeMakeOriginServer)
-{
- std::string uri = "";
- testObject.getResourceServer()->setAttribute(
- "Temperature", RCSResourceAttributes::Value((int)0));
- waitForCondition();
-
- mocks.OnCallFunc(onDiscoveryResource).Do(
- [this, &uri](RCSRemoteResourceObject::Ptr ptr)
- {
- if(ptr->getUri() == testObject.getHostedServerUri())
- {
- uri = ptr->getUri();
- discoveryTask->cancel();
- notifyCondition();
- }
- });
-
- discoveryTask = RCSDiscoveryManager::getInstance()->discoverResourceByType(
- RCSAddress::multicast(), "oic.r.resourcehosting", onDiscoveryResource);
- waitForCondition();
-
- std::string mirroredUri = { testObject.getHostedServerUri() };
-
- ASSERT_EQ(mirroredUri, uri);
-}
-
-
-TEST_F(ResourceHostingTest, stopHosting)
-{
- ResourceHosting::getInstance()->stopHosting();
- isFinished = 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.
-#
-#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-##
-# ResourceHosting Unit Test build script
-##
-# SConscript file for Local PKI google tests
-gtest_env = SConscript('#extlibs/gtest/SConscript')
-lib_env = gtest_env.Clone()
-
-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'])
-
-
-SConscript('#service/third_party_libs.scons', 'lib_env')
-
-######################################################################
-#unit test setting
-######################################################################
-src_dir = lib_env.get('SRC_DIR')
-
-hosting_test_env = lib_env.Clone()
-target_os = hosting_test_env.get('TARGET_OS')
-
-######################################################################
-# Build flags
-######################################################################
-
-hosting_test_env.AppendUnique(LIBPATH = [hosting_test_env.get('BUILD_DIR')])
-hosting_test_env.AppendUnique(LIBS = [
- 'resource_hosting', 'rcs_server', 'rcs_client','rcs_common',
- 'oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'coap'])
-
-if target_os not in ['windows']:
- hosting_test_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0'])
-
-hosting_test_env.PrependUnique(CPPPATH = [ src_dir + '/extlibs/hippomocks-master'])
-hosting_test_env.AppendUnique(CPPPATH = ['../src'])
-hosting_test_env.AppendUnique(CPPPATH = ['../../resource-encapsulation/include'])
-hosting_test_env.AppendUnique(CPPPATH = ['../../resource-encapsulation/src/common/primitiveResource/include'])
-hosting_test_env.AppendUnique(CPPPATH = ['../../resource-encapsulation/src/common/utils/include'])
-
-if hosting_test_env.get('SECURED') == '1':
- if hosting_test_env.get('WITH_TCP') == True:
- hosting_test_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509', 'mbedcrypto'])
-
-######################################################################
-# Build Test
-######################################################################
-
-hosting_test_src = hosting_test_env.Glob('./*.cpp')
-hosting_test = hosting_test_env.Program('hosting_test', hosting_test_src)
-Alias("hosting_test", hosting_test)
-hosting_test_env.AppendTarget('hosting_test')
-
-# TODO: fix this test on linux and remove commented lines
-if hosting_test_env.get('TEST') == '1':
- target_os = hosting_test_env.get('TARGET_OS')
- if target_os in ['linux']:
- from tools.scons.RunTest import run_test
- run_test(hosting_test_env,
-# 'service_resource-hosting_unittest_hosting_test.memcheck',
- '',
- 'service/resource-hosting/unittest/hosting_test')