~ubuntu-branches/ubuntu/gutsy/amsn/gutsy

« back to all changes in this revision

Viewing changes to xmms.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Theodore Karkoulis
  • Date: 2006-01-04 15:26:02 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060104152602-ipe1yg00rl3nlklv
Tags: 0.95-1
New Upstream Release (closes: #345052, #278575).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# XMMS Plugin for aMSN
2
 
 
3
 
set paths [split $env(PATH) ":"]
4
 
 
5
 
foreach path $paths { if {[file exist $path/xmms]} { set found 1 } }
6
 
 
7
 
if {[info exist found]} {
8
 
 
9
 
        set xmms(loaded) 1
10
 
 
11
 
        # Gets the current playing song.
12
 
        proc GetSong {} {
13
 
                set file "/tmp/xmms-info"
14
 
                if {![file exist $file]} {return 0}
15
 
 
16
 
                set gets [open $file r]
17
 
 
18
 
                while {![eof $gets]} {
19
 
                        set tmp [gets $gets]
20
 
                        set pos [string first ":" $tmp]
21
 
                        set index [string map {" " "_"} [string range $tmp 0 $pos]]
22
 
                        set info($index) [string range $tmp [expr {$pos+2}] end]
23
 
                        unset tmp
24
 
                }
25
 
 
26
 
                close $gets
27
 
 
28
 
                switch -- $info(Status:) {
29
 
                        "Playing" { lappend return $info(Title:); lappend return $info(File:) }
30
 
                        "Paused" { lappend return $info(Title:); lappend return $info(File:) }
31
 
                        "Stopped" { set return 0 }
32
 
                        default { set return 0 }
33
 
                }
34
 
 
35
 
                status_log "Song is $return\n"
36
 
                return $return
37
 
        }
38
 
 
39
 
        # Use this procedure to:
40
 
        # - Display current song. (1)
41
 
        # - Send current song. (2)
42
 
        # - Change nick to $nick - song. (3)
43
 
        proc xmms {win_name action} {
44
 
                global user_info
45
 
 
46
 
                set info [GetSong]
47
 
                set song [lindex $info 0]
48
 
                set file [lindex $info 1]
49
 
 
50
 
                if {$info == "0"} { msg_box [trans xmmserr]; return 0 }
51
 
 
52
 
 
53
 
                switch -- $action {
54
 
                        1 {
55
 
                                ::amsn::MessageSend .${win_name} 0 "[trans playing $song]"
56
 
                        }
57
 
                        2 {
58
 
                                ::amsn::FileTransferSend .${win_name} $file
59
 
                                return 0
60
 
                        }
61
 
                        3 {
62
 
                                # This stage should be improved, how should we do it?
63
 
                                # - Should it be a "custom state" where we can set the "songnick" ?
64
 
                                # - Should it set the nick to "$currentnick - $song" ? if so, we need to make a nick. cache.
65
 
                                # Can someone make the gui for this ? :)
66
 
 
67
 
                                set newnick [::config::getKey songnick]
68
 
                                if { $newnick == "" } {
69
 
                                        # should this tell the user to set a nick? or shall it set the nick to the song??
70
 
                                        ::MSN::changeName [lindex $user_info 3] $song
71
 
                                } else {
72
 
                                        # We must find a solution to remove the song if someone use this function twice!
73
 
                                        ::MSN::changeName [lindex $user_info 3] "$newnick - $song"
74
 
                                }
75
 
                        }
76
 
                }
77
 
                return 1
78
 
        }
79
 
}