Add object detection, tracking, mobile notifications, and search to any security camera.
deslop more
roryclear610421af66e9
diff --git a/clearcam/AppDelegate.m b/clearcam/AppDelegate.mindex c087522..ded5c65 100644--- a/clearcam/AppDelegate.m+++ b/clearcam/AppDelegate.m@@ -65,7 +65,6 @@}- (void)handleNotificationReceived:(NSDictionary *)userInfo {- NSLog(@"Notification received %@", userInfo);GalleryViewController *gallery = [[GalleryViewController alloc] init];sleep(15); // Consider replacing this with a proper async operation[gallery getEvents];@@ -88,11 +87,6 @@[FileServer sendDeviceTokenToServer];}--- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {- NSLog(@"Failed to register for remote notifications: %@", error);-}-- (void)userNotificationCenter:(UNUserNotificationCenter *)centerwillPresentNotification:(UNNotification *)notificationwithCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {diff --git a/clearcam/FileServer.m b/clearcam/FileServer.mindex 8e20e74..c876e7a 100644--- a/clearcam/FileServer.m+++ b/clearcam/FileServer.m@@ -81,14 +81,12 @@setsockopt(self.serverSocket, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));if (bind(self.serverSocket, (struct sockaddr *)&serverAddr, sizeof(serverAddr)) == -1) {- NSLog(@"Failed to bind socket: %s", strerror(errno));close(self.serverSocket);self.serverSocket = -1;return;}if (listen(self.serverSocket, 5) == -1) {- NSLog(@"Failed to listen on socket: %s", strerror(errno));close(self.serverSocket);self.serverSocket = -1;return;@@ -106,7 +104,6 @@}} @catch (NSException *exception) {- NSLog(@"Exception in server: %@", exception);self.isServerRunning = NO;if (self.serverSocket != -1) {close(self.serverSocket);@@ -669,67 +666,33 @@NSString *imageFileName = [NSString stringWithFormat:@"%lld", roundedTimestamp];NSString *imageFilePath = [imagesDirectory stringByAppendingPathComponent:[imageFileName stringByAppendingString:@".jpg"]];NSString *smallImageFilePath = [imagesDirectory stringByAppendingPathComponent:[imageFileName stringByAppendingString:@"_small.jpg"]];-- // Delete regular image if it exists+NSError *fileError = nil;- if ([fileManager fileExistsAtPath:imageFilePath]) {- if ([fileManager removeItemAtPath:imageFilePath error:&fileError]) NSLog(@"Deleted image at %@", imageFilePath);- }-- // Delete small image if it exists- fileError = nil;- if ([fileManager fileExistsAtPath:smallImageFilePath]) {- if ([fileManager removeItemAtPath:smallImageFilePath error:&fileError]) NSLog(@"Deleted small image at %@", smallImageFilePath);- }-- // Delete the event from Core Data+ if ([fileManager fileExistsAtPath:imageFilePath]) [fileManager removeItemAtPath:imageFilePath error:&fileError];+ if ([fileManager fileExistsAtPath:smallImageFilePath]) [fileManager removeItemAtPath:smallImageFilePath error:&fileError];[self.context deleteObject:event];- NSLog(@"Marked event with timestamp %lf for deletion", timeStamp);}// Save changesif ([self.context hasChanges]) {- NSLog(@"Context has %lu deleted objects to save (attempt %d)", (unsigned long)[self.context.deletedObjects count], attempt);NSError *saveError = nil;@try {success = [self.context save:&saveError];- if (success) {- NSLog(@"Successfully saved deletions (attempt %d)", attempt);- } else {- NSLog(@"Save failed (attempt %d): %@", attempt, saveError.localizedDescription);- }}@catch (NSException *exception) {- NSLog(@"Save exception (attempt %d): %@", attempt, exception.reason);success = NO;}} else {- NSLog(@"No changes detected in context (attempt %d)", attempt);success = YES; // No changes to save, but this shouldn't happen if events were deleted}}];-- if (!success) {- NSLog(@"Retrying batch delete (attempt %d/%d)...", attempt, maxRetries);- [NSThread sleepForTimeInterval:0.1];- }- }-- if (!success) {- NSLog(@"Failed to delete events between %lf and %lf after %d attempts", startTimeStamp, endTimeStamp, maxRetries);- } else {- NSLog(@"Successfully deleted events between %lf and %lf", startTimeStamp, endTimeStamp);+ if (!success) [NSThread sleepForTimeInterval:0.1];}-return success;}- (NSArray *)fetchFramesForURL:(NSString *)url context:(NSManagedObjectContext *)context {- if (!context) {- NSLog(@"Context is nil, skipping fetch.");- return @[];- }-+ if (!context) return @[];__block NSArray *framesForURL = @[];[context performBlockAndWait:^{@@ -743,16 +706,8 @@segmentFetchRequest.returnsObjectsAsFaults = NO;NSArray *segments = [context executeFetchRequest:segmentFetchRequest error:&error];- if (error) {- NSLog(@"Failed to fetch segment for URL %@: %@", url, error.localizedDescription);- return;- }-- if (segments.count == 0) {- NSLog(@"No segment found for URL %@", url);- return;- }-+ if (error) return;+ if (segments.count == 0) return;NSManagedObject *segment = segments.firstObject;NSArray *frames = [[segment valueForKey:@"frames"] array];NSMutableArray *tempFrames = [NSMutableArray arrayWithCapacity:frames.count];@@ -799,31 +754,14 @@+ (void)sendDeviceTokenToServer {NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];NSString *deviceToken = [defaults stringForKey:@"device_token"];- if (!deviceToken || deviceToken.length == 0) {- NSLog(@"No device token found, skipping API call.");- return;- }+ if (!deviceToken || deviceToken.length == 0) return;NSString *sessionToken = [[StoreManager sharedInstance] retrieveSessionTokenFromKeychain];- if (!sessionToken || sessionToken.length == 0) {- NSLog(@"No session token found in Keychain. Skipping API call.");- return;- }-+ if (!sessionToken || sessionToken.length == 0) return;[FileServer performPostRequestWithURL:@"https://rors.ai/add_device"method:@"POST"contentType:@"application/json"body:@{@"device_token": deviceToken, @"session_token": sessionToken}- completionHandler:^(NSData *data, NSHTTPURLResponse *response, NSError *error) {- if (error) {- NSLog(@"Error sending device token: %@", error.localizedDescription);- return;- }- if (response.statusCode == 200) {- NSLog(@"Device token successfully sent to server");- } else {- NSLog(@"Failed to send device token, server responded with status code: %ld", (long)response.statusCode);- }- }];+ completionHandler:^(NSData *data, NSHTTPURLResponse *response, NSError *error) { if (error) return; }];}+ (void)performPostRequestWithURL:(NSString *)urlString@@ -866,11 +804,7 @@for (NSString *filePath in filePaths) {AVAsset *asset = [AVAsset assetWithURL:[NSURL fileURLWithPath:filePath]];- if (asset.tracks.count == 0) {- NSLog(@"Error: No tracks found in asset %@", filePath);- continue;- }-+ if (asset.tracks.count == 0) continue;AVAssetTrack *videoAssetTrack = [[asset tracksWithMediaType:AVMediaTypeVideo] firstObject];NSError *error = nil;@@ -878,9 +812,6 @@ofTrack:videoAssetTrackatTime:currentTimeerror:&error];-- if (error) NSLog(@"Error inserting video track: %@", error.localizedDescription);-currentTime = CMTimeAdd(currentTime, asset.duration);}@@ -896,22 +827,15 @@[exportSession exportAsynchronouslyWithCompletionHandler:^{if (exportSession.status == AVAssetExportSessionStatusCompleted) {- if (![[NSFileManager defaultManager] fileExistsAtPath:outputPath]) NSLog(@"File not found in Documents: %@", outputPath);completion(outputPath, nil);} else {- NSLog(@"Export failed: %@", exportSession.error.localizedDescription);completion(nil, exportSession.error);}}];}- (NSArray *)fetchEventDataFromCoreData:(NSManagedObjectContext *)context {- // Validate context- if (!context) {- NSLog(@"Error: Managed object context is nil");- return @[];- }-+ if (!context) return @[];__block NSArray *eventDataArray = nil;// Perform fetch synchronously on the context's queue@@ -928,19 +852,11 @@fetchedEvents = [context executeFetchRequest:fetchRequest error:&error];}@catch (NSException *exception) {- NSLog(@"Fetch exception: %@", exception.reason);eventDataArray = @[];return;}- if (error) {- NSLog(@"Error fetching events: %@, %@", error, error.userInfo);- eventDataArray = @[];- return;- }-- if (!fetchedEvents) {- NSLog(@"Fetch returned nil array");+ if (error || !fetchedEvents) {eventDataArray = @[];return;}@@ -952,10 +868,7 @@for (NSManagedObject *event in fetchedEvents) {// Safely access attributes with nil checksNSNumber *timeStampNumber = [event valueForKey:@"timeStamp"];- if (!timeStampNumber) {- NSLog(@"Warning: Event missing timestamp, skipping");- continue;- }+ if (!timeStampNumber) continue;NSTimeInterval timestamp = [timeStampNumber doubleValue];long long roundedTimestamp = (long long)timestamp;@@ -983,10 +896,7 @@size_t chunkSize = fread(buffer, 1, sizeof(buffer), file);if (chunkSize == 0) break;ssize_t bytesSent = send(socket, buffer, chunkSize, 0);- if (bytesSent < 0) {- NSLog(@"Failed to send data: %s", strerror(errno));- break;- }+ if (bytesSent < 0) break;bytesToSend -= bytesSent;}}@@ -998,11 +908,7 @@NSFetchRequest *eventFetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"EventEntity"];NSArray *eventEntities = [context executeFetchRequest:eventFetchRequest error:&fetchError];- if (fetchError) {- NSLog(@"Failed to fetch EventEntity objects: %@", fetchError.localizedDescription);- return;- }-+ if (fetchError) return;for (NSManagedObject *eventEntity in eventEntities) {[context deleteObject:eventEntity];}@@ -1011,10 +917,7 @@NSFetchRequest *dayFetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"DayEntity"];NSArray *dayEntities = [context executeFetchRequest:dayFetchRequest error:&fetchError];- if (fetchError) {- NSLog(@"Failed to fetch DayEntity objects: %@", fetchError.localizedDescription);- return;- }+ if (fetchError) return;for (NSManagedObject *dayEntity in dayEntities) {[context deleteObject:dayEntity];@@ -1062,7 +965,6 @@dispatch_semaphore_t trimSema = dispatch_semaphore_create(0);__block NSInteger trimCount = 0;- NSLog(@"Requested range: %.2f to %.2f (duration: %.2f seconds)", relativeStart, relativeEnd, requestedDuration);for (NSInteger i = 0; i < segments.count; i++) {NSTimeInterval segmentStart = [segments[i][@"timeStamp"] doubleValue];NSTimeInterval segmentDuration = [segments[i][@"duration"] doubleValue];@@ -1073,17 +975,12 @@}NSString *originalFilePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:segments[i][@"url"]];- if (![[NSFileManager defaultManager] fileExistsAtPath:originalFilePath]) {- NSLog(@"Segment file not found: %@", originalFilePath);- continue;- }+ if (![[NSFileManager defaultManager] fileExistsAtPath:originalFilePath]) continue;NSTimeInterval trimStart = MAX(0, relativeStart - segmentStart);NSTimeInterval trimEnd = MIN(segmentDuration, relativeEnd - segmentStart);NSTimeInterval trimmedDuration = trimEnd - trimStart;- NSLog(@"Segment %ld: %.2f to %.2f (duration: %.2f), trimming to %.2f-%.2f (%.2f seconds)", (long)i, segmentStart, segmentEnd, segmentDuration, trimStart, trimEnd, trimmedDuration);-NSString *trimmedFilePath = [tempDir stringByAppendingPathComponent:[NSString stringWithFormat:@"trimmed_%ld.mp4", (long)i]];AVURLAsset *asset = [AVURLAsset assetWithURL:[NSURL fileURLWithPath:originalFilePath]];AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetHighestQuality];@@ -1096,7 +993,6 @@if (CMTimeCompare(CMTimeAdd(startTime, durationTime), CMTimeMakeWithSeconds(segmentDuration, 600)) > 0) {durationTime = CMTimeSubtract(CMTimeMakeWithSeconds(segmentDuration, 600), startTime);timeRange = CMTimeRangeMake(startTime, durationTime);- NSLog(@"Adjusted duration for segment %ld to fit asset: %.2f seconds", (long)i, CMTimeGetSeconds(durationTime));}exportSession.timeRange = timeRange;@@ -1126,16 +1022,6 @@trimCount++;[exportSession exportAsynchronouslyWithCompletionHandler:^{- switch (exportSession.status) {- case AVAssetExportSessionStatusCompleted:- NSLog(@"Processed segment %ld successfully%@, duration: %.2f seconds", (long)i, low_res ? @" at 960x540" : @"", CMTimeGetSeconds(timeRange.duration));- break;- case AVAssetExportSessionStatusFailed:- NSLog(@"Failed to process segment %ld: %@", (long)i, exportSession.error);- break;- default:- break;- }dispatch_semaphore_signal(trimSema);}];}@@ -1192,8 +1078,7 @@NSError *renameError = nil;[[NSFileManager defaultManager] moveItemAtPath:outputPath toPath:newOutputPath error:&renameError];if (renameError) {- NSLog(@"Failed to rename file: %@", renameError);- return outputPath; // Return original path if renaming fails+ return outputPath;}return newOutputPath;diff --git a/clearcam/GalleryViewController.m b/clearcam/GalleryViewController.mindex 44e0784..f9d9185 100644--- a/clearcam/GalleryViewController.m+++ b/clearcam/GalleryViewController.m@@ -136,9 +136,6 @@withIntermediateDirectories:YESattributes:nilerror:&error];- if (error) {- NSLog(@"Failed to create directory: %@", error.localizedDescription);- }}}@@ -191,11 +188,7 @@NSMutableArray<NSURLQueryItem *> *queryItems = [NSMutableArray array];- if (sessionToken) {- [queryItems addObject:[NSURLQueryItem queryItemWithName:@"session_token" value:sessionToken]];- } else {- NSLog(@"No session token found in Keychain. Proceeding without it.");- }+ if (sessionToken) [queryItems addObject:[NSURLQueryItem queryItemWithName:@"session_token" value:sessionToken]];NSDate *latestDate = [self latestDownloadedFileDate];if (latestDate) {@@ -215,10 +208,7 @@self.isLoadingVideos = NO;});- if (error) {- NSLog(@"Request failed: %@", error.localizedDescription);- return;- }+ if (error) return;NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;if (httpResponse.statusCode == 200) {@@ -229,11 +219,7 @@dispatch_async(dispatch_get_main_queue(), ^{[self downloadFiles:json[@"files"]];});- } else {- NSLog(@"JSON parsing error: %@ or no 'files' key in response.", jsonError.localizedDescription);}- } else {- NSLog(@"Request failed with status code: %ld", (long)httpResponse.statusCode);}}] resume];}@@ -253,7 +239,6 @@NSURLComponents *components = [NSURLComponents componentsWithString:@"https://rors.ai/video"];NSString *sessionToken = [[StoreManager sharedInstance] retrieveSessionTokenFromKeychain];if (!sessionToken) {- NSLog(@"No session token found in Keychain.");dispatch_group_leave(downloadGroup);return;}@@ -273,13 +258,6 @@NSURL *destURL = [NSURL fileURLWithPath:destPath];[[NSFileManager defaultManager] moveItemAtURL:location toURL:destURL error:&moveError];- if (!moveError) {- NSLog(@"File downloaded to: %@", destPath);- } else {- NSLog(@"File move failed with error: %@", moveError.localizedDescription);- }- } else {- NSLog(@"Download failed with error: %@, status code: %ld", error.localizedDescription, (long)[(NSHTTPURLResponse *)response statusCode]);}dispatch_group_leave(downloadGroup);}] resume];@@ -393,10 +371,7 @@NSError *error = nil;CGImageRef imageRef = [generator copyCGImageAtTime:time actualTime:NULL error:&error];- if (!imageRef) {- NSLog(@"Thumbnail generation failed: %@", error.localizedDescription);- return nil;- }+ if (!imageRef) return nil;UIImage *thumbnail = [UIImage imageWithCGImage:imageRef];CGImageRelease(imageRef);@@ -422,7 +397,6 @@NSError *readError = nil;NSData *encryptedData = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:filePath] options:0 error:&readError];if (!encryptedData) {- NSLog(@"Failed to read .aes file: %@", readError.localizedDescription);[self showErrorAlertWithMessage:[NSString stringWithFormat:@"Failed to read the file: %@", readError.localizedDescription]];return;}@@ -467,9 +441,7 @@NSString *fileName = [[aesFileURL lastPathComponent] stringByDeletingPathExtension];NSString *keyPrefix = [userProvidedKey substringToIndex:MIN(6, userProvidedKey.length)];NSString *keyIdentifier = [NSString stringWithFormat:@"decryption_key_%@_%@", fileName, keyPrefix];- if (![[SecretManager sharedManager] saveDecryptionKey:userProvidedKey withIdentifier:keyIdentifier error:&saveError]) {- NSLog(@"Failed to save key to SecretManager: %@", saveError.localizedDescription);- }+ if (![[SecretManager sharedManager] saveDecryptionKey:userProvidedKey withIdentifier:keyIdentifier error:&saveError]) NSLog(@"Failed to save key to SecretManager: %@", saveError.localizedDescription);NSURL *decryptedURL = [self handleDecryptedData:decryptedData fromURL:aesFileURL];if (decryptedURL) {// Reload the table view to reflect the decrypted state@@ -483,13 +455,11 @@}];}} else { // Key didn't work, prompt again- NSLog(@"Failed to decrypt data with user-provided key.");[self showErrorAlertWithMessage:@"The provided key is incorrect. Please try again or cancel." completion:^{[self promptUserForKeyWithAESFileURL:aesFileURL encryptedData:encryptedData];}];}} else { // User canceled- NSLog(@"User canceled key entry.");[self showErrorAlertWithMessage:@"Decryption canceled. A valid key is required to decrypt the file."];}}];@@ -624,25 +594,16 @@CGPoint touchPoint = [sender convertPoint:CGPointZero toView:self.tableView];NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:touchPoint];- if (!indexPath) {- NSLog(@"Failed to get indexPath for menu button tap");- return;- }+ if (!indexPath) return;NSInteger section = indexPath.section;NSInteger row = indexPath.row;- if (section >= self.sectionTitles.count) {- NSLog(@"Invalid section: %ld, total sections: %lu", (long)section, (unsigned long)self.sectionTitles.count);- return;- }+ if (section >= self.sectionTitles.count) return;NSString *sectionTitle = self.sectionTitles[section];- if (row >= self.groupedVideos[sectionTitle].count) {- NSLog(@"Invalid row: %ld for section '%@', total rows: %lu", (long)row, sectionTitle, (unsigned long)self.groupedVideos[sectionTitle].count);- return;- }+ if (row >= self.groupedVideos[sectionTitle].count) return;NSString *videoPath = self.groupedVideos[sectionTitle][row];NSString *filename = [videoPath lastPathComponent];@@ -665,27 +626,19 @@style:UIAlertActionStyleDestructivehandler:^(UIAlertAction * _Nonnull action) {NSString *sessionToken = [[StoreManager sharedInstance] retrieveSessionTokenFromKeychain];- if (!sessionToken) {- NSLog(@"No session token found in Keychain. Proceeding with local deletion only.");- }+ if (!sessionToken) NSLog(@"No session token found in Keychain. Proceeding with local deletion only.");NSError *localError;NSFileManager *fileManager = [NSFileManager defaultManager];if ([fileManager fileExistsAtPath:videoPath]) {[fileManager removeItemAtPath:videoPath error:&localError];- if (localError) {- NSLog(@"Failed to delete decrypted file at %@: %@", videoPath, localError.localizedDescription);- return;- }+ if (localError) return;}if ([fileManager fileExistsAtPath:originalAesPath]) {[fileManager removeItemAtPath:originalAesPath error:&localError];- if (localError) {- NSLog(@"Failed to delete original .aes file at %@: %@", originalAesPath, localError.localizedDescription);- return;- }+ if (localError) return;}[self.videoFiles removeObject:videoPath];@@ -716,11 +669,6 @@[[self.downloadSession dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;- if (!error && httpResponse.statusCode == 200) {- NSLog(@"Successfully deleted %@ from backend", backendFilename);- } else {- NSLog(@"Failed to delete from backend: %@, status code: %ld", error.localizedDescription, (long)httpResponse.statusCode);- }}] resume];}}]];@@ -746,10 +694,7 @@NSError *writeError = nil;[decryptedData writeToURL:decFileURL options:NSDataWritingAtomic error:&writeError];- if (writeError) {- NSLog(@"Failed to write decrypted data: %@", writeError.localizedDescription);- return nil;- }+ if (writeError) return nil;NSError *attributesError = nil;NSDictionary *originalAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[aesFileURL path] error:&attributesError];@@ -758,14 +703,8 @@if (originalCreationDate) {NSDictionary *newAttributes = @{NSFileCreationDate: originalCreationDate};[[NSFileManager defaultManager] setAttributes:newAttributes ofItemAtPath:[decFileURL path] error:&attributesError];- if (attributesError) {- NSLog(@"Failed to set creation date: %@", attributesError.localizedDescription);- }}- } else {- NSLog(@"Failed to get original attributes: %@", attributesError.localizedDescription);}-return decFileURL;}diff --git a/clearcam/PortScanner.m b/clearcam/PortScanner.mindex 519c09b..f6c73a8 100644--- a/clearcam/PortScanner.m+++ b/clearcam/PortScanner.m@@ -119,7 +119,6 @@- (void)throttledScanNetworkForPort:(int)port withBatchSize:(int)batchSize completion:(void (^)(NSArray<NSString *> *openPorts))completion {NSDictionary *ipInfo = [self getLocalIPInfo];if (!ipInfo) {- NSLog(@"Failed to get local IP info.");if (completion) completion(@[]);return;}diff --git a/clearcam/SceneDelegate.m b/clearcam/SceneDelegate.mindex cf93bd9..8271f24 100644--- a/clearcam/SceneDelegate.m+++ b/clearcam/SceneDelegate.m@@ -58,18 +58,15 @@NSError *downloadError = nil;[aesFileURL getResourceValue:&downloadStatus forKey:NSURLUbiquitousItemDownloadingStatusKey error:&downloadError];if (downloadError) {- NSLog(@"Error checking iCloud download status: %@", downloadError.localizedDescription);[self showErrorAlertWithMessage:[NSString stringWithFormat:@"Failed to check iCloud status: %@", downloadError.localizedDescription] completion:nil];return;}- NSLog(@"iCloud download status: %@", downloadStatus);if (![downloadStatus isEqualToString:NSURLUbiquitousItemDownloadingStatusCurrent]) {NSError *downloadStartError = nil;[fileManager startDownloadingUbiquitousItemAtURL:aesFileURL error:&downloadStartError];if (downloadStartError) {- NSLog(@"Failed to start downloading iCloud file: %@", downloadStartError.localizedDescription);[self showErrorAlertWithMessage:[NSString stringWithFormat:@"Failed to start download: %@", downloadStartError.localizedDescription] completion:nil];return;}@@ -80,7 +77,6 @@} else {// Check if the file exists locally (for non-iCloud files)if (![fileManager fileExistsAtPath:aesFileURL.path]) {- NSLog(@"File does not exist at path: %@", aesFileURL.path);[self showErrorAlertWithMessage:@"The file does not exist or is not accessible." completion:nil];return;}@@ -97,7 +93,6 @@NSError *readError = nil;NSData *encryptedData = [NSData dataWithContentsOfURL:newURL options:0 error:&readError];if (!encryptedData) {- NSLog(@"Failed to read .aes file: %@", readError.localizedDescription);[self showErrorAlertWithMessage:[NSString stringWithFormat:@"Failed to read the file: %@", readError.localizedDescription] completion:nil];return;}@@ -126,10 +121,7 @@}}];- if (coordinationError) {- NSLog(@"File coordination failed: %@", coordinationError.localizedDescription);- [self showErrorAlertWithMessage:[NSString stringWithFormat:@"File access failed: %@", coordinationError.localizedDescription] completion:nil];- }+ if (coordinationError) [self showErrorAlertWithMessage:[NSString stringWithFormat:@"File access failed: %@", coordinationError.localizedDescription] completion:nil];}// Helper method to handle decrypted data@@ -158,20 +150,16 @@NSString *fileName = [[aesFileURL lastPathComponent] stringByDeletingPathExtension];NSString *keyPrefix = [userProvidedKey substringToIndex:MIN(6, userProvidedKey.length)];NSString *keyIdentifier = [NSString stringWithFormat:@"decryption_key_%@_%@", fileName, keyPrefix];- if (![[SecretManager sharedManager] saveDecryptionKey:userProvidedKey withIdentifier:keyIdentifier error:&saveError]) {- NSLog(@"Failed to save key to SecretManager: %@", saveError.localizedDescription);- }+ [[SecretManager sharedManager] saveDecryptionKey:userProvidedKey withIdentifier:keyIdentifier error:&saveError];NSURL *url = [self handleDecryptedData:decryptedData fromURL:aesFileURL];if(url) [self openImageInPhotoViewer:url];} else { // Key didn't work, prompt again- NSLog(@"Failed to decrypt data with user-provided key.");[self showErrorAlertWithMessage:@"The provided key is incorrect. Please try again or cancel." completion:^{// Call the method again instead of the block[self promptUserForKeyWithAESFileURL:aesFileURL encryptedData:encryptedData];}];}} else { // User canceled- NSLog(@"User canceled key entry.");[self showErrorAlertWithMessage:@"Decryption canceled. A valid key is required to decrypt the file." completion:nil];}}];@@ -263,8 +251,6 @@NSMetadataQuery *query = notification.object;[query enumerateResultsUsingBlock:^(NSMetadataItem *result, NSUInteger idx, BOOL *stop) {NSString *downloadStatus = [result valueForAttribute:NSMetadataUbiquitousItemDownloadingStatusKey];- NSLog(@"Download status updated: %@", downloadStatus);-if ([downloadStatus isEqualToString:NSURLUbiquitousItemDownloadingStatusCurrent]) {// File is downloaded, stop the query and handle the file[query stopQuery];diff --git a/clearcam/SceneState.m b/clearcam/SceneState.mindex d242926..20a28e3 100644--- a/clearcam/SceneState.m+++ b/clearcam/SceneState.m@@ -90,9 +90,7 @@NSData *imageData = UIImageJPEGRepresentation(uiImage, 1.0); // 1.0 for maximum qualityNSString *filePathSmall = [imagesDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%lld_small.jpg", roundedUnixTimestamp]];// Write the image data to file- if (![imageData writeToFile:filePath atomically:YES]) {- NSLog(@"Failed to save image at path: %@", filePath);- } else {+ if ([imageData writeToFile:filePath atomically:YES]) {//thumbnailUIGraphicsBeginImageContextWithOptions(CGSizeMake(uiImage.size.width / 2, uiImage.size.height / 2), YES, 1.0);[uiImage drawInRect:CGRectMake(0, 0, uiImage.size.width / 2, uiImage.size.height / 2)];@@ -101,6 +99,7 @@NSData *lowResImageData = UIImageJPEGRepresentation(resizedImage, 0.7);[lowResImageData writeToFile:filePathSmall atomically:YES];+ //todo only send with isSubscribedif (self.last_email_time && [[NSDate date] timeIntervalSinceDate:self.last_email_time] > 120) { // only once per hour? enforce server side!NSLog(@"sending email");if(![[NSUserDefaults standardUserDefaults] boolForKey:@"isSubscribed"] || ![[NSDate date] compare:[[NSUserDefaults standardUserDefaults] objectForKey:@"expiry"]] || [[NSDate date] compare:[[NSUserDefaults standardUserDefaults] objectForKey:@"expiry"]] == NSOrderedDescending){@@ -111,12 +110,6 @@} else {[self sendEmail:filePath];}- //todo- //if ([[NSUserDefaults standardUserDefaults] boolForKey:@"send_email_alerts_enabled"] &&- // ([[NSUserDefaults standardUserDefaults] boolForKey:@"isSubscribed"] ||- // [[NSUserDefaults standardUserDefaults] boolForKey:@"use_own_server_enabled"])) {- } else {- NSLog(@"NOT sending an email");}}}@@ -129,9 +122,7 @@[newEvent setValue:@(current_state) forKey:@"quantity"];NSError *saveError = nil;- if (![self.backgroundContext save:&saveError]) {- NSLog(@"Failed to save EventEntity: %@, %@", saveError, saveError.userInfo);- }+ [self.backgroundContext save:&saveError];}];}@@ -144,7 +135,6 @@}- (void)sendEmail:(NSString *)filePath {- NSLog(@"ACC SENDING?");if ([[NSUserDefaults standardUserDefaults] boolForKey:@"send_notif_enabled"] || !([[NSUserDefaults standardUserDefaults] boolForKey:@"isSubscribed"] || [[NSUserDefaults standardUserDefaults] boolForKey:@"use_own_server_enabled"])){ //todo add back other stuffNSDate *now = [NSDate date];NSDateComponents *components = [[NSCalendar currentCalendar] components:(NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitWeekday) fromDate:now];@@ -169,11 +159,9 @@NSString *filePath = [[FileServer sharedInstance] processVideoDownloadWithLowRes:YES startTime:start endTime:end context:context];[[Email sharedInstance] sendEmailWithImageAtPath:filePath];});- NSLog(@"Email sent: Within scheduled time");break;}}- NSLog(@"Email suppressed: Outside scheduled time or no matching schedule");}}diff --git a/clearcam/SecretManager.m b/clearcam/SecretManager.mindex 43e7248..0ccbc6a 100644--- a/clearcam/SecretManager.m+++ b/clearcam/SecretManager.m@@ -44,10 +44,7 @@ static NSString *const kServiceIdentifier = @"com.yourapp.aeskeys"; // Replace w}}}- } else if (status != errSecItemNotFound) {- NSLog(@"Failed to retrieve keys from Keychain: %d", (int)status);}-return [keys copy];}@@ -80,7 +77,6 @@ static NSString *const kServiceIdentifier = @"com.yourapp.aeskeys"; // Replace wOSStatus status = SecItemAdd((__bridge CFDictionaryRef)query, NULL);if (status != errSecSuccess) {- NSLog(@"Failed to save encryption key: %d", (int)status);if (error) {*error = [NSError errorWithDomain:@"SecretManagerErrorDomain"code:statusdiff --git a/clearcam/SettingsViewController.m b/clearcam/SettingsViewController.mindex 1a2c77c..cc6b48e 100644--- a/clearcam/SettingsViewController.m+++ b/clearcam/SettingsViewController.m@@ -712,8 +712,7 @@if (!password) return;NSError *error = nil;- BOOL success = [[SecretManager sharedManager] saveEncryptionKey:password error:&error];- if (!success) NSLog(@"Failed to save password to Keychain: %@", error.localizedDescription);+ [[SecretManager sharedManager] saveEncryptionKey:password error:&error];}- (NSString *)retrievePasswordFromSecretsManager {diff --git a/clearcam/StoreManager.m b/clearcam/StoreManager.mindex 7683e06..22141c6 100644--- a/clearcam/StoreManager.m+++ b/clearcam/StoreManager.m@@ -43,10 +43,6 @@ NSString *const StoreManagerSubscriptionStatusDidChangeNotification = @"StoreMan[self purchaseProduct];}-- (void)request:(SKRequest *)request didFailWithError:(NSError *)error {- NSLog(@"Failed to fetch products: %@", error.localizedDescription);-}-#pragma mark - Purchase Product- (void)purchaseProduct {@@ -189,12 +185,7 @@ NSString *const StoreManagerSubscriptionStatusDidChangeNotification = @"StoreMan(__bridge id)kSecAttrService: @"com.clearcam.session",(__bridge id)kSecAttrAccount: @"sessionToken"};-- OSStatus status = SecItemDelete((__bridge CFDictionaryRef)query);- if (status != errSecSuccess && status != errSecItemNotFound) {- NSLog(@"Failed to clear session token from Keychain: %d", (int)status);- }-}+ SecItemDelete((__bridge CFDictionaryRef)query);}// Optional: Retrieve the session token if needed later- (NSString *)retrieveSessionTokenFromKeychain {diff --git a/clearcam/ViewController.m b/clearcam/ViewController.mindex 31b8366..5bf1413 100644--- a/clearcam/ViewController.m+++ b/clearcam/ViewController.m@@ -614,9 +614,7 @@ NSMutableDictionary *classColorMap;if ([self.backgroundContext save:&error]) {// Save parent context only if necessaryNSError *parentError = nil;- if (![self.fileServer.context save:&parentError]) {- NSLog(@"Failed to save parent context: %@", parentError.localizedDescription);- }+ [self.fileServer.context save:&parentError];}// Create a local copy of current_segment_squares, moved to after file save