Paste number 40558: initChatWindow

Index of paste annotations: 3 | 2 | 1

Paste number 40558: initChatWindow
Pasted by: Jasarien
When:2 years, 2 months ago
Share:Tweet this! | http://paste.lisp.org/+VAM
Channel:#adium-devl
Paste contents:
Raw Source | XML | Display As
//Get everything needed to start a chat with a buddy.
- (void)initChatWindow
{
	//Init the buddy to chat with.
	XfireBuddyListEntry *entry = [[[_xfire buddyList] onlineEntries] objectAtIndex:[buddyListTableView selectedRow]];
	
	chatListEnum = [[chatList openChats] objectEnumerator];
	ChatWindowController *chat;
	
	while ((chat = [chatListEnum nextObject]))
	{
		if ([[chat chatForBuddy] isEqualTo:entry])
		{
			[[chat windowForChat] makeKeyAndOrderFront:self];
		} else
		{
			ChatWindowController *tempChat = [[ChatWindowController alloc] initWithBuddy:entry];
			tempList = [chatList openChats];
			[tempList addObject:tempChat];
			[tempChat release];
		}
	}
	
	[chatList mergeListWithChatList:tempList];	
}

Annotations for this paste:

Annotation number 3: do, while loop
Pasted by: Jasarien
When:2 years, 2 months ago
Share:Tweet this! | http://paste.lisp.org/+VAM#3
Paste contents:
Raw Source | Display As
NSLog(@"Before loop");

	do {
		NSLog(@"Starting while loop.");
		if ([[chat chatForBuddy] isEqualTo:entry])
		{
			NSLog(@"Bringing existing chat forward for buddy: ", [entry displayName]);
			[[chat windowForChat] makeKeyAndOrderFront:self];
		} else
		{
			NSLog(@"Creating new chat for buddy: ", [entry displayName]);
			ChatWindowController *tempChat = [[ChatWindowController alloc] initWithBuddy:entry];
			
			[tempList addObjectsFromArray:[chatList openChats]];
			[tempList addObject:tempChat];
			[tempChat release];
		}
	} while (chat = [chatListEnum nextObject]);

NSLog(@"After Loop");

Annotation number 2: XFChatList
Pasted by: Jasarien
When:2 years, 2 months ago
Share:Tweet this! | http://paste.lisp.org/+VAM#2
Paste contents:
Raw Source | Display As
//
//  XFChatList.h
//  Xflame
//
//  Created by Jasarien on 30/04/2007.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import <Cocoa/Cocoa.h>


@interface XFChatList : NSObject {
	
	NSMutableArray *openChats;

}

- (NSMutableArray *)openChats;
- (void)mergeListWithChatList:(NSMutableArray *)aList;

@end

-----------------------------------------------------------------------------------------

//
//  XFChatList.m
//  Xflame
//
//  Created by Jasarien on 30/04/2007.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import "XFChatList.h"


@implementation XFChatList

- (id)init
{
	if (self = [super init])
		{
			openChats = [NSMutableArray array];
		}
	
	return self;
}

- (void)dealloc
{
	NSLog(@"deallocating XFChatList");
	[openChats release];
	[super dealloc];
}

- (NSMutableArray *)openChats
{
	NSLog(@"oc1");
	return openChats;
}

- (void)mergeListWithChatList:(NSMutableArray *)aList
{
	openChats = aList;
}

@end

Annotation number 1: XFController
Pasted by: Jasarien
When:2 years, 2 months ago
Share:Tweet this! | http://paste.lisp.org/+VAM#1
Paste contents:
Raw Source | Display As
//
//  XFController.h
//  Xflame
//
//  Created by James Addyman on 15/01/07.
//  2007 Jasarien.Com.
//

#import <Cocoa/Cocoa.h>
#import "Xfire.h"
#import "ChatWindowController.h"
#import "XFChatList.h"

@interface XFController : NSWindowController <XfireDelegate>
{
	//Main Window Outlets
	IBOutlet NSTableView *buddyListTableView;
	IBOutlet NSTextField *statusField;
	IBOutlet NSTextField *nickField;
	IBOutlet NSTextField *passwordField;
	IBOutlet NSTextField *usernameField;
	IBOutlet NSButton *connectButton;
	IBOutlet NSPanel *addBuddy;
	IBOutlet NSPanel *loginPanel;
	IBOutlet NSWindow *mainWindow;

	//Menu Bar Outlets
	IBOutlet NSMenuItem *loginItem;
	IBOutlet NSMenuItem *logoutItem;
	
	//Add Buddy Window Outlets
	IBOutlet NSTextField *buddyField;
	IBOutlet NSTextField *buddyMessage;

	//Connection Status
	BOOL connected;
	
	//ChatList object
	XFChatList *chatList;
	NSMutableArray *tempList;
	NSEnumerator *chatListEnum;
	
	//Xfire object for interacting with XfireLib
	Xfire *_xfire;
}

//Main Window Methods
- (IBAction)login:(id)sender;
- (IBAction)logout:(id)sender;
- (IBAction)showLoginPanel:(id)sender;
- (IBAction)hideLoginPanel:(id)sender;
- (IBAction)setStatus:(id)sender;
- (IBAction)setNickName:(id)sender;
- (IBAction)showAddBuddyWindow:(id)sender;
- (IBAction)removeBuddy:(id)sender;
- (void)initChatWindow;
- (void)openChatWindowForBuddy:(XfireBuddyListEntry *)theBuddy;

//Add Buddy Window Methods
- (IBAction)addBuddy:(id)sender;
- (IBAction)cancelAddBuddy:(id)sender;

@end

Colorize as:
Show Line Numbers
Index of paste annotations: 3 | 2 | 1

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.