Task TT-75 Implement "Main page loading UI" view
[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
38         HistoryItem(const std::string& url);
39         HistoryItem(const std::string& url, int& date_created);
40         HistoryItem(const HistoryItem& source);
41         virtual ~HistoryItem();
42
43         HistoryItem & operator=(HistoryItem && other) throw();
44
45        /**
46         * @brief compares two HisoryItems, only "url" are checked no other elements are checked.
47         *
48         * @return bool
49         */
50         bool operator==(const HistoryItem& other);
51         bool operator!=(const HistoryItem& other);
52
53         void setUrl(const std::string & url);
54         std::string getUrl();
55
56         void setTitle(const std::string & title);
57         std::string getTitle() const;
58
59 ///\todo Below functions is different because two different services uses different types. To fix.
60 //      void setVisitDate(boost::gregorian::date visitDate);
61 //      boost::gregorian::date getVisitDate();
62
63         void setLastVisit(boost::posix_time::ptime visitDate);
64         boost::posix_time::ptime getLastVisit() const;
65
66         void setVisitCounter(int visitCounter);
67         int getVisitCounter();
68
69         void setThumbnail(std::shared_ptr<tizen_browser::tools::BrowserImage> thumbnail);
70         std::shared_ptr<tizen_browser::tools::BrowserImage> getThumbnail() const ;
71
72         void setFavIcon(std::shared_ptr<tizen_browser::tools::BrowserImage> favIcon);
73         std::shared_ptr<tizen_browser::tools::BrowserImage> getFavIcon();
74
75         void setUriFavicon(const std::string & uri);
76         std::string getUriFavicon();
77
78
79 private:
80     std::string m_primaryKey;
81     std::string m_url;
82     std::string m_title;
83     boost::gregorian::date m_visitDate;
84     boost::posix_time::ptime m_lastVisit;
85     std::shared_ptr<tizen_browser::tools::BrowserImage> m_thumbnail;
86     std::shared_ptr<tizen_browser::tools::BrowserImage> m_favIcon;
87     std::string m_urifavicon;
88     int m_visitCounter;
89 };
90 ///\todo consider this
91 typedef std::vector<std::shared_ptr<HistoryItem>> HistoryItemVector;
92 typedef std::vector<std::shared_ptr<HistoryItem>>::iterator HistoryItemVectorIter;
93 typedef std::vector<std::shared_ptr<HistoryItem>>::const_iterator HistoryItemVectorConstIter;
94
95 }
96 }
97
98 #endif