/** * Initializes the service implementation, and puts it in a sate where it could interoperate with * other services. It is strongly recomended that properties in this Map be mapped to property * names as specified by <tt>AccountProperties</tt>. * * @param userID the user id of the ssh account we're currently initializing * @param accountID the identifier of the account that this protocol provider represents. * @see net.java.sip.communicator.service.protocol.AccountID */ protected void initialize(String userID, AccountID accountID) { synchronized (initializationLock) { this.accountID = accountID; // initialize the presence operationset OperationSetPersistentPresenceSSHImpl persistentPresence = new OperationSetPersistentPresenceSSHImpl(this); supportedOperationSets.put( OperationSetPersistentPresence.class.getName(), persistentPresence); // register it once again for those that simply need presence and // won't be smart enough to check for a persistent presence // alternative supportedOperationSets.put(OperationSetPresence.class.getName(), persistentPresence); // initialize the IM operation set basicInstantMessaging = new OperationSetBasicInstantMessagingSSHImpl(this); supportedOperationSets.put( OperationSetBasicInstantMessaging.class.getName(), basicInstantMessaging); // initialze the file transfer operation set fileTranfer = new OperationSetFileTransferSSHImpl(this); supportedOperationSets.put(OperationSetFileTransfer.class.getName(), fileTranfer); isInitialized = true; } }
static { iconsTable.put( ProtocolIcon.ICON_SIZE_16x16, getImageInBytes("service.protocol.yahoo.YAHOO_16x16")); iconsTable.put( ProtocolIcon.ICON_SIZE_32x32, getImageInBytes("service.protocol.yahoo.YAHOO_32x32")); iconsTable.put( ProtocolIcon.ICON_SIZE_48x48, getImageInBytes("service.protocol.yahoo.YAHOO_48x48")); iconsTable.put( ProtocolIcon.ICON_SIZE_64x64, getImageInBytes("service.protocol.yahoo.YAHOO_64x64")); }
/** * Initializes and creates an account corresponding to the specified accountProperties and * registers the resulting ProtocolProvider in the <tt>context</tt> BundleContext parameter. * * @param accountProperties a set of protocol (or implementation) specific properties defining the * new account. * @return the AccountID of the newly created account */ protected AccountID loadAccount(Map accountProperties) { BundleContext context = SipActivator.getBundleContext(); if (context == null) throw new NullPointerException("The specified BundleContext was null"); String userIDStr = (String) accountProperties.get(USER_ID); if (userIDStr == null) throw new NullPointerException("The account properties contained no user id."); if (accountProperties == null) throw new NullPointerException("The specified property map was null"); String serverAddress = (String) accountProperties.get(SERVER_ADDRESS); if (serverAddress == null) throw new NullPointerException(serverAddress + " is not a valid ServerAddress"); if (!accountProperties.containsKey(PROTOCOL)) accountProperties.put(PROTOCOL, ProtocolNames.SIP); SipAccountID accountID = new SipAccountID(userIDStr, accountProperties, serverAddress); // get a reference to the configuration service and register whatever // properties we have in it. Hashtable properties = new Hashtable(); properties.put(PROTOCOL, ProtocolNames.SIP); properties.put(USER_ID, userIDStr); ProtocolProviderServiceSipImpl sipProtocolProvider = new ProtocolProviderServiceSipImpl(); try { sipProtocolProvider.initialize(userIDStr, accountID); // We store again the account in order to store all properties added // during the protocol provider initialization. this.storeAccount(SipActivator.getBundleContext(), accountID); } catch (OperationFailedException ex) { logger.error("Failed to initialize account", ex); throw new IllegalArgumentException("Failed to initialize account" + ex.getMessage()); } ServiceRegistration registration = context.registerService( ProtocolProviderService.class.getName(), sipProtocolProvider, properties); registeredAccounts.put(accountID, registration); return accountID; }
/** * Returns the set of data that user has entered through this wizard. * * @return Iterator */ public Iterator<Map.Entry<String, String>> getSummary() { Hashtable<String, String> summaryTable = new Hashtable<String, String>(); /* * Hashtable arranges the entries alphabetically so the order * of appearance is * - Computer Name / IP * - Port * - User ID */ summaryTable.put("Account ID", registration.getAccountID()); summaryTable.put("Known Hosts", registration.getKnownHostsFile()); summaryTable.put("Identity", registration.getIdentityFile()); return summaryTable.entrySet().iterator(); }
/** * Implements CallListener.incomingCallReceived. When a call is received creates a call panel and * adds it to the main tabbed pane and plays the ring phone sound to the user. */ public void incomingCallReceived(CallEvent event) { Call sourceCall = event.getSourceCall(); CallPanel callPanel = new CallPanel(this, sourceCall, GuiCallParticipantRecord.INCOMING_CALL); mainFrame.addCallPanel(callPanel); if (mainFrame.getState() == JFrame.ICONIFIED) mainFrame.setState(JFrame.NORMAL); if (!mainFrame.isVisible()) mainFrame.setVisible(true); mainFrame.toFront(); this.callButton.setEnabled(true); this.hangupButton.setEnabled(true); NotificationManager.fireNotification( NotificationManager.INCOMING_CALL, null, "Incoming call recived from: " + sourceCall.getCallParticipants().next()); activeCalls.put(sourceCall, callPanel); this.setCallPanelVisible(true); }
static { iconPathsTable.put( ProtocolIcon.ICON_SIZE_16x16, getResources().getImagePath("service.protocol.gibberish.GIBBERISH_16x16")); iconPathsTable.put( ProtocolIcon.ICON_SIZE_32x32, getResources().getImagePath("service.protocol.gibberish.GIBBERISH_32x32")); iconPathsTable.put( ProtocolIcon.ICON_SIZE_48x48, getResources().getImagePath("service.protocol.gibberish.GIBBERISH_48x48")); iconPathsTable.put( ProtocolIcon.ICON_SIZE_64x64, getResources().getImagePath("service.protocol.gibberish.GIBBERISH_64x64")); }
static { iconsTable.put( ProtocolIcon.ICON_SIZE_16x16, getImageInBytes("service.protocol.gibberish.GIBBERISH_16x16")); iconsTable.put( ProtocolIcon.ICON_SIZE_32x32, getImageInBytes("service.protocol.gibberish.GIBBERISH_32x32")); iconsTable.put( ProtocolIcon.ICON_SIZE_48x48, getImageInBytes("service.protocol.gibberish.GIBBERISH_48x48")); iconsTable.put( ProtocolIcon.ICON_SIZE_64x64, getImageInBytes("service.protocol.gibberish.GIBBERISH_64x64")); }
static { iconPathsTable.put( ProtocolIcon.ICON_SIZE_16x16, getResources().getImagePath("service.protocol.yahoo.YAHOO_16x16")); iconPathsTable.put( ProtocolIcon.ICON_SIZE_32x32, getResources().getImagePath("service.protocol.yahoo.YAHOO_32x32")); iconPathsTable.put( ProtocolIcon.ICON_SIZE_48x48, getResources().getImagePath("service.protocol.yahoo.YAHOO_48x48")); iconPathsTable.put( ProtocolIcon.ICON_SIZE_64x64, getResources().getImagePath("service.protocol.yahoo.YAHOO_64x64")); }
/** * Returns all properties necessary for the intialization of the account with * <tt>accountPrefix</tt>. * * @param accountPrefix the prefix contained by all property names for the the account we'd like * to initialized * @return a Hashtable that can be used when creating the account in a protocol provider factory. */ private Hashtable<String, String> getAccountProperties(String accountPrefix) { Hashtable<String, String> table = new Hashtable<String, String>(); String userID = System.getProperty(accountPrefix + ProtocolProviderFactory.USER_ID, null); assertNotNull( "The system property named " + accountPrefix + ProtocolProviderFactory.USER_ID + " has to tontain a valid Jabber address that could be used during " + "SIP Communicator's tests.", userID); table.put(ProtocolProviderFactory.USER_ID, userID); String passwd = System.getProperty(accountPrefix + ProtocolProviderFactory.PASSWORD, null); assertNotNull( "The system property named " + accountPrefix + ProtocolProviderFactory.PASSWORD + " has to contain the password corresponding to the account " + "specified in " + accountPrefix + ProtocolProviderFactory.USER_ID, passwd); table.put(ProtocolProviderFactory.PASSWORD, passwd); String serverAddress = System.getProperty(accountPrefix + ProtocolProviderFactory.SERVER_ADDRESS, null); // optional if (serverAddress != null) table.put(ProtocolProviderFactory.SERVER_ADDRESS, serverAddress); String serverPort = System.getProperty(accountPrefix + ProtocolProviderFactory.SERVER_PORT, null); // optional if (serverPort != null) table.put(ProtocolProviderFactory.SERVER_PORT, serverPort); return table; }
/** * Returns the set of data that user has entered through this wizard. * * @return Iterator */ @Override public Iterator<Map.Entry<String, String>> getSummary() { Hashtable<String, String> summaryTable = new Hashtable<String, String>(); summaryTable.put( Resources.getString("plugin.jabberaccregwizz.USERNAME"), registration.getUserID()); summaryTable.put( Resources.getString("service.gui.REMEMBER_PASSWORD"), Boolean.toString(registration.isRememberPassword())); summaryTable.put( Resources.getString("plugin.jabberaccregwizz.SERVER"), registration.getServerAddress()); summaryTable.put( Resources.getString("service.gui.PORT"), String.valueOf(registration.getServerPort())); summaryTable.put( Resources.getString("plugin.jabberaccregwizz.ENABLE_KEEP_ALIVE"), String.valueOf(registration.isSendKeepAlive())); summaryTable.put( Resources.getString("plugin.jabberaccregwizz.ENABLE_GMAIL_NOTIFICATIONS"), String.valueOf(registration.isGmailNotificationEnabled())); summaryTable.put( Resources.getString("plugin.jabberaccregwizz.RESOURCE"), registration.getResource()); summaryTable.put( Resources.getString("plugin.jabberaccregwizz.PRIORITY"), String.valueOf(registration.getPriority())); summaryTable.put( Resources.getString("plugin.sipaccregwizz.DTMF_METHOD"), registration.getDTMFMethod()); summaryTable.put( Resources.getString("plugin.sipaccregwizz.DTMF_MINIMAL_TONE_DURATION"), registration.getDtmfMinimalToneDuration()); return summaryTable.entrySet().iterator(); }
/** * Creates an account for the given user and password. * * @param providerFactory the ProtocolProviderFactory which will create the account * @param user the user identifier * @return the <tt>ProtocolProviderService</tt> for the new account. */ public ProtocolProviderService installAccount( ProtocolProviderFactory providerFactory, String user) throws OperationFailedException { Hashtable<String, String> accountProperties = new Hashtable<String, String>(); accountProperties.put( ProtocolProviderFactory.ACCOUNT_ICON_PATH, "resources/images/protocol/gibberish/gibberish32x32.png"); if (registration.isRememberPassword()) { accountProperties.put(ProtocolProviderFactory.PASSWORD, registration.getPassword()); } if (isModification()) { providerFactory.uninstallAccount(protocolProvider.getAccountID()); this.protocolProvider = null; setModification(false); } try { AccountID accountID = providerFactory.installAccount(user, accountProperties); ServiceReference serRef = providerFactory.getProviderForAccount(accountID); protocolProvider = (ProtocolProviderService) GibberishAccRegWizzActivator.bundleContext.getService(serRef); } catch (IllegalStateException exc) { logger.warn(exc.getMessage()); throw new OperationFailedException( "Account already exists.", OperationFailedException.IDENTIFICATION_CONFLICT); } catch (Exception exc) { logger.warn(exc.getMessage()); throw new OperationFailedException( "Failed to add account", OperationFailedException.GENERAL_ERROR); } return protocolProvider; }
/** * Creates an account for the given Account ID, Identity File and Known Hosts File * * @param providerFactory the ProtocolProviderFactory which will create the account * @param user the user identifier * @return the <tt>ProtocolProviderService</tt> for the new account. */ public ProtocolProviderService installAccount( ProtocolProviderFactory providerFactory, String user) throws OperationFailedException { Hashtable<String, String> accountProperties = new Hashtable<String, String>(); accountProperties.put( ProtocolProviderFactory.ACCOUNT_ICON_PATH, "resources/images/protocol/ssh/ssh32x32.png"); accountProperties.put( ProtocolProviderFactory.NO_PASSWORD_REQUIRED, new Boolean(true).toString()); accountProperties.put( ProtocolProviderFactorySSHImpl.IDENTITY_FILE, registration.getIdentityFile()); accountProperties.put( ProtocolProviderFactorySSHImpl.KNOWN_HOSTS_FILE, String.valueOf(registration.getKnownHostsFile())); try { AccountID accountID = providerFactory.installAccount(user, accountProperties); ServiceReference serRef = providerFactory.getProviderForAccount(accountID); protocolProvider = (ProtocolProviderService) SSHAccRegWizzActivator.bundleContext.getService(serRef); } catch (IllegalStateException exc) { logger.warn(exc.getMessage()); throw new OperationFailedException( "Account already exists.", OperationFailedException.IDENTIFICATION_CONFLICT); } catch (Exception exc) { logger.warn(exc.getMessage()); throw new OperationFailedException( "Failed to add account", OperationFailedException.GENERAL_ERROR); } return protocolProvider; }
/** * Creates an account for the given user and password. * * @param providerFactory the ProtocolProviderFactory which will create the account * @param userName the user identifier * @param passwd the password * @return the <tt>ProtocolProviderService</tt> for the new account. * @throws OperationFailedException if the operation didn't succeed */ protected ProtocolProviderService installAccount( ProtocolProviderFactory providerFactory, String userName, String passwd) throws OperationFailedException { if (logger.isTraceEnabled()) { logger.trace("Preparing to install account for user " + userName); } Hashtable<String, String> accountProperties = new Hashtable<String, String>(); String protocolIconPath = getProtocolIconPath(); String accountIconPath = getAccountIconPath(); registration.storeProperties( userName, passwd, protocolIconPath, accountIconPath, accountProperties); accountProperties.put( ProtocolProviderFactory.IS_PREFERRED_PROTOCOL, Boolean.toString(isPreferredProtocol())); accountProperties.put(ProtocolProviderFactory.PROTOCOL, getProtocol()); if (isModification()) { providerFactory.modifyAccount(protocolProvider, accountProperties); setModification(false); return protocolProvider; } try { if (logger.isTraceEnabled()) { logger.trace( "Will install account for user " + userName + " with the following properties." + accountProperties); } AccountID accountID = providerFactory.installAccount(userName, accountProperties); ServiceReference serRef = providerFactory.getProviderForAccount(accountID); protocolProvider = (ProtocolProviderService) JabberAccRegWizzActivator.bundleContext.getService(serRef); } catch (IllegalArgumentException exc) { logger.warn(exc.getMessage()); throw new OperationFailedException( "Username, password or server is null.", OperationFailedException.ILLEGAL_ARGUMENT); } catch (IllegalStateException exc) { logger.warn(exc.getMessage()); throw new OperationFailedException( "Account already exists.", OperationFailedException.IDENTIFICATION_CONFLICT); } catch (Throwable exc) { logger.warn(exc.getMessage()); throw new OperationFailedException( "Failed to add account.", OperationFailedException.GENERAL_ERROR); } return protocolProvider; }
/** Loads the configuration form obtained from the chat room. */ protected void loadConfigurationForm() { Iterator<ChatRoomConfigurationFormField> configurationSet = configForm.getConfigurationSet(); while (configurationSet.hasNext()) { ChatRoomConfigurationFormField formField = configurationSet.next(); Iterator<?> values = formField.getValues(); Iterator<String> options = formField.getOptions(); JComponent field; JLabel label = new JLabel("", JLabel.RIGHT); if (formField.getLabel() != null) label.setText(formField.getLabel() + ": "); String fieldType = formField.getType(); if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_BOOLEAN)) { // Create a check box when the field is of type boolean. field = new SIPCommCheckBox(formField.getLabel()); label.setText(""); if (values.hasNext()) { ((JCheckBox) field).setSelected((Boolean) values.next()); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_FIXED)) { field = new JLabel(); if (values.hasNext()) { String value = values.next().toString(); ((JLabel) field).setText(value); field.setFont(new Font(null, Font.ITALIC, 10)); field.setForeground(Color.GRAY); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_LIST_MULTI)) { field = new TransparentPanel(new GridLayout(0, 1)); field.setBorder(BorderFactory.createLineBorder(Color.GRAY)); Hashtable<Object, JCheckBox> optionCheckBoxes = new Hashtable<Object, JCheckBox>(); while (options.hasNext()) { Object option = options.next(); JCheckBox checkBox = new SIPCommCheckBox(option.toString()); field.add(checkBox); optionCheckBoxes.put(option, checkBox); } while (values.hasNext()) { Object value = values.next(); (optionCheckBoxes.get(value)).setSelected(true); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_LIST_SINGLE)) { field = new JComboBox(); while (options.hasNext()) { ((JComboBox) field).addItem(options.next()); } if (values.hasNext()) { ((JComboBox) field).setSelectedItem(values.next()); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_MULTI)) { field = new JEditorPane(); if (values.hasNext()) { String value = values.next().toString(); ((JEditorPane) field).setText(value); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_SINGLE) || fieldType.equals(ChatRoomConfigurationFormField.TYPE_ID_SINGLE)) { field = new JTextField(); if (values.hasNext()) { String value = values.next().toString(); ((JTextField) field).setText(value); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_PRIVATE)) { field = new JPasswordField(); if (values.hasNext()) { String value = values.next().toString(); ((JPasswordField) field).setText(value); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_ID_MULTI)) { StringBuffer buff = new StringBuffer(); while (values.hasNext()) { String value = values.next().toString(); buff.append(value); if (values.hasNext()) buff.append(System.getProperty("line.separator")); } field = new JTextArea(buff.toString()); } else { if (label.getText() == null) continue; field = new JTextField(); if (values.hasNext()) { String value = values.next().toString(); ((JTextField) field).setText(value); } } // If the field is not fixed (i.e. could be changed) we would like // to save it in a list in order to use it later when user saves // the configuration data. if (!fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_FIXED)) { uiFieldsTable.put(formField.getName(), field); } JPanel fieldPanel = new TransparentPanel(new GridLayout(1, 2)); fieldPanel.setOpaque(false); if (!(field instanceof JLabel)) fieldPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0)); else fieldPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 1, 0)); fieldPanel.add(label); fieldPanel.add(field); this.mainPanel.add(fieldPanel); } }