#import "TalkRequest.h"
#import <appkit/appkit.h>


@implementation TalkRequest

- initFor:(View *)aDocument
	from:(const char *)aUName
	code:(const char *)aCode
	topicIs:(const char*)aTopic
{
	[super init];
	
	document = aDocument;
	clientUName = NULL;
	topic = NULL;
	code = NULL;
	
	if (aUName)
	{
		clientUName = malloc(strlen(aUName)+1);
		strcpy(clientUName, aUName);
	}
	if (aCode)
	{
		code = malloc(strlen(aCode)+1);
		strcpy(code, aCode);
	}
	if (aTopic)
	{
		topic = malloc(strlen(aTopic)+1);
		strcpy(topic, aTopic);
	}
	return self;
}

- free
{
	if (clientUName)
		free(clientUName);
	if (code)
		free(code);
	if (topic)
		free(topic);

	return [super free];
}

- (View *)requestDocument
{
	return document;
}

- (const char *)requestUName
{
	return clientUName;
}

- (const char *)requestCode
{
	return code;
}

- (const char *)requestTopic
{
	return topic;
}

@end
