adium/adium

Parents 5dbed3571369
Children d899ccda08c8
Add shortcuts for boolean properties back to ESObjectWithProperties, thanks to Catfish_Man.

This should help speed up things like sorting the contact list.
--- a/Frameworks/Adium Framework/Source/AIAccount.h Tue Aug 07 13:05:53 2012 -0500
+++ b/Frameworks/Adium Framework/Source/AIAccount.h Wed Aug 08 16:21:21 2012 +0200
@@ -186,11 +186,17 @@
NSString *formattedUID;
AIStatus *accountStatus;
+ BOOL isConnecting;
NSDate *waitingToReconnect;
+ BOOL isDisconnecting;
+
+ BOOL isWaitingForNetwork;
NSInteger connectionProgressPercent;
NSString *connectionProgressString;
+ BOOL mustPromptForPasswordOnNextConnect;
+
NSString *currentDisplayName;
}
--- a/Frameworks/Adium Framework/Source/AIChat.h Tue Aug 07 13:05:53 2012 -0500
+++ b/Frameworks/Adium Framework/Source/AIChat.h Wed Aug 08 16:21:21 2012 +0200
@@ -133,6 +133,8 @@
NSDictionary *chatCreationInfo;
+ BOOL accountJoined;
+
NSInteger unviewedMention;
NSInteger unviewedContent;
@@ -142,6 +144,8 @@
NSDictionary *securityDetails;
+ BOOL secureMessagingLastEncryptedState;
+
NSString *topic;
AIListContact *topicSetter;
}
--- a/Frameworks/Adium Framework/Source/AIListContact.h Tue Aug 07 13:05:53 2012 -0500
+++ b/Frameworks/Adium Framework/Source/AIListContact.h Wed Aug 08 16:21:21 2012 +0200
@@ -34,17 +34,26 @@
NSColor *labelColor;
NSNumber *imageOpacity;
+ BOOL isEvent;
NSString *ABUniqueID;
NSAttributedString *textProfile;
+ BOOL isBlocked;
+ BOOL isIdle;
NSInteger idle;
NSDate *idleSince;
NSString *idleReadable;
+ BOOL notAStranger;
+ BOOL isMobile;
+
NSString *serverDisplayName;
NSString *formattedUID;
+
+ BOOL signedOff;
+ BOOL signedOn;
}
- (id)initWithUID:(NSString *)inUID account:(AIAccount *)inAccount service:(AIService *)inService;
--- a/Frameworks/Adium Framework/Source/AIListObject.h Tue Aug 07 13:05:53 2012 -0500
+++ b/Frameworks/Adium Framework/Source/AIListObject.h Wed Aug 08 16:21:21 2012 +0200
@@ -102,6 +102,9 @@
NSImage *listStateIcon;
NSImage *listStatusIcon;
+ BOOL isOnline;
+ BOOL alwaysVisible;
+
NSInteger unviewedContent;
NSInteger unviewedMention;
--- a/Frameworks/Adium Framework/Source/ESObjectWithProperties.m Tue Aug 07 13:05:53 2012 -0500
+++ b/Frameworks/Adium Framework/Source/ESObjectWithProperties.m Wed Aug 08 16:21:21 2012 +0200
@@ -79,8 +79,14 @@
}
[self willChangeValueForKey:key];
-
- Ivar ivar = class_getInstanceVariable([self class], [key UTF8String]);
+
+ char property_name[256];
+
+ NSAssert([key length] < 256, @"Too long property!");
+
+ [key getCString:property_name maxLength:32 encoding:NSUTF8StringEncoding];
+
+ Ivar ivar = class_getInstanceVariable([self class], property_name);
// fall back to the dictionary
if (ivar == NULL) {
@@ -107,16 +113,16 @@
} else if (strcmp(ivarType, @encode(NSInteger)) == 0) {
- NSInteger iValue;
+ NSInteger *idx = (NSInteger*)((char *)self + ivar_getOffset(ivar));
+ NSInteger iValue = [value integerValue];
- if (value) {
- iValue = [value integerValue];
- } else {
- iValue = 0;
- }
+ *idx = iValue;
+ } else if (strcmp(ivarType, @encode(BOOL)) == 0) {
- object_setIvar(self, ivar, (void *)iValue);
+ BOOL *idx = (BOOL*)((char *)self + ivar_getOffset(ivar));
+ BOOL iValue = [value boolValue];
+ *idx = iValue;
}
}
@@ -202,7 +208,13 @@
id ret = nil;
id value = nil;
- Ivar ivar = object_getInstanceVariable(self, [key UTF8String], (void **)&value);
+ char property_name[256];
+
+ NSAssert([key length] < 256, @"Too long property!");
+
+ [key getCString:property_name maxLength:32 encoding:NSUTF8StringEncoding];
+
+ Ivar ivar = object_getInstanceVariable(self, property_name, (void **)&value);
if (ivar == NULL) {
@@ -218,6 +230,9 @@
// attempt to wrap it, if we know how
if (strcmp(ivarType, @encode(NSInteger)) == 0) {
ret = [[[NSNumber alloc] initWithInteger:(NSInteger)value] autorelease];
+ } else if (strcmp(ivarType, @encode(BOOL)) == 0) {
+ BOOL *idx = (BOOL*)((char *)self + ivar_getOffset(ivar));
+ ret = [NSNumber numberWithBool:*idx];
} else if (ivarType[0] != _C_ID) {
AILogWithSignature(@" *** This ivar is not an object but an %s! Should not use -valueForProperty: @\"%@\" ***", ivarType, key);
} else {
@@ -237,7 +252,13 @@
{
NSInteger ret = 0;
- Ivar ivar = class_getInstanceVariable([self class], [key UTF8String]);
+ char property_name[256];
+
+ NSAssert([key length] < 256, @"Too long property!");
+
+ [key getCString:property_name maxLength:32 encoding:NSUTF8StringEncoding];
+
+ Ivar ivar = class_getInstanceVariable([self class], property_name);
if (ivar == NULL) {
NSNumber *number = [self numberValueForProperty:key];
@@ -270,8 +291,27 @@
{
BOOL ret = FALSE;
- NSNumber *number = [self numberValueForProperty:key];
- ret = number ? [number boolValue] : NO;
+ char property_name[256];
+
+ NSAssert([key length] < 256, @"Too long property!");
+
+ [key getCString:property_name maxLength:32 encoding:NSUTF8StringEncoding];
+
+ Ivar ivar = class_getInstanceVariable([self class], property_name);
+
+ if (ivar == NULL) {
+ NSNumber *number = [self numberValueForProperty:key];
+ ret = number ? [number boolValue] : NO;
+ } else {
+ const char *ivarType = ivar_getTypeEncoding(ivar);
+
+ if (strcmp(ivarType, @encode(BOOL)) != 0) {
+ AILogWithSignature(@"%@'s %@ ivar is not a BOOL but an %s! Will attempt to cast, but should not use -boolValueForProperty: @\"%@\"", self, key, ivarType, key);
+ }
+
+ BOOL *idx = (BOOL*)((char *)self + ivar_getOffset(ivar));
+ ret = (NSInteger)(*idx);
+ }
return ret;
}