WWDC2003 Session 415
Transcript
Kind: captions
Language: en
data exchange so what do we mean by data
exchange as avi i mentioned we're
talking about in today's mac OS 10 and
and earlier mac OS some technologies
such as the scrap manager which we've
had since 1984 for doing data exchange
moving data between applications on the
clipboard a few years later we
introduced the drag manager which is
similar api many ways for moving data
between applications but through drag
gestures we're also talking today about
the translation manager which was also
introduced several years ago and
integrated into scrap and drag so that
translations can be performed somewhat
automatically when moving data between
applications and all of these
technologies are based on OS type data
identifiers for character data
identifiers and all of these
technologies have served us very well
we've made a lot of strides and user
interface in making it easy for users to
move their data between applications but
there are also some limitations some
problems that we would like to get past
going forward we have a lot of ideas for
enhancing the user experience and being
able to make classifications work
together more seamlessly and we were
bumping up against some problems one is
just that the scrap manager and the drag
manager although they have a lot in
common for marshaling a bunch of data
together to move to another application
their separate API and so if you want to
support the clipboard you do one thing
when you want to add drag and drop
support you have a whole other similar
API that you also have to adopt so kind
of double the work for you with Trent
with the translation manager it's kind
of a difficult API to use the model
isn't really quite what we want for data
translation it's handled based so it
doesn't really work with core foundation
collections and so on which make memory
management much easier
so translation just isn't isn't really
working quite right and then finally the
whole issue of type identification as i
said the carbon technologies tend to be
OS tight based coco uses strings and NS
and it's pasteboard use of strings for
data identifiers and then there's also
mine types coming in over the internet
there's filename extensions all these
different ways of identifying types and
there's a number of issues of that that
we'd like to resolve so what are the
solutions that we're going to be talking
about today first one is the carbon face
board this is a new technology new API
which is a complete replacement for the
scrap manager and also a replacement for
large pieces of the drag manager so it
unifies that data model for moving data
around between apps and then there's a
new API called translation services
which is integrated into the carbon
paste board and improves the translation
architecture to make it easier and
faster to work with when you're
developing your applications and
underneath those technology those
technologies that something we're
calling uniform type identifier which is
a new way to describe type information
and gives a very rich model for managing
type information and it's a foundation
both for translation and pasteboard as
well as future technologies that we're
hoping to introduce so since it's really
the foundation we're going to talk about
uniform type identifiers first and then
later on my colleague Brian Fisher will
come up and talk about carbon paste
boarding translation so in order to help
you kind of understand the concepts of
uniform type identification I want to
start with an example of I just picked
the type tip tip images how do we know
what a tiff images what is what's the
tip I'm not talking about what's the
format but how do we identify chips and
the first one you might see is the OS
type T iff
that's what a lot of carbon apps would
work with that they were putting TIFF
data on the scrap but there's also a
mime type so an image coming in or with
the internet would have the image / tip
mimetype there also happens to be a
filename extension dot t iff there's
another file name extension gif which
you have to reckon your app working with
tiff data or tip files has to also
recognize that filename extension and
then data put on the pasteboard by coco
applications would use a string and
asked if keyboard type so there's kind
of this whole cloud of type identifiers
and currently on Mac OS 10 in previous
Mac OS SE the only facility really for
tying these together at all was internet
config which was very internet oriented
and its API is also pretty fixed in
terms of the tight spaces that supports
for instance it doesn't understand
anything about and if pasteboard types
and so we were trying to think well we
really need a way to talk about types we
need applications to communicate about
type information by passing type
descriptors around we need type
information expressed in bundle property
lists and we want want it to be easy to
indicate what kinds of documents and
data your app can work with and so we
need a good descriptor for types and
these type spaces all have various
limitations OS types work great for the
ones that we're very familiar with but
we're pretty limited by four characters
they're not very descriptive and so if
you see some third-party OS type with
four characters there it's extremely
cryptic you have no idea what that data
type is and furthermore it's there's
really not really much collision
protection toro it and for new OS types
similarly corresponding expenses are
mess there's no collision protection is
all there well they're not a complete
mess but there are some some collisions
there
to file our filename extension meaning
two different things and although mine
types are a little bit better because
they have a registry in order to avoid
duplicate or reuse of a line type string
the registry turns out to be not used a
whole lot there's extensive use of the X
dash experimental space in line types
and if in in addition people will use
the mind types as very the Creator X
Dash mind type and and then later on
they might register the same mind type
without the X Dash and so there's
multiple mime types that actually mean
the same thing and so we kind of wanted
to normalize all of this and come up
with a name space that could tie all
these together and make sense of type
management on Mac OS 10 and in the
example here the identifiers that we're
talking about is public tip and this is
the uniform type of diner fire for the
tip data type and I like to think of
uniform type identifiers as the one true
name for it for the type on the system
and to use kind of a literary analogy
it's sort of the one name to one name to
rule them one name to find them one name
to bring them all and in the darkness
finds them because not only does the
uniform talk identifier identify the
chip type but it makes the API makes it
very easy to discover all of the other
type descriptors for this type and so
it's kind of the Nexus 4 type
description so what about that public
thing upfront well unlike mime types you
know from type of identifiers don't
actually they don't actually express any
sort of type hierarchy in the name so
the prefix on any type identifier is in
general a reverse dns name we're reusing
the reverse dns naming convention that
in use in several places on mac OS x
such as in bundle identifier so type
identifiers from that our proprietary or
associated with a particular
organization are prefixed with that
organizations reverse domain space
however there's a lot of types that
really aren't owned by any particular
organization and those go in the public
domain which is at this point controlled
by Apple I encourage you not to use the
public domain and let us put things into
the public domain now because of the
naming convention I mean you know from
taco ten car really is just a string and
and the format is a naming convention
that we're asking everyone to use if you
follow the naming convention you're
pretty much guaranteed and not conflict
with anybody else a and B it's a very
descriptive string for what the type is
it tells you not only at the end it
described can describe something about
the type but it indicates what
organization actually owns and defines
that type and so it gives you as a
developer when you see some uniform type
identifier coming at you from another
application you have an idea of where to
go to learn more about that type
throughout the rest of the talk we might
be referring to them as UTI uniform type
identifiers that's the abbreviation so
what are some examples in addition to
public tip another one is a little more
verbose public dot UTF plain text so
it's an example of a very descriptive
type you can pretty much look at that
and figure out what it is it's a Unicode
utf-16 encoded chunk of plain text in
fact this is the type that we encourage
everyone to start using with the carbon
paste board when you are sending plain
text to another application here's an
example picked a quick drop-kicked is
something that is specific to apple and
so we put it in the common space and
adobe might they they haven't done this
but just as an example they might for
photoshop documents use condotta dobie
PSP or they might use something more for
both like photoshop document
so in addition to describing identifying
types specifically there's something
else which the system has never done
before to model our understanding of
types that we all have as developers in
his users which is what else do we know
about a tiff as humans we know that it's
an image and we know that it's a chunk
of data and what the uniform type
identification system does is allow
types to exist in a conformance
hierarchy we can we can declare types as
conforming to super types so that even
if your app doesn't know anything about
a very specific type of you receive you
can discover that oh this type is
actually a form of text or it's a form
or it's an image and that example was
somewhat trivial but a somewhat more
interesting example is receiving
something that I'm not even going to
pronounce because every time I did
during rehearsals I sounded silly but
this is an example of something you have
no idea what it is and it arrives in
your application through a drag gesture
say and you would think you can't do
anything with it but if you happen to be
an XML parser you can say is this type
XML and it turns out it does conform to
XML or is it even generic text and you
can discover from by asking the system
that it does conform to text and so you
can actually work with this data even
though you don't know that complete
specifics of its format so in those last
few slides then I just outlined all the
major goals of uniform type identifiers
to tie together all the disparate type
identifiers spaces model conformance
between types enable extensibility
through new third party type
declarations without needing registry or
any sort of having to worry about
collisions and in support of all that
just provide a very simple lightweight
API which is a foundation for any
component or code that needs to do type
management so now I likely go back and
just go through the same concepts with a
little more deep
about some of the API behind this when
we talked about OS types and mime types
and extensions and NS pasteboard types
we needed a word to describe all of that
so we just kind of fix this one tags
what we have all that cloud of blue
identifies are all tags that are related
to a particular uniform type identifier
and each tag has a class the classes
indicates if it's an OS type or a
filename extension or a mime type etc
and the thing to remember about tags is
that it's not always a one-to-one
mapping usually there's a one-to-one
mapping but not always and so some cases
are complex you have to map multiple
filename extensions back to the same
uniform type identifier sometimes the
same extension or os os type may have a
collision in may map to two different
type identifiers so our API makes it
easy to deal with the common case of a
one-to-one mapping but it also allows
you to enumerate all the different
combinations so that you can discover
more complex type relationships so
here's here's that cloud again of types
and the API lets you easily map between
the tags around the outside and the one
true type identifier in the middle and
so that makes it very easy to go through
kind of a two-step translation where you
you get to the uniform type of inner
fire and then you want to know what the
tag is in another space and you can go
from there to the tag and this this is
actually used probably more heavily in
the system than you may have to use it
because we have to deal with co collapse
and filename extensions in in the file
dialogs and os types in the scrap
manager and we need to make all those
systems work together especially moving
between moving data between the NS
pasteboard and the scrap manager and so
we rely on this internally to do all of
our mapping between namespaces and how
do we do that very simple this is just a
trivial example of taking the OS type
jpg which is treated as
string in the API and you call UT type
create preferred identifier for tag you
passing the tag information you say that
it's an OS type tag and you get back the
type identifier 4.jpg which happens to
be public jpg then if you want to go to
the mime type for that you would just do
another it's another string operation UT
type copy preferred tag with class and
you say you want the mime type class and
you get back the string which is image /
jpg so it's a very simple mapping
process now on to the conformance model
and testing types for equality so this
is a just a simple hierarchy of type
identifiers we've got HTML and XML as
generic text types in an XML includes
combat Ethel dot property list on your
right and XHTML is a subtype of of XML
and let's say you're receiving some data
from another application and you there
it is you handle XML you're at some sort
of XML processor you want to find out if
the data is is XML you can ask does the
data that I'm receiving conform to xml
and if that if the type identifier that
you're receiving is XHTML or com Apple
plist or just plain XML then you get
back the answer yes this is data that I
can deal with in other contexts you
actually would you want to test for
specific equality of types of the type
information and we provide an API for
that which fundamentally uses a string
comparison to do the Equality but there
are cases where a string comparison
isn't enough here are those api's again
very simple just to input strings
returns a boolean and I wanted to say a
little bit more about why the equal why
the Equality test is there obviously to
do conformance testing you have to
result for resort to calling that so
that we can use the type information in
our database
to give you the right answer as for
equality well we do use the string
comparison internally to test equality
its case insensitive since these are
like DNS names UTIs are all case
insensitive but we also expect in the
future that you know as carefully as we
try to design the naming conventions for
types we're expecting that little warts
will happen there will be a type
identifier which is in somebody's or
some organizations domain and somebody
else will put it in the public domain or
Apple will want it in the public domain
and if you use this API to test for
conformance and equality will be able to
do things like declare to type
identifiers of synonyms and everyone
will just continue to work if you use
our API so I want to talk a little bit
about declaring new types and then why
go into the details but there are some
samples I can point you at so new type
identifiers are declared in bundle
property lists in your applications
bundle property lists in fact all of our
built-in identifiers are declared in the
currently anyway in the seed in system
icons bundle down in system library core
services so you can go there to find an
example it's very similar to though if
you're familiar with declaring document
types in your plist declaring the types
of documents you can open it's very
similar to that we've kind of taken that
idea and abstracted it out to just deal
with type information so that you can
declare in your pee list what your type
identifier is that you want to use and
what the equivalent tags are so you can
associate it with mine types and
filename extensions as well as what it
conforms to is it an image is it text or
something more specific and once you do
that and your app becomes registered on
the system we we add that type
information to our database and it's
available globally so that when you send
your data to another application with
your specific type of identifiers
to it that application can use our API
to discover things about your data the
last thing I want to say about it was
that there's actually two ways to
declare a type one is called exported
and one is imported it's a little subtle
but its necessary in general for any
type identify earth at you are giving
out to the world for your your data type
you export it from your property list
you make an exported declaration in for
in if you're using a built-in type such
as any of the public types then you can
rely on that always being declared in
the system because the OS guarantees
that it's there but sometimes your apps
might depend on some third-party types
that has been declared in oh say a
Microsoft Application you want to import
Word documents and Microsoft has
declared in their property with their
bundle Microsoft Word identifier and you
depend on that declaration and you
depend on the system knowing about that
UTI but you don't know if Microsoft Word
is installed on the system you're
running on in fact you probably hope it
isn't installed because you want to read
those files and provide services for
importing Microsoft Word documents so in
that case you can actually read eclair
Microsoft's definition or declaration of
their type and that's called importing
and you say i'm importing this type
declaration which really tells us that
you're not the definitive owner of that
type and if if word is installed or the
third party app is installed will use
their declaration but if you want to
ensure that a declaration is there then
you can use that style of importing so
that is really an overview I didn't I
didn't cover all the API as I said
there's there's additional functions for
dealing with ambiguities in mapping
between different types but and so it's
a conceptual overview and what are the
guidelines for working with these again
we provide tests especially when working
with pasteboard data and drag data you
want to use
those these new api's use uniform type
identifiers until you want to use the
conformance and equality test when
receiving data to find out if its data
that you can accept wherever possible
use the built-in types that we're
providing and when you do need to
declare new types just make sure you
pick an identifier that's in your
organization's domain space so that
you're guaranteed as long as you're your
own or because organization is
coordinating within itself you're
guaranteed to have a unique identifier
for your data this is all implemented as
essentially an extension of the launch
services database and so at this in the
seed anyway the API and extensive
commentary and documentation lives in
launch services H it's likely to get its
own header file before we go GM but
that's where you can look in the seed
for more information so that is the
foundation for tight management and this
brings us to Brian's part of the talk
where it will talk about how the carbon
pasteboard leverages type identification
all right thank you Chris Chris has just
played a great foundation for these two
new API with uniform type identification
now I'd like to introduce the carbon
paste board and translation services
which will leverage this foundation
first I want to talk about data exchange
today a little bit more as you meant as
Chris mentioned earlier we have separate
scrap and drag managers they do
basically the same thing you put
information on a scrap or drag in one
application you pull it off another
application this is a little redundant
this not only means that you have to pay
attention to two api's then you have to
do twice the work in your app if you
have twice the amount of code and these
involve different models the scrap
manager only has a single item drag
manager has multiple items the way that
you provide data or provide promises and
fulfill promises are different so you
don't have so it's really kind of a pain
to keep in mind which model year in also
as Chris mentioned there's a limited
typing mechanism they're both based on
OS type and you can have collisions you
need to contact apple and
make sure that you register your types
and this is difficult and something we
wanted to move away from and currently
there's pretty much non-existent
communication with Coco you might think
well I can copy and paste between Coco
and certainly they can communicate but
this is something that's handled by us
internally we only do it for a few
standard text and picture types and so
there's really no way for a an OS type
based API to communicate with a string
bass Coco API and the memory model is
fairly labor labor intensive what I mean
by this is that when you want to pull
information off of a scrap or drag you
have to ask for you asked how large the
information is and then once you have
that create your own memory then ask for
that member do this field be filled in
and then release that later so we wanted
to get away from each of these issues
now the solution to that is the carbon
pasteboard the carving paid sport is the
unification of the scrap and drag flavor
API so it's a complete replacement and
you can move away from them today the
carbon paste board supports copy and
paste drag-and-drop and services both
Apple menu services and translation
filter services which I'll get into
later we really like the model of having
multiple items each with their own set
of flavors that the drag manager has we
think this is very flexible and we
wanted to bring that forward and flavor
tape types are now based on uniform type
identifiers one great thing for for
scrap and drag means that because it's
based on UT is you can now communicate
with a netpage board type Coco types
will be added onto the page board you
know convert it into UTI and then you
can pull them off as uniform type
identifiers and then convert them into
any type you like using the ETI API and
the pasteboard carbon page for disc or
foundation based the pasteboard
reference itself is the core foundation
types and so you want to use the you
wanna release them after you've created
them but the entire throughout the API
is based on core foundations vlcc of
strings dictionaries and data alright
let's talk about the base type that
you'll be dealing with with baseboard
the page board
a page board reference is a proxy to a
global pasteboard resource you can have
multiple references a reference in
multiple applications to a single global
pasteboard that's kind of the point so
you can communicate between the two you
can have multiple references within a
single application so if you have
multiple objects within your application
each one of them could have a local page
for draft as the number of references on
the system within multiple applications
increases the rest count on the global
pasteboard resource increases and so as
each of the references are released to
CF release then the references on the
global page for release once the last
application has released its reference
the global page board memory goes away
now there are two exceptions of this
well which I'll mention in a moment now
that we know what a page flow references
how do you create it one well you can
call pasteboard create they're created
by name and there are three ways to do
this first its use to standard names
either k pasteboard clipboard or k
pasteboard find the clipboard is the
standard copy paste clipboard that
you're all used to and you can keep
using that for copy and paste operations
the sign pasteboard is relatively new we
brought this over this an idea from coco
if your if you've ever been in project
builder and you've performed a search
through your code maybe there's some
output you wanted to search for like you
know printf statement and then you can
go to terminal or console and perform
the same search without having the types
of text and again that's because as soon
as you execute the search in project
builder or now Xcode that information is
added to define pasteboard you go over
to lend me a flick one of the other
applications perform the same search
it'll read the information from the find
pasteboard this is one of my personal
favorite features I use it all the time
and I really hope you guys all take
advantage of it the second way to create
baseboard is to create a unique
baseboard you can pass either null to
baseboard create or the K pasteboard
unique constant and this is a way to
make sure that you're creating a
pasteboard that no one else has
referenced yet no one else has access to
it's completely new you can fill it up
with your own data and it's ready to go
the third way is to create a custom
baseboards so since they're created by
name we want to encourage that you use
a reverse dns scheme so you're not
running in anybody else's face boards so
this is the way if you have a suite of
applications or if you have the suite of
applications and you want to communicate
between all of them they can agree ahead
of time and what name they're going to
use making all references page the
single pasteboard perhaps you have a
multiple processor machining and you
have a series of separate apps that you
want to send marching instructions out
to if you continue to get on the face
board for instance
alright now that we've created a
pasteboard want to access that page
board to do certain operations with it
typically reading or writing the first
thing I'm going to talk about is reading
from the pasteboard before you want to
read from the pasteboard you want to
check out and see if any other
applications has modified it so you can
call pasteboard synchronize which
returns to the flag indicating whether
the page sport has been modified so if
you're some other applications in the
fronds lee the user has performed a copy
your applications been brought to the
front and you're curious as to whether
you want to enable paste or not you can
call pasteboard synchronize on the
clipboard the clipboard baseboard and
and it will return to the flags
indicating whether it's been modified or
not if it has then you can go ahead and
look at the pasteboard see if there any
tasty flavors on there if so go ahead
and enable your pace item paste when you
item now if you're going to write new
information to a page board you want to
make sure that you clear it first
clearing the page floor wipes out any
data that any other application has
written to it and makes your application
the owner so you are the only one who
can write to it at that time so the tool
to rules here are always think of
pasteboard for reading data from it and
always clear the pace forward before
writing to it all right there are two
branches I could take at this point
either writing or reading data I'm going
to take the reading data branch first so
when you're receiving items or when
you're receiving Gator from the
pasteboard page report has multiple
items and so you want to get the number
of items through pasteboard get item
count and then we access each of the
items through a unique identifier
doesn't matter what the identifier is it
could be you know one two three indices
or it could be a pointer to your memory
in your data in memory this is actually
very similar to the way drag manager
works today with multiple items so for
use to that model most of you should
have some grad code or copy and paste
code in your application so a lot of
this will look very familiar ok once
you've looked at the first item you can
enumerate the item you want to look at
all the flavors that are inside so
unlike the drag manager which required
you to not only iterate through each of
the items but then iterate for each of
the flavors will pass all the flavors to
you it wants from a single API
pasteboard copy Adam flavors it passes
back a core foundation array
each of the each of the types on the
page board are uniform type identifiers
so you'll want to make sure to use the
comparison routines especially when
you're when you're reading the data
especially conformant ask for the data
in a general way as possible if you're a
general text editor first you want to
ask it can I handle or is text available
on the pasteboard and then you could be
more specific after that if you like one
important thing to notice translations
are back with translation services and
the translation now translations are
always offered after the sender flavors
so ordering when the ordering is
important when pulling flavors off the
baseboard when you're done with the
flavor array you'll want to release it
okay now you've got a bunch of these
flavors but you want some more rich
metadata associated with these flavors
so you can grab the flavor flag to be a
pasteboard get item flavors like now
these are almost exactly the same set of
flags available in drag manager today
this is for compatibility with one
exception the there's a request only
flag now that behaves very similarly to
the sender only flag of yesterday it
behaves a little like having an unlisted
phone number so so somebody trolling
through the phone book can't find your
phone number but if you share it with
your friends then you can call each
other and so this is very nice if you
have a suite of applications and you
want to communicate between them but you
don't really want to announce certain
data types out to the world and so any
any flavor that you add to the
pasteboard that has a request only flag
set on it will not be advertised in the
previous API that returns all the
flavors on the pasteboard but if you
know that if you know the flavor name
you can go ahead and ask for it
explicitly and then get it flags and get
the data so this is a nice addition that
I think you'll appreciate ok once you've
looked at all the flavor flags you can
look at the flavors paid attention
they're ordering there's a rich amount
of information there that you want to
pay attention to but you've decided
you've got the flavor that's right for
you and you want to get that data a
single API you want we want to deal with
at this point is pasteboard copy items
flavor data again it's based on CS data
and so you'll want to release the memory
when you're done with it but now you
don't have to do when you okay
you don't have to ask how big the flavor
is very simple ok now let's back up a
little bit i mentioned that other two
branches we could take let's go down the
other branch where we can add
information to baseboard when you add
data first thing you want to do is add
data in your applications order of
preference in richness now that seems a
little odd you think you want to add it
in the order of richness seta a
receiving app would prefer but really
when you're initiating a drag or putting
information on the page board for a copy
there's no way to know what the receiver
is going to be and so you can't
anticipate what order they will want the
information in so the the best thing you
can do is indicate this by adding
information in your applications order
richness as justification saying you
might want to look at this item first in
order to add a promise you can pass null
as the data or the que pase Ford promise
data constant now this is very
convenient there's just one way to add
data one way to add promises there's no
longer two separate models between scrap
and drag once you add data you want to
fulfill this in a promise keeper so
keeping promises you all wait you you
have to install a promise keeper before
making promises the carbons pasteboard
make sure that you are able to fulfill
the promises that you add because it
wants to guarantee that receivers of
that information can get access to it in
order to keep the promise some
application has requested that your
promise be fulfilled and your pasteboard
promise keeper proc will be called back
you'll be given the pasteboard that the
promise was made on the item that was
made within and the flavor type being
requested and any contact information
that you've passed through so when the
promise we can be kept just called pace
flow put item flavor data as if you were
not making promise to begin with very
simple again it's just a single API for
adding data and fulfilling promises so
promises one cool thing here is that
promises are resolved when you release
your page for graph so if you have again
a plug-in architecture in each one of
your plugins has its own pasteboard
reference and they can each make
promises to the global pasteboard
independently of the others and so if
one plug-in is
brought in to memory it adds a promise
to the pace board but for some reason
it's going to be moved out you know
you're dropping that plug-in then when
it releases the pasteboard only its
promises will be explicitly called in
all the others will remain so this is a
great way to a lot of promises in a
plug-in architecture all right I
mentioned that this is a replacement for
the drag flavor API there are a couple
additions to the drag manager you can
see some header doc on them in drag th
in a tie toolbox you can use the
pasteboard with dragon in two ways
either create a drag and pull the
pasteboard out of it this is useful if
you're receiving a drag and you want to
use the pasteboard api then you can just
when you're given the dry graph pull the
pasteboard out of it or depending on
your the flow of your application if you
are using the same code to perform copy
paste and drag and drop maybe you have a
pasteboard that exists already and so
you can call new drag with spaceport and
a new drag will be created with the
pasteboard that you've provided alright
a couple guidelines now for using the
pasteboard carbon pasteboard always pay
attention to the flavor flags and
ordering if you're receiving information
you want to take advantage of all the
information that you have to choose the
right flavor we've had issues when
trying to add some default translations
that applications will see a translated
flavor and think that that's the one
they want to make it in context and in
fact the context that you'd be pasting
your dragon 2 might not even be
applicable for that type so it's very
important to take all the information
that you have and make the best decision
you can always use UTI comparisons for
the best results you want to leverage
that API to get the most covered you can
in receiving data one note about the wwc
feed is that NS pasteboard types are
added by coco ads and its base flow
types they're not yet converted to you
form type identifiers their existence is
only temporary they will be going away
they will be converted to uniform type
identifiers before panthers ships so i
don't want you to see them and depend on
them so pay attention about being there
this will change for Panther and again
there's plenty of header documentation
in pasteboard eh this is located in h
services in the application services
framework there's header doc there
there's a couple features that I wasn't
able to get into here go check it out
for details also there's some sample
code that we whipped up for the
conference pasteboard picker it's kind
of a cool little sort of text editing
app that shows you everything that is on
the drag or in the pasteboard you can
add information to the to drag or
pasteboard and it exercises the API and
shows you how you can use it that's on
the ATT member site go check it out all
right that's the carbon paste board
let's get on to new translation services
thank you translation let's talk about
translation the waiter today again
they're a set of problems that we've
discovered and we really wanted to solve
these again there's a limited typing
mechanism with four character for
character codes OS types and we've gone
over this several times it's also a
legacy API for instance based on FS
specs which they have no unicorn unicode
support and so we couldn't support the
full type of full number of those files
that we want to support on Mac OS 10
today in fact it with the memory models
still based on handles and it's still
based on C arrays of all things you know
if you if you wanted to get some
information in an array back from the
translation manager you'd have to pass
through a CRA and if you didn't allocate
enough space to bad if it wanted to give
you more information than you had asked
for and the third thing is really one of
the biggest things is that the way to
extend translations in Mac OS 9 and
earlier the plugin mechanism was based
on extensions and extension simply don't
exist in Mac OS 10 today and so this is
an issue that really needed to be
resolved in the solution translate some
services so translation services is the
successor to the translation manager the
source and destination types are both
provided as uniform type identifiers so
very flexible it's accessible via filter
services which I mentioned earlier this
is something else actually we've adopted
from coco they're very similar to Apple
many services with a modified plist and
I'll get into that later and the entire
API again is core foundation base so it
an advanced memory model so a
translation reference a translation
references the base type will be dealing
with it's a proxy to a resource on the
system that translates data from one
format to another it contains all the
information that's required to perform a
translation to sort the source types
that handle the destination type that
will provide and whether it handles file
or file or data translations and in the
translation services model translation
discovery and execution are separated
and so that's that's important because
you can create a translation if you know
you're going to be referencing that
translation many times and finds like a
mini files or something for instance you
can hold on to that because it's the CF
types can throw it in a CF array or
dictionary and keep it around so later
let's talk about discovery translation
create translation created is a pretty
simple straightforward API for finding
translation you might need you to say
you have a source file you have you know
point a here and you want to get to
point B you know what you know that
there's a destination you want to get
too does the translation exist that
supports step so you can hand the source
type the destination type and searching
for data and file translations I perform
through the same API now and so you can
pass through the translation flags
whether you want a translation that
handles just data just files or maybe
both and then if the resource exists
that performs its translation the
translation references handed back to
you so that looks for very simple needs
if you have more details or complex
discovery need you can use translation
create with sorcery it will handle any
permutation of translation discovery
that you need given an array of source
types it will provide to you all the
possible destinations that can be
generated from the source types and a
dictionary of translation reps which
perform those translations the
translation dictionary of translation
rest is keyed by the destination types
and so it's easy to look up again when
you decide on the translation that's
right for you you need to release the CF
array and the CF dictionary now how do
you discover which translates out of all
the translations which one is the right
one for you well you can easily
translation accesses you can you have
access to the source type the
destination types and the translate
and flags it support we hope to add more
accessors in the future for when more
information is provided this is the way
you can go through your side that I
really want to get to this to this
destination type and you really want to
get to one destination type but I prefer
it coming from this source than this
works because it may be this one's a
little bit richer if you really get fine
details if you want to alright you've
discovered translation you've created it
you've got on your hot little hand and
you want to now perform a translation
you want executed translation so if you
want to perform a data translation you
can call translation perform for data
hand it the translation rest hand at
your source data as a CF data and then
the CF eight arrests will be given back
to you holding the destination data you
know read that data out do whatever you
want with it and then release it that a
couple things you need to pay attention
to make sure that when you're handing a
translation rest to translation perform
for data that it actually handles data
translation otherwise you'll receive an
error immediately also something that
you want to make sure is that the source
and destination types in the translation
ref are the same source and destination
that you're providing and expecting from
this API and very similar for
translating files call translation
perform for file after the translation
ref your source file you can provide the
destination directory and named for the
destination file and then the API will
return an fsr of your translated file
and again you need to make sure that the
translation have to force files that you
have the correct to the correct source
and destination types if your
application happens to not be FS rest
base or the translation code is not FS
rest base you can use the URL API
currently only file URLs are supported
and again when you receive the data back
we need to receive the URL to your
translated file release the fury CF URL
reference alright I've mentioned filton
services a couple times along the way
these are the extension mechanism for
the default translations these are very
similar to Apple's service ethel many
services with a modified p list so if
you've written one of those
be very familiar I don't want to get
into too much detail here the page
boards the pasteboard peaker sample
again that I mentioned earlier about the
bottom this slide has an example for you
but when you're going to perform it
you're going to perform a translation
your services launched if necessary if
it's not already running the source say
that is delivered to you on a pasteboard
you can pull that data off to form a
translation and then put the destination
data back on the pasteboard hand it back
and the client can have that have access
to that data all right a couple
guidelines for translation services you
translate create for very simple needs
if you have one or two types that you're
interested in for given source types you
can just call it a couple times and ask
does it handle this flavor doesn't can I
get this flavor can I get that flavor oh
I can get this one great if you have
more complex needs than that called
translation create with sorcery and
again it'll handle any permutations you
have definitely check out translation
services eh header for details lots of
header doc there again some more lots of
examples there for how to create a
translation service and so on so go
check it out NHS services in the
application services framework all right
in summary we come up with three great
new api's that i think will i know they
definitely helped us internally and
we're really hoping that they'll be
great for you what we need to do now is
you know you've got the season your
hands get to work uniform one type of
dental fires are a really flexible
framework for typing if you if you have
data that you need to type it's the way
to go always declare new types in your
internet domain so that if there are
your type you own them otherwise import
them from other applications and always
use the ETI api for conformance test
this is your mantra because you want to
make sure that you can really leverage
the full flexibility of the uniform type
identification API make pasteboards can
really streamline your scrap and drag
you said you know I was coming up with
that pace that pasteboard paper Peter
sample and it was it was really cool
just how simple i could use the same the
same function to read data from both
drag and copies and the same function to
add
formation to drag the copy really
convenient now that you have access to
UTIs to local applications look at coco
applications that your apps might be
able to correspond with and really see
how you can leverage coco app usage and
then always be aware of automatic
translations they're there to help you
but make sure that they're not getting
in your way is make sure that you're
looking at the flags as you see whether
it's a translation or not and decide
whether you want to have a translation
or not and a piece of translation
services translation manager is frankly
unimplemented on on 10 we wanted to make
it happen but because the reasons I
stated earlier I knew that we could
perform or create a much better solution
for you and useful for services to
extend the default translations there's
only a limited set that apple will be
able to provide there was a really rich
set of translations available in the mac
OS 9 world we really like to see those
brought forward to mac OS 10 so check
this out this is excellent third-party
opportunity for all of you so with that
I'd like to bring Xavi a backup for the
wrap-up thank you okay okay quickly the
road map before we go to the Q&A session
for night eh I two books was Wednesday
some of you can travel in time I
encourage you to get that session it was
pretty good and if not we'll have it on
DVD using the apple trees for cover and
development same shame that was just
before but Apple has been investing a
lot of time and effort in Xcode and then
encourage you as well to like check it
out you won't have to travel in time to
see session for 16 which is optimizing
performance on presidio it's a great
great session for anybody that is doing
C and C++ develop milano platform we're
going to be going to like a tonne of
information we're going to give you like
ideas on how to improve performance on
your app please join us this afternoon
and tomorrow of course if you haven't
heard you know we have a brand new h-hi
toolbox available in Mac OS 10 since
10.2 we introduce a chive you and should
you need more information on this great
energy please join us tomorrow afternoon
all right should she did you change that
you still fired you are so fired anyway
which is that later should you have any
questions on the new place both services
please send me an email and we try to
get you going it's very important to
understand that you know the idea here
is we need to have your feedback so
please check out the api's and contact
us should you have any specific needs or
maybe we forget something or like maybe
there's a special case to make you like
you know around that you know we need to
implement and that but the idea with
like you know having wdc and giving you
the state of painter
you