public void process(String command) throws Exception
{
// TODO im and pres protocols
System.out.println(command);
if(command.startsWith("xmpp:")) command = command.substring(5,command.length());
JID authJID=null;
if(command.startsWith("//"))
{//auth component
command = command.substring(2,command.length());
String authJidText=null;
int questionIndex = command.indexOf("?");
int slashIndex = command.indexOf("/");
if(slashIndex<questionIndex)
{
authJidText =command.substring(0,slashIndex);
command = command.substring(slashIndex+1,command.length());
}
else if(questionIndex!=-1)
{
authJidText =command.substring(0,questionIndex);
command = command.substring(questionIndex,command.length());
}
else
{
authJidText =command;
command = "";
}
authJidText = URLDecoder.decode(authJidText,"UTF-8");
try
{
authJID = JID.checkedJIDFromString(authJidText);
} catch (InstantiationException e)
{
Log.notParsedXML("Wrong JID from link " + e.getMessage());
}
}
//JID part
String jidText=null;
int questionIndex = command.indexOf("?");
if(questionIndex!=-1)
{
jidText = command.substring(0,questionIndex);
command = command.substring(questionIndex+1,command.length());
}
else
{
jidText =command;
command = "";
}
jidText = URLDecoder.decode(jidText,"UTF-8");
JID jid = null;
try
{
jid = JID.checkedJIDFromString(jidText);
} catch (InstantiationException e)
{
Log.notParsedXML("Wrong JID from link " + e.getMessage());
}
String queryText=null;
if(command.length()!=0)
{//Query part
int hashIndex = command.indexOf("#");
if(hashIndex!=-1)
{
queryText = command.substring(0,hashIndex);
command = command.substring(hashIndex+1,command.length());
}
else queryText = command;
}//add fragment part? (#)
//TODO login with authJID if not yet logged in
System.out.println(authJID);
System.out.println(jid);
System.out.println(queryText);
if(jid!=null)
{
JIDStatus jidStatus = backend.getJIDStatus(jid);
if(jidStatus==null)jidStatus = new UnknownJIDStatus(jid);
if(queryText==null)
{
backend.getMain().chat(jidStatus);
}
else
{
if(queryText.startsWith("message"))
{
messageAction(queryText, jidStatus);
}
else if(queryText.startsWith("roster"))
{
rosterAction(jid, queryText);
}
else if(queryText.startsWith("join"))
{
groupchatAction(jid);
}
else if(queryText.startsWith("invite;"))
{//If the joining user is not yet in the room, the application MUST send two stanzas: the first to join the room and the second to invite the other individual. If the joining user is in the room already, the application shall send only the invitation stanza.
//TODO make this
if(true)return;
if(PluginsInfo.isPluginLoaded("groupchat"))
{//todo open groupchat + check if already open
queryText = queryText.substring(7,queryText.length());
String[] keyvalues = queryText.split(";");
for(int i=0;i<keyvalues.length;i++)
{
String keyvalue = keyvalues[i];
String value = getValue(keyvalue);
if(value!=null)
{
if(keyvalue.startsWith("jid"))
{
try
{//TODO invite user
JID invitee = JID.checkedJIDFromString(value);
} catch (InstantiationException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}