#import "Controller.h"
#import <shared.h>

@implementation Controller

/*=========================================================================
 * NAME        : appDidInit:
 * DESCRIPTION : Delegate message of Application.
 *=========================================================================*/
- appDidInit:sender
{
    // Move the application icon off screen
    [[NXApp appIcon] moveTo:-1000.0 :-1000.0];
    
    // Don't become the key application
    [NXApp deactivateSelf];

    return self;
}

/*=========================================================================
 * NAME        : broadcast:from:
 * DESCRIPTION : Delegate message from Listener.  This is a request to
 *		 pop up a panel with a message.
 *=========================================================================*/
- (int) broadcast:(char *)msg from:(char *)user
{
    //id thePanel = nil;
    char title[128];
    
    // Get rid of previous panel
    //if (thePanel) {
    //    [thePanel orderOut:self];
	//[thePanel free];
	//thePanel = nil;
   // }
    
    // Build title
    if (user && strlen(user))
        sprintf(title, "Alert from %s", user);
    else
        strcpy(title, "Alert");
	
    // Show panel
    if (msg && strlen(msg)) {
        NXRunAlertPanel(title, msg, "OK", NULL, NULL);
        //thePanel = NXGetAlertPanel(title, msg, NULL, NULL, NULL);
	//[thePanel orderFront:self];
    }
    return 0;
}

@end
