add more explicit error message during login
authorNikita Kozlov <nikita@beem-project.com>
Sat, 13 Feb 2010 19:54:42 +0100
changeset 658 baaee1877b2b
parent 657 f0ee4f04b3ac
child 662 f4349711b6c8
child 665 01f3b7160f4b
add more explicit error message during login
.classpath
default.properties
res/values-fr/strings.xml
res/values/strings.xml
src/com/beem/project/beem/service/XmppConnectionAdapter.java
--- a/.classpath	Sat Feb 13 15:55:49 2010 +0100
+++ b/.classpath	Sat Feb 13 19:54:42 2010 +0100
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
-	<classpathentry kind="lib" path="libs/asmack-jse.jar"/>
+	<classpathentry kind="lib" path="libs/asmack-jse.jar" sourcepath="/home/nikita/devel/smack/source"/>
 	<classpathentry kind="src" path="src"/>
 	<classpathentry kind="src" path="gen"/>
 	<classpathentry kind="lib" path="libs/jlibrtp.jar"/>
--- a/default.properties	Sat Feb 13 15:55:49 2010 +0100
+++ b/default.properties	Sat Feb 13 19:54:42 2010 +0100
@@ -10,5 +10,5 @@
 # Indicates whether an apk should be generated for each density.
 split.density=false
 # Project target.
-target=android-4
+target=android-7
 apk-configurations=
--- a/res/values-fr/strings.xml	Sat Feb 13 15:55:49 2010 +0100
+++ b/res/values-fr/strings.xml	Sat Feb 13 19:54:42 2010 +0100
@@ -302,4 +302,33 @@
 	<string name="privacy_list_delete_dialog_no">Non</string>
 
 	<string name="UpdateButton">Mettre à jour</string>
+	
+	<!-- Error messages -->
+	
+	<string name="error_login_authentication">Erreur lors de l\'authenfitication, mauvais login ou password</string>
+	
+	<string name="interna_server_error">Erreur survenu sur le serveur</string>
+	<string name="bad_request">bad-request</string>
+	<string name="forbidden">forbidden</string>
+	<string name="item_not_found">item-not-found</string>
+	<string name="conflict">conflict</string>
+	<string name="feature_not_implemented">feature-not-implemented</string>
+	<string name="gone">gone</string>
+	<string name="jid_malformed">jid-malformed</string>
+	<string name="no_acceptable">no-acceptable</string>
+	<string name="not_allowed">not-allowed</string>
+	<string name="not_authorized">not-authorized</string>
+	<string name="payment_required">payment-required</string>
+	<string name="recipient_unavailable">recipient-unavailable</string>
+	<string name="redirect">redirect</string>
+	<string name="registration_required">registration-required</string>
+	<string name="remote_server_not_found">Serveur non trouvé</string>
+	<string name="remote_server_timeout">Pas de réponse du serveur</string>
+	<string name="remote_server_error">Erreur survenu sur le serveur</string>
+	<string name="resource_constraint">resource-constraint</string>
+	<string name="service_unavailable">service-unavailable</string>
+	<string name="subscription_required">subscription-required</string>
+	<string name="undefined_condition">undefined-condition</string>
+	<string name="unexpected_condition">unexpected-condition</string>
+	<string name="request_timeout">request-timeout</string>
 </resources>
--- a/res/values/strings.xml	Sat Feb 13 15:55:49 2010 +0100
+++ b/res/values/strings.xml	Sat Feb 13 19:54:42 2010 +0100
@@ -286,4 +286,33 @@
 	<string name="privacy_list_delete_dialog_no">No</string>
 
 	<string name="UpdateButton">Update</string>
+	
+	<!-- Error messages -->
+	
+	<string name="error_login_authentication">Error during authentication, bad login or password.</string>
+	
+	<string name="interna_server_error">Remote server error</string>
+	<string name="bad_request">bad-request</string>
+	<string name="forbidden">forbidden</string>
+	<string name="item_not_found">item-not-found</string>
+	<string name="conflict">conflict</string>
+	<string name="feature_not_implemented">feature-not-implemented</string>
+	<string name="gone">gone</string>
+	<string name="jid_malformed">jid-malformed</string>
+	<string name="no_acceptable">no-acceptable</string>
+	<string name="not_allowed">not-allowed</string>
+	<string name="not_authorized">not-authorized</string>
+	<string name="payment_required">payment-required</string>
+	<string name="recipient_unavailable">recipient-unavailable</string>
+	<string name="redirect">redirect</string>
+	<string name="registration_required">registration-required</string>
+	<string name="remote_server_not_found">Remote server not found</string>
+	<string name="remote_server_timeout">No server response</string>
+	<string name="remote_server_error">Remote server error</string>
+	<string name="resource_constraint">resource-constraint</string>
+	<string name="service_unavailable">service-unavailable</string>
+	<string name="subscription_required">subscription-required</string>
+	<string name="undefined_condition">undefined-condition</string>
+	<string name="unexpected_condition">unexpected-condition</string>
+	<string name="request_timeout">request-timeout</string>
 </resources>
--- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java	Sat Feb 13 15:55:49 2010 +0100
+++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java	Sat Feb 13 19:54:42 2010 +0100
@@ -40,7 +40,7 @@
     Flavien Astraud, November 26, 2009
     Head of the EIP Laboratory.
 
-*/
+ */
 package com.beem.project.beem.service;
 
 import org.jivesoftware.smack.ConnectionConfiguration;
@@ -171,10 +171,17 @@
 		return true;
 	    } catch (XMPPException e) {
 		Log.e(TAG, "Error while connecting", e);
-		if (!"".equals(e.getMessage()))
-		    mErrorMsg = e.getMessage();
-		else
-		    mErrorMsg = e.toString();
+		try {
+		    String str = mService.getResources().getString(
+			mService.getResources().getIdentifier(
+			    e.getXMPPError().getCondition().replace("-", "_"), "string", "com.beem.project.beem"));
+		    mErrorMsg = str;
+		} catch(NullPointerException e2) {
+		    if (!"".equals(e.getMessage()))
+			mErrorMsg = e.getMessage();
+		    else
+			mErrorMsg = e.toString();
+		}
 	    }
 	    return false;
 	}
@@ -211,15 +218,12 @@
 	    mService.resetStatus();
 	    mService.initJingle(mAdaptee);
 
-	  //  triggerAsynchronousConnectEvent();
+	    //  triggerAsynchronousConnectEvent();
 	    changeStatus(Status.CONTACT_STATUS_AVAILABLE, mService.getServicePreference().getString("status_text", ""));
 	    return true;
 	} catch (XMPPException e) {
 	    Log.e(TAG, "Error while connecting", e);
-	    if (!"".equals(e.getMessage()))
-		mErrorMsg = e.getMessage();
-	    else
-		mErrorMsg = e.toString();
+	    mErrorMsg = mService.getString(R.string.error_login_authentication);
 	    return false;
 	}
     }