Resolved build errors for Sample Server application.
Change-Id: I96065e2b9eb8a85cb5936fb55e769bb33a25e252
Signed-off-by: arya.k <arya.kumar@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2474
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
description
{
rel1.relative: 0.01 0.01;
- rel2.relative: 0.5 0.09;
+ rel2.relative: 0.7 0.09;
}
}
part
--- /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.
+ *
+ ******************************************************************/
+
+group
+{
+ name: "container_layout";
+ parts
+ {
+ part
+ {
+ name: "listnew";
+ type: SWALLOW;
+ scale: 1;
+ description
+ {
+ rel1.relative: 0.01 0.1;
+ rel2.relative: 0.99 0.7;
+ }
+ }
+ part
+ {
+ name: "log_bg";
+ type: RECT;
+ scale: 1;
+ description
+ {
+ state: "default" 0.0;
+ rel1.relative: 0.01 0.71;
+ rel2.relative: 0.98 1.0;
+ color: 220 220 220 255;
+ }
+ }
+ part
+ {
+ name: "log";
+ type: SWALLOW;
+ scale: 1;
+ description
+ {
+ rel1.to: "log_bg";
+ rel2.to: "log_bg";
+ }
+ }
+ }
+}
+
+group
+{
+ name: "popup_datetime_text";
+ parts
+ {
+ part
+ {
+ name: "pad_l";
+ type: SPACER;
+ scale: 1;
+ description
+ {
+ state: "default" 0.0;
+ min: POPUP_CONTENT_DEFAULT_PADDING_LEFT_MIN_INC 0;
+ fixed: 1 0;
+ rel1.relative: 0.0 0.0;
+ rel2.relative: 0.0 1.0;
+ align: 0.0 0.0;
+ }
+ }
+ part
+ {
+ name: "pad_r";
+ type: SPACER;
+ scale: 1;
+ description
+ {
+ state: "default" 0.0;
+ min: POPUP_CONTENT_DEFAULT_PADDING_LEFT_MIN_INC 0;
+ fixed: 1 0;
+ rel1.relative: 1.0 0.0;
+ rel2.relative: 1.0 1.0;
+ align: 1.0 0.0;
+ }
+ }
+ part
+ {
+ name: "elm.swallow.content";
+ type: SWALLOW;
+ scale: 1;
+ description
+ {
+ state: "default" 0.0;
+ min: 0 POPUP_EDITFIELD_LAYOUT_MINMAX_HEIGHT_INC;
+ max: -1 POPUP_EDITFIELD_LAYOUT_MINMAX_HEIGHT_INC;
+ align: 0.5 0.5;
+ rel1
+ {
+ relative: 1.0 0.0;
+ to_x: "pad_l";
+ }
+ rel2
+ {
+ relative: 0.0 1.0;
+ to_x: "pad_r";
+ }
+ }
+ }
+ }
+}
*
******************************************************************/
-#ifndef __RECLIENT_H__
-#define __RECLIENT_H__
+#ifndef RECLIENT_H__
+#define RECLIENT_H__
typedef void(*ClientMenuHandler)();
typedef int ReturnValue;
-void *showGroupAPIs(void *data);
+void *showClientAPIs(void *data);
-#endif // __RECLIENT_H__
+#endif // RECLIENT_H__
\ No newline at end of file
*
******************************************************************/
-#ifndef __RECLIENTMAIN_H__
-#define __RECLIENTMAIN_H__
+#ifndef RECLIENTMAIN_H__
+#define RECLIENTMAIN_H__
#include <app.h>
#include <Elementary.h>
void group_cb(void *data, Evas_Object *obj, void *event_info);
-#endif // __RECLIENTMAIN_H__
+void containerCreateUI(void *data, Evas_Object *obj, void *event_info);
+
+#endif // RECLIENTMAIN_H__
\ No newline at end of file
--- /dev/null
+/******************************************************************
+ *
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************/
+
+#include "reclientmain.h"
+
+#include "RCSRemoteResourceObject.h"
+
+#include <app.h>
+#include <Elementary.h>
+#include <system_settings.h>
+#include <efl_extension.h>
+#include <dlog.h>
+
+#ifndef RECONTAINER_H__
+#define RECONTAINER_H__
+
+# define LOG_TAG "recontainerclient"
+
+using namespace OIC::Service;
+
+void *showContainerAPIs(void *data);
+
+void onContainerDiscovered(std::shared_ptr<RCSRemoteResourceObject> foundResource);
+
+static void find_resource_cb(void *data, Evas_Object *obj, void *event_info);
+
+static void findLight(void *data, Evas_Object *obj, void *event_info);
+
+static void findSoftsensor(void *data, Evas_Object *obj, void *event_info);
+
+#endif // RECONTAINER_H__
\ No newline at end of file
{
base_scale: 1.8;
#include "../edc_resource/re_client_control.edc"
+ #include "../edc_resource/re_container_control.edc"
}
\ No newline at end of file
resource = foundResource;
- ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))showGroupAPIs, NULL);
+ ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))showClientAPIs, NULL);
cond.notify_all();
}
evas_object_show(popup);
}
-void *showGroupAPIs(void *data)
+// Method to be called when the Discover Resource UI Button is selected
+static void
+find_resource_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ if (NULL != list)
+ {
+ discoverResource();
+ }
+ else
+ {
+ dlog_print(DLOG_ERROR, "find_resource_cb", "list is NULL - So unable to add items!!!");
+ }
+}
+
+void *showClientAPIs(void *data)
{
// Add items to the list only if the list is empty
const Eina_List *eina_list = elm_list_items_get(list);
Evas_Object *layout;
Evas_Object *scroller;
Evas_Object *nf = (Evas_Object *)data;
+ Evas_Object *find_button;
Elm_Object_Item *nf_it;
naviframe = nf;
elm_object_content_set(scroller, layout);
+ // Button
+ find_button = elm_button_add(layout);
+ elm_object_part_content_set(layout, "find_button", find_button);
+ elm_object_text_set(find_button, "Discover Resource");
+ evas_object_smart_callback_add(find_button, "clicked", find_resource_cb, NULL);
+
// List
list = elm_list_add(layout);
elm_list_mode_set(list, ELM_LIST_COMPRESS);
nf_it = elm_naviframe_item_push(nf, "Resource Encapsulation", NULL, NULL, scroller, NULL);
elm_naviframe_item_pop_cb_set(nf_it, naviframe_pop_cb, NULL);
-
- discoverResource();
}
evas_object_smart_callback_add(list, "selected", list_selected_cb, NULL);
// Main Menu Items Here
- elm_list_item_append(list, "Discover Resource", NULL, NULL, group_cb, nf);
+ elm_list_item_append(list, "Resource Client", NULL, NULL, group_cb, nf);
+
+ elm_list_item_append(list, "Resource Container", NULL, NULL, containerCreateUI, nf);
elm_list_go(list);
--- /dev/null
+/******************************************************************
+ *
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************/
+
+#include "recontainerclient.h"
+
+#include "reclientmain.h"
+#include "RCSDiscoveryManager.h"
+#include "RCSResourceAttributes.h"
+#include "RCSAddress.h"
+
+#include <string>
+#include "mutex"
+#include "condition_variable"
+
+using namespace std;
+using namespace OC;
+using namespace OIC::Service;
+
+std::shared_ptr<RCSRemoteResourceObject> g_containerResource;
+
+const std::string resourceTypeLight = "?rt=oic.light.control";
+const std::string resourceTypeSoftsensor = "?rt=oic.softsensor";
+const std::string targetLightUri = OC_RSRVD_WELL_KNOWN_URI + resourceTypeLight;
+const std::string targetSoftsensorUri = OC_RSRVD_WELL_KNOWN_URI + resourceTypeSoftsensor;
+
+std::mutex g_containerMtx;
+std::condition_variable g_containerCond;
+
+static Evas_Object *log_entry = NULL;
+static Evas_Object *listnew = NULL;
+static Evas_Object *naviframe = NULL;
+
+// Function to update the log in UI
+void *updateContainerLog(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 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 onDestroy()
+{
+ g_containerResource = NULL;
+}
+
+void onContainerDiscovered(std::shared_ptr<RCSRemoteResourceObject> foundResource)
+{
+ dlog_print(DLOG_INFO, LOG_TAG, "#### onResourceDiscovered callback");
+
+ std::string resourceURI = foundResource->getUri();
+ std::string hostAddress = foundResource->getAddress();
+
+ dlog_print(DLOG_INFO, LOG_TAG, "#### Resource URI : %s", resourceURI.c_str());
+ dlog_print(DLOG_INFO, LOG_TAG, "#### Resource Host : %S", hostAddress.c_str());
+
+ string logMessage = "Resource Found <br>";
+ logMessage = logMessage + "URI: " + resourceURI + "<br>";
+ logMessage = logMessage + "Host:" + hostAddress + "<br>";
+ logMessage += "----------------------<br>";
+ dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
+ ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateContainerLog,
+ &logMessage);
+
+ g_containerResource = foundResource;
+
+ ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))showContainerAPIs, NULL);
+ g_containerCond.notify_all();
+}
+
+void *showContainerAPIs(void *data)
+{
+ // Add items to the list only if the list is empty
+ const Eina_List *eina_list = elm_list_items_get(listnew);
+ int count = eina_list_count(eina_list);
+ if (!count)
+ {
+ elm_list_item_append(listnew, "1. Find Light resource", NULL, NULL,
+ findLight, NULL);
+
+ elm_list_item_append(listnew, "1. Find Softsensor resource", NULL, NULL,
+ findSoftsensor, NULL);
+
+ elm_list_go(listnew);
+ }
+ return NULL;
+}
+
+static void findLight(void *data, Evas_Object *obj, void *event_info)
+{
+ dlog_print(DLOG_INFO, LOG_TAG, "#### Wait 2 seconds until discovered");
+
+ RCSDiscoveryManager::getInstance()->discoverResource(RCSAddress::multicast(), targetLightUri,
+ &onContainerDiscovered);
+
+ std::unique_lock<std::mutex> lck(g_containerMtx);
+ g_containerCond.wait_for(lck, std::chrono::seconds(2));
+
+ dlog_print(DLOG_INFO, LOG_TAG, "#### Light Discovery over");
+}
+
+static void findSoftsensor(void *data, Evas_Object *obj, void *event_info)
+{
+ dlog_print(DLOG_INFO, LOG_TAG, "#### Wait 2 seconds until discovered");
+
+ RCSDiscoveryManager::getInstance()->discoverResource(RCSAddress::multicast(), targetSoftsensorUri,
+ &onContainerDiscovered);
+
+ std::unique_lock<std::mutex> lck(g_containerMtx);
+ g_containerCond.wait_for(lck, std::chrono::seconds(2));
+
+ dlog_print(DLOG_INFO, LOG_TAG, "#### Softsensor Discovery over");
+}
+
+static Eina_Bool
+naviframe_pop_cb(void *data, Elm_Object_Item *it)
+{
+ onDestroy();
+
+ if (NULL != log_entry)
+ {
+ evas_object_del(log_entry);
+ log_entry = NULL;
+ }
+ if (NULL != listnew)
+ {
+ evas_object_del(listnew);
+ listnew = NULL;
+ }
+ return EINA_TRUE;
+}
+
+// Method to set up server screens
+void containerCreateUI(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *layout;
+ Evas_Object *scroller;
+ Evas_Object *nf = (Evas_Object *)data;
+ 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, "container_layout");
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ elm_object_content_set(scroller, layout);
+
+ // List
+ listnew = elm_list_add(layout);
+ elm_list_mode_set(listnew, ELM_LIST_COMPRESS);
+ evas_object_smart_callback_add(listnew, "selected", list_selected_cb, NULL);
+ elm_object_part_content_set(layout, "listnew", listnew);
+ elm_list_go(listnew);
+
+ // log_entry - text area for log
+ log_entry = elm_entry_add(layout);
+ elm_entry_scrollable_set(log_entry, EINA_TRUE);
+ elm_entry_editable_set(log_entry, EINA_FALSE);
+ elm_object_part_text_set(log_entry, "elm.guide", "Logs will be updated here!!!");
+ evas_object_size_hint_weight_set(log_entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(log_entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_object_part_content_set(layout, "log", log_entry);
+
+ nf_it = elm_naviframe_item_push(nf, "Resource Container", NULL, NULL, scroller, NULL);
+ elm_naviframe_item_pop_cb_set(nf_it, naviframe_pop_cb, NULL);
+
+ // Show the UI list of group APIs
+ ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))showContainerAPIs, NULL);
+}
#include "remain.h"
-#ifndef __RECONTAINER_H__
-#define __RECONTAINER_H__
+#ifndef RECONTAINER_H__
+#define RECONTAINER_H__
# define LOG_TAG "recontainer"
static void stopContainer(void *data, Evas_Object *obj, void *event_info);
-#endif // __RECONTAINER_H__
+#endif // RECONTAINER_H__
*
******************************************************************/
-#ifndef __REMAIN_H__
-#define __REMAIN_H__
+#ifndef REMAIN_H__
+#define REMAIN_H__
#include <app.h>
#include <Elementary.h>
void containerCreateUI(void *data, Evas_Object *obj, void *event_info);
-#endif // __REMAIN_H__
+#endif // REMAIN_H__
\ No newline at end of file
#include "RCSResourceObject.h"
-#ifndef __RESERVER_H__
-#define __RESERVER_H__
+#ifndef RESERVER_H__
+#define RESERVER_H__
using namespace std;
using namespace OIC::Service;
void *showGroupAPIs(void *data);
-#endif // __RESERVER_H__
+#endif // RESERVER_H__
\ No newline at end of file
*
******************************************************************/
-#ifndef __RESERVERMAIN_H__
-#define __RESERVERMAIN_H__
+#ifndef RESERVERMAIN_H__
+#define RESERVERMAIN_H__
#include <app.h>
#include <Elementary.h>
void start_server_cb(void *data, Evas_Object *obj, void *event_info);
-#endif // __RESERVERMAIN_H__
+#endif // RESERVERMAIN_H__
\ No newline at end of file
nf_it = elm_naviframe_item_push(nf, "Resource Encapsulation", btn, NULL, list, NULL);
elm_naviframe_item_pop_cb_set(nf_it, naviframe_pop_cb, ad->win);
}
-
-
-static void
-create_base_gui(appdata_s *ad)
-{
- // Window
- ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
- elm_win_conformant_set(ad->win, EINA_TRUE);
- elm_win_autodel_set(ad->win, EINA_TRUE);
-
- if (elm_win_wm_rotation_supported_get(ad->win))
- {
- int rots[4] = { 0, 90, 180, 270 };
- elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
- }
-
- evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);
-
- // Conformant
- ad->conform = elm_conformant_add(ad->win);
- evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_win_resize_object_add(ad->win, ad->conform);
- evas_object_show(ad->conform);
-
- // Base Layout
- ad->layout = elm_layout_add(ad->conform);
- evas_object_size_hint_weight_set(ad->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_layout_theme_set(ad->layout, "layout", "application", "default");
- evas_object_show(ad->layout);
-
- elm_object_content_set(ad->conform, ad->layout);
-
- // Naviframe
- ad->nf = elm_naviframe_add(ad->layout);
- create_list_view(ad);
- elm_object_part_content_set(ad->layout, "elm.swallow.content", ad->nf);
- eext_object_event_callback_add(ad->nf, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
- eext_object_event_callback_add(ad->nf, EEXT_CALLBACK_MORE, eext_naviframe_more_cb, NULL);
-
- // Show window after base gui is set up
- evas_object_show(ad->win);
-}
-
-// Configures the OCPlatform
-static void
-configure_platform()
-{
- try
- {
- PlatformConfig config
- { OC::ServiceType::InProc, ModeType::Server, "0.0.0.0", 0, OC::QualityOfService::LowQos };
-
- OCPlatform::Configure(config);
-
- dlog_print(DLOG_INFO, LOG_TAG, "#### Platform configuration done!!!!");
- }
- catch (OCException &e)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "Exception occured! (%s)", e.what());
- }
-}
-
-static bool
-app_create(void *data)
-{
- /* Hook to take necessary actions before main event loop starts
- Initialize UI resources and application's data
- If this function returns true, the main loop of application starts
- If this function returns false, the application is terminated */
- appdata_s *ad = (appdata_s *)data;
-
- elm_app_base_scale_set(1.8);
-
- create_base_gui(ad);
-
- configure_platform();
-
- return true;
-}
-
-static void
-app_control(app_control_h app_control, void *data)
-{
- // Handle the launch request.
-}
-
-static void
-app_pause(void *data)
-{
- // Take necessary actions when application becomes invisible.
-}
-
-static void
-app_resume(void *data)
-{
- // Take necessary actions when application becomes visible.
-}
-
-static void
-app_terminate(void *data)
-{
- // Release all resources.
-}
-
-static void
-ui_app_lang_changed(app_event_info_h event_info, void *user_data)
-{
- // APP_EVENT_LANGUAGE_CHANGED
- char *locale = NULL;
- system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
- elm_language_set(locale);
- free(locale);
- return;
-}
-
-static void
-ui_app_orient_changed(app_event_info_h event_info, void *user_data)
-{
- // APP_EVENT_DEVICE_ORIENTATION_CHANGED
- return;
-}
-
-static void
-ui_app_region_changed(app_event_info_h event_info, void *user_data)
-{
- // APP_EVENT_REGION_FORMAT_CHANGED
-}
-
-static void
-ui_app_low_battery(app_event_info_h event_info, void *user_data)
-{
- // APP_EVENT_LOW_BATTERY
-}
-
-static void
-ui_app_low_memory(app_event_info_h event_info, void *user_data)
-{
- // APP_EVENT_LOW_MEMORY
-}
-
-int
-main(int argc, char *argv[])
-{
- appdata_s ad = {0,};
- int ret = 0;
-
- ui_app_lifecycle_callback_s event_callback = {0,};
- app_event_handler_h handlers[5] = {NULL, };
-
- event_callback.create = app_create;
- event_callback.terminate = app_terminate;
- event_callback.pause = app_pause;
- event_callback.resume = app_resume;
- event_callback.app_control = app_control;
-
- ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY,
- ui_app_low_battery, &ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY,
- ui_app_low_memory, &ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED],
- APP_EVENT_DEVICE_ORIENTATION_CHANGED,
- ui_app_orient_changed, &ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED],
- APP_EVENT_LANGUAGE_CHANGED,
- ui_app_lang_changed, &ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED],
- APP_EVENT_REGION_FORMAT_CHANGED,
- ui_app_region_changed, &ad);
- ui_app_remove_event_handler(handlers[APP_EVENT_LOW_MEMORY]);
-
- ret = ui_app_main(argc, argv, &event_callback, &ad);
- if (APP_ERROR_NONE != ret)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "app_main() is failed. err = %d", ret);
- }
- return ret;
-}