File: mail.tcl

package info (click to toggle)
dotfile 2.2-1
  • links: PTS
  • area: main
  • in suites: hamm, slink
  • size: 4,596 kB
  • ctags: 456
  • sloc: tcl: 11,732; sh: 965; makefile: 304; csh: 13; ansic: 7
file content (149 lines) | stat: -rw-r--r-- 4,641 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
proc mail`comment_bug {type} {
  global module
  
  set w [makeTempWindow "Mail $type"]

  label $w.label -text "Send $type to:"
  checkbutton $w.dotfile -text \
    "Dotfile Generator programmer (blackie@imada.ou.dk)" \
    -variable __mail(dotfile)
  if {[info exists module(email)]} {
    checkbutton $w.module -text \
      "$module(name) module programmer ($module(email))" \
      -variable __mail(module)
  } else {
    checkbutton $w.module -text \
      "$module(name) module programmer" -variable __mail(module)
  }
  text $w.text -width 50 -height 15 -wrap word

  if {![info exists module(email)]} {
    $w.module configure -state disabled
  }
  frame $w.buts
  button $w.buts.mail   -text Mail   -command "mail`mail1 {$type} $w"
  button $w.buts.cancel -text Cancel -command "destroy $w"

  pack $w.label $w.dotfile $w.module -anchor w
  pack $w.text -anchor w -fill both -expand 1
  pack $w.buts -anchor w
  pack $w.buts.mail $w.buts.cancel -side left
}

proc mail`postcard {} {
  global __postcard argv
  catch "unset __postcard"
  set modules [myGlob [file dirname [lindex $argv 0]]/*]
  
  set w [makeTempWindow "Send postcard"]

  label $w.desc -text "The Dotfile Generator team would very much like the encouragement that you could give us by sending this postcard. It is *NOT* a registration, or any thing else. It is just an encouragement." \
    -wraplength 600 -justify l
  pack $w.desc

    checkbutton $w.newversion -text "Mail information about new versions" \
    -variable __postcard(newversion)
  pack $w.newversion -anchor w 
    
  pack [frame $w.line  -height 0.1c -relief sunken -bd 1] -fill x -expand 1 -pady 3

  pack [label $w.label -text "Which modules do you use?" -anchor w] 
  pack [frame $w.modules] -fill x
  for {set i 0} {$i < 4} {incr i} {
    pack [frame $w.modules.$i] -side left -fill x -expand 1
  }

  set i 0
  foreach module $modules {
    if {![file isdirectory $module] || ![file exists $module/main.template]} continue
    set module [file tail $module]
    if {$module == "Generator"} continue
    if {$module == "demo"} continue
    
    checkbutton $w.modules.[expr $i % 3].$i -text $module \
      -variable __postcard($module) -anchor w
    pack $w.modules.[expr $i % 3].$i -fill x
    incr i
  }

  pack [label $w.com -text "Comment:"]
  pack [text $w.text -width 50 -height 15 -wrap word] -fill both -expand 1

  frame $w.buts
  button $w.buts.mail   -text Mail   -command "mail`mail2 $w"
  button $w.buts.cancel -text Cancel -command "destroy $w"
  pack $w.buts -anchor w
  pack $w.buts.mail $w.buts.cancel -side left
}

  
proc mail`mail1 {type w} {
  global __mail module
  set text [$w.text get 1.0 end]
  set text "This mail is send from the $module(name) module:\n$text"
  if {$__mail(dotfile)} {
    mail`mailIt $type blackie@imada.ou.dk $text
  }
  if {$__mail(module)} {
    if {!($__mail(dotfile) && $module(email) == "blackie@imada.ou.dk")} {
      mail`mailIt $type $module(email) $text
    }
  }
  destroy $w
}

proc mail`mail2 {w} {
  global __postcard
  set text ""
  foreach mod [array names __postcard] {
    if {$mod=="newversion"} continue
    if {$__postcard($mod)} {
      append text "I use $mod\n"
    }
  }
  append text \n\n
  append text [$w.text get 1.0 end]
  if {$__postcard(newversion)} {
    append text "\nPlease send me info about new versions"
  }
  mail`mailIt "Use it" blackie@imada.ou.dk $text
  destroy $w
}

proc mail`mailIt {type to message} {
  global env __system
  if {$__system(mail) == ""} {
    set w [makeTempWindow "Mail"]
    label $w.label -text "During installation of the Dotfile Generator no mailer was found.\nPlease send the following mail yourself:\n" -anchor w -justify left

    label $w.to -text "To:" -anchor w
    entry $w.toWho
    $w.toWho insert insert $to
    
    label $w.subject -text "Subject:" -anchor w
    entry $w.sub 
    $w.sub insert insert "TDG - $type" 

    label $w.content -text "Content:" -anchor w
    frame $w.text
    text  $w.text.cont -width 50 -height 10 -yscrollcommand "$w.text.scroll set"
    scrollbar $w.text.scroll -command "$w.text.cont yview"
    $w.text.cont insert insert $message

    pack $w.label $w.to -anchor w
    pack $w.toWho -padx 20 -anchor w -expand 1 -fill x
    pack $w.subject -anchor w
    pack $w.sub -padx 20 -anchor w -expand 1 -fill x
    pack $w.content -anchor w
    pack $w.text -padx 20
    pack $w.text.cont $w.text.scroll -side left -fill y -expand 1

    button $w.close -text CLOSE -command "destroy $w" 
    pack $w.close
  } else {
    set MAIL [open "|$__system(mail) $to" w]
    puts $MAIL "TDG - $type"
    puts $MAIL $message
    close $MAIL
  }
}