+ {{Indicate the meaning of this image, and click OK.}}
+ }
+}
+
+proc approve_showentry_xinfo/pixmap {w def} {
+ label $w -image image/empty
+}
+
+#========== UPLOADS TO DICTIONARY SERVER ==========
+
+proc upload_init {} {
+ global privacy_setting
+
+ set privacy_setting [upload_status]
+
+ label .privacy.warn -text " Privacy "
+ if {$privacy_setting} {
+ .privacy.warn configure -background yellow -foreground black
+ }
+ label .privacy.overall -text " Upload new dictionary entry:"
+ label .privacy.reference -text " See README.privacy."
+
+ pack .privacy.warn .privacy.overall -side left
+
+ foreach {setting string} {
+ 0 {No}
+ 1 {Yes, anonymously}
+ 2 {Yes, quoting my pirate name.}
+ } {
+ radiobutton .privacy.o$setting -text $string \
+ -value $setting -variable privacy_setting
+ pack .privacy.o$setting -side left
+ if {$setting > $privacy_setting} {
+ .privacy.o$setting configure -state disabled
+ }
+ }
+ pack .privacy.reference -side left
+
+ if {!$privacy_setting} {
+ foreach w [winfo children .privacy] {
+ $w configure -state disabled
+ }
+ }
+ if {$privacy_setting} {
+ package require http
+ ::http::config -urlencoding utf-8
+ }
+}
+
+proc upload_status {} {
+ # returns 0, 1, 2 for none, anon, with pirate name
+ global env
+
+ if {![info exists env(YPPSC_PCTB_DICT_SUBMIT)]} { debug a; return 0 }
+ if {![string compare 0 $env(YPPSC_PCTB_DICT_SUBMIT)]} { debug b; return 0 }
+
+ if {![info exists env(YPPSC_PIRATE)]} { return 1 }
+ if {![info exists env(YPPSC_OCEAN)]} { return 1 }
+ if {![string length $env(YPPSC_PIRATE)]} { return 1 }
+ if {![string length $env(YPPSC_OCEAN)]} { return 1 }
+
+ return 2
+}
+
+proc maybe_upload_entry {im def} {
+ global reqkind privacy_setting env dbname quiet
+
+ debug "DB-UPDATE PRIVACY $privacy_setting"
+ if {!$privacy_setting} return
+
+ debug "DB-UPDATE UPLOADING"
+
+ set pl {}
+ lappend pl dict $dbname
+
+ if {$privacy_setting>=2} {
+ set pirate [string totitle $env(YPPSC_PIRATE)]
+ set ocean [string totitle $env(YPPSC_OCEAN)]
+ debug "DB-UPDATE NON-ANON $ocean $pirate"
+ lappend pl \
+ pirate $pirate \
+ ocean $ocean
+ }
+ lappend pl entry [format_database_entry/$reqkind $im $def]
+
+ set url $env(YPPSC_PCTB_DICT_SUBMIT)
+ append url dictionary-update-receiver
+
+ set query [eval ::http::formatQuery $pl]
+ regsub -all {%0d} $query {} query
+ debug "DB-UPDATE QUERY $query"
+
+ if {[regexp {^\.?/} $url]} {
+ set cmd [list $url $query]
+ debug "SUBMIT CMD [string range $cmd 0 200]..."
+ set body [eval exec $cmd 2>@ stderr]
+ regsub {^Content-Type: text/plain.*\n\n} $body {} body
+ } else {
+
+ if {[catch {
+ set req [::http::geturl $url -query $query]
+ } emsg]} {
+ puts stderr \
+ "\nWARNING: Cannot do dictionary upload: $emsg\n"
+ return
+ }
+ upvar #0 $req s
+ debug "DB-UPDATE DONE $req $s(status) [array names s]"
+ set ncode [::http::ncode $req]
+
+ if {!(![string compare ok $s(status)] &&
+ ![string compare 200 $ncode])} {
+ set m "\nWARNING: Dictionary upload failed:"
+ foreach v {status http error posterror} {
+ if {[info exists s($v)]} { append m "\n $v: $s($v)" }
+ }
+ puts stderr $m
+ return
+ }
+ set body $s(body)
+ ::http::cleanup $req
+ }
+
+ if {![string match {OK *} $body]} {
+ set m "\nWARNING: Dictionary upload went wrong:\n"
+ append m "\n " [join [split $body "\n"] "\n "]
+ puts stderr $m
+ return
+ }
+
+ if {!$quiet} {
+ puts stderr \
+ "Uploaded $dbname `$def': $body"