History Implementation using Browser Provider.
[profile/tv/apps/web/browser.git] / services / HistoryService / HistoryItem.h
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __HISTORY_ITEM_H
18 #define __HISTORY_ITEM_H
19
20 #include <boost/date_time/gregorian/gregorian.hpp>
21 #include <boost/date_time/posix_time/posix_time.hpp>
22 #include <memory>
23 #include <vector>
24
25 #include "BrowserImage.h"
26
27 namespace tizen_browser {
28 namespace services {
29
30 class HistoryItem {
31 public:
32         HistoryItem(const std::string & url,
33                 const std::string & title,
34                 std::shared_ptr<tizen_browser::tools::BrowserImage> image);
35
36         HistoryItem(HistoryItem && other) throw();
37         HistoryItem(const std::string& url);
38         HistoryItem(const HistoryItem& source);
39         virtual ~HistoryItem();
40
41         HistoryItem & operator=(HistoryItem && other) throw();
42
43        /**
44         * @brief compares two HisoryItems, only "url" are checked no other elements are checked.
45         *
46         * @return bool
47         */
48         bool operator==(const HistoryItem& other);
49         bool operator!=(const HistoryItem& other);
50
51         void setUrl(const std::string & url);
52         std::string getUrl();
53
54         void setTitle(const std::string & title);
55         std::string getTitle() const;
56
57 ///\todo Below functions is different because two different services uses different types. To fix.
58 //      void setVisitDate(boost::gregorian::date visitDate);
59 //      boost::gregorian::date getVisitDate();
60
61         void setLastVisit(boost::posix_time::ptime visitDate);
62         boost::posix_time::ptime getLastVisit() const;
63
64         void setVisitCounter(int visitCounter);
65         int getVisitCounter();
66
67         void setFavIcon(std::shared_ptr<tizen_browser::tools::BrowserImage> favIcon);
68         std::shared_ptr<tizen_browser::tools::BrowserImage> getFavIcon();
69
70         void setUriFavicon(const std::string & uri);
71         std::string getUriFavicon();
72
73
74 private:
75     std::string m_primaryKey;
76     std::string m_url;
77     std::string m_title;
78     boost::gregorian::date m_visitDate;
79     boost::posix_time::ptime m_lastVisit;
80     std::shared_ptr<tizen_browser::tools::BrowserImage> m_favIcon;
81     std::string m_urifavicon;
82     int m_visitCounter;
83 };
84 ///\todo consider this
85 typedef std::vector<std::shared_ptr<HistoryItem>> HistoryItemVector;
86 typedef std::vector<std::shared_ptr<HistoryItem>>::iterator HistoryItemVectorIter;
87 typedef std::vector<std::shared_ptr<HistoryItem>>::const_iterator HistoryItemVectorConstIter;
88
89 }
90 }
91
92 #endif