[IOT-1065][IOT-1069] RC - Tizen: sample application fix
authorMarkus Jung <markus.jung@samsung.com>
Tue, 5 Apr 2016 04:38:40 +0000 (13:38 +0900)
committerHabib Virji <habib.virji@samsung.com>
Thu, 28 Apr 2016 15:21:47 +0000 (15:21 +0000)
- Correct sample configuration
- Deactivate notification on bundle resource initialization
- Remove BMI related UI for Tizen. Soft-sensors cannot be configered at runtime.
  This will be a feature for the next release.
- Removed async bundle activation which is causing crashes in Tizen

Change-Id: Id87a36b1cb27d4267433823494415e35d2c6acee
Signed-off-by: Markus Jung <markus.jung@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/7593
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
(cherry picked from commit 08ee7c41e9b7bb64243fd1dc1f416e53aad6f1d1)
Reviewed-on: https://gerrit.iotivity.org/gerrit/7623
Reviewed-by: Habib Virji <habib.virji@samsung.com>
service/resource-container/examples/HueSampleBundle/src/HueLight.cpp
service/resource-container/examples/tizen/ContainerServerApp/lib/ResourceContainerConfig.xml
service/resource-container/examples/tizen/ContainerServerApp/src/container.cpp
service/resource-container/src/BundleResource.cpp
service/resource-container/src/ResourceContainerImpl.cpp
service/resource-container/src/ResourceContainerImpl.h

index 90ae1a1..ba77414 100644 (file)
@@ -44,9 +44,9 @@ HueLight::~HueLight()
 
 void HueLight::initAttributes()
 {
-    BundleResource::setAttribute("on-off", false);
-    BundleResource::setAttribute("dim", 0);
-    BundleResource::setAttribute("color", 0);
+    BundleResource::setAttribute("on-off", false, false);
+    BundleResource::setAttribute("dim", 0, false);
+    BundleResource::setAttribute("color", 0, false);
 }
 
 RCSResourceAttributes HueLight::handleGetAttributesRequest()
index 3dfc9a9..9938053 100644 (file)
@@ -6,11 +6,11 @@
         <activator>huesample</activator>
         <version>1.0.0</version>
         <resources>
-            <resourceInfo>
-                <name>light</name>
-                <resourceType>oic.r.control</resourceType>
-                <address>http://192.168.0.2/api/newdeveloper/lights/1</address>
-            </resourceInfo>
+            
         </resources>
-    </bundle>
+    </bundle>       
 </container>
+
+
+
+
index eb5572b..64652d5 100644 (file)
@@ -528,18 +528,6 @@ void *showContainerAPIs(void *data)
         elm_list_item_append(listnew, "4. Remove HUE Bundle Resource", NULL, NULL,
                              removeHueResourceConfig, NULL);
 
-        elm_list_item_append(listnew, "5. Add BMI Bundle", NULL, NULL,
-                             addBMIBundle, NULL);
-
-        elm_list_item_append(listnew, "6. Start BMI Bundle", NULL, NULL,
-                             startBMIBundle, NULL);
-
-        elm_list_item_append(listnew, "7. Remove BMI Bundle", NULL, NULL,
-                             removeBMIBundle, NULL);
-
-        elm_list_item_append(listnew, "8. Stop BMI Bundle", NULL, NULL,
-                             stopBMIBundle, NULL);
-
         elm_list_go(listnew);
     }
     return NULL;
@@ -593,8 +581,8 @@ static void stopContainer(void *data, Evas_Object *obj, void *event_info)
     if (checkContainer)
     {
         s_containerFlag = false;
-        removeHueBundle(NULL, NULL, NULL);
         stopHueBundle(NULL, NULL, NULL);
+        removeHueBundle(NULL, NULL, NULL);
 
         container->stopContainer();
         logMessage += "CONTAINER STOPPED<br>";
index 5b38edc..f39e77c 100644 (file)
@@ -32,7 +32,7 @@ namespace OIC
 {
     namespace Service
     {
-        BundleResource::BundleResource() : m_pNotiReceiver(nullptr)
+        BundleResource::BundleResource() : m_pNotiReceiver(nullptr), m_resourceAttributes_mutex()
         {
 
         }
index 328fe50..1cbbd62 100644 (file)
@@ -68,58 +68,53 @@ namespace OIC
 
 
             activationLock.lock();
-            if (!configFile.empty())
-            {
-                m_config = new Configuration(configFile);
-
-                if (m_config->isLoaded())
+            try{
+                if (!configFile.empty())
                 {
-                    configInfo bundles;
-                    m_config->getConfiguredBundles(&bundles);
+                    m_config = new Configuration(configFile);
 
-                    for (unsigned int i = 0; i < bundles.size(); i++)
+                    if (m_config->isLoaded())
                     {
-                        shared_ptr<BundleInfoInternal> bundleInfo(new BundleInfoInternal);
-                        bundleInfo->setPath(bundles[i][BUNDLE_PATH]);
-                        bundleInfo->setVersion(bundles[i][BUNDLE_VERSION]);
-                        bundleInfo->setID(bundles[i][BUNDLE_ID]);
-                        if (!bundles[i][BUNDLE_ACTIVATOR].empty())
+                        configInfo bundles;
+                        m_config->getConfiguredBundles(&bundles);
+
+                        for (unsigned int i = 0; i < bundles.size(); i++)
                         {
-                            string activatorName = bundles[i][BUNDLE_ACTIVATOR];
-                            std::replace(activatorName.begin(), activatorName.end(), '.', '/');
-                            bundleInfo->setActivatorName(activatorName);
-                            bundleInfo->setLibraryPath(bundles[i][BUNDLE_LIBRARY_PATH]);
-                        }
+                            shared_ptr<BundleInfoInternal> bundleInfo(new BundleInfoInternal);
+                            bundleInfo->setPath(bundles[i][BUNDLE_PATH]);
+                            bundleInfo->setVersion(bundles[i][BUNDLE_VERSION]);
+                            bundleInfo->setID(bundles[i][BUNDLE_ID]);
+                            if (!bundles[i][BUNDLE_ACTIVATOR].empty())
+                            {
+                                string activatorName = bundles[i][BUNDLE_ACTIVATOR];
+                                std::replace(activatorName.begin(), activatorName.end(), '.', '/');
+                                bundleInfo->setActivatorName(activatorName);
+                                bundleInfo->setLibraryPath(bundles[i][BUNDLE_LIBRARY_PATH]);
+                            }
 
-                        OIC_LOG_V(INFO, CONTAINER_TAG, "Init Bundle:(%s)",
-                                 std::string(bundles[i][BUNDLE_ID] + ";" +
-                                             bundles[i][BUNDLE_PATH]).c_str());
+                            OIC_LOG_V(INFO, CONTAINER_TAG, "Init Bundle:(%s)",
+                                     std::string(bundles[i][BUNDLE_ID] + ";" +
+                                                 bundles[i][BUNDLE_PATH]).c_str());
 
-                        registerBundle(bundleInfo);
-                        activateBundle(bundleInfo);
+                            registerBundle(bundleInfo);
+                            activateBundle(bundleInfo);
+                        }
+                    }
+                    else
+                    {
+                        OIC_LOG_V(ERROR, CONTAINER_TAG, "Container started with invalid configfile path.");
                     }
                 }
                 else
                 {
-                    OIC_LOG_V(ERROR, CONTAINER_TAG, "Container started with invalid configfile path.");
+                    OIC_LOG_V(INFO, CONTAINER_TAG, "No configuration file for the container provided.");
                 }
-            }
-            else
-            {
-                OIC_LOG_V(INFO, CONTAINER_TAG, "No configuration file for the container provided.");
-            }
-
-            map<std::string, boost::thread >::iterator activatorIterator;
 
-            for (activatorIterator = m_activators.begin(); activatorIterator != m_activators.end();
-                 activatorIterator++)
-            {
-                activatorIterator->second.timed_join(
-                    boost::posix_time::seconds(BUNDLE_ACTIVATION_WAIT_SEC));
-                // wait for bundles to be activated
+                OIC_LOG(INFO, CONTAINER_TAG, "Resource container started.");
+            }catch(...){
+                OIC_LOG(INFO, CONTAINER_TAG, "Resource container failed starting.");
             }
             activationLock.unlock();
-            OIC_LOG(INFO, CONTAINER_TAG, "Resource container started.");
         }
 
         void ResourceContainerImpl::stopContainer()
@@ -178,11 +173,15 @@ namespace OIC
         {
             OIC_LOG_V(INFO, CONTAINER_TAG, "Activating bundle: (%s)",
                      std::string(m_bundles[id]->getID()).c_str());
+
             activationLock.lock();
-            auto f = std::bind(&ResourceContainerImpl::activateBundleThread, this,
-                               id);
-            boost::thread activator(f);
-            activator.timed_join(boost::posix_time::seconds(BUNDLE_SET_GET_WAIT_SEC));
+            try{
+                activateBundleThread(id);
+            }
+            catch(...){
+                OIC_LOG_V(INFO, CONTAINER_TAG, "Activating bundle: (%s) failed",
+                                     std::string(m_bundles[id]->getID()).c_str());
+            }
             activationLock.unlock();
             OIC_LOG_V(INFO, CONTAINER_TAG, "Bundle activated: (%s)",
                      std::string(m_bundles[id]->getID()).c_str());
index b7cb614..5d5f81b 100644 (file)
@@ -107,8 +107,6 @@ namespace OIC
                 //<uri, DiscoverUnit>
                 string m_configFile;
                 Configuration *m_config;
-                // holds for a bundle the threads for bundle activation
-                map< std::string, boost::thread > m_activators;
                 // used for synchronize the resource registration of multiple bundles
                 std::mutex registrationLock;
                 // used to synchronize the startup of the container with other operation