import java.awt.event.ActionListener; | import java.awt.event.ActionListener; | ||||
import java.util.logging.Logger; | import java.util.logging.Logger; | ||||
import logger.OhmLogger; | import logger.OhmLogger; | ||||
import model.VoIP; | |||||
import model.SIPmodel; | |||||
/** | /** | ||||
* | * | ||||
public class CommandController implements ActionListener | public class CommandController implements ActionListener | ||||
{ | { | ||||
private static final Logger lc = OhmLogger.getLogger(); | private static final Logger lc = OhmLogger.getLogger(); | ||||
private VoIP model; | |||||
private SIPmodel model; | |||||
private Hauptfenster view; | private Hauptfenster view; | ||||
private CommandInvoker invoker; | private CommandInvoker invoker; | ||||
public CommandController(VoIP model, Hauptfenster view) | |||||
public CommandController(SIPmodel model, Hauptfenster view) | |||||
{ | { | ||||
this.model = model; | this.model = model; | ||||
this.view = view; | this.view = view; |
/** | /** | ||||
* | * | ||||
* @author Jan | * @author Jan | ||||
* wird an sich noch nicht gebraucht aber später noch nützlich | |||||
* momentan wird nur execute gebraucht, undo später sinnvoll bzw. vielleicht | |||||
* bei cancel von Invite oder Anruf statt Anruf beenden. | |||||
*/ | */ | ||||
public interface CommandInterface | public interface CommandInterface | ||||
{ | { |
import gui.Hauptfenster; | import gui.Hauptfenster; | ||||
import java.util.logging.Logger; | import java.util.logging.Logger; | ||||
import logger.OhmLogger; | import logger.OhmLogger; | ||||
import model.VoIP; | |||||
import model.SIPmodel; | |||||
/** | /** | ||||
* | * | ||||
public class CommandAnnehmen implements CommandInterface | public class CommandAnnehmen implements CommandInterface | ||||
{ | { | ||||
private static final Logger lginvite = OhmLogger.getLogger(); | private static final Logger lginvite = OhmLogger.getLogger(); | ||||
private VoIP model; | |||||
private SIPmodel model; | |||||
private Hauptfenster view; | private Hauptfenster view; | ||||
public CommandAnnehmen(VoIP model, Hauptfenster view) | |||||
public CommandAnnehmen(SIPmodel model, Hauptfenster view) | |||||
{ | { | ||||
this.model = model; | this.model = model; | ||||
this.view = view; | this.view = view; |
import gui.Hauptfenster; | import gui.Hauptfenster; | ||||
import java.util.logging.Logger; | import java.util.logging.Logger; | ||||
import logger.OhmLogger; | import logger.OhmLogger; | ||||
import model.VoIP; | |||||
import model.SIPmodel; | |||||
/** | /** | ||||
* | * | ||||
* @author Jan | * @author Jan | ||||
* Muss noch komplett implementiert werden | * Muss noch komplett implementiert werden | ||||
* -> Bye bei laufendem Gespräch | |||||
* -> Cancel bei laufender Anfrage | |||||
*/ | */ | ||||
public class CommandBeenden implements CommandInterface | public class CommandBeenden implements CommandInterface | ||||
{ | { | ||||
private static final Logger lginvite = OhmLogger.getLogger(); | private static final Logger lginvite = OhmLogger.getLogger(); | ||||
private VoIP model; | |||||
private SIPmodel model; | |||||
private Hauptfenster view; | private Hauptfenster view; | ||||
public CommandBeenden(VoIP model, Hauptfenster view) | |||||
public CommandBeenden(SIPmodel model, Hauptfenster view) | |||||
{ | { | ||||
this.model = model; | this.model = model; | ||||
this.view = view; | this.view = view; |
import javax.sip.InvalidArgumentException; | import javax.sip.InvalidArgumentException; | ||||
import javax.sip.SipException; | import javax.sip.SipException; | ||||
import logger.OhmLogger; | import logger.OhmLogger; | ||||
import model.VoIP; | |||||
import model.SIPmodel; | |||||
/** | /** | ||||
* | * | ||||
public class CommandInvite implements CommandInterface | public class CommandInvite implements CommandInterface | ||||
{ | { | ||||
private static final Logger lginvite = OhmLogger.getLogger(); | private static final Logger lginvite = OhmLogger.getLogger(); | ||||
private VoIP model; | |||||
private SIPmodel model; | |||||
private Hauptfenster view; | private Hauptfenster view; | ||||
public CommandInvite(VoIP model, Hauptfenster view) | |||||
public CommandInvite(SIPmodel model, Hauptfenster view) | |||||
{ | { | ||||
this.model = model; | this.model = model; | ||||
this.view = view; | this.view = view; |
import javax.sip.InvalidArgumentException; | import javax.sip.InvalidArgumentException; | ||||
import javax.sip.SipException; | import javax.sip.SipException; | ||||
import logger.OhmLogger; | import logger.OhmLogger; | ||||
import model.VoIP; | |||||
import model.SIPmodel; | |||||
/** | /** | ||||
* | * | ||||
public class CommandRegister implements CommandInterface | public class CommandRegister implements CommandInterface | ||||
{ | { | ||||
private static final Logger lgregister = OhmLogger.getLogger(); | private static final Logger lgregister = OhmLogger.getLogger(); | ||||
private VoIP model; | |||||
private SIPmodel model; | |||||
private Hauptfenster view; | private Hauptfenster view; | ||||
public CommandRegister(VoIP model, Hauptfenster view) | |||||
public CommandRegister(SIPmodel model, Hauptfenster view) | |||||
{ | { | ||||
this.model = model; | this.model = model; | ||||
this.view = view; | this.view = view; |
import logger.myformatter.MyFormatter; | import logger.myformatter.MyFormatter; | ||||
/** | /** | ||||
* | |||||
* nobody | |||||
* | * | ||||
*/ | */ | ||||
public class OhmLogger | public class OhmLogger |
/** | /** | ||||
* | * | ||||
* @author Jan | * @author Jan | ||||
* komplettes Model für VoIP | |||||
komplettes Model für SIPmodel | |||||
*/ | */ | ||||
public class VoIP implements SipListenerExt | |||||
public class SIPmodel implements SipListenerExt | |||||
{ | { | ||||
Hauptfenster view; //später entfernen wegen Zugriff | Hauptfenster view; //später entfernen wegen Zugriff | ||||
private static final Logger lg = OhmLogger.getLogger(); | private static final Logger lg = OhmLogger.getLogger(); | ||||
Address contactAddress; | Address contactAddress; | ||||
private ContactHeader contactHeader; | private ContactHeader contactHeader; | ||||
public VoIP(Hauptfenster view) //Konstruktor für eigene Daten | |||||
public SIPmodel(Hauptfenster view) //Konstruktor für eigene Daten | |||||
{ | { | ||||
this.view = view; | this.view = view; | ||||
invite = true; | invite = true; | ||||
} | } | ||||
catch (ParseException | SipException ex) | catch (ParseException | SipException ex) | ||||
{ | { | ||||
lg.getLogger(VoIP.class.getName()).log(Level.SEVERE, null, ex); | |||||
lg.getLogger(SIPmodel.class.getName()).log(Level.SEVERE, null, ex); | |||||
} | } | ||||
} | } | ||||
//Aktive Kommunikation | //Aktive Kommunikation | ||||
} | } | ||||
catch (ParseException | SipException | InvalidArgumentException ex) | catch (ParseException | SipException | InvalidArgumentException ex) | ||||
{ | { | ||||
lg.getLogger(VoIP.class.getName()).log(Level.SEVERE, null, ex); | |||||
lg.getLogger(SIPmodel.class.getName()).log(Level.SEVERE, null, ex); | |||||
} | } | ||||
} | } | ||||
mediavec.add(sdpFactory.createAttribute("rtpmap", "18 G729/8000")); | mediavec.add(sdpFactory.createAttribute("rtpmap", "18 G729/8000")); | ||||
mediavec.add(sdpFactory.createAttribute("ptime", "20")); | mediavec.add(sdpFactory.createAttribute("ptime", "20")); | ||||
} | } | ||||
else | |||||
else//Vergleich von eigenen Codecs mit Codecs der anruft und Rückgabe entsprechend wählen | |||||
{ | { | ||||
} | } | ||||
try | try | ||||
{ | { | ||||
//Trying Message to Server (Response Trying) | //Trying Message to Server (Response Trying) | ||||
Response responsetry = this.messageFactory.createResponse(100, requestEvent.getRequest()); | Response responsetry = this.messageFactory.createResponse(100, requestEvent.getRequest()); | ||||
responsetry.addHeader((ViaHeader) requestEvent.getRequest().getHeader("Via")); | responsetry.addHeader((ViaHeader) requestEvent.getRequest().getHeader("Via")); | ||||
responsetry.addHeader((FromHeader) requestEvent.getRequest().getHeader("From")); | responsetry.addHeader((FromHeader) requestEvent.getRequest().getHeader("From")); | ||||
} | } | ||||
catch (ParseException | SipException | SdpException ex) | catch (ParseException | SipException | SdpException ex) | ||||
{ | { | ||||
Logger.getLogger(VoIP.class.getName()).log(Level.SEVERE, null, ex); | |||||
Logger.getLogger(SIPmodel.class.getName()).log(Level.SEVERE, null, ex); | |||||
} | } | ||||
} | } | ||||
@Override | @Override | ||||
public void processTimeout(TimeoutEvent timeoutEvent) | public void processTimeout(TimeoutEvent timeoutEvent) | ||||
{ | { | ||||
view.getTxtArea().append("processTimeout\n"); | |||||
//view.getTxtArea().append("processTimeout\n"); | |||||
} | } | ||||
@Override | @Override | ||||
public void processIOException(IOExceptionEvent exceptionEvent) | public void processIOException(IOExceptionEvent exceptionEvent) | ||||
{ | { | ||||
view.getTxtArea().append("processIOException\n"); | |||||
//view.getTxtArea().append("processIOException\n"); | |||||
} | } | ||||
@Override | @Override | ||||
public void processTransactionTerminated( | public void processTransactionTerminated( | ||||
TransactionTerminatedEvent transactionTerminatedEvent) | TransactionTerminatedEvent transactionTerminatedEvent) | ||||
{ | { | ||||
view.getTxtArea().append("processTransactionTerminated\n"); | |||||
//view.getTxtArea().append("processTransactionTerminated\n"); | |||||
} | } | ||||
@Override | @Override | ||||
public void processDialogTerminated( | public void processDialogTerminated( | ||||
DialogTerminatedEvent dialogTerminatedEvent) | DialogTerminatedEvent dialogTerminatedEvent) | ||||
{ | { | ||||
view.getTxtArea().append("processDialogTerminated\n"); | |||||
//view.getTxtArea().append("processDialogTerminated\n"); | |||||
} | } | ||||
} | } |
import java.net.InetAddress; | import java.net.InetAddress; | ||||
import java.net.UnknownHostException; | import java.net.UnknownHostException; | ||||
import java.text.ParseException; | import java.text.ParseException; | ||||
import model.VoIP; | |||||
import model.SIPmodel; | |||||
/** | /** | ||||
* Builder Class / Start Klasse des Programmes | * Builder Class / Start Klasse des Programmes | ||||
* @author Jan | * @author Jan | ||||
public Start() throws ParseException, UnknownHostException | public Start() throws ParseException, UnknownHostException | ||||
{ | { | ||||
Hauptfenster view = new Hauptfenster(); | Hauptfenster view = new Hauptfenster(); | ||||
VoIP model = new VoIP(view); | |||||
SIPmodel model = new SIPmodel(view); | |||||
CommandController controller = new CommandController(model, view); | CommandController controller = new CommandController(model, view); | ||||
controller.registerEvents(); | controller.registerEvents(); |