upload tizen1.0 source
[framework/web/wrt-commons.git] / modules / widget_dao / dao / global_dao.cpp
index 6f1f406..c36fbcc 100644 (file)
 #include <dpl/wrt-dao-ro/WrtDatabase.h>
 
 namespace WrtDB {
-
-void GlobalDAO::AddAdultBlackListElement(const DPL::String &url)
-{
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-
-        ScopedTransaction transaction(&WrtDatabase::interface());
-        if (IsElementOnAdultBlackList(url)) {
-            transaction.Commit();
-            return;
-        }
-
-        WRT_DB_INSERT(insert, ChildProtectionBlacklist, &WrtDatabase::interface())
-        ChildProtectionBlacklist::Row row;
-        row.Set_url(url);
-
-        insert->Values(row);
-        insert->Execute();
-        transaction.Commit();
-    } Catch(DPL::DB::SqlConnection::Exception::Base) {
-        ReThrowMsg(GlobalDAO::Exception::DatabaseError,
-                   "Failed to add element to AdultBlackList");
-    }
-}
-
-void GlobalDAO::RemoveAdultBlackListElement(const DPL::String &url)
-{
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        WRT_DB_DELETE(deleteFrom, ChildProtectionBlacklist, &WrtDatabase::interface())
-
-        deleteFrom->Where(Equals<ChildProtectionBlacklist::url>(url));
-        deleteFrom->Execute();
-    } Catch(DPL::DB::SqlConnection::Exception::Base) {
-        ReThrowMsg(GlobalDAO::Exception::DatabaseError,
-                   "Failed to removed element from AdultBlackList");
-    }
-}
-
-void GlobalDAO::UpdateAdultBlackList(const DPL::String &oldUrl,
-                                     const DPL::String &newUrl)
-{
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-
-        ScopedTransaction transaction(&WrtDatabase::interface());
-        if (IsElementOnAdultBlackList(newUrl)) {
-            transaction.Commit();
-            return;
-        }
-        WRT_DB_UPDATE(update, ChildProtectionBlacklist, &WrtDatabase::interface())
-        ChildProtectionBlacklist::Row row;
-        row.Set_url(newUrl);
-
-        update->Where(Equals<ChildProtectionBlacklist::url>(oldUrl));
-        update->Values(row);
-        update->Execute();
-        transaction.Commit();
-    } Catch(DPL::DB::SqlConnection::Exception::Base) {
-        ReThrowMsg(GlobalDAO::Exception::DatabaseError,
-                   "Failed to update an element in AdultBlackList");
-    }
-}
-
-void GlobalDAO::SetDeveloperMode(bool mode)
-{
-    LogDebug("updating Developer mode to:" << mode);
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        GlobalProperties::Row row;
-        row.Set_developer_mode(mode);
-
-        WRT_DB_UPDATE(update, GlobalProperties, &WrtDatabase::interface())
-        update->Values(row);
-        update->Execute();
-    }
-    Catch(DPL::DB::SqlConnection::Exception::Base){
-        ReThrowMsg(GlobalDAO::Exception::DatabaseError,
-                   "Failed to update Developer Mode");
-    }
-}
-
 void GlobalDAO::AddDefferedWidgetPackageInstallation(const DPL::String &path)
 {
     LogDebug("Adding widget package as defered. Path: " << path);
@@ -150,38 +64,22 @@ void GlobalDAO::RemoveDefferedWidgetPackageInstallation(const DPL::String &path)
     }
 }
 
-void GlobalDAO::SetParentalMode(bool parental_status)
+void GlobalDAO::SetDeveloperMode(bool mode)
 {
+    LogDebug("updating Developer mode to:" << mode);
     Try {
         using namespace DPL::DB::ORM;
         using namespace DPL::DB::ORM::wrt;
         GlobalProperties::Row row;
-        row.Set_parental_mode(parental_status);
-        WRT_DB_UPDATE(update, GlobalProperties, &WrtDatabase::interface())
-
-        update->Values(row);
-        update->Execute();
-    } Catch(DPL::DB::SqlConnection::Exception::Base) {
-        ReThrowMsg(GlobalDAO::Exception::DatabaseError,
-                   "Failed to update Parental Mode");
-    }
-}
-
-void GlobalDAO::SetParentalAllowedAge(const DPL::OptionalInt& age)
-{
-    using namespace DPL::DB::ORM;
-    using namespace DPL::DB::ORM::wrt;
-    Try {
-        typedef wrt::GlobalProperties::Row ParentalAllowedAgeRow;
+        row.Set_developer_mode(mode);
 
-        ParentalAllowedAgeRow row;
-        row.Set_parental_allowed_age(age);
         WRT_DB_UPDATE(update, GlobalProperties, &WrtDatabase::interface())
         update->Values(row);
         update->Execute();
-    } Catch(DPL::DB::SqlConnection::Exception::Base) {
+    }
+    Catch(DPL::DB::SqlConnection::Exception::Base){
         ReThrowMsg(GlobalDAO::Exception::DatabaseError,
-                   "Failed to update Parental Mode");
+                   "Failed to update Developer Mode");
     }
 }
 
@@ -257,105 +155,6 @@ void GlobalDAO::setComplianceFakeMeid(const std::string &meid)
     }
 }
 
-void GlobalDAO::AddCategoryRule(const ChildProtection::PowderRules::
-                                CategoryRule& powder)
-{
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        PowderRules::Row row;
-        row.Set_category(powder.category);
-        row.Set_level(powder.level);
-        row.Set_context(powder.context);
-
-        wrt::ScopedTransaction transaction(&WrtDatabase::interface());
-        if (IsPowderRulePresent(powder)) {
-            transaction.Commit();
-            return;
-        }
-        WRT_DB_INSERT(insert, PowderRules, &WrtDatabase::interface())
-
-        insert->Values(row);
-        insert->Execute();
-        transaction.Commit();
-    } Catch(DPL::DB::SqlConnection::Exception::Base) {
-        ReThrowMsg(GlobalDAO::Exception::DatabaseError,
-                   "Failed to add POWDER rules");
-    }
-}
-
-void GlobalDAO::RemoveCategoryRule(const ChildProtection::PowderRules::
-                                   CategoryRule& powder)
-{
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-
-        if (!powder.context.IsNull()) {
-            WRT_DB_DELETE(delWithContext, PowderRules, &WrtDatabase::interface())
-
-            delWithContext->Where(
-                And(Equals<PowderRules::category>(powder.category),
-                    And(Equals<PowderRules::level>(powder.level),
-                        Equals<PowderRules::context>(powder.context))));
-            delWithContext->Execute();
-        } else {
-            WRT_DB_DELETE(delWithoutContext, PowderRules, &WrtDatabase::interface())
-            delWithoutContext->Where(
-                And(Equals<PowderRules::category>(powder.category),
-                    And(Equals<PowderRules::level>(powder.level),
-                        Is<PowderRules::context>(powder.context))));
-            delWithoutContext->Execute();
-        }
-    } Catch(DPL::DB::SqlConnection::Exception::Base) {
-        ReThrowMsg(GlobalDAO::Exception::DatabaseError,
-                   "Failed to remove POWDER rules");
-    }
-}
-
-void GlobalDAO::UpdateCategoryRule(
-        const ChildProtection::PowderRules::CategoryRule& oldRule,
-        const ChildProtection::PowderRules::CategoryRule& newRule)
-{
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        PowderRules::Row row;
-        row.Set_category(newRule.category);
-        row.Set_level(newRule.level);
-        row.Set_context(newRule.context);
-
-        wrt::ScopedTransaction transaction(&WrtDatabase::interface());
-
-        if (IsPowderRulePresent(newRule)) {
-            transaction.Commit();
-            return;
-        }
-
-        if (!oldRule.context.IsNull()) {
-            WRT_DB_UPDATE(updateWithContext, PowderRules, &WrtDatabase::interface())
-            updateWithContext->Where(
-                And(Equals<PowderRules::category>(oldRule.category),
-                    And(Equals<PowderRules::level>(oldRule.level),
-                        Equals<PowderRules::context>(oldRule.context))));
-            updateWithContext->Values(row);
-            updateWithContext->Execute();
-        } else {
-            WRT_DB_UPDATE(updateWithoutContext, PowderRules, &WrtDatabase::interface())
-            updateWithoutContext->Where(
-                And(Equals<PowderRules::category>(oldRule.category),
-                    And(Equals<PowderRules::level>(oldRule.level),
-                        Is<PowderRules::context>(oldRule.context))));
-            updateWithoutContext->Values(row);
-            updateWithoutContext->Execute();
-        }
-        transaction.Commit();
-    } Catch(DPL::DB::SqlConnection::Exception::Base) {
-        ReThrowMsg(GlobalDAO::Exception::DatabaseError,
-                   "Failed to update POWDER rules");
-    }
-}
-
 void GlobalDAO::SetHomeNetworkDataUsage(GlobalDAO::NetworkAccessMode newMode)
 {
     LogDebug("updating home network data usage to:" << newMode);
@@ -394,41 +193,6 @@ void GlobalDAO::SetRoamingDataUsage(GlobalDAO::NetworkAccessMode newMode)
     }
 }
 
-void GlobalDAO::SetAutoSaveIdPasswd(const DPL::String &url,
-                                    const AutoSaveData &saveData)
-{
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        ScopedTransaction transaction(&WrtDatabase::interface());
-        AutoSaveIdPasswd::Row row;
-
-        row.Set_address(url);
-        row.Set_userId(saveData.userId);
-        row.Set_passwd(saveData.passwd);
-
-        DPL::Optional<GlobalDAO::AutoSaveData> savedData =
-            GetAutoSaveIdPasswd(url);
-
-        if (!savedData.IsNull()) {
-            WRT_DB_UPDATE(update, AutoSaveIdPasswd, &WrtDatabase::interface())
-
-            update->Where(Equals<AutoSaveIdPasswd::address>(url));
-            update->Values(row);
-            update->Execute();
-        } else {
-            WRT_DB_INSERT(insert, AutoSaveIdPasswd, &WrtDatabase::interface());
-            insert->Values(row);
-            insert->Execute();
-        }
-
-        transaction.Commit();
-    } Catch(DPL::DB::SqlConnection::Exception::Base) {
-        ReThrowMsg(GlobalDAO::Exception::DatabaseError,
-                   "Fail to register id, passwd for autosave");
-    }
-}
-
 void GlobalDAO::AddWhiteURI(const std::string &uri, bool subDomain)
 {
     LogDebug("Add White URI : " << uri);