Skip to content

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

deslop a bit

rorycleara84c043ec8e6
diff --git a/clearcam/AppDelegate.m b/clearcam/AppDelegate.m
index 8a9c8c8..c087522 100644
--- a/clearcam/AppDelegate.m
+++ b/clearcam/AppDelegate.m
@@ -11,7 +11,6 @@
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- NSLog(@"App launched with options: %@", launchOptions);
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
@@ -19,7 +18,6 @@
if (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) {
NSDictionary *userInfo = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];
self.pendingNotification = userInfo;
- NSLog(@"Launched from notification: %@", userInfo);
// Only process if notifications are enabled
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"receive_notif_enabled"] && userInfo[@"aps"][@"content-available"]) {
[self handleNotificationReceived:userInfo];
@@ -30,7 +28,6 @@
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
- NSLog(@"Application became active");
if (self.pendingNotification && [[NSUserDefaults standardUserDefaults] boolForKey:@"receive_notif_enabled"]) {
[self handleNotificationNavigation];
self.pendingNotification = nil;
@@ -41,7 +38,6 @@
- (void)handleNotificationNavigation {
dispatch_async(dispatch_get_main_queue(), ^{
- NSLog(@"Handling notification navigation (user tapped)");
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UIViewController *rootVC = window.rootViewController;
@@ -52,10 +48,7 @@
if ([topVC isKindOfClass:[UINavigationController class]]) {
UINavigationController *nav = (UINavigationController *)topVC;
- if ([nav.topViewController isKindOfClass:[GalleryViewController class]]) {
- NSLog(@"GalleryViewController already visible");
- return;
- }
+ if ([nav.topViewController isKindOfClass:[GalleryViewController class]]) return;
}
GalleryViewController *galleryVC = [[GalleryViewController alloc] init];
@@ -72,7 +65,7 @@
}
- (void)handleNotificationReceived:(NSDictionary *)userInfo {
- NSLog(@"Notification received (user did NOT tap): %@", userInfo);
+ NSLog(@"Notification received %@", userInfo);
GalleryViewController *gallery = [[GalleryViewController alloc] init];
sleep(15); // Consider replacing this with a proper async operation
[gallery getEvents];
@@ -90,10 +83,6 @@
for (int i = 0; i < deviceToken.length; i++) {
[token appendFormat:@"%02x", dataBuffer[i]];
}
-
- NSLog(@"Device Token: %@", token);
-
- // Save token to NSUserDefaults
[[NSUserDefaults standardUserDefaults] setObject:token forKey:@"device_token"];
[[NSUserDefaults standardUserDefaults] synchronize];
[FileServer sendDeviceTokenToServer];
@@ -108,7 +97,6 @@
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
NSDictionary *userInfo = notification.request.content.userInfo;
- NSLog(@"Will present notification: %@", userInfo);
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"receive_notif_enabled"]) {
if (userInfo[@"aps"][@"content-available"]) {
[self handleNotificationReceived:userInfo];
@@ -123,7 +111,6 @@
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)(void))completionHandler {
NSDictionary *userInfo = response.notification.request.content.userInfo;
- NSLog(@"User tapped notification: %@", userInfo);
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"receive_notif_enabled"]) {
[self handleNotificationNavigation];
}
@@ -133,45 +120,29 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
- NSLog(@"Received remote notification: %@", userInfo);
-
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"receive_notif_enabled"]) {
completionHandler(UIBackgroundFetchResultNoData);
return;
}
if (userInfo[@"aps"][@"content-available"]) {
- NSLog(@"Background notification detected");
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self handleNotificationReceived:userInfo];
completionHandler(UIBackgroundFetchResultNewData);
});
} else {
- if (application.applicationState == UIApplicationStateInactive) {
- NSLog(@"App inactive - handling navigation");
- self.pendingNotification = userInfo;
- } else if (application.applicationState == UIApplicationStateBackground) {
- NSLog(@"App in background - storing notification");
- self.pendingNotification = userInfo;
- } else {
- NSLog(@"App in foreground - regular notification received");
- }
+ if (application.applicationState == UIApplicationStateInactive || application.applicationState == UIApplicationStateBackground) self.pendingNotification = userInfo;
completionHandler(UIBackgroundFetchResultNoData);
}
}
-#pragma mark - Core Data Stack
-
@synthesize persistentContainer = _persistentContainer;
- (NSPersistentContainer *)persistentContainer {
if (_persistentContainer == nil) {
_persistentContainer = [[NSPersistentContainer alloc] initWithName:@"SegmentsModel"];
[_persistentContainer loadPersistentStoresWithCompletionHandler:^(NSPersistentStoreDescription *storeDescription, NSError *error) {
- if (error) {
- NSLog(@"Unresolved error %@, %@", error, error.userInfo);
- abort();
- }
+ if (error) abort();
}];
}
return _persistentContainer;
diff --git a/clearcam/Email.m b/clearcam/Email.m
index aba4c86..aeb89f1 100644
--- a/clearcam/Email.m
+++ b/clearcam/Email.m
@@ -30,7 +30,6 @@
NSString *filePathToSend = imagePath;
if (imagePath.length == 0) {
- NSLog(@"Image path is empty. Generating blank image.");
CGSize imageSize = CGSizeMake(1280, 720);
UIGraphicsBeginImageContext(imageSize);
CGContextRef context = UIGraphicsGetCurrentContext();
@@ -47,24 +46,15 @@
imageData = [NSData dataWithContentsOfFile:imagePath];
}
- if (!imageData) {
- NSLog(@"Failed to read image data.");
- return;
- }
+ if (!imageData) return;
NSData *fileData = imageData;
BOOL encryptImage = ![[NSUserDefaults standardUserDefaults] boolForKey:@"use_own_server_enabled"];
if (encryptImage) {
NSString *encryptionKey = [[SecretManager sharedManager] getEncryptionKey];
- if (!encryptionKey) {
- NSLog(@"Encryption key not found. Encryption aborted.");
- return;
- }
+ if (!encryptionKey) return;
fileData = [[SecretManager sharedManager] encryptData:imageData withKey:encryptionKey];
- if (!fileData) {
- NSLog(@"Encryption failed.");
- return;
- }
+ if (!fileData) return;
filePathToSend = [filePathToSend stringByAppendingString:@".aes"];
}
@@ -86,8 +76,6 @@
[bodyData appendData:[@"Content-Disposition: form-data; name=\"session_token\"\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[bodyData appendData:[sessionToken dataUsingEncoding:NSUTF8StringEncoding]];
[bodyData appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
- } else {
- NSLog(@"Warning: No session token found in Keychain.");
}
}
[bodyData appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
@@ -96,13 +84,7 @@
method:@"POST"
contentType:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary]
body:bodyData
- completionHandler:^(NSData *data, NSHTTPURLResponse *response, NSError *error) {
- if (error) {
- NSLog(@"Error: %@", error.localizedDescription);
- } else {
- NSLog(@"Send request completed successfully.");
- }
- }];
+ completionHandler:^(NSData *data, NSHTTPURLResponse *response, NSError *error) {}];
}
@end
diff --git a/clearcam/FileServer.m b/clearcam/FileServer.m
index 43b1ac9..8e20e74 100644
--- a/clearcam/FileServer.m
+++ b/clearcam/FileServer.m
@@ -50,48 +50,12 @@
- (void)start {
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
self.context = appDelegate.persistentContainer.viewContext;
-
- NSFileManager *fileManager = [NSFileManager defaultManager];
- NSURL *documentsURL = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] firstObject];
- NSString *documentsPath = [documentsURL path];
-
- NSError *error;
- NSArray *contents = [fileManager contentsOfDirectoryAtPath:documentsPath error:&error];
-
- if (error) {
- NSLog(@"Failed to get contents of Documents directory: %@", error.localizedDescription);
- return;
- }
-
- if ([SettingsManager sharedManager].delete_on_launch) {
- [[SecretManager sharedManager] deleteAllKeysWithError:&error];
- for (NSString *file in contents) {
- if ([file hasPrefix:@"batch_req"]) continue;
- NSString *filePath = [documentsPath stringByAppendingPathComponent:file];
- NSError *error = nil;
- BOOL success = [fileManager removeItemAtPath:filePath error:&error];
-
- if (!success) {
- NSLog(@"Failed to delete %@: %@", file, error.localizedDescription);
- }
- }
- [self deleteAllDayEntitiesAndEventsInContext:self.context];
- [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"LastDeletedDayIndex"];
- [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"LastDeletedSegmentIndex"];
- [[NSUserDefaults standardUserDefaults] synchronize];
- }
-
self.segment_length = 1;
self.scanner = [[PortScanner alloc] init];
self.last_req_time = [NSDate now];
self.basePath = [self getDocumentsDirectory];
self.durationCache = [[NSMutableDictionary alloc] init];
-
- // Check initial state and start server if enabled
- BOOL streamViaWiFiEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"stream_via_wifi_enabled"];
- if (streamViaWiFiEnabled) {
- [self startServer];
- }
+ if ([[NSUserDefaults standardUserDefaults] boolForKey:@"stream_via_wifi_enabled"]) [self startServer];
}
- (void)dealloc {
@@ -101,26 +65,18 @@
}
- (void)startServer {
- if (self.isServerRunning) {
- return; // Server already running
- }
-
+ if (self.isServerRunning) return;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
@try {
signal(SIGPIPE, SIG_IGN);
-
self.serverSocket = socket(AF_INET, SOCK_STREAM, 0);
- if (self.serverSocket == -1) {
- NSLog(@"Failed to create socket: %s", strerror(errno));
- return;
- }
-
+ if (self.serverSocket == -1) return;
struct sockaddr_in serverAddr;
memset(&serverAddr, 0, sizeof(serverAddr));
serverAddr.sin_family = AF_INET;
serverAddr.sin_addr.s_addr = INADDR_ANY;
serverAddr.sin_port = htons(80);
-
+
int opt = 1;
setsockopt(self.serverSocket, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
@@ -194,10 +150,7 @@
- (NSArray *)fetchAndProcessSegmentsFromCoreDataForDateParam:(NSString *)dateParam
start:(double)startTime
context:(NSManagedObjectContext *)context {
- if (!context) {
- NSLog(@"Context is nil, skipping fetch.");
- return @[];
- }
+ if (!context) return @[];
__block NSArray *processedSegments = @[];
@@ -210,10 +163,7 @@
dayFetchRequest.fetchLimit = 1; // We only need one DayEntity
NSArray *fetchedDays = [context executeFetchRequest:dayFetchRequest error:&error];
- if (error || fetchedDays.count == 0) {
- NSLog(@"Failed to fetch DayEntity: %@ or no day found for %@", error.localizedDescription, dateParam);
- return;
- }
+ if (error || fetchedDays.count == 0) return;
NSManagedObject *dayEntity = fetchedDays.firstObject;
@@ -225,10 +175,7 @@
segmentFetchRequest.resultType = NSDictionaryResultType; // Return dictionaries directly
NSArray *fetchedSegments = [context executeFetchRequest:segmentFetchRequest error:&error];
- if (error) {
- NSLog(@"Failed to fetch segments: %@", error.localizedDescription);
- return;
- }
+ if (error) return;
processedSegments = fetchedSegments;
}];
@@ -238,10 +185,7 @@
- (NSArray *)fetchFramesWithURLsFromCoreDataForDateParam:(NSString *)dateParam
start:(NSInteger)start
context:(NSManagedObjectContext *)context {
- if (!context) {
- NSLog(@"Context is nil, skipping fetch.");
- return @[];
- }
+ if (!context) return @[];
__block NSArray *copiedSegments = @[];
@@ -254,15 +198,8 @@
NSArray *fetchedDays = [context executeFetchRequest:dayFetchRequest error:&error];
- if (error) {
- NSLog(@"Failed to fetch DayEntity: %@", error.localizedDescription);
- return;
- }
-
- if (fetchedDays.count == 0) {
- NSLog(@"No DayEntity found for date %@", dateParam);
- return;
- }
+ if (error) return;
+ if (fetchedDays.count == 0) return;
NSManagedObject *dayEntity = fetchedDays.firstObject;
NSOrderedSet *segments = [dayEntity valueForKey:@"segments"];
@@ -331,10 +268,7 @@
- (void)handleClientRequest:(int)clientSocket withBasePath:(NSString *)basePath {
char requestBuffer[1024];
ssize_t bytesRead = recv(clientSocket, requestBuffer, sizeof(requestBuffer) - 1, 0);
- if (bytesRead < 0) {
- NSLog(@"Failed to read request from client: %s", strerror(errno));
- return;
- }
+ if (bytesRead < 0) return;
requestBuffer[bytesRead] = '\0';
NSString *request = [NSString stringWithUTF8String:requestBuffer];
NSRange range = [request rangeOfString:@"GET /"];
@@ -380,7 +314,6 @@
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:[presets allKeys] options:0 error:&error];
if (!jsonData) {
- NSLog(@"JSON Serialization Error: %@", error.localizedDescription);
NSString *errorResponse = @"HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\n\r\n";
send(clientSocket, [errorResponse UTF8String], errorResponse.length, 0);
return;
@@ -500,10 +433,7 @@
size_t bytesRead;
while ((bytesRead = fread(buffer, 1, sizeof(buffer), mergedFile)) > 0) {
ssize_t bytesSent = send(clientSocket, buffer, bytesRead, 0);
- if (bytesSent < 0) {
- NSLog(@"Error sending file data: %s", strerror(errno));
- break;
- }
+ if (bytesSent < 0) break;
}
fclose(mergedFile);
@@ -669,25 +599,15 @@
const int maxRetries = 3;
int attempt = 0;
- // Validate context
- if (!self.context) {
- NSLog(@"Error: Managed object context is nil");
- return NO;
- }
+ if (!self.context) return NO;
// Verify entity exists in model
NSEntityDescription *entity = [NSEntityDescription entityForName:@"EventEntity"
inManagedObjectContext:self.context];
- if (!entity) {
- NSLog(@"Error: Entity 'EventEntity' not found in model");
- return NO;
- }
+ if (!entity) return NO;
// Validate timestamp range
- if (startTimeStamp > endTimeStamp) {
- NSLog(@"Error: startTimeStamp (%lf) must be less than or equal to endTimeStamp (%lf)", startTimeStamp, endTimeStamp);
- return NO;
- }
+ if (startTimeStamp > endTimeStamp) return NO;
// Get the app's Documents directory and images folder
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
@@ -696,12 +616,9 @@
while (attempt < maxRetries && !success) {
attempt++;
- NSLog(@"Attempt %d to delete events between %lf and %lf", attempt, startTimeStamp, endTimeStamp);
-
[self.context performBlockAndWait:^{
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
if (!fetchRequest) {
- NSLog(@"Failed to create fetch request (attempt %d)", attempt);
success = NO;
return;
}
@@ -717,28 +634,23 @@
NSArray *events = nil;
@try {
events = [self.context executeFetchRequest:fetchRequest error:&fetchError];
- NSLog(@"Fetched %lu events for deletion (attempt %d)", (unsigned long)events.count, attempt);
}
@catch (NSException *exception) {
- NSLog(@"Fetch exception (attempt %d): %@", attempt, exception.reason);
success = NO;
return;
}
if (fetchError) {
- NSLog(@"Fetch error (attempt %d): %@", attempt, fetchError.localizedDescription);
success = NO;
return;
}
if (!events) {
- NSLog(@"Fetch returned nil array (attempt %d)", attempt);
success = YES; // Treat as success if no objects to delete
return;
}
if (events.count == 0) {
- NSLog(@"No events found in range (attempt %d)", attempt);
success = YES; // No events in range, still a success
return;
}
@@ -748,7 +660,6 @@
for (NSManagedObject *event in events) {
NSNumber *timeStampNumber = [event valueForKey:@"timeStamp"];
if (!timeStampNumber) {
- NSLog(@"Warning: Event missing timestamp, skipping image deletion but deleting event");
[self.context deleteObject:event];
continue;
}
@@ -762,21 +673,13 @@
// Delete regular image if it exists
NSError *fileError = nil;
if ([fileManager fileExistsAtPath:imageFilePath]) {
- if ([fileManager removeItemAtPath:imageFilePath error:&fileError]) {
- NSLog(@"Deleted image at %@", imageFilePath);
- } else {
- NSLog(@"Failed to delete image at %@: %@", imageFilePath, fileError.localizedDescription);
- }
+ 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);
- } else {
- NSLog(@"Failed to delete small image at %@: %@", smallImageFilePath, fileError.localizedDescription);
- }
+ if ([fileManager removeItemAtPath:smallImageFilePath error:&fileError]) NSLog(@"Deleted small image at %@", smallImageFilePath);
}
// Delete the event from Core Data
diff --git a/clearcam/SecretManager.m b/clearcam/SecretManager.m
index 22f1cd3..43e7248 100644
--- a/clearcam/SecretManager.m
+++ b/clearcam/SecretManager.m
@@ -147,7 +147,6 @@ static NSString *const kServiceIdentifier = @"com.yourapp.aeskeys"; // Replace w
OSStatus status = SecItemAdd((__bridge CFDictionaryRef)query, NULL);
if (status != errSecSuccess) {
- NSLog(@"Failed to save decryption key: %d", (int)status);
if (error) {
*error = [NSError errorWithDomain:@"SecretManagerErrorDomain"
code:status
@@ -177,8 +176,6 @@ static NSString *const kServiceIdentifier = @"com.yourapp.aeskeys"; // Replace w
NSData *keyData = (__bridge_transfer NSData *)result;
return [[NSString alloc] initWithData:keyData encoding:NSUTF8StringEncoding];
}
-
- NSLog(@"Encryption key not found.");
return nil;
}
@@ -204,7 +201,6 @@ static NSString *const kServiceIdentifier = @"com.yourapp.aeskeys"; // Replace w
OSStatus status = SecItemDelete((__bridge CFDictionaryRef)query);
if (status != errSecSuccess && status != errSecItemNotFound) {
- NSLog(@"Failed to delete key from Keychain: %d", (int)status);
if (error) {
*error = [NSError errorWithDomain:@"SecretManagerErrorDomain"
code:status
@@ -224,7 +220,6 @@ static NSString *const kServiceIdentifier = @"com.yourapp.aeskeys"; // Replace w
OSStatus status = SecItemDelete((__bridge CFDictionaryRef)query);
if (status != errSecSuccess && status != errSecItemNotFound) {
- NSLog(@"Failed to delete all keys from Keychain: %d", (int)status);
if (error) {
*error = [NSError errorWithDomain:@"SecretManagerErrorDomain"
code:status
diff --git a/clearcam/SettingsManager.m b/clearcam/SettingsManager.m
index 2061ce3..6cf8b50 100644
--- a/clearcam/SettingsManager.m
+++ b/clearcam/SettingsManager.m
@@ -85,7 +85,6 @@
- (void)loadDeleteOnLaunch {
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"delete_on_launch"] == nil) {
- NSLog(@"no delete_on_launch value found");
self.delete_on_launch = NO;
} else {
self.delete_on_launch = [[NSUserDefaults standardUserDefaults] boolForKey:@"delete_on_launch"];
diff --git a/clearcam/SettingsViewController.m b/clearcam/SettingsViewController.m
index bce8367..1a2c77c 100644
--- a/clearcam/SettingsViewController.m
+++ b/clearcam/SettingsViewController.m
@@ -38,9 +38,7 @@
[self.tableView reloadData];
});
}];
- }
- NSLog(@"%d %@", [[NSUserDefaults standardUserDefaults] boolForKey:@"isSubscribed"], [[NSUserDefaults standardUserDefaults] objectForKey:@"expiry"]);
-
+ }
// Register for subscription status change notifications
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(subscriptionStatusDidChange:)
@@ -185,28 +183,22 @@
[defaults synchronize];
if (sender.on) {
- NSLog(@"Receive Notifications on This Device turned ON");
-
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
dispatch_async(dispatch_get_main_queue(), ^{
if (settings.authorizationStatus == UNAuthorizationStatusAuthorized) {
- NSLog(@"Notifications already authorized, sending token...");
[FileServer sendDeviceTokenToServer]; // Send token when toggled ON
} else if (!hasRequestedPermission) {
- NSLog(@"Requesting permission for notifications...");
[center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge)
completionHandler:^(BOOL granted, NSError * _Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (granted) {
- NSLog(@"Notification permission granted");
[[UIApplication sharedApplication] registerForRemoteNotifications];
[defaults setBool:YES forKey:@"hasRequestedNotificationPermission"];
[defaults synchronize];
[FileServer sendDeviceTokenToServer]; // Send token after granting permission
} else {
- NSLog(@"Notification permission denied: %@", error);
self.receiveNotifEnabled = NO;
[defaults setBool:NO forKey:@"receive_notif_enabled"];
[defaults synchronize];
@@ -221,7 +213,6 @@
});
}];
} else {
- NSLog(@"Notifications not authorized, showing settings alert.");
self.receiveNotifEnabled = NO;
[defaults setBool:NO forKey:@"receive_notif_enabled"];
[defaults synchronize];
@@ -236,7 +227,6 @@
});
}];
} else {
- NSLog(@"Receive Notifications on This Device turned OFF");
// Clear any pending notifications when turning off
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center removeAllPendingNotificationRequests];
@@ -251,21 +241,14 @@
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;
// Retrieve session token from Keychain
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;
NSURL *url = [NSURL URLWithString:@"https://rors.ai/delete_device"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
- request.HTTPMethod = @"DELETE"; // Changed from POST to DELETE
+ request.HTTPMethod = @"DELETE";
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSDictionary *body = @{
@@ -277,17 +260,8 @@
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
- if (error) {
- NSLog(@"Error deleting device token: %@", error.localizedDescription);
- return;
- }
-
+ if (error) return;
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
- if (httpResponse.statusCode == 200) {
- NSLog(@"Device token successfully deleted from server");
- } else {
- NSLog(@"Failed to delete device token, server responded with statusevity code: %ld", (long)httpResponse.statusCode);
- }
}];
[task resume];
@@ -557,9 +531,6 @@
} else if (indexPath.row == 6 + offset) {
if (isPremium) {
[self promptForPasswordWithCompletion:^(BOOL success) {
- if (success) {
- NSLog(@"Encryption password changed successfully.");
- }
}];
} else {
[self showPremiumRequiredAlert];
@@ -742,7 +713,6 @@
NSError *error = nil;
BOOL success = [[SecretManager sharedManager] saveEncryptionKey:password error:&error];
-
if (!success) NSLog(@"Failed to save password to Keychain: %@", error.localizedDescription);
}
@@ -751,7 +721,6 @@
if (storedKey) {
return storedKey;
}
- NSLog(@"No password found in Keychain.");
return nil;
}
@@ -789,10 +758,7 @@
if (indexPath.row >= 4 && indexPath.row < 4 + presetKeys.count) {
NSString *presetKey = presetKeys[indexPath.row - 4];
- if ([presetKey isEqualToString:@"all"]) {
- NSLog(@"Cannot delete the 'all' preset.");
- return;
- }
+ if ([presetKey isEqualToString:@"all"]) return;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSMutableDictionary *yoloPresets = [[defaults objectForKey:@"yolo_presets"] mutableCopy];
diff --git a/clearcam/StoreManager.m b/clearcam/StoreManager.m
index 7618d79..7683e06 100644
--- a/clearcam/StoreManager.m
+++ b/clearcam/StoreManager.m
@@ -38,25 +38,7 @@ NSString *const StoreManagerSubscriptionStatusDidChangeNotification = @"StoreMan
#pragma mark - SKProductsRequestDelegate
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
- NSLog(@"✅ Received response from App Store.");
-
- if (response.invalidProductIdentifiers.count > 0) {
- NSLog(@"🚨 Invalid product IDs: %@", response.invalidProductIdentifiers);
- }
-
- if (response.products.count == 0) {
- NSLog(@"🚨 No valid products found! Double-check subscription status in App Store Connect.");
- return;
- }
-
- // Print details of the subscription
- for (SKProduct *product in response.products) {
- NSLog(@"✅ Found product: %@", product.productIdentifier);
- NSLog(@"Title: %@", product.localizedTitle);
- NSLog(@"Description: %@", product.localizedDescription);
- NSLog(@"Price: %@", product.price);
- }
-
+ if (response.products.count == 0) return;
self.premiumProduct = response.products.firstObject;
[self purchaseProduct];
}
@@ -71,8 +53,6 @@ NSString *const StoreManagerSubscriptionStatusDidChangeNotification = @"StoreMan
if ([SKPaymentQueue canMakePayments] && self.premiumProduct) {
SKPayment *payment = [SKPayment paymentWithProduct:self.premiumProduct];
[[SKPaymentQueue defaultQueue] addPayment:payment];
- } else {
- NSLog(@"Purchases are disabled on this device.");
}
}
@@ -82,7 +62,6 @@ NSString *const StoreManagerSubscriptionStatusDidChangeNotification = @"StoreMan
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchased:
- NSLog(@"Purchase successful!");
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
// After a successful purchase, verify the subscription status
[self verifySubscriptionWithCompletion:^(BOOL isActive, NSDate *expiryDate) {
@@ -94,12 +73,10 @@ NSString *const StoreManagerSubscriptionStatusDidChangeNotification = @"StoreMan
break;
case SKPaymentTransactionStateFailed:
- NSLog(@"Purchase failed: %@", transaction.error.localizedDescription);
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
break;
case SKPaymentTransactionStateRestored:
- NSLog(@"Purchase restored.");
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
// After restoring purchases, verify the subscription status
[self verifySubscriptionWithCompletion:^(BOOL isActive, NSDate *expiryDate) {
@@ -119,22 +96,17 @@ NSString *const StoreManagerSubscriptionStatusDidChangeNotification = @"StoreMan
- (void)verifySubscriptionWithCompletion:(void (^)(BOOL isActive, NSDate *expiryDate))completion {
static BOOL isRequestInProgress = NO;
- if (isRequestInProgress) {
- NSLog(@"🛑 Subscription verification already in progress. Skipping duplicate request.");
- return;
- }
+ if (isRequestInProgress) return;
isRequestInProgress = YES; // Mark request as in progress
NSString *storedReceipt = [[NSUserDefaults standardUserDefaults] stringForKey:@"subscriptionReceipt"];
if (!storedReceipt) {
- NSLog(@"🔄 Fetching new receipt from App Store.");
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData *receiptData = [NSData dataWithContentsOfURL:receiptURL];
if (!receiptData) {
- NSLog(@"No receipt found. User may not have purchased any subscriptions.");
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"isSubscribed"];
[[NSUserDefaults standardUserDefaults] synchronize];
isRequestInProgress = NO; // Reset flag
@@ -153,7 +125,6 @@ NSString *const StoreManagerSubscriptionStatusDidChangeNotification = @"StoreMan
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:requestDict options:0 error:&error];
if (error) {
- NSLog(@"JSON serialization error: %@", error.localizedDescription);
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"isSubscribed"];
[[NSUserDefaults standardUserDefaults] synchronize];
isRequestInProgress = NO; // Reset flag
@@ -164,11 +135,10 @@ NSString *const StoreManagerSubscriptionStatusDidChangeNotification = @"StoreMan
[FileServer performPostRequestWithURL:@"https://rors.ai/verify_receipt"
method:@"POST"
contentType:@"application/json"
- body:jsonData // Assuming jsonData is already an NSData object
+ body:jsonData
completionHandler:^(NSData *data, NSHTTPURLResponse *response, NSError *error) {
isRequestInProgress = NO;
if (error) {
- NSLog(@"Error verifying receipt: %@", error.localizedDescription);
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"isSubscribed"];
[[NSUserDefaults standardUserDefaults] synchronize];
completion(NO, nil);
@@ -176,7 +146,6 @@ NSString *const StoreManagerSubscriptionStatusDidChangeNotification = @"StoreMan
}
NSDictionary *jsonResponse = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
if (!jsonResponse || ![jsonResponse isKindOfClass:[NSDictionary class]]) {
- NSLog(@"Invalid response from server.");
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"isSubscribed"];
[[NSUserDefaults standardUserDefaults] synchronize];
completion(NO, nil);
@@ -188,13 +157,10 @@ NSString *const StoreManagerSubscriptionStatusDidChangeNotification = @"StoreMan
if (sessionToken && [sessionToken isKindOfClass:[NSString class]]) {
[self storeSessionTokenInKeychain:sessionToken];
[[NSUserDefaults standardUserDefaults] setObject:[NSDate dateWithTimeIntervalSinceNow:45 * 60] forKey:@"expiry"];
- } else {
- NSLog(@"Warning: No valid session_token in response.");
}
[[NSNotificationCenter defaultCenter] postNotificationName:StoreManagerSubscriptionStatusDidChangeNotification object:nil];
} else {
[self clearSessionTokenFromKeychain];
- NSLog(@"🚨 Subscription has expired.");
}
[[NSUserDefaults standardUserDefaults] setBool:isSubscribed forKey:@"isSubscribed"];
[[NSUserDefaults standardUserDefaults] synchronize];
@@ -213,12 +179,8 @@ NSString *const StoreManagerSubscriptionStatusDidChangeNotification = @"StoreMan
// Delete any existing token first
SecItemDelete((__bridge CFDictionaryRef)query);
-
// Add the new token
OSStatus status = SecItemAdd((__bridge CFDictionaryRef)query, NULL);
- if (status != errSecSuccess) {
- NSLog(@"Failed to store session token in Keychain: %d", (int)status);
- }
}
- (void)clearSessionTokenFromKeychain {
diff --git a/clearcam/ViewController.m b/clearcam/ViewController.m
index 61fdc0c..31b8366 100644
--- a/clearcam/ViewController.m
+++ b/clearcam/ViewController.m
@@ -164,18 +164,12 @@ NSMutableDictionary *classColorMap;
if ([self.captureSession canSetSessionPreset:presetString]) {
self.captureSession.sessionPreset = presetString;
- } else {
- NSLog(@"Unsupported preset: %@", presetString);
- return;
- }
+ } else return;
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSError *error = nil;
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error];
- if (!input) {
- NSLog(@"Error setting up camera input: %@", error.localizedDescription);
- return;
- }
+ if (!input) return;
[self.captureSession addInput:input];
AVCaptureVideoDataOutput *output = [[AVCaptureVideoDataOutput alloc] init];
@@ -233,19 +227,12 @@ NSMutableDictionary *classColorMap;
NSError *error = nil;
if (![[NSFileManager defaultManager] fileExistsAtPath:dayFolderURL.path]) {
[[NSFileManager defaultManager] createDirectoryAtURL:dayFolderURL withIntermediateDirectories:YES attributes:nil error:&error];
- if (error) {
- NSLog(@"Error creating day folder: %@", error.localizedDescription);
- return;
- }
+ if (error) return;
}
NSURL *outputURL = [dayFolderURL URLByAppendingPathComponent:[NSString stringWithFormat:@"output_%@.mp4", finalTimestamp]];
self.assetWriter = [AVAssetWriter assetWriterWithURL:outputURL fileType:AVFileTypeMPEG4 error:&error];
- if (error) {
- NSLog(@"Error creating asset writer: %@", error.localizedDescription);
- return;
- }
-
+ if (error) return;
// Check if the device supports HEVC encoding
NSDictionary *videoSettings;
videoSettings = @{
@@ -286,7 +273,6 @@ NSMutableDictionary *classColorMap;
if ([self.assetWriter canAddInput:self.videoWriterInput]) {
[self.assetWriter addInput:self.videoWriterInput];
} else {
- NSLog(@"Cannot add video writer input");
return;
}
@@ -295,10 +281,7 @@ NSMutableDictionary *classColorMap;
self.isRecording = YES;
[self.assetWriter startWriting];
[self.assetWriter startSessionAtSourceTime:kCMTimeZero];
- if(![self ensureFreeDiskSpace]) {
- [self stopRecording];
- NSLog(@"no space, recording stopped. Delete some stuff");
- }
+ if(![self ensureFreeDiskSpace]) [self stopRecording];
}
@@ -592,21 +575,14 @@ NSMutableDictionary *classColorMap;
}
- (void)stopRecording {
- if (!(self.isRecording && self.assetWriter.status == AVAssetWriterStatusWriting)) {
- NSLog(@"Cannot finish writing. Asset writer status: %ld", (long)self.assetWriter.status);
- return;
- }
-
+ if (!(self.isRecording && self.assetWriter.status == AVAssetWriterStatusWriting)) return;
self.isRecording = NO;
[self.videoWriterInput markAsFinished];
}
- (void)finishRecording {
- if (!(self.isRecording && self.assetWriter.status == AVAssetWriterStatusWriting)) {
- NSLog(@"Cannot finish writing. Asset writer status: %ld", (long)self.assetWriter.status);
- return;
- }
+ if (!(self.isRecording && self.assetWriter.status == AVAssetWriterStatusWriting)) return;
NSString *segmentsDirectory = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:self.dayFolderName];
[[NSFileManager defaultManager] createDirectoryAtPath:segmentsDirectory withIntermediateDirectories:YES attributes:nil error:nil];
@@ -641,8 +617,6 @@ NSMutableDictionary *classColorMap;
if (![self.fileServer.context save:&parentError]) {
NSLog(@"Failed to save parent context: %@", parentError.localizedDescription);
}
- } else {
- NSLog(@"Failed to save segment: %@", error.localizedDescription);
}
// Create a local copy of current_segment_squares, moved to after file save
@@ -660,10 +634,7 @@ NSMutableDictionary *classColorMap;
NSArray *fetchedDays = [self.backgroundContext executeFetchRequest:fetchRequest error:&error];
NSManagedObject *dayEntity;
- if (error) {
- NSLog(@"Failed to fetch DayEntity: %@", error.localizedDescription);
- return;
- }
+ if (error) return;
if (fetchedDays.count > 0) {
dayEntity = fetchedDays.firstObject;
@@ -723,7 +694,6 @@ NSMutableDictionary *classColorMap;
if (!error) {
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
} else {
- NSLog(@"Error converting dictionary to JSON string: %@", error.localizedDescription);
return nil;
}
}
@@ -732,10 +702,7 @@ NSMutableDictionary *classColorMap;
NSError *error = nil;
NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:&error];
- if (error) {
- NSLog(@"Error retrieving file system info: %@", error.localizedDescription);
- return 0;
- }
+ if (error) return 0;
uint64_t freeSpace = [[attributes objectForKey:NSFileSystemFreeSize] unsignedLongLongValue];
return freeSpace;
@@ -755,13 +722,9 @@ NSMutableDictionary *classColorMap;
NSError *fetchError = nil;
NSArray *dayEntities = [self.fileServer.context executeFetchRequest:fetchRequest error:&fetchError];
- if (fetchError) {
- NSLog(@"Failed to fetch DayEntity objects: %@", fetchError.localizedDescription);
- return YES;
- }
+ if (fetchError) return YES;
if (dayEntities.count == 0 || lastDeletedDayIndex >= dayEntities.count) {
- NSLog(@"No more DayEntities available. Resetting deletion indexes.");
[defaults removeObjectForKey:@"LastDeletedDayIndex"];
[defaults removeObjectForKey:@"LastDeletedSegmentIndex"];
[defaults synchronize];
@@ -770,10 +733,6 @@ NSMutableDictionary *classColorMap;
// Fetch event timestamps from Core Data
NSArray *eventDataArray = [self.fileServer fetchEventDataFromCoreData:self.fileServer.context];
- if (!eventDataArray || eventDataArray.count == 0) {
- NSLog(@"No event timestamps found.");
- }
-
NSMutableArray<NSNumber *> *eventTimestamps = [NSMutableArray array];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
@@ -855,12 +814,8 @@ NSMutableDictionary *classColorMap;
[defaults setInteger:lastDeletedSegmentIndex forKey:@"LastDeletedSegmentIndex"];
[defaults synchronize];
return YES;
- } else {
- NSLog(@"Failed to save context after deletion: %@", saveError.localizedDescription);
}
}
- } else {
- NSLog(@"Failed to delete file %@: %@", segmentURL, deleteError.localizedDescription);
}
}
} @catch (NSException *exception) {
@@ -874,8 +829,6 @@ NSMutableDictionary *classColorMap;
[defaults setInteger:dayIndex forKey:@"LastDeletedDayIndex"];
[defaults setInteger:lastDeletedSegmentIndex forKey:@"LastDeletedSegmentIndex"];
[defaults synchronize];
- } else {
- NSLog(@"Failed to save context: %@", saveError.localizedDescription);
}
// Reset segment index for the next day
@@ -884,7 +837,6 @@ NSMutableDictionary *classColorMap;
// If nothing was deleted, reset the indexes
if (!deletedFile) {
- NSLog(@"No more files to delete but still low on space! Resetting deletion indexes.");
[defaults removeObjectForKey:@"LastDeletedDayIndex"];
[defaults removeObjectForKey:@"LastDeletedSegmentIndex"];
[defaults synchronize];
@@ -895,7 +847,6 @@ NSMutableDictionary *classColorMap;
NSLog(@"Exception in ensureFreeDiskSpace: %@", exception.reason);
return YES;
}
- //NSLog(@"Free space = %f MB", (double)[[[[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:nil] objectForKey:NSFileSystemFreeSize] unsignedLongLongValue] / (1024.0 * 1024.0));
return YES;
}
diff --git a/clearcam/Yolo.m b/clearcam/Yolo.m
index 3a05086..bd34cd1 100644
--- a/clearcam/Yolo.m
+++ b/clearcam/Yolo.m
@@ -253,10 +253,7 @@ UInt8 *rgbData;
- (NSArray *)yolo_infer:(CGImageRef)cgImage withOrientation:(AVCaptureVideoOrientation)orientation {
CFDataRef rawData = CGDataProviderCopyData(CGImageGetDataProvider(cgImage));
- if (!rawData) {
- NSLog(@"Failed to get raw image data");
- return nil;
- }
+ if (!rawData) return nil;
const UInt8 *rawBytes = CFDataGetBytePtr(rawData);
size_t length = CFDataGetLength(rawData);
@@ -289,26 +286,16 @@ UInt8 *rgbData;
CFRelease(rawData);
id<MTLBuffer> buffer = self.buffers[self.input_buffer];
- if (!buffer || !buffer.contents) {
- NSLog(@"Metal buffer is not initialized or invalid");
- return nil;
- }
+ if (!buffer || !buffer.contents) return nil;
memset(buffer.contents, 0, buffer.length);
memcpy(buffer.contents, self.rgbData, MIN(buffer.length, width * width * 3));
for (NSMutableDictionary *values in self._q) {
id<MTLCommandBuffer> commandBuffer = [self.mtl_queue commandBuffer];
- if (!commandBuffer) {
- NSLog(@"Failed to create Metal command buffer");
- continue;
- }
-
+ if (!commandBuffer) continue;
id<MTLComputeCommandEncoder> encoder = [commandBuffer computeCommandEncoder];
- if (!encoder) {
- NSLog(@"Failed to create compute command encoder");
- continue;
- }
+ if (!encoder) continue;
[encoder setComputePipelineState:self.pipeline_states[@[values[@"name"][0], values[@"datahash"][0]]]]; //ignore warning
for (int i = 0; i < [(NSArray *)values[@"bufs"] count]; i++) {
@@ -333,17 +320,11 @@ UInt8 *rgbData;
[self.mtl_buffers_in_flight removeAllObjects];
buffer = self.buffers[self.output_buffer];
- if (!buffer || !buffer.contents) {
- NSLog(@"Output buffer is invalid");
- return nil;
- }
+ if (!buffer || !buffer.contents) return nil;
const void *bufferPointer = buffer.contents;
float *floatArray = malloc(buffer.length);
- if (!floatArray) {
- NSLog(@"Memory allocation failed for output array");
- return nil;
- }
+ if (!floatArray) return nil;
memcpy(floatArray, bufferPointer, buffer.length);
NSArray *output = [self processOutput:floatArray];