mirror of
https://github.com/Llewellynvdm/Tomb.git
synced 2024-11-10 23:20:57 +00:00
Merge pull request #73 from hellekin/cleanup-square
Merge cleanup refactoring
This commit is contained in:
commit
28d81f1004
55
HACKING
55
HACKING
@ -19,3 +19,58 @@ If you feel the need to name a variable `$longdescriptionofwhatthisisusefulfor`,
|
||||
then you're allowed to use underscores. But do you really need?
|
||||
|
||||
functions should be lowercase+underscores: `do_this()`
|
||||
|
||||
|
||||
Reporting to the user
|
||||
---------------------
|
||||
|
||||
There are some nifty messaging functions to use. They all come with
|
||||
shortcuts that you can use during development or for temporary
|
||||
messages. The long name is to be used for translatable strings.
|
||||
|
||||
They display formatted messages, using colors when available.
|
||||
|
||||
DEBUG=1 make the _verbose messages visible.
|
||||
QUIET=1 suppresses all messages (but the _verbose messages if DEBUG=1).
|
||||
|
||||
Here is the deal:
|
||||
|
||||
Name (Shortcut) Return When to use
|
||||
=================================================================================
|
||||
_failure (die) exit 1 You want to exit the program with a fatal error.
|
||||
You may pass a different exit code as second argument.
|
||||
|
||||
_warning (no) You want to inform the user about an error condition.
|
||||
|
||||
_message (say) You want to tell the user about what's going on.
|
||||
You can pass -n (shortcut: act) for inline messages.
|
||||
|
||||
_verbose (xxx) You need to check the current state of the program.
|
||||
|
||||
_success (yes) You want to tell the user about a successful result.
|
||||
|
||||
All messaging function take a single "message" argument.
|
||||
_failure takes an exit code as an optional second argument.
|
||||
|
||||
Examples:
|
||||
|
||||
_verbose "Showing translatable debug message"
|
||||
xxx "This is temporary debug"
|
||||
_message "The program is doing something"
|
||||
_message -n "Inline messages "
|
||||
echo "are useful"
|
||||
_success "All is fine"
|
||||
_warning "Something's wrong"
|
||||
_failure "Fatal error: exiting with default exit code 1"
|
||||
_message "This is not reached, nor the next 'die' command"
|
||||
die "I am Jack's dead corpse." 127
|
||||
|
||||
Will display something like:
|
||||
|
||||
tomb [D] Showing translatable debug message
|
||||
tomb [D] This is temporary debug
|
||||
tomb . The program is doing something
|
||||
tomb > Inline messages are useful
|
||||
tomb (*) All is fine
|
||||
tomb [W] Something's wrong
|
||||
tomb [E] Fatal error: exiting with default exit code 1
|
||||
|
@ -79,7 +79,7 @@ dnl these are not *build* dependencies, but *runtime* dependencies.
|
||||
|
||||
dnl Mandatory
|
||||
AC_CHECK_PROG(have_zsh,zsh,yes,no)
|
||||
AC_CHECK_PROG(have_cryptsetup,cryptsetup,yes,no)
|
||||
AC_CHECK_PROG(have_cryptsetup,cryptsetup,yes,no,[/sbin$PATH_SEPARATOR/usr/local/sbin$PATH_SEPARATOR$PATH])
|
||||
AC_CHECK_PROG(have_pinentry,pinentry,yes,no)
|
||||
AC_CHECK_PROG(have_sudo,sudo,yes,no)
|
||||
dnl Optional
|
||||
|
@ -46,13 +46,13 @@ install-data-hook:
|
||||
$(top_srcdir)/src/monmort.xpm monmort; \
|
||||
xdg-icon-resource install --size 32 $(top_srcdir)/src/monmort.xpm monmort; fi
|
||||
@mkdir -p $(DESTDIR)/$(datadir)/icons/hicolor/32x32/mimetypes; \
|
||||
ln -s $(AppInstIcondir)/monmort.png \
|
||||
ln -sf $(AppInstIcondir)/monmort.png \
|
||||
$(DESTDIR)/$(datadir)/icons/hicolor/32x32/mimetypes/application-x-tomb-volume.png
|
||||
ln -s $(AppInstIcondir)/monmort.png \
|
||||
ln -sf $(AppInstIcondir)/monmort.png \
|
||||
$(DESTDIR)/$(datadir)/icons/hicolor/32x32/mimetypes/application-x-tomb-key.png
|
||||
@if ! [ -n `which update-icon-caches` ]; then \
|
||||
update-icon-caches $(DESTDIR)/$(datadir)/icons/hicolor; fi
|
||||
install $(top_builddir)/share/gtkrc $(DESTDIR)/$(GtkRcdir)/
|
||||
distclean:
|
||||
unlink gtkrc
|
||||
unlink Makefile
|
||||
unlink Makefile
|
||||
|
@ -6,7 +6,7 @@
|
||||
#
|
||||
# Undertaker is a tool to retrieve tomb keys from various sources
|
||||
#
|
||||
# Copyleft (C) 2011 Denis Roio <jaromil@dyne.org>
|
||||
# {{{ Copyleft (C) 2011 Denis Roio <jaromil@dyne.org>
|
||||
#
|
||||
# This source code is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Public License as published by
|
||||
@ -22,6 +22,7 @@
|
||||
# this source code; if not, write to:
|
||||
# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
# }}}
|
||||
|
||||
# first of all source the tomb core functions
|
||||
which tomb > /dev/null
|
||||
@ -31,26 +32,24 @@ fi
|
||||
source tomb source
|
||||
|
||||
if ! [ $1 ] ; then
|
||||
error "an argument is missing, the undertaker is confused"
|
||||
act "usage: undertaker url://host:path/to/tomb.key"
|
||||
exit 1;
|
||||
_warning "an argument is missing, the undertaker is confused"
|
||||
_failure "usage: undertaker url://host:path/to/tomb.key"
|
||||
fi
|
||||
|
||||
ARG1=${1}
|
||||
|
||||
check_bin
|
||||
|
||||
notice "Undertaker will look for ${ARG1}"
|
||||
_message "Undertaker will look for ${ARG1}"
|
||||
|
||||
baseurl=${ARG1%//*}
|
||||
|
||||
case $baseurl in
|
||||
bluetooth:)
|
||||
act "access to bluetooth protocol requested"
|
||||
_message "access to bluetooth protocol requested"
|
||||
which obexftp &> /dev/null
|
||||
if [[ $? != 0 ]]; then
|
||||
error "obexftp not found, needed for bluetooth: operation aborted."
|
||||
exit 1
|
||||
die "obexftp not found, needed for bluetooth: operation aborted."
|
||||
fi
|
||||
keytmp=`safe_dir undertaker`
|
||||
cd $keytmp
|
||||
@ -58,18 +57,17 @@ case $baseurl in
|
||||
obexdevpath=${ARG1#*//}
|
||||
obexdev=${obexdevpath%%/*}
|
||||
obexpath=${obexdevpath#*/}
|
||||
act "obex device: $obexdev"
|
||||
act "obex path: $obexpath"
|
||||
_message "obex device: $obexdev"
|
||||
_message "obex path: $obexpath"
|
||||
obexftp -b $obexdev -g $obexpath
|
||||
if [[ $? != 0 ]]; then
|
||||
error "a problem occurred retreiving the key via bluetooth."
|
||||
rmdir ${keytmp}
|
||||
exit 1;
|
||||
die "a problem occurred retreiving the key via bluetooth."
|
||||
fi
|
||||
# print out the key on stdout
|
||||
cat $obexpath >&1
|
||||
# wipe out the key
|
||||
${WIPE[@]} $obexpath
|
||||
${=WIPE} $obexpath
|
||||
cd -
|
||||
rmdir ${keytmp}
|
||||
|
||||
@ -78,19 +76,18 @@ case $baseurl in
|
||||
;;
|
||||
|
||||
file:)
|
||||
act "local file access requested"
|
||||
error "TODO"
|
||||
_message "local file access requested"
|
||||
die "TODO"
|
||||
;;
|
||||
http:)
|
||||
act "access to web protocol requested"
|
||||
error "TODO"
|
||||
_message "access to web protocol requested"
|
||||
die "TODO"
|
||||
;;
|
||||
ssh:)
|
||||
act "access to secure shell requested"
|
||||
error "TODO"
|
||||
_message "access to secure shell requested"
|
||||
die "TODO"
|
||||
;;
|
||||
*)
|
||||
error "url protocol not recognized: $baseurl"
|
||||
exit 1
|
||||
die "url protocol not recognized: $baseurl"
|
||||
;;
|
||||
esac
|
||||
|
Loading…
Reference in New Issue
Block a user