Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / September 2007



Tip: Looking for answers? Try searching our database.

Read plist from Carbon

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrei Korostelev - 27 Sep 2007 13:45 GMT
Hi folks,

Is it a way to read a plist file from the Carbon app, that is using
Carbon API and maybe lower-level API, but not Cocoa API?

To be specific I need to know the default browser. I det retrieve this
info from ~/Library/com.apple.LaunchServices.plist file. The problem
is that this file is in a binary format, not in xml.

What I can think of now is to convert this file to xml format with
'plutil' utility and then parse, however such a silution looks rather
clumsy to me. Any hints?

Mac OS X 10.4
Michael Ash - 27 Sep 2007 14:29 GMT
> Hi folks,
>
[quoted text clipped - 8 lines]
> 'plutil' utility and then parse, however such a silution looks rather
> clumsy to me. Any hints?

http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFPropertyLists/

Signature

Michael Ash
Rogue Amoeba Software

Andrei Korostelev - 27 Sep 2007 19:20 GMT
> > Hi folks,
>
[quoted text clipped - 14 lines]
> Michael Ash
> Rogue Amoeba Software

Thanks Michael, this is what I need.
Michael Fielitz - 27 Sep 2007 14:59 GMT
> Hi folks,
>
[quoted text clipped - 10 lines]
>
> Mac OS X 10.4

Core Foundation Carbon
#  import <CoreFoundation/CFPreferences.h>
Michael Ash - 27 Sep 2007 15:01 GMT
> Core Foundation Carbon
> #  import <CoreFoundation/CFPreferences.h>

Yeah, that makes a lot more sense than my link. Mine will let you parse
the file but it's not the right API for reading something in
Library/Preferences. I wasn't quite paying attention to the part where he
specified which file he wanted to read.

Signature

Michael Ash
Rogue Amoeba Software

Michael Fielitz - 27 Sep 2007 15:03 GMT
> Core Foundation Carbon
> #  import <CoreFoundation/CFPreferences.h>

oops, I mistakenly hit the send button...

Anyway, maybe it is also possible to access the System Settings with the
System Configuration Framework (though I am not really sure).

Michael
Jolly Roger - 27 Sep 2007 19:04 GMT
>> Hi folks,
>>
[quoted text clipped - 11 lines]
> Core Foundation Carbon
> #  import <CoreFoundation/CFPreferences.h>

Exactly.  <http://tinyurl.com/29tjzr>

Signature

Please let me know if you send email to this address so that I can be
sure your email doesn't get eaten by pobox.com's ultra-aggressive SPAM
filter.

Help improve usenet. Kill-file Google Groups:
http://improve-usenet.org/

JR

Reinder Verlinde - 27 Sep 2007 19:09 GMT
> Hi folks,
>
[quoted text clipped - 8 lines]
> 'plutil' utility and then parse, however such a silution looks rather
> clumsy to me. Any hints?

Do you really "need to know the default browser", or do you need to open
an item using the default browser, and are you thinking that "to know
the default browser" is a necessary first step?

<http://developer.apple.com/documentation/Carbon/Conceptual/LaunchService
sConcepts/LSCTasks/chapter_3_section_1.html> contains links to answers
to both questions. In short:

- to open an item using the default browser, use LSOpenFromRefSpec,
LSOpenCFURLRef, or LSOpenFromURLSpec.

- to determine the preferred application for an item, use
LSGetApplicationForItem, LSGetApplicationForURL, or
LSCopyApplicationForMIMEType.

Neither of these involves reading a .plist yourself.

Reinder
Andrei Korostelev - 27 Sep 2007 19:29 GMT
> In article <1190897141.095758.241...@d55g2000hsg.googlegroups.com>,
>
[quoted text clipped - 29 lines]
>
> Reinder

Thanx, this gets the things even easier.
Michael Ash - 27 Sep 2007 20:52 GMT
>> Neither of these involves reading a .plist yourself.
>
> Thanx, this gets the things even easier.

A beautiful example of why you should always ask about your overarching
goal when you post these things.

It does no harm to ask the specific question *as well*, but you should
always put it into context. For example, "I'm trying to open an URL in the
default browser. I thought I'd be able to read the default browser out of
whatever.plist and then tell it to open the URL, but it's binary and I
can't figure out how to read it with Carbon. How can I read this file, or
is there a better way to open an URL in the default browser?" This saves
everyone a lot of time, and gives you better code when you're not so lucky
to have people deduce your true intentions.

Signature

Michael Ash
Rogue Amoeba Software

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.