3093081553602dce5f464100868e46999b8a692e
[framework/web/wrt-plugins-common.git] / src / modules / API / Messaging / MessageFilter.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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  *
18  *
19  * @file       MessageFilter.h
20  * @author     Pawel Misiak (p.misiak@samsung.com)
21  * @version    0.1
22  * @brief
23  */
24 #ifndef MESSAGEFILTER_H
25 #define MESSAGEFILTER_H
26
27 #include <string>
28 #include <dpl/shared_ptr.h>
29 #include <pcrecpp.h>
30
31 #include "MessagePriority.h"
32 #include "Recipient.h"
33 #include "ISms.h"
34 #include "IMms.h"
35 #include "IEmail.h"
36
37 namespace WrtDeviceApis {
38 namespace Messaging {
39 namespace Api {
40 //--------------------------------------------------------------------------
41
42 class MessageFilter;
43
44 typedef DPL::SharedPtr<MessageFilter> MessageFilterPtr;
45
46 class MessageFilter
47 {
48   private: // fields
49
50     std::string m_msgId;
51     bool m_msgIdCheck;
52
53     time_t m_startTime;
54     bool m_startTimeCheck;
55
56     time_t m_endTime;
57     bool m_endTimeCheck;
58
59     Recipients m_to;
60     bool m_toCheck;
61
62     Recipients m_cc;
63     bool m_ccCheck;
64
65     Recipients m_bcc;
66     bool m_bccCheck;
67
68     std::string m_subject;
69     bool m_subjectCheck;
70
71     std::string m_body;
72     bool m_bodyCheck;
73
74     bool m_isRead;
75     bool m_isReadCheck;
76
77     std::string m_from;
78     bool m_fromCheck;
79
80     MessagePriority::Priority m_messagePriority;
81     bool m_messagePriorityCheck;
82
83   public: // methods
84
85     /**
86      * constructor of messageFilter
87      */
88     MessageFilter();
89
90     virtual ~MessageFilter();
91
92     void setMsgId(const std::string& value);
93
94     void setTo(const Recipients& value); // the same as destination address
95
96     void setCc(const Recipients& value);
97
98     void setBcc(const Recipients& value);
99
100     void setSubject(const std::string& value);
101
102     void setBody(const std::string& value);
103
104     void setFrom(const std::string& value); //email account from email was sent
105
106     void setStartTime(const time_t& value);
107
108     void setEndTime(const time_t& value);
109
110     void setIsRead(bool value);
111
112     void setMessagePriority(const MessagePriority::Priority& value);
113
114     bool isValid() const;
115
116     bool compare(const ISmsPtr& msg) const;
117
118     bool compare(const IMmsPtr& msg) const;
119
120     bool compare(const IEmailPtr& msg) const;
121
122   private:
123     pcrecpp::RE reCreate(const std::string& value) const;
124
125     bool idCheck(const std::string& value) const;
126
127     bool timeCheck(tm value) const;
128
129     bool bodyCheck(const std::string& value) const;
130
131     bool toCheck(const Recipients& value) const;
132
133     bool ccCheck(const Recipients& value) const;
134
135     bool bccCheck(const Recipients& value) const;
136
137     bool recipientCheck(const Recipients& filter,
138             const Recipients& value) const;
139
140     bool fromCheck(const std::string& value) const;
141
142     bool subjectCheck(const std::string& value) const;
143
144     bool isReadCheck(bool value) const;
145
146     bool priorityCheck(MessagePriority::Priority value) const;
147 };
148 }
149 }
150 }
151 #endif