package include.dbcommunication;
import village.webservice.VillageServiceInterfaceProxy;
public class WindowAdder {
/**
* Function adds window to user's desktop.
*
* @param sid session identifier
* @param apiwindow window which should be added
* @return true if window was added correctly
*/
public boolean addWindow(String sid, village.webservice.user.Window apiwindow){
boolean result = false;
include.net.Server serv = new include.net.Server();
String server;
include.converter.Converter convert = new include.converter.Converter();
include.auth.Validation val = new include.auth.Validation();
String login = val.validate(sid);
System.out.println("[WindowAdder] Executing function 'addWindow'. Parameters:");
System.out.println("[WindowAdder] sid: '" + sid + "'");
server = sid.substring(sid.indexOf('@') + 1);
if (serv.isMyName(server)) {
System.out.println("[WindowAdder] Local execution.");
if (login != null) {
System.out.println("[WindowsAdder] Session is Valid");
if (login.indexOf('@') != -1)
login = login.substring(0, login.indexOf('@'));
result = (convert.windowToDB(apiwindow, login) != null);
} else
System.out.println("[WindowAdder] Session is invalid");
} else {
System.out.println("[WindowAdder] Remote execution.");
VillageServiceInterfaceProxy prox = new VillageServiceInterfaceProxy();
village.webservice.VillageServiceInterface iface =
prox.setEndpoint("http://"+server+prox.villagePort+prox.villageSuffix);
try {
result = iface.addRoom(sid, apiwindow);
} catch(Exception cex){
cex.printStackTrace();
}
}
System.out.println("[WindowAdder] Function 'addWindow' returned value: '" + result + "'");
return result;
}
public boolean addWindow(String sid, String rid){
village.webservice.user.Window apiwindow = new village.webservice.user.Window();
/* Default window */
Integer x = 0;
Integer y = 0;
Integer h = 125;
Integer l = 250;
Boolean bar = false;
Boolean fullscreen = false;
/* End */
apiwindow.setBar(bar);
apiwindow.setFullscreen(fullscreen);
apiwindow.setH(h);
apiwindow.setRid(rid);
apiwindow.setW(l);
apiwindow.setX(x);
apiwindow.setY(y);
return addWindow(sid, apiwindow);
}
}