Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Shchepin <alexey@process-one.net>2005-05-23 23:47:57 +0400
committerAlexey Shchepin <alexey@process-one.net>2005-05-23 23:47:57 +0400
commitdbb248247b5dbc0113ea9e272ea2b9495ed34041 (patch)
treee9935111a281788cbbc88b88cb1739cd8ae4ead3 /src/jd2ejd.erl
parent6b1e56f78603dfa02fc1eec304a37f6ddc6f5afc (diff)
* src/mod_last_odbc.erl: Added store_last_info/4 function (thanks
to Sergei Golovan) * src/mod_last.erl: Likewise * src/jd2ejd.erl: Support for exporting iq:last information, better error handling (thanks to Sergei Golovan) * src/ejabberd_ctl.erl: Added "import-file" and "import-dir" commands (thanks to Sergei Golovan) SVN Revision: 358
Diffstat (limited to 'src/jd2ejd.erl')
-rw-r--r--src/jd2ejd.erl34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/jd2ejd.erl b/src/jd2ejd.erl
index 6f2152b97..86e36a038 100644
--- a/src/jd2ejd.erl
+++ b/src/jd2ejd.erl
@@ -37,19 +37,23 @@ import_file(File) ->
{'EXIT', Reason} ->
?ERROR_MSG(
"Error while processing file \"~s\": ~p~n",
- [File, Reason]);
+ [File, Reason]),
+ {error, Reason};
_ ->
ok
end;
{error, Reason} ->
?ERROR_MSG("Can't parse file \"~s\": ~p~n",
- [File, Reason])
+ [File, Reason]),
+ {error, Reason}
end;
{error, Reason} ->
- ?ERROR_MSG("Can't read file \"~s\": ~p~n", [File, Reason])
+ ?ERROR_MSG("Can't read file \"~s\": ~p~n", [File, Reason]),
+ {error, Reason}
end;
false ->
- ?ERROR_MSG("Incorrect user/server name in file \"~s\"~n", [File])
+ ?ERROR_MSG("Illegal user/server name in file \"~s\"~n", [File]),
+ {error, "illegal user/server"}
end.
@@ -65,11 +69,15 @@ import_dir(Dir) ->
false
end
end, Files),
- lists:foreach(
- fun(FN) ->
- import_file(filename:join([Dir, FN]))
- end, MsgFiles),
- ok.
+ lists:foldl(
+ fun(FN, A) ->
+ Res = import_file(filename:join([Dir, FN])),
+ case {A, Res} of
+ {ok, ok} -> ok;
+ {ok, _} -> {error, "see ejabberd log for details"};
+ _ -> A
+ end
+ end, ok, MsgFiles).
%%%----------------------------------------------------------------------
%%% Internal functions
@@ -99,6 +107,14 @@ xdb_data(User, Server, {xmlelement, _Name, Attrs, _Els} = El) ->
?NS_ROSTER ->
catch mod_roster:set_items(User, Server, El),
ok;
+ ?NS_LAST ->
+ TimeStamp = xml:get_attr_s("last", Attrs),
+ Status = xml:get_tag_cdata(El),
+ catch mod_last:store_last_info(User,
+ Server,
+ list_to_integer(TimeStamp),
+ Status),
+ ok;
?NS_VCARD ->
catch mod_vcard:process_sm_iq(
From,