f67e51746c02192db0ea2203edf1c3d65cf488b4
[framework/web/wrt-plugins-common.git] / src / modules / 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  * @file        ContactManager.h
18  * @author      Lukasz Marek(l.marek@samsung.com)
19  * @version     0.1
20  */
21
22 #ifndef WRTDEVICEAPIS_CONTACT_CONTACT_WRAPPER_H_
23 #define WRTDEVICEAPIS_CONTACT_CONTACT_WRAPPER_H_
24
25 #include <string>
26 #include <list>
27 #include <contacts-svc.h>
28 #include <Contact/Contact.h>
29 #include <Contact/IAddressBook.h>
30
31 namespace WrtDeviceApis {
32 namespace Contact {
33
34 class ContactWrapper
35 {
36   public:
37     explicit ContactWrapper(Api::IAddressBookObject::BookType type);
38     virtual ~ContactWrapper();
39     Api::ContactPtr getAbstractContact() const;
40     void setAbstractContact(const Api::ContactPtr &contact);
41     CTSstruct* getPlatformContact() const;
42     //WARNING: calling this function will cause to store pointer inside private field
43     //Structure will be freed by this class when is not needed anymore.
44     //User should not modify nor free passed pointer.
45     void setPlatformContact(CTSstruct* contact);
46
47   protected:
48     bool convertToPlatformObject();
49     bool convertToAbstractObject();
50
51     Api::ContactPtr m_abstractContact;
52     CTSstruct*      m_platformContact;
53
54   private:
55     void freePlatformObject();
56     void freeAbstractObject();
57     bool convertToPlatformBaseData();
58     bool convertToPlatformAddressObject();
59     bool convertToPlatformEmailObject();
60     bool convertToPlatformPhoneObject();
61     bool convertToPlatformNicknameObject();
62     bool convertToPlatformPhoneticnameObject();
63     bool convertToPlatformGroupObject();
64     bool convertToAbstractBaseData();
65     bool convertToAbstractAddressObject();
66     bool convertToAbstractEmailObject();
67     bool convertToAbstractPhoneObject();
68     bool convertToAbstractNicknameObject();
69     bool convertToAbstractPhoneticnameObject();
70     bool convertToAbstractGroupObject();
71     int getCustomTypeInContactsSvc(const std::string &typeName) const;
72     //for debug purpose only
73     void printPlatformObject();
74     //for debug purpose only
75     void printAbstractObject();
76 };
77
78 typedef DPL::SharedPtr<ContactWrapper> ContactWrapperPtr;
79
80 }
81 }
82
83 #endif // WRTDEVICEAPIS_CONTACT_CONTACT_WRAPPER_H_