Ejemplo n.º 1
0
  /**
   * Creates all the controls (including encoding) for a type(AUDIO or VIDEO)
   *
   * @param type the type.
   * @return the build Component.
   */
  private static Component createControls(int type) {
    ConfigurationService cfg = NeomediaActivator.getConfigurationService();
    SIPCommTabbedPane container = new SIPCommTabbedPane();
    ResourceManagementService res = NeomediaActivator.getResources();

    if ((cfg == null) || !cfg.getBoolean(DEVICES_DISABLED_PROP, false)) {
      container.insertTab(
          res.getI18NString("impl.media.configform.DEVICES"),
          null,
          createBasicControls(type),
          null,
          0);
    }
    if ((cfg == null) || !cfg.getBoolean(ENCODINGS_DISABLED_PROP, false)) {
      container.insertTab(
          res.getI18NString("impl.media.configform.ENCODINGS"),
          null,
          new PriorityTable(
              new EncodingConfigurationTableModel(mediaService.getEncodingConfiguration(), type),
              100),
          null,
          1);
    }
    if ((type == DeviceConfigurationComboBoxModel.VIDEO)
        && ((cfg == null) || !cfg.getBoolean(VIDEO_MORE_SETTINGS_DISABLED_PROP, false))) {
      container.insertTab(
          res.getI18NString("impl.media.configform.VIDEO_MORE_SETTINGS"),
          null,
          createVideoAdvancedSettings(),
          null,
          2);
    }
    return container;
  }
  /**
   * Returns the prefix for all persistently stored properties of the account with the specified id.
   *
   * @param bundleContext a currently valid bundle context.
   * @param accountID the AccountID of the account whose properties we're looking for.
   * @param sourcePackageName a String containing the package name of the concrete factory class
   *     that extends us.
   * @return a String indicating the ConfigurationService property name prefix under which all
   *     account properties are stored or null if no account corresponding to the specified id was
   *     found.
   */
  public static String findAccountPrefix(
      BundleContext bundleContext, AccountID accountID, String sourcePackageName) {
    ServiceReference confReference =
        bundleContext.getServiceReference(ConfigurationService.class.getName());
    ConfigurationService configurationService =
        (ConfigurationService) bundleContext.getService(confReference);

    // first retrieve all accounts that we've registered
    List<String> storedAccounts =
        configurationService.getPropertyNamesByPrefix(sourcePackageName, true);

    // find an account with the corresponding id.
    for (String accountRootPropertyName : storedAccounts) {
      // unregister the account in the configuration service.
      // all the properties must have been registered in the following
      // hierarchy:
      // net.java.sip.communicator.impl.protocol.PROTO_NAME.ACC_ID.PROP_NAME
      String accountUID =
          configurationService.getString(
              accountRootPropertyName // node id
                  + "."
                  + ACCOUNT_UID); // propname

      if (accountID.getAccountUniqueID().equals(accountUID)) {
        return accountRootPropertyName;
      }
    }
    return null;
  }
Ejemplo n.º 3
0
  /**
   * Gets the data from the <tt>ConfigurationService</tt> that will construct the
   * <tt>PropsTableModel</tt> for the properties table.
   *
   * @return The data necessary to initialize the <tt>PropsTableModel</tt>
   */
  private Object[][] initTableModel() {
    ConfigurationService confService = PropertiesEditorActivator.getConfigurationService();
    java.util.List<String> properties = confService.getAllPropertyNames();
    Object[][] data = new Object[properties.size()][];
    int i = 0;

    for (String property : properties) {
      data[i++] = new Object[] {property, confService.getProperty(property)};
    }

    return data;
  }
Ejemplo n.º 4
0
  static {
    ConfigurationService cfg = LibJitsi.getConfigurationService();
    boolean dropUnencryptedPkts = false;

    if (cfg == null) {
      String s = System.getProperty(DROP_UNENCRYPTED_PKTS_PNAME);

      if (s != null) dropUnencryptedPkts = Boolean.parseBoolean(s);
    } else {
      dropUnencryptedPkts = cfg.getBoolean(DROP_UNENCRYPTED_PKTS_PNAME, dropUnencryptedPkts);
    }
    DROP_UNENCRYPTED_PKTS = dropUnencryptedPkts;
  }
Ejemplo n.º 5
0
  /**
   * The dependent service is available and the bundle will start.
   *
   * @param dependentService the UIService this activator is waiting.
   */
  @Override
  public void start(Object dependentService) {
    if (logger.isDebugEnabled()) logger.debug("Update checker [STARTED]");

    ConfigurationService cfg = getConfiguration();

    if (OSUtils.IS_WINDOWS) {
      updateService = new Update();

      bundleContext.registerService(UpdateService.class.getName(), updateService, null);

      // Register the "Check for Updates" menu item if
      // the "Check for Updates" property isn't disabled.
      if (!cfg.getBoolean(CHECK_FOR_UPDATES_MENU_DISABLED_PROP, false)) {
        // Register the "Check for Updates" menu item.
        CheckForUpdatesMenuItemComponent checkForUpdatesMenuItemComponent =
            new CheckForUpdatesMenuItemComponent(Container.CONTAINER_HELP_MENU);

        Hashtable<String, String> toolsMenuFilter = new Hashtable<String, String>();
        toolsMenuFilter.put(Container.CONTAINER_ID, Container.CONTAINER_HELP_MENU.getID());

        bundleContext.registerService(
            PluginComponent.class.getName(), checkForUpdatesMenuItemComponent, toolsMenuFilter);
      }

      // Check for software update upon startup if enabled.
      if (cfg.getBoolean(UPDATE_ENABLED, true)) updateService.checkForUpdates(false);
    }

    if (cfg.getBoolean(CHECK_FOR_UPDATES_DAILY_ENABLED_PROP, false)) {
      logger.info("Scheduled update checking enabled");

      // Schedule a "check for updates" task that will run once a day
      int hoursToWait = calcHoursToWait();
      Runnable updateRunnable =
          new Runnable() {
            public void run() {
              logger.debug("Performing scheduled update check");
              getUpdateService().checkForUpdates(false);
            }
          };

      mUpdateExecutor = Executors.newSingleThreadScheduledExecutor();
      mUpdateExecutor.scheduleAtFixedRate(
          updateRunnable, hoursToWait, 24 * 60 * 60, TimeUnit.SECONDS);
    }

    if (logger.isDebugEnabled()) logger.debug("Update checker [REGISTERED]");
  }
Ejemplo n.º 6
0
  @Override
  public void chatLinkClicked(URI url) {
    String action = url.getPath();
    if (action.equals("/SHOWPREVIEW")) {
      enableReplacement.setSelected(cfg.getBoolean(ReplacementProperty.REPLACEMENT_ENABLE, true));
      enableReplacementProposal.setSelected(
          cfg.getBoolean(ReplacementProperty.REPLACEMENT_PROPOSAL, true));

      currentMessageID = url.getQuery();
      currentLinkPosition = url.getFragment();

      this.setVisible(true);
      this.setLocationRelativeTo(chatPanel);
    }
  }
Ejemplo n.º 7
0
 /**
  * Calculate the number of hour to wait until the first scheduled update check. This will only be
  * called if daily checking for config updates is enabled
  *
  * @return The number of hours to wait
  */
 private int calcHoursToWait() {
   // The hours to wait is the number of hours until midnight tonight (24
   // minus the current hour) plus the hour that the config says updates
   // should be
   return 24
       - Calendar.getInstance().get(Calendar.HOUR_OF_DAY)
       + configuration.getInt(CHECK_FOR_UPDATES_DAILY_TIME_PROP, 0);
 }
Ejemplo n.º 8
0
  /**
   * Initializes a new <tt>RecordButton</tt> instance which is to record the audio stream.
   *
   * @param call the <tt>Call</tt> to be associated with the new instance and to have its audio
   *     stream recorded
   * @param selected <tt>true</tt> if the new toggle button is to be initially selected; otherwise,
   *     <tt>false</tt>
   */
  public RecordButton(Call call, boolean selected) {
    super(call, true, selected, ImageLoader.RECORD_BUTTON, ImageLoader.RECORD_BUTTON_PRESSED, null);

    String toolTip = resources.getI18NString("service.gui.RECORD_BUTTON_TOOL_TIP");
    String saveDir = configuration.getString(Recorder.SAVED_CALLS_PATH);

    if ((saveDir != null) && (saveDir.length() != 0)) toolTip += " (" + saveDir + ")";
    setToolTipText(toolTip);
  }
  /**
   * Gets the max allowed size value in bytes from Configuration service and sets the value to
   * <tt>imgMaxSize</tt> if succeed. If the configuration property isn't available or the value
   * can't be parsed correctly the value of <tt>imgMaxSize</tt> isn't changed.
   */
  private void setMaxImgSizeFromConf() {
    ConfigurationService configService = DirectImageActivator.getConfigService();

    if (configService != null) {
      String confImgSizeStr = (String) configService.getProperty(MAX_IMG_SIZE);
      try {
        if (confImgSizeStr != null) {
          imgMaxSize = Long.parseLong(confImgSizeStr);
        } else {
          configService.setProperty(MAX_IMG_SIZE, imgMaxSize);
        }
      } catch (NumberFormatException e) {
        if (logger.isDebugEnabled())
          logger.debug(
              "Failed to parse max image size: " + confImgSizeStr + ". Going for default.");
      }
    }
  }
  /**
   * Returns the path to the directory where the media recording related files should be saved, or
   * <tt>null</tt> if recording is not enabled in the configuration, or a recording path has not
   * been configured.
   *
   * @return the path to the directory where the media recording related files should be saved, or
   *     <tt>null</tt> if recording is not enabled in the configuration, or a recording path has not
   *     been configured.
   */
  String getRecordingPath() {
    if (recordingPath == null) {
      ConfigurationService cfg = getVideobridge().getConfigurationService();

      if (cfg != null) {
        boolean recordingIsEnabled =
            cfg.getBoolean(Videobridge.ENABLE_MEDIA_RECORDING_PNAME, false);

        if (recordingIsEnabled) {
          String path = cfg.getString(Videobridge.MEDIA_RECORDING_PATH_PNAME, null);

          if (path != null) {
            this.recordingPath = path + "/" + this.getRecordingDirectory();
          }
        }
      }
    }
    return recordingPath;
  }
Ejemplo n.º 11
0
  /**
   * Returns the last contact status saved in the configuration.
   *
   * @param protocolProvider the protocol provider to which the status corresponds
   * @return the last contact status saved in the configuration.
   */
  public String getLastStatusString(ProtocolProviderService protocolProvider) {
    // find the last contact status saved in the configuration.
    String lastStatus = null;

    ConfigurationService configService = GuiActivator.getConfigurationService();
    String prefix = "net.java.sip.communicator.impl.gui.accounts";
    List<String> accounts = configService.getPropertyNamesByPrefix(prefix, true);
    String protocolProviderAccountUID = protocolProvider.getAccountID().getAccountUniqueID();

    for (String accountRootPropName : accounts) {
      String accountUID = configService.getString(accountRootPropName);

      if (accountUID.equals(protocolProviderAccountUID)) {
        lastStatus = configService.getString(accountRootPropName + ".lastAccountStatus");

        if (lastStatus != null) break;
      }
    }

    return lastStatus;
  }
Ejemplo n.º 12
0
  /**
   * Saves the last status for all accounts. This information is used on loging. Each time user logs
   * in he's logged with the same status as he was the last time before closing the application.
   *
   * @param protocolProvider the protocol provider to save status information for
   * @param statusName the name of the status to save
   */
  private void saveStatusInformation(ProtocolProviderService protocolProvider, String statusName) {
    ConfigurationService configService = GuiActivator.getConfigurationService();

    String prefix = "net.java.sip.communicator.impl.gui.accounts";

    List<String> accounts = configService.getPropertyNamesByPrefix(prefix, true);

    boolean savedAccount = false;

    for (String accountRootPropName : accounts) {
      String accountUID = configService.getString(accountRootPropName);

      if (accountUID.equals(protocolProvider.getAccountID().getAccountUniqueID())) {

        configService.setProperty(accountRootPropName + ".lastAccountStatus", statusName);

        savedAccount = true;
      }
    }

    if (!savedAccount) {
      String accNodeName = "acc" + Long.toString(System.currentTimeMillis());

      String accountPackage = "net.java.sip.communicator.impl.gui.accounts." + accNodeName;

      configService.setProperty(
          accountPackage, protocolProvider.getAccountID().getAccountUniqueID());

      configService.setProperty(accountPackage + ".lastAccountStatus", statusName);
    }
  }
Ejemplo n.º 13
0
  /** Constructs MessageSourceService. */
  MessageSourceService(MessageHistoryServiceImpl messageHistoryService) {
    this.messageHistoryService = messageHistoryService;

    ConfigurationService conf = MessageHistoryActivator.getConfigurationService();

    if (conf.getBoolean(IN_HISTORY_PROPERTY, false)) {
      sourceServiceType = HISTORY_TYPE;
    }

    MESSAGE_HISTORY_NAME =
        MessageHistoryActivator.getResources().getI18NString("service.gui.RECENT_MESSAGES");

    numberOfMessages = conf.getInt(NUMBER_OF_RECENT_MSGS_PROP, numberOfMessages);

    isSMSEnabled = conf.getBoolean(IS_MESSAGE_SUBTYPE_SMS_PROP, isSMSEnabled);

    RECENT_MSGS_VER = conf.getString(VER_OF_RECENT_MSGS_PROP, RECENT_MSGS_VER);

    MessageSourceContactPresenceStatus.MSG_SRC_CONTACT_ONLINE.setStatusIcon(
        MessageHistoryActivator.getResources()
            .getImageInBytes("service.gui.icons.SMS_STATUS_ICON"));
  }
Ejemplo n.º 14
0
  /**
   * Makes home folder and the configuration file readable and writable only to the owner.
   *
   * @param cs the <tt>ConfigurationService</tt> instance to check for home folder and configuration
   *     file.
   */
  private static void fixPermissions(ConfigurationService cs) {
    if (!OSUtils.IS_LINUX && !OSUtils.IS_MAC) return;

    try {
      // let's check config file and config folder
      File homeFolder = new File(cs.getScHomeDirLocation(), cs.getScHomeDirName());
      Set<PosixFilePermission> perms =
          new HashSet<PosixFilePermission>() {
            {
              add(PosixFilePermission.OWNER_READ);
              add(PosixFilePermission.OWNER_WRITE);
              add(PosixFilePermission.OWNER_EXECUTE);
            }
          };
      Files.setPosixFilePermissions(Paths.get(homeFolder.getAbsolutePath()), perms);

      String fileName = cs.getConfigurationFilename();
      if (fileName != null) {
        File cf = new File(homeFolder, fileName);
        if (cf.exists()) {
          perms =
              new HashSet<PosixFilePermission>() {
                {
                  add(PosixFilePermission.OWNER_READ);
                  add(PosixFilePermission.OWNER_WRITE);
                }
              };
          Files.setPosixFilePermissions(Paths.get(cf.getAbsolutePath()), perms);
        }
      }
    } catch (Throwable t) {
      logger.error("Error creating c lib instance for fixing file permissions", t);

      if (t instanceof InterruptedException) Thread.currentThread().interrupt();
      else if (t instanceof ThreadDeath) throw (ThreadDeath) t;
    }
  }
Ejemplo n.º 15
0
  /**
   * Creates a full filename for the call by combining the directory, file prefix and extension. If
   * the directory is <tt>null</tt> user's home directory is used.
   *
   * @param savedCallsPath the path to the directory in which the generated file name is to be
   *     placed
   * @return a full filename for the call
   */
  private String createDefaultFilename(String savedCallsPath) {
    // set to user's home when null
    if (savedCallsPath == null) {
      try {
        savedCallsPath =
            GuiActivator.getFileAccessService().getDefaultDownloadDirectory().getAbsolutePath();
      } catch (IOException ioex) {
        // Leave it in the current directory.
      }
    }

    String ext = configuration.getString(Recorder.FORMAT);

    // Use a default format when the configured one seems invalid.
    if ((ext == null) || (ext.length() == 0) || !isSupportedFormat(ext))
      ext = SoundFileUtils.DEFAULT_CALL_RECORDING_FORMAT;
    return ((savedCallsPath == null) ? "" : (savedCallsPath + File.separator))
        + generateCallFilename(ext);
  }
 /**
  * Indicates if the given string is possibly a phone number.
  *
  * @param possibleNumber the string to be verified
  * @return <tt>true</tt> if the possibleNumber is a phone number, <tt>false</tt> - otherwise
  */
 public static boolean isPhoneNumber(String possibleNumber) {
   // If the string does not contains an "@", this may be a phone number.
   if (possibleNumber.indexOf('@') == -1) {
     // If the string does not contain any alphabetical characters, then
     // this is a phone number.
     if (!possibleNumber.matches(".*[a-zA-Z].*")) {
       return true;
     } else {
       // Removes the " ", "(" and ")" in order to search the "+"
       // character at the beginning at the string.
       String tmpPossibleNumber = possibleNumber.replaceAll(" \\(\\)", "");
       // If the property is enabled and the string starts with a "+",
       // then we consider that this is a phone number.
       if (configService.getBoolean("impl.gui.ACCEPT_PHONE_NUMBER_WITH_ALPHA_CHARS", true)
           && tmpPossibleNumber.startsWith("+")) {
         return true;
       }
     }
   }
   // Else the string is not a phone number.
   return false;
 }
Ejemplo n.º 17
0
  /** Starts this manager for given <tt>hostName</tt>. */
  public void start() {
    expireThread.start();

    ConfigurationService config = FocusBundleActivator.getConfigService();
    String hostName = config.getString(HOSTNAME_PNAME);
    String xmppDomain = config.getString(XMPP_DOMAIN_PNAME);

    focusUserDomain = config.getString(FOCUS_USER_DOMAIN_PNAME);
    focusUserName = config.getString(FOCUS_USER_NAME_PNAME);

    String focusUserPassword = config.getString(FOCUS_USER_PASSWORD_PNAME);

    protocolProviderHandler.start(hostName, focusUserDomain, focusUserPassword, focusUserName);

    jitsiMeetServices =
        new JitsiMeetServices(
            protocolProviderHandler.getOperationSet(OperationSetSubscription.class));

    String statsPubSubNode = config.getString(SHARED_STATS_PUBSUB_NODE_PNAME);

    componentsDiscovery = new ComponentsDiscovery(jitsiMeetServices);

    componentsDiscovery.start(xmppDomain, statsPubSubNode, protocolProviderHandler);

    meetExtensionsHandler = new MeetExtensionsHandler(this);

    ProviderManager.getInstance()
        .addExtensionProvider(
            LogPacketExtension.LOG_ELEM_NAME,
            LogPacketExtension.NAMESPACE,
            new LogExtensionProvider());

    FocusBundleActivator.bundleContext.registerService(
        JitsiMeetServices.class, jitsiMeetServices, null);

    protocolProviderHandler.addRegistrationListener(this);
    protocolProviderHandler.register();
  }
Ejemplo n.º 18
0
  /**
   * Retrieve DiscoverInfo for a specific node.
   *
   * @param caps the <tt>Caps</tt> i.e. the node, the hash and the ver
   * @return The corresponding DiscoverInfo or null if none is known.
   */
  public static DiscoverInfo getDiscoverInfoByCaps(Caps caps) {
    synchronized (caps2discoverInfo) {
      DiscoverInfo discoverInfo = caps2discoverInfo.get(caps);

      /*
       * If we don't have the discoverInfo in the runtime cache yet, we
       * may have it remembered in a previous application instance.
       */
      if (discoverInfo == null) {
        ConfigurationService configurationService = getConfigService();
        String capsPropertyName = getCapsPropertyName(caps);
        String xml = configurationService.getString(capsPropertyName);

        if ((xml != null) && (xml.length() != 0)) {
          IQProvider discoverInfoProvider =
              (IQProvider)
                  ProviderManager.getInstance()
                      .getIQProvider("query", "http://jabber.org/protocol/disco#info");

          if (discoverInfoProvider != null) {
            XmlPullParser parser = new MXParser();

            try {
              parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
              parser.setInput(new StringReader(xml));
              // Start the parser.
              parser.next();
            } catch (XmlPullParserException xppex) {
              parser = null;
            } catch (IOException ioex) {
              parser = null;
            }

            if (parser != null) {
              try {
                discoverInfo = (DiscoverInfo) discoverInfoProvider.parseIQ(parser);
              } catch (Exception ex) {
              }

              if (discoverInfo != null) {
                if (caps.isValid(discoverInfo)) caps2discoverInfo.put(caps, discoverInfo);
                else {
                  logger.error(
                      "Invalid DiscoverInfo for " + caps.getNodeVer() + ": " + discoverInfo);
                  /*
                   * The discoverInfo doesn't seem valid
                   * according to the caps which means that we
                   * must have stored invalid information.
                   * Delete the invalid information in order
                   * to not try to validate it again.
                   */
                  configurationService.removeProperty(capsPropertyName);
                }
              }
            }
          }
        }
      }
      return discoverInfo;
    }
  }
Ejemplo n.º 19
0
  /**
   * Creates an instance of <tt>ShowPreviewDialog</tt>
   *
   * @param chatPanel The <tt>ChatConversationPanel</tt> that is associated with this dialog.
   */
  ShowPreviewDialog(final ChatConversationPanel chatPanel) {
    this.chatPanel = chatPanel;

    this.setTitle(
        GuiActivator.getResources().getI18NString("service.gui.SHOW_PREVIEW_DIALOG_TITLE"));
    okButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.OK"));
    cancelButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.CANCEL"));

    JPanel mainPanel = new TransparentPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    // mainPanel.setPreferredSize(new Dimension(200, 150));
    this.getContentPane().add(mainPanel);

    JTextPane descriptionMsg = new JTextPane();
    descriptionMsg.setEditable(false);
    descriptionMsg.setOpaque(false);
    descriptionMsg.setText(
        GuiActivator.getResources().getI18NString("service.gui.SHOW_PREVIEW_WARNING_DESCRIPTION"));

    Icon warningIcon = null;
    try {
      warningIcon =
          new ImageIcon(
              ImageIO.read(
                  GuiActivator.getResources().getImageURL("service.gui.icons.WARNING_ICON")));
    } catch (IOException e) {
      logger.debug("failed to load the warning icon");
    }
    JLabel warningSign = new JLabel(warningIcon);

    JPanel warningPanel = new TransparentPanel();
    warningPanel.setLayout(new BoxLayout(warningPanel, BoxLayout.X_AXIS));
    warningPanel.add(warningSign);
    warningPanel.add(Box.createHorizontalStrut(10));
    warningPanel.add(descriptionMsg);

    enableReplacement =
        new JCheckBox(
            GuiActivator.getResources()
                .getI18NString("plugin.chatconfig.replacement.ENABLE_REPLACEMENT_STATUS"));
    enableReplacement.setOpaque(false);
    enableReplacement.setSelected(cfg.getBoolean(ReplacementProperty.REPLACEMENT_ENABLE, true));
    enableReplacementProposal =
        new JCheckBox(
            GuiActivator.getResources()
                .getI18NString("plugin.chatconfig.replacement.ENABLE_REPLACEMENT_PROPOSAL"));
    enableReplacementProposal.setOpaque(false);

    JPanel checkBoxPanel = new TransparentPanel();
    checkBoxPanel.setLayout(new BoxLayout(checkBoxPanel, BoxLayout.Y_AXIS));
    checkBoxPanel.add(enableReplacement);
    checkBoxPanel.add(enableReplacementProposal);

    JPanel buttonsPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER));
    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);

    mainPanel.add(warningPanel);
    mainPanel.add(Box.createVerticalStrut(10));
    mainPanel.add(checkBoxPanel);
    mainPanel.add(buttonsPanel);

    okButton.addActionListener(this);
    cancelButton.addActionListener(this);

    this.setPreferredSize(new Dimension(390, 230));
  }
  /**
   * Starts the execution of the neomedia bundle in the specified context.
   *
   * @param bundleContext the context in which the neomedia bundle is to start executing
   * @throws Exception if an error occurs while starting the execution of the neomedia bundle in the
   *     specified context
   */
  public void start(BundleContext bundleContext) throws Exception {
    if (logger.isDebugEnabled()) logger.debug("Started.");

    NeomediaActivator.bundleContext = bundleContext;

    // MediaService
    mediaServiceImpl = (MediaServiceImpl) LibJitsi.getMediaService();

    bundleContext.registerService(MediaService.class.getName(), mediaServiceImpl, null);
    if (logger.isDebugEnabled()) logger.debug("Media Service ... [REGISTERED]");

    //        mediaConfiguration = new MediaConfigurationImpl();
    //        bundleContext.registerService(
    //                MediaConfigurationService.class.getStatus(),
    //                getMediaConfiguration(),
    //                null);
    if (logger.isDebugEnabled()) logger.debug("Media Configuration ... [REGISTERED]");

    ConfigurationService cfg = NeomediaActivator.getConfigurationService();
    Dictionary<String, String> mediaProps = new Hashtable<String, String>();

    mediaProps.put(ConfigurationForm.FORM_TYPE, ConfigurationForm.GENERAL_TYPE);

    // If the audio configuration form is disabled don't register it.
    //        if ((cfg == null) || !cfg.getBoolean(AUDIO_CONFIG_DISABLED_PROP, false))
    //        {
    //            audioConfigurationForm
    //                = new LazyConfigurationForm(
    //                        AudioConfigurationPanel.class.getStatus(),
    //                        getClass().getClassLoader(),
    //                        "plugin.mediaconfig.AUDIO_ICON",
    //                        "impl.neomedia.configform.AUDIO",
    //                        3);
    //
    //            bundleContext.registerService(
    //                    ConfigurationForm.class.getStatus(),
    //                    audioConfigurationForm,
    //                    mediaProps);
    //
    //            if (deviceConfigurationPropertyChangeListener == null)
    //            {
    //                // Initializes and registers the changed device configuration
    //                // event ot the notification service.
    //                getNotificationService();
    //
    //                deviceConfigurationPropertyChangeListener
    //                    = new AudioDeviceConfigurationListener();
    //                mediaServiceImpl
    //                    .getDeviceConfiguration()
    //                        .addPropertyChangeListener(
    //                                deviceConfigurationPropertyChangeListener);
    //            }
    //        }

    // If the video configuration form is disabled don't register it.
    //        if ((cfg == null) || !cfg.getBoolean(VIDEO_CONFIG_DISABLED_PROP, false))
    //        {
    //            bundleContext.registerService(
    //                    ConfigurationForm.class.getStatus(),
    //                    new LazyConfigurationForm(
    //                            VideoConfigurationPanel.class.getStatus(),
    //                            getClass().getClassLoader(),
    //                            "plugin.mediaconfig.VIDEO_ICON",
    //                            "impl.neomedia.configform.VIDEO",
    //                            4),
    //                    mediaProps);
    //        }

    // H.264
    // If the H.264 configuration form is disabled don't register it.
    //        if ((cfg == null) || !cfg.getBoolean(H264_CONFIG_DISABLED_PROP, false))
    //        {
    //            Dictionary<String, String> h264Props
    //                = new Hashtable<String, String>();
    //
    //            h264Props.put(
    //                    ConfigurationForm.FORM_TYPE,
    //                    ConfigurationForm.ADVANCED_TYPE);
    //            bundleContext.registerService(
    //                    ConfigurationForm.class.getStatus(),
    //                    new LazyConfigurationForm(
    //                            ConfigurationPanel.class.getStatus(),
    //                            getClass().getClassLoader(),
    //                            "plugin.mediaconfig.VIDEO_ICON",
    //                            "impl.neomedia.configform.H264",
    //                            -1,
    //                            true),
    //                    h264Props);
    //        }

    // ZRTP
    // If the ZRTP configuration form is disabled don't register it.
    //        if ((cfg == null) || !cfg.getBoolean(ZRTP_CONFIG_DISABLED_PROP, false))
    //        {
    //            Dictionary<String, String> securityProps
    //                = new Hashtable<String, String>();
    //
    //            securityProps.put( ConfigurationForm.FORM_TYPE,
    //                            ConfigurationForm.SECURITY_TYPE);
    //            bundleContext.registerService(
    //                ConfigurationForm.class.getStatus(),
    //                new LazyConfigurationForm(
    //                    SecurityConfigForm.class.getStatus(),
    //                    getClass().getClassLoader(),
    //                    "impl.media.security.zrtp.CONF_ICON",
    //                    "impl.media.security.zrtp.TITLE",
    //                    0),
    //                securityProps);
    //        }

    // we use the nist-sdp stack to make parse sdp and we need to set the
    // following property to make sure that it would accept java generated
    // IPv6 addresses that contain address scope zones.
    System.setProperty("gov.nist.core.STRIP_ADDR_SCOPES", "true");

    // AudioNotifierService
    AudioNotifierService audioNotifierService = LibJitsi.getAudioNotifierService();

    audioNotifierService.setMute(
        (cfg == null)
            || !cfg.getBoolean("net.java.sip.communicator" + ".impl.sound.isSoundEnabled", true));
    bundleContext.registerService(AudioNotifierService.class.getName(), audioNotifierService, null);

    if (logger.isInfoEnabled()) logger.info("Audio Notifier Service ...[REGISTERED]");

    // Call Recording
    // If the call recording configuration form is disabled don't continue.
    //        if ((cfg == null)
    //                || !cfg.getBoolean(CALL_RECORDING_CONFIG_DISABLED_PROP, false))
    //        {
    //            Dictionary<String, String> callRecordingProps
    //                = new Hashtable<String, String>();
    //
    //            callRecordingProps.put(
    //                    ConfigurationForm.FORM_TYPE,
    //                    ConfigurationForm.ADVANCED_TYPE);
    //            bundleContext.registerService(
    //                    ConfigurationForm.class.getStatus(),
    //                    new LazyConfigurationForm(
    //                            CallRecordingConfigForm.class.getStatus(),
    //                            getClass().getClassLoader(),
    //                            null,
    //                            "plugin.callrecordingconfig.CALL_RECORDING_CONFIG",
    //                            1100,
    //                            true),
    //                    callRecordingProps);
    //        }
  }
Ejemplo n.º 21
0
  @Override
  public void actionPerformed(ActionEvent arg0) {
    if (arg0.getSource().equals(okButton)) {
      cfg.setProperty(ReplacementProperty.REPLACEMENT_ENABLE, enableReplacement.isSelected());
      cfg.setProperty(
          ReplacementProperty.REPLACEMENT_PROPOSAL, enableReplacementProposal.isSelected());
      SwingWorker worker =
          new SwingWorker() {
            /**
             * Called on the event dispatching thread (not on the worker thread) after the <code>
             * construct</code> method has returned.
             */
            @Override
            public void finished() {
              String newChatString = (String) get();

              if (newChatString != null) {
                try {
                  Element elem = chatPanel.document.getElement(currentMessageID);
                  chatPanel.document.setOuterHTML(elem, newChatString);
                  msgIDToChatString.put(currentMessageID, newChatString);
                } catch (BadLocationException ex) {
                  logger.error("Could not replace chat message", ex);
                } catch (IOException ex) {
                  logger.error("Could not replace chat message", ex);
                }
              }
            }

            @Override
            protected Object construct() throws Exception {
              String newChatString = msgIDToChatString.get(currentMessageID);
              try {
                String originalLink =
                    msgIDandPositionToLink.get(currentMessageID + "#" + currentLinkPosition);
                String replacementLink = linkToReplacement.get(originalLink);
                String replacement;
                DirectImageReplacementService source =
                    GuiActivator.getDirectImageReplacementSource();
                if (originalLink.equals(replacementLink)
                    && (!source.isDirectImage(originalLink)
                        || source.getImageSize(originalLink) == -1)) {
                  replacement = originalLink;
                } else {
                  replacement =
                      "<IMG HEIGHT=\"90\" WIDTH=\"120\" SRC=\""
                          + replacementLink
                          + "\" BORDER=\"0\" ALT=\""
                          + originalLink
                          + "\"></IMG>";
                }

                String old =
                    originalLink
                        + "</A> <A href=\"jitsi://"
                        + ShowPreviewDialog.this.getClass().getName()
                        + "/SHOWPREVIEW?"
                        + currentMessageID
                        + "#"
                        + currentLinkPosition
                        + "\">"
                        + GuiActivator.getResources().getI18NString("service.gui.SHOW_PREVIEW");

                newChatString = newChatString.replace(old, replacement);
              } catch (Exception ex) {
                logger.error("Could not replace chat message", ex);
              }
              return newChatString;
            }
          };
      worker.start();
      this.setVisible(false);
    } else if (arg0.getSource().equals(cancelButton)) {
      this.setVisible(false);
    }
  }
Ejemplo n.º 22
0
  /**
   * Starts recording {@link #call} creating {@link #recorder} first and asking the user for the
   * recording format and file if they are not configured in the "Call Recording" configuration
   * form.
   *
   * @return <tt>true</tt> if the recording has been started successfully; otherwise, <tt>false</tt>
   */
  private boolean startRecording() {
    String savedCallsPath = configuration.getString(Recorder.SAVED_CALLS_PATH);
    String callFormat;

    // Ask the user where to save the call.
    if ((savedCallsPath == null) || (savedCallsPath.length() == 0)) {
      /*
       * Delay the initialization of callFileChooser in order to delay the
       * creation of the recorder.
       */
      if (callFileChooser == null) {
        callFileChooser =
            GenericFileDialog.create(
                null,
                resources.getI18NString("plugin.callrecordingconfig.SAVE_CALL"),
                SipCommFileChooser.SAVE_FILE_OPERATION);
        callFileChooser.addFilter(
            new SipCommFileFilter() {
              @Override
              public boolean accept(File f) {
                return f.isDirectory() || isSupportedFormat(f);
              }

              @Override
              public String getDescription() {
                StringBuilder description = new StringBuilder();

                description.append("Recorded call");

                Recorder recorder;

                try {
                  recorder = getRecorder();
                } catch (OperationFailedException ofex) {
                  logger.error("Failed to get Recorder", ofex);
                  recorder = null;
                }
                if (recorder != null) {
                  List<String> supportedFormats = recorder.getSupportedFormats();

                  if (supportedFormats != null) {
                    description.append(" (");

                    boolean firstSupportedFormat = true;

                    for (String supportedFormat : supportedFormats) {
                      if (firstSupportedFormat) firstSupportedFormat = false;
                      else description.append(", ");
                      description.append("*.");
                      description.append(supportedFormat);
                    }

                    description.append(')');
                  }
                }
                return description.toString();
              }
            });
      }
      // Offer a default name for the file to record into.
      callFileChooser.setStartPath(createDefaultFilename(null));

      File selectedFile = callFileChooser.getFileFromDialog();

      if (selectedFile != null) {
        callFilename = selectedFile.getAbsolutePath();

        /*
         * If the user specified no extension (which seems common on Mac
         * OS X at least) i.e. no format, then it is not obvious that we
         * have to override the set Recorder.CALL_FORMAT.
         */
        callFormat = SoundFileUtils.getExtension(selectedFile);

        if ((callFormat != null) && (callFormat.length() != 0)) {
          /*
           * If the use has specified an extension and thus a format
           * which is not supported, use a default format instead.
           */
          if (!isSupportedFormat(selectedFile)) {
            /*
             * If what appears to be an extension seems a lot like
             * an extension, then it should be somewhat safer to
             * replace it.
             */
            if (SoundFileUtils.isSoundFile(selectedFile)) {
              callFilename = callFilename.substring(0, callFilename.lastIndexOf('.'));
            }
            String configuredFormat = configuration.getString(Recorder.FORMAT);
            callFormat =
                (configuredFormat != null && configuredFormat.length() != 0)
                    ? configuredFormat
                    : SoundFileUtils.DEFAULT_CALL_RECORDING_FORMAT;

            callFilename += '.' + callFormat;
          }
          configuration.setProperty(Recorder.FORMAT, callFormat);
        }
      } else {
        // user canceled the recording
        return false;
      }
    } else {
      callFilename = createDefaultFilename(savedCallsPath);
      callFormat = SoundFileUtils.getExtension(new File(callFilename));
    }

    Throwable exception = null;

    try {
      Recorder recorder = getRecorder();

      if (recorder != null) {
        if ((callFormat == null) || (callFormat.length() <= 0))
          callFormat = SoundFileUtils.DEFAULT_CALL_RECORDING_FORMAT;

        recorder.start(callFormat, callFilename);
      }

      this.recorder = recorder;
    } catch (IOException ioex) {
      exception = ioex;
    } catch (MediaException mex) {
      exception = mex;
    } catch (OperationFailedException ofex) {
      exception = ofex;
    }
    if ((recorder == null) || (exception != null)) {
      logger.error(
          "Failed to start recording call " + call + " into file " + callFilename, exception);
      return false;
    } else return true;
  }
Ejemplo n.º 23
0
  /** Installs an account and verifies whether the installation has gone well. */
  public void testInstallAccount() {
    // first obtain a reference to the provider factory
    ServiceReference[] serRefs = null;
    String osgiFilter = "(" + ProtocolProviderFactory.PROTOCOL + "=" + ProtocolNames.JABBER + ")";
    try {
      serRefs =
          JabberSlickFixture.bc.getServiceReferences(
              ProtocolProviderFactory.class.getName(), osgiFilter);
    } catch (InvalidSyntaxException ex) {
      // this really shouldhn't occur as the filter expression is static.
      fail(osgiFilter + " is not a valid osgi filter");
    }

    assertTrue(
        "Failed to find a provider factory service for protocol Jabber",
        serRefs != null && serRefs.length > 0);

    // Enable always trust mode for testing tls jabber connections
    ServiceReference confReference =
        JabberSlickFixture.bc.getServiceReference(ConfigurationService.class.getName());
    ConfigurationService configurationService =
        (ConfigurationService) JabberSlickFixture.bc.getService(confReference);

    configurationService.setProperty(CertificateService.PNAME_ALWAYS_TRUST, Boolean.TRUE);

    // Keep the reference for later usage.
    ProtocolProviderFactory jabberProviderFactory =
        (ProtocolProviderFactory) JabberSlickFixture.bc.getService(serRefs[0]);

    // make sure the account is empty
    assertTrue(
        "There was an account registered with the account mananger " + "before we've installed any",
        jabberProviderFactory.getRegisteredAccounts().size() == 0);

    // Prepare the properties of the first jabber account.

    Hashtable<String, String> jabberAccount1Properties =
        getAccountProperties(JabberProtocolProviderServiceLick.ACCOUNT_1_PREFIX);
    Hashtable<String, String> jabberAccount2Properties =
        getAccountProperties(JabberProtocolProviderServiceLick.ACCOUNT_2_PREFIX);
    Hashtable<String, String> jabberAccount3Properties =
        getAccountProperties(JabberProtocolProviderServiceLick.ACCOUNT_3_PREFIX);

    // try to install an account with a null account id
    try {
      jabberProviderFactory.installAccount(null, jabberAccount1Properties);
      fail(
          "installing an account with a null account id must result "
              + "in a NullPointerException");
    } catch (NullPointerException exc) {
      // that's what had to happen
    }

    // now really install the accounts
    jabberProviderFactory.installAccount(
        jabberAccount1Properties.get(ProtocolProviderFactory.USER_ID), jabberAccount1Properties);
    jabberProviderFactory.installAccount(
        jabberAccount2Properties.get(ProtocolProviderFactory.USER_ID), jabberAccount2Properties);
    jabberProviderFactory.installAccount(
        jabberAccount3Properties.get(ProtocolProviderFactory.USER_ID), jabberAccount3Properties);

    // try to install one of the accounts one more time and verify that an
    // excepion is thrown.
    try {
      jabberProviderFactory.installAccount(
          jabberAccount1Properties.get(ProtocolProviderFactory.USER_ID), jabberAccount1Properties);

      fail(
          "An IllegalStateException must be thrown when trying to "
              + "install a duplicate account");

    } catch (IllegalStateException exc) {
      // that's what supposed to happen.
    }

    // Verify that the provider factory is aware of our installation
    assertTrue(
        "The newly installed account was not in the acc man's " + "registered accounts!",
        jabberProviderFactory.getRegisteredAccounts().size() == 3);

    // Verify protocol providers corresponding to the new account have
    // been properly registered with the osgi framework.

    osgiFilter =
        "(&("
            + ProtocolProviderFactory.PROTOCOL
            + "="
            + ProtocolNames.JABBER
            + ")"
            + "("
            + ProtocolProviderFactory.USER_ID
            + "="
            + jabberAccount1Properties.get(ProtocolProviderFactory.USER_ID)
            + "))";

    try {
      serRefs =
          JabberSlickFixture.bc.getServiceReferences(
              ProtocolProviderService.class.getName(), osgiFilter);
    } catch (InvalidSyntaxException ex) {
      // this really shouldhn't occur as the filter expression is static.
      fail(osgiFilter + "is not a valid osgi filter");
    }

    assertTrue(
        "An protocol provider was apparently not installed as " + "requested.",
        serRefs != null && serRefs.length > 0);

    Object jabberProtocolProvider = JabberSlickFixture.bc.getService(serRefs[0]);

    assertTrue(
        "The installed protocol provider does not implement " + "the protocol provider service.",
        jabberProtocolProvider instanceof ProtocolProviderService);
  }
Ejemplo n.º 24
0
  /** Creates an instance of <tt>ZrtpConfigurePanel</tt>. */
  public ZrtpConfigurePanel() {
    super(new BorderLayout());

    ResourceManagementService resources = NeomediaActivator.getResources();

    JPanel mainPanel = new TransparentPanel(new BorderLayout(0, 10));

    final JButton stdButton =
        new JButton(resources.getI18NString("impl.media.security.zrtp.STANDARD"));
    stdButton.setOpaque(false);

    final JButton mandButton =
        new JButton(resources.getI18NString("impl.media.security.zrtp.MANDATORY"));
    mandButton.setOpaque(false);

    final JButton saveButton = new JButton(resources.getI18NString("service.gui.SAVE"));
    saveButton.setOpaque(false);

    JPanel buttonBar = new TransparentPanel(new GridLayout(1, 7));
    buttonBar.add(stdButton);
    buttonBar.add(mandButton);
    buttonBar.add(Box.createHorizontalStrut(10));
    buttonBar.add(saveButton);

    ConfigurationService cfg = NeomediaActivator.getConfigurationService();
    boolean trusted = cfg.getBoolean(TRUSTED_PROP, false);
    boolean sasSign = cfg.getBoolean(SASSIGN_PROP, false);

    JPanel checkBar = new TransparentPanel(new GridLayout(1, 2));
    final JCheckBox trustedMitM =
        new SIPCommCheckBox(resources.getI18NString("impl.media.security.zrtp.TRUSTED"), trusted);
    final JCheckBox sasSignature =
        new SIPCommCheckBox(
            resources.getI18NString("impl.media.security.zrtp.SASSIGNATURE"), sasSign);
    checkBar.add(trustedMitM);
    checkBar.add(sasSignature);
    mainPanel.add(checkBar, BorderLayout.NORTH);

    ActionListener buttonListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            Object source = event.getSource();
            if (source == stdButton) {
              inActive.clear();
              active.setStandardConfig();
              pkc.setStandard();
              hc.setStandard();
              sc.setStandard();
              cc.setStandard();
              lc.setStandard();
            } else if (source == mandButton) {
              inActive.clear();
              active.setMandatoryOnly();
              pkc.setStandard();
              hc.setStandard();
              sc.setStandard();
              cc.setStandard();
              lc.setStandard();
            } else if (source == saveButton) {
              ConfigurationService cfg = NeomediaActivator.getConfigurationService();

              cfg.setProperty(TRUSTED_PROP, String.valueOf(active.isTrustedMitM()));
              cfg.setProperty(SASSIGN_PROP, String.valueOf(active.isSasSignature()));
              pkc.saveConfig();
              hc.saveConfig();
              sc.saveConfig();
              cc.saveConfig();
              lc.saveConfig();
            } else return;
          }
        };
    stdButton.addActionListener(buttonListener);
    mandButton.addActionListener(buttonListener);
    saveButton.addActionListener(buttonListener);

    ItemListener itemListener =
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Object source = e.getItemSelectable();

            if (source == trustedMitM) {
              active.setTrustedMitM(trustedMitM.isSelected());
            } else if (source == sasSignature) {
              active.setSasSignature(sasSignature.isSelected());
            }
          }
        };
    trustedMitM.addItemListener(itemListener);
    sasSignature.addItemListener(itemListener);

    JTabbedPane algorithmsPane = new SIPCommTabbedPane();

    algorithmsPane.addTab(resources.getI18NString("impl.media.security.zrtp.PUB_KEYS"), pkc);
    algorithmsPane.addTab(resources.getI18NString("impl.media.security.zrtp.HASHES"), hc);
    algorithmsPane.addTab(resources.getI18NString("impl.media.security.zrtp.SYM_CIPHERS"), cc);
    algorithmsPane.addTab(resources.getI18NString("impl.media.security.zrtp.SAS_TYPES"), sc);
    algorithmsPane.addTab(resources.getI18NString("impl.media.security.zrtp.SRTP_LENGTHS"), lc);

    algorithmsPane.setMinimumSize(new Dimension(400, 100));
    algorithmsPane.setPreferredSize(new Dimension(400, 200));
    mainPanel.add(algorithmsPane, BorderLayout.CENTER);

    mainPanel.add(buttonBar, BorderLayout.SOUTH);

    add(mainPanel);
  }