[JDEV] hack to make transports work with xdb_sql
raditha dissanayake
jabber at raditha.com
Thu Oct 24 21:44:52 CDT 2002
hi guys,
We've been having posts on and off about using xdb_sql with transports.
Here is a plain old hack to
make xdb_sql work with transports other than yahoo. Most of it is
inspired by the yahoo transport
and the example works with icqv7t 0.3.0 (great work alex)
1. Let's start off by creating the table in mysql
CREATE TABLE icq (
username VARCHAR(32) PRIMARY KEY,
icq_id VARCHAR(32) NOT NULL,
icq_pass VARCHAR(32) NOT NULL
);
2. then you need to create the query defs in xdb_sql.xml try adding the
following island. Since
we are using v2 queries we don't need to code any validation functions
<!-- icq set query -->
<querydef name="icq-set" dtd="2" type="set" namespace="icqtrans:data">
<text>
INSERT INTO icq VALUES ('$$user$$', '$$id$$', '$$pass$$')
</text>
<user>$$user$$</user>
<bindvar attrib="id">$$id$$</bindvar>
<bindvar attrib="pass">$$pass$$</bindvar>
<purge>icq-remove</purge>
</querydef>
<!-- icq removal query -->
<querydef name="icq-remove" dtd="2" type="remove"
namespace="icqtrans:data">
<text>
DELETE FROM icq where username='$$user$$'
</text>
<user>$$user$$</user>
</querydef>
<!-- icq get query -->
<querydef name="icq-get" dtd="2" type="get" namespace="icqtrans:data">
<text>
SELECT icq_id, icq_pass FROM icq WHERE username = '$$user$$'
</text>
<user>$$user$$</user>
<top-result>
<logon/>
</top-result>
<bindcol attrib="username" offset="0"/>
<bindcol attrib="password" offset="1"/>
</querydef>
3. Then you need to make changes to the actual code. Since it would be
nice if the transport continued
to work with xdb_file i have used an #ifdef, so that means you will need
to add a -Dsql to your makefile
if you want to use it with xdb_sql.
The actual changes are to jabberd/utils.c and jabbered/unknown.c. The
two files are attached. Please compare
them with the original. Couple of new functions have been added to utils
c while unknown.c gets a few
lines of code inserted.
4. make the transport and restart it.
all the best
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: utils.c
URL: <http://mail.jabber.org/pipermail/jdev/attachments/20021024/cfba0a36/attachment-0003.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: unkown.c
URL: <http://mail.jabber.org/pipermail/jdev/attachments/20021024/cfba0a36/attachment-0001.asc>
More information about the JDev
mailing list