/**
   * Creates an instance of this operation set.
   *
   * @param provider a reference to the <tt>ProtocolProviderServiceImpl</tt> that created us and
   *     that we'll use for retrieving the underlying aim connection.
   */
  OperationSetBasicInstantMessagingJabberImpl(ProtocolProviderServiceJabberImpl provider) {
    this.jabberProvider = provider;

    packetFilters.add(new GroupMessagePacketFilter());
    packetFilters.add(new PacketTypeFilter(org.jivesoftware.smack.packet.Message.class));

    provider.addRegistrationStateChangeListener(new RegistrationStateListener());

    ProviderManager man = ProviderManager.getInstance();
    MessageCorrectionExtensionProvider extProvider = new MessageCorrectionExtensionProvider();
    man.addExtensionProvider(
        MessageCorrectionExtension.ELEMENT_NAME, MessageCorrectionExtension.NAMESPACE, extProvider);
  }
  /**
   * Process candidates received.
   *
   * @param sessionInitIQ The {@link SessionIQ} that created the session we are handling here
   */
  public void processCandidates(SessionIQ sessionInitIQ) {
    Collection<PacketExtension> extensions = sessionInitIQ.getExtensions();
    List<GTalkCandidatePacketExtension> candidates = new ArrayList<GTalkCandidatePacketExtension>();

    for (PacketExtension ext : extensions) {
      if (ext.getElementName().equalsIgnoreCase(GTalkCandidatePacketExtension.ELEMENT_NAME)) {
        GTalkCandidatePacketExtension cand = (GTalkCandidatePacketExtension) ext;
        candidates.add(cand);
      }
    }

    try {
      getMediaHandler().processCandidates(candidates);
    } catch (OperationFailedException ofe) {
      logger.warn("Failed to process an incoming candidates", ofe);

      // send an error response
      String reasonText = "Error: " + ofe.getMessage();
      SessionIQ errResp =
          GTalkPacketFactory.createSessionTerminate(
              sessionInitIQ.getTo(),
              sessionInitIQ.getFrom(),
              sessionInitIQ.getID(),
              Reason.GENERAL_ERROR,
              reasonText);

      getMediaHandler().getTransportManager().close();
      setState(CallPeerState.FAILED, reasonText);
      getProtocolProvider().getConnection().sendPacket(errResp);
      return;
    }

    // HACK for FreeSwitch that send accept message before sending
    // candidates
    if (sessAcceptedWithNoCands != null) {
      if (isInitiator()) {
        try {
          answer();
        } catch (OperationFailedException e) {
          logger.info("Failed to answer call (FreeSwitch hack)");
        }
      } else {
        final SessionIQ sess = sessAcceptedWithNoCands;
        sessAcceptedWithNoCands = null;

        // run in another thread to not block smack receive thread and
        // possibly delay others candidates messages.
        new Thread() {
          @Override
          public void run() {
            processSessionAccept(sess);
          }
        }.start();
      }
      sessAcceptedWithNoCands = null;
    }
  }
    /**
     * Adds a <tt>payload-type</tt> element defined by XEP-0167: Jingle RTP Sessions to this
     * <tt>channel</tt>.
     *
     * @param payloadType the <tt>payload-type</tt> element to be added to this <tt>channel</tt>
     * @return <tt>true</tt> if the list of <tt>payload-type</tt> elements associated with this
     *     <tt>channel</tt> has been modified as part of the method call; otherwise, <tt>false</tt>
     * @throws NullPointerException if the specified <tt>payloadType</tt> is <tt>null</tt>
     */
    public boolean addPayloadType(PayloadTypePacketExtension payloadType) {
      if (payloadType == null) throw new NullPointerException("payloadType");

      // Make sure that the COLIBRI namespace is used.
      payloadType.setNamespace(null);
      for (ParameterPacketExtension p : payloadType.getParameters()) p.setNamespace(null);

      return payloadTypes.contains(payloadType) ? false : payloadTypes.add(payloadType);
    }
Beispiel #4
0
  static {
    // DATE_FORMATS
    DateFormat fmt;

    // XEP-0091
    DATE_FORMATS.add(DelayInformation.XEP_0091_UTC_FORMAT);
    fmt = new SimpleDateFormat("yyyyMd'T'HH:mm:ss'Z'");
    fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
    DATE_FORMATS.add(fmt);

    // XEP-0082
    fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
    fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
    DATE_FORMATS.add(fmt);
    fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
    DATE_FORMATS.add(fmt);
    DATE_FORMATS.add(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"));
    DATE_FORMATS.add(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"));
  }
 /**
  * Adds a new <tt>crypto</tt> element to this encryption element.
  *
  * @param crypto the new <tt>crypto</tt> element to add.
  */
 public void addCrypto(CryptoPacketExtension crypto) {
   if (!cryptoList.contains(crypto)) {
     cryptoList.add(crypto);
   }
 }
  /**
   * Adds a specific {@link Content} instance to the list of <tt>Content</tt> instances included
   * into this <tt>conference</tt> IQ.
   *
   * @param content the <tt>Content</tt> instance to be added to this list of <tt>Content</tt>
   *     instances included into this <tt>conference</tt> IQ
   * @return <tt>true</tt> if the list of <tt>Content</tt> instances included into this
   *     <tt>conference</tt> IQ has been modified as a result of the method call; otherwise,
   *     <tt>false</tt>
   * @throws NullPointerException if the specified <tt>content</tt> is <tt>null</tt>
   */
  public boolean addContent(Content content) {
    if (content == null) throw new NullPointerException("content");

    return contents.contains(content) ? false : contents.add(content);
  }
    /**
     * Adds a <tt>SourcePacketExtension</tt> to the list of sources of this channel.
     *
     * @param source the <tt>SourcePacketExtension</tt> to add to the list of sources of this
     *     channel
     * @return <tt>true</tt> if the list of sources of this channel changed as a result of the
     *     execution of the method; otherwise, <tt>false</tt>
     */
    public synchronized boolean addSource(SourcePacketExtension source) {
      if (source == null) throw new NullPointerException("source");

      return sources.contains(source) ? false : sources.add(source);
    }
    /**
     * Adds a specific <tt>SctpConnection</tt> to the list of <tt>SctpConnection</tt>s included into
     * this <tt>Content</tt>.
     *
     * @param conn the <tt>SctpConnection</tt> to be included into this <tt>Content</tt>
     * @return <tt>true</tt> if the list of <tt>SctpConnection</tt>s included into this
     *     <tt>Content</tt> was modified as a result of the execution of the method; otherwise,
     *     <tt>false</tt>
     * @throws NullPointerException if the specified <tt>conn</tt> is <tt>null</tt>
     */
    public boolean addSctpConnection(SctpConnection conn) {
      if (conn == null) throw new NullPointerException("Sctp connection");

      return !sctpConnections.contains(conn) && sctpConnections.add(conn);
    }
    /**
     * Adds a specific <tt>Channel</tt> to the list of <tt>Channel</tt>s included into this
     * <tt>Content</tt>.
     *
     * @param channel the <tt>Channel</tt> to be included into this <tt>Content</tt>
     * @return <tt>true</tt> if the list of <tt>Channel</tt>s included into this <tt>Content</tt>
     *     was modified as a result of the execution of the method; otherwise, <tt>false</tt>
     * @throws NullPointerException if the specified <tt>channel</tt> is <tt>null</tt>
     */
    public boolean addChannel(Channel channel) {
      if (channel == null) throw new NullPointerException("channel");

      return channels.contains(channel) ? false : channels.add(channel);
    }
Beispiel #10
0
 /**
  * Adds a specific <tt>UserCapsNodeListener</tt> to the list of <tt>UserCapsNodeListener</tt>s
  * interested in events notifying about changes in the list of user caps nodes of this
  * <tt>EntityCapsManager</tt>.
  *
  * @param listener the <tt>UserCapsNodeListener</tt> which is interested in events notifying about
  *     changes in the list of user caps nodes of this <tt>EntityCapsManager</tt>
  */
 public void addUserCapsNodeListener(UserCapsNodeListener listener) {
   if (listener == null) throw new NullPointerException("listener");
   synchronized (userCapsNodeListeners) {
     if (!userCapsNodeListeners.contains(listener)) userCapsNodeListeners.add(listener);
   }
 }