/** Handle a dial request */ public void handleDialRequest(String phoneNumber) { try { System.err.println( "Audio Static:" + PhoneManager.isUseStaticLocator() + " Using:" + PhoneManager.isUsingMediaLocator()); // cancel call request if no Media Locator if (PhoneManager.isUseStaticLocator() && PhoneManager.isUsingMediaLocator()) { return; } PhoneManager.setUsingMediaLocator(true); SessionDescription sdpData = mediaManager.generateSdpDescription(); Call call = sipManager.establishCall(phoneNumber, sdpData.toString()); if (call == null) return; call.setLocalSdpDescription(sdpData); call.addStateChangeListener(this); Interlocutor interlocutor = new Interlocutor(); interlocutor.setCall(call); guiManager.addInterlocutor(interlocutor); } catch (Exception e) { Log.error("handleDialRequest", e); } }
/** Initializes the core phone objects. */ private void initializePhone() { // Load Preferences loadPreferences(); if (preferences == null) { return; } guiManager = new GuiManager(); guiManager.addUserActionListener(this); logManager = new LogManagerImpl(this); this.getLogManager().setRemoteLogging(true); try { EventQueue.invokeAndWait( new Runnable() { @Override public void run() { registerMenu = new JCheckBoxMenuItem(PhoneRes.getIString("phone.enabled")); } }); } catch (Exception e) { Log.error(e); } registerMenu.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { if (getStatus() == SipRegisterStatus.Unregistered || getStatus() == SipRegisterStatus.RegistrationFailed) { register(); } else { handleUnregisterRequest(); } } }); SIPConfig.setPreferredNetworkAddress(preferences.getPreferredAddress()); NetworkAddressManager.start(); try { EventQueue.invokeAndWait( new Runnable() { @Override public void run() { // Initialize Missed calls missedCalls = new MissedCalls(); } }); } catch (Exception e) { Log.error(e); } final JMenu actionsMenu = SparkManager.getMainWindow().getMenuByName(Res.getString("menuitem.actions")); actionsMenu.add(registerMenu); }
/** Handle a hangup request */ public boolean handleHangupRequest(Interlocutor interlocutor) { boolean hangupOk = true; try { sipManager.endCall(interlocutor.getID()); } catch (CommunicationsException exc) { guiManager.remove(interlocutor); hangupOk = false; Log.error("handleHangupRequest", exc); } return hangupOk; }
/** * Fired when a call is received * * @param evt CallEvent */ public void callReceived(CallEvent evt) { try { Call call = evt.getSourceCall(); Interlocutor interlocutor = new Interlocutor(); interlocutor.setCall(call); guiManager.addInterlocutor(interlocutor); call.addStateChangeListener(this); // handleAnswerRequest(interlocutor); } catch (Exception e) { Log.error("callReceived", e); } }
/** * Returns the current interlocutors * * @return List<InterlocutorUI> */ public List<InterlocutorUI> getInterlocutors() { return guiManager.getInterlocutors(); }
/** * Remove InterlocutorListener * * @param interlocutorListener the listener */ public void removeInterlocutorListener(InterlocutorListener interlocutorListener) { guiManager.removeInterlocutorListener(interlocutorListener); }
/** * Add InterlocutorListener * * @param interlocutorListener the listener. */ public void addInterlocutorListener(InterlocutorListener interlocutorListener) { guiManager.addInterlocutorListener(interlocutorListener); }