]>
git.zerfleddert.de Git - snom-frontend/blob - snom.pl
bbb359d0cd77a626993832af62bdf00ca7caa206
2 #$Id: snom.pl,v 1.7 2006-05-21 13:08:52 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;
15 #$ua->credentials("${ARGV[0]}:80","snom","root","geheim");
21 $key='%23' if ($key eq '#');
22 my $req = HTTP
::Request
->new(GET
=> "http://${ARGV[0]}/command.htm?key=${key}");
28 my $req = HTTP
::Request
->new(GET
=> "http://${ARGV[0]}/command.htm?number=${number}");
32 if (!defined($ARGV[0])) {
33 print STDERR
"Usage: ${0} snom.phone.address\n";
37 my $window = Gtk2
::Window
->new('toplevel');
38 $window->set_title("snom");
39 $window->signal_connect(delete_event
=> \
&CloseAppWindow
);
40 $window->signal_connect(destroy
=> sub { Gtk2
->main_quit; });
41 my $kphandler = $window->signal_connect(key_press_event
=> \
&KBDInput
);
42 $window->set_border_width(15);
43 $window->set_resizable(FALSE
);
45 my $keypad = Gtk2
::Table
->new(4, 3, 1);
46 $keypad->set_row_spacings(2);
47 $keypad->set_col_spacings(2);
50 foreach my $i (1, 2, 3, 4, 5, 6, 7, 8, 9, '*', 0, '#') {
51 $key{$i} = Gtk2
::Button
->new(" ${i} ");
52 $key{$i}->signal_connect(clicked
=> \
&KeyPressed
, $i);
53 $keypad->attach_defaults($key{$i}, (($n)%3), (($n)%3)+1, int(($n)/3), int((($n)/3)+1));
59 my $fkeys = Gtk2
::Table
->new(6, 2, 1);
60 $fkeys->set_row_spacings(2);
61 $fkeys->set_col_spacings(2);
63 foreach my $i qw(Redial Settings Directory Help Menu snom _ _ Conference Transfer Hold DND) {
65 $key{$i} = Gtk2
::Button
->new("${i}");
66 $key{$i}->signal_connect(clicked
=> \
&KeyPressed
, $i);
67 $fkeys->attach_defaults($key{$i}, (($n)%2), (($n)%2)+1, int(($n)/2), int((($n)/2)+1));
74 my $pkeys = Gtk2
::Table
->new(6, 2, 1);
75 $pkeys->set_row_spacings(2);
76 $pkeys->set_col_spacings(2);
78 foreach my $i qw(P7 P1 P8 P2 P9 P3 P10 P4 P11 P5 P12 P6) {
79 $key{$i} = Gtk2
::Button
->new("${i}");
80 $key{$i}->signal_connect(clicked
=> \
&KeyPressed
, $i);
81 $pkeys->attach_defaults($key{$i}, (($n+1)%2), (($n+1)%2)+1, int($n/2), int($n/2)+1);
87 my $softkeys = Gtk2
::Table
->new(1, 4);
88 $softkeys->set_col_spacings(6);
90 foreach my $i qw(F1 F2 F3 F4) {
91 $key{$i} = Gtk2
::Button
->new("${i}");
92 $key{$i}->signal_connect(clicked
=> \
&KeyPressed
, $i);
93 $softkeys->attach_defaults($key{$i}, $n, $n+1, 0, 1);
99 my $navi = Gtk2
::Table
->new(3, 5);
101 foreach my $i qw(_ _ ^ _ _ X < _ > OK _ _ V _ _) {
103 $key{$i} = Gtk2
::Button
->new("${i}");
104 $key{$i}->signal_connect(clicked
=> \
&KeyPressed
, $i);
105 $navi->attach_defaults($key{$i}, (($n)%5), (($n)%5)+1, int(($n)/5), int((($n)/5)+1));
112 my $output = Gtk2
::Table
->new(2, 3);
113 $output->set_row_spacings(2);
114 $output->set_col_spacings(2);
116 foreach my $i qw(- + _ Mute Speaker Headset) {
118 $key{$i} = Gtk2
::Button
->new("${i}");
119 $key{$i}->signal_connect(clicked
=> \
&KeyPressed
, $i);
120 $output->attach_defaults($key{$i}, (($n)%3), (($n)%3)+1, int(($n)/3), int((($n)/3)+1));
127 my $special= Gtk2
::Table
->new(1, 2);
128 $special->set_col_spacings(2);
130 foreach my $i qw(Record Retrieve) {
131 $key{$i} = Gtk2
::Button
->new("${i}");
132 $key{$i}->signal_connect(clicked
=> \
&KeyPressed
, $i);
133 $special->attach_defaults($key{$i}, $n, $n+1, 0, 1);
139 my $display = Gtk2
::Entry
->new();
140 $display->signal_connect(activate
=> \
&DialNumber
);
141 my $kph_blocked = FALSE
;
142 $display->signal_connect(enter_notify_event
=> \
&DisplayMouseOver
, TRUE
);
143 $display->signal_connect(leave_notify_event
=> \
&DisplayMouseOver
, FALSE
);
146 my $dispbox = Gtk2
::VBox
->new(0, 5);
147 $dispbox->pack_start($display, 0, 0, 0);
148 $dispbox->pack_start($softkeys, 0, 0, 0);
149 $dispbox->pack_start($navi, 0, 0, 0);
152 my $outbox = Gtk2
::VBox
->new(0, 0);
153 $outbox->pack_end($output, 0, 0, 0);
156 my $specialbox = Gtk2
::VBox
->new(0, 0);
157 $specialbox->pack_end($special, 0, 0, 0);
160 my $ubox = Gtk2
::HBox
->new(0, 30);
161 $ubox->pack_start($outbox, 0, 0, 0);
162 $ubox->pack_start($dispbox, 0, 0, 0);
163 $ubox->pack_start($specialbox, 0, 0, 0);
167 my $kbbox = Gtk2
::HBox
->new(0, 30);
168 $kbbox->pack_start($keypad, 1, 1, 0);
169 $kbbox->pack_start($fkeys, 0, 0, 0);
172 my $kvbox = Gtk2
::VBox
->new(0, 5);
173 $kvbox->pack_end($kbbox, 0, 0, 0);
176 my $lbox = Gtk2
::HBox
->new(0, 30);
177 $lbox->pack_start($kvbox, 1, 1, 0);
178 $lbox->pack_start($pkeys, 0, 0, 0);
181 my $mainbox = Gtk2
::VBox
->new(0,5);
182 $mainbox->pack_start($ubox, 0, 0, 0);
183 $mainbox->pack_start($lbox, 0, 0, 0);
186 $window->add($mainbox);
189 $key{OK
}->grab_focus();
194 # Should never get here
200 my ($button, $text) = @_;
201 foreach my $i (1, 2, 3, 4, 5, 6, 7, 8, 9, '*', 0, '#',
202 'F1', 'F2', 'F3', 'F4',
203 'P1', 'P2', 'P3', 'P4', 'P5', 'P6',
204 'P7', 'P8', 'P9', 'P10', 'P11', 'P12') {
211 snom_key
("REDIAL") if ( $text eq "Redial" );
212 snom_key
("SETTINGS") if ( $text eq "Settings" );
213 snom_key
("F_ADR_BOOK") if ( $text eq "Directory" );
214 snom_key
("HELP") if ( $text eq "Help" );
215 snom_key
("MENU") if ( $text eq "Menu" );
216 snom_key
("SNOM") if ( $text eq "snom" );
217 snom_key
("CONFERENCE") if ( $text eq "Conference" );
218 snom_key
("TRANSFER") if ( $text eq "Transfer" );
219 snom_key
("F_R") if ( $text eq "Hold" );
220 snom_key
("DND") if ( $text eq "DND" );
222 snom_key
("MUTE") if ( $text eq "Mute" );
223 snom_key
("SPEAKER") if ( $text eq "Speaker" );
224 snom_key
("HEADSET") if ( $text eq "Headset" );
226 snom_key
("CANCEL") if ( $text eq "X" );
227 snom_key
("ENTER") if ( $text eq "OK" );
228 snom_key
("UP") if ( $text eq "^" );
229 snom_key
("DOWN") if ( $text eq "V" );
230 snom_key
("LEFT") if ( $text eq "<" );
231 snom_key
("RIGHT") if ( $text eq ">" );
233 snom_key
("F_REC") if ( $text eq "Record" );
234 snom_key
("F_RETRIEVE") if ( $text eq "Retrieve" );
236 snom_key
("VOLUME_UP") if ( $text eq "+" );
237 snom_key
("VOLUME_DOWN") if ( $text eq "-" );
245 snom_number
($entry->get_text());
251 my ($widget, $event, $active) = @_;
254 $widget->grab_focus();
256 $window->signal_handler_block($kphandler);
260 $key{OK
}->grab_focus();
262 $window->signal_handler_unblock($kphandler);
272 my ($widget, $event) = @_;
274 my $keyval = $event->keyval;
276 for (my $i=1; $i<10; $i++) {
277 if ($keyval == $Gtk2::Gdk
::Keysyms
{$i} || $keyval == $Gtk2::Gdk
::Keysyms
{"KP_${i}"}) {
283 if ($keyval == $Gtk2::Gdk
::Keysyms
{asterisk
}) {snom_key
('*'); return TRUE
;}
284 if ($keyval == $Gtk2::Gdk
::Keysyms
{KP_Multiply
}) {snom_key
('*'); return TRUE
;}
285 if ($keyval == $Gtk2::Gdk
::Keysyms
{numbersign
}) {snom_key
('#'); return TRUE
;}
286 if ($keyval == $Gtk2::Gdk
::Keysyms
{Return
}) {snom_key
("ENTER"); return TRUE
;}
287 if ($keyval == $Gtk2::Gdk
::Keysyms
{KP_Enter
}) {snom_key
("ENTER"); return TRUE
;}
288 if ($keyval == $Gtk2::Gdk
::Keysyms
{Escape
}) {snom_key
("CANCEL"); return TRUE
;}
289 if ($keyval == $Gtk2::Gdk
::Keysyms
{Left
}) {snom_key
("LEFT"); return TRUE
;}
290 if ($keyval == $Gtk2::Gdk
::Keysyms
{KP_Left
}) {snom_key
("LEFT"); return TRUE
;}
291 if ($keyval == $Gtk2::Gdk
::Keysyms
{Right
}) {snom_key
("RIGHT"); return TRUE
;}
292 if ($keyval == $Gtk2::Gdk
::Keysyms
{KP_Right
}) {snom_key
("RIGHT"); return TRUE
;}
293 if ($keyval == $Gtk2::Gdk
::Keysyms
{Up
}) {snom_key
("UP"); return TRUE
;}
294 if ($keyval == $Gtk2::Gdk
::Keysyms
{KP_Up
}) {snom_key
("UP"); return TRUE
;}
295 if ($keyval == $Gtk2::Gdk
::Keysyms
{Down
}) {snom_key
("DOWN"); return TRUE
;}
296 if ($keyval == $Gtk2::Gdk
::Keysyms
{KP_Down
}) {snom_key
("DOWN"); return TRUE
;}
298 if (!$event->state) {
299 for (my $i=1; $i<5; $i++) {
300 if ($keyval == $Gtk2::Gdk
::Keysyms
{"F${i}"}) {
306 if ($event->state eq 'mod1-mask') {
307 for (my $i=1; $i<13; $i++) {
308 if ($keyval == $Gtk2::Gdk
::Keysyms
{"F${i}"}) {
316 print "Unhandled: Modifier: ".$event->state.", Key: ";
317 foreach my $key (keys(%Gtk2::Gdk
::Keysyms
)) {
318 if ($keyval == $Gtk2::Gdk
::Keysyms
{$key}) {