]>
git.zerfleddert.de Git - snom-frontend/blob - snom.pl
283b3988f06e35cec60ae5cea8489f763abadd12
2 #$Id: snom.pl,v 1.1 2006-05-21 11:53:53 simigern Exp $
4 PATH
=/opt/csw
/bin:/opt
/local/bin
:/usr/bin
:/bin
exec perl
-w
-x
"$0" "$@"
8 use Glib qw
/TRUE FALSE/;
10 use Gtk2
::Gdk
::Keysyms
;
14 my $ua = LWP
::UserAgent
->new;
20 $key='%23' if ($key eq '#');
21 my $req = HTTP
::Request
->new(GET
=> "http://${ARGV[0]}/command.htm?key=${key}");
27 my $req = HTTP
::Request
->new(GET
=> "http://${ARGV[0]}/command.htm?number=${number}");
31 if (!defined($ARGV[0])) {
32 print STDERR
"Usage: ${0} snom.phone.address\n";
36 my $window = Gtk2
::Window
->new('toplevel');
37 $window->set_title("snom");
38 $window->signal_connect(delete_event
=> \
&CloseAppWindow
);
39 $window->signal_connect(destroy
=> sub { Gtk2
->main_quit; });
40 my $kphandler = $window->signal_connect(key_press_event
=> \
&KBDInput
);
41 $window->set_border_width(15);
42 $window->set_resizable(FALSE
);
44 my $keypad = Gtk2
::Table
->new(4, 3, 1);
45 $keypad->set_row_spacings(2);
46 $keypad->set_col_spacings(2);
49 foreach my $i (1, 2, 3, 4, 5, 6, 7, 8, 9, '*', 0, '#') {
50 $key{$i} = Gtk2
::Button
->new(" ${i} ");
51 $key{$i}->signal_connect(clicked
=> \
&KeyPressed
, $i);
52 $keypad->attach_defaults($key{$i}, (($n)%3), (($n)%3)+1, int(($n)/3), int((($n)/3)+1));
58 my $fkeys = Gtk2
::Table
->new(6, 2, 1);
59 $fkeys->set_row_spacings(2);
60 $fkeys->set_col_spacings(2);
62 foreach my $i qw(Redial Settings Directory Help Menu snom _ _ Conference Transfer Hold DND) {
64 $key{$i} = Gtk2
::Button
->new("${i}");
65 $key{$i}->signal_connect(clicked
=> \
&KeyPressed
, $i);
66 $fkeys->attach_defaults($key{$i}, (($n)%2), (($n)%2)+1, int(($n)/2), int((($n)/2)+1));
73 my $pkeys = Gtk2
::Table
->new(6, 2, 1);
74 $pkeys->set_row_spacings(2);
75 $pkeys->set_col_spacings(2);
77 foreach my $i qw(P7 P1 P8 P2 P9 P3 P10 P4 P11 P5 P12 P6) {
78 $key{$i} = Gtk2
::Button
->new("${i}");
79 $key{$i}->signal_connect(clicked
=> \
&KeyPressed
, $i);
80 $pkeys->attach_defaults($key{$i}, (($n+1)%2), (($n+1)%2)+1, int($n/2), int($n/2)+1);
86 my $softkeys = Gtk2
::Table
->new(1, 4);
87 $softkeys->set_col_spacings(6);
89 foreach my $i qw(F1 F2 F3 F4) {
90 $key{$i} = Gtk2
::Button
->new("${i}");
91 $key{$i}->signal_connect(clicked
=> \
&KeyPressed
, $i);
92 $softkeys->attach_defaults($key{$i}, $n, $n+1, 0, 1);
98 my $navi = Gtk2
::Table
->new(3, 5);
100 foreach my $i qw(_ _ ^ _ _ X < _ > OK _ _ V _ _) {
102 $key{$i} = Gtk2
::Button
->new("${i}");
103 $key{$i}->signal_connect(clicked
=> \
&KeyPressed
, $i);
104 $navi->attach_defaults($key{$i}, (($n)%5), (($n)%5)+1, int(($n)/5), int((($n)/5)+1));
111 my $output = Gtk2
::Table
->new(2, 3);
112 $output->set_row_spacings(2);
113 $output->set_col_spacings(2);
115 foreach my $i qw(- + _ Mute Speaker Headset) {
117 $key{$i} = Gtk2
::Button
->new("${i}");
118 $key{$i}->signal_connect(clicked
=> \
&KeyPressed
, $i);
119 $output->attach_defaults($key{$i}, (($n)%3), (($n)%3)+1, int(($n)/3), int((($n)/3)+1));
126 my $special= Gtk2
::Table
->new(1, 2);
127 $special->set_col_spacings(2);
129 foreach my $i qw(Record Retrieve) {
130 $key{$i} = Gtk2
::Button
->new("${i}");
131 $key{$i}->signal_connect(clicked
=> \
&KeyPressed
, $i);
132 $special->attach_defaults($key{$i}, $n, $n+1, 0, 1);
138 my $display = Gtk2
::Entry
->new();
139 $display->signal_connect(activate
=> \
&DialNumber
);
140 my $kph_blocked = FALSE
;
141 #$display->signal_connect(focus_in_event => \&DisplayMouseOver, TRUE);
142 $display->signal_connect(enter_notify_event
=> \
&DisplayMouseOver
, TRUE
);
143 #$display->signal_connect(focus_out_event => \&DisplayMouseOver, FALSE);
144 $display->signal_connect(leave_notify_event
=> \
&DisplayMouseOver
, FALSE
);
147 my $dispbox = Gtk2
::VBox
->new(0, 5);
148 $dispbox->pack_start($display, 0, 0, 0);
149 $dispbox->pack_start($softkeys, 0, 0, 0);
150 $dispbox->pack_start($navi, 0, 0, 0);
153 my $outbox = Gtk2
::VBox
->new(0, 0);
154 $outbox->pack_end($output, 0, 0, 0);
157 my $specialbox = Gtk2
::VBox
->new(0, 0);
158 $specialbox->pack_end($special, 0, 0, 0);
161 my $ubox = Gtk2
::HBox
->new(0, 30);
162 $ubox->pack_start($outbox, 0, 0, 0);
163 $ubox->pack_start($dispbox, 0, 0, 0);
164 $ubox->pack_start($specialbox, 0, 0, 0);
168 my $kbbox = Gtk2
::HBox
->new(0, 30);
169 $kbbox->pack_start($keypad, 1, 1, 0);
170 $kbbox->pack_start($fkeys, 0, 0, 0);
173 my $kvbox = Gtk2
::VBox
->new(0, 5);
174 $kvbox->pack_end($kbbox, 0, 0, 0);
177 my $lbox = Gtk2
::HBox
->new(0, 30);
178 $lbox->pack_start($kvbox, 1, 1, 0);
179 $lbox->pack_start($pkeys, 0, 0, 0);
182 my $mainbox = Gtk2
::VBox
->new(0,5);
183 $mainbox->pack_start($ubox, 0, 0, 0);
184 $mainbox->pack_start($lbox, 0, 0, 0);
187 $window->add($mainbox);
193 # Should never get here
199 my ($button, $text) = @_;
200 foreach my $i (1, 2, 3, 4, 5, 6, 7, 8, 9, '*', 0, '#',
201 'F1', 'F2', 'F3', 'F4',
202 'P1', 'P2', 'P3', 'P4', 'P5', 'P6',
203 'P7', 'P8', 'P9', 'P10', 'P11', 'P12') {
210 snom_key
("REDIAL") if ( $text eq "Redial" );
211 snom_key
("SETTINGS") if ( $text eq "Settings" );
212 snom_key
("F_ADR_BOOK") if ( $text eq "Directory" );
213 snom_key
("HELP") if ( $text eq "Help" );
214 snom_key
("MENU") if ( $text eq "Menu" );
215 snom_key
("SNOM") if ( $text eq "snom" );
216 snom_key
("CONFERENCE") if ( $text eq "Conference" );
217 snom_key
("TRANSFER") if ( $text eq "Transfer" );
218 snom_key
("F_R") if ( $text eq "Hold" );
219 snom_key
("DND") if ( $text eq "DND" );
221 snom_key
("MUTE") if ( $text eq "Mute" );
222 snom_key
("SPEAKER") if ( $text eq "Speaker" );
223 snom_key
("HEADSET") if ( $text eq "Headset" );
225 snom_key
("CANCEL") if ( $text eq "X" );
226 snom_key
("ENTER") if ( $text eq "OK" );
227 snom_key
("UP") if ( $text eq "^" );
228 snom_key
("DOWN") if ( $text eq "V" );
229 snom_key
("LEFT") if ( $text eq "<" );
230 snom_key
("RIGHT") if ( $text eq ">" );
232 snom_key
("F_REC") if ( $text eq "Record" );
233 snom_key
("F_RETRIEVE") if ( $text eq "Retrieve" );
235 snom_key
("VOLUME_UP") if ( $text eq "+" );
236 snom_key
("VOLUME_DOWN") if ( $text eq "-" );
242 snom_number
($entry->get_text());
247 my ($widget, $event, $active) = @_;
250 $widget->grab_focus();
252 $window->signal_handler_block($kphandler);
256 $key{OK
}->grab_focus();
258 $window->signal_handler_unblock($kphandler);
268 my ($widget, $event) = @_;
270 my $keyval = $event->keyval;
271 foreach my $i (1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 'F1', 'F2', 'F3', 'F4') {
272 if ($keyval == $Gtk2::Gdk
::Keysyms
{$i}) {
278 if ($keyval == $Gtk2::Gdk
::Keysyms
{Return
}) {snom_key
("ENTER"); return TRUE
;}
279 if ($keyval == $Gtk2::Gdk
::Keysyms
{KP_Enter
}) {snom_key
("ENTER"); return TRUE
;}
280 if ($keyval == $Gtk2::Gdk
::Keysyms
{Escape
}) {snom_key
("CANCEL"); return TRUE
;}
281 if ($keyval == $Gtk2::Gdk
::Keysyms
{Left
}) {snom_key
("LEFT"); return TRUE
;}
282 if ($keyval == $Gtk2::Gdk
::Keysyms
{KP_Left
}) {snom_key
("LEFT"); return TRUE
;}
283 if ($keyval == $Gtk2::Gdk
::Keysyms
{Right
}) {snom_key
("RIGHT"); return TRUE
;}
284 if ($keyval == $Gtk2::Gdk
::Keysyms
{KP_Right
}) {snom_key
("RIGHT"); return TRUE
;}
285 if ($keyval == $Gtk2::Gdk
::Keysyms
{Up
}) {snom_key
("UP"); return TRUE
;}
286 if ($keyval == $Gtk2::Gdk
::Keysyms
{KP_Up
}) {snom_key
("UP"); return TRUE
;}
287 if ($keyval == $Gtk2::Gdk
::Keysyms
{Down
}) {snom_key
("DOWN"); return TRUE
;}
288 if ($keyval == $Gtk2::Gdk
::Keysyms
{KP_Down
}) {snom_key
("DOWN"); return TRUE
;}
292 ### Callback function to close the window
300 # END EXAMPLE PROGRAM