|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // mw/remoteconn/mtpdataproviders/mtpcontactdp/src/CMTPFullEnumDataCodeMgr.cpp |
|
15 |
|
16 #include <mtp/mmtpstoragemgr.h> |
|
17 #include <mtp/mmtpdataproviderframework.h> |
|
18 #include <mtp/mmtpdatacodegenerator.h> |
|
19 |
|
20 #include "cmtpabstractdatacodemgr.h" |
|
21 |
|
22 __FLOG_STMT(_LIT8(KComponent, "FullEnumDataCodeMgr");) |
|
23 |
|
24 EXPORT_C RMTPServiceFormat::~RMTPServiceFormat() |
|
25 { |
|
26 iProps.Close(); |
|
27 } |
|
28 |
|
29 EXPORT_C TInt TMTPServicePropertyInfo::LinearOrderServicePropOrder(const TMTPServicePropertyInfo& aLhs, const TMTPServicePropertyInfo& aRhs) |
|
30 { |
|
31 return aLhs.iServicePropCode - aRhs.iServicePropCode; |
|
32 } |
|
33 |
|
34 EXPORT_C TInt TMTPServicePropertyInfo::LinearOrderServicePropOrder(const TUint16* aServicePropCode, const TMTPServicePropertyInfo& aObject) |
|
35 { |
|
36 return (*aServicePropCode - aObject.iServicePropCode); |
|
37 } |
|
38 |
|
39 EXPORT_C TBool RMTPServiceFormat::FormatRelation(const TUint16* aFormatCode, const RMTPServiceFormat& aObject) |
|
40 { |
|
41 return *aFormatCode == aObject.iFormatCode; |
|
42 } |
|
43 |
|
44 EXPORT_C CMTPFullEnumDataCodeMgr* CMTPFullEnumDataCodeMgr::NewL(MMTPDataProviderFramework& aFramework) |
|
45 { |
|
46 CMTPFullEnumDataCodeMgr* self = new(ELeave) CMTPFullEnumDataCodeMgr(aFramework); |
|
47 CleanupStack::PushL(self); |
|
48 self->ConstructL(); |
|
49 CleanupStack::Pop(self); |
|
50 return self; |
|
51 } |
|
52 |
|
53 |
|
54 EXPORT_C CMTPFullEnumDataCodeMgr::~CMTPFullEnumDataCodeMgr() |
|
55 { |
|
56 __FLOG(_L8("~CMTPFullEnumDataCodeMgr - Entry")); |
|
57 delete iKnowledgeFormat; |
|
58 iServiceProperties.Close(); |
|
59 __FLOG(_L8("~CMTPFullEnumDataCodeMgr - Exit")); |
|
60 __FLOG_CLOSE; |
|
61 } |
|
62 |
|
63 CMTPFullEnumDataCodeMgr::CMTPFullEnumDataCodeMgr(MMTPDataProviderFramework& aFramework) : |
|
64 iFramework(aFramework), |
|
65 iServiceGUID(MAKE_TUINT64(KMTPFullEnumServiceGUID[0], KMTPFullEnumServiceGUID[1]), |
|
66 MAKE_TUINT64(KMTPFullEnumServiceGUID[2], KMTPFullEnumServiceGUID[3])), |
|
67 iPersistentServiceGUID(MAKE_TUINT64(KMTPFullEnumServicePSGUID[0], KMTPFullEnumServicePSGUID[1]), |
|
68 MAKE_TUINT64(KMTPFullEnumServicePSGUID[2], KMTPFullEnumServicePSGUID[3])) |
|
69 { |
|
70 } |
|
71 |
|
72 void CMTPFullEnumDataCodeMgr::ConstructL() |
|
73 { |
|
74 __FLOG_OPEN(KMTPSubsystem, KComponent); |
|
75 __FLOG(_L8("ConstructL - Entry")); |
|
76 BuildServiceIDL(); |
|
77 BuildFormatL(); |
|
78 BuildServicePropertyL(); |
|
79 __FLOG(_L8("ConstructL - Exit")); |
|
80 } |
|
81 |
|
82 EXPORT_C TUint CMTPFullEnumDataCodeMgr::ServiceID() const |
|
83 { |
|
84 return iServiceID; |
|
85 } |
|
86 |
|
87 EXPORT_C const TMTPTypeGuid& CMTPFullEnumDataCodeMgr::ServiceGUID() const |
|
88 { |
|
89 return iServiceGUID; |
|
90 } |
|
91 |
|
92 void CMTPFullEnumDataCodeMgr::BuildServiceIDL() |
|
93 { |
|
94 __FLOG(_L8("BuildServiceIDL - Entry")); |
|
95 //Allocate abstract service ID |
|
96 User::LeaveIfError(iFramework.DataCodeGenerator().AllocateServiceID( |
|
97 iPersistentServiceGUID, |
|
98 EMTPServiceTypeAbstract, |
|
99 iServiceID)); |
|
100 __FLOG(_L8("BuildServiceIDL - Exit")); |
|
101 } |
|
102 |
|
103 void CMTPFullEnumDataCodeMgr::BuildFormatL() |
|
104 { |
|
105 __FLOG(_L8("BuildFormatL - Entry")); |
|
106 |
|
107 |
|
108 iKnowledgeFormat = new(ELeave) RMTPServiceFormat; |
|
109 iKnowledgeFormat->iIndex = EMTPFormatTypeFullEnumSyncKnowledge; |
|
110 iKnowledgeFormat->iFormatCode = 0; |
|
111 const TMTPTypeGuid KMTPKnowledgeFormatGUID( |
|
112 MAKE_TUINT64(KMTPFullEnumSyncKnowledgeFormatGUID[0], KMTPFullEnumSyncKnowledgeFormatGUID[1]), |
|
113 MAKE_TUINT64(KMTPFullEnumSyncKnowledgeFormatGUID[2], KMTPFullEnumSyncKnowledgeFormatGUID[3])); |
|
114 iKnowledgeFormat->iFormatGUID = KMTPKnowledgeFormatGUID; |
|
115 iKnowledgeFormat->iBaseFormatCode = KBaseFormatCode; |
|
116 iKnowledgeFormat->iFormatName.Set(KNameFullEnumSyncKnowledege()); |
|
117 iKnowledgeFormat->iMIMEType.Set(KNameFullEnumSyncKnowledegeMIMEType()); |
|
118 User::LeaveIfError(iFramework.DataCodeGenerator().AllocateServiceFormatCode( |
|
119 iPersistentServiceGUID, |
|
120 iKnowledgeFormat->iFormatGUID, |
|
121 iKnowledgeFormat->iFormatCode)); |
|
122 TUint propertyCount = sizeof(KMTPFullEnumSyncKnowledgeObjectProperties) / sizeof(KMTPFullEnumSyncKnowledgeObjectProperties[0]); |
|
123 for (TUint j = 0; j < propertyCount; j++) |
|
124 { |
|
125 iKnowledgeFormat->iProps.AppendL(KMTPFullEnumSyncKnowledgeObjectProperties[j]); |
|
126 } |
|
127 |
|
128 __FLOG(_L8("BuildFormatL - Exit")); |
|
129 } |
|
130 |
|
131 void CMTPFullEnumDataCodeMgr::BuildServicePropertyL() |
|
132 { |
|
133 __FLOG(_L8("BuildServicePropertyL - Entry")); |
|
134 |
|
135 const TMTPTypeGuid KMTPFullEnumSyncServiceNamespace( |
|
136 MAKE_TUINT64(KMTPFullEnumSyncServiceNSGUID[0], KMTPFullEnumSyncServiceNSGUID[1]), |
|
137 MAKE_TUINT64(KMTPFullEnumSyncServiceNSGUID[2], KMTPFullEnumSyncServiceNSGUID[3])); |
|
138 |
|
139 const TMTPTypeGuid KMTPSyncSvcServiceNamespace( |
|
140 MAKE_TUINT64(KMTPSyncSvcServiceNSGUID[0], KMTPSyncSvcServiceNSGUID[1]), |
|
141 MAKE_TUINT64(KMTPSyncSvcServiceNSGUID[2], KMTPSyncSvcServiceNSGUID[3])); |
|
142 |
|
143 // Filtertype only need be allocate once by framework, so put it into abstract service. |
|
144 const TMTPServicePropertyInfo KMTPFullEnumSyncServiceProperties[] = |
|
145 { |
|
146 {EMTPServicePropertyVersionProps, 0, KMTPFullEnumSyncServiceNamespace, 3, KNameFullEnumVersionProps()}, |
|
147 {EMTPServicePropertyReplicaID, 0, KMTPFullEnumSyncServiceNamespace, 4, KNameFullEnumReplicaID()}, |
|
148 {EMTPServicePropertyKnowledgeObjectID, 0, KMTPFullEnumSyncServiceNamespace, 7, KNameFullEnumKnowledgeObjectID()}, |
|
149 {EMTPServicePropertyLastSyncProxyID, 0, KMTPFullEnumSyncServiceNamespace, 8, KNameFullEnumLastSyncProxyID()}, |
|
150 {EMTPServicePropertyProviderVersion, 0, KMTPFullEnumSyncServiceNamespace, 9, KNameFullEnumProviderVersion()}, |
|
151 {EMTPServicePropertySyncFormat, 0, KMTPSyncSvcServiceNamespace, 2, KNameSyncSvcSyncFormat()}, |
|
152 {EMTPServicePropertyLocalOnlyDelete, 0, KMTPSyncSvcServiceNamespace, 3, KNameSyncSvcLocalOnlyDelete()}, |
|
153 {EMTPServicePropertyFilterType, 0, KMTPSyncSvcServiceNamespace, 4, KNameSyncSvcFilterType()}, |
|
154 {EMTPServicePropertySyncObjectReferences, 0, KMTPSyncSvcServiceNamespace, 5, KNameSyncSvcSyncObjectReferences()} |
|
155 }; |
|
156 |
|
157 TUint propCount = sizeof(KMTPFullEnumSyncServiceProperties) / sizeof(KMTPFullEnumSyncServiceProperties[0]); |
|
158 |
|
159 for (TUint i = 0; i < propCount; i++) |
|
160 { |
|
161 TMTPServicePropertyInfo servicePropertyInfo = KMTPFullEnumSyncServiceProperties[i]; |
|
162 User::LeaveIfError(iFramework.DataCodeGenerator().AllocateServicePropertyCode(iPersistentServiceGUID, |
|
163 servicePropertyInfo.iServicePropPKeyNamespace, servicePropertyInfo.iServicePropPKeyID, servicePropertyInfo.iServicePropCode)); |
|
164 iServiceProperties.InsertInOrder(servicePropertyInfo, TMTPServicePropertyInfo::LinearOrderServicePropOrder); |
|
165 } |
|
166 |
|
167 __FLOG(_L8("BuildServicePropertyL - Exit")); |
|
168 } |
|
169 |
|
170 EXPORT_C void CMTPFullEnumDataCodeMgr::GetSevicePropCodesL(RArray<TUint32>& aArray) const |
|
171 { |
|
172 __FLOG(_L8("GetSevicePropCodesL - Entry")); |
|
173 TInt count = iServiceProperties.Count(); |
|
174 for (TInt i = 0; i < count; i++) |
|
175 { |
|
176 aArray.AppendL(iServiceProperties[i].iServicePropCode); |
|
177 } |
|
178 __FLOG(_L8("GetSevicePropCodesL - Exit")); |
|
179 } |
|
180 |
|
181 EXPORT_C const RMTPServiceFormat& CMTPFullEnumDataCodeMgr::KnowledgeFormat() const |
|
182 { |
|
183 // only Knowledge Format supported in FullEnum Sync Service |
|
184 __ASSERT_DEBUG((iKnowledgeFormat != NULL), User::Invariant()); |
|
185 return *iKnowledgeFormat; |
|
186 } |
|
187 |
|
188 /** |
|
189 The property code must be valid to call this func |
|
190 */ |
|
191 EXPORT_C const TMTPServicePropertyInfo* CMTPFullEnumDataCodeMgr::ServicePropertyInfo(TUint16 aPropCode) const |
|
192 { |
|
193 __FLOG(_L8("ServicePropertyInfo - Entry")); |
|
194 const TMTPServicePropertyInfo* pPropInfo = NULL; |
|
195 TInt index = iServiceProperties.FindInOrder(aPropCode, TMTPServicePropertyInfo::LinearOrderServicePropOrder); |
|
196 if (KErrNotFound != index) |
|
197 { |
|
198 pPropInfo = &(iServiceProperties[index]); |
|
199 } |
|
200 __FLOG(_L8("ServicePropertyInfo - Exit")); |
|
201 return pPropInfo; |
|
202 } |
|
203 |
|
204 |