
/* Generated by Interface Builder */

#import "InfoController.h"
#import <appkit/Window.h>
#import <strings.h>
#import <libc.h>
#import <appkit/Application.h>
#import <appkit/Panel.h>
#import <appkit/TextField.h>
#import <appkit/defaults.h>	/* preferences (defaults) */
#import <appkit/Speaker.h>
#import <appkit/Listener.h>


@implementation InfoController

- init				// make sure that *Panel is nil.
{
	self = [super init];
	infoPanel = nil;
	helpPanel = nil;
	licensePanel = nil;
	READMEPanel = nil;
	return self;
}

- infoPanel		// return the infoPanel, load it if needed.
{
  if( !infoPanel)
    [NXApp loadNibSection:"InfoPanel.nib" owner:self withNames:NO];
  return infoPanel;
}

- helpPanel		// return the helpPanel, load it if needed.
{
  if( !helpPanel)
    [NXApp loadNibSection:"HelpPanel.nib" owner:self withNames:NO];
  return helpPanel;
}

- licensePanel		// return the licensePanel, load it if needed.
{
  if( !licensePanel)
    [NXApp loadNibSection:"LicensePanel.nib" owner:self withNames:NO];
  return licensePanel;
}

- readmePanel	// return the READMEPanel, load it if needed.
{
  if( !READMEPanel)
    [NXApp loadNibSection:"README.nib" owner:self withNames:NO];
  return READMEPanel;
}

- info:sender		// make the info panel be up there.
{
  [[self infoPanel] orderFront:sender];
  return self;
}

- help:sender		// make the help panel be up there.
{
	[[self helpPanel] orderFront:sender];
	return self;
}

- license:sender	// make the license panel be up there.
{
	[[self licensePanel] orderFront:sender];
	return self;
}

- readme:sender	// make the README panel be up there.
{
	[[self readmePanel] orderFront:sender];
	return self;
}

- suggestion:sender	// This is pretty much lifted from Opener.
{
	char subj[256];
	char body[4096]="\
Don:\n\n\
I've been playing PacMan a bit and find it to be\n\
simply piles of fun.  In fact, I think it would be\n\
even more fun if it:\n\n\
<insert interesting suggestions here>\n\n\
I also found that I had the following problems:\n\n\
<insert report of annoying bugs here>\n\n\
Well, thanks for the prompt reply I know you'll\n\
be sending to me...\n\n\
             I love to play games on the NeXT,\n\
             ";

#define call(a,b) [s performRemoteMethod:a with:b length:strlen(b)+1]

    id s = [NXApp appSpeaker];
	int x = 1;
	int doit = NO;
	
	const char *tmpstr = NXGetDefaultValue ([NXApp appName], "Mail");
	
	if (!tmpstr) doit = YES;
	else if (strcmp(tmpstr, "OK")) doit = YES;
	if (doit) x = NXRunAlertPanel("Warning",
		"Due to a bug in Mail.app in the 2.x software release, this action \
will clobber any letter you may be currently composing.",
		"OK", "OK Forever", "Abort");
		
	if (x == 0) NXWriteDefault ([NXApp appName], "Mail", "OK");
	if (x == -1) return self; // abort

    NXPortFromName("Mail", NULL); // make sure app is launched
    [[NXApp appSpeaker] setSendPort:NXPortFromName("MailSendDemo", NULL)];

    sprintf(subj,"Comments and suggestions for ``%s'' ",[NXApp appName]);
    strcat(subj,versionString); strcat(subj, " (");
	strcat(subj,"PD"); strcat(subj,")");
    strcat(body,NXUserName()); strcat(body,"\n");

    call("setTo:","yackd@wombat.ee.byu.edu");
    call("setSubject:",subj);
    call("setBody:",body);
    
    return self;
}

@end
