xdb_sql and tranports

More Articles

Open Exam

Tiled JComponents

FTP security issues.

xdb_sql and transports, how to make them work together.

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 anyway and the example works with icqv7t (great work alex)

1. Databse Changes.

Let's start off by creating the table in mysql

		  username VARCHAR(32) PRIMARY KEY,
		  icq_id    VARCHAR(32) NOT NULL,
		  icq_pass  VARCHAR(32) NOT NULL

2. Modifying the querydef.

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">
	INSERT INTO icq VALUES ('$$user$$', '$$id$$', '$$pass$$')
	<bindvar attrib="id">$$id$$</bindvar>
	<bindvar attrib="pass">$$pass$$</bindvar>

<!-- icq removal query -->
	<querydef name="icq-remove" dtd="2" type="remove" namespace="icqtrans:data">
	DELETE FROM icq where username='$$user$$'

<!-- icq get query -->
	<querydef name="icq-get" dtd="2" type="get" namespace="icqtrans:data">
	SELECT icq_id, icq_pass  FROM icq WHERE username = '$$user$$'
	<bindcol attrib="username" offset="0"/>
	<bindcol attrib="password" offset="1"/>

3. Code Changes

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 files are attached. Please compare them with the original. Couple of new functions have been added to utils c and unknown.c gets a few lines of code.

4. Finishing up

Rebuild the transport and restart it.

all the best