From 5993fe97c396d868cf9ed46049cee41ba3c0e849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20J=2E=20Hern=C3=A1ndez=20Blasco?= Date: Fri, 11 Dec 2015 11:37:02 +0100 Subject: [PATCH] oc-db: Implement description message to ease debugging Which dumps the properties NSMutableDictionary --- OpenChange/MAPIStoreDBMessage.m | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/OpenChange/MAPIStoreDBMessage.m b/OpenChange/MAPIStoreDBMessage.m index bb5acbb57..836cfb4e1 100644 --- a/OpenChange/MAPIStoreDBMessage.m +++ b/OpenChange/MAPIStoreDBMessage.m @@ -109,6 +109,49 @@ return self; } +- (NSString *) description +{ + id key, value; + NSEnumerator *propEnumerator; + NSMutableString *description; + + description = [NSMutableString stringWithFormat: @"%@ %@. Properties: {", NSStringFromClass ([self class]), + [self url]]; + + propEnumerator = [properties keyEnumerator]; + while ((key = [propEnumerator nextObject])) + { + uint32_t proptag = 0; + if ([key isKindOfClass: [NSString class]] && [(NSString *)key intValue] > 0) + proptag = [(NSString *)key intValue]; + else if ([key isKindOfClass: [NSNumber class]]) + proptag = [key unsignedLongValue]; + + if (proptag > 0) + { + const char *propTagName = get_proptag_name ([key unsignedLongValue]); + NSString *propName; + + if (propTagName) + propName = [NSString stringWithCString: propTagName + encoding: NSUTF8StringEncoding]; + else + propName = [NSString stringWithFormat: @"0x%.4x", [key unsignedLongValue]]; + + [description appendFormat: @"'%@': ", propName]; + } + else + [description appendFormat: @"'%@': ", key]; + + value = [properties objectForKey: key]; + [description appendFormat: @"%@ (%@), ", value, NSStringFromClass ([value class])]; + } + + [description appendString: @"}\n"]; + + return description; +} + - (uint64_t) objectVersion { NSNumber *versionNbr;