|
From: <bu...@us...> - 2006-04-12 15:19:16
|
Revision: 677 Author: bugant Date: 2006-04-12 08:18:53 -0700 (Wed, 12 Apr 2006) ViewCVS: http://svn.sourceforge.net/yaacs/?rev=677&view=rev Log Message: ----------- * added a new button to let you send sms importing a list of mobile phone from a text file; * error message at debug level if an sms cannot be enqueued; Modified Paths: -------------- trunk/yaacs/op.tcl trunk/yacco.tcl Modified: trunk/yaacs/op.tcl =================================================================== --- trunk/yaacs/op.tcl 2006-04-12 15:16:38 UTC (rev 676) +++ trunk/yaacs/op.tcl 2006-04-12 15:18:53 UTC (rev 677) @@ -442,6 +442,7 @@ set sqlSms "insert into sms.sms_single (login,phone,msg) values \ ('$login','$cell','$text')" if {[::yadb::execl $db $sqlSms] == -1} { + ::yalog::debug "cannot enqueue sms" return -1 } return 0 Modified: trunk/yacco.tcl =================================================================== --- trunk/yacco.tcl 2006-04-12 15:16:38 UTC (rev 676) +++ trunk/yacco.tcl 2006-04-12 15:18:53 UTC (rev 677) @@ -360,6 +360,79 @@ ::yacco::onPressUsync $db $::yacco::config(REMOTE_HOST) } } +button $bts.smses -image $::yatk_icons::sms -text [mc "Sms to list"] -compound left \ + -command { + set w .smses + + toplevel $w + + set head [label $w.head -text [mc "Send sms to a list loading it from a text file. \ + The file has to contain the mobile number, one for each line."] \ + -font [list lucidasans 14 bold] -wraplength 400 -justify left] + set txt [text $w.txt -width 20 -height 6] + + set f [frame $w.f] + set lblfile [label $f.lblfile -text [mc "Mobile list file: "]] + set file [entry $f.file -bg white -width 30] + set btfile [button $f.btfile -image $::yatk_icons::folder -relief groove \ + -command { + set path [tk_getOpenFile -filetypes [list [list [mc "Text files"] [list .txt]] \ + [list [mc "All files"] [list *]]] -parent .smses -initialdir ~] + if {$path ne ""} { + .smses.f.file delete 0 end + .smses.f.file insert 0 $path + } + }] + grid $lblfile $file $btfile -sticky we -padx 6 -pady 6 + + set bts [frame $w.bts] + set close [button $bts.close -text [mc "Close"] -image $::yatk_icons::cancel \ + -compound left -command {destroy .smses}] + set send [button $bts.send -text [mc "Send"] -image $::yatk_icons::email \ + -compound left -command { + set txt [.smses.txt get 0.0 end] + if {$txt eq ""} { + ::yatk_dlg::error [mc "Write a text first"] + return + } + + set path [.smses.f.file get] + if {$path eq "" || ![file isfile $path]} { + ::yatk_dlg::error [mc "Bad file path"] + return + } + + set fd [open $path] + set mobiles [split [read $fd] "\n"] + close $fd + + set sent 0 + set tot 0 + foreach line $mobiles { + if {$line eq ""} {continue} + if {[::op::enqueueSms $::yacco::db "" $line $txt] == 0} { + incr sent + } + incr tot + } + set msg [format "%d/%d %s" $sent $tot [mc "sms sucessfully enqueued"]] + ::yatk_dlg::info $msg + }] + grid $close $send -sticky se -padx [list 6 0] + + grid $head -sticky news -padx 12 -pady 12 + grid $txt -sticky news -padx 12 -pady [list 12 6] + grid $f -sticky nws -padx 12 -pady 6 + grid $bts - - -sticky se -padx 6 -pady [list 12 6] + + grid configure $lblfile -sticky nse + grid configure $btfile -ipadx 5 -ipady 5 -sticky nsw + + update + ::yatk_wm::center .smses . + + } + button $bts.settings -text [mc "Settings"] -image $::yatk_icons::control -compound left \ -command {::yacco::onPressSettings} @@ -370,6 +443,7 @@ grid $bts.new -pady 3 -sticky news grid $bts.opst -pady 3 -sticky news grid $bts.usync -pady 3 -sticky news +grid $bts.smses -padx 3 -sticky news grid $bts.settings -pady 3 -sticky news #$bts.quit -padx [list 6 0] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |