[Tkabber-dev] r1364 - branches/xml-import-export/plugins/roster

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Thu Jan 31 04:38:24 MSK 2008


Author: kostix
Date: 2008-01-31 04:38:22 +0300 (Thu, 31 Jan 2008)
New Revision: 1364

Added:
   branches/xml-import-export/plugins/roster/TODO
Modified:
   branches/xml-import-export/plugins/roster/backup.tcl
   branches/xml-import-export/plugins/roster/bkup_conferences.tcl
   branches/xml-import-export/plugins/roster/conferences.tcl
Log:
roster/backup.tcl: NS made a global variable, removed unneeded
 procedure [xml_parse_roster_item].

roster/conferences.tcl: Fixed semantics for merging bookmark groups.

roster/bkup_conferences.tcl: Misc code cleanup.

roster/TODO: Added new file to track ongoing tasks for this branch.

Importing of MUC bookmarks and their groups now works.
It turned out that importing of roster annotations doesn't play
well with importing of roster items since they must be in the roster
for their corresponding annotations to be successfully processed.


Added: branches/xml-import-export/plugins/roster/TODO
===================================================================
--- branches/xml-import-export/plugins/roster/TODO	                        (rev 0)
+++ branches/xml-import-export/plugins/roster/TODO	2008-01-31 01:38:22 UTC (rev 1364)
@@ -0,0 +1,10 @@
+* Roster notes aren't added because they are fetched and matched
+  against the roster items before the latter are pushed back
+  from the server (race condition).
+
+  Probably we should send all the things fetched from a backup
+  file at once, after the parsing.
+
+  Or we should make certain all roster contacts are sent to the
+  server and pushed back, then manipulate roster notes.
+


Property changes on: branches/xml-import-export/plugins/roster/TODO
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: branches/xml-import-export/plugins/roster/backup.tcl
===================================================================
--- branches/xml-import-export/plugins/roster/backup.tcl	2008-01-30 19:19:09 UTC (rev 1363)
+++ branches/xml-import-export/plugins/roster/backup.tcl	2008-01-31 01:38:22 UTC (rev 1364)
@@ -7,10 +7,8 @@
 # such as conference bookmarks, annotations, etc.
 
 namespace eval rosterbackup {
-    variable NS; array set NS {
-	root   http://tkabber.jabber.ru/contactlist
-	roster jabber:iq:roster
-    }
+    global NS
+    set NS(rosterbackup) http://tkabber.jabber.ru/contactlist
 
     hook::add connected_hook \
 	[namespace current]::setup_import_export_menus
@@ -83,13 +81,13 @@
 ###############################################################################
 
 proc rosterbackup::serialize_roster {connid} {
-    variable NS
+    global NS
 
     set subtags [list]
     hook::run serialize_roster_hook $connid #[info level] subtags
 
     jlib::wrapper:createxml [jlib::wrapper:createtag contactlist \
-	    -vars [list xmlns $NS(root)] -subtags $subtags] \
+	    -vars [list xmlns $NS(rosterbackup)] -subtags $subtags] \
 	-prettyprint 1
 }
 
@@ -152,7 +150,7 @@
 ###############################################################################
 
 proc rosterbackup::parse_roster_xml {connid data} {
-    variable NS
+    global NS
 
     jlib::wrapper:splitxml $data tag vars isempty cdata children
 
@@ -161,9 +159,9 @@
 	    must be contactlist"
     }
     set xmlns [jlib::wrapper:getattr $vars xmlns]
-    if {![string equal $xmlns $NS(root)]} {
+    if {![string equal $xmlns $NS(rosterbackup)]} {
 	return -code error "Bad root element namespace \"$xmlns\":\
-	    must be \"$NS(root)\""
+	    must be \"$NS(rosterbackup)\""
     }
 
     foreach child $children {
@@ -174,7 +172,7 @@
 ###############################################################################
 
 proc rosterbackup::deserialize_roster_contacts {connid data} {
-    variable NS
+    global NS
 
     jlib::wrapper:splitxml $data tag vars isempty cdata children
 
@@ -209,41 +207,4 @@
     jlib::wrapper:getattr $vars jid
 }
 
-###############################################################################
-
-# TODO drop it
-proc rosterbackup::xml_parse_roster_item {data} {
-    jlib::wrapper:splitxml $data tag vars isempty cdata children
-
-    set out [list]
-
-    foreach child $children {
-	jlib::wrapper:splitxml $child ctag cvars cisempty ccdata cchildren
-
-	set vars [list jid [jlib::wrapper:getattr $cvars jid]]
-
-	foreach item {name subscription ask} {
-	    set val [jlib::wrapper:getattr $cvars $item]
-	    if {$val != ""} {
-		lappend vars $item $val]
-	    }
-	}
-
-	set grtags [list]
-	foreach subchild $cchildren {
-	    jlib::wrapper:splitxml $subchild subtag tmp tmp subcdata tmp
-
-	    switch -- $subtag {
-		group {
-		    lappend grtags [jlib::wrapper:createtag group -chdata $subchdata]
-		}
-	    }
-	}
-
-	lappend out [jlib::wrapper:createtag item -vars $vars -subtags $grtags]
-    }
-
-    set out
-}
-
 # vim:ts=8:sw=4:sts=4:noet

Modified: branches/xml-import-export/plugins/roster/bkup_conferences.tcl
===================================================================
--- branches/xml-import-export/plugins/roster/bkup_conferences.tcl	2008-01-30 19:19:09 UTC (rev 1363)
+++ branches/xml-import-export/plugins/roster/bkup_conferences.tcl	2008-01-31 01:38:22 UTC (rev 1364)
@@ -3,7 +3,7 @@
 # Depends on: conferences.tcl, backup.tcl
 
 namespace eval mucbackup {
-    variable updated; array set updated {}
+    variable updated
 
     # Should probably go after the roster contacts, so we set prio to 70:
     hook::add serialize_roster_hook \

Modified: branches/xml-import-export/plugins/roster/conferences.tcl
===================================================================
--- branches/xml-import-export/plugins/roster/conferences.tcl	2008-01-30 19:19:09 UTC (rev 1363)
+++ branches/xml-import-export/plugins/roster/conferences.tcl	2008-01-31 01:38:22 UTC (rev 1364)
@@ -135,9 +135,9 @@
 	set bookmarks($connid,password,$jid) ""
 	if {![info exists bookmarks($connid,groups,$jid)]} {
 	    set bookmarks($connid,groups,$jid) {}
-	    set bookmarks($connid,rcvdgroups,$jid) 0
+	    set bookmarks($connid,hasgroups,$jid) 0
 	} else {
-	    set bookmarks($connid,rcvdgroups,$jid) 1
+	    set bookmarks($connid,hasgroups,$jid) 1
 	}
 
 	set autojoin [jlib::wrapper:getattr $bvars autojoin]
@@ -187,11 +187,12 @@
 	}
     }
 
-    if {$merge && !([info exists bookmarks($connid,jid,$jid)]
-		&& $bookmarks($connid,rcvdgroups,$jid))} {
+    if {$merge && [info exists bookmarks($connid,jid,$jid)]
+		&& $bookmarks($connid,hasgroups,$jid)} {
 	return 0
     } else {
 	set bookmarks($connid,groups,$jid) $groups
+	set bookmarks($connid,hasgroups,$jid) 1
 	return 1
     }
 }
@@ -499,7 +500,7 @@
     set bookmarks($connid,password,$jid) $password
     set bookmarks($connid,autojoin,$jid) $autojoin
     set bookmarks($connid,groups,$jid) $groups
-    set bookmarks($connid,rcvdgroups,$jid) 1
+    set bookmarks($connid,hasgroups,$jid) 1
 
     # TODO should we remove $jid from the roster if it is here?
     client:roster_push $connid $jid $name $groups bookmark ""
@@ -596,6 +597,7 @@
     catch { unset bookmarks($connid,password,$jid) }
     catch { unset bookmarks($connid,autojoin,$jid) }
     catch { unset bookmarks($connid,groups,$jid) }
+    catch { unset bookmarks($connid,hasgroups,$jid) }
 
     store_bookmarks $connid
 



More information about the Tkabber-dev mailing list