mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-18 19:48:53 +00:00
Monotone-Parent: cf528c32a864b21894f3e0902af7a6f58b27594a
Monotone-Revision: b7300c32ea4332dc810095989c8cea185300c032 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-11-19T20:21:48 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
2009-11-19 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* SoObjects/SOGo/SOGoUserDefaults.m (-fetchJSONProfileFromDB):
|
||||
extracted the conversion of property list values to JSON values
|
||||
into a new separate method (-_convertPListToJSON:), that will be
|
||||
invoked by -jsonRepresentation.
|
||||
|
||||
* SoObjects/SOGo/SQLSource.m (-checkLogin:andPassword:):
|
||||
(_lookupContactEntry:considerEmail:, -allEntryIDS)
|
||||
(_lookupContactEntry:consideringEmail:, fetchContactsMatching:):
|
||||
|
||||
@@ -103,11 +103,10 @@ static NSString *uidColumnName = @"c_uid";
|
||||
{
|
||||
GCSChannelManager *cm;
|
||||
EOAdaptorChannel *channel;
|
||||
NSDictionary *row, *plist;
|
||||
NSDictionary *row;
|
||||
NSException *ex;
|
||||
NSString *sql, *value, *error;
|
||||
NSString *sql, *value;
|
||||
NSArray *attrs;
|
||||
NSData *plistData;
|
||||
|
||||
value = nil;
|
||||
|
||||
@@ -140,26 +139,6 @@ static NSString *uidColumnName = @"c_uid";
|
||||
#warning The result is supposed to be unescaped, why re-unescaping it here ?
|
||||
value = [value stringByReplacingString: @"''" withString: @"'"];
|
||||
value = [value stringByReplacingString: @"\\\\" withString: @"\\"];
|
||||
if (![value isJSONString])
|
||||
{
|
||||
plistData = [value dataUsingEncoding: NSUTF8StringEncoding];
|
||||
plist = [NSPropertyListSerialization propertyListFromData: plistData
|
||||
mutabilityOption: NSPropertyListMutableContainers
|
||||
format: NULL
|
||||
errorDescription: &error];
|
||||
if (plist)
|
||||
{
|
||||
[self logWithFormat: @"database value for '%@'"
|
||||
@" (uid: '%@') is a plist", fieldName, uid];
|
||||
value = [plist jsonStringValue];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self errorWithFormat: @"failed to parse property list value"
|
||||
@" (error: %@): %@", error, value];
|
||||
value = nil;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -180,6 +159,36 @@ static NSString *uidColumnName = @"c_uid";
|
||||
return value;
|
||||
}
|
||||
|
||||
- (NSString *) _convertPListToJSON: (NSString *) plistValue
|
||||
{
|
||||
NSData *plistData;
|
||||
NSDictionary *plist;
|
||||
NSString *jsonValue, *error;
|
||||
|
||||
plistData = [plistValue dataUsingEncoding: NSUTF8StringEncoding];
|
||||
plist = [NSPropertyListSerialization propertyListFromData: plistData
|
||||
mutabilityOption: NSPropertyListMutableContainers
|
||||
format: NULL
|
||||
errorDescription: &error];
|
||||
if (plist)
|
||||
{
|
||||
[self logWithFormat: @"database value for '%@'"
|
||||
@" (uid: '%@') is a plist", fieldName, uid];
|
||||
jsonValue = [plist jsonStringValue];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self errorWithFormat: @"failed to parse property list value"
|
||||
@" (error: %@): %@", error, plistValue];
|
||||
jsonValue = nil;
|
||||
}
|
||||
|
||||
if (!jsonValue)
|
||||
jsonValue = @"{}";
|
||||
|
||||
return jsonValue;
|
||||
}
|
||||
|
||||
- (NSString *) jsonRepresentation
|
||||
{
|
||||
SOGoCache *cache;
|
||||
@@ -200,6 +209,8 @@ static NSString *uidColumnName = @"c_uid";
|
||||
jsonValue = [self fetchJSONProfileFromDB];
|
||||
if ([jsonValue length])
|
||||
{
|
||||
if (![jsonValue isJSONString])
|
||||
jsonValue = [self _convertPListToJSON: jsonValue];
|
||||
defFlags.isNew = NO;
|
||||
if ([fieldName isEqualToString: @"c_defaults"])
|
||||
[cache setUserDefaults: jsonValue forLogin: uid];
|
||||
|
||||
Reference in New Issue
Block a user