{
respond((ChallengePacket)packet);
}
else if (packet instanceof InfoQuery)
{
InfoQuery infoquery = (InfoQuery)packet;
IQExtension iq = infoquery.getIQExtension();
if(iq instanceof IQBind)
{
if (infoquery.getType().equals("result"))
{
jid = ((IQBind)iq).getJID();
System.out.println(jid);
connect.sendWhileConnecting(new InfoQuery(null,"set","sessionStart",new IQSession()));
}
else if(infoquery.getType().equals("error"))
{
String error = infoquery.getXMPPError().getFirstXMPPError().getError();
if(error.equals("bad-request "))
{//wrong resource, try otherone (not allowed by string prep)
//make one, improve
connect.sendWhileConnecting(new InfoQuery("get",new IQBind()));
}
else if(error.equals("not-allowed"))
{//resource limit reached
connect.sendLoginError("Resource limit reached, logoff a resource");
}
else if(error.equals("conflict"))
{//resource in use choose new
// make one, improve
connect.sendWhileConnecting(new InfoQuery("get",new IQBind()));
}
}
}
else if(infoquery.getID().equals("sessionStart"))
{
if (infoquery.getType().equals("result"))
{
connect.authenticated(jid);
}
else if(infoquery.getType().equals("error"))
{
String error = infoquery.getXMPPError().getFirstXMPPError().getError();
if(error.equals("internal-server-error"))
{//internal server error, try again, retry limit?
connect.sendLoginError("Server error, try again");
}
else if(error.equals("forbidden"))
{//not allowed to make session, try non sasl
connect.sendLoginError("Not allowed to create session");
}
else if(error.equals("cancel"))
{//resource conflict, choose different resource
// make one, improve
connect.sendWhileConnecting(new InfoQuery("get",new IQBind()));
}
}
}
}
else if(PluginsInfo.isPluginLoaded("compression")){