Fix for receiving of the last session from database 28/49228/3 accepted/tizen/tv/20151013.040805 submit/tizen_tv/20151012.224538
authorKamil Nowac <k.nowac@samsung.com>
Fri, 9 Oct 2015 08:03:40 +0000 (10:03 +0200)
committerKamil Nowac <k.nowac@samsung.com>
Fri, 9 Oct 2015 12:27:03 +0000 (14:27 +0200)
[Issue] https://bugs.tizen.org/jira/browse/TT-182
[Problem] Browser does not load the last session
properly.
[Solution] Changed SQL instruction and a Session
copy constructor
[Verify]
1.Open few tabs.
2.Close browser.
3.Open browser.
Tabs from the last session should be loaded.

Change-Id: I401a7ea2f864c8459e6b2c2a6cef3af035138627
Signed-off-by: Kamil Nowac <k.nowac@samsung.com>
services/SessionStorage/Session.cpp
services/SessionStorage/SqlStorage.cpp
services/SimpleUI/SimpleUI.cpp

index ee474a6cfe2655a1d1f9d6e3666f2f35ccdd827c..9d999e15a641a604ad9fabe1ba429351369fbf74 100644 (file)
@@ -53,13 +53,15 @@ Session::Session(Session&& source)
  , m_lastModificationTime(std::move(source.m_lastModificationTime))
  , m_sessinName(std::move(source.m_sessinName))
  , m_isValid(std::move(source.m_isValid))
+ , m_items(std::move(source.m_items))
 {
 }
 
 Session & Session::operator=(Session&& other)
 {
     if (this != &other) {
-       m_sessionId = std::move(other.m_sessionId);
+        m_sessionId = std::move(other.m_sessionId);
+        m_items = std::move(other.m_items);
         m_lastModificationTime = std::move(other.m_lastModificationTime);
         m_sessinName = std::move(other.m_sessinName);
         m_isValid = std::move(other.m_isValid);
@@ -134,6 +136,7 @@ void Session::removeItem(const std::string& tabId)
         SqlStorage* const storage = SqlStorage::getInstance();
         if(storage){
             storage->removeItem(*this, tabId);
+            storage->updateSession(*this);
         }
     }
 }
index b2cf36c0539d6a6a19a59232c33994bab5140406..3de63cb469df4d3edea217c9a2a48cb2987676fa 100644 (file)
@@ -83,6 +83,7 @@ SqlStorage::~SqlStorage()
 
 bool SqlStorage::init()
 {
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
     if(m_isInitialized){
         return true;
     }
@@ -92,9 +93,7 @@ bool SqlStorage::init()
     std::string sessionDb(boost::any_cast < std::string > (config.get("DB_SESSION")));
 
     m_dbString = resourceDbDir + sessionDb;
-
     bool status = initSessionDatabase();
-
     if( status ) {
         m_isInitialized = true;
         return true;
@@ -114,6 +113,7 @@ SqlStorage* const SqlStorage::getInstance()
 
 bool SqlStorage::initSessionDatabase()
 {
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
     storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(m_dbString));
     try{
         tizen_browser::services::StorageService::checkAndCreateTable(&scope
@@ -161,7 +161,8 @@ Session SqlStorage::createSession(const std::string& name)
 
 Session SqlStorage::getLastSession()
 {
-    boost::format getLastSessionString("SELECT %1%, %2%, %3% FROM %4% ORDER BY %3% DESC LIMIT 1;");
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+    boost::format getLastSessionString("SELECT %1%, %2%, %3% FROM %4% ORDER BY %3% DESC LIMIT 1,1;");
     getLastSessionString % COL_SESSION_ID % COL_SESSION_NAME % COL_SESSION_DATE % TABLE_SESSION;
     unsigned int sessionId;
     std::string sessionName;
@@ -169,7 +170,6 @@ Session SqlStorage::getLastSession()
     try{
         storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(m_dbString));
         std::shared_ptr<storage::SQLDatabase> connection = scope.database();
-
         storage::SQLQuery getLastSessionQuery(connection->prepare(getLastSessionString.str()));
 
         getLastSessionQuery.exec();
@@ -327,6 +327,7 @@ void SqlStorage::updateSessionName(Session& session, std::string newName)
 
 void SqlStorage::readSession(Session& session, std::shared_ptr< storage::SQLDatabase > connection)
 {
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
     if(session.isValid()){
         boost::format getSessionDataString("SELECT %1%, %2% FROM %3% WHERE %4% = ? ");
         getSessionDataString % COL_URL_TABID % COL_URL_URL % TABLE_URL % COL_URL_SESION_ID;
index 189c28418ab61a9e5e540ec08b46b73fdd302f3a..e4044ed0c054559782d39503e3f1ed76af9866c9 100644 (file)
@@ -1061,7 +1061,8 @@ void SimpleUI::updateView() {
     m_webPageUI->setTabsNumber(tabs);
 }
 
-void SimpleUI::tabClosed(const tizen_browser::basic_webengine::TabId&) {
+void SimpleUI::tabClosed(const tizen_browser::basic_webengine::TabId& id) {
+    m_currentSession.removeItem(id.toString());
     updateView();
 }