home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / OPENSTEP / Networking / msend-3.3-I / MSController.m < prev    next >
Encoding:
Text File  |  1997-10-28  |  3.2 KB  |  123 lines

  1. /*
  2.   $Id: MSController.m,v 3.3 1997/10/28 13:32:44 lukeh Exp $
  3.  
  4.   Copyright (c) 1996, 1997 Luke Howard.
  5.   All rights reserved.
  6.  
  7.   Redistribution and use in source and binary forms, with or without
  8.   modification, are permitted provided that the following conditions
  9.   are met:
  10.   1. Redistributions of source code must retain the above copyright
  11.      notice, this list of conditions and the following disclaimer.
  12.   2. Redistributions in binary form must reproduce the above copyright
  13.      notice, this list of conditions and the following disclaimer in the
  14.      documentation and/or other materials provided with the distribution.
  15.   3. All advertising materials mentioning features or use of this software
  16.      must display the following acknowledgement:
  17.          This product includes software developed by Luke Howard.
  18.   4. The name of the other may not be used to endorse or promote products
  19.      derived from this software without specific prior written permission.
  20.  
  21.   THIS SOFTWARE IS PROVIDED BY LUKE HOWARD ``AS IS'' AND
  22.   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.   ARE DISCLAIMED.  IN NO EVENT SHALL LUKE HOWARD BE LIABLE
  25.   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.   SUCH DAMAGE.
  32.  */
  33.  
  34. #import <Foundation/Foundation.h>
  35. #import <AppKit/AppKit.h>
  36. #import <AppKit/NSNibLoading.h>
  37. #import "MSController.h"
  38. #import "version.h"
  39.  
  40. @implementation MSController
  41.  
  42. - (void)awakeFromNib
  43. {
  44.     messageFont = [NSFont fontWithName:@"Olhfs" size:10.0];
  45.     if (messageFont)
  46.         [messagePad setFont:messageFont];
  47.  
  48.     theMessage = [MSMessage message];
  49.     [MSMessage setLogDelegate:self];
  50. }
  51.  
  52. - init
  53. {
  54.     [super init];
  55.     return self;
  56. }
  57.  
  58. - (void)dealloc
  59. {
  60.     [theMessage release];
  61.     [super dealloc];
  62. }
  63.  
  64. - (void)showInfoPanel:sender
  65. {
  66.     if (!infoPanel) {
  67.         [NSBundle loadNibNamed:@"Info.nib" owner:self];
  68.         [versionString setStringValue:[NSString stringWithFormat:@"Version %s", VERS_NUM]];
  69.     }
  70.     [infoPanel makeKeyAndOrderFront:self];
  71. }
  72.  
  73. - (void)broadcastMessage:sender
  74. {
  75.     broadcasting = YES;
  76.     [self sendMessage:sender];
  77.     broadcasting = NO;
  78. }
  79.  
  80. - (void)sendMessage:sender
  81. {
  82.     NSString *recipient;
  83.     
  84.         recipient = [recipientField stringValue];
  85.  
  86.     if (![recipient cStringLength]) {
  87.         [self log:@"You haven't typed a message!"];
  88.         return;
  89.     }
  90.     
  91.     if (![recipient cStringLength]) {
  92.         [self log:@"You haven't specified a recipient"];
  93.         return;
  94.     }
  95.     
  96.     [theMessage setBroadcasting:broadcasting];
  97.  
  98.     [theMessage setRecipient:recipient];
  99.         [theMessage setMessage:[messagePad string]];
  100.  
  101.         if (![theMessage ready]) {
  102.         [self log:@"Message not ready"];
  103.         } else {
  104.         [theMessage post];
  105.         }
  106. }
  107.  
  108. - (void)clearRecipientField:sender
  109. {
  110.     [recipientField setString:@""];
  111. }
  112.  
  113. - (void)clearMessagePad:sender
  114. {
  115.     [messagePad setString:@""];
  116. }
  117.  
  118. - (void)log:(NSString *)msg
  119. {
  120.     NSRunAlertPanel(@"Message Send", msg, @"OK", nil, nil);
  121. }
  122. @end
  123.