public class BluetoothMasClient extends Object
Modifier and Type | Class and Description |
---|---|
static class |
BluetoothMasClient.CharsetType |
static class |
BluetoothMasClient.ConnectionState |
static class |
BluetoothMasClient.MessagesFilter
Object representation of filters to be applied on message listing
|
Modifier and Type | Field and Description |
---|---|
static int |
EVENT_CONNECT
Callback message sent when connection state changes
arg1 is set to STATUS_OK when connection is
established successfully and STATUS_FAILED when connection
either failed or was disconnected (depends on request from application) |
static int |
EVENT_EVENT_REPORT
Callback message sent when event report is received from MSE to MNS
obj contains BluetoothMapEventReport |
static int |
EVENT_GET_FOLDER_LISTING
Callback message sent when folder listing is received
obj contains ArrayList of sub-folder names |
static int |
EVENT_GET_FOLDER_LISTING_SIZE
Callback message sent when folder listing size is received
obj contains number of items in folder listing |
static int |
EVENT_GET_MESSAGE
Callback message sent when message is received
obj contains BluetoothMapBmessage |
static int |
EVENT_GET_MESSAGES_LISTING
Callback message sent when messages listing is received
obj contains ArrayList of BluetoothMapBmessage |
static int |
EVENT_GET_MESSAGES_LISTING_SIZE
Callback message sent when messages listing size is received
obj contains number of items in messages listing |
static int |
EVENT_PUSH_MESSAGE
Callback message sent when message is pushed to MSE
obj contains handle of message as allocated by MSE |
static int |
EVENT_SET_MESSAGE_STATUS
Callback message sent when message status is changed
|
static int |
EVENT_SET_NOTIFICATION_REGISTRATION
Callback message sent when notification status is changed
obj contains 1 if notifications are enabled and
0 otherwise |
static int |
EVENT_SET_PATH
Callback message sent when path is changed
obj is set to path currently set on MSE |
static int |
EVENT_UPDATE_INBOX
Callback message sent when MSE accepted update inbox request
|
static int |
PARAMETER_ATTACHMENT_SIZE
Constant corresponding to
ParameterMask application
parameter value in MAP specification |
static int |
PARAMETER_DATETIME
Constant corresponding to
ParameterMask application
parameter value in MAP specification |
static int |
PARAMETER_DEFAULT
Constant corresponding to
ParameterMask application
parameter value in MAP specification |
static int |
PARAMETER_PRIORITY
Constant corresponding to
ParameterMask application
parameter value in MAP specification |
static int |
PARAMETER_PROTECTED
Constant corresponding to
ParameterMask application
parameter value in MAP specification |
static int |
PARAMETER_READ
Constant corresponding to
ParameterMask application
parameter value in MAP specification |
static int |
PARAMETER_RECEPTION_STATUS
Constant corresponding to
ParameterMask application
parameter value in MAP specification |
static int |
PARAMETER_RECIPIENT_ADDRESSING
Constant corresponding to
ParameterMask application
parameter value in MAP specification |
static int |
PARAMETER_RECIPIENT_NAME
Constant corresponding to
ParameterMask application
parameter value in MAP specification |
static int |
PARAMETER_REPLYTO_ADDRESSING
Constant corresponding to
ParameterMask application
parameter value in MAP specification |
static int |
PARAMETER_SENDER_ADDRESSING
Constant corresponding to
ParameterMask application
parameter value in MAP specification |
static int |
PARAMETER_SENDER_NAME
Constant corresponding to
ParameterMask application
parameter value in MAP specification |
static int |
PARAMETER_SENT
Constant corresponding to
ParameterMask application
parameter value in MAP specification |
static int |
PARAMETER_SIZE
Constant corresponding to
ParameterMask application
parameter value in MAP specification |
static int |
PARAMETER_SUBJECT
Constant corresponding to
ParameterMask application
parameter value in MAP specification |
static int |
PARAMETER_TEXT
Constant corresponding to
ParameterMask application
parameter value in MAP specification |
static int |
PARAMETER_TYPE
Constant corresponding to
ParameterMask application
parameter value in MAP specification |
static int |
STATUS_FAILED
Status for callback message when request is not successful
|
static int |
STATUS_OK
Status for callback message when request is successful
|
Constructor and Description |
---|
BluetoothMasClient(BluetoothDevice device,
SdpMasRecord mas,
Handler callback)
Constructs client object to communicate with single MAS instance on MSE
|
Modifier and Type | Method and Description |
---|---|
void |
connect()
Connects to MAS instance
Upon completion callback handler will receive
EVENT_CONNECT |
void |
disconnect()
Disconnects from MAS instance
Upon completion callback handler will receive
EVENT_CONNECT |
void |
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
String |
getCurrentPath()
Gets current path in folder hierarchy
|
boolean |
getFolderListing()
Gets list of sub-folders in current folder
Upon completion callback handler will receive
EVENT_GET_FOLDER_LISTING |
boolean |
getFolderListing(int maxListCount,
int listStartOffset)
Gets list of sub-folders in current folder
Upon completion callback handler will receive
EVENT_GET_FOLDER_LISTING |
boolean |
getFolderListingSize()
Gets number of sub-folders in current folder
Upon completion callback handler will receive
EVENT_GET_FOLDER_LISTING_SIZE |
SdpMasRecord |
getInstanceData()
Retrieves MAS instance data associated with client
|
boolean |
getMessage(String handle,
boolean attachment)
Retrieves message from MSE
Upon completion callback handler will receive
EVENT_GET_MESSAGE |
boolean |
getMessagesListing(String folder,
int parameters)
Gets list of messages in specified sub-folder
Upon completion callback handler will receive
EVENT_GET_MESSAGES_LISTING |
boolean |
getMessagesListing(String folder,
int parameters,
BluetoothMasClient.MessagesFilter filter,
int subjectLength)
Gets list of messages in specified sub-folder
Upon completion callback handler will receive
EVENT_GET_MESSAGES_LISTING |
boolean |
getMessagesListing(String folder,
int parameters,
BluetoothMasClient.MessagesFilter filter,
int subjectLength,
int maxListCount,
int listStartOffset)
Gets list of messages in specified sub-folder
Upon completion callback handler will receive
EVENT_GET_MESSAGES_LISTING |
boolean |
getMessagesListingSize()
Gets number of messages in current folder
Upon completion callback handler will receive
EVENT_GET_MESSAGES_LISTING_SIZE |
boolean |
getNotificationRegistration()
Gets current state of notifications for MAS instance
|
BluetoothMasClient.ConnectionState |
getState()
Gets current connection state
|
boolean |
pushMessage(String folder,
BluetoothMapBmessage bmsg,
BluetoothMasClient.CharsetType charset)
Pushes new message to MSE
Upon completion callback handler will receive
EVENT_PUSH_MESSAGE |
boolean |
pushMessage(String folder,
BluetoothMapBmessage bmsg,
BluetoothMasClient.CharsetType charset,
boolean transparent,
boolean retry)
Pushes new message to MSE
Upon completion callback handler will receive
EVENT_PUSH_MESSAGE |
boolean |
setFolderDown(String name)
Goes down to specified sub-folder in folder hierarchy
Upon completion callback handler will receive
EVENT_SET_PATH |
boolean |
setFolderRoot()
Goes back to root of folder hierarchy
Upon completion callback handler will receive
EVENT_SET_PATH |
boolean |
setFolderUp()
Goes back to parent folder in folder hierarchy
Upon completion callback handler will receive
EVENT_SET_PATH |
boolean |
setMessageDeletedStatus(String handle,
boolean deleted)
Sets deleted status of message on MSE
Upon completion callback handler will receive
EVENT_SET_MESSAGE_STATUS |
boolean |
setMessageReadStatus(String handle,
boolean read)
Sets read status of message on MSE
Upon completion callback handler will receive
EVENT_SET_MESSAGE_STATUS |
boolean |
setNotificationRegistration(boolean status)
Sets state of notifications for MAS instance
Once notifications are enabled, callback handler will receive
EVENT_EVENT_REPORT when new notification is received
Upon completion callback handler will receive
EVENT_SET_NOTIFICATION_REGISTRATION |
boolean |
updateInbox()
Requests MSE to initiate ubdate of inbox
Upon completion callback handler will receive
EVENT_UPDATE_INBOX |
public static final int EVENT_CONNECT
arg1
is set to STATUS_OK
when connection is
established successfully and STATUS_FAILED
when connection
either failed or was disconnected (depends on request from application)
connect()
,
disconnect()
,
Constant Field Valuespublic static final int EVENT_UPDATE_INBOX
updateInbox()
,
Constant Field Valuespublic static final int EVENT_SET_PATH
obj
is set to path currently set on MSE
public static final int EVENT_GET_FOLDER_LISTING
obj
contains ArrayList of sub-folder names
public static final int EVENT_GET_FOLDER_LISTING_SIZE
obj
contains number of items in folder listing
getFolderListingSize()
,
Constant Field Valuespublic static final int EVENT_GET_MESSAGES_LISTING
obj
contains ArrayList of BluetoothMapBmessage
public static final int EVENT_GET_MESSAGE
obj
contains BluetoothMapBmessage
#getMessage(String, CharsetType, boolean)
,
Constant Field Valuespublic static final int EVENT_SET_MESSAGE_STATUS
public static final int EVENT_PUSH_MESSAGE
obj
contains handle of message as allocated by MSE
public static final int EVENT_SET_NOTIFICATION_REGISTRATION
obj
contains 1
if notifications are enabled and
0
otherwise
public static final int EVENT_EVENT_REPORT
obj
contains BluetoothMapEventReport
public static final int EVENT_GET_MESSAGES_LISTING_SIZE
obj
contains number of items in messages listing
getMessagesListingSize()
,
Constant Field Valuespublic static final int STATUS_OK
public static final int STATUS_FAILED
public static final int PARAMETER_DEFAULT
ParameterMask
application
parameter value in MAP specificationpublic static final int PARAMETER_SUBJECT
ParameterMask
application
parameter value in MAP specificationpublic static final int PARAMETER_DATETIME
ParameterMask
application
parameter value in MAP specificationpublic static final int PARAMETER_SENDER_NAME
ParameterMask
application
parameter value in MAP specificationpublic static final int PARAMETER_SENDER_ADDRESSING
ParameterMask
application
parameter value in MAP specificationpublic static final int PARAMETER_RECIPIENT_NAME
ParameterMask
application
parameter value in MAP specificationpublic static final int PARAMETER_RECIPIENT_ADDRESSING
ParameterMask
application
parameter value in MAP specificationpublic static final int PARAMETER_TYPE
ParameterMask
application
parameter value in MAP specificationpublic static final int PARAMETER_SIZE
ParameterMask
application
parameter value in MAP specificationpublic static final int PARAMETER_RECEPTION_STATUS
ParameterMask
application
parameter value in MAP specificationpublic static final int PARAMETER_TEXT
ParameterMask
application
parameter value in MAP specificationpublic static final int PARAMETER_ATTACHMENT_SIZE
ParameterMask
application
parameter value in MAP specificationpublic static final int PARAMETER_PRIORITY
ParameterMask
application
parameter value in MAP specificationpublic static final int PARAMETER_READ
ParameterMask
application
parameter value in MAP specificationpublic static final int PARAMETER_SENT
ParameterMask
application
parameter value in MAP specificationpublic static final int PARAMETER_PROTECTED
ParameterMask
application
parameter value in MAP specificationpublic static final int PARAMETER_REPLYTO_ADDRESSING
ParameterMask
application
parameter value in MAP specificationpublic BluetoothMasClient(BluetoothDevice device, SdpMasRecord mas, Handler callback)
device
- BluetoothDevice
corresponding to remote device
acting as MSEmas
- BluetoothMasInstance
object describing MAS instance on
remote devicecallback
- Handler
object to which callback messages will be
sent Each message will have arg1
set to either
STATUS_OK
or STATUS_FAILED
and
arg2
to MAS instance ID. obj
in
message is event specific.public SdpMasRecord getInstanceData()
public void connect()
Upon completion callback handler will receive EVENT_CONNECT
public void disconnect()
Upon completion callback handler will receive EVENT_CONNECT
public void finalize()
Object
finalize
method to dispose of
system resources or to perform other cleanup.
The general contract of finalize
is that it is invoked
if and when the JavaTM virtual
machine has determined that there is no longer any
means by which this object can be accessed by any thread that has
not yet died, except as a result of an action taken by the
finalization of some other object or class which is ready to be
finalized. The finalize
method may take any action, including
making this object available again to other threads; the usual purpose
of finalize
, however, is to perform cleanup actions before
the object is irrevocably discarded. For example, the finalize method
for an object that represents an input/output connection might perform
explicit I/O transactions to break the connection before the object is
permanently discarded.
The finalize
method of class Object
performs no
special action; it simply returns normally. Subclasses of
Object
may override this definition.
The Java programming language does not guarantee which thread will
invoke the finalize
method for any given object. It is
guaranteed, however, that the thread that invokes finalize will not
be holding any user-visible synchronization locks when finalize is
invoked. If an uncaught exception is thrown by the finalize method,
the exception is ignored and finalization of that object terminates.
After the finalize
method has been invoked for an object, no
further action is taken until the Java virtual machine has again
determined that there is no longer any means by which this object can
be accessed by any thread that has not yet died, including possible
actions by other objects or classes which are ready to be finalized,
at which point the object may be discarded.
The finalize
method is never invoked more than once by a Java
virtual machine for any given object.
Any exception thrown by the finalize
method causes
the finalization of this object to be halted, but is otherwise
ignored.
public BluetoothMasClient.ConnectionState getState()
BluetoothMasClient.ConnectionState
public boolean setNotificationRegistration(boolean status)
Once notifications are enabled, callback handler will receive
EVENT_EVENT_REPORT
when new notification is received
Upon completion callback handler will receive
EVENT_SET_NOTIFICATION_REGISTRATION
status
- true
if notifications shall be enabled,
false
otherwisetrue
if request has been sent, false
otherwisepublic boolean getNotificationRegistration()
true
if notifications are enabled,
false
otherwisepublic boolean setFolderRoot()
Upon completion callback handler will receive EVENT_SET_PATH
true
if request has been sent, false
otherwisepublic boolean setFolderUp()
Upon completion callback handler will receive EVENT_SET_PATH
true
if request has been sent, false
otherwisepublic boolean setFolderDown(String name)
Upon completion callback handler will receive EVENT_SET_PATH
name
- name of sub-foldertrue
if request has been sent, false
otherwisepublic String getCurrentPath()
public boolean getFolderListing()
Upon completion callback handler will receive
EVENT_GET_FOLDER_LISTING
true
if request has been sent, false
otherwisepublic boolean getFolderListing(int maxListCount, int listStartOffset)
Upon completion callback handler will receive
EVENT_GET_FOLDER_LISTING
maxListCount
- maximum number of items returned or 0
for default valuelistStartOffset
- index of first item returned or 0
for
default valuetrue
if request has been sent, false
otherwiseIllegalArgumentException
- if either maxListCount or
listStartOffset are outside allowed range [0..65535]public boolean getFolderListingSize()
Upon completion callback handler will receive
EVENT_GET_FOLDER_LISTING_SIZE
true
if request has been sent, false
otherwisepublic boolean getMessagesListing(String folder, int parameters)
Upon completion callback handler will receive
EVENT_GET_MESSAGES_LISTING
folder
- name of sub-folder or null
for current folderparameters
- bit-mask specifying requested parameters in listing or
0
for default valuetrue
if request has been sent, false
otherwisepublic boolean getMessagesListing(String folder, int parameters, BluetoothMasClient.MessagesFilter filter, int subjectLength)
Upon completion callback handler will receive
EVENT_GET_MESSAGES_LISTING
folder
- name of sub-folder or null
for current folderparameters
- corresponds to ParameterMask
application
parameter in MAP specificationfilter
- BluetoothMasClient.MessagesFilter
object describing filters to be
applied on listing by MSEsubjectLength
- maximum length of message subject in returned
listing or 0
for default valuetrue
if request has been sent, false
otherwiseIllegalArgumentException
- if subjectLength is outside allowed
range [0..255]public boolean getMessagesListing(String folder, int parameters, BluetoothMasClient.MessagesFilter filter, int subjectLength, int maxListCount, int listStartOffset)
Upon completion callback handler will receive
EVENT_GET_MESSAGES_LISTING
folder
- name of sub-folder or null
for current folderparameters
- corresponds to ParameterMask
application
parameter in MAP specificationfilter
- BluetoothMasClient.MessagesFilter
object describing filters to be
applied on listing by MSEsubjectLength
- maximum length of message subject in returned
listing or 0
for default valuemaxListCount
- maximum number of items returned or 0
for default valuelistStartOffset
- index of first item returned or 0
for
default valuetrue
if request has been sent, false
otherwiseIllegalArgumentException
- if subjectLength is outside allowed
range [0..255] or either maxListCount or listStartOffset are
outside allowed range [0..65535]public boolean getMessagesListingSize()
Upon completion callback handler will receive
EVENT_GET_MESSAGES_LISTING_SIZE
true
if request has been sent, false
otherwisepublic boolean getMessage(String handle, boolean attachment)
Upon completion callback handler will receive EVENT_GET_MESSAGE
handle
- handle of message to retrievecharset
- BluetoothMasClient.CharsetType
object corresponding to
Charset
application parameter in MAP
specificationattachment
- corresponds to Attachment
application
parameter in MAP specificationtrue
if request has been sent, false
otherwisepublic boolean setMessageReadStatus(String handle, boolean read)
Upon completion callback handler will receive
EVENT_SET_MESSAGE_STATUS
handle
- handle of messageread
- true
for "read", false
for "unread"true
if request has been sent, false
otherwisepublic boolean setMessageDeletedStatus(String handle, boolean deleted)
Upon completion callback handler will receive
EVENT_SET_MESSAGE_STATUS
handle
- handle of messagedeleted
- true
for "deleted", false
for
"undeleted"true
if request has been sent, false
otherwisepublic boolean pushMessage(String folder, BluetoothMapBmessage bmsg, BluetoothMasClient.CharsetType charset)
Upon completion callback handler will receive EVENT_PUSH_MESSAGE
folder
- name of sub-folder to push to or null
for
current foldercharset
- BluetoothMasClient.CharsetType
object corresponding to
Charset
application parameter in MAP
specificationtrue
if request has been sent, false
otherwisepublic boolean pushMessage(String folder, BluetoothMapBmessage bmsg, BluetoothMasClient.CharsetType charset, boolean transparent, boolean retry)
Upon completion callback handler will receive EVENT_PUSH_MESSAGE
folder
- name of sub-folder to push to or null
for
current folderbmsg
- BluetoothMapBmessage
object representing message to
be pushedcharset
- BluetoothMasClient.CharsetType
object corresponding to
Charset
application parameter in MAP
specificationtransparent
- corresponds to Transparent
application
parameter in MAP specificationretry
- corresponds to Transparent
application
parameter in MAP specificationtrue
if request has been sent, false
otherwisepublic boolean updateInbox()
Upon completion callback handler will receive EVENT_UPDATE_INBOX
true
if request has been sent, false
otherwise