#import "MasterController.h"
#import "MailController.h"
#import "ModuleMgr.h"
#import "FileShelfView.h"
#import "InfoController.h"
#import "Directory.h"
#import "FileName.h"
#import "Defaults.h"
#import "MailSend.h"

NXDefaultsVector defaultDefaults = 
{
{ "DefaultSendType","PlainText" },
{ "DefaultEnclosureType", "NeXTMail" },
{ "ReplyTo", "" },
{ "AutoSig", "NO" },   
{ "SigFile", "" }
};

@implementation MasterController

- init
{
   [super init];

   defaults = [Defaults new];
   [defaults regDefaults: defaultDefaults];
   composePanels = [[List alloc] init];
   sendBundles = [[ModuleMgr alloc] initForPaths: (char*)0 fileType: "sndO"];
   [sendBundles setFeatures: @protocol(MailSend)];
   return self;
}

- newCompose:sender
{
   id aLetter = [[MailController alloc] init];
   
   [aLetter makeKeyAndOrderFront: self];
   [composePanels addObject: aLetter];

   return aLetter;
}

- appDidInit: sender
{
   [[NXApp appListener] setServicesDelegate: self];
   return [self newCompose: sender];
}

- sendBundles
{
   return sendBundles;
}

- defaults
{
   return defaults;
}

- mailIt: (id)pasteboard userData:(const char *)userData error:(char **)msg
{
   id letter;
   char *filename;
   int length;
    
   [pasteboard types];			     /* pretend to check the pasteboard types */
    
   /* read the ASCII data from the pasteboard */

   if ([pasteboard readType:NXFilenamePboardType data:&filename length:&length])
   {
      letter = [self newCompose: self];
      [letter selectTypeByName: [defaults get: "DefaultEnclosureType"]];
      [[letter shelf] addFile: filename ];
   }
   
   return self;
}

@end
