mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 22:52:26 +00:00
prototyped plugin repository browsing
This commit is contained in:
@@ -208,6 +208,7 @@
|
|||||||
4CA334CA18AD60D1008A3322 /* MPWindowAssociationsTableViewDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA334C918AD60D1008A3322 /* MPWindowAssociationsTableViewDelegate.m */; };
|
4CA334CA18AD60D1008A3322 /* MPWindowAssociationsTableViewDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA334C918AD60D1008A3322 /* MPWindowAssociationsTableViewDelegate.m */; };
|
||||||
4CA3530B18A53CB800839B0F /* MPKeyMapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA3530A18A53CB800839B0F /* MPKeyMapper.m */; };
|
4CA3530B18A53CB800839B0F /* MPKeyMapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA3530A18A53CB800839B0F /* MPKeyMapper.m */; };
|
||||||
4CA4B3461FC8833A007DF507 /* PickcharView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CA4B3451FC88339007DF507 /* PickcharView.xib */; };
|
4CA4B3461FC8833A007DF507 /* PickcharView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CA4B3451FC88339007DF507 /* PickcharView.xib */; };
|
||||||
|
4CA78C001FD58C92003C8560 /* MPPluginRepository.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA78BFF1FD58C92003C8560 /* MPPluginRepository.m */; };
|
||||||
4CAAA8271D787B8B00CDE977 /* MPAutotypeBuilderViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CAAA8251D787B8B00CDE977 /* MPAutotypeBuilderViewController.m */; };
|
4CAAA8271D787B8B00CDE977 /* MPAutotypeBuilderViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CAAA8251D787B8B00CDE977 /* MPAutotypeBuilderViewController.m */; };
|
||||||
4CAD748C15B889B700104512 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CAD748B15B889B700104512 /* Security.framework */; };
|
4CAD748C15B889B700104512 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CAD748B15B889B700104512 /* Security.framework */; };
|
||||||
4CAD748E15B88AC100104512 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CAD748D15B88AC100104512 /* libz.dylib */; };
|
4CAD748E15B88AC100104512 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CAD748D15B88AC100104512 /* libz.dylib */; };
|
||||||
@@ -706,6 +707,8 @@
|
|||||||
4CA3530918A53CB800839B0F /* MPKeyMapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPKeyMapper.h; sourceTree = "<group>"; };
|
4CA3530918A53CB800839B0F /* MPKeyMapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPKeyMapper.h; sourceTree = "<group>"; };
|
||||||
4CA3530A18A53CB800839B0F /* MPKeyMapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPKeyMapper.m; sourceTree = "<group>"; };
|
4CA3530A18A53CB800839B0F /* MPKeyMapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPKeyMapper.m; sourceTree = "<group>"; };
|
||||||
4CA4B3451FC88339007DF507 /* PickcharView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PickcharView.xib; sourceTree = "<group>"; };
|
4CA4B3451FC88339007DF507 /* PickcharView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PickcharView.xib; sourceTree = "<group>"; };
|
||||||
|
4CA78BFE1FD58C92003C8560 /* MPPluginRepository.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPPluginRepository.h; sourceTree = "<group>"; };
|
||||||
|
4CA78BFF1FD58C92003C8560 /* MPPluginRepository.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MPPluginRepository.m; sourceTree = "<group>"; };
|
||||||
4CAAA8241D787B8B00CDE977 /* MPAutotypeBuilderViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPAutotypeBuilderViewController.h; sourceTree = "<group>"; };
|
4CAAA8241D787B8B00CDE977 /* MPAutotypeBuilderViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPAutotypeBuilderViewController.h; sourceTree = "<group>"; };
|
||||||
4CAAA8251D787B8B00CDE977 /* MPAutotypeBuilderViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPAutotypeBuilderViewController.m; sourceTree = "<group>"; };
|
4CAAA8251D787B8B00CDE977 /* MPAutotypeBuilderViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPAutotypeBuilderViewController.m; sourceTree = "<group>"; };
|
||||||
4CAD748B15B889B700104512 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
|
4CAD748B15B889B700104512 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
|
||||||
@@ -1591,6 +1594,8 @@
|
|||||||
4CD034A91BFE113B003C002C /* MPPluginHost.m */,
|
4CD034A91BFE113B003C002C /* MPPluginHost.m */,
|
||||||
4C8F0C6C1FCEE98900BE157F /* MPPluginConstants.h */,
|
4C8F0C6C1FCEE98900BE157F /* MPPluginConstants.h */,
|
||||||
4C8F0C6D1FCEE9B900BE157F /* MPPluginConstants.m */,
|
4C8F0C6D1FCEE9B900BE157F /* MPPluginConstants.m */,
|
||||||
|
4CA78BFE1FD58C92003C8560 /* MPPluginRepository.h */,
|
||||||
|
4CA78BFF1FD58C92003C8560 /* MPPluginRepository.m */,
|
||||||
);
|
);
|
||||||
name = Plugin;
|
name = Plugin;
|
||||||
path = MacPass;
|
path = MacPass;
|
||||||
@@ -1933,6 +1938,7 @@
|
|||||||
4C0C59F118B17F10009C7B76 /* DDHotKeyUtilities.m in Sources */,
|
4C0C59F118B17F10009C7B76 /* DDHotKeyUtilities.m in Sources */,
|
||||||
4CEE46DD181C301D006BF1E5 /* MPAutotypeDaemon.m in Sources */,
|
4CEE46DD181C301D006BF1E5 /* MPAutotypeDaemon.m in Sources */,
|
||||||
4C50CC041F6C18830095629D /* MPCollectionViewItem.m in Sources */,
|
4C50CC041F6C18830095629D /* MPCollectionViewItem.m in Sources */,
|
||||||
|
4CA78C001FD58C92003C8560 /* MPPluginRepository.m in Sources */,
|
||||||
4C8990F71EE978EB0043B48D /* MPDuplicateEntryOptionsWindowController.m in Sources */,
|
4C8990F71EE978EB0043B48D /* MPDuplicateEntryOptionsWindowController.m in Sources */,
|
||||||
4CA3530B18A53CB800839B0F /* MPKeyMapper.m in Sources */,
|
4CA3530B18A53CB800839B0F /* MPKeyMapper.m in Sources */,
|
||||||
4CE298EB1795FC2A00DF7BDB /* MPEntryContextMenuDelegate.m in Sources */,
|
4CE298EB1795FC2A00DF7BDB /* MPEntryContextMenuDelegate.m in Sources */,
|
||||||
|
|||||||
@@ -39,4 +39,5 @@ FOUNDATION_EXPORT NSString *const MPPluginUTI;
|
|||||||
*/
|
*/
|
||||||
FOUNDATION_EXPORT NSString *const MPBundleHelpURLKey; // MPHelpURL
|
FOUNDATION_EXPORT NSString *const MPBundleHelpURLKey; // MPHelpURL
|
||||||
FOUNDATION_EXPORT NSString *const MPBundlePluginRepositoryURLKey; // MPPluginRepositoryURL
|
FOUNDATION_EXPORT NSString *const MPBundlePluginRepositoryURLKey; // MPPluginRepositoryURL
|
||||||
|
FOUNDATION_EXPORT NSString *const MPBundlePluginCompaibilityURLKey; // MPPluginCompaibilityURL
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -28,5 +28,6 @@ NSString *const MPKdbxDocumentUTI = @"com.hicknhack.macpass.kdbx";
|
|||||||
NSString *const MPPluginUTI = @"com.hicknhack.macpass.plugin";
|
NSString *const MPPluginUTI = @"com.hicknhack.macpass.plugin";
|
||||||
|
|
||||||
NSString *const MPBundleHelpURLKey = @"MPHelpURL";
|
NSString *const MPBundleHelpURLKey = @"MPHelpURL";
|
||||||
NSString *const MPBundlePluginRepositoryURLKey = @"MPPluginRepositoryURL"
|
NSString *const MPBundlePluginRepositoryURLKey = @"MPPluginRepositoryURL";
|
||||||
|
NSString *const MPBundlePluginCompaibilityURLKey = @"MPPluginCompaibilityURL";
|
||||||
|
|
||||||
|
|||||||
31
MacPass/MPPluginRepository.h
Normal file
31
MacPass/MPPluginRepository.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
//
|
||||||
|
// MPPluginRepository.h
|
||||||
|
// MacPass
|
||||||
|
//
|
||||||
|
// Created by Michael Starke on 04.12.17.
|
||||||
|
// Copyright © 2017 HicknHack Software GmbH. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
||||||
|
@interface MPPluginRepository : NSObject
|
||||||
|
|
||||||
|
@property (nonatomic, copy) NSArray<MPPluginRespositoryItem *> *availablePlugins;
|
||||||
|
|
||||||
|
+ (instancetype)sharedRespoitory;
|
||||||
|
|
||||||
|
@end
|
||||||
94
MacPass/MPPluginRepository.m
Normal file
94
MacPass/MPPluginRepository.m
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
//
|
||||||
|
// MPPluginRepository.m
|
||||||
|
// MacPass
|
||||||
|
//
|
||||||
|
// Created by Michael Starke on 04.12.17.
|
||||||
|
// Copyright © 2017 HicknHack Software GmbH. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
|
@implementation MPPluginRepository
|
||||||
|
|
||||||
|
@dynamic availablePlugins;
|
||||||
|
|
||||||
|
+ (instancetype)sharedRespoitory {
|
||||||
|
static MPPluginRepository *instance;
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
instance = [[MPPluginRepository alloc] init];
|
||||||
|
});
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)init {
|
||||||
|
self = [super init];
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray<MPPluginRespositoryItem *> *)availablePlugins {
|
||||||
|
NSString *urlString = NSBundle.mainBundle.infoDictionary[MPBundlePluginRepositoryURLKey];
|
||||||
|
if(!urlString) {
|
||||||
|
return @[];
|
||||||
|
}
|
||||||
|
NSURL *jsonURL = [NSURL URLWithString:urlString];
|
||||||
|
if(!jsonURL) {
|
||||||
|
return @[];
|
||||||
|
}
|
||||||
|
NSError *error;
|
||||||
|
NSData *jsonData = [NSData dataWithContentsOfURL:jsonURL options:0 error:&error];
|
||||||
|
if(!jsonData) {
|
||||||
|
return @[];
|
||||||
|
}
|
||||||
|
id jsonRoot = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
|
||||||
|
if(!jsonRoot || ![jsonRoot isKindOfClass:NSArray.class]) {
|
||||||
|
return @[];
|
||||||
|
}
|
||||||
|
NSMutableArray *items = [[NSMutableArray alloc] init];
|
||||||
|
for(id item in jsonRoot) {
|
||||||
|
if(![item isKindOfClass:NSDictionary.class]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
MPPluginRespositoryItem *pluginItem = [MPPluginRespositoryItem pluginItemFromDictionary:item];
|
||||||
|
if(pluginItem.isVaid) {
|
||||||
|
[items addObject:pluginItem];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [items copy];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -68,7 +68,7 @@
|
|||||||
<key>MPHelpURL</key>
|
<key>MPHelpURL</key>
|
||||||
<string>https://github.com/mstarke/MacPass</string>
|
<string>https://github.com/mstarke/MacPass</string>
|
||||||
<key>MPPluginRepositoryURL</key>
|
<key>MPPluginRepositoryURL</key>
|
||||||
<string>file:///Users/michael/Projekte/GitHub/MacPassPlugins/plugins.json</string>
|
<string>https://macpass.github.io/data/plugins.json</string>
|
||||||
<key>NSHumanReadableCopyright</key>
|
<key>NSHumanReadableCopyright</key>
|
||||||
<string>Copyright © 2012-2017 HicknHack Software GmbH. All rights reserved.</string>
|
<string>Copyright © 2012-2017 HicknHack Software GmbH. All rights reserved.</string>
|
||||||
<key>NSMainNibFile</key>
|
<key>NSMainNibFile</key>
|
||||||
|
|||||||
Reference in New Issue
Block a user