25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

* src/mod_vcard_odbc: added vCard support for MS SQL Server 2005 (missing from previous commit)

SVN Revision: 1596
This commit is contained in:
Jérôme Sautret 2008-10-03 15:30:56 +00:00
parent 8883e4ad8b
commit 744b827169

View File

@ -16,7 +16,7 @@
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%%% General Public License for more details.
%%%
%%%
%%% You should have received a copy of the GNU General Public License
%%% along with this program; if not, write to the Free Software
%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
@ -96,7 +96,7 @@ stop(Host) ->
get_sm_features({error, _Error} = Acc, _From, _To, _Node, _Lang) ->
Acc;
get_sm_features(Acc, _From, _To, Node, _Lang) ->
case Node of
[] ->
@ -148,10 +148,7 @@ process_sm_iq(From, To, #iq{type = Type, sub_el = SubEl} = IQ) ->
get ->
#jid{luser = LUser, lserver = LServer} = To,
Username = ejabberd_odbc:escape(LUser),
case catch ejabberd_odbc:sql_query(
LServer,
["select vcard from vcard "
"where username='", Username, "';"]) of
case catch odbc_queries:get_vcard(LServer, Username) of
{selected, ["vcard"], [{SVCARD}]} ->
case xml_stream:parse_element(SVCARD) of
{error, _Reason} ->
@ -244,30 +241,13 @@ set_vcard(User, LServer, VCARD) ->
SOrgUnit = ejabberd_odbc:escape(OrgUnit),
SLOrgUnit = ejabberd_odbc:escape(LOrgUnit),
ejabberd_odbc:sql_transaction(
LServer,
[["delete from vcard where username='", LUsername, "';"],
["insert into vcard(username, vcard) "
"values ('", LUsername, "', '", SVCARD, "');"],
["delete from vcard_search where lusername='", LUsername, "';"],
["insert into vcard_search("
" username, lusername, fn, lfn, family, lfamily,"
" given, lgiven, middle, lmiddle, nickname, lnickname,"
" bday, lbday, ctry, lctry, locality, llocality,"
" email, lemail, orgname, lorgname, orgunit, lorgunit)"
"values (",
" '", Username, "', '", LUsername, "',"
" '", SFN, "', '", SLFN, "',"
" '", SFamily, "', '", SLFamily, "',"
" '", SGiven, "', '", SLGiven, "',"
" '", SMiddle, "', '", SLMiddle, "',"
" '", SNickname, "', '", SLNickname, "',"
" '", SBDay, "', '", SLBDay, "',"
" '", SCTRY, "', '", SLCTRY, "',"
" '", SLocality, "', '", SLLocality, "',"
" '", SEMail, "', '", SLEMail, "',"
" '", SOrgName, "', '", SLOrgName, "',"
" '", SOrgUnit, "', '", SLOrgUnit, "');"]])
odbc_queries:set_vcard(LServer, LUsername, SBDay, SCTRY, SEMail,
SFN, SFamily, SGiven, SLBDay, SLCTRY,
SLEMail, SLFN, SLFamily, SLGiven,
SLLocality, SLMiddle, SLNickname,
SLOrgName, SLOrgUnit, SLocality,
SMiddle, SNickname, SOrgName,
SOrgUnit, SVCARD, Username)
end.
-define(TLFIELD(Type, Label, Var),
@ -392,7 +372,7 @@ do_route(ServerHost, From, To, Packet) ->
Packet, ?ERR_NOT_ALLOWED),
ejabberd_router:route(To, From, Err);
get ->
ResIQ =
ResIQ =
IQ#iq{type = result,
sub_el = [{xmlelement,
"query",
@ -403,7 +383,7 @@ do_route(ServerHost, From, To, Packet) ->
jlib:iq_to_xml(ResIQ))
end;
#iq{type = get, xmlns = ?NS_VCARD, lang = Lang} ->
ResIQ =
ResIQ =
IQ#iq{type = result,
sub_el = [{xmlelement,
"vCard",
@ -635,18 +615,18 @@ make_val(Match, Field, Val) ->
% true ->
% mnesia:write(
% #vcard_search{us = US,
% user = User, luser = LUser,
% fn = FN, lfn = LFN,
% family = Family, lfamily = LFamily,
% given = Given, lgiven = LGiven,
% middle = Middle, lmiddle = LMiddle,
% nickname = Nickname, lnickname = LNickname,
% bday = BDay, lbday = LBDay,
% ctry = CTRY, lctry = LCTRY,
% locality = Locality, llocality = LLocality,
% email = EMail, lemail = LEMail,
% orgname = OrgName, lorgname = LOrgName,
% orgunit = OrgUnit, lorgunit = LOrgUnit
% user = User, luser = LUser,
% fn = FN, lfn = LFN,
% family = Family, lfamily = LFamily,
% given = Given, lgiven = LGiven,
% middle = Middle, lmiddle = LMiddle,
% nickname = Nickname, lnickname = LNickname,
% bday = BDay, lbday = LBDay,
% ctry = CTRY, lctry = LCTRY,
% locality = Locality, llocality = LLocality,
% email = EMail, lemail = LEMail,
% orgname = OrgName, lorgname = LOrgName,
% orgunit = OrgUnit, lorgunit = LOrgUnit
% })
% end.
%
@ -666,5 +646,3 @@ remove_user(User, Server) ->
LServer,
[["delete from vcard where username='", Username, "';"],
["delete from vcard_search where lusername='", Username, "';"]]).