summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMax Krasnyansky <maxk@qualcomm.com>2002-03-08 21:12:35 +0000
committerMax Krasnyansky <maxk@qualcomm.com>2002-03-08 21:12:35 +0000
commitc98b2f82a4e532ca61592b08e3ad60749eb9f8d7 (patch)
tree19a3df72d2cd6a8d64b7d98473261c7e07e306a0 /scripts
Initial revision
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.am18
-rw-r--r--scripts/Makefile.in227
-rwxr-xr-xscripts/bluepin148
-rwxr-xr-xscripts/bluetooth.rc.rh72
4 files changed, 465 insertions, 0 deletions
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
new file mode 100644
index 00000000..12f32c78
--- /dev/null
+++ b/scripts/Makefile.am
@@ -0,0 +1,18 @@
+#
+# $Id$
+#
+
+bin_SCRIPTS = bluepin
+
+install-data-local: @DISTRO@
+
+unknown:
+ -echo Unknown distribution
+
+redhat:
+ $(mkinstalldirs) $(DESTDIR)/etc/rc.d/init.d
+ $(INSTALL) -m 755 $(srcdir)/bluetooth.rc.rh $(DESTDIR)/etc/rc.d/init.d/bluetooth
+
+debian:
+ $(mkinstalldirs) $(DESTDIR)/etc/init.d
+ $(INSTALL) -m 755 $(srcdir)/bluetooth.rc.rh $(DESTDIR)/etc/init.d/bluetooth
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
new file mode 100644
index 00000000..d750a69c
--- /dev/null
+++ b/scripts/Makefile.in
@@ -0,0 +1,227 @@
+# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
+
+# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+#
+# $Id$
+#
+
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = ..
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_alias = @build_alias@
+build_triplet = @build@
+host_alias = @host_alias@
+host_triplet = @host@
+target_alias = @target_alias@
+target_triplet = @target@
+AR = @AR@
+AWK = @AWK@
+CC = @CC@
+DISTRO = @DISTRO@
+GLIB = @GLIB@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LDFLAGS = @GLIB_LDFLAGS@
+LD = @LD@
+LEX = @LEX@
+MAKEINFO = @MAKEINFO@
+PACKAGE = @PACKAGE@
+PCMCIA = @PCMCIA@
+VERSION = @VERSION@
+YACC = @YACC@
+
+bin_SCRIPTS = bluepin
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_CLEAN_FILES =
+SCRIPTS = $(bin_SCRIPTS)
+
+DIST_COMMON = Makefile.am Makefile.in
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = gtar
+GZIP_ENV = --best
+all: all-redirect
+.SUFFIXES:
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOMAKE) --gnu scripts/Makefile
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
+ cd $(top_builddir) \
+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+
+install-binSCRIPTS: $(bin_SCRIPTS)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(bindir)
+ @list='$(bin_SCRIPTS)'; for p in $$list; do \
+ if test -f $$p; then \
+ echo " $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \
+ $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \
+ else if test -f $(srcdir)/$$p; then \
+ echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \
+ $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \
+ else :; fi; fi; \
+ done
+
+uninstall-binSCRIPTS:
+ @$(NORMAL_UNINSTALL)
+ list='$(bin_SCRIPTS)'; for p in $$list; do \
+ rm -f $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \
+ done
+tags: TAGS
+TAGS:
+
+
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+subdir = scripts
+
+distdir: $(DISTFILES)
+ here=`cd $(top_builddir) && pwd`; \
+ top_distdir=`cd $(top_distdir) && pwd`; \
+ distdir=`cd $(distdir) && pwd`; \
+ cd $(top_srcdir) \
+ && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu scripts/Makefile
+ @for file in $(DISTFILES); do \
+ d=$(srcdir); \
+ if test -d $$d/$$file; then \
+ cp -pr $$d/$$file $(distdir)/$$file; \
+ else \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file || :; \
+ fi; \
+ done
+info-am:
+info: info-am
+dvi-am:
+dvi: dvi-am
+check-am: all-am
+check: check-am
+installcheck-am:
+installcheck: installcheck-am
+install-exec-am: install-binSCRIPTS
+install-exec: install-exec-am
+
+install-data-am: install-data-local
+install-data: install-data-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+install: install-am
+uninstall-am: uninstall-binSCRIPTS
+uninstall: uninstall-am
+all-am: Makefile $(SCRIPTS)
+all-redirect: all-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+installdirs:
+ $(mkinstalldirs) $(DESTDIR)$(bindir)
+
+
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+mostlyclean-am: mostlyclean-generic
+
+mostlyclean: mostlyclean-am
+
+clean-am: clean-generic mostlyclean-am
+
+clean: clean-am
+
+distclean-am: distclean-generic clean-am
+
+distclean: distclean-am
+
+maintainer-clean-am: maintainer-clean-generic distclean-am
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+maintainer-clean: maintainer-clean-am
+
+.PHONY: uninstall-binSCRIPTS install-binSCRIPTS tags distdir info-am \
+info dvi-am dvi check check-am installcheck-am installcheck \
+install-exec-am install-exec install-data-local install-data-am \
+install-data install-am install uninstall-am uninstall all-redirect \
+all-am all installdirs mostlyclean-generic distclean-generic \
+clean-generic maintainer-clean-generic clean mostlyclean distclean \
+maintainer-clean
+
+
+install-data-local: @DISTRO@
+
+unknown:
+ -echo Unknown distribution
+
+redhat:
+ $(mkinstalldirs) $(DESTDIR)/etc/rc.d/init.d
+ $(INSTALL) -m 755 $(srcdir)/bluetooth.rc.rh $(DESTDIR)/etc/rc.d/init.d/bluetooth
+
+debian:
+ $(mkinstalldirs) $(DESTDIR)/etc/init.d
+ $(INSTALL) -m 755 $(srcdir)/bluetooth.rc.rh $(DESTDIR)/etc/init.d/bluetooth
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/scripts/bluepin b/scripts/bluepin
new file mode 100755
index 00000000..db1f8196
--- /dev/null
+++ b/scripts/bluepin
@@ -0,0 +1,148 @@
+#!/usr/bin/python
+#
+# Bluetooth PIN helper
+# Written by Maxim Krasnyansky <maxk@qualcomm.com>
+#
+
+import sys, os, string
+
+#
+# FIXME:
+#
+# We have to find actual user and proper X display here. And if
+# it's not available (no one's logged in) we should lookup some
+# file for predefined PINs.
+#
+# For now we just assume that we have access to local X display
+# and whoever is logged in there will get a window pop.
+#
+
+os.environ['DISPLAY'] = ':0'
+
+# For X Window display access blueping has to find a user and use
+# his(her) .Xauthority file.
+# os.environ['XAUTHORITY'] = '/home/maxk/.Xauthority'
+
+from gtk import *
+#import GdkImlib, GtkExtra
+
+# Dialog Class
+DLG_OK = 1
+DLG_CANCEL = 2
+class Dialog(GtkDialog):
+ result = DLG_CANCEL
+ args = {}
+ def __init__(self, modal=FALSE, mesg=None, args = {}):
+ GtkDialog.__init__(self)
+ self.args = args
+ self.set_modal(modal)
+ self.set_usize(400, 0)
+ self.set_uposition(300,300)
+
+ self.connect("destroy", self.quit)
+ self.connect("delete_event", self.quit)
+
+ self.action_area.set_border_width(2)
+
+ ok = GtkButton("Accept")
+ ok.connect("clicked", self.ok)
+ self.action_area.pack_start(ok, padding = 20)
+ ok.show()
+
+ cl = GtkButton("Reject")
+ cl.connect("clicked", self.cancel)
+ self.action_area.pack_start(cl, padding = 20)
+ cl.show()
+
+ if mesg:
+ msg = GtkLabel()
+ msg.set_text(mesg)
+ self.vbox.pack_start(msg, padding = 10)
+ msg.show()
+
+ self.ents = []
+ for k in self.args.keys():
+ hbox = GtkHBox()
+ hbox.set_border_width(5)
+ self.vbox.pack_start(hbox)
+ hbox.show()
+
+ l = GtkLabel()
+ e = GtkEntry()
+ l.set_text( k )
+ e.set_text( self.args[k] )
+ e.connect("key_press_event", self.key_press)
+ hbox.pack_start(l, padding = 10, expand = FALSE)
+ hbox.pack_start(e)
+ l.show()
+ e.show()
+
+ self.ents.append( (k, e) )
+
+ self.ents[0][1].grab_focus()
+
+ def key_press(self, entry, event):
+ if event.keyval == GDK.Return:
+ entry.emit_stop_by_name("key_press_event")
+ self.ok()
+ elif event.keyval == GDK.Escape:
+ entry.emit_stop_by_name("key_press_event")
+ self.cancel()
+
+ def ok(self, *args):
+ self.result = DLG_OK
+ for e in self.ents:
+ k = e[0]
+ self.args[k] = e[1].get_text()
+ self.quit()
+
+ def cancel(self, *args):
+ self.result = DLG_CANCEL
+ self.quit()
+
+ def quit(self, *args):
+ self.hide()
+ self.destroy()
+ mainquit()
+
+def dialog(title, mesg, args, modal = FALSE):
+ dlg = Dialog(args = args, mesg = mesg, modal = modal)
+ dlg.set_title(title)
+ dlg.show()
+ mainloop()
+ return dlg.result
+
+def main(*args):
+ dir = sys.argv[1]
+ bdaddr = sys.argv[2]
+
+ if len(sys.argv) > 3:
+ name = sys.argv[3]
+ else:
+ name = ""
+
+ title = "Bluetooth PIN Code"
+
+ # Bluetooth spec recommends automatic strong random PIN generation.
+ # So eventually we should implement that.
+ pin = { "PIN": "" }
+
+ if dir == "out":
+ mesg = "Outgoing connection to "
+ else:
+ mesg = "Incomming connection from "
+
+ mesg = mesg + name + "[" + bdaddr + "]"
+
+ if dialog(title, mesg, pin) == DLG_OK:
+ pin["PIN"] = string.strip(pin["PIN"])
+
+ if len(pin["PIN"]) >= 4 and len(pin["PIN"]) <=16:
+ print "PIN:" + pin["PIN"]
+ else:
+ print "ERR"
+ else:
+ print "ERR"
+
+#
+main()
diff --git a/scripts/bluetooth.rc.rh b/scripts/bluetooth.rc.rh
new file mode 100755
index 00000000..f0586788
--- /dev/null
+++ b/scripts/bluetooth.rc.rh
@@ -0,0 +1,72 @@
+#!/bin/sh
+#
+# bluetooth Bluetooth subsystem starting and stopping
+#
+# chkconfig: 345 25 90
+# description: Bluetooth subsystem
+#
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+# Source Bluetooth configuration.
+#. /etc/sysconfig/bluetooth
+
+prog="Bluetooth"
+
+UART_CONF="/etc/bluetooth/uart"
+
+start_uarts()
+{
+ [ -f /sbin/hciattach -a -f $UART_CONF ] || return
+ grep -v '^#' $UART_CONF | while read i; do
+ /sbin/hciattach $i
+ done
+}
+
+stop_uarts()
+{
+ killproc hciattach > /dev/null 2>&1
+}
+
+start()
+{
+ echo -n $"Starting $prog: "
+ daemon /sbin/hcid
+ start_uarts
+ touch /var/lock/subsys/bluetooth
+ echo
+}
+
+stop()
+{
+ echo -n $"Shutting down $prog: "
+ stop_uarts
+ killproc hcid
+ rm -f /var/lock/subsys/bluetooth
+ echo
+}
+
+[ -f /sbin/hcid ] || exit 0
+
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart|reload)
+ stop
+ start
+ ;;
+ condrestart)
+ [ -e /var/lock/subsys/bluetooth ] && (stop; start)
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|reload|condrestart}"
+ exit 1
+esac
+
+exit 0