gaim/www

*** empty log message ***

2005-08-28, Mel Dooki
9d5cea53a99d
Parents 684319e4d4bf
Children 77072e9b993e
*** empty log message ***
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/htdocs/summerofcode/mel/RoutingSMS/server/CellPhoneMidlet.java Sun Aug 28 21:04:54 2005 -0400
@@ -0,0 +1,142 @@
+
+import javax.microedition.lcdui.*;
+import javax.microedition.midlet.*;
+
+public class CellPhoneMIDlet extends MIDlet implements CommandListener
+{
+
+ /**
+ * menulist, main menu List object.
+ */
+ public List menulist;
+ private String title;
+
+ /**
+ * elements, String elements of the menu.
+ */
+ private String[] elements;
+
+ /**
+ * server, Server object is created if this MIDlet is launced as Server.
+ */
+ private Server server;
+
+ /**
+ * UUIDString, Service record UUID that is used in this example application.
+ * Both Client and Server retrives this UUID string from this MIDlet class.
+ */
+ public static final String UUIDString = "11223344556677889900aabbccddeeff";
+
+ /**
+ * CellPhoneMIDlet
+ * Constructor. Initialize main menu;
+ */
+ public CellPhoneMIDlet()
+ {
+
+ title = "Main menu";
+ elements = new String[3];
+ elements[0] = "Start Application";
+ elements[1] = "About";
+ elements[2] = "Exit";
+
+ menulist = new List(title, List.IMPLICIT, elements, null);
+
+ menulist.setCommandListener(this);
+
+ }
+
+ /**
+ * startApp Shows main menu
+ *
+ * @throws MIDletStateChangeException
+ */
+ protected void startApp()
+ throws MIDletStateChangeException
+ {
+ showMenu();
+ }
+
+ protected void pauseApp()
+ {
+ }
+
+ /**
+ * destroyApp. Ensures that connections have been closed.
+ *
+ * param p1 boolean
+ */
+ protected void destroyApp(boolean p1)
+ {
+ if (server != null)
+ {
+ server.applicationClosed = true;
+ server.closeConnection();
+ }
+
+ }
+
+ /**
+ * commandAction. Handles main menu command events.
+ *
+ * param c Command
+ * param d Displayable
+ */
+ public void commandAction(Command c, Displayable d)
+ {
+ if (d == menulist)
+ {
+ int index = menulist.getSelectedIndex();
+ switch (index)
+ {
+ case 0:
+ startServer();
+ break;
+ case 1:
+ showAbout();
+ break;
+ case 2:
+ quitApp();
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ /*
+ * quitApp. Called when application is closed.
+ */
+ public void quitApp()
+ {
+ destroyApp(false);
+ notifyDestroyed();
+ }
+
+ /*
+ * showMenu. Shows main menu list.
+ */
+ public void showMenu()
+ {
+ Display.getDisplay(this).setCurrent(menulist);
+ }
+
+ /*
+ * showAbout. Shows About dialog.
+ */
+ public void showAbout()
+ {
+ AboutForm aboutForm = new AboutForm("About SMS Routing over BT Link", this);
+ Display.getDisplay(this).setCurrent(aboutForm);
+ }
+
+ /**
+ * startServer. Starts bluetooth server thread.
+ */
+ private void startServer()
+ {
+ server = new Server(this);
+ server.start();
+ }
+}