commit 77f1a026c3ac81e7fdcf5b21ebaf1f54b66e5947 Author: Erik C. Thauvin Date: Fri Jul 8 16:54:56 2005 +0000 Initial import. diff --git a/.cvsignore b/.cvsignore new file mode 100644 index 0000000..29aa1e0 --- /dev/null +++ b/.cvsignore @@ -0,0 +1,4 @@ +DevSuite +deployed +build +cmd.bat \ No newline at end of file diff --git a/YahooME-1.iml b/YahooME-1.iml new file mode 100644 index 0000000..32f3335 --- /dev/null +++ b/YahooME-1.iml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/YahooME-1.ipr b/YahooME-1.ipr new file mode 100644 index 0000000..eaa44bf --- /dev/null +++ b/YahooME-1.ipr @@ -0,0 +1,264 @@ + + + + + + + + + + + + + + false + false + false + false + false + + false + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/YahooME-1.iws b/YahooME-1.iws new file mode 100644 index 0000000..5e8af2d --- /dev/null +++ b/YahooME-1.iws @@ -0,0 +1,530 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/YahooME-2.iml b/YahooME-2.iml new file mode 100644 index 0000000..9268a8a --- /dev/null +++ b/YahooME-2.iml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/YahooME-2.ipr b/YahooME-2.ipr new file mode 100644 index 0000000..6595b6a --- /dev/null +++ b/YahooME-2.ipr @@ -0,0 +1,259 @@ + + + + + + + false + false + false + false + false + + false + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/YahooME-2.iws b/YahooME-2.iws new file mode 100644 index 0000000..8eac8d3 --- /dev/null +++ b/YahooME-2.iws @@ -0,0 +1,408 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/YahooME-2.jad b/YahooME-2.jad new file mode 100644 index 0000000..89f2c83 --- /dev/null +++ b/YahooME-2.jad @@ -0,0 +1,10 @@ +MIDlet-1: YahooME,/yahoome.png,net.thauvin.j2me.yahoome.YahooME +MIDlet-Jar-URL: YahooME-2.jar +MIDlet-Icon: /yahoome.png +MIDlet-Version: 0.1 +MIDlet-Description: YahooME +MIDlet-Name: YahooME +MIDlet-Vendor: Erik C. Thauvin +MIDlet-Info-URL: http://mobile.thauvin.net/j2me/ +MicroEdition-Profile: MIDP-2.0 +MIDlet-Permissions: javax.microedition.io.Connector.sms,javax.wireless.messaging.sms.send \ No newline at end of file diff --git a/YahooME.jad b/YahooME.jad new file mode 100644 index 0000000..4f2a3a2 --- /dev/null +++ b/YahooME.jad @@ -0,0 +1,8 @@ +MIDlet-1: YahooME,/yahoome.png,net.thauvin.j2me.yahoome.YahooME +MIDlet-Jar-URL: YahooME.jar +MIDlet-Icon: /yahoome.png +MIDlet-Version: 0.1 +MIDlet-Description: YahooME +MIDlet-Name: YahooME +MIDlet-Vendor: Erik C. Thauvin +MIDlet-Info-URL: http://mobile.thauvin.net/j2me/ diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..eb08241 --- /dev/null +++ b/build.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/cldcapi10.jar b/lib/cldcapi10.jar new file mode 100644 index 0000000..d53b92b Binary files /dev/null and b/lib/cldcapi10.jar differ diff --git a/lib/midpapi10.jar b/lib/midpapi10.jar new file mode 100644 index 0000000..58514a9 Binary files /dev/null and b/lib/midpapi10.jar differ diff --git a/lib/midpapi20.jar b/lib/midpapi20.jar new file mode 100644 index 0000000..46d9dc0 Binary files /dev/null and b/lib/midpapi20.jar differ diff --git a/lib/wma.jar b/lib/wma.jar new file mode 100644 index 0000000..dd28b7e Binary files /dev/null and b/lib/wma.jar differ diff --git a/licenses/J2ME WTK BinaryLicense.html b/licenses/J2ME WTK BinaryLicense.html new file mode 100644 index 0000000..f4e111b --- /dev/null +++ b/licenses/J2ME WTK BinaryLicense.html @@ -0,0 +1,178 @@ + + + + + + + + +
Sun Microsystems, Inc.
+
+ +
Binary Code License Agreement
+
+
+ READ THE TERMS OF THIS AGREEMENT AND ANY PROVIDED SUPPLEMENTAL LICENSE +TERMS (COLLECTIVELY "AGREEMENT") CAREFULLY BEFORE OPENING THE SOFTWARE MEDIA +PACKAGE.  BY OPENING THE SOFTWARE MEDIA PACKAGE, YOU AGREE TO THE TERMS +OF THIS AGREEMENT.  IF YOU ARE ACCESSING THE SOFTWARE ELECTRONICALLY, +INDICATE YOUR ACCEPTANCE OF THESE TERMS BY SELECTING THE "ACCEPT" BUTTON +AT THE END OF THIS AGREEMENT.  IF YOU DO NOT AGREE TO ALL THESE TERMS, +PROMPTLY RETURN THE UNUSED SOFTWARE TO YOUR PLACE OF PURCHASE FOR A REFUND +OR, IF THE SOFTWARE IS ACCESSED ELECTRONICALLY, SELECT THE "DECLINE" BUTTON +AT THE END OF THIS AGREEMENT.
+
+ 1. LICENSE TO USE.  Sun grants you a non-exclusive and non-transferable + license for the internal use only of the accompanying software and documentation + and any error corrections provided by Sun (collectively "Software"), by +the number of users and the class of computer hardware for which the corresponding + fee has been paid.
+
+ 2. RESTRICTIONS.  Software is confidential and copyrighted. +Title to Software and all associated intellectual property rights is retained +by Sun and/or its licensors.  Except as specifically authorized in any + Supplemental License Terms, you may not make copies of Software, other than + a single copy of Software for archival purposes.  Unless enforcement + is prohibited by applicable law, you may not modify, decompile, or reverse + engineer Software.  You acknowledge that Software is not designed, +licensed or intended for use in the design, construction, operation or maintenance + of any nuclear facility.  Sun disclaims any express or implied warranty + of fitness for such uses.  No right, title or interest in or to any +trademark, service mark, logo or trade name of Sun or its licensors is granted +under this Agreement.
+
+ 3. LIMITED WARRANTY.  Sun warrants to you that for a period +of ninety (90) days from the date of purchase, as evidenced by a copy of the +receipt, the media on which Software is furnished (if any) will be free of +defects in materials and workmanship under normal use.  Except for the +foregoing, Software is provided "AS IS".  Your exclusive remedy and +Sun's entire liability under this limited warranty will be at Sun's option + to replace Software media or refund the fee paid for Software.
+
+  4. DISCLAIMER OF WARRANTY.  UNLESS SPECIFIED IN THIS +AGREEMENT, ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, +INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE OR NON-INFRINGEMENT ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT THESE +DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.
+
+ 5. LIMITATION OF LIABILITY.  TO THE EXTENT NOT PROHIBITED BY + LAW, IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, + PROFIT OR DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + DAMAGES, HOWEVER CAUSED REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT + OF OR RELATED TO THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS + BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.  In no event will +Sun's liability to you, whether in contract, tort (including negligence), +or otherwise, exceed the amount paid by you for Software under this Agreement.  +The foregoing limitations will apply even if the above stated warranty fails +of its essential purpose.
+
+ 6. Termination.  This Agreement is effective until terminated.  + You may terminate this Agreement at any time by destroying all copies of +Software.  This Agreement will terminate immediately without notice +from Sun if you fail to comply with any provision of this Agreement.  +Upon Termination, you must destroy all copies of Software.
+
+ 7. Export Regulations. All Software and technical data delivered +under this Agreement are subject to US export control laws and may be subject +to export or import regulations in other countries.  You agree to comply + strictly with all such laws and regulations and acknowledge that you have + the responsibility to obtain such licenses to export, re-export, or import + as may be required after delivery to you.
+
+ 8. U.S. Government Restricted Rights.  If Software is being +acquired by or on behalf of the U.S. Government or by a U.S. Government prime +contractor or subcontractor (at any tier), then the Government's rights in +Software and accompanying documentation will be only as set forth in this +Agreement; this is in accordance with 48 CFR 227.7201 through 227.7202-4 (for +Department of Defense (DOD) acquisitions) and with 48 CFR 2.101 and 12.212 +(for non-DOD acquisitions).
+
+ 9. Governing Law.  Any action related to this Agreement will + be governed by California law and controlling U.S. federal law.  No +choice of law rules of any jurisdiction will apply.
+
+ 10. Severability. If any provision of this Agreement is held to +be unenforceable, this Agreement will remain in effect with the provision +omitted, unless omission would frustrate the intent of the parties, in which +case this Agreement will immediately terminate.
+
+ 11. Integration.  This Agreement is the entire agreement between + you and Sun relating to its subject matter.  It supersedes all prior + or contemporaneous oral or written communications, proposals, representations + and warranties and prevails over any conflicting or additional terms of +any quote, order, acknowledgment, or other communication between the parties +relating to its subject matter during the term of this Agreement.  No +modification of this Agreement will be binding, unless in writing and signed +by an authorized representative of each party.
+
+ +
JAVA(TM) DEVELOPMENT TOOLS
+
+ J2ME(TM) WIRELESS TOOLKIT (J2ME WTK), VERSION 2.1.x
+ SUPPLEMENTAL LICENSE TERMS

+

+
+  These supplemental license terms ("Supplemental Terms") add to or +modify the terms of the Binary Code License Agreement (collectively, the "Agreement"). +Capitalized terms not defined in these Supplemental Terms shall have the +same meanings ascribed to them in the Agreement. These Supplemental Terms +shall supersede any inconsistent or conflicting terms in the Agreement, or +in any license contained within the Software.
+
+
+ 1. Software Internal Use and Development License Grant. Subject +to the terms and conditions of this Agreement, including, but not limited +to Section 2 (Java Technology Restrictions) of these Supplemental Terms, +Sun grants you a non-exclusive, non-transferable, limited license to reproduce + internally and use internally the binary form of the Software complete and + unmodified for the sole purpose of designing, developing and testing your + Java applets and applications intended to run on the Java platform ("Programs") + provided that any executable output generated by a compiler that is contained + in the Software must (a) only be compiled from source code that conforms +to the corresponding version of the OEM Java Language Specification; (b) +be in the class file format defined by the corresponding version of the OEM +Java Virtual Machine Specification; and (c) execute properly on a reference +runtime, as specified by Sun, associated with such version of the Java platform. +
+
+ 2. Java Technology Restrictions. You may not modify the Java Platform + Interface ("JPI", identified as classes contained within the "java" package + or any subpackages of the "java" package), by creating additional classes + within the JPI or otherwise causing the addition to or modification of the + classes in the JPI.  In the event that you create an additional class + and associated API(s) which (i) extends the functionality of the Java platform, + and (ii) is exposed to third party software developers for the purpose of + developing additional software which invokes such additional API, you must + promptly publish broadly an accurate specification for such API for free +use by all developers. You may not create, or authorize your licensees to +create, additional classes, interfaces, or subpackages that are in any way +identified as "java", "javax", "sun" or similar convention as specified by +Sun in any naming convention designation.
+
+ 3. Java Runtime Availability.  Refer to the appropriate version + of the Java Runtime Environment binary code license (currently located at + http://www.java.sun.com/jdk/index.html) for the availability of runtime +code which may be distributed with Java applets and applications.
+
+ 4. Trademarks and Logos. You acknowledge and agree as between you + and Sun that Sun owns the SUN, SOLARIS, JAVA, JINI, FORTE, and iPLANET trademarks + and all SUN, SOLARIS, JAVA, JINI, FORTE, and iPLANET-related trademarks, +service marks, logos and other brand designations ("Sun Marks"), and you +agree to comply with the Sun Trademark and Logo Usage Requirements currently +located at http://www.sun.com/policies/trademarks. Any use you make of the +Sun Marks inures to Sun's benefit.
+
+ 5. Source Code. Software may contain source code that is provided + solely for reference purposes pursuant to the terms of this Agreement.  + Source code may not be redistributed unless expressly provided for in this + Agreement. 6. Termination for Infringement.  Either party may terminate + this Agreement immediately should any Software become, or in either party's + opinion be likely to become, the subject of a claim of infringement of any + intellectual property right.
+
+  For inquiries please contact: Sun Microsystems, Inc.  4150 Network + Circle, Santa Clara, California 95054, U.S.A.
+ (Form ID#011801)
+ + + diff --git a/licenses/RmsIndex License.txt b/licenses/RmsIndex License.txt new file mode 100644 index 0000000..c5e2d86 --- /dev/null +++ b/licenses/RmsIndex License.txt @@ -0,0 +1,20 @@ +/* Copyright (c) 2002,2003, Stefan Haustein, Oberhausen, Rhld., Germany + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ \ No newline at end of file diff --git a/midp-1/net/thauvin/j2me/yahoome/Util.java b/midp-1/net/thauvin/j2me/yahoome/Util.java new file mode 100644 index 0000000..a7ba3b2 --- /dev/null +++ b/midp-1/net/thauvin/j2me/yahoome/Util.java @@ -0,0 +1,100 @@ +/* + * @(#)Util.java + * + * Copyright (c) 2004-2005, Erik C. Thauvin (http://www.thauvin.net/erik/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the authors nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.j2me.yahoome; + +import javax.microedition.lcdui.Choice; +import javax.microedition.lcdui.ChoiceGroup; +import javax.microedition.lcdui.Display; +import javax.microedition.lcdui.Item; +import javax.microedition.lcdui.TextField; + + +/** + * The Util class implements methods specific to MIDP 1.x. + * + * @author Erik C. Thauvin + * @version $Revision$, $Date$ + * @created October 8, 2004 + * @since 1.0 + */ +public class Util +{ + /** + * Disables the default constructor. + * + * @throws UnsupportedOperationException if the constructor is called. + */ + private Util() + { + ; + } + + /** + * Returns a new exclusive choice group. + * + * @param title The title. + * @param choices The choices. + * + * @return The choice group. + */ + public static ChoiceGroup getChoiceGroup(String title, String[] choices) + { + return new ChoiceGroup(title, Choice.EXCLUSIVE, choices, null); + } + + /** + * Sets the current item. + * + * @param screen The screen. + * @param item The item. + */ + public static void setCurrentItem(Display screen, Item item) + { + ; // Do nothing + } + + /** + * Sets the initial input mode of the given text field. + * + * @param field The text field. + * @param inputMode The input mode. + */ + public static void setInitialInputMode(TextField field, String inputMode) + { + ; // Do nothing + } +} diff --git a/midp-2/net/thauvin/j2me/yahoome/Util.java b/midp-2/net/thauvin/j2me/yahoome/Util.java new file mode 100644 index 0000000..a405865 --- /dev/null +++ b/midp-2/net/thauvin/j2me/yahoome/Util.java @@ -0,0 +1,97 @@ +/* + * @(#)Util.java + * + * Copyright (c) 2004-2005, Erik C. Thauvin (http://www.thauvin.net/erik/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the authors nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.j2me.yahoome; + +import javax.microedition.lcdui.ChoiceGroup; +import javax.microedition.lcdui.Display; +import javax.microedition.lcdui.Item; +import javax.microedition.lcdui.TextField; + + +/** + * The Util class implements methods specific to MIDP 2.x. + * + * @author Erik C. Thauvin + * @version $Revision$, $Date$ + * @created October 8, 2004 + * @since 1.0 + */ +public class Util +{ + /** + * Disables the default constructor. + */ + private Util() + { + ; + } + + /** + * Returns a new exclusive choice group. + * + * @param title The title. + * @param choices The choices. + * + * @return The choice group. + */ + public static ChoiceGroup getChoiceGroup(String title, String[] choices) + { + return new ChoiceGroup(title, ChoiceGroup.POPUP, choices, null); + } + + /** + * Sets the current item. + * + * @param screen The screen. + * @param item The item. + */ + public static void setCurrentItem(Display screen, Item item) + { + screen.setCurrentItem(item); + } + + /** + * Sets the initial input mode of the given text field. + * + * @param field The text field. + * @param inputMode The input mode. + */ + public static void setInitialInputMode(TextField field, String inputMode) + { + field.setInitialInputMode(inputMode); + } +} diff --git a/res/.cvsignore b/res/.cvsignore new file mode 100644 index 0000000..98e6ef6 --- /dev/null +++ b/res/.cvsignore @@ -0,0 +1 @@ +*.db diff --git a/res/yahoome.png b/res/yahoome.png new file mode 100644 index 0000000..29d642d Binary files /dev/null and b/res/yahoome.png differ diff --git a/src/net/thauvin/j2me/yahoome/HelpScreen.java b/src/net/thauvin/j2me/yahoome/HelpScreen.java new file mode 100644 index 0000000..cd57dad --- /dev/null +++ b/src/net/thauvin/j2me/yahoome/HelpScreen.java @@ -0,0 +1,83 @@ +/* + * @(#)HelpScreen.java + * + * Copyright (c) 2004-2005, Erik C. Thauvin (http://www.thauvin.net/erik/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the authors nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.j2me.yahoome; + +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.StringItem; + + +/** + * The HelpScreen class implements a form used to display some help. + * + * @author Erik C. Thauvin + * @version $Revision$, $Date$ + * @created October 8, 2004 + * @since 1.0 + */ +public class HelpScreen extends Form +{ + /** + * Creates a new HelpScreen instance. + * + * @param midlet The MIDlet instance. + */ + public HelpScreen(YahooME midlet) + { + super(YahooME.APP_NAME + " Help"); + + append(new StringItem(YahooME.CHOICE_YAHOO_SMS + ": ", + "Instantly find any local business, from pizza parlors to florists. Type: [type of business] [city] [state] or [type of business] [zip code] or [name of business] [city] [state] or [name of business] [zip code]\n\n")); + append(new StringItem(YahooME.CHOICE_YAHOO_LOCAL + ": ", + "Instantly find any local business, from pizza parlors to florists. Type: [type of business] or [name of business]. The permanent location setting is automatically added to your query.\n\n")); + append(new StringItem(YahooME.CHOICE_STOCK + ": ", "Get the price of any stock with links to quotes, charts, news, and more. Type: [ticker symbol]\n\n")); + append(new StringItem(YahooME.CHOICE_HOROSCOPE + ": ", + "Are the stars aligned for you today? Type: [sign]\n\n")); + append(new StringItem(YahooME.CHOICE_WIFI + ": ", + "Find the closest WIFI hotspot. Type [zip code] or [city] [state]\n\n")); + append(new StringItem(YahooME.CHOICE_AREA_CODE + ": ", + "Find out where your call's coming from. Type: [3-digit area code]\n\n")); + append(new StringItem(YahooME.CHOICE_DEFINITION + ": ", "Get the definition of any English word. Type: [word]\n\n")); + append(new StringItem(YahooME.CHOICE_ZIP + ": ", "Find the zip codes for any city. Type: [city]\n\n")); + + append(new StringItem(YahooME.CHOICE_WEATHER + ": ", + "Get current conditions and a 3-day forecast for over 50,000 cities worldwide. Type: weather [zip code] or weather [city] [state].\n\n")); + + addCommand(YahooME.COMMAND_BACK); + + setCommandListener(midlet); + } +} diff --git a/src/net/thauvin/j2me/yahoome/HistoryScreen.java b/src/net/thauvin/j2me/yahoome/HistoryScreen.java new file mode 100644 index 0000000..e019be7 --- /dev/null +++ b/src/net/thauvin/j2me/yahoome/HistoryScreen.java @@ -0,0 +1,65 @@ +/* + * @(#)HistoryScreen.java + * + * Copyright (c) 2004-2005, Erik C. Thauvin (http://www.thauvin.net/erik/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the authors nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.j2me.yahoome; + +import javax.microedition.lcdui.List; + + +/** + * The HistoryScreen class implements a form used to display the history. + * + * @author Erik C. Thauvin + * @version $Revision$, $Date$ + * @created Oct 12, 2004 + * @since 1.0 + */ +public class HistoryScreen extends List +{ + /** + * Creates a new HistoryScreen object. + * + * @param midlet The MIDlet instance. + */ + public HistoryScreen(YahooME midlet) + { + super(YahooME.APP_NAME + " History", List.IMPLICIT); + + addCommand(YahooME.COMMAND_BACK); + + setCommandListener(midlet); + } +} diff --git a/src/net/thauvin/j2me/yahoome/MainScreen.java b/src/net/thauvin/j2me/yahoome/MainScreen.java new file mode 100644 index 0000000..b9ad428 --- /dev/null +++ b/src/net/thauvin/j2me/yahoome/MainScreen.java @@ -0,0 +1,90 @@ +/* + * @(#)MainScreen.java + * + * Copyright (c) 2004-2005, Erik C. Thauvin (http://www.thauvin.net/erik/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the authors nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.j2me.yahoome; + +import javax.microedition.lcdui.ChoiceGroup; +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.TextField; + + +/** + * The MainScreen class implements a form used to gather the data needed to perform a Yahoo! SMS query. + * + * @author Erik C. Thauvin + * @version $Revision$, $Date$ + * @created October 8, 2004 + * @since 1.0 + */ +public class MainScreen extends Form +{ + /** + * The query action popup. + */ + protected /* final */ ChoiceGroup actionPopup; + + /** + * The query field. + */ + protected /* final */ TextField queryFld; + + /** + * Creates a new MainScreen object. + * + * @param midlet The MIDlet instance. + */ + public MainScreen(YahooME midlet) + { + super(YahooME.APP_NAME); + + queryFld = new TextField("Query: ", "", 25, TextField.ANY); + Util.setInitialInputMode(queryFld, "MIDP_LOWERCASE_LATIN"); + actionPopup = Util.getChoiceGroup("Type: ", YahooME.CHOICES); + actionPopup.setSelectedIndex(0, true); + append(queryFld); + append(actionPopup); + + addCommand(YahooME.COMMAND_SEND); + addCommand(YahooME.COMMAND_CLEAR); + addCommand(YahooME.COMMAND_HISTORY); + addCommand(YahooME.COMMAND_SETTINGS); + addCommand(YahooME.COMMAND_HELP); + addCommand(YahooME.COMMAND_ABOUT); + addCommand(YahooME.COMMAND_EXIT); + + setCommandListener(midlet); + } +} diff --git a/src/net/thauvin/j2me/yahoome/PrefsScreen.java b/src/net/thauvin/j2me/yahoome/PrefsScreen.java new file mode 100644 index 0000000..fcb5621 --- /dev/null +++ b/src/net/thauvin/j2me/yahoome/PrefsScreen.java @@ -0,0 +1,88 @@ +/* + * @(#)PrefsScreen.java + * + * Copyright (c) 2004-2005, Erik C. Thauvin (http://www.thauvin.net/erik/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the authors nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.j2me.yahoome; + +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.StringItem; +import javax.microedition.lcdui.TextField; + + +/** + * The PrefsScreen class implements a form used to set the preferences. + * + * @author Erik C. Thauvin + * @version $Revision$, $Date$ + * @created Oct 12, 2004 + * @since 1.0 + */ +public class PrefsScreen extends Form +{ + /** + * The query field. + */ + protected /* final */ TextField locationFld; + + /** + * The SMS number field. + */ + protected /* final */ TextField smsFld; + + /** + * Creates a new PrefsScreen object. + * + * @param midlet The MIDlet instance. + */ + public PrefsScreen(YahooME midlet) + { + super(YahooME.APP_NAME + " Settings"); + + locationFld = new TextField("Location: ", "", 25, TextField.ANY); + + append(locationFld); + append(new StringItem("", "Your current city and state or zip. (e.g.: san francisco ca or 94123)")); + + smsFld = new TextField("Yahoo! SMS: ", "", 25, TextField.PHONENUMBER); + + append(smsFld); + append(new StringItem("", "The short code or number of the Yahoo! SMS service. (e.g.: 92466)")); + + addCommand(YahooME.COMMAND_BACK); + addCommand(YahooME.COMMAND_SAVE); + + setCommandListener(midlet); + } +} diff --git a/src/net/thauvin/j2me/yahoome/RmsIndex.java b/src/net/thauvin/j2me/yahoome/RmsIndex.java new file mode 100644 index 0000000..a1b319c --- /dev/null +++ b/src/net/thauvin/j2me/yahoome/RmsIndex.java @@ -0,0 +1,269 @@ +/* Copyright (c) 2002,2003, Stefan Haustein, Oberhausen, Rhld., Germany + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +package net.thauvin.j2me.yahoome; + +import javax.microedition.rms.*; +import java.io.*; + +/** + * An Rms based BTree index. Currently, the functionality is similar to a + * persistent hashtable. + */ +public class RmsIndex { + + static byte[] DUMMY = new byte[0]; + + RecordStore store; + + Node root; + + int n = 32; + + String cachedKey; + + Node cachedNode; + + int cachedIndex; + + /** Node helper class */ + class Node { + int index; + + int size; + + String[] keys = new String[n + n + 1]; + + String[] values = new String[n + n + 1]; + + int[] children = new int[n + n + 2]; + + /** Create a new Node */ + + Node() throws RecordStoreException { + index = store.addRecord(DUMMY, 0, 0); + } + + Node(Node split) throws RecordStoreException { + this(); + System.arraycopy(split.keys, n + 1, keys, 0, n); + System.arraycopy(split.values, n + 1, values, 0, n); + System.arraycopy(split.children, n + 1, children, 0, n + 1); + size = n; + split.size = n; + split.store(); + store(); + } + + /** Load the node at the given index position */ + + Node(int index) throws RecordStoreException { + this.index = index; + byte[] data = store.getRecord(index); + + if (data == null || data.length == 0) + return; + + try { + DataInputStream dis = new DataInputStream( + new ByteArrayInputStream(data)); + + size = dis.readInt(); + + for (int i = 0; i < size; i++) { + children[i] = dis.readInt(); + keys[i] = dis.readUTF(); + values[i] = dis.readUTF(); + } + + children[size] = dis.readInt(); + } catch (IOException e) { + throw new RuntimeException(e.toString()); + } + } + + public void put(String key, String value) throws RecordStoreException { + + int i; + for (i = 0; i < size; i++) { + int cmp = key.compareTo(keys[i]); + if (cmp == 0) { + values[i] = value; + store(); + return; + } else if (cmp < 0) + break; + } + + int newIndex = 0; + + if (children[i] != 0) { + Node child = new Node(children[i]); + child.put(key, value); + + if (child.size < n + n + 1) + return; + + Node split = new Node(child); + newIndex = split.index; + + key = child.keys[n]; + value = child.values[n]; + } + + System.arraycopy(keys, i, keys, i + 1, size - i); + System.arraycopy(values, i, values, i + 1, size - i); + System.arraycopy(children, i + 1, children, i + 2, size - i); + + keys[i] = key; + values[i] = value; + children[i + 1] = newIndex; + size++; + + if (size < n + n + 1) + // otherwise, store will be performed by uplink + store(); + } + + public void store() throws RecordStoreException { + + try { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + DataOutputStream dos = new DataOutputStream(bos); + dos.writeInt(size); + for (int i = 0; i < size; i++) { + dos.writeInt(children[i]); + dos.writeUTF(keys[i]); + dos.writeUTF(values[i]); + } + dos.writeInt(children[size]); + byte[] data = bos.toByteArray(); + store.setRecord(index, data, 0, data.length); + } catch (IOException e) { + throw new RuntimeException(e.toString()); + } + } + } + + /** + * Creates a new index with the given Name + */ + public RmsIndex(String name) throws RecordStoreException { + + store = RecordStore.openRecordStore(name, true); + root = store.getNumRecords() == 0 ? new Node() : new Node(1); + } + + /** + * Returns the value for the given key + * + * @param key: The key + * @return String: The value associated with the key, or null if none. + * @throws RecordStoreException + */ + public String get(String key) throws RecordStoreException { + + Node current = root; + + while (true) { + int i; + for (i = 0; i < current.size; i++) { + int cmp = key.compareTo(current.keys[i]); + if (cmp == 0) + return current.values[i]; + else if (cmp < 0) + break; + } + if (current.children[i] == 0) + return null; + current = new Node(current.children[i]); + } + } + + /** + * Assigns the given value to the given key persistently + * + * @param key: The key + * @param value: The value + * @throws RecordStoreException + */ + public void put(String key, String value) throws RecordStoreException { + + root.put(key, value); + if (root.size < n + n + 1) + return; + + // split root.... + + Node left = root; + root = new Node(); + + left.index = root.index; + root.index = 1; + + Node right = new Node(left); + + root.keys[0] = left.keys[n]; + root.values[0] = left.values[n]; + root.children[0] = left.index; + root.children[1] = right.index; + root.size = 1; + root.store(); + } + + public void close() throws RecordStoreException { + store.closeRecordStore(); + } + + public int size() throws RecordStoreException { + + Node current = root; + + return current.size; + + } + + public String get(int recordNum) throws RecordStoreException { + + Node current = root; + + return current.values[recordNum]; + + } + + public String getKey(int recordNum) throws RecordStoreException { + + Node current = root; + + return current.keys[recordNum]; + + } + + public void deleteAll(String name) throws RecordStoreException { + + store.closeRecordStore(); + RecordStore.deleteRecordStore(name); + store = RecordStore.openRecordStore(name, true); + root = store.getNumRecords() == 0 ? new Node() : new Node(1); + + } + +} \ No newline at end of file diff --git a/src/net/thauvin/j2me/yahoome/YahooME.java b/src/net/thauvin/j2me/yahoome/YahooME.java new file mode 100644 index 0000000..d3ccc3c --- /dev/null +++ b/src/net/thauvin/j2me/yahoome/YahooME.java @@ -0,0 +1,797 @@ +/* + * @(#)YahooME.java + * + * Copyright (c) 2004-2005, Erik C. Thauvin (http://www.thauvin.net/erik/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the authors nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.j2me.yahoome; + +import java.util.Vector; + +import javax.microedition.io.Connector; +import javax.microedition.lcdui.*; +import javax.microedition.midlet.MIDlet; +import javax.microedition.midlet.MIDletStateChangeException; +import javax.microedition.rms.RecordStoreException; + +import javax.wireless.messaging.MessageConnection; +import javax.wireless.messaging.TextMessage; + + +/** + * The YahooME class implements a simple front-end for Yahoo! SMS. + * + * @author Erik C. Thauvin + * @version $Revision$, $Date$ + * @created October 8, 2004 + * @since 1.0 + */ +public class YahooME extends MIDlet implements CommandListener, Runnable +{ + /** + * Definition choice. + */ + protected static final String CHOICE_DEFINITION = "Definitions"; + + /** + * Stock Quote choice. + */ + protected static final String CHOICE_STOCK = "Stock Quotes"; + + /** + * Local choice. + */ + protected static final String CHOICE_YAHOO_LOCAL = "Local Listings"; + + /** + * Horoscope choice. + */ + protected static final String CHOICE_HOROSCOPE = "Daily Horoscope"; + + /** + * Yahoo! SMS choice. + */ + protected static final String CHOICE_YAHOO_SMS = "Yahoo! SMS"; + + /** + * Weather choice. + */ + protected static final String CHOICE_WEATHER = "Weather"; + + /** + * Area Codes choice. + */ + protected static final String CHOICE_AREA_CODE = "Area Codes"; + + /** + * WIFI Hotspots choice. + */ + protected static final String CHOICE_WIFI = "WIFI Hotspots"; + + /** + * Zip Code choice. + */ + protected static final String CHOICE_ZIP = "Zip Codes"; + + + /** + * The About command. + */ + protected static final Command COMMAND_ABOUT = new Command("About", Command.SCREEN, 2); + + /** + * The application name. + */ + protected static final String APP_NAME = "YahooME"; + + /** + * The application version. + */ + protected static final String APP_VERSION = "0.1"; + + /** + * The Back command. + */ + protected static final Command COMMAND_BACK = new Command("Back", Command.BACK, 2); + + /** + * The action choices. + */ + protected static final String[] CHOICES = new String[] + { + CHOICE_YAHOO_SMS, CHOICE_YAHOO_LOCAL, CHOICE_WEATHER, CHOICE_STOCK, + CHOICE_DEFINITION, CHOICE_HOROSCOPE, CHOICE_WIFI, CHOICE_AREA_CODE, + CHOICE_ZIP + }; + + /** + * The Clear command. + */ + protected static final Command COMMAND_CLEAR = new Command("Clear", Command.SCREEN, 2); + + /** + * The Exit command. + */ + protected static final Command COMMAND_EXIT = new Command("Exit", Command.EXIT, 2); + + /** + * The Help command. + */ + protected static final Command COMMAND_HELP = new Command("Help", Command.HELP, 2); + + /** + * The History command. + */ + protected static final Command COMMAND_HISTORY = new Command("History", Command.SCREEN, 2); + + /** + * The Settings command. + */ + protected static final Command COMMAND_SETTINGS = new Command("Settings", Command.SCREEN, 2); + + /** + * The Save command. + */ + protected static final Command COMMAND_SAVE = new Command("Save", Command.OK, 1); + + /** + * The Send command. + */ + protected static final Command COMMAND_SEND = new Command("Send", Command.OK, 1); + + /** + * The history maximum size. + */ + private static final int MAX_HISTORY = 8; + + /** + * The description query prefix. + */ + private static final String PREFIX_DEFINITION = "D "; + + /** + * The Weather query prefix. + */ + private static final String PREFIX_WEATHER = "W "; + + /** + * The Horoscope query prefix. + */ + private static final String PREFIX_HOROSCOPE = "Horo "; + + /** + * The Stock Quote query prefix. + */ + private static final String PREFIX_STOCK = "Q "; + + + /** + * The WiFi Hotspots query prefix. + */ + private static final String PREFIX_WIFI = "Wifi "; + + /** + * The Area Code query prefix. + */ + private static final String PREFIX_AREA_CODE = "Area Code "; + + /** + * The Zip Code query prefix. + */ + private static final String PREFIX_ZIP = "Zip Code "; + + /** + * The history preferences key. + */ + private static final String PREFS_HISTORY_KEY = "h"; + + /** + * The location preferences key. + */ + private static final String PREFS_LOCATION_KEY = "l"; + + /** + * The address preferences key. + */ + private static final String PREFS_ADDRESS_KEY = "a"; + + // The current action. + private String _action = CHOICE_YAHOO_SMS; + + // The Yahoo! SMS address. + private String _address = "92466"; + + // The default error/message alert dialog. + private Alert _defaultAlert; + + // The display instance. + private Display _display; + + // The first time flag. + private boolean _firstTime; + + // The help screen. + private HelpScreen _helpScreen; + + // The history. + private /* final */ Vector _history = new Vector(8); + + // The history screen. + private HistoryScreen _historyScreen; + + // The location. + private String _location = ""; + + // The main screen. + private /* final */ MainScreen _mainScreen; + + // The preferences store. + private RmsIndex _prefs; + + // The preferences screen. + private PrefsScreen _prefsScreen; + + // The current query. + private String _query = ""; + + // The sending message alert dialog. + private Alert _sendingAlert; + + /** + * Creates a new YahooME instance. + */ + public YahooME() + { + super(); + + _mainScreen = new MainScreen(this); + _firstTime = true; + } + + /** + * Performs a command. + * + * @param c The command action. + * @param d The diplayable screen. + */ + public /* final */ void commandAction(Command c, Displayable d) + { + if (c == COMMAND_EXIT) + { + exit(); + } + else if (c == COMMAND_ABOUT) + { + alert("About " + APP_NAME, + APP_NAME + ' ' + APP_VERSION + "\nCopyright 2005\nErik C. Thauvin\nerik@thauvin.net", d, false); + } + else if (c == COMMAND_CLEAR) + { + _mainScreen.queryFld.setString(""); + Util.setCurrentItem(_display, (Item) _mainScreen.queryFld); + } + else if (c == COMMAND_SEND) + { + if (isValidString(_address)) + { + /* final */ String q = _mainScreen.queryFld.getString(); + _action = CHOICES[_mainScreen.actionPopup.getSelectedIndex()]; + + if (isValidString(q)) + { + if ((_action.equals(CHOICE_YAHOO_LOCAL) && !isValidString(_location))) + { + alert("No Location", "Please set a location first.", d, true); + } + else + { + if (_sendingAlert == null) + { + _sendingAlert = new Alert(""); + } + + _query = buildQuery(q); + + addHistory(_query); + saveHistory(); + + alert(_sendingAlert, "Sending SMS", "Sending message to " + _address + "...", d, 2500, false); + + new Thread(this).start(); + } + } + else + { + Util.setCurrentItem(_display, (Item) _mainScreen.queryFld); + alert("Invalid Input", "Please specify a query.", d, true); + } + } + else + { + alert("No SMS Address", "Please set the Yahoo! SMS number.", d, true); + } + } + else if (c == COMMAND_SETTINGS) + { + if (_prefsScreen == null) + { + _prefsScreen = new PrefsScreen(this); + } + + _prefsScreen.smsFld.setString(_address); + _prefsScreen.locationFld.setString(_location); + + _display.setCurrent(_prefsScreen); + } + else if (c == COMMAND_SAVE) + { + _location = _prefsScreen.locationFld.getString(); + _address = _prefsScreen.smsFld.getString(); + + _display.setCurrent(_mainScreen); + + saveSettings(); + } + else if (c == COMMAND_HISTORY) + { + if (_historyScreen == null) + { + _historyScreen = new HistoryScreen(this); + } + + int size = _historyScreen.size(); + + if (size > 0) + { + for (int i = 0; i < size; i++) + { + _historyScreen.delete(0); + } + } + + size = _history.size(); + + if (size > 0) + { + for (int i = 0; i < size; i++) + { + _historyScreen.append((String) _history.elementAt(i), null); + } + + _display.setCurrent(_historyScreen); + } + else + { + alert("No History", "There is no history to display.", d, true); + } + } + else if (c == List.SELECT_COMMAND) + { + /* final */ String query = _historyScreen.getString(_historyScreen.getSelectedIndex()); + + // Definition + if (query.startsWith(PREFIX_DEFINITION)) + { + _mainScreen.queryFld.setString(query.substring(query.indexOf(' ') + 1)); + _mainScreen.actionPopup.setSelectedIndex(choiceIndex(CHOICE_DEFINITION), true); + } + + // Horoscope + else if (query.startsWith(PREFIX_HOROSCOPE)) + { + _mainScreen.queryFld.setString(query.substring(query.indexOf(' ') + 1)); + _mainScreen.actionPopup.setSelectedIndex(choiceIndex(CHOICE_HOROSCOPE), true); + } + + // Stock Quote + else if (query.startsWith(PREFIX_STOCK)) + { + _mainScreen.queryFld.setString(query.substring(query.indexOf(' ') + 1)); + _mainScreen.actionPopup.setSelectedIndex(choiceIndex(CHOICE_STOCK), true); + } + + // Weather + else if (query.startsWith(PREFIX_WEATHER)) + { + _mainScreen.queryFld.setString(query.substring(PREFIX_WEATHER.length())); + _mainScreen.actionPopup.setSelectedIndex(choiceIndex(CHOICE_WEATHER), true); + } + + // Area Code + else if (query.startsWith(PREFIX_AREA_CODE)) + { + _mainScreen.queryFld.setString(query.substring(PREFIX_AREA_CODE.length())); + _mainScreen.actionPopup.setSelectedIndex(choiceIndex(CHOICE_AREA_CODE), true); + } + + // Zip Code + else if (query.startsWith(PREFIX_ZIP)) + { + _mainScreen.queryFld.setString(query.substring(PREFIX_ZIP.length())); + _mainScreen.actionPopup.setSelectedIndex(choiceIndex(CHOICE_ZIP), true); + } + + // WiFi Hotspots + else if (query.startsWith(PREFIX_WIFI)) + { + _mainScreen.queryFld.setString(query.substring(PREFIX_WIFI.length())); + _mainScreen.actionPopup.setSelectedIndex(choiceIndex(CHOICE_WIFI), true); + } + + // Local + else if (isValidString(_location) && query.endsWith(' ' + _location)) + { + _mainScreen.queryFld.setString(query.substring(0, query.lastIndexOf(' '))); + _mainScreen.actionPopup.setSelectedIndex(choiceIndex(CHOICE_YAHOO_LOCAL), true); + } + else + { + _mainScreen.queryFld.setString(query); + _mainScreen.actionPopup.setSelectedIndex(choiceIndex(CHOICE_YAHOO_SMS), true); + } + + _display.setCurrent(_mainScreen); + } + else if (c == COMMAND_HELP) + { + if (_helpScreen == null) + { + _helpScreen = new HelpScreen(this); + } + + _display.setCurrent(_helpScreen); + } + else if (c == COMMAND_BACK) + { + _display.setCurrent(_mainScreen); + } + } + + /** + * Executes the thread. + */ + public /* final */ void run() + { + sendSMS(); + } + + /** + * @see javax.microedition.midlet.MIDlet#destroyApp(boolean) + */ + protected void destroyApp(boolean b) + throws MIDletStateChangeException + { + try + { + if (_prefs != null) + { + _prefs.close(); + } + } + catch (RecordStoreException e) + { + alert("Close Error", "Could not close the preferences store: " + e.getMessage(), _mainScreen, true); + } + + notifyDestroyed(); + } + + /** + * @see javax.microedition.midlet.MIDlet#pauseApp() + */ + protected /* final */ void pauseApp() + { + ; + } + + /** + * @see javax.microedition.midlet.MIDlet#startApp() + */ + protected /* final */ void startApp() + throws MIDletStateChangeException + { + if (_firstTime) + { + try + { + _prefs = new RmsIndex("YahooME"); + + String item; + + // Load the history. + for (int i = 0; i < MAX_HISTORY; i++) + { + item = _prefs.get(PREFS_HISTORY_KEY + i); + + if (item != null) + { + _history.addElement(item); + } + else + { + break; + } + } + + // Load the location. + item = _prefs.get(PREFS_LOCATION_KEY); + + if (item != null) + { + _location = item; + } + + // Load the address. + item = _prefs.get(PREFS_ADDRESS_KEY); + + if (item != null) + { + _address = item; + } + } + catch (RecordStoreException e) + { + alert("Load Error", "Could not load the preferences: " + e.getMessage(), _mainScreen, true); + } + + _firstTime = false; + } + + _display = Display.getDisplay(this); + _display.setCurrent(_mainScreen); + } + + // Return the index of the given choice. + private static int choiceIndex(String choice) + { + for (int i = 0; i < CHOICES.length; i++) + { + if (CHOICES[i].equals(choice)) + { + return i; + } + } + + return 0; + } + + // Validates a string. + private static boolean isValidString(String s) + { + return ((s != null) && (s.length() > 0)); + } + + // Adds to the history. + private void addHistory(String query) + { + if (_history.size() == MAX_HISTORY) + { + _history.removeElementAt(MAX_HISTORY - 1); + } + + _history.insertElementAt(query, 0); + } + + // Displays a modal message/error alert dialog. + private void alert(String title, String msg, Displayable d, boolean isError) + { + if (_defaultAlert == null) + { + _defaultAlert = new Alert(""); + } + + alert(_defaultAlert, title, msg, d, Alert.FOREVER, isError); + } + + // Displays a message/error alert dialog. + private void alert(Alert alert, String title, String msg, Displayable d, int timeout, boolean isError) + { + if (title != null) + { + alert.setTitle(title); + } + + alert.setString(msg); + alert.setType(isError ? AlertType.ERROR : AlertType.INFO); + + alert.setTimeout(timeout); + + _display.setCurrent(alert, d); + } + + // Builds the full query . + private String buildQuery(String query) + { + /* final */ String text; + + if (_action.equals(CHOICE_YAHOO_LOCAL)) + { + if (isValidString(_location)) + { + text = query + ' ' + _location; + } + else + { + text = query; + } + } + + // Stock + else if (_action.equals(CHOICE_STOCK)) + { + text = PREFIX_STOCK + query; + } + + // Horoscope + else if (_action.equals(CHOICE_HOROSCOPE)) + { + text = PREFIX_HOROSCOPE + query; + } + + // Definition + else if (_action.equals(CHOICE_DEFINITION)) + { + text = PREFIX_DEFINITION + query; + } + + // WIFI + else if (_action.equals(CHOICE_WIFI)) + { + text = PREFIX_WIFI + query; + } + + // Area Code + else if (_action.equals(CHOICE_AREA_CODE)) + { + text = PREFIX_AREA_CODE + query; + } + + // Weather + else if (_action.equals(CHOICE_WEATHER)) + { + text = PREFIX_WEATHER + query; + } + + // Zip Code + else if (_action.equals(CHOICE_ZIP)) + { + text = PREFIX_ZIP + query; + } + + // Default + else + { + text = query; + } + + return text; + } + + // Exits the application. + private void exit() + { + try + { + destroyApp(false); + } + catch (MIDletStateChangeException ignore) + { + ; // Do nothing + } + } + + // Saves the history. + private void saveHistory() + { + try + { + if (_prefs != null) + { + /* final */ int size = _history.size(); + + // Save the history. + for (int i = 0; i < size; i++) + { + _prefs.put(PREFS_HISTORY_KEY + i, (String) _history.elementAt(i)); + } + } + } + catch (RecordStoreException e) + { + alert("Save Error", "Could not save the history: " + e.getMessage(), _mainScreen, true); + } + } + + // Saves the settings. + private void saveSettings() + { + try + { + if (_prefs != null) + { + // Save the location. + _prefs.put(PREFS_LOCATION_KEY, _location); + + // Save the address. + _prefs.put(PREFS_ADDRESS_KEY, _address); + } + } + catch (RecordStoreException e) + { + alert("Save Error", "Could not save the settings: " + e.getMessage(), _mainScreen, true); + } + } + + // Sends the SMS. + private void sendSMS() + { + /* final */ String address = "sms://" + _address; + MessageConnection conn = null; + + try + { + conn = (MessageConnection) Connector.open(address); + + /* final */ TextMessage msg = (TextMessage) conn.newMessage(MessageConnection.TEXT_MESSAGE); + msg.setAddress(address); + + msg.setPayloadText(_query); + + conn.send(msg); + + //alert("SMS Sent", "The text message was sent.", _mainScreen, false); + } + catch (SecurityException e) + { + alert("SMS Error", "Access to SMS was refused: " + e.getMessage(), _mainScreen, true); + } + catch (Exception e) + { + alert("SMS Error", "The text message could not be sent: " + e.getMessage(), _mainScreen, true); + } + finally + { + try + { + if (conn != null) + { + conn.close(); + } + } + catch (Exception ignore) + { + ; // Do nothing; + } + } + } +} diff --git a/yahoome.gif b/yahoome.gif new file mode 100644 index 0000000..a5f1d62 Binary files /dev/null and b/yahoome.gif differ diff --git a/yahoome.wml b/yahoome.wml new file mode 100644 index 0000000..5d748e2 --- /dev/null +++ b/yahoome.wml @@ -0,0 +1,24 @@ + + + + + +

+ YahooME 0.1 (~13Kb)
+

+

+ MIDP 2.0
+ Download Jad
+ Download Jar
+

+

+ MIDP 1.0
+ Download Jad
+ Download Jar
+

+
+