⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loging.tcl

📁 Linux下的MSN聊天程序源码
💻 TCL
📖 第 1 页 / 共 4 页
字号:
		$wname.search hide		$wname.search bindwindow $wname		if { [file exists [file join ${log_dir} ${email}.log]] == 1 } {			set id [open "[file join ${log_dir} ${email}.log]" r]			fconfigure $id -encoding utf-8			set logvar [read $id]			close $id		} else {			set logvar "\|\"LRED[trans nologfile $email]"		}		frame $wname.top.contact  -class Amsn -borderwidth 0		combobox::combobox $wname.top.contact.list -editable true -highlightthickness 0 -width 22 -bg #FFFFFF -font splainf		$wname.top.contact.list list delete 0 end		foreach contact $sortedcontact_list {			$wname.top.contact.list list insert end $contact		}		#Get all the list		set list [$wname.top.contact.list list get 0 end]		#Do a search in that list to find where is exactly the email we need		set exactMatch [lsearch -exact $list $email]		#Select the email in the list when we open the window with the result of the search		$wname.top.contact.list select $exactMatch		$wname.top.contact.list configure -command "::log::ChangeLogWin $wname $email"		$wname.top.contact.list configure -editable false		pack $wname.top.contact.list -side left		pack $wname.top.contact -side left		::log::LogsByDate $wname $email "1"		ParseLog $wname $logvar		button $wname.buttons.close -text "[trans close]" -command "destroy $wname"		button $wname.buttons.stats -text "[trans stats]" -command "::log::stats"		button $wname.buttons.save -text "[trans savetofile]" -command "::log::SaveToFile ${wname} ${email} [list ${logvar}]"		button $wname.buttons.clear -text "[trans clearlog]" \		    -command "if { !\[winfo exists $wname.top.date.list\] } { \				                    set date \".\" \				              } else {				                    set date \[$wname.top.date.list list get \[$wname.top.date.list curselection\]\]\					      }                                              if { \[::log::ClearLog $email \"\$date\"\] } { 				                    destroy $wname			         	      }" \		    		menu ${wname}.copypaste -tearoff 0 -type normal		${wname}.copypaste add command -label [trans copy] -command "tk_textCopy ${wname}.blueframe.log.txt"				pack $wname.top -side top -fill x		pack $wname.blueframe.log.ys -side right -fill y		pack $wname.blueframe.log.txt -side left -expand true -fill both		pack $wname.blueframe.log -side top -expand true -fill both -padx 4 -pady 4		pack $wname.blueframe -side top -expand true -fill both		pack $wname.buttons.close -padx 0 -side left		pack $wname.buttons.stats -padx 0 -side right		pack $wname.buttons.save -padx 0 -side right		pack $wname.buttons.clear -padx 0 -side right		pack $wname.buttons -side bottom -fill x -pady 3		bind $wname <<Escape>> "destroy $wname"		bind ${wname}.blueframe.log.txt <<Button3>> "tk_popup ${wname}.copypaste %X %Y"		bind ${wname} <Control-c> "tk_textCopy ${wname}.blueframe.log.txt"		moveinscreen $wname 30	}	proc OpenCamLogWin { {email ""} } {		global webcam_dir langenc logvar		#Get all the contacts		foreach contact [::abook::getAllContacts] {			#Selects the contacts who are in our list and adds them to the contact_list			if {[string last "FL" [::abook::getContactData $contact lists]] != -1} {				lappend contact_list $contact			}		}		#Sorts contacts		set sortedcontact_list [lsort -dictionary $contact_list]		#If there is no email defined, we remplace it by the first email in the dictionary order		if {$email == ""} {			set email [lindex $sortedcontact_list 0]		}				set wname [::log::cam_wname $email]		if { [catch {toplevel ${wname} -borderwidth 0 -highlightthickness 0 } res ] } {			raise ${wname}			focus ${wname}			wm deiconify ${wname}			return 0		}		wm group ${wname} .		if { [file exists [file join ${webcam_dir} ${email}.cam]] } {			set fsize [file size [file join ${webcam_dir} ${email}.cam]]			set size "[::amsn::sizeconvert ${fsize}]o"			set exists normal		} else {			set exists disabled			set size "0Ko"		}		wm title $wname "[trans webcamhistory] (${email} - $size)"				frame $wname.top		#No ugly blue frame on Mac OS X, system already put a border around windows		if {![catch {tk windowingsystem} wsystem] && $wsystem == "aqua"} {			frame $wname.blueframe		} else {			frame $wname.blueframe -background [::skin::getKey mainwindowbg]		}		frame $wname.blueframe.log -class Amsn -borderwidth 0		frame $wname.buttons -class Amsn		set img [image create photo ${wname}_img -w 320 -h 240]		label $wname.blueframe.log.l -image $img		frame $wname.top.contact  -class Amsn -borderwidth 0		combobox::combobox $wname.top.contact.list -editable true -highlightthickness 0 -width 22 -bg #FFFFFF -font splainf		$wname.top.contact.list list delete 0 end		foreach contact $sortedcontact_list {			$wname.top.contact.list list insert end $contact		}		#Get all the list		set list [$wname.top.contact.list list get 0 end]		#Do a search in that list to find where is exactly the email we need		set exactMatch [lsearch -exact $list $email]		#Select the email in the list when we open the window with the result of the search		$wname.top.contact.list select $exactMatch		$wname.top.contact.list configure -command "::log::ChangeCamLogWin $wname $email"		$wname.top.contact.list configure -editable false		pack $wname.top.contact.list -side left -expand true -fill both		grid $wname.top.contact -row 0 -column 0 -sticky news		::log::CamLogsByDate $wname $email "1"		button $wname.buttons.play -text "[trans play]" -state $exists \		    -command [list ::CAMGUI::Play $wname [file join ${webcam_dir} ${email}.cam]]				button $wname.buttons.pause -text "[trans pause]" -command "::CAMGUI::Pause $wname"  -state disabled		button $wname.buttons.stop -text "[trans stop]" -command "::CAMGUI::Stop $wname" -state disabled		button $wname.buttons.save -text "[trans snapshot]" -command "::CAMGUI::saveToImage $wname" -state $exists		button $wname.buttons.close -text "[trans close]" -command "destroy $wname"		#	button $wname.buttons.stats -text "[trans stats]" -command "::log::cam_stats"		button $wname.buttons.clear -text "[trans clearlog]" \		    -command "if { !\[winfo exists $wname.top.date.list\] } { \				                    set date \".\" \				              } else {				                    set date \[$wname.top.date.list list get \[$wname.top.date.list curselection\]\]\					      }                                              if { \[::log::ClearCamLog $email \"\$date\"\] } { 				                    destroy $wname			         	      }" \		frame $wname.slider -class Amsn -borderwidth 0		scale $wname.slider.playbackspeed -from 10 -to 500 -resolution 1 -showvalue 1 -label "[trans playbackspeed]" -variable [::config::getVar playbackspeed] -orient horizontal				frame $wname.position -class Amsn -borderwidth 0		#if { ![info exists ::seek_val($img)] } {		#	set ::seek_val($img) 0		#}		if { ![file exists [file join ${webcam_dir} ${email}.cam]] } {			set whole_size 0		} else {			set whole_size [file size [file join ${webcam_dir} ${email}.cam]]		}			scale $wname.position.slider -from 0 -to $whole_size -resolution 1 -showvalue 0 -label "[trans playbackposition]" -variable ::seek_val($img) -orient horizontal		if { $whole_size > 0 } {			$wname.slider.playbackspeed configure -state normal			$wname.position.slider configure -state normal		} else {			$wname.slider.playbackspeed configure -state disabled			$wname.position.slider configure -state disabled		}		#not using -command to avoid constantly changing while user is dragging it around		#interp alias {} imgseek {} ::CAMGUI::Seek $wname [file join ${webcam_dir} ${email}.cam]		bind $wname.position.slider <ButtonPress-1> "::CAMGUI::Pause $wname"		#bind $wname.position.slider <Button1-ButtonRelease> {imgseek [%W get]}		bind $wname.position.slider <ButtonRelease-1> [list ::CAMGUI::Resume $wname [file join ${webcam_dir} ${email}.cam]]				pack $wname.top -side top -fill x		pack $wname.blueframe.log.l -side left -expand true -fill both		pack $wname.blueframe.log -side top -expand true -fill both -padx 4 -pady 4		pack $wname.blueframe -side top -expand true -fill both		pack $wname.buttons.play -padx 0 -side left		pack $wname.buttons.pause -padx 0 -side left		pack $wname.buttons.stop -padx 0 -side left		#	pack $wname.buttons.stats -padx 0 -side right		pack $wname.buttons.save -padx 0 -side right		pack $wname.buttons.clear -padx 0 -side right		pack $wname.buttons.close -padx 0 -side right		pack $wname.buttons -side bottom -fill x -pady 3		pack $wname.slider.playbackspeed -fill x		pack $wname.slider -side bottom -fill x -pady 3		pack $wname.position.slider -fill x		pack $wname.position -side bottom -fill x -pady 3		bind $wname <<Escape>> "destroy $wname"		bind $wname <Destroy> "::CAMGUI::Stop $wname; catch {image delete $img}"		moveinscreen $wname 30	}	proc updateCamButtonsState {wname button} {		set play $wname.buttons.play		set pause $wname.buttons.pause		set stop $wname.buttons.stop		if {![winfo exists $play] || ![winfo exists $pause] || ![winfo exists $stop] } { return }		switch $button {			play {				$play configure -state disabled				$pause configure -state normal				$stop configure -state normal			}			pause {				$play configure -state normal				$pause configure -state disabled				$stop configure -state normal			}			stop {				$play configure -state normal				$pause configure -state disabled				$stop configure -state disabled			}			default {			}					}	}	proc UpdateCamMetadata {email} {		global webcam_dir		if { ![catch {set fd [open [file join $webcam_dir ${email}.dat] a]}] } {			set epoch [clock seconds]			if { [file exists [file join $webcam_dir ${email}.cam]] } {				set fsize [file size [file join $webcam_dir ${email}.cam]]			} else {				set fsize 0			}			puts $fd "$epoch $fsize"					close $fd		}	}	proc UpdateSessionList {wname email {date "."}} {		global webcam_dir		variable logged_webcam_sessions_${email}				# Clear session list		$wname.top.sessions.list configure -editable true		$wname.top.sessions.list list delete 0 end		# Open metadata		set metadata [file join $webcam_dir $date ${email}.dat]		set camfile [file join $webcam_dir $date ${email}.cam]		if { [file exists "$metadata"] && [file exists "$camfile"]} {			set fd [open "$metadata" r]			# Parse session data			array unset logged_webcam_sessions_${email}			set i 0			while {[gets $fd line] >= 0} {				set logged_webcam_sessions_${email}($i,epoch) [lindex $line 0]				set logged_webcam_sessions_${email}($i,fsize) [lindex $line 1]				incr i			}			close $fd			# Add sessions to combobox			for {set j 0} {$j < $i} {incr j} {				set session_date [clock format [set logged_webcam_sessions_${email}($j,epoch)]]				if {$j < [expr {$i-1}]} {					set fsize1 [set logged_webcam_sessions_${email}($j,fsize)]					set fsize2 [set logged_webcam_sessions_${email}([expr {$j+1}],fsize)]					set fsize [expr {$fsize2 - $fsize1}]				} else {					set fsize1 [set logged_webcam_sessions_${email}($j,fsize)]					set fsize2 [file size "$camfile"]					set fsize [expr {$fsize2 - $fsize1}]				}				set fsize "[::amsn::sizeconvert $fsize]o"				$wname.top.sessions.list list insert end "Session [expr {$j+1}], ${session_date}, (${fsize})"			}		} else {			status_log "::log::UpdateSessionList: cannot open metadata $metadata."		}		$wname.top.sessions.list select 0		$wname.top.sessions.list configure -editable false	}	proc JumpToSession {wname widget sel} {		global webcam_dir		# Rebuild .cam filename		set email [$wname.top.contact.list list get [$wname.top.contact.list curselection]]		set date [$wname.top.date.list list get [$wname.top.date.list curselection]]		if { $date == "[trans currentdate]" } { set date "." }		if { $date == "_ _ _ _ _" } { return }		variable logged_webcam_sessions_${email}		set idx [$wname.top.sessions.list curselection]		if {[catch {set seekval [set logged_webcam_sessions_${email}($idx,fsize)]}]} {			set seekval 0		}		set filename [file join ${webcam_dir} $date ${email}.cam]		status_log "Seeking to $sel at $seekval"		# after 100 to give the combobox time to close, how to do this neatly?		::CAMGUI::Seek $wname $filename $seekval		#if {[catch {::CAMGUI::Seek $wname $filename $seekval} res]} {		#	status_log "Seeking failed: $res"		#}	}	proc wname {email} {		set wname [split $email "@ ."]		set wname [join $wname "_"]		set wname ".${wname}_hist"		return $wname	}	proc cam_wname {email} {		set wname [split $email "@ ."]		set wname [join $wname "_"]		set wname ".${wname}_cam"		return $wname	}	proc LogsByDate {wname email init} {		global log_dir logvar		#If we store logs by date		if { [::config::getKey logsbydate] == 1 } {			#If this is the first log we view			if {$init == 1} {				frame $wname.top.date  -class Amsn -borderwidth 0				combobox::combobox $wname.top.date.list -editable true -highlightthickness 0 -width 22 -bg #FFFFFF -font splainf			}						set date_list ""			set erdate_list ""			$wname.top.date.list list delete 0 end			foreach date [glob -nocomplain -types f [file join ${log_dir} * ${email}.log]] {				set date [getfilename [file dirname $date]]				status_log "Found date $date for log of $email\n"				if { [catch { clock scan "1 $date"}] == 0 } {					lappend date_list  [clock scan "1 $date"]				} else {					lappend erdate_list $date				}			}			set sorteddate_list [lsort -integer -decreasing $date_list]			set months "0 January February March April May June July August September October November December"			$wname.top.date.list list insert end "[trans currentdate]"			foreach date $sorteddate_list {				status_log "Adding date [clock format $date -format "%B"] [clock format $date -format "%Y"]\n" blue				set month [clock format $date -format "%m"]				if { [string range $month 0 0] == "0" } {					set month [string range $month 1 1]				}				set month "[lindex $months $month]"				set year "[clock format $date -format "%Y"]"				$wname.top.date.list list insert end "$month $year"			}			if { $erdate_list != "" } {				$wname.top.date.list list insert end "_ _ _ _ _"				foreach date $erdate_list {					status_log "Adding Erroneous date $date\n" red					$wname.top.date.list list insert end "$date"				}			}			$wname.top.date.list select 0			$wname.top.date.list configure -command "::log::ChangeLogToDate $wname $email"			$wname.top.date.list configure -editable false			pack $wname.top.date.list -side right			pack $wname.top.date -side right		}	}	proc CamLogsByDate {wname email init} {		global webcam_dir		#If we store logs by date		if { [::config::getKey logsbydate] == 1 } {			#If this is the first log we view			if {$init == 1} {				frame $wname.top.date  -class Amsn -borderwidth 0				combobox::combobox $wname.top.date.list -editable true -highlightthickness 0 -width 22 -bg #FFFFFF -font splainf				frame $wname.top.sessions  -class Amsn -borderwidth 0				combobox::combobox $wname.top.sessions.list \				    -command "::log::JumpToSession $wname" \				    -highlightthickness 0 -width 22 -bg #FFFFFF -font splainf			}						set date_list ""			set erdate_list ""			$wname.top.date.list list delete 0 end			foreach date [glob -nocomplain -types f [file join ${webcam_dir} * ${email}.cam]] {				set date [getfilename [file dirname $date]]				status_log "Found date $date for log of $email\n"				if { [catch { clock scan "1 $date"}] == 0 } {					lappend date_list  [clock scan "1 $date"]				} else {					lappend erdate_list $date				}			}			set sorteddate_list [lsort -integer -decreasing $date_list]			set months "0 January February March April May June July August September October November December"			$wname.top.date.list list insert end "[trans currentdate]"			foreach date $sorteddate_list {				status_log "Adding date [clock format $date -format "%B"] [clock format $date -format "%Y"]\n" blue				set month [clock format $date -format "%m"]				if { [string range $month 0 0] == "0" } {					set month [string range $month 1 1]				}				set month "[lindex $months $month]"				set year "[clock format $date -format "%Y"]"				$wname.top.date.list list insert end "$month $year"			}			if { $erdate_list != "" } {				$wname.top.date.list list insert end "_ _ _ _ _"				foreach date $erdate_list {					status_log "Adding Erroneous date $date\n" red					$wname.top.date.list list insert end "$date"				}			}			$wname.top.date.list select 0			$wname.top.date.list configure -command "::log::ChangeCamLogToDate $wname $email"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -