/*
(non-Javadoc)

@see
net.java.slee.resource.sip.SleeSipProvider#getNewDialog(net.java.slee
.resource.sip.DialogActivity, boolean)
497608
public DialogActivity getNewDialog(DialogActivity incomingDialog,
			boolean useSameCallId) throws SipException {
		checkState();
		if (incomingDialog == null || !incomingDialog.isServer()) {
			throw new IllegalArgumentException(
					"Incoming dialog is either null or is UAC dialog!!");
		}
		CallIdHeader callIdHeader = null;
		if (useSameCallId) {
			callIdHeader = incomingDialog.getCallId();
		}

		return _getNewDialog(incomingDialog.getRemoteParty(), Utils.getInstance().generateTag(), incomingDialog.getLocalParty(), callIdHeader);
	}
898819
@UiHandler("m_newButton")
    void onClickNew(ClickEvent e) {

        String aliasPath = m_newAliasPath.getText();
        String resourcePath = m_newResourcePath.getText();
        m_controller.editNewAlias(aliasPath, resourcePath, CmsAliasMode.valueOf(m_newMode.getFormValueAsString()));
    }
276141
public Dialog getNewUnstructuredDialog(SccpAddress localAddress, SccpAddress remoteAddress) throws TCAPException {
        DialogImpl res = _getDialog(localAddress, remoteAddress, false, getNextSeqControl(), null);
        this.setSsnToDialog(res, localAddress.getSubsystemNumber());
        return res;
    }
127302
private MobicentsSipSession retrieveSipSession(Dialog dialog) {
		
		if(dialog != null) {
			Iterator<SipContext> iterator = sipApplicationDispatcher.findSipApplications();
			while(iterator.hasNext()) {
				SipContext sipContext = iterator.next();
				SipManager sipManager = sipContext.getSipManager();
				
				Iterator<MobicentsSipSession> sipSessionsIt= sipManager.getAllSipSessions();
				while (sipSessionsIt.hasNext()) {
					MobicentsSipSession mobicentsSipSession = (MobicentsSipSession) sipSessionsIt
							.next();
					MobicentsSipSessionKey sessionKey = mobicentsSipSession.getKey();				
					if(sessionKey.getCallId().trim().equals(dialog.getCallId().getCallId())) {
						if(logger.isDebugEnabled()) {
							logger.debug("found session with the same Call Id " + sessionKey + ", to Tag " + sessionKey.getToTag());
							logger.debug("dialog localParty = " + dialog.getLocalParty().getURI() + ", localTag " + dialog.getLocalTag());
							logger.debug("dialog remoteParty = " + dialog.getRemoteParty().getURI() + ", remoteTag " + dialog.getRemoteTag());
						}
						if(sessionKey.getFromTag().equals(dialog.getLocalTag()) && sessionKey.getToTag().equals(dialog.getRemoteTag())) {
							if(mobicentsSipSession.getProxy() == null) {
								return mobicentsSipSession;	
							}
						} else if (sessionKey.getFromTag().equals(dialog.getRemoteTag()) && sessionKey.getToTag().equals(dialog.getLocalTag())){
							if(mobicentsSipSession.getProxy() == null) {
								return mobicentsSipSession;	
							}
						}
					}
				}
			}
		}
		
		return null;
	}
95219
public static SupportSimpleAlertDialogFragment newInstance(int titleResId, int messageResId) {
        SupportSimpleAlertDialogFragment fragment = new SupportSimpleAlertDialogFragment();
        Bundle args = new Bundle();
        args.putInt(ARGS_MESSAGE_RES, messageResId);
        args.putInt(ARGS_TITLE_RES, titleResId);
        fragment.setArguments(args);
        return fragment;
    }
572853
void launchAddFederationDialog() {
        ResourceDescription resourceDescription = StaticResourceDescription
                .from(PICKET_LINK_RESOURCES.newFederationDescription());
        ComboBoxItem securityDomains = new ComboBoxItem("security-domain", "Security Domain");
        securityDomains.setRequired(false);
        securityDomains.setValueMap(this.securityDomains);

        DefaultWindow dialog = new DefaultWindow(Console.MESSAGES.newTitle("Federation"));
        ModelNodeFormBuilder.FormAssets assets = new ModelNodeFormBuilder()
                .setResourceDescription(resourceDescription)
                .addFactory("security-domain", attributeDescription -> securityDomains)
                .setSecurityContext(securityContext)
                .unsorted()
                .build();
        assets.getForm().setEnabled(true);
        assets.getForm().addFormValidator(new IdentityProviderEditor.IdentityProviderFormValidator());

        DialogueOptions options = new DialogueOptions(
                event -> {
                    FormValidation validation = assets.getForm().validate();
                    if (!validation.hasErrors()) {
                        dialog.hide();

                        ModelNode payload = assets.getForm().getUpdatedEntity();
                        String name = payload.get(NAME).asString();
                        String ip = payload.get("identity-provider").asString();

                        Operation addFederation = new Operation.Builder(ADD,
                                FEDERATION_TEMPLATE.resolve(statementContext, name)).build();
                        Operation addIdentityProvider = new Operation.Builder(ADD,
                                IDENTITY_PROVIDER_TEMPLATE.resolve(statementContext, name, ip))
                                .param("security-domain", payload.get("security-domain").asString())
                                .param("external", payload.get("external").asBoolean())
                                .param("url", payload.get("url").asString())
                                .build();
                        dispatcher.execute(new DMRAction(new Composite(addFederation, addIdentityProvider)),
                                new SimpleCallback<DMRResponse>() {
                                    @Override
                                    public void onFailure(final Throwable caught) {
                                        super.onFailure(caught);
                                        readFederations();
                                    }

                                    @Override
                                    public void onSuccess(final DMRResponse dmrResponse) {
                                        Console.info(Console.MESSAGES.successfullyAdded((name)));
                                        readFederations();
                                    }
                                });
                    }
                },
                event -> dialog.hide()
        );

        VerticalPanel layout = new VerticalPanel();
        layout.setStyleName("fill-layout-width window-content");
        ContentDescription text = new ContentDescription(resourceDescription.get(DESCRIPTION).asString());
        layout.add(text);
        layout.add(assets.getHelp().asWidget());
        layout.add(assets.getForm().asWidget());

        ScrollPanel scroll = new ScrollPanel(layout);
        LayoutPanel content = new LayoutPanel();
        content.addStyleName("fill-layout");
        content.add(scroll);
        content.add(options);
        content.getElement().setAttribute("style", "margin-bottom:10px");
        content.setWidgetTopHeight(scroll, 0, Style.Unit.PX, 92, Style.Unit.PCT);
        content.setWidgetBottomHeight(options, 0, Style.Unit.PX, 35, Style.Unit.PX);

        dialog.setWidth(640);
        dialog.setHeight(480);
        dialog.setWidget(new TrappedFocusPanel(content));
        dialog.setGlassEnabled(true);
        dialog.center();
    }
1311452
public Dialog getNewDialog(Transaction transaction) throws SipException {
		checkState();
		if (transaction.getClass() == ServerTransactionWrapper.class) {
			return getNewDialog((ServerTransactionWrapper) transaction);
			
		} else if (transaction.getClass() == ClientTransactionWrapper.class) {
			return getNewDialog((ClientTransactionWrapper) transaction);
			
		} else {
			throw new IllegalArgumentException("unknown transaction class");
		}
	}
290559
public int onLogonDialog()
    {
        String strDisplay = "Login required";
        strDisplay = this.getTask().getString(strDisplay);
        for (int i = 1; i < 3; i++)
        {
            String strUserName = this.getProperty(Params.USER_NAME);
            Frame frame = ScreenUtil.getFrame(this);
            LoginDialog dialog = new LoginDialog(frame, true, strDisplay, strUserName);
            if (frame != null)
                ScreenUtil.centerDialogInFrame(dialog, frame);
            
            dialog.setVisible(true);
            int iOption = dialog.getReturnStatus();
            if (iOption == LoginDialog.NEW_USER_OPTION)
            	iOption = this.createNewUser(dialog);
            if (iOption != JOptionPane.OK_OPTION)
                return iOption;   // Canceled dialog = You don't get in.
            strUserName = dialog.getUserName();
            String strPassword = dialog.getPassword();
            try {
                byte[] bytes = strPassword.getBytes(Base64.DEFAULT_ENCODING);
                bytes = Base64.encodeSHA(bytes);
                char[] chars = Base64.encode(bytes);
                strPassword = new String(chars);
            } catch (NoSuchAlgorithmException ex) {
                ex.printStackTrace();
            } catch (UnsupportedEncodingException ex) {
                ex.printStackTrace();
            }
            String strDomain = this.getProperty(Params.DOMAIN);
            int iSuccess = this.getApplication().login(this, strUserName, strPassword, strDomain);
            if (iSuccess == Constants.NORMAL_RETURN)
            {   // If they want to save the user... save it in a muffin.
                if (this.getApplication().getMuffinManager() != null)
                    if (this.getApplication().getMuffinManager().isServiceAvailable())
                {
                    if (dialog.getSaveState() == true)
                        this.getApplication().getMuffinManager().setMuffin(Params.USER_ID, this.getApplication().getProperty(Params.USER_ID));    // Set muffin to current user.
                    else
                        this.getApplication().getMuffinManager().setMuffin(Params.USER_ID, null);    // Set muffin to current user.
                }
                return iSuccess;
            }
            // Otherwise, continue looping (3 times)
        }
        return this.setLastError(strDisplay);
    }
793922
public ClientTransactionWrapper getNewDialogActivityClientTransaction(
			DialogWrapper dialogWrapper, Request request)
			throws TransactionUnavailableException {
		final SIPClientTransaction ct = (SIPClientTransaction) provider.getNewClientTransaction(request);
		final ClientTransactionWrapper ctw = new ClientTransactionWrapper(ct,
				ra);
		dialogWrapper.addOngoingTransaction(ctw);
		return ctw;
	}
1256614
private void dialogChanged() {

		// Validate MEP
		int mepIdx = mepCombo.getSelectionIndex();
		if (mepIdx == -1) {
			updateStatus("Select a message exchange pattern");
			return;
		}
		
		if (mepIdx == 2) {
			updateStatus("Message exchange pattern One-Way-Robust is deprecated.");
			return;
		}
		
		// Do not allow pub/sub mep right now...
		if (mepIdx == 3) {
			updateStatus("Message exchange pattern Publish/Subscribe not yet supported");
			return;
		}
		
		// Validate Inbound Transport
		int ibtIdx = inboundTransportCombo.getSelectionIndex();
		if (ibtIdx == -1) {
			updateStatus("Select an inbound transport");
			return;
		}
		
		// Validate Outbound Transport
		int obtIdx = outboundTransportCombo.getSelectionIndex();
		if (obtIdx == -1) {
			updateStatus("Select an outbound transport");
			return;
		}
		
		// Validate Transformer-type, do no allow smooks for oneway's right now.
		int ttIdx = transformerType.value;
		if (mepIdx == 1 && ttIdx == 1) {
			updateStatus("Smooks based transformers are currently not supported for oneway message exchange patterns");
			return;
		}
		

		String containerName = getContainerName().trim();
		IResource container = ResourcesPlugin.getWorkspace().getRoot()
				.findMember(new Path(containerName));
		String serviceName = getServiceName();

		if (containerName.length() == 0) {
			updateStatus("Select a project");
			return;
		}
		if (container == null || (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) {
			updateStatus("Selected project must exist");
			return;
		}
		if (!container.isAccessible()) {
			updateStatus("Selected project must be writable");
			return;
		}
		if (serviceName.length() == 0) {
			updateStatus("Name of the service must be specified");
			return;
		}
		if (!isJavaIdentifier(ModelUtil.makeJavaName(serviceName))) {
			updateStatus("Service name must be a valid Java identifier");
			return;
		}
		updateStatus(null);
	}
52047
@Override
    protected BaseDialogFragment.Builder build(BaseDialogFragment.Builder builder) {
        final CharSequence title = getTitle();
        if (!TextUtils.isEmpty(title)) {
            builder.setTitle(title);
        }

        final CharSequence message = getMessage();
        if (!TextUtils.isEmpty(message)) {
            builder.setMessage(message);
        }

        final CharSequence positiveButtonText = getPositiveButtonText();
        if (!TextUtils.isEmpty(positiveButtonText)) {
            builder.setPositiveButton(positiveButtonText, new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    for (IPositiveButtonDialogListener listener : getPositiveButtonDialogListeners()) {
                        listener.onPositiveButtonClicked(mRequestCode);
                    }
                    dismiss();
                }
            });
        }

        final CharSequence negativeButtonText = getNegativeButtonText();
        if (!TextUtils.isEmpty(negativeButtonText)) {
            builder.setNegativeButton(negativeButtonText, new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    for (INegativeButtonDialogListener listener : getNegativeButtonDialogListeners()) {
                        listener.onNegativeButtonClicked(mRequestCode);
                    }
                    dismiss();
                }
            });
        }

        final CharSequence neutralButtonText = getNeutralButtonText();
        if (!TextUtils.isEmpty(neutralButtonText)) {
            builder.setNeutralButton(neutralButtonText, new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    for (INeutralButtonDialogListener listener : getNeutralButtonDialogListeners()) {
                        listener.onNeutralButtonClicked(mRequestCode);
                    }
                    dismiss();
                }
            });
        }

        return builder;
    }
806311
public MAPDialogOam createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, AddressString origReference, SccpAddress destAddress,
            AddressString destReference) throws MAPException {
        return this.createNewDialog(appCntx, origAddress, origReference, destAddress, destReference, null);
    }
782100
void onClickNew() {

        try {
            CmsObject cms = A_CmsUI.getCmsObject();

            CmsResource folderRes = cms.readResource(m_currentFolder, CmsResourceFilter.IGNORE_EXPIRATION);
            I_CmsDialogContext newDialogContext = getDialogContext();

            CmsNewDialog newDialog = new CmsNewDialog(folderRes, newDialogContext);
            newDialogContext.start(
                CmsVaadinUtils.getMessageText(org.opencms.ui.Messages.GUI_NEWRESOURCEDIALOG_TITLE_0),
                newDialog);

        } catch (Exception e) {
            LOG.error(e.getLocalizedMessage(), e);
        }
    }
403588
public TCUserAbortRequest createUAbort(Dialog d) {
        if (d == null) {
            throw new NullPointerException("Dialog is null");
        }
        TCUserAbortRequestImpl tcer = new TCUserAbortRequestImpl();
        tcer.setDialog(d);
        tcer.setOriginatingAddress(d.getLocalAddress());
        return tcer;
    }
507128
public Long getNewInvokeId() throws TCAPException {
        try {
            this.dialogLock.lock();
            if (this.freeCount == 0) {
                throw new TCAPException("No free invokeId");
            }

            int tryCnt = 0;
            while (true) {
                if (++this.lastInvokeIdIndex >= this.invokeIDTable.length)
                    this.lastInvokeIdIndex = 0;
                if (this.invokeIDTable[this.lastInvokeIdIndex] == _INVOKEID_FREE) {
                    freeCount--;
                    this.invokeIDTable[this.lastInvokeIdIndex] = _INVOKEID_TAKEN;
                    return getInvokeIdFromIndex(this.lastInvokeIdIndex);
                }
                if (++tryCnt >= 256)
                    throw new TCAPException("No free invokeId");
            }

        } finally {
            this.dialogLock.unlock();
        }
    }
1169031
protected function getNewMessage(Dialog $dialog, array $segments, array $options)
    {
        return new Message(
            $this->bankCode,
            $this->username,
            $this->pin,
            $dialog->getSystemId(),
            $dialog->getDialogId(),
            $dialog->getMessageNumber(),
            $segments,
            $options
        );
    }
803064
@Override
    public String getConversationId() {
        final HttpSession session = this.getPortalSesion(false);

        if (session == null) {
            return null;
        }

        return session.getId();
    }