Parcourir la source

handling notes for tuples:
- they are processed in PUBLISH handling - not tested
- they are stored in DB
- they are added to generated PIDF documents

Vaclav Kubart il y a 20 ans
Parent
commit
2cbeb3df22

+ 1 - 0
db/schema/ser.xml

@@ -69,6 +69,7 @@
     <xi:include href="presentity_notes.xml"/>
     <xi:include href="presentity_contact.xml"/>
     <xi:include href="watcherinfo.xml"/>
+    <xi:include href="tuple_notes.xml"/>
     
 	<!-- Resource-lists related tables -->
     <xi:include href="rls_subscription.xml"/>

+ 44 - 0
db/schema/tuple_notes.xml

@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE table PUBLIC "-//iptel.org//DTD DBSchema V1.0//EN"
+  "http://iptel.org/dbschema/dtd/1.0/dbschema.dtd" [
+
+<!ENTITY % entities SYSTEM "entities.xml">
+%entities;
+
+]>
+
+<table role="presence"
+    xmlns:db="http://docbook.org/ns/docbook"
+    xmlns:my="http://iptel.org/dbschema/mysql"
+    xmlns:pg="http://iptel.org/dbschema/postgres"
+    xmlns:dt="http://iptel.org/dbschema/dbtext">
+    <name>tuple_notes</name>
+    <version>1</version>
+    
+	<!-- foreign key (presid, tupleid -> presentity_contant) -->
+	
+    <column>
+		<name>presid</name>
+		<type>unsigned int</type>
+		<size>10</size>
+    </column>
+    
+	<column>
+		<name>tupleid</name>
+		<type>string</type>
+		<size>64</size>
+    </column>
+    
+	<column>
+		<name>note</name>
+		<type>string</type>
+		<size>128</size>
+    </column>
+	
+	<column>
+		<name>lang</name>
+		<type>string</type>
+		<size>64</size>
+    </column>
+    
+</table>

+ 27 - 3
lib/presence/pidf.c

@@ -33,9 +33,27 @@
 
 /* ------------------------------ PIDF document creation ------------------------------ */
 
+static void doc_add_tuple_note(dstring_t *buf, presence_note_t *n)
+{
+	DEBUG_LOG("doc_add_tuple_note()\n");
+	
+	dstr_append_zt(buf, "\t\t<note");
+	if (n->lang.len > 0) {
+		dstr_append_zt(buf, " lang=\"");
+		dstr_append_str(buf, &n->lang);
+		dstr_append_zt(buf, "\"");
+	}
+	dstr_append_zt(buf, ">");
+	dstr_append_str(buf, &n->value);	
+	dstr_append_zt(buf, "</note>\r\n");
+}
+
+
 static void doc_add_tuple(dstring_t *buf, presentity_info_t *p, presence_tuple_info_t *t)
 {
+	presence_note_t *n;
 	char tmp[32];
+	
 	DEBUG_LOG("doc_add_tuple()\n");
 	
 	dstr_append_zt(buf, "\t<tuple id=\"");
@@ -52,13 +70,19 @@ static void doc_add_tuple(dstring_t *buf, presentity_info_t *p, presence_tuple_i
 	dstr_append_str(buf, &t->contact);
 	dstr_append_zt(buf, "</contact>\r\n");
 
+	n = t->first_note;
+	while (n) {
+		doc_add_tuple_note(buf, n);
+		n = n->next;
+	}
+	
 	dstr_append_zt(buf, "\t</tuple>\r\n");
 }
 
 static void doc_add_empty_tuple(dstring_t *buf)
 {
 	/* "empty" tuple is needed in PIDF by Microsoft Windows Messenger v. 5.1) */
-	DEBUG_LOG("doc_add_tuple()\n");
+	DEBUG_LOG("doc_add_empty_tuple()\n");
 	
 	dstr_append_zt(buf, "\t<tuple id=\"none\">\r\n");
 	dstr_append_zt(buf, "\t\t<status><basic>closed</basic></status>\r\n");
@@ -68,7 +92,7 @@ static void doc_add_empty_tuple(dstring_t *buf)
 
 static void doc_add_note(dstring_t *buf, presentity_info_t *p, presence_note_t *n)
 {
-	DEBUG_LOG("doc_add_tuple()\n");
+	DEBUG_LOG("doc_add_note()\n");
 	
 	dstr_append_zt(buf, "\t<note");
 	if (n->lang.len > 0) {
@@ -282,7 +306,7 @@ static int read_presentity(xmlNode *root, presentity_info_t **dst, int ignore_ns
 	int res = 0;
 	char *ns = ignore_ns ? NULL: pidf_ns;
 	
-	DEBUG_LOG("read_presentity()\n");
+	DEBUG_LOG("read_presentity(ns=%s)\n", ns ? ns : "");
 	if (cmp_node(root, "presence", ns) < 0) {
 		ERROR_LOG("document is not presence \n");
 		return -1;

+ 7 - 0
scripts/mysql/my_create.sql

@@ -347,6 +347,13 @@ CREATE TABLE watcherinfo (
     KEY wi_wuri_idx (w_uri)
 );
 
+CREATE TABLE tuple_notes (
+    presid INT(10) UNSIGNED NOT NULL,
+    tupleid VARCHAR(64) NOT NULL,
+    note VARCHAR(128) NOT NULL,
+    lang VARCHAR(64) NOT NULL
+);
+
 CREATE TABLE rls_subscription (
     id VARCHAR(48) NOT NULL,
     doc_version INT NOT NULL,

+ 7 - 0
scripts/oracle/or_create.sql

@@ -330,6 +330,13 @@ CREATE TABLE watcherinfo (
 
 );
 
+CREATE TABLE tuple_notes (
+    presid int(10) NOT NULL,
+    tupleid string(64) NOT NULL,
+    note string(128) NOT NULL,
+    lang string(64) NOT NULL
+);
+
 CREATE TABLE rls_subscription (
     id string(48) NOT NULL,
     doc_version int NOT NULL,

+ 7 - 0
scripts/postgres/pg_create.sql

@@ -361,6 +361,13 @@ CREATE TABLE watcherinfo (
 CREATE INDEX wi_ruri_idx ON watcherinfo (r_uri);
 CREATE INDEX wi_wuri_idx ON watcherinfo (w_uri);
 
+CREATE TABLE tuple_notes (
+    presid INTEGER NOT NULL,
+    tupleid VARCHAR(64) NOT NULL,
+    note VARCHAR(128) NOT NULL,
+    lang VARCHAR(64) NOT NULL
+);
+
 CREATE TABLE rls_subscription (
     id VARCHAR(48) NOT NULL,
     doc_version INTEGER NOT NULL,