41f4cd0cad96be754939e5342b11b4b6af083da9
[profile/ivi/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 isConvertingVCard);
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, bool isConvertingVCard);
51
52         bool convertAbstractToPlatform(const TizenApis::Api::Contact::ContactPtr &abstract, CTSstruct* platform, bool isConvertingVCard);
53         bool convertPlatformToAbstract(CTSstruct* platform, TizenApis::Api::Contact::ContactPtr &abstract, bool isConvertingVCard);
54
55 protected:
56         bool convertToPlatformObject(bool isConvertingVCard);
57         bool convertToAbstractObject(bool isConvertingVCard);
58
59         TizenApis::Api::Contact::ContactPtr m_abstractContact;
60         CTSstruct*        m_platformContact;
61         bool m_platformContactOwnership;
62
63 private:
64         void freePlatformObject();
65         void freeAbstractObject();
66
67         bool convertToPlatformBaseData();
68         bool convertToPlatformAddressObject();
69         bool convertToPlatformEmailObject();
70         bool convertToPlatformPhoneObject();
71         bool convertToPlatformNicknameObject();
72         bool convertToPlatformPhoneticnameObject();
73         bool convertToPlatformGroupObject();
74         bool convertToPlatformUrlObject();
75         bool convertToPlatformOrganizationObject();
76         bool convertToPlatformAnniversaryObject();
77         bool convertToPlatformbirthdayObject();
78
79         bool convertToAbstractBaseData();
80         bool convertToAbstractAddressObject();
81         bool convertToAbstractEmailObject();
82         bool convertToAbstractPhoneObject();
83         bool convertToAbstractNicknameObject();
84         bool convertToAbstractPhoneticnameObject();
85         bool convertToAbstractGroupObject();
86         bool convertToAbstractUrlObject();
87         bool convertToAbstractOrganizationObject();
88         bool convertToAbstractAnniversaryObject();
89         bool convertToAbstractBirthdayObject();
90
91         int getCustomTypeInContactsSvc(const std::string &typeName) const;
92         //for debug purpose only
93         void printPlatformObject();
94         //for debug purpose only
95         void printAbstractObject();
96
97         std::string convertUriToPath(std::string str) const;
98         std::string convertPathToUri(std::string str) const;
99 };
100
101 typedef DPL::SharedPtr<ContactWrapper> ContactWrapperPtr;
102
103 } // Contact
104 } // Platform
105 } // TizenApis
106
107 #endif // _PLATFORM_CONTACT_CONTACT_WRAPPER_H_