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
@@ -6,10 +6,10 @@
// //
// //
#import <client/ovpncli.hpp>
#import "OpenVPNConnectionInfo.h" #import "OpenVPNConnectionInfo.h"
#include <client/ovpncli.hpp>
using namespace openvpn; using namespace openvpn;
@interface OpenVPNConnectionInfo (Internal) @interface OpenVPNConnectionInfo (Internal)
+2 -2
View File
@@ -28,7 +28,7 @@ using namespace openvpn;
@implementation OpenVPNConnectionInfo @implementation OpenVPNConnectionInfo
- (instancetype)initWithConnectionInfo:(ClientAPI::ConnectionInfo)info { - (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.user = !info.user.empty() ? [NSString stringWithUTF8String:info.user.c_str()] : nil;
self.serverHost = !info.serverHost.empty() ? [NSString stringWithUTF8String:info.serverHost.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; 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 { - (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.user = [aDecoder decodeObjectOfClass:[NSString class] forKey:NSStringFromSelector(@selector(user))];
self.serverHost = [aDecoder decodeObjectOfClass:[NSString class] forKey:NSStringFromSelector(@selector(serverHost))]; self.serverHost = [aDecoder decodeObjectOfClass:[NSString class] forKey:NSStringFromSelector(@selector(serverHost))];
self.serverPort = [aDecoder decodeObjectOfClass:[NSString class] forKey:NSStringFromSelector(@selector(serverPort))]; self.serverPort = [aDecoder decodeObjectOfClass:[NSString class] forKey:NSStringFromSelector(@selector(serverPort))];
@@ -5,11 +5,10 @@
// Created by Sergey Abramchuk on 24.04.17. // Created by Sergey Abramchuk on 24.04.17.
// //
// //
#import <client/ovpncli.hpp>
#import "OpenVPNCredentials.h" #import "OpenVPNCredentials.h"
#include <client/ovpncli.hpp>
using namespace openvpn; using namespace openvpn;
@interface OpenVPNCredentials (Internal) @interface OpenVPNCredentials (Internal)
+2 -1
View File
@@ -52,7 +52,8 @@ using namespace openvpn;
} }
- (NSString *)dynamicChallengeCookie { - (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 { - (void)setDynamicChallengeCookie:(NSString *)dynamicChallengeCookie {
@@ -6,10 +6,10 @@
// //
// //
#import <client/ovpncli.hpp>
#import "OpenVPNInterfaceStats.h" #import "OpenVPNInterfaceStats.h"
#include <client/ovpncli.hpp>
using namespace openvpn; using namespace openvpn;
@interface OpenVPNInterfaceStats (Internal) @interface OpenVPNInterfaceStats (Internal)
+2 -2
View File
@@ -21,7 +21,7 @@
@implementation OpenVPNInterfaceStats @implementation OpenVPNInterfaceStats
- (instancetype)initWithInterfaceStats:(ClientAPI::InterfaceStats)stats { - (instancetype)initWithInterfaceStats:(ClientAPI::InterfaceStats)stats {
if ((self = [super init])) { if (self = [super init]) {
self.bytesIn = stats.bytesIn; self.bytesIn = stats.bytesIn;
self.bytesOut = stats.bytesOut; self.bytesOut = stats.bytesOut;
self.packetsIn = stats.packetsIn; self.packetsIn = stats.packetsIn;
@@ -53,7 +53,7 @@
} }
- (nullable instancetype)initWithCoder:(nonnull NSCoder *)aDecoder { - (nullable instancetype)initWithCoder:(nonnull NSCoder *)aDecoder {
if ((self = [self init])) { if (self = [self init]) {
self.bytesIn = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(bytesIn))]; self.bytesIn = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(bytesIn))];
self.bytesOut = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(bytesOut))]; self.bytesOut = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(bytesOut))];
self.packetsIn = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(packetsIn))]; self.packetsIn = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(packetsIn))];
+2 -2
View File
@@ -21,7 +21,7 @@
@implementation OpenVPNPacket @implementation OpenVPNPacket
- (instancetype)initWithVPNData:(NSData *)data { - (instancetype)initWithVPNData:(NSData *)data {
if ((self = [super init])) { if (self = [super init]) {
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE
// Get network protocol family from data prefix // Get network protocol family from data prefix
NSUInteger prefix_size = sizeof(uint32_t); NSUInteger prefix_size = sizeof(uint32_t);
@@ -59,7 +59,7 @@
} }
- (instancetype)initWithPacketFlowData:(NSData *)data protocolFamily:(NSNumber *)protocolFamily { - (instancetype)initWithPacketFlowData:(NSData *)data protocolFamily:(NSNumber *)protocolFamily {
if ((self = [super init])) { if (self = [super init]) {
_data = data; _data = data;
_protocolFamily = protocolFamily; _protocolFamily = protocolFamily;
} }
+2 -2
View File
@@ -6,10 +6,10 @@
// //
// //
#import <client/ovpncli.hpp>
#import "OpenVPNProperties.h" #import "OpenVPNProperties.h"
#include <client/ovpncli.hpp>
using namespace openvpn; using namespace openvpn;
@interface OpenVPNProperties (Internal) @interface OpenVPNProperties (Internal)
+3 -4
View File
@@ -8,8 +8,7 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "OpenVPNTransportProtocol.h" typedef NS_ENUM(NSInteger, OpenVPNTransportProtocol);
@class OpenVPNServerEntry; @class OpenVPNServerEntry;
@interface OpenVPNProperties : NSObject @interface OpenVPNProperties : NSObject
@@ -47,7 +46,7 @@
/** /**
YES if this profile requires a private key password 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 YES if user is allowed to save authentication password in UI
@@ -74,6 +73,6 @@
*/ */
@property (nullable, readonly, nonatomic) NSArray<OpenVPNServerEntry *> *servers; @property (nullable, readonly, nonatomic) NSArray<OpenVPNServerEntry *> *servers;
- (nonnull instancetype) __unavailable init; - (nonnull instancetype) init NS_UNAVAILABLE;
@end @end
+6 -5
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 "OpenVPNConfiguration+Internal.h"
#import "OpenVPNServerEntry+Internal.h" #import "OpenVPNServerEntry+Internal.h"
#import "OpenVPNProperties.h"
#import "OpenVPNProperties+Internal.h"
using namespace openvpn; using namespace openvpn;
@implementation OpenVPNProperties @implementation OpenVPNProperties
- (instancetype)initWithEvalConfig:(ClientAPI::EvalConfig)eval { - (instancetype)initWithEvalConfig:(ClientAPI::EvalConfig)eval {
self = [super init]; if (self = [super init]) {
if (self) {
_username = !eval.userlockedUsername.empty() ? [NSString stringWithUTF8String:eval.userlockedUsername.c_str()] : nil; _username = !eval.userlockedUsername.empty() ? [NSString stringWithUTF8String:eval.userlockedUsername.c_str()] : nil;
_profileName = !eval.profileName.empty() ? [NSString stringWithUTF8String:eval.profileName.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]; _remoteProto = [OpenVPNConfiguration getTransportProtocolFromValue:currentProto];
_servers = nil; _servers = nil;
if (!eval.serverList.empty()) { if (!eval.serverList.empty()) {
NSMutableArray *servers = [NSMutableArray new]; NSMutableArray *servers = [NSMutableArray new];
@@ -6,10 +6,10 @@
// //
// //
#import <client/ovpncli.hpp>
#import "OpenVPNServerEntry.h" #import "OpenVPNServerEntry.h"
#include <client/ovpncli.hpp>
using namespace openvpn; using namespace openvpn;
@interface OpenVPNServerEntry (Internal) @interface OpenVPNServerEntry (Internal)
+1 -1
View File
@@ -13,6 +13,6 @@
@property (nullable, readonly, nonatomic) NSString *server; @property (nullable, readonly, nonatomic) NSString *server;
@property (nullable, readonly, nonatomic) NSString *friendlyName; @property (nullable, readonly, nonatomic) NSString *friendlyName;
- (nonnull instancetype) __unavailable init; - (nonnull instancetype) init NS_UNAVAILABLE;
@end @end
+1 -2
View File
@@ -12,8 +12,7 @@
@implementation OpenVPNServerEntry @implementation OpenVPNServerEntry
- (instancetype)initWithServerEntry:(ClientAPI::ServerEntry)entry { - (instancetype)initWithServerEntry:(ClientAPI::ServerEntry)entry {
self = [super init]; if (self = [super init]) {
if (self) {
_server = !entry.server.empty() ? [NSString stringWithUTF8String:entry.server.c_str()] : nil; _server = !entry.server.empty() ? [NSString stringWithUTF8String:entry.server.c_str()] : nil;
_friendlyName = !entry.friendlyName.empty() ? [NSString stringWithUTF8String:entry.friendlyName.c_str()] : nil; _friendlyName = !entry.friendlyName.empty() ? [NSString stringWithUTF8String:entry.friendlyName.c_str()] : nil;
} }
@@ -6,10 +6,10 @@
// //
// //
#import <client/ovpncli.hpp>
#import "OpenVPNSessionToken.h" #import "OpenVPNSessionToken.h"
#include <client/ovpncli.hpp>
using namespace openvpn; using namespace openvpn;
@interface OpenVPNSessionToken (Internal) @interface OpenVPNSessionToken (Internal)
+3 -2
View File
@@ -6,6 +6,7 @@
// //
// //
#import "OpenVPNSessionToken.h"
#import "OpenVPNSessionToken+Internal.h" #import "OpenVPNSessionToken+Internal.h"
using namespace openvpn; using namespace openvpn;
@@ -18,7 +19,7 @@ using namespace openvpn;
@implementation OpenVPNSessionToken @implementation OpenVPNSessionToken
- (instancetype)initWithSessionToken:(ClientAPI::SessionToken)token { - (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.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; 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 { - (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.username = [aDecoder decodeObjectOfClass:[NSString class] forKey:NSStringFromSelector(@selector(username))];
self.session = [aDecoder decodeObjectOfClass:[NSString class] forKey:NSStringFromSelector(@selector(session))]; self.session = [aDecoder decodeObjectOfClass:[NSString class] forKey:NSStringFromSelector(@selector(session))];
} }
@@ -6,10 +6,10 @@
// //
// //
#import <client/ovpncli.hpp>
#import "OpenVPNTransportStats.h" #import "OpenVPNTransportStats.h"
#include <client/ovpncli.hpp>
using namespace openvpn; using namespace openvpn;
@interface OpenVPNTransportStats (Internal) @interface OpenVPNTransportStats (Internal)
+7 -4
View File
@@ -6,6 +6,7 @@
// //
// //
#import "OpenVPNTransportStats.h"
#import "OpenVPNTransportStats+Internal.h" #import "OpenVPNTransportStats+Internal.h"
using namespace openvpn; using namespace openvpn;
@@ -21,12 +22,13 @@ using namespace openvpn;
@implementation OpenVPNTransportStats @implementation OpenVPNTransportStats
- (instancetype)initWithTransportStats:(ClientAPI::TransportStats)stats { - (instancetype)initWithTransportStats:(ClientAPI::TransportStats)stats {
if ((self = [self init])) { if (self = [self init]) {
self.bytesIn = stats.bytesIn; self.bytesIn = stats.bytesIn;
self.bytesOut = stats.bytesOut; self.bytesOut = stats.bytesOut;
self.packetsIn = stats.packetsIn; self.packetsIn = stats.packetsIn;
self.packetsOut = stats.packetsOut; 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; return self;
} }
@@ -50,12 +52,13 @@ using namespace openvpn;
} }
- (instancetype)initWithCoder:(NSCoder *)aDecoder { - (instancetype)initWithCoder:(NSCoder *)aDecoder {
if ((self = [super init])) { if (self = [super init]) {
self.bytesIn = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(bytesIn))]; self.bytesIn = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(bytesIn))];
self.bytesOut = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(bytesOut))]; self.bytesOut = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(bytesOut))];
self.packetsIn = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(packetsIn))]; self.packetsIn = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(packetsIn))];
self.packetsOut = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(packetsOut))]; 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; return self;
} }