Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
heyvito committed Sep 4, 2021
0 parents commit 20cefb4
Show file tree
Hide file tree
Showing 63 changed files with 4,434 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
**/xcuserdata/*
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2021 Victor Gama

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
482 changes: 482 additions & 0 deletions Podman.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Podman.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"object": {
"pins": [
{
"package": "Sparkle",
"repositoryURL": "https://github.com/sparkle-project/Sparkle",
"state": {
"branch": null,
"revision": "c0933a516b420806e9216e71bd13ba76c54f0de6",
"version": "1.26.0"
}
}
]
},
"version": 1
}
18 changes: 18 additions & 0 deletions Podman/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// AppDelegate.h
// Podman macOS
//
// Created by Victor Gama on 02/09/2021.
//

#import <Cocoa/Cocoa.h>

@interface AppDelegate : NSObject <NSApplicationDelegate>


/// Starts the agent by placing an icon in the system's Menu Bar.
/// Multiple calls to this method has no effect.
- (void)startAgent;

@end

164 changes: 164 additions & 0 deletions Podman/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
//
// AppDelegate.m
// Podman macOS
//
// Created by Victor Gama on 02/09/2021.
//

#import <Sparkle/Sparkle.h>

#import "AppDelegate.h"
#import "PMStatusBarController.h"
#import "PopoverController.h"
#import "PMManager.h"
#import "PMMoveToApplications.h"
#import "PMPreferences.h"
#import "PMDispatch.h"

@interface AppDelegate ()

@end

@implementation AppDelegate {
PMStatusBarController *controller;
NSPopover *popover;
BOOL agentRunning;
}

- (void)ensureSingleInstance {
pid_t selfPid = [[NSRunningApplication currentApplication] processIdentifier];
NSArray *appArray = [NSRunningApplication runningApplicationsWithBundleIdentifier:[[NSBundle mainBundle] bundleIdentifier]];
for (NSRunningApplication *app in appArray) {
if ([app processIdentifier] != selfPid) {
[NSApp terminate:nil];
break;
}
}
}


- (void)applicationWillFinishLaunching:(NSNotification *)notification {
[self ensureSingleInstance];
#ifndef DEBUG
[PMMoveToApplications moveToApplicationsFolderIfNecessary];
#endif
}


- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
SUUpdater *updater = [SUUpdater sharedUpdater];
updater.automaticallyChecksForUpdates = PMPreferences.checkForUpdates;
updater.feedURL = [NSURL URLWithString:@"https://heyvito.github.io/podman-macos/sparkle.xml"];

PMOperationResult *detectPodmanResult = [PMManager.manager detectPodman];
switch ([detectPodmanResult detectStateValue]) {
case PMDetectStateNotInPath: {
NSAlert *alert = [[NSAlert alloc] init];
alert.alertStyle = NSAlertStyleCritical;
alert.messageText = @"Podman for macOS did not find a Podman executable";
alert.informativeText = @"Make sure Podman is installed and available in your PATH.";
[alert addButtonWithTitle:@"OK"];
[alert runModal];
[NSApp terminate:nil];
return;
}
case PMDetectStateError: {
NSAlert *alert = [[NSAlert alloc] init];
alert.alertStyle = NSAlertStyleCritical;
alert.messageText = @"Error detecting Podman executable";
alert.informativeText = detectPodmanResult.output;
[alert addButtonWithTitle:@"OK"];
[alert runModal];
[NSApp terminate:nil];
return;
}
case PMDetectStateOK:
NSLog(@"Podman detection succeeded.");
}

PMOperationResult *detectVMResult = [PMManager.manager detectVM];
switch ([detectVMResult vmPresenceValue]) {
case PMVMPresenceError: {
NSAlert *alert = [[NSAlert alloc] init];
alert.alertStyle = NSAlertStyleCritical;
alert.messageText = @"Error detecting Podman Machine";
alert.informativeText = detectVMResult.output;
[alert addButtonWithTitle:@"OK"];
[alert runModal];
[NSApp terminate:nil];
return;
}

case PMVMPresenceAbsent: {
NSStoryboard *story = [NSStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
NSWindowController *windowController = [story instantiateControllerWithIdentifier:@"InstallWindow"];
[windowController showWindow:self];
return;
}

case PMVMPresencePresent:
NSLog(@"Podman Machine detection succeeded.");
}

[self startAgent];
}


- (void)startAgent {
if (self->agentRunning) {
return;
}
self->agentRunning = YES;

NSStoryboard *story = [NSStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
NSViewController *viewController = [story instantiateControllerWithIdentifier:@"PopoverViewController"];
popover = [[NSPopover alloc] init];
popover.contentViewController = viewController;
popover.behavior = NSPopoverBehaviorTransient;
controller = [[PMStatusBarController alloc] initWithPopover:popover];
if (PMPreferences.startPodmanVM) {
NSLog(@"PM is set to autostart VM");
if (PMManager.manager.serviceStatus == PMServiceStatusStopped) {
[PMDispatch background:^{
PMOperationResult *result = [PMManager.manager startVM];
if (!result.succeeded) {
[PMDispatch sync:^{
NSAlert *alert = [[NSAlert alloc] init];
alert.alertStyle = NSAlertStyleWarning;
alert.messageText = @"Podman for macOS could not automatically start Podman's VM";
alert.informativeText = result.output;
[alert addButtonWithTitle:@"OK"];
[alert runModal];
}];
} else {
NSLog(@"VM started successfully.");
}
}];
} else {
NSLog(@"VM is already running.");
}
}

if (!PMPreferences.askedToStartAtLogin) {
PMPreferences.askedToStartAtLogin = YES;
NSAlert *alert = [[NSAlert alloc] init];
alert.alertStyle = NSAlertStyleInformational;
alert.messageText = @"Would you like to Podman for macOS to start at login?";
alert.informativeText = @"This can be changed both in Podman for macOS's preferences and the System Preferences.";
NSButton *yesButton = [alert addButtonWithTitle:@"Yes"];
yesButton.keyEquivalent = @"\r";
NSButton *noButton = [alert addButtonWithTitle:@"No"];
noButton.keyEquivalent = @"\033";
if([alert runModal] == NSAlertFirstButtonReturn) {
PMPreferences.startAtLogin = YES;
}
}
}


- (void)applicationWillResignActive:(NSNotification *)notification {
[popover close];
}


@end
11 changes: 11 additions & 0 deletions Podman/Assets.xcassets/AccentColor.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
68 changes: 68 additions & 0 deletions Podman/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"images" : [
{
"filename" : "icon_16x16.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"filename" : "icon_16x16@[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"filename" : "icon_32x32.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"filename" : "icon_32x32@[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"filename" : "icon_128x128.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"filename" : "icon_128x128@[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"filename" : "icon_256x256.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"filename" : "icon_256x256@[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"filename" : "icon_512x512.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"filename" : "icon_512x512@[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions Podman/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
15 changes: 15 additions & 0 deletions Podman/Assets.xcassets/icon.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "icon.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Binary file added Podman/Assets.xcassets/icon.imageset/icon.pdf
Binary file not shown.
12 changes: 12 additions & 0 deletions Podman/Assets.xcassets/podman-logo-full.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "podman-logo-full.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
15 changes: 15 additions & 0 deletions Podman/Assets.xcassets/podman-logo-text.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "podman-logo-text.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "original"
}
}
Binary file not shown.
15 changes: 15 additions & 0 deletions Podman/Assets.xcassets/podman-logo.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "podman-logo.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "original"
}
}
Binary file not shown.
Loading

0 comments on commit 20cefb4

Please sign in to comment.