Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import <Foundation/Foundation.h>
- #import <UIKit/UIKit.h>
- #import "BBWeeAppController-Protocol.h"
- #include <ifaddrs.h>
- #include <arpa/inet.h>
- float VIEW_HEIGHT = 90.0f;
- @interface WiCentreController : NSObject <BBWeeAppController>
- {
- UIView *_view;
- }
- @end
- @implementation WiCentreController
- static inline NSString *GetIPAddress()
- {
- NSString *result = nil;
- struct ifaddrs *interfaces;
- char str[INET_ADDRSTRLEN];
- if (getifaddrs(&interfaces))
- return nil;
- struct ifaddrs *test_addr = interfaces;
- while (test_addr) {
- if(test_addr->ifa_addr->sa_family == AF_INET) {
- if (strcmp(test_addr->ifa_name, "en0") == 0) {
- inet_ntop(AF_INET, &((struct sockaddr_in *)test_addr->ifa_addr)->sin_addr, str, INET_ADDRSTRLEN);
- result = [NSString stringWithUTF8String:str];
- break;
- }
- }
- test_addr = test_addr->ifa_next;
- }
- freeifaddrs(interfaces);
- return result;
- }
- -(id)displayName
- {
- NSString *zString = nil;
- if ([[%c(SBWiFiManager) sharedInstance] wiFiEnabled]) {
- switch (_currentMode)
- case 0:
- zString = [NSString stringWithFormat:@"| %@", [[%c(SBWiFiManager) sharedInstance] currentNetworkName] ? : @"None"];
- break;
- case 1:
- zString = [NSString stringWithFormat:@"| %@", GetIPAddress()];
- break;
- case 2:
- zString = [NSString stringWithFormat:@"| %i", [[%c(SBWiFiManager) sharedInstance] signalStrengthBars]];
- break;
- default:
- zString = @"ERR";
- break;
- } else {
- zString = @"O";
- }
- return zString;
- }
- - (id)init
- {
- if ((self = [super init]))
- {
- }
- return self;
- }
- - (UIView *)view
- {
- if (!_view)
- {
- _view = [[UIView alloc] initWithFrame:CGRectMake(2.0f, 0.0f, 316.0f, VIEW_HEIGHT)];
- UIImage *bgImg = [[UIImage imageWithContentsOfFile:@"/System/Library/WeeAppPlugins/StocksWeeApp.bundle/WeeAppBackground.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(35.0f, 4.0f, 35.0f, 4.0f)];
- UIImageView *bg = [[UIImageView alloc] initWithImage:bgImg];
- bg.frame = CGRectMake(0.0f, 0.0f, 316.0f, VIEW_HEIGHT);
- [_view addSubview:bg];
- [bg release];
- UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 316, 90)];
- lbl.backgroundColor = [UIColor clearColor];
- lbl.textColor = [UIColor whiteColor];
- lbl.textAlignment = UITextAlignmentCenter;
- lbl.text = [NSString zString];
- [_view addSubview:lbl];
- [lbl release];
- }
- return _view;
- }
- - (float)viewHeight
- {
- return VIEW_HEIGHT;
- }
- @end
Add Comment
Please, Sign In to add comment