mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-24 11:09:50 +00:00
Extracted MPPluginRepositoryItem into a seperate file
This commit is contained in:
@@ -28,6 +28,6 @@ NSString *const MPKdbxDocumentUTI = @"com.hicknhack.macpass.kdbx";
|
||||
NSString *const MPPluginUTI = @"com.hicknhack.macpass.plugin";
|
||||
|
||||
NSString *const MPBundleHelpURLKey = @"MPHelpURL";
|
||||
NSString *const MPBundlePluginRepositoryURLKey = @"MPPluginRepositoryURL";
|
||||
NSString *const MPBundlePluginCompaibilityURLKey = @"MPPluginCompaibilityURL";
|
||||
NSString *const MPBundlePluginRepositoryURLKey = @"MPPluginRepositoryURLKey";
|
||||
NSString *const MPBundlePluginCompadibilityURLKey = @"MPPluginCompadibilityURLKey";
|
||||
|
||||
|
||||
@@ -13,7 +13,4 @@
|
||||
|
||||
FOUNDATION_EXPORT NSString *const MPPluginFileExtension;
|
||||
|
||||
FOUNDATION_EXPORT NSString *const MPPluginMinimumHostVersionKey;
|
||||
FOUNDATION_EXPORT NSString *const MPPluginMaxiumHostVersoinKey;
|
||||
|
||||
#endif /* MPPluginConstants_h */
|
||||
|
||||
@@ -6,26 +6,14 @@
|
||||
// Copyright © 2017 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@import Foundation;
|
||||
|
||||
@interface MPPluginRespositoryItem : NSObject
|
||||
|
||||
@property (copy) NSString *name;
|
||||
@property (copy) NSString *version;
|
||||
@property (copy) NSString *descriptionText;
|
||||
@property (copy) NSURL *sourceURL;
|
||||
@property (copy) NSURL *downloadURL;
|
||||
@property (readonly, nonatomic, getter=isVaid) BOOL valid;
|
||||
|
||||
+ (instancetype)pluginItemFromDictionary:(NSDictionary *)dict;
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict;
|
||||
|
||||
@end
|
||||
@class MPPluginRepositoryItem;
|
||||
|
||||
@interface MPPluginRepository : NSObject
|
||||
|
||||
@property (nonatomic, copy) NSArray<MPPluginRespositoryItem *> *availablePlugins;
|
||||
@property (class, strong, readonly) MPPluginRepository *sharedRespoitory;
|
||||
@property (nonatomic, copy) NSArray<MPPluginRepositoryItem *> *availablePlugins;
|
||||
|
||||
+ (instancetype)sharedRespoitory;
|
||||
|
||||
@end
|
||||
|
||||
@@ -8,39 +8,7 @@
|
||||
|
||||
#import "MPPluginRepository.h"
|
||||
#import "MPConstants.h"
|
||||
|
||||
NSString *const MPPluginItemNameKey = @"name";
|
||||
NSString *const MPPluginItemDescriptionKey = @"description";
|
||||
NSString *const MPPluginItemDownloadURLKey = @"download";
|
||||
NSString *const MPPluginItemSourceURLKey = @"source";
|
||||
NSString *const MPPluginItemVersionKey = @"version";
|
||||
|
||||
@implementation MPPluginRespositoryItem
|
||||
|
||||
@dynamic valid;
|
||||
|
||||
+ (instancetype)pluginItemFromDictionary:(NSDictionary *)dict {
|
||||
return [[MPPluginRespositoryItem alloc] initWithDictionary:dict];
|
||||
}
|
||||
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict {
|
||||
self = [super init];
|
||||
if(self) {
|
||||
self.name = dict[MPPluginItemNameKey];
|
||||
self.descriptionText = dict[MPPluginItemDescriptionKey];
|
||||
self.downloadURL = [NSURL URLWithString:dict[MPPluginItemDownloadURLKey]];
|
||||
self.sourceURL = [NSURL URLWithString:dict[MPPluginItemSourceURLKey]];
|
||||
self.version = dict[MPPluginItemVersionKey];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)isVaid {
|
||||
/* name and download seems ok */
|
||||
return (self.name.length > 0 && self.downloadURL);
|
||||
}
|
||||
|
||||
@end
|
||||
#import "MPPluginRepositoryItem.h"
|
||||
|
||||
@implementation MPPluginRepository
|
||||
|
||||
@@ -60,7 +28,7 @@ NSString *const MPPluginItemVersionKey = @"version";
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSArray<MPPluginRespositoryItem *> *)availablePlugins {
|
||||
- (NSArray<MPPluginRepositoryItem *> *)availablePlugins {
|
||||
NSString *urlString = NSBundle.mainBundle.infoDictionary[MPBundlePluginRepositoryURLKey];
|
||||
if(!urlString) {
|
||||
return @[];
|
||||
@@ -83,7 +51,7 @@ NSString *const MPPluginItemVersionKey = @"version";
|
||||
if(![item isKindOfClass:NSDictionary.class]) {
|
||||
continue;
|
||||
}
|
||||
MPPluginRespositoryItem *pluginItem = [MPPluginRespositoryItem pluginItemFromDictionary:item];
|
||||
MPPluginRepositoryItem *pluginItem = [MPPluginRepositoryItem pluginItemFromDictionary:item];
|
||||
if(pluginItem.isVaid) {
|
||||
[items addObject:pluginItem];
|
||||
}
|
||||
|
||||
25
MacPass/MPPluginRepositoryItem.h
Normal file
25
MacPass/MPPluginRepositoryItem.h
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// MPPluginRepositoryItem.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 08.03.18.
|
||||
// Copyright © 2018 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface MPPluginRepositoryItem : NSObject
|
||||
|
||||
@property (copy,readonly) NSString *name;
|
||||
@property (copy,readonly) NSString *currentVersion;
|
||||
@property (copy,readonly) NSString *descriptionText;
|
||||
@property (copy,readonly) NSURL *sourceURL;
|
||||
@property (copy,readonly) NSURL *downloadURL;
|
||||
@property (copy,readonly) NSURL *bundleIdentifier;
|
||||
|
||||
@property (readonly, nonatomic, getter=isVaid) BOOL valid;
|
||||
|
||||
+ (instancetype)pluginItemFromDictionary:(NSDictionary *)dict;
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict;
|
||||
|
||||
@end
|
||||
54
MacPass/MPPluginRepositoryItem.m
Normal file
54
MacPass/MPPluginRepositoryItem.m
Normal file
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// MPPluginRepositoryItem.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 08.03.18.
|
||||
// Copyright © 2018 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPPluginRepositoryItem.h"
|
||||
|
||||
|
||||
NSString *const MPPluginItemNameKey = @"name";
|
||||
NSString *const MPPluginItemDescriptionKey = @"description";
|
||||
NSString *const MPPluginItemDownloadURLKey = @"download";
|
||||
NSString *const MPPluginItemSourceURLKey = @"source";
|
||||
NSString *const MPPluginItemCurrentVersionKey = @"currentVersion";
|
||||
|
||||
@interface MPPluginRepositoryItem ()
|
||||
|
||||
@property (copy) NSString *name;
|
||||
@property (copy) NSString *currentVersion;
|
||||
@property (copy) NSString *descriptionText;
|
||||
@property (copy) NSURL *sourceURL;
|
||||
@property (copy) NSURL *downloadURL;
|
||||
@property (copy) NSURL *bundleIdentifier;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MPPluginRepositoryItem
|
||||
|
||||
@dynamic valid;
|
||||
|
||||
+ (instancetype)pluginItemFromDictionary:(NSDictionary *)dict {
|
||||
return [[MPPluginRepositoryItem alloc] initWithDictionary:dict];
|
||||
}
|
||||
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict {
|
||||
self = [super init];
|
||||
if(self) {
|
||||
self.name = dict[MPPluginItemNameKey];
|
||||
self.descriptionText = dict[MPPluginItemDescriptionKey];
|
||||
self.downloadURL = [NSURL URLWithString:dict[MPPluginItemDownloadURLKey]];
|
||||
self.sourceURL = [NSURL URLWithString:dict[MPPluginItemSourceURLKey]];
|
||||
self.currentVersion = dict[MPPluginItemCurrentVersionKey];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)isVaid {
|
||||
/* name and download seems ok */
|
||||
return (self.name.length > 0 && self.downloadURL);
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user