@author evgs
| 25 | * @author evgs |
| 26 | */ |
| 27 | public class MoodList extends DefForm implements MIDPTextBox.TextBoxNotify { |
| 28 | |
| 29 | |
| 30 | String moodName; |
| 31 | |
| 32 | /** Creates a new instance of MoodList */ |
| 33 | |
| 34 | public MoodList() { |
| 35 | super(SR.MS_USERMOOD); |
| 36 | |
| 37 | int count=Moods.getInstance().moodValue.size(); |
| 38 | |
| 39 | for (int i=0; i<count; i++) { |
| 40 | itemsList.addElement(new MoodItem(i)); |
| 41 | } |
| 42 | |
| 43 | sort(itemsList); |
| 44 | enableListWrapping(true); |
| 45 | } |
| 46 | |
| 47 | public void cmdOk() { |
| 48 | eventOk(); |
| 49 | } |
| 50 | |
| 51 | public void eventOk() { |
| 52 | moodName = ((MoodItem)getFocusedObject()).getTipString(); |
| 53 | if (cursor==0) |
| 54 | OkNotify(null); |
| 55 | else |
| 56 | new MIDPTextBox(SR.MS_USERMOOD, Moods.getInstance().myMoodText, this); |
| 57 | } |
| 58 | |
| 59 | public void OkNotify(String moodText) { |
| 60 | publishTune(moodText, moodName); |
| 61 | parentView = sd.roster; |
| 62 | destroyView(); |
| 63 | } |
| 64 | |
| 65 | private void publishTune(final String moodText, final String moodName) { |
| 66 | String sid="publish-mood"; |
| 67 | JabberDataBlock setMood=new Iq(null, Iq.TYPE_SET, sid); |
| 68 | JabberDataBlock action=setMood.addChildNs("pubsub", "http://jabber.org/protocol/pubsub") .addChild( (moodText!=null)?"publish":"retract", null); |
| 69 | action.setAttribute("node", "http://jabber.org/protocol/mood"); |
| 70 | JabberDataBlock item=action.addChild("item", null); |
| 71 | item.setAttribute("id", Moods.getInstance().myMoodId); |
| 72 | |
| 73 | if (moodText!=null) { |
| 74 | JabberDataBlock mood=item.addChildNs("mood", "http://jabber.org/protocol/mood"); |
| 75 | |
| 76 | mood.addChild(moodName, null); |
| 77 | mood.addChild("text",moodText); |
| 78 | } else { |
| 79 | item.addChild("retract", null); |
| 80 | action.setAttribute("notify","1"); |
| 81 | } |
| 82 | try { |
| 83 | //todo: refactor theStream call; send notification to JabberBlockListener if stream was terminated |
| 84 | StaticData.getInstance().getTheStream().addBlockListener(new PepPublishResult( sid)); |
nothing calls this directly
no outgoing calls
no test coverage detected