// // DDWRT_MonitorAppDelegate.h // DDWRT-Monitor // // Created by Matthieu Lalonde & Spike Grobstein on 11-05-27. // Copyleft 2011 Spurf CC BY-SH-NC. Some rights reserved. // #import #import #import "WRTStatusClient.h" @interface DDWRT_MonitorAppDelegate : NSObject { IBOutlet NSMenu *AppMenu; IBOutlet NSPanel *ConfigPanel; IBOutlet NSPanel *BandwidthViewer; IBOutlet WebView* BandwidthViewerWebView; IBOutlet id configFieldHostname; IBOutlet NSMatrix *configFieldProtocol; IBOutlet NSButtonCell *configFieldProtocolHTTP; IBOutlet NSButtonCell *configFieldProtocolHTTPS; IBOutlet id configFieldPort; IBOutlet id configFieldRefresh; IBOutlet id configLabelRefresh; IBOutlet id configFieldUseBytes; IBOutlet id configFieldShowIcon; IBOutlet id configLabelStatus; IBOutlet NSProgressIndicator *configStateStatus; IBOutlet id configButtonSave; // System Menu Outlets IBOutlet NSMenuItem *menuSystem; IBOutlet NSMenuItem *menuSystemUptime; IBOutlet NSMenuItem *menuSystemLoad; IBOutlet NSMenuItem *menuSystemName; IBOutlet NSMenuItem *menuSystemDomain; IBOutlet NSMenuItem *menuSystemMemory; // Wan Menu Outlets IBOutlet NSMenuItem *menuWan; IBOutlet NSMenuItem *menuWanIP; IBOutlet NSMenuItem *menuWanStatus; IBOutlet NSMenuItem *menuWanUptime; IBOutlet NSMenuItem *menuWanTrafficIn; IBOutlet NSMenuItem *menuWanTrafficOut; IBOutlet NSMenuItem *menuWanSeparator; IBOutlet NSMenuItem *menuWanDNS; IBOutlet NSMenuItem *menuWanDNSItem0; IBOutlet NSMenuItem *menuWanDNSItem1; IBOutlet NSMenuItem *menuWanDNSItem2; IBOutlet NSMenuItem *menuWanBandwidthGraph; // Clients Menu Outlets IBOutlet NSMenu *menuClients; IBOutlet NSMenuItem *menuClientsItem; IBOutlet NSMenuItem *menuClientsCount; IBOutlet NSMenuItem *menuClientsConnections; IBOutlet NSMenuItem *menuClientsSeparator; NSUserDefaults *defaults; // application prefs: NSString *hostname; NSString *protocol; uint16_t port; NSString *username; NSString *password; uint16_t refreshTime; BOOL useBytes; BOOL showMenuIcon; // end app prefs NSStatusItem *_appMenu; WRTStatusClient *wrt_update_client; WRTStatusClient *wrt_request_client; NSTimer *_updateTimer; NSDate *_lastDateThroughput; uint64_t _lastInThroughput; uint64_t _lastOutThroughput; @private uint8_t _statusDataRequestNumber; NSString *_statusStringData; } # pragma mark Application Delegates: - (void) terminate:(id)sender; - (void) initialize; - (void) deinitialize; - (void) showInitAlert; - (IBAction) showBandwidthViewer:(id)sender; # pragma mark Menu Methods: - (void) showMenubar; - (void) hideMenubar; - (void) showMenubarIcon:(BOOL)enabled; - (void) hideMenubarIcon; - (void) setMenubarText:(NSString *)menubarText; - (void) disableDynamicMenus; - (void) enableDynamicMenus; # pragma mark Configs Methods: - (void) initDefaults; - (void) readDefaults; - (void) writeDefaults; - (IBAction) showConfigPanel:(id)sender; - (IBAction) hideConfigPanel:(id)sender; - (IBAction) setConfigProtocol:(id)sender; - (IBAction) setConfigRefresh:(id)sender; - (IBAction) saveConfig:(id)sender; # pragma mark Request Handlers: - (void) cbUpdateStatus; - (void) getThroughput:(NSTimer *)timer; - (void) cbThroughput:(NSData *)data; - (void) getRouterData:(NSData *)data; # pragma mark Menu Handlers: - (IBAction) refreshMenu:(id)sender; - (void) populateMenuSystem; - (void) populateMenuWan; - (void) populateMenuClients; - (NSMenu *) createCopyMenuItem; # pragma mark Utilities: - (IBAction) copyParentMenuTitle:(id)sender; - (NSString *) stringFromSize:(uint64_t)theBytes; - (NSString *) stringFromSize:(uint64_t)theBytes withUnits:(BOOL)withUnits; - (NSString *) stringFromSpeed:(uint64_t)theBytes; @end