mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-17 19:29:24 +00:00
download plugin archive works
This commit is contained in:
@@ -47,8 +47,9 @@ typedef NS_ENUM(NSUInteger, MPPluginTableColumn) {
|
|||||||
|
|
||||||
- (void)executePluginAction:(id)sender {
|
- (void)executePluginAction:(id)sender {
|
||||||
NSInteger tableRow = [self.itemTable rowForView:sender];
|
NSInteger tableRow = [self.itemTable rowForView:sender];
|
||||||
if(tableRow < -1 && tableRow < self.repositoryItems.count) {
|
if(tableRow > -1 && tableRow < self.repositoryItems.count) {
|
||||||
MPPluginRepositoryItem *actionItem = self.repositoryItems[tableRow];
|
MPPluginRepositoryItem *actionItem = self.repositoryItems[tableRow];
|
||||||
|
[self _downloadPluginForItem:actionItem];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,6 +59,7 @@ typedef NS_ENUM(NSUInteger, MPPluginTableColumn) {
|
|||||||
|
|
||||||
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
|
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
|
||||||
NSTableCellView *view = [tableView makeViewWithIdentifier:tableColumn.identifier owner:self];
|
NSTableCellView *view = [tableView makeViewWithIdentifier:tableColumn.identifier owner:self];
|
||||||
|
|
||||||
MPPluginRepositoryItem *item = self.repositoryItems[row];
|
MPPluginRepositoryItem *item = self.repositoryItems[row];
|
||||||
|
|
||||||
NSUInteger column = [tableView.tableColumns indexOfObjectIdenticalTo:tableColumn];
|
NSUInteger column = [tableView.tableColumns indexOfObjectIdenticalTo:tableColumn];
|
||||||
@@ -71,6 +73,7 @@ typedef NS_ENUM(NSUInteger, MPPluginTableColumn) {
|
|||||||
else if(column == MPPluginTableColumnStatus) {
|
else if(column == MPPluginTableColumnStatus) {
|
||||||
MPPluginStatusTableCellView *statusView = (MPPluginStatusTableCellView *)view;
|
MPPluginStatusTableCellView *statusView = (MPPluginStatusTableCellView *)view;
|
||||||
statusView.actionButton.title = NSLocalizedString(@"PLUGIN_BROWSER_DOWNLOAD_PLUGIN_BUTTON", "Button to download the Plugin");
|
statusView.actionButton.title = NSLocalizedString(@"PLUGIN_BROWSER_DOWNLOAD_PLUGIN_BUTTON", "Button to download the Plugin");
|
||||||
|
|
||||||
MPPlugin *plugin = [MPPluginHost.sharedHost pluginWithBundleIdentifier:item.bundleIdentifier];
|
MPPlugin *plugin = [MPPluginHost.sharedHost pluginWithBundleIdentifier:item.bundleIdentifier];
|
||||||
if(plugin) {
|
if(plugin) {
|
||||||
switch([MPPluginVersionComparator compareVersion:plugin.shortVersionString toVersion:item.currentVersion]) {
|
switch([MPPluginVersionComparator compareVersion:plugin.shortVersionString toVersion:item.currentVersion]) {
|
||||||
@@ -95,26 +98,24 @@ typedef NS_ENUM(NSUInteger, MPPluginTableColumn) {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)row {
|
|
||||||
NSLog(@"%@", NSStringFromSelector(_cmd));
|
|
||||||
return YES;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)tableViewSelectionIsChanging:(NSNotification *)notification {
|
|
||||||
NSLog(@"%@", NSStringFromSelector(_cmd));
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)tableViewSelectionDidChange:(NSNotification *)notification {
|
|
||||||
NSLog(@"%@", NSStringFromSelector(_cmd));
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)_refreshRepository {
|
- (void)_refreshRepository {
|
||||||
self.repositoryItems = MPPluginRepository.defaultRepository.availablePlugins;
|
self.repositoryItems = MPPluginRepository.defaultRepository.availablePlugins;
|
||||||
[self.itemTable reloadData];
|
[self.itemTable reloadData];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_downloadPluginAtURL:(NSURL *)url {
|
- (void)_downloadPluginForItem:(MPPluginRepositoryItem *)item {
|
||||||
NSURLSessionDownloadTask *taks = [NSURLSession.sharedSession downloadTaskWithURL:url];
|
NSURL *url = item.downloadURL;
|
||||||
|
NSURLSessionDownloadTask *task = [NSURLSession.sharedSession downloadTaskWithURL:url completionHandler:^(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
||||||
|
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response;
|
||||||
|
if(httpResponse.statusCode == 200) {
|
||||||
|
if(location) {
|
||||||
|
NSError *error;
|
||||||
|
NSURL *downloadFolderURL = [NSFileManager.defaultManager URLsForDirectory:NSDownloadsDirectory inDomains:NSUserDomainMask].firstObject;
|
||||||
|
NSURL *fileURL = [downloadFolderURL URLByAppendingPathComponent:httpResponse.suggestedFilename];
|
||||||
|
[NSFileManager.defaultManager moveItemAtURL:location toURL:fileURL error:&error];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
[task resume];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
<rect key="frame" x="1" y="0.0" width="596" height="418"/>
|
<rect key="frame" x="1" y="0.0" width="596" height="418"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="sequential" alternatingRowBackgroundColors="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" rowHeight="24" rowSizeStyle="systemDefault" headerView="uVe-04-Now" viewBased="YES" id="gDR-Fx-c0h">
|
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="sequential" alternatingRowBackgroundColors="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" rowHeight="24" rowSizeStyle="systemDefault" headerView="uVe-04-Now" viewBased="YES" id="gDR-Fx-c0h">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="599" height="395"/>
|
<rect key="frame" x="0.0" y="0.0" width="599" height="395"/>
|
||||||
<autoresizingMask key="autoresizingMask"/>
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
<size key="intercellSpacing" width="3" height="2"/>
|
<size key="intercellSpacing" width="3" height="2"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user