Click here to Skip to main content
15,920,217 members
Home / Discussions / Java
   

Java

 
AnswerRe: go through an HTML file and create a list of all the bold and italic words Pin
427748030-Aug-09 12:18
427748030-Aug-09 12:18 
QuestionJava code of Vernam Cipher Algorithm Pin
Munna Bhagat28-Aug-09 6:50
Munna Bhagat28-Aug-09 6:50 
AnswerRe: Java code of Vernam Cipher Algorithm Pin
David Crow28-Aug-09 8:42
David Crow28-Aug-09 8:42 
AnswerRe: Java code of Vernam Cipher Algorithm Pin
427748030-Aug-09 12:22
427748030-Aug-09 12:22 
Questionmaking msn plugin using java [modified] Pin
Muhammad Adeel Zahid28-Aug-09 6:45
Muhammad Adeel Zahid28-Aug-09 6:45 
AnswerRe: making msn plugin using java Pin
42774802-Sep-09 7:21
42774802-Sep-09 7:21 
QuestionRe: making msn plugin using java Pin
Muhammad Adeel Zahid2-Sep-09 11:38
Muhammad Adeel Zahid2-Sep-09 11:38 
AnswerRe: making msn plugin using java Pin
42774802-Sep-09 17:51
42774802-Sep-09 17:51 
I played around with JML and this is what I did:

1. created a dummy hotmail with user and password.
2. added the dummy to an existing hotmail through windows live messenger and accepted from both sides i.e. I accepted the mutual invitation from my dummy and existing.
3. I logged in to my existing account. I will see dummy offline.
4. Now to Java part.

Code 1: BasicMessenger.java

/*
 * Copyright 2004-2005 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


import net.sf.jml.MsnMessenger;
import net.sf.jml.impl.MsnMessengerFactory;

/**
 * @author Roger Chen
 */
public class BasicMessenger {

    private String email;
    private String password;

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    protected void initMessenger(MsnMessenger messenger) {
    }

    public void start() {
        //create MsnMessenger instance
        MsnMessenger messenger = MsnMessengerFactory.createMsnMessenger(email,
                password);

        //MsnMessenger support all protocols by default
        //messenger.setSupportedProtocol(new MsnProtocol[] { MsnProtocol.MSNP8 });

        //default init status is online, 
        //messenger.getOwner().setInitStatus(MsnUserStatus.BUSY);

        //log incoming message
        messenger.setLogIncoming(true);

        //log outgoing message
        messenger.setLogOutgoing(true);

        initMessenger(messenger);
        messenger.login();
    }

    public static void main(String[] args) throws Exception {
        //if (args.length != 3) {
        //    System.out.println("Usage: java messengerClassName email password");
        //    return;
       // }
        BasicMessenger messenger = (BasicMessenger) Class.forName("EchoMessenger")
                .newInstance();
        messenger.setEmail("dummyhotmail@hotmail.com");
        messenger.setPassword("password");//fake password
        messenger.start();
    }
}


I commented the 4 first lines in main and filled in the arg[0 to 3] data as shown above.

Code 2: EchoMessenger.java

/*
 * Copyright 2004-2005 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


import net.sf.jml.MsnContact;
import net.sf.jml.MsnMessenger;
import net.sf.jml.MsnSwitchboard;
import net.sf.jml.event.MsnMessageAdapter;
import net.sf.jml.message.MsnControlMessage;
import net.sf.jml.message.MsnDatacastMessage;
import net.sf.jml.message.MsnInstantMessage;

/**
 * @author Roger Chen
 */
public class EchoMessenger extends BasicMessenger {

    protected void initMessenger(MsnMessenger messenger) {
        messenger.addMessageListener(new MsnMessageAdapter() {

            public void instantMessageReceived(MsnSwitchboard switchboard,
                    MsnInstantMessage message, MsnContact contact) {
                //text message received
       
                //switchboard.sendMessage(message);
            }

            public void controlMessageReceived(MsnSwitchboard switchboard,
                    MsnControlMessage message, MsnContact contact) {
                //such as typing message and recording message
            	System.out.println("Type: ");
            	//System.out.println(message);
            	java.util.Scanner scan = new java.util.Scanner(System.in);
            	MsnInstantMessage  message2 = new MsnInstantMessage();
            	message2.setContent(scan.nextLine());
                switchboard.sendMessage(message2);
            }

            public void datacastMessageReceived(MsnSwitchboard switchboard,
                    MsnDatacastMessage message, MsnContact contact) {
                //such as Nudge
           
                switchboard.sendMessage(message);
            }

        });
    }

}


I simply modified method 2 to be able to send a message I type.

For your first post:
1. you need to use the code here to give it a nice Gui
2. embed your language correction.

For your second post:
1. It communicates with MSN Messenger as a sender only for example when you send nudge or so.
2. For the contacts it does get me all the contacts. Here you need to use the information of who is online and offline to create a list, then specify to whom you want to chat with.

As I was reading about this library to make a fully functional MSN takes time thats what the MSN2Go developer stated on his website. (his/her work is great check it out if you want)

Hope this helps.
QuestionRe: making msn plugin using java [modified] Pin
Muhammad Adeel Zahid22-Oct-09 1:45
Muhammad Adeel Zahid22-Oct-09 1:45 
QuestionRe: making msn plugin using java [modified] Pin
Muhammad Adeel Zahid4-Nov-09 19:47
Muhammad Adeel Zahid4-Nov-09 19:47 
QuestionSlow performance of javax.swing.JOptionPane.showOptionDialog Pin
Pasan Eeriyagama26-Aug-09 15:22
Pasan Eeriyagama26-Aug-09 15:22 
AnswerRe: Slow performance of javax.swing.JOptionPane.showOptionDialog Pin
Nagy Vilmos26-Aug-09 22:03
professionalNagy Vilmos26-Aug-09 22:03 
GeneralRe: Slow performance of javax.swing.JOptionPane.showOptionDialog Pin
Pasan Eeriyagama27-Aug-09 1:36
Pasan Eeriyagama27-Aug-09 1:36 
GeneralRe: Slow performance of javax.swing.JOptionPane.showOptionDialog Pin
woo_378304-Jun-10 21:44
woo_378304-Jun-10 21:44 
GeneralRe: Slow performance of javax.swing.JOptionPane.showOptionDialog Pin
woo_378304-Jun-10 21:49
woo_378304-Jun-10 21:49 
GeneralRe: Slow performance of javax.swing.JOptionPane.showOptionDialog Pin
woo_378304-Jun-10 21:51
woo_378304-Jun-10 21:51 
QuestionHelp! on concatenation Pin
hellboy_8326-Aug-09 10:53
hellboy_8326-Aug-09 10:53 
AnswerRe: Help! on concatenation Pin
David Skelly27-Aug-09 4:23
David Skelly27-Aug-09 4:23 
Questionmessenger using java Pin
Sedruol2k926-Aug-09 5:52
Sedruol2k926-Aug-09 5:52 
AnswerRe: messenger using java Pin
Nagy Vilmos26-Aug-09 5:58
professionalNagy Vilmos26-Aug-09 5:58 
AnswerRe: messenger using java Pin
Dave Kreskowiak26-Aug-09 6:17
mveDave Kreskowiak26-Aug-09 6:17 
QuestionInput field for time only! Pin
hellboy_8326-Aug-09 5:49
hellboy_8326-Aug-09 5:49 
AnswerRe: Input field for time only! Pin
Nagy Vilmos26-Aug-09 6:11
professionalNagy Vilmos26-Aug-09 6:11 
AnswerRe: Input field for time only! Pin
fly90426-Aug-09 6:26
fly90426-Aug-09 6:26 
GeneralRe: Input field for time only! Pin
Nagy Vilmos26-Aug-09 6:35
professionalNagy Vilmos26-Aug-09 6:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.