merge wrt-plugins-tizen_0.2.0-3
[platform/framework/web/wrt-plugins-tizen.git] / src / platform / Tizen / Contact / ContactWrapper.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  * @file        ContactManager.h
19  * @author
20  * @version     0.1
21  * @brief
22  */
23
24 #ifndef _PLATFORM_CONTACT_CONTACT_WRAPPER_H_
25 #define _PLATFORM_CONTACT_CONTACT_WRAPPER_H_
26
27 #include <string>
28 #include <list>
29 #include <contacts-svc.h>
30 #include <API/Contact/IContact.h>
31 #include <API/Contact/IAddressBook.h>
32
33 namespace TizenApis {
34 namespace Platform {
35 namespace Contact {
36
37 class ContactWrapper
38 {
39 public:
40         explicit ContactWrapper(TizenApis::Api::Contact::IAddressBook::AddressBookType type);
41         virtual ~ContactWrapper();
42
43         TizenApis::Api::Contact::ContactPtr getAbstractContact() const;
44         void setAbstractContact(const TizenApis::Api::Contact::ContactPtr &contact, bool is_convert_vCard);
45
46         CTSstruct* getPlatformContact() const;
47         //WARNING: calling this function will cause to store pointer inside private field
48         //Structure will be freed by this class when is not needed anymore.
49         //User should not modify nor free passed pointer.
50         void setPlatformContact(CTSstruct* contact);
51
52 protected:
53         bool convertToPlatformObject(bool is_convert_vCard);
54         bool convertToAbstractObject();
55
56         TizenApis::Api::Contact::ContactPtr m_abstractContact;
57         CTSstruct*        m_platformContact;
58
59 private:
60         void freePlatformObject();
61         void freeAbstractObject();
62
63         bool convertToPlatformBaseData();
64         bool convertToPlatformAddressObject();
65         bool convertToPlatformEmailObject();
66         bool convertToPlatformPhoneObject();
67         bool convertToPlatformNicknameObject();
68         bool convertToPlatformPhoneticnameObject();
69         bool convertToPlatformGroupObject();
70         bool convertToPlatformUrlObject();
71         bool convertToPlatformOrganizationObject();
72         bool convertToPlatformAnniversaryObject();
73         bool convertToPlatformbirthdayObject();
74
75         bool convertToAbstractBaseData();
76         bool convertToAbstractAddressObject();
77         bool convertToAbstractEmailObject();
78         bool convertToAbstractPhoneObject();
79         bool convertToAbstractNicknameObject();
80         bool convertToAbstractPhoneticnameObject();
81         bool convertToAbstractGroupObject();
82         bool convertToAbstractUrlObject();
83         bool convertToAbstractOrganizationObject();
84         bool convertToAbstractAnniversaryObject();
85         bool convertToAbstractBirthdayObject();
86
87         int getCustomTypeInContactsSvc(const std::string &typeName) const;
88         //for debug purpose only
89         void printPlatformObject();
90         //for debug purpose only
91         void printAbstractObject();
92
93         std::string convertUriToPath(std::string str) const;
94         std::string convertPathToUri(std::string str) const;
95 };
96
97 typedef DPL::SharedPtr<ContactWrapper> ContactWrapperPtr;
98
99 } // Contact
100 } // Platform
101 } // TizenApis
102
103 #endif // _PLATFORM_CONTACT_CONTACT_WRAPPER_H_