Anexo A: Implementación pasarela SMS/SIP SMStoSIP.java Anexo A: Implementación pasarela SMS/SIP SMStoSIP.java package com.ericsson; import java.io.File; import java.io.FileInputStream; import java.util.Properties; import javax.servlet.sip.SipApplicationSession; import javax.servlet.sip.SipFactory; import javax.servlet.sip.SipServletRequest; public class SMStoSIP extends Thread { Config file_config = new Config("/par.txt"); SipFactory sipf; SMStoSIP(SipFactory sipfact) { sipf = sipfact; } public void run() { Properties propiedades; String SMS = "/sms.txt"; /* Carga del fichero de propiedades */ try { // while (true) { File file = new File(SMS); FileInputStream f = new FileInputStream(file); propiedades = new Properties(); propiedades.load(f); f.close(); // file.delete(); String from = String.valueOf(propiedades.getProperty("From")); String m = String.valueOf(propiedades.getProperty("m")); String s = String.valueOf(propiedades.getProperty("s")); if (!(m.equals("null"))) send_method(from, m, false); else if (!(s.equals("null"))) send_method(from, s, true); // } /* Buscamos algunos valores */ } catch (Exception e) { /* * Manejo de excepciones */ } } public void send_method(String from, String cadena, boolean subs) { try { SipServletRequest messageRequest; SipApplicationSession sipas = sipf.createApplicationSession(); // set the message content if (subs) { messageRequest = sipf.createRequest(sipas, "SUBSCRIBE", "sip:" + from + "@ericsson.com", file_config.service_sip); messageRequest.addHeader("Expires", "3600"); messageRequest.addHeader("Event", cadena); } else { messageRequest = sipf.createRequest(sipas, "MESSAGE", "sip:" + from + "@ericsson.com", file_config.service_sip); messageRequest.setContent(cadena, "text/plain"); } messageRequest.pushRoute(sipf.createSipURI(null, file_config.direccion)); messageRequest.addHeader("Accept-Contact", file_config.ac); messageRequest.addHeader("User-Agent", file_config.ua); // add p-asserted-identity header for CSCF messageRequest.addHeader("p-asserted-identity", 104 Anexo A: Implementación pasarela SMS/SIP SIPtoSMS.java file_config.service_sip); // send the request messageRequest.send(); } catch (Exception e) { } } } SIPtoSMS.java /** * */ package com.ericsson; import import import import import import import import import javax.servlet.sip.SipServlet; javax.servlet.sip.SipFactory; java.io.IOException; javax.servlet.sip.SipServletRequest; javax.servlet.ServletException; javax.servlet.ServletContext; javax.servlet.ServletConfig; java.io.*; java.util.*; public class SIPtoSMS extends SipServlet { /** * The SIP Factory. Can be used to create URI and requests. */ private SipFactory sipFactory; /** * @inheritDoc */ public void init(ServletConfig config) throws ServletException { super.init(config); ServletContext context = config.getServletContext(); sipFactory = (SipFactory) context .getAttribute("javax.servlet.sip.SipFactory"); SMStoSIP ss = new SMStoSIP(sipFactory); ss.start(); } /** * @inheritDoc */ protected void doMessage(SipServletRequest arg0) throws ServletException, IOException { // TODO: Implement this method arg0.createResponse(200).send(); Date dater = new Date(); String file_name = arg0.getFrom().toString().substring(5, arg0.getFrom().toString().indexOf('@')); File file = new File("/" + file_name + ".txt"); if (file.createNewFile()) { FileOutputStream fo = new FileOutputStream(file); fo.write("From: ".getBytes()); fo.write(arg0.getFrom().toString().getBytes()); fo.write("\r\n".getBytes()); fo.write("From_SMSC: ".getBytes()); fo.write("666777888".getBytes()); fo.write("\r\n".getBytes()); Date dates = new Date(); fo.write("Sent: ".getBytes()); fo.write(dates.toString().getBytes()); fo.write("\r\n".getBytes()); fo.write("Received: ".getBytes()); fo.write(dater.toString().getBytes()); fo.write("\r\n".getBytes()); fo.write("Subject: ".getBytes()); fo.write("grupo".getBytes()); fo.write("\r\n".getBytes()); fo.write("Alphabet: ".getBytes()); fo.write("ISO".getBytes()); fo.write("\r\n".getBytes()); fo.write("UDH: ".getBytes()); 105 Anexo A: Implementación pasarela SMS/SIP Config.java fo.write("false".getBytes()); fo.write("\r\n".getBytes()); fo.write("\r\n".getBytes()); fo.write("m ".getBytes()); fo.write(arg0.getRawContent()); fo.close(); } } /** * @inheritDoc */ protected void doNotify(SipServletRequest arg0) throws ServletException, IOException { // TODO: Implement this method Date dater = new Date(); String file_name = arg0.getTo().toString(); File file = new File(file_name); if (file.createNewFile()) { FileOutputStream fo = new FileOutputStream(file); fo.write("From: ".getBytes()); fo.write(arg0.getFrom().toString().getBytes()); fo.write("\r\n".getBytes()); fo.write("From_SMSC: ".getBytes()); fo.write("666777888".getBytes()); fo.write("\r\n".getBytes()); Date dates = new Date(); fo.write("Sent: ".getBytes()); fo.write(dates.toString().getBytes()); fo.write("\r\n".getBytes()); fo.write("Received: ".getBytes()); fo.write(dater.toString().getBytes()); fo.write("\r\n".getBytes()); fo.write("Subject: ".getBytes()); fo.write("grupo".getBytes()); fo.write("\r\n".getBytes()); fo.write("Alphabet: ".getBytes()); fo.write("ISO".getBytes()); fo.write("\r\n".getBytes()); fo.write("UDH: ".getBytes()); fo.write("false".getBytes()); fo.write("\r\n".getBytes()); fo.write("\r\n".getBytes()); fo.write("n ".getBytes()); fo.write(arg0.getRawContent()); fo.close(); } } } Config.java package com.ericsson; import java.util.Properties; import java.io.FileInputStream; /** * This class read a configuration file and store these parameters. * * @author Alejandro y Tony. * */ public class Config { String direccion; // direccion IP y puerto del CSCF String service_sip; // uri del servidor de aplicaciones String ua; // cabecera user agent String ac; // cabecera accept contanct Config(String file) { String FICHERO_CONFIGURACION = file; Properties propiedades; /* Carga del fichero de propiedades */ try { FileInputStream f = new FileInputStream(FICHERO_CONFIGURACION); 106 Anexo A: Implementación pasarela SMS/SIP Config.java propiedades = new Properties(); propiedades.load(f); f.close(); /* Imprimimos los pares clave = valor */ // propiedades.list(System.out); /* Buscamos algunos valores */ direccion = String.valueOf(propiedades.getProperty("direccion")); service_sip = String .valueOf(propiedades.getProperty("service_sip")); ua = String.valueOf(propiedades.getProperty("user_agent")); ac = String.valueOf(propiedades.getProperty("accept_contact")); } catch (Exception e) { /* * Manejo de excepciones */ } } } 107 Anexo B: Implementación del cliente PLClient.java Anexo B: Implementación del cliente PLClient.java package com.ericsson; import com.ericsson.icp.ICPFactory; import com.ericsson.icp.IPlatform; import com.ericsson.icp.IService; /** * This is the main class of the client. Its function is listening to incoming * SIP methods. Depending on the incoming method call the apropiate class of the * client. * * @param service * It's used by all client classes to send the apropiate SIP method * to the server. * @param platform * It's used by all client classes to obtain the service identity. * @param app * It's used to open the application window. It's an 'Aplicacion' * object. * * @author Alejandro y Tony * */ public class PLClient { private static IService service; private static IPlatform platform; static String cadena; static boolean f = true; private static Aplicacion app; private static Union add; public static void main(String args[]) { int last_loc = 5; try { platform = ICPFactory.createPlatform(Constants.cliente); platform.addListener(new PlatformAdapter()); service = platform.createService(Constants.gcliente, Constants.cliente, null); app = new Aplicacion(platform, service); add = new Union(platform, service); service.addListener(new ServiceAdapter() { boolean creado = false; /** * It handles incoming SIP MESSAGES. It identifies the MESSAGE * type among the six possible types and acts correctly. */ public void processMessage(String remote, String messageType, byte[] content, int length) { String message = new String(content); System.out.println("Message: " + message); String addr = (message.substring(message.indexOf('<'), message.indexOf('>') + 1)); // Peticion para GC de union de usuario fuera banda if (message.charAt(0) == 'n') { new FueraB(platform, service, addr); // Has sido invitado a unirte (candidato) } else if (message.charAt(0) == 'i') { new Invitacion(platform, service, addr, app); // IM difusion (GC y candidatos) } else if (message.charAt(0) == 's') { System.out.println("IM: " + message); String msg = (message.substring( message.indexOf('>') + 2, message.length() - 1)); app.txt.append("\n" + msg); 108 Anexo B: Implementación del cliente PLClient.java // union fuera banda admitida } else if (message.charAt(0) == 'a') { app.grupo = addr; System.out.println(addr); app.nick = message.substring(2, message.indexOf('<') - 1); // nick miembro app.setTitle(app.getTitle() + " " + app.grupo); app.run(); // se abre la aplicacion // union fuera banda rechazada } else if (message.charAt(0) == 'r') { new Aviso(Constants.nounion, true); // mensaje de error que sera mostrado por pantalla } else if (message.charAt(0) == 'e') { String aviso = message.substring( message.indexOf('>') + 2, message.length()); new Aviso(aviso, false); // Método empleado para solicitar un listado de grupos // de provisión cerrada activos. } else if (message.charAt(0) == 'g') { String grupospc = message.substring(message .indexOf('>') + 2, message.length()); int k = 0; if (message.substring(message.indexOf('<') + 1, message.indexOf('>')).equals("0")) new Aviso(grupospc, false); else { for (int i = 0; i < grupospc.length(); i++) if (grupospc.charAt(i) == ',') { add.lista.add(grupospc.substring(k, i)); k = i + 1; } } } } /** * It handles incoming SIP NOTIFY. It identifies the NOTIFY type * among the six possible types and acts correctly. */ public void processSubscribeNotification(String remote, String event, String messageType, byte[] content, int legth) { String message = new String(content); System.out.println("Notify: " + message); // notificacion al GC de que el grupo ha sido creado if (message.charAt(0) == 'c') { // notificacion al GC de que // el grupo ha sido creado if (!creado) { app.nick = "0"; // nick del GC // sip del grupo app.grupo = message.substring(2, message.length()); app.setTitle(app.getTitle() + " " + app.grupo); app.add_expulsar(); app.run(); creado = true; } // notificacion al cliente de que el grupo ha sido // eliminado por el creador } else if (message.charAt(0) == 'f') { if (f) { app.dispose(); new Aviso(Constants.grupoeliminadoGC, true); } // se le notifica al cliente que ha sido expulsado del // grupo por el GC } else if (message.charAt(0) == 'e') { app.dispose(); new Aviso(Constants.expulsadoGC, true); // se le comunica su nick al cliente } else if (message.charAt(0) == 'n') { app.nick = message.substring(2, message.length()); app.run(); // el usuario se ha salido de la zona de cobertura } else if (message.charAt(0) == 'l') { app.dispose(); f = false; new Aviso(Constants.fueracobert, true); 109 Anexo B: Implementación del cliente Activacion.java // si llega un numero quiere decir el numero de // ususarios que hay actualmente en el grupo, asi que se // refresca el numero de usuarios en la aplicacion } else { app.refresh_users(message, true); } } public void processPublishResult(boolean aStatus, String aRemote, String aEvent) { System.out.println("Resultado del Publish: " + aStatus + aRemote + aEvent); } }); new Principal(platform, service, app, add); // wait/notify mechanism could be used as well while (true) { Thread.sleep(2000); // periodicamente actualizar localizacion y notificar a servidor // cuando cambie if (last_loc != app.actual_loc) { last_loc = app.actual_loc; String location = (new Integer(app.actual_loc)).toString(); String comandol = "l/" + location + "/" + app.grupo + "/" + app.nick; /* * service.publish(platform.getIdentity(), * "sip:[email protected]", "grupo", "text/plain", * comandol.getBytes(), comandol.getBytes().length, 3600); */ service.sendMessage(platform.getIdentity(), Constants.sipas, Constants.content_tp, comandol .getBytes(), comandol.getBytes().length); ; } } } catch (Exception e) { e.printStackTrace(); System.out.println(e); } } } Activacion.java package com.ericsson; import import import import java.awt.*; java.awt.event.*; com.ericsson.icp.IPlatform; com.ericsson.icp.IService; /** * This class shows the 'union' window and offers the posibility to join a * group. The user need to know the uri of an existing group for join it. * * @author Tony * */ public class Activacion extends Frame { TextArea txt = new TextArea("", 1, 8, 3); Button activar = new Button(Constants.activar); Button cancel = new Button(Constants.cancelar); IPlatform miplatf; IService miserv; public Activacion(IPlatform platf, IService serv) { Label grupo = new Label(Constants.inserturig); grupo.setForeground(Color.blue); Font font = Constants.font9; 110 Anexo B: Implementación del cliente Activacion.java Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); if (screenSize.width >= 640) { txt.setColumns(12); txt.setRows(1); font = Constants.font12; } grupo.setFont(font); txt.setFont(font); Panel p1 = new Panel(); Panel p2 = new Panel(); Panel p3 = new Panel(); miplatf = platf; miserv = serv; setTitle(Constants.title_act); activar.setActionCommand("CLICK"); activar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) { try { if (txt.getText() != null) { // se concatena la uri completa del grupo y se envia // el mensaje adecuado al servidor String comando = "e/" + txt.getText().trim() + "/"; miserv.subscribe(miplatf.getIdentity(), Constants.sipas, comando, null, 3600, null); // dispose(); } } catch (Exception excep) { System.out.println(excep); } ; } } }); cancel.setActionCommand("CLICK"); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) // si se pulsa cancel se cierra la ventana y se vuelve a la // pantalla inicial dispose(); } }); p1.setLayout(new FlowLayout(FlowLayout.CENTER)); p2.setLayout(new FlowLayout(FlowLayout.CENTER)); p3.setLayout(new FlowLayout(FlowLayout.CENTER)); p1.add(grupo); p2.add(txt); p3.add(activar); p3.add(cancel); add("North", p1); add("Center", p2); add("South", p3); addWindowListener(new WindowListener() { public void windowActivated(WindowEvent e) { } public void windowClosed(WindowEvent e) { } public void windowClosing(WindowEvent e) { dispose(); } public void windowDeactivated(WindowEvent e) { } public void windowDeiconified(WindowEvent e) { 111 Anexo B: Implementación del cliente Aplicacion.java } public void windowIconified(WindowEvent e) { } public void windowOpened(WindowEvent e) { } }); pack(); show(); } } Aplicacion.java package com.ericsson; import import import import import java.awt.*; java.awt.event.*; java.text.AttributedString; java.text.AttributedCharacterIterator; java.util.Map; import com.ericsson.icp.IPlatform; import com.ericsson.icp.IService; /** * This class shows the main service window. It's composed by 2 text areas and 2 * buttons. One text area shows the incoming instant messages and the other one * is used to send instant messages to the server using the 'enviar' button. * * * @author Alejandro y Tony * */ public class Aplicacion extends Frame { TextArea txt = new TextArea(7, 20); TextArea msg = new TextArea("", 1, 25, 3); Button enviar = new Button(Constants.enviar); Button salir = new Button(Constants.x); Button loc = new Button(Constants.l); Button expulsar = new Button(Constants.expulsar); Button invitar = new Button(Constants.invitar); IPlatform miplatf; IService miserv; Integer users = new Integer(1); Label numusers = new Label("1"); Label logas = new Label(Constants.nick); String grupo; String nick; Panel p1 = new Panel(); Panel p2 = new Panel(); Panel p22 = new Panel(); Panel p3 = new Panel(); List listusers = new List(5); boolean addlist = false; int actual_loc = 5; public Aplicacion(IPlatform platf, IService serv) { miplatf = platf; 112 Anexo B: Implementación del cliente Aplicacion.java miserv = serv; } // boton que solo aparece en la aplicacion del GC. Se usa para expulsar a un // miembro public void add_expulsar() { expulsar.setActionCommand("CLICK"); expulsar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) { try { String user = listusers.getSelectedItem(); if (listusers.getSelectedIndex() != 0) { String usuario = user.substring(4, user.length()); // se envia la solicitud de expulsion miserv.sendMessage(miplatf.getIdentity(), Constants.sipas, Constants.content_tp, ("e/" + grupo + "/" + usuario).getBytes(), ("e/" + grupo + "/" + usuario).length()); txt.append(Constants.info1 + listusers.getSelectedItem() + "..."); msg.setText(""); } else new Aviso(Constants.noexpulsarte, false); } catch (Exception ex) { } ; } } }); invitar.setActionCommand("CLICK"); invitar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) { try { new Invitar(miplatf, miserv, grupo, txt); } catch (Exception ex) { } ; } } }); // p1.add(expulsar); // p22.add(expulsar); // p1.add(invitar); addlist = true; // p2.add(listusers); } // parte de la ventana de aplicacion comun a clientes normales y GC public void run() { Font font = Constants.font9; Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); if (screenSize.width >= 640) { txt.setColumns(60); txt.setRows(15); msg.setColumns(49); msg.setRows(1); font = Constants.font12; } txt.setFont(font); msg.setFont(font); loc.setFont(font); listusers.setFont(font); enviar.setFont(font); salir.setFont(font); expulsar.setFont(font); invitar.setFont(font); numusers.setText(users.toString()); numusers.setFont(font); 113 Anexo B: Implementación del cliente Aplicacion.java numusers.setForeground(Color.red); Label info = new Label(Constants.users); info.setFont(font); Label lnick = new Label("user" + nick); lnick.setFont(font); lnick.setForeground(Color.blue); logas.setFont(font); txt.setEditable(false); txt.setBackground(Color.white); msg.setText(""); setTitle(grupo.substring(grupo.indexOf(':') + 1, grupo.indexOf('>'))); // boton enviar. Para difusion de mensajeria instantanea enviar.setActionCommand("CLICK"); enviar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) { try { if (msg.getText() != "") { // si hay algo se envia String cadena = "s/" + grupo + "/user" + nick + ": " + msg.getText().toString() + "/"; System.out.println(cadena); miserv.sendMessage(miplatf.getIdentity(), Constants.sipas, Constants.content_tp, cadena.getBytes(), cadena.length()); // se muestra en pantalla el nick del usuario String yo = "user" + nick; txt.append("\n" + yo + ": " + msg.getText()); msg.setText(""); } } catch (Exception excep) { System.out.println(excep); } ; } } }); // boton salir. Se abandona el grupo. Si lo pulsa el GC se da de baja al // grupo salir.setActionCommand("CLICK"); salir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) { try { // se envia el mensaje de baja al servidor miserv.sendMessage(miplatf.getIdentity(), Constants.sipas, Constants.content_tp, ("b/" + grupo).getBytes(), ("b/" + grupo) .length()); System.exit(0); // se cierra la aplicacion } catch (Exception ex) { } ; } } }); loc.setActionCommand("CLICK"); loc.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) { try { actual_loc = actual_loc + 1; } catch (Exception ex) { } ; } } }); p1.setLayout(new FlowLayout(FlowLayout.LEFT)); p1.add(logas); p1.add(lnick); p1.add(info); p1.add(numusers); p1.add(salir); p1.add(loc); 114 Anexo B: Implementación del cliente Aplicacion.java GridBagLayout gbl = new GridBagLayout(); p2.setLayout(gbl); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 3; p2.add(txt, gbc); gbc.gridx = 1; gbc.gridy = 0; gbc.gridheight = 1; gbc.gridwidth = 1; listusers.add("user0"); if (addlist) { p2.add(invitar); gbc.gridy = 1; p2.add(listusers, gbc); gbc.gridy = 2; p2.add(expulsar, gbc); } p3.setLayout(new FlowLayout(FlowLayout.LEFT)); p3.add(msg); p3.add(enviar); add("North", p1); add("Center", p2); add("South", p3); addWindowListener(new WindowListener() { public void windowActivated(WindowEvent e) { } public void windowClosed(WindowEvent e) { } public void windowClosing(WindowEvent e) { dispose(); } public void windowDeactivated(WindowEvent e) { } public void windowDeiconified(WindowEvent e) { } public void windowIconified(WindowEvent e) { } public void windowOpened(WindowEvent e) { } }); pack(); show(); } // metodo que se encarga de refrescar el numero de usuarios en la ventana de // aplicacion y de informar de las altas y las bajas. public void refresh_users(String texto, boolean show) { Integer numero = new Integer(texto.substring(0, texto.indexOf('/'))); String message; String newuser = texto .substring(texto.indexOf('/') + 2, texto.length()); Font font = Constants.font9; Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); if (screenSize.width >= 640) { font = Constants.font12; } if (texto.charAt(texto.indexOf('/') + 1) == '+') { message = Constants.info2 + newuser + Constants.info3; if (addlist) listusers.add(newuser); } else { message = Constants.info2 + newuser + Constants.info4; if (addlist) listusers.remove(newuser); 115 Anexo B: Implementación del cliente Aviso.java } numusers.setText(numero.toString()); txt.setFont(font); if (show) txt.append(message); } } Aviso.java package com.ericsson; import java.awt.*; import java.awt.event.*; import java.awt.event.ActionListener; /** * This class is used to shows messages for users, like a pop-up window. * * @param mitipo * Boolean value that represents if the application will be closed * when the user click on 'aceptar' button. * * * @author Alejandro y Tony * */ public class Aviso extends Frame { Button ok = new Button(Constants.aceptar); boolean salir; public Aviso(String txt, boolean exit) { Panel p1 = new Panel(); Panel p2 = new Panel(); Font font = Constants.font9; Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); if (screenSize.width >= 640) { font = Constants.font12; } Label aviso = new Label(txt); aviso.setFont(font); salir = exit; setTitle(Constants.title_aviso); ok.setActionCommand("CLICK"); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) // si el segundo parametro es true se cierra la aplicacion if (salir) System.exit(0); else dispose(); } }); p1.setLayout(new FlowLayout(FlowLayout.CENTER)); p2.setLayout(new FlowLayout(FlowLayout.CENTER)); p1.add(aviso); p2.add(ok); add("North", p1); add("Center", p2); addWindowListener(new WindowListener() { 116 Anexo B: Implementación del cliente Constant.java public void windowActivated(WindowEvent e) { } public void windowClosed(WindowEvent e) { } public void windowClosing(WindowEvent e) { dispose(); } public void windowDeactivated(WindowEvent e) { } public void windowDeiconified(WindowEvent e) { } public void windowIconified(WindowEvent e) { } public void windowOpened(WindowEvent e) { } }); pack(); show(); } } Constant.java package com.ericsson; import java.awt.*; /** * This class has all the constants that are used on the client, so that if * anybody wants to translate the client he only has to change this class. * * @author Alejandro y Tony * */ public class Constants { // messages to be shown public static final String nounion = "Union no aceptada"; public static final String grupoeliminadoGC = "Grupo eliminado por el creador"; public static final String expulsadoGC = "Ha sido expulsado por el creador"; public static final String fueracobert = "Se ha salido zona de cobertura"; public static final String noexpulsarte = "No te puedes expulsar a ti mismo"; public static final String info1 = "\nINFO: Expulsando a: "; public static final String info2 = "\nINFO: "; public static final String info3 = " se unio\n"; public static final String info4 = " se fue\n"; public static final String info5 = "\nINFO: Invitando a: "; // text in labels public static final String inserturig = "Introduzca la URI del grupo"; public static final String inserturii = "Introduzca uri invitado"; public static final String ackunion = "¿Confirmar uniones?"; public static final String insertcand = "Introduzca candidatos"; public static final String telefonos = "Inserte telefonos "; public static final String invitadoa = "Invitado a: "; public static final String deseaunion = "¿Desea unirse?"; public static final String permitir = "¿Permitir union de "; 117 Anexo B: Implementación del cliente Constant.java public static final String wellcome = "Bienvenido a Party Line v1.0"; public static final String wellcome2 = "¿Qué desea hacer?"; public static final String pgPC = "Pulse GruposPC"; public static final String nick = "Nick:"; public static final String users = "Users:"; public static final String si = "Sí"; public static final String no = "No"; // text in buttons public static final String activar = "Activar"; public static final String cancelar = "Cancelar"; public static final String enviar = "Enviar"; public static final String x = "X"; public static final String l = "L"; public static final String expulsar = "Expulsar"; public static final String invitar = "Invitar"; public static final String aceptar = "Aceptar"; public static final String crear = "Crear"; public static final String creacion = "Creacion"; public static final String union = "Union"; public static final String pc = "Activacion PC"; public static final String unir = "Unir"; public static final String grupos = "Grupos PC"; // titles text public static final String title_act = "PLv1.0 Activacion"; public static final String title_aviso = "PLv1.0 Aviso"; public static final String title_crea = "PLv1.0 Creacion"; public static final String title_fb = "PLv1.0 Usuario Fuera de Banda"; public static final String title_inv = "PLv1.0 Invitación"; public static final String title_miembro = "PLv1.0 Invitar a miembro"; // graphics options public static final Font font9 = new Font("Arial", Font.CENTER_BASELINE, 9); public static final Font font12 = new Font("Arial", Font.CENTER_BASELINE, 12); // service configuration public static final String sipas = "sip:[email protected]"; public static final String content_tp = "text/plain"; public static final String dominio = "@ericsson.com"; public static final String dominiog = "@servicio.com"; public static final String cliente = "PLClient"; public static final String gcliente = "+g.PLClient.ericsson.com"; } 118 Anexo B: Implementación del cliente Creacion.java Creacion.java package com.ericsson; import import import import java.awt.*; java.awt.event.*; com.ericsson.icp.IPlatform; com.ericsson.icp.IService; /** * Tihs class shows a window to set up a group. To do this it shows a text area * where the user has to write the candidate members of the group and a checkbox * where the user can choose if he want to be asked for new user addings. * * @author Alejandro y Tony * */ public class Creacion extends Frame { Checkbox ack = new Checkbox(Constants.si, true); TextArea sip = new TextArea("", 1, 20, 3); TextArea tel = new TextArea("", 1, 20, 3); Button crear = new Button(Constants.crear); Button cancel = new Button(Constants.cancelar); IPlatform miplatf; IService miserv; public Creacion(IPlatform platf, IService serv) { Font font = Constants.font9; Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); if (screenSize.width >= 640) { sip.setColumns(30); sip.setRows(3); tel.setColumns(30); tel.setRows(3); font = Constants.font12; } ack.setFont(font); sip.setFont(font); tel.setFont(font); crear.setFont(font); cancel.setFont(font); Label confirmado = new Label(Constants.ackunion); confirmado.setFont(font); Label info = new Label(Constants.insertcand); info.setFont(font); Label info2 = new Label(Constants.telefonos); info2.setFont(font); Panel p1 = new Panel(); Panel p2 = new Panel(); Panel p3 = new Panel(); miplatf = platf; miserv = serv; setTitle(Constants.title_crea); crear.setActionCommand("CLICK"); crear.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) { try { String comando; boolean vacio = true; String miembros = ""; if (ack.getState() == true) comando = "c/y/";// si el grupo es confirmado else 119 Anexo B: Implementación del cliente Creacion.java comando = "c/n/";// si el grupo es no confirmado // // // if si hay candidatos se comprueba el formato en trata_cadena if (txt.getText() != null) { (!(sip.getText().trim().equals(""))) { miembros = trata_cadena(sip.getText().trim()); vacio = false; } if (!(tel.getText().trim().equals(""))) { if (vacio) miembros = trata_cadena_tel(tel.getText() .trim()); else miembros = miembros + trata_cadena_tel(tel.getText().trim()); vacio = false; } if (!vacio) { comando = comando + miembros; miserv.subscribe(miplatf.getIdentity(), Constants.sipas, comando, null, 3600, null); // si la lista de candidatos esta vacia se crea un // grupo sin candidatos } else miserv.subscribe(miplatf.getIdentity(), Constants.sipas, comando, null, 3600, null); dispose(); } catch (Exception excep) { System.out.println(excep); } ; } } }); cancel.setActionCommand("CLICK"); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) dispose(); } }); p1.setLayout(new GridLayout(3, 2)); p2.setLayout(new GridLayout(2, 1)); p3.setLayout(new FlowLayout(FlowLayout.CENTER)); p1.add(confirmado); p1.add(ack); p1.add(info); p1.add(new Label("")); p1.add(sip); p2.add(info2); p2.add(tel); p3.add(crear); p3.add(cancel); add("North", p1); add("Center", p2); add("South", p3); addWindowListener(new WindowListener() { public void windowActivated(WindowEvent e) { } public void windowClosed(WindowEvent e) { } public void windowClosing(WindowEvent e) { dispose(); } public void windowDeactivated(WindowEvent e) { } public void windowDeiconified(WindowEvent e) { } public void windowIconified(WindowEvent e) { } public void windowOpened(WindowEvent e) { 120 Anexo B: Implementación del cliente FueraB.java } }); pack(); show(); } // recoge la lista de candidatos separadas por comas y le añade los // caracteres necesarios para formar la sip correcta public String trata_cadena(String texto) { // comand contiene las sip correctas de los candidatos miembros // separadas por '/' String comand = ""; int k = 0; texto = texto + ","; for (int i = 0; i < texto.length(); i++) { if (texto.charAt(i) == ',') if (texto.charAt(i - 1) == ',') k++; else { comand = comand + "sip:" + texto.substring(k, i).trim() + Constants.dominio + "/"; k = i + 1; } } return (comand); } public String trata_cadena_tel(String texto) { // comand contiene las sip correctas de los candidatos miembros // separadas por '/' String comand = ""; int k = 0; texto = texto + ","; for (int i = 0; i < texto.length(); i++) { if (texto.charAt(i) == ',') if (texto.charAt(i - 1) == ',') k++; else { comand = comand + "sip:+" + texto.substring(k, i).trim() + Constants.dominio + "/"; k = i + 1; } } return (comand); } } FueraB.java package com.ericsson; import import import import java.awt.*; java.awt.event.*; com.ericsson.icp.IPlatform; com.ericsson.icp.IService; /** * This class is used to ask for an out of band adding to the GC. * * @author Tony * */ public class FueraB extends Frame { Button si = new Button(Constants.si); Button no = new Button(Constants.no); IPlatform miplatf; IService miserv; String user; public FueraB(IPlatform platf, IService serv, String usuario) { 121 Anexo B: Implementación del cliente FueraB.java Font font = Constants.font9; Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); if (screenSize.width >= 640) { font = Constants.font12; } Label peticion = new Label(usuario + " ?"); peticion.setFont(font); Label permiso = new Label(Constants.permitir); permiso.setFont(font); Panel p1 = new Panel(); Panel p2 = new Panel(); Panel p3 = new Panel(); miplatf = platf; miserv = serv; user = usuario; setTitle(Constants.title_fb); si.setActionCommand("CLICK"); si.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) { try { // si se acepta la union del candidato fuera de banda se // envia el mensaje de aceptacion al servidor String orden = "u/" + user + "/y/"; newuser(miserv, miplatf, orden); dispose(); } catch (Exception excep) { System.out.println(excep); } ; } } }); no.setActionCommand("CLICK"); no.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) { try { // union no aceptada por el GC String orden = "u/" + user + "/n/"; newuser(miserv, miplatf, orden); dispose(); } catch (Exception excep) { System.out.println(excep); } ; } } }); p1.setLayout(new FlowLayout(FlowLayout.CENTER)); p2.setLayout(new FlowLayout(FlowLayout.CENTER)); p3.setLayout(new FlowLayout(FlowLayout.CENTER)); p1.add(permiso); p2.add(peticion); p3.add(si); p3.add(no); add("North", p1); add("Center", p2); add("South", p3); addWindowListener(new WindowListener() { public void windowActivated(WindowEvent e) { } public void windowClosed(WindowEvent e) { } public void windowClosing(WindowEvent e) { dispose(); } 122 Anexo B: Implementación del cliente Invitacion.java public void windowDeactivated(WindowEvent e) { } public void windowDeiconified(WindowEvent e) { } public void windowIconified(WindowEvent e) { } public void windowOpened(WindowEvent e) { } }); pack(); show(); } // envia el MESSAGE al servidor public static void newuser(IService servicio, IPlatform platf, String cadena) { try { servicio.sendMessage(platf.getIdentity(), Constants.sipas, Constants.content_tp, cadena.getBytes(), cadena.length()); } catch (Exception e) { } } } Invitacion.java package com.ericsson; import import import import java.awt.*; java.awt.event.*; com.ericsson.icp.IPlatform; com.ericsson.icp.IService; /** * This class shows a window to the candidates asking them if they want to be * added to a group. * * @author Tony * */ public class Invitacion extends Frame { Button si = new Button(Constants.si); Button no = new Button(Constants.no); IPlatform miplatf; IService miserv; String group; Aplicacion miapp; public Invitacion(IPlatform platf, IService serv, String grupo, Aplicacion app) { Font font = Constants.font9; Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); if (screenSize.width >= 640) { font = Constants.font12; } Label invitado = new Label(Constants.invitadoa + grupo); invitado.setFont(font); Label peticion = new Label(Constants.deseaunion); peticion.setFont(font); Panel p1 = new Panel(); Panel p2 = new Panel(); Panel p3 = new Panel(); miplatf = platf; miserv = serv; group = grupo; // grupo al que hemos sido invitado miapp = app; 123 Anexo B: Implementación del cliente Invitacion.java setTitle(Constants.title_inv); si.setActionCommand("CLICK"); si.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) { try { // si el candidato se quiere unir String orden = "u/" + group + "/"; joingroup(miserv, miplatf, orden); miapp.grupo = group; dispose(); } catch (Exception excep) { System.out.println(excep); } ; } } }); no.setActionCommand("CLICK"); no.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) { try { // si el candidato no se quiere unir no se envia nada dispose(); } catch (Exception excep) { System.out.println(excep); } ; } } }); p1.setLayout(new FlowLayout(FlowLayout.CENTER)); p2.setLayout(new FlowLayout(FlowLayout.CENTER)); p3.setLayout(new FlowLayout(FlowLayout.CENTER)); p1.add(invitado); p2.add(peticion); p3.add(si); p3.add(no); add("North", p1); add("Center", p2); add("South", p3); addWindowListener(new WindowListener() { public void windowActivated(WindowEvent e) { } public void windowClosed(WindowEvent e) { } public void windowClosing(WindowEvent e) { dispose(); } public void windowDeactivated(WindowEvent e) { } public void windowDeiconified(WindowEvent e) { } public void windowIconified(WindowEvent e) { } public void windowOpened(WindowEvent e) { } }); pack(); show(); } // se crea el SUBSCRIBE correspondiente para unirnos al grupo public static void joingroup(IService servicio, IPlatform platf, String cadena) { try { servicio.subscribe(platf.getIdentity(), Constants.sipas, cadena, null, 3600, null); 124 Anexo B: Implementación del cliente Invitar.java } catch (Exception e) { } } } Invitar.java package com.ericsson; import import import import import import import import import import import import java.awt.Button; java.awt.FlowLayout; java.awt.Panel; java.awt.TextArea; java.awt.event.ActionEvent; java.awt.event.ActionListener; java.awt.event.WindowEvent; java.awt.event.WindowListener; java.awt.Frame; java.awt.Label; java.awt.event.*; java.awt.*; import com.ericsson.icp.IPlatform; import com.ericsson.icp.IService; public class Invitar extends Frame { TextArea msg = new TextArea("", 1, 30, 3); Button invitar = new Button(Constants.invitar); Button cancelar = new Button(Constants.cancelar); IPlatform miplatf; IService miserv; Aplicacion miapp; TextArea mitxt; String migrupo; Panel p1 = new Panel(); Panel p2 = new Panel(); Panel p3 = new Panel(); Label linvit = new Label(Constants.inserturii); public Invitar(IPlatform platf, IService serv, String grupo, TextArea txt) { miplatf = platf; miserv = serv; mitxt = txt; migrupo = grupo; invitar.setActionCommand("CLICK"); invitar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) { try { String user = msg.getText(); // comprobacion de formato valido // se envia la solicitud de expulsion miserv.sendMessage(miplatf.getIdentity(), Constants.sipas, Constants.content_tp, ("i/" + migrupo + "/sip:" + user + Constants.dominio + "/").getBytes(), ("i/" + migrupo + "/sip:" + user + Constants.dominio + "/").length()); mitxt.append(Constants.info5 + msg.getText() + "..."); msg.setText(""); dispose(); } catch (Exception ex) { } ; } } }); 125 Anexo B: Implementación del cliente PlatformAdapter.java cancelar.setActionCommand("CLICK"); cancelar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) dispose(); } }); setTitle(Constants.title_miembro); p1.setLayout(new FlowLayout(FlowLayout.CENTER)); p1.add(linvit); p2.setLayout(new FlowLayout(FlowLayout.CENTER)); p2.add(msg); p3.setLayout(new FlowLayout(FlowLayout.CENTER)); p3.add(invitar); p3.add(cancelar); add("North", p1); add("Center", p2); add("South", p3); addWindowListener(new WindowListener() { public void windowActivated(WindowEvent e) { } public void windowClosed(WindowEvent e) { } public void windowClosing(WindowEvent e) { dispose(); } public void windowDeactivated(WindowEvent e) { } public void windowDeiconified(WindowEvent e) { } public void windowIconified(WindowEvent e) { } public void windowOpened(WindowEvent e) { } }); pack(); show(); } } PlatformAdapter.java /* * * * * * * * * * * * * ********************************************************************** Copyright (c) Ericsson 2006. All Rights Reserved. Reproduction in whole or in part is prohibited without the written consent of the copyright owner. ERICSSON MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. ERICSSON SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. **********************************************************************/ package com.ericsson; import com.ericsson.icp.IPlatformListener; import com.ericsson.icp.IPlatform.State; import com.ericsson.icp.util.ErrorReason; public class PlatformAdapter implements IPlatformListener { public void processApplicationData(String aApplication, byte[] aData, int aLength) { } 126 Anexo B: Implementación del cliente Principal.java public void processEvent(String aEvent, String aSource, ErrorReason aReasonCode) { } public void processIcpStateChanged(State aState) { } public void processError(ErrorReason aError) { } } Principal.java package com.ericsson; import java.awt.*; import java.awt.event.*; import com.ericsson.icp.IPlatform; import com.ericsson.icp.IService; /** * This class shows the main windows with two options: Create a gruop or join an * existing group. * * @author Tony * */ public class Principal extends Frame { Button creacion = new Button(Constants.creacion); Button union = new Button(Constants.union); Button pc = new Button(Constants.pc); Button salir = new Button(Constants.x); String cadena; IPlatform miplatf; IService miserv; Aplicacion miapp; Union miadd; public Principal(IPlatform platf, IService servicio, Aplicacion app, Union add) { miplatf = platf; miserv = servicio; miapp = app; miadd = add; Font font = Constants.font9; Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); if (screenSize.width >= 640) { font = Constants.font12; } Label wellcome = new Label(Constants.wellcome); wellcome.setFont(font); wellcome.setForeground(Color.blue); Label wellcome2 = new Label(Constants.wellcome2); wellcome2.setFont(font); wellcome2.setForeground(Color.red); Panel p1 = new Panel(); Panel p2 = new Panel(); Panel p3 = new Panel(); setTitle("PLv1.0"); creacion.setActionCommand("CLICK"); creacion.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) { 127 Anexo B: Implementación del cliente Principal.java // se llama a la clase de creacion del grupo new Creacion(miplatf, miserv); } } }); union.setActionCommand("CLICK"); union.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) { // se llama a la clase de union a un grupo miadd.run(); } } }); pc.setActionCommand("CLICK"); pc.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) { // se llama a la clase de creacion del grupo new Activacion(miplatf, miserv); } } }); salir.setActionCommand("CLICK"); salir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) { System.exit(0); } } }); p1.setLayout(new FlowLayout(FlowLayout.CENTER)); p2.setLayout(new FlowLayout(FlowLayout.CENTER)); p3.setLayout(new FlowLayout(FlowLayout.CENTER)); p1.add(wellcome); p1.add(salir); p2.add(wellcome2); p3.add(creacion); p3.add(union); p3.add(pc); add("North", p1); add("Center", p2); add("South", p3); addWindowListener(new WindowListener() { public void windowActivated(WindowEvent e) { } public void windowClosed(WindowEvent e) { } public void windowClosing(WindowEvent e) { System.exit(0); } public void windowDeactivated(WindowEvent e) { } public void windowDeiconified(WindowEvent e) { } public void windowIconified(WindowEvent e) { } public void windowOpened(WindowEvent e) { } }); pack(); show(); } } 128 Anexo B: Implementación del cliente ServiceAdapter.java ServiceAdapter.java /* * * * * * * * * * * * * ********************************************************************** Copyright (c) Ericsson 2006. All Rights Reserved. Reproduction in whole or in part is prohibited without the written consent of the copyright owner. ERICSSON MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. ERICSSON SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. **********************************************************************/ package com.ericsson; import com.ericsson.icp.IServiceListener; import com.ericsson.icp.ISession; import com.ericsson.icp.util.ErrorReason; public class ServiceAdapter implements IServiceListener { public void processIncomingSession(ISession aSession) { } public void processSendMessageResult(boolean aStatus) { } public void processMessage(String aRemote, String aMsgType, byte[] aMessage, int aLength) { } public void processSubscribeResult(boolean aStatus, String aRemote, String aEvent) { } public void processUnsubscribeResult(boolean aStatus, String aRemote, String aEvent) { } public void processSubscribeNotification(String aRemote, String aEvent, String aType, byte[] aContent, int aLength) { } public void processPublishResult(boolean aStatus, String aRemote, String aEvent) { } public void processReferResult(boolean aStatus, String aReferId) { } public void processReferEnded(String aReferID) { } public void processSubscribeEnded(String aPreferedContact, String aRemote, String aEvent) { } public void processReferNotification(String aReferId, int aState) { } public void processRefer(String aReferID, String aRemote, String aThirdParty, String aContentType, byte[] aContent, int aLength) { } public void processReferNotifyResult(boolean status, String aReferID) { } public void processSendOptionsResult(boolean aStatus, String aPreferedContact, String aRemote, String aType, byte[] aContent, int aLength) { } public void processOptions(String aPreferedContact, String aRemote, String aType, 129 Anexo B: Implementación del cliente Union.java byte[] aContent, int aLength) { } public void processError(ErrorReason aError) { } } Union.java package com.ericsson; import import import import java.awt.*; java.awt.event.*; com.ericsson.icp.IPlatform; com.ericsson.icp.IService; /** * This class shows the 'union' window and offers the posibility to join a * group. The user need to know the uri of an existing group for join it. * * @author Tony * */ public class Union extends Frame { TextArea txt = new TextArea("", 1, 15, 3); Button unir = new Button(Constants.unir); Button cancel = new Button(Constants.cancelar); Button grupos = new Button(Constants.grupos); Panel p22 = new Panel(); Panel p2 = new Panel(); Panel p1 = new Panel(); Panel p3 = new Panel(); Panel p21 = new Panel(); List lista = new List(3); Label grupo = new Label(Constants.inserturig); IPlatform miplatf; IService miserv; public Union(IPlatform platf, IService serv) { miplatf = platf; miserv = serv; } public void run() { Font font = Constants.font9; Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); if (screenSize.width >= 640) { txt.setColumns(5); txt.setRows(1); font = Constants.font12; } grupo.setFont(font); txt.setFont(font); lista.setFont(font); setTitle("PLv1.0 Union"); unir.setActionCommand("CLICK"); unir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) { try { if (txt.getText() != null) { 130 Anexo B: Implementación del cliente Union.java // se concatena la uri completa del grupo y se envia // el mensaje adecuado al servidor String comando = "u/sip:" + txt.getText().trim() + Constants.dominiog + "/"; miserv.subscribe(miplatf.getIdentity(), Constants.sipas, comando, null, 3600, null); dispose(); } } catch (Exception excep) { System.out.println(excep); } ; } } }); cancel.setActionCommand("CLICK"); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) // si se pulsa cancel se cierra la ventana y se vuelve a la // pantalla inicial lista.removeAll(); dispose(); } }); grupos.setActionCommand("CLICK"); grupos.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Comando = e.getActionCommand(); if (Comando.compareTo("CLICK") == 0) try { // p22.add(lista); lista.removeAll(); miserv.sendMessage(miplatf.getIdentity(), Constants.sipas, Constants.content_tp, "g/<null>/" .getBytes(), "g/<null>/".length()); } catch (Exception excep) { } ; } }); p1.setLayout(new FlowLayout(FlowLayout.CENTER)); p2.setLayout(new FlowLayout(FlowLayout.LEFT)); p21.setLayout(new FlowLayout(FlowLayout.CENTER)); p22.setLayout(new FlowLayout(FlowLayout.RIGHT)); p3.setLayout(new FlowLayout(FlowLayout.CENTER)); lista.addItemListener(new ListaAL(lista, txt)); lista.setMultipleMode(false); lista.add(Constants.pgPC); p1.add(grupo); p21.add(txt); p22.add(lista); p2.add(p21); p2.add(p22); p3.add(unir); p3.add(grupos); p3.add(cancel); add("North", p1); add("Center", p2); add("South", p3); addWindowListener(new WindowListener() { public void windowActivated(WindowEvent e) { } public void windowClosed(WindowEvent e) { } public void windowClosing(WindowEvent e) { dispose(); } public void windowDeactivated(WindowEvent e) { } 131 Anexo B: Implementación del cliente Union.java public void windowDeiconified(WindowEvent e) { } public void windowIconified(WindowEvent e) { } public void windowOpened(WindowEvent e) { } }); pack(); show(); } } class ListaAL implements ItemListener { List milista; TextArea ta; ListaAL(List lista, TextArea texto) { milista = lista; ta = texto; } public void itemStateChanged(ItemEvent evt) { if (milista.getSelectedItem() != null) { if (!(milista.getSelectedItem().equals(Constants.pgPC))) ta.append(milista.getSelectedItem()); } } } 132 Anexo C: Script xml de pruebas PLTest.xml Anexo C: Script xml de pruebas PLTest.xml <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE ATF-SCRIPT (View Source for full doctype...)> ATF-SCRIPT> ser-agents> ser-agent name="Alice"> <public-id> <![CDATA[sip:[email protected]]]> </public-id> </user-agent> ser-agent name="Alex"> <public-id> <![CDATA[sip:[email protected]]]> </public-id> </user-agent> ser-agent name="Tony"> <public-id> <![CDATA[sip:[email protected]]]> </public-id> </user-agent> ser-agent name="Pol"> <public-id> <![CDATA[sip:[email protected]]]> </public-id> </user-agent> </user-agents> asks> ask name="Registro Alex, Tony y Pol" description="Registro de Alex, Tony y Pol"> end user-agent="Alex"> equest method="REGISTER" uri="sip:ericsson.com" protocol="sip" message-context=""> eceive user-agent="Alex"> esponse code="200" reason="OK" message-context=""> end user-agent="Tony"> equest method="REGISTER" uri="sip:ericsson.com" protocol="sip" message-context=""> eceive user-agent="Tony"> esponse code="200" reason="OK" message-context=""> end user-agent="Pol"> equest method="REGISTER" uri="sip:ericsson.com" protocol="sip" message-context=""> eceive user-agent="Pol"> esponse code="200" reason="OK" message-context="" /> </receive> </request> </send> </response> </receive> </request> </send> </response> </receive> </request> </send> </task> ask name="Registro Alice" description="Registro del UA Alice"> end user-agent="Alice"> equest method="REGISTER" uri="sip:ericsson.com" protocol="sip" message-context=""> eceive user-agent="Alice"> esponse code="200" reason="OK" message-context="" /> </receive> </request> </send> </task> ask name="Alice GC, Alex y Tony candidatos" description="Alice crea el grupo invitando a Alex y Tony"> end user-agent="Alice"> equest method="SUBSCRIBE" uri="sip:[email protected]" protocol="sip" message-context=""> eader name="Route"> <equals> <![CDATA[<sip:[email protected]:5081;lr>]]> </equals> </header> eader name="Event"> <equals> <![CDATA[c/y/sip:[email protected]/sip:[email protected]/]]> </equals> </header> eader name="Expires"> <equals> <![CDATA[3600]]> </equals> </header> 133 Anexo C: Script xml de pruebas PLTest.xml eceive user-agent="Alice"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Alice"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alice"> esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> </response> </receive> </request> </send> </task> ask name="Alex y Tony invitados y aceptan (servidor)" description="Alex y Tony aceptan invitación y notificaciones"> eceive user-agent="Alex"> equest method="MESSAGE" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Tony"> equest method="MESSAGE" uri="" protocol="sip" message-context=""> end user-agent="Tony"> esponse code="200" reason="OK" message-context=""> end user-agent="Alex"> equest method="SUBSCRIBE" uri="sip:[email protected]" protocol="sip" message-context=""> eader name="Route"> <equals> <![CDATA[<sip:[email protected]:5081;lr>]]> </equals> </header> eader name="Event"> <equals> <![CDATA[u/sip:[email protected]/]]> </equals> </header> eader name="Expires"> <equals> <![CDATA[3600]]> </equals> </header> eceive user-agent="Alex"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Alex"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Alice"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alice"> esponse code="200" reason="OK" message-context=""> end user-agent="Tony"> equest method="SUBSCRIBE" uri="sip:[email protected]" protocol="sip" message-context=""> eader name="Route"> <equals> <![CDATA[<sip:[email protected]:5081;lr>]]> </equals> </header> eader name="Event"> <equals> <![CDATA[u/sip:[email protected]/]]> </equals> </header> eader name="Expires"> <equals> <![CDATA[3600]]> </equals> </header> eceive user-agent="Tony"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Tony"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Tony"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Alice"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alice"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Alex"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> </response> </send> 134 Anexo C: Script xml de pruebas PLTest.xml </request> </receive> </response> </send> </request> </receive> </response> </receive> </request> </send> </response> </send> </request> </receive> </response> </send> </request> </receive> </response> </receive> </request> </send> </response> </send> </request> </receive> </response> </send> </request> </receive> </task> ask name="Alex y Tony invitados y aceptan (Cliente GC)" description="Alex y Tony aceptan invitación y notificaciones"> eceive user-agent="Alex"> equest method="MESSAGE" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Tony"> equest method="MESSAGE" uri="" protocol="sip" message-context=""> end user-agent="Tony"> esponse code="200" reason="OK" message-context=""> end user-agent="Alex"> equest method="SUBSCRIBE" uri="sip:[email protected]" protocol="sip" message-context=""> eader name="Route"> <equals> <![CDATA[<sip:[email protected]:5081;lr>]]> </equals> </header> eader name="Event"> <equals> <![CDATA[u/sip:[email protected]/]]> </equals> </header> eader name="Expires"> <equals> <![CDATA[3600]]> </equals> </header> eceive user-agent="Alex"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Alex"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context=""> end user-agent="Tony"> equest method="SUBSCRIBE" uri="sip:[email protected]" protocol="sip" message-context=""> eader name="Route"> <equals> <![CDATA[<sip:[email protected]:5081;lr>]]> </equals> </header> eader name="Event"> <equals> <![CDATA[u/sip:[email protected]/]]> </equals> </header> eader name="Expires"> <equals> <![CDATA[3600]]> </equals> </header> eceive user-agent="Tony"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Tony"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Tony"> esponse code="200" reason="OK" message-context=""> 135 Anexo C: Script xml de pruebas PLTest.xml eceive user-agent="Alex"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> </response> </send> </request> </receive> </response> </receive> </request> </send> </response> </send> </request> </receive> </response> </receive> </request> </send> </response> </send> </request> </receive> </response> </send> </request> </receive> </task> ask name="Pol solicita FB" description="Pol solicita unión FB"> end user-agent="Pol"> equest method="SUBSCRIBE" uri="sip:[email protected]" protocol="sip" message-context=""> eader name="Route"> <equals> <![CDATA[<sip:[email protected]:5081;lr>]]> </equals> </header> eader name="Event"> <equals> <![CDATA[u/sip:[email protected]/]]> </equals> </header> eader name="Expires"> <equals> <![CDATA[3600]]> </equals> </header> eceive user-agent="Pol"> esponse code="200" reason="OK" message-context="" /> </receive> </request> </send> </task> ask name="AliceGC acepta Pol" description="AliceGC acepta POL y recibe notificacion"> eceive user-agent="Alice"> equest method="MESSAGE" uri="" protocol="sip" message-context=""> end user-agent="Alice"> esponse code="200" reason="OK" message-context=""> end user-agent="Alice"> equest method="MESSAGE" uri="sip:[email protected]" protocol="sip" message-context=""> eader name="Route"> <equals> <![CDATA[<sip:[email protected]:5081;lr>]]> </equals> </header> eader name="Content-Type"> <equals> <![CDATA[text/plain]]> </equals> </header> ontent> <equals> <![CDATA[u/<sip:[email protected]>/y]]> </equals> </content> eceive user-agent="Alice"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Alice"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alice"> esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> 136 Anexo C: Script xml de pruebas PLTest.xml </response> </receive> </request> </send> </response> </send> </request> </receive> </task> ask name="AliceGC rechaza a Pol" description="Union FB de Pol rechazada"> eceive user-agent="Alice"> equest method="MESSAGE" uri="" protocol="sip" message-context=""> end user-agent="Alice"> esponse code="200" reason="OK" message-context=""> end user-agent="Alice"> equest method="MESSAGE" uri="sip:[email protected]" protocol="sip" message-context=""> eader name="Route"> <equals> <![CDATA[<sip:[email protected]:5081;lr>]]> </equals> </header> eader name="Content-Type"> <equals> <![CDATA[text/plain]]> </equals> </header> ontent> <equals> <![CDATA[u/<sip:[email protected]>/n]]> </equals> </content> eceive user-agent="Alice"> esponse code="200" reason="OK" message-context="" /> </receive> </request> </send> </response> </send> </request> </receive> </task> ask name="Pol rechazado" description="Pol recibe mensaje de union rechazada"> eceive user-agent="Pol"> equest method="MESSAGE" uri="" protocol="sip" message-context=""> end user-agent="Pol"> esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> </task> ask name="Notificacion POL FB unido" description="Alex,Tony y Pol reciben notificacion"> eceive user-agent="Pol"> equest method="MESSAGE" uri="" protocol="sip" message-context=""> end user-agent="Pol"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Alex"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Tony"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Tony"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Pol"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Pol"> esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> </response> </send> </request> </receive> </response> </send> </request> </receive> </response> </send> </request> </receive> </task> ask name="AlexGC, Alice y Tony candidatos" description="Alex crea grupo e invita a Alice y Tony"> end user-agent="Alex"> equest method="SUBSCRIBE" uri="sip:[email protected]" protocol="sip" message-context=""> 137 Anexo C: Script xml de pruebas PLTest.xml eader name="Route"> <equals> <![CDATA[<sip:[email protected]:5081;lr>]]> </equals> </header> eader name="Event"> <equals> <![CDATA[c/y/sip:[email protected]/sip:[email protected]/]]> </equals> </header> eader name="Expires"> <equals> <![CDATA[3600]]> </equals> </header> eceive user-agent="Alex"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Alex"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> </response> </receive> </request> </send> </task> ask name="Tony recibe invitación y acepta" description="Tony acepta invitacion y notificaciones"> eceive user-agent="Tony"> equest method="MESSAGE" uri="" protocol="sip" message-context=""> end user-agent="Tony"> esponse code="200" reason="OK" message-context=""> end user-agent="Tony"> equest method="SUBSCRIBE" uri="sip:[email protected]" protocol="sip" message-context=""> eader name="Route"> <equals> <![CDATA[<sip:[email protected]:5081;lr>]]> </equals> </header> eader name="Event"> <equals> <![CDATA[u/sip:[email protected]/]]> </equals> </header> eader name="Expires"> <equals> <![CDATA[3600]]> </equals> </header> eceive user-agent="Tony"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Tony"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Tony"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Alex"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> </response> </send> </request> </receive> </response> </receive> </request> </send> </response> </send> </request> </receive> </task> ask name="Notificaciones union Alice" description="Alex y Tony reciben notificacion tras union de Alice"> eceive user-agent="Alex"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Tony"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Tony"> 138 Anexo C: Script xml de pruebas PLTest.xml esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> </response> </send> </request> </receive> </task> ask name="AlexGC acepta PolFB" description="Alex acepta a Pol y notificaciones"> eceive user-agent="Alex"> equest method="MESSAGE" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context=""> end user-agent="Alex"> equest method="MESSAGE" uri="sip:[email protected]" protocol="sip" message-context=""> eader name="Route"> <equals> <![CDATA[<sip:[email protected]:5081;lr>]]> </equals> </header> eader name="Content-Type"> <equals> <![CDATA[text/plain]]> </equals> </header> ontent> <equals> <![CDATA[u/<sip:[email protected]>/y]]> </equals> </content> eceive user-agent="Alex"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Alex"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Tony"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Tony"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Pol"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Pol"> esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> </response> </send> </request> </receive> </response> </send> </request> </receive> </response> </receive> </request> </send> </response> </send> </request> </receive> </task> ask name="AlexGC, Tony Pol candidatos (no confirmado)" description="Alex crea grupo e invita a Tony y Pol"> end user-agent="Alex"> equest method="SUBSCRIBE" uri="sip:[email protected]" protocol="sip" message-context=""> eader name="Route"> <equals> <![CDATA[<sip:[email protected]:5081;lr>]]> </equals> </header> eader name="Event"> <equals> <![CDATA[c/n/sip:[email protected]/sip:[email protected]/]]> </equals> </header> eader name="Expires"> <equals> <![CDATA[3600]]> </equals> </header> eceive user-agent="Alex"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Alex"> 139 Anexo C: Script xml de pruebas PLTest.xml equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> </response> </receive> </request> </send> </task> ask name="AlexGC, Tony Pol candidatos (confirmado)" description="Alex crea grupo e invita a Tony y Pol"> end user-agent="Alex"> equest method="SUBSCRIBE" uri="sip:[email protected]" protocol="sip" message-context=""> eader name="Route"> <equals> <![CDATA[<sip:[email protected]:5081;lr>]]> </equals> </header> eader name="Event"> <equals> <![CDATA[c/y/sip:[email protected]/sip:[email protected]/]]> </equals> </header> eader name="Expires"> <equals> <![CDATA[3600]]> </equals> </header> eceive user-agent="Alex"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Alex"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> </response> </receive> </request> </send> </task> ask name="Tony Pol invitados y aceptan" description="Tony y Pol aceptan invitacion y notificaciones"> eceive user-agent="Tony"> equest method="MESSAGE" uri="" protocol="sip" message-context=""> end user-agent="Tony"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Pol"> equest method="MESSAGE" uri="" protocol="sip" message-context=""> end user-agent="Pol"> esponse code="200" reason="OK" message-context=""> end user-agent="Tony"> equest method="SUBSCRIBE" uri="sip:[email protected]" protocol="sip" message-context=""> eader name="Route"> <equals> <![CDATA[<sip:[email protected]:5081;lr>]]> </equals> </header> eader name="Event"> <equals> <![CDATA[u/sip:[email protected]/]]> </equals> </header> eceive user-agent="Tony"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Tony"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Tony"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Alex"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context=""> end user-agent="Pol"> equest method="SUBSCRIBE" uri="sip:[email protected]" protocol="sip" message-context=""> eader name="Route"> <equals> <![CDATA[<sip:[email protected]:5081;lr>]]> </equals> </header> eader name="Event"> <equals> <![CDATA[u/sip:[email protected]/]]> </equals> 140 Anexo C: Script xml de pruebas PLTest.xml </header> eader name="Expires"> <equals> <![CDATA[3600]]> </equals> </header> eceive user-agent="Pol"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Pol"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Pol"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Alex"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Tony"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Tony"> esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> </response> </send> </request> </receive> </response> </send> </request> </receive> </response> </receive> </request> </send> </response> </send> </request> </receive> </response> </send> </request> </receive> </response> </receive> </request> </send> </response> </send> </request> </receive> </response> </send> </request> </receive> </task> ask name="Alice se une FB" description="Notificaciones de union FB"> eceive user-agent="Alex"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Tony"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Tony"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Pol"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Pol"> esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> </response> </send> </request> </receive> </response> </send> </request> </receive> </task> ask name="Cliente se da de baja (Alice)" description="Notificaciones de la baja a Alex"> eceive user-agent="Alex"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> ontent> <contains> <![CDATA[f/]]> 141 Anexo C: Script xml de pruebas PLTest.xml </contains> </content> end user-agent="Alex"> esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> </task> ask name="Miembro se da de baja (Tony)" description="Envio de la baja y rx de notificaciones (Alex, Tony y Pol)"> end user-agent="Tony"> equest method="MESSAGE" uri="sip:[email protected]" protocol="sip" message-context=""> eader name="Route"> <equals> <![CDATA[<sip:[email protected]:5081;lr>]]> </equals> </header> eader name="Content-Type"> <equals> <![CDATA[text/plain]]> </equals> </header> ontent> <equals> <![CDATA[b/<sip:[email protected]>/]]> </equals> </content> eceive user-agent="Tony"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Alex"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Tony"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Tony"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Pol"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Pol"> esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> </response> </send> </request> </receive> </response> </send> </request> </receive> </response> </receive> </request> </send> </task> ask name="Alex GC se da de baja" description="Envio de baja y notificaciones a Alex y a Pol"> end user-agent="Alex"> equest method="MESSAGE" uri="sip:[email protected]" protocol="sip" message-context=""> eader name="Route"> <equals> <![CDATA[<sip:[email protected]:5081;lr>]]> </equals> </header> eader name="Content-Type"> <equals> <![CDATA[text/plain]]> </equals> </header> ontent> <equals> <![CDATA[b/<sip:[email protected]>]]> </equals> </content> eceive user-agent="Alex"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Alex"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Pol"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Pol"> esponse code="200" reason="OK" message-context="" /> </send> 142 Anexo C: Script xml de pruebas PLTest.xml </request> </receive> </response> </send> </request> </receive> </response> </receive> </request> </send> </task> ask name="Alice recibe notificacion de baja" description="NOTIFY de baja para Alice"> eceive user-agent="Alice"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alice"> esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> </task> ask name="Alice solicita baja y notificaciones" description="Baja de Alice y notificaciones para Alice y Alex"> end user-agent="Alice"> equest method="MESSAGE" uri="sip:[email protected]" protocol="sip" message-context=""> eader name="Route"> <equals> <![CDATA[<sip:[email protected]:5081;lr>]]> </equals> </header> eader name="Content-Type"> <equals> <![CDATA[text/plain]]> </equals> </header> ontent> <equals> <![CDATA[b/<sip:[email protected]>/]]> </equals> </content> eceive user-agent="Alice"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Alice"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alice"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Alex"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> </response> </send> </request> </receive> </response> </receive> </request> </send> </task> ask name="AlexGC acepta Alice FB" description="AlexGC acepta union FB"> eceive user-agent="Alex"> equest method="MESSAGE" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context=""> end user-agent="Alex"> equest method="MESSAGE" uri="sip:[email protected]" protocol="sip" message-context=""> eader name="Route"> <equals> <![CDATA[<sip:[email protected]:5081;lr>]]> </equals> </header> eader name="Content-Type"> <equals> <![CDATA[text/plain]]> </equals> </header> ontent> <equals> <![CDATA[u/<sip:[email protected]>/y]]> </equals> </content> eceive user-agent="Alex"> esponse code="200" reason="OK" message-context="" /> </receive> </request> 143 Anexo C: Script xml de pruebas PLTest.xml </send> </response> </send> </request> </receive> </task> ask name="Union bucle usuarios" description=""> end user-agent="Alice"> equest method="SUBSCRIBE" uri="sip:[email protected]" protocol="sip" message-context=""> eader name="Route"> <equals> <![CDATA[<sip:[email protected]:5081;lr>]]> </equals> </header> eader name="Expires"> <equals> <![CDATA[3600]]> </equals> </header> eader name="Event"> <equals> <![CDATA[u/sip:[email protected]/]]> </equals> </header> eceive user-agent="Alice"> esponse code="200" reason="OK" message-context="" /> </receive> </request> </send> </task> ask name="Alice expulsa a Pol" description="Expulsion de Pol"> end user-agent="Alice"> equest method="MESSAGE" uri="sip:[email protected]" protocol="sip" message-context=""> eader name="Route"> <equals> <![CDATA[<sip:[email protected]:5081;lr>]]> </equals> </header> eader name="Content-Type"> <equals> <![CDATA[text/plain]]> </equals> </header> ontent> <equals> <![CDATA[e/<sip:[email protected]>/3]]> </equals> </content> eceive user-agent="Alice"> esponse code="200" reason="OK" message-context="" /> </receive> </request> </send> </task> ask name="Alice confirma Pol expulsado" description="NOTIFY de expulsion de Pol para Alice"> eceive user-agent="Alice"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alice"> esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> </task> ask name="Pol expulsado" description="Notificaciones de expulsion de Pol para Alex y Pol"> eceive user-agent="Alex"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Pol"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Pol"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Pol"> equest method="NOTIFY" uri="" protocol="sip" message-context=""> end user-agent="Pol"> esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> </response> </send> </request> </receive> </response> </send> 144 Anexo C: Script xml de pruebas PLTest.xml </request> </receive> </task> ask name="Pol envia IM" description="Envio de IM"> end user-agent="Pol"> equest method="MESSAGE" uri="sip:[email protected]" protocol="sip" message-context=""> eader name="Route"> <equals> <![CDATA[<sip:[email protected]:5081;lr>]]> </equals> </header> eader name="Content-Type"> <equals> <![CDATA[text/plain]]> </equals> </header> ontent> <equals> <![CDATA[s/<sip:[email protected]>/user3: Aqui esta Pol/]]> </equals> </content> eceive user-agent="Pol"> esponse code="200" reason="OK" message-context="" /> </receive> </request> </send> </task> ask name="Pol IM para Alice" description="Pol IM para Alice"> eceive user-agent="Alice"> equest method="MESSAGE" uri="" protocol="sip" message-context=""> end user-agent="Alice"> esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> </task> ask name="Difusion de Pol IM" description="Envio de Pol IM a Alex y Tony"> eceive user-agent="Alex"> equest method="MESSAGE" uri="" protocol="sip" message-context=""> end user-agent="Alex"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Tony"> equest method="MESSAGE" uri="" protocol="sip" message-context=""> end user-agent="Tony"> esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> </response> </send> </request> </receive> </task> ask name="Cliente envia IM (Alice)" description="Difusion de AliceGC IM para Alex,Tony y Pol"> eceive user-agent="Alex"> equest method="MESSAGE" uri="" protocol="sip" message-context=""> ontent> <contains> <![CDATA[s/]]> </contains> </content> end user-agent="Alex"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Tony"> equest method="MESSAGE" uri="" protocol="sip" message-context=""> ontent> <contains> <![CDATA[s/]]> </contains> </content> end user-agent="Tony"> esponse code="200" reason="OK" message-context=""> eceive user-agent="Pol"> equest method="MESSAGE" uri="" protocol="sip" message-context=""> ontent> <contains> <![CDATA[s/]]> </contains> </content> end user-agent="Pol"> esponse code="200" reason="OK" message-context="" /> </send> </request> </receive> </response> </send> 145 Anexo C: Script xml de pruebas PLTest.xml </request> </receive> </response> </send> </request> </receive> </task> </tasks> xecution> epeat name="Servidor" description="Prueba completa de las funcionalidades del servidor." times="1" task-wait="1000" loop-wait="1000"> ask name="Registro Alice" /> ask name="Registro Alex, Tony y Pol" /> ask name="Alice GC, Alex y Tony candidatos" /> ask name="Alex y Tony invitados y aceptan (servidor)" /> ask name="Pol solicita FB" /> ask name="AliceGC rechaza a Pol" /> ask name="Pol rechazado" /> ask name="Pol solicita FB" /> ask name="AliceGC acepta Pol" /> ask name="Notificacion POL FB unido" /> ask name="Pol envia IM" /> ask name="Pol IM para Alice" /> ask name="Difusion de Pol IM" /> ask name="Miembro se da de baja (Tony)" /> ask name="Alice recibe notificacion de baja" /> ask name="Alice expulsa a Pol" /> ask name="Alice confirma Pol expulsado" /> ask name="Pol expulsado" /> ask name="Alice solicita baja y notificaciones" /> </repeat> epeat name="Cliente GC" description="Prueba de las funcionalidades del cliente en rol de GC" times="1" task-wait="1000" loop-wait="1000"> ask name="Registro Alex, Tony y Pol" /> wait milliseconds="2000" /> ask name="Alex y Tony invitados y aceptan (Cliente GC)" /> ask name="Pol solicita FB" /> ask name="Pol rechazado" /> ask name="Pol solicita FB" /> ask name="Notificacion POL FB unido" /> ask name="Pol envia IM" /> ask name="Difusion de Pol IM" /> ask name="Cliente envia IM (Alice)" /> ask name="Miembro se da de baja (Tony)" /> wait milliseconds="5000" /> ask name="Pol expulsado" /> ask name="Cliente se da de baja (Alice)" /> </repeat> epeat name="Cliente candidato" description="Prueba de las funcionalidades del cliente en rol de candidato" times="1" task-wait="1000" loop-wait="1000"> ask name="Registro Alex, Tony y Pol" /> ask name="AlexGC, Alice y Tony candidatos" /> ask name="Tony recibe invitación y acepta" /> wait milliseconds="2000" /> ask name="Notificaciones union Alice" /> ask name="Pol solicita FB" /> ask name="AlexGC acepta PolFB" /> ask name="Cliente envia IM (Alice)" /> ask name="Miembro se da de baja (Tony)" /> wait milliseconds="3000" /> ask name="Alex GC se da de baja" /> </repeat> epeat name="Cliente FB (confirmado)" description="Prueba de las funcionalidades del cliente como usuario FB" times="1" task-wait="1000" loop-wait="1000"> ask name="Registro Alex, Tony y Pol" /> ask name="AlexGC, Tony Pol candidatos (confirmado)" /> ask name="Tony Pol invitados y aceptan" /> ask name="AlexGC acepta Alice FB" /> ask name="Alice se une FB" /> ask name="Miembro se da de baja (Tony)" /> ask name="Cliente se da de baja (Alice)" /> </repeat> epeat name="Cliente FB (no confirmado)" description="" times="1" task-wait="1000" loopwait="1000"> ask name="Registro Alex, Tony y Pol" /> ask name="AlexGC, Tony Pol candidatos (no confirmado)" /> ask name="Tony Pol invitados y aceptan" /> ask name="Alice se une FB" /> ask name="Miembro se da de baja (Tony)" /> ask name="Cliente se da de baja (Alice)" /> </repeat> epeat name="Prueba bucle usuarios" description="" times="1" task-wait="1000" loopwait="1000"> ask name="Registro Alice" /> ask name="Union bucle usuarios" /> </repeat> </execution> 146 Anexo C: Script xml de pruebas PLTest.xml </ATF-SCRIPT> 147