merge master
commit
8fe849a930
|
@ -0,0 +1,74 @@
|
|||
### Objective-C ###
|
||||
# Xcode
|
||||
|
||||
## Build generated
|
||||
build/
|
||||
DerivedData/
|
||||
|
||||
## Various settings
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
xcuserdata/
|
||||
|
||||
## Other
|
||||
*.moved-aside
|
||||
*.xccheckout
|
||||
*.xcscmblueprint
|
||||
|
||||
## Obj-C/Swift specific
|
||||
*.hmap
|
||||
*.ipa
|
||||
*.dSYM.zip
|
||||
*.dSYM
|
||||
|
||||
### Objective-C Patch ###
|
||||
|
||||
### OSX ###
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
|
||||
## Playgrounds
|
||||
timeline.xctimeline
|
||||
playground.xcworkspace
|
||||
|
||||
# Swift Package Manager
|
||||
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
|
||||
# Packages/
|
||||
# Package.pins
|
||||
# Package.resolved
|
||||
.build/
|
||||
|
||||
|
||||
### Xcode Patch ###
|
||||
**/xcshareddata/WorkspaceSettings.xcsettings
|
|
@ -160,6 +160,8 @@
|
|||
434707F924C30E9700E05485 /* PEPSessionTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 434707F824C30E9700E05485 /* PEPSessionTest.m */; };
|
||||
4349CD7924ADDB8800A22A13 /* PEPPassphraseCache+Reset.m in Sources */ = {isa = PBXBuildFile; fileRef = 4349CD7824ADDB8800A22A13 /* PEPPassphraseCache+Reset.m */; };
|
||||
43589EFB24A4ACFC0079BEA2 /* PEPPassphraseCacheTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 43589EFA24A4ACFC0079BEA2 /* PEPPassphraseCacheTest.m */; };
|
||||
4366177D25778F0D00AB8ECA /* PEPAutoPointer+Message.h in Headers */ = {isa = PBXBuildFile; fileRef = 4366177B25778F0D00AB8ECA /* PEPAutoPointer+Message.h */; };
|
||||
4366177E25778F0D00AB8ECA /* PEPAutoPointer+Message.m in Sources */ = {isa = PBXBuildFile; fileRef = 4366177C25778F0D00AB8ECA /* PEPAutoPointer+Message.m */; };
|
||||
43676B661C57EA1A00233933 /* B623F674_sec.asc in Resources */ = {isa = PBXBuildFile; fileRef = 43676B641C57EA1A00233933 /* B623F674_sec.asc */; };
|
||||
436E917224B714A2000296FF /* Rick Deckard (43F270EC) – Secret.asc in Resources */ = {isa = PBXBuildFile; fileRef = 436E917124B714A1000296FF /* Rick Deckard (43F270EC) – Secret.asc */; };
|
||||
436E917724B71E12000296FF /* PEPPassphraseProviderMock.m in Sources */ = {isa = PBXBuildFile; fileRef = 436E917624B71E12000296FF /* PEPPassphraseProviderMock.m */; };
|
||||
|
@ -336,6 +338,8 @@
|
|||
435C0CAB222930340025C6B5 /* PEPConstants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPConstants.m; sourceTree = "<group>"; };
|
||||
4360A9FD2227CFA300E62E5A /* NSError+PEP+Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSError+PEP+Internal.h"; sourceTree = "<group>"; };
|
||||
4360A9FE2227EBB200E62E5A /* NSNumber+PEPRating+Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSNumber+PEPRating+Internal.h"; sourceTree = "<group>"; };
|
||||
4366177B25778F0D00AB8ECA /* PEPAutoPointer+Message.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PEPAutoPointer+Message.h"; sourceTree = "<group>"; };
|
||||
4366177C25778F0D00AB8ECA /* PEPAutoPointer+Message.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "PEPAutoPointer+Message.m"; sourceTree = "<group>"; };
|
||||
43676B631C57EA1A00233933 /* 0xB623F674.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = 0xB623F674.asc; sourceTree = "<group>"; };
|
||||
43676B641C57EA1A00233933 /* B623F674_sec.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = B623F674_sec.asc; sourceTree = "<group>"; };
|
||||
436C9A3124DC48B600007A3D /* PEPPassphraseUtil.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPPassphraseUtil.h; sourceTree = "<group>"; };
|
||||
|
@ -670,6 +674,8 @@
|
|||
4349CD6E24AC73FC00A22A13 /* NSString+NormalizePassphrase.m */,
|
||||
433DFBB524A61D4B00AB373B /* PEPInternalSession+PassphraseCache.h */,
|
||||
433DFBB624A61D4B00AB373B /* PEPInternalSession+PassphraseCache.m */,
|
||||
4366177B25778F0D00AB8ECA /* PEPAutoPointer+Message.h */,
|
||||
4366177C25778F0D00AB8ECA /* PEPAutoPointer+Message.m */,
|
||||
);
|
||||
path = Extensions;
|
||||
sourceTree = "<group>";
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
case PEP_KEY_IMPORTED:
|
||||
case PEP_KEY_IMPORT_STATUS_UNKNOWN:
|
||||
case PEP_VERIFY_SIGNER_KEY_REVOKED:
|
||||
case PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH:
|
||||
return nil;
|
||||
break;
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
//
|
||||
// PEPAutoPointer+Message.h
|
||||
// PEPObjCAdapterFramework
|
||||
//
|
||||
// Created by Dirk Zimmermann on 02.12.20.
|
||||
// Copyright © 2020 p≡p. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "PEPAutoPointer.h"
|
||||
|
||||
#import "message.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface PEPAutoPointer (Message)
|
||||
|
||||
/// Specialized version that will auto-release/free the given message struct when it goes out of scope.
|
||||
+ (instancetype)autoPointerWithMessage:(message *)message;
|
||||
|
||||
/// Specialized version that will auto-release/free the given message struct when it goes out of scope.
|
||||
- (instancetype)initWithMessage:(message *)message;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// PEPAutoPointer+Message.m
|
||||
// PEPObjCAdapterFramework
|
||||
//
|
||||
// Created by Dirk Zimmermann on 02.12.20.
|
||||
// Copyright © 2020 p≡p. All rights reserved.
|
||||
//
|
||||
|
||||
#import "PEPAutoPointer+Message.h"
|
||||
|
||||
@implementation PEPAutoPointer (Message)
|
||||
|
||||
+ (instancetype)autoPointerWithMessage:(message *)message
|
||||
{
|
||||
return [[self alloc] initWithMessage:message];
|
||||
}
|
||||
|
||||
- (instancetype)initWithMessage:(message *)message
|
||||
{
|
||||
return [self initWithPointer:message freeFn:(void (*)(void *)) free_message];
|
||||
}
|
||||
|
||||
@end
|
|
@ -8,34 +8,35 @@
|
|||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/**
|
||||
Implements a very basic method to enable use of ARC (or manual cocoa memory management)
|
||||
for malloc-created pointers.
|
||||
|
||||
When this object goes out of scope (is freed), it calls free() on the contained pointer.
|
||||
*/
|
||||
/// Implements a basic method to enable automated reference counting (ARC)
|
||||
/// for pointers that are not aware of it, e.g. allocated by malloc.
|
||||
///
|
||||
/// When this object goes out of scope (is released), it calls `free()` or a configurable function on the managed pointer.
|
||||
@interface PEPAutoPointer : NSObject
|
||||
|
||||
/**
|
||||
Provide this to a C-function that expects a `void **` pointer to allocate and fill.
|
||||
*/
|
||||
/// The function that will be used to free the managed pointer, `free` by default.
|
||||
@property (nonatomic) void (* freeFn)(void *);
|
||||
|
||||
/// Construct an object containing a pointer, and invoke the freeing function when the object,
|
||||
/// and therefore the pointer, goes out of scope.
|
||||
/// @param pointer The pointer to free when going out of scope.
|
||||
/// @param freeFn The function to use for freeing the pointer.
|
||||
- (instancetype)initWithPointer:(void *)pointer freeFn:(void (*)(void *))freeFn;
|
||||
|
||||
/// Constructs an object containing nil as a pointer, and using `free()` as the method to free it.
|
||||
/// In order to be useful, the pointer needs to be filled after that. See `voidPointerPointer` or `charPointerPointer`.
|
||||
- (instancetype)init;
|
||||
|
||||
/// Provide this to a function that expects a `void **` pointer to allocate and fill.
|
||||
- (void **)voidPointerPointer;
|
||||
|
||||
/**
|
||||
Provide this to a C-function that expects a `char **` pointer to allocate and fill.
|
||||
*/
|
||||
/// Provide this to a function that expects a `char **` pointer to allocate and fill.
|
||||
- (char **)charPointerPointer;
|
||||
|
||||
/**
|
||||
When you have used some C-function to receive content,
|
||||
use this to access it as a `void *` pointer.
|
||||
*/
|
||||
/// Access the managed pointer as a void pointer.
|
||||
- (void *)voidPointer;
|
||||
|
||||
/**
|
||||
When you have used some C-function to receive content,
|
||||
use this to access it as a `char *` pointer.
|
||||
*/
|
||||
/// Access the managed pointer as a char pointer.
|
||||
- (char *)charPointer;
|
||||
|
||||
@end
|
||||
|
|
|
@ -16,6 +16,21 @@
|
|||
|
||||
@implementation PEPAutoPointer
|
||||
|
||||
- (instancetype)initWithPointer:(void *)pointer freeFn:(void (*)(void *))freeFn
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_thePointer = pointer;
|
||||
_freeFn = freeFn;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
return [self initWithPointer:nil freeFn:free];
|
||||
}
|
||||
|
||||
- (void **)voidPointerPointer
|
||||
{
|
||||
return &_thePointer;
|
||||
|
@ -38,7 +53,9 @@
|
|||
|
||||
- (void)dealloc
|
||||
{
|
||||
free(_thePointer);
|
||||
if (_thePointer) {
|
||||
self.freeFn(_thePointer);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#import "Logger.h"
|
||||
#import "PEPIdentity+Engine.h"
|
||||
#import "PEPMessage+Engine.h"
|
||||
#import "PEPAutoPointer+Message.h"
|
||||
|
||||
// MARK: - Internals
|
||||
|
||||
|
@ -274,6 +275,9 @@ static __weak PEPSync *s_pEpSync;
|
|||
|
||||
- (PEP_STATUS)messageToSend:(struct _message * _Nullable)msg
|
||||
{
|
||||
// auto destruct
|
||||
PEPAutoPointer *msgPtr = [PEPAutoPointer autoPointerWithMessage:msg];
|
||||
|
||||
[self blockUntilPassphraseIsEnteredIfRequired];
|
||||
if (self.shutdownRequested) {
|
||||
// The client has signalled that she was unable to provide a passphrase by calling
|
||||
|
@ -325,6 +329,8 @@ static __weak PEPSync *s_pEpSync;
|
|||
} else {
|
||||
return PEP_SYNC_ILLEGAL_MESSAGE;
|
||||
}
|
||||
|
||||
msgPtr = nil; // please the compiler
|
||||
}
|
||||
|
||||
/// Injects the given event into the queue.
|
||||
|
|
Loading…
Reference in New Issue