Changeset 18
- Timestamp:
- 10/05/08 12:57:50 (16 years ago)
- Location:
- Trunk
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
Trunk/ABSortByLogSizePlugin.m
r16 r18 46 46 - (NSString *)pluginVersion 47 47 { 48 return @"1. 0";48 return @"1.1"; 49 49 } 50 50 -
Trunk/AILogSizeSort.h
r16 r18 27 27 @interface AILogSizeSort : AISortController 28 28 { 29 NSMutableDictionary *logSizeCache; 29 30 } 30 31 31 +(unsigned long long)getContactLogSize:(AIListContact *)listObject; 32 -(unsigned long long)getCachedLogSize:(AIListContact *)listContact; 33 +(unsigned long long)getContactLogSize:(AIListContact *)listContact; 32 34 33 35 @end -
Trunk/AILogSizeSort.m
r16 r18 32 32 #import <Adium/AIMetaContact.h> 33 33 34 #import <Adium/ESDebugAILog.h> 35 34 36 @implementation AILogSizeSort 35 37 … … 41 43 - (void)didBecomeActiveFirstTime 42 44 { 45 AILog(@"Sort by log size controller became active for first time."); 46 logSizeCache = [[NSMutableDictionary alloc] init]; 47 AILog(@"%@", logSizeCache); 43 48 } 44 49 … … 105 110 106 111 /*! 107 * Allow users to manually sort groups.112 * @brief Allow users to manually sort groups 108 113 */ 109 114 -(BOOL)canSortManually … … 112 117 } 113 118 114 /** 119 -(unsigned long long)getCachedLogSize:(AIListContact *)listContact 120 { 121 AILogWithSignature(@"Getting cached log size for %@/%@.", [[listContact account] explicitFormattedUID], [listContact UID]); 122 123 if([logSizeCache valueForKey:[[listContact account] explicitFormattedUID]] == nil) 124 { 125 [logSizeCache setValue:[[NSMutableDictionary alloc] init] forKey:[[listContact account] explicitFormattedUID]]; 126 } 127 128 NSMutableDictionary *accountDictionary = [logSizeCache valueForKey:[[listContact account] explicitFormattedUID]]; 129 130 if([accountDictionary valueForKey:[listContact UID]] == nil) 131 { 132 AILogWithSignature(@"\tNo cache hit."); 133 [accountDictionary setValue:[NSNumber numberWithUnsignedLongLong:[AILogSizeSort getContactLogSize:listContact]] forKey: [listContact UID]]; 134 } 135 136 AILogWithSignature(@"\tLog file size: %@", [accountDictionary valueForKey:[listContact UID]]); 137 return [[accountDictionary valueForKey:[listContact UID]] unsignedLongLongValue]; 138 } 139 140 /*! 141 * @brief Returns the total aggregate log size for a contact 142 * 115 143 * Returns the total aggregate log size for a contact. For meta-contacts, the 116 144 * total log file size of all sub-contacts is returned. If no log exists or if 117 145 * something else goes wrong, 0 is returned. 118 146 * 119 * @param list Object an AIListContact for which to retrieve a total log file size147 * @param listContact an AIListContact for which to retrieve a total log file size 120 148 * @return the total log file size in bytes or 0 if an error occurred 121 149 */ 122 +(unsigned long long)getContactLogSize:(AIListContact *)list Object150 +(unsigned long long)getContactLogSize:(AIListContact *)listContact 123 151 { 124 152 NSFileManager *fileManager = [NSFileManager defaultManager]; 125 153 126 if([list Object isMemberOfClass:[AIMetaContact class]])154 if([listContact isMemberOfClass:[AIMetaContact class]]) 127 155 { 128 156 // Recurse through all sub-contacts 129 130 157 id contact; 131 158 unsigned long long size = 0; 132 159 133 NSEnumerator *contactEnumerator = [[ listObject listContacts] objectEnumerator];160 NSEnumerator *contactEnumerator = [[(AIMetaContact *)listContact listContacts] objectEnumerator]; 134 161 135 162 while(contact = [contactEnumerator nextObject]) … … 143 170 { 144 171 // Find the path to the directory containing the log files for this contact 145 NSString *path = [[AILoggerPlugin logBasePath] stringByAppendingPathComponent:[AILoggerPlugin relativePathForLogWithObject:[list Object UID] onAccount: [listObject account]]];172 NSString *path = [[AILoggerPlugin logBasePath] stringByAppendingPathComponent:[AILoggerPlugin relativePathForLogWithObject:[listContact UID] onAccount: [listContact account]]]; 146 173 147 174 // Grab an enumerator for all log files for this contact … … 171 198 #pragma mark Sorting 172 199 /*! 173 * @brief Alphabetical sort200 * @brief Sort by log size 174 201 */ 175 202 int logSizeSort(id objectA, id objectB, BOOL groups) … … 188 215 } 189 216 190 unsigned long long sizeA = [AILogSizeSort getContactLogSize:objectA]; 191 unsigned long long sizeB = [AILogSizeSort getContactLogSize:objectB]; 192 217 // Get a reference to one and only AILogSizeSort instance. If this sorting method is being 218 // called, it should always be the case that AILogSizeSort is the active sort controller. 219 AISortController *sortController = [[adium contactController] activeSortController]; 220 221 unsigned long long sizeA = 0; 222 unsigned long long sizeB = 0; 223 224 if([sortController isMemberOfClass:[AILogSizeSort class]]) 225 { 226 sizeA = [(AILogSizeSort *)sortController getCachedLogSize:objectA]; 227 sizeB = [(AILogSizeSort *)sortController getCachedLogSize:objectB]; 228 } 229 else 230 { 231 sizeA = [AILogSizeSort getContactLogSize:objectA]; 232 sizeB = [AILogSizeSort getContactLogSize:objectB]; 233 } 234 193 235 if(sizeB == sizeA) 194 236 { -
Trunk/Info.plist
r2 r18 3 3 <plist version="1.0"> 4 4 <dict> 5 <key>AIMinimumAdiumVersionRequirement</key> 6 <string>1.3</string> 5 7 <key>CFBundleDevelopmentRegion</key> 6 8 <string>English</string> … … 10 12 <string></string> 11 13 <key>CFBundleIdentifier</key> 12 <string>com. yourcompany.${PRODUCT_NAME:identifier}</string>14 <string>com.eatthepath.${PRODUCT_NAME:identifier}</string> 13 15 <key>CFBundleInfoDictionaryVersion</key> 14 16 <string>6.0</string> … … 20 22 <string>AdIM</string> 21 23 <key>CFBundleVersion</key> 22 <string>1. 0</string>24 <string>1.1</string> 23 25 <key>NSPrincipalClass</key> 24 26 <string>ABSortByLogSizePlugin</string> 25 <key>AIMinimumAdiumVersionRequirement</key>26 <string>1.3</string>27 27 </dict> 28 28 </plist>