RUMlogNG will not save preferences.

RUMlog, the Next Generation. Completely rewritten.
User avatar
DL2RUM
Administrator
Posts: 2945
Joined: Mon 27. Aug 2007, 13:36
Location: JO40DF

Re: RUMlogNG will not save preferences.

Unread post by DL2RUM »

Charles, you started always with Menu–>Logbook–>New with RUMlog Classic file ?
What is happening when you create an empty log file using Menu–>Logbook–>New?
73 and best dx de Tom, DL2RUM
k4zrj
Posts: 27
Joined: Fri 14. Jan 2011, 04:36
Location: EM74rc, Woodstock, GA, USA

Re: RUMlogNG will not save preferences.

Unread post by k4zrj »

When starting with a new, empty log, same results. Same errors generated.

3/2/15 18:04:34.000 kernel[0]: Sandbox: RUMlogNG(3765) deny file-read-data /Users/charlesjohnson/Documents/K4ZRJ.rlog
3/2/15 18:04:34.087 RUMlogNG[3765]: Error saving Logfile URL: The file “K4ZRJ.rlog” couldn’t be opened.
3/2/15 18:04:34.490 RUMlogNG[3765]: view service marshal for <NSRemoteView: 0x7fe530489a60> failed to forget accessibility connection due to Error Domain=NSCocoaErrorDomain Code=4099 "Couldn’t communicate with a helper application." (The connection was invalidated from this process.) UserInfo=0x60800066a400 {NSDebugDescription=The connection was invalidated from this process.}
timestamp: 23:04:34.489 Monday 02 March 2015
process/thread/queue: RUMlogNG (3765) / 0x103dce000 / com.apple.NSXPCConnection.user.endpoint
code: line 2972 of /SourceCache/ViewBridge/ViewBridge-46.2/NSRemoteView.m in __57-[NSRemoteView viewServiceMarshalProxy:withErrorHandler:]_block_invoke
domain: communications-failure

This happens when I manually open the log.

73, Charles, K4ZRJ
User avatar
DL2RUM
Administrator
Posts: 2945
Joined: Mon 27. Aug 2007, 13:36
Location: JO40DF

Re: RUMlogNG will not save preferences.

Unread post by DL2RUM »

Do you have tried another file name? Okay, this is to simple, but I'm running out of ideas.
73 and best dx de Tom, DL2RUM
k4zrj
Posts: 27
Joined: Fri 14. Jan 2011, 04:36
Location: EM74rc, Woodstock, GA, USA

Re: RUMlogNG will not save preferences.

Unread post by k4zrj »

Changing to a different file name makes no difference.

The issue involves sandboxing. The console messages I've sent show what the issue is.

Which OS are you developing on and which SDK and which version of Xcode?

Maybe if we could get the platforms equal, we could figure out what's wrong. You have the source and the project, I don't, so I can't help analyze console errors with out it.

73, Charles, K4ZRJ
User avatar
DL2RUM
Administrator
Posts: 2945
Joined: Mon 27. Aug 2007, 13:36
Location: JO40DF

Re: RUMlogNG will not save preferences.

Unread post by DL2RUM »

After you created a new file, is the new file really on your disk?
What happens when you open this file using Menu-->Logbook-->Open?


Here the whole code for the menu action Menu-->Logbook-->New Any ideas?

Code: Select all

- (IBAction)menuLogNew:(NSMenuItem *)sender {
    NSSavePanel* panel = [NSSavePanel savePanel];
    [panel setTitle:NSLocalizedString(@"Select the location and a logbook filename", nil)];
    [panel setCanCreateDirectories:YES];
    [panel setCanSelectHiddenExtension:NO];
    [panel setAllowedFileTypes:@[@"rlog"]];
    [panel setTreatsFilePackagesAsDirectories:NO];
    [panel beginWithCompletionHandler:^(NSInteger resultPanel) {
        if (resultPanel == NSFileHandlingPanelOKButton) {
            NSURL* saveURL = [panel URL];
            NSFileManager* fileManager = [NSFileManager defaultManager];
            NSString* pathFromApp = [[NSBundle mainBundle] pathForResource:@"EmptyLog" ofType:@"rlog"];
            NSError* error;
            [fileManager copyItemAtPath:pathFromApp toPath:saveURL.path error:&error];
            if (error) {
                NSAlert* al = [[NSAlert alloc] init];
                al.alertStyle = NSWarningAlertStyle;
                al.messageText = NSLocalizedString(@"Can't create new logfile:",Nil);
                al.informativeText = error.localizedDescription;
                [al runModal];
            } else {
                NSUserDefaults* prefs = [NSUserDefaults standardUserDefaults];
                error = nil;
                NSData* bookmarkData = [[panel URL] bookmarkDataWithOptions:NSURLBookmarkCreationWithSecurityScope includingResourceValuesForKeys:nil relativeToURL:nil error:&error];
                if (!error) {
                    [prefs setObject:bookmarkData forKey:@"LogFileUrlStringSecured"];
                    [prefs synchronize];
                } else  {
                    NSLog(@"Error saving Logfile URL: %@ ",error.localizedDescription);
                }
            }
        } 
    }];
}
73 and best dx de Tom, DL2RUM
k4zrj
Posts: 27
Joined: Fri 14. Jan 2011, 04:36
Location: EM74rc, Woodstock, GA, USA

Re: RUMlogNG will not save preferences.

Unread post by k4zrj »

Tom,

I added your code to one of my projects and it compiles OK but I need your list of entitlements (the code fails to create the NSSavePanel).

73, Charles, K4ZRJ
k4zrj
Posts: 27
Joined: Fri 14. Jan 2011, 04:36
Location: EM74rc, Woodstock, GA, USA

Re: RUMlogNG will not save preferences.

Unread post by k4zrj »

Tom,

Please disregard previous post.

This code fails under sandboxing, but works if sandboxing is turned off. I had to make two small changes in order to get a clean compile in the app that I added the code to:

NSFileManager* fileManager = [NSFileManager defaultManager];
// NSString* pathFromApp = [[NSBundle mainBundle] pathForResource:@"EmptyLog" ofType:@"rlog"];
NSError* error;
// [fileManager copyItemAtPath:pathFromApp toPath:saveURL.path error:&error];
[fileManager copyItemAtPath:@"/Users/charlesbjohnson/Documents/K4ZRJ.rlog" toPath:saveURL.path error:&error];


I am no expert on sandboxing, so I can't say why it fails for me and apparently not for other people, but tracing the code shows an error -503 when fileManager is called to do the copy. However, when I run your app and select a new log, it does create the empty rlog file in the correct folder. However, the app can't reopen it.

73, Charles, K4ZRJ
User avatar
DL2RUM
Administrator
Posts: 2945
Joined: Mon 27. Aug 2007, 13:36
Location: JO40DF

Re: RUMlogNG will not save preferences.

Unread post by DL2RUM »

I don't know what the problem is, but i found similar issues with other applications, even an Apple app. Same error messages. But nobody can explain it. Some ideas are:
  • Is any Anti Virus software running?
  • Parental Control activated?
  • Any system tools installed?
For any reason, the system don't allow you to read the files.

Can you test it on another user or guest account?
73 and best dx de Tom, DL2RUM
k4zrj
Posts: 27
Joined: Fri 14. Jan 2011, 04:36
Location: EM74rc, Woodstock, GA, USA

Re: RUMlogNG will not save preferences.

Unread post by k4zrj »

Tom,

All is well. Your code snippet works OK under sandboxing.

I copied the resource file EmptyLog.rlog from the package contents of your app and added it as a resource file in the bundle of my app and then executed your code without any changes under sandboxing. The new "empty" log file is created wherever I tell NSSavePanel to put it. No errors logged that relate to sandboxing.

So, the problem of not being able to reopen the log file is elsewhere in your code. What about the code that reads the container preferences and extracts "LogFileUrlStringSecured"?

Sandboxing normally forces a user to manually open files, but in the case where the app was closed with a sandboxed file open, it should automatically reopen the file. For some reason, this is not happening.

Sorry for the previous inaccurate reply. I had not tried to use your EmptyLog.rlog bundle file, but created my own and how I accessed it violated sandboxing.

I'll be glad to look at more code...

73, Charles, K4ZRJ
Post Reply