Change language for existing boxes on reloading when system language is changed.
authorleerang song <leerang.song@samsung.com>
Tue, 10 Sep 2013 12:04:06 +0000 (21:04 +0900)
committerSoo-Hyun Choi <sh9.choi@samsung.com>
Thu, 12 Sep 2013 04:31:38 +0000 (13:31 +0900)
[Issue#]     N/A
[Problem]    DynamicBox language is not changed after systme language is changed.
[Cause]      Not suppport language changing after systme language is changed.
[Solution]   Add callback called when system language is changed.
             1. web-provider triggers language system change directly.
             2. and then, web-provider set update flags of all boxes after change

[SCMRequest] N/A

Change-Id: I26e15bce4d0a801648e144292c3072bdcfca982f

src/Core/Box.cpp
src/Core/Box.h
src/Core/BoxData.h
src/Core/BoxManager.cpp
src/Core/BoxManager.h
src/Core/IBox.h
src/Daemon/BoxDaemonImpl.cpp
src/Daemon/BoxDaemonImpl.h
src/Plugin/BoxPluginConnector.cpp
src/Plugin/box_plugin_interface.h

index 736b559..371eb7a 100644 (file)
@@ -375,3 +375,9 @@ Eina_Bool Box::startUpdateRenderBufferIdlerCallback(void* data)
 
     return ECORE_CALLBACK_CANCEL;
 }
+
+BoxInfoPtr Box::getBoxInfo()
+{
+    LogD("enter");
+    return m_boxInfo;
+}
index 915afb5..33eaf17 100644 (file)
@@ -55,6 +55,8 @@ class Box: public IBox, public IBoxContext {
         bool changePeriod(float period);
         bool isCurrentTab();
         time_t getLastUpdateRequestTime();
+        BoxInfoPtr getBoxInfo();
+
         ~Box();
 
     private:
index b265d84..86bdfb4 100644 (file)
@@ -56,6 +56,22 @@ struct BoxInfo
         contentInfo()
     {
     };
+
+   BoxInfo() :
+        boxType(),
+        boxId(),
+        instanceId(),
+        boxWidth(0),
+        boxHeight(0),
+        pdWidth(0),
+        pdHeight(0),
+        pdX(0.0f),
+        pdY(0.0f),
+        priority(0),
+        period(0),
+        contentInfo()
+    {
+    };
 };
 
 typedef std::shared_ptr<struct BoxInfo> BoxInfoPtr;
index b6f3e17..14af107 100644 (file)
@@ -80,6 +80,9 @@ bool BoxManager::doCommand(const request_cmd_type type, const BoxInfoPtr& boxInf
     case REQUEST_CMD_UPDATE_BOX:
         result = requestUpdateBox(boxInfo->boxId, boxInfo->contentInfo);
         break;
+    case REQUEST_CMD_CHANGE_LANGUAGE:
+        result = requestChangeLanguage(boxInfo->instanceId);
+        break;
     default:
         LogD("not available request type");
         break;
@@ -245,6 +248,24 @@ bool BoxManager::requestUpdateBox(std::string& boxId, std::string& contentInfo)
     return true;
 }
 
+bool BoxManager::requestChangeLanguage(std::string& instanceId)
+{
+    LogD("enter");
+
+    IBoxPtr box;
+    box.reset();
+
+   time_t requestTime = time(NULL);
+
+    for (auto it = m_boxMap.begin(); it != m_boxMap.end(); ++it) {
+        if (it->second) {
+            box = it->second;
+            box->update(requestTime, box->getBoxInfo()->contentInfo);
+        }
+    }
+    return true;
+}
+
 void BoxManager::insertBoxMap(std::string& instanceId, IBoxPtr box)
 {
     if (!searchBoxMap(instanceId)) {
index 76a00cb..77806bb 100644 (file)
@@ -54,6 +54,7 @@ class EXPORT_CLASS BoxManager: public IBoxManager {
         virtual bool requestClosePd(std::string& instanceId);
         virtual bool requestChangePeriod(std::string& instanceId, float period);
         virtual bool requestUpdateBox(std::string& boxId, std::string& contentInfo);
+        virtual bool requestChangeLanguage(std::string& instanceId);
 
         // ewk context deleter 
         struct EwkContextDeleter {
index 0664eda..bea5570 100644 (file)
@@ -42,6 +42,7 @@ class IBox {
         virtual bool changePeriod(float period) = 0;
         virtual bool isCurrentTab() = 0;
         virtual time_t getLastUpdateRequestTime() = 0;
+        virtual BoxInfoPtr getBoxInfo() = 0;
 
         //virtual IBox& operator=(const IBox& rhs) = 0;
         //virtual bool operator==(const IBox& rhs) const = 0;
index ecf0163..7e36ed3 100755 (executable)
@@ -26,6 +26,7 @@
 #include <Ecore_X.h>
 #include <provider.h>
 #include <livebox-service.h>
+#include <appcore-efl.h>
 #include <Core/Util/Log.h>
 #include <Plugin/IBoxPluginConnector.h>
 #include <Plugin/BoxPluginConnector.h>
@@ -45,6 +46,7 @@ static const std::string ALARM_CALLER_KEY("__ALARM_MGR_CALLER_APPID");
 BoxDaemonImpl::BoxDaemonImpl()
     : m_pluginConnector(BoxPluginConnector::create())
 {
+    appcore_set_event_callback(APPCORE_EVENT_LANG_CHANGE, requestChangeLanguageCallback, this);
 }
 
 BoxDaemonImpl::~BoxDaemonImpl()
@@ -675,3 +677,14 @@ void BoxDaemonImpl::requestBoxJobCallback(void* data)
 
     delete jobInfo;
 }
+int BoxDaemonImpl::requestChangeLanguageCallback(void* data)
+{
+    LogD("enter");
+
+    BoxDaemonImpl* This = static_cast<BoxDaemonImpl*>(data);
+    BoxInfoPtr info = BoxInfoPtr(new BoxInfo());
+    JobInfo* jobInfo = new JobInfo(REQUEST_CMD_CHANGE_LANGUAGE,  info, This);
+
+    Ecore_Job* ret = ecore_job_add(requestBoxJobCallback, jobInfo);
+    return 0;
+}
index df4a96f..f9f994a 100644 (file)
@@ -69,6 +69,8 @@ class BoxDaemonImpl {
         static int resumeCallback(ProviderEventArgPtr arg, void* data);
         static int boxPeriodChangeCallback(ProviderEventArgPtr arg, void* data);
         static int boxUpdateCallback(ProviderEventArgPtr arg, void* data);
+        // callback for app-core event
+        static int requestChangeLanguageCallback(void* data);
 
         // common private functions
         void setProviderCallbacks(ProviderCallbacks& callbacks);
index cc3e58a..a0cc23a 100644 (file)
@@ -137,12 +137,13 @@ bool BoxPluginConnector::requestCommand(
     LogD("enter");
 
     // in case of request of resume all or pause all, all plugins should handle that.
-    if (type == REQUEST_CMD_RESUME_ALL || type == REQUEST_CMD_PAUSE_ALL) {
+    if (type == REQUEST_CMD_RESUME_ALL ||
+        type == REQUEST_CMD_PAUSE_ALL ||
+        type == REQUEST_CMD_CHANGE_LANGUAGE) {
         for (auto it = m_pluginMap.begin(); 
                 it != m_pluginMap.end(); ++it) 
         {
             if (it->second) {
-                // In this case, boxInfo doesn't have any meaning 
                 it->second->command(type, boxInfo);
             }
         }
index 918caff..093814d 100644 (file)
@@ -45,6 +45,7 @@ typedef enum {
     REQUEST_CMD_PAUSE_ALL,
     REQUEST_CMD_CHANGE_PERIOD,
     REQUEST_CMD_UPDATE_BOX,
+    REQUEST_CMD_CHANGE_LANGUAGE
 } request_cmd_type;
 
 // definition of interface function type