src/net/java/sip/communicator/impl/protocol/jabber/UriHandlerJabberImpl.java
/**
     * Parses the specified URI and creates a chat with the currently active
     * im operation set.
     *
     * @param uri the xmpp URI that we have to handle.
     */
Parses the specified URI and creates a chat with the currently active
im operation set.

@param uri the xmpp URI that we have to handle.
Parses the specified URI and creates a chat with the currently active im operation set . @param uri the xmpp URI that we have to handle .
public void handleUri(String uri)
    {
        /*
         * TODO If the requirement to register the factory service after
         * creating this instance is broken, we'll end up not handling the URIs.
         */
        synchronized (storedAccountsAreLoaded)
        {
            if (!storedAccountsAreLoaded[0])
            {
                if (uris == null)
                {
                    uris = new LinkedList<String>();
                }
                uris.add(uri);
                return;
            }
        }
        ProtocolProviderService provider;
        try
        {
            provider = selectHandlingProvider(uri);
        }
        catch (OperationFailedException exc)
        {
            if (logger.isTraceEnabled())
                logger.trace("User canceled handling of uri " + uri);
            return;
        }
        if (provider == null)
        {
            showErrorMessage(
                "You need to configure at least one XMPP account \n"
                    + "to be able to call " + uri, null);
            return;
        }
        if(!uri.contains("?"))
        {
            OperationSetPersistentPresence presenceOpSet
                = provider
                    .getOperationSet(OperationSetPersistentPresence.class);
            String contactId = uri.substring(uri.indexOf(':') + 1);
            Pattern p = Pattern.compile(".+@.+");
            if(!p.matcher(contactId).matches())
            {
                showErrorMessage(
                "Wrong contact id : " + uri, null);
                return;
            }
            Contact contact = presenceOpSet.findContactByID(contactId);
            if(contact == null)
            {
                Object result =
                    JabberActivator.getUIService().getPopupDialog()
                            .showConfirmPopupDialog(
                                    "Do you want to add the contact : "
                                        + contactId + " ?",
                                    "Add contact",
                                    PopupDialog.YES_NO_OPTION);
                if(result.equals(PopupDialog.YES_OPTION))
                {
                    ExportedWindow ex = JabberActivator.getUIService().
                            getExportedWindow(ExportedWindow.ADD_CONTACT_WINDOW,
                                new String[]{contactId});
                    ex.setVisible(true);
                }
                return;
            }
            JabberActivator.getUIService().
                    getChat(contact).setChatVisible(true);
        }
        else
        {
            String croom = uri.replaceFirst(getProtocol() + ":", "");
            int ix = croom.indexOf("?");
            String param = croom.substring(ix + 1, croom.length());
            croom = croom.substring(0, ix);
            if(param.equalsIgnoreCase("join"))
            {
                OperationSetMultiUserChat mchatOpSet
                    = provider
                        .getOperationSet(OperationSetMultiUserChat.class);
                try
                {
                    ChatRoom room = mchatOpSet.findRoom(croom);
                    if(room != null)
                    {
                        room.join();
                    }
                }
                catch (OperationFailedException exc)
                {
                    if((exc.getErrorCode()
                                == OperationFailedException.NETWORK_FAILURE)
                            && !networkFailReceived)
                    {
                        networkFailReceived = true;
                        OperationSetPresence presenceOpSet
                            = provider
                                .getOperationSet(OperationSetPresence.class);
                        presenceOpSet.addProviderPresenceStatusListener(
                                new ProviderStatusListener(uri, presenceOpSet));
                    }
                    else
                        showErrorMessage("Error joining to  " + croom, exc);
                }
                catch (OperationNotSupportedException exc)
                {
                    showErrorMessage(
                            "Join to " + croom + ", not supported!",
                            exc);
                }
            }
            else
                showErrorMessage(
                "Unknown param : " + param, null);
        }
    }
public void handleUri ( String uri ) { /*
         * TODO If the requirement to register the factory service after
         * creating this instance is broken, we'll end up not handling the URIs.
         */ synchronized ( storedAccountsAreLoaded ) { if ( ! storedAccountsAreLoaded [ 0 ] ) { if ( uris == null ) { uris = new LinkedList < String > ( ) ; } uris . add ( uri ) ; return ; } } ProtocolProviderService provider ; try { provider = selectHandlingProvider ( uri ) ; } catch ( OperationFailedException exc ) { if ( logger . isTraceEnabled ( ) ) logger . trace ( "User canceled handling of uri " + uri ) ; return ; } if ( provider == null ) { showErrorMessage ( "You need to configure at least one XMPP account \n" + "to be able to call " + uri , null ) ; return ; } if ( ! uri . contains ( "?" ) ) { OperationSetPersistentPresence presenceOpSet = provider . getOperationSet ( OperationSetPersistentPresence . class ) ; String contactId = uri . substring ( uri . indexOf ( ':' ) + 1 ) ; Pattern p = Pattern . compile ( ".+@.+" ) ; if ( ! p . matcher ( contactId ) . matches ( ) ) { showErrorMessage ( "Wrong contact id : " + uri , null ) ; return ; } Contact contact = presenceOpSet . findContactByID ( contactId ) ; if ( contact == null ) { Object result = JabberActivator . getUIService ( ) . getPopupDialog ( ) . showConfirmPopupDialog ( "Do you want to add the contact : " + contactId + " ?" , "Add contact" , PopupDialog . YES_NO_OPTION ) ; if ( result . equals ( PopupDialog . YES_OPTION ) ) { ExportedWindow ex = JabberActivator . getUIService ( ) . getExportedWindow ( ExportedWindow . ADD_CONTACT_WINDOW , new String [ ] { contactId } ) ; ex . setVisible ( true ) ; } return ; } JabberActivator . getUIService ( ) . getChat ( contact ) . setChatVisible ( true ) ; } else { String croom = uri . replaceFirst ( getProtocol ( ) + ":" , "" ) ; int ix = croom . indexOf ( "?" ) ; String param = croom . substring ( ix + 1 , croom . length ( ) ) ; croom = croom . substring ( 0 , ix ) ; if ( param . equalsIgnoreCase ( "join" ) ) { OperationSetMultiUserChat mchatOpSet = provider . getOperationSet ( OperationSetMultiUserChat . class ) ; try { ChatRoom room = mchatOpSet . findRoom ( croom ) ; if ( room != null ) { room . join ( ) ; } } catch ( OperationFailedException exc ) { if ( ( exc . getErrorCode ( ) == OperationFailedException . NETWORK_FAILURE ) && ! networkFailReceived ) { networkFailReceived = true ; OperationSetPresence presenceOpSet = provider . getOperationSet ( OperationSetPresence . class ) ; presenceOpSet . addProviderPresenceStatusListener ( new ProviderStatusListener ( uri , presenceOpSet ) ) ; } else showErrorMessage ( "Error joining to  " + croom , exc ) ; } catch ( OperationNotSupportedException exc ) { showErrorMessage ( "Join to " + croom + ", not supported!" , exc ) ; } } else showErrorMessage ( "Unknown param : " + param , null ) ; } }
Parses the specified URI and creates a chat with the currently active
 im operation set.
Parses the specified URI and creates a chat with the currently active im operation set .
// The operation has been canceled by the user. Bail out. // if provider is null then we need to tell the user to create an // account //todo check url!! //Set the email pattern string // if we are not online we get this error // will wait for it and then will try to handle once again