File: NotifyCall.tcl

package info (click to toggle)
coccinella 0.96.20-9
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 13,184 kB
  • sloc: tcl: 124,744; xml: 206; makefile: 66; sh: 62
file content (167 lines) | stat: -rw-r--r-- 4,025 bytes parent folder | download | duplicates (4)
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#agents NotifyCall.tcl --
# 
#       NotifyCall is an Dialog Window with Inbound calls notifications 
#
#  Copyright (c) 2007 Mats Bengtsson
#  
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#   
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#   
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
#       

namespace eval ::NotifyCall { 

    return
    component::define NotifyCall  \
      "Provides support for Incoming Calls Dialog"
}

proc ::NotifyCall::Init {} {
    
    return
    
    component::register NotifyCall

    ::hooks::register jivePhoneEvent		::NotifyCall::JivePhoneEventHook
    ::hooks::register IAXPhoneEvent		::NotifyCall::IAXPhoneEventHook

    #--------------- Variables Uses For SpeedDial Addressbook Tab ----------------
    InitState
}

proc ::NotifyCall::InitState { } {
    variable state
    
    array set state {
	win             .notify
    }
}


#-----------------------------------------------------------------------
#--------------------------- Notify Call Window ------------------------
#-----------------------------------------------------------------------


# NotifyCall::InboundCall  --
# 

proc ::NotifyCall::InboundCall { {phoneNumber ""} } {
    variable state
  
    set win $state(win)

    if { $phoneNumber ne "" } { 
        BuildDialer $win $phoneNumber 
    }
}

# NotifyCall::BuildDialer --
# 
#       A toplevel dialer.
       
proc ::NotifyCall::BuildDialer {w phoneNumber } {
    variable state

    # Make sure only single instance of this dialog.
    if {[winfo exists $w]} {
	raise $w
	return
    }

    ::UI::Toplevel $w -class PhoneNotify \
      -usemacmainmenu 1 -macstyle documentProc -macclass {document closeBox} \
      -closecommand ::NotifyCall::CloseDialer

    wm title $w [mc "Notify Call"]

    ::UI::SetWindowPosition $w


    # Global frame.
    ttk::frame $w.f
    pack  $w.f  -fill x

    set msg [mc "Inbound Call"]
    append msg ": $phoneNumber"
    ttk::label $w.f.head -style Headlabel -text $msg
    pack  $w.f.head  -side top -fill both -expand 1

    ttk::separator $w.f.s -orient horizontal
    pack  $w.f.s  -side top -fill x

    set wbox $w.f.f
    ttk::frame $wbox -padding [option get . dialogPadding {}]
    pack  $wbox  -fill both -expand 1
    
    set box $wbox.b
    ttk::frame $box
    pack $box -side bottom -fill x
    
#    ttk::label $box.l -text [mc "Number"]:
#    ttk::entry $box.e -textvariable [namespace current]::phoneNumber  \
#      -width 18


    ttk::button $box.hungup -text [mc "Hung Up"]  \
      -command [list [namespace current]::HungUp $w ]

    ttk::button $box.vm  -text [mc "Call VM?"]  \
      -command [list [namespace current]::HungUp $w ]

#    grid  $box.l  $box.e  $box.dial -padx 1 -pady 4
 
    grid $box.hungup $box.vm -padx 1 -pady 4

    focus $box.hungup
    wm resizable $w 0 0

}

proc ::NotifyCall::CloseDialer {w} {
    
#    ::UI::SaveWinGeom $w   
}

proc ::NotifyCall::HungUp {w } {

    eval {::JivePhone::DialExtension "666" "FORWARD"}

    destroy $w
}

proc ::NotifyCall::JivePhoneEventHook {type ext cid args} {
    variable cociFile
    variable state

    set win $state(win)
    if {$type eq "RING"} {
        InboundCall $cid 
    } else {
        if {[winfo exists $win]} {
            destroy $win
        }
    }
}

proc ::NotifyCall::IAXPhoneEventHook {type cid args} {
    variable state

    set win $state(win)
    if {$type eq "RING"} {
        InboundCall $cid
    } else {
        if {[winfo exists $win]} {
            destroy $win
        }
    }
}