Display error messages when account creation failed.
Improve the creation wizard and add a dummy script to fetch
a list of xmpp services.
--- a/res/layout/create_account.xml Tue Sep 25 22:40:22 2012 +0200
+++ b/res/layout/create_account.xml Sat Sep 29 04:47:42 2012 +0200
@@ -12,16 +12,36 @@
android:layout_marginTop="15dp"
android:layout_marginBottom="30dp"
android:src="@drawable/logo"/>
-
+
+ <TextView
+ android:layout_width="fill_parent" android:layout_height="wrap_content"
+ android:text="@string/create_account_text"
+ android:textSize="18sp"
+ android:paddingBottom="10dip"
+ android:focusable="true" />
<TextView
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:text="@string/create_account_username" style="@style/Label" />
- <EditText android:id="@+id/create_account_username"
- android:inputType="textEmailAddress" android:imeOptions="actionNext"
- android:layout_width="fill_parent" android:layout_height="wrap_content"
- android:singleLine="true"
- android:hint="beem@beem-project.com "
- android:contentDescription="@string/create_account_username"/>
+ <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content"
+ android:orientation="horizontal">
+ <EditText android:id="@+id/create_account_username"
+ android:inputType="textEmailAddress" android:imeOptions="actionNext"
+ android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:minWidth="120dp"
+ android:hint="beem"
+ android:contentDescription="@string/create_account_username"/>
+ <TextView
+ android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text=" @ " style="@style/Label" />
+ <AutoCompleteTextView android:id="@+id/xmpp_server"
+ android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:minWidth="160dp"
+ android:gravity="left"
+ android:hint="beem-project.com"
+ android:inputType="textNoSuggestions"
+ style="?android:attr/dropDownSpinnerStyle"/>
+ </LinearLayout>
<TextView
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:text="@string/create_account_password" style="@style/Label" />
@@ -38,7 +58,10 @@
android:inputType="textPassword" android:imeOptions="actionNext"
android:singleLine="true"
android:contentDescription="@string/create_account_confirm_password"/>
-
+ <TextView android:id="@+id/error_label"
+ android:layout_width="fill_parent" android:layout_height="wrap_content"
+ android:textColor="@color/red" android:textStyle="bold"
+ style="@style/Label"/>
</LinearLayout>
</ScrollView>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/simple_combobox_item.xml Sat Sep 29 04:47:42 2012 +0200
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@android:id/text1"
+ style="?android:attr/dropDownItemStyle"
+ android:textAppearance="?android:attr/textAppearanceSmallPopupMenu"
+ android:singleLine="true"
+ android:layout_width="match_parent"
+ android:layout_height="36dip"
+ android:ellipsize="marquee" />
--- a/res/values-fr/strings.xml Tue Sep 25 22:40:22 2012 +0200
+++ b/res/values-fr/strings.xml Sat Sep 29 04:47:42 2012 +0200
@@ -199,11 +199,14 @@
<!--
Create an account Activity
-->
+ <string name="create_account_text">Entrez les informations nécéssaires pour créer votre compte</string>
<string name="create_account_err_username">Mauvais JabberID</string>
<string name="create_account_err_passwords">Les mots de passe ne correspondent pas</string>
<string name="create_account_username">Nom d\'utilisateur</string>
<string name="create_account_password">Mot de passe</string>
<string name="create_account_confirm_password">Confirmation du mot de passe</string>
+ <string name="create_account_err_conflict">Ce compte est déjà utilisé. Essayez d\'en créer un autre</string>
+ <string name="create_account_err_connection">Le serveur choisi n\'est pas disponible. Essayez en un autre</string>
<!--
ContactList Activity
--- a/res/values/strings.xml Tue Sep 25 22:40:22 2012 +0200
+++ b/res/values/strings.xml Sat Sep 29 04:47:42 2012 +0200
@@ -198,11 +198,15 @@
<string name="account_wizard_create_account">I want to register for a new account</string>
<!-- Create an account Activity -->
+ <string name="create_account_text">Enter the required informations to create your account</string>
<string name="create_account_err_username">Bad JabberID</string>
<string name="create_account_err_passwords">Passwords do not match.</string>
<string name="create_account_username">Username</string>
<string name="create_account_password">Password</string>
<string name="create_account_confirm_password">Confirm password</string>
+ <string name="create_account_err_conflict">This account is already used. Please try another one</string>
+ <string name="create_account_err_connection">The selected server is not available. Please try another one</string>
+
<!-- ContactList Activity -->
<string name="contact_list_menu_add_contact">Add a contact</string>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/res/values/xmpp_server_list.xml Sat Sep 29 04:47:42 2012 +0200
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string-array name="xmpp_server_list">
+ <item>0nl1ne.at</item>
+ <item>blah.at</item>
+ <item>blah.im</item>
+ <item>boese-ban.de</item>
+ <item>brauchen.info</item>
+ <item>chatme.im</item>
+ <item>chrome.pl</item>
+ <item>climm.org</item>
+ <item>coderollers.com</item>
+ <item>codingteam.net</item>
+ <item>comm.unicate.me</item>
+ <item>darkdna.net</item>
+ <item>deshalbfrei.org</item>
+ <item>draugr.de</item>
+ <item>einfachjabber.de</item>
+ <item>forumanalogue.fr</item>
+ <item>im.apinc.org</item>
+ <item>im.flosoft.biz</item>
+ <item>internet-exception.de</item>
+ <item>jabb3r.net</item>
+ <item>jabber-br.org</item>
+ <item>jabber-hosting.de</item>
+ <item>jabber.at</item>
+ <item>jabber.ccc.de</item>
+ <item>jabber.chaotic.de</item>
+ <item>jabber.co.nz</item>
+ <item>jabber.cz</item>
+ <item>jabber.de</item>
+ <item>jabber.earth.li</item>
+ <item>jabber.etighichat.com</item>
+ <item>jabber.fourecks.de</item>
+ <item>jabber.gate31.net</item>
+ <item>jabber.hot-chilli.net</item>
+ <item>jabber.i-pobox.net</item>
+ <item>jabber.iitsp.com</item>
+ <item>jabber.loudas.com</item>
+ <item>jabber.me</item>
+ <item>jabber.meta.net.nz</item>
+ <item>jabber.minus273.org</item>
+ <item>jabber.no-sense.net</item>
+ <item>jabber.no</item>
+ <item>jabber.rootbash.com</item>
+ <item>jabber.rueckgr.at</item>
+ <item>jabber.scha.de</item>
+ <item>jabber.schnied.net</item>
+ <item>jabber.second-home.de</item>
+ <item>jabber.smash-net.org</item>
+ <item>jabber.sow.as</item>
+ <item>jabber.theforest.us</item>
+ <item>jabber.tmkis.com</item>
+ <item>jabber.yeahnah.co.nz</item>
+ <item>jabberd.eu</item>
+ <item>jabberes.org</item>
+ <item>jabbim.com</item>
+ <item>jabbim.cz</item>
+ <item>jabbim.pl</item>
+ <item>jabbim.sk</item>
+ <item>jabin.org</item>
+ <item>jabme.de</item>
+ <item>jabster.pl</item>
+ <item>jaim.at</item>
+ <item>jappix.com</item>
+ <item>jisshi.com</item>
+ <item>labnote.org</item>
+ <item>lightwitch.org</item>
+ <item>limun.org</item>
+ <item>macjabber.de</item>
+ <item>mayplaces.com</item>
+ <item>na-di.de</item>
+ <item>neko.im</item>
+ <item>netmindz.net</item>
+ <item>njs.netlab.cz</item>
+ <item>palita.net</item>
+ <item>pandion.im</item>
+ <item>pidgin.su</item>
+ <item>programmer-art.org</item>
+ <item>prosody.de</item>
+ <item>richim.org</item>
+ <item>rkquery.de</item>
+ <item>sss.chaoslab.ru</item>
+ <item>sternenschweif.de</item>
+ <item>swissjabber.ch</item>
+ <item>swissjabber.de</item>
+ <item>swissjabber.eu</item>
+ <item>swissjabber.li</item>
+ <item>swissjabber.org</item>
+ <item>tcweb.org</item>
+ <item>tekst.me</item>
+ <item>thiessen.im</item>
+ <item>thiessen.it</item>
+ <item>thiessen.org</item>
+ <item>tigase.im</item>
+ <item>twattle.net</item>
+ <item>ubuntu-jabber.de</item>
+ <item>ubuntu-jabber.net</item>
+ <item>univers-libre.net</item>
+ <item>verdammung.org</item>
+ <item>wtfismyip.com</item>
+ <item>xabber.de</item>
+ <item>xmpp-hosting.de</item>
+ <item>xmpp.jp</item>
+ <item>xmppnet.de</item>
+ <item>zauris.ru</item>
+ <item>zsim.de</item>
+ <item>xmpp.kz</item>
+ <item>freamware.net</item>
+ <item>gabbler.de</item>
+ <item>gabbler.eu</item>
+ <item>gabbler.org</item>
+ <item>hot-chilli.net</item>
+ <item>igniterealtime.org</item>
+ <item>is-the-shit.com</item>
+ <item>jabberheaven.com</item>
+ <item>jabberheaven.de</item>
+ <item>jabber.rückgr.at</item>
+ <item>jabber.se</item>
+ <item>jabberus.kz</item>
+ <item>jabberzac.org</item>
+ <item>vrane.com</item>
+ <item>xmpp.ru.net</item>
+ <item>gojabber.org</item>
+ <item>jabbeng.in</item>
+ <item>jabber.gnubox.net</item>
+ <item>jabberid.org</item>
+ <item>jodo.im</item>
+ <item>jsmart.web.id</item>
+ <item>linuxlovers.at</item>
+ <item>n0g.at</item>
+ <item>totalueberwachung.de</item>
+ <item>jabber.kiev.ua</item>
+ <item>jabbir.org</item>
+ <item>j-talk.me</item>
+ <item>xmppres.com</item>
+ </string-array>
+</resources>
--- a/src/com/beem/project/beem/ui/wizard/AccountConfigureFragment.java Tue Sep 25 22:40:22 2012 +0200
+++ b/src/com/beem/project/beem/ui/wizard/AccountConfigureFragment.java Sat Sep 29 04:47:42 2012 +0200
@@ -126,7 +126,7 @@
super.onCreate(savedInstanceState);
Log.d(TAG, "onCreate");
setRetainInstance(true);
-
+
settings = PreferenceManager.getDefaultSharedPreferences(getActivity());
}
@@ -158,34 +158,34 @@
@Override
public void onStart() {
- super.onStart();
- useSystemAccount = settings.getBoolean(BeemApplication.USE_SYSTEM_ACCOUNT_KEY, false);
- // temporaly disable jid watcher
- mAccountJID.removeTextChangedListener(mJidTextWatcher);
- mAccountJID.setText(settings.getString(BeemApplication.ACCOUNT_USERNAME_KEY, ""));
- if (useSystemAccount) {
- mAccountPassword.setText("*******"); //dummy password
- mAccountJID.setText(settings.getString(BeemApplication.ACCOUNT_USERNAME_KEY, ""));
- mAccountPassword.setEnabled(false);
- mNextButton.setEnabled(true);
- }
- mAccountJID.addTextChangedListener(mJidTextWatcher);
+ super.onStart();
+ useSystemAccount = settings.getBoolean(BeemApplication.USE_SYSTEM_ACCOUNT_KEY, false);
+ // temporaly disable jid watcher
+ mAccountJID.removeTextChangedListener(mJidTextWatcher);
+ mAccountJID.setText(settings.getString(BeemApplication.ACCOUNT_USERNAME_KEY, ""));
+ if (useSystemAccount) {
+ mAccountPassword.setText("*******"); //dummy password
+ mAccountJID.setText(settings.getString(BeemApplication.ACCOUNT_USERNAME_KEY, ""));
+ mAccountPassword.setEnabled(false);
+ mNextButton.setEnabled(true);
+ }
+ mAccountJID.addTextChangedListener(mJidTextWatcher);
}
@TargetApi(14)
@Override
public void onClick(View v) {
if (v == mNextButton) {
- if (useSystemAccount) {
- onDeviceAccountSelected(settings.getString(BeemApplication.ACCOUNT_USERNAME_KEY, ""),
- settings.getString(BeemApplication.ACCOUNT_SYSTEM_TYPE_KEY, ""));
- } else {
- String jid = mAccountJID.getText().toString();
- jid = StringUtils.parseBareAddress(jid);
- String password = mAccountPassword.getText().toString();
- task = new ConnectionTestTask();
- task.execute(jid, password);
- }
+ if (useSystemAccount) {
+ onDeviceAccountSelected(settings.getString(BeemApplication.ACCOUNT_USERNAME_KEY, ""),
+ settings.getString(BeemApplication.ACCOUNT_SYSTEM_TYPE_KEY, ""));
+ } else {
+ String jid = mAccountJID.getText().toString();
+ jid = StringUtils.parseBareAddress(jid);
+ String password = mAccountPassword.getText().toString();
+ task = new ConnectionTestTask();
+ task.execute(jid, password);
+ }
} else if (v == mManualConfigButton) {
onManualConfigurationSelected();
} else if (v == mSelectAccountButton) {
@@ -214,7 +214,6 @@
mSelectedAccountType = data.getStringExtra(AccountManager.KEY_ACCOUNT_TYPE);
onDeviceAccountSelected(mSelectedAccountName, mSelectedAccountType);
} else if (requestCode == MANUAL_CONFIGURATION_CODE) {
- SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getActivity());
String login = settings.getString(BeemApplication.ACCOUNT_USERNAME_KEY, "");
String password = settings.getString(BeemApplication.ACCOUNT_PASSWORD_KEY, "");
mAccountJID.setText(login);
@@ -246,7 +245,6 @@
*
*/
private void onAccountConnectionFailed() {
- //TODO display error
mAccountPassword.setText("");
mErrorLabel.setVisibility(View.VISIBLE);
}
@@ -282,7 +280,7 @@
edit.putBoolean(BeemApplication.USE_SYSTEM_ACCOUNT_KEY, false);
edit.commit();
}
-
+
/**
* Save the user credentials.
*
@@ -365,7 +363,7 @@
checkUsername(s.toString());
mNextButton.setEnabled(mValidJid && mValidPassword);
if (useSystemAccount) {
- mAccountPassword.setEnabled(true);
+ mAccountPassword.setEnabled(true);
mAccountPassword.setText("");
}
useSystemAccount = false;
@@ -385,9 +383,9 @@
*/
class ConnectionTestTask extends AsyncTask<String, Void, Boolean> {
- private ProgressFragment progress;
- private ConnectionConfiguration config;
- private XMPPException exception;
+ private ProgressFragment progress;
+ private ConnectionConfiguration config;
+ private XMPPException exception;
private String jid;
private String password;
private String server;
@@ -452,17 +450,17 @@
* @return the XMPPConnection prepared to connect
*/
private Connection prepareConnection(String jid, String server, int port) {
- boolean useProxy = settings.getBoolean(BeemApplication.PROXY_USE_KEY, false);
- ProxyInfo proxyinfo = ProxyInfo.forNoProxy();
- if (useProxy) {
- String stype = settings.getString(BeemApplication.PROXY_TYPE_KEY, "HTTP");
- String phost = settings.getString(BeemApplication.PROXY_SERVER_KEY, "");
- String puser = settings.getString(BeemApplication.PROXY_USERNAME_KEY, "");
- String ppass = settings.getString(BeemApplication.PROXY_PASSWORD_KEY, "");
- int pport = Integer.parseInt(settings.getString(BeemApplication.PROXY_PORT_KEY, "1080"));
- ProxyInfo.ProxyType type = ProxyType.valueOf(stype);
- proxyinfo = new ProxyInfo(type, phost, pport, puser, ppass);
- }
+ boolean useProxy = settings.getBoolean(BeemApplication.PROXY_USE_KEY, false);
+ ProxyInfo proxyinfo = ProxyInfo.forNoProxy();
+ if (useProxy) {
+ String stype = settings.getString(BeemApplication.PROXY_TYPE_KEY, "HTTP");
+ String phost = settings.getString(BeemApplication.PROXY_SERVER_KEY, "");
+ String puser = settings.getString(BeemApplication.PROXY_USERNAME_KEY, "");
+ String ppass = settings.getString(BeemApplication.PROXY_PASSWORD_KEY, "");
+ int pport = Integer.parseInt(settings.getString(BeemApplication.PROXY_PORT_KEY, "1080"));
+ ProxyInfo.ProxyType type = ProxyType.valueOf(stype);
+ proxyinfo = new ProxyInfo(type, phost, pport, puser, ppass);
+ }
String serviceName = StringUtils.parseServer(jid);
if (port != -1 || !TextUtils.isEmpty(server)) {
if (port == -1)
@@ -473,6 +471,8 @@
} else {
config = new ConnectionConfiguration(serviceName, proxyinfo);
}
+ if (settings.getBoolean(BeemApplication.SMACK_DEBUG_KEY, false))
+ config.setDebuggerEnabled(true);
return new XMPPConnection(config);
}
}
--- a/src/com/beem/project/beem/ui/wizard/CreateAccountFragment.java Tue Sep 25 22:40:22 2012 +0200
+++ b/src/com/beem/project/beem/ui/wizard/CreateAccountFragment.java Sat Sep 29 04:47:42 2012 +0200
@@ -44,8 +44,12 @@
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.View.OnClickListener;
import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.AutoCompleteTextView;
import android.widget.Button;
+import android.widget.EditText;
import android.widget.TextView;
import com.beem.project.beem.BeemApplication;
@@ -57,6 +61,7 @@
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smack.proxy.ProxyInfo;
import org.jivesoftware.smack.proxy.ProxyInfo.ProxyType;
import org.jivesoftware.smack.util.StringUtils;
@@ -67,9 +72,11 @@
*/
public class CreateAccountFragment extends Fragment implements android.view.View.OnClickListener {
private static final String TAG = CreateAccountFragment.class.getSimpleName();
- private TextView username;
- private TextView password;
- private TextView confirmPassword;
+ private EditText username;
+ private EditText password;
+ private EditText confirmPassword;
+ private TextView errorText;
+ private AutoCompleteTextView serverEdit;
private Button createButton;
private CreateAccountTask task;
private final NotEmptyTextWatcher mTextWatcher = new NotEmptyTextWatcher();
@@ -101,14 +108,29 @@
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.create_account, container, false);
- username = (TextView) v.findViewById(R.id.create_account_username);
+ username = (EditText) v.findViewById(R.id.create_account_username);
username.addTextChangedListener(mTextWatcher);
- password = (TextView) v.findViewById(R.id.create_account_password);
+ password = (EditText) v.findViewById(R.id.create_account_password);
password.addTextChangedListener(mTextWatcher);
- confirmPassword = (TextView) v.findViewById(R.id.create_account_confirm_password);
+ confirmPassword = (EditText) v.findViewById(R.id.create_account_confirm_password);
confirmPassword.addTextChangedListener(mTextWatcher);
+ errorText = (TextView) v.findViewById(R.id.error_label);
createButton = (Button) v.findViewById(R.id.next);
createButton.setOnClickListener(this);
+ serverEdit = (AutoCompleteTextView) v.findViewById(R.id.xmpp_server);
+ ArrayAdapter<CharSequence> completeAdapter = ArrayAdapter.createFromResource(
+ getActivity(), R.array.xmpp_server_list, R.layout.simple_combobox_item);
+
+ serverEdit.setAdapter(completeAdapter);
+ serverEdit.addTextChangedListener(mTextWatcher);
+ // show the list on second click on the text view
+ serverEdit.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ serverEdit.showDropDown();
+ }
+ });
return v;
}
@@ -116,17 +138,21 @@
public void onClick(View v) {
if (v == createButton) {
boolean create = true;
- if (!checkEmail()) {
+ if (!checkUserName()) {
username.setError(getString(R.string.create_account_err_username));
create = false;
}
+ if (TextUtils.isEmpty(serverEdit.getText())) {
+ serverEdit.setError("Choose a server");
+ create = false;
+ }
if (!checkPasswords()) {
password.setError(getString(R.string.create_account_err_passwords));
confirmPassword.setError(getString(R.string.create_account_err_passwords));
create = false;
}
if (create) {
- String jid = username.getText().toString();
+ String jid = String.format("%s@%s", username.getText(), serverEdit.getText());
jid = StringUtils.parseBareAddress(jid);
String pass = password.getText().toString();
task = new CreateAccountTask();
@@ -143,7 +169,6 @@
*
*/
private void saveCredential(String jid, String pass) {
- SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getActivity());
SharedPreferences.Editor edit = settings.edit();
edit.putString(BeemApplication.ACCOUNT_USERNAME_KEY, jid);
edit.putString(BeemApplication.ACCOUNT_PASSWORD_KEY, pass);
@@ -174,7 +199,12 @@
*
*/
private void onAccountCreationFailed(XMPPException e) {
- // TODO displayError
+ XMPPError error = e.getXMPPError();
+ if (error != null && XMPPError.Condition.conflict.equals(error.getCondition()))
+ errorText.setText(R.string.create_account_err_conflict);
+ else
+ errorText.setText(R.string.create_account_err_connection);
+ Log.v(TAG, "Unable to create an account on xmpp server", e);
}
/**
@@ -182,9 +212,9 @@
*
* @return true if the email is valid.
*/
- private boolean checkEmail() {
+ private boolean checkUserName() {
String email = username.getText().toString();
- return Pattern.matches("[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+.)+[a-zA-Z]{2,4}", email);
+ return Pattern.matches("[a-zA-Z0-9._%+-]+", email);
}
/**
@@ -270,17 +300,17 @@
* @return the XMPPConnection prepared to connect
*/
private Connection prepareConnection(String jid, String server, int port) {
- boolean useProxy = settings.getBoolean(BeemApplication.PROXY_USE_KEY, false);
- ProxyInfo proxyinfo = ProxyInfo.forNoProxy();
- if (useProxy) {
- String stype = settings.getString(BeemApplication.PROXY_TYPE_KEY, "HTTP");
- String phost = settings.getString(BeemApplication.PROXY_SERVER_KEY, "");
- String puser = settings.getString(BeemApplication.PROXY_USERNAME_KEY, "");
- String ppass = settings.getString(BeemApplication.PROXY_PASSWORD_KEY, "");
- int pport = Integer.parseInt(settings.getString(BeemApplication.PROXY_PORT_KEY, "1080"));
- ProxyInfo.ProxyType type = ProxyType.valueOf(stype);
- proxyinfo = new ProxyInfo(type, phost, pport, puser, ppass);
- }
+ boolean useProxy = settings.getBoolean(BeemApplication.PROXY_USE_KEY, false);
+ ProxyInfo proxyinfo = ProxyInfo.forNoProxy();
+ if (useProxy) {
+ String stype = settings.getString(BeemApplication.PROXY_TYPE_KEY, "HTTP");
+ String phost = settings.getString(BeemApplication.PROXY_SERVER_KEY, "");
+ String puser = settings.getString(BeemApplication.PROXY_USERNAME_KEY, "");
+ String ppass = settings.getString(BeemApplication.PROXY_PASSWORD_KEY, "");
+ int pport = Integer.parseInt(settings.getString(BeemApplication.PROXY_PORT_KEY, "1080"));
+ ProxyInfo.ProxyType type = ProxyType.valueOf(stype);
+ proxyinfo = new ProxyInfo(type, phost, pport, puser, ppass);
+ }
String serviceName = StringUtils.parseServer(jid);
if (port != -1 || !TextUtils.isEmpty(server)) {
if (port == -1)
@@ -291,6 +321,8 @@
} else {
config = new ConnectionConfiguration(serviceName, proxyinfo);
}
+ if (settings.getBoolean(BeemApplication.SMACK_DEBUG_KEY, false))
+ config.setDebuggerEnabled(true);
return new XMPPConnection(config);
}
}
@@ -339,6 +371,7 @@
@Override
public void afterTextChanged(Editable s) {
boolean enable = !(TextUtils.isEmpty(username.getText())
+ || TextUtils.isEmpty(serverEdit.getText())
|| TextUtils.isEmpty(password.getText())
|| TextUtils.isEmpty(confirmPassword.getText()));
createButton.setEnabled(enable);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/getFreeXmppServices.py Sat Sep 29 04:47:42 2012 +0200
@@ -0,0 +1,68 @@
+#!/usr/bin/env python3
+
+import urllib.request
+import argparse, sys
+from xml.dom.minidom import parse, getDOMImplementation
+
+
+def getJidsFromUrl(url):
+ f = urllib.request.urlopen(url)
+ indoc = parse(f)
+ jids = []
+ query = indoc.documentElement
+ if query.localName == "query" :
+ for item in query.getElementsByTagName("item"):
+ jid = item.getAttribute("jid")
+ jids.append(jid)
+ return jids
+
+def createDocument():
+ impl = getDOMImplementation()
+ return impl.createDocument(None, "resources", None)
+
+
+def purge(elems):
+ res = []
+ for i in elems:
+ if i not in res:
+ res.append(i)
+ return res
+
+def appendStringElem(doc, node, jids):
+ for i in jids:
+ item = doc.createElement("item")
+ text = doc.createTextNode(i)
+ item.appendChild(text)
+ node.appendChild(item)
+
+
+parser = argparse.ArgumentParser(description='Collect some free xmpp services')
+parser.add_argument('url', metavar="url",
+ default=['http://xmpp.net/services.xml', "https://list.jabber.at/api/?format=services.xml"] , nargs='*',
+ help='url to get the services')
+
+parser.add_argument('-o', metavar="FILE", type=argparse.FileType('bw'),
+ default = sys.stdout.buffer,
+ help='send output to FILE')
+
+args = parser.parse_args()
+
+# collect the servers jid
+jids = []
+for url in args.url:
+ jids += getJidsFromUrl(url)
+
+jids = purge(jids)
+
+# create the xml output document
+outdoc = createDocument()
+res_element = outdoc.documentElement
+string_array_elem = outdoc.createElement('string-array')
+res_element.appendChild(string_array_elem)
+string_array_elem.setAttribute("name", "xmpp_server_list")
+appendStringElem(outdoc, string_array_elem, jids)
+
+# print result
+f = args.o
+f.write(outdoc.toprettyxml(encoding="utf-8"))
+