/** * Callback method to process modifications in the common ConfigOptions panel. ConfigOptions was * developed to be common to many applications (even though we only have three modes), so it does * not have any knowledge of how we are using it within this dialog box. So ConfigOptions just * sends updates to registered Observers whenever anything changes. We can receive those * notifications here, and decide whether we have enough information to enable the "Connect" * button of the dialog box. */ public void update(Observable o, Object arg) { // we are going to ignore the Observable object, since we are only // observing one object. All we are interested in is the argument. if (!(arg instanceof OptionUpdate)) { log.log( Level.WARNING, "DatabaseLocationDialog received update type: " + arg, new IllegalArgumentException()); return; } OptionUpdate optionUpdate = (OptionUpdate) arg; // load saved configuration SavedConfiguration config = SavedConfiguration.getSavedConfiguration(); switch (optionUpdate.getUpdateType()) { case DB_LOCATION_CHANGED: location = (String) optionUpdate.getPayload(); if (configOptions.getApplicationMode() == ApplicationMode.STANDALONE_CLIENT) { File f = new File(location); if (f.exists() && f.canRead() && f.canWrite()) { validDb = true; log.info("File chosen " + location); config.setParameter(SavedConfiguration.DATABASE_LOCATION, location); } else { log.warning("Invalid file " + location); } } else { try { if (location.matches("\\d+\\.\\d+\\.\\d+\\.\\d+")) { // location given matches 4 '.' separated numbers // regex could be improved by limiting each quad to // no more than 3 digits. String[] quads = location.split("\\."); byte[] address = new byte[quads.length]; for (int i = 0; i < quads.length; i++) { address[i] = new Integer(quads[i]).byteValue(); } InetAddress.getByAddress(address); } else { InetAddress.getAllByName(location); } log.info("Server specified " + location); validDb = true; config.setParameter(SavedConfiguration.SERVER_ADDRESS, location); } catch (UnknownHostException uhe) { log.warning("Unknown host: " + location); validDb = false; } } break; case PORT_CHANGED: port = (String) optionUpdate.getPayload(); int p = Integer.parseInt(port); if (p >= LOWEST_PORT && p < HIGHEST_PORT) { if (p < SYSTEM_PORT_BOUNDARY) { log.info("User chose System port " + port); } else if (p < IANA_PORT_BOUNDARY) { log.info("User chose IANA port " + port); } else { log.info("User chose dynamic port " + port); } validPort = true; config.setParameter(SavedConfiguration.SERVER_PORT, port); } else { validPort = false; } break; case NETWORK_CHOICE_MADE: networkType = (ConnectionType) optionUpdate.getPayload(); switch (networkType) { case SOCKET: log.info("Server connection via Sockets"); break; case RMI: log.info("Server connection via RMI"); break; default: log.info("Unknown connection type: " + networkType); break; } config.setParameter(SavedConfiguration.NETWORK_TYPE, "" + networkType); validCnx = true; break; default: log.warning("Unknown update: " + optionUpdate); break; } boolean allValid = validDb && validPort && validCnx; connectButton.setEnabled(allValid); }
/** * 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); // } }