Copy-paste code removal
authorTomasz Iwanek <t.iwanek@samsung.com>
Mon, 26 Nov 2012 08:21:15 +0000 (09:21 +0100)
committerGerrit Code Review <gerrit2@kim11>
Tue, 4 Dec 2012 14:55:28 +0000 (23:55 +0900)
[Issue#]       LINUXNGWAP-567
[Bug]          There is some copy-pasted code
[Cause]        Someone copy-pasted it
[Solution]     Remove code-pasted code.
[Verification] Build repository. Run any widget.
Run widget manual_tests/wrt_test_widgets/scheme_support/scheme_test_tizen.wgt
then go: window.open() test -> youtube, check log for successfull launch of com.samsung.video-player.
Player is closing imediately but is beyond change scope.

Change-Id: Ie6fb50e31a41542b07118f6b5367d2842dd0e5c8

src/view/webkit/bundles/wrt-wk2-bundle.cpp
src/view/webkit/bundles/wrt-wk2-bundle.h
src/wrt-launcher/wrt-launcher.cpp

index 7543851..915ba00 100644 (file)
@@ -192,6 +192,31 @@ void Bundle::willDestroyPage(WKBundlePageRef page)
     PluginModule::stop(context);
 }
 
+void Bundle::fixWKMessageArgs(std::string & argScale, std::string & argEncodedBundle, std::string & argTheme)
+{
+    if (argScale != "null" && argScale[0] == '_')
+    {
+        argScale.erase(0, 1);
+
+        std::stringstream ssScale(argScale);
+        ssScale >> m_scale;
+    }
+
+    if (argEncodedBundle != "null" && argEncodedBundle[0] == '_')
+    {
+        argEncodedBundle.erase(0, 1);
+
+        m_encodedBundle = argEncodedBundle;
+    }
+
+    if (argTheme != "null" && argTheme[0] == '_')
+    {
+        argTheme.erase(0, 1);
+
+        m_theme = argTheme;
+    }
+}
+
 void Bundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody)
 {
     LogDebug("got message type: " << toString(messageName).c_str());
@@ -242,28 +267,7 @@ void Bundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody)
         }
 
         // ** Language tags setting completed **
-
-        if (argScale != "null" && argScale[0] == '_')
-        {
-            argScale.erase(0, 1);
-
-            std::stringstream ssScale(argScale);
-            ssScale >> m_scale;
-        }
-
-        if (argEncodedBundle != "null" && argEncodedBundle[0] == '_')
-        {
-            argEncodedBundle.erase(0, 1);
-
-            m_encodedBundle = argEncodedBundle;
-        }
-
-        if (argTheme != "null" && argTheme[0] == '_')
-        {
-            argTheme.erase(0, 1);
-
-            m_theme = argTheme;
-        }
+        fixWKMessageArgs(argScale, argEncodedBundle, argTheme);
 
         m_widgetType = dao.getWidgetType();
         LogDebug("m_widgetType : " << m_widgetType.getApptypeToString() <<
@@ -311,27 +315,7 @@ void Bundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody)
         ssMsg >> argEncodedBundle;
         ssMsg >> argTheme;
 
-        if(argScale != "null" && argScale[0] == '_')
-        {
-            argScale.erase(0, 1);
-
-            std::stringstream ssScale(argScale);
-            ssScale >> m_scale;
-        }
-
-        if(argEncodedBundle != "null" && argEncodedBundle[0] == '_')
-        {
-            argEncodedBundle.erase(0, 1);
-
-            m_encodedBundle = argEncodedBundle;
-        }
-
-        if(argTheme != "null" && argTheme[0] == '_')
-        {
-            argTheme.erase(0, 1);
-
-            m_theme = argTheme;
-        }
+        fixWKMessageArgs(argScale, argEncodedBundle, argTheme);
 
         //apply for each context
         PageGlobalContext::iterator it = m_pageGlobalContext.begin();
index de4a089..22c9ade 100644 (file)
@@ -156,6 +156,9 @@ class Bundle {
     bool isEncryptedResource(std::string Url, int &size);
     std::string DecryptResource(std::string resource, int size);
 
+    void fixWKMessageArgs(std::string & argScale,
+        std::string & argEncodedBundle, std::string & argTheme);
+
     void requestSuspend();
     void requestResume();
 
index d3cf750..fc41133 100644 (file)
@@ -88,7 +88,7 @@ static char* new_strdup(const char *str)
     return ret;
 }
 
-static bool display_widget_info()
+static bool attachDbConnection()
 {
     if (NULL == g_dbConnection.get()) {
         Try {
@@ -100,6 +100,12 @@ static bool display_widget_info()
             return FALSE;
         }
     }
+    return TRUE;
+}
+
+static bool display_widget_info()
+{
+    if(!attachDbConnection()) return FALSE;
 
     WidgetDAOReadOnlyList widgetList =
             WrtDB::WidgetDAOReadOnly::getWidgetList();
@@ -295,16 +301,7 @@ int main(int argc, char* argv[])
 
         case 'v':
             strncpy(temp_arg, optarg, strlen(optarg));
-            if (NULL == g_dbConnection.get()) {
-                Try {
-                    g_dbConnection.reset(new DBConnection());
-                    g_dbConnection->AttachDatabase();
-                }
-                Catch (DPL::DB::SqlConnection::Exception::Base) {
-                    LogDebug("Fail to connect DB");
-                    return FALSE;
-                }
-            }
+            if(!attachDbConnection()) return FALSE;
             if (!strcmp("1", temp_arg)) {
                 WrtDB::GlobalDAO::SetDeveloperMode(true);
             } else {
@@ -313,16 +310,7 @@ int main(int argc, char* argv[])
             break;
         case 'c':
             strncpy(temp_arg, optarg, strlen(optarg));
-            if (NULL == g_dbConnection.get()) {
-                Try {
-                    g_dbConnection.reset(new DBConnection());
-                    g_dbConnection->AttachDatabase();
-                }
-                Catch (DPL::DB::SqlConnection::Exception::Base) {
-                    LogDebug("Fail to connect DB");
-                    return FALSE;
-                }
-            }
+            if(!attachDbConnection()) return FALSE;
             if(!strcmp("1", temp_arg)) {
                 WrtDB::GlobalDAO::setComplianceMode(true);
             } else {
@@ -331,30 +319,12 @@ int main(int argc, char* argv[])
             break;
         case 'i':
             strncpy(temp_arg, optarg, strlen(optarg));
-            if (NULL == g_dbConnection.get()) {
-                Try {
-                    g_dbConnection.reset(new DBConnection());
-                    g_dbConnection->AttachDatabase();
-                }
-                Catch (DPL::DB::SqlConnection::Exception::Base) {
-                    LogDebug("Fail to connect DB");
-                    return FALSE;
-                }
-            }
+            if(!attachDbConnection()) return FALSE;
             WrtDB::GlobalDAO::setComplianceFakeImei(temp_arg);
             break;
         case 'm':
             strncpy(temp_arg, optarg, strlen(optarg));
-            if (NULL == g_dbConnection.get()) {
-                Try {
-                    g_dbConnection.reset(new DBConnection());
-                    g_dbConnection->AttachDatabase();
-                }
-                Catch (DPL::DB::SqlConnection::Exception::Base) {
-                    LogDebug("Fail to connect DB");
-                    return FALSE;
-                }
-            }
+            if(!attachDbConnection()) return FALSE;
             WrtDB::GlobalDAO::setComplianceFakeMeid(temp_arg);
             break;