VLCFirstStepsThirdPageViewController.m 1.92 KB
Newer Older
1
/*****************************************************************************
2
 * VLCFirstStepsThirdPageViewController
3 4
 * VLC for iOS
 *****************************************************************************
5
 * Copyright (c) 2013-2014 VideoLAN. All rights reserved.
6 7 8 9 10 11 12 13
 * $Id$
 *
 * Authors: Felix Paul Kühne <fkuehne # videolan.org>
 *
 * Refer to the COPYING file of the official project for license.
 *****************************************************************************/

#import "VLCFirstStepsThirdPageViewController.h"
14 15
#import <ifaddrs.h>
#import <arpa/inet.h>
16 17 18 19 20 21 22 23 24 25 26

@interface VLCFirstStepsThirdPageViewController ()

@end

@implementation VLCFirstStepsThirdPageViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

27 28
    self.connectDescriptionLabel.text = [NSString stringWithFormat:NSLocalizedString(@"FIRST_STEPS_WIFI_CONNECT_DETAILS", nil), [[UIDevice currentDevice] model]];
    self.uploadDescriptionLabel.text = NSLocalizedString(@"FIRST_STEPS_WIFI_UPLOAD_DETAILS", nil);
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

    NSString *address = @"192.168.1.2"; // something generic
    struct ifaddrs *interfaces = NULL;
    struct ifaddrs *temp_addr = NULL;
    int success = getifaddrs(&interfaces);

    if (success == 0) {
        temp_addr = interfaces;
        while (temp_addr != NULL) {
            if (temp_addr->ifa_addr->sa_family == AF_INET) {
                if([@(temp_addr->ifa_name) isEqualToString:WifiInterfaceName])
                    address = @(inet_ntoa(((struct sockaddr_in *)temp_addr->ifa_addr)->sin_addr));
            }
            temp_addr = temp_addr->ifa_next;
        }
    }

    freeifaddrs(interfaces);
    self.currentAddressLabel.text = [NSString stringWithFormat:@"http://%@", address];
48 49
}

50 51
- (void)viewWillAppear:(BOOL)animated
{
Marc's avatar
Marc committed
52
    [super viewWillAppear:animated];
53 54 55
    self.actualContentView.center = self.view.center;
}

56 57
- (NSString *)pageTitle
{
58
    return NSLocalizedString(@"WEBINTF_TITLE", nil);
59 60 61 62 63 64 65 66
}

- (NSUInteger)page
{
    return 3;
}

@end