X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=blobdiff_plain;f=modules%2Ferl%2Feuphorik_protocole.erl;h=8fad0e9e585dded3b355462f7d93a17a0d8650fb;hp=35bf9933b3603b8aff8ea93a7c5eb05d356a25d8;hb=bacec85920574375f4b8df20d6a0457e1fffc658;hpb=cded85bdaf899cef1ba38d2ee6fd24c67f2abc52 diff --git a/modules/erl/euphorik_protocole.erl b/modules/erl/euphorik_protocole.erl index 35bf993..8fad0e9 100755 --- a/modules/erl/euphorik_protocole.erl +++ b/modules/erl/euphorik_protocole.erl @@ -112,13 +112,16 @@ profile(Action) -> Pseudo = case xmerl_xpath:string("pseudo", Action) of [#xmlElement{content = [#xmlText{value = P2}]}] -> P2; _ -> Login end, Email = case xmerl_xpath:string("email", Action) of [#xmlElement{content = [#xmlText{value = E}]}] -> E; _ -> undefined end, Css = case xmerl_xpath:string("css", Action) of [#xmlElement{content = [#xmlText{value = C}]}] -> C; _ -> undefined end, - Conversations = case xmerl_xpath:string("conversations", Action) of - Conversations -> - % extraction de chaque conversation - - _ -> [] - end, - case euphorik_minichat:set_profile(Cookie, Login, Password, Pseudo, Email, Css) of + Page_principale = case xmerl_xpath:string("pagePrincipale", Action) of [#xmlElement{content = [#xmlText{value = P3}]}] -> list_to_integer(P3); _ -> undefined end, + Conversations = lists:map( + fun(Conv) -> + [#xmlElement{content = [#xmlText{value = Id_racine_str}]}] = xmerl_xpath:string("racine", Conv), + [#xmlElement{content = [#xmlText{value = Page_conv_str}]}] = xmerl_xpath:string("page", Conv), + {erlang:list_to_integer(Id_racine_str, 36), list_to_integer(Page_conv_str)} + end, + xmerl_xpath:string("conversation", Action) + ), + case euphorik_minichat:set_profile(Cookie, Login, Password, Pseudo, Email, Css, Page_principale, Conversations) of ok -> xml_reponse_profile_ok(); login_deja_pris -> @@ -158,14 +161,15 @@ refreshMessage(Action) -> _ -> inconnu end, % extraction des conversations en [{id, page}, ..] - Conversations = lists:map( - fun(Conv) -> - [#xmlElement{content = [#xmlText{value = Id_racine_str}]}] = xmerl_xpath:string("racine", Conv), - [#xmlElement{content = [#xmlText{value = Page_conv_str}]}] = xmerl_xpath:string("page", Conv), - {erlang:list_to_integer(Id_racine_str, 36), erlang:list_to_integer(Page_conv_str)} - end, - xmerl_xpath:string("conversation", Action) - ), + % Obsolète : obtenu depuis la table 'user' + %~ Conversations = lists:map( + %~ fun(Conv) -> + %~ [#xmlElement{content = [#xmlText{value = Id_racine_str}]}] = xmerl_xpath:string("racine", Conv), + %~ [#xmlElement{content = [#xmlText{value = Page_conv_str}]}] = xmerl_xpath:string("page", Conv), + %~ {erlang:list_to_integer(Id_racine_str, 36), erlang:list_to_integer(Page_conv_str)} + %~ end, + %~ xmerl_xpath:string("conversation", Action) + %~ ), % accrochez-vous ca va siouxer ;) [{reponse, [{name, "refreshMessages"}], lists:map( @@ -203,7 +207,7 @@ refreshMessage(Action) -> ] } end, - euphorik_minichat_conversation:conversations(Conversations, Nb_message, Dernier_id, Page) + euphorik_minichat_conversation:conversations(User#user.conversations, Nb_message, Dernier_id, Page) ) }]; _ -> @@ -299,8 +303,20 @@ xml_reponse_login_ok(User) -> {pseudo, [User#user.pseudo]}, {login, [User#user.login]}, {email, [User#user.email]}, - {css, [User#user.css]} - ] + {css, [User#user.css]}, + {pagePrincipale, [integer_to_list(User#user.page_principale)]} + ] ++ + lists:map( + fun(C) -> + {conversation, + [ + {racine, [erlang:integer_to_list(element(1, C), 36)]}, + {page, [integer_to_list(element(2, C))]} + ] + } + end, + User#user.conversations + ) }].