mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Rename odbc to sql everywhere
This commit is contained in:
parent
fafeeb80c2
commit
1aae8a9fda
@ -254,10 +254,10 @@ auth_method: internal
|
|||||||
## extauth_program: "/path/to/authentication/script"
|
## extauth_program: "/path/to/authentication/script"
|
||||||
|
|
||||||
##
|
##
|
||||||
## Authentication using ODBC
|
## Authentication using SQL
|
||||||
## Remember to setup a database in the next section.
|
## Remember to setup a database in the next section.
|
||||||
##
|
##
|
||||||
## auth_method: odbc
|
## auth_method: sql
|
||||||
|
|
||||||
##
|
##
|
||||||
## Authentication using PAM
|
## Authentication using PAM
|
||||||
@ -330,26 +330,26 @@ auth_method: internal
|
|||||||
##
|
##
|
||||||
## MySQL server:
|
## MySQL server:
|
||||||
##
|
##
|
||||||
## odbc_type: mysql
|
## sql_type: mysql
|
||||||
## odbc_server: "server"
|
## sql_server: "server"
|
||||||
## odbc_database: "database"
|
## sql_database: "database"
|
||||||
## odbc_username: "username"
|
## sql_username: "username"
|
||||||
## odbc_password: "password"
|
## sql_password: "password"
|
||||||
##
|
##
|
||||||
## If you want to specify the port:
|
## If you want to specify the port:
|
||||||
## odbc_port: 1234
|
## sql_port: 1234
|
||||||
|
|
||||||
##
|
##
|
||||||
## PostgreSQL server:
|
## PostgreSQL server:
|
||||||
##
|
##
|
||||||
## odbc_type: pgsql
|
## sql_type: pgsql
|
||||||
## odbc_server: "server"
|
## sql_server: "server"
|
||||||
## odbc_database: "database"
|
## sql_database: "database"
|
||||||
## odbc_username: "username"
|
## sql_username: "username"
|
||||||
## odbc_password: "password"
|
## sql_password: "password"
|
||||||
##
|
##
|
||||||
## If you want to specify the port:
|
## If you want to specify the port:
|
||||||
## odbc_port: 1234
|
## sql_port: 1234
|
||||||
##
|
##
|
||||||
## If you use PostgreSQL, have a large database, and need a
|
## If you use PostgreSQL, have a large database, and need a
|
||||||
## faster but inexact replacement for "select count(*) from users"
|
## faster but inexact replacement for "select count(*) from users"
|
||||||
@ -359,25 +359,25 @@ auth_method: internal
|
|||||||
##
|
##
|
||||||
## SQLite:
|
## SQLite:
|
||||||
##
|
##
|
||||||
## odbc_type: sqlite
|
## sql_type: sqlite
|
||||||
## odbc_database: "/path/to/database.db"
|
## sql_database: "/path/to/database.db"
|
||||||
|
|
||||||
##
|
##
|
||||||
## ODBC compatible or MSSQL server:
|
## ODBC compatible or MSSQL server:
|
||||||
##
|
##
|
||||||
## odbc_type: odbc
|
## sql_type: odbc
|
||||||
## odbc_server: "DSN=ejabberd;UID=ejabberd;PWD=ejabberd"
|
## sql_server: "DSN=ejabberd;UID=ejabberd;PWD=ejabberd"
|
||||||
|
|
||||||
##
|
##
|
||||||
## Number of connections to open to the database for each virtual host
|
## Number of connections to open to the database for each virtual host
|
||||||
##
|
##
|
||||||
## odbc_pool_size: 10
|
## sql_pool_size: 10
|
||||||
|
|
||||||
##
|
##
|
||||||
## Interval to make a dummy SQL request to keep the connections to the
|
## Interval to make a dummy SQL request to keep the connections to the
|
||||||
## database alive. Specify in seconds: for example 28800 means 8 hours
|
## database alive. Specify in seconds: for example 28800 means 8 hours
|
||||||
##
|
##
|
||||||
## odbc_keepalive_interval: undefined
|
## sql_keepalive_interval: undefined
|
||||||
|
|
||||||
###. ===============
|
###. ===============
|
||||||
###' TRAFFIC SHAPERS
|
###' TRAFFIC SHAPERS
|
||||||
|
@ -23,9 +23,9 @@
|
|||||||
|
|
||||||
-define(SQL_UPSERT_MARK, sql_upsert__mark_).
|
-define(SQL_UPSERT_MARK, sql_upsert__mark_).
|
||||||
-define(SQL_UPSERT(Host, Table, Fields),
|
-define(SQL_UPSERT(Host, Table, Fields),
|
||||||
ejabberd_odbc:sql_query(Host, ?SQL_UPSERT_MARK(Table, Fields))).
|
ejabberd_sql:sql_query(Host, ?SQL_UPSERT_MARK(Table, Fields))).
|
||||||
-define(SQL_UPSERT_T(Table, Fields),
|
-define(SQL_UPSERT_T(Table, Fields),
|
||||||
ejabberd_odbc:sql_query_t(?SQL_UPSERT_MARK(Table, Fields))).
|
ejabberd_sql:sql_query_t(?SQL_UPSERT_MARK(Table, Fields))).
|
||||||
|
|
||||||
-record(sql_query, {hash, format_query, format_res, args, loc}).
|
-record(sql_query, {hash, format_query, format_res, args, loc}).
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@
|
|||||||
%% note: pos_integer() should always be used, but we allow anything else coded
|
%% note: pos_integer() should always be used, but we allow anything else coded
|
||||||
%% as binary, so one can have a custom implementation of nodetree with custom
|
%% as binary, so one can have a custom implementation of nodetree with custom
|
||||||
%% indexing (see nodetree_virtual). this also allows to use any kind of key for
|
%% indexing (see nodetree_virtual). this also allows to use any kind of key for
|
||||||
%% indexing nodes, as this can be usefull with external backends such as odbc.
|
%% indexing nodes, as this can be usefull with external backends such as sql.
|
||||||
|
|
||||||
-type(itemId() :: binary()).
|
-type(itemId() :: binary()).
|
||||||
%% @type itemId() = string().
|
%% @type itemId() = string().
|
||||||
|
@ -192,20 +192,20 @@ get_commands_spec() ->
|
|||||||
module = ejabberd_piefxis, function = export_host,
|
module = ejabberd_piefxis, function = export_host,
|
||||||
args = [{dir, string}, {host, string}], result = {res, rescode}},
|
args = [{dir, string}, {host, string}], result = {res, rescode}},
|
||||||
|
|
||||||
#ejabberd_commands{name = export_odbc, tags = [mnesia, odbc],
|
#ejabberd_commands{name = export_sql, tags = [mnesia, sql],
|
||||||
desc = "Export all tables as SQL queries to a file",
|
desc = "Export all tables as SQL queries to a file",
|
||||||
module = ejd2odbc, function = export,
|
module = ejd2sql, function = export,
|
||||||
args = [{host, string}, {file, string}], result = {res, rescode}},
|
args = [{host, string}, {file, string}], result = {res, rescode}},
|
||||||
#ejabberd_commands{name = delete_mnesia, tags = [mnesia, odbc],
|
#ejabberd_commands{name = delete_mnesia, tags = [mnesia, sql],
|
||||||
desc = "Export all tables as SQL queries to a file",
|
desc = "Export all tables as SQL queries to a file",
|
||||||
module = ejd2odbc, function = delete,
|
module = ejd2sql, function = delete,
|
||||||
args = [{host, string}], result = {res, rescode}},
|
args = [{host, string}], result = {res, rescode}},
|
||||||
#ejabberd_commands{name = convert_to_scram, tags = [odbc],
|
#ejabberd_commands{name = convert_to_scram, tags = [sql],
|
||||||
desc = "Convert the passwords in 'users' ODBC table to SCRAM",
|
desc = "Convert the passwords in 'users' ODBC table to SCRAM",
|
||||||
module = ejabberd_auth_odbc, function = convert_to_scram,
|
module = ejabberd_auth_sql, function = convert_to_scram,
|
||||||
args = [{host, binary}], result = {res, rescode}},
|
args = [{host, binary}], result = {res, rescode}},
|
||||||
|
|
||||||
#ejabberd_commands{name = import_prosody, tags = [mnesia, odbc, riak],
|
#ejabberd_commands{name = import_prosody, tags = [mnesia, sql, riak],
|
||||||
desc = "Import data from Prosody",
|
desc = "Import data from Prosody",
|
||||||
module = prosody2ejabberd, function = from_dir,
|
module = prosody2ejabberd, function = from_dir,
|
||||||
args = [{dir, string}], result = {res, rescode}},
|
args = [{dir, string}], result = {res, rescode}},
|
||||||
@ -225,9 +225,9 @@ get_commands_spec() ->
|
|||||||
module = ?MODULE, function = delete_old_messages,
|
module = ?MODULE, function = delete_old_messages,
|
||||||
args = [{days, integer}], result = {res, rescode}},
|
args = [{days, integer}], result = {res, rescode}},
|
||||||
|
|
||||||
#ejabberd_commands{name = export2odbc, tags = [mnesia],
|
#ejabberd_commands{name = export2sql, tags = [mnesia],
|
||||||
desc = "Export virtual host information from Mnesia tables to SQL files",
|
desc = "Export virtual host information from Mnesia tables to SQL files",
|
||||||
module = ejd2odbc, function = export,
|
module = ejd2sql, function = export,
|
||||||
args = [{host, string}, {directory, string}],
|
args = [{host, string}, {directory, string}],
|
||||||
result = {res, rescode}},
|
result = {res, rescode}},
|
||||||
#ejabberd_commands{name = set_master, tags = [mnesia],
|
#ejabberd_commands{name = set_master, tags = [mnesia],
|
||||||
|
@ -137,7 +137,7 @@ check_password(User, AuthzId, Server, Password, Digest,
|
|||||||
%% where
|
%% where
|
||||||
%% AuthModule = ejabberd_auth_anonymous | ejabberd_auth_external
|
%% AuthModule = ejabberd_auth_anonymous | ejabberd_auth_external
|
||||||
%% | ejabberd_auth_internal | ejabberd_auth_ldap
|
%% | ejabberd_auth_internal | ejabberd_auth_ldap
|
||||||
%% | ejabberd_auth_odbc | ejabberd_auth_pam | ejabberd_auth_riak
|
%% | ejabberd_auth_sql | ejabberd_auth_pam | ejabberd_auth_riak
|
||||||
-spec check_password_with_authmodule(binary(), binary(), binary(), binary()) -> false |
|
-spec check_password_with_authmodule(binary(), binary(), binary(), binary()) -> false |
|
||||||
{true, atom()}.
|
{true, atom()}.
|
||||||
|
|
||||||
|
@ -474,8 +474,8 @@ export(_Server) ->
|
|||||||
[{passwd,
|
[{passwd,
|
||||||
fun(Host, #passwd{us = {LUser, LServer}, password = Password})
|
fun(Host, #passwd{us = {LUser, LServer}, password = Password})
|
||||||
when LServer == Host ->
|
when LServer == Host ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
Pass = ejabberd_odbc:escape(Password),
|
Pass = ejabberd_sql:escape(Password),
|
||||||
[[<<"delete from users where username='">>, Username, <<"';">>],
|
[[<<"delete from users where username='">>, Username, <<"';">>],
|
||||||
[<<"insert into users(username, password) "
|
[<<"insert into users(username, password) "
|
||||||
"values ('">>, Username, <<"', '">>, Pass, <<"');">>]];
|
"values ('">>, Username, <<"', '">>, Pass, <<"');">>]];
|
||||||
|
@ -291,8 +291,8 @@ export(_Server) ->
|
|||||||
[{passwd,
|
[{passwd,
|
||||||
fun(Host, #passwd{us = {LUser, LServer}, password = Password})
|
fun(Host, #passwd{us = {LUser, LServer}, password = Password})
|
||||||
when LServer == Host ->
|
when LServer == Host ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
Pass = ejabberd_odbc:escape(Password),
|
Pass = ejabberd_sql:escape(Password),
|
||||||
[[<<"delete from users where username='">>, Username, <<"';">>],
|
[[<<"delete from users where username='">>, Username, <<"';">>],
|
||||||
[<<"insert into users(username, password) "
|
[<<"insert into users(username, password) "
|
||||||
"values ('">>, Username, <<"', '">>, Pass, <<"');">>]];
|
"values ('">>, Username, <<"', '">>, Pass, <<"');">>]];
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%% File : ejabberd_auth_odbc.erl
|
%%% File : ejabberd_auth_sql.erl
|
||||||
%%% Author : Alexey Shchepin <alexey@process-one.net>
|
%%% Author : Alexey Shchepin <alexey@process-one.net>
|
||||||
%%% Purpose : Authentification via ODBC
|
%%% Purpose : Authentification via ODBC
|
||||||
%%% Created : 12 Dec 2004 by Alexey Shchepin <alexey@process-one.net>
|
%%% Created : 12 Dec 2004 by Alexey Shchepin <alexey@process-one.net>
|
||||||
@ -23,7 +23,7 @@
|
|||||||
%%%
|
%%%
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
-module(ejabberd_auth_odbc).
|
-module(ejabberd_auth_sql).
|
||||||
|
|
||||||
-behaviour(ejabberd_config).
|
-behaviour(ejabberd_config).
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ check_password(User, AuthzId, Server, Password) ->
|
|||||||
true ->
|
true ->
|
||||||
case is_scrammed() of
|
case is_scrammed() of
|
||||||
true ->
|
true ->
|
||||||
try odbc_queries:get_password_scram(LServer, LUser) of
|
try sql_queries:get_password_scram(LServer, LUser) of
|
||||||
{selected,
|
{selected,
|
||||||
[{StoredKey, ServerKey, Salt, IterationCount}]} ->
|
[{StoredKey, ServerKey, Salt, IterationCount}]} ->
|
||||||
Scram =
|
Scram =
|
||||||
@ -95,7 +95,7 @@ check_password(User, AuthzId, Server, Password) ->
|
|||||||
false %% Typical error is database not accessible
|
false %% Typical error is database not accessible
|
||||||
end;
|
end;
|
||||||
false ->
|
false ->
|
||||||
try odbc_queries:get_password(LServer, LUser) of
|
try sql_queries:get_password(LServer, LUser) of
|
||||||
{selected, [{Password}]} ->
|
{selected, [{Password}]} ->
|
||||||
Password /= <<"">>;
|
Password /= <<"">>;
|
||||||
{selected, [{_Password2}]} ->
|
{selected, [{_Password2}]} ->
|
||||||
@ -127,7 +127,7 @@ check_password(User, AuthzId, Server, Password, Digest,
|
|||||||
true ->
|
true ->
|
||||||
case is_scrammed() of
|
case is_scrammed() of
|
||||||
false ->
|
false ->
|
||||||
try odbc_queries:get_password(LServer, LUser) of
|
try sql_queries:get_password(LServer, LUser) of
|
||||||
%% Account exists, check if password is valid
|
%% Account exists, check if password is valid
|
||||||
{selected, [{Passwd}]} ->
|
{selected, [{Passwd}]} ->
|
||||||
DigRes = if Digest /= <<"">> ->
|
DigRes = if Digest /= <<"">> ->
|
||||||
@ -164,7 +164,7 @@ set_password(User, Server, Password) ->
|
|||||||
case is_scrammed() of
|
case is_scrammed() of
|
||||||
true ->
|
true ->
|
||||||
Scram = password_to_scram(Password),
|
Scram = password_to_scram(Password),
|
||||||
case catch odbc_queries:set_password_scram_t(
|
case catch sql_queries:set_password_scram_t(
|
||||||
LServer,
|
LServer,
|
||||||
LUser,
|
LUser,
|
||||||
Scram#scram.storedkey,
|
Scram#scram.storedkey,
|
||||||
@ -177,7 +177,7 @@ set_password(User, Server, Password) ->
|
|||||||
Other -> {error, Other}
|
Other -> {error, Other}
|
||||||
end;
|
end;
|
||||||
false ->
|
false ->
|
||||||
case catch odbc_queries:set_password_t(LServer,
|
case catch sql_queries:set_password_t(LServer,
|
||||||
LUser, Password)
|
LUser, Password)
|
||||||
of
|
of
|
||||||
{atomic, ok} -> ok;
|
{atomic, ok} -> ok;
|
||||||
@ -198,7 +198,7 @@ try_register(User, Server, Password) ->
|
|||||||
case is_scrammed() of
|
case is_scrammed() of
|
||||||
true ->
|
true ->
|
||||||
Scram = password_to_scram(Password),
|
Scram = password_to_scram(Password),
|
||||||
case catch odbc_queries:add_user_scram(
|
case catch sql_queries:add_user_scram(
|
||||||
LServer,
|
LServer,
|
||||||
LUser,
|
LUser,
|
||||||
Scram#scram.storedkey,
|
Scram#scram.storedkey,
|
||||||
@ -210,7 +210,7 @@ try_register(User, Server, Password) ->
|
|||||||
_ -> {atomic, exists}
|
_ -> {atomic, exists}
|
||||||
end;
|
end;
|
||||||
false ->
|
false ->
|
||||||
case catch odbc_queries:add_user(LServer, LUser,
|
case catch sql_queries:add_user(LServer, LUser,
|
||||||
Password) of
|
Password) of
|
||||||
{updated, 1} -> {atomic, ok};
|
{updated, 1} -> {atomic, ok};
|
||||||
_ -> {atomic, exists}
|
_ -> {atomic, exists}
|
||||||
@ -219,7 +219,7 @@ try_register(User, Server, Password) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
dirty_get_registered_users() ->
|
dirty_get_registered_users() ->
|
||||||
Servers = ejabberd_config:get_vh_by_auth_method(odbc),
|
Servers = ejabberd_config:get_vh_by_auth_method(sql),
|
||||||
lists:flatmap(fun (Server) ->
|
lists:flatmap(fun (Server) ->
|
||||||
get_vh_registered_users(Server)
|
get_vh_registered_users(Server)
|
||||||
end,
|
end,
|
||||||
@ -230,7 +230,7 @@ get_vh_registered_users(Server) ->
|
|||||||
error -> [];
|
error -> [];
|
||||||
<<>> -> [];
|
<<>> -> [];
|
||||||
LServer ->
|
LServer ->
|
||||||
case catch odbc_queries:list_users(LServer) of
|
case catch sql_queries:list_users(LServer) of
|
||||||
{selected, Res} ->
|
{selected, Res} ->
|
||||||
[{U, LServer} || {U} <- Res];
|
[{U, LServer} || {U} <- Res];
|
||||||
_ -> []
|
_ -> []
|
||||||
@ -242,7 +242,7 @@ get_vh_registered_users(Server, Opts) ->
|
|||||||
error -> [];
|
error -> [];
|
||||||
<<>> -> [];
|
<<>> -> [];
|
||||||
LServer ->
|
LServer ->
|
||||||
case catch odbc_queries:list_users(LServer, Opts) of
|
case catch sql_queries:list_users(LServer, Opts) of
|
||||||
{selected, Res} ->
|
{selected, Res} ->
|
||||||
[{U, LServer} || {U} <- Res];
|
[{U, LServer} || {U} <- Res];
|
||||||
_ -> []
|
_ -> []
|
||||||
@ -254,7 +254,7 @@ get_vh_registered_users_number(Server) ->
|
|||||||
error -> 0;
|
error -> 0;
|
||||||
<<>> -> 0;
|
<<>> -> 0;
|
||||||
LServer ->
|
LServer ->
|
||||||
case catch odbc_queries:users_number(LServer) of
|
case catch sql_queries:users_number(LServer) of
|
||||||
{selected, [{Res}]} ->
|
{selected, [{Res}]} ->
|
||||||
Res;
|
Res;
|
||||||
_ -> 0
|
_ -> 0
|
||||||
@ -266,7 +266,7 @@ get_vh_registered_users_number(Server, Opts) ->
|
|||||||
error -> 0;
|
error -> 0;
|
||||||
<<>> -> 0;
|
<<>> -> 0;
|
||||||
LServer ->
|
LServer ->
|
||||||
case catch odbc_queries:users_number(LServer, Opts) of
|
case catch sql_queries:users_number(LServer, Opts) of
|
||||||
{selected, [{Res}]} ->
|
{selected, [{Res}]} ->
|
||||||
Res;
|
Res;
|
||||||
_Other -> 0
|
_Other -> 0
|
||||||
@ -283,7 +283,7 @@ get_password(User, Server) ->
|
|||||||
true ->
|
true ->
|
||||||
case is_scrammed() of
|
case is_scrammed() of
|
||||||
true ->
|
true ->
|
||||||
case catch odbc_queries:get_password_scram(
|
case catch sql_queries:get_password_scram(
|
||||||
LServer, LUser) of
|
LServer, LUser) of
|
||||||
{selected,
|
{selected,
|
||||||
[{StoredKey, ServerKey, Salt, IterationCount}]} ->
|
[{StoredKey, ServerKey, Salt, IterationCount}]} ->
|
||||||
@ -294,7 +294,7 @@ get_password(User, Server) ->
|
|||||||
_ -> false
|
_ -> false
|
||||||
end;
|
end;
|
||||||
false ->
|
false ->
|
||||||
case catch odbc_queries:get_password(LServer, LUser)
|
case catch sql_queries:get_password(LServer, LUser)
|
||||||
of
|
of
|
||||||
{selected, [{Password}]} -> Password;
|
{selected, [{Password}]} -> Password;
|
||||||
_ -> false
|
_ -> false
|
||||||
@ -312,7 +312,7 @@ get_password_s(User, Server) ->
|
|||||||
true ->
|
true ->
|
||||||
case is_scrammed() of
|
case is_scrammed() of
|
||||||
false ->
|
false ->
|
||||||
case catch odbc_queries:get_password(LServer, LUser) of
|
case catch sql_queries:get_password(LServer, LUser) of
|
||||||
{selected, [{Password}]} -> Password;
|
{selected, [{Password}]} -> Password;
|
||||||
_ -> <<"">>
|
_ -> <<"">>
|
||||||
end;
|
end;
|
||||||
@ -329,7 +329,7 @@ is_user_exists(User, Server) ->
|
|||||||
(LUser == <<>>) or (LServer == <<>>) ->
|
(LUser == <<>>) or (LServer == <<>>) ->
|
||||||
false;
|
false;
|
||||||
true ->
|
true ->
|
||||||
try odbc_queries:get_password(LServer, LUser) of
|
try sql_queries:get_password(LServer, LUser) of
|
||||||
{selected, [{_Password}]} ->
|
{selected, [{_Password}]} ->
|
||||||
true; %% Account exists
|
true; %% Account exists
|
||||||
{selected, []} ->
|
{selected, []} ->
|
||||||
@ -351,7 +351,7 @@ remove_user(User, Server) ->
|
|||||||
(LUser == <<>>) or (LServer == <<>>) ->
|
(LUser == <<>>) or (LServer == <<>>) ->
|
||||||
error;
|
error;
|
||||||
true ->
|
true ->
|
||||||
catch odbc_queries:del_user(LServer, LUser),
|
catch sql_queries:del_user(LServer, LUser),
|
||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -375,7 +375,7 @@ remove_user(User, Server, Password) ->
|
|||||||
end;
|
end;
|
||||||
false ->
|
false ->
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
Result = odbc_queries:del_user_return_password(
|
Result = sql_queries:del_user_return_password(
|
||||||
LServer, LUser, Password),
|
LServer, LUser, Password),
|
||||||
case Result of
|
case Result of
|
||||||
{selected, [{Password}]} -> ok;
|
{selected, [{Password}]} -> ok;
|
||||||
@ -383,7 +383,7 @@ remove_user(User, Server, Password) ->
|
|||||||
_ -> not_allowed
|
_ -> not_allowed
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
{atomic, Result} = odbc_queries:sql_transaction(
|
{atomic, Result} = sql_queries:sql_transaction(
|
||||||
LServer, F),
|
LServer, F),
|
||||||
Result
|
Result
|
||||||
end
|
end
|
||||||
@ -427,7 +427,7 @@ is_password_scram_valid(Password, Scram) ->
|
|||||||
|
|
||||||
set_password_scram_t(Username,
|
set_password_scram_t(Username,
|
||||||
StoredKey, ServerKey, Salt, IterationCount) ->
|
StoredKey, ServerKey, Salt, IterationCount) ->
|
||||||
odbc_queries:update_t(<<"users">>,
|
sql_queries:update_t(<<"users">>,
|
||||||
[<<"username">>,
|
[<<"username">>,
|
||||||
<<"password">>,
|
<<"password">>,
|
||||||
<<"serverkey">>,
|
<<"serverkey">>,
|
||||||
@ -447,7 +447,7 @@ convert_to_scram(Server) ->
|
|||||||
{error, {incorrect_server_name, Server}};
|
{error, {incorrect_server_name, Server}};
|
||||||
true ->
|
true ->
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
case ejabberd_odbc:sql_query_t(
|
case ejabberd_sql:sql_query_t(
|
||||||
[<<"select username, password from users where "
|
[<<"select username, password from users where "
|
||||||
"iterationcount=0 limit ">>,
|
"iterationcount=0 limit ">>,
|
||||||
integer_to_binary(?BATCH_SIZE),
|
integer_to_binary(?BATCH_SIZE),
|
||||||
@ -457,13 +457,13 @@ convert_to_scram(Server) ->
|
|||||||
{selected, [<<"username">>, <<"password">>], Rs} ->
|
{selected, [<<"username">>, <<"password">>], Rs} ->
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun([LUser, Password]) ->
|
fun([LUser, Password]) ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
Scram = password_to_scram(Password),
|
Scram = password_to_scram(Password),
|
||||||
set_password_scram_t(
|
set_password_scram_t(
|
||||||
Username,
|
Username,
|
||||||
ejabberd_odbc:escape(Scram#scram.storedkey),
|
ejabberd_sql:escape(Scram#scram.storedkey),
|
||||||
ejabberd_odbc:escape(Scram#scram.serverkey),
|
ejabberd_sql:escape(Scram#scram.serverkey),
|
||||||
ejabberd_odbc:escape(Scram#scram.salt),
|
ejabberd_sql:escape(Scram#scram.salt),
|
||||||
integer_to_binary(Scram#scram.iterationcount)
|
integer_to_binary(Scram#scram.iterationcount)
|
||||||
)
|
)
|
||||||
end, Rs),
|
end, Rs),
|
||||||
@ -471,7 +471,7 @@ convert_to_scram(Server) ->
|
|||||||
Err -> {bad_reply, Err}
|
Err -> {bad_reply, Err}
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
case odbc_queries:sql_transaction(LServer, F) of
|
case sql_queries:sql_transaction(LServer, F) of
|
||||||
{atomic, ok} -> ok;
|
{atomic, ok} -> ok;
|
||||||
{atomic, continue} -> convert_to_scram(Server);
|
{atomic, continue} -> convert_to_scram(Server);
|
||||||
{atomic, Error} -> {error, Error};
|
{atomic, Error} -> {error, Error};
|
@ -651,14 +651,27 @@ process_host_term(Term, Host, State, Action) ->
|
|||||||
{hosts, _} ->
|
{hosts, _} ->
|
||||||
State;
|
State;
|
||||||
{Opt, Val} when Action == set ->
|
{Opt, Val} when Action == set ->
|
||||||
set_option({Opt, Host}, Val, State);
|
set_option({rename_option(Opt), Host}, Val, State);
|
||||||
{Opt, Val} when Action == append ->
|
{Opt, Val} when Action == append ->
|
||||||
append_option({Opt, Host}, Val, State);
|
append_option({rename_option(Opt), Host}, Val, State);
|
||||||
Opt ->
|
Opt ->
|
||||||
?WARNING_MSG("Ignore invalid (outdated?) option ~p", [Opt]),
|
?WARNING_MSG("Ignore invalid (outdated?) option ~p", [Opt]),
|
||||||
State
|
State
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
rename_option(Option) when is_atom(Option) ->
|
||||||
|
case atom_to_list(Option) of
|
||||||
|
"odbc_" ++ T ->
|
||||||
|
NewOption = list_to_atom("sql_" ++ T),
|
||||||
|
?WARNING_MSG("Option '~s' is obsoleted, use '~s' instead",
|
||||||
|
[Option, NewOption]),
|
||||||
|
NewOption;
|
||||||
|
_ ->
|
||||||
|
Option
|
||||||
|
end;
|
||||||
|
rename_option(Option) ->
|
||||||
|
Option.
|
||||||
|
|
||||||
set_option(Opt, Val, State) ->
|
set_option(Opt, Val, State) ->
|
||||||
State#state{opts = [#local_config{key = Opt, value = Val} |
|
State#state{opts = [#local_config{key = Opt, value = Val} |
|
||||||
State#state.opts]}.
|
State#state.opts]}.
|
||||||
@ -867,20 +880,20 @@ get_mylang() ->
|
|||||||
fun iolist_to_binary/1,
|
fun iolist_to_binary/1,
|
||||||
<<"en">>).
|
<<"en">>).
|
||||||
|
|
||||||
replace_module(mod_announce_odbc) -> {mod_announce, odbc};
|
replace_module(mod_announce_odbc) -> {mod_announce, sql};
|
||||||
replace_module(mod_blocking_odbc) -> {mod_blocking, odbc};
|
replace_module(mod_blocking_odbc) -> {mod_blocking, sql};
|
||||||
replace_module(mod_caps_odbc) -> {mod_caps, odbc};
|
replace_module(mod_caps_odbc) -> {mod_caps, sql};
|
||||||
replace_module(mod_irc_odbc) -> {mod_irc, odbc};
|
replace_module(mod_irc_odbc) -> {mod_irc, sql};
|
||||||
replace_module(mod_last_odbc) -> {mod_last, odbc};
|
replace_module(mod_last_odbc) -> {mod_last, sql};
|
||||||
replace_module(mod_muc_odbc) -> {mod_muc, odbc};
|
replace_module(mod_muc_odbc) -> {mod_muc, sql};
|
||||||
replace_module(mod_offline_odbc) -> {mod_offline, odbc};
|
replace_module(mod_offline_odbc) -> {mod_offline, sql};
|
||||||
replace_module(mod_privacy_odbc) -> {mod_privacy, odbc};
|
replace_module(mod_privacy_odbc) -> {mod_privacy, sql};
|
||||||
replace_module(mod_private_odbc) -> {mod_private, odbc};
|
replace_module(mod_private_odbc) -> {mod_private, sql};
|
||||||
replace_module(mod_roster_odbc) -> {mod_roster, odbc};
|
replace_module(mod_roster_odbc) -> {mod_roster, sql};
|
||||||
replace_module(mod_shared_roster_odbc) -> {mod_shared_roster, odbc};
|
replace_module(mod_shared_roster_odbc) -> {mod_shared_roster, sql};
|
||||||
replace_module(mod_vcard_odbc) -> {mod_vcard, odbc};
|
replace_module(mod_vcard_odbc) -> {mod_vcard, sql};
|
||||||
replace_module(mod_vcard_xupdate_odbc) -> {mod_vcard_xupdate, odbc};
|
replace_module(mod_vcard_xupdate_odbc) -> {mod_vcard_xupdate, sql};
|
||||||
replace_module(mod_pubsub_odbc) -> {mod_pubsub, odbc};
|
replace_module(mod_pubsub_odbc) -> {mod_pubsub, sql};
|
||||||
replace_module(Module) ->
|
replace_module(Module) ->
|
||||||
case is_elixir_module(Module) of
|
case is_elixir_module(Module) of
|
||||||
true -> expand_elixir_module(Module);
|
true -> expand_elixir_module(Module);
|
||||||
@ -985,7 +998,7 @@ transform_terms(Terms) ->
|
|||||||
mod_last,
|
mod_last,
|
||||||
ejabberd_s2s,
|
ejabberd_s2s,
|
||||||
ejabberd_listener,
|
ejabberd_listener,
|
||||||
ejabberd_odbc_sup,
|
ejabberd_sql_sup,
|
||||||
shaper,
|
shaper,
|
||||||
ejabberd_s2s_out,
|
ejabberd_s2s_out,
|
||||||
acl,
|
acl,
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
|
|
||||||
%%% Not implemented:
|
%%% Not implemented:
|
||||||
%%% - write mod_piefxis with ejabberdctl commands
|
%%% - write mod_piefxis with ejabberdctl commands
|
||||||
%%% - Export from mod_offline_odbc.erl
|
%%% - Export from mod_offline_sql.erl
|
||||||
%%% - Export from mod_private_odbc.erl
|
%%% - Export from mod_private_sql.erl
|
||||||
%%% - XEP-227: 6. Security Considerations
|
%%% - XEP-227: 6. Security Considerations
|
||||||
%%% - Other schemas of XInclude are not tested, and may not be imported correctly.
|
%%% - Other schemas of XInclude are not tested, and may not be imported correctly.
|
||||||
%%% - If a host has many users, split that host in XML files with 50 users each.
|
%%% - If a host has many users, split that host in XML files with 50 users each.
|
||||||
|
@ -35,10 +35,10 @@
|
|||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
|
|
||||||
start() ->
|
start() ->
|
||||||
file:delete(ejabberd_odbc:freetds_config()),
|
file:delete(ejabberd_sql:freetds_config()),
|
||||||
file:delete(ejabberd_odbc:odbc_config()),
|
file:delete(ejabberd_sql:odbc_config()),
|
||||||
file:delete(ejabberd_odbc:odbcinst_config()),
|
file:delete(ejabberd_sql:odbcinst_config()),
|
||||||
case lists:any(fun(H) -> needs_odbc(H) /= false end,
|
case lists:any(fun(H) -> needs_sql(H) /= false end,
|
||||||
?MYHOSTS) of
|
?MYHOSTS) of
|
||||||
true ->
|
true ->
|
||||||
start_hosts();
|
start_hosts();
|
||||||
@ -49,34 +49,34 @@ start() ->
|
|||||||
%% Start relationnal DB module on the nodes where it is needed
|
%% Start relationnal DB module on the nodes where it is needed
|
||||||
start_hosts() ->
|
start_hosts() ->
|
||||||
lists:foreach(fun (Host) ->
|
lists:foreach(fun (Host) ->
|
||||||
case needs_odbc(Host) of
|
case needs_sql(Host) of
|
||||||
{true, App} -> start_odbc(Host, App);
|
{true, App} -> start_sql(Host, App);
|
||||||
false -> ok
|
false -> ok
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
?MYHOSTS).
|
?MYHOSTS).
|
||||||
|
|
||||||
%% Start the ODBC module on the given host
|
%% Start the SQL module on the given host
|
||||||
start_odbc(Host, App) ->
|
start_sql(Host, App) ->
|
||||||
ejabberd:start_app(App),
|
ejabberd:start_app(App),
|
||||||
Supervisor_name = gen_mod:get_module_proc(Host,
|
Supervisor_name = gen_mod:get_module_proc(Host,
|
||||||
ejabberd_odbc_sup),
|
ejabberd_sql_sup),
|
||||||
ChildSpec = {Supervisor_name,
|
ChildSpec = {Supervisor_name,
|
||||||
{ejabberd_odbc_sup, start_link, [Host]}, transient,
|
{ejabberd_sql_sup, start_link, [Host]}, transient,
|
||||||
infinity, supervisor, [ejabberd_odbc_sup]},
|
infinity, supervisor, [ejabberd_sql_sup]},
|
||||||
case supervisor:start_child(ejabberd_sup, ChildSpec) of
|
case supervisor:start_child(ejabberd_sup, ChildSpec) of
|
||||||
{ok, _PID} -> ok;
|
{ok, _PID} -> ok;
|
||||||
_Error ->
|
_Error ->
|
||||||
?ERROR_MSG("Start of supervisor ~p failed:~n~p~nRetrying."
|
?ERROR_MSG("Start of supervisor ~p failed:~n~p~nRetrying."
|
||||||
"..~n",
|
"..~n",
|
||||||
[Supervisor_name, _Error]),
|
[Supervisor_name, _Error]),
|
||||||
start_odbc(Host, App)
|
start_sql(Host, App)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% Returns {true, App} if we have configured odbc for the given host
|
%% Returns {true, App} if we have configured sql for the given host
|
||||||
needs_odbc(Host) ->
|
needs_sql(Host) ->
|
||||||
LHost = jid:nameprep(Host),
|
LHost = jid:nameprep(Host),
|
||||||
case ejabberd_config:get_option({odbc_type, LHost},
|
case ejabberd_config:get_option({sql_type, LHost},
|
||||||
fun(mysql) -> mysql;
|
fun(mysql) -> mysql;
|
||||||
(pgsql) -> pgsql;
|
(pgsql) -> pgsql;
|
||||||
(sqlite) -> sqlite;
|
(sqlite) -> sqlite;
|
||||||
@ -91,11 +91,11 @@ needs_odbc(Host) ->
|
|||||||
undefined -> false
|
undefined -> false
|
||||||
end.
|
end.
|
||||||
|
|
||||||
opt_type(odbc_type) ->
|
opt_type(sql_type) ->
|
||||||
fun (mysql) -> mysql;
|
fun (mysql) -> mysql;
|
||||||
(pgsql) -> pgsql;
|
(pgsql) -> pgsql;
|
||||||
(sqlite) -> sqlite;
|
(sqlite) -> sqlite;
|
||||||
(mssql) -> mssql;
|
(mssql) -> mssql;
|
||||||
(odbc) -> odbc
|
(odbc) -> odbc
|
||||||
end;
|
end;
|
||||||
opt_type(_) -> [odbc_type].
|
opt_type(_) -> [sql_type].
|
||||||
|
@ -814,7 +814,8 @@ make_sid() ->
|
|||||||
opt_type(sm_db_type) ->
|
opt_type(sm_db_type) ->
|
||||||
fun (mnesia) -> mnesia;
|
fun (mnesia) -> mnesia;
|
||||||
(internal) -> mnesia;
|
(internal) -> mnesia;
|
||||||
(odbc) -> odbc;
|
(sql) -> sql;
|
||||||
|
(odbc) -> sql;
|
||||||
(redis) -> redis
|
(redis) -> redis
|
||||||
end;
|
end;
|
||||||
opt_type(_) -> [sm_db_type].
|
opt_type(_) -> [sm_db_type].
|
||||||
|
@ -29,11 +29,11 @@
|
|||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
-spec init() -> ok | {error, any()}.
|
-spec init() -> ok | {error, any()}.
|
||||||
init() ->
|
init() ->
|
||||||
Node = ejabberd_odbc:escape(jlib:atom_to_binary(node())),
|
Node = ejabberd_sql:escape(jlib:atom_to_binary(node())),
|
||||||
?INFO_MSG("Cleaning SQL SM table...", []),
|
?INFO_MSG("Cleaning SQL SM table...", []),
|
||||||
lists:foldl(
|
lists:foldl(
|
||||||
fun(Host, ok) ->
|
fun(Host, ok) ->
|
||||||
case ejabberd_odbc:sql_query(
|
case ejabberd_sql:sql_query(
|
||||||
Host, [<<"delete from sm where node='">>, Node, <<"'">>]) of
|
Host, [<<"delete from sm where node='">>, Node, <<"'">>]) of
|
||||||
{updated, _} ->
|
{updated, _} ->
|
||||||
ok;
|
ok;
|
||||||
@ -47,14 +47,14 @@ init() ->
|
|||||||
|
|
||||||
set_session(#session{sid = {Now, Pid}, usr = {U, LServer, R},
|
set_session(#session{sid = {Now, Pid}, usr = {U, LServer, R},
|
||||||
priority = Priority, info = Info}) ->
|
priority = Priority, info = Info}) ->
|
||||||
Username = ejabberd_odbc:escape(U),
|
Username = ejabberd_sql:escape(U),
|
||||||
Resource = ejabberd_odbc:escape(R),
|
Resource = ejabberd_sql:escape(R),
|
||||||
InfoS = ejabberd_odbc:encode_term(Info),
|
InfoS = ejabberd_sql:encode_term(Info),
|
||||||
PrioS = enc_priority(Priority),
|
PrioS = enc_priority(Priority),
|
||||||
TS = now_to_timestamp(Now),
|
TS = now_to_timestamp(Now),
|
||||||
PidS = list_to_binary(erlang:pid_to_list(Pid)),
|
PidS = list_to_binary(erlang:pid_to_list(Pid)),
|
||||||
Node = ejabberd_odbc:escape(jlib:atom_to_binary(node(Pid))),
|
Node = ejabberd_sql:escape(jlib:atom_to_binary(node(Pid))),
|
||||||
case odbc_queries:update(
|
case sql_queries:update(
|
||||||
LServer,
|
LServer,
|
||||||
<<"sm">>,
|
<<"sm">>,
|
||||||
[<<"usec">>, <<"pid">>, <<"node">>, <<"username">>,
|
[<<"usec">>, <<"pid">>, <<"node">>, <<"username">>,
|
||||||
@ -70,12 +70,12 @@ set_session(#session{sid = {Now, Pid}, usr = {U, LServer, R},
|
|||||||
delete_session(_LUser, LServer, _LResource, {Now, Pid}) ->
|
delete_session(_LUser, LServer, _LResource, {Now, Pid}) ->
|
||||||
TS = now_to_timestamp(Now),
|
TS = now_to_timestamp(Now),
|
||||||
PidS = list_to_binary(erlang:pid_to_list(Pid)),
|
PidS = list_to_binary(erlang:pid_to_list(Pid)),
|
||||||
case ejabberd_odbc:sql_query(
|
case ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
[<<"select usec, pid, username, resource, priority, info ">>,
|
[<<"select usec, pid, username, resource, priority, info ">>,
|
||||||
<<"from sm where usec='">>, TS, <<"' and pid='">>,PidS, <<"'">>]) of
|
<<"from sm where usec='">>, TS, <<"' and pid='">>,PidS, <<"'">>]) of
|
||||||
{selected, _, [Row]} ->
|
{selected, _, [Row]} ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer, [<<"delete from sm where usec='">>,
|
LServer, [<<"delete from sm where usec='">>,
|
||||||
TS, <<"' and pid='">>, PidS, <<"'">>]),
|
TS, <<"' and pid='">>, PidS, <<"'">>]),
|
||||||
{ok, row_to_session(LServer, Row)};
|
{ok, row_to_session(LServer, Row)};
|
||||||
@ -93,7 +93,7 @@ get_sessions() ->
|
|||||||
end, ejabberd_sm:get_vh_by_backend(?MODULE)).
|
end, ejabberd_sm:get_vh_by_backend(?MODULE)).
|
||||||
|
|
||||||
get_sessions(LServer) ->
|
get_sessions(LServer) ->
|
||||||
case ejabberd_odbc:sql_query(
|
case ejabberd_sql:sql_query(
|
||||||
LServer, [<<"select usec, pid, username, ">>,
|
LServer, [<<"select usec, pid, username, ">>,
|
||||||
<<"resource, priority, info from sm">>]) of
|
<<"resource, priority, info from sm">>]) of
|
||||||
{selected, _, Rows} ->
|
{selected, _, Rows} ->
|
||||||
@ -104,8 +104,8 @@ get_sessions(LServer) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
get_sessions(LUser, LServer) ->
|
get_sessions(LUser, LServer) ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
case ejabberd_odbc:sql_query(
|
case ejabberd_sql:sql_query(
|
||||||
LServer, [<<"select usec, pid, username, ">>,
|
LServer, [<<"select usec, pid, username, ">>,
|
||||||
<<"resource, priority, info from sm where ">>,
|
<<"resource, priority, info from sm where ">>,
|
||||||
<<"username='">>, Username, <<"'">>]) of
|
<<"username='">>, Username, <<"'">>]) of
|
||||||
@ -117,9 +117,9 @@ get_sessions(LUser, LServer) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
get_sessions(LUser, LServer, LResource) ->
|
get_sessions(LUser, LServer, LResource) ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
Resource = ejabberd_odbc:escape(LResource),
|
Resource = ejabberd_sql:escape(LResource),
|
||||||
case ejabberd_odbc:sql_query(
|
case ejabberd_sql:sql_query(
|
||||||
LServer, [<<"select usec, pid, username, ">>,
|
LServer, [<<"select usec, pid, username, ">>,
|
||||||
<<"resource, priority, info from sm where ">>,
|
<<"resource, priority, info from sm where ">>,
|
||||||
<<"username='">>, Username, <<"' and resource='">>,
|
<<"username='">>, Username, <<"' and resource='">>,
|
||||||
@ -162,7 +162,7 @@ row_to_session(LServer, [USec, PidS, User, Resource, PrioS, InfoS]) ->
|
|||||||
Now = timestamp_to_now(USec),
|
Now = timestamp_to_now(USec),
|
||||||
Pid = erlang:list_to_pid(binary_to_list(PidS)),
|
Pid = erlang:list_to_pid(binary_to_list(PidS)),
|
||||||
Priority = dec_priority(PrioS),
|
Priority = dec_priority(PrioS),
|
||||||
Info = ejabberd_odbc:decode_term(InfoS),
|
Info = ejabberd_sql:decode_term(InfoS),
|
||||||
#session{sid = {Now, Pid}, us = {User, LServer},
|
#session{sid = {Now, Pid}, us = {User, LServer},
|
||||||
usr = {User, LServer, Resource},
|
usr = {User, LServer, Resource},
|
||||||
priority = Priority,
|
priority = Priority,
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
%%%
|
%%%
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
-module(ejabberd_odbc).
|
-module(ejabberd_sql).
|
||||||
|
|
||||||
-behaviour(ejabberd_config).
|
-behaviour(ejabberd_config).
|
||||||
|
|
||||||
@ -75,9 +75,9 @@
|
|||||||
max_pending_requests_len :: non_neg_integer(),
|
max_pending_requests_len :: non_neg_integer(),
|
||||||
pending_requests = {0, queue:new()} :: {non_neg_integer(), ?TQUEUE}}).
|
pending_requests = {0, queue:new()} :: {non_neg_integer(), ?TQUEUE}}).
|
||||||
|
|
||||||
-define(STATE_KEY, ejabberd_odbc_state).
|
-define(STATE_KEY, ejabberd_sql_state).
|
||||||
|
|
||||||
-define(NESTING_KEY, ejabberd_odbc_nesting_level).
|
-define(NESTING_KEY, ejabberd_sql_nesting_level).
|
||||||
|
|
||||||
-define(TOP_LEVEL_TXN, 0).
|
-define(TOP_LEVEL_TXN, 0).
|
||||||
|
|
||||||
@ -95,7 +95,7 @@
|
|||||||
|
|
||||||
-define(KEEPALIVE_QUERY, [<<"SELECT 1;">>]).
|
-define(KEEPALIVE_QUERY, [<<"SELECT 1;">>]).
|
||||||
|
|
||||||
-define(PREPARE_KEY, ejabberd_odbc_prepare).
|
-define(PREPARE_KEY, ejabberd_sql_prepare).
|
||||||
|
|
||||||
%%-define(DBGFSM, true).
|
%%-define(DBGFSM, true).
|
||||||
|
|
||||||
@ -113,11 +113,11 @@
|
|||||||
%%% API
|
%%% API
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
start(Host) ->
|
start(Host) ->
|
||||||
(?GEN_FSM):start(ejabberd_odbc, [Host],
|
(?GEN_FSM):start(ejabberd_sql, [Host],
|
||||||
fsm_limit_opts() ++ (?FSMOPTS)).
|
fsm_limit_opts() ++ (?FSMOPTS)).
|
||||||
|
|
||||||
start_link(Host, StartInterval) ->
|
start_link(Host, StartInterval) ->
|
||||||
(?GEN_FSM):start_link(ejabberd_odbc,
|
(?GEN_FSM):start_link(ejabberd_sql,
|
||||||
[Host, StartInterval],
|
[Host, StartInterval],
|
||||||
fsm_limit_opts() ++ (?FSMOPTS)).
|
fsm_limit_opts() ++ (?FSMOPTS)).
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ sql_bloc(Host, F) -> sql_call(Host, {sql_bloc, F}).
|
|||||||
sql_call(Host, Msg) ->
|
sql_call(Host, Msg) ->
|
||||||
case get(?STATE_KEY) of
|
case get(?STATE_KEY) of
|
||||||
undefined ->
|
undefined ->
|
||||||
case ejabberd_odbc_sup:get_random_pid(Host) of
|
case ejabberd_sql_sup:get_random_pid(Host) of
|
||||||
none -> {error, <<"Unknown Host">>};
|
none -> {error, <<"Unknown Host">>};
|
||||||
Pid ->
|
Pid ->
|
||||||
(?GEN_FSM):sync_send_event(Pid,{sql_cmd, Msg,
|
(?GEN_FSM):sync_send_event(Pid,{sql_cmd, Msg,
|
||||||
@ -190,7 +190,7 @@ sql_query_t(Query) ->
|
|||||||
|
|
||||||
%% Escape character that will confuse an SQL engine
|
%% Escape character that will confuse an SQL engine
|
||||||
escape(S) ->
|
escape(S) ->
|
||||||
<< <<(odbc_queries:escape(Char))/binary>> || <<Char>> <= S >>.
|
<< <<(sql_queries:escape(Char))/binary>> || <<Char>> <= S >>.
|
||||||
|
|
||||||
%% Escape character that will confuse an SQL engine
|
%% Escape character that will confuse an SQL engine
|
||||||
%% Percent and underscore only need to be escaped for pattern matching like
|
%% Percent and underscore only need to be escaped for pattern matching like
|
||||||
@ -199,7 +199,7 @@ escape_like(S) when is_binary(S) ->
|
|||||||
<< <<(escape_like(C))/binary>> || <<C>> <= S >>;
|
<< <<(escape_like(C))/binary>> || <<C>> <= S >>;
|
||||||
escape_like($%) -> <<"\\%">>;
|
escape_like($%) -> <<"\\%">>;
|
||||||
escape_like($_) -> <<"\\_">>;
|
escape_like($_) -> <<"\\_">>;
|
||||||
escape_like(C) when is_integer(C), C >= 0, C =< 255 -> odbc_queries:escape(C).
|
escape_like(C) when is_integer(C), C >= 0, C =< 255 -> sql_queries:escape(C).
|
||||||
|
|
||||||
escape_like_arg(S) when is_binary(S) ->
|
escape_like_arg(S) when is_binary(S) ->
|
||||||
<< <<(escape_like_arg(C))/binary>> || <<C>> <= S >>;
|
<< <<(escape_like_arg(C))/binary>> || <<C>> <= S >>;
|
||||||
@ -232,7 +232,7 @@ sqlite_db(Host) ->
|
|||||||
|
|
||||||
-spec sqlite_file(binary()) -> string().
|
-spec sqlite_file(binary()) -> string().
|
||||||
sqlite_file(Host) ->
|
sqlite_file(Host) ->
|
||||||
case ejabberd_config:get_option({odbc_database, Host},
|
case ejabberd_config:get_option({sql_database, Host},
|
||||||
fun iolist_to_binary/1) of
|
fun iolist_to_binary/1) of
|
||||||
undefined ->
|
undefined ->
|
||||||
{ok, Cwd} = file:get_cwd(),
|
{ok, Cwd} = file:get_cwd(),
|
||||||
@ -247,7 +247,7 @@ sqlite_file(Host) ->
|
|||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
init([Host, StartInterval]) ->
|
init([Host, StartInterval]) ->
|
||||||
case ejabberd_config:get_option(
|
case ejabberd_config:get_option(
|
||||||
{odbc_keepalive_interval, Host},
|
{sql_keepalive_interval, Host},
|
||||||
fun(I) when is_integer(I), I>0 -> I end) of
|
fun(I) when is_integer(I), I>0 -> I end) of
|
||||||
undefined ->
|
undefined ->
|
||||||
ok;
|
ok;
|
||||||
@ -257,7 +257,7 @@ init([Host, StartInterval]) ->
|
|||||||
end,
|
end,
|
||||||
[DBType | _] = db_opts(Host),
|
[DBType | _] = db_opts(Host),
|
||||||
(?GEN_FSM):send_event(self(), connect),
|
(?GEN_FSM):send_event(self(), connect),
|
||||||
ejabberd_odbc_sup:add_pid(Host, self()),
|
ejabberd_sql_sup:add_pid(Host, self()),
|
||||||
{ok, connecting,
|
{ok, connecting,
|
||||||
#state{db_type = DBType, host = Host,
|
#state{db_type = DBType, host = Host,
|
||||||
max_pending_requests_len = max_fsm_queue(),
|
max_pending_requests_len = max_fsm_queue(),
|
||||||
@ -371,7 +371,7 @@ handle_info(Info, StateName, State) ->
|
|||||||
{next_state, StateName, State}.
|
{next_state, StateName, State}.
|
||||||
|
|
||||||
terminate(_Reason, _StateName, State) ->
|
terminate(_Reason, _StateName, State) ->
|
||||||
ejabberd_odbc_sup:remove_pid(State#state.host, self()),
|
ejabberd_sql_sup:remove_pid(State#state.host, self()),
|
||||||
case State#state.db_type of
|
case State#state.db_type of
|
||||||
mysql -> catch p1_mysql_conn:stop(State#state.db_ref);
|
mysql -> catch p1_mysql_conn:stop(State#state.db_ref);
|
||||||
sqlite -> catch sqlite3:close(sqlite_db(State#state.host));
|
sqlite -> catch sqlite3:close(sqlite_db(State#state.host));
|
||||||
@ -869,14 +869,14 @@ log(Level, Format, Args) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
db_opts(Host) ->
|
db_opts(Host) ->
|
||||||
Type = ejabberd_config:get_option({odbc_type, Host},
|
Type = ejabberd_config:get_option({sql_type, Host},
|
||||||
fun(mysql) -> mysql;
|
fun(mysql) -> mysql;
|
||||||
(pgsql) -> pgsql;
|
(pgsql) -> pgsql;
|
||||||
(sqlite) -> sqlite;
|
(sqlite) -> sqlite;
|
||||||
(mssql) -> mssql;
|
(mssql) -> mssql;
|
||||||
(odbc) -> odbc
|
(odbc) -> odbc
|
||||||
end, odbc),
|
end, odbc),
|
||||||
Server = ejabberd_config:get_option({odbc_server, Host},
|
Server = ejabberd_config:get_option({sql_server, Host},
|
||||||
fun iolist_to_binary/1,
|
fun iolist_to_binary/1,
|
||||||
<<"localhost">>),
|
<<"localhost">>),
|
||||||
case Type of
|
case Type of
|
||||||
@ -886,20 +886,20 @@ db_opts(Host) ->
|
|||||||
[sqlite, Host];
|
[sqlite, Host];
|
||||||
_ ->
|
_ ->
|
||||||
Port = ejabberd_config:get_option(
|
Port = ejabberd_config:get_option(
|
||||||
{odbc_port, Host},
|
{sql_port, Host},
|
||||||
fun(P) when is_integer(P), P > 0, P < 65536 -> P end,
|
fun(P) when is_integer(P), P > 0, P < 65536 -> P end,
|
||||||
case Type of
|
case Type of
|
||||||
mssql -> ?MSSQL_PORT;
|
mssql -> ?MSSQL_PORT;
|
||||||
mysql -> ?MYSQL_PORT;
|
mysql -> ?MYSQL_PORT;
|
||||||
pgsql -> ?PGSQL_PORT
|
pgsql -> ?PGSQL_PORT
|
||||||
end),
|
end),
|
||||||
DB = ejabberd_config:get_option({odbc_database, Host},
|
DB = ejabberd_config:get_option({sql_database, Host},
|
||||||
fun iolist_to_binary/1,
|
fun iolist_to_binary/1,
|
||||||
<<"ejabberd">>),
|
<<"ejabberd">>),
|
||||||
User = ejabberd_config:get_option({odbc_username, Host},
|
User = ejabberd_config:get_option({sql_username, Host},
|
||||||
fun iolist_to_binary/1,
|
fun iolist_to_binary/1,
|
||||||
<<"ejabberd">>),
|
<<"ejabberd">>),
|
||||||
Pass = ejabberd_config:get_option({odbc_password, Host},
|
Pass = ejabberd_config:get_option({sql_password, Host},
|
||||||
fun iolist_to_binary/1,
|
fun iolist_to_binary/1,
|
||||||
<<"">>),
|
<<"">>),
|
||||||
case Type of
|
case Type of
|
||||||
@ -912,14 +912,14 @@ db_opts(Host) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
init_mssql(Host) ->
|
init_mssql(Host) ->
|
||||||
Server = ejabberd_config:get_option({odbc_server, Host},
|
Server = ejabberd_config:get_option({sql_server, Host},
|
||||||
fun iolist_to_binary/1,
|
fun iolist_to_binary/1,
|
||||||
<<"localhost">>),
|
<<"localhost">>),
|
||||||
Port = ejabberd_config:get_option(
|
Port = ejabberd_config:get_option(
|
||||||
{odbc_port, Host},
|
{sql_port, Host},
|
||||||
fun(P) when is_integer(P), P > 0, P < 65536 -> P end,
|
fun(P) when is_integer(P), P > 0, P < 65536 -> P end,
|
||||||
?MSSQL_PORT),
|
?MSSQL_PORT),
|
||||||
DB = ejabberd_config:get_option({odbc_database, Host},
|
DB = ejabberd_config:get_option({sql_database, Host},
|
||||||
fun iolist_to_binary/1,
|
fun iolist_to_binary/1,
|
||||||
<<"ejabberd">>),
|
<<"ejabberd">>),
|
||||||
FreeTDS = io_lib:fwrite("[~s]~n"
|
FreeTDS = io_lib:fwrite("[~s]~n"
|
||||||
@ -1004,22 +1004,22 @@ check_error(Result, _Query) ->
|
|||||||
|
|
||||||
opt_type(max_fsm_queue) ->
|
opt_type(max_fsm_queue) ->
|
||||||
fun (N) when is_integer(N), N > 0 -> N end;
|
fun (N) when is_integer(N), N > 0 -> N end;
|
||||||
opt_type(odbc_database) -> fun iolist_to_binary/1;
|
opt_type(sql_database) -> fun iolist_to_binary/1;
|
||||||
opt_type(odbc_keepalive_interval) ->
|
opt_type(sql_keepalive_interval) ->
|
||||||
fun (I) when is_integer(I), I > 0 -> I end;
|
fun (I) when is_integer(I), I > 0 -> I end;
|
||||||
opt_type(odbc_password) -> fun iolist_to_binary/1;
|
opt_type(sql_password) -> fun iolist_to_binary/1;
|
||||||
opt_type(odbc_port) ->
|
opt_type(sql_port) ->
|
||||||
fun (P) when is_integer(P), P > 0, P < 65536 -> P end;
|
fun (P) when is_integer(P), P > 0, P < 65536 -> P end;
|
||||||
opt_type(odbc_server) -> fun iolist_to_binary/1;
|
opt_type(sql_server) -> fun iolist_to_binary/1;
|
||||||
opt_type(odbc_type) ->
|
opt_type(sql_type) ->
|
||||||
fun (mysql) -> mysql;
|
fun (mysql) -> mysql;
|
||||||
(pgsql) -> pgsql;
|
(pgsql) -> pgsql;
|
||||||
(sqlite) -> sqlite;
|
(sqlite) -> sqlite;
|
||||||
(mssql) -> mssql;
|
(mssql) -> mssql;
|
||||||
(odbc) -> odbc
|
(odbc) -> odbc
|
||||||
end;
|
end;
|
||||||
opt_type(odbc_username) -> fun iolist_to_binary/1;
|
opt_type(sql_username) -> fun iolist_to_binary/1;
|
||||||
opt_type(_) ->
|
opt_type(_) ->
|
||||||
[max_fsm_queue, odbc_database, odbc_keepalive_interval,
|
[max_fsm_queue, sql_database, sql_keepalive_interval,
|
||||||
odbc_password, odbc_port, odbc_server, odbc_type,
|
sql_password, sql_port, sql_server, sql_type,
|
||||||
odbc_username].
|
sql_username].
|
@ -163,7 +163,7 @@ parse1([$@, $( | S], Acc, State) ->
|
|||||||
EVar;
|
EVar;
|
||||||
boolean ->
|
boolean ->
|
||||||
erl_syntax:application(
|
erl_syntax:application(
|
||||||
erl_syntax:atom(ejabberd_odbc),
|
erl_syntax:atom(ejabberd_sql),
|
||||||
erl_syntax:atom(to_bool),
|
erl_syntax:atom(to_bool),
|
||||||
[EVar])
|
[EVar])
|
||||||
end,
|
end,
|
||||||
@ -348,7 +348,7 @@ make_sql_upsert_generic(Table, ParseRes) ->
|
|||||||
InsertBranch =
|
InsertBranch =
|
||||||
erl_syntax:case_expr(
|
erl_syntax:case_expr(
|
||||||
erl_syntax:application(
|
erl_syntax:application(
|
||||||
erl_syntax:atom(ejabberd_odbc),
|
erl_syntax:atom(ejabberd_sql),
|
||||||
erl_syntax:atom(sql_query_t),
|
erl_syntax:atom(sql_query_t),
|
||||||
[Insert]),
|
[Insert]),
|
||||||
[erl_syntax:clause(
|
[erl_syntax:clause(
|
||||||
@ -361,7 +361,7 @@ make_sql_upsert_generic(Table, ParseRes) ->
|
|||||||
[erl_syntax:variable("__UpdateRes")])]),
|
[erl_syntax:variable("__UpdateRes")])]),
|
||||||
erl_syntax:case_expr(
|
erl_syntax:case_expr(
|
||||||
erl_syntax:application(
|
erl_syntax:application(
|
||||||
erl_syntax:atom(ejabberd_odbc),
|
erl_syntax:atom(ejabberd_sql),
|
||||||
erl_syntax:atom(sql_query_t),
|
erl_syntax:atom(sql_query_t),
|
||||||
[Update]),
|
[Update]),
|
||||||
[erl_syntax:clause(
|
[erl_syntax:clause(
|
||||||
@ -453,7 +453,7 @@ make_sql_upsert_pgsql901(Table, ParseRes) ->
|
|||||||
]),
|
]),
|
||||||
Upsert = make_sql_query(State),
|
Upsert = make_sql_query(State),
|
||||||
erl_syntax:application(
|
erl_syntax:application(
|
||||||
erl_syntax:atom(ejabberd_odbc),
|
erl_syntax:atom(ejabberd_sql),
|
||||||
erl_syntax:atom(sql_query_t),
|
erl_syntax:atom(sql_query_t),
|
||||||
[Upsert]).
|
[Upsert]).
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%% File : ejabberd_odbc_sup.erl
|
%%% File : ejabberd_sql_sup.erl
|
||||||
%%% Author : Alexey Shchepin <alexey@process-one.net>
|
%%% Author : Alexey Shchepin <alexey@process-one.net>
|
||||||
%%% Purpose : ODBC connections supervisor
|
%%% Purpose : SQL connections supervisor
|
||||||
%%% Created : 22 Dec 2004 by Alexey Shchepin <alexey@process-one.net>
|
%%% Created : 22 Dec 2004 by Alexey Shchepin <alexey@process-one.net>
|
||||||
%%%
|
%%%
|
||||||
%%%
|
%%%
|
||||||
@ -23,7 +23,7 @@
|
|||||||
%%%
|
%%%
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
-module(ejabberd_odbc_sup).
|
-module(ejabberd_sql_sup).
|
||||||
|
|
||||||
-behaviour(ejabberd_config).
|
-behaviour(ejabberd_config).
|
||||||
|
|
||||||
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
-define(DEFAULT_POOL_SIZE, 10).
|
-define(DEFAULT_POOL_SIZE, 10).
|
||||||
|
|
||||||
-define(DEFAULT_ODBC_START_INTERVAL, 30).
|
-define(DEFAULT_SQL_START_INTERVAL, 30).
|
||||||
|
|
||||||
-define(CONNECT_TIMEOUT, 500).
|
-define(CONNECT_TIMEOUT, 500).
|
||||||
|
|
||||||
@ -62,14 +62,14 @@ start_link(Host) ->
|
|||||||
|
|
||||||
init([Host]) ->
|
init([Host]) ->
|
||||||
PoolSize = ejabberd_config:get_option(
|
PoolSize = ejabberd_config:get_option(
|
||||||
{odbc_pool_size, Host},
|
{sql_pool_size, Host},
|
||||||
fun(I) when is_integer(I), I>0 -> I end,
|
fun(I) when is_integer(I), I>0 -> I end,
|
||||||
?DEFAULT_POOL_SIZE),
|
?DEFAULT_POOL_SIZE),
|
||||||
StartInterval = ejabberd_config:get_option(
|
StartInterval = ejabberd_config:get_option(
|
||||||
{odbc_start_interval, Host},
|
{sql_start_interval, Host},
|
||||||
fun(I) when is_integer(I), I>0 -> I end,
|
fun(I) when is_integer(I), I>0 -> I end,
|
||||||
?DEFAULT_ODBC_START_INTERVAL),
|
?DEFAULT_SQL_START_INTERVAL),
|
||||||
Type = ejabberd_config:get_option({odbc_type, Host},
|
Type = ejabberd_config:get_option({sql_type, Host},
|
||||||
fun(mysql) -> mysql;
|
fun(mysql) -> mysql;
|
||||||
(pgsql) -> pgsql;
|
(pgsql) -> pgsql;
|
||||||
(sqlite) -> sqlite;
|
(sqlite) -> sqlite;
|
||||||
@ -80,7 +80,7 @@ init([Host]) ->
|
|||||||
sqlite ->
|
sqlite ->
|
||||||
check_sqlite_db(Host);
|
check_sqlite_db(Host);
|
||||||
mssql ->
|
mssql ->
|
||||||
ejabberd_odbc:init_mssql(Host);
|
ejabberd_sql:init_mssql(Host);
|
||||||
_ ->
|
_ ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
@ -89,7 +89,7 @@ init([Host]) ->
|
|||||||
{{one_for_one, PoolSize * 10, 1},
|
{{one_for_one, PoolSize * 10, 1},
|
||||||
lists:map(fun (I) ->
|
lists:map(fun (I) ->
|
||||||
{I,
|
{I,
|
||||||
{ejabberd_odbc, start_link,
|
{ejabberd_sql, start_link,
|
||||||
[Host, StartInterval * 1000]},
|
[Host, StartInterval * 1000]},
|
||||||
transient, 2000, worker, [?MODULE]}
|
transient, 2000, worker, [?MODULE]}
|
||||||
end,
|
end,
|
||||||
@ -121,12 +121,12 @@ transform_options(Opts) ->
|
|||||||
lists:foldl(fun transform_options/2, [], Opts).
|
lists:foldl(fun transform_options/2, [], Opts).
|
||||||
|
|
||||||
transform_options({odbc_server, {Type, Server, Port, DB, User, Pass}}, Opts) ->
|
transform_options({odbc_server, {Type, Server, Port, DB, User, Pass}}, Opts) ->
|
||||||
[{odbc_type, Type},
|
[{sql_type, Type},
|
||||||
{odbc_server, Server},
|
{sql_server, Server},
|
||||||
{odbc_port, Port},
|
{sql_port, Port},
|
||||||
{odbc_database, DB},
|
{sql_database, DB},
|
||||||
{odbc_username, User},
|
{sql_username, User},
|
||||||
{odbc_password, Pass}|Opts];
|
{sql_password, Pass}|Opts];
|
||||||
transform_options({odbc_server, {mysql, Server, DB, User, Pass}}, Opts) ->
|
transform_options({odbc_server, {mysql, Server, DB, User, Pass}}, Opts) ->
|
||||||
transform_options({odbc_server, {mysql, Server, ?MYSQL_PORT, DB, User, Pass}}, Opts);
|
transform_options({odbc_server, {mysql, Server, ?MYSQL_PORT, DB, User, Pass}}, Opts);
|
||||||
transform_options({odbc_server, {pgsql, Server, DB, User, Pass}}, Opts) ->
|
transform_options({odbc_server, {pgsql, Server, DB, User, Pass}}, Opts) ->
|
||||||
@ -137,8 +137,8 @@ transform_options(Opt, Opts) ->
|
|||||||
[Opt|Opts].
|
[Opt|Opts].
|
||||||
|
|
||||||
check_sqlite_db(Host) ->
|
check_sqlite_db(Host) ->
|
||||||
DB = ejabberd_odbc:sqlite_db(Host),
|
DB = ejabberd_sql:sqlite_db(Host),
|
||||||
File = ejabberd_odbc:sqlite_file(Host),
|
File = ejabberd_sql:sqlite_file(Host),
|
||||||
Ret = case filelib:ensure_dir(File) of
|
Ret = case filelib:ensure_dir(File) of
|
||||||
ok ->
|
ok ->
|
||||||
case sqlite3:open(DB, [{file, File}]) of
|
case sqlite3:open(DB, [{file, File}]) of
|
||||||
@ -211,11 +211,11 @@ read_lines(Fd, File, Acc) ->
|
|||||||
[]
|
[]
|
||||||
end.
|
end.
|
||||||
|
|
||||||
opt_type(odbc_pool_size) ->
|
opt_type(sql_pool_size) ->
|
||||||
fun (I) when is_integer(I), I > 0 -> I end;
|
fun (I) when is_integer(I), I > 0 -> I end;
|
||||||
opt_type(odbc_start_interval) ->
|
opt_type(sql_start_interval) ->
|
||||||
fun (I) when is_integer(I), I > 0 -> I end;
|
fun (I) when is_integer(I), I > 0 -> I end;
|
||||||
opt_type(odbc_type) ->
|
opt_type(sql_type) ->
|
||||||
fun (mysql) -> mysql;
|
fun (mysql) -> mysql;
|
||||||
(pgsql) -> pgsql;
|
(pgsql) -> pgsql;
|
||||||
(sqlite) -> sqlite;
|
(sqlite) -> sqlite;
|
||||||
@ -223,4 +223,4 @@ opt_type(odbc_type) ->
|
|||||||
(odbc) -> odbc
|
(odbc) -> odbc
|
||||||
end;
|
end;
|
||||||
opt_type(_) ->
|
opt_type(_) ->
|
||||||
[odbc_pool_size, odbc_start_interval, odbc_type].
|
[sql_pool_size, sql_start_interval, sql_type].
|
@ -2414,7 +2414,7 @@ node_backup_parse_query(Node, Query) ->
|
|||||||
lists:keysearch(<<Action/binary,
|
lists:keysearch(<<Action/binary,
|
||||||
"host">>,
|
"host">>,
|
||||||
1, Query),
|
1, Query),
|
||||||
ejabberd_cluster:call(Node, ejd2odbc,
|
ejabberd_cluster:call(Node, ejd2sql,
|
||||||
export, [Host, Path]);
|
export, [Host, Path]);
|
||||||
<<"import_file">> ->
|
<<"import_file">> ->
|
||||||
ejabberd_cluster:call(Node, ejabberd_admin,
|
ejabberd_cluster:call(Node, ejabberd_admin,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%% File : ejd2odbc.erl
|
%%% File : ejd2sql.erl
|
||||||
%%% Author : Alexey Shchepin <alexey@process-one.net>
|
%%% Author : Alexey Shchepin <alexey@process-one.net>
|
||||||
%%% Purpose : Export some mnesia tables to SQL DB
|
%%% Purpose : Export some mnesia tables to SQL DB
|
||||||
%%% Created : 22 Aug 2005 by Alexey Shchepin <alexey@process-one.net>
|
%%% Created : 22 Aug 2005 by Alexey Shchepin <alexey@process-one.net>
|
||||||
@ -23,7 +23,7 @@
|
|||||||
%%%
|
%%%
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
-module(ejd2odbc).
|
-module(ejd2sql).
|
||||||
|
|
||||||
-author('alexey@process-one.net').
|
-author('alexey@process-one.net').
|
||||||
|
|
||||||
@ -43,7 +43,7 @@
|
|||||||
%%% A table can be converted from Mnesia to an ODBC database by calling
|
%%% A table can be converted from Mnesia to an ODBC database by calling
|
||||||
%%% one of the API function with the following parameters:
|
%%% one of the API function with the following parameters:
|
||||||
%%% - Server is the server domain you want to convert
|
%%% - Server is the server domain you want to convert
|
||||||
%%% - Output can be either odbc to export to the configured relational
|
%%% - Output can be either sql to export to the configured relational
|
||||||
%%% database or "Filename" to export to text file.
|
%%% database or "Filename" to export to text file.
|
||||||
|
|
||||||
modules() ->
|
modules() ->
|
||||||
@ -168,8 +168,8 @@ export(LServer, Table, IO, ConvertFun) ->
|
|||||||
|
|
||||||
output(_LServer, _Table, _IO, []) ->
|
output(_LServer, _Table, _IO, []) ->
|
||||||
ok;
|
ok;
|
||||||
output(LServer, _Table, odbc, SQLs) ->
|
output(LServer, _Table, sql, SQLs) ->
|
||||||
ejabberd_odbc:sql_transaction(LServer, SQLs);
|
ejabberd_sql:sql_transaction(LServer, SQLs);
|
||||||
output(_LServer, Table, Fd, SQLs) ->
|
output(_LServer, Table, Fd, SQLs) ->
|
||||||
file:write(Fd, ["-- \n-- Mnesia table: ", atom_to_list(Table),
|
file:write(Fd, ["-- \n-- Mnesia table: ", atom_to_list(Table),
|
||||||
"\n--\n", SQLs]).
|
"\n--\n", SQLs]).
|
||||||
@ -197,7 +197,7 @@ import(LServer, SelectQuery, IO, ConvertFun, Opts) ->
|
|||||||
F = case proplists:get_bool(fast, Opts) of
|
F = case proplists:get_bool(fast, Opts) of
|
||||||
true ->
|
true ->
|
||||||
fun() ->
|
fun() ->
|
||||||
case ejabberd_odbc:sql_query_t(SelectQuery) of
|
case ejabberd_sql:sql_query_t(SelectQuery) of
|
||||||
{selected, _, Rows} ->
|
{selected, _, Rows} ->
|
||||||
lists:foldl(fun process_sql_row/2,
|
lists:foldl(fun process_sql_row/2,
|
||||||
{IO, ConvertFun, undefined}, Rows);
|
{IO, ConvertFun, undefined}, Rows);
|
||||||
@ -207,16 +207,16 @@ import(LServer, SelectQuery, IO, ConvertFun, Opts) ->
|
|||||||
end;
|
end;
|
||||||
false ->
|
false ->
|
||||||
fun() ->
|
fun() ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
[iolist_to_binary(
|
[iolist_to_binary(
|
||||||
[<<"declare c cursor for ">>, SelectQuery])]),
|
[<<"declare c cursor for ">>, SelectQuery])]),
|
||||||
fetch(IO, ConvertFun, undefined)
|
fetch(IO, ConvertFun, undefined)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
ejabberd_odbc:sql_transaction(LServer, F).
|
ejabberd_sql:sql_transaction(LServer, F).
|
||||||
|
|
||||||
fetch(IO, ConvertFun, PrevRow) ->
|
fetch(IO, ConvertFun, PrevRow) ->
|
||||||
case ejabberd_odbc:sql_query_t([<<"fetch c;">>]) of
|
case ejabberd_sql:sql_query_t([<<"fetch c;">>]) of
|
||||||
{selected, _, [Row]} ->
|
{selected, _, [Row]} ->
|
||||||
process_sql_row(Row, {IO, ConvertFun, PrevRow}),
|
process_sql_row(Row, {IO, ConvertFun, PrevRow}),
|
||||||
fetch(IO, ConvertFun, Row);
|
fetch(IO, ConvertFun, Row);
|
@ -48,7 +48,7 @@
|
|||||||
opts = [] :: opts() | '_' | '$2'}).
|
opts = [] :: opts() | '_' | '$2'}).
|
||||||
|
|
||||||
-type opts() :: [{atom(), any()}].
|
-type opts() :: [{atom(), any()}].
|
||||||
-type db_type() :: odbc | mnesia | riak.
|
-type db_type() :: sql | mnesia | riak.
|
||||||
|
|
||||||
-callback start(binary(), opts()) -> any().
|
-callback start(binary(), opts()) -> any().
|
||||||
-callback stop(binary()) -> any().
|
-callback stop(binary()) -> any().
|
||||||
@ -297,7 +297,8 @@ validate_opts(Module, Opts) ->
|
|||||||
|
|
||||||
-spec v_db(db_type() | internal) -> db_type().
|
-spec v_db(db_type() | internal) -> db_type().
|
||||||
|
|
||||||
v_db(odbc) -> odbc;
|
v_db(odbc) -> sql;
|
||||||
|
v_db(sql) -> sql;
|
||||||
v_db(internal) -> mnesia;
|
v_db(internal) -> mnesia;
|
||||||
v_db(mnesia) -> mnesia;
|
v_db(mnesia) -> mnesia;
|
||||||
v_db(riak) -> riak.
|
v_db(riak) -> riak.
|
||||||
@ -322,6 +323,7 @@ default_db(Host) ->
|
|||||||
-spec db_mod(binary() | global | db_type(), module()) -> module().
|
-spec db_mod(binary() | global | db_type(), module()) -> module().
|
||||||
|
|
||||||
db_mod(odbc, Module) -> list_to_atom(atom_to_list(Module) ++ "_sql");
|
db_mod(odbc, Module) -> list_to_atom(atom_to_list(Module) ++ "_sql");
|
||||||
|
db_mod(sql, Module) -> list_to_atom(atom_to_list(Module) ++ "_sql");
|
||||||
db_mod(mnesia, Module) -> list_to_atom(atom_to_list(Module) ++ "_mnesia");
|
db_mod(mnesia, Module) -> list_to_atom(atom_to_list(Module) ++ "_mnesia");
|
||||||
db_mod(riak, Module) -> list_to_atom(atom_to_list(Module) ++ "_riak");
|
db_mod(riak, Module) -> list_to_atom(atom_to_list(Module) ++ "_riak");
|
||||||
db_mod(Host, Module) when is_binary(Host) orelse Host == global ->
|
db_mod(Host, Module) when is_binary(Host) orelse Host == global ->
|
||||||
|
@ -27,35 +27,35 @@ set_motd_users(LServer, USRs) ->
|
|||||||
F = fun() ->
|
F = fun() ->
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun({U, _S, _R}) ->
|
fun({U, _S, _R}) ->
|
||||||
Username = ejabberd_odbc:escape(U),
|
Username = ejabberd_sql:escape(U),
|
||||||
odbc_queries:update_t(
|
sql_queries:update_t(
|
||||||
<<"motd">>,
|
<<"motd">>,
|
||||||
[<<"username">>, <<"xml">>],
|
[<<"username">>, <<"xml">>],
|
||||||
[Username, <<"">>],
|
[Username, <<"">>],
|
||||||
[<<"username='">>, Username, <<"'">>])
|
[<<"username='">>, Username, <<"'">>])
|
||||||
end, USRs)
|
end, USRs)
|
||||||
end,
|
end,
|
||||||
ejabberd_odbc:sql_transaction(LServer, F).
|
ejabberd_sql:sql_transaction(LServer, F).
|
||||||
|
|
||||||
set_motd(LServer, Packet) ->
|
set_motd(LServer, Packet) ->
|
||||||
XML = ejabberd_odbc:escape(fxml:element_to_binary(Packet)),
|
XML = ejabberd_sql:escape(fxml:element_to_binary(Packet)),
|
||||||
F = fun() ->
|
F = fun() ->
|
||||||
odbc_queries:update_t(
|
sql_queries:update_t(
|
||||||
<<"motd">>,
|
<<"motd">>,
|
||||||
[<<"username">>, <<"xml">>],
|
[<<"username">>, <<"xml">>],
|
||||||
[<<"">>, XML],
|
[<<"">>, XML],
|
||||||
[<<"username=''">>])
|
[<<"username=''">>])
|
||||||
end,
|
end,
|
||||||
ejabberd_odbc:sql_transaction(LServer, F).
|
ejabberd_sql:sql_transaction(LServer, F).
|
||||||
|
|
||||||
delete_motd(LServer) ->
|
delete_motd(LServer) ->
|
||||||
F = fun() ->
|
F = fun() ->
|
||||||
ejabberd_odbc:sql_query_t([<<"delete from motd;">>])
|
ejabberd_sql:sql_query_t([<<"delete from motd;">>])
|
||||||
end,
|
end,
|
||||||
ejabberd_odbc:sql_transaction(LServer, F).
|
ejabberd_sql:sql_transaction(LServer, F).
|
||||||
|
|
||||||
get_motd(LServer) ->
|
get_motd(LServer) ->
|
||||||
case catch ejabberd_odbc:sql_query(
|
case catch ejabberd_sql:sql_query(
|
||||||
LServer, [<<"select xml from motd where username='';">>]) of
|
LServer, [<<"select xml from motd where username='';">>]) of
|
||||||
{selected, [<<"xml">>], [[XML]]} ->
|
{selected, [<<"xml">>], [[XML]]} ->
|
||||||
case fxml_stream:parse_element(XML) of
|
case fxml_stream:parse_element(XML) of
|
||||||
@ -69,8 +69,8 @@ get_motd(LServer) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
is_motd_user(LUser, LServer) ->
|
is_motd_user(LUser, LServer) ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
case catch ejabberd_odbc:sql_query(
|
case catch ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
[<<"select username from motd "
|
[<<"select username from motd "
|
||||||
"where username='">>, Username, <<"';">>]) of
|
"where username='">>, Username, <<"';">>]) of
|
||||||
@ -81,15 +81,15 @@ is_motd_user(LUser, LServer) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
set_motd_user(LUser, LServer) ->
|
set_motd_user(LUser, LServer) ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
F = fun() ->
|
F = fun() ->
|
||||||
odbc_queries:update_t(
|
sql_queries:update_t(
|
||||||
<<"motd">>,
|
<<"motd">>,
|
||||||
[<<"username">>, <<"xml">>],
|
[<<"username">>, <<"xml">>],
|
||||||
[Username, <<"">>],
|
[Username, <<"">>],
|
||||||
[<<"username='">>, Username, <<"'">>])
|
[<<"username='">>, Username, <<"'">>])
|
||||||
end,
|
end,
|
||||||
ejabberd_odbc:sql_transaction(LServer, F).
|
ejabberd_sql:sql_transaction(LServer, F).
|
||||||
|
|
||||||
export(_Server) ->
|
export(_Server) ->
|
||||||
[{motd,
|
[{motd,
|
||||||
@ -97,7 +97,7 @@ export(_Server) ->
|
|||||||
when LServer == Host ->
|
when LServer == Host ->
|
||||||
[[<<"delete from motd where username='';">>],
|
[[<<"delete from motd where username='';">>],
|
||||||
[<<"insert into motd(username, xml) values ('', '">>,
|
[<<"insert into motd(username, xml) values ('', '">>,
|
||||||
ejabberd_odbc:escape(fxml:element_to_binary(El)),
|
ejabberd_sql:escape(fxml:element_to_binary(El)),
|
||||||
<<"');">>]];
|
<<"');">>]];
|
||||||
(_Host, _R) ->
|
(_Host, _R) ->
|
||||||
[]
|
[]
|
||||||
@ -105,7 +105,7 @@ export(_Server) ->
|
|||||||
{motd_users,
|
{motd_users,
|
||||||
fun(Host, #motd_users{us = {LUser, LServer}})
|
fun(Host, #motd_users{us = {LUser, LServer}})
|
||||||
when LServer == Host, LUser /= <<"">> ->
|
when LServer == Host, LUser /= <<"">> ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
[[<<"delete from motd where username='">>, Username, <<"';">>],
|
[[<<"delete from motd where username='">>, Username, <<"';">>],
|
||||||
[<<"insert into motd(username, xml) values ('">>,
|
[<<"insert into motd(username, xml) values ('">>,
|
||||||
Username, <<"', '');">>]];
|
Username, <<"', '');">>]];
|
||||||
|
@ -44,7 +44,7 @@ process_blocklist_block(LUser, LServer, Filter) ->
|
|||||||
mod_privacy_sql:sql_set_privacy_list(ID, NewRItems),
|
mod_privacy_sql:sql_set_privacy_list(ID, NewRItems),
|
||||||
{ok, Default, NewList}
|
{ok, Default, NewList}
|
||||||
end,
|
end,
|
||||||
ejabberd_odbc:sql_transaction(LServer, F).
|
ejabberd_sql:sql_transaction(LServer, F).
|
||||||
|
|
||||||
unblock_by_filter(LUser, LServer, Filter) ->
|
unblock_by_filter(LUser, LServer, Filter) ->
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
@ -67,7 +67,7 @@ unblock_by_filter(LUser, LServer, Filter) ->
|
|||||||
_ -> ok
|
_ -> ok
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
ejabberd_odbc:sql_transaction(LServer, F).
|
ejabberd_sql:sql_transaction(LServer, F).
|
||||||
|
|
||||||
process_blocklist_get(LUser, LServer) ->
|
process_blocklist_get(LUser, LServer) ->
|
||||||
case catch mod_privacy_sql:sql_get_default_privacy_list(LUser, LServer) of
|
case catch mod_privacy_sql:sql_get_default_privacy_list(LUser, LServer) of
|
||||||
|
@ -609,7 +609,7 @@ import_start(LServer, DBType) ->
|
|||||||
Mod:init(LServer, []),
|
Mod:init(LServer, []),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
import(_LServer, {odbc, _}, _DBType, <<"caps_features">>,
|
import(_LServer, {sql, _}, _DBType, <<"caps_features">>,
|
||||||
[Node, SubNode, Feature, _TimeStamp]) ->
|
[Node, SubNode, Feature, _TimeStamp]) ->
|
||||||
Feature1 = case catch jlib:binary_to_integer(Feature) of
|
Feature1 = case catch jlib:binary_to_integer(Feature) of
|
||||||
I when is_integer(I), I>0 -> I;
|
I when is_integer(I), I>0 -> I;
|
||||||
@ -642,7 +642,7 @@ import_next(LServer, DBType, NodePair) ->
|
|||||||
ejabberd_riak:put(
|
ejabberd_riak:put(
|
||||||
#caps_features{node_pair = NodePair, features = Features},
|
#caps_features{node_pair = NodePair, features = Features},
|
||||||
caps_features_schema());
|
caps_features_schema());
|
||||||
_ when DBType == odbc ->
|
_ when DBType == sql ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
import_next(LServer, DBType, ets:next(caps_features_tmp, NodePair)).
|
import_next(LServer, DBType, ets:next(caps_features_tmp, NodePair)).
|
||||||
|
@ -21,9 +21,9 @@ init(_Host, _Opts) ->
|
|||||||
ok.
|
ok.
|
||||||
|
|
||||||
caps_read(LServer, {Node, SubNode}) ->
|
caps_read(LServer, {Node, SubNode}) ->
|
||||||
SNode = ejabberd_odbc:escape(Node),
|
SNode = ejabberd_sql:escape(Node),
|
||||||
SSubNode = ejabberd_odbc:escape(SubNode),
|
SSubNode = ejabberd_sql:escape(SubNode),
|
||||||
case ejabberd_odbc:sql_query(
|
case ejabberd_sql:sql_query(
|
||||||
LServer, [<<"select feature from caps_features where ">>,
|
LServer, [<<"select feature from caps_features where ">>,
|
||||||
<<"node='">>, SNode, <<"' and subnode='">>,
|
<<"node='">>, SNode, <<"' and subnode='">>,
|
||||||
SSubNode, <<"';">>]) of
|
SSubNode, <<"';">>]) of
|
||||||
@ -39,7 +39,7 @@ caps_read(LServer, {Node, SubNode}) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
caps_write(LServer, NodePair, Features) ->
|
caps_write(LServer, NodePair, Features) ->
|
||||||
ejabberd_odbc:sql_transaction(
|
ejabberd_sql:sql_transaction(
|
||||||
LServer,
|
LServer,
|
||||||
sql_write_features_t(NodePair, Features)).
|
sql_write_features_t(NodePair, Features)).
|
||||||
|
|
||||||
@ -56,8 +56,8 @@ export(_Server) ->
|
|||||||
%%% Internal functions
|
%%% Internal functions
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
sql_write_features_t({Node, SubNode}, Features) ->
|
sql_write_features_t({Node, SubNode}, Features) ->
|
||||||
SNode = ejabberd_odbc:escape(Node),
|
SNode = ejabberd_sql:escape(Node),
|
||||||
SSubNode = ejabberd_odbc:escape(SubNode),
|
SSubNode = ejabberd_sql:escape(SubNode),
|
||||||
NewFeatures = if is_integer(Features) ->
|
NewFeatures = if is_integer(Features) ->
|
||||||
[jlib:integer_to_binary(Features)];
|
[jlib:integer_to_binary(Features)];
|
||||||
true ->
|
true ->
|
||||||
@ -67,5 +67,5 @@ sql_write_features_t({Node, SubNode}, Features) ->
|
|||||||
SNode, <<"' and subnode='">>, SSubNode, <<"';">>]|
|
SNode, <<"' and subnode='">>, SSubNode, <<"';">>]|
|
||||||
[[<<"insert into caps_features(node, subnode, feature) ">>,
|
[[<<"insert into caps_features(node, subnode, feature) ">>,
|
||||||
<<"values ('">>, SNode, <<"', '">>, SSubNode, <<"', '">>,
|
<<"values ('">>, SNode, <<"', '">>, SSubNode, <<"', '">>,
|
||||||
ejabberd_odbc:escape(F), <<"');">>] || F <- NewFeatures]].
|
ejabberd_sql:escape(F), <<"');">>] || F <- NewFeatures]].
|
||||||
|
|
||||||
|
@ -24,33 +24,33 @@ init(_Host, _Opts) ->
|
|||||||
|
|
||||||
get_data(LServer, Host, From) ->
|
get_data(LServer, Host, From) ->
|
||||||
LJID = jid:tolower(jid:remove_resource(From)),
|
LJID = jid:tolower(jid:remove_resource(From)),
|
||||||
SJID = ejabberd_odbc:escape(jid:to_string(LJID)),
|
SJID = ejabberd_sql:escape(jid:to_string(LJID)),
|
||||||
SHost = ejabberd_odbc:escape(Host),
|
SHost = ejabberd_sql:escape(Host),
|
||||||
case catch ejabberd_odbc:sql_query(
|
case catch ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
[<<"select data from irc_custom where jid='">>,
|
[<<"select data from irc_custom where jid='">>,
|
||||||
SJID, <<"' and host='">>, SHost,
|
SJID, <<"' and host='">>, SHost,
|
||||||
<<"';">>]) of
|
<<"';">>]) of
|
||||||
{selected, [<<"data">>], [[SData]]} ->
|
{selected, [<<"data">>], [[SData]]} ->
|
||||||
mod_irc:data_to_binary(From, ejabberd_odbc:decode_term(SData));
|
mod_irc:data_to_binary(From, ejabberd_sql:decode_term(SData));
|
||||||
{'EXIT', _} -> error;
|
{'EXIT', _} -> error;
|
||||||
{selected, _, _} -> empty
|
{selected, _, _} -> empty
|
||||||
end.
|
end.
|
||||||
|
|
||||||
set_data(LServer, Host, From, Data) ->
|
set_data(LServer, Host, From, Data) ->
|
||||||
LJID = jid:tolower(jid:remove_resource(From)),
|
LJID = jid:tolower(jid:remove_resource(From)),
|
||||||
SJID = ejabberd_odbc:escape(jid:to_string(LJID)),
|
SJID = ejabberd_sql:escape(jid:to_string(LJID)),
|
||||||
SHost = ejabberd_odbc:escape(Host),
|
SHost = ejabberd_sql:escape(Host),
|
||||||
SData = ejabberd_odbc:encode_term(Data),
|
SData = ejabberd_sql:encode_term(Data),
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
odbc_queries:update_t(<<"irc_custom">>,
|
sql_queries:update_t(<<"irc_custom">>,
|
||||||
[<<"jid">>, <<"host">>, <<"data">>],
|
[<<"jid">>, <<"host">>, <<"data">>],
|
||||||
[SJID, SHost, SData],
|
[SJID, SHost, SData],
|
||||||
[<<"jid='">>, SJID, <<"' and host='">>,
|
[<<"jid='">>, SJID, <<"' and host='">>,
|
||||||
SHost, <<"'">>]),
|
SHost, <<"'">>]),
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
ejabberd_odbc:sql_transaction(LServer, F).
|
ejabberd_sql:sql_transaction(LServer, F).
|
||||||
|
|
||||||
export(_Server) ->
|
export(_Server) ->
|
||||||
[{irc_custom,
|
[{irc_custom,
|
||||||
@ -58,11 +58,11 @@ export(_Server) ->
|
|||||||
data = Data}) ->
|
data = Data}) ->
|
||||||
case str:suffix(Host, IRCHost) of
|
case str:suffix(Host, IRCHost) of
|
||||||
true ->
|
true ->
|
||||||
SJID = ejabberd_odbc:escape(
|
SJID = ejabberd_sql:escape(
|
||||||
jid:to_string(
|
jid:to_string(
|
||||||
jid:make(U, S, <<"">>))),
|
jid:make(U, S, <<"">>))),
|
||||||
SIRCHost = ejabberd_odbc:escape(IRCHost),
|
SIRCHost = ejabberd_sql:escape(IRCHost),
|
||||||
SData = ejabberd_odbc:encode_term(Data),
|
SData = ejabberd_sql:encode_term(Data),
|
||||||
[[<<"delete from irc_custom where jid='">>, SJID,
|
[[<<"delete from irc_custom where jid='">>, SJID,
|
||||||
<<"' and host='">>, SIRCHost, <<"';">>],
|
<<"' and host='">>, SIRCHost, <<"';">>],
|
||||||
[<<"insert into irc_custom(jid, host, "
|
[<<"insert into irc_custom(jid, host, "
|
||||||
@ -78,7 +78,7 @@ import(_LServer) ->
|
|||||||
[{<<"select jid, host, data from irc_custom;">>,
|
[{<<"select jid, host, data from irc_custom;">>,
|
||||||
fun([SJID, IRCHost, SData]) ->
|
fun([SJID, IRCHost, SData]) ->
|
||||||
#jid{luser = U, lserver = S} = jid:from_string(SJID),
|
#jid{luser = U, lserver = S} = jid:from_string(SJID),
|
||||||
Data = ejabberd_odbc:decode_term(SData),
|
Data = ejabberd_sql:decode_term(SData),
|
||||||
#irc_custom{us_host = {{U, S}, IRCHost},
|
#irc_custom{us_host = {{U, S}, IRCHost},
|
||||||
data = Data}
|
data = Data}
|
||||||
end}].
|
end}].
|
||||||
|
@ -23,7 +23,7 @@ init(_Host, _Opts) ->
|
|||||||
ok.
|
ok.
|
||||||
|
|
||||||
get_last(LUser, LServer) ->
|
get_last(LUser, LServer) ->
|
||||||
case catch odbc_queries:get_last(LServer, LUser) of
|
case catch sql_queries:get_last(LServer, LUser) of
|
||||||
{selected, []} ->
|
{selected, []} ->
|
||||||
not_found;
|
not_found;
|
||||||
{selected, [{TimeStamp, Status}]} ->
|
{selected, [{TimeStamp, Status}]} ->
|
||||||
@ -35,10 +35,10 @@ get_last(LUser, LServer) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
store_last_info(LUser, LServer, TimeStamp, Status) ->
|
store_last_info(LUser, LServer, TimeStamp, Status) ->
|
||||||
odbc_queries:set_last_t(LServer, LUser, TimeStamp, Status).
|
sql_queries:set_last_t(LServer, LUser, TimeStamp, Status).
|
||||||
|
|
||||||
remove_user(LUser, LServer) ->
|
remove_user(LUser, LServer) ->
|
||||||
odbc_queries:del_last(LServer, LUser).
|
sql_queries:del_last(LServer, LUser).
|
||||||
|
|
||||||
import(_LServer, _LA) ->
|
import(_LServer, _LA) ->
|
||||||
pass.
|
pass.
|
||||||
@ -48,10 +48,10 @@ export(_Server) ->
|
|||||||
fun(Host, #last_activity{us = {LUser, LServer},
|
fun(Host, #last_activity{us = {LUser, LServer},
|
||||||
timestamp = TimeStamp, status = Status})
|
timestamp = TimeStamp, status = Status})
|
||||||
when LServer == Host ->
|
when LServer == Host ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
Seconds =
|
Seconds =
|
||||||
ejabberd_odbc:escape(jlib:integer_to_binary(TimeStamp)),
|
ejabberd_sql:escape(jlib:integer_to_binary(TimeStamp)),
|
||||||
State = ejabberd_odbc:escape(Status),
|
State = ejabberd_sql:escape(Status),
|
||||||
[[<<"delete from last where username='">>, Username, <<"';">>],
|
[[<<"delete from last where username='">>, Username, <<"';">>],
|
||||||
[<<"insert into last(username, seconds, "
|
[<<"insert into last(username, seconds, "
|
||||||
"state) values ('">>,
|
"state) values ('">>,
|
||||||
|
@ -344,7 +344,7 @@ delete_old_messages(TypeBin, Days) when TypeBin == <<"chat">>;
|
|||||||
lists:map(
|
lists:map(
|
||||||
fun(Host) ->
|
fun(Host) ->
|
||||||
case gen_mod:db_type(Host, ?MODULE) of
|
case gen_mod:db_type(Host, ?MODULE) of
|
||||||
odbc -> {odbc, Host};
|
sql -> {sql, Host};
|
||||||
Other -> {Other, global}
|
Other -> {Other, global}
|
||||||
end
|
end
|
||||||
end, ?MYHOSTS)),
|
end, ?MYHOSTS)),
|
||||||
@ -1018,7 +1018,8 @@ mod_opt_type(cache_life_time) ->
|
|||||||
mod_opt_type(cache_size) ->
|
mod_opt_type(cache_size) ->
|
||||||
fun (I) when is_integer(I), I > 0 -> I end;
|
fun (I) when is_integer(I), I > 0 -> I end;
|
||||||
mod_opt_type(db_type) ->
|
mod_opt_type(db_type) ->
|
||||||
fun(odbc) -> odbc;
|
fun(sql) -> sql;
|
||||||
|
(odbc) -> sql;
|
||||||
(internal) -> mnesia;
|
(internal) -> mnesia;
|
||||||
(mnesia) -> mnesia
|
(mnesia) -> mnesia
|
||||||
end;
|
end;
|
||||||
|
@ -26,11 +26,11 @@ init(_Host, _Opts) ->
|
|||||||
ok.
|
ok.
|
||||||
|
|
||||||
remove_user(LUser, LServer) ->
|
remove_user(LUser, LServer) ->
|
||||||
SUser = ejabberd_odbc:escape(LUser),
|
SUser = ejabberd_sql:escape(LUser),
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
[<<"delete from archive where username='">>, SUser, <<"';">>]),
|
[<<"delete from archive where username='">>, SUser, <<"';">>]),
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
[<<"delete from archive_prefs where username='">>, SUser, <<"';">>]).
|
[<<"delete from archive_prefs where username='">>, SUser, <<"';">>]).
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ delete_old_messages(ServerHost, TimeStamp, Type) ->
|
|||||||
true -> [<<" and kind='">>, jlib:atom_to_binary(Type), <<"'">>]
|
true -> [<<" and kind='">>, jlib:atom_to_binary(Type), <<"'">>]
|
||||||
end,
|
end,
|
||||||
TS = integer_to_binary(now_to_usec(TimeStamp)),
|
TS = integer_to_binary(now_to_usec(TimeStamp)),
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
ServerHost, [<<"delete from archive where timestamp<">>,
|
ServerHost, [<<"delete from archive where timestamp<">>,
|
||||||
TS, TypeClause, <<";">>]),
|
TS, TypeClause, <<";">>]),
|
||||||
ok.
|
ok.
|
||||||
@ -67,18 +67,18 @@ store(Pkt, LServer, {LUser, LHost}, Type, Peer, Nick, _Dir) ->
|
|||||||
jid:tolower(Peer)),
|
jid:tolower(Peer)),
|
||||||
XML = fxml:element_to_binary(Pkt),
|
XML = fxml:element_to_binary(Pkt),
|
||||||
Body = fxml:get_subtag_cdata(Pkt, <<"body">>),
|
Body = fxml:get_subtag_cdata(Pkt, <<"body">>),
|
||||||
case ejabberd_odbc:sql_query(
|
case ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
[<<"insert into archive (username, timestamp, "
|
[<<"insert into archive (username, timestamp, "
|
||||||
"peer, bare_peer, xml, txt, kind, nick) values (">>,
|
"peer, bare_peer, xml, txt, kind, nick) values (">>,
|
||||||
<<"'">>, ejabberd_odbc:escape(SUser), <<"', ">>,
|
<<"'">>, ejabberd_sql:escape(SUser), <<"', ">>,
|
||||||
<<"'">>, TS, <<"', ">>,
|
<<"'">>, TS, <<"', ">>,
|
||||||
<<"'">>, ejabberd_odbc:escape(LPeer), <<"', ">>,
|
<<"'">>, ejabberd_sql:escape(LPeer), <<"', ">>,
|
||||||
<<"'">>, ejabberd_odbc:escape(BarePeer), <<"', ">>,
|
<<"'">>, ejabberd_sql:escape(BarePeer), <<"', ">>,
|
||||||
<<"'">>, ejabberd_odbc:escape(XML), <<"', ">>,
|
<<"'">>, ejabberd_sql:escape(XML), <<"', ">>,
|
||||||
<<"'">>, ejabberd_odbc:escape(Body), <<"', ">>,
|
<<"'">>, ejabberd_sql:escape(Body), <<"', ">>,
|
||||||
<<"'">>, jlib:atom_to_binary(Type), <<"', ">>,
|
<<"'">>, jlib:atom_to_binary(Type), <<"', ">>,
|
||||||
<<"'">>, ejabberd_odbc:escape(Nick), <<"');">>]) of
|
<<"'">>, ejabberd_sql:escape(Nick), <<"');">>]) of
|
||||||
{updated, _} ->
|
{updated, _} ->
|
||||||
{ok, ID};
|
{ok, ID};
|
||||||
Err ->
|
Err ->
|
||||||
@ -89,10 +89,10 @@ write_prefs(LUser, _LServer, #archive_prefs{default = Default,
|
|||||||
never = Never,
|
never = Never,
|
||||||
always = Always},
|
always = Always},
|
||||||
ServerHost) ->
|
ServerHost) ->
|
||||||
SUser = ejabberd_odbc:escape(LUser),
|
SUser = ejabberd_sql:escape(LUser),
|
||||||
SDefault = erlang:atom_to_binary(Default, utf8),
|
SDefault = erlang:atom_to_binary(Default, utf8),
|
||||||
SAlways = ejabberd_odbc:encode_term(Always),
|
SAlways = ejabberd_sql:encode_term(Always),
|
||||||
SNever = ejabberd_odbc:encode_term(Never),
|
SNever = ejabberd_sql:encode_term(Never),
|
||||||
case update(ServerHost, <<"archive_prefs">>,
|
case update(ServerHost, <<"archive_prefs">>,
|
||||||
[<<"username">>, <<"def">>, <<"always">>, <<"never">>],
|
[<<"username">>, <<"def">>, <<"always">>, <<"never">>],
|
||||||
[SUser, SDefault, SAlways, SNever],
|
[SUser, SDefault, SAlways, SNever],
|
||||||
@ -104,15 +104,15 @@ write_prefs(LUser, _LServer, #archive_prefs{default = Default,
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
get_prefs(LUser, LServer) ->
|
get_prefs(LUser, LServer) ->
|
||||||
case ejabberd_odbc:sql_query(
|
case ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
[<<"select def, always, never from archive_prefs ">>,
|
[<<"select def, always, never from archive_prefs ">>,
|
||||||
<<"where username='">>,
|
<<"where username='">>,
|
||||||
ejabberd_odbc:escape(LUser), <<"';">>]) of
|
ejabberd_sql:escape(LUser), <<"';">>]) of
|
||||||
{selected, _, [[SDefault, SAlways, SNever]]} ->
|
{selected, _, [[SDefault, SAlways, SNever]]} ->
|
||||||
Default = erlang:binary_to_existing_atom(SDefault, utf8),
|
Default = erlang:binary_to_existing_atom(SDefault, utf8),
|
||||||
Always = ejabberd_odbc:decode_term(SAlways),
|
Always = ejabberd_sql:decode_term(SAlways),
|
||||||
Never = ejabberd_odbc:decode_term(SNever),
|
Never = ejabberd_sql:decode_term(SNever),
|
||||||
{ok, #archive_prefs{us = {LUser, LServer},
|
{ok, #archive_prefs{us = {LUser, LServer},
|
||||||
default = Default,
|
default = Default,
|
||||||
always = Always,
|
always = Always,
|
||||||
@ -135,8 +135,8 @@ select(LServer, JidRequestor, #jid{luser = LUser} = JidArchive,
|
|||||||
% and the client did not specify a limit using RSM then the server should
|
% and the client did not specify a limit using RSM then the server should
|
||||||
% return a policy-violation error to the client." We currently don't do this
|
% return a policy-violation error to the client." We currently don't do this
|
||||||
% for v0.2 requests, but we do limit #rsm_in.max for v0.3 and newer.
|
% for v0.2 requests, but we do limit #rsm_in.max for v0.3 and newer.
|
||||||
case {ejabberd_odbc:sql_query(LServer, Query),
|
case {ejabberd_sql:sql_query(LServer, Query),
|
||||||
ejabberd_odbc:sql_query(LServer, CountQuery)} of
|
ejabberd_sql:sql_query(LServer, CountQuery)} of
|
||||||
{{selected, _, Res}, {selected, _, [[Count]]}} ->
|
{{selected, _, Res}, {selected, _, [[Count]]}} ->
|
||||||
{Max, Direction} = case RSM of
|
{Max, Direction} = case RSM of
|
||||||
#rsm_in{max = M, direction = D} -> {M, D};
|
#rsm_in{max = M, direction = D} -> {M, D};
|
||||||
@ -206,8 +206,8 @@ make_sql_query(User, LServer, Start, End, With, RSM) ->
|
|||||||
{none, none, <<>>}
|
{none, none, <<>>}
|
||||||
end,
|
end,
|
||||||
ODBCType = ejabberd_config:get_option(
|
ODBCType = ejabberd_config:get_option(
|
||||||
{odbc_type, LServer},
|
{sql_type, LServer},
|
||||||
ejabberd_odbc:opt_type(odbc_type)),
|
ejabberd_sql:opt_type(sql_type)),
|
||||||
LimitClause = if is_integer(Max), Max >= 0, ODBCType /= mssql ->
|
LimitClause = if is_integer(Max), Max >= 0, ODBCType /= mssql ->
|
||||||
[<<" limit ">>, jlib:integer_to_binary(Max+1)];
|
[<<" limit ">>, jlib:integer_to_binary(Max+1)];
|
||||||
true ->
|
true ->
|
||||||
@ -223,14 +223,14 @@ make_sql_query(User, LServer, Start, End, With, RSM) ->
|
|||||||
[];
|
[];
|
||||||
{text, Txt} ->
|
{text, Txt} ->
|
||||||
[<<" and match (txt) against ('">>,
|
[<<" and match (txt) against ('">>,
|
||||||
ejabberd_odbc:escape(Txt), <<"')">>];
|
ejabberd_sql:escape(Txt), <<"')">>];
|
||||||
{_, _, <<>>} ->
|
{_, _, <<>>} ->
|
||||||
[<<" and bare_peer='">>,
|
[<<" and bare_peer='">>,
|
||||||
ejabberd_odbc:escape(jid:to_string(With)),
|
ejabberd_sql:escape(jid:to_string(With)),
|
||||||
<<"'">>];
|
<<"'">>];
|
||||||
{_, _, _} ->
|
{_, _, _} ->
|
||||||
[<<" and peer='">>,
|
[<<" and peer='">>,
|
||||||
ejabberd_odbc:escape(jid:to_string(With)),
|
ejabberd_sql:escape(jid:to_string(With)),
|
||||||
<<"'">>];
|
<<"'">>];
|
||||||
none ->
|
none ->
|
||||||
[]
|
[]
|
||||||
@ -262,7 +262,7 @@ make_sql_query(User, LServer, Start, End, With, RSM) ->
|
|||||||
_ ->
|
_ ->
|
||||||
[]
|
[]
|
||||||
end,
|
end,
|
||||||
SUser = ejabberd_odbc:escape(User),
|
SUser = ejabberd_sql:escape(User),
|
||||||
|
|
||||||
Query = [<<"SELECT ">>, TopClause, <<" timestamp, xml, peer, kind, nick"
|
Query = [<<"SELECT ">>, TopClause, <<" timestamp, xml, peer, kind, nick"
|
||||||
" FROM archive WHERE username='">>,
|
" FROM archive WHERE username='">>,
|
||||||
@ -291,14 +291,14 @@ update(LServer, Table, Fields, Vals, Where) ->
|
|||||||
<<A/binary, "='", B/binary, "'">>
|
<<A/binary, "='", B/binary, "'">>
|
||||||
end,
|
end,
|
||||||
Fields, Vals),
|
Fields, Vals),
|
||||||
case ejabberd_odbc:sql_query(LServer,
|
case ejabberd_sql:sql_query(LServer,
|
||||||
[<<"update ">>, Table, <<" set ">>,
|
[<<"update ">>, Table, <<" set ">>,
|
||||||
join(UPairs, <<", ">>), <<" where ">>, Where,
|
join(UPairs, <<", ">>), <<" where ">>, Where,
|
||||||
<<";">>])
|
<<";">>])
|
||||||
of
|
of
|
||||||
{updated, 1} -> {updated, 1};
|
{updated, 1} -> {updated, 1};
|
||||||
_ ->
|
_ ->
|
||||||
ejabberd_odbc:sql_query(LServer,
|
ejabberd_sql:sql_query(LServer,
|
||||||
[<<"insert into ">>, Table, <<"(">>,
|
[<<"insert into ">>, Table, <<"(">>,
|
||||||
join(Fields, <<", ">>), <<") values ('">>,
|
join(Fields, <<", ">>), <<") values ('">>,
|
||||||
join(Vals, <<"', '">>), <<"');">>])
|
join(Vals, <<"', '">>), <<"');">>])
|
||||||
|
@ -26,46 +26,46 @@ init(_Host, _Opts) ->
|
|||||||
ok.
|
ok.
|
||||||
|
|
||||||
store_room(LServer, Host, Name, Opts) ->
|
store_room(LServer, Host, Name, Opts) ->
|
||||||
SName = ejabberd_odbc:escape(Name),
|
SName = ejabberd_sql:escape(Name),
|
||||||
SHost = ejabberd_odbc:escape(Host),
|
SHost = ejabberd_sql:escape(Host),
|
||||||
SOpts = ejabberd_odbc:encode_term(Opts),
|
SOpts = ejabberd_sql:encode_term(Opts),
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
odbc_queries:update_t(<<"muc_room">>,
|
sql_queries:update_t(<<"muc_room">>,
|
||||||
[<<"name">>, <<"host">>, <<"opts">>],
|
[<<"name">>, <<"host">>, <<"opts">>],
|
||||||
[SName, SHost, SOpts],
|
[SName, SHost, SOpts],
|
||||||
[<<"name='">>, SName, <<"' and host='">>,
|
[<<"name='">>, SName, <<"' and host='">>,
|
||||||
SHost, <<"'">>])
|
SHost, <<"'">>])
|
||||||
end,
|
end,
|
||||||
ejabberd_odbc:sql_transaction(LServer, F).
|
ejabberd_sql:sql_transaction(LServer, F).
|
||||||
|
|
||||||
restore_room(LServer, Host, Name) ->
|
restore_room(LServer, Host, Name) ->
|
||||||
SName = ejabberd_odbc:escape(Name),
|
SName = ejabberd_sql:escape(Name),
|
||||||
SHost = ejabberd_odbc:escape(Host),
|
SHost = ejabberd_sql:escape(Host),
|
||||||
case catch ejabberd_odbc:sql_query(LServer,
|
case catch ejabberd_sql:sql_query(LServer,
|
||||||
[<<"select opts from muc_room where name='">>,
|
[<<"select opts from muc_room where name='">>,
|
||||||
SName, <<"' and host='">>, SHost,
|
SName, <<"' and host='">>, SHost,
|
||||||
<<"';">>]) of
|
<<"';">>]) of
|
||||||
{selected, [<<"opts">>], [[Opts]]} ->
|
{selected, [<<"opts">>], [[Opts]]} ->
|
||||||
mod_muc:opts_to_binary(ejabberd_odbc:decode_term(Opts));
|
mod_muc:opts_to_binary(ejabberd_sql:decode_term(Opts));
|
||||||
_ ->
|
_ ->
|
||||||
error
|
error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
forget_room(LServer, Host, Name) ->
|
forget_room(LServer, Host, Name) ->
|
||||||
SName = ejabberd_odbc:escape(Name),
|
SName = ejabberd_sql:escape(Name),
|
||||||
SHost = ejabberd_odbc:escape(Host),
|
SHost = ejabberd_sql:escape(Host),
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
ejabberd_odbc:sql_query_t([<<"delete from muc_room where name='">>,
|
ejabberd_sql:sql_query_t([<<"delete from muc_room where name='">>,
|
||||||
SName, <<"' and host='">>, SHost,
|
SName, <<"' and host='">>, SHost,
|
||||||
<<"';">>])
|
<<"';">>])
|
||||||
end,
|
end,
|
||||||
ejabberd_odbc:sql_transaction(LServer, F).
|
ejabberd_sql:sql_transaction(LServer, F).
|
||||||
|
|
||||||
can_use_nick(LServer, Host, JID, Nick) ->
|
can_use_nick(LServer, Host, JID, Nick) ->
|
||||||
SJID = jid:to_string(jid:tolower(jid:remove_resource(JID))),
|
SJID = jid:to_string(jid:tolower(jid:remove_resource(JID))),
|
||||||
SNick = ejabberd_odbc:escape(Nick),
|
SNick = ejabberd_sql:escape(Nick),
|
||||||
SHost = ejabberd_odbc:escape(Host),
|
SHost = ejabberd_sql:escape(Host),
|
||||||
case catch ejabberd_odbc:sql_query(LServer,
|
case catch ejabberd_sql:sql_query(LServer,
|
||||||
[<<"select jid from muc_registered ">>,
|
[<<"select jid from muc_registered ">>,
|
||||||
<<"where nick='">>, SNick,
|
<<"where nick='">>, SNick,
|
||||||
<<"' and host='">>, SHost, <<"';">>]) of
|
<<"' and host='">>, SHost, <<"';">>]) of
|
||||||
@ -74,8 +74,8 @@ can_use_nick(LServer, Host, JID, Nick) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
get_rooms(LServer, Host) ->
|
get_rooms(LServer, Host) ->
|
||||||
SHost = ejabberd_odbc:escape(Host),
|
SHost = ejabberd_sql:escape(Host),
|
||||||
case catch ejabberd_odbc:sql_query(LServer,
|
case catch ejabberd_sql:sql_query(LServer,
|
||||||
[<<"select name, opts from muc_room ">>,
|
[<<"select name, opts from muc_room ">>,
|
||||||
<<"where host='">>, SHost, <<"';">>]) of
|
<<"where host='">>, SHost, <<"';">>]) of
|
||||||
{selected, [<<"name">>, <<"opts">>], RoomOpts} ->
|
{selected, [<<"name">>, <<"opts">>], RoomOpts} ->
|
||||||
@ -83,7 +83,7 @@ get_rooms(LServer, Host) ->
|
|||||||
fun([Room, Opts]) ->
|
fun([Room, Opts]) ->
|
||||||
#muc_room{name_host = {Room, Host},
|
#muc_room{name_host = {Room, Host},
|
||||||
opts = mod_muc:opts_to_binary(
|
opts = mod_muc:opts_to_binary(
|
||||||
ejabberd_odbc:decode_term(Opts))}
|
ejabberd_sql:decode_term(Opts))}
|
||||||
end, RoomOpts);
|
end, RoomOpts);
|
||||||
Err ->
|
Err ->
|
||||||
?ERROR_MSG("failed to get rooms: ~p", [Err]),
|
?ERROR_MSG("failed to get rooms: ~p", [Err]),
|
||||||
@ -91,9 +91,9 @@ get_rooms(LServer, Host) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
get_nick(LServer, Host, From) ->
|
get_nick(LServer, Host, From) ->
|
||||||
SJID = ejabberd_odbc:escape(jid:to_string(jid:tolower(jid:remove_resource(From)))),
|
SJID = ejabberd_sql:escape(jid:to_string(jid:tolower(jid:remove_resource(From)))),
|
||||||
SHost = ejabberd_odbc:escape(Host),
|
SHost = ejabberd_sql:escape(Host),
|
||||||
case catch ejabberd_odbc:sql_query(LServer,
|
case catch ejabberd_sql:sql_query(LServer,
|
||||||
[<<"select nick from muc_registered where "
|
[<<"select nick from muc_registered where "
|
||||||
"jid='">>,
|
"jid='">>,
|
||||||
SJID, <<"' and host='">>, SHost,
|
SJID, <<"' and host='">>, SHost,
|
||||||
@ -104,20 +104,20 @@ get_nick(LServer, Host, From) ->
|
|||||||
|
|
||||||
set_nick(LServer, Host, From, Nick) ->
|
set_nick(LServer, Host, From, Nick) ->
|
||||||
JID = jid:to_string(jid:tolower(jid:remove_resource(From))),
|
JID = jid:to_string(jid:tolower(jid:remove_resource(From))),
|
||||||
SJID = ejabberd_odbc:escape(JID),
|
SJID = ejabberd_sql:escape(JID),
|
||||||
SNick = ejabberd_odbc:escape(Nick),
|
SNick = ejabberd_sql:escape(Nick),
|
||||||
SHost = ejabberd_odbc:escape(Host),
|
SHost = ejabberd_sql:escape(Host),
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
case Nick of
|
case Nick of
|
||||||
<<"">> ->
|
<<"">> ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
[<<"delete from muc_registered where ">>,
|
[<<"delete from muc_registered where ">>,
|
||||||
<<"jid='">>, SJID,
|
<<"jid='">>, SJID,
|
||||||
<<"' and host='">>, Host,
|
<<"' and host='">>, Host,
|
||||||
<<"';">>]),
|
<<"';">>]),
|
||||||
ok;
|
ok;
|
||||||
_ ->
|
_ ->
|
||||||
Allow = case ejabberd_odbc:sql_query_t(
|
Allow = case ejabberd_sql:sql_query_t(
|
||||||
[<<"select jid from muc_registered ">>,
|
[<<"select jid from muc_registered ">>,
|
||||||
<<"where nick='">>,
|
<<"where nick='">>,
|
||||||
SNick,
|
SNick,
|
||||||
@ -127,7 +127,7 @@ set_nick(LServer, Host, From, Nick) ->
|
|||||||
_ -> true
|
_ -> true
|
||||||
end,
|
end,
|
||||||
if Allow ->
|
if Allow ->
|
||||||
odbc_queries:update_t(<<"muc_registered">>,
|
sql_queries:update_t(<<"muc_registered">>,
|
||||||
[<<"jid">>, <<"host">>,
|
[<<"jid">>, <<"host">>,
|
||||||
<<"nick">>],
|
<<"nick">>],
|
||||||
[SJID, SHost, SNick],
|
[SJID, SHost, SNick],
|
||||||
@ -140,16 +140,16 @@ set_nick(LServer, Host, From, Nick) ->
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
ejabberd_odbc:sql_transaction(LServer, F).
|
ejabberd_sql:sql_transaction(LServer, F).
|
||||||
|
|
||||||
export(_Server) ->
|
export(_Server) ->
|
||||||
[{muc_room,
|
[{muc_room,
|
||||||
fun(Host, #muc_room{name_host = {Name, RoomHost}, opts = Opts}) ->
|
fun(Host, #muc_room{name_host = {Name, RoomHost}, opts = Opts}) ->
|
||||||
case str:suffix(Host, RoomHost) of
|
case str:suffix(Host, RoomHost) of
|
||||||
true ->
|
true ->
|
||||||
SName = ejabberd_odbc:escape(Name),
|
SName = ejabberd_sql:escape(Name),
|
||||||
SRoomHost = ejabberd_odbc:escape(RoomHost),
|
SRoomHost = ejabberd_sql:escape(RoomHost),
|
||||||
SOpts = ejabberd_odbc:encode_term(Opts),
|
SOpts = ejabberd_sql:encode_term(Opts),
|
||||||
[[<<"delete from muc_room where name='">>, SName,
|
[[<<"delete from muc_room where name='">>, SName,
|
||||||
<<"' and host='">>, SRoomHost, <<"';">>],
|
<<"' and host='">>, SRoomHost, <<"';">>],
|
||||||
[<<"insert into muc_room(name, host, opts) ",
|
[<<"insert into muc_room(name, host, opts) ",
|
||||||
@ -165,11 +165,11 @@ export(_Server) ->
|
|||||||
nick = Nick}) ->
|
nick = Nick}) ->
|
||||||
case str:suffix(Host, RoomHost) of
|
case str:suffix(Host, RoomHost) of
|
||||||
true ->
|
true ->
|
||||||
SJID = ejabberd_odbc:escape(
|
SJID = ejabberd_sql:escape(
|
||||||
jid:to_string(
|
jid:to_string(
|
||||||
jid:make(U, S, <<"">>))),
|
jid:make(U, S, <<"">>))),
|
||||||
SNick = ejabberd_odbc:escape(Nick),
|
SNick = ejabberd_sql:escape(Nick),
|
||||||
SRoomHost = ejabberd_odbc:escape(RoomHost),
|
SRoomHost = ejabberd_sql:escape(RoomHost),
|
||||||
[[<<"delete from muc_registered where jid='">>,
|
[[<<"delete from muc_registered where jid='">>,
|
||||||
SJID, <<"' and host='">>, SRoomHost, <<"';">>],
|
SJID, <<"' and host='">>, SRoomHost, <<"';">>],
|
||||||
[<<"insert into muc_registered(jid, host, "
|
[<<"insert into muc_registered(jid, host, "
|
||||||
@ -184,7 +184,7 @@ export(_Server) ->
|
|||||||
import(_LServer) ->
|
import(_LServer) ->
|
||||||
[{<<"select name, host, opts from muc_room;">>,
|
[{<<"select name, host, opts from muc_room;">>,
|
||||||
fun([Name, RoomHost, SOpts]) ->
|
fun([Name, RoomHost, SOpts]) ->
|
||||||
Opts = mod_muc:opts_to_binary(ejabberd_odbc:decode_term(SOpts)),
|
Opts = mod_muc:opts_to_binary(ejabberd_sql:decode_term(SOpts)),
|
||||||
#muc_room{name_host = {Name, RoomHost}, opts = Opts}
|
#muc_room{name_host = {Name, RoomHost}, opts = Opts}
|
||||||
end},
|
end},
|
||||||
{<<"select jid, host, nick from muc_registered;">>,
|
{<<"select jid, host, nick from muc_registered;">>,
|
||||||
|
@ -243,7 +243,7 @@ receive_all(US, Msgs, DBType) ->
|
|||||||
after 0 ->
|
after 0 ->
|
||||||
case DBType of
|
case DBType of
|
||||||
mnesia -> Msgs;
|
mnesia -> Msgs;
|
||||||
odbc -> lists:reverse(Msgs);
|
sql -> lists:reverse(Msgs);
|
||||||
riak -> Msgs
|
riak -> Msgs
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
@ -39,7 +39,7 @@ store_messages(Host, {User, _Server}, Msgs, Len, MaxOfflineMsgs) ->
|
|||||||
Query = lists:map(
|
Query = lists:map(
|
||||||
fun(M) ->
|
fun(M) ->
|
||||||
Username =
|
Username =
|
||||||
ejabberd_odbc:escape((M#offline_msg.to)#jid.luser),
|
ejabberd_sql:escape((M#offline_msg.to)#jid.luser),
|
||||||
From = M#offline_msg.from,
|
From = M#offline_msg.from,
|
||||||
To = M#offline_msg.to,
|
To = M#offline_msg.to,
|
||||||
Packet =
|
Packet =
|
||||||
@ -50,15 +50,15 @@ store_messages(Host, {User, _Server}, Msgs, Len, MaxOfflineMsgs) ->
|
|||||||
M#offline_msg.timestamp,
|
M#offline_msg.timestamp,
|
||||||
<<"Offline Storage">>),
|
<<"Offline Storage">>),
|
||||||
XML =
|
XML =
|
||||||
ejabberd_odbc:escape(fxml:element_to_binary(NewPacket)),
|
ejabberd_sql:escape(fxml:element_to_binary(NewPacket)),
|
||||||
odbc_queries:add_spool_sql(Username, XML)
|
sql_queries:add_spool_sql(Username, XML)
|
||||||
end,
|
end,
|
||||||
Msgs),
|
Msgs),
|
||||||
odbc_queries:add_spool(Host, Query)
|
sql_queries:add_spool(Host, Query)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
pop_messages(LUser, LServer) ->
|
pop_messages(LUser, LServer) ->
|
||||||
case odbc_queries:get_and_del_spool_msg_t(LServer, LUser) of
|
case sql_queries:get_and_del_spool_msg_t(LServer, LUser) of
|
||||||
{atomic, {selected, Rs}} ->
|
{atomic, {selected, Rs}} ->
|
||||||
{ok, lists:flatmap(
|
{ok, lists:flatmap(
|
||||||
fun({_, XML}) ->
|
fun({_, XML}) ->
|
||||||
@ -78,7 +78,7 @@ remove_expired_messages(_LServer) ->
|
|||||||
{atomic, ok}.
|
{atomic, ok}.
|
||||||
|
|
||||||
remove_old_messages(Days, LServer) ->
|
remove_old_messages(Days, LServer) ->
|
||||||
case catch ejabberd_odbc:sql_query(
|
case catch ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
[<<"DELETE FROM spool"
|
[<<"DELETE FROM spool"
|
||||||
" WHERE created_at < "
|
" WHERE created_at < "
|
||||||
@ -92,11 +92,11 @@ remove_old_messages(Days, LServer) ->
|
|||||||
{atomic, ok}.
|
{atomic, ok}.
|
||||||
|
|
||||||
remove_user(LUser, LServer) ->
|
remove_user(LUser, LServer) ->
|
||||||
odbc_queries:del_spool_msg(LServer, LUser).
|
sql_queries:del_spool_msg(LServer, LUser).
|
||||||
|
|
||||||
read_message_headers(LUser, LServer) ->
|
read_message_headers(LUser, LServer) ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
case catch ejabberd_odbc:sql_query(
|
case catch ejabberd_sql:sql_query(
|
||||||
LServer, [<<"select xml, seq from spool where username ='">>,
|
LServer, [<<"select xml, seq from spool where username ='">>,
|
||||||
Username, <<"' order by seq;">>]) of
|
Username, <<"' order by seq;">>]) of
|
||||||
{selected, [<<"xml">>, <<"seq">>], Rows} ->
|
{selected, [<<"xml">>, <<"seq">>], Rows} ->
|
||||||
@ -117,9 +117,9 @@ read_message_headers(LUser, LServer) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
read_message(LUser, LServer, Seq) ->
|
read_message(LUser, LServer, Seq) ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
SSeq = ejabberd_odbc:escape(integer_to_binary(Seq)),
|
SSeq = ejabberd_sql:escape(integer_to_binary(Seq)),
|
||||||
case ejabberd_odbc:sql_query(
|
case ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
[<<"select xml from spool where username='">>, Username,
|
[<<"select xml from spool where username='">>, Username,
|
||||||
<<"' and seq='">>, SSeq, <<"';">>]) of
|
<<"' and seq='">>, SSeq, <<"';">>]) of
|
||||||
@ -135,16 +135,16 @@ read_message(LUser, LServer, Seq) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
remove_message(LUser, LServer, Seq) ->
|
remove_message(LUser, LServer, Seq) ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
SSeq = ejabberd_odbc:escape(integer_to_binary(Seq)),
|
SSeq = ejabberd_sql:escape(integer_to_binary(Seq)),
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
[<<"delete from spool where username='">>, Username,
|
[<<"delete from spool where username='">>, Username,
|
||||||
<<"' and seq='">>, SSeq, <<"';">>]),
|
<<"' and seq='">>, SSeq, <<"';">>]),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
read_all_messages(LUser, LServer) ->
|
read_all_messages(LUser, LServer) ->
|
||||||
case catch ejabberd_odbc:sql_query(
|
case catch ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(xml)s from spool where "
|
?SQL("select @(xml)s from spool where "
|
||||||
"username=%(LUser)s order by seq")) of
|
"username=%(LUser)s order by seq")) of
|
||||||
@ -161,11 +161,11 @@ read_all_messages(LUser, LServer) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
remove_all_messages(LUser, LServer) ->
|
remove_all_messages(LUser, LServer) ->
|
||||||
odbc_queries:del_spool_msg(LServer, LUser),
|
sql_queries:del_spool_msg(LServer, LUser),
|
||||||
{atomic, ok}.
|
{atomic, ok}.
|
||||||
|
|
||||||
count_messages(LUser, LServer) ->
|
count_messages(LUser, LServer) ->
|
||||||
case catch ejabberd_odbc:sql_query(
|
case catch ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(count(*))d from spool "
|
?SQL("select @(count(*))d from spool "
|
||||||
"where username=%(LUser)s")) of
|
"where username=%(LUser)s")) of
|
||||||
@ -180,11 +180,11 @@ export(_Server) ->
|
|||||||
timestamp = TimeStamp, from = From, to = To,
|
timestamp = TimeStamp, from = From, to = To,
|
||||||
packet = Packet})
|
packet = Packet})
|
||||||
when LServer == Host ->
|
when LServer == Host ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
Packet1 = jlib:replace_from_to(From, To, Packet),
|
Packet1 = jlib:replace_from_to(From, To, Packet),
|
||||||
Packet2 = jlib:add_delay_info(Packet1, LServer, TimeStamp,
|
Packet2 = jlib:add_delay_info(Packet1, LServer, TimeStamp,
|
||||||
<<"Offline Storage">>),
|
<<"Offline Storage">>),
|
||||||
XML = ejabberd_odbc:escape(fxml:element_to_binary(Packet2)),
|
XML = ejabberd_sql:escape(fxml:element_to_binary(Packet2)),
|
||||||
[[<<"delete from spool where username='">>, Username, <<"';">>],
|
[[<<"delete from spool where username='">>, Username, <<"';">>],
|
||||||
[<<"insert into spool(username, xml) values ('">>,
|
[<<"insert into spool(username, xml) values ('">>,
|
||||||
Username, <<"', '">>, XML, <<"');">>]];
|
Username, <<"', '">>, XML, <<"');">>]];
|
||||||
|
@ -77,7 +77,7 @@ process_default_set(LUser, LServer, {value, Name}) ->
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
odbc_queries:sql_transaction(LServer, F);
|
sql_queries:sql_transaction(LServer, F);
|
||||||
process_default_set(LUser, LServer, false) ->
|
process_default_set(LUser, LServer, false) ->
|
||||||
case catch sql_unset_default_privacy_list(LUser,
|
case catch sql_unset_default_privacy_list(LUser,
|
||||||
LServer)
|
LServer)
|
||||||
@ -110,7 +110,7 @@ remove_privacy_list(LUser, LServer, Name) ->
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
odbc_queries:sql_transaction(LServer, F).
|
sql_queries:sql_transaction(LServer, F).
|
||||||
|
|
||||||
set_privacy_list(#privacy{us = {LUser, LServer},
|
set_privacy_list(#privacy{us = {LUser, LServer},
|
||||||
default = Default,
|
default = Default,
|
||||||
@ -131,7 +131,7 @@ set_privacy_list(#privacy{us = {LUser, LServer},
|
|||||||
end
|
end
|
||||||
end, Lists)
|
end, Lists)
|
||||||
end,
|
end,
|
||||||
odbc_queries:sql_transaction(LServer, F).
|
sql_queries:sql_transaction(LServer, F).
|
||||||
|
|
||||||
set_privacy_list(LUser, LServer, Name, List) ->
|
set_privacy_list(LUser, LServer, Name, List) ->
|
||||||
RItems = lists:map(fun item_to_raw/1, List),
|
RItems = lists:map(fun item_to_raw/1, List),
|
||||||
@ -147,7 +147,7 @@ set_privacy_list(LUser, LServer, Name, List) ->
|
|||||||
sql_set_privacy_list(ID, RItems),
|
sql_set_privacy_list(ID, RItems),
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
odbc_queries:sql_transaction(LServer, F).
|
sql_queries:sql_transaction(LServer, F).
|
||||||
|
|
||||||
get_user_list(LUser, LServer) ->
|
get_user_list(LUser, LServer) ->
|
||||||
case catch sql_get_default_privacy_list(LUser, LServer)
|
case catch sql_get_default_privacy_list(LUser, LServer)
|
||||||
@ -196,7 +196,7 @@ remove_user(LUser, LServer) ->
|
|||||||
sql_del_privacy_lists(LUser, LServer).
|
sql_del_privacy_lists(LUser, LServer).
|
||||||
|
|
||||||
export(Server) ->
|
export(Server) ->
|
||||||
case catch ejabberd_odbc:sql_query(jid:nameprep(Server),
|
case catch ejabberd_sql:sql_query(jid:nameprep(Server),
|
||||||
[<<"select id from privacy_list order by "
|
[<<"select id from privacy_list order by "
|
||||||
"id desc limit 1;">>]) of
|
"id desc limit 1;">>]) of
|
||||||
{selected, [<<"id">>], [[I]]} ->
|
{selected, [<<"id">>], [[I]]} ->
|
||||||
@ -208,9 +208,9 @@ export(Server) ->
|
|||||||
fun(Host, #privacy{us = {LUser, LServer}, lists = Lists,
|
fun(Host, #privacy{us = {LUser, LServer}, lists = Lists,
|
||||||
default = Default})
|
default = Default})
|
||||||
when LServer == Host ->
|
when LServer == Host ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
if Default /= none ->
|
if Default /= none ->
|
||||||
SDefault = ejabberd_odbc:escape(Default),
|
SDefault = ejabberd_sql:escape(Default),
|
||||||
[[<<"delete from privacy_default_list where ">>,
|
[[<<"delete from privacy_default_list where ">>,
|
||||||
<<"username='">>, Username, <<"';">>],
|
<<"username='">>, Username, <<"';">>],
|
||||||
[<<"insert into privacy_default_list(username, "
|
[<<"insert into privacy_default_list(username, "
|
||||||
@ -222,7 +222,7 @@ export(Server) ->
|
|||||||
end ++
|
end ++
|
||||||
lists:flatmap(
|
lists:flatmap(
|
||||||
fun({Name, List}) ->
|
fun({Name, List}) ->
|
||||||
SName = ejabberd_odbc:escape(Name),
|
SName = ejabberd_sql:escape(Name),
|
||||||
RItems = lists:map(fun item_to_raw/1, List),
|
RItems = lists:map(fun item_to_raw/1, List),
|
||||||
ID = jlib:integer_to_binary(get_id()),
|
ID = jlib:integer_to_binary(get_id()),
|
||||||
[[<<"delete from privacy_list where username='">>,
|
[[<<"delete from privacy_list where username='">>,
|
||||||
@ -329,8 +329,8 @@ item_to_raw(#listitem{type = Type, value = Value,
|
|||||||
none -> {<<"n">>, <<"">>};
|
none -> {<<"n">>, <<"">>};
|
||||||
jid ->
|
jid ->
|
||||||
{<<"j">>,
|
{<<"j">>,
|
||||||
ejabberd_odbc:escape(jid:to_string(Value))};
|
ejabberd_sql:escape(jid:to_string(Value))};
|
||||||
group -> {<<"g">>, ejabberd_odbc:escape(Value)};
|
group -> {<<"g">>, ejabberd_sql:escape(Value)};
|
||||||
subscription ->
|
subscription ->
|
||||||
case Value of
|
case Value of
|
||||||
none -> {<<"s">>, <<"none">>};
|
none -> {<<"s">>, <<"none">>};
|
||||||
@ -347,51 +347,51 @@ item_to_raw(#listitem{type = Type, value = Value,
|
|||||||
MatchMessage, MatchPresenceIn, MatchPresenceOut}.
|
MatchMessage, MatchPresenceIn, MatchPresenceOut}.
|
||||||
|
|
||||||
sql_get_default_privacy_list(LUser, LServer) ->
|
sql_get_default_privacy_list(LUser, LServer) ->
|
||||||
odbc_queries:get_default_privacy_list(LServer, LUser).
|
sql_queries:get_default_privacy_list(LServer, LUser).
|
||||||
|
|
||||||
sql_get_default_privacy_list_t(LUser) ->
|
sql_get_default_privacy_list_t(LUser) ->
|
||||||
odbc_queries:get_default_privacy_list_t(LUser).
|
sql_queries:get_default_privacy_list_t(LUser).
|
||||||
|
|
||||||
sql_get_privacy_list_names(LUser, LServer) ->
|
sql_get_privacy_list_names(LUser, LServer) ->
|
||||||
odbc_queries:get_privacy_list_names(LServer, LUser).
|
sql_queries:get_privacy_list_names(LServer, LUser).
|
||||||
|
|
||||||
sql_get_privacy_list_names_t(LUser) ->
|
sql_get_privacy_list_names_t(LUser) ->
|
||||||
odbc_queries:get_privacy_list_names_t(LUser).
|
sql_queries:get_privacy_list_names_t(LUser).
|
||||||
|
|
||||||
sql_get_privacy_list_id(LUser, LServer, Name) ->
|
sql_get_privacy_list_id(LUser, LServer, Name) ->
|
||||||
odbc_queries:get_privacy_list_id(LServer, LUser, Name).
|
sql_queries:get_privacy_list_id(LServer, LUser, Name).
|
||||||
|
|
||||||
sql_get_privacy_list_id_t(LUser, Name) ->
|
sql_get_privacy_list_id_t(LUser, Name) ->
|
||||||
odbc_queries:get_privacy_list_id_t(LUser, Name).
|
sql_queries:get_privacy_list_id_t(LUser, Name).
|
||||||
|
|
||||||
sql_get_privacy_list_data(LUser, LServer, Name) ->
|
sql_get_privacy_list_data(LUser, LServer, Name) ->
|
||||||
odbc_queries:get_privacy_list_data(LServer, LUser, Name).
|
sql_queries:get_privacy_list_data(LServer, LUser, Name).
|
||||||
|
|
||||||
sql_get_privacy_list_data_t(LUser, Name) ->
|
sql_get_privacy_list_data_t(LUser, Name) ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
SName = ejabberd_odbc:escape(Name),
|
SName = ejabberd_sql:escape(Name),
|
||||||
odbc_queries:get_privacy_list_data_t(Username, SName).
|
sql_queries:get_privacy_list_data_t(Username, SName).
|
||||||
|
|
||||||
sql_get_privacy_list_data_by_id(ID, LServer) ->
|
sql_get_privacy_list_data_by_id(ID, LServer) ->
|
||||||
odbc_queries:get_privacy_list_data_by_id(LServer, ID).
|
sql_queries:get_privacy_list_data_by_id(LServer, ID).
|
||||||
|
|
||||||
sql_get_privacy_list_data_by_id_t(ID) ->
|
sql_get_privacy_list_data_by_id_t(ID) ->
|
||||||
odbc_queries:get_privacy_list_data_by_id_t(ID).
|
sql_queries:get_privacy_list_data_by_id_t(ID).
|
||||||
|
|
||||||
sql_set_default_privacy_list(LUser, Name) ->
|
sql_set_default_privacy_list(LUser, Name) ->
|
||||||
odbc_queries:set_default_privacy_list(LUser, Name).
|
sql_queries:set_default_privacy_list(LUser, Name).
|
||||||
|
|
||||||
sql_unset_default_privacy_list(LUser, LServer) ->
|
sql_unset_default_privacy_list(LUser, LServer) ->
|
||||||
odbc_queries:unset_default_privacy_list(LServer, LUser).
|
sql_queries:unset_default_privacy_list(LServer, LUser).
|
||||||
|
|
||||||
sql_remove_privacy_list(LUser, Name) ->
|
sql_remove_privacy_list(LUser, Name) ->
|
||||||
odbc_queries:remove_privacy_list(LUser, Name).
|
sql_queries:remove_privacy_list(LUser, Name).
|
||||||
|
|
||||||
sql_add_privacy_list(LUser, Name) ->
|
sql_add_privacy_list(LUser, Name) ->
|
||||||
odbc_queries:add_privacy_list(LUser, Name).
|
sql_queries:add_privacy_list(LUser, Name).
|
||||||
|
|
||||||
sql_set_privacy_list(ID, RItems) ->
|
sql_set_privacy_list(ID, RItems) ->
|
||||||
odbc_queries:set_privacy_list(ID, RItems).
|
sql_queries:set_privacy_list(ID, RItems).
|
||||||
|
|
||||||
sql_del_privacy_lists(LUser, LServer) ->
|
sql_del_privacy_lists(LUser, LServer) ->
|
||||||
odbc_queries:del_privacy_lists(LServer, LUser).
|
sql_queries:del_privacy_lists(LServer, LUser).
|
||||||
|
@ -28,14 +28,14 @@ set_data(LUser, LServer, Data) ->
|
|||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun({XMLNS, El}) ->
|
fun({XMLNS, El}) ->
|
||||||
SData = fxml:element_to_binary(El),
|
SData = fxml:element_to_binary(El),
|
||||||
odbc_queries:set_private_data(
|
sql_queries:set_private_data(
|
||||||
LServer, LUser, XMLNS, SData)
|
LServer, LUser, XMLNS, SData)
|
||||||
end, Data)
|
end, Data)
|
||||||
end,
|
end,
|
||||||
ejabberd_odbc:sql_transaction(LServer, F).
|
ejabberd_sql:sql_transaction(LServer, F).
|
||||||
|
|
||||||
get_data(LUser, LServer, XMLNS) ->
|
get_data(LUser, LServer, XMLNS) ->
|
||||||
case catch odbc_queries:get_private_data(LServer, LUser, XMLNS) of
|
case catch sql_queries:get_private_data(LServer, LUser, XMLNS) of
|
||||||
{selected, [{SData}]} ->
|
{selected, [{SData}]} ->
|
||||||
case fxml_stream:parse_element(SData) of
|
case fxml_stream:parse_element(SData) of
|
||||||
Data when is_record(Data, xmlel) ->
|
Data when is_record(Data, xmlel) ->
|
||||||
@ -48,7 +48,7 @@ get_data(LUser, LServer, XMLNS) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
get_all_data(LUser, LServer) ->
|
get_all_data(LUser, LServer) ->
|
||||||
case catch odbc_queries:get_private_data(LServer, LUser) of
|
case catch sql_queries:get_private_data(LServer, LUser) of
|
||||||
{selected, Res} ->
|
{selected, Res} ->
|
||||||
lists:flatmap(
|
lists:flatmap(
|
||||||
fun({_, SData}) ->
|
fun({_, SData}) ->
|
||||||
@ -64,18 +64,18 @@ get_all_data(LUser, LServer) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
remove_user(LUser, LServer) ->
|
remove_user(LUser, LServer) ->
|
||||||
odbc_queries:del_user_private_storage(LServer, LUser).
|
sql_queries:del_user_private_storage(LServer, LUser).
|
||||||
|
|
||||||
export(_Server) ->
|
export(_Server) ->
|
||||||
[{private_storage,
|
[{private_storage,
|
||||||
fun(Host, #private_storage{usns = {LUser, LServer, XMLNS},
|
fun(Host, #private_storage{usns = {LUser, LServer, XMLNS},
|
||||||
xml = Data})
|
xml = Data})
|
||||||
when LServer == Host ->
|
when LServer == Host ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
LXMLNS = ejabberd_odbc:escape(XMLNS),
|
LXMLNS = ejabberd_sql:escape(XMLNS),
|
||||||
SData =
|
SData =
|
||||||
ejabberd_odbc:escape(fxml:element_to_binary(Data)),
|
ejabberd_sql:escape(fxml:element_to_binary(Data)),
|
||||||
odbc_queries:set_private_data_sql(Username, LXMLNS,
|
sql_queries:set_private_data_sql(Username, LXMLNS,
|
||||||
SData);
|
SData);
|
||||||
(_Host, _R) ->
|
(_Host, _R) ->
|
||||||
[]
|
[]
|
||||||
|
@ -2527,7 +2527,7 @@ get_last_item(Host, Type, Nidx, LJID, mnesia) ->
|
|||||||
{result, {[LastItem|_], _}} -> LastItem;
|
{result, {[LastItem|_], _}} -> LastItem;
|
||||||
_ -> undefined
|
_ -> undefined
|
||||||
end;
|
end;
|
||||||
get_last_item(Host, Type, Nidx, LJID, odbc) ->
|
get_last_item(Host, Type, Nidx, LJID, sql) ->
|
||||||
case node_action(Host, Type, get_last_items, [Nidx, LJID, 1]) of
|
case node_action(Host, Type, get_last_items, [Nidx, LJID, 1]) of
|
||||||
{result, [LastItem]} -> LastItem;
|
{result, [LastItem]} -> LastItem;
|
||||||
_ -> undefined
|
_ -> undefined
|
||||||
@ -2542,7 +2542,7 @@ get_last_items(Host, Type, Nidx, LJID, Number, mnesia) ->
|
|||||||
{result, {Items, _}} -> lists:sublist(Items, Number);
|
{result, {Items, _}} -> lists:sublist(Items, Number);
|
||||||
_ -> []
|
_ -> []
|
||||||
end;
|
end;
|
||||||
get_last_items(Host, Type, Nidx, LJID, Number, odbc) ->
|
get_last_items(Host, Type, Nidx, LJID, Number, sql) ->
|
||||||
case node_action(Host, Type, get_last_items, [Nidx, LJID, Number]) of
|
case node_action(Host, Type, get_last_items, [Nidx, LJID, Number]) of
|
||||||
{result, Items} -> Items;
|
{result, Items} -> Items;
|
||||||
_ -> []
|
_ -> []
|
||||||
@ -3012,7 +3012,7 @@ get_subscriptions_for_send_last(Host, PType, mnesia, JID, LJID, BJID) ->
|
|||||||
|| {Node, Sub, SubId, SubJID} <- Subs,
|
|| {Node, Sub, SubId, SubJID} <- Subs,
|
||||||
Sub =:= subscribed, (SubJID == LJID) or (SubJID == BJID),
|
Sub =:= subscribed, (SubJID == LJID) or (SubJID == BJID),
|
||||||
match_option(Node, send_last_published_item, on_sub_and_presence)];
|
match_option(Node, send_last_published_item, on_sub_and_presence)];
|
||||||
get_subscriptions_for_send_last(Host, PType, odbc, JID, LJID, BJID) ->
|
get_subscriptions_for_send_last(Host, PType, sql, JID, LJID, BJID) ->
|
||||||
case catch node_action(Host, PType,
|
case catch node_action(Host, PType,
|
||||||
get_entity_subscriptions_for_send_last,
|
get_entity_subscriptions_for_send_last,
|
||||||
[Host, JID])
|
[Host, JID])
|
||||||
@ -3688,7 +3688,7 @@ filter_node_options(Options) ->
|
|||||||
|
|
||||||
node_owners_action(Host, Type, Nidx, []) ->
|
node_owners_action(Host, Type, Nidx, []) ->
|
||||||
case gen_mod:db_type(serverhost(Host), ?MODULE) of
|
case gen_mod:db_type(serverhost(Host), ?MODULE) of
|
||||||
odbc ->
|
sql ->
|
||||||
case node_action(Host, Type, get_node_affiliations, [Nidx]) of
|
case node_action(Host, Type, get_node_affiliations, [Nidx]) of
|
||||||
{result, Affs} -> [LJID || {LJID, Aff} <- Affs, Aff =:= owner];
|
{result, Affs} -> [LJID || {LJID, Aff} <- Affs, Aff =:= owner];
|
||||||
_ -> []
|
_ -> []
|
||||||
@ -3701,7 +3701,7 @@ node_owners_action(_Host, _Type, _Nidx, Owners) ->
|
|||||||
|
|
||||||
node_owners_call(Host, Type, Nidx, []) ->
|
node_owners_call(Host, Type, Nidx, []) ->
|
||||||
case gen_mod:db_type(serverhost(Host), ?MODULE) of
|
case gen_mod:db_type(serverhost(Host), ?MODULE) of
|
||||||
odbc ->
|
sql ->
|
||||||
case node_call(Host, Type, get_node_affiliations, [Nidx]) of
|
case node_call(Host, Type, get_node_affiliations, [Nidx]) of
|
||||||
{result, Affs} -> [LJID || {LJID, Aff} <- Affs, Aff =:= owner];
|
{result, Affs} -> [LJID || {LJID, Aff} <- Affs, Aff =:= owner];
|
||||||
_ -> []
|
_ -> []
|
||||||
@ -4066,14 +4066,14 @@ tree(_Host, <<"virtual">>) ->
|
|||||||
tree(Host, Name) ->
|
tree(Host, Name) ->
|
||||||
case gen_mod:db_type(serverhost(Host), ?MODULE) of
|
case gen_mod:db_type(serverhost(Host), ?MODULE) of
|
||||||
mnesia -> jlib:binary_to_atom(<<"nodetree_", Name/binary>>);
|
mnesia -> jlib:binary_to_atom(<<"nodetree_", Name/binary>>);
|
||||||
odbc -> jlib:binary_to_atom(<<"nodetree_", Name/binary, "_odbc">>);
|
sql -> jlib:binary_to_atom(<<"nodetree_", Name/binary, "_sql">>);
|
||||||
_ -> Name
|
_ -> Name
|
||||||
end.
|
end.
|
||||||
|
|
||||||
plugin(Host, Name) ->
|
plugin(Host, Name) ->
|
||||||
case gen_mod:db_type(serverhost(Host), ?MODULE) of
|
case gen_mod:db_type(serverhost(Host), ?MODULE) of
|
||||||
mnesia -> jlib:binary_to_atom(<<"node_", Name/binary>>);
|
mnesia -> jlib:binary_to_atom(<<"node_", Name/binary>>);
|
||||||
odbc -> jlib:binary_to_atom(<<"node_", Name/binary, "_odbc">>);
|
sql -> jlib:binary_to_atom(<<"node_", Name/binary, "_sql">>);
|
||||||
_ -> Name
|
_ -> Name
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -4087,7 +4087,7 @@ plugins(Host) ->
|
|||||||
subscription_plugin(Host) ->
|
subscription_plugin(Host) ->
|
||||||
case gen_mod:db_type(serverhost(Host), ?MODULE) of
|
case gen_mod:db_type(serverhost(Host), ?MODULE) of
|
||||||
mnesia -> pubsub_subscription;
|
mnesia -> pubsub_subscription;
|
||||||
odbc -> pubsub_subscription_odbc;
|
sql -> pubsub_subscription_sql;
|
||||||
_ -> none
|
_ -> none
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -4184,8 +4184,8 @@ tree_action(Host, Function, Args) ->
|
|||||||
case gen_mod:db_type(ServerHost, ?MODULE) of
|
case gen_mod:db_type(ServerHost, ?MODULE) of
|
||||||
mnesia ->
|
mnesia ->
|
||||||
catch mnesia:sync_dirty(Fun);
|
catch mnesia:sync_dirty(Fun);
|
||||||
odbc ->
|
sql ->
|
||||||
case catch ejabberd_odbc:sql_bloc(ServerHost, Fun) of
|
case catch ejabberd_sql:sql_bloc(ServerHost, Fun) of
|
||||||
{atomic, Result} ->
|
{atomic, Result} ->
|
||||||
Result;
|
Result;
|
||||||
{aborted, Reason} ->
|
{aborted, Reason} ->
|
||||||
@ -4244,7 +4244,7 @@ transaction(Host, Fun, Trans) ->
|
|||||||
ServerHost = serverhost(Host),
|
ServerHost = serverhost(Host),
|
||||||
DBType = gen_mod:db_type(ServerHost, ?MODULE),
|
DBType = gen_mod:db_type(ServerHost, ?MODULE),
|
||||||
Retry = case DBType of
|
Retry = case DBType of
|
||||||
odbc -> 2;
|
sql -> 2;
|
||||||
_ -> 1
|
_ -> 1
|
||||||
end,
|
end,
|
||||||
transaction_retry(Host, ServerHost, Fun, Trans, DBType, Retry).
|
transaction_retry(Host, ServerHost, Fun, Trans, DBType, Retry).
|
||||||
@ -4255,12 +4255,12 @@ transaction_retry(Host, ServerHost, Fun, Trans, DBType, Count) ->
|
|||||||
Res = case DBType of
|
Res = case DBType of
|
||||||
mnesia ->
|
mnesia ->
|
||||||
catch mnesia:Trans(Fun);
|
catch mnesia:Trans(Fun);
|
||||||
odbc ->
|
sql ->
|
||||||
SqlFun = case Trans of
|
SqlFun = case Trans of
|
||||||
transaction -> sql_transaction;
|
transaction -> sql_transaction;
|
||||||
_ -> sql_bloc
|
_ -> sql_bloc
|
||||||
end,
|
end,
|
||||||
catch ejabberd_odbc:SqlFun(ServerHost, Fun);
|
catch ejabberd_sql:SqlFun(ServerHost, Fun);
|
||||||
_ ->
|
_ ->
|
||||||
{unsupported, DBType}
|
{unsupported, DBType}
|
||||||
end,
|
end,
|
||||||
|
@ -28,28 +28,28 @@ init(_Host, _Opts) ->
|
|||||||
ok.
|
ok.
|
||||||
|
|
||||||
read_roster_version(LUser, LServer) ->
|
read_roster_version(LUser, LServer) ->
|
||||||
case odbc_queries:get_roster_version(LServer, LUser) of
|
case sql_queries:get_roster_version(LServer, LUser) of
|
||||||
{selected, [{Version}]} -> Version;
|
{selected, [{Version}]} -> Version;
|
||||||
{selected, []} -> error
|
{selected, []} -> error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
write_roster_version(LUser, LServer, InTransaction, Ver) ->
|
write_roster_version(LUser, LServer, InTransaction, Ver) ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
EVer = ejabberd_odbc:escape(Ver),
|
EVer = ejabberd_sql:escape(Ver),
|
||||||
if InTransaction ->
|
if InTransaction ->
|
||||||
odbc_queries:set_roster_version(Username, EVer);
|
sql_queries:set_roster_version(Username, EVer);
|
||||||
true ->
|
true ->
|
||||||
odbc_queries:sql_transaction(
|
sql_queries:sql_transaction(
|
||||||
LServer,
|
LServer,
|
||||||
fun () ->
|
fun () ->
|
||||||
odbc_queries:set_roster_version(Username, EVer)
|
sql_queries:set_roster_version(Username, EVer)
|
||||||
end)
|
end)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_roster(LUser, LServer) ->
|
get_roster(LUser, LServer) ->
|
||||||
case catch odbc_queries:get_roster(LServer, LUser) of
|
case catch sql_queries:get_roster(LServer, LUser) of
|
||||||
{selected, Items} when is_list(Items) ->
|
{selected, Items} when is_list(Items) ->
|
||||||
JIDGroups = case catch odbc_queries:get_roster_jid_groups(
|
JIDGroups = case catch sql_queries:get_roster_jid_groups(
|
||||||
LServer, LUser) of
|
LServer, LUser) of
|
||||||
{selected, JGrps} when is_list(JGrps) ->
|
{selected, JGrps} when is_list(JGrps) ->
|
||||||
JGrps;
|
JGrps;
|
||||||
@ -80,7 +80,7 @@ get_roster(LUser, LServer) ->
|
|||||||
|
|
||||||
get_roster_by_jid(LUser, LServer, LJID) ->
|
get_roster_by_jid(LUser, LServer, LJID) ->
|
||||||
{selected, Res} =
|
{selected, Res} =
|
||||||
odbc_queries:get_roster_by_jid(LServer, LUser, jid:to_string(LJID)),
|
sql_queries:get_roster_by_jid(LServer, LUser, jid:to_string(LJID)),
|
||||||
case Res of
|
case Res of
|
||||||
[] ->
|
[] ->
|
||||||
#roster{usj = {LUser, LServer, LJID},
|
#roster{usj = {LUser, LServer, LJID},
|
||||||
@ -99,7 +99,7 @@ get_roster_by_jid(LUser, LServer, LJID) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
get_only_items(LUser, LServer) ->
|
get_only_items(LUser, LServer) ->
|
||||||
case catch odbc_queries:get_roster(LServer, LUser) of
|
case catch sql_queries:get_roster(LServer, LUser) of
|
||||||
{selected, Is} when is_list(Is) ->
|
{selected, Is} when is_list(Is) ->
|
||||||
lists:map(fun(I) -> raw_to_record(LServer, I) end, Is);
|
lists:map(fun(I) -> raw_to_record(LServer, I) end, Is);
|
||||||
_ -> []
|
_ -> []
|
||||||
@ -107,18 +107,18 @@ get_only_items(LUser, LServer) ->
|
|||||||
|
|
||||||
roster_subscribe(_LUser, _LServer, _LJID, Item) ->
|
roster_subscribe(_LUser, _LServer, _LJID, Item) ->
|
||||||
ItemVals = record_to_row(Item),
|
ItemVals = record_to_row(Item),
|
||||||
odbc_queries:roster_subscribe(ItemVals).
|
sql_queries:roster_subscribe(ItemVals).
|
||||||
|
|
||||||
transaction(LServer, F) ->
|
transaction(LServer, F) ->
|
||||||
ejabberd_odbc:sql_transaction(LServer, F).
|
ejabberd_sql:sql_transaction(LServer, F).
|
||||||
|
|
||||||
get_roster_by_jid_with_groups(LUser, LServer, LJID) ->
|
get_roster_by_jid_with_groups(LUser, LServer, LJID) ->
|
||||||
SJID = jid:to_string(LJID),
|
SJID = jid:to_string(LJID),
|
||||||
case odbc_queries:get_roster_by_jid(LServer, LUser, SJID) of
|
case sql_queries:get_roster_by_jid(LServer, LUser, SJID) of
|
||||||
{selected, [I]} ->
|
{selected, [I]} ->
|
||||||
R = raw_to_record(LServer, I),
|
R = raw_to_record(LServer, I),
|
||||||
Groups =
|
Groups =
|
||||||
case odbc_queries:get_roster_groups(LServer, LUser, SJID) of
|
case sql_queries:get_roster_groups(LServer, LUser, SJID) of
|
||||||
{selected, JGrps} when is_list(JGrps) ->
|
{selected, JGrps} when is_list(JGrps) ->
|
||||||
[JGrp || {JGrp} <- JGrps];
|
[JGrp || {JGrp} <- JGrps];
|
||||||
_ -> []
|
_ -> []
|
||||||
@ -130,23 +130,23 @@ get_roster_by_jid_with_groups(LUser, LServer, LJID) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
remove_user(LUser, LServer) ->
|
remove_user(LUser, LServer) ->
|
||||||
odbc_queries:del_user_roster_t(LServer, LUser),
|
sql_queries:del_user_roster_t(LServer, LUser),
|
||||||
{atomic, ok}.
|
{atomic, ok}.
|
||||||
|
|
||||||
update_roster(LUser, LServer, LJID, Item) ->
|
update_roster(LUser, LServer, LJID, Item) ->
|
||||||
SJID = jid:to_string(LJID),
|
SJID = jid:to_string(LJID),
|
||||||
ItemVals = record_to_row(Item),
|
ItemVals = record_to_row(Item),
|
||||||
ItemGroups = Item#roster.groups,
|
ItemGroups = Item#roster.groups,
|
||||||
odbc_queries:update_roster(LServer, LUser, SJID, ItemVals,
|
sql_queries:update_roster(LServer, LUser, SJID, ItemVals,
|
||||||
ItemGroups).
|
ItemGroups).
|
||||||
|
|
||||||
del_roster(LUser, LServer, LJID) ->
|
del_roster(LUser, LServer, LJID) ->
|
||||||
SJID = jid:to_string(LJID),
|
SJID = jid:to_string(LJID),
|
||||||
odbc_queries:del_roster(LServer, LUser, SJID).
|
sql_queries:del_roster(LServer, LUser, SJID).
|
||||||
|
|
||||||
read_subscription_and_groups(LUser, LServer, LJID) ->
|
read_subscription_and_groups(LUser, LServer, LJID) ->
|
||||||
SJID = jid:to_string(LJID),
|
SJID = jid:to_string(LJID),
|
||||||
case catch odbc_queries:get_subscription(LServer, LUser, SJID) of
|
case catch sql_queries:get_subscription(LServer, LUser, SJID) of
|
||||||
{selected, [{SSubscription}]} ->
|
{selected, [{SSubscription}]} ->
|
||||||
Subscription = case SSubscription of
|
Subscription = case SSubscription of
|
||||||
<<"B">> -> both;
|
<<"B">> -> both;
|
||||||
@ -154,7 +154,7 @@ read_subscription_and_groups(LUser, LServer, LJID) ->
|
|||||||
<<"F">> -> from;
|
<<"F">> -> from;
|
||||||
_ -> none
|
_ -> none
|
||||||
end,
|
end,
|
||||||
Groups = case catch odbc_queries:get_rostergroup_by_jid(
|
Groups = case catch sql_queries:get_rostergroup_by_jid(
|
||||||
LServer, LUser, SJID) of
|
LServer, LUser, SJID) of
|
||||||
{selected, JGrps} when is_list(JGrps) ->
|
{selected, JGrps} when is_list(JGrps) ->
|
||||||
[JGrp || {JGrp} <- JGrps];
|
[JGrp || {JGrp} <- JGrps];
|
||||||
@ -169,11 +169,11 @@ export(_Server) ->
|
|||||||
[{roster,
|
[{roster,
|
||||||
fun(Host, #roster{usj = {LUser, LServer, LJID}} = R)
|
fun(Host, #roster{usj = {LUser, LServer, LJID}} = R)
|
||||||
when LServer == Host ->
|
when LServer == Host ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
SJID = ejabberd_odbc:escape(jid:to_string(LJID)),
|
SJID = ejabberd_sql:escape(jid:to_string(LJID)),
|
||||||
ItemVals = record_to_string(R),
|
ItemVals = record_to_string(R),
|
||||||
ItemGroups = groups_to_string(R),
|
ItemGroups = groups_to_string(R),
|
||||||
odbc_queries:update_roster_sql(Username, SJID,
|
sql_queries:update_roster_sql(Username, SJID,
|
||||||
ItemVals, ItemGroups);
|
ItemVals, ItemGroups);
|
||||||
(_Host, _R) ->
|
(_Host, _R) ->
|
||||||
[]
|
[]
|
||||||
@ -181,8 +181,8 @@ export(_Server) ->
|
|||||||
{roster_version,
|
{roster_version,
|
||||||
fun(Host, #roster_version{us = {LUser, LServer}, version = Ver})
|
fun(Host, #roster_version{us = {LUser, LServer}, version = Ver})
|
||||||
when LServer == Host ->
|
when LServer == Host ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
SVer = ejabberd_odbc:escape(Ver),
|
SVer = ejabberd_sql:escape(Ver),
|
||||||
[[<<"delete from roster_version where username='">>,
|
[[<<"delete from roster_version where username='">>,
|
||||||
Username, <<"';">>],
|
Username, <<"';">>],
|
||||||
[<<"insert into roster_version(username, version) values('">>,
|
[<<"insert into roster_version(username, version) values('">>,
|
||||||
@ -196,10 +196,10 @@ import(LServer) ->
|
|||||||
"ask, askmessage, server, subscribe, type from rosterusers;">>,
|
"ask, askmessage, server, subscribe, type from rosterusers;">>,
|
||||||
fun([LUser, JID|_] = Row) ->
|
fun([LUser, JID|_] = Row) ->
|
||||||
Item = raw_to_record(LServer, Row),
|
Item = raw_to_record(LServer, Row),
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
SJID = ejabberd_odbc:escape(JID),
|
SJID = ejabberd_sql:escape(JID),
|
||||||
{selected, _, Rows} =
|
{selected, _, Rows} =
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
[<<"select grp from rostergroups where username='">>,
|
[<<"select grp from rostergroups where username='">>,
|
||||||
Username, <<"' and jid='">>, SJID, <<"'">>]),
|
Username, <<"' and jid='">>, SJID, <<"'">>]),
|
||||||
Groups = [Grp || [Grp] <- Rows],
|
Groups = [Grp || [Grp] <- Rows],
|
||||||
@ -252,10 +252,10 @@ raw_to_record(LServer,
|
|||||||
record_to_string(#roster{us = {User, _Server},
|
record_to_string(#roster{us = {User, _Server},
|
||||||
jid = JID, name = Name, subscription = Subscription,
|
jid = JID, name = Name, subscription = Subscription,
|
||||||
ask = Ask, askmessage = AskMessage}) ->
|
ask = Ask, askmessage = AskMessage}) ->
|
||||||
Username = ejabberd_odbc:escape(User),
|
Username = ejabberd_sql:escape(User),
|
||||||
SJID =
|
SJID =
|
||||||
ejabberd_odbc:escape(jid:to_string(jid:tolower(JID))),
|
ejabberd_sql:escape(jid:to_string(jid:tolower(JID))),
|
||||||
Nick = ejabberd_odbc:escape(Name),
|
Nick = ejabberd_sql:escape(Name),
|
||||||
SSubscription = case Subscription of
|
SSubscription = case Subscription of
|
||||||
both -> <<"B">>;
|
both -> <<"B">>;
|
||||||
to -> <<"T">>;
|
to -> <<"T">>;
|
||||||
@ -270,7 +270,7 @@ record_to_string(#roster{us = {User, _Server},
|
|||||||
in -> <<"I">>;
|
in -> <<"I">>;
|
||||||
none -> <<"N">>
|
none -> <<"N">>
|
||||||
end,
|
end,
|
||||||
SAskMessage = ejabberd_odbc:escape(AskMessage),
|
SAskMessage = ejabberd_sql:escape(AskMessage),
|
||||||
[Username, SJID, Nick, SSubscription, SAsk, SAskMessage,
|
[Username, SJID, Nick, SSubscription, SAsk, SAskMessage,
|
||||||
<<"N">>, <<"">>, <<"item">>].
|
<<"N">>, <<"">>, <<"item">>].
|
||||||
|
|
||||||
@ -297,12 +297,12 @@ record_to_row(
|
|||||||
|
|
||||||
groups_to_string(#roster{us = {User, _Server},
|
groups_to_string(#roster{us = {User, _Server},
|
||||||
jid = JID, groups = Groups}) ->
|
jid = JID, groups = Groups}) ->
|
||||||
Username = ejabberd_odbc:escape(User),
|
Username = ejabberd_sql:escape(User),
|
||||||
SJID =
|
SJID =
|
||||||
ejabberd_odbc:escape(jid:to_string(jid:tolower(JID))),
|
ejabberd_sql:escape(jid:to_string(jid:tolower(JID))),
|
||||||
lists:foldl(fun (<<"">>, Acc) -> Acc;
|
lists:foldl(fun (<<"">>, Acc) -> Acc;
|
||||||
(Group, Acc) ->
|
(Group, Acc) ->
|
||||||
G = ejabberd_odbc:escape(Group),
|
G = ejabberd_sql:escape(Group),
|
||||||
[[Username, SJID, G] | Acc]
|
[[Username, SJID, G] | Acc]
|
||||||
end,
|
end,
|
||||||
[], Groups).
|
[], Groups).
|
||||||
|
@ -29,69 +29,69 @@ init(_Host, _Opts) ->
|
|||||||
ok.
|
ok.
|
||||||
|
|
||||||
list_groups(Host) ->
|
list_groups(Host) ->
|
||||||
case ejabberd_odbc:sql_query(
|
case ejabberd_sql:sql_query(
|
||||||
Host, [<<"select name from sr_group;">>]) of
|
Host, [<<"select name from sr_group;">>]) of
|
||||||
{selected, [<<"name">>], Rs} -> [G || [G] <- Rs];
|
{selected, [<<"name">>], Rs} -> [G || [G] <- Rs];
|
||||||
_ -> []
|
_ -> []
|
||||||
end.
|
end.
|
||||||
|
|
||||||
groups_with_opts(Host) ->
|
groups_with_opts(Host) ->
|
||||||
case ejabberd_odbc:sql_query(Host,
|
case ejabberd_sql:sql_query(Host,
|
||||||
[<<"select name, opts from sr_group;">>])
|
[<<"select name, opts from sr_group;">>])
|
||||||
of
|
of
|
||||||
{selected, [<<"name">>, <<"opts">>], Rs} ->
|
{selected, [<<"name">>, <<"opts">>], Rs} ->
|
||||||
[{G, mod_shared_roster:opts_to_binary(ejabberd_odbc:decode_term(Opts))}
|
[{G, mod_shared_roster:opts_to_binary(ejabberd_sql:decode_term(Opts))}
|
||||||
|| [G, Opts] <- Rs];
|
|| [G, Opts] <- Rs];
|
||||||
_ -> []
|
_ -> []
|
||||||
end.
|
end.
|
||||||
|
|
||||||
create_group(Host, Group, Opts) ->
|
create_group(Host, Group, Opts) ->
|
||||||
SGroup = ejabberd_odbc:escape(Group),
|
SGroup = ejabberd_sql:escape(Group),
|
||||||
SOpts = ejabberd_odbc:encode_term(Opts),
|
SOpts = ejabberd_sql:encode_term(Opts),
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
odbc_queries:update_t(<<"sr_group">>,
|
sql_queries:update_t(<<"sr_group">>,
|
||||||
[<<"name">>, <<"opts">>], [SGroup, SOpts],
|
[<<"name">>, <<"opts">>], [SGroup, SOpts],
|
||||||
[<<"name='">>, SGroup, <<"'">>])
|
[<<"name='">>, SGroup, <<"'">>])
|
||||||
end,
|
end,
|
||||||
ejabberd_odbc:sql_transaction(Host, F).
|
ejabberd_sql:sql_transaction(Host, F).
|
||||||
|
|
||||||
delete_group(Host, Group) ->
|
delete_group(Host, Group) ->
|
||||||
SGroup = ejabberd_odbc:escape(Group),
|
SGroup = ejabberd_sql:escape(Group),
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
ejabberd_odbc:sql_query_t([<<"delete from sr_group where name='">>,
|
ejabberd_sql:sql_query_t([<<"delete from sr_group where name='">>,
|
||||||
SGroup, <<"';">>]),
|
SGroup, <<"';">>]),
|
||||||
ejabberd_odbc:sql_query_t([<<"delete from sr_user where grp='">>,
|
ejabberd_sql:sql_query_t([<<"delete from sr_user where grp='">>,
|
||||||
SGroup, <<"';">>])
|
SGroup, <<"';">>])
|
||||||
end,
|
end,
|
||||||
case ejabberd_odbc:sql_transaction(Host, F) of
|
case ejabberd_sql:sql_transaction(Host, F) of
|
||||||
{atomic,{updated,_}} -> {atomic, ok};
|
{atomic,{updated,_}} -> {atomic, ok};
|
||||||
Res -> Res
|
Res -> Res
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_group_opts(Host, Group) ->
|
get_group_opts(Host, Group) ->
|
||||||
SGroup = ejabberd_odbc:escape(Group),
|
SGroup = ejabberd_sql:escape(Group),
|
||||||
case catch ejabberd_odbc:sql_query(
|
case catch ejabberd_sql:sql_query(
|
||||||
Host,
|
Host,
|
||||||
[<<"select opts from sr_group where name='">>,
|
[<<"select opts from sr_group where name='">>,
|
||||||
SGroup, <<"';">>]) of
|
SGroup, <<"';">>]) of
|
||||||
{selected, [<<"opts">>], [[SOpts]]} ->
|
{selected, [<<"opts">>], [[SOpts]]} ->
|
||||||
mod_shared_roster:opts_to_binary(ejabberd_odbc:decode_term(SOpts));
|
mod_shared_roster:opts_to_binary(ejabberd_sql:decode_term(SOpts));
|
||||||
_ -> error
|
_ -> error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
set_group_opts(Host, Group, Opts) ->
|
set_group_opts(Host, Group, Opts) ->
|
||||||
SGroup = ejabberd_odbc:escape(Group),
|
SGroup = ejabberd_sql:escape(Group),
|
||||||
SOpts = ejabberd_odbc:encode_term(Opts),
|
SOpts = ejabberd_sql:encode_term(Opts),
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
odbc_queries:update_t(<<"sr_group">>,
|
sql_queries:update_t(<<"sr_group">>,
|
||||||
[<<"name">>, <<"opts">>], [SGroup, SOpts],
|
[<<"name">>, <<"opts">>], [SGroup, SOpts],
|
||||||
[<<"name='">>, SGroup, <<"'">>])
|
[<<"name='">>, SGroup, <<"'">>])
|
||||||
end,
|
end,
|
||||||
ejabberd_odbc:sql_transaction(Host, F).
|
ejabberd_sql:sql_transaction(Host, F).
|
||||||
|
|
||||||
get_user_groups(US, Host) ->
|
get_user_groups(US, Host) ->
|
||||||
SJID = make_jid_s(US),
|
SJID = make_jid_s(US),
|
||||||
case catch ejabberd_odbc:sql_query(
|
case catch ejabberd_sql:sql_query(
|
||||||
Host,
|
Host,
|
||||||
[<<"select grp from sr_user where jid='">>,
|
[<<"select grp from sr_user where jid='">>,
|
||||||
SJID, <<"';">>]) of
|
SJID, <<"';">>]) of
|
||||||
@ -100,8 +100,8 @@ get_user_groups(US, Host) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
get_group_explicit_users(Host, Group) ->
|
get_group_explicit_users(Host, Group) ->
|
||||||
SGroup = ejabberd_odbc:escape(Group),
|
SGroup = ejabberd_sql:escape(Group),
|
||||||
case catch ejabberd_odbc:sql_query(
|
case catch ejabberd_sql:sql_query(
|
||||||
Host,
|
Host,
|
||||||
[<<"select jid from sr_user where grp='">>,
|
[<<"select jid from sr_user where grp='">>,
|
||||||
SGroup, <<"';">>]) of
|
SGroup, <<"';">>]) of
|
||||||
@ -117,7 +117,7 @@ get_group_explicit_users(Host, Group) ->
|
|||||||
|
|
||||||
get_user_displayed_groups(LUser, LServer, GroupsOpts) ->
|
get_user_displayed_groups(LUser, LServer, GroupsOpts) ->
|
||||||
SJID = make_jid_s(LUser, LServer),
|
SJID = make_jid_s(LUser, LServer),
|
||||||
case catch ejabberd_odbc:sql_query(
|
case catch ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
[<<"select grp from sr_user where jid='">>,
|
[<<"select grp from sr_user where jid='">>,
|
||||||
SJID, <<"';">>]) of
|
SJID, <<"';">>]) of
|
||||||
@ -129,8 +129,8 @@ get_user_displayed_groups(LUser, LServer, GroupsOpts) ->
|
|||||||
|
|
||||||
is_user_in_group(US, Group, Host) ->
|
is_user_in_group(US, Group, Host) ->
|
||||||
SJID = make_jid_s(US),
|
SJID = make_jid_s(US),
|
||||||
SGroup = ejabberd_odbc:escape(Group),
|
SGroup = ejabberd_sql:escape(Group),
|
||||||
case catch ejabberd_odbc:sql_query(Host,
|
case catch ejabberd_sql:sql_query(Host,
|
||||||
[<<"select * from sr_user where jid='">>,
|
[<<"select * from sr_user where jid='">>,
|
||||||
SJID, <<"' and grp='">>, SGroup,
|
SJID, <<"' and grp='">>, SGroup,
|
||||||
<<"';">>]) of
|
<<"';">>]) of
|
||||||
@ -140,32 +140,32 @@ is_user_in_group(US, Group, Host) ->
|
|||||||
|
|
||||||
add_user_to_group(Host, US, Group) ->
|
add_user_to_group(Host, US, Group) ->
|
||||||
SJID = make_jid_s(US),
|
SJID = make_jid_s(US),
|
||||||
SGroup = ejabberd_odbc:escape(Group),
|
SGroup = ejabberd_sql:escape(Group),
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
odbc_queries:update_t(<<"sr_user">>,
|
sql_queries:update_t(<<"sr_user">>,
|
||||||
[<<"jid">>, <<"grp">>], [SJID, SGroup],
|
[<<"jid">>, <<"grp">>], [SJID, SGroup],
|
||||||
[<<"jid='">>, SJID, <<"' and grp='">>,
|
[<<"jid='">>, SJID, <<"' and grp='">>,
|
||||||
SGroup, <<"'">>])
|
SGroup, <<"'">>])
|
||||||
end,
|
end,
|
||||||
ejabberd_odbc:sql_transaction(Host, F).
|
ejabberd_sql:sql_transaction(Host, F).
|
||||||
|
|
||||||
remove_user_from_group(Host, US, Group) ->
|
remove_user_from_group(Host, US, Group) ->
|
||||||
SJID = make_jid_s(US),
|
SJID = make_jid_s(US),
|
||||||
SGroup = ejabberd_odbc:escape(Group),
|
SGroup = ejabberd_sql:escape(Group),
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
ejabberd_odbc:sql_query_t([<<"delete from sr_user where jid='">>,
|
ejabberd_sql:sql_query_t([<<"delete from sr_user where jid='">>,
|
||||||
SJID, <<"' and grp='">>, SGroup,
|
SJID, <<"' and grp='">>, SGroup,
|
||||||
<<"';">>]),
|
<<"';">>]),
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
ejabberd_odbc:sql_transaction(Host, F).
|
ejabberd_sql:sql_transaction(Host, F).
|
||||||
|
|
||||||
export(_Server) ->
|
export(_Server) ->
|
||||||
[{sr_group,
|
[{sr_group,
|
||||||
fun(Host, #sr_group{group_host = {Group, LServer}, opts = Opts})
|
fun(Host, #sr_group{group_host = {Group, LServer}, opts = Opts})
|
||||||
when LServer == Host ->
|
when LServer == Host ->
|
||||||
SGroup = ejabberd_odbc:escape(Group),
|
SGroup = ejabberd_sql:escape(Group),
|
||||||
SOpts = ejabberd_odbc:encode_term(Opts),
|
SOpts = ejabberd_sql:encode_term(Opts),
|
||||||
[[<<"delete from sr_group where name='">>, Group, <<"';">>],
|
[[<<"delete from sr_group where name='">>, Group, <<"';">>],
|
||||||
[<<"insert into sr_group(name, opts) values ('">>,
|
[<<"insert into sr_group(name, opts) values ('">>,
|
||||||
SGroup, <<"', '">>, SOpts, <<"');">>]];
|
SGroup, <<"', '">>, SOpts, <<"');">>]];
|
||||||
@ -175,8 +175,8 @@ export(_Server) ->
|
|||||||
{sr_user,
|
{sr_user,
|
||||||
fun(Host, #sr_user{us = {U, S}, group_host = {Group, LServer}})
|
fun(Host, #sr_user{us = {U, S}, group_host = {Group, LServer}})
|
||||||
when LServer == Host ->
|
when LServer == Host ->
|
||||||
SGroup = ejabberd_odbc:escape(Group),
|
SGroup = ejabberd_sql:escape(Group),
|
||||||
SJID = ejabberd_odbc:escape(
|
SJID = ejabberd_sql:escape(
|
||||||
jid:to_string(
|
jid:to_string(
|
||||||
jid:tolower(
|
jid:tolower(
|
||||||
jid:make(U, S, <<"">>)))),
|
jid:make(U, S, <<"">>)))),
|
||||||
@ -192,7 +192,7 @@ import(LServer) ->
|
|||||||
[{<<"select name, opts from sr_group;">>,
|
[{<<"select name, opts from sr_group;">>,
|
||||||
fun([Group, SOpts]) ->
|
fun([Group, SOpts]) ->
|
||||||
#sr_group{group_host = {Group, LServer},
|
#sr_group{group_host = {Group, LServer},
|
||||||
opts = ejabberd_odbc:decode_term(SOpts)}
|
opts = ejabberd_sql:decode_term(SOpts)}
|
||||||
end},
|
end},
|
||||||
{<<"select jid, grp from sr_user;">>,
|
{<<"select jid, grp from sr_user;">>,
|
||||||
fun([SJID, Group]) ->
|
fun([SJID, Group]) ->
|
||||||
@ -207,6 +207,6 @@ import(_, _) ->
|
|||||||
%%% Internal functions
|
%%% Internal functions
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
make_jid_s(U, S) ->
|
make_jid_s(U, S) ->
|
||||||
ejabberd_odbc:escape(jid:to_string(jid:tolower(jid:make(U, S, <<"">>)))).
|
ejabberd_sql:escape(jid:to_string(jid:tolower(jid:make(U, S, <<"">>)))).
|
||||||
|
|
||||||
make_jid_s({U, S}) -> make_jid_s(U, S).
|
make_jid_s({U, S}) -> make_jid_s(U, S).
|
||||||
|
@ -28,7 +28,7 @@ init(_Host, _Opts) ->
|
|||||||
ok.
|
ok.
|
||||||
|
|
||||||
get_vcard(LUser, LServer) ->
|
get_vcard(LUser, LServer) ->
|
||||||
case catch odbc_queries:get_vcard(LServer, LUser) of
|
case catch sql_queries:get_vcard(LServer, LUser) of
|
||||||
{selected, [{SVCARD}]} ->
|
{selected, [{SVCARD}]} ->
|
||||||
case fxml_stream:parse_element(SVCARD) of
|
case fxml_stream:parse_element(SVCARD) of
|
||||||
{error, _Reason} -> error;
|
{error, _Reason} -> error;
|
||||||
@ -63,7 +63,7 @@ set_vcard(LUser, LServer, VCARD,
|
|||||||
orgunit = OrgUnit,
|
orgunit = OrgUnit,
|
||||||
lorgunit = LOrgUnit}) ->
|
lorgunit = LOrgUnit}) ->
|
||||||
SVCARD = fxml:element_to_binary(VCARD),
|
SVCARD = fxml:element_to_binary(VCARD),
|
||||||
odbc_queries:set_vcard(LServer, LUser, BDay, CTRY,
|
sql_queries:set_vcard(LServer, LUser, BDay, CTRY,
|
||||||
EMail, FN, Family, Given, LBDay,
|
EMail, FN, Family, Given, LBDay,
|
||||||
LCTRY, LEMail, LFN, LFamily,
|
LCTRY, LEMail, LFN, LFamily,
|
||||||
LGiven, LLocality, LMiddle,
|
LGiven, LLocality, LMiddle,
|
||||||
@ -81,7 +81,7 @@ search(LServer, Data, AllowReturnAll, MaxMatch) ->
|
|||||||
Val ->
|
Val ->
|
||||||
[<<" LIMIT ">>, jlib:integer_to_binary(Val)]
|
[<<" LIMIT ">>, jlib:integer_to_binary(Val)]
|
||||||
end,
|
end,
|
||||||
case catch ejabberd_odbc:sql_query(
|
case catch ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
[<<"select username, fn, family, given, "
|
[<<"select username, fn, family, given, "
|
||||||
"middle, nickname, bday, ctry, "
|
"middle, nickname, bday, ctry, "
|
||||||
@ -100,12 +100,12 @@ search(LServer, Data, AllowReturnAll, MaxMatch) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
remove_user(LUser, LServer) ->
|
remove_user(LUser, LServer) ->
|
||||||
ejabberd_odbc:sql_transaction(
|
ejabberd_sql:sql_transaction(
|
||||||
LServer,
|
LServer,
|
||||||
fun() ->
|
fun() ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("delete from vcard where username=%(LUser)s")),
|
?SQL("delete from vcard where username=%(LUser)s")),
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("delete from vcard_search where lusername=%(LUser)s"))
|
?SQL("delete from vcard_search where lusername=%(LUser)s"))
|
||||||
end).
|
end).
|
||||||
|
|
||||||
@ -113,9 +113,9 @@ export(_Server) ->
|
|||||||
[{vcard,
|
[{vcard,
|
||||||
fun(Host, #vcard{us = {LUser, LServer}, vcard = VCARD})
|
fun(Host, #vcard{us = {LUser, LServer}, vcard = VCARD})
|
||||||
when LServer == Host ->
|
when LServer == Host ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
SVCARD =
|
SVCARD =
|
||||||
ejabberd_odbc:escape(fxml:element_to_binary(VCARD)),
|
ejabberd_sql:escape(fxml:element_to_binary(VCARD)),
|
||||||
[[<<"delete from vcard where username='">>, Username, <<"';">>],
|
[[<<"delete from vcard where username='">>, Username, <<"';">>],
|
||||||
[<<"insert into vcard(username, vcard) values ('">>,
|
[<<"insert into vcard(username, vcard) values ('">>,
|
||||||
Username, <<"', '">>, SVCARD, <<"');">>]];
|
Username, <<"', '">>, SVCARD, <<"');">>]];
|
||||||
@ -135,30 +135,30 @@ export(_Server) ->
|
|||||||
orgname = OrgName, lorgname = LOrgName,
|
orgname = OrgName, lorgname = LOrgName,
|
||||||
orgunit = OrgUnit, lorgunit = LOrgUnit})
|
orgunit = OrgUnit, lorgunit = LOrgUnit})
|
||||||
when LServer == Host ->
|
when LServer == Host ->
|
||||||
Username = ejabberd_odbc:escape(User),
|
Username = ejabberd_sql:escape(User),
|
||||||
LUsername = ejabberd_odbc:escape(LUser),
|
LUsername = ejabberd_sql:escape(LUser),
|
||||||
SFN = ejabberd_odbc:escape(FN),
|
SFN = ejabberd_sql:escape(FN),
|
||||||
SLFN = ejabberd_odbc:escape(LFN),
|
SLFN = ejabberd_sql:escape(LFN),
|
||||||
SFamily = ejabberd_odbc:escape(Family),
|
SFamily = ejabberd_sql:escape(Family),
|
||||||
SLFamily = ejabberd_odbc:escape(LFamily),
|
SLFamily = ejabberd_sql:escape(LFamily),
|
||||||
SGiven = ejabberd_odbc:escape(Given),
|
SGiven = ejabberd_sql:escape(Given),
|
||||||
SLGiven = ejabberd_odbc:escape(LGiven),
|
SLGiven = ejabberd_sql:escape(LGiven),
|
||||||
SMiddle = ejabberd_odbc:escape(Middle),
|
SMiddle = ejabberd_sql:escape(Middle),
|
||||||
SLMiddle = ejabberd_odbc:escape(LMiddle),
|
SLMiddle = ejabberd_sql:escape(LMiddle),
|
||||||
SNickname = ejabberd_odbc:escape(Nickname),
|
SNickname = ejabberd_sql:escape(Nickname),
|
||||||
SLNickname = ejabberd_odbc:escape(LNickname),
|
SLNickname = ejabberd_sql:escape(LNickname),
|
||||||
SBDay = ejabberd_odbc:escape(BDay),
|
SBDay = ejabberd_sql:escape(BDay),
|
||||||
SLBDay = ejabberd_odbc:escape(LBDay),
|
SLBDay = ejabberd_sql:escape(LBDay),
|
||||||
SCTRY = ejabberd_odbc:escape(CTRY),
|
SCTRY = ejabberd_sql:escape(CTRY),
|
||||||
SLCTRY = ejabberd_odbc:escape(LCTRY),
|
SLCTRY = ejabberd_sql:escape(LCTRY),
|
||||||
SLocality = ejabberd_odbc:escape(Locality),
|
SLocality = ejabberd_sql:escape(Locality),
|
||||||
SLLocality = ejabberd_odbc:escape(LLocality),
|
SLLocality = ejabberd_sql:escape(LLocality),
|
||||||
SEMail = ejabberd_odbc:escape(EMail),
|
SEMail = ejabberd_sql:escape(EMail),
|
||||||
SLEMail = ejabberd_odbc:escape(LEMail),
|
SLEMail = ejabberd_sql:escape(LEMail),
|
||||||
SOrgName = ejabberd_odbc:escape(OrgName),
|
SOrgName = ejabberd_sql:escape(OrgName),
|
||||||
SLOrgName = ejabberd_odbc:escape(LOrgName),
|
SLOrgName = ejabberd_sql:escape(LOrgName),
|
||||||
SOrgUnit = ejabberd_odbc:escape(OrgUnit),
|
SOrgUnit = ejabberd_sql:escape(OrgUnit),
|
||||||
SLOrgUnit = ejabberd_odbc:escape(LOrgUnit),
|
SLOrgUnit = ejabberd_sql:escape(LOrgUnit),
|
||||||
[[<<"delete from vcard_search where lusername='">>,
|
[[<<"delete from vcard_search where lusername='">>,
|
||||||
LUsername, <<"';">>],
|
LUsername, <<"';">>],
|
||||||
[<<"insert into vcard_search( username, "
|
[<<"insert into vcard_search( username, "
|
||||||
@ -255,11 +255,11 @@ make_val(Match, Field, Val) ->
|
|||||||
Condition = case str:suffix(<<"*">>, Val) of
|
Condition = case str:suffix(<<"*">>, Val) of
|
||||||
true ->
|
true ->
|
||||||
Val1 = str:substr(Val, 1, byte_size(Val) - 1),
|
Val1 = str:substr(Val, 1, byte_size(Val) - 1),
|
||||||
SVal = <<(ejabberd_odbc:escape_like(Val1))/binary,
|
SVal = <<(ejabberd_sql:escape_like(Val1))/binary,
|
||||||
"%">>,
|
"%">>,
|
||||||
[Field, <<" LIKE '">>, SVal, <<"'">>];
|
[Field, <<" LIKE '">>, SVal, <<"'">>];
|
||||||
_ ->
|
_ ->
|
||||||
SVal = ejabberd_odbc:escape(Val),
|
SVal = ejabberd_sql:escape(Val),
|
||||||
[Field, <<" = '">>, SVal, <<"'">>]
|
[Field, <<" = '">>, SVal, <<"'">>]
|
||||||
end,
|
end,
|
||||||
case Match of
|
case Match of
|
||||||
|
@ -21,19 +21,19 @@ init(_Host, _Opts) ->
|
|||||||
ok.
|
ok.
|
||||||
|
|
||||||
add_xupdate(LUser, LServer, Hash) ->
|
add_xupdate(LUser, LServer, Hash) ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
SHash = ejabberd_odbc:escape(Hash),
|
SHash = ejabberd_sql:escape(Hash),
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
odbc_queries:update_t(<<"vcard_xupdate">>,
|
sql_queries:update_t(<<"vcard_xupdate">>,
|
||||||
[<<"username">>, <<"hash">>],
|
[<<"username">>, <<"hash">>],
|
||||||
[Username, SHash],
|
[Username, SHash],
|
||||||
[<<"username='">>, Username, <<"'">>])
|
[<<"username='">>, Username, <<"'">>])
|
||||||
end,
|
end,
|
||||||
ejabberd_odbc:sql_transaction(LServer, F).
|
ejabberd_sql:sql_transaction(LServer, F).
|
||||||
|
|
||||||
get_xupdate(LUser, LServer) ->
|
get_xupdate(LUser, LServer) ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
case ejabberd_odbc:sql_query(LServer,
|
case ejabberd_sql:sql_query(LServer,
|
||||||
[<<"select hash from vcard_xupdate where "
|
[<<"select hash from vcard_xupdate where "
|
||||||
"username='">>,
|
"username='">>,
|
||||||
Username, <<"';">>])
|
Username, <<"';">>])
|
||||||
@ -43,19 +43,19 @@ get_xupdate(LUser, LServer) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
remove_xupdate(LUser, LServer) ->
|
remove_xupdate(LUser, LServer) ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
ejabberd_odbc:sql_query_t([<<"delete from vcard_xupdate where username='">>,
|
ejabberd_sql:sql_query_t([<<"delete from vcard_xupdate where username='">>,
|
||||||
Username, <<"';">>])
|
Username, <<"';">>])
|
||||||
end,
|
end,
|
||||||
ejabberd_odbc:sql_transaction(LServer, F).
|
ejabberd_sql:sql_transaction(LServer, F).
|
||||||
|
|
||||||
export(_Server) ->
|
export(_Server) ->
|
||||||
[{vcard_xupdate,
|
[{vcard_xupdate,
|
||||||
fun(Host, #vcard_xupdate{us = {LUser, LServer}, hash = Hash})
|
fun(Host, #vcard_xupdate{us = {LUser, LServer}, hash = Hash})
|
||||||
when LServer == Host ->
|
when LServer == Host ->
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_sql:escape(LUser),
|
||||||
SHash = ejabberd_odbc:escape(Hash),
|
SHash = ejabberd_sql:escape(Hash),
|
||||||
[[<<"delete from vcard_xupdate where username='">>,
|
[[<<"delete from vcard_xupdate where username='">>,
|
||||||
Username, <<"';">>],
|
Username, <<"';">>],
|
||||||
[<<"insert into vcard_xupdate(username, "
|
[<<"insert into vcard_xupdate(username, "
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%% File : node_flat_odbc.erl
|
%%% File : node_flat_sql.erl
|
||||||
%%% Author : Christophe Romain <christophe.romain@process-one.net>
|
%%% Author : Christophe Romain <christophe.romain@process-one.net>
|
||||||
%%% Purpose : Standard PubSub node plugin with ODBC backend
|
%%% Purpose : Standard PubSub node plugin with ODBC backend
|
||||||
%%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net>
|
%%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net>
|
||||||
@ -29,7 +29,7 @@
|
|||||||
%%% types.</p>
|
%%% types.</p>
|
||||||
%%% <p>PubSub plugin nodes are using the {@link gen_node} behaviour.</p>
|
%%% <p>PubSub plugin nodes are using the {@link gen_node} behaviour.</p>
|
||||||
|
|
||||||
-module(node_flat_odbc).
|
-module(node_flat_sql).
|
||||||
-behaviour(gen_pubsub_node).
|
-behaviour(gen_pubsub_node).
|
||||||
-author('christophe.romain@process-one.net').
|
-author('christophe.romain@process-one.net').
|
||||||
|
|
||||||
@ -56,14 +56,14 @@
|
|||||||
encode_host/1]).
|
encode_host/1]).
|
||||||
|
|
||||||
init(_Host, _ServerHost, _Opts) ->
|
init(_Host, _ServerHost, _Opts) ->
|
||||||
%%pubsub_subscription_odbc:init(),
|
%%pubsub_subscription_sql:init(),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
terminate(_Host, _ServerHost) ->
|
terminate(_Host, _ServerHost) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
options() ->
|
options() ->
|
||||||
[{odbc, true}, {rsm, true} | node_flat:options()].
|
[{sql, true}, {rsm, true} | node_flat:options()].
|
||||||
|
|
||||||
features() ->
|
features() ->
|
||||||
[<<"rsm">> | node_flat:features()].
|
[<<"rsm">> | node_flat:features()].
|
||||||
@ -74,14 +74,14 @@ create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
|
|||||||
create_node(Nidx, Owner) ->
|
create_node(Nidx, Owner) ->
|
||||||
{_U, _S, _R} = OwnerKey = jid:tolower(jid:remove_resource(Owner)),
|
{_U, _S, _R} = OwnerKey = jid:tolower(jid:remove_resource(Owner)),
|
||||||
State = #pubsub_state{stateid = {OwnerKey, Nidx}, affiliation = owner},
|
State = #pubsub_state{stateid = {OwnerKey, Nidx}, affiliation = owner},
|
||||||
catch ejabberd_odbc:sql_query_t([<<"insert into pubsub_state(nodeid, jid, affiliation, subscriptions) "
|
catch ejabberd_sql:sql_query_t([<<"insert into pubsub_state(nodeid, jid, affiliation, subscriptions) "
|
||||||
"values(">>, state_to_raw(Nidx, State), <<");">>]),
|
"values(">>, state_to_raw(Nidx, State), <<");">>]),
|
||||||
{result, {default, broadcast}}.
|
{result, {default, broadcast}}.
|
||||||
|
|
||||||
delete_node(Nodes) ->
|
delete_node(Nodes) ->
|
||||||
Reply = lists:map(fun (#pubsub_node{id = Nidx} = PubsubNode) ->
|
Reply = lists:map(fun (#pubsub_node{id = Nidx} = PubsubNode) ->
|
||||||
Subscriptions = case catch
|
Subscriptions = case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"select jid, subscriptions "
|
ejabberd_sql:sql_query_t([<<"select jid, subscriptions "
|
||||||
"from pubsub_state where nodeid='">>, Nidx, <<"';">>])
|
"from pubsub_state where nodeid='">>, Nidx, <<"';">>])
|
||||||
of
|
of
|
||||||
{selected, [<<"jid">>, <<"subscriptions">>], RItems} ->
|
{selected, [<<"jid">>, <<"subscriptions">>], RItems} ->
|
||||||
@ -130,12 +130,12 @@ subscribe_node(Nidx, Sender, Subscriber, AccessModel,
|
|||||||
%% % Requesting entity is anonymous
|
%% % Requesting entity is anonymous
|
||||||
%% {error, ?ERR_FORBIDDEN};
|
%% {error, ?ERR_FORBIDDEN};
|
||||||
true ->
|
true ->
|
||||||
%%{result, SubId} = pubsub_subscription_odbc:subscribe_node(Subscriber, Nidx, Options),
|
%%{result, SubId} = pubsub_subscription_sql:subscribe_node(Subscriber, Nidx, Options),
|
||||||
{NewSub, SubId} = case Subscriptions of
|
{NewSub, SubId} = case Subscriptions of
|
||||||
[{subscribed, Id}|_] ->
|
[{subscribed, Id}|_] ->
|
||||||
{subscribed, Id};
|
{subscribed, Id};
|
||||||
[] ->
|
[] ->
|
||||||
Id = pubsub_subscription_odbc:make_subid(),
|
Id = pubsub_subscription_sql:make_subid(),
|
||||||
Sub = case AccessModel of
|
Sub = case AccessModel of
|
||||||
authorize -> pending;
|
authorize -> pending;
|
||||||
_ -> subscribed
|
_ -> subscribed
|
||||||
@ -209,7 +209,7 @@ unsubscribe_node(Nidx, Sender, Subscriber, SubId) ->
|
|||||||
|
|
||||||
delete_subscription(SubKey, Nidx, {Subscription, SubId}, Affiliation, Subscriptions) ->
|
delete_subscription(SubKey, Nidx, {Subscription, SubId}, Affiliation, Subscriptions) ->
|
||||||
NewSubs = Subscriptions -- [{Subscription, SubId}],
|
NewSubs = Subscriptions -- [{Subscription, SubId}],
|
||||||
%%pubsub_subscription_odbc:unsubscribe_node(SubKey, Nidx, SubId),
|
%%pubsub_subscription_sql:unsubscribe_node(SubKey, Nidx, SubId),
|
||||||
case {Affiliation, NewSubs} of
|
case {Affiliation, NewSubs} of
|
||||||
{none, []} -> del_state(Nidx, SubKey);
|
{none, []} -> del_state(Nidx, SubKey);
|
||||||
_ -> update_subscription(Nidx, SubKey, NewSubs)
|
_ -> update_subscription(Nidx, SubKey, NewSubs)
|
||||||
@ -296,12 +296,12 @@ get_entity_affiliations(Host, Owner) ->
|
|||||||
H = encode_host(Host),
|
H = encode_host(Host),
|
||||||
J = encode_jid(GenKey),
|
J = encode_jid(GenKey),
|
||||||
Reply = case catch
|
Reply = case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"select node, type, i.nodeid, affiliation "
|
ejabberd_sql:sql_query_t([<<"select node, type, i.nodeid, affiliation "
|
||||||
"from pubsub_state i, pubsub_node n where "
|
"from pubsub_state i, pubsub_node n where "
|
||||||
"i.nodeid = n.nodeid and jid='">>, J, <<"' and host='">>, H, <<"';">>])
|
"i.nodeid = n.nodeid and jid='">>, J, <<"' and host='">>, H, <<"';">>])
|
||||||
of
|
of
|
||||||
{selected, [<<"node">>, <<"type">>, <<"nodeid">>, <<"affiliation">>], RItems} ->
|
{selected, [<<"node">>, <<"type">>, <<"nodeid">>, <<"affiliation">>], RItems} ->
|
||||||
[{nodetree_tree_odbc:raw_to_node(Host, [N, <<"">>, T, I]), decode_affiliation(A)}
|
[{nodetree_tree_sql:raw_to_node(Host, [N, <<"">>, T, I]), decode_affiliation(A)}
|
||||||
|| [N, T, I, A] <- RItems];
|
|| [N, T, I, A] <- RItems];
|
||||||
_ ->
|
_ ->
|
||||||
[]
|
[]
|
||||||
@ -310,7 +310,7 @@ get_entity_affiliations(Host, Owner) ->
|
|||||||
|
|
||||||
get_node_affiliations(Nidx) ->
|
get_node_affiliations(Nidx) ->
|
||||||
Reply = case catch
|
Reply = case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"select jid, affiliation from pubsub_state "
|
ejabberd_sql:sql_query_t([<<"select jid, affiliation from pubsub_state "
|
||||||
"where nodeid='">>, Nidx, <<"';">>])
|
"where nodeid='">>, Nidx, <<"';">>])
|
||||||
of
|
of
|
||||||
{selected, [<<"jid">>, <<"affiliation">>], RItems} ->
|
{selected, [<<"jid">>, <<"affiliation">>], RItems} ->
|
||||||
@ -325,7 +325,7 @@ get_affiliation(Nidx, Owner) ->
|
|||||||
GenKey = jid:remove_resource(SubKey),
|
GenKey = jid:remove_resource(SubKey),
|
||||||
J = encode_jid(GenKey),
|
J = encode_jid(GenKey),
|
||||||
Reply = case catch
|
Reply = case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"select affiliation from pubsub_state "
|
ejabberd_sql:sql_query_t([<<"select affiliation from pubsub_state "
|
||||||
"where nodeid='">>, Nidx, <<"' and jid='">>, J, <<"';">>])
|
"where nodeid='">>, Nidx, <<"' and jid='">>, J, <<"';">>])
|
||||||
of
|
of
|
||||||
{selected, [<<"affiliation">>], [[A]]} ->
|
{selected, [<<"affiliation">>], [[A]]} ->
|
||||||
@ -360,11 +360,11 @@ get_entity_subscriptions(Host, Owner) ->
|
|||||||
"from pubsub_state i, pubsub_node n "
|
"from pubsub_state i, pubsub_node n "
|
||||||
"where i.nodeid = n.nodeid and jid in ('">>, SJ, <<"', '">>, GJ, <<"') and host='">>, H, <<"';">>]
|
"where i.nodeid = n.nodeid and jid in ('">>, SJ, <<"', '">>, GJ, <<"') and host='">>, H, <<"';">>]
|
||||||
end,
|
end,
|
||||||
Reply = case catch ejabberd_odbc:sql_query_t(Query) of
|
Reply = case catch ejabberd_sql:sql_query_t(Query) of
|
||||||
{selected,
|
{selected,
|
||||||
[<<"node">>, <<"type">>, <<"nodeid">>, <<"jid">>, <<"subscriptions">>], RItems} ->
|
[<<"node">>, <<"type">>, <<"nodeid">>, <<"jid">>, <<"subscriptions">>], RItems} ->
|
||||||
lists:foldl(fun ([N, T, I, J, S], Acc) ->
|
lists:foldl(fun ([N, T, I, J, S], Acc) ->
|
||||||
Node = nodetree_tree_odbc:raw_to_node(Host, [N, <<"">>, T, I]),
|
Node = nodetree_tree_sql:raw_to_node(Host, [N, <<"">>, T, I]),
|
||||||
Jid = decode_jid(J),
|
Jid = decode_jid(J),
|
||||||
case decode_subscriptions(S) of
|
case decode_subscriptions(S) of
|
||||||
[] ->
|
[] ->
|
||||||
@ -411,11 +411,11 @@ get_entity_subscriptions_for_send_last(Host, Owner) ->
|
|||||||
"where i.nodeid = n.nodeid and n.nodeid = o.nodeid and name='send_last_published_item' "
|
"where i.nodeid = n.nodeid and n.nodeid = o.nodeid and name='send_last_published_item' "
|
||||||
"and val='on_sub_and_presence' and jid in ('">>, SJ, <<"', '">>, GJ, <<"') and host='">>, H, <<"';">>]
|
"and val='on_sub_and_presence' and jid in ('">>, SJ, <<"', '">>, GJ, <<"') and host='">>, H, <<"';">>]
|
||||||
end,
|
end,
|
||||||
Reply = case catch ejabberd_odbc:sql_query_t(Query) of
|
Reply = case catch ejabberd_sql:sql_query_t(Query) of
|
||||||
{selected,
|
{selected,
|
||||||
[<<"node">>, <<"type">>, <<"nodeid">>, <<"jid">>, <<"subscriptions">>], RItems} ->
|
[<<"node">>, <<"type">>, <<"nodeid">>, <<"jid">>, <<"subscriptions">>], RItems} ->
|
||||||
lists:foldl(fun ([N, T, I, J, S], Acc) ->
|
lists:foldl(fun ([N, T, I, J, S], Acc) ->
|
||||||
Node = nodetree_tree_odbc:raw_to_node(Host, [N, <<"">>, T, I]),
|
Node = nodetree_tree_sql:raw_to_node(Host, [N, <<"">>, T, I]),
|
||||||
Jid = decode_jid(J),
|
Jid = decode_jid(J),
|
||||||
case decode_subscriptions(S) of
|
case decode_subscriptions(S) of
|
||||||
[] ->
|
[] ->
|
||||||
@ -435,7 +435,7 @@ get_entity_subscriptions_for_send_last(Host, Owner) ->
|
|||||||
|
|
||||||
get_node_subscriptions(Nidx) ->
|
get_node_subscriptions(Nidx) ->
|
||||||
Reply = case catch
|
Reply = case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"select jid, subscriptions from pubsub_state "
|
ejabberd_sql:sql_query_t([<<"select jid, subscriptions from pubsub_state "
|
||||||
"where nodeid='">>, Nidx, <<"';">>])
|
"where nodeid='">>, Nidx, <<"';">>])
|
||||||
of
|
of
|
||||||
{selected, [<<"jid">>, <<"subscriptions">>], RItems} ->
|
{selected, [<<"jid">>, <<"subscriptions">>], RItems} ->
|
||||||
@ -461,7 +461,7 @@ get_subscriptions(Nidx, Owner) ->
|
|||||||
SubKey = jid:tolower(Owner),
|
SubKey = jid:tolower(Owner),
|
||||||
J = encode_jid(SubKey),
|
J = encode_jid(SubKey),
|
||||||
Reply = case catch
|
Reply = case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"select subscriptions from pubsub_state where "
|
ejabberd_sql:sql_query_t([<<"select subscriptions from pubsub_state where "
|
||||||
"nodeid='">>, Nidx, <<"' and jid='">>, J, <<"';">>])
|
"nodeid='">>, Nidx, <<"' and jid='">>, J, <<"';">>])
|
||||||
of
|
of
|
||||||
{selected, [<<"subscriptions">>], [[S]]} ->
|
{selected, [<<"subscriptions">>], [[S]]} ->
|
||||||
@ -507,14 +507,14 @@ replace_subscription({Sub, SubId}, [{_, SubId} | T], Acc) ->
|
|||||||
replace_subscription({Sub, SubId}, T, [{Sub, SubId} | Acc]).
|
replace_subscription({Sub, SubId}, T, [{Sub, SubId} | Acc]).
|
||||||
|
|
||||||
new_subscription(_Nidx, _Owner, Subscription, SubState) ->
|
new_subscription(_Nidx, _Owner, Subscription, SubState) ->
|
||||||
%%{result, SubId} = pubsub_subscription_odbc:subscribe_node(Owner, Nidx, []),
|
%%{result, SubId} = pubsub_subscription_sql:subscribe_node(Owner, Nidx, []),
|
||||||
SubId = pubsub_subscription_odbc:make_subid(),
|
SubId = pubsub_subscription_sql:make_subid(),
|
||||||
Subscriptions = [{Subscription, SubId} | SubState#pubsub_state.subscriptions],
|
Subscriptions = [{Subscription, SubId} | SubState#pubsub_state.subscriptions],
|
||||||
set_state(SubState#pubsub_state{subscriptions = Subscriptions}),
|
set_state(SubState#pubsub_state{subscriptions = Subscriptions}),
|
||||||
{Subscription, SubId}.
|
{Subscription, SubId}.
|
||||||
|
|
||||||
unsub_with_subid(Nidx, SubId, SubState) ->
|
unsub_with_subid(Nidx, SubId, SubState) ->
|
||||||
%%pubsub_subscription_odbc:unsubscribe_node(SubState#pubsub_state.stateid, Nidx, SubId),
|
%%pubsub_subscription_sql:unsubscribe_node(SubState#pubsub_state.stateid, Nidx, SubId),
|
||||||
NewSubs = [{S, Sid}
|
NewSubs = [{S, Sid}
|
||||||
|| {S, Sid} <- SubState#pubsub_state.subscriptions,
|
|| {S, Sid} <- SubState#pubsub_state.subscriptions,
|
||||||
SubId =/= Sid],
|
SubId =/= Sid],
|
||||||
@ -561,7 +561,7 @@ get_nodes_helper(NodeTree, #pubsub_state{stateid = {_, N}, subscriptions = Subs}
|
|||||||
|
|
||||||
get_states(Nidx) ->
|
get_states(Nidx) ->
|
||||||
case catch
|
case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"select jid, affiliation, subscriptions "
|
ejabberd_sql:sql_query_t([<<"select jid, affiliation, subscriptions "
|
||||||
"from pubsub_state where nodeid='">>, Nidx, <<"';">>])
|
"from pubsub_state where nodeid='">>, Nidx, <<"';">>])
|
||||||
of
|
of
|
||||||
{selected,
|
{selected,
|
||||||
@ -591,7 +591,7 @@ get_state(Nidx, JID) ->
|
|||||||
get_state_without_itemids(Nidx, JID) ->
|
get_state_without_itemids(Nidx, JID) ->
|
||||||
J = encode_jid(JID),
|
J = encode_jid(JID),
|
||||||
case catch
|
case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"select jid, affiliation, subscriptions "
|
ejabberd_sql:sql_query_t([<<"select jid, affiliation, subscriptions "
|
||||||
"from pubsub_state where jid='">>, J, <<"' and nodeid='">>, Nidx, <<"';">>])
|
"from pubsub_state where jid='">>, J, <<"' and nodeid='">>, Nidx, <<"';">>])
|
||||||
of
|
of
|
||||||
{selected,
|
{selected,
|
||||||
@ -613,14 +613,14 @@ set_state(Nidx, State) ->
|
|||||||
S = encode_subscriptions(State#pubsub_state.subscriptions),
|
S = encode_subscriptions(State#pubsub_state.subscriptions),
|
||||||
A = encode_affiliation(State#pubsub_state.affiliation),
|
A = encode_affiliation(State#pubsub_state.affiliation),
|
||||||
case catch
|
case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"update pubsub_state set subscriptions='">>, S, <<"', affiliation='">>, A,
|
ejabberd_sql:sql_query_t([<<"update pubsub_state set subscriptions='">>, S, <<"', affiliation='">>, A,
|
||||||
<<"' where nodeid='">>, Nidx, <<"' and jid='">>, J, <<"';">>])
|
<<"' where nodeid='">>, Nidx, <<"' and jid='">>, J, <<"';">>])
|
||||||
of
|
of
|
||||||
{updated, 1} ->
|
{updated, 1} ->
|
||||||
ok;
|
ok;
|
||||||
_ ->
|
_ ->
|
||||||
catch
|
catch
|
||||||
ejabberd_odbc:sql_query_t([<<"insert into pubsub_state(nodeid, jid, affiliation, subscriptions) "
|
ejabberd_sql:sql_query_t([<<"insert into pubsub_state(nodeid, jid, affiliation, subscriptions) "
|
||||||
"values('">>,
|
"values('">>,
|
||||||
Nidx, <<"', '">>, J, <<"', '">>, A, <<"', '">>, S, <<"');">>])
|
Nidx, <<"', '">>, J, <<"', '">>, A, <<"', '">>, S, <<"');">>])
|
||||||
end,
|
end,
|
||||||
@ -628,13 +628,13 @@ set_state(Nidx, State) ->
|
|||||||
|
|
||||||
del_state(Nidx, JID) ->
|
del_state(Nidx, JID) ->
|
||||||
J = encode_jid(JID),
|
J = encode_jid(JID),
|
||||||
catch ejabberd_odbc:sql_query_t([<<"delete from pubsub_state where jid='">>,
|
catch ejabberd_sql:sql_query_t([<<"delete from pubsub_state where jid='">>,
|
||||||
J, <<"' and nodeid='">>, Nidx, <<"';">>]),
|
J, <<"' and nodeid='">>, Nidx, <<"';">>]),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
%get_items(Nidx, _From) ->
|
%get_items(Nidx, _From) ->
|
||||||
% case catch
|
% case catch
|
||||||
% ejabberd_odbc:sql_query_t([<<"select itemid, publisher, creation, modification, payload "
|
% ejabberd_sql:sql_query_t([<<"select itemid, publisher, creation, modification, payload "
|
||||||
% "from pubsub_item where nodeid='">>, Nidx,
|
% "from pubsub_item where nodeid='">>, Nidx,
|
||||||
% <<"' order by modification desc;">>])
|
% <<"' order by modification desc;">>])
|
||||||
% of
|
% of
|
||||||
@ -647,7 +647,7 @@ del_state(Nidx, JID) ->
|
|||||||
|
|
||||||
get_items(Nidx, From, none) ->
|
get_items(Nidx, From, none) ->
|
||||||
MaxItems = case catch
|
MaxItems = case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"select val from pubsub_node_option "
|
ejabberd_sql:sql_query_t([<<"select val from pubsub_node_option "
|
||||||
"where nodeid='">>, Nidx, <<"' and name='max_items';">>])
|
"where nodeid='">>, Nidx, <<"' and name='max_items';">>])
|
||||||
of
|
of
|
||||||
{selected, [<<"val">>], [[Value]]} ->
|
{selected, [<<"val">>], [[Value]]} ->
|
||||||
@ -659,7 +659,7 @@ get_items(Nidx, From, none) ->
|
|||||||
get_items(Nidx, From, #rsm_in{max = MaxItems});
|
get_items(Nidx, From, #rsm_in{max = MaxItems});
|
||||||
get_items(Nidx, _From,
|
get_items(Nidx, _From,
|
||||||
#rsm_in{max = M, direction = Direction, id = I, index = IncIndex}) ->
|
#rsm_in{max = M, direction = Direction, id = I, index = IncIndex}) ->
|
||||||
Max = ejabberd_odbc:escape(jlib:i2l(M)),
|
Max = ejabberd_sql:escape(jlib:i2l(M)),
|
||||||
{Way, Order} = case Direction of
|
{Way, Order} = case Direction of
|
||||||
% aft -> {<<"<">>, <<"desc">>};
|
% aft -> {<<"<">>, <<"desc">>};
|
||||||
% before when I == <<>> -> {<<"is not">>, <<"asc">>};
|
% before when I == <<>> -> {<<"is not">>, <<"asc">>};
|
||||||
@ -672,11 +672,11 @@ get_items(Nidx, _From,
|
|||||||
[AttrName, Id] = case I of
|
[AttrName, Id] = case I of
|
||||||
undefined when IncIndex =/= undefined ->
|
undefined when IncIndex =/= undefined ->
|
||||||
case catch
|
case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"select modification from pubsub_item pi "
|
ejabberd_sql:sql_query_t([<<"select modification from pubsub_item pi "
|
||||||
"where exists ( select count(*) as count1 "
|
"where exists ( select count(*) as count1 "
|
||||||
"from pubsub_item where nodeid='">>, Nidx,
|
"from pubsub_item where nodeid='">>, Nidx,
|
||||||
<<"' and modification > pi.modification having count1 = ">>,
|
<<"' and modification > pi.modification having count1 = ">>,
|
||||||
ejabberd_odbc:escape(jlib:i2l(IncIndex)), <<" );">>])
|
ejabberd_sql:escape(jlib:i2l(IncIndex)), <<" );">>])
|
||||||
of
|
of
|
||||||
{selected, [_], [[O]]} ->
|
{selected, [_], [[O]]} ->
|
||||||
[<<"modification">>, <<"'", O/binary, "'">>];
|
[<<"modification">>, <<"'", O/binary, "'">>];
|
||||||
@ -688,36 +688,36 @@ get_items(Nidx, _From,
|
|||||||
<<>> ->
|
<<>> ->
|
||||||
[<<"modification">>, <<"null">>];
|
[<<"modification">>, <<"null">>];
|
||||||
I ->
|
I ->
|
||||||
[A, B] = str:tokens(ejabberd_odbc:escape(jlib:i2l(I)), <<"@">>),
|
[A, B] = str:tokens(ejabberd_sql:escape(jlib:i2l(I)), <<"@">>),
|
||||||
[A, <<"'", B/binary, "'">>]
|
[A, <<"'", B/binary, "'">>]
|
||||||
end,
|
end,
|
||||||
Count = case catch
|
Count = case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"select count(*) from pubsub_item where nodeid='">>, Nidx, <<"';">>])
|
ejabberd_sql:sql_query_t([<<"select count(*) from pubsub_item where nodeid='">>, Nidx, <<"';">>])
|
||||||
of
|
of
|
||||||
{selected, [_], [[C]]} -> C;
|
{selected, [_], [[C]]} -> C;
|
||||||
_ -> <<"0">>
|
_ -> <<"0">>
|
||||||
end,
|
end,
|
||||||
Query = fun(mssql, _) ->
|
Query = fun(mssql, _) ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
[<<"select top ">>, jlib:i2l(Max),
|
[<<"select top ">>, jlib:i2l(Max),
|
||||||
<<" itemid, publisher, creation, modification, payload "
|
<<" itemid, publisher, creation, modification, payload "
|
||||||
"from pubsub_item where nodeid='">>, Nidx,
|
"from pubsub_item where nodeid='">>, Nidx,
|
||||||
<<"' and ">>, AttrName, <<" ">>, Way, <<" ">>, Id, <<" order by ">>,
|
<<"' and ">>, AttrName, <<" ">>, Way, <<" ">>, Id, <<" order by ">>,
|
||||||
AttrName, <<" ">>, Order, <<";">>]);
|
AttrName, <<" ">>, Order, <<";">>]);
|
||||||
(_, _) ->
|
(_, _) ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
[<<"select itemid, publisher, creation, modification, payload "
|
[<<"select itemid, publisher, creation, modification, payload "
|
||||||
"from pubsub_item where nodeid='">>, Nidx,
|
"from pubsub_item where nodeid='">>, Nidx,
|
||||||
<<"' and ">>, AttrName, <<" ">>, Way, <<" ">>, Id, <<" order by ">>,
|
<<"' and ">>, AttrName, <<" ">>, Way, <<" ">>, Id, <<" order by ">>,
|
||||||
AttrName, <<" ">>, Order, <<" limit ">>, jlib:i2l(Max), <<" ;">>])
|
AttrName, <<" ">>, Order, <<" limit ">>, jlib:i2l(Max), <<" ;">>])
|
||||||
end,
|
end,
|
||||||
case catch ejabberd_odbc:sql_query_t(Query) of
|
case catch ejabberd_sql:sql_query_t(Query) of
|
||||||
{selected,
|
{selected,
|
||||||
[<<"itemid">>, <<"publisher">>, <<"creation">>, <<"modification">>, <<"payload">>], RItems} ->
|
[<<"itemid">>, <<"publisher">>, <<"creation">>, <<"modification">>, <<"payload">>], RItems} ->
|
||||||
case RItems of
|
case RItems of
|
||||||
[[_, _, _, F, _]|_] ->
|
[[_, _, _, F, _]|_] ->
|
||||||
Index = case catch
|
Index = case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"select count(*) from pubsub_item "
|
ejabberd_sql:sql_query_t([<<"select count(*) from pubsub_item "
|
||||||
"where nodeid='">>, Nidx, <<"' and ">>,
|
"where nodeid='">>, Nidx, <<"' and ">>,
|
||||||
AttrName, <<" > '">>, F, <<"';">>])
|
AttrName, <<" > '">>, F, <<"';">>])
|
||||||
of
|
of
|
||||||
@ -771,18 +771,18 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId, RSM
|
|||||||
get_last_items(Nidx, _From, Count) ->
|
get_last_items(Nidx, _From, Count) ->
|
||||||
Limit = jlib:i2l(Count),
|
Limit = jlib:i2l(Count),
|
||||||
Query = fun(mssql, _) ->
|
Query = fun(mssql, _) ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
[<<"select top ">>, Limit,
|
[<<"select top ">>, Limit,
|
||||||
<<" itemid, publisher, creation, modification, payload "
|
<<" itemid, publisher, creation, modification, payload "
|
||||||
"from pubsub_item where nodeid='">>, Nidx,
|
"from pubsub_item where nodeid='">>, Nidx,
|
||||||
<<"' order by modification desc ;">>]);
|
<<"' order by modification desc ;">>]);
|
||||||
(_, _) ->
|
(_, _) ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
[<<"select itemid, publisher, creation, modification, payload "
|
[<<"select itemid, publisher, creation, modification, payload "
|
||||||
"from pubsub_item where nodeid='">>, Nidx,
|
"from pubsub_item where nodeid='">>, Nidx,
|
||||||
<<"' order by modification desc limit ">>, Limit, <<";">>])
|
<<"' order by modification desc limit ">>, Limit, <<";">>])
|
||||||
end,
|
end,
|
||||||
case catch ejabberd_odbc:sql_query_t(Query) of
|
case catch ejabberd_sql:sql_query_t(Query) of
|
||||||
{selected,
|
{selected,
|
||||||
[<<"itemid">>, <<"publisher">>, <<"creation">>, <<"modification">>, <<"payload">>], RItems} ->
|
[<<"itemid">>, <<"publisher">>, <<"creation">>, <<"modification">>, <<"payload">>], RItems} ->
|
||||||
{result, [raw_to_item(Nidx, RItem) || RItem <- RItems]};
|
{result, [raw_to_item(Nidx, RItem) || RItem <- RItems]};
|
||||||
@ -791,9 +791,9 @@ get_last_items(Nidx, _From, Count) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
get_item(Nidx, ItemId) ->
|
get_item(Nidx, ItemId) ->
|
||||||
I = ejabberd_odbc:escape(ItemId),
|
I = ejabberd_sql:escape(ItemId),
|
||||||
case catch
|
case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"select itemid, publisher, creation, "
|
ejabberd_sql:sql_query_t([<<"select itemid, publisher, creation, "
|
||||||
"modification, payload from pubsub_item "
|
"modification, payload from pubsub_item "
|
||||||
"where nodeid='">>, Nidx, <<"' and itemid='">>, I, <<"';">>])
|
"where nodeid='">>, Nidx, <<"' and itemid='">>, I, <<"';">>])
|
||||||
of
|
of
|
||||||
@ -839,17 +839,17 @@ get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, _Sub
|
|||||||
|
|
||||||
set_item(Item) ->
|
set_item(Item) ->
|
||||||
{ItemId, Nidx} = Item#pubsub_item.itemid,
|
{ItemId, Nidx} = Item#pubsub_item.itemid,
|
||||||
I = ejabberd_odbc:escape(ItemId),
|
I = ejabberd_sql:escape(ItemId),
|
||||||
{C, _} = Item#pubsub_item.creation,
|
{C, _} = Item#pubsub_item.creation,
|
||||||
{M, JID} = Item#pubsub_item.modification,
|
{M, JID} = Item#pubsub_item.modification,
|
||||||
P = encode_jid(JID),
|
P = encode_jid(JID),
|
||||||
Payload = Item#pubsub_item.payload,
|
Payload = Item#pubsub_item.payload,
|
||||||
XML = ejabberd_odbc:escape(str:join([fxml:element_to_binary(X) || X<-Payload], <<>>)),
|
XML = ejabberd_sql:escape(str:join([fxml:element_to_binary(X) || X<-Payload], <<>>)),
|
||||||
S = fun ({T1, T2, T3}) ->
|
S = fun ({T1, T2, T3}) ->
|
||||||
str:join([jlib:i2l(T1, 6), jlib:i2l(T2, 6), jlib:i2l(T3, 6)], <<":">>)
|
str:join([jlib:i2l(T1, 6), jlib:i2l(T2, 6), jlib:i2l(T3, 6)], <<":">>)
|
||||||
end,
|
end,
|
||||||
case catch
|
case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"update pubsub_item set publisher='">>, P,
|
ejabberd_sql:sql_query_t([<<"update pubsub_item set publisher='">>, P,
|
||||||
<<"', modification='">>, S(M),
|
<<"', modification='">>, S(M),
|
||||||
<<"', payload='">>, XML,
|
<<"', payload='">>, XML,
|
||||||
<<"' where nodeid='">>, Nidx, <<"' and itemid='">>, I, <<"';">>])
|
<<"' where nodeid='">>, Nidx, <<"' and itemid='">>, I, <<"';">>])
|
||||||
@ -858,7 +858,7 @@ set_item(Item) ->
|
|||||||
ok;
|
ok;
|
||||||
_ ->
|
_ ->
|
||||||
catch
|
catch
|
||||||
ejabberd_odbc:sql_query_t([<<"insert into pubsub_item (nodeid, itemid, "
|
ejabberd_sql:sql_query_t([<<"insert into pubsub_item (nodeid, itemid, "
|
||||||
"publisher, creation, modification, payload) "
|
"publisher, creation, modification, payload) "
|
||||||
"values('">>, Nidx, <<"', '">>, I, <<"', '">>, P,
|
"values('">>, Nidx, <<"', '">>, I, <<"', '">>, P,
|
||||||
<<"', '">>, S(C), <<"', '">>, S(M),
|
<<"', '">>, S(C), <<"', '">>, S(M),
|
||||||
@ -867,8 +867,8 @@ set_item(Item) ->
|
|||||||
ok.
|
ok.
|
||||||
|
|
||||||
del_item(Nidx, ItemId) ->
|
del_item(Nidx, ItemId) ->
|
||||||
I = ejabberd_odbc:escape(ItemId),
|
I = ejabberd_sql:escape(ItemId),
|
||||||
catch ejabberd_odbc:sql_query_t([<<"delete from pubsub_item where itemid='">>,
|
catch ejabberd_sql:sql_query_t([<<"delete from pubsub_item where itemid='">>,
|
||||||
I, <<"' and nodeid='">>, Nidx, <<"';">>]).
|
I, <<"' and nodeid='">>, Nidx, <<"';">>]).
|
||||||
|
|
||||||
del_items(_, []) ->
|
del_items(_, []) ->
|
||||||
@ -876,9 +876,9 @@ del_items(_, []) ->
|
|||||||
del_items(Nidx, [ItemId]) ->
|
del_items(Nidx, [ItemId]) ->
|
||||||
del_item(Nidx, ItemId);
|
del_item(Nidx, ItemId);
|
||||||
del_items(Nidx, ItemIds) ->
|
del_items(Nidx, ItemIds) ->
|
||||||
I = str:join([[<<"'">>, ejabberd_odbc:escape(X), <<"'">>] || X <- ItemIds], <<",">>),
|
I = str:join([[<<"'">>, ejabberd_sql:escape(X), <<"'">>] || X <- ItemIds], <<",">>),
|
||||||
catch
|
catch
|
||||||
ejabberd_odbc:sql_query_t([<<"delete from pubsub_item where itemid in (">>,
|
ejabberd_sql:sql_query_t([<<"delete from pubsub_item where itemid in (">>,
|
||||||
I, <<") and nodeid='">>, Nidx, <<"';">>]).
|
I, <<") and nodeid='">>, Nidx, <<"';">>]).
|
||||||
|
|
||||||
get_item_name(_Host, _Node, Id) ->
|
get_item_name(_Host, _Node, Id) ->
|
||||||
@ -903,7 +903,7 @@ itemids(Nidx, {U, S, R}) ->
|
|||||||
itemids(Nidx, encode_jid({U, S, R}));
|
itemids(Nidx, encode_jid({U, S, R}));
|
||||||
itemids(Nidx, SJID) ->
|
itemids(Nidx, SJID) ->
|
||||||
case catch
|
case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"select itemid from pubsub_item where "
|
ejabberd_sql:sql_query_t([<<"select itemid from pubsub_item where "
|
||||||
"nodeid='">>, Nidx, <<"' and publisher like '">>, SJID,
|
"nodeid='">>, Nidx, <<"' and publisher like '">>, SJID,
|
||||||
<<"%' order by modification desc;">>])
|
<<"%' order by modification desc;">>])
|
||||||
of
|
of
|
||||||
@ -916,7 +916,7 @@ itemids(Nidx, SJID) ->
|
|||||||
select_affiliation_subscriptions(Nidx, JID) ->
|
select_affiliation_subscriptions(Nidx, JID) ->
|
||||||
J = encode_jid(JID),
|
J = encode_jid(JID),
|
||||||
case catch
|
case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"select affiliation,subscriptions from "
|
ejabberd_sql:sql_query_t([<<"select affiliation,subscriptions from "
|
||||||
"pubsub_state where nodeid='">>,
|
"pubsub_state where nodeid='">>,
|
||||||
Nidx, <<"' and jid='">>, J, <<"';">>])
|
Nidx, <<"' and jid='">>, J, <<"';">>])
|
||||||
of
|
of
|
||||||
@ -937,7 +937,7 @@ update_affiliation(Nidx, JID, Affiliation) ->
|
|||||||
J = encode_jid(JID),
|
J = encode_jid(JID),
|
||||||
A = encode_affiliation(Affiliation),
|
A = encode_affiliation(Affiliation),
|
||||||
case catch
|
case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"update pubsub_state set affiliation='">>,
|
ejabberd_sql:sql_query_t([<<"update pubsub_state set affiliation='">>,
|
||||||
A, <<"' where nodeid='">>, Nidx,
|
A, <<"' where nodeid='">>, Nidx,
|
||||||
<<"' and jid='">>, J, <<"';">>])
|
<<"' and jid='">>, J, <<"';">>])
|
||||||
of
|
of
|
||||||
@ -945,7 +945,7 @@ update_affiliation(Nidx, JID, Affiliation) ->
|
|||||||
ok;
|
ok;
|
||||||
_ ->
|
_ ->
|
||||||
catch
|
catch
|
||||||
ejabberd_odbc:sql_query_t([<<"insert into pubsub_state(nodeid, jid, affiliation, subscriptions) "
|
ejabberd_sql:sql_query_t([<<"insert into pubsub_state(nodeid, jid, affiliation, subscriptions) "
|
||||||
"values('">>, Nidx, <<"', '">>, J, <<"', '">>, A, <<"', '');">>])
|
"values('">>, Nidx, <<"', '">>, J, <<"', '">>, A, <<"', '');">>])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -953,14 +953,14 @@ update_subscription(Nidx, JID, Subscription) ->
|
|||||||
J = encode_jid(JID),
|
J = encode_jid(JID),
|
||||||
S = encode_subscriptions(Subscription),
|
S = encode_subscriptions(Subscription),
|
||||||
case catch
|
case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"update pubsub_state set subscriptions='">>, S,
|
ejabberd_sql:sql_query_t([<<"update pubsub_state set subscriptions='">>, S,
|
||||||
<<"' where nodeid='">>, Nidx, <<"' and jid='">>, J, <<"';">>])
|
<<"' where nodeid='">>, Nidx, <<"' and jid='">>, J, <<"';">>])
|
||||||
of
|
of
|
||||||
{updated, 1} ->
|
{updated, 1} ->
|
||||||
ok;
|
ok;
|
||||||
_ ->
|
_ ->
|
||||||
catch
|
catch
|
||||||
ejabberd_odbc:sql_query_t([<<"insert into pubsub_state(nodeid, jid, affiliation, subscriptions) "
|
ejabberd_sql:sql_query_t([<<"insert into pubsub_state(nodeid, jid, affiliation, subscriptions) "
|
||||||
"values('">>, Nidx, <<"', '">>, J, <<"', 'n', '">>, S, <<"');">>])
|
"values('">>, Nidx, <<"', '">>, J, <<"', 'n', '">>, S, <<"');">>])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -1009,14 +1009,14 @@ decode_subscriptions(Subscriptions) ->
|
|||||||
-> binary()
|
-> binary()
|
||||||
).
|
).
|
||||||
encode_jid(JID) ->
|
encode_jid(JID) ->
|
||||||
ejabberd_odbc:escape(jid:to_string(JID)).
|
ejabberd_sql:escape(jid:to_string(JID)).
|
||||||
|
|
||||||
-spec(encode_host/1 ::
|
-spec(encode_host/1 ::
|
||||||
( Host :: host())
|
( Host :: host())
|
||||||
-> binary()
|
-> binary()
|
||||||
).
|
).
|
||||||
encode_host({_U, _S, _R} = LJID) -> encode_jid(LJID);
|
encode_host({_U, _S, _R} = LJID) -> encode_jid(LJID);
|
||||||
encode_host(Host) -> ejabberd_odbc:escape(Host).
|
encode_host(Host) -> ejabberd_sql:escape(Host).
|
||||||
|
|
||||||
-spec(encode_affiliation/1 ::
|
-spec(encode_affiliation/1 ::
|
||||||
( Arg :: atom())
|
( Arg :: atom())
|
@ -1,5 +1,5 @@
|
|||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%% File : node_hometree_odbc.erl
|
%%% File : node_hometree_sql.erl
|
||||||
%%% Author : Christophe Romain <christophe.romain@process-one.net>
|
%%% Author : Christophe Romain <christophe.romain@process-one.net>
|
||||||
%%% Purpose : Standard tree ordered node plugin with ODBC backend
|
%%% Purpose : Standard tree ordered node plugin with ODBC backend
|
||||||
%%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net>
|
%%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net>
|
||||||
@ -23,7 +23,7 @@
|
|||||||
%%%
|
%%%
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
-module(node_hometree_odbc).
|
-module(node_hometree_sql).
|
||||||
-behaviour(gen_pubsub_node).
|
-behaviour(gen_pubsub_node).
|
||||||
-author('christophe.romain@process-one.net').
|
-author('christophe.romain@process-one.net').
|
||||||
|
|
||||||
@ -45,17 +45,17 @@
|
|||||||
get_entity_subscriptions_for_send_last/2, get_last_items/3]).
|
get_entity_subscriptions_for_send_last/2, get_last_items/3]).
|
||||||
|
|
||||||
init(Host, ServerHost, Opts) ->
|
init(Host, ServerHost, Opts) ->
|
||||||
node_flat_odbc:init(Host, ServerHost, Opts),
|
node_flat_sql:init(Host, ServerHost, Opts),
|
||||||
Owner = mod_pubsub:service_jid(Host),
|
Owner = mod_pubsub:service_jid(Host),
|
||||||
mod_pubsub:create_node(Host, ServerHost, <<"/home">>, Owner, <<"hometree">>),
|
mod_pubsub:create_node(Host, ServerHost, <<"/home">>, Owner, <<"hometree">>),
|
||||||
mod_pubsub:create_node(Host, ServerHost, <<"/home/", ServerHost/binary>>, Owner, <<"hometree">>),
|
mod_pubsub:create_node(Host, ServerHost, <<"/home/", ServerHost/binary>>, Owner, <<"hometree">>),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
terminate(Host, ServerHost) ->
|
terminate(Host, ServerHost) ->
|
||||||
node_flat_odbc:terminate(Host, ServerHost).
|
node_flat_sql:terminate(Host, ServerHost).
|
||||||
|
|
||||||
options() ->
|
options() ->
|
||||||
[{odbc, true}, {rsm, true} | node_hometree:options()].
|
[{sql, true}, {rsm, true} | node_hometree:options()].
|
||||||
|
|
||||||
features() ->
|
features() ->
|
||||||
[<<"rsm">> | node_hometree:features()].
|
[<<"rsm">> | node_hometree:features()].
|
||||||
@ -64,92 +64,92 @@ create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
|
|||||||
node_hometree:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
|
node_hometree:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
|
||||||
|
|
||||||
create_node(Nidx, Owner) ->
|
create_node(Nidx, Owner) ->
|
||||||
node_flat_odbc:create_node(Nidx, Owner).
|
node_flat_sql:create_node(Nidx, Owner).
|
||||||
|
|
||||||
delete_node(Nodes) ->
|
delete_node(Nodes) ->
|
||||||
node_flat_odbc:delete_node(Nodes).
|
node_flat_sql:delete_node(Nodes).
|
||||||
|
|
||||||
subscribe_node(Nidx, Sender, Subscriber, AccessModel,
|
subscribe_node(Nidx, Sender, Subscriber, AccessModel,
|
||||||
SendLast, PresenceSubscription, RosterGroup, Options) ->
|
SendLast, PresenceSubscription, RosterGroup, Options) ->
|
||||||
node_flat_odbc:subscribe_node(Nidx, Sender, Subscriber, AccessModel, SendLast,
|
node_flat_sql:subscribe_node(Nidx, Sender, Subscriber, AccessModel, SendLast,
|
||||||
PresenceSubscription, RosterGroup, Options).
|
PresenceSubscription, RosterGroup, Options).
|
||||||
|
|
||||||
unsubscribe_node(Nidx, Sender, Subscriber, SubId) ->
|
unsubscribe_node(Nidx, Sender, Subscriber, SubId) ->
|
||||||
node_flat_odbc:unsubscribe_node(Nidx, Sender, Subscriber, SubId).
|
node_flat_sql:unsubscribe_node(Nidx, Sender, Subscriber, SubId).
|
||||||
|
|
||||||
publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload) ->
|
publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload) ->
|
||||||
node_flat_odbc:publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload).
|
node_flat_sql:publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload).
|
||||||
|
|
||||||
remove_extra_items(Nidx, MaxItems, ItemIds) ->
|
remove_extra_items(Nidx, MaxItems, ItemIds) ->
|
||||||
node_flat_odbc:remove_extra_items(Nidx, MaxItems, ItemIds).
|
node_flat_sql:remove_extra_items(Nidx, MaxItems, ItemIds).
|
||||||
|
|
||||||
delete_item(Nidx, Publisher, PublishModel, ItemId) ->
|
delete_item(Nidx, Publisher, PublishModel, ItemId) ->
|
||||||
node_flat_odbc:delete_item(Nidx, Publisher, PublishModel, ItemId).
|
node_flat_sql:delete_item(Nidx, Publisher, PublishModel, ItemId).
|
||||||
|
|
||||||
purge_node(Nidx, Owner) ->
|
purge_node(Nidx, Owner) ->
|
||||||
node_flat_odbc:purge_node(Nidx, Owner).
|
node_flat_sql:purge_node(Nidx, Owner).
|
||||||
|
|
||||||
get_entity_affiliations(Host, Owner) ->
|
get_entity_affiliations(Host, Owner) ->
|
||||||
node_flat_odbc:get_entity_affiliations(Host, Owner).
|
node_flat_sql:get_entity_affiliations(Host, Owner).
|
||||||
|
|
||||||
get_node_affiliations(Nidx) ->
|
get_node_affiliations(Nidx) ->
|
||||||
node_flat_odbc:get_node_affiliations(Nidx).
|
node_flat_sql:get_node_affiliations(Nidx).
|
||||||
|
|
||||||
get_affiliation(Nidx, Owner) ->
|
get_affiliation(Nidx, Owner) ->
|
||||||
node_flat_odbc:get_affiliation(Nidx, Owner).
|
node_flat_sql:get_affiliation(Nidx, Owner).
|
||||||
|
|
||||||
set_affiliation(Nidx, Owner, Affiliation) ->
|
set_affiliation(Nidx, Owner, Affiliation) ->
|
||||||
node_flat_odbc:set_affiliation(Nidx, Owner, Affiliation).
|
node_flat_sql:set_affiliation(Nidx, Owner, Affiliation).
|
||||||
|
|
||||||
get_entity_subscriptions(Host, Owner) ->
|
get_entity_subscriptions(Host, Owner) ->
|
||||||
node_flat_odbc:get_entity_subscriptions(Host, Owner).
|
node_flat_sql:get_entity_subscriptions(Host, Owner).
|
||||||
|
|
||||||
get_entity_subscriptions_for_send_last(Host, Owner) ->
|
get_entity_subscriptions_for_send_last(Host, Owner) ->
|
||||||
node_flat_odbc:get_entity_subscriptions_for_send_last(Host, Owner).
|
node_flat_sql:get_entity_subscriptions_for_send_last(Host, Owner).
|
||||||
|
|
||||||
get_node_subscriptions(Nidx) ->
|
get_node_subscriptions(Nidx) ->
|
||||||
node_flat_odbc:get_node_subscriptions(Nidx).
|
node_flat_sql:get_node_subscriptions(Nidx).
|
||||||
|
|
||||||
get_subscriptions(Nidx, Owner) ->
|
get_subscriptions(Nidx, Owner) ->
|
||||||
node_flat_odbc:get_subscriptions(Nidx, Owner).
|
node_flat_sql:get_subscriptions(Nidx, Owner).
|
||||||
|
|
||||||
set_subscriptions(Nidx, Owner, Subscription, SubId) ->
|
set_subscriptions(Nidx, Owner, Subscription, SubId) ->
|
||||||
node_flat_odbc:set_subscriptions(Nidx, Owner, Subscription, SubId).
|
node_flat_sql:set_subscriptions(Nidx, Owner, Subscription, SubId).
|
||||||
|
|
||||||
get_pending_nodes(Host, Owner) ->
|
get_pending_nodes(Host, Owner) ->
|
||||||
node_flat_odbc:get_pending_nodes(Host, Owner).
|
node_flat_sql:get_pending_nodes(Host, Owner).
|
||||||
|
|
||||||
get_states(Nidx) ->
|
get_states(Nidx) ->
|
||||||
node_flat_odbc:get_states(Nidx).
|
node_flat_sql:get_states(Nidx).
|
||||||
|
|
||||||
get_state(Nidx, JID) ->
|
get_state(Nidx, JID) ->
|
||||||
node_flat_odbc:get_state(Nidx, JID).
|
node_flat_sql:get_state(Nidx, JID).
|
||||||
|
|
||||||
set_state(State) ->
|
set_state(State) ->
|
||||||
node_flat_odbc:set_state(State).
|
node_flat_sql:set_state(State).
|
||||||
|
|
||||||
get_items(Nidx, From, RSM) ->
|
get_items(Nidx, From, RSM) ->
|
||||||
node_flat_odbc:get_items(Nidx, From, RSM).
|
node_flat_sql:get_items(Nidx, From, RSM).
|
||||||
|
|
||||||
get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) ->
|
get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) ->
|
||||||
node_flat_odbc:get_items(Nidx, JID, AccessModel,
|
node_flat_sql:get_items(Nidx, JID, AccessModel,
|
||||||
PresenceSubscription, RosterGroup, SubId, RSM).
|
PresenceSubscription, RosterGroup, SubId, RSM).
|
||||||
|
|
||||||
get_item(Nidx, ItemId) ->
|
get_item(Nidx, ItemId) ->
|
||||||
node_flat_odbc:get_item(Nidx, ItemId).
|
node_flat_sql:get_item(Nidx, ItemId).
|
||||||
|
|
||||||
get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
|
get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
|
||||||
node_flat_odbc:get_item(Nidx, ItemId, JID,
|
node_flat_sql:get_item(Nidx, ItemId, JID,
|
||||||
AccessModel, PresenceSubscription, RosterGroup, SubId).
|
AccessModel, PresenceSubscription, RosterGroup, SubId).
|
||||||
|
|
||||||
set_item(Item) ->
|
set_item(Item) ->
|
||||||
node_flat_odbc:set_item(Item).
|
node_flat_sql:set_item(Item).
|
||||||
|
|
||||||
get_item_name(Host, Node, Id) ->
|
get_item_name(Host, Node, Id) ->
|
||||||
node_flat_odbc:get_item_name(Host, Node, Id).
|
node_flat_sql:get_item_name(Host, Node, Id).
|
||||||
|
|
||||||
get_last_items(Nidx, From, Count) ->
|
get_last_items(Nidx, From, Count) ->
|
||||||
node_flat_odbc:get_last_items(Nidx, From, Count).
|
node_flat_sql:get_last_items(Nidx, From, Count).
|
||||||
|
|
||||||
node_to_path(Node) ->
|
node_to_path(Node) ->
|
||||||
node_hometree:node_to_path(Node).
|
node_hometree:node_to_path(Node).
|
@ -6,7 +6,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
%%% Created : 8 Mar 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net>
|
%%% Created : 8 Mar 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net>
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
-module(node_mix_odbc).
|
-module(node_mix_sql).
|
||||||
|
|
||||||
-behaviour(gen_pubsub_node).
|
-behaviour(gen_pubsub_node).
|
||||||
|
|
||||||
@ -30,10 +30,10 @@
|
|||||||
%%% API
|
%%% API
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
init(Host, ServerHost, Opts) ->
|
init(Host, ServerHost, Opts) ->
|
||||||
node_flat_odbc:init(Host, ServerHost, Opts).
|
node_flat_sql:init(Host, ServerHost, Opts).
|
||||||
|
|
||||||
terminate(Host, ServerHost) ->
|
terminate(Host, ServerHost) ->
|
||||||
node_flat_odbc:terminate(Host, ServerHost).
|
node_flat_sql:terminate(Host, ServerHost).
|
||||||
|
|
||||||
options() ->
|
options() ->
|
||||||
[{deliver_payloads, true},
|
[{deliver_payloads, true},
|
||||||
@ -72,98 +72,98 @@ features() ->
|
|||||||
<<"subscription-notifications">>].
|
<<"subscription-notifications">>].
|
||||||
|
|
||||||
create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
|
create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
|
||||||
node_flat_odbc:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
|
node_flat_sql:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
|
||||||
|
|
||||||
create_node(Nidx, Owner) ->
|
create_node(Nidx, Owner) ->
|
||||||
node_flat_odbc:create_node(Nidx, Owner).
|
node_flat_sql:create_node(Nidx, Owner).
|
||||||
|
|
||||||
delete_node(Removed) ->
|
delete_node(Removed) ->
|
||||||
node_flat_odbc:delete_node(Removed).
|
node_flat_sql:delete_node(Removed).
|
||||||
|
|
||||||
subscribe_node(Nidx, Sender, Subscriber, AccessModel,
|
subscribe_node(Nidx, Sender, Subscriber, AccessModel,
|
||||||
SendLast, PresenceSubscription, RosterGroup, Options) ->
|
SendLast, PresenceSubscription, RosterGroup, Options) ->
|
||||||
node_flat_odbc:subscribe_node(Nidx, Sender, Subscriber, AccessModel, SendLast,
|
node_flat_sql:subscribe_node(Nidx, Sender, Subscriber, AccessModel, SendLast,
|
||||||
PresenceSubscription, RosterGroup, Options).
|
PresenceSubscription, RosterGroup, Options).
|
||||||
|
|
||||||
unsubscribe_node(Nidx, Sender, Subscriber, SubId) ->
|
unsubscribe_node(Nidx, Sender, Subscriber, SubId) ->
|
||||||
node_flat_odbc:unsubscribe_node(Nidx, Sender, Subscriber, SubId).
|
node_flat_sql:unsubscribe_node(Nidx, Sender, Subscriber, SubId).
|
||||||
|
|
||||||
publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload) ->
|
publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload) ->
|
||||||
node_flat_odbc:publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload).
|
node_flat_sql:publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload).
|
||||||
|
|
||||||
remove_extra_items(Nidx, MaxItems, ItemIds) ->
|
remove_extra_items(Nidx, MaxItems, ItemIds) ->
|
||||||
node_flat_odbc:remove_extra_items(Nidx, MaxItems, ItemIds).
|
node_flat_sql:remove_extra_items(Nidx, MaxItems, ItemIds).
|
||||||
|
|
||||||
delete_item(Nidx, Publisher, PublishModel, ItemId) ->
|
delete_item(Nidx, Publisher, PublishModel, ItemId) ->
|
||||||
node_flat_odbc:delete_item(Nidx, Publisher, PublishModel, ItemId).
|
node_flat_sql:delete_item(Nidx, Publisher, PublishModel, ItemId).
|
||||||
|
|
||||||
purge_node(Nidx, Owner) ->
|
purge_node(Nidx, Owner) ->
|
||||||
node_flat_odbc:purge_node(Nidx, Owner).
|
node_flat_sql:purge_node(Nidx, Owner).
|
||||||
|
|
||||||
get_entity_affiliations(Host, Owner) ->
|
get_entity_affiliations(Host, Owner) ->
|
||||||
node_flat_odbc:get_entity_affiliations(Host, Owner).
|
node_flat_sql:get_entity_affiliations(Host, Owner).
|
||||||
|
|
||||||
get_node_affiliations(Nidx) ->
|
get_node_affiliations(Nidx) ->
|
||||||
node_flat_odbc:get_node_affiliations(Nidx).
|
node_flat_sql:get_node_affiliations(Nidx).
|
||||||
|
|
||||||
get_affiliation(Nidx, Owner) ->
|
get_affiliation(Nidx, Owner) ->
|
||||||
node_flat_odbc:get_affiliation(Nidx, Owner).
|
node_flat_sql:get_affiliation(Nidx, Owner).
|
||||||
|
|
||||||
set_affiliation(Nidx, Owner, Affiliation) ->
|
set_affiliation(Nidx, Owner, Affiliation) ->
|
||||||
node_flat_odbc:set_affiliation(Nidx, Owner, Affiliation).
|
node_flat_sql:set_affiliation(Nidx, Owner, Affiliation).
|
||||||
|
|
||||||
get_entity_subscriptions(Host, Owner) ->
|
get_entity_subscriptions(Host, Owner) ->
|
||||||
node_flat_odbc:get_entity_subscriptions(Host, Owner).
|
node_flat_sql:get_entity_subscriptions(Host, Owner).
|
||||||
|
|
||||||
get_node_subscriptions(Nidx) ->
|
get_node_subscriptions(Nidx) ->
|
||||||
node_flat_odbc:get_node_subscriptions(Nidx).
|
node_flat_sql:get_node_subscriptions(Nidx).
|
||||||
|
|
||||||
get_subscriptions(Nidx, Owner) ->
|
get_subscriptions(Nidx, Owner) ->
|
||||||
node_flat_odbc:get_subscriptions(Nidx, Owner).
|
node_flat_sql:get_subscriptions(Nidx, Owner).
|
||||||
|
|
||||||
set_subscriptions(Nidx, Owner, Subscription, SubId) ->
|
set_subscriptions(Nidx, Owner, Subscription, SubId) ->
|
||||||
node_flat_odbc:set_subscriptions(Nidx, Owner, Subscription, SubId).
|
node_flat_sql:set_subscriptions(Nidx, Owner, Subscription, SubId).
|
||||||
|
|
||||||
get_pending_nodes(Host, Owner) ->
|
get_pending_nodes(Host, Owner) ->
|
||||||
node_flat_odbc:get_pending_nodes(Host, Owner).
|
node_flat_sql:get_pending_nodes(Host, Owner).
|
||||||
|
|
||||||
get_states(Nidx) ->
|
get_states(Nidx) ->
|
||||||
node_flat_odbc:get_states(Nidx).
|
node_flat_sql:get_states(Nidx).
|
||||||
|
|
||||||
get_state(Nidx, JID) ->
|
get_state(Nidx, JID) ->
|
||||||
node_flat_odbc:get_state(Nidx, JID).
|
node_flat_sql:get_state(Nidx, JID).
|
||||||
|
|
||||||
set_state(State) ->
|
set_state(State) ->
|
||||||
node_flat_odbc:set_state(State).
|
node_flat_sql:set_state(State).
|
||||||
|
|
||||||
get_items(Nidx, From, RSM) ->
|
get_items(Nidx, From, RSM) ->
|
||||||
node_flat_odbc:get_items(Nidx, From, RSM).
|
node_flat_sql:get_items(Nidx, From, RSM).
|
||||||
|
|
||||||
get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) ->
|
get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) ->
|
||||||
node_flat_odbc:get_items(Nidx, JID, AccessModel,
|
node_flat_sql:get_items(Nidx, JID, AccessModel,
|
||||||
PresenceSubscription, RosterGroup, SubId, RSM).
|
PresenceSubscription, RosterGroup, SubId, RSM).
|
||||||
|
|
||||||
get_item(Nidx, ItemId) ->
|
get_item(Nidx, ItemId) ->
|
||||||
node_flat_odbc:get_item(Nidx, ItemId).
|
node_flat_sql:get_item(Nidx, ItemId).
|
||||||
|
|
||||||
get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
|
get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
|
||||||
node_flat_odbc:get_item(Nidx, ItemId, JID, AccessModel,
|
node_flat_sql:get_item(Nidx, ItemId, JID, AccessModel,
|
||||||
PresenceSubscription, RosterGroup, SubId).
|
PresenceSubscription, RosterGroup, SubId).
|
||||||
|
|
||||||
set_item(Item) ->
|
set_item(Item) ->
|
||||||
node_flat_odbc:set_item(Item).
|
node_flat_sql:set_item(Item).
|
||||||
|
|
||||||
get_item_name(Host, Node, Id) ->
|
get_item_name(Host, Node, Id) ->
|
||||||
node_flat_odbc:get_item_name(Host, Node, Id).
|
node_flat_sql:get_item_name(Host, Node, Id).
|
||||||
|
|
||||||
node_to_path(Node) ->
|
node_to_path(Node) ->
|
||||||
node_flat_odbc:node_to_path(Node).
|
node_flat_sql:node_to_path(Node).
|
||||||
|
|
||||||
path_to_node(Path) ->
|
path_to_node(Path) ->
|
||||||
node_flat_odbc:path_to_node(Path).
|
node_flat_sql:path_to_node(Path).
|
||||||
|
|
||||||
get_entity_subscriptions_for_send_last(Host, Owner) ->
|
get_entity_subscriptions_for_send_last(Host, Owner) ->
|
||||||
node_flat_odbc:get_entity_subscriptions_for_send_last(Host, Owner).
|
node_flat_sql:get_entity_subscriptions_for_send_last(Host, Owner).
|
||||||
|
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% Internal functions
|
%%% Internal functions
|
@ -1,5 +1,5 @@
|
|||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%% File : node_pep_odbc.erl
|
%%% File : node_pep_sql.erl
|
||||||
%%% Author : Christophe Romain <christophe.romain@process-one.net>
|
%%% Author : Christophe Romain <christophe.romain@process-one.net>
|
||||||
%%% Purpose : Standard PubSub PEP plugin with ODBC backend
|
%%% Purpose : Standard PubSub PEP plugin with ODBC backend
|
||||||
%%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net>
|
%%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net>
|
||||||
@ -26,7 +26,7 @@
|
|||||||
%%% @doc The module <strong>{@module}</strong> is the pep PubSub plugin.
|
%%% @doc The module <strong>{@module}</strong> is the pep PubSub plugin.
|
||||||
%%% <p>PubSub plugin nodes are using the {@link gen_pubsub_node} behaviour.</p>
|
%%% <p>PubSub plugin nodes are using the {@link gen_pubsub_node} behaviour.</p>
|
||||||
|
|
||||||
-module(node_pep_odbc).
|
-module(node_pep_sql).
|
||||||
-behaviour(gen_pubsub_node).
|
-behaviour(gen_pubsub_node).
|
||||||
-author('christophe.romain@process-one.net').
|
-author('christophe.romain@process-one.net').
|
||||||
|
|
||||||
@ -49,16 +49,16 @@
|
|||||||
get_entity_subscriptions_for_send_last/2, get_last_items/3]).
|
get_entity_subscriptions_for_send_last/2, get_last_items/3]).
|
||||||
|
|
||||||
init(Host, ServerHost, Opts) ->
|
init(Host, ServerHost, Opts) ->
|
||||||
node_flat_odbc:init(Host, ServerHost, Opts),
|
node_flat_sql:init(Host, ServerHost, Opts),
|
||||||
complain_if_modcaps_disabled(ServerHost),
|
complain_if_modcaps_disabled(ServerHost),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
terminate(Host, ServerHost) ->
|
terminate(Host, ServerHost) ->
|
||||||
node_flat_odbc:terminate(Host, ServerHost),
|
node_flat_sql:terminate(Host, ServerHost),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
options() ->
|
options() ->
|
||||||
[{odbc, true}, {rsm, true} | node_pep:options()].
|
[{sql, true}, {rsm, true} | node_pep:options()].
|
||||||
|
|
||||||
features() ->
|
features() ->
|
||||||
[<<"rsm">> | node_pep:features()].
|
[<<"rsm">> | node_pep:features()].
|
||||||
@ -67,56 +67,56 @@ create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
|
|||||||
node_pep:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
|
node_pep:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
|
||||||
|
|
||||||
create_node(Nidx, Owner) ->
|
create_node(Nidx, Owner) ->
|
||||||
node_flat_odbc:create_node(Nidx, Owner),
|
node_flat_sql:create_node(Nidx, Owner),
|
||||||
{result, {default, broadcast}}.
|
{result, {default, broadcast}}.
|
||||||
|
|
||||||
delete_node(Nodes) ->
|
delete_node(Nodes) ->
|
||||||
{result, {_, _, Result}} = node_flat_odbc:delete_node(Nodes),
|
{result, {_, _, Result}} = node_flat_sql:delete_node(Nodes),
|
||||||
{result, {[], Result}}.
|
{result, {[], Result}}.
|
||||||
|
|
||||||
subscribe_node(Nidx, Sender, Subscriber, AccessModel,
|
subscribe_node(Nidx, Sender, Subscriber, AccessModel,
|
||||||
SendLast, PresenceSubscription, RosterGroup, Options) ->
|
SendLast, PresenceSubscription, RosterGroup, Options) ->
|
||||||
node_flat_odbc:subscribe_node(Nidx, Sender, Subscriber, AccessModel, SendLast,
|
node_flat_sql:subscribe_node(Nidx, Sender, Subscriber, AccessModel, SendLast,
|
||||||
PresenceSubscription, RosterGroup, Options).
|
PresenceSubscription, RosterGroup, Options).
|
||||||
|
|
||||||
|
|
||||||
unsubscribe_node(Nidx, Sender, Subscriber, SubId) ->
|
unsubscribe_node(Nidx, Sender, Subscriber, SubId) ->
|
||||||
case node_flat_odbc:unsubscribe_node(Nidx, Sender, Subscriber, SubId) of
|
case node_flat_sql:unsubscribe_node(Nidx, Sender, Subscriber, SubId) of
|
||||||
{error, Error} -> {error, Error};
|
{error, Error} -> {error, Error};
|
||||||
{result, _} -> {result, []}
|
{result, _} -> {result, []}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload) ->
|
publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload) ->
|
||||||
node_flat_odbc:publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload).
|
node_flat_sql:publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload).
|
||||||
|
|
||||||
remove_extra_items(Nidx, MaxItems, ItemIds) ->
|
remove_extra_items(Nidx, MaxItems, ItemIds) ->
|
||||||
node_flat_odbc:remove_extra_items(Nidx, MaxItems, ItemIds).
|
node_flat_sql:remove_extra_items(Nidx, MaxItems, ItemIds).
|
||||||
|
|
||||||
delete_item(Nidx, Publisher, PublishModel, ItemId) ->
|
delete_item(Nidx, Publisher, PublishModel, ItemId) ->
|
||||||
node_flat_odbc:delete_item(Nidx, Publisher, PublishModel, ItemId).
|
node_flat_sql:delete_item(Nidx, Publisher, PublishModel, ItemId).
|
||||||
|
|
||||||
purge_node(Nidx, Owner) ->
|
purge_node(Nidx, Owner) ->
|
||||||
node_flat_odbc:purge_node(Nidx, Owner).
|
node_flat_sql:purge_node(Nidx, Owner).
|
||||||
|
|
||||||
get_entity_affiliations(_Host, Owner) ->
|
get_entity_affiliations(_Host, Owner) ->
|
||||||
OwnerKey = jid:tolower(jid:remove_resource(Owner)),
|
OwnerKey = jid:tolower(jid:remove_resource(Owner)),
|
||||||
node_flat_odbc:get_entity_affiliations(OwnerKey, Owner).
|
node_flat_sql:get_entity_affiliations(OwnerKey, Owner).
|
||||||
|
|
||||||
get_node_affiliations(Nidx) ->
|
get_node_affiliations(Nidx) ->
|
||||||
node_flat_odbc:get_node_affiliations(Nidx).
|
node_flat_sql:get_node_affiliations(Nidx).
|
||||||
|
|
||||||
get_affiliation(Nidx, Owner) ->
|
get_affiliation(Nidx, Owner) ->
|
||||||
node_flat_odbc:get_affiliation(Nidx, Owner).
|
node_flat_sql:get_affiliation(Nidx, Owner).
|
||||||
|
|
||||||
set_affiliation(Nidx, Owner, Affiliation) ->
|
set_affiliation(Nidx, Owner, Affiliation) ->
|
||||||
node_flat_odbc:set_affiliation(Nidx, Owner, Affiliation).
|
node_flat_sql:set_affiliation(Nidx, Owner, Affiliation).
|
||||||
|
|
||||||
get_entity_subscriptions(_Host, Owner) ->
|
get_entity_subscriptions(_Host, Owner) ->
|
||||||
SubKey = jid:tolower(Owner),
|
SubKey = jid:tolower(Owner),
|
||||||
GenKey = jid:remove_resource(SubKey),
|
GenKey = jid:remove_resource(SubKey),
|
||||||
Host = node_flat_odbc:encode_host(element(2, SubKey)),
|
Host = node_flat_sql:encode_host(element(2, SubKey)),
|
||||||
SJ = node_flat_odbc:encode_jid(SubKey),
|
SJ = node_flat_sql:encode_jid(SubKey),
|
||||||
GJ = node_flat_odbc:encode_jid(GenKey),
|
GJ = node_flat_sql:encode_jid(GenKey),
|
||||||
Query = case SubKey of
|
Query = case SubKey of
|
||||||
GenKey ->
|
GenKey ->
|
||||||
[<<"select host, node, type, i.nodeid, jid, "
|
[<<"select host, node, type, i.nodeid, jid, "
|
||||||
@ -129,16 +129,16 @@ get_entity_subscriptions(_Host, Owner) ->
|
|||||||
"where i.nodeid = n.nodeid and jid "
|
"where i.nodeid = n.nodeid and jid "
|
||||||
"in ('">>, SJ, <<"', '">>, GJ, <<"') and host like '%@">>, Host, <<"';">>]
|
"in ('">>, SJ, <<"', '">>, GJ, <<"') and host like '%@">>, Host, <<"';">>]
|
||||||
end,
|
end,
|
||||||
Reply = case catch ejabberd_odbc:sql_query_t(Query) of
|
Reply = case catch ejabberd_sql:sql_query_t(Query) of
|
||||||
{selected,
|
{selected,
|
||||||
[<<"host">>, <<"node">>, <<"type">>, <<"nodeid">>, <<"jid">>, <<"subscriptions">>],
|
[<<"host">>, <<"node">>, <<"type">>, <<"nodeid">>, <<"jid">>, <<"subscriptions">>],
|
||||||
RItems} ->
|
RItems} ->
|
||||||
lists:map(fun ([H, N, T, I, J, S]) ->
|
lists:map(fun ([H, N, T, I, J, S]) ->
|
||||||
O = node_flat_odbc:decode_jid(H),
|
O = node_flat_sql:decode_jid(H),
|
||||||
Node = nodetree_tree_odbc:raw_to_node(O, [N, <<"">>, T, I]),
|
Node = nodetree_tree_sql:raw_to_node(O, [N, <<"">>, T, I]),
|
||||||
{Node,
|
{Node,
|
||||||
node_flat_odbc:decode_subscriptions(S),
|
node_flat_sql:decode_subscriptions(S),
|
||||||
node_flat_odbc:decode_jid(J)}
|
node_flat_sql:decode_jid(J)}
|
||||||
end,
|
end,
|
||||||
RItems);
|
RItems);
|
||||||
_ ->
|
_ ->
|
||||||
@ -149,9 +149,9 @@ get_entity_subscriptions(_Host, Owner) ->
|
|||||||
get_entity_subscriptions_for_send_last(_Host, Owner) ->
|
get_entity_subscriptions_for_send_last(_Host, Owner) ->
|
||||||
SubKey = jid:tolower(Owner),
|
SubKey = jid:tolower(Owner),
|
||||||
GenKey = jid:remove_resource(SubKey),
|
GenKey = jid:remove_resource(SubKey),
|
||||||
Host = node_flat_odbc:encode_host(element(2, SubKey)),
|
Host = node_flat_sql:encode_host(element(2, SubKey)),
|
||||||
SJ = node_flat_odbc:encode_jid(SubKey),
|
SJ = node_flat_sql:encode_jid(SubKey),
|
||||||
GJ = node_flat_odbc:encode_jid(GenKey),
|
GJ = node_flat_sql:encode_jid(GenKey),
|
||||||
Query = case SubKey of
|
Query = case SubKey of
|
||||||
GenKey ->
|
GenKey ->
|
||||||
[<<"select host, node, type, i.nodeid, jid, "
|
[<<"select host, node, type, i.nodeid, jid, "
|
||||||
@ -168,16 +168,16 @@ get_entity_subscriptions_for_send_last(_Host, Owner) ->
|
|||||||
"val='on_sub_and_presence' and jid in ",
|
"val='on_sub_and_presence' and jid in ",
|
||||||
"('">>, SJ, <<"', '">>, GJ, <<"') and host like '%@">>, Host, <<"';">>]
|
"('">>, SJ, <<"', '">>, GJ, <<"') and host like '%@">>, Host, <<"';">>]
|
||||||
end,
|
end,
|
||||||
Reply = case catch ejabberd_odbc:sql_query_t(Query) of
|
Reply = case catch ejabberd_sql:sql_query_t(Query) of
|
||||||
{selected,
|
{selected,
|
||||||
[<<"host">>, <<"node">>, <<"type">>, <<"nodeid">>, <<"jid">>, <<"subscriptions">>],
|
[<<"host">>, <<"node">>, <<"type">>, <<"nodeid">>, <<"jid">>, <<"subscriptions">>],
|
||||||
RItems} ->
|
RItems} ->
|
||||||
lists:map(fun ([H, N, T, I, J, S]) ->
|
lists:map(fun ([H, N, T, I, J, S]) ->
|
||||||
O = node_flat_odbc:decode_jid(H),
|
O = node_flat_sql:decode_jid(H),
|
||||||
Node = nodetree_tree_odbc:raw_to_node(O, [N, <<"">>, T, I]),
|
Node = nodetree_tree_sql:raw_to_node(O, [N, <<"">>, T, I]),
|
||||||
{Node,
|
{Node,
|
||||||
node_flat_odbc:decode_subscriptions(S),
|
node_flat_sql:decode_subscriptions(S),
|
||||||
node_flat_odbc:decode_jid(J)}
|
node_flat_sql:decode_jid(J)}
|
||||||
end,
|
end,
|
||||||
RItems);
|
RItems);
|
||||||
_ ->
|
_ ->
|
||||||
@ -186,54 +186,54 @@ get_entity_subscriptions_for_send_last(_Host, Owner) ->
|
|||||||
{result, Reply}.
|
{result, Reply}.
|
||||||
|
|
||||||
get_node_subscriptions(Nidx) ->
|
get_node_subscriptions(Nidx) ->
|
||||||
node_flat_odbc:get_node_subscriptions(Nidx).
|
node_flat_sql:get_node_subscriptions(Nidx).
|
||||||
|
|
||||||
get_subscriptions(Nidx, Owner) ->
|
get_subscriptions(Nidx, Owner) ->
|
||||||
node_flat_odbc:get_subscriptions(Nidx, Owner).
|
node_flat_sql:get_subscriptions(Nidx, Owner).
|
||||||
|
|
||||||
set_subscriptions(Nidx, Owner, Subscription, SubId) ->
|
set_subscriptions(Nidx, Owner, Subscription, SubId) ->
|
||||||
node_flat_odbc:set_subscriptions(Nidx, Owner, Subscription, SubId).
|
node_flat_sql:set_subscriptions(Nidx, Owner, Subscription, SubId).
|
||||||
|
|
||||||
get_pending_nodes(Host, Owner) ->
|
get_pending_nodes(Host, Owner) ->
|
||||||
node_flat_odbc:get_pending_nodes(Host, Owner).
|
node_flat_sql:get_pending_nodes(Host, Owner).
|
||||||
|
|
||||||
get_states(Nidx) ->
|
get_states(Nidx) ->
|
||||||
node_flat_odbc:get_states(Nidx).
|
node_flat_sql:get_states(Nidx).
|
||||||
|
|
||||||
get_state(Nidx, JID) ->
|
get_state(Nidx, JID) ->
|
||||||
node_flat_odbc:get_state(Nidx, JID).
|
node_flat_sql:get_state(Nidx, JID).
|
||||||
|
|
||||||
set_state(State) ->
|
set_state(State) ->
|
||||||
node_flat_odbc:set_state(State).
|
node_flat_sql:set_state(State).
|
||||||
|
|
||||||
get_items(Nidx, From, RSM) ->
|
get_items(Nidx, From, RSM) ->
|
||||||
node_flat_odbc:get_items(Nidx, From, RSM).
|
node_flat_sql:get_items(Nidx, From, RSM).
|
||||||
|
|
||||||
get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) ->
|
get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) ->
|
||||||
node_flat_odbc:get_items(Nidx, JID, AccessModel,
|
node_flat_sql:get_items(Nidx, JID, AccessModel,
|
||||||
PresenceSubscription, RosterGroup, SubId, RSM).
|
PresenceSubscription, RosterGroup, SubId, RSM).
|
||||||
|
|
||||||
get_last_items(Nidx, JID, Count) ->
|
get_last_items(Nidx, JID, Count) ->
|
||||||
node_flat_odbc:get_last_items(Nidx, JID, Count).
|
node_flat_sql:get_last_items(Nidx, JID, Count).
|
||||||
|
|
||||||
get_item(Nidx, ItemId) ->
|
get_item(Nidx, ItemId) ->
|
||||||
node_flat_odbc:get_item(Nidx, ItemId).
|
node_flat_sql:get_item(Nidx, ItemId).
|
||||||
|
|
||||||
get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
|
get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
|
||||||
node_flat_odbc:get_item(Nidx, ItemId, JID, AccessModel,
|
node_flat_sql:get_item(Nidx, ItemId, JID, AccessModel,
|
||||||
PresenceSubscription, RosterGroup, SubId).
|
PresenceSubscription, RosterGroup, SubId).
|
||||||
|
|
||||||
set_item(Item) ->
|
set_item(Item) ->
|
||||||
node_flat_odbc:set_item(Item).
|
node_flat_sql:set_item(Item).
|
||||||
|
|
||||||
get_item_name(Host, Node, Id) ->
|
get_item_name(Host, Node, Id) ->
|
||||||
node_flat_odbc:get_item_name(Host, Node, Id).
|
node_flat_sql:get_item_name(Host, Node, Id).
|
||||||
|
|
||||||
node_to_path(Node) ->
|
node_to_path(Node) ->
|
||||||
node_flat_odbc:node_to_path(Node).
|
node_flat_sql:node_to_path(Node).
|
||||||
|
|
||||||
path_to_node(Path) ->
|
path_to_node(Path) ->
|
||||||
node_flat_odbc:path_to_node(Path).
|
node_flat_sql:path_to_node(Path).
|
||||||
|
|
||||||
%%%
|
%%%
|
||||||
%%% Internal
|
%%% Internal
|
@ -1,5 +1,5 @@
|
|||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%% File : nodetree_tree_odbc.erl
|
%%% File : nodetree_tree_sql.erl
|
||||||
%%% Author : Christophe Romain <christophe.romain@process-one.net>
|
%%% Author : Christophe Romain <christophe.romain@process-one.net>
|
||||||
%%% Purpose : Standard node tree plugin with ODBC backend
|
%%% Purpose : Standard node tree plugin with ODBC backend
|
||||||
%%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net>
|
%%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net>
|
||||||
@ -33,7 +33,7 @@
|
|||||||
%%% useable and useful as is. Please, send us comments, feedback and
|
%%% useable and useful as is. Please, send us comments, feedback and
|
||||||
%%% improvements.</p>
|
%%% improvements.</p>
|
||||||
|
|
||||||
-module(nodetree_tree_odbc).
|
-module(nodetree_tree_sql).
|
||||||
-behaviour(gen_pubsub_nodetree).
|
-behaviour(gen_pubsub_nodetree).
|
||||||
-author('christophe.romain@process-one.net').
|
-author('christophe.romain@process-one.net').
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ terminate(_Host, _ServerHost) ->
|
|||||||
ok.
|
ok.
|
||||||
|
|
||||||
options() ->
|
options() ->
|
||||||
[{odbc, true} | nodetree_tree:options()].
|
[{sql, true} | nodetree_tree:options()].
|
||||||
|
|
||||||
set_node(Record) when is_record(Record, pubsub_node) ->
|
set_node(Record) when is_record(Record, pubsub_node) ->
|
||||||
{Host, Node} = Record#pubsub_node.nodeid,
|
{Host, Node} = Record#pubsub_node.nodeid,
|
||||||
@ -64,16 +64,16 @@ set_node(Record) when is_record(Record, pubsub_node) ->
|
|||||||
[First | _] -> First
|
[First | _] -> First
|
||||||
end,
|
end,
|
||||||
Type = Record#pubsub_node.type,
|
Type = Record#pubsub_node.type,
|
||||||
H = node_flat_odbc:encode_host(Host),
|
H = node_flat_sql:encode_host(Host),
|
||||||
N = ejabberd_odbc:escape(Node),
|
N = ejabberd_sql:escape(Node),
|
||||||
P = ejabberd_odbc:escape(Parent),
|
P = ejabberd_sql:escape(Parent),
|
||||||
Nidx = case nodeidx(Host, Node) of
|
Nidx = case nodeidx(Host, Node) of
|
||||||
{result, OldNidx} ->
|
{result, OldNidx} ->
|
||||||
catch
|
catch
|
||||||
ejabberd_odbc:sql_query_t([<<"delete from pubsub_node_option where "
|
ejabberd_sql:sql_query_t([<<"delete from pubsub_node_option where "
|
||||||
"nodeid='">>, OldNidx, <<"';">>]),
|
"nodeid='">>, OldNidx, <<"';">>]),
|
||||||
catch
|
catch
|
||||||
ejabberd_odbc:sql_query_t([<<"update pubsub_node set host='">>,
|
ejabberd_sql:sql_query_t([<<"update pubsub_node set host='">>,
|
||||||
H, <<"' node='">>, N,
|
H, <<"' node='">>, N,
|
||||||
<<"' parent='">>, P,
|
<<"' parent='">>, P,
|
||||||
<<"' type='">>, Type,
|
<<"' type='">>, Type,
|
||||||
@ -82,7 +82,7 @@ set_node(Record) when is_record(Record, pubsub_node) ->
|
|||||||
OldNidx;
|
OldNidx;
|
||||||
_ ->
|
_ ->
|
||||||
catch
|
catch
|
||||||
ejabberd_odbc:sql_query_t([<<"insert into pubsub_node(host, node, "
|
ejabberd_sql:sql_query_t([<<"insert into pubsub_node(host, node, "
|
||||||
"parent, type) values('">>,
|
"parent, type) values('">>,
|
||||||
H, <<"', '">>, N, <<"', '">>, P,
|
H, <<"', '">>, N, <<"', '">>, P,
|
||||||
<<"', '">>, Type, <<"');">>]),
|
<<"', '">>, Type, <<"');">>]),
|
||||||
@ -98,11 +98,11 @@ set_node(Record) when is_record(Record, pubsub_node) ->
|
|||||||
_ ->
|
_ ->
|
||||||
lists:foreach(fun ({Key, Value}) ->
|
lists:foreach(fun ({Key, Value}) ->
|
||||||
SKey = iolist_to_binary(atom_to_list(Key)),
|
SKey = iolist_to_binary(atom_to_list(Key)),
|
||||||
SValue = ejabberd_odbc:escape(
|
SValue = ejabberd_sql:escape(
|
||||||
list_to_binary(
|
list_to_binary(
|
||||||
lists:flatten(io_lib:fwrite("~p", [Value])))),
|
lists:flatten(io_lib:fwrite("~p", [Value])))),
|
||||||
catch
|
catch
|
||||||
ejabberd_odbc:sql_query_t([<<"insert into pubsub_node_option(nodeid, "
|
ejabberd_sql:sql_query_t([<<"insert into pubsub_node_option(nodeid, "
|
||||||
"name, val) values('">>,
|
"name, val) values('">>,
|
||||||
Nidx, <<"', '">>,
|
Nidx, <<"', '">>,
|
||||||
SKey, <<"', '">>, SValue, <<"');">>])
|
SKey, <<"', '">>, SValue, <<"');">>])
|
||||||
@ -115,10 +115,10 @@ get_node(Host, Node, _From) ->
|
|||||||
get_node(Host, Node).
|
get_node(Host, Node).
|
||||||
|
|
||||||
get_node(Host, Node) ->
|
get_node(Host, Node) ->
|
||||||
H = node_flat_odbc:encode_host(Host),
|
H = node_flat_sql:encode_host(Host),
|
||||||
N = ejabberd_odbc:escape(Node),
|
N = ejabberd_sql:escape(Node),
|
||||||
case catch
|
case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"select node, parent, type, nodeid from "
|
ejabberd_sql:sql_query_t([<<"select node, parent, type, nodeid from "
|
||||||
"pubsub_node where host='">>,
|
"pubsub_node where host='">>,
|
||||||
H, <<"' and node='">>, N, <<"';">>])
|
H, <<"' and node='">>, N, <<"';">>])
|
||||||
of
|
of
|
||||||
@ -133,7 +133,7 @@ get_node(Host, Node) ->
|
|||||||
|
|
||||||
get_node(Nidx) ->
|
get_node(Nidx) ->
|
||||||
case catch
|
case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"select host, node, parent, type from "
|
ejabberd_sql:sql_query_t([<<"select host, node, parent, type from "
|
||||||
"pubsub_node where nodeid='">>,
|
"pubsub_node where nodeid='">>,
|
||||||
Nidx, <<"';">>])
|
Nidx, <<"';">>])
|
||||||
of
|
of
|
||||||
@ -150,9 +150,9 @@ get_nodes(Host, _From) ->
|
|||||||
get_nodes(Host).
|
get_nodes(Host).
|
||||||
|
|
||||||
get_nodes(Host) ->
|
get_nodes(Host) ->
|
||||||
H = node_flat_odbc:encode_host(Host),
|
H = node_flat_sql:encode_host(Host),
|
||||||
case catch
|
case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"select node, parent, type, nodeid from "
|
ejabberd_sql:sql_query_t([<<"select node, parent, type, nodeid from "
|
||||||
"pubsub_node where host='">>, H, <<"';">>])
|
"pubsub_node where host='">>, H, <<"';">>])
|
||||||
of
|
of
|
||||||
{selected,
|
{selected,
|
||||||
@ -177,10 +177,10 @@ get_subnodes(Host, Node, _From) ->
|
|||||||
get_subnodes(Host, Node).
|
get_subnodes(Host, Node).
|
||||||
|
|
||||||
get_subnodes(Host, Node) ->
|
get_subnodes(Host, Node) ->
|
||||||
H = node_flat_odbc:encode_host(Host),
|
H = node_flat_sql:encode_host(Host),
|
||||||
N = ejabberd_odbc:escape(Node),
|
N = ejabberd_sql:escape(Node),
|
||||||
case catch
|
case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"select node, parent, type, nodeid from "
|
ejabberd_sql:sql_query_t([<<"select node, parent, type, nodeid from "
|
||||||
"pubsub_node where host='">>,
|
"pubsub_node where host='">>,
|
||||||
H, <<"' and parent='">>, N, <<"';">>])
|
H, <<"' and parent='">>, N, <<"';">>])
|
||||||
of
|
of
|
||||||
@ -195,10 +195,10 @@ get_subnodes_tree(Host, Node, _From) ->
|
|||||||
get_subnodes_tree(Host, Node).
|
get_subnodes_tree(Host, Node).
|
||||||
|
|
||||||
get_subnodes_tree(Host, Node) ->
|
get_subnodes_tree(Host, Node) ->
|
||||||
H = node_flat_odbc:encode_host(Host),
|
H = node_flat_sql:encode_host(Host),
|
||||||
N = ejabberd_odbc:escape(Node),
|
N = ejabberd_sql:escape(Node),
|
||||||
case catch
|
case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"select node, parent, type, nodeid from "
|
ejabberd_sql:sql_query_t([<<"select node, parent, type, nodeid from "
|
||||||
"pubsub_node where host='">>,
|
"pubsub_node where host='">>,
|
||||||
H, <<"' and node like '">>, N, <<"%';">>])
|
H, <<"' and node like '">>, N, <<"%';">>])
|
||||||
of
|
of
|
||||||
@ -255,17 +255,17 @@ create_node(Host, Node, Type, Owner, Options, Parents) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
delete_node(Host, Node) ->
|
delete_node(Host, Node) ->
|
||||||
H = node_flat_odbc:encode_host(Host),
|
H = node_flat_sql:encode_host(Host),
|
||||||
N = ejabberd_odbc:escape(Node),
|
N = ejabberd_sql:escape(Node),
|
||||||
Removed = get_subnodes_tree(Host, Node),
|
Removed = get_subnodes_tree(Host, Node),
|
||||||
catch ejabberd_odbc:sql_query_t([<<"delete from pubsub_node where host='">>,
|
catch ejabberd_sql:sql_query_t([<<"delete from pubsub_node where host='">>,
|
||||||
H, <<"' and node like '">>, N, <<"%';">>]),
|
H, <<"' and node like '">>, N, <<"%';">>]),
|
||||||
Removed.
|
Removed.
|
||||||
|
|
||||||
%% helpers
|
%% helpers
|
||||||
raw_to_node(Host, [Node, Parent, Type, Nidx]) ->
|
raw_to_node(Host, [Node, Parent, Type, Nidx]) ->
|
||||||
Options = case catch
|
Options = case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"select name,val from pubsub_node_option "
|
ejabberd_sql:sql_query_t([<<"select name,val from pubsub_node_option "
|
||||||
"where nodeid='">>, Nidx, <<"';">>])
|
"where nodeid='">>, Nidx, <<"';">>])
|
||||||
of
|
of
|
||||||
{selected, [<<"name">>, <<"val">>], ROptions} ->
|
{selected, [<<"name">>, <<"val">>], ROptions} ->
|
||||||
@ -276,7 +276,7 @@ raw_to_node(Host, [Node, Parent, Type, Nidx]) ->
|
|||||||
{RKey, RValue}
|
{RKey, RValue}
|
||||||
end,
|
end,
|
||||||
ROptions),
|
ROptions),
|
||||||
Module = jlib:binary_to_atom(<<"node_", Type/binary, "_odbc">>),
|
Module = jlib:binary_to_atom(<<"node_", Type/binary, "_sql">>),
|
||||||
StdOpts = Module:options(),
|
StdOpts = Module:options(),
|
||||||
lists:foldl(fun ({Key, Value}, Acc) ->
|
lists:foldl(fun ({Key, Value}, Acc) ->
|
||||||
lists:keyreplace(Key, 1, Acc, {Key, Value})
|
lists:keyreplace(Key, 1, Acc, {Key, Value})
|
||||||
@ -294,10 +294,10 @@ raw_to_node(Host, [Node, Parent, Type, Nidx]) ->
|
|||||||
id = Nidx, type = Type, options = Options}.
|
id = Nidx, type = Type, options = Options}.
|
||||||
|
|
||||||
nodeidx(Host, Node) ->
|
nodeidx(Host, Node) ->
|
||||||
H = node_flat_odbc:encode_host(Host),
|
H = node_flat_sql:encode_host(Host),
|
||||||
N = ejabberd_odbc:escape(Node),
|
N = ejabberd_sql:escape(Node),
|
||||||
case catch
|
case catch
|
||||||
ejabberd_odbc:sql_query_t([<<"select nodeid from pubsub_node where "
|
ejabberd_sql:sql_query_t([<<"select nodeid from pubsub_node where "
|
||||||
"host='">>,
|
"host='">>,
|
||||||
H, <<"' and node='">>, N, <<"';">>])
|
H, <<"' and node='">>, N, <<"';">>])
|
||||||
of
|
of
|
||||||
@ -310,5 +310,5 @@ nodeidx(Host, Node) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
nodeowners(Nidx) ->
|
nodeowners(Nidx) ->
|
||||||
{result, Res} = node_flat_odbc:get_node_affiliations(Nidx),
|
{result, Res} = node_flat_sql:get_node_affiliations(Nidx),
|
||||||
[LJID || {LJID, Aff} <- Res, Aff =:= owner].
|
[LJID || {LJID, Aff} <- Res, Aff =:= owner].
|
@ -1,5 +1,5 @@
|
|||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%% File : pubsub_db_odbc.erl
|
%%% File : pubsub_db_sql.erl
|
||||||
%%% Author : Pablo Polvorin <pablo.polvorin@process-one.net>
|
%%% Author : Pablo Polvorin <pablo.polvorin@process-one.net>
|
||||||
%%% Purpose : Provide helpers for PubSub ODBC backend
|
%%% Purpose : Provide helpers for PubSub ODBC backend
|
||||||
%%% Created : 7 Aug 2009 by Pablo Polvorin <pablo.polvorin@process-one.net>
|
%%% Created : 7 Aug 2009 by Pablo Polvorin <pablo.polvorin@process-one.net>
|
||||||
@ -23,7 +23,7 @@
|
|||||||
%%%
|
%%%
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
-module(pubsub_db_odbc).
|
-module(pubsub_db_sql).
|
||||||
|
|
||||||
-author("pablo.polvorin@process-one.net").
|
-author("pablo.polvorin@process-one.net").
|
||||||
|
|
||||||
@ -37,16 +37,16 @@
|
|||||||
%% -spec read_subscription(SubID :: string()) -> {ok, #pubsub_subscription{}} | notfound.
|
%% -spec read_subscription(SubID :: string()) -> {ok, #pubsub_subscription{}} | notfound.
|
||||||
read_subscription(SubID) ->
|
read_subscription(SubID) ->
|
||||||
case
|
case
|
||||||
ejabberd_odbc:sql_query_t([<<"select opt_name, opt_value from pubsub_subscr"
|
ejabberd_sql:sql_query_t([<<"select opt_name, opt_value from pubsub_subscr"
|
||||||
"iption_opt where subid = '">>,
|
"iption_opt where subid = '">>,
|
||||||
ejabberd_odbc:escape(SubID), <<"'">>])
|
ejabberd_sql:escape(SubID), <<"'">>])
|
||||||
of
|
of
|
||||||
{selected, [<<"opt_name">>, <<"opt_value">>], []} ->
|
{selected, [<<"opt_name">>, <<"opt_value">>], []} ->
|
||||||
notfound;
|
notfound;
|
||||||
{selected, [<<"opt_name">>, <<"opt_value">>], Options} ->
|
{selected, [<<"opt_name">>, <<"opt_value">>], Options} ->
|
||||||
{ok,
|
{ok,
|
||||||
#pubsub_subscription{subid = SubID,
|
#pubsub_subscription{subid = SubID,
|
||||||
options = lists:map(fun subscription_opt_from_odbc/1, Options)}}
|
options = lists:map(fun subscription_opt_from_sql/1, Options)}}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% -spec delete_subscription(SubID :: string()) -> ok.
|
%% -spec delete_subscription(SubID :: string()) -> ok.
|
||||||
@ -54,19 +54,19 @@ delete_subscription(SubID) ->
|
|||||||
%% -spec update_subscription(#pubsub_subscription{}) -> ok .
|
%% -spec update_subscription(#pubsub_subscription{}) -> ok .
|
||||||
%% -spec add_subscription(#pubsub_subscription{}) -> ok.
|
%% -spec add_subscription(#pubsub_subscription{}) -> ok.
|
||||||
%% -------------- Internal utilities -----------------------
|
%% -------------- Internal utilities -----------------------
|
||||||
ejabberd_odbc:sql_query_t([<<"delete from pubsub_subscription_opt "
|
ejabberd_sql:sql_query_t([<<"delete from pubsub_subscription_opt "
|
||||||
"where subid = '">>,
|
"where subid = '">>,
|
||||||
ejabberd_odbc:escape(SubID), <<"'">>]),
|
ejabberd_sql:escape(SubID), <<"'">>]),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
update_subscription(#pubsub_subscription{subid = SubId} = Sub) ->
|
update_subscription(#pubsub_subscription{subid = SubId} = Sub) ->
|
||||||
delete_subscription(SubId), add_subscription(Sub).
|
delete_subscription(SubId), add_subscription(Sub).
|
||||||
|
|
||||||
add_subscription(#pubsub_subscription{subid = SubId, options = Opts}) ->
|
add_subscription(#pubsub_subscription{subid = SubId, options = Opts}) ->
|
||||||
EscapedSubId = ejabberd_odbc:escape(SubId),
|
EscapedSubId = ejabberd_sql:escape(SubId),
|
||||||
lists:foreach(fun (Opt) ->
|
lists:foreach(fun (Opt) ->
|
||||||
{OdbcOptName, OdbcOptValue} = subscription_opt_to_odbc(Opt),
|
{OdbcOptName, OdbcOptValue} = subscription_opt_to_sql(Opt),
|
||||||
ejabberd_odbc:sql_query_t([<<"insert into pubsub_subscription_opt(subid, "
|
ejabberd_sql:sql_query_t([<<"insert into pubsub_subscription_opt(subid, "
|
||||||
"opt_name, opt_value)values ('">>,
|
"opt_name, opt_value)values ('">>,
|
||||||
EscapedSubId, <<"','">>,
|
EscapedSubId, <<"','">>,
|
||||||
OdbcOptName, <<"','">>,
|
OdbcOptName, <<"','">>,
|
||||||
@ -75,67 +75,67 @@ add_subscription(#pubsub_subscription{subid = SubId, options = Opts}) ->
|
|||||||
Opts),
|
Opts),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
subscription_opt_from_odbc({<<"DELIVER">>, Value}) ->
|
subscription_opt_from_sql({<<"DELIVER">>, Value}) ->
|
||||||
{deliver, odbc_to_boolean(Value)};
|
{deliver, sql_to_boolean(Value)};
|
||||||
subscription_opt_from_odbc({<<"DIGEST">>, Value}) ->
|
subscription_opt_from_sql({<<"DIGEST">>, Value}) ->
|
||||||
{digest, odbc_to_boolean(Value)};
|
{digest, sql_to_boolean(Value)};
|
||||||
subscription_opt_from_odbc({<<"DIGEST_FREQUENCY">>, Value}) ->
|
subscription_opt_from_sql({<<"DIGEST_FREQUENCY">>, Value}) ->
|
||||||
{digest_frequency, odbc_to_integer(Value)};
|
{digest_frequency, sql_to_integer(Value)};
|
||||||
subscription_opt_from_odbc({<<"EXPIRE">>, Value}) ->
|
subscription_opt_from_sql({<<"EXPIRE">>, Value}) ->
|
||||||
{expire, odbc_to_timestamp(Value)};
|
{expire, sql_to_timestamp(Value)};
|
||||||
subscription_opt_from_odbc({<<"INCLUDE_BODY">>, Value}) ->
|
subscription_opt_from_sql({<<"INCLUDE_BODY">>, Value}) ->
|
||||||
{include_body, odbc_to_boolean(Value)};
|
{include_body, sql_to_boolean(Value)};
|
||||||
%%TODO: might be > than 1 show_values value??.
|
%%TODO: might be > than 1 show_values value??.
|
||||||
%% need to use compact all in only 1 opt.
|
%% need to use compact all in only 1 opt.
|
||||||
subscription_opt_from_odbc({<<"SHOW_VALUES">>, Value}) ->
|
subscription_opt_from_sql({<<"SHOW_VALUES">>, Value}) ->
|
||||||
{show_values, Value};
|
{show_values, Value};
|
||||||
subscription_opt_from_odbc({<<"SUBSCRIPTION_TYPE">>, Value}) ->
|
subscription_opt_from_sql({<<"SUBSCRIPTION_TYPE">>, Value}) ->
|
||||||
{subscription_type,
|
{subscription_type,
|
||||||
case Value of
|
case Value of
|
||||||
<<"items">> -> items;
|
<<"items">> -> items;
|
||||||
<<"nodes">> -> nodes
|
<<"nodes">> -> nodes
|
||||||
end};
|
end};
|
||||||
subscription_opt_from_odbc({<<"SUBSCRIPTION_DEPTH">>, Value}) ->
|
subscription_opt_from_sql({<<"SUBSCRIPTION_DEPTH">>, Value}) ->
|
||||||
{subscription_depth,
|
{subscription_depth,
|
||||||
case Value of
|
case Value of
|
||||||
<<"all">> -> all;
|
<<"all">> -> all;
|
||||||
N -> odbc_to_integer(N)
|
N -> sql_to_integer(N)
|
||||||
end}.
|
end}.
|
||||||
|
|
||||||
subscription_opt_to_odbc({deliver, Bool}) ->
|
subscription_opt_to_sql({deliver, Bool}) ->
|
||||||
{<<"DELIVER">>, boolean_to_odbc(Bool)};
|
{<<"DELIVER">>, boolean_to_sql(Bool)};
|
||||||
subscription_opt_to_odbc({digest, Bool}) ->
|
subscription_opt_to_sql({digest, Bool}) ->
|
||||||
{<<"DIGEST">>, boolean_to_odbc(Bool)};
|
{<<"DIGEST">>, boolean_to_sql(Bool)};
|
||||||
subscription_opt_to_odbc({digest_frequency, Int}) ->
|
subscription_opt_to_sql({digest_frequency, Int}) ->
|
||||||
{<<"DIGEST_FREQUENCY">>, integer_to_odbc(Int)};
|
{<<"DIGEST_FREQUENCY">>, integer_to_sql(Int)};
|
||||||
subscription_opt_to_odbc({expire, Timestamp}) ->
|
subscription_opt_to_sql({expire, Timestamp}) ->
|
||||||
{<<"EXPIRE">>, timestamp_to_odbc(Timestamp)};
|
{<<"EXPIRE">>, timestamp_to_sql(Timestamp)};
|
||||||
subscription_opt_to_odbc({include_body, Bool}) ->
|
subscription_opt_to_sql({include_body, Bool}) ->
|
||||||
{<<"INCLUDE_BODY">>, boolean_to_odbc(Bool)};
|
{<<"INCLUDE_BODY">>, boolean_to_sql(Bool)};
|
||||||
subscription_opt_to_odbc({show_values, Values}) ->
|
subscription_opt_to_sql({show_values, Values}) ->
|
||||||
{<<"SHOW_VALUES">>, Values};
|
{<<"SHOW_VALUES">>, Values};
|
||||||
subscription_opt_to_odbc({subscription_type, Type}) ->
|
subscription_opt_to_sql({subscription_type, Type}) ->
|
||||||
{<<"SUBSCRIPTION_TYPE">>,
|
{<<"SUBSCRIPTION_TYPE">>,
|
||||||
case Type of
|
case Type of
|
||||||
items -> <<"items">>;
|
items -> <<"items">>;
|
||||||
nodes -> <<"nodes">>
|
nodes -> <<"nodes">>
|
||||||
end};
|
end};
|
||||||
subscription_opt_to_odbc({subscription_depth, Depth}) ->
|
subscription_opt_to_sql({subscription_depth, Depth}) ->
|
||||||
{<<"SUBSCRIPTION_DEPTH">>,
|
{<<"SUBSCRIPTION_DEPTH">>,
|
||||||
case Depth of
|
case Depth of
|
||||||
all -> <<"all">>;
|
all -> <<"all">>;
|
||||||
N -> integer_to_odbc(N)
|
N -> integer_to_sql(N)
|
||||||
end}.
|
end}.
|
||||||
|
|
||||||
integer_to_odbc(N) -> iolist_to_binary(integer_to_list(N)).
|
integer_to_sql(N) -> iolist_to_binary(integer_to_list(N)).
|
||||||
|
|
||||||
boolean_to_odbc(true) -> <<"1">>;
|
boolean_to_sql(true) -> <<"1">>;
|
||||||
boolean_to_odbc(false) -> <<"0">>.
|
boolean_to_sql(false) -> <<"0">>.
|
||||||
|
|
||||||
timestamp_to_odbc(T) -> jlib:now_to_utc_string(T).
|
timestamp_to_sql(T) -> jlib:now_to_utc_string(T).
|
||||||
|
|
||||||
odbc_to_integer(N) -> jlib:binary_to_integer(N).
|
sql_to_integer(N) -> jlib:binary_to_integer(N).
|
||||||
|
|
||||||
odbc_to_boolean(B) -> B == <<"1">>.
|
sql_to_boolean(B) -> B == <<"1">>.
|
||||||
|
|
||||||
odbc_to_timestamp(T) -> jlib:datetime_string_to_timestamp(T).
|
sql_to_timestamp(T) -> jlib:datetime_string_to_timestamp(T).
|
@ -1,5 +1,5 @@
|
|||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%% File : pubsub_subscription_odbc.erl
|
%%% File : pubsub_subscription_sql.erl
|
||||||
%%% Author : Pablo Polvorin <pablo.polvorin@process-one.net>
|
%%% Author : Pablo Polvorin <pablo.polvorin@process-one.net>
|
||||||
%%% Purpose : Handle pubsub subscriptions options with ODBC backend
|
%%% Purpose : Handle pubsub subscriptions options with ODBC backend
|
||||||
%%% based on pubsub_subscription.erl by Brian Cully <bjc@kublai.com>
|
%%% based on pubsub_subscription.erl by Brian Cully <bjc@kublai.com>
|
||||||
@ -24,7 +24,7 @@
|
|||||||
%%%
|
%%%
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
-module(pubsub_subscription_odbc).
|
-module(pubsub_subscription_sql).
|
||||||
-author("pablo.polvorin@process-one.net").
|
-author("pablo.polvorin@process-one.net").
|
||||||
|
|
||||||
%% API
|
%% API
|
||||||
@ -66,7 +66,7 @@
|
|||||||
-define(SUBSCRIPTION_DEPTH_VALUE_ONE_LABEL, <<"Receive notification from direct child nodes only">>).
|
-define(SUBSCRIPTION_DEPTH_VALUE_ONE_LABEL, <<"Receive notification from direct child nodes only">>).
|
||||||
-define(SUBSCRIPTION_DEPTH_VALUE_ALL_LABEL, <<"Receive notification from all descendent nodes">>).
|
-define(SUBSCRIPTION_DEPTH_VALUE_ALL_LABEL, <<"Receive notification from all descendent nodes">>).
|
||||||
|
|
||||||
-define(DB_MOD, pubsub_db_odbc).
|
-define(DB_MOD, pubsub_db_sql).
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
%% API
|
%% API
|
||||||
%%====================================================================
|
%%====================================================================
|
@ -1,5 +1,5 @@
|
|||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%% File : odbc_queries.erl
|
%%% File : sql_queries.erl
|
||||||
%%% Author : Mickael Remond <mremond@process-one.net>
|
%%% Author : Mickael Remond <mremond@process-one.net>
|
||||||
%%% Purpose : ODBC queries dependind on back-end
|
%%% Purpose : ODBC queries dependind on back-end
|
||||||
%%% Created : by Mickael Remond <mremond@process-one.net>
|
%%% Created : by Mickael Remond <mremond@process-one.net>
|
||||||
@ -23,7 +23,7 @@
|
|||||||
%%%
|
%%%
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
-module(odbc_queries).
|
-module(sql_queries).
|
||||||
|
|
||||||
-compile([{parse_transform, ejabberd_sql_pt}]).
|
-compile([{parse_transform, ejabberd_sql_pt}]).
|
||||||
|
|
||||||
@ -78,13 +78,13 @@ update_t(Table, Fields, Vals, Where) ->
|
|||||||
<<A/binary, "='", B/binary, "'">>
|
<<A/binary, "='", B/binary, "'">>
|
||||||
end,
|
end,
|
||||||
Fields, Vals),
|
Fields, Vals),
|
||||||
case ejabberd_odbc:sql_query_t([<<"update ">>, Table,
|
case ejabberd_sql:sql_query_t([<<"update ">>, Table,
|
||||||
<<" set ">>, join(UPairs, <<", ">>),
|
<<" set ">>, join(UPairs, <<", ">>),
|
||||||
<<" where ">>, Where, <<";">>])
|
<<" where ">>, Where, <<";">>])
|
||||||
of
|
of
|
||||||
{updated, 1} -> ok;
|
{updated, 1} -> ok;
|
||||||
_ ->
|
_ ->
|
||||||
Res = ejabberd_odbc:sql_query_t([<<"insert into ">>, Table,
|
Res = ejabberd_sql:sql_query_t([<<"insert into ">>, Table,
|
||||||
<<"(">>, join(Fields, <<", ">>),
|
<<"(">>, join(Fields, <<", ">>),
|
||||||
<<") values ('">>, join(Vals, <<"', '">>),
|
<<") values ('">>, join(Vals, <<"', '">>),
|
||||||
<<"');">>]),
|
<<"');">>]),
|
||||||
@ -99,14 +99,14 @@ update(LServer, Table, Fields, Vals, Where) ->
|
|||||||
<<A/binary, "='", B/binary, "'">>
|
<<A/binary, "='", B/binary, "'">>
|
||||||
end,
|
end,
|
||||||
Fields, Vals),
|
Fields, Vals),
|
||||||
case ejabberd_odbc:sql_query(LServer,
|
case ejabberd_sql:sql_query(LServer,
|
||||||
[<<"update ">>, Table, <<" set ">>,
|
[<<"update ">>, Table, <<" set ">>,
|
||||||
join(UPairs, <<", ">>), <<" where ">>, Where,
|
join(UPairs, <<", ">>), <<" where ">>, Where,
|
||||||
<<";">>])
|
<<";">>])
|
||||||
of
|
of
|
||||||
{updated, 1} -> ok;
|
{updated, 1} -> ok;
|
||||||
_ ->
|
_ ->
|
||||||
Res = ejabberd_odbc:sql_query(LServer,
|
Res = ejabberd_sql:sql_query(LServer,
|
||||||
[<<"insert into ">>, Table, <<"(">>,
|
[<<"insert into ">>, Table, <<"(">>,
|
||||||
join(Fields, <<", ">>), <<") values ('">>,
|
join(Fields, <<", ">>), <<") values ('">>,
|
||||||
join(Vals, <<"', '">>), <<"');">>]),
|
join(Vals, <<"', '">>), <<"');">>]),
|
||||||
@ -118,12 +118,12 @@ update(LServer, Table, Fields, Vals, Where) ->
|
|||||||
|
|
||||||
%% F can be either a fun or a list of queries
|
%% F can be either a fun or a list of queries
|
||||||
%% TODO: We should probably move the list of queries transaction
|
%% TODO: We should probably move the list of queries transaction
|
||||||
%% wrapper from the ejabberd_odbc module to this one (odbc_queries)
|
%% wrapper from the ejabberd_sql module to this one (sql_queries)
|
||||||
sql_transaction(LServer, F) ->
|
sql_transaction(LServer, F) ->
|
||||||
ejabberd_odbc:sql_transaction(LServer, F).
|
ejabberd_sql:sql_transaction(LServer, F).
|
||||||
|
|
||||||
get_last(LServer, LUser) ->
|
get_last(LServer, LUser) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(seconds)d, @(state)s from last"
|
?SQL("select @(seconds)d, @(state)s from last"
|
||||||
" where username=%(LUser)s")).
|
" where username=%(LUser)s")).
|
||||||
@ -135,24 +135,24 @@ set_last_t(LServer, LUser, TimeStamp, Status) ->
|
|||||||
"state=%(Status)s"]).
|
"state=%(Status)s"]).
|
||||||
|
|
||||||
del_last(LServer, LUser) ->
|
del_last(LServer, LUser) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("delete from last where username=%(LUser)s")).
|
?SQL("delete from last where username=%(LUser)s")).
|
||||||
|
|
||||||
get_password(LServer, LUser) ->
|
get_password(LServer, LUser) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(password)s from users where username=%(LUser)s")).
|
?SQL("select @(password)s from users where username=%(LUser)s")).
|
||||||
|
|
||||||
get_password_scram(LServer, LUser) ->
|
get_password_scram(LServer, LUser) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(password)s, @(serverkey)s, @(salt)s, @(iterationcount)d"
|
?SQL("select @(password)s, @(serverkey)s, @(salt)s, @(iterationcount)d"
|
||||||
" from users"
|
" from users"
|
||||||
" where username=%(LUser)s")).
|
" where username=%(LUser)s")).
|
||||||
|
|
||||||
set_password_t(LServer, LUser, Password) ->
|
set_password_t(LServer, LUser, Password) ->
|
||||||
ejabberd_odbc:sql_transaction(
|
ejabberd_sql:sql_transaction(
|
||||||
LServer,
|
LServer,
|
||||||
fun () ->
|
fun () ->
|
||||||
?SQL_UPSERT_T(
|
?SQL_UPSERT_T(
|
||||||
@ -163,7 +163,7 @@ set_password_t(LServer, LUser, Password) ->
|
|||||||
|
|
||||||
set_password_scram_t(LServer, LUser,
|
set_password_scram_t(LServer, LUser,
|
||||||
StoredKey, ServerKey, Salt, IterationCount) ->
|
StoredKey, ServerKey, Salt, IterationCount) ->
|
||||||
ejabberd_odbc:sql_transaction(
|
ejabberd_sql:sql_transaction(
|
||||||
LServer,
|
LServer,
|
||||||
fun () ->
|
fun () ->
|
||||||
?SQL_UPSERT_T(
|
?SQL_UPSERT_T(
|
||||||
@ -176,14 +176,14 @@ set_password_scram_t(LServer, LUser,
|
|||||||
end).
|
end).
|
||||||
|
|
||||||
add_user(LServer, LUser, Password) ->
|
add_user(LServer, LUser, Password) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("insert into users(username, password) "
|
?SQL("insert into users(username, password) "
|
||||||
"values (%(LUser)s, %(Password)s)")).
|
"values (%(LUser)s, %(Password)s)")).
|
||||||
|
|
||||||
add_user_scram(LServer, LUser,
|
add_user_scram(LServer, LUser,
|
||||||
StoredKey, ServerKey, Salt, IterationCount) ->
|
StoredKey, ServerKey, Salt, IterationCount) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("insert into users(username, password, serverkey, salt, "
|
?SQL("insert into users(username, password, serverkey, salt, "
|
||||||
"iterationcount) "
|
"iterationcount) "
|
||||||
@ -191,21 +191,21 @@ add_user_scram(LServer, LUser,
|
|||||||
" %(Salt)s, %(IterationCount)d)")).
|
" %(Salt)s, %(IterationCount)d)")).
|
||||||
|
|
||||||
del_user(LServer, LUser) ->
|
del_user(LServer, LUser) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("delete from users where username=%(LUser)s")).
|
?SQL("delete from users where username=%(LUser)s")).
|
||||||
|
|
||||||
del_user_return_password(_LServer, LUser, Password) ->
|
del_user_return_password(_LServer, LUser, Password) ->
|
||||||
P =
|
P =
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("select @(password)s from users where username=%(LUser)s")),
|
?SQL("select @(password)s from users where username=%(LUser)s")),
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("delete from users"
|
?SQL("delete from users"
|
||||||
" where username=%(LUser)s and password=%(Password)s")),
|
" where username=%(LUser)s and password=%(Password)s")),
|
||||||
P.
|
P.
|
||||||
|
|
||||||
list_users(LServer) ->
|
list_users(LServer) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(username)s from users")).
|
?SQL("select @(username)s from users")).
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ list_users(LServer,
|
|||||||
{offset, Start - 1}]);
|
{offset, Start - 1}]);
|
||||||
list_users(LServer, [{limit, Limit}, {offset, Offset}])
|
list_users(LServer, [{limit, Limit}, {offset, Offset}])
|
||||||
when is_integer(Limit) and is_integer(Offset) ->
|
when is_integer(Limit) and is_integer(Offset) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(username)s from users "
|
?SQL("select @(username)s from users "
|
||||||
"order by username "
|
"order by username "
|
||||||
@ -231,9 +231,9 @@ list_users(LServer,
|
|||||||
[{prefix, Prefix}, {limit, Limit}, {offset, Offset}])
|
[{prefix, Prefix}, {limit, Limit}, {offset, Offset}])
|
||||||
when is_binary(Prefix) and is_integer(Limit) and
|
when is_binary(Prefix) and is_integer(Limit) and
|
||||||
is_integer(Offset) ->
|
is_integer(Offset) ->
|
||||||
SPrefix = ejabberd_odbc:escape_like_arg(Prefix),
|
SPrefix = ejabberd_sql:escape_like_arg(Prefix),
|
||||||
SPrefix2 = <<SPrefix/binary, $%>>,
|
SPrefix2 = <<SPrefix/binary, $%>>,
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(username)s from users "
|
?SQL("select @(username)s from users "
|
||||||
"where username like %(SPrefix2)s "
|
"where username like %(SPrefix2)s "
|
||||||
@ -241,7 +241,7 @@ list_users(LServer,
|
|||||||
"limit %(Limit)d offset %(Offset)d")).
|
"limit %(Limit)d offset %(Offset)d")).
|
||||||
|
|
||||||
users_number(LServer) ->
|
users_number(LServer) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
fun(pgsql, _) ->
|
fun(pgsql, _) ->
|
||||||
case
|
case
|
||||||
@ -250,100 +250,99 @@ users_number(LServer) ->
|
|||||||
fun(V) when is_boolean(V) -> V end,
|
fun(V) when is_boolean(V) -> V end,
|
||||||
false) of
|
false) of
|
||||||
true ->
|
true ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("select @(reltuples :: bigint)d from pg_class"
|
?SQL("select @(reltuples :: bigint)d from pg_class"
|
||||||
" where oid = 'users'::regclass::oid"));
|
" where oid = 'users'::regclass::oid"));
|
||||||
_ ->
|
_ ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("select @(count(*))d from users"))
|
?SQL("select @(count(*))d from users"))
|
||||||
end;
|
end;
|
||||||
(_Type, _) ->
|
(_Type, _) ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("select @(count(*))d from users"))
|
?SQL("select @(count(*))d from users"))
|
||||||
end).
|
end).
|
||||||
|
|
||||||
users_number(LServer, [{prefix, Prefix}])
|
users_number(LServer, [{prefix, Prefix}])
|
||||||
when is_binary(Prefix) ->
|
when is_binary(Prefix) ->
|
||||||
SPrefix = ejabberd_odbc:escape_like_arg(Prefix),
|
SPrefix = ejabberd_sql:escape_like_arg(Prefix),
|
||||||
SPrefix2 = <<SPrefix/binary, $%>>,
|
SPrefix2 = <<SPrefix/binary, $%>>,
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(count(*))d from users "
|
?SQL("select @(count(*))d from users "
|
||||||
"where username like %(SPrefix2)s"));
|
"where username like %(SPrefix2)s"));
|
||||||
users_number(LServer, []) ->
|
users_number(LServer, []) ->
|
||||||
users_number(LServer).
|
users_number(LServer).
|
||||||
|
|
||||||
|
|
||||||
add_spool_sql(Username, XML) ->
|
add_spool_sql(Username, XML) ->
|
||||||
[<<"insert into spool(username, xml) values ('">>,
|
[<<"insert into spool(username, xml) values ('">>,
|
||||||
Username, <<"', '">>, XML, <<"');">>].
|
Username, <<"', '">>, XML, <<"');">>].
|
||||||
|
|
||||||
add_spool(LServer, Queries) ->
|
add_spool(LServer, Queries) ->
|
||||||
ejabberd_odbc:sql_transaction(LServer, Queries).
|
ejabberd_sql:sql_transaction(LServer, Queries).
|
||||||
|
|
||||||
get_and_del_spool_msg_t(LServer, LUser) ->
|
get_and_del_spool_msg_t(LServer, LUser) ->
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
Result =
|
Result =
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("select @(username)s, @(xml)s from spool where "
|
?SQL("select @(username)s, @(xml)s from spool where "
|
||||||
"username=%(LUser)s order by seq;")),
|
"username=%(LUser)s order by seq;")),
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("delete from spool where username=%(LUser)s;")),
|
?SQL("delete from spool where username=%(LUser)s;")),
|
||||||
Result
|
Result
|
||||||
end,
|
end,
|
||||||
ejabberd_odbc:sql_transaction(LServer, F).
|
ejabberd_sql:sql_transaction(LServer, F).
|
||||||
|
|
||||||
del_spool_msg(LServer, LUser) ->
|
del_spool_msg(LServer, LUser) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("delete from spool where username=%(LUser)s")).
|
?SQL("delete from spool where username=%(LUser)s")).
|
||||||
|
|
||||||
get_roster(LServer, LUser) ->
|
get_roster(LServer, LUser) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(username)s, @(jid)s, @(nick)s, @(subscription)s, "
|
?SQL("select @(username)s, @(jid)s, @(nick)s, @(subscription)s, "
|
||||||
"@(ask)s, @(askmessage)s, @(server)s, @(subscribe)s, "
|
"@(ask)s, @(askmessage)s, @(server)s, @(subscribe)s, "
|
||||||
"@(type)s from rosterusers where username=%(LUser)s")).
|
"@(type)s from rosterusers where username=%(LUser)s")).
|
||||||
|
|
||||||
get_roster_jid_groups(LServer, LUser) ->
|
get_roster_jid_groups(LServer, LUser) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(jid)s, @(grp)s from rostergroups where "
|
?SQL("select @(jid)s, @(grp)s from rostergroups where "
|
||||||
"username=%(LUser)s")).
|
"username=%(LUser)s")).
|
||||||
|
|
||||||
get_roster_groups(_LServer, LUser, SJID) ->
|
get_roster_groups(_LServer, LUser, SJID) ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("select @(grp)s from rostergroups"
|
?SQL("select @(grp)s from rostergroups"
|
||||||
" where username=%(LUser)s and jid=%(SJID)s")).
|
" where username=%(LUser)s and jid=%(SJID)s")).
|
||||||
|
|
||||||
del_user_roster_t(LServer, LUser) ->
|
del_user_roster_t(LServer, LUser) ->
|
||||||
ejabberd_odbc:sql_transaction(
|
ejabberd_sql:sql_transaction(
|
||||||
LServer,
|
LServer,
|
||||||
fun () ->
|
fun () ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("delete from rosterusers where username=%(LUser)s")),
|
?SQL("delete from rosterusers where username=%(LUser)s")),
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("delete from rostergroups where username=%(LUser)s"))
|
?SQL("delete from rostergroups where username=%(LUser)s"))
|
||||||
end).
|
end).
|
||||||
|
|
||||||
get_roster_by_jid(_LServer, LUser, SJID) ->
|
get_roster_by_jid(_LServer, LUser, SJID) ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("select @(username)s, @(jid)s, @(nick)s, @(subscription)s,"
|
?SQL("select @(username)s, @(jid)s, @(nick)s, @(subscription)s,"
|
||||||
" @(ask)s, @(askmessage)s, @(server)s, @(subscribe)s,"
|
" @(ask)s, @(askmessage)s, @(server)s, @(subscribe)s,"
|
||||||
" @(type)s from rosterusers"
|
" @(type)s from rosterusers"
|
||||||
" where username=%(LUser)s and jid=%(SJID)s")).
|
" where username=%(LUser)s and jid=%(SJID)s")).
|
||||||
|
|
||||||
get_rostergroup_by_jid(LServer, LUser, SJID) ->
|
get_rostergroup_by_jid(LServer, LUser, SJID) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(grp)s from rostergroups"
|
?SQL("select @(grp)s from rostergroups"
|
||||||
" where username=%(LUser)s and jid=%(SJID)s")).
|
" where username=%(LUser)s and jid=%(SJID)s")).
|
||||||
|
|
||||||
del_roster(_LServer, LUser, SJID) ->
|
del_roster(_LServer, LUser, SJID) ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("delete from rosterusers"
|
?SQL("delete from rosterusers"
|
||||||
" where username=%(LUser)s and jid=%(SJID)s")),
|
" where username=%(LUser)s and jid=%(SJID)s")),
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("delete from rostergroups"
|
?SQL("delete from rostergroups"
|
||||||
" where username=%(LUser)s and jid=%(SJID)s")).
|
" where username=%(LUser)s and jid=%(SJID)s")).
|
||||||
|
|
||||||
@ -358,12 +357,12 @@ del_roster_sql(Username, SJID) ->
|
|||||||
update_roster(_LServer, LUser, SJID, ItemVals,
|
update_roster(_LServer, LUser, SJID, ItemVals,
|
||||||
ItemGroups) ->
|
ItemGroups) ->
|
||||||
roster_subscribe(ItemVals),
|
roster_subscribe(ItemVals),
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("delete from rostergroups"
|
?SQL("delete from rostergroups"
|
||||||
" where username=%(LUser)s and jid=%(SJID)s")),
|
" where username=%(LUser)s and jid=%(SJID)s")),
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(ItemGroup) ->
|
fun(ItemGroup) ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("insert into rostergroups(username, jid, grp) "
|
?SQL("insert into rostergroups(username, jid, grp) "
|
||||||
"values (%(LUser)s, %(SJID)s, %(ItemGroup)s)"))
|
"values (%(LUser)s, %(SJID)s, %(ItemGroup)s)"))
|
||||||
end,
|
end,
|
||||||
@ -403,7 +402,7 @@ roster_subscribe({LUser, SJID, Name, SSubscription, SAsk, AskMessage}) ->
|
|||||||
"type='item'"]).
|
"type='item'"]).
|
||||||
|
|
||||||
get_subscription(LServer, LUser, SJID) ->
|
get_subscription(LServer, LUser, SJID) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(subscription)s from rosterusers "
|
?SQL("select @(subscription)s from rosterusers "
|
||||||
"where username=%(LUser)s and jid=%(SJID)s")).
|
"where username=%(LUser)s and jid=%(SJID)s")).
|
||||||
@ -424,19 +423,19 @@ set_private_data_sql(Username, LXMLNS, SData) ->
|
|||||||
<<"');">>]].
|
<<"');">>]].
|
||||||
|
|
||||||
get_private_data(LServer, LUser, XMLNS) ->
|
get_private_data(LServer, LUser, XMLNS) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(data)s from private_storage"
|
?SQL("select @(data)s from private_storage"
|
||||||
" where username=%(LUser)s and namespace=%(XMLNS)s")).
|
" where username=%(LUser)s and namespace=%(XMLNS)s")).
|
||||||
|
|
||||||
get_private_data(LServer, LUser) ->
|
get_private_data(LServer, LUser) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(namespace)s, @(data)s from private_storage"
|
?SQL("select @(namespace)s, @(data)s from private_storage"
|
||||||
" where username=%(LUser)s")).
|
" where username=%(LUser)s")).
|
||||||
|
|
||||||
del_user_private_storage(LServer, LUser) ->
|
del_user_private_storage(LServer, LUser) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("delete from private_storage"
|
?SQL("delete from private_storage"
|
||||||
" where username=%(LUser)s")).
|
" where username=%(LUser)s")).
|
||||||
@ -446,7 +445,7 @@ set_vcard(LServer, LUser, BDay, CTRY, EMail, FN,
|
|||||||
LFamily, LGiven, LLocality, LMiddle, LNickname,
|
LFamily, LGiven, LLocality, LMiddle, LNickname,
|
||||||
LOrgName, LOrgUnit, Locality, Middle, Nickname,
|
LOrgName, LOrgUnit, Locality, Middle, Nickname,
|
||||||
OrgName, OrgUnit, SVCARD, User) ->
|
OrgName, OrgUnit, SVCARD, User) ->
|
||||||
ejabberd_odbc:sql_transaction(
|
ejabberd_sql:sql_transaction(
|
||||||
LServer,
|
LServer,
|
||||||
fun() ->
|
fun() ->
|
||||||
?SQL_UPSERT(LServer, "vcard",
|
?SQL_UPSERT(LServer, "vcard",
|
||||||
@ -480,45 +479,45 @@ set_vcard(LServer, LUser, BDay, CTRY, EMail, FN,
|
|||||||
end).
|
end).
|
||||||
|
|
||||||
get_vcard(LServer, LUser) ->
|
get_vcard(LServer, LUser) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(vcard)s from vcard where username=%(LUser)s")).
|
?SQL("select @(vcard)s from vcard where username=%(LUser)s")).
|
||||||
|
|
||||||
get_default_privacy_list(LServer, LUser) ->
|
get_default_privacy_list(LServer, LUser) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(name)s from privacy_default_list "
|
?SQL("select @(name)s from privacy_default_list "
|
||||||
"where username=%(LUser)s")).
|
"where username=%(LUser)s")).
|
||||||
|
|
||||||
get_default_privacy_list_t(LUser) ->
|
get_default_privacy_list_t(LUser) ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("select @(name)s from privacy_default_list "
|
?SQL("select @(name)s from privacy_default_list "
|
||||||
"where username=%(LUser)s")).
|
"where username=%(LUser)s")).
|
||||||
|
|
||||||
get_privacy_list_names(LServer, LUser) ->
|
get_privacy_list_names(LServer, LUser) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(name)s from privacy_list"
|
?SQL("select @(name)s from privacy_list"
|
||||||
" where username=%(LUser)s")).
|
" where username=%(LUser)s")).
|
||||||
|
|
||||||
get_privacy_list_names_t(LUser) ->
|
get_privacy_list_names_t(LUser) ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("select @(name)s from privacy_list"
|
?SQL("select @(name)s from privacy_list"
|
||||||
" where username=%(LUser)s")).
|
" where username=%(LUser)s")).
|
||||||
|
|
||||||
get_privacy_list_id(LServer, LUser, Name) ->
|
get_privacy_list_id(LServer, LUser, Name) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(id)d from privacy_list"
|
?SQL("select @(id)d from privacy_list"
|
||||||
" where username=%(LUser)s and name=%(Name)s")).
|
" where username=%(LUser)s and name=%(Name)s")).
|
||||||
|
|
||||||
get_privacy_list_id_t(LUser, Name) ->
|
get_privacy_list_id_t(LUser, Name) ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("select @(id)d from privacy_list"
|
?SQL("select @(id)d from privacy_list"
|
||||||
" where username=%(LUser)s and name=%(Name)s")).
|
" where username=%(LUser)s and name=%(Name)s")).
|
||||||
|
|
||||||
get_privacy_list_data(LServer, LUser, Name) ->
|
get_privacy_list_data(LServer, LUser, Name) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(t)s, @(value)s, @(action)s, @(ord)d, @(match_all)b, "
|
?SQL("select @(t)s, @(value)s, @(action)s, @(ord)d, @(match_all)b, "
|
||||||
"@(match_iq)b, @(match_message)b, @(match_presence_in)b, "
|
"@(match_iq)b, @(match_message)b, @(match_presence_in)b, "
|
||||||
@ -530,7 +529,7 @@ get_privacy_list_data(LServer, LUser, Name) ->
|
|||||||
|
|
||||||
%% Not used?
|
%% Not used?
|
||||||
get_privacy_list_data_t(LUser, Name) ->
|
get_privacy_list_data_t(LUser, Name) ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("select @(t)s, @(value)s, @(action)s, @(ord)d, @(match_all)b, "
|
?SQL("select @(t)s, @(value)s, @(action)s, @(ord)d, @(match_all)b, "
|
||||||
"@(match_iq)b, @(match_message)b, @(match_presence_in)b, "
|
"@(match_iq)b, @(match_message)b, @(match_presence_in)b, "
|
||||||
"@(match_presence_out)b from privacy_list_data "
|
"@(match_presence_out)b from privacy_list_data "
|
||||||
@ -540,7 +539,7 @@ get_privacy_list_data_t(LUser, Name) ->
|
|||||||
"order by ord")).
|
"order by ord")).
|
||||||
|
|
||||||
get_privacy_list_data_by_id(LServer, ID) ->
|
get_privacy_list_data_by_id(LServer, ID) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(t)s, @(value)s, @(action)s, @(ord)d, @(match_all)b, "
|
?SQL("select @(t)s, @(value)s, @(action)s, @(ord)d, @(match_all)b, "
|
||||||
"@(match_iq)b, @(match_message)b, @(match_presence_in)b, "
|
"@(match_iq)b, @(match_message)b, @(match_presence_in)b, "
|
||||||
@ -548,7 +547,7 @@ get_privacy_list_data_by_id(LServer, ID) ->
|
|||||||
"where id=%(ID)d order by ord")).
|
"where id=%(ID)d order by ord")).
|
||||||
|
|
||||||
get_privacy_list_data_by_id_t(ID) ->
|
get_privacy_list_data_by_id_t(ID) ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("select @(t)s, @(value)s, @(action)s, @(ord)d, @(match_all)b, "
|
?SQL("select @(t)s, @(value)s, @(action)s, @(ord)d, @(match_all)b, "
|
||||||
"@(match_iq)b, @(match_message)b, @(match_presence_in)b, "
|
"@(match_iq)b, @(match_message)b, @(match_presence_in)b, "
|
||||||
"@(match_presence_out)b from privacy_list_data "
|
"@(match_presence_out)b from privacy_list_data "
|
||||||
@ -561,28 +560,28 @@ set_default_privacy_list(LUser, Name) ->
|
|||||||
"name=%(Name)s"]).
|
"name=%(Name)s"]).
|
||||||
|
|
||||||
unset_default_privacy_list(LServer, LUser) ->
|
unset_default_privacy_list(LServer, LUser) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("delete from privacy_default_list"
|
?SQL("delete from privacy_default_list"
|
||||||
" where username=%(LUser)s")).
|
" where username=%(LUser)s")).
|
||||||
|
|
||||||
remove_privacy_list(LUser, Name) ->
|
remove_privacy_list(LUser, Name) ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("delete from privacy_list where"
|
?SQL("delete from privacy_list where"
|
||||||
" username=%(LUser)s and name=%(Name)s")).
|
" username=%(LUser)s and name=%(Name)s")).
|
||||||
|
|
||||||
add_privacy_list(LUser, Name) ->
|
add_privacy_list(LUser, Name) ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("insert into privacy_list(username, name) "
|
?SQL("insert into privacy_list(username, name) "
|
||||||
"values (%(LUser)s, %(Name)s)")).
|
"values (%(LUser)s, %(Name)s)")).
|
||||||
|
|
||||||
set_privacy_list(ID, RItems) ->
|
set_privacy_list(ID, RItems) ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("delete from privacy_list_data where id=%(ID)d")),
|
?SQL("delete from privacy_list_data where id=%(ID)d")),
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun({SType, SValue, SAction, Order, MatchAll, MatchIQ,
|
fun({SType, SValue, SAction, Order, MatchAll, MatchIQ,
|
||||||
MatchMessage, MatchPresenceIn, MatchPresenceOut}) ->
|
MatchMessage, MatchPresenceIn, MatchPresenceOut}) ->
|
||||||
ejabberd_odbc:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("insert into privacy_list_data(id, t, "
|
?SQL("insert into privacy_list_data(id, t, "
|
||||||
"value, action, ord, match_all, match_iq, "
|
"value, action, ord, match_all, match_iq, "
|
||||||
"match_message, match_presence_in, match_presence_out) "
|
"match_message, match_presence_in, match_presence_out) "
|
||||||
@ -594,14 +593,14 @@ set_privacy_list(ID, RItems) ->
|
|||||||
RItems).
|
RItems).
|
||||||
|
|
||||||
del_privacy_lists(LServer, LUser) ->
|
del_privacy_lists(LServer, LUser) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("delete from privacy_list where username=%(LUser)s")),
|
?SQL("delete from privacy_list where username=%(LUser)s")),
|
||||||
%US = <<LUser/binary, "@", LServer/binary>>,
|
%US = <<LUser/binary, "@", LServer/binary>>,
|
||||||
%ejabberd_odbc:sql_query(
|
%ejabberd_sql:sql_query(
|
||||||
% LServer,
|
% LServer,
|
||||||
% ?SQL("delete from privacy_list_data where value=%(US)s")),
|
% ?SQL("delete from privacy_list_data where value=%(US)s")),
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("delete from privacy_default_list where username=%(LUser)s")).
|
?SQL("delete from privacy_default_list where username=%(LUser)s")).
|
||||||
|
|
||||||
@ -618,12 +617,12 @@ escape(C) -> <<C>>.
|
|||||||
|
|
||||||
%% Count number of records in a table given a where clause
|
%% Count number of records in a table given a where clause
|
||||||
count_records_where(LServer, Table, WhereClause) ->
|
count_records_where(LServer, Table, WhereClause) ->
|
||||||
ejabberd_odbc:sql_query(LServer,
|
ejabberd_sql:sql_query(LServer,
|
||||||
[<<"select count(*) from ">>, Table, <<" ">>,
|
[<<"select count(*) from ">>, Table, <<" ">>,
|
||||||
WhereClause, <<";">>]).
|
WhereClause, <<";">>]).
|
||||||
|
|
||||||
get_roster_version(LServer, LUser) ->
|
get_roster_version(LServer, LUser) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(version)s from roster_version"
|
?SQL("select @(version)s from roster_version"
|
||||||
" where username = %(LUser)s")).
|
" where username = %(LUser)s")).
|
||||||
@ -633,7 +632,7 @@ set_roster_version(LUser, Version) ->
|
|||||||
[<<"username">>, <<"version">>], [LUser, Version],
|
[<<"username">>, <<"version">>], [LUser, Version],
|
||||||
[<<"username = '">>, LUser, <<"'">>]).
|
[<<"username = '">>, LUser, <<"'">>]).
|
||||||
|
|
||||||
opt_type(odbc_type) ->
|
opt_type(sql_type) ->
|
||||||
fun (pgsql) -> pgsql;
|
fun (pgsql) -> pgsql;
|
||||||
(mysql) -> mysql;
|
(mysql) -> mysql;
|
||||||
(sqlite) -> sqlite;
|
(sqlite) -> sqlite;
|
||||||
@ -642,4 +641,4 @@ opt_type(odbc_type) ->
|
|||||||
end;
|
end;
|
||||||
opt_type(pgsql_users_number_estimate) ->
|
opt_type(pgsql_users_number_estimate) ->
|
||||||
fun (V) when is_boolean(V) -> V end;
|
fun (V) when is_boolean(V) -> V end;
|
||||||
opt_type(_) -> [odbc_type, pgsql_users_number_estimate].
|
opt_type(_) -> [sql_type, pgsql_users_number_estimate].
|
@ -86,7 +86,7 @@ do_init_per_group(redis, Config) ->
|
|||||||
mod_muc:shutdown_rooms(?REDIS_VHOST),
|
mod_muc:shutdown_rooms(?REDIS_VHOST),
|
||||||
set_opt(server, ?REDIS_VHOST, Config);
|
set_opt(server, ?REDIS_VHOST, Config);
|
||||||
do_init_per_group(mysql, Config) ->
|
do_init_per_group(mysql, Config) ->
|
||||||
case catch ejabberd_odbc:sql_query(?MYSQL_VHOST, [<<"select 1;">>]) of
|
case catch ejabberd_sql:sql_query(?MYSQL_VHOST, [<<"select 1;">>]) of
|
||||||
{selected, _, _} ->
|
{selected, _, _} ->
|
||||||
mod_muc:shutdown_rooms(?MYSQL_VHOST),
|
mod_muc:shutdown_rooms(?MYSQL_VHOST),
|
||||||
create_sql_tables(mysql, ?config(base_dir, Config)),
|
create_sql_tables(mysql, ?config(base_dir, Config)),
|
||||||
@ -95,7 +95,7 @@ do_init_per_group(mysql, Config) ->
|
|||||||
{skip, {mysql_not_available, Err}}
|
{skip, {mysql_not_available, Err}}
|
||||||
end;
|
end;
|
||||||
do_init_per_group(pgsql, Config) ->
|
do_init_per_group(pgsql, Config) ->
|
||||||
case catch ejabberd_odbc:sql_query(?PGSQL_VHOST, [<<"select 1;">>]) of
|
case catch ejabberd_sql:sql_query(?PGSQL_VHOST, [<<"select 1;">>]) of
|
||||||
{selected, _, _} ->
|
{selected, _, _} ->
|
||||||
mod_muc:shutdown_rooms(?PGSQL_VHOST),
|
mod_muc:shutdown_rooms(?PGSQL_VHOST),
|
||||||
create_sql_tables(pgsql, ?config(base_dir, Config)),
|
create_sql_tables(pgsql, ?config(base_dir, Config)),
|
||||||
@ -104,7 +104,7 @@ do_init_per_group(pgsql, Config) ->
|
|||||||
{skip, {pgsql_not_available, Err}}
|
{skip, {pgsql_not_available, Err}}
|
||||||
end;
|
end;
|
||||||
do_init_per_group(sqlite, Config) ->
|
do_init_per_group(sqlite, Config) ->
|
||||||
case catch ejabberd_odbc:sql_query(?SQLITE_VHOST, [<<"select 1;">>]) of
|
case catch ejabberd_sql:sql_query(?SQLITE_VHOST, [<<"select 1;">>]) of
|
||||||
{selected, _, _} ->
|
{selected, _, _} ->
|
||||||
mod_muc:shutdown_rooms(?SQLITE_VHOST),
|
mod_muc:shutdown_rooms(?SQLITE_VHOST),
|
||||||
set_opt(server, ?SQLITE_VHOST, Config);
|
set_opt(server, ?SQLITE_VHOST, Config);
|
||||||
@ -2248,7 +2248,7 @@ create_sql_tables(Type, BaseDir) ->
|
|||||||
SQLFile = filename:join([BaseDir, "sql", File]),
|
SQLFile = filename:join([BaseDir, "sql", File]),
|
||||||
CreationQueries = read_sql_queries(SQLFile),
|
CreationQueries = read_sql_queries(SQLFile),
|
||||||
DropTableQueries = drop_table_queries(CreationQueries),
|
DropTableQueries = drop_table_queries(CreationQueries),
|
||||||
case ejabberd_odbc:sql_transaction(
|
case ejabberd_sql:sql_transaction(
|
||||||
VHost, DropTableQueries ++ CreationQueries) of
|
VHost, DropTableQueries ++ CreationQueries) of
|
||||||
{atomic, ok} ->
|
{atomic, ok} ->
|
||||||
ok;
|
ok;
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
host_config:
|
host_config:
|
||||||
"pgsql.localhost":
|
"pgsql.localhost":
|
||||||
odbc_username: "@@pgsql_user@@"
|
sql_username: "@@pgsql_user@@"
|
||||||
odbc_type: pgsql
|
sql_type: pgsql
|
||||||
odbc_server: "@@pgsql_server@@"
|
sql_server: "@@pgsql_server@@"
|
||||||
odbc_port: @@pgsql_port@@
|
sql_port: @@pgsql_port@@
|
||||||
odbc_pool_size: 1
|
sql_pool_size: 1
|
||||||
odbc_password: "@@pgsql_pass@@"
|
sql_password: "@@pgsql_pass@@"
|
||||||
odbc_database: "@@pgsql_db@@"
|
sql_database: "@@pgsql_db@@"
|
||||||
auth_method: odbc
|
auth_method: sql
|
||||||
sm_db_type: odbc
|
sm_db_type: sql
|
||||||
modules:
|
modules:
|
||||||
mod_announce:
|
mod_announce:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
access: local
|
access: local
|
||||||
mod_blocking: []
|
mod_blocking: []
|
||||||
mod_caps:
|
mod_caps:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_last:
|
mod_last:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_muc:
|
mod_muc:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_offline:
|
mod_offline:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_privacy:
|
mod_privacy:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_private:
|
mod_private:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_pubsub:
|
mod_pubsub:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
access_createnode: pubsub_createnode
|
access_createnode: pubsub_createnode
|
||||||
ignore_pep_from_offline: true
|
ignore_pep_from_offline: true
|
||||||
last_item_cache: false
|
last_item_cache: false
|
||||||
@ -39,13 +39,13 @@ host_config:
|
|||||||
mod_roster:
|
mod_roster:
|
||||||
versioning: true
|
versioning: true
|
||||||
store_current_id: true
|
store_current_id: true
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_mam:
|
mod_mam:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_vcard:
|
mod_vcard:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_vcard_xupdate:
|
mod_vcard_xupdate:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_adhoc: []
|
mod_adhoc: []
|
||||||
mod_configure: []
|
mod_configure: []
|
||||||
mod_disco: []
|
mod_disco: []
|
||||||
@ -60,28 +60,28 @@ Welcome to this XMPP server."
|
|||||||
mod_time: []
|
mod_time: []
|
||||||
mod_version: []
|
mod_version: []
|
||||||
"sqlite.localhost":
|
"sqlite.localhost":
|
||||||
odbc_type: sqlite
|
sql_type: sqlite
|
||||||
auth_method: odbc
|
auth_method: sql
|
||||||
sm_db_type: odbc
|
sm_db_type: sql
|
||||||
modules:
|
modules:
|
||||||
mod_announce:
|
mod_announce:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
access: local
|
access: local
|
||||||
mod_blocking: []
|
mod_blocking: []
|
||||||
mod_caps:
|
mod_caps:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_last:
|
mod_last:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_muc:
|
mod_muc:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_offline:
|
mod_offline:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_privacy:
|
mod_privacy:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_private:
|
mod_private:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_pubsub:
|
mod_pubsub:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
access_createnode: pubsub_createnode
|
access_createnode: pubsub_createnode
|
||||||
ignore_pep_from_offline: true
|
ignore_pep_from_offline: true
|
||||||
last_item_cache: false
|
last_item_cache: false
|
||||||
@ -93,13 +93,13 @@ Welcome to this XMPP server."
|
|||||||
mod_roster:
|
mod_roster:
|
||||||
versioning: true
|
versioning: true
|
||||||
store_current_id: true
|
store_current_id: true
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_mam:
|
mod_mam:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_vcard:
|
mod_vcard:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_vcard_xupdate:
|
mod_vcard_xupdate:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_adhoc: []
|
mod_adhoc: []
|
||||||
mod_configure: []
|
mod_configure: []
|
||||||
mod_disco: []
|
mod_disco: []
|
||||||
@ -114,34 +114,34 @@ Welcome to this XMPP server."
|
|||||||
mod_time: []
|
mod_time: []
|
||||||
mod_version: []
|
mod_version: []
|
||||||
"mysql.localhost":
|
"mysql.localhost":
|
||||||
odbc_username: "@@mysql_user@@"
|
sql_username: "@@mysql_user@@"
|
||||||
odbc_type: mysql
|
sql_type: mysql
|
||||||
odbc_server: "@@mysql_server@@"
|
sql_server: "@@mysql_server@@"
|
||||||
odbc_port: @@mysql_port@@
|
sql_port: @@mysql_port@@
|
||||||
odbc_pool_size: 1
|
sql_pool_size: 1
|
||||||
odbc_password: "@@mysql_pass@@"
|
sql_password: "@@mysql_pass@@"
|
||||||
odbc_database: "@@mysql_db@@"
|
sql_database: "@@mysql_db@@"
|
||||||
auth_method: odbc
|
auth_method: sql
|
||||||
sm_db_type: odbc
|
sm_db_type: sql
|
||||||
modules:
|
modules:
|
||||||
mod_announce:
|
mod_announce:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
access: local
|
access: local
|
||||||
mod_blocking: []
|
mod_blocking: []
|
||||||
mod_caps:
|
mod_caps:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_last:
|
mod_last:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_muc:
|
mod_muc:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_offline:
|
mod_offline:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_privacy:
|
mod_privacy:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_private:
|
mod_private:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_pubsub:
|
mod_pubsub:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
access_createnode: pubsub_createnode
|
access_createnode: pubsub_createnode
|
||||||
ignore_pep_from_offline: true
|
ignore_pep_from_offline: true
|
||||||
last_item_cache: false
|
last_item_cache: false
|
||||||
@ -153,13 +153,13 @@ Welcome to this XMPP server."
|
|||||||
mod_roster:
|
mod_roster:
|
||||||
versioning: true
|
versioning: true
|
||||||
store_current_id: true
|
store_current_id: true
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_mam:
|
mod_mam:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_vcard:
|
mod_vcard:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_vcard_xupdate:
|
mod_vcard_xupdate:
|
||||||
db_type: odbc
|
db_type: sql
|
||||||
mod_adhoc: []
|
mod_adhoc: []
|
||||||
mod_configure: []
|
mod_configure: []
|
||||||
mod_disco: []
|
mod_disco: []
|
||||||
|
Loading…
Reference in New Issue
Block a user