Fields Summary |
---|
private static WMAFramework | instance/
/** Singleton |
private static int | DEFAULT_PORTDefault Server Port Number |
private static NewMessageHandler | messageHandlerMessageHandler |
private Command | thCmdCommand for thread processing |
private IncomingMessageListener | incomingMessageListenerNew Message Listener |
private MessageConnection | mcWMA Message Connection |
protected Display | display/
/** LCDUI Display context |
private MessageInboxScreen | messageInboxScreenMessage inbox screen |
private MessageDetailsScreen | messageDetailsScreenMessage summary screen |
private NewMessageScreen | newMessageScreenNew message screen |
private Displayable | backScreenReturn (to caller application) screen |
Methods Summary |
---|
private void | alertSegmentationError()Alerts the user of segmentation error.
// Alert the user...
|
public void | commandAction(Command c, Displayable d)Command/button listener.
Thread th = new Thread(this);
thCmd = c;
th.start();
|
public void | createServerConnection()Creates a server message connection
String url;
if (mc == null) {
try {
String p = System.getProperty("WMAFW-ServerPort");
if (p == null)
url = "sms://:"+DEFAULT_PORT;
else
url = "sms://:"+p.trim();
mc = (MessageConnection) Connector.open(url);
messageHandler = new NewMessageHandler(mc);
messageHandler.setIncomingMessageListener(this);
messageHandler.start();
} catch (Exception e) {
System.out.println("createMessageConnection Exception: " + e);
}
}
|
public static wmafw.WMAFramework | getInstance(Display d)/
/**
Returns the singleton instance of the WMAFramework.
if (instance == null) instance = new WMAFramework(d);
return instance;
|
public java.lang.String | getSMSC()Returns the active SMSC used by WMA Framework.
return System.getProperty("wireless.messaging.sms.smsc");
|
public void | onBinaryMessage(java.lang.String from, byte[] message)Notification Listener entry point
// 1. create, queue, persist message
ShortMessage sm = new ShortMessage(from, null, message);
inbox.addElement(sm);
// 2. notify application
incomingMessageListener.onBinaryMessage(from, message);
|
public void | onTextMessage(java.lang.String from, java.lang.String message)/
/**
Notification Listener entry point
// 1. create, queue, persist message
ShortMessage sm = new ShortMessage(from, message, null);
inbox.addElement(sm);
messageInboxScreen.setInbox(inbox);
// 2. notify application
incomingMessageListener.onTextMessage(from, message);
|
public void | run()Runnable entry point. Processes UI commands, providing all
navigation at the application level. Note that navigation at the
WMAFramework level is provided by the WMAFramework.
if (thCmd == MessageInboxScreen.VIEW) {
try {
int i = messageInboxScreen.getMenuSelection();
if (i != -1) {
ShortMessage sm = (ShortMessage) inbox.elementAt(i);
messageDetailsScreen.showScreen(sm.from, sm.text);
}
} catch (Exception e) {
}
} else if (thCmd == MessageInboxScreen.BACK) {
display.setCurrent(backScreen);
} else if (thCmd == MessageInboxScreen.RESET) {
inbox.removeAllElements();
messageInboxScreen.setInbox(inbox);
} else if (thCmd == MessageInboxScreen.NEW) {
newMessageScreen.showScreen("", display.getCurrent());
} else if (thCmd == MessageDetailsScreen.BACK) {
messageInboxScreen.showScreen(inbox);
} else if (thCmd == MessageDetailsScreen.REPLY) {
newMessageScreen.showScreen(messageDetailsScreen.getFrom(), display.getCurrent());
} else if (thCmd == NewMessageScreen.BACK) {
display.setCurrent(newMessageScreen.getBackScreen());
} else if (thCmd == NewMessageScreen.SEND) {
sendTextMessage(newMessageScreen.getFieldTo(),newMessageScreen.getFieldMessage());
display.setCurrent(newMessageScreen.getBackScreen());
}
|
public void | sendBinaryMessage(java.lang.String address, byte[] message)Sends a binary message
// To be implemented...
|
public void | sendTextMessage(java.lang.String address, java.lang.String message)Sends a text message
if (address.startsWith("sms") == false) {
address = "sms://"+address;
}
try {
TextMessage tmsg = (TextMessage)mc.newMessage(MessageConnection.TEXT_MESSAGE);
if (address != null) tmsg.setAddress(address);
tmsg.setPayloadText(message);
// Make sure the message can be sent before trying...
int segcount = mc.numberOfSegments(tmsg);
if (segcount == 0) {
// Message is too long for the underlying protocol...
alertSegmentationError();
} else
// Send the message.
mc.send(tmsg);
} catch(Exception e) {
// Handle the exception...
System.out.println("Exception during sendTextMessage " + e);
}
|
public void | setIncomingMessageListener(IncomingMessageListener listener)Sets the WMAFramework incoming message nofitication listener.
incomingMessageListener = listener;
|
public void | showInbox(Displayable backScreen)Makes the WMAFramework Inbox Screen visible.
this.backScreen = backScreen;
messageInboxScreen.showScreen(inbox);
|
public void | stopFramework()Stops the WMA Framework
instance = null;
messageInboxScreen = null;
messageDetailsScreen = null;
newMessageScreen = null;
messageHandler.stop();
messageHandler = null;
try {
mc.setMessageListener(null);
if (mc != null) {
mc.close();
mc = null;
}
} catch (Exception e) {
System.out.println("stopFramework Exception: " + e);
}
|