Add use cases and message implementation details for all "Item()" type member functions except

the AddItem() member function.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@997 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
jrand 2002-09-09 04:18:20 +00:00
parent f1e38490eb
commit fd9e0303b3
1 changed files with 116 additions and 8 deletions

View File

@ -1,5 +1,5 @@
<HTML>
<!-- $Id: BDeskbarUseCases.html,v 1.2 2002/09/08 05:03:36 jrand Exp $ -->
<!-- $Id: BDeskbarUseCases.html,v 1.3 2002/09/09 04:18:20 jrand Exp $ -->
<HEAD>
<TITLE>BDeskbar Use Cases and Implementation Details</TITLE>
</HEAD>
@ -42,19 +42,42 @@ persists.</P></LI>
<LI><P><B>Add Item 2:</B> </P></LI>
<LI><P><B>Remove Item 1:</B> </P></LI>
<LI><P><B>Remove Item 1:</B> The RemoveItem() member function takes an integer id and removes it
from the deskbar shelf if it exists. The member returns B_OK at all times (unless the deskbar is
not running or some communication failure occurs). A B_OK result does not mean that an item was
actually removed.</P></LI>
<LI><P><B>Remove Item 2:</B> </P></LI>
<LI><P><B>Remove Item 2:</B> The RemoveItem() member function also takes a string name and removes
it from the deskbar shelf if it exists. The member returns B_OK at all times (unless the deskbar is
not running or some communication failure occurs). A B_OK result does not mean that an item was
actually removed.</P></LI>
<LI><P><B>Count Items:</B> </P></LI>
<LI><P><B>Count Items:</B> The CountItems() member function takes no arguments. It returns the
number of "items" in the deskbar shelf. For example, the small email icon often found in the
deskbar is one such item.</P></LI>
<LI><P><B>Has Item 1:</B> </P></LI>
<LI><P><B>Has Item 1:</B> The HasItem() member function takes a integer id and returns a true or
false value which indicates whether or not an item exists in the deskbar shelf on that id. For
example, the small email icon often found in the deskbar is one such item.</P></LI>
<LI><P><B>Has Item 2:</B> </P></LI>
<LI><P><B>Has Item 2:</B> The HasItem() member function also takes a string name parameter and
returns a true or false value which indicates whether or not an item by than name exists in
the deskbar shelf. For example, the small email icon often found in the deskbar is named
"mail".</P></LI>
<LI><P><B>Get Item Info 1:</B> </P></LI>
<LI><P><B>Get Item Info 1:</B> The GetItemInfo() member function takes an integer id and a pointer
to a const char * (ie a string). It checks to see if the id passed in exists in the deskbar and
sets the value of the const char * to point to a allocated buffer which contains the name of the
item which corresponds to this id and the function returns B_OK. Ownership of this allocated
buffer is assigned to the caller of this member function so it is up to the caller to free the
memory. If the id doesn't exist, then it still returns B_OK but the pointer to the string is set
to NULL. If the pointer to the string passed in is NULL, the function returns B_BAD_VALUE.</P></LI>
<LI><P><B>Get Item Info 2:</B> </P></LI>
<LI><P><B>Get Item Info 2:</B> The GetItemInfo() member also takes a string (const char *) name
and a pointer to an int. If the name matches an item in the deskbar shelf, the id of this
item is returned at the location pointed to by the integer pointer and the member returns B_OK.
If the name doesn't match an item in the deskbar shelf, the id is set to -1. If the pointer
passed in is NULL, the function returns B_BAD_VALUE.</P></LI>
<LI><P><B>Frame:</B> The Frame() member function returns a BRect which describes the location and
size of the deskbar on the screen.</P></LI>
@ -104,6 +127,91 @@ here:</P>
itself.</P>
<H3>HasItem:</H3>
<P>The HasItem() member sends the following message to the deskbar:</P>
<PRE>
BMessage theMsg;
theMsg.what = 'exst'
theMsg.AddInt32("id", theID); // This is the id to check for
// OR, only one of id or name should be in the message
theMsg.AddString("name", theName); // This is the name to check for
</PRE>
<P>The deskbar responds with a message which looks like:</P>
<PRE>
BMessage theMsg;
theMsg.AddBool("exists", IDorNameExists()); // This is a true/false value which indicates whether or not the name/id exists in the shelf
</PRE>
<P>Note that the deskbar does not set the what code of the reply. Checking the source code
for
<A href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/opentracker/opentracker/deskbar/BarWindow.cpp?rev=1.2&content-type=text/vnd.viewcvs-markup">TBarWindow::ItemExists()</A>
confirms this.</P>
<H3>GetItemInfo:</H3>
<P>The GetItemInfo() member sends the following message to the deskbar:</P>
<PRE>
BMessage theMsg;
theMsg.what = 'exst'
theMsg.AddInt32("id", theID); // This is the id to check for
// OR, only one of id or name should be in the message
theMsg.AddString("name", theName); // This is the name to check for
</PRE>
<P>The deskbar responds with a message which looks like:</P>
<PRE>
BMessage theMsg;
theMsg.AddString("name", theName); // This is the name corresponding to the id of the original request
// OR, only one of id or name should be in the response message depending on the request sent
theMsg.AddInt32("id", theID); // This is the id corresponding to the name of the original request
</PRE>
<P>Note that the deskbar does not set the what code of the reply. Checking the source code
for
<A href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/opentracker/opentracker/deskbar/BarWindow.cpp?rev=1.2&content-type=text/vnd.viewcvs-markup">TBarWindow::ItemExists()</A>
confirms this.</P>
<H3>CountItems:</H3>
<P>The CountItems() member sends the following message to the deskbar:</P>
<PRE>
BMessage theMsg;
theMsg.what = 'cwnt'
</PRE>
<P>The deskbar responds with a message which looks like:</P>
<PRE>
BMessage theMsg;
theMsg.what = 'rply'; // This means reply
theMsg.AddInt32("count", ItemCount()); // This is the number of items in the deskbar shelf
</PRE>
<H3>RemoveItem:</H3>
<P>The RemoveItem() member sends the following message to the deskbar:</P>
<PRE>
BMessage theMsg;
theMsg.what = 'exst'
theMsg.AddInt32("id", theID); // This is the id to remove
// OR, only one of id or name should be in the message
theMsg.AddString("name", theName); // This is the name to remove
</PRE>
<P>The deskbar does not send a response.</P>
<H3>Frame:</H3>
<P>The Frame() member sends a standard scripting message to get the frame from the deskbar. It