Apply style guide rules to the remaining classes

This commit is contained in:
Sergey Abramchuk
2018-01-23 17:04:32 +03:00
parent c682c2a325
commit badd6d28be
17 changed files with 43 additions and 40 deletions

View File

@@ -6,10 +6,10 @@
//
//
#import <client/ovpncli.hpp>
#import "OpenVPNConnectionInfo.h"
#include <client/ovpncli.hpp>
using namespace openvpn;
@interface OpenVPNConnectionInfo (Internal)

View File

@@ -28,7 +28,7 @@ using namespace openvpn;
@implementation OpenVPNConnectionInfo
- (instancetype)initWithConnectionInfo:(ClientAPI::ConnectionInfo)info {
if ((self = [super init])) {
if (self = [super init]) {
self.user = !info.user.empty() ? [NSString stringWithUTF8String:info.user.c_str()] : nil;
self.serverHost = !info.serverHost.empty() ? [NSString stringWithUTF8String:info.serverHost.c_str()] : nil;
self.serverPort = !info.serverPort.empty() ? [NSString stringWithUTF8String:info.serverPort.c_str()] : nil;
@@ -75,7 +75,7 @@ using namespace openvpn;
}
- (nullable instancetype)initWithCoder:(nonnull NSCoder *)aDecoder {
if ((self = [self init])) {
if (self = [self init]) {
self.user = [aDecoder decodeObjectOfClass:[NSString class] forKey:NSStringFromSelector(@selector(user))];
self.serverHost = [aDecoder decodeObjectOfClass:[NSString class] forKey:NSStringFromSelector(@selector(serverHost))];
self.serverPort = [aDecoder decodeObjectOfClass:[NSString class] forKey:NSStringFromSelector(@selector(serverPort))];

View File

@@ -5,11 +5,10 @@
// Created by Sergey Abramchuk on 24.04.17.
//
//
#import <client/ovpncli.hpp>
#import "OpenVPNCredentials.h"
#include <client/ovpncli.hpp>
using namespace openvpn;
@interface OpenVPNCredentials (Internal)

View File

@@ -52,7 +52,8 @@ using namespace openvpn;
}
- (NSString *)dynamicChallengeCookie {
return !_credentials.dynamicChallengeCookie.empty() ? [NSString stringWithUTF8String:_credentials.dynamicChallengeCookie.c_str()] : nil;
return !_credentials.dynamicChallengeCookie.empty() ?
[NSString stringWithUTF8String:_credentials.dynamicChallengeCookie.c_str()] : nil;
}
- (void)setDynamicChallengeCookie:(NSString *)dynamicChallengeCookie {

View File

@@ -6,10 +6,10 @@
//
//
#import <client/ovpncli.hpp>
#import "OpenVPNInterfaceStats.h"
#include <client/ovpncli.hpp>
using namespace openvpn;
@interface OpenVPNInterfaceStats (Internal)

View File

@@ -21,7 +21,7 @@
@implementation OpenVPNInterfaceStats
- (instancetype)initWithInterfaceStats:(ClientAPI::InterfaceStats)stats {
if ((self = [super init])) {
if (self = [super init]) {
self.bytesIn = stats.bytesIn;
self.bytesOut = stats.bytesOut;
self.packetsIn = stats.packetsIn;
@@ -53,7 +53,7 @@
}
- (nullable instancetype)initWithCoder:(nonnull NSCoder *)aDecoder {
if ((self = [self init])) {
if (self = [self init]) {
self.bytesIn = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(bytesIn))];
self.bytesOut = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(bytesOut))];
self.packetsIn = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(packetsIn))];

View File

@@ -21,7 +21,7 @@
@implementation OpenVPNPacket
- (instancetype)initWithVPNData:(NSData *)data {
if ((self = [super init])) {
if (self = [super init]) {
#if TARGET_OS_IPHONE
// Get network protocol family from data prefix
NSUInteger prefix_size = sizeof(uint32_t);
@@ -59,7 +59,7 @@
}
- (instancetype)initWithPacketFlowData:(NSData *)data protocolFamily:(NSNumber *)protocolFamily {
if ((self = [super init])) {
if (self = [super init]) {
_data = data;
_protocolFamily = protocolFamily;
}

View File

@@ -6,10 +6,10 @@
//
//
#import <client/ovpncli.hpp>
#import "OpenVPNProperties.h"
#include <client/ovpncli.hpp>
using namespace openvpn;
@interface OpenVPNProperties (Internal)

View File

@@ -8,8 +8,7 @@
#import <Foundation/Foundation.h>
#import "OpenVPNTransportProtocol.h"
typedef NS_ENUM(NSInteger, OpenVPNTransportProtocol);
@class OpenVPNServerEntry;
@interface OpenVPNProperties : NSObject
@@ -47,7 +46,7 @@
/**
YES if this profile requires a private key password
*/
@property (readonly, nonatomic) BOOL privateKeyPasswordRequired;
@property (readonly, nonatomic, getter=isPrivateKeyPasswordRequired) BOOL privateKeyPasswordRequired;
/**
YES if user is allowed to save authentication password in UI
@@ -74,6 +73,6 @@
*/
@property (nullable, readonly, nonatomic) NSArray<OpenVPNServerEntry *> *servers;
- (nonnull instancetype) __unavailable init;
- (nonnull instancetype) init NS_UNAVAILABLE;
@end

View File

@@ -6,20 +6,20 @@
//
//
#import <openvpn/common/number.hpp>
#import "OpenVPNProperties.h"
#import "OpenVPNProperties+Internal.h"
#include <openvpn/common/number.hpp>
#import "OpenVPNConfiguration+Internal.h"
#import "OpenVPNServerEntry+Internal.h"
#import "OpenVPNProperties.h"
#import "OpenVPNProperties+Internal.h"
using namespace openvpn;
@implementation OpenVPNProperties
- (instancetype)initWithEvalConfig:(ClientAPI::EvalConfig)eval {
self = [super init];
if (self) {
if (self = [super init]) {
_username = !eval.userlockedUsername.empty() ? [NSString stringWithUTF8String:eval.userlockedUsername.c_str()] : nil;
_profileName = !eval.profileName.empty() ? [NSString stringWithUTF8String:eval.profileName.c_str()] : nil;
@@ -44,6 +44,7 @@ using namespace openvpn;
_remoteProto = [OpenVPNConfiguration getTransportProtocolFromValue:currentProto];
_servers = nil;
if (!eval.serverList.empty()) {
NSMutableArray *servers = [NSMutableArray new];

View File

@@ -6,10 +6,10 @@
//
//
#import <client/ovpncli.hpp>
#import "OpenVPNServerEntry.h"
#include <client/ovpncli.hpp>
using namespace openvpn;
@interface OpenVPNServerEntry (Internal)

View File

@@ -13,6 +13,6 @@
@property (nullable, readonly, nonatomic) NSString *server;
@property (nullable, readonly, nonatomic) NSString *friendlyName;
- (nonnull instancetype) __unavailable init;
- (nonnull instancetype) init NS_UNAVAILABLE;
@end

View File

@@ -12,8 +12,7 @@
@implementation OpenVPNServerEntry
- (instancetype)initWithServerEntry:(ClientAPI::ServerEntry)entry {
self = [super init];
if (self) {
if (self = [super init]) {
_server = !entry.server.empty() ? [NSString stringWithUTF8String:entry.server.c_str()] : nil;
_friendlyName = !entry.friendlyName.empty() ? [NSString stringWithUTF8String:entry.friendlyName.c_str()] : nil;
}

View File

@@ -6,10 +6,10 @@
//
//
#import <client/ovpncli.hpp>
#import "OpenVPNSessionToken.h"
#include <client/ovpncli.hpp>
using namespace openvpn;
@interface OpenVPNSessionToken (Internal)

View File

@@ -6,6 +6,7 @@
//
//
#import "OpenVPNSessionToken.h"
#import "OpenVPNSessionToken+Internal.h"
using namespace openvpn;
@@ -18,7 +19,7 @@ using namespace openvpn;
@implementation OpenVPNSessionToken
- (instancetype)initWithSessionToken:(ClientAPI::SessionToken)token {
if ((self = [super init])) {
if (self = [super init]) {
self.username = !token.username.empty() ? [NSString stringWithUTF8String:token.username.c_str()] : nil;
self.session = !token.session_id.empty() ? [NSString stringWithUTF8String:token.session_id.c_str()] : nil;
}
@@ -38,7 +39,7 @@ using namespace openvpn;
}
- (nullable instancetype)initWithCoder:(nonnull NSCoder *)aDecoder {
if ((self = [self init])) {
if (self = [self init]) {
self.username = [aDecoder decodeObjectOfClass:[NSString class] forKey:NSStringFromSelector(@selector(username))];
self.session = [aDecoder decodeObjectOfClass:[NSString class] forKey:NSStringFromSelector(@selector(session))];
}

View File

@@ -6,10 +6,10 @@
//
//
#import <client/ovpncli.hpp>
#import "OpenVPNTransportStats.h"
#include <client/ovpncli.hpp>
using namespace openvpn;
@interface OpenVPNTransportStats (Internal)

View File

@@ -6,6 +6,7 @@
//
//
#import "OpenVPNTransportStats.h"
#import "OpenVPNTransportStats+Internal.h"
using namespace openvpn;
@@ -21,12 +22,13 @@ using namespace openvpn;
@implementation OpenVPNTransportStats
- (instancetype)initWithTransportStats:(ClientAPI::TransportStats)stats {
if ((self = [self init])) {
if (self = [self init]) {
self.bytesIn = stats.bytesIn;
self.bytesOut = stats.bytesOut;
self.packetsIn = stats.packetsIn;
self.packetsOut = stats.packetsOut;
self.lastPacketReceived = stats.lastPacketReceived >= 0 ? [NSDate dateWithTimeIntervalSinceNow:stats.lastPacketReceived / -1024.0] : nil;
self.lastPacketReceived = stats.lastPacketReceived >= 0 ?
[NSDate dateWithTimeIntervalSinceNow:stats.lastPacketReceived / -1024.0] : nil;
}
return self;
}
@@ -50,12 +52,13 @@ using namespace openvpn;
}
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
if ((self = [super init])) {
if (self = [super init]) {
self.bytesIn = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(bytesIn))];
self.bytesOut = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(bytesOut))];
self.packetsIn = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(packetsIn))];
self.packetsOut = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(packetsOut))];
self.lastPacketReceived = [aDecoder decodeObjectOfClass:[NSDate class] forKey:NSStringFromSelector(@selector(lastPacketReceived))];
self.lastPacketReceived = [aDecoder decodeObjectOfClass:[NSDate class]
forKey:NSStringFromSelector(@selector(lastPacketReceived))];
}
return self;
}