Changeset 23478
- Timestamp:
- 05/17/2008 06:51:06 PM (7 months ago)
- Files:
-
- trunk/Frameworks/Adium Framework/Source/AIInterfaceControllerProtocol.h (modified) (2 diffs)
- trunk/Plugins/Dual Window Interface/AIDualWindowInterfacePlugin.m (modified) (2 diffs)
- trunk/Resources/en.lproj/GeneralPreferences.nib/classes.nib (modified) (1 diff)
- trunk/Resources/en.lproj/GeneralPreferences.nib/info.nib (modified) (1 diff)
- trunk/Resources/en.lproj/GeneralPreferences.nib/keyedobjects.nib (modified) (previous)
- trunk/Source/AIInterfaceController.h (modified) (1 diff)
- trunk/Source/AIInterfaceController.m (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Frameworks/Adium Framework/Source/AIInterfaceControllerProtocol.h
r23390 r23478 25 25 #define KEY_TABBED_CHATTING @"Tabbed Chatting" 26 26 #define KEY_GROUP_CHATS_BY_GROUP @"Group Chats By Group" 27 #define KEY_SAVE_CONTAINERS @"Save Containers On Quit" 28 #define KEY_CONTAINERS @"Containers" 27 29 28 30 #define PREF_GROUP_CONTACT_LIST @"Contact List" … … 442 444 * Key Value 443 445 * @"ID" NSString of the containerID 446 * @"Frame" NSString of the window's [NSWindow frame] 444 447 * @"Content" NSArray of the AIChat objects within that container 445 448 * @"Name" NSString of the container's name trunk/Plugins/Dual Window Interface/AIDualWindowInterfacePlugin.m
r23389 r23478 172 172 * Key Value 173 173 * @"ID" NSString of the containerID 174 * @"Frame" NSString of the window's [NSWindow frame] 174 175 * @"Content" NSArray of the AIChat objects within that container 175 176 * @"Name" NSString of the container's name … … 183 184 while ((container = [containerEnumerator nextObject])) { 184 185 [openContainersAndChats addObject:[NSDictionary dictionaryWithObjectsAndKeys: 185 [container containerID], @"ID", 186 [container containedChats], @"Content", 187 [container name], @"Name", 188 nil]]; 186 [container containerID], @"ID", 187 NSStringFromRect([[container window] frame]), @"Frame", 188 [container containedChats], @"Content", 189 [container name], @"Name", 190 nil]]; 189 191 } 190 192 trunk/Resources/en.lproj/GeneralPreferences.nib/classes.nib
r22854 r23478 51 51 <key>prefsWindowWillClose</key> 52 52 <string>SS_PrefsController</string> 53 <key>toggleFindPanel</key> 54 <string>id</string> 53 55 <key>willAdjustSubviews</key> 54 56 <string>RBSplitView</string> trunk/Resources/en.lproj/GeneralPreferences.nib/info.nib
r22854 r23478 14 14 </array> 15 15 <key>IBSystem Version</key> 16 <string>9C 31</string>16 <string>9C7010</string> 17 17 <key>targetFramework</key> 18 18 <string>IBCocoaFramework</string> trunk/Source/AIInterfaceController.h
r20924 r23478 75 75 76 76 BOOL groupChatsByContactGroup; 77 BOOL saveContainers; 77 78 78 79 NSMenuItem *menuItem_toggleUserlist; trunk/Source/AIInterfaceController.m
r23389 r23478 19 19 #import "AIInterfaceController.h" 20 20 21 #import <Adium/AIAccountControllerProtocol.h> 21 22 #import <Adium/AIContactControllerProtocol.h> 22 23 #import <Adium/AIChatControllerProtocol.h> … … 65 66 - (void)updateCloseMenuKeys; 66 67 68 - (void)saveContainers; 69 - (void)restoreSavedContainers; 70 67 71 //Window Menu 68 72 - (void)updateActiveWindowMenuItem; … … 161 165 //Open the contact list window 162 166 [self showContactList:nil]; 163 167 164 168 //Userlist show/hide item 165 169 menuItem_toggleUserlist = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:AILocalizedString(@"Toggle User List", nil) … … 192 196 name:CONTENT_MESSAGE_RECEIVED object:nil]; 193 197 [[adium notificationCenter] addObserver:self selector:@selector(didReceiveContent:) 194 name:CONTENT_MESSAGE_RECEIVED_GROUP object:nil]; 198 name:CONTENT_MESSAGE_RECEIVED_GROUP object:nil]; 199 200 //Observe quits so we can save containers. 201 [[adium notificationCenter] addObserver:self 202 selector:@selector(saveContainers) 203 name:AIAppWillTerminateNotification 204 object:nil]; 195 205 } 196 206 … … 241 251 tabbedChatting = [[prefDict objectForKey:KEY_TABBED_CHATTING] boolValue]; 242 252 groupChatsByContactGroup = [[prefDict objectForKey:KEY_GROUP_CHATS_BY_GROUP] boolValue]; 253 saveContainers = [[prefDict objectForKey:KEY_SAVE_CONTAINERS] boolValue]; 254 255 if (saveContainers && firstTime) { 256 //Restore saved containers 257 [self restoreSavedContainers]; 258 } 243 259 } 244 260 … … 350 366 * @returns Created contact list controller for detached contact list 351 367 */ 352 - (AIListWindowController *)detachContactList:(AIListGroup *)aContactList { 368 - (AIListWindowController *)detachContactList:(AIListGroup *)aContactList 369 { 353 370 return [contactListPlugin detachContactList:aContactList]; 354 371 } 355 372 373 374 #pragma mark Container Saving 375 /*! 376 * @brief Restores containers saved from a previous session 377 */ 378 - (void)restoreSavedContainers 379 { 380 NSData *savedData = [[adium preferenceController] preferenceForKey:KEY_CONTAINERS 381 group:PREF_GROUP_INTERFACE]; 382 383 // If there's no data, we can't restore anything. 384 if (!savedData) 385 return; 386 387 NSEnumerator *enumerator = [[NSKeyedUnarchiver unarchiveObjectWithData:savedData] objectEnumerator]; 388 NSDictionary *dict; 389 390 while ((dict = [enumerator nextObject])) { 391 AIMessageWindowController *windowController = [self openContainerWithID:[dict objectForKey:@"ID"] 392 name:[dict objectForKey:@"Name"]]; 393 394 NSEnumerator *chatEnumerator = [[dict objectForKey:@"Content"] objectEnumerator]; 395 NSDictionary *chatDict; 396 397 while ((chatDict = [chatEnumerator nextObject])) { 398 AIChat *chat = nil; 399 AIService *service = [[adium accountController] firstServiceWithServiceID:[chatDict objectForKey:@"serviceID"]]; 400 AIAccount *account = [[adium accountController] accountWithInternalObjectID:[chatDict objectForKey:@"AccountID"]]; 401 402 if ([[chatDict objectForKey:@"IsGroupChat"] boolValue]) { 403 chat = [[adium chatController] chatWithName:[chatDict objectForKey:@"Name"] 404 identifier:nil 405 onAccount:account 406 chatCreationInfo:[chatDict objectForKey:@"ChatCreationInfo"]]; 407 } else { 408 AIListContact *contact = [[adium contactController] contactWithService:service 409 account:account 410 UID:[chatDict objectForKey:@"UID"]]; 411 412 chat = [[adium chatController] chatWithContact:contact]; 413 } 414 415 // Open the chat into the container we've created above. 416 [self openChat:chat inContainerWithID:[dict objectForKey:@"ID"] atIndex:-1]; 417 } 418 419 // Position the container where it was last saved (using -savedFrameFromString: to prevent going offscreen) 420 [[windowController window] setFrame:[windowController savedFrameFromString:[dict objectForKey:@"Frame"]] display:YES]; 421 } 422 } 423 424 /*! 425 * @brief Saves open container information when Adium quits 426 */ 427 - (void)saveContainers 428 { 429 // If we're quitting with containers unsaved, be sure to reset the possibly-formerly-valid information to nil 430 // We don't do this upon unchecking the preference so that it isn't a permanent removal of the saved information until 431 // end of session. 432 if (!saveContainers) { 433 [[adium preferenceController] setPreference:nil 434 forKey:KEY_CONTAINERS 435 group:PREF_GROUP_INTERFACE]; 436 return; 437 } 438 439 // Save active containers. 440 NSMutableArray *savedContainers = [NSMutableArray array]; 441 NSEnumerator *enumerator = [[interfacePlugin openContainersAndChats] objectEnumerator]; 442 NSDictionary *dict; 443 444 while ((dict = [enumerator nextObject])) { 445 NSMutableArray *containerContents = [NSMutableArray array]; 446 NSEnumerator *containedEnumerator = [[dict objectForKey:@"Content"] objectEnumerator]; 447 AIChat *chat; 448 449 while ((chat = [containedEnumerator nextObject])) { 450 if ([chat isOpen]) { 451 if ([chat isGroupChat]) { 452 // -chatCreationDictionary may be nil, so put it last. 453 [containerContents addObject:[NSDictionary dictionaryWithObjectsAndKeys: 454 [NSNumber numberWithBool:YES], @"IsGroupChat", 455 [chat name], @"Name", 456 [[chat account] internalObjectID], @"AccountID", 457 [chat chatCreationDictionary], @"ChatCreationInfo",nil]]; 458 } else { 459 [containerContents addObject:[NSDictionary dictionaryWithObjectsAndKeys: 460 [[chat listObject] UID], @"UID", 461 [[chat listObject] serviceID], @"serviceID", 462 [[chat account] internalObjectID], @"AccountID",nil]]; 463 } 464 } 465 } 466 467 // Replace the "Content" key in -openContainersAndChats with our version of the content. 468 // We use the same keys otherwise that -openContainersAndChats provides (Name, ID, Frame) 469 NSMutableDictionary *saveDict = [[dict mutableCopy] autorelease]; 470 471 [saveDict setObject:containerContents 472 forKey:@"Content"]; 473 474 [savedContainers addObject:saveDict]; 475 } 476 477 [[adium preferenceController] setPreference:[NSKeyedArchiver archivedDataWithRootObject:savedContainers] 478 forKey:KEY_CONTAINERS 479 group:PREF_GROUP_INTERFACE]; 480 } 356 481 357 482 //Messaging ------------------------------------------------------------------------------------------------------------