Dark Mode & Stream Overlay [macOS] (#315)

* dark mode & stream overlay

* removed all redundant imports

* update for the new xcode version with fixes for the new 'implicitly retains self warning'

* reworked the overlay view

* cleaning up unused variables

* small corrections
This commit is contained in:
Felix Kratz
2018-04-22 06:44:22 +02:00
committed by Cameron Gutman
parent 74283a6763
commit f759f719e6
50 changed files with 358 additions and 146 deletions

View File

@@ -0,0 +1,15 @@
//
// NetworkTraffic.h
// Moonlight macOS
//
// Created by Felix Kratz on 28.03.18.
// Copyright © 2018 Felix Kratz. All rights reserved.
//
#ifndef NetworkTraffic_h
#define NetworkTraffic_h
unsigned long getBytesDown(void);
unsigned long getBytesUp(void);
#endif /* NetworkTraffic_h */

View File

@@ -0,0 +1,50 @@
//
// NetworkTraffic.m
// Moonlight macOS
//
// Created by Felix Kratz on 28.03.18.
// Copyright © 2018 Felix Kratz. All rights reserved.
//
#import "NetworkTraffic.h"
#include <ifaddrs.h>
#include <net/if.h>
struct ifaddrs *ifap, *ifa;
unsigned long da;
unsigned long getBytesDown() {
da = 0;
getifaddrs (&ifap);
ifa = ifap;
while (ifa != NULL) {
if (ifa->ifa_addr->sa_family == AF_LINK) {
const struct if_data *ifa_data = (struct if_data *)ifa->ifa_data;
if (ifa_data != NULL) {
da += ifa_data->ifi_ibytes;
}
}
ifa = ifa->ifa_next;
}
freeifaddrs(ifap);
return da;
}
unsigned long getBytesUp() {
da = 0;
getifaddrs (&ifap);
ifa = ifap;
while (ifa != NULL) {
if (ifa->ifa_addr->sa_family == AF_LINK) {
const struct if_data *ifa_data = (struct if_data *)ifa->ifa_data;
if (ifa_data != NULL) {
da += ifa_data->ifi_obytes;
}
}
ifa = ifa->ifa_next;
}
freeifaddrs(ifap);
return da;
}