[Tkabber-dev] r448 - in trunk/plugins/vimage: . msgs

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Tue Dec 28 11:26:59 MSK 2010


Author: Rejjin
Date: 2010-12-28 11:26:59 +0300 (Tue, 28 Dec 2010)
New Revision: 448

Modified:
   trunk/plugins/vimage/msgs/ru.msg
   trunk/plugins/vimage/vimage.tcl
Log:
Deactivate the automatic opening image, if chat is inactive. Added option "auto reload image when error". Fixed bug in regexp.

Modified: trunk/plugins/vimage/msgs/ru.msg
===================================================================
--- trunk/plugins/vimage/msgs/ru.msg	2010-12-28 07:14:38 UTC (rev 447)
+++ trunk/plugins/vimage/msgs/ru.msg	2010-12-28 08:26:59 UTC (rev 448)
@@ -21,4 +21,5 @@
 ::msgcat::mcset ru "Vimage colors options" "Настройки цветовых стилей Vimage"
 ::msgcat::mcset ru "Background color of downloading urls." "Цвет фона загружаемых ссылок."
 ::msgcat::mcset ru "Background color of downloaded urls." "Цвет фона загруженных ссылок."
-::msgcat::mcset ru "Background color of don't downloaded urls. (with error)" "Цвет фона ссылок, загруженных с ошибкой."
\ No newline at end of file
+::msgcat::mcset ru "Background color of don't downloaded urls. (with error)" "Цвет фона ссылок, загруженных с ошибкой."
+::msgcat::mcset ru "Reload image when error." "Автоматическая перезагрузка скачивания при ошибке."
\ No newline at end of file

Modified: trunk/plugins/vimage/vimage.tcl
===================================================================
--- trunk/plugins/vimage/vimage.tcl	2010-12-28 07:14:38 UTC (rev 447)
+++ trunk/plugins/vimage/vimage.tcl	2010-12-28 08:26:59 UTC (rev 448)
@@ -58,7 +58,7 @@
 	return
 	}
 
-	set map [format {^(http\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(?:\/\S*)?(?:[a-zA-Z0-9_])+\.(?:%s))$} $extensions]
+	set map [format {^(http\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,4}(?:\/\S*)?(?:[a-zA-Z0-9_])+\.(?:%s))$} $extensions]
 	set matched [regexp -inline -nocase -all -- $map $body]
 	set chatwin [chat::chat_win $chatid]
 	
@@ -122,8 +122,10 @@
 }
 
 proc vimage::Location_handle { url } {
-
-	set token [http::geturl $url -validate 1]
+	
+	if {[catch {set token [http::geturl $url -validate 1]}]} {
+	return error
+	}
 	foreach {type value} [http::meta $token] {
 	if {$type eq "Location"} { return $value }
 	}
@@ -168,6 +170,7 @@
 proc vimage::image_create { chatwin url } {
 	variable images
 	variable options
+	variable reloaded
 	
 	if { ![info exist images($url,full)] } {
 		set images($url,data) [base64::encode $images($url,data)]
@@ -177,15 +180,22 @@
 				change_state_url $url $chatwin error
 				return
 		}
-		if { $options(auto_show_image) } {
-			image_full_show $url
+		if { $options(auto_show_image) && \
+			[string equal -length 40 $chatwin [focus]]} {
+				image_full_show $url
 		}
 		return
 	}
 	
 	if { $images($url,full) eq "error" } {
+		if {$options(reload_when_error) && [info exist reloaded($url)] \
+			&& $reloaded($url)} {
+			image_process $url $chatwin reload
+			set reloaded($url) 1
+			return
+		}
 		change_state_url $url $chatwin error
-		return
+		set eloaded($url) 0
 	}
 	
 	if { $images($url,full) eq "large" } {
@@ -483,4 +493,8 @@
 	custom::defvar options(max_size) 50 \
 	[::msgcat::mc "Maximum size of content (kb)."] \
 	-type string -group Vimage	
+	
+	custom::defvar options(reload_when_error) 1 \
+		[::msgcat::mc "Reload image when error."] \
+		-type boolean -group Vimage
 }
\ No newline at end of file



More information about the Tkabber-dev mailing list