rendered paste body//
// IPMenulet.m
// IPMenulet
//
// Created by Andrew Pennebaker on 13 Dec 2007.
// Copyright 2007 YelloSoft. All rights reserved.
//
#import "IPMenulet.h"
@implementation IPMenulet
-(void) dealloc {
[statusItem release];
[super dealloc];
}
-(void) awakeFromNib {
statusItem=[[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain];
[statusItem setHighlightMode:YES];
[statusItem setTitle:[NSString stringWithString:@"0.0.0.0"]];
[statusItem setEnabled:YES];
[statusItem setToolTip:@"IPMenulet"];
[statusItem setAction:@selector(update:)];
[statusItem setTarget:self];
}
-(IBAction) update: (id) sender {
NSURLRequest *request=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://highearthorbit.com/service/myip.php"]];
NSData *data=[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *ipAddress=[NSString stringWithCString:[data bytes]];
if (ipAddress != NULL) {
[statusItem setTitle:ipAddress];
}
else {
printf("Error\n");
}
}
@end