Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Anyone know how to access user profiles (icons) on OS X from Java?



Russell Miles wrote:

>I'm trying to write a simple app that shows a list of current users as one
>of its functions and it would be great if I could link this in so that it
>picks up user icons as set in the users section of System Preferences.
>Anyone have any clue how this can be done from Java?

The user information is in the NetInfo database.  It's normally managed by
the app:
  /Applications/Utilities/NetInfo Manager

There are also commands you can run: niutil, nireport, nidump.

The niutil command has two sub-commands of direct interest: -list and -read.

You exec() the command-line in Java and then read the result from the
Process's input-stream.  Always use the String[] forms of exec(), never the
stupider and more blunder-prone single-String forms.

For example, for a user-name of "me":
  niutil -read . /users/me

The picture is listed as the property whose line begins with "picture:".
It's convenient that a java.util.Properties will read this format directly,
though it might become dazed and confused if there are any #'s, !'s, or \'s
in the stream.

To list all the user-names (short account names):
  niutil -list . /users

For reference, see 'man niutil' and the API docs for Properties, etc.  To
decode TIFF files, which many user-pictures will be, choose a library here:
  <http://www.geocities.com/marcoschmidt.geo/java-image-coding.html>

  -- GG


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.