Fixed update instance
[framework/osp/social.git] / src / FScl_AddressbookFilterImpl.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18  * @file                FScl_AddressbookFilterImpl.h
19  * @brief               This is the header file for the %_AddressbookFilterImpl class.
20  *
21  * This header file contains the declarations of the %_AddressbookFilterImpl class.
22  */
23 #ifndef _FSCL_ADDRESSBOOK_FILTER_IMPL_H_
24 #define _FSCL_ADDRESSBOOK_FILTER_IMPL_H_
25
26 #include <contacts.h>
27 #include <FBaseTypes.h>
28 #include <FSclTypes.h>
29 #include <FBaseObject.h>
30
31 namespace Tizen { namespace Base
32 {
33 class String;
34 }}
35
36 namespace Tizen { namespace Social
37 {
38
39 class AddressbookFilter;
40
41 enum __DataType
42 {
43         DATA_TYPE_NONE,
44         DATA_TYPE_INT,
45         DATA_TYPE_BOOL,
46         DATA_TYPE_STRING,
47 };
48
49 class _OSP_EXPORT_ _AddressbookFilterImpl
50            : public Tizen::Base::Object
51 {
52 public:
53         _AddressbookFilterImpl(AddressbookFilterType type);
54
55         virtual ~_AddressbookFilterImpl(void);
56
57         virtual bool Equals(const Tizen::Base::Object& rhs) const;
58
59         virtual int GetHashCode(void) const;
60
61         contacts_filter_h GetFilterHandle(void) const;
62
63         AddressbookFilterType GetType(void) const;
64
65         bool IsEmpty(void) const;
66
67         result AppendInt(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, int value);
68
69         result AppendBool(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, bool value);
70
71         result AppendString(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterStringOperator comparisonOperator, const Tizen::Base::String& value);
72
73         result AppendFilter(FilterConjunctiveOperator conjunctiveOperator, const _AddressbookFilterImpl& filter);
74
75         static const char* GetUriFromType(AddressbookFilterType type);
76
77         static __DataType GetPropertyType(AddressbookFilterType type, unsigned long filterProperty);
78
79         static bool IsValidProperty(AddressbookFilterType type, unsigned long filterProperty);
80
81         static unsigned int GetViewPropertyId(AddressbookFilterType type, unsigned long filterProperty);
82
83         static const _AddressbookFilterImpl* GetInstance(const AddressbookFilter& filter);
84
85         static  _AddressbookFilterImpl* GetInstance(AddressbookFilter& filter);
86
87 public:
88         struct __FilterPropertyInfoEntry
89         {
90                 unsigned long propertyId;
91                 unsigned long viewPropertyId;
92                 __DataType dataType;
93         };
94
95         struct __FilterInfoEntry
96         {
97                 unsigned long filterType;
98                 const char* pViewUri;
99                 unsigned long baseIndex;
100                 unsigned long propertyInfoCount;
101                 const __FilterPropertyInfoEntry* propertyInfos;
102         };
103
104         static const __FilterPropertyInfoEntry __addressbookFilterPropertyInfos[];
105         static const __FilterPropertyInfoEntry __personFilterPropertyInfos[];
106         static const __FilterPropertyInfoEntry __contactFilterPropertyInfos[];
107         static const __FilterPropertyInfoEntry __categoryFilterPropertyInfos[];
108         static const __FilterPropertyInfoEntry __phoneContactFilterPropertyInfos[];
109         static const __FilterPropertyInfoEntry __emailContactFilterPropertyInfos[];
110         static const __FilterInfoEntry __filterInfos[];
111
112 private:
113         // get match flag
114         static contacts_match_str_flag_e GetMatchStrFlag(FilterStringOperator stringOperstor);
115         static contacts_match_int_flag_e GetMatchIntFlag(FilterComparisonOperator comparisonOperator);
116
117         contacts_filter_h __filterHandle;
118         AddressbookFilterType __filterType;
119         bool __isEmpty;
120 };         // _AddressbookFilterImpl
121
122 }} // Tizen::Social
123
124 #endif // _FSCL_ADDRESSBOOK_FILTER_IMPL_H_