/** * Creates and sends a SUBSCRIBE request to the subscription <tt>Address</tt>/Request URI of a * specific <tt>Subscription</tt> in order to request receiving event notifications and adds the * specified <tt>Subscription</tt> to the list of subscriptions managed by this instance. The * added <tt>Subscription</tt> may later receive notifications to process the <tt>Request</tt>s * and/or <tt>Response</tt>s which constitute the signaling session associated with it. If the * attempt to create and send the SUBSCRIBE request fails, the specified <tt>Subscription</tt> is * not added to the list of subscriptions managed by this instance. * * @param subscription a <tt>Subscription</tt> which specifies the properties of the SUBSCRIBE * request to be created and sent, to be added to the list of subscriptions managed by this * instance * @throws OperationFailedException if we fail constructing or sending the subscription request. */ public void subscribe(Subscription subscription) throws OperationFailedException { Dialog dialog = subscription.getDialog(); if ((dialog != null) && DialogState.TERMINATED.equals(dialog.getState())) dialog = null; // create the subscription ClientTransaction subscribeTransaction = null; try { subscribeTransaction = (dialog == null) ? createSubscription(subscription, subscriptionDuration) : createSubscription(subscription, dialog, subscriptionDuration); } catch (OperationFailedException ex) { ProtocolProviderServiceSipImpl.throwOperationFailedException( "Failed to create the subscription", OperationFailedException.INTERNAL_ERROR, ex, logger); } // we register the contact to find him when the OK will arrive CallIdHeader callIdHeader = (CallIdHeader) subscribeTransaction.getRequest().getHeader(CallIdHeader.NAME); String callId = callIdHeader.getCallId(); addSubscription(callId, subscription); // send the message try { if (dialog == null) subscribeTransaction.sendRequest(); else dialog.sendRequest(subscribeTransaction); } catch (SipException ex) { // this contact will never been accepted or rejected removeSubscription(callId, subscription); ProtocolProviderServiceSipImpl.throwOperationFailedException( "Failed to send the subscription", OperationFailedException.NETWORK_FAILURE, ex, logger); } }
/** Process the invite request. */ public void processInvite(RequestEvent requestEvent, ServerTransaction serverTransaction) { SipProvider sipProvider = (SipProvider) requestEvent.getSource(); Request request = requestEvent.getRequest(); try { System.out.println("b2bua: got an Invite sending Trying"); ServerTransaction st = requestEvent.getServerTransaction(); if (st == null) { st = sipProvider.getNewServerTransaction(request); } Dialog dialog = st.getDialog(); ToHeader to = (ToHeader) request.getHeader(ToHeader.NAME); SipURI toUri = (SipURI) to.getAddress().getURI(); SipURI target = registrar.get(toUri.getUser()); if (target == null) { System.out.println("User " + toUri + " is not registered."); throw new RuntimeException("User not registered " + toUri); } else { ClientTransaction otherLeg = call(target); otherLeg.setApplicationData(st); st.setApplicationData(otherLeg); dialog.setApplicationData(otherLeg.getDialog()); otherLeg.getDialog().setApplicationData(dialog); } } catch (Exception ex) { ex.printStackTrace(); System.exit(0); } }
/** Process the invite request. */ public void processInvite(RequestEvent requestEvent, ServerTransaction serverTransaction) { SipProvider sipProvider = (SipProvider) requestEvent.getSource(); Request request = requestEvent.getRequest(); try { logger.info("shootme: got an Invite sending Trying"); // logger.info("shootme: " + request); ServerTransaction st = requestEvent.getServerTransaction(); if (st == null) { logger.info("null server tx -- getting a new one"); st = sipProvider.getNewServerTransaction(request); } logger.info("getNewServerTransaction : " + st); String txId = ((ViaHeader) request.getHeader(ViaHeader.NAME)).getBranch(); this.serverTxTable.put(txId, st); // Create the 100 Trying response. Response response = protocolObjects.messageFactory.createResponse(Response.TRYING, request); ListeningPoint lp = sipProvider.getListeningPoint(protocolObjects.transport); int myPort = lp.getPort(); Address address = protocolObjects.addressFactory.createAddress( "Shootme <sip:" + myAddress + ":" + myPort + ">"); // Add a random sleep to stagger the two OK's for the benifit of implementations // that may not be too good about handling re-entrancy. int timeToSleep = (int) (Math.random() * 1000); Thread.sleep(timeToSleep); st.sendResponse(response); Response ringingResponse = protocolObjects.messageFactory.createResponse(Response.RINGING, request); ContactHeader contactHeader = protocolObjects.headerFactory.createContactHeader(address); response.addHeader(contactHeader); ToHeader toHeader = (ToHeader) ringingResponse.getHeader(ToHeader.NAME); String toTag = actAsNonRFC3261UAS ? null : new Integer((int) (Math.random() * 10000)).toString(); if (!actAsNonRFC3261UAS) toHeader.setTag(toTag); // Application is supposed to set. ringingResponse.addHeader(contactHeader); st.sendResponse(ringingResponse); Dialog dialog = st.getDialog(); dialog.setApplicationData(st); this.inviteSeen = true; new Timer().schedule(new MyTimerTask(requestEvent, st /*,toTag*/), 1000); } catch (Exception ex) { ex.printStackTrace(); System.exit(0); } }
public void processResponse(ResponseEvent responseReceivedEvent) { System.out.println("Got a response"); Response response = (Response) responseReceivedEvent.getResponse(); Transaction tid = responseReceivedEvent.getClientTransaction(); System.out.println( "Response received with client transaction id " + tid + ":\n" + response.getStatusCode()); if (tid == null) { System.out.println("Stray response -- dropping "); return; } System.out.println("transaction state is " + tid.getState()); System.out.println("Dialog = " + tid.getDialog()); System.out.println("Dialog State is " + tid.getDialog().getState()); try { if (response.getStatusCode() == Response.OK && ((CSeqHeader) response.getHeader(CSeqHeader.NAME)) .getMethod() .equals(Request.INVITE)) { // Request cancel = inviteTid.createCancel(); // ClientTransaction ct = // sipProvider.getNewClientTransaction(cancel); // ct.sendRequest(); Dialog dialog = tid.getDialog(); CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME); Request ackRequest = dialog.createAck(cseq.getSeqNumber()); System.out.println("Sending ACK"); dialog.sendAck(ackRequest); // Send a Re INVITE but this time force it // to use UDP as the transport. Else, it will // Use whatever transport was used to create // the dialog. if (reInviteCount == 0) { Request inviteRequest = dialog.createRequest(Request.INVITE); ((SipURI) inviteRequest.getRequestURI()).removeParameter("transport"); ((ViaHeader) inviteRequest.getHeader(ViaHeader.NAME)).setTransport("udp"); inviteRequest.addHeader(contactHeader); try { Thread.sleep(100); } catch (Exception ex) { } ClientTransaction ct = udpProvider.getNewClientTransaction(inviteRequest); dialog.sendRequest(ct); reInviteCount++; } } } catch (Exception ex) { ex.printStackTrace(); System.exit(0); } }
/** Process the ACK request. Send the bye and complete the call flow. */ public void processAck(RequestEvent requestEvent, ServerTransaction serverTransaction) { SipProvider sipProvider = (SipProvider) requestEvent.getSource(); try { // System.out.println("*** shootme: got an ACK " // + requestEvent.getRequest()); if (serverTransaction == null) { System.out.println("null server transaction -- ignoring the ACK!"); return; } Dialog dialog = serverTransaction.getDialog(); this.createdCount++; System.out.println( "Dialog Created = " + dialog.getDialogId() + " createdCount " + this.createdCount + " Dialog State = " + dialog.getState()); if (this.dialogIds.contains(dialog.getDialogId())) { System.out.println("OOPS ! I already saw " + dialog.getDialogId()); } else { this.dialogIds.add(dialog.getDialogId()); } Request byeRequest = dialog.createRequest(Request.BYE); ClientTransaction tr = sipProvider.getNewClientTransaction(byeRequest); // System.out.println("shootme: got an ACK -- sending bye! "); dialog.sendRequest(tr); } catch (Exception ex) { ex.printStackTrace(); System.exit(0); } }
public void processDialogTerminated(DialogTerminatedEvent dialogTerminatedEvent) { Dialog dialog = dialogTerminatedEvent.getDialog(); this.terminatedCount++; System.out.println( "Dialog Terminated Event " + dialog.getDialogId() + " terminatedCount = " + terminatedCount); if (!this.dialogIds.contains(dialog.getDialogId())) { System.out.println("Saw a terminated event for an unknown dialog id"); } else { this.dialogIds.remove(dialog.getDialogId()); } }
@SuppressWarnings("deprecation") public void setModalBlocked(Dialog dialog, boolean blocked) { synchronized ( ((Component) getTarget()).getTreeLock()) // State lock should always be after awtLock { // use WWindowPeer instead of WDialogPeer because of FileDialogs and PrintDialogs WWindowPeer blockerPeer = (WWindowPeer) dialog.getPeer(); if (blocked) { modalBlocker = blockerPeer; // handle native dialogs separately, as they may have not // got HWND yet; modalEnable/modalDisable is called from // their setHWnd() methods if (blockerPeer instanceof WFileDialogPeer) { ((WFileDialogPeer) blockerPeer).blockWindow(this); } else if (blockerPeer instanceof WPrintDialogPeer) { ((WPrintDialogPeer) blockerPeer).blockWindow(this); } else { modalDisable(dialog, blockerPeer.getHWnd()); } } else { modalBlocker = null; if (blockerPeer instanceof WFileDialogPeer) { ((WFileDialogPeer) blockerPeer).unblockWindow(this); } else if (blockerPeer instanceof WPrintDialogPeer) { ((WPrintDialogPeer) blockerPeer).unblockWindow(this); } else { modalEnable(dialog); } } } }
public void dispose(boolean toDispose) { if (toDispose) { super.dispose(); frame.toFront(); } if (client != null) client.dialogDismissed(this); }
public void processBye(Request request, ServerTransaction serverTransactionId) { try { System.out.println("shootist: got a bye ."); if (serverTransactionId == null) { System.out.println("shootist: null TID."); return; } Dialog dialog = serverTransactionId.getDialog(); System.out.println("Dialog State = " + dialog.getState()); Response response = messageFactory.createResponse(200, request); serverTransactionId.sendResponse(response); System.out.println("shootist: Sending OK."); System.out.println("Dialog State = " + dialog.getState()); this.shutDown(); } catch (Exception ex) { ex.printStackTrace(); System.exit(0); } }
public void paint(Graphics g) { super.paint(g); if (firstPaint) { if (numberField != null && IJ.isMacOSX()) { // work around for bug on Intel Macs that caused 1st field to be un-editable TextField tf = (TextField) (numberField.elementAt(0)); tf.setEditable(false); tf.setEditable(true); } if (numberField == null && stringField == null) okay.requestFocus(); firstPaint = false; } }
public void setVisible(boolean visible) { pack(); if (centered) { Dimension frameSize = getParent().getSize(); Point frameLoc = getParent().getLocation(); Dimension mySize = getSize(); int x, y; x = frameLoc.x + (frameSize.width / 2) - (mySize.width / 2); y = frameLoc.y + (frameSize.height / 2) - (mySize.height / 2); setBounds(x, y, getSize().width, getSize().height); } super.setVisible(visible); }
/** Process the ACK request, forward it to the other leg. */ public void processAck(RequestEvent requestEvent, ServerTransaction serverTransaction) { try { Dialog dialog = serverTransaction.getDialog(); System.out.println("b2bua: got an ACK! "); System.out.println("Dialog State = " + dialog.getState()); Dialog otherDialog = (Dialog) dialog.getApplicationData(); Request request = otherDialog.createAck(otherDialog.getLocalSeqNumber()); otherDialog.sendAck(request); } catch (Exception ex) { ex.printStackTrace(); } }
/** Handles button events */ public void actionPerformed(ActionEvent e) { // only chooseMainClassButton can be performed final MainClassChooser panel = new MainClassChooser(sourceRoots.getRoots(), null, mainClassTextField.getText()); Object[] options = new Object[] {okButton, DialogDescriptor.CANCEL_OPTION}; panel.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { if (e.getSource() instanceof MouseEvent && MouseUtils.isDoubleClick(((MouseEvent) e.getSource()))) { // click button and finish the dialog with selected class okButton.doClick(); } else { okButton.setEnabled(panel.getSelectedMainClass() != null); } } }); okButton.setEnabled(false); DialogDescriptor desc = new DialogDescriptor( panel, NbBundle.getMessage(CustomizerRun.class, "LBL_ChooseMainClass_Title"), // NOI18N true, options, options[0], DialogDescriptor.BOTTOM_ALIGN, null, null); // desc.setMessageType (DialogDescriptor.INFORMATION_MESSAGE); Dialog dlg = DialogDisplayer.getDefault().createDialog(desc); dlg.setVisible(true); if (desc.getValue() == options[0]) { mainClassTextField.setText(panel.getSelectedMainClass()); } dlg.dispose(); }
/** * Creates a new SUBSCRIBE request in the form of a <tt>ClientTransaction</tt> with the parameters * of a specific <tt>Subscription</tt>. * * @param subscription the <tt>Subscription</tt> to be described in a SUBSCRIBE request * @param dialog the <tt>Dialog</tt> with which this request should be associated * @param expires the subscription duration of the SUBSCRIBE request to be created * @return a new <tt>ClientTransaction</tt> initialized with a new SUBSCRIBE request which matches * the parameters of the specified <tt>Subscription</tt> and is associated with the specified * <tt>Dialog</tt> * @throws OperationFailedException if the message could not be generated */ private ClientTransaction createSubscription( Subscription subscription, Dialog dialog, int expires) throws OperationFailedException { Request req = messageFactory.createRequest(dialog, Request.SUBSCRIBE); // Address Address toAddress = dialog.getRemoteTarget(); // no Contact field if (toAddress == null) toAddress = dialog.getRemoteParty(); // MaxForwards MaxForwardsHeader maxForwards = protocolProvider.getMaxForwardsHeader(); req.setHeader(maxForwards); /* * Create the transaction and then add the via header as recommended by * the jain-sip documentation at * http://snad.ncsl.nist.gov/proj/iptel/jain-sip-1.2/javadoc * /javax/sip/Dialog.html#createRequest(String). */ ClientTransaction transac = null; try { transac = protocolProvider.getDefaultJainSipProvider().getNewClientTransaction(req); } catch (TransactionUnavailableException ex) { logger.error( "Failed to create subscriptionTransaction.\n" + "This is most probably a network connection error.", ex); throw new OperationFailedException( "Failed to create the subscription transaction", OperationFailedException.NETWORK_FAILURE); } populateSubscribeRequest(req, subscription, expires); return transac; }
/** Refreshes the <tt>Subscription</tt> associated with this <tt>TimerTask</tt>. */ @Override public void run() { Dialog dialog = subscription.getDialog(); if (dialog == null) { logger.warn( "null dialog associated with " + subscription + ", can't refresh the subscription"); return; } ClientTransaction transac = null; try { transac = createSubscription(subscription, dialog, subscriptionDuration); } catch (OperationFailedException e) { logger.error("Failed to create subscriptionTransaction.", e); return; } try { dialog.sendRequest(transac); } catch (SipException e) { logger.error("Can't send the request", e); } }
/** * Creates and sends a SUBSCRIBE request to a specific subscription <tt>Address</tt>/Request URI * if it matches a <tt>Subscription</tt> with an id tag of its Event header of a specific value in * the list of subscriptions managed by this instance with an Expires header value of zero in * order to terminate receiving event notifications and removes the specified * <tt>Subscription</tt> from the list of subscriptions managed by this instance. The removed * <tt>Subscription</tt> may receive notifications to process the <tt>Request</tt>s and/or * <tt>Response</tt>s which constitute the signaling session associated with it. If the attempt to * create the SUBSCRIBE request fails, the associated <tt>Subscription</tt> is not removed from * the list of subscriptions managed by this instance. If the specified <tt>Address</tt> does not * identify an existing <tt>Subscription</tt> in the list of subscriptions managed by this * instance, an assertion may optionally be performed or no reaction can be taken. * * @param toAddress a subscription <tt>Address</tt>/Request URI which identifies a * <tt>Subscription</tt> to be removed from the list of subscriptions managed by this instance * @param eventId the id tag placed in the Event header of the <tt>Subscription</tt> to be matched * if there is one or <tt>null</tt> if the <tt>Subscription</tt> should have no id tag in its * Event header * @param assertSubscribed <tt>true</tt> to assert if the specified subscription * <tt>Address</tt>/Request URI does not identify an existing <tt>Subscription</tt> in the * list of subscriptions managed by this instance; <tt>false</tt> to not assert if the * mentioned condition is met * @throws IllegalArgumentException if <tt>assertSubscribed</tt> is <tt>true</tt> and * <tt>toAddress</tt> and <tt>eventId</tt> do not identify an existing <tt>Subscription</tt> * in the list of subscriptions managed by this instance * @throws OperationFailedException if we fail constructing or sending the unSUBSCRIBE request. */ public void unsubscribe(Address toAddress, String eventId, boolean assertSubscribed) throws IllegalArgumentException, OperationFailedException { Subscription subscription = getSubscription(toAddress, eventId); if (subscription == null) if (assertSubscribed) throw new IllegalArgumentException("trying to unregister a not registered contact"); else return; Dialog dialog = subscription.getDialog(); // we stop the subscription if we're subscribed to this contact if (dialog != null) { String callId = dialog.getCallId().getCallId(); ClientTransaction subscribeTransaction; try { subscribeTransaction = createSubscription(subscription, dialog, 0); } catch (OperationFailedException e) { if (logger.isDebugEnabled()) logger.debug("failed to create the unsubscription", e); throw e; } // we are not anymore subscribed to this contact // this ensure that the response of this request will be // handled as an unsubscription response removeSubscription(callId, subscription); try { dialog.sendRequest(subscribeTransaction); } catch (SipException e) { if (logger.isDebugEnabled()) logger.debug("Can't send the request", e); throw new OperationFailedException( "Failed to send the subscription message", OperationFailedException.NETWORK_FAILURE, e); } } }
public void processResponse(ResponseEvent responseReceivedEvent) { // System.out.println("Got a response"); Response response = (Response) responseReceivedEvent.getResponse(); Transaction tid = responseReceivedEvent.getClientTransaction(); // System.out.println("Response received with client transaction id " // + tid + ":\n" + response); try { if (response.getStatusCode() == Response.OK && ((CSeqHeader) response.getHeader(CSeqHeader.NAME)) .getMethod() .equals(Request.INVITE)) { Dialog dialog = tid.getDialog(); Request request = tid.getRequest(); dialog.sendAck(request); } } catch (Exception ex) { ex.printStackTrace(); System.exit(0); } }
public int runXmlImport() { DataImportXmlParser responseHandler = null; try { XMLReader parser = EfaUtil.getXMLReader(); responseHandler = new DataImportXmlParser(this, dataAccess); parser.setContentHandler(responseHandler); parser.parse(new InputSource(new FileInputStream(filename))); } catch (Exception e) { logInfo(e.toString()); errorCount++; Logger.log(e); if (Daten.isGuiAppl()) { Dialog.error(e.toString()); } } return (responseHandler != null ? responseHandler.getImportedRecordsCount() : 0); }
protected void onPrepareDialog(int id, Dialog dialog) { super.onPrepareDialog(id, dialog); switch (id) { case SampleDialog: break; case QuestionDialog: Calendar calendar = Calendar.getInstance(); String stime = String.format( "%d시 %d분 %d초", calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND)); dialog.setTitle(stime); break; } }
public void processCancel(RequestEvent requestEvent, ServerTransaction serverTransactionId) { SipProvider sipProvider = (SipProvider) requestEvent.getSource(); Request request = requestEvent.getRequest(); try { System.out.println("shootme: got a cancel."); if (serverTransactionId == null) { System.out.println("shootme: null tid."); return; } Response response = messageFactory.createResponse(200, request); serverTransactionId.sendResponse(response); if (dialog.getState() != DialogState.CONFIRMED) { response = messageFactory.createResponse(Response.REQUEST_TERMINATED, inviteRequest); inviteTid.sendResponse(response); } } catch (Exception ex) { ex.printStackTrace(); System.exit(0); } }
/** Process the any in dialog request - MESSAGE, BYE, INFO, UPDATE. */ public void processInDialogRequest( RequestEvent requestEvent, ServerTransaction serverTransactionId) { SipProvider sipProvider = (SipProvider) requestEvent.getSource(); Request request = requestEvent.getRequest(); Dialog dialog = requestEvent.getDialog(); System.out.println("local party = " + dialog.getLocalParty()); try { System.out.println("b2bua: got a bye sending OK."); Response response = messageFactory.createResponse(200, request); serverTransactionId.sendResponse(response); System.out.println("Dialog State is " + serverTransactionId.getDialog().getState()); Dialog otherLeg = (Dialog) dialog.getApplicationData(); Request otherBye = otherLeg.createRequest(request.getMethod()); ClientTransaction clientTransaction = sipProvider.getNewClientTransaction(otherBye); clientTransaction.setApplicationData(serverTransactionId); serverTransactionId.setApplicationData(clientTransaction); otherLeg.sendRequest(clientTransaction); } catch (Exception ex) { ex.printStackTrace(); System.exit(0); } }
public int runCsvImport() { int count = 0; try { int linecnt = 0; String[] header = null; ArrayList<String> fieldsInImport = new ArrayList<String>(); BufferedReader f = new BufferedReader(new InputStreamReader(new FileInputStream(filename), encoding)); String s; DataRecord dummyRecord = storageObject.createNewRecord(); while ((s = f.readLine()) != null) { s = s.trim(); if (s.length() == 0) { continue; } Vector<String> fields = splitFields(s); if (fields.size() > 0) { if (linecnt == 0) { // header header = new String[fields.size()]; for (int i = 0; i < fields.size(); i++) { header[i] = fields.get(i); if (header[i].startsWith("#") && header[i].endsWith("#") && header.length > 2) { header[i] = header[i].substring(1, header[i].length() - 1).trim(); overrideKeyField = header[i]; } String[] equivFields = dummyRecord.getEquivalentFields(header[i]); for (String ef : equivFields) { fieldsInImport.add(ef); } } } else { // fields DataRecord r = storageObject.createNewRecord(); for (int i = 0; i < header.length; i++) { String value = (fields.size() > i ? fields.get(i) : null); if (value != null && value.length() > 0) { try { if (!r.setFromText(header[i], value.trim())) { logImportWarning( r, "Value '" + value + "' for Field '" + header[i] + "' corrected to '" + r.getAsText(header[i]) + "'"); } } catch (Exception esetvalue) { logImportWarning( r, "Cannot set value '" + value + "' for Field '" + header[i] + "': " + esetvalue.toString()); } } } if (importRecord(r, fieldsInImport)) { count++; } } } linecnt++; } f.close(); } catch (Exception e) { logInfo(e.toString()); errorCount++; Logger.log(e); if (Daten.isGuiAppl()) { Dialog.error(e.toString()); } } return count; }
/** Process the ACK request. Send the bye and complete the call flow. */ public void processAck(RequestEvent requestEvent, ServerTransaction serverTransaction) { System.out.println("shootme: got an ACK! "); System.out.println("Dialog State = " + dialog.getState()); }
public void processDialogTerminated(DialogTerminatedEvent dialogTerminatedEvent) { System.out.println("Dialog terminated event recieved"); Dialog d = dialogTerminatedEvent.getDialog(); System.out.println("Local Party = " + d.getLocalParty()); }
public void sendSubscribe(String localURL, String buddyURI, boolean EXPIRED) { try { logger.debug("Sending SUBSCRIBE in progress to the buddy: " + buddyURI); int proxyPort = imUA.getProxyPort(); String proxyAddress = imUA.getProxyAddress(); String imProtocol = imUA.getIMProtocol(); SipStack sipStack = imUA.getSipStack(); SipProvider sipProvider = imUA.getSipProvider(); MessageFactory messageFactory = imUA.getMessageFactory(); HeaderFactory headerFactory = imUA.getHeaderFactory(); AddressFactory addressFactory = imUA.getAddressFactory(); // Request-URI: // URI requestURI=addressFactory.createURI(buddyURI); SipURI requestURI = addressFactory.createSipURI(null, proxyAddress); requestURI.setPort(proxyPort); requestURI.setTransportParam(imProtocol); // Call-Id: CallIdHeader callIdHeader = null; // CSeq: CSeqHeader cseqHeader = null; // To header: ToHeader toHeader = null; // From Header: FromHeader fromHeader = null; // Via header String branchId = Utils.generateBranchId(); ViaHeader viaHeader = headerFactory.createViaHeader( imUA.getIMAddress(), imUA.getIMPort(), imProtocol, branchId); Vector viaList = new Vector(); viaList.addElement(viaHeader); PresenceManager presenceManager = imUA.getPresenceManager(); Presentity presentity = presenceManager.getPresentity(buddyURI); Dialog dialog = null; if (presentity != null) dialog = presentity.getDialog(); if (dialog != null) { // We have to remove the subscriber and the Presentity related // with this Buddy... presenceManager.removePresentity(buddyURI); Subscriber subscriber = presenceManager.getSubscriber(buddyURI); if (subscriber == null) { // It means that the guy does not have us in his buddy list // nothing to do!!! } else { presenceManager.removeSubscriber(buddyURI); } Address localAddress = dialog.getLocalParty(); Address remoteAddress = dialog.getRemoteParty(); fromHeader = headerFactory.createFromHeader(localAddress, dialog.getLocalTag()); toHeader = headerFactory.createToHeader(remoteAddress, dialog.getRemoteTag()); long cseq = dialog.getLocalSeqNumber(); cseqHeader = headerFactory.createCSeqHeader(cseq, "MESSAGE"); callIdHeader = dialog.getCallId(); } else { String localTag = Utils.generateTag(); Address toAddress = addressFactory.createAddress(buddyURI); Address fromAddress = addressFactory.createAddress(localURL); fromHeader = headerFactory.createFromHeader(fromAddress, localTag); toHeader = headerFactory.createToHeader(toAddress, null); // CSeq: cseqHeader = headerFactory.createCSeqHeader(1L, "SUBSCRIBE"); callIdCounter++; // Call-ID: callIdHeader = (CallIdHeader) headerFactory.createCallIdHeader("nist-sip-im-subscribe-callId" + callIdCounter); } // MaxForwards header: MaxForwardsHeader maxForwardsHeader = headerFactory.createMaxForwardsHeader(70); Request request = messageFactory.createRequest( requestURI, "SUBSCRIBE", callIdHeader, cseqHeader, fromHeader, toHeader, viaList, maxForwardsHeader); RouteHeader rh = this.imUA.getRouteToProxy(); request.setHeader(rh); // Contact header: SipURI sipURI = addressFactory.createSipURI(null, imUA.getIMAddress()); sipURI.setPort(imUA.getIMPort()); sipURI.setTransportParam(imUA.getIMProtocol()); Address contactAddress = addressFactory.createAddress(sipURI); ContactHeader contactHeader = headerFactory.createContactHeader(contactAddress); request.setHeader(contactHeader); ExpiresHeader expiresHeader = null; if (EXPIRED) { expiresHeader = headerFactory.createExpiresHeader(0); } else { expiresHeader = headerFactory.createExpiresHeader(presenceManager.getExpiresTime()); } request.setHeader(expiresHeader); // WE have to add a new Header: "Event" Header eventHeader = headerFactory.createHeader("Event", "presence"); request.setHeader(eventHeader); // Add Acceptw Header Header acceptHeader = headerFactory.createHeader("Accept", "application/pidf+xml"); request.setHeader(acceptHeader); // ProxyAuthorization header if not null: ProxyAuthorizationHeader proxyAuthHeader = imUA.getProxyAuthorizationHeader(); if (proxyAuthHeader != null) request.setHeader(proxyAuthHeader); ClientTransaction clientTransaction = sipProvider.getNewClientTransaction(request); if (dialog != null) { dialog.sendRequest(clientTransaction); } else { clientTransaction.sendRequest(); } logger.debug("IMSubscribeProcessing, sendSubscribe(), SUBSCRIBE sent:\n" + request); } catch (Exception ex) { ex.printStackTrace(); } }
public ServerDialog(OptionsDialog options_, Options opts_, CConn cc_) { super(true); cc = cc_; opts = opts_; options = options_; JLabel serverLabel = new JLabel("VNC server:", JLabel.RIGHT); String valueStr = null; if (opts.serverName != null) { String[] s = new String[1]; s[0] = opts.serverName; server = new JComboBox(s); } else if ((valueStr = UserPreferences.get("ServerDialog", "history")) != null) { server = new JComboBox(valueStr.split(",")); } else { server = new JComboBox(); } // Hack to set the left inset on editable JComboBox if (UIManager.getLookAndFeel().getID() == "Windows") { server.setBorder( BorderFactory.createCompoundBorder( server.getBorder(), BorderFactory.createEmptyBorder(0, 2, 0, 0))); } else if (UIManager.getLookAndFeel().getID() == "Metal") { ComboBoxEditor editor = server.getEditor(); JTextField jtf = (JTextField) editor.getEditorComponent(); jtf.setBorder(new CompoundBorder(jtf.getBorder(), new EmptyBorder(0, 2, 0, 0))); } server.setEditable(true); editor = server.getEditor(); editor .getEditorComponent() .addKeyListener( new KeyListener() { public void keyTyped(KeyEvent e) {} public void keyReleased(KeyEvent e) {} public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { server.insertItemAt(editor.getItem(), 0); server.setSelectedIndex(0); commit(); endDialog(); } } }); topPanel = new JPanel(new GridBagLayout()); Dialog.addGBComponent( new JLabel(VncViewer.logoIcon), topPanel, 0, 0, 1, 1, 0, 0, 0, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(5, 5, 5, 15)); Dialog.addGBComponent( serverLabel, topPanel, 1, 0, 1, 1, 0, 0, 0, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_END, new Insets(10, 0, 5, 5)); Dialog.addGBComponent( server, topPanel, 2, 0, 1, 1, 0, 0, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(10, 0, 5, 20)); optionsButton = new JButton("Options..."); aboutButton = new JButton("About..."); okButton = new JButton("Connect"); cancelButton = new JButton("Cancel"); buttonPanel = new JPanel(new GridBagLayout()); buttonPanel.setPreferredSize(new Dimension(350, 40)); Dialog.addGBComponent( aboutButton, buttonPanel, 0, 3, 1, 1, 0, 0, 0.8, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(0, 2, 0, 5)); Dialog.addGBComponent( optionsButton, buttonPanel, 1, 3, 1, 1, 0, 0, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(0, 2, 0, 5)); Dialog.addGBComponent( okButton, buttonPanel, 2, 3, 1, 1, 0, 0, 0.7, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(0, 2, 0, 5)); Dialog.addGBComponent( cancelButton, buttonPanel, 3, 3, 1, 1, 0, 0, 0.6, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(0, 2, 0, 5)); server.addActionListener(this); optionsButton.addActionListener(this); aboutButton.addActionListener(this); okButton.addActionListener(this); cancelButton.addActionListener(this); }
public void repaint() { super.repaint(); if (imagePanels != null) { for (int i = 0; i < imagePanels.size(); i++) ((ImagePanel) imagePanels.get(i)).repaint(); } }
/* Display the dialog at the specified location. */ public void setLocation(int x, int y) { super.setLocation(x, y); centerDialog = false; }