Preconfigured account wizard for iptel.org

cusax-fix
Yana Stamcheva 16 years ago
parent 8b70bbd675
commit 3b2f176284

@ -850,7 +850,7 @@
bundle-argdelegation,bundle-zrtp4j,
bundle-filehistory,bundle-metahistory,bundle-metahistory-slick,
bundle-facebook,bundle-plugin-facebookaccregwizz,
bundle-bouncycastle,bundle-plugin-otr"/>
bundle-bouncycastle,bundle-plugin-otr,bundle-plugin-iptelaccregwizz"/>
<!--BUNDLE-SC-LAUNCHER-->
<target name="bundle-sc-launcher">
@ -1559,6 +1559,16 @@ javax.swing.event, javax.swing.border"/>
</jar>
</target>
<!-- BUNDLE-PLUGIN-IPTELACCREGWIZZ -->
<target name="bundle-plugin-iptelaccregwizz">
<!-- Creates a bundle for the plugin IP Tel Account Registration Wizard.-->
<jar compress="false" destfile="${bundles.dest}/iptelaccregwizz.jar"
manifest="${src}/net/java/sip/communicator/plugin/iptelaccregwizz/iptelaccregwizz.manifest.mf">
<zipfileset dir="${dest}/net/java/sip/communicator/plugin/iptelaccregwizz"
prefix="net/java/sip/communicator/plugin/iptelaccregwizz"/>
</jar>
</target>
<!-- BUNDLE-PLUGIN-GIBBERISHACCREGWIZZ -->
<target name="bundle-plugin-gibberishaccregwizz">
<!-- Creates a bundle for the plugin Gibberish Account Registration
@ -2227,6 +2237,6 @@ org.apache.http.util"/>
<zipfileset dir="${dest}/net/java/sip/communicator/slick/metahistory"
prefix="net/java/sip/communicator/slick/metahistory"/>
</jar>
</target>
</target>
</project>

@ -147,6 +147,7 @@ felix.auto.start.67= \
reference:file:sc-bundles/icqaccregwizz.jar \
reference:file:sc-bundles/aimaccregwizz.jar \
reference:file:sc-bundles/sipaccregwizz.jar \
reference:file:sc-bundles/iptelaccregwizz.jar \
reference:file:sc-bundles/jabberaccregwizz.jar \
reference:file:sc-bundles/googletalkaccregwizz.jar \
reference:file:sc-bundles/msnaccregwizz.jar \

@ -339,6 +339,10 @@ service.protocol.jabber.JABBER_64x64=resources/images/protocol/jabber/logo48x48.
service.protocol.googletalk.GTALK_16x16=resources/images/protocol/googletalk/status16x16-online.png
service.protocol.googletalk.GTALK_64x64=resources/images/protocol/googletalk/logo48x48.png
# iptel accregwizz
service.protocol.iptel.IPTEL_16x16=resources/images/protocol/iptel/sip16x16.png
service.protocol.iptel.IPTEL_64x64=resources/images/protocol/iptel/sip64x64.png
# facebook accregwizz
service.protocol.facebook.FACEBOOK_16x16=resources/images/protocol/facebook/facebook-online.png
service.protocol.facebook.FACEBOOK_32x32=resources/images/protocol/facebook/facebook32.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 815 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 801 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 447 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

@ -762,6 +762,12 @@ plugin.googletalkaccregwizz.USERNAME=Google Talk username
plugin.googletalkaccregwizz.REGISTER_NEW_ACCOUNT_TEXT=In case you don't have a Google Talk account, click on this button to create a new one.
plugin.googletalkaccregwizz.NEW_ACCOUNT_TITLE=Google Talk new account registration
# iptel accregwizz
plugin.iptelaccregwizz.PROTOCOL_NAME=iptel.org
plugin.iptelaccregwizz.PROTOCOL_DESCRIPTION=iptel.org, the IP Telecommunications Portal
plugin.iptelaccregwizz.USERNAME=Username
plugin.iptelaccregwizz.NEW_ACCOUNT_TITLE=Subscribe to iptel.org
# key binding chooser
plugin.keybindings.CHAT_CLOSE=Close Chat Window
plugin.keybindings.CHAT_COPY=Copy

@ -186,7 +186,7 @@ private void initNetworkList()
public int compare(AccountRegistrationWizard arg0,
AccountRegistrationWizard arg1)
{
return arg0.getProtocolName().compareTo(
return arg0.getProtocolName().compareToIgnoreCase(
arg1.getProtocolName());
}
});

@ -0,0 +1,734 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license. See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.iptelaccregwizz;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.swing.*;
/**
* The <tt>FirstWizardPage</tt> is the page, where user could enter the uin
* and the password of the account.
*
* @author Yana Stamcheva
*/
@SuppressWarnings("serial")
public class FirstWizardPage
extends TransparentPanel
implements WizardPage, DocumentListener, ItemListener
{
private static final Logger logger
= Logger.getLogger(FirstWizardPage.class);
/**
* The identifier of this wizard page.
*/
public static final String FIRST_PAGE_IDENTIFIER = "FirstPageIdentifier";
/**
* The example text that guides the user for the format of the username.
*/
public static final String USER_NAME_EXAMPLE
= "Ex: myusername or myusername@iptel.org";
private JPanel firstTabPanel = new TransparentPanel(new BorderLayout());
private JPanel uinPassPanel = new TransparentPanel(new BorderLayout(10, 10));
private JPanel labelsPanel = new TransparentPanel();
private JPanel valuesPanel = new TransparentPanel();
private JLabel uinLabel
= new JLabel(Resources.getString("plugin.iptelaccregwizz.USERNAME"));
private JLabel passLabel
= new JLabel(Resources.getString("service.gui.PASSWORD"));
private JPanel emptyPanel = new TransparentPanel();
private JLabel uinExampleLabel = new JLabel(USER_NAME_EXAMPLE);
private JTextField userIDField = new JTextField();
private JPasswordField passField = new JPasswordField();
private JCheckBox rememberPassBox =
new SIPCommCheckBox(
Resources.getString("service.gui.REMEMBER_PASSWORD"));
private JPanel advancedOpPanel
= new TransparentPanel(new BorderLayout(10, 10));
private JPanel labelsAdvOpPanel
= new TransparentPanel(new GridLayout(0, 1, 10, 10));
private JPanel valuesAdvOpPanel
= new TransparentPanel(new GridLayout(0, 1, 10, 10));
private JLabel serverLabel
= new JLabel(Resources.getString("plugin.sipaccregwizz.REGISTRAR"));
private JCheckBox enableDefaultEncryption =
new SIPCommCheckBox(Resources
.getString("plugin.sipaccregwizz.ENABLE_DEFAULT_ENCRYPTION"), true);
private JCheckBox enableSipZrtpAttribute =
new SIPCommCheckBox(Resources
.getString("plugin.sipaccregwizz.ENABLE_SIPZRTP_ATTRIBUTE"), true);
private JLabel proxyLabel
= new JLabel(Resources.getString("plugin.sipaccregwizz.PROXY"));
private JLabel authNameLabel =
new JLabel(Resources.getString("plugin.sipaccregwizz.AUTH_NAME"));
private JLabel serverPortLabel =
new JLabel(Resources.getString("plugin.sipaccregwizz.SERVER_PORT"));
private JLabel proxyPortLabel =
new JLabel(Resources.getString("plugin.sipaccregwizz.PROXY_PORT"));
private JLabel transportLabel =
new JLabel(Resources.getString(
"plugin.sipaccregwizz.PREFERRED_TRANSPORT"));
private JTextField serverField = new JTextField();
private JTextField proxyField = new JTextField();
private JTextField authNameField = new JTextField();
private JTextField serverPortField
= new JTextField(IptelAccountRegistration.DEFAULT_PORT);
private JTextField proxyPortField
= new JTextField(IptelAccountRegistration.DEFAULT_PORT);
private JComboBox transportCombo = new JComboBox(new Object[]
{ "UDP", "TCP", "TLS" });
private JPanel presenceOpPanel
= new TransparentPanel(new BorderLayout(10, 10));
private JPanel buttonsPresOpPanel
= new TransparentPanel(new GridLayout(0, 1, 10, 10));
private JPanel labelsPresOpPanel
= new TransparentPanel(new GridLayout(0, 1, 10, 10));
private JPanel valuesPresOpPanel
= new TransparentPanel(new GridLayout(0, 1, 10, 10));
private JCheckBox enablePresOpButton =
new SIPCommCheckBox(Resources
.getString("plugin.sipaccregwizz.ENABLE_PRESENCE"), true);
private JCheckBox forceP2PPresOpButton =
new SIPCommCheckBox(Resources
.getString("plugin.sipaccregwizz.FORCE_P2P_PRESENCE"), true);
private JLabel pollPeriodLabel = new JLabel(
Resources.getString(
"plugin.sipaccregwizz.OFFLINE_CONTACT_POLLING_PERIOD"));
private JLabel subscribeExpiresLabel = new JLabel(
Resources.getString("plugin.sipaccregwizz.SUBSCRIPTION_EXPIRATION"));
private JTextField pollPeriodField
= new JTextField(IptelAccountRegistration.DEFAULT_POLL_PERIOD);
private JTextField subscribeExpiresField =
new JTextField(IptelAccountRegistration.DEFAULT_SUBSCRIBE_EXPIRES);
private JPanel keepAlivePanel
= new TransparentPanel(new BorderLayout(10, 10));
private JPanel keepAliveLabels
= new TransparentPanel(new GridLayout(0, 1, 5, 5));
private JPanel keepAliveValues
= new TransparentPanel(new GridLayout(0, 1, 5, 5));
private JLabel keepAliveMethodLabel = new JLabel(
Resources.getString("plugin.sipaccregwizz.KEEP_ALIVE_METHOD"));
private JLabel keepAliveIntervalLabel = new JLabel(
Resources.getString("plugin.sipaccregwizz.KEEP_ALIVE_INTERVAL"));
private JLabel keepAliveIntervalExampleLabel = new JLabel(
Resources.getString("plugin.sipaccregwizz.KEEP_ALIVE_INTERVAL_INFO"));
private JComboBox keepAliveMethodBox
= new JComboBox(new Object []
{
"REGISTER",
"OPTIONS"
});
private JTextField keepAliveIntervalValue = new JTextField();
private JTabbedPane tabbedPane = new SIPCommTabbedPane(false, false);
private JPanel advancedPanel = new TransparentPanel();
private Object nextPageIdentifier = WizardPage.SUMMARY_PAGE_IDENTIFIER;
private IptelAccountRegistrationWizard wizard;
private boolean isCommitted = false;
private boolean isServerOverridden = false;
/**
* Creates an instance of <tt>FirstWizardPage</tt>.
*
* @param wizard the parent wizard
*/
public FirstWizardPage(IptelAccountRegistrationWizard wizard)
{
super(new BorderLayout());
this.wizard = wizard;
advancedPanel.setLayout(new BoxLayout(advancedPanel, BoxLayout.Y_AXIS));
this.init();
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
this.labelsPanel
.setLayout(new BoxLayout(labelsPanel, BoxLayout.Y_AXIS));
this.valuesPanel
.setLayout(new BoxLayout(valuesPanel, BoxLayout.Y_AXIS));
}
/**
* Initializes all panels, buttons, etc.
*/
private void init()
{
this.labelsPanel.setOpaque(false);
this.valuesPanel.setOpaque(false);
this.uinPassPanel.setOpaque(false);
this.emptyPanel.setOpaque(false);
this.userIDField.getDocument().addDocumentListener(this);
this.transportCombo.addItemListener(this);
this.rememberPassBox.setSelected(true);
this.uinExampleLabel.setForeground(Color.GRAY);
this.uinExampleLabel.setFont(uinExampleLabel.getFont().deriveFont(8));
this.emptyPanel.setMaximumSize(new Dimension(40, 35));
this.uinExampleLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8,
0));
labelsPanel.add(uinLabel);
labelsPanel.add(emptyPanel);
labelsPanel.add(passLabel);
valuesPanel.add(userIDField);
valuesPanel.add(uinExampleLabel);
valuesPanel.add(passField);
uinPassPanel.add(labelsPanel, BorderLayout.WEST);
uinPassPanel.add(valuesPanel, BorderLayout.CENTER);
TransparentPanel southPanel
= new TransparentPanel(new GridLayout(1, 2));
southPanel.add(rememberPassBox);
southPanel.add(createSubscribeLabel());
uinPassPanel.add(southPanel, BorderLayout.SOUTH);
uinPassPanel.setBorder(BorderFactory.createTitledBorder(Resources
.getString("plugin.sipaccregwizz.USERNAME_AND_PASSWORD")));
firstTabPanel.add(uinPassPanel, BorderLayout.NORTH);
tabbedPane.addTab( Resources.getString("service.gui.SUMMARY"),
firstTabPanel);
transportCombo
.setSelectedItem(IptelAccountRegistration.DEFAULT_TRANSPORT);
labelsAdvOpPanel.add(serverLabel);
labelsAdvOpPanel.add(authNameLabel);
labelsAdvOpPanel.add(serverPortLabel);
labelsAdvOpPanel.add(proxyLabel);
labelsAdvOpPanel.add(proxyPortLabel);
labelsAdvOpPanel.add(transportLabel);
valuesAdvOpPanel.add(serverField);
valuesAdvOpPanel.add(authNameField);
valuesAdvOpPanel.add(serverPortField);
valuesAdvOpPanel.add(proxyField);
valuesAdvOpPanel.add(proxyPortField);
valuesAdvOpPanel.add(transportCombo);
advancedOpPanel.add(labelsAdvOpPanel, BorderLayout.WEST);
advancedOpPanel.add(valuesAdvOpPanel, BorderLayout.CENTER);
JPanel encryptionPanel = new TransparentPanel(new GridLayout(1, 2, 2, 2));
encryptionPanel.add(enableDefaultEncryption, BorderLayout.WEST);
encryptionPanel.add(enableSipZrtpAttribute, BorderLayout.EAST);
enableDefaultEncryption.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
// Perform action
JCheckBox cb = (JCheckBox) evt.getSource();
enableSipZrtpAttribute.setEnabled(cb.isSelected());
}
});
advancedOpPanel.add(encryptionPanel, BorderLayout.SOUTH);
advancedOpPanel.setBorder(BorderFactory.createTitledBorder(Resources
.getString("plugin.aimaccregwizz.ADVANCED_OPTIONS")));
advancedPanel.add(advancedOpPanel);
enablePresOpButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
// Perform action
JCheckBox cb = (JCheckBox) evt.getSource();
setPresenceOptionsEnabled(cb.isSelected());
}
});
labelsPresOpPanel.add(pollPeriodLabel);
labelsPresOpPanel.add(subscribeExpiresLabel);
valuesPresOpPanel.add(pollPeriodField);
valuesPresOpPanel.add(subscribeExpiresField);
buttonsPresOpPanel.add(enablePresOpButton);
buttonsPresOpPanel.add(forceP2PPresOpButton);
presenceOpPanel.add(buttonsPresOpPanel, BorderLayout.NORTH);
presenceOpPanel.add(labelsPresOpPanel, BorderLayout.WEST);
presenceOpPanel.add(valuesPresOpPanel, BorderLayout.CENTER);
presenceOpPanel.setBorder(BorderFactory.createTitledBorder(
Resources.getString("plugin.sipaccregwizz.PRESENCE_OPTIONS")));
advancedPanel.add(presenceOpPanel);
JPanel emptyLabelPanel = new TransparentPanel();
emptyLabelPanel.setMaximumSize(new Dimension(40, 35));
keepAliveLabels.add(keepAliveMethodLabel);
keepAliveLabels.add(keepAliveIntervalLabel);
keepAliveLabels.add(emptyLabelPanel);
this.keepAliveIntervalExampleLabel.setForeground(Color.GRAY);
this.keepAliveIntervalExampleLabel
.setFont(uinExampleLabel.getFont().deriveFont(8));
this.keepAliveIntervalExampleLabel
.setMaximumSize(new Dimension(40, 35));
this.keepAliveIntervalExampleLabel
.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0));
keepAliveIntervalValue
.setText(IptelAccountRegistration.DEFAULT_KEEP_ALIVE_INTERVAL);
keepAliveMethodBox.setSelectedItem(
IptelAccountRegistration.DEFAULT_KEEP_ALIVE_METHOD);
keepAliveValues.add(keepAliveMethodBox);
keepAliveValues.add(keepAliveIntervalValue);
keepAliveValues.add(keepAliveIntervalExampleLabel);
keepAlivePanel.add(keepAliveLabels, BorderLayout.WEST);
keepAlivePanel.add(keepAliveValues, BorderLayout.CENTER);
keepAlivePanel.setBorder(BorderFactory.createTitledBorder(
Resources.getString("plugin.sipaccregwizz.KEEP_ALIVE")));
advancedPanel.add(keepAlivePanel);
tabbedPane.addTab(
Resources.getString("service.gui.ADVANCED"),
advancedPanel);
this.add(tabbedPane, BorderLayout.NORTH);
}
/**
* Creates the subscribe label.
* @return the newly created subscribe label
*/
private Component createSubscribeLabel()
{
JLabel subscribeLabel =
new JLabel("<html><a href=''>"
+ Resources.getString("plugin.iptelaccregwizz.NEW_ACCOUNT_TITLE")
+ "</a></html>",
JLabel.RIGHT);
subscribeLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
subscribeLabel.setToolTipText(
Resources.getString("plugin.simpleaccregwizz.SPECIAL_SIGNUP"));
subscribeLabel.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
try
{
wizard.webSignup();
}
catch (UnsupportedOperationException ex)
{
// This should not happen, because we check if the
// operation is supported, before adding the sign
// up.
logger.error("The web sign up is not supported.",
ex);
}
}
});
return subscribeLabel;
}
/**
* Implements the <code>WizardPage.getIdentifier</code> to return this
* page identifier.
* @return the identifier of this page
*/
public Object getIdentifier()
{
return FIRST_PAGE_IDENTIFIER;
}
/**
* Implements the <code>WizardPage.getNextPageIdentifier</code> to return
* the next page identifier - the summary page.
* @return the next page identifier
*/
public Object getNextPageIdentifier()
{
return nextPageIdentifier;
}
/**
* Implements the <code>WizardPage.getBackPageIdentifier</code> to return
* the next back identifier - the default page.
* @return the back page identifier
*/
public Object getBackPageIdentifier()
{
return WizardPage.DEFAULT_PAGE_IDENTIFIER;
}
/**
* Implements the <code>WizardPage.getWizardForm</code> to return this
* panel.
* @return the wizard form
*/
public Object getWizardForm()
{
return this;
}
/**
* Before this page is displayed enables or disables the "Next" wizard
* button according to whether the UIN field is empty.
*/
public void pageShowing()
{
this.setNextButtonAccordingToUIN();
wizard.getWizardContainer().setBackButtonEnabled(false);
}
/**
* Saves the user input when the "Next" wizard buttons is clicked.
*/
public void commitPage()
{
String uin = userIDField.getText();
int indexOfSeparator = uin.indexOf('@');
if (indexOfSeparator > -1) {
uin = uin.substring(0, indexOfSeparator);
}
IptelAccountRegistration registration = wizard.getRegistration();
String userID = userIDField.getText();
if(userID == null || userID.trim().length() == 0)
throw new IllegalStateException("No user ID provided.");
registration.setUserID(userID);
if (passField.getPassword() != null)
registration.setPassword(new String(passField.getPassword()));
registration.setRememberPassword(rememberPassBox.isSelected());
if (serverField.getText() != null && serverField.getText().length() > 0)
registration.setServerAddress(serverField.getText());
String authName = authNameField.getText();
if(authName != null && authName.length() > 0)
registration.setAuthorizationName(authName);
registration.setServerPort(serverPortField.getText());
registration.setProxy(proxyField.getText());
registration.setProxyPort(proxyPortField.getText());
registration.setPreferredTransport(transportCombo.getSelectedItem()
.toString());
registration.setEnablePresence(enablePresOpButton.isSelected());
registration.setForceP2PMode(forceP2PPresOpButton.isSelected());
registration.setDefaultEncryption(enableDefaultEncryption.isSelected());
registration.setSipZrtpAttribute(enableSipZrtpAttribute.isSelected());
registration.setPollingPeriod(pollPeriodField.getText());
registration.setSubscriptionExpiration(subscribeExpiresField
.getText());
registration.setKeepAliveMethod(
keepAliveMethodBox.getSelectedItem().toString());
registration.setKeepAliveInterval(keepAliveIntervalValue.getText());
wizard.getWizardContainer().setBackButtonEnabled(true);
nextPageIdentifier = SUMMARY_PAGE_IDENTIFIER;
this.isCommitted = true;
}
/**
* Enables or disables the "Next" wizard button according to whether the UIN
* field is empty.
*/
private void setNextButtonAccordingToUIN()
{
if (userIDField.getText() == null || userIDField.getText().equals(""))
{
wizard.getWizardContainer().setNextFinishButtonEnabled(false);
}
else
{
wizard.getWizardContainer().setNextFinishButtonEnabled(true);
}
}
/**
* Handles the <tt>DocumentEvent</tt> triggered when user types in the UIN
* field. Enables or disables the "Next" wizard button according to whether
* the UIN field is empty.
* @param e the <tt>DocumentEvent</tt> that notified us
*/
public void insertUpdate(DocumentEvent e)
{
this.setNextButtonAccordingToUIN();
this.setServerFieldAccordingToUIN();
}
/**
* Handles the <tt>DocumentEvent</tt> triggered when user deletes letters
* from the UIN field. Enables or disables the "Next" wizard button
* according to whether the UIN field is empty.
* @param e the <tt>DocumentEvent</tt>
*/
public void removeUpdate(DocumentEvent e)
{
this.setNextButtonAccordingToUIN();
this.setServerFieldAccordingToUIN();
}
public void changedUpdate(DocumentEvent e) {}
public void pageHiding() {}
public void pageShown() {}
public void pageBack() {}
/**
* Fills the UIN and Password fields in this panel with the data coming from
* the given protocolProvider.
*
* @param protocolProvider The <tt>ProtocolProviderService</tt> to load
* the data from.
*/
public void loadAccount(ProtocolProviderService protocolProvider)
{
AccountID accountID = protocolProvider.getAccountID();
String password = accountID.getAccountPropertyString(
ProtocolProviderFactory.PASSWORD);
String serverAddress = accountID.getAccountPropertyString(
ProtocolProviderFactory.SERVER_ADDRESS);
String authName = accountID.getAccountPropertyString(
ProtocolProviderFactory.AUTHORIZATION_NAME);
String serverPort = accountID.getAccountPropertyString(
ProtocolProviderFactory.SERVER_PORT);
String proxyAddress = accountID.getAccountPropertyString(
ProtocolProviderFactory.PROXY_ADDRESS);
String proxyPort = accountID.getAccountPropertyString(
ProtocolProviderFactory.PROXY_PORT);
String preferredTransport = accountID.getAccountPropertyString(
ProtocolProviderFactory.PREFERRED_TRANSPORT);
boolean enablePresence = accountID.getAccountPropertyBoolean(
ProtocolProviderFactory.IS_PRESENCE_ENABLED, false);
boolean forceP2P = accountID.getAccountPropertyBoolean(
ProtocolProviderFactory.FORCE_P2P_MODE, false);
boolean enabledDefaultEncryption = accountID.getAccountPropertyBoolean(
ProtocolProviderFactory.DEFAULT_ENCRYPTION, true);
boolean enabledSipZrtpAttribute = accountID.getAccountPropertyBoolean(
ProtocolProviderFactory.DEFAULT_SIPZRTP_ATTRIBUTE, true);
String pollingPeriod = accountID.getAccountPropertyString(
ProtocolProviderFactory.POLLING_PERIOD);
String subscriptionPeriod = accountID.getAccountPropertyString(
ProtocolProviderFactory.SUBSCRIPTION_EXPIRATION);
String keepAliveMethod =
accountID.getAccountPropertyString("KEEP_ALIVE_METHOD");
String keepAliveInterval =
accountID.getAccountPropertyString("KEEP_ALIVE_INTERVAL");
this.isServerOverridden = accountID.getAccountPropertyBoolean(
ProtocolProviderFactory.IS_SERVER_OVERRIDDEN, false);
userIDField.setEnabled(false);
this.userIDField.setText((serverAddress == null) ? accountID.getUserID()
: (accountID.getUserID() + "@" + serverAddress));
if (password != null)
{
this.passField.setText(password);
this.rememberPassBox.setSelected(true);
}
serverField.setText(serverAddress);
serverField.setEnabled(false);
if(authName != null && authName.length() > 0)
authNameField.setText(authName);
serverPortField.setText(serverPort);
proxyField.setText(proxyAddress);
// The order of the next two fields is important, as a change listener
// of the transportCombo sets the proxyPortField to its default
transportCombo.setSelectedItem(preferredTransport);
proxyPortField.setText(proxyPort);
enablePresOpButton.setSelected(enablePresence);
forceP2PPresOpButton.setSelected(forceP2P);
enableDefaultEncryption.setSelected(enabledDefaultEncryption);
enableSipZrtpAttribute.setSelected(enabledSipZrtpAttribute);
enableSipZrtpAttribute.setEnabled(enabledDefaultEncryption);
pollPeriodField.setText(pollingPeriod);
subscribeExpiresField.setText(subscriptionPeriod);
if (!enablePresence)
{
setPresenceOptionsEnabled(enablePresence);
}
keepAliveMethodBox.setSelectedItem(keepAliveMethod);
keepAliveIntervalValue.setText(keepAliveInterval);
}
/**
* Parse the server part from the sip id and set it to server as default
* value. If Advanced option is enabled Do nothing.
*/
private void setServerFieldAccordingToUIN()
{
String serverAddress
= wizard.getServerFromUserName(userIDField.getText());
if (!wizard.isModification() || !isServerOverridden)
{
serverField.setText(serverAddress);
proxyField.setText(serverAddress);
}
}
/**
* Enables or disable all presence related options.
*
* @param isEnabled <code>true</code> to enable the presence related
* options, <code>false</code> - to disable them.
*/
private void setPresenceOptionsEnabled(boolean isEnabled)
{
forceP2PPresOpButton.setEnabled(isEnabled);
pollPeriodField.setEnabled(isEnabled);
subscribeExpiresField.setEnabled(isEnabled);
}
/**
* Sets the proxy and server ports depending on the selected transport type.
* @param e the <tt>ItemEvent</tt> that notified us
*/
public void itemStateChanged(ItemEvent e)
{
if (e.getStateChange() == ItemEvent.SELECTED
&& e.getItem().equals("TLS"))
{
serverPortField.setText(IptelAccountRegistration.DEFAULT_TLS_PORT);
proxyPortField.setText(IptelAccountRegistration.DEFAULT_TLS_PORT);
}
else
{
serverPortField.setText(IptelAccountRegistration.DEFAULT_PORT);
proxyPortField.setText(IptelAccountRegistration.DEFAULT_PORT);
}
}
/**
* Returns the simple form shown by default.
* @return the simple form shown by default
*/
public Object getSimpleForm()
{
return uinPassPanel;
}
/**
* Returns <tt>true</tt> if the form is committed, <tt>false</tt> -
* otherwise.
* @return <tt>true</tt> if the form is committed, <tt>false</tt> -
* otherwise
*/
public boolean isCommitted()
{
return isCommitted;
}
}

@ -0,0 +1,121 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.iptelaccregwizz;
import java.util.*;
import org.osgi.framework.*;
import net.java.sip.communicator.service.browserlauncher.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
/**
* Registers the <tt>GoogleTalkAccountRegistrationWizard</tt> in the UI Service.
*
* @author Lubomir Marinov
*/
public class IptelAccRegWizzActivator
implements BundleActivator
{
public static BundleContext bundleContext;
private static final Logger logger = Logger.getLogger(
IptelAccRegWizzActivator.class.getName());
private static BrowserLauncherService browserLauncherService;
private static UIService uiService;
/**
* Starts this bundle.
* @param bc BundleContext
* @throws Exception
*/
public void start(BundleContext bc)
throws Exception
{
bundleContext = bc;
uiService =
(UIService) bundleContext.getService(bundleContext
.getServiceReference(UIService.class.getName()));
IptelAccountRegistrationWizard wizard
= new IptelAccountRegistrationWizard(uiService
.getAccountRegWizardContainer());
Hashtable<String, String> containerFilter
= new Hashtable<String, String>();
containerFilter.put(
ProtocolProviderFactory.PROTOCOL,
IptelAccountRegistrationWizard.PROTOCOL);
bundleContext.registerService(
AccountRegistrationWizard.class.getName(),
wizard,
containerFilter);
}
public void stop(BundleContext bundleContext) throws Exception {}
/**
* Returns the <tt>ProtocolProviderFactory</tt> for the IP Tel protocol.
*
* @return the <tt>ProtocolProviderFactory</tt> for the IP Tel protocol
*/
public static ProtocolProviderFactory getIptelProtocolProviderFactory()
{
ServiceReference[] serRefs = null;
String osgiFilter = "("
+ ProtocolProviderFactory.PROTOCOL
+ "=" + ProtocolNames.SIP + ")";
try
{
serRefs = bundleContext.getServiceReferences(
ProtocolProviderFactory.class.getName(), osgiFilter);
}
catch (InvalidSyntaxException ex)
{
logger.error("IptelAccRegWizzActivator : " + ex);
}
return (ProtocolProviderFactory) bundleContext.getService(serRefs[0]);
}
/**
* Returns the <tt>UIService</tt>.
*
* @return the <tt>UIService</tt>
*/
public static UIService getUIService()
{
return uiService;
}
/**
* Returns the <tt>BrowserLauncherService</tt> obtained from the bundle
* context.
* @return the <tt>BrowserLauncherService</tt> obtained from the bundle
* context
*/
public static BrowserLauncherService getBrowserLauncher() {
if (browserLauncherService == null)
{
browserLauncherService =
(BrowserLauncherService) bundleContext
.getService(bundleContext
.getServiceReference(BrowserLauncherService.class
.getName()));
}
return browserLauncherService;
}
}

@ -0,0 +1,433 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license. See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.iptelaccregwizz;
/**
* The <tt>IptelAccountRegistration</tt> is used to store all user input data
* through the <tt>IptelAccountRegistrationWizard</tt>.
*
* @author Yana Stamcheva
*/
public class IptelAccountRegistration
{
/**
* The default port.
*/
public static String DEFAULT_PORT = "5060";
/**
* The default TLS port.
*/
public static String DEFAULT_TLS_PORT = "5061";
/**
* The default transport.
*/
public static String DEFAULT_TRANSPORT = "UDP";
/**
* The default poll period.
*/
public static String DEFAULT_POLL_PERIOD = "30";
/**
* The default subscribe expiration time in milliseconds.
*/
public static String DEFAULT_SUBSCRIBE_EXPIRES = "3600";
/**
* The default keep alive method.
*/
public static String DEFAULT_KEEP_ALIVE_METHOD = "REGISTER";
/**
* The default keep alive interval.
*/
public static String DEFAULT_KEEP_ALIVE_INTERVAL = "25";
/**
* The iptel.org default server address.
*/
static final String IPTEL_CONNECT_SRV = "iptel.org";
private String id;
private String password;
private boolean rememberPassword = true;
private String serverAddress = IPTEL_CONNECT_SRV;
private String authorizationName;
private String serverPort = DEFAULT_PORT;
private String proxyPort = DEFAULT_PORT;
private String proxy;
private String preferredTransport = DEFAULT_TRANSPORT;
private boolean enablePresence = true;
private boolean forceP2PMode = true;
private boolean defaultEncryption = false;
private boolean sipZrtpAttribute = false;
private String pollingPeriod = DEFAULT_POLL_PERIOD;
private String subscriptionExpiration = DEFAULT_SUBSCRIBE_EXPIRES;
private String keepAliveMethod = DEFAULT_KEEP_ALIVE_METHOD;
private String keepAliveInterval = DEFAULT_KEEP_ALIVE_INTERVAL;
/**
* Returns the preferred transport to use.
* @return the preferred transport to use
*/
public String getPreferredTransport()
{
return preferredTransport;
}
/**
* Sets the preferred transport to use.
* @param preferredTransport the transport to set
*/
public void setPreferredTransport(String preferredTransport)
{
this.preferredTransport = preferredTransport;
}
/**
* Returns the proxy.
* @return the proxy
*/
public String getProxy()
{
return proxy;
}
/**
* Sets the proxy
* @param proxy the proxy to set
*/
public void setProxy(String proxy)
{
this.proxy = proxy;
}
/**
* Returns the password of the sip registration account.
*
* @return the password of the sip registration account.
*/
public String getPassword()
{
return password;
}
/**
* Sets the password of the sip registration account.
*
* @param password the password of the sip registration account.
*/
public void setPassword(String password)
{
this.password = password;
}
/**
* Returns TRUE if password has to remembered, FALSE otherwise.
*
* @return TRUE if password has to remembered, FALSE otherwise
*/
public boolean isRememberPassword()
{
return rememberPassword;
}
/**
* Sets the rememberPassword value of this sip account registration.
*
* @param rememberPassword TRUE if password has to remembered, FALSE
* otherwise
*/
public void setRememberPassword(boolean rememberPassword)
{
this.rememberPassword = rememberPassword;
}
/**
* Returns the UIN of the sip registration account.
*
* @return the UIN of the sip registration account.
*/
public String getId()
{
String serverAddress = getServerAddress();
return
((id != null)
&& (id.indexOf('@') < 0)
&& ((serverAddress == null)
|| serverAddress.equals(IPTEL_CONNECT_SRV)))
? (id + '@' + IPTEL_CONNECT_SRV)
: id;
}
/**
* The address of the server we will use for this account
*
* @return String
*/
public String getServerAddress()
{
return serverAddress;
}
/**
* The port on the specified server
*
* @return int
*/
public String getServerPort()
{
return serverPort;
}
/**
* The authorization name
*
* @return String auth name
*/
public String getAuthorizationName()
{
return authorizationName;
}
/**
* The port on the specified proxy
*
* @return int
*/
public String getProxyPort()
{
return proxyPort;
}
/**
* Sets the identifier of the sip registration account.
*
* @param id the identifier of the sip registration account.
*/
public void setUserID(String id)
{
this.id = id;
}
/**
* Sets the server
*
* @param serverAddress String
*/
public void setServerAddress(String serverAddress)
{
this.serverAddress = serverAddress;
}
/**
* Sets the server port.
*
* @param port int
*/
public void setServerPort(String port)
{
this.serverPort = port;
}
/**
* Sets authorization name.
*
* @param authName String
*/
public void setAuthorizationName(String authName)
{
this.authorizationName = authName;
}
/**
* Sets the proxy port.
*
* @param port int
*/
public void setProxyPort(String port)
{
this.proxyPort = port;
}
/**
* If the presence is enabled
*
* @return If the presence is enabled
*/
public boolean isEnablePresence()
{
return enablePresence;
}
/**
* If the p2p mode is forced
*
* @return If the p2p mode is forced
*/
public boolean isForceP2PMode()
{
return forceP2PMode;
}
/**
* The offline contact polling period
*
* @return the polling period
*/
public String getPollingPeriod()
{
return pollingPeriod;
}
/**
* The default expiration of subscriptions
*
* @return the subscription expiration
*/
public String getSubscriptionExpiration()
{
return subscriptionExpiration;
}
/**
* Sets if the presence is enabled
*
* @param enablePresence if the presence is enabled
*/
public void setEnablePresence(boolean enablePresence)
{
this.enablePresence = enablePresence;
}
/**
* Sets if we have to force the p2p mode
*
* @param forceP2PMode if we have to force the p2p mode
*/
public void setForceP2PMode(boolean forceP2PMode)
{
this.forceP2PMode = forceP2PMode;
}
/**
* Sets the offline contacts polling period
*
* @param pollingPeriod the offline contacts polling period
*/
public void setPollingPeriod(String pollingPeriod)
{
this.pollingPeriod = pollingPeriod;
}
/**
* Sets the subscription expiration value
*
* @param subscriptionExpiration the subscription expiration value
*/
public void setSubscriptionExpiration(String subscriptionExpiration)
{
this.subscriptionExpiration = subscriptionExpiration;
}
/**
* Returns the keep alive method.
*
* @return the keep alive method.
*/
public String getKeepAliveMethod()
{
return keepAliveMethod;
}
/**
* Sets the keep alive method.
*
* @param keepAliveMethod the keep alive method to set
*/
public void setKeepAliveMethod(String keepAliveMethod)
{
this.keepAliveMethod = keepAliveMethod;
}
/**
* Returns the keep alive interval.
*
* @return the keep alive interval
*/
public String getKeepAliveInterval()
{
return keepAliveInterval;
}
/**
* Sets the keep alive interval.
*
* @param keepAliveInterval the keep alive interval to set
*/
public void setKeepAliveInterval(String keepAliveInterval)
{
this.keepAliveInterval = keepAliveInterval;
}
/**
* If default call encryption is enabled
*
* @return If default call encryption is enabled
*/
public boolean isDefaultEncryption()
{
return defaultEncryption;
}
/**
* Sets default call encryption
*
* @param defaultEncryption if we want to set call encryption on as default
*/
public void setDefaultEncryption(boolean defaultEncryption)
{
this.defaultEncryption = defaultEncryption;
}
/**
* Sets SIP ZRTP attribute support
*
* @param sipZrtpAttribute include the ZRTP attribute to SIP/SDP
*/
public void setSipZrtpAttribute(boolean sipZrtpAttribute) {
this.sipZrtpAttribute = sipZrtpAttribute;
}
/**
* Check if to include the ZRTP attribute to SIP/SDP
*
* @return include the ZRTP attribute to SIP/SDP
*/
public boolean isSipZrtpAttribute() {
return sipZrtpAttribute;
}
}

@ -0,0 +1,705 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.iptelaccregwizz;
import java.awt.*;
import java.util.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
import org.osgi.framework.*;
/**
* The <tt>IPPIAccountRegistrationWizard</tt> is an implementation of the
* <tt>AccountRegistrationWizard</tt> for the SIP protocol. It should allow
* the user to create and configure a new SIP account.
*
* @author Yana Stamcheva
*/
public class IptelAccountRegistrationWizard
implements AccountRegistrationWizard
{
/**
* The protocol name.
*/
public static final String PROTOCOL = "iptel.org";
private FirstWizardPage firstWizardPage;
private IptelAccountRegistration registration
= new IptelAccountRegistration();
private final WizardContainer wizardContainer;
private ProtocolProviderService protocolProvider;
private boolean isModification;
private static final Logger logger
= Logger.getLogger(IptelAccountRegistrationWizard.class);
/**
* Creates an instance of <tt>IPPIAccountRegistrationWizard</tt>.
* @param wizardContainer the wizard container, where this wizard
* is added
*/
public IptelAccountRegistrationWizard(WizardContainer wizardContainer)
{
this.wizardContainer = wizardContainer;
this.wizardContainer.setFinishButtonText(
Resources.getString("service.gui.SIGN_IN"));
}
/**
* Implements the <code>AccountRegistrationWizard.getIcon</code> method.
* Returns the icon to be used for this wizard.
* @return byte[]
*/
public byte[] getIcon()
{
return Resources.getImage(Resources.PROTOCOL_ICON);
}
/**
* Implements the <code>AccountRegistrationWizard.getPageImage</code> method.
* Returns the image used to decorate the wizard page
*
* @return byte[] the image used to decorate the wizard page
*/
public byte[] getPageImage()
{
return Resources.getImage(Resources.PAGE_IMAGE);
}
/**
* Implements the <code>AccountRegistrationWizard.getProtocolName</code>
* method. Returns the protocol name for this wizard.
* @return String
*/
public String getProtocolName()
{
return Resources.getString("plugin.iptelaccregwizz.PROTOCOL_NAME");
}
/**
* Implements the <code>AccountRegistrationWizard.getProtocolDescription
* </code> method. Returns the description of the protocol for this wizard.
* @return String
*/
public String getProtocolDescription()
{
return Resources.getString("plugin.iptelaccregwizz.PROTOCOL_DESCRIPTION");
}
/**
* Returns the set of pages contained in this wizard.
* @return Iterator
*/
public Iterator<WizardPage> getPages() {
java.util.List<WizardPage> pages = new ArrayList<WizardPage>();
firstWizardPage = new FirstWizardPage(this);
pages.add(firstWizardPage);
return pages.iterator();
}
/**
* Returns the set of data that user has entered through this wizard.
* @return Iterator
*/
public Iterator<Map.Entry<String, String>> getSummary()
{
ArrayList<Map.Entry<String, String>> summaryTable
= new ArrayList<Map.Entry<String, String>>();
boolean rememberPswd = registration.isRememberPassword();
String rememberPswdString = Resources.getString(
rememberPswd ? "service.gui.YES" : "service.gui.NO");
summaryTable.add(new SimpleEntry<String, String>(
Resources.getString("plugin.sipaccregwizz.USERNAME"),
registration.getId()));
summaryTable.add(new SimpleEntry<String, String>(
Resources.getString("service.gui.REMEMBER_PASSWORD"),
rememberPswdString));
summaryTable.add(new SimpleEntry<String, String>(
Resources.getString("plugin.sipaccregwizz.REGISTRAR"),
registration.getServerAddress()));
summaryTable.add(new SimpleEntry<String, String>(
Resources.getString("plugin.sipaccregwizz.AUTH_NAME"),
registration.getAuthorizationName()));
summaryTable.add(new SimpleEntry<String, String>(
Resources.getString("plugin.sipaccregwizz.SERVER_PORT"),
registration.getServerPort()));
summaryTable.add(new SimpleEntry<String, String>(
Resources.getString("plugin.sipaccregwizz.PROXY"),
registration.getProxy()));
summaryTable.add(new SimpleEntry<String, String>(
Resources.getString("plugin.sipaccregwizz.PROXY_PORT"),
registration.getProxyPort()));
summaryTable.add(new SimpleEntry<String, String>(
Resources.getString("plugin.sipaccregwizz.PREFERRED_TRANSPORT"),
registration.getPreferredTransport()));
if (registration.isEnablePresence())
{
summaryTable.add(new SimpleEntry<String, String>(
Resources.getString("plugin.sipaccregwizz.ENABLE_PRESENCE"),
Resources.getString("service.gui.YES")));
}
else
{
summaryTable.add(new SimpleEntry<String, String>(
Resources.getString("plugin.sipaccregwizz.ENABLE_PRESENCE"),
Resources.getString("service.gui.NO")));
}
if (registration.isForceP2PMode())
{
summaryTable.add(new SimpleEntry<String, String>(
Resources.getString("plugin.sipaccregwizz.FORCE_P2P_PRESENCE"),
Resources.getString("service.gui.YES")));
}
else
{
summaryTable.add(new SimpleEntry<String, String>(
Resources.getString("plugin.sipaccregwizz.FORCE_P2P_PRESENCE"),
Resources.getString("service.gui.NO")));
}
if (registration.isDefaultEncryption())
{
summaryTable.add(new SimpleEntry<String, String>(Resources.getString(
"plugin.sipaccregwizz.ENABLE_DEFAULT_ENCRYPTION"),
Resources.getString("service.gui.YES")));
}
else
{
summaryTable.add(new SimpleEntry<String, String>(Resources.getString(
"plugin.sipaccregwizz.ENABLE_DEFAULT_ENCRYPTION"),
Resources.getString("service.gui.NO")));
}
if (registration.isSipZrtpAttribute())
{
summaryTable.add(new SimpleEntry<String, String>(Resources.getString(
"plugin.sipaccregwizz.ENABLE_SIPZRTP_ATTRIBUTE"),
Resources.getString("service.gui.YES")));
}
else
{
summaryTable.add(new SimpleEntry<String, String>(Resources.getString(
"plugin.sipaccregwizz.ENABLE_SIPZRTP_ATTRIBUTE"),
Resources.getString("service.gui.NO")));
}
summaryTable.add(new SimpleEntry<String, String>(Resources.getString(
"plugin.sipaccregwizz.OFFLINE_CONTACT_POLLING_PERIOD"),
registration.getPollingPeriod()));
summaryTable.add(new SimpleEntry<String, String>(Resources.getString(
"plugin.sipaccregwizz.SUBSCRIPTION_EXPIRATION"),
registration.getSubscriptionExpiration()));
summaryTable.add(new SimpleEntry<String, String>(
Resources.getString("plugin.sipaccregwizz.KEEP_ALIVE_METHOD"),
registration.getKeepAliveMethod()));
summaryTable.add(new SimpleEntry<String, String>(
Resources.getString("plugin.sipaccregwizz.KEEP_ALIVE_INTERVAL"),
registration.getKeepAliveInterval()));
return summaryTable.iterator();
}
/**
* Installs the account created through this wizard.
* @return the created <tt>ProtocolProviderService</tt>
* @throws OperationFailedException if the sign in operation fails
*/
public ProtocolProviderService signin()
throws OperationFailedException
{
firstWizardPage.commitPage();
return signin(registration.getId(), registration.getPassword());
}
/**
* Installs the account with the given user name and password.
* @param username the username to sign in with
* @param password the password used for login
* @return the <tt>ProtocolProviderService</tt> corresponding to the newly
* created account.
* @throws OperationFailedException if the sign in operation fails
*/
public ProtocolProviderService signin(String username, String password)
throws OperationFailedException
{
ProtocolProviderFactory factory
= IptelAccRegWizzActivator.getIptelProtocolProviderFactory();
ProtocolProviderService pps = null;
if (factory != null)
pps = this.installAccount( factory,
username,
password);
return pps;
}
/**
* 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 install account operation fails
*/
private ProtocolProviderService installAccount(
ProtocolProviderFactory providerFactory,
String userName,
String passwd)
throws OperationFailedException
{
Hashtable<String, String> accountProperties
= new Hashtable<String, String>();
/* Make the account use the resources specific to iptel.org. */
accountProperties.put(ProtocolProviderFactory.PROTOCOL, PROTOCOL);
accountProperties
.put(ProtocolProviderFactory.PROTOCOL_ICON_PATH,
"resources/images/protocol/iptel");
if(registration.isRememberPassword())
{
accountProperties.put(ProtocolProviderFactory.PASSWORD, passwd);
}
String serverAddress = null;
if (registration.getServerAddress() != null)
serverAddress = registration.getServerAddress();
else
serverAddress = getServerFromUserName(userName);
if (serverAddress != null)
{
accountProperties.put(ProtocolProviderFactory.SERVER_ADDRESS,
serverAddress);
if (userName.indexOf(serverAddress) < 0)
accountProperties.put(
ProtocolProviderFactory.IS_SERVER_OVERRIDDEN,
Boolean.toString(true));
}
if(registration.getAuthorizationName() != null)
accountProperties.put(ProtocolProviderFactory.AUTHORIZATION_NAME,
registration.getAuthorizationName());
accountProperties.put(ProtocolProviderFactory.SERVER_PORT,
registration.getServerPort());
String proxyAddress = null;
if (registration.getProxy() != null)
proxyAddress = registration.getProxy();
else
proxyAddress = getServerFromUserName(userName);
if (proxyAddress != null)
accountProperties.put(ProtocolProviderFactory.PROXY_ADDRESS,
proxyAddress);
accountProperties.put(ProtocolProviderFactory.PROXY_PORT,
registration.getProxyPort());
accountProperties.put(ProtocolProviderFactory.PREFERRED_TRANSPORT,
registration.getPreferredTransport());
accountProperties.put(ProtocolProviderFactory.IS_PRESENCE_ENABLED,
Boolean.toString(registration.isEnablePresence()));
accountProperties.put(ProtocolProviderFactory.FORCE_P2P_MODE,
Boolean.toString(registration.isForceP2PMode()));
accountProperties.put(ProtocolProviderFactory.DEFAULT_ENCRYPTION,
Boolean.toString(registration.isDefaultEncryption()));
accountProperties.put(ProtocolProviderFactory.DEFAULT_SIPZRTP_ATTRIBUTE,
Boolean.toString(registration.isSipZrtpAttribute()));
accountProperties.put(ProtocolProviderFactory.POLLING_PERIOD,
registration.getPollingPeriod());
accountProperties.put(ProtocolProviderFactory.SUBSCRIPTION_EXPIRATION,
registration.getSubscriptionExpiration());
accountProperties.put("KEEP_ALIVE_METHOD",
registration.getKeepAliveMethod());
accountProperties.put("KEEP_ALIVE_INTERVAL",
registration.getKeepAliveInterval());
if(isModification)
{
accountProperties.put(ProtocolProviderFactory.USER_ID, userName);
providerFactory.modifyAccount( protocolProvider,
accountProperties);
this.isModification = false;
return protocolProvider;
}
try
{
AccountID accountID = providerFactory.installAccount(
userName, accountProperties);
ServiceReference serRef = providerFactory
.getProviderForAccount(accountID);
protocolProvider
= (ProtocolProviderService) IptelAccRegWizzActivator
.bundleContext.getService(serRef);
}
catch (IllegalStateException exc)
{
logger.warn(exc.getMessage());
throw new OperationFailedException(
"Account already exists.",
OperationFailedException.IDENTIFICATION_CONFLICT);
}
catch (Exception exc)
{
exc.printStackTrace();
throw new OperationFailedException(
exc.getMessage(),
OperationFailedException.GENERAL_ERROR);
}
return protocolProvider;
}
/**
* Fills the id and Password fields in this panel with the data coming
* from the given protocolProvider.
* @param protocolProvider The <tt>ProtocolProviderService</tt> to load the
* data from.
*/
public void loadAccount(ProtocolProviderService protocolProvider)
{
this.isModification = true;
this.protocolProvider = protocolProvider;
this.registration = new IptelAccountRegistration();
this.firstWizardPage.loadAccount(protocolProvider);
}
/**
* Indicates if this wizard is opened for modification or for creating a
* new account.
*
* @return <code>true</code> if this wizard is opened for modification and
* <code>false</code> otherwise.
*/
public boolean isModification()
{
return isModification;
}
/**
* Returns the wizard container, where all pages are added.
*
* @return the wizard container, where all pages are added
*/
public WizardContainer getWizardContainer()
{
return wizardContainer;
}
/**
* Returns the registration object, which will store all the data through
* the wizard.
*
* @return the registration object, which will store all the data through
* the wizard
*/
public IptelAccountRegistration getRegistration()
{
return registration;
}
/**
* Returns the size of this wizard.
* @return the size of this wizard
*/
public Dimension getSize()
{
return new Dimension(600, 500);
}
/**
* Returns the identifier of the page to show first in the wizard.
* @return the identifier of the page to show first in the wizard.
*/
public Object getFirstPageIdentifier()
{
return firstWizardPage.getIdentifier();
}
/**
* Returns the identifier of the page to show last in the wizard.
* @return the identifier of the page to show last in the wizard.
*/
public Object getLastPageIdentifier()
{
return firstWizardPage.getIdentifier();
}
/**
* Sets the modification property to indicate if this wizard is opened for
* a modification.
*
* @param isModification indicates if this wizard is opened for modification
* or for creating a new account.
*/
public void setModification(boolean isModification)
{
this.isModification = isModification;
}
/**
* Returns an example string, which should indicate to the user how the
* user name should look like.
* @return an example string, which should indicate to the user how the
* user name should look like.
*/
public String getUserNameExample()
{
return FirstWizardPage.USER_NAME_EXAMPLE;
}
/**
* Enables the simple "Sign in" form.
* @return <tt>true</tt> if the simple form is enabled, otherwise returns
* <tt>false</tt>
*/
public boolean isSimpleFormEnabled()
{
return true;
}
/**
* Return the server part of the sip user name.
*
* @param userName the user name entered by the user
* @return the server part of the sip user name.
*/
protected String getServerFromUserName(String userName)
{
int delimIndex = userName.indexOf("@");
if (delimIndex != -1)
{
return userName.substring(delimIndex + 1);
}
return null;
}
/**
* Opens the browser on the page sign up
*/
public void webSignup()
{
IptelAccRegWizzActivator.getBrowserLauncher()
.openURL("https://serweb.iptel.org/user/reg/index.php");
}
/**
* Returns <code>true</code> if the web sign up is supported by the current
* implementation, <code>false</code> - otherwise.
* @return <code>true</code> if the web sign up is supported by the current
* implementation, <code>false</code> - otherwise
*/
public boolean isWebSignupSupported()
{
return true;
}
/**
* Returns the simple form used in the simple account wizard.
* @return the simple form used in the simple account wizard
*/
public Object getSimpleForm()
{
firstWizardPage = new FirstWizardPage(this);
return firstWizardPage.getSimpleForm();
}
/**
* A class which implements Map.Entry.
*
* This private class is necessary to compile SC using Java 5. This
* class was copied from GNU classpath and modified to fit here.
*
* @author Jon Zeppieri
* @author Eric Blake (ebb9@email.byu.edu)
*
* @since 1.6
*/
private static class SimpleEntry<K, V> implements Map.Entry<K, V>
{
/**
* Compatible with JDK 1.6
*/
private static final long serialVersionUID = -8499721149061103585L;
/**
* The key. Package visible for direct manipulation.
*/
K key;
/**
* The value. Package visible for direct manipulation.
*/
V value;
/**
* Basic constructor initializes the fields.
* @param newKey the key
* @param newValue the value
*/
protected SimpleEntry(K newKey, V newValue)
{
key = newKey;
value = newValue;
}
protected SimpleEntry(Map.Entry<? extends K, ? extends V> entry)
{
this(entry.getKey(), entry.getValue());
}
static final boolean equals(Object o1, Object o2)
{
return o1 == o2 || (o1 != null && o1.equals(o2));
}
static final int hashCode(Object o)
{
return o == null ? 0 : o.hashCode();
}
/**
* Compares the specified object with this entry. Returns true only if
* the object is a mapping of identical key and value. In other words,
* this must be:<br>
* <pre>(o instanceof Map.Entry)
* && (getKey() == null ? ((HashMap) o).getKey() == null
* : getKey().equals(((HashMap) o).getKey()))
* && (getValue() == null ? ((HashMap) o).getValue() == null
* : getValue().equals(((HashMap) o).getValue()))</pre>
*
* @param o the object to compare
* @return <code>true</code> if it is equal
*/
@SuppressWarnings("unchecked")
public boolean equals(Object o)
{
if (! (o instanceof Map.Entry))
return false;
// Optimize for our own entries.
if (o instanceof SimpleEntry)
{
SimpleEntry<K,V> e = (SimpleEntry<K,V>) o;
return (SimpleEntry.equals(key, e.key)
&& SimpleEntry.equals(value, e.value));
}
Map.Entry<K,V> e = (Map.Entry<K,V>) o;
return (SimpleEntry.equals(key, e.getKey())
&& SimpleEntry.equals(value, e.getValue()));
}
/**
* Get the key corresponding to this entry.
*
* @return the key
*/
public K getKey()
{
return key;
}
/**
* Get the value corresponding to this entry. If you already called
* Iterator.remove(), the behavior undefined, but in this case it works.
*
* @return the value
*/
public V getValue()
{
return value;
}
/**
* Returns the hash code of the entry. This is defined as the exclusive-or
* of the hashcodes of the key and value (using 0 for null). In other
* words, this must be:<br>
* <pre>(getKey() == null ? 0 : getKey().hashCode())
* ^ (getValue() == null ? 0 : getValue().hashCode())</pre>
*
* @return the hash code
*/
public int hashCode()
{
return (SimpleEntry.hashCode(key) ^ SimpleEntry.hashCode(value));
}
/**
* Replaces the value with the specified object. This writes through
* to the map, unless you have already called Iterator.remove(). It
* may be overridden to restrict a null value.
*
* @param newVal the new value to store
* @return the old value
* @throws NullPointerException if the map forbids null values.
* @throws UnsupportedOperationException if the map doesn't support
* <code>put()</code>.
* @throws ClassCastException if the value is of a type unsupported
* by the map.
* @throws IllegalArgumentException if something else about this
* value prevents it being stored in the map.
*/
public V setValue(V newVal)
{
V r = value;
value = newVal;
return r;
}
/**
* This provides a string representation of the entry. It is of the form
* "key=value", where string concatenation is used on key and value.
*
* @return the string representation
*/
public String toString()
{
return key + "=" + value;
}
} // class SimpleEntry
}

@ -0,0 +1,88 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license. See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.iptelaccregwizz;
import net.java.sip.communicator.service.resources.*;
/**
* The <tt>Resources</tt> class manages the access to the internationalization
* properties files and the image resources used in this plugin.
*
* @author Yana Stamcheva
*/
public class Resources
{
private static ResourceManagementService resourcesService;
/**
* A constant pointing to the IP Tel protocol logo image.
*/
public static final ImageID PROTOCOL_ICON
= new ImageID("service.protocol.iptel.IPTEL_16x16");
/**
* A constant pointing to the IP Tel protocol wizard page image.
*/
public static final ImageID PAGE_IMAGE
= new ImageID("service.protocol.iptel.IPTEL_64x64");
/**
* Returns an internationalized string corresponding to the given key.
*
* @param key The key of the string.
* @return An internationalized string corresponding to the given key.
*/
public static String getString(String key)
{
return getResources().getI18NString(key);
}
/**
* Returns an internationalized string corresponding to the given key.
*
* @param key The key of the string.
* @return An internationalized string corresponding to the given key.
*/
public static char getMnemonic(String key)
{
return getResources().getI18nMnemonic(key);
}
/**
* Loads an image from a given image identifier.
*
* @param imageID The identifier of the image.
* @return The image for the given identifier.
*/
public static byte[] getImage(ImageID imageID)
{
return getResources().getImageInBytes(imageID.getId());
}
/**
* Returns the resource for the given key. This could be any resource stored
* in the resources.properties file of this bundle.
*
* @param key the key of the resource to search for
* @return the resource for the given key
*/
public static String getProperty(String key)
{
return getResources().getI18NString(key);
}
/**
* Returns the service giving access to resources.
* @return the service giving access to resources
*/
public static ResourceManagementService getResources()
{
if (resourcesService == null)
resourcesService = ResourceManagementServiceUtils
.getService(IptelAccRegWizzActivator.bundleContext);
return resourcesService;
}
}

@ -0,0 +1,41 @@
Bundle-Activator: net.java.sip.communicator.plugin.iptelaccregwizz.IptelAccRegWizzActivator
Bundle-Name: IP Tel account registration wizard
Bundle-Description: IP Tel account registration wizard.
Bundle-Vendor: sip-communicator.org
Bundle-Version: 0.0.1
System-Bundle: yes
Import-Package: org.osgi.framework,
net.java.sip.communicator.service.browserlauncher,
net.java.sip.communicator.service.configuration,
net.java.sip.communicator.service.configuration.event,
net.java.sip.communicator.service.contactlist,
net.java.sip.communicator.service.contactlist.event,
net.java.sip.communicator.service.fileaccess,
net.java.sip.communicator.service.gui,
net.java.sip.communicator.service.gui.event,
net.java.sip.communicator.service.protocol,
net.java.sip.communicator.service.protocol.event,
net.java.sip.communicator.service.protocol.icqconstants,
net.java.sip.communicator.service.resources,
net.java.sip.communicator.util,
net.java.sip.communicator.util.swing,
javax.naming,
javax.naming.directory,
javax.xml.parsers,
org.w3c.dom,
org.xml.sax,
javax.swing,
javax.swing.event,
javax.swing.table,
javax.swing.text,
javax.swing.text.html,
javax.accessibility,
javax.swing.plaf,
javax.swing.plaf.metal,
javax.swing.plaf.basic,
javax.imageio,
javax.swing.filechooser,
javax.swing.tree,
javax.swing.undo,
javax.swing.border,
org.jivesoftware.smack
Loading…
Cancel
Save