shashankt
unread,Jun 3, 2009, 9:07:35 PM6/3/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to joscar discussion
Hi
Am trying to upload avatar in ICQ but am having some problem. The
avatar doesnt get changed immediately but changes after I do a proper
login from ICQ client. The same code is working fine for AIM account
with changes being displayed immediately.
Here is the code:
public class joscar {
public static void main(String args[]) {
final Screenname screenName = new Screenname("username");
AppSession appSession = new AppSession() {
public AimSession openAimSession(Screenname sn) {
return new DefaultAimSession(this, sn) {
};
}
};
AimConnectionProperties connectionProperties = new
AimConnectionProperties();
final AimConnection connection;
AimSession session = appSession.openAimSession(screenName);
connectionProperties.setScreenname(screenName);
connectionProperties.setPassword("password");
connection = session.openConnection(connectionProperties);
connection.addStateListener(new StateListener() {
public void handleStateChange(StateEvent event) {
try {
if (State.ONLINE == event.getNewState()) {
System.out.println("online");
uploadimage(connection);
} else if (State.FAILED == event.getNewState()) {
System.out.println("failed");//
fireFailedToConnect();
} else if (State.DISCONNECTED == event.getNewState
()) {
System.out.println("disconnect");//
fireDisconnect();
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
});
connection.connect();
}
static void uploadimage(AimConnection connection) {
try {
int h = 128;
int w = 128;
Image img = ImageIO.read(new File("d:\\doodle.jpg"));
BufferedImage bu = new BufferedImage(h, w,
BufferedImage.TYPE_INT_RGB);
Graphics2D g = bu.createGraphics();
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g.drawImage(img, 0, 0, h, w, null);
g.dispose();
ByteArrayOutputStream bas = new ByteArrayOutputStream();
ImageIO.write(bu, "jpg", bas);
byte[] data = bas.toByteArray();
connection.getMyBuddyIconManager().requestSetIcon
(ByteBlock.wrap(data));
} catch (Exception e) {
e.printStackTrace();
}
}
}
And here is the output that comes:
Jun 3, 2009 5:19:10 AM net.kano.joustsim.oscar.AimConnection
createTrustedCertificatesTracker
WARNING: Warning: this AIM connection's certificate and signer
managers will not be set because the trust manager is null
Jun 3, 2009 5:19:12 AM net.kano.joustsim.oscar.ConnectionManager
$BasicServiceFactory getService
WARNING: No service for family 0x6
Jun 3, 2009 5:19:12 AM net.kano.joustsim.oscar.ConnectionManager
$BasicServiceFactory getService
WARNING: No service for family 0x8
Jun 3, 2009 5:19:12 AM net.kano.joustsim.oscar.ConnectionManager
$BasicServiceFactory getService
WARNING: No service for family 0x9
Jun 3, 2009 5:19:12 AM net.kano.joustsim.oscar.ConnectionManager
$BasicServiceFactory getService
WARNING: No service for family 0xa
Jun 3, 2009 5:19:12 AM net.kano.joustsim.oscar.ConnectionManager
$BasicServiceFactory getService
WARNING: No service for family 0xb
Jun 3, 2009 5:19:12 AM net.kano.joustsim.oscar.ConnectionManager
$BasicServiceFactory getService
WARNING: No service for family 0xc
Jun 3, 2009 5:19:12 AM net.kano.joustsim.oscar.ConnectionManager
$BasicServiceFactory getService
WARNING: No service for family 0x15
Jun 3, 2009 5:19:12 AM net.kano.joustsim.oscar.ConnectionManager
$BasicServiceFactory getService
WARNING: No service for family 0x22
Jun 3, 2009 5:19:12 AM net.kano.joustsim.oscar.ConnectionManager
$BasicServiceFactory getService
WARNING: No service for family 0x24
Jun 3, 2009 5:19:12 AM net.kano.joustsim.oscar.ConnectionManager
$BasicServiceFactory getService
WARNING: No service for family 0x25
online
Jun 3, 2009 5:19:33 AM net.kano.joustsim.oscar.BuddyIconTracker
$MyIconRequestListener buddyIconUpdated
INFO: Buddy icon data for 556337162 set too late - hash ExtraInfoData:
flags=0x1 (FLAG_HASH_PRESENT), data=d7 14 90 d1 a2 5e c1 59 12 e5 01
71 be b2 32 e6 no longer matches
Am not sure why the last two lines come in Output.