-Client.prototype.identifie = function()
-{
- return this.statut == statutType.enregistre || this.statut == statutType.identifie
-}
-
-Client.prototype.setStatut = function(statut)
-{ \r
- if(typeof(statut) == "string")\r
- {
- statut =
- statut == "enregistre" ?
- statutType.enregistre : (statut == "identifie" ? statutType.identifie : statutType.non_identifie) \r
- } \r
- \r
- if (statut == this.statut) return \r
- \r
- this.statut = statut \r
- this.majMenu()
-}
-\r
-/**\r
- * Effectue la connexion vers le serveur.\r
- * Cette fonction est bloquante tant que la connexion n'a pas été établie.\r
- * S'il existe un cookie en local on s'authentifie directement avec lui.\r
- * Si il n'est pas possible de s'authentifier alors on affiche un captcha anti-bot.\r
- */\r
-Client.prototype.connexionCookie = function()\r
-{\r
- this.getCookie()\r
- if (this.cookie == null) return false;
- return this.connexion(this.util.xmlVersAction(this.getXMLloginCookie()))\r
-}
-
-Client.prototype.connexionLogin = function(login, password)
-{
- return this.connexion(this.util.xmlVersAction(this.getXMLlogin(login, password)))
-}\r
-
-Client.prototype.enregistrement = function(login, password)
-{
- if (this.identifie())
- {
- this.login = login
- this.password = password
- if(this.flush())
- this.setStatut(statutType.enregistre)
- return true
- }
- else\r
- {\r
- if (login == undefined) login = ""\r
- if (password == undefined) password = ""
- return this.connexion(this.util.xmlVersAction(this.getXMLEnregistrement(login, password)))\r
- }
-}
-
-Client.prototype.connexion = function(action)
-{
- //action.action.dump()
- thisClient = this
- jQuery.ajax(
- {
- async: false,
- type: "POST",
- url: "request",
- dataType: "xml",
- data: action,
- success:
- function(data)
- {
- //thisClient.util.serializer.serializeToString(data).dump("Charger client")
- thisClient.chargerDonnees(data)
- }
- }
- )
- return this.identifie()
-}\r
-\r
-Client.prototype.deconnexion = function()\r
-{\r
- this.setStatut(statutType.non_identifie) // deconnexion\r
- this.resetDonneesPersonnelles()\r
- this.delCookie ()\r
-}
-
-Client.prototype.chargerDonnees = function(data)
-{
- var thisClient = this
-
- this.setStatut(jQuery("statut", data.documentElement).text())
-
- if (this.identifie())
- {
- this.cookie = jQuery("cookie", data.documentElement).text()
- this.setCookie()
- \r
- this.login = jQuery("login", data.documentElement).text()
- this.pseudo = jQuery("pseudo", data.documentElement).text()\r
- this.email = jQuery("email", data.documentElement).text()\r
- this.css = jQuery("css", data.documentElement).text()
-
- // la page de la conversation principale
- var tmp = jQuery("pagePrincipale", data.documentElement)
- this.pagePrincipale = tmp.length < 1 ? 1 : parseInt(tmp.text())
-
- // met à jour la css
- if (this.css != "")
- {
- jQuery("link#cssPrincipale").attr("href", this.css)
- this.majMenu()
- }
- // les conversations
- this.conversations = new Array()
- jQuery("conversation", data.documentElement).each(
- function(i)
- {
- thisClient.conversations.push( { racine : jQuery("racine", this).text(), page : jQuery("page", this).text() } )
- }
- )
- }
- this.dernierMessageErreur = jQuery("information", data.documentElement).text()
-}
-
-/**
- * Met à jour les données personne sur serveur.
- * @param async de manière asynchrone ? défaut = true
- */
-Client.prototype.flush = function(async)
-{
- if (async == undefined)
- async = true
-
- thisClient = this
- //this.util.xmlVersAction(this.getXMLProfile()).action.dump("Flush client")
- jQuery.ajax(
- {
- async: async,
- type: "POST",
- url: "request",
- dataType: "xml",
- data: this.util.xmlVersAction(this.getXMLProfile()),
- success:
- function(data)
- {
- //thisClient.util.log(thisClient.util.serializer.serializeToString(data))
- }
- }
- )
- // TODO : retourner false si un problème est survenu lors de l'update du profile
- return true
-}
-
-Client.prototype.majMenu = function()
-{
- var displayType = this.css == "css/3/euphorik.css" ? "block" : "inline" //this.client
-
- // met à jour le menu
- if (this.statut == statutType.enregistre)
- {
- jQuery("#menu .profile").css("display", displayType).text("profile")\r
- jQuery("#menu .logout").css("display", displayType)
- jQuery("#menu .register").css("display", "none")
- }
- else if (this.statut == statutType.identifie)
- {
- jQuery("#menu .profile").css("display", "none")\r
- jQuery("#menu .logout").css("display", displayType)
- jQuery("#menu .register").css("display", displayType)
- }
- else
- {
- jQuery("#menu .profile").css("display", displayType).text("login")\r
- jQuery("#menu .logout").css("display", "none")
- jQuery("#menu .register").css("display", displayType)
- }
-}