Skip to content

Add object detection, tracking, mobile notifications, and search to any security camera.

can open pgp files anywhere now

roryclear844b692e2d15
diff --git a/clearcam/Info.plist b/clearcam/Info.plist
index ee91646..5a5a392 100644
--- a/clearcam/Info.plist
+++ b/clearcam/Info.plist
@@ -9,24 +9,45 @@
<string>PGP File</string>
<key>LSItemContentTypes</key>
<array>
- <string>public.data</string>
+ <string>com.clearcam.pgpfile</string>
</array>
<key>CFBundleTypeExtensions</key>
<array>
<string>pgp</string>
</array>
- <!--<key>CFBundleTypeIconFile</key> -->
- <!--<string>icon.png</string> Optional: specify an icon for .pgp files -->
- <!--<key>LSHandlerRank</key>-->
- <!--<string>Alternate</string> <!-- Optional: specify handler rank -->
+ <key>LSHandlerRank</key>
+ <string>Owner</string> <!-- Makes app the default handler -->
+ </dict>
+ </array>
+
+ <key>UTExportedTypeDeclarations</key>
+ <array>
+ <dict>
+ <key>UTTypeIdentifier</key>
+ <string>com.clearcam.pgpfile</string>
+ <key>UTTypeDescription</key>
+ <string>PGP Encrypted File</string>
+ <key>UTTypeConformsTo</key>
+ <array>
+ <string>public.data</string>
+ </array>
+ <key>UTTypeTagSpecification</key>
+ <dict>
+ <key>public.filename-extension</key>
+ <array>
+ <string>pgp</string>
+ </array>
+ </dict>
</dict>
</array>
+
<key>UIFileSharingEnabled</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>NSCameraUsageDescription</key>
<string>We need access to your camera to take photos and videos.</string>
+
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
diff --git a/clearcam/SceneDelegate.m b/clearcam/SceneDelegate.m
index 7e04ffb..c06cf9c 100644
--- a/clearcam/SceneDelegate.m
+++ b/clearcam/SceneDelegate.m
@@ -72,21 +72,30 @@
// Destination path inside the app's Documents directory
NSURL *localPGPFileURL = [documentsDirectoryURL URLByAppendingPathComponent:url.lastPathComponent];
- // Check if file is already in Documents, otherwise copy it
- if (![url.path isEqualToString:localPGPFileURL.path]) {
- NSError *copyError = nil;
- [[NSFileManager defaultManager] copyItemAtURL:url toURL:localPGPFileURL error:&copyError];
+ // If the file already exists, remove it before copying
+ if ([[NSFileManager defaultManager] fileExistsAtPath:localPGPFileURL.path]) {
+ NSError *removeError = nil;
+ [[NSFileManager defaultManager] removeItemAtURL:localPGPFileURL error:&removeError];
- if (copyError) {
- NSLog(@"Error copying file: %@", copyError.localizedDescription);
+ if (removeError) {
+ NSLog(@"Error removing existing file: %@", removeError.localizedDescription);
[url stopAccessingSecurityScopedResource]; // Stop access before returning
return;
}
}
+ // Copy the file to Documents directory
+ NSError *copyError = nil;
+ [[NSFileManager defaultManager] copyItemAtURL:url toURL:localPGPFileURL error:&copyError];
+
// Stop accessing the security-scoped resource after copying
[url stopAccessingSecurityScopedResource];
+ if (copyError) {
+ NSLog(@"Error copying file: %@", copyError.localizedDescription);
+ return;
+ }
+
// Decrypt the copied .pgp file using your PGP class
NSString *encryptedFilePath = localPGPFileURL.path;
[self.pgp decryptImageWithPrivateKey:encryptedFilePath];
@@ -110,7 +119,6 @@
}
}
-
#pragma mark - UIDocumentInteractionControllerDelegate
- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller {