ACAP Code

This page is dedicated to samples of ACAP code, generally intended for specific uses; many of these examples use the bookmarks, etc, dataset classes. The intent is to make it easy for ACAP implementors to know what to send the server.

The general format in which they appear on the page is on multiple lines with comments separated out with hashes. However, the ACAP server does not recognise comments; I'm not sure that it recognises line breaks either. Therefore, both of these should be removed. Infotrope often insists on either 0 or 1 spaces (rather than arbitrary whitespace), so you may need to modify the queries to fit that.

Bookmarks Dataset

Bookmark storage

The following example basically does a single store on the server. The sample data is taken directly from the draft spec for bookmarks.


STORE (
    "/bookmarks/~/"
    "bookmarks.Name"        "Fred's Bait and Tackle"
    "bookmarks.Type"        "link"
    "bookmarks.Description"        "Where I get my worms"
    "bookmarks.URL"            "http://www.fredsbaitandtackle.fog/"
    "bookmarks.Date.Added"        "199840101000001+0800"
    "bookmarks.Last.Modified"    "19971114071202+0800"
    "bookmarks.Last.Visited"    "19980311173545+0800"
)

Please note that, in the above code, the spaces immediately inside the parentheses must be eliminated, and the spaces between the quoted items must be reduced to a single space.

Bookmark retrieval

This sample is based on one by Dave Cridland. It basically gets all the bookmarks from the server, and asks to be notified of updates.


SEARCH "/bookmarks/~/"                    # Where we want to search
    MAKECONTEXT ENUMERATE NOTIFY "BookmarksContext"    # We want to know how many entries 
                            #   there are, and that we want to 
                            #   be notified when changes occur
    RETURN ("*")                    # We want to receive all fields
    SORT ("entry" "i;ascii-casemap")        # Sort the bookmarks by entry
    ALL                        # We want all records too

The following is the return dataset from the command above. I've reformatted it as usual.


ENTRY "" (
    ("dataset.acl" ("anyone    rx" "$owner     rwixa"))
    ("modtime" "20030603005159000")
    ("vendor.infotrope.system.noinherit.entry.reconstruct-modtime" "20030603005159000")
    ("vendor.infotrope.system.inherit.entry.origin" "/byowner/user/timn/bookmarks/")
    ("vendor.infotrope.system.inherit.entry.control" "/byowner/user/timn/bookmarks/")
    ("entry" "")
    ("bookmarks.Type" "link")
    ("bookmarks.URL" "http://www.fredsbaitandtackle.fog/")
    ("bookmarks.Name" "Fred's Bait and Tackle")
    ("bookmarks.Description" "Where I get my worms")
    ("bookmarks.Last.Modified" "19971114071202+0800")
    ("bookmarks.Date.Added" "19840101000001+0800")
    ("bookmarks.Last.Visited" "19980311173545+0800")
)
MODTIME "20030603011407000"
OK "Search complete."

The commands below are the notes sent through from the server when another ACAP client modified a bookmark while the context was still open. Note that the commands below were untagged (ie. the tag was replaced with a "*"). Reformatted.


CHANGE "BookmarksContext" "" 1 1 (
    ("dataset.acl" ("anyone     rx" "$owner     rwixa"))
    ("modtime" "20030603011534000")
    ("vendor.infotrope.system.noinherit.entry.reconstruct-modtime" "20030603011534000")
    ("vendor.infotrope.system.inherit.entry.origin" "/byowner/user/timn/bookmarks/")
    ("vendor.infotrope.system.inherit.entry.control" "/byowner/user/timn/bookmarks/")
    ("entry" "")
    ("bookmarks.Type" "link")
    ("bookmarks.URL" "http://www.fredsbaitandtackle.fog/")
    ("bookmarks.Name" "Fred's Bait and Tackle")
    ("bookmarks.Description" "Where I get my worms")
    ("bookmarks.Last.Modified" "19971114071202+0800")
    ("bookmarks.Date.Added" "19840101000001+0800")
    ("bookmarks.Last.Visited" "19980311173545+0800")
)
MODTIME "BookmarksContext" "20030603011534001"