[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/pim/akonadi/exchange/connector
From: Shaheed Haque <srhaque () theiet ! org>
Date: 2012-03-26 18:16:02
Message-ID: 20120326181602.71AA8AC899 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1287190 by shaheed:
Bring the error handling around named property mapping up to scratch,
and optimise for the no-named property case. A bigger optimisation to only
fetch mappings once is TBD.
M +40 -7 mapiconnector2.cpp
--- trunk/playground/pim/akonadi/exchange/connector/mapiconnector2.cpp \
#1287189:1287190 @@ -1455,6 +1455,8 @@
bool MapiObject::propertiesPull(QVector<int> &tags, const bool tagsAppended, bool \
pullAll) {
+ bool usingNamedProperties = false;
+
// If the user tells us the tags he has given us have not previously been
// seen, or the cache is empty, fill it.
if (!tagsAppended || !m_cachedTags.aulPropTag) {
@@ -1464,18 +1466,28 @@
error() << "cannot allocate tags:" << tags.size() << mapiError();
return false;
}
+
+ // Now create the array that MAPI will use.
m_cachedTags.cValues = tags.size();
unsigned i = 0;
foreach (int tag, tags) {
m_cachedTags.aulPropTag[i++] = (MAPITAGS)tag;
+ usingNamedProperties |= ((tag & 0x80000000) != 0);
}
m_cachedTags.aulPropTag[i] = (MAPITAGS)0;
- // Now create the array that MAPI will use.
-
- // Now create the named property translation.
+ // Now create the named property translation, if needed.
+ if (usingNamedProperties) {
m_cachedNames = mapi_nameid_new(ctx());
+ if (!m_cachedNames) {
+ error() << "Cannot create named property context" << mapiError();
+ return false;
+ }
m_cachedNamedTags = talloc_zero(ctx(), struct SPropTagArray);
+ if (!m_cachedNamedTags) {
+ error() << "Cannot create named property array" << mapiError();
+ return false;
+ }
MAPISTATUS status = mapi_nameid_lookup_SPropTagArray(m_cachedNames, \
&m_cachedTags); if ((MAPI_E_NOT_FOUND != status) && (MAPI_E_SUCCESS != status)) {
error() << "Cannot find named properties" << mapiError();
@@ -1485,7 +1497,10 @@
error() << "Cannot find named property ids" << mapiError();
return false;
}
+ } else {
+ m_cachedNames = 0;
}
+ }
m_properties = 0;
m_propertyCount = 0;
@@ -1494,13 +1509,27 @@
}
// Map the tags before the call, and unmap them afterwards.
- mapi_nameid_map_SPropTagArray(m_cachedNames, &m_cachedTags, m_cachedNamedTags);
+ if (usingNamedProperties) {
+ if (MAPI_E_SUCCESS != mapi_nameid_map_SPropTagArray(m_cachedNames, \
&m_cachedTags, m_cachedNamedTags)) { + error() << "Cannot map named \
properties" << mapiError(); + return false;
+ }
+ }
if (MAPI_E_SUCCESS != GetProps(&m_object, MAPI_UNICODE | \
MAPI_PROPS_SKIP_NAMEDID_CHECK, &m_cachedTags, &m_properties, &m_propertyCount)) { \
error() << "cannot pull properties:" << mapiError();
- mapi_nameid_unmap_SPropTagArray(m_cachedNames, &m_cachedTags);
+ if (usingNamedProperties) {
+ if (MAPI_E_SUCCESS != mapi_nameid_unmap_SPropTagArray(m_cachedNames, \
&m_cachedTags)) { + error() << "Cannot unmap named properties" << \
mapiError(); return false;
}
- mapi_nameid_unmap_SPropTagArray(m_cachedNames, &m_cachedTags);
+ }
+ return false;
+ }
+ if (usingNamedProperties) {
+ if (MAPI_E_SUCCESS != mapi_nameid_unmap_SPropTagArray(m_cachedNames, \
&m_cachedTags)) { + error() << "Cannot unmap named properties" << \
mapiError(); + return false;
+ }
// When we unmap the property tags in the value array, preserve the type
// portion since that's how we get to know about errors.
@@ -1508,10 +1537,14 @@
for (unsigned i = 0; i < m_propertyCount; i++) {
types[i] = m_properties[i].ulPropTag & 0xFFFF;
}
- mapi_nameid_unmap_SPropValue(m_cachedNames, m_properties, m_propertyCount);
+ if (MAPI_E_SUCCESS != mapi_nameid_unmap_SPropValue(m_cachedNames, \
m_properties, m_propertyCount)) { + error() << "Cannot unmap named values" \
<< mapiError(); + return false;
+ }
for (unsigned i = 0; i < m_propertyCount; i++) {
m_properties[i].ulPropTag = (MAPITAGS)(m_properties[i].ulPropTag & \
(0xFFFF0000 | types[i])); }
+ }
return true;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic