Menu

Easy Client-Program

sebbi89
2007-09-04
2012-09-15
  • sebbi89

    sebbi89 - 2007-09-04

    Hi,

    today I had discovered these great Java API. First I tried to log in at the icq server with my account and I was happy when that worked.

    Then I tried to do something more but I wasn't really succesfull. So I want to ask here if it's possible that someone shows me a code of an easy program that logs in on icq and gets the ID's of all Users in my ICQ-List (maybe the ID's can be saved in an Array?) and finally also the status of them.

    It would be great if someone could do this. Thank's a lot

    Sebastian

     
    • Daniel

      Daniel - 2007-09-04

      Hi sebastian,

      First of all, great to hear you find this lib useful.

      Getting your contacts from the server is a beta feature only available in the sourcecode repository (you can log in and download/compile it yourself). We never got around to releasing it as a download unfortunately. Perhaps I could look in to doing that some time if there is an interest..

      There are several listener interfaces your code can implement though (e.g. StatusListener, MessagingListener, ContactListListener). For example:

      OscarConnection myCon = new OscarConnection(ICQSERVERADDRESS, ICQSERVERPORT, CONTACT_UID, PASSWORD);

      myCon.addObserver(this);
      myCon.addStatusListener(this);
      myCon.addMessagingListener(this);

      This will cause interesting events to be sent to your code, such as contact status changes, incoming messages, etc. Have a look at those.

       
      • Lolo101

        Lolo101 - 2007-09-06

        Hi ! Yes the specified error seems to say the AuthorizationReply recieved from the server didn't allow you to connect, or was not recieved, or whatever else where wrong during the login.

        You should add these two lines in your icq() constructor:

        con.getPacketAnalyser().setDebug(true);
        con.getPacketAnalyser().getJarClassLoader().setPath(<path to the joscalib jar>);

        Thus, if you execute your application from a console you should get many useful logs as your program starts like :

        Warning : No jar file found. Packet unmarshalling won't be possible. Please verify your classpath
        Received 1 - 3
        --> JOscarLib.Packet.Received.ServerReady__1_3 loaded
        Received 1 - 24
        --> JOscarLib.Packet.Received.ServerFamilies__1_24 loaded
        Received 1 - 19
        --> JOscarLib.Packet.Received.Motd__1_19 loaded
        Received 1 - 7
        --> JOscarLib.Packet.Received.RateReply__1_7 loaded
        Received 2 - 3
        --> JOscarLib.Packet.Received.LocationRightsReply__2_3 loaded
        Received 1 - 15
        --> JOscarLib.Packet.Received.OnlineInfoResp__1_15 loaded
        Received 3 - 3
        --> JOscarLib.Packet.Received.BuddyListRightsReply__3_3 loaded

        And so on.
        These logs would help finding out the problem.

        y the way, the contact list managment is quite functionnal in the most recent sources and i think it ought to be released soon. It's indeed a very useful feature.

         
    • sebbi89

      sebbi89 - 2007-09-04

      Hi Daniel,

      thank's for your fast answer.

      I tried to do this now and that's the code I programmed:

      public class icq extends JFrame implements StatusListener, MessagingListener, Observer {

      public icq(){
          OscarConnection con = new OscarConnection(&quot;login.icq.com&quot;, 5190, user, passw);        
          con.addObserver(this);
          con.addStatusListener(this); 
          con.addMessagingListener(this);
      }
      public static void main(String[]args){
          icq q = new icq();
          q.setBounds(200,200,300,200);
          q.setDefaultCloseOperation(EXIT_ON_CLOSE);
          q.setVisible(true);
      }
      public void onIncomingUser(IncomingUserEvent e) {
          System.out.println(e.getIncomingUserId()+ &quot; ist online. Status: &quot;+e.getStatusMode());
          setTitle(e.getIncomingUserId()+ &quot;is online&quot;);
      }
      public void onOffgoingUser(OffgoingUserEvent e) {
      }
      public void onIncomingMessage(IncomingMessageEvent e) {
          String b = e.getMessage();
          System.out.println(b + &quot; Das ist die Message.&quot;);
      }
      public void onIncomingUrl(IncomingUrlEvent arg0) {  
      }
      public void onOfflineMessage(OfflineMessageEvent arg0) {    
      }
      public void update(Observable arg0, Object arg1) {
      }
      

      }

      Unfortunately it doesn't work that I get a message when someone signs in or when I get a message. By the way, when I start my program I also get the message: "Client error : Problem due to : null". Please: What is it I'm doing wrong?

       
      • Daniel

        Daniel - 2007-09-04

        Sebastian,

        The error comes from the code that receives authorization data from the ICQ server. In other words, your login seems to be failing, so no further events are processed (explaining your observations).

        The login server+port you are using are correct. Please verify that your UIN / password are correct as well.

         
    • sebbi89

      sebbi89 - 2007-09-06

      Daniel,

      I know that my UIN and my password are correct. I know that because I checked this and for example if I have the ICQ-Client opened and I execute my program I get the message from ICQ that someone signed in to my account from a different computer. So I think the log in can’t be the problem.

      Have you may any other ideas what the problem can be?

       

Log in to post a comment.