powered by Jive Software

Posting Hyperlinks in GTalk

How Do I pre-parse a url so that it is clickable on the chat window of GTalk ?

I mean sending a message like Google to the chat using the API does not become a hyperlink…

But when I type it in the chat window, www.google.com automatically becomes a hyperlink and is clickable !

Any ideas ?

What method do you use ?

Hi Konstantin,

I am using smack and the org.jivesoftware.smack.XMPPConnection’s sendPacket(reply) method

The reply is of type org.jivesoftware.smack.packet.Message

P.S: I noticed that I am also not able to post emoticons… i mean : D appears like that and does not turn into a whan i send it using the above method… am I missing something here ? btw, I am using the MessageParrot Example …

Any leads ?

Jabber server didn’t send emoticons as images. It send text ( like : D ) And client converts it into image. Hyberlinks works same.

Look at org.jivesoftware.spark.ui.ChatInputEditor or org.jivesoftware.spark.ui.TranscriptWindow classes. there you will find some info & functionality.

That is fine, but the hyperlinks are not working…

if I send www.google.com in the org.jivesoftware.smack.XMPPConnection’s sendPacket(reply) method like…

Message replyback = new Message();

replyback.setTo(fromName);

replyback.setBody(“www.google.com”);

xmppConnection.sendPacket(replyback);



When this comes up in the chat window of the client, there is no hyperlink here…

Message replyback = new Message();

replyback.setTo(fromName);

replyback.setBody("<a href=“www.google.com”>Google");

xmppConnection.sendPacket(replyback);

When this is sent, the chat window again displays Google , but still no hyperlinks …

What should I do so that the GTalk chat-window renders it as a hyperlink ??

try something like http://www.google.com

Nope, that’s not working either…

Maybe it has got to do something with the reply type ?

Hmm. I’m looking in logs. My Spark converts links like www.google.com & http://www.google.com. What spark version do you use ?

I am using the latest version…

this is my code… I jus want to know why this does not work…

Forgot to add this piece:

import org.jivesoftware.smack.ConnectionConfiguration;

import org.jivesoftware.smack.PacketListener;

import org.jivesoftware.smack.XMPPConnection;

import org.jivesoftware.smack.XMPPException;

import org.jivesoftware.smack.filter.MessageTypeFilter;

import org.jivesoftware.smack.filter.PacketFilter;

import org.jivesoftware.smack.packet.Message;

import org.jivesoftware.smack.packet.Packet;

import org.jivesoftware.smack.packet.Presence;

import org.jivesoftware.smack.util.StringUtils;

public static void main( String[] args ) {

System.out.println(“Starting”);

ConnectionConfiguration connConfig = new ConnectionConfiguration("

talk.google.com", 5222, “gmail.com”);

XMPPConnection connection = new XMPPConnection(connConfig);

try {

connection.connect();

System.out.println("Connected to " + connection.getHost());

} catch (XMPPException ex) {

//ex.printStackTrace();

System.out.println("Failed to connect to " +

connection.getHost());

System.exit(1);

}

try {

connection.login(username, password);

System.out.println("Logged in as " + connection.getUser());

Presence presence = new Presence(Presence.Type.available);

connection.sendPacket(presence);

} catch (XMPPException ex) {

System.out.println("Failed to log in as " + username);

System.exit(1);

}

PacketFilter filter = new MessageTypeFilter(Message.Type.chat);

connection.addPacketListener(new MessageParrot(connection), filter);

if(args.length > 0) {

// google bounces back the default message types, you must use

chat

Message msg = new Message(args[0], Message.Type.chat);

msg.setBody(“Test”);

connection.sendPacket(msg);

}

System.out.println(“Press enter to disconnect\n”);

try {

System.in.read();

} catch (IOException ex) {

//ex.printStackTrace();

}

connection.disconnect();

}

public void processPacket(Packet packet) {

Message message = (Message)packet;

if(message.getBody() != null) {

String fromName =

StringUtils.parseBareAddress(message.getFrom());

Message reply = new Message();

reply.setTo(fromName);

String messageString = message.getBody();

reply.setBody(“www.google.com”);

}

xmppConnection.sendPacket(reply);

}

}

public static class MessageParrot implements PacketListener {

private XMPPConnection xmppConnection;

public MessageParrot(XMPPConnection conn) {

xmppConnection = conn;

}

On Mon, Jan 11, 2010 at 10:40 PM, Vaidyanathan S <