Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit c0ce20f7d3f2a60c9cdfc89589d87f9a2d20b1c7 @sh1mmer sh1mmer committed Sep 1, 2010
Showing 1,216 changed files with 19,968 additions and 0 deletions.
24 LICENSE
@@ -0,0 +1,24 @@
+Software Copyright License Agreement (BSD License)
+
+Copyright (c) 2010, Yahoo! Inc.
+All rights reserved.
+
+Redistribution and use of this software 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 Yahoo! Inc. nor the names of its
+ contributors may be used to endorse or promote products
+ derived from this software without specific prior
+ written permission of Yahoo! Inc.
+
+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.
+
+
27 README
@@ -0,0 +1,27 @@
+This SDK provides an interface to the Yahoo! Messenger API (http://developer.yahoo.com/messenger/) and a sample GUI app both written in Java.
+
+The Messenger SDK contains certain 3rd party open source libraries and tools. This file summarizes the tools used, their purpose, and the licenses under which they're released.
+
+The following 3rd party software package is not distributed as part of this project, but instead is separately downloaded from the respective provider and is only used as part of the separately packaged example code which illustrate how the SDK may be used:
+
+* Light Weight UI Toolkit (LWUIT)
+Licensed under GPL with classpath exception
+(https://lwuit.dev.java.net/)
+
+----------------------
+
+The following 3rd Party code is included as part of this Project:
+
+* json in Java version 0.5 See http://www.json.org
+
+Copyright (c) 2002 JSON.org
+
+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 shall be used for Good, not Evil.
+
+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.
+
+
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- You may freely edit this file. See commented blocks below for -->
+<!-- some examples of how to customize the build. -->
+<!-- (If you delete it and reopen the project it will be recreated.) -->
+<project name="YahooMessengerLWUIT" default="jar" basedir=".">
+ <description>Builds, tests, and runs the project .</description>
+ <import file="nbproject/build-impl.xml"/>
+ <!--
+
+ There exist several targets which are by default empty and which can be
+ used for execution of your tasks. These targets are usually executed
+ before and after some main targets. They are:
+
+ pre-init: called before initialization of project properties
+ post-init: called after initialization of project properties
+ pre-preprocess: called before text preprocessing of sources
+ post-preprocess: called after text preprocessing of sources
+ pre-compile: called before source compilation
+ post-compile: called after source compilation
+ pre-obfuscate: called before obfuscation
+ post-obfuscate: called after obfuscation
+ pre-preverify: called before preverification
+ post-preverify: called after preverification
+ pre-jar: called before jar building
+ post-jar: called after jar building
+ pre-build: called before final distribution building
+ post-build: called after final distribution building
+ pre-clean: called before cleaning build products
+ post-clean: called after cleaning build products
+
+ Example of pluging a my-special-task after the compilation could look like
+
+ <target name="post-compile">
+ <my-special-task>
+ <fileset dir="${build.classes.dir}"/>
+ </my-special-task>
+ </target>
+
+ For list of available properties check the imported
+ nbproject/build-impl.xml file.
+
+ Other way how to customize the build is by overriding existing main targets.
+ The target of interest are:
+
+ preprocess: preprocessing
+ extract-libs: extraction of libraries and resources
+ compile: compilation
+ create-jad: construction of jad and jar manifest source
+ obfuscate: obfuscation
+ preverify: preverification
+ jar: jar archive building
+ run: execution
+ debug: execution in debug mode
+ build: building of the final distribution
+ javadoc: javadoc generation
+
+ Example of overriding the target for project execution could look like
+
+ <target name="run" depends="init,jar">
+ <my-special-exec jadfile="${dist.dir}/${dist.jad}"/>
+ </target>
+
+ Be careful about correct dependencies when overriding original target.
+ Again, for list of available properties which you can use check the target
+ you are overriding in nbproject/build-impl.xml file.
+
+ A special target for-all-configs can be used to run some specific targets for
+ all project configurations in a sequence. File nbproject/build-impl.xml
+ already contains some "for-all" targets:
+
+ jar-all
+ javadoc-all
+ clean-all
+
+ Example of definition of target iterating over all project configurations:
+
+ <target name="jar-all">
+ <property name="target.to.call" value="jar"/>
+ <antcall target="for-all-configs"/>
+ </target>
+
+ -->
+</project>
@@ -0,0 +1 @@
+ignore me
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,6 @@
+MIDlet-1: HelloLWUITMidlet, ,com.yahoo.messenger.ui.MessengerLWUITMidlet
+MIDlet-Vendor: Vendor
+MIDlet-Name: YahooMessengerLWUIT
+MIDlet-Version: 1.0
+MicroEdition-Configuration: CLDC-1.1
+MicroEdition-Profile: MIDP-2.0
Binary file not shown.
@@ -0,0 +1,233 @@
+/**
+ * Copyright (c) 2009-2010, Yahoo! Inc. All rights reserved.
+ * Code licensed under the BSD License:
+ * http://searchmarketing.yahoo.com/developer/docs/license.txt
+ */
+
+package com.yahoo.messenger.ui;
+
+import com.sun.lwuit.Command;
+import com.sun.lwuit.Form;
+import com.sun.lwuit.List;
+import com.sun.lwuit.TextArea;
+import com.sun.lwuit.events.ActionEvent;
+import com.sun.lwuit.events.ActionListener;
+import com.sun.lwuit.layouts.BoxLayout;
+import com.sun.lwuit.list.DefaultListModel;
+import com.sun.lwuit.list.ListModel;
+import com.yahoo.messenger.beans.PropertyChangeListener;
+import com.yahoo.messenger.data.json.Contact;
+import com.yahoo.messenger.data.notification.json.Message;
+import com.yahoo.messenger.data.notification.json.Response;
+import com.yahoo.messenger.manager.YahooMessengerLoginManager;
+import com.yahoo.messenger.manager.YahooMessengerNotificationManager;
+import com.yahoo.messenger.manager.data.NotificationData;
+import com.yahoo.messenger.ui.task.SendMessageCancellableTask;
+import java.util.Hashtable;
+import org.netbeans.microedition.util.SimpleCancellableTask;
+
+
+public class MessengerChatScreen implements ActionListener, PropertyChangeListener {
+
+ private MessengerLWUITMidlet midlet;
+ private Contact contact;
+
+ private Form ymChatForm;
+ private TextArea ymChatTextArea;
+
+ private List ymConversationList;
+ private ListModel listModel;
+
+ private Hashtable messagesReceived;
+
+
+ public MessengerChatScreen(MessengerLWUITMidlet midlet,
+ Contact contact)
+ {
+
+ this.midlet = midlet;
+ this.contact = contact;
+
+ this.messagesReceived = new Hashtable();
+
+ YahooMessengerNotificationManager manager =
+ YahooMessengerNotificationManager.getInstance();
+ manager.addPropertyChangeListener(this);
+
+ }
+
+ public void displayYahooMessengerChatScreen() {
+
+ getYahooMessengerChatForm().show();
+
+ }
+
+ public Form getYahooMessengerChatForm() {
+
+ if (ymChatForm == null) {
+
+ ymChatForm = new Form("Chat with " + contact.getId());
+
+ ymChatForm.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
+ ymChatForm.addComponent(getYahooMessengerChatTextArea());
+ ymChatForm.addComponent(getYahooMessengerConversationList());
+ ymChatForm.addCommand(midlet.getYahooMessengerBackCommand());
+
+ ymChatForm.setCommandListener(this);
+
+ }
+
+ return ymChatForm;
+ }
+
+ public TextArea getYahooMessengerChatTextArea() {
+
+ if (ymChatTextArea == null) {
+ ymChatTextArea = new TextArea();
+ ymChatTextArea.addActionListener(this);
+ }
+
+ return ymChatTextArea;
+ }
+
+
+
+ public List getYahooMessengerConversationList() {
+
+ if (ymConversationList == null) {
+ listModel = new DefaultListModel();
+ ymConversationList = new List(listModel);
+ ymConversationList.addActionListener(this);
+ ymConversationList.setListCellRenderer(new MessengerChatScreenChatRenderer(this));
+ } else {
+ ymConversationList.setModel(listModel);
+ }
+
+ return ymConversationList;
+
+ }
+
+
+
+ public void actionPerformed(ActionEvent event) {
+
+
+ if (event.getSource() == ymChatTextArea)
+ {
+
+ Thread t = new Thread() {
+ public void run() {
+
+ String myLoginID = YahooMessengerLoginManager.getInstance().
+ getCurrentUsername();
+
+ String message = ymChatTextArea.getText();
+ performSendMessageTask(contact, message);
+ ymConversationList.addItem(new ChatScreenMessage(myLoginID, message));
+ ymChatTextArea.setText("");
+ ymChatForm.repaint();
+ ymConversationList.setSelectedIndex(ymConversationList.getModel().getSize()-1);
+ }
+ };
+ t.start();
+
+ } else {
+
+ Command c = event.getCommand();
+
+ if (c != null) {
+
+ int commandID = c.getId();
+
+ if (commandID == MessengerLWUITMidlet.BACK_COMMAND) {
+ midlet.changeApplicationState(MessengerLWUITMidlet.MIDLET_STATE_CONTACT_SCREEN);
+ } else if (commandID == MessengerLWUITMidlet.EXIT_COMMAND) {
+ midlet.exitApplication();
+ }
+ }
+
+ }
+ }
+
+ public void propertyChanged(Object id, Object oldValue, Object newValue) {
+
+ if (id.equals(YahooMessengerNotificationManager.NOTIFICATION)) {
+
+ NotificationData n = (NotificationData)newValue;
+ Response[] rlist = n.getResponseList().getResponses();
+
+ for (int i = 0; i < rlist.length; i++) {
+ if (rlist[i] instanceof Message) {
+
+ Message m = (Message)rlist[i];
+
+ if (!messagesReceived.containsKey(m.getSequence())) {
+ messagesReceived.put(m.getSequence(), m.getHash());
+ ymConversationList.addItem(new ChatScreenMessage(m.getSender(), m.getMsg()));
+ ymChatForm.repaint();
+ ymConversationList.setSelectedIndex(ymConversationList.getModel().getSize()-1);
+ }
+
+ }
+ }
+
+
+ }
+
+ }
+
+ public void performSendMessageTask(Contact contact, String message) {
+
+
+ SendMessageCancellableTask getPresenceTask =
+ new SendMessageCancellableTask(midlet, contact, message);
+
+ SimpleCancellableTask cTask = new SimpleCancellableTask(getPresenceTask);
+ cTask.run();
+
+
+ }
+
+ public class ChatScreenMessage {
+
+ private String sender;
+ private String message;
+
+ public ChatScreenMessage(String sender, String message) {
+
+ this.sender = sender;
+ this.message = message;
+
+ }
+ /**
+ * @return the sender
+ */
+ public String getSender() {
+ return sender;
+ }
+
+ /**
+ * @param sender the sender to set
+ */
+ public void setSender(String sender) {
+ this.sender = sender;
+ }
+
+ /**
+ * @return the message
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * @param message the message to set
+ */
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ }
+
+
+}
Oops, something went wrong.

0 comments on commit c0ce20f

Please sign in to comment.