// // Duncan.m // GNUstep Duncan // // Created by Risa Mettaserikul on Fri Feb 07 2003. // Copyright (c) 2003 CSFSS. All rights reserved. // #import #import "Duncan.h" #import "WordFileContainer.h" #import "WordAZContainer.h" @implementation Duncan - (WordContainer *)createResource:(NSString *)resourceName withFile:(NSString *)fileName { id word = [[WordFileContainer alloc] initWithName:resourceName file:fileName target:[self target]]; [self addWord:word]; return word; } - (WordContainer *)createResource:(NSString *)resourceName { id container = [[WordContainer alloc] initWithName:resourceName]; [self addWord:container]; return container; } - (void)sort { } - (void)loadAZDictionary { [self addWord:[[WordAZContainer alloc] init]]; } - (void) query:(id)datarep { [datarep flush]; [self query:datarep withParentPath:@""]; } - (id)init { /* NSPort *port1,*port2; NSConnection *conn1,*conn2; port1 = [NSPort port]; port2 = [NSPort port]; conn1 = [[NSConnection alloc] initWithReceivePort:port1 sendPort:port2]; [conn1 setRootObject:self]; conn2 = [NSConnection connectionWithReceivePort:port2 sendPort:port1]; [conn2 enableMultipleThreads]; portsArray = [[NSMutableArray alloc] initWithObjects:port1,port2,nil]; */ self = [super init]; [self setString:@"Duncan"]; [self setPath:@"/"]; [self setDefinition:@"Duncan"]; //[self addWord:[Word wordWithString:@"wow" definition:@"I love you"]]; [self loadAZDictionary]; return self; } - (id)initWithTarget:(id)newTarget { id dict; id blank; self = [super init]; [self setString:@""]; [self setPath:@"/"]; [self setTarget:newTarget]; [self setDefinition:@"Duncan"]; isReady = YES; // THIS METHOD WILL BE REMOVED, NO NEED TO SET ANY TARGET, WILL USE -queryWord:by: bookmark = [self createResource:@"Bookmark" withFile:[[NSBundle mainBundle] pathForResource:@"Bookmark" ofType:@"plist"]]; //dict,cache,blank are short-cut and must not be used w/o //making sure dict = [self createResource:@"Dictionary" withFile:[[NSBundle mainBundle] pathForResource:@"Dictionary" ofType:@"plist"]]; cache = [self createResource:@"Cache" withFile:[[NSBundle mainBundle] pathForResource:@"Cache" ofType:@"plist"]]; blank = [self createResource:@"BlankTest"]; [blank addWord:[Word wordWithString:@"wow" definition:@"I love you"]]; [blank addWord:[Word wordWithString:@"free" definition:@"I love you so much"]]; // [self createResource:@"Dictionary2" withFile:[[NSBundle mainBundle] pathForResource:@"Dictionary" ofType:@"plist"]]; [dict setDefinition:@"This is the dictionary list"]; [cache setDefinition:@"cache all browsed object"]; [bookmark setDefinition:@"Bookmarks of-course"]; [blank addWord:[Word wordWithString:@"wow" definition:@"I love you"]]; [blank addWord:[Word wordWithString:@"free" definition:@"I love you so much"]]; [self addWord:[Word wordWithString:@"free" definition:@"I love you so much"]]; { id container = [[WordContainer alloc] initWithName:@"subfolder"]; [container addWord:[Word wordWithString:@"confree" definition:@"I love you so much"]]; [container addWord:[Word wordWithString:@"confree2" definition:@"I love you so much"]]; [container addWord:[Word wordWithString:@"confree3" definition:@"I love you so much"]]; [blank addWord:container]; } return self; } - (void) bookmark:(NSString *)word { // [bookmark setObject:[self getValueOfWord:word] forKey:word]; } - (void) release { NSLog(@"Duncan got release"); return [super release]; } @end