/*
 *	IRC.app -- IRC client program for NEXTSTEP
 *	Copyright (C)1995 Norihiro Itoh
 *
 *	このソースはIRC.appの一部です。
 *	This file is part of IRC.app.
 *
 *	本プログラムはフリー・ソフトウェアです。あなたは、Free Software 
 *	Foundationが公表したGNU一般公有使用許諾の「バージョン２」或いは
 *	それ以降の各バージョンの中からいずれかを選択し、そのバージョンが
 *	定める条項に従って本プログラムを再頒布または変更することができま
 *	す。
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation; either version 2 of the License, or
 *	(at your option) any later version.
 *
 *	本プログラムは有用とは思いますが、頒布にあたっては、市場性及び特
 *	定目的適合性についての暗黙の保証を含めて、いかなる保証も行ないま
 *	せん。詳細についてはGNU一般公有使用許諾書をお読みください。
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	あなたは、本プログラムと一緒にGNU一般公有使用許諾の写しを受け取っ
 *	ているはずです。そうでない場合は、Free Software Foundation, Inc.,
 *	675 Mass Ave, Cambridge, MA 02139, USAへ手紙を書いてください。
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *	作者のメールアドレス: nito@scorpio.bekkoame.or.jp
 *	Author's e-mail address: nito@scorpio.bekkoame.or.jp
 */	

#import "MenuSupport.h"

@implementation IRCManager (MenuSupport)

- showInfo:sender
{
    if (info == nil) {
	if (![self loadNibSection:"info.nib" owner:self]) {
	    return nil;
	}
    }
    [info makeKeyAndOrderFront:nil];
    return self;
}

- showGPL:sender
{
    int		ret;
    char	path[MAXPATHLEN+1];
    port_t	port;
    id		speaker;

    if ([[NXBundle mainBundle] getPath:path
    		forResource:"GNUGPL" ofType:"rtf"]) {
	port = NXPortFromName("Edit", NULL);
	if (port != PORT_NULL) {
	    speaker = [NXApp appSpeaker];
	    [speaker setSendPort:port];
	    [speaker openFile:path ok:&ret];
	}
    }
    return self;
}

- sendMail:sender
{
    port_t	port;
    id		speaker;

    port = NXPortFromName("MailSendDemo", NULL);
    if (port != PORT_NULL) {
	speaker = [NXApp appSpeaker];
	[speaker setSendPort:port];
	[speaker selectorRPC:"setTo:" paramTypes:"c",
		[messageTable valueForStringKey:"MAIL_ADDRESS"]];
	[speaker selectorRPC:"setSubject:" paramTypes:"c",
		[messageTable valueForStringKey:"MAIL_SUBJECT"]];
	[speaker selectorRPC:"setBody:" paramTypes:"c",
		[messageTable valueForStringKey:"MAIL_BODY"]];
    }
    return self;
}

- print:sender
{
    id		window;
    id		manager;
    
    if ((window = [NXApp keyWindow]) == nil) {
    	NXBeep();
	return nil;
    }

    manager = [window delegate];
    if ([manager respondsTo:@selector(printDialogue:)] == YES)
	[manager printDialogue:nil];
    else
    	[window printPSCode:nil];
    return self;
}

- save:sender
{
    id		manager;
    
    manager = [[NXApp keyWindow] delegate];
    if ([manager respondsTo:@selector(saveDialogue:)] == YES)
	[manager saveDialogue:nil];
    else
    	NXBeep();
    return self;
}

- close:sender
{
    id		manager;
    
    manager = [[NXApp keyWindow] delegate];
    if ([manager respondsTo:@selector(closeDialogue:)] == YES)
	[manager closeDialogue:nil];
    else
    	NXBeep();
    return self;
}

@end
