Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Thu Nov 21, 2019 4:35 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: subclass folderitem for sandboxing
PostPosted: Thu Feb 14, 2013 5:56 pm 
Offline

Joined: Tue Aug 07, 2012 9:46 pm
Posts: 26
What would it take to subclass folder item so that it better reports out. With sandboxing my biggest headache is with folderitems and if something goes wrong it only reports to the console, so most users aren't any help to find out what happened. Any ideas or other routes?

Luke


Top
 Profile  
Reply with quote  
 Post subject: Re: subclass folderitem for sandboxing
PostPosted: Thu Feb 14, 2013 7:04 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
I don't believe folderitem is a subclassable object....

But I'm confused as to what you mean by "it only reports to the console"

You have full control over examining folderitem results and reporting them as appropriate.

Can you provide an example of what your are doing where this is not the case????

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: subclass folderitem for sandboxing
PostPosted: Thu Feb 14, 2013 9:15 pm 
Offline

Joined: Tue Aug 07, 2012 9:46 pm
Posts: 26
It is more just being lazy and not wanting to add a bunch more checks. It is a lot of code that has worked for a long time, just the sandboxing throwing kinks.

What I want to do is have folderitem report errors and such in more detail to a log file. So to be able to globally report folderitem errors, rather than have to add code to all folderitems.

It doesn't look to subclass like other items. Any other ideas?


Top
 Profile  
Reply with quote  
 Post subject: Re: subclass folderitem for sandboxing
PostPosted: Thu Feb 14, 2013 9:22 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
What kind of errors are you talking?

It is NIL (bad path), or NOT exists..... I can't think of an actual ERROR that a folderitem ever "raises"

Why not just create a global method and pass the folderitem in, and let that method analyze it?


check_my_folderitem(f)

or MAYBE (and I have not tried this)... you can look into the EXTENDS feature

SUB check_it(extends folderitem)
....stuff..
END SUB


f.check_it

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: subclass folderitem for sandboxing
PostPosted: Thu Feb 14, 2013 10:14 pm 
Offline

Joined: Tue Aug 07, 2012 9:46 pm
Posts: 26
I had briefly looked at extends. Most of the time I think it is permission denied, which throws strange errors.


Top
 Profile  
Reply with quote  
 Post subject: Re: subclass folderitem for sandboxing
PostPosted: Fri Feb 15, 2013 8:34 am 
Offline
User avatar

Joined: Thu Sep 10, 2009 2:50 am
Posts: 418
Location: Santa Cruz, CA, USA
You can also create your own class (not a subclass) and use Operator_Convert to send it where FolderItem is expected. Then you can design the interface exactly how you like.
Class EZFile

Protected refFile As FolderItem

Sub Operator_Convert(rhs As FolderItem)
refFile = rhs
End Sub

Function Operator_Convert() As FolderItem
return refFile
End Function

//use this if you don't expose all of folderitem
Function realFile() As FolderItem
return refFile
End Function

//expose some or all of folderitem
Function exists() As boolean
if refFile = nil then return false
return refFile.Exists
End Function

//add utility methods
Function extension() As String
//...
End Function

End Class

It appears to work like a Folderitem...
dim f As EZFile = GetOpenFolderItem("")
if f <> nil and f.exists then
if f.extension = "txt" then
f.realFile.CopyFileTo(SpecialFolder.Desktop)
end
end

dim f2 As new FolderItem(f)

Not sure if it's 100% interoperable, I'm new to Oparator_Convert and maybe there's edge cases to look out for.


Top
 Profile  
Reply with quote  
 Post subject: Re: subclass folderitem for sandboxing
PostPosted: Sat Feb 16, 2013 9:48 pm 
Offline
User avatar

Joined: Fri Sep 30, 2005 11:00 am
Posts: 583
Location: Beautiful Taiwan
If the user hasn't granted your application permission to read or write to locations (except some specific locations) then you will get denied.

By default your application can access anything in it's application container and can read anything in the application bundle, although trying to make a bookmark reference to anything in your application bundle, will only confuse the App Store Reviewers and you'll then need to appeal to get the application approved.

I suspect you may need to change your application or add special entitlements, where are you trying to access?

_________________
Sam Rowlands
rMBP 15" @ 10.8 & '08 MBA 13" @ 10.6 + 10.7, RB2012
http://www.ohanaware.com/
AppWrapper - Prepare Apps for Mac App Store & OS X 10.8 - http://www.ohanaware.com/appwrapper/


Top
 Profile  
Reply with quote  
 Post subject: Re: subclass folderitem for sandboxing
PostPosted: Sat Feb 16, 2013 11:29 pm 
Offline

Joined: Tue Aug 07, 2012 9:46 pm
Posts: 26
I found my bug, but I don't think I have designed code to handle permission issues well (just usually not an issue). Trying to find a cleaner solution to help with sandboxing.


Top
 Profile  
Reply with quote  
 Post subject: Re: subclass folderitem for sandboxing
PostPosted: Sun Feb 17, 2013 12:04 am 
Offline
User avatar

Joined: Fri Sep 30, 2005 11:00 am
Posts: 583
Location: Beautiful Taiwan
lajdesign wrote:
I found my bug, but I don't think I have designed code to handle permission issues well (just usually not an issue). Trying to find a cleaner solution to help with sandboxing.

Indeed under later version of the Mac OS X and now with Sandboxing, permissions have become more of an issue for us developers. It does mean that when opening and saving files your app must handle potential errors much more elegantly.

_________________
Sam Rowlands
rMBP 15" @ 10.8 & '08 MBA 13" @ 10.6 + 10.7, RB2012
http://www.ohanaware.com/
AppWrapper - Prepare Apps for Mac App Store & OS X 10.8 - http://www.ohanaware.com/appwrapper/


Top
 Profile  
Reply with quote  
 Post subject: Re: subclass folderitem for sandboxing
PostPosted: Sun Feb 17, 2013 10:34 am 
Offline

Joined: Tue Aug 07, 2012 9:46 pm
Posts: 26
That is my problem. Normally I just check for nil and exists. I guess I need to look at lastError. What else are others looking at?


Top
 Profile  
Reply with quote  
 Post subject: Re: subclass folderitem for sandboxing
PostPosted: Sun Feb 17, 2013 8:53 pm 
Offline
User avatar

Joined: Fri Sep 30, 2005 11:00 am
Posts: 583
Location: Beautiful Taiwan
lajdesign wrote:
That is my problem. Normally I just check for nil and exists. I guess I need to look at lastError. What else are others looking at?


It depends on the action, if I'm reading a file, I check to make sure it exists and isReadable. If I'm writing a file, check to see if it's writable or locked. This should cover most bases, providing you're following the Sandbox rules, getting these kind of errors generally indicates that the user doesn't have permission to read or write.

_________________
Sam Rowlands
rMBP 15" @ 10.8 & '08 MBA 13" @ 10.6 + 10.7, RB2012
http://www.ohanaware.com/
AppWrapper - Prepare Apps for Mac App Store & OS X 10.8 - http://www.ohanaware.com/appwrapper/


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group