Compare commits

...

35 Commits

Author SHA1 Message Date
e3de8157ed po: update the translations 2025-02-20 17:47:27 +01:00
8d2931f8ea About to release DeforaOS Camera 0.3.1 2025-02-20 17:38:33 +01:00
88701c479b camera: make comments more consistent 2024-09-04 18:35:26 +02:00
9e855dad62 camera: allow the window to be resized smaller 2024-09-04 18:20:48 +02:00
3b5399a8d2 Merge branch 'khorben/mmap' 2024-09-04 18:19:37 +02:00
fd1e4419fa camera: improve support for MMAP 2024-09-04 18:18:54 +02:00
1e01aa9d63 Merge branch 'khorben/cairo' 2024-08-28 23:29:09 +02:00
444664a2cc camera: use the Cairo API to draw the surface 2024-08-28 23:28:27 +02:00
df22589e2b camera: fix the build on NetBSD 2024-08-28 22:54:53 +02:00
17bb67ec85 camera: minor optimisation 2024-08-28 17:57:57 +02:00
077f40603c camera: recognise more capabilities 2024-08-28 17:57:31 +02:00
8d3b7beaa7 camera: start the stream when setting up MMAP 2024-08-28 17:43:23 +02:00
65d1cde81e camera: recognise more capabilities 2024-08-28 00:18:36 +02:00
b01deb9382 camera: fix the build 2024-08-08 18:28:49 +02:00
440003c108 camera: always set YUYV as the video capture format
This is the only format supported at the moment.
2024-08-08 18:23:29 +02:00
e2a9ad3d0f Update the copyright notice 2024-07-30 18:00:46 +02:00
26a9af0ed7 camera: fix the build without X11 2024-07-30 18:00:23 +02:00
6c390be503 project.conf: register the compilation modes 2024-07-30 02:47:14 +02:00
16795bbfc0 camera: re-indent 2024-07-29 19:40:29 +02:00
5c74d87c7e Import the newer scripts from DeforaOS configure 2024-07-29 19:39:58 +02:00
4046248133 camera: fix possible off-by-one with strncat() 2024-07-29 19:33:12 +02:00
a0fb95977e Update the copyright notice 2024-07-29 19:29:13 +02:00
809d06dc3e camera: fix obtaining the current format 2024-07-29 19:28:45 +02:00
ae0b7954b9 Import the newer scripts from DeforaOS configure 2020-11-19 03:14:50 +01:00
be0e7a87e0 Rename the desktop files 2020-11-18 23:14:01 +01:00
8d49ceca6b Complete the flags for building with Gtk+ 3 2020-01-23 20:12:06 +01:00
77c0833c08 Update the translations 2020-01-23 20:01:43 +01:00
22c2a91474 Also ship the "clint" and "fixme" tests 2020-01-23 20:00:48 +01:00
d615ed3041 About to release DeforaOS Camera 0.3.0 2020-01-23 18:24:35 +01:00
c64523749a Update the translations 2020-01-18 14:46:22 +01:00
5bb723df43 Update the copyright notice 2020-01-18 14:45:27 +01:00
f535b36fd6 Re-license under the 2-clause BSD license 2020-01-18 14:45:18 +01:00
480c9feb77 Update the copyright notice 2020-01-18 14:38:20 +01:00
a902394d19 Use PROGNAME_BROWSER for browser(1) 2020-01-18 14:38:09 +01:00
b3c4caa076 Merge branch 'khorben/gtk3' 2020-01-18 14:37:41 +01:00
25 changed files with 873 additions and 421 deletions

View File

@ -1,7 +1,8 @@
dist=Makefile,deforaos-camera.desktop,deforaos-gallery.desktop dist=Makefile,org.defora.camera.desktop,org.defora.gallery.desktop
[deforaos-camera.desktop] #dist
[org.defora.camera.desktop]
install=$(PREFIX)/share/applications install=$(PREFIX)/share/applications
[deforaos-gallery.desktop] [org.defora.gallery.desktop]
install=$(PREFIX)/share/applications install=$(PREFIX)/share/applications

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
#$Id$ #$Id$
#Copyright (c) 2012-2015 Pierre Pronchery <khorben@defora.org> #Copyright (c) 2012-2024 Pierre Pronchery <khorben@defora.org>
# #
#Redistribution and use in source and binary forms, with or without #Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are met: #modification, are permitted provided that the following conditions are met:
@ -25,17 +25,22 @@
#variables #variables
CONFIGSH="${0%/docbook.sh}/../config.sh"
PREFIX="/usr/local" PREFIX="/usr/local"
[ -f "../config.sh" ] && . "../config.sh"
PROGNAME="docbook.sh" PROGNAME="docbook.sh"
XSL_HTML="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"
XSL_MAN="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"
XSL_PDF="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"
#executables #executables
DEBUG="_debug" DEBUG="_debug"
FOP="fop" FOP="fop"
INSTALL="install -m 0644" INSTALL="install -m 0644"
MKDIR="mkdir -m 0755 -p" MKDIR="mkdir -m 0755 -p"
RM="rm -f" RM="rm -f"
XMLLINT="xmllint" XMLLINT="xmllint --noent --nonet --xinclude --path ${PWD}"
XSLTPROC="xsltproc --nonet --xinclude" XSLTPROC="xsltproc --nonet --xinclude --path ${PWD}"
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
#functions #functions
@ -58,18 +63,20 @@ _docbook()
ext="${ext##.}" ext="${ext##.}"
case "$ext" in case "$ext" in
html) html)
XSL="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl" XSL="$XSL_HTML"
[ -f "${source%.*}.xsl" ] && XSL="${source%.*}.xsl" [ -f "${source%.*}.xsl" ] && XSL="${source%.*}.xsl"
[ -f "${target%.*}.xsl" ] && XSL="${target%.*}.xsl" [ -f "${target%.*}.xsl" ] && XSL="${target%.*}.xsl"
if [ -f "${target%.*}.css.xml" ]; then if [ -f "${target%.*}.css.xml" ]; then
XSLTPROC="$XSLTPROC --param custom.css.source \"${target%.*}.css.xml\" --param generate.css.header 1" XSLTPROC_PARAMS="--param custom.css.source \"${target%.*}.css.xml\" --param generate.css.header 1"
elif [ -f "${source%.*}.css.xml" ]; then elif [ -f "${source%.*}.css.xml" ]; then
XSLTPROC="$XSLTPROC --param custom.css.source \"${source%.*}.css.xml\" --param generate.css.header 1" XSLTPROC_PARAMS="--param custom.css.source \"${source%.*}.css.xml\" --param generate.css.header 1"
else
XSLTPROC_PARAMS=
fi fi
$DEBUG $XSLTPROC -o "$target" "$XSL" "$source" $DEBUG $XSLTPROC $XSLTPROC_PARAMS -o "$target" "$XSL" "$source"
;; ;;
pdf) pdf)
XSL="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl" XSL="$XSL_PDF"
[ -f "${source%.*}.xsl" ] && XSL="${source%.*}.xsl" [ -f "${source%.*}.xsl" ] && XSL="${source%.*}.xsl"
[ -f "${target%.*}.xsl" ] && XSL="${target%.*}.xsl" [ -f "${target%.*}.xsl" ] && XSL="${target%.*}.xsl"
$DEBUG $XSLTPROC -o "${target%.*}.fo" "$XSL" "$source" && $DEBUG $XSLTPROC -o "${target%.*}.fo" "$XSL" "$source" &&
@ -77,7 +84,7 @@ _docbook()
$RM -- "${target%.*}.fo" $RM -- "${target%.*}.fo"
;; ;;
1|2|3|4|5|6|7|8|9) 1|2|3|4|5|6|7|8|9)
XSL="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl" XSL="$XSL_MAN"
$DEBUG $XSLTPROC -o "$target" "$XSL" "$source" $DEBUG $XSLTPROC -o "$target" "$XSL" "$source"
;; ;;
*) *)
@ -114,7 +121,7 @@ _usage()
clean=0 clean=0
install=0 install=0
uninstall=0 uninstall=0
while getopts "ciuP:" name; do while getopts "ciO:uP:" name; do
case "$name" in case "$name" in
c) c)
clean=1 clean=1
@ -123,6 +130,9 @@ while getopts "ciuP:" name; do
uninstall=0 uninstall=0
install=1 install=1
;; ;;
O)
export "${OPTARG%%=*}"="${OPTARG#*=}"
;;
u) u)
install=0 install=0
uninstall=1 uninstall=1
@ -137,7 +147,7 @@ while getopts "ciuP:" name; do
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
if [ $# -eq 0 ]; then if [ $# -lt 1 ]; then
_usage _usage
exit $? exit $?
fi fi
@ -165,9 +175,9 @@ while [ $# -gt 0 ]; do
source="${target#$OBJDIR}" source="${target#$OBJDIR}"
source="${source%.*}.xml" source="${source%.*}.xml"
xpath="string(/refentry/refmeta/manvolnum)" xpath="string(/refentry/refmeta/manvolnum)"
section=$($XMLLINT --xpath "$xpath" "$source") section=$($DEBUG $XMLLINT --xpath "$xpath" "$source")
if [ $? -eq 0 -a -n "$section" ]; then if [ $? -eq 0 -a -n "$section" ]; then
instdir="$DATADIR/man/html$section" instdir="$MANDIR/html$section"
fi fi
;; ;;
pdf) pdf)

132
po/es.po
View File

@ -5,166 +5,166 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Camera 0.1.0\n" "Project-Id-Version: Camera 0.3.1\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-01-18 14:16+0100\n" "POT-Creation-Date: 2024-07-30 02:46+0200\n"
"PO-Revision-Date: 2015-02-16 07:20+0100\n" "PO-Revision-Date: 2025-02-20 17:45+0100\n"
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n" "Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
"Language-Team: Spanish\n" "Language-Team: Spanish\n"
"Language: es\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Language: es\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: ../src/camera.c:203 #: ../src/camera.c:213
msgid "Snapshot" msgid "Snapshot"
msgstr "" msgstr ""
#: ../src/camera.c:206 #: ../src/camera.c:216
msgid "Gallery" msgid "Gallery"
msgstr "" msgstr "Galería"
#: ../src/camera.c:210 ../src/camera.c:217 ../src/camera.c:889 #: ../src/camera.c:220 ../src/camera.c:227 ../src/camera.c:899
#: ../src/camera.c:899 #: ../src/camera.c:909
msgid "Properties" msgid "Properties"
msgstr "Propriedades" msgstr "Propriedades"
#: ../src/camera.c:213 ../src/camera.c:706 #: ../src/camera.c:223 ../src/camera.c:716
msgid "Preferences" msgid "Preferences"
msgstr "Preferencias" msgstr "Preferencias"
#: ../src/camera.c:293 #: ../src/camera.c:303
msgid "Fullscreen" msgid "Fullscreen"
msgstr "" msgstr "Pantalla completa"
#: ../src/camera.c:691 #: ../src/camera.c:701
msgid "Nearest" msgid "Nearest"
msgstr "" msgstr ""
#: ../src/camera.c:692 #: ../src/camera.c:702
msgid "Tiles" msgid "Tiles"
msgstr "" msgstr ""
#: ../src/camera.c:693 #: ../src/camera.c:703
msgid "Bilinear" msgid "Bilinear"
msgstr "" msgstr ""
#: ../src/camera.c:694 #: ../src/camera.c:704
msgid "Hyperbolic" msgid "Hyperbolic"
msgstr "" msgstr ""
#: ../src/camera.c:721 #: ../src/camera.c:731
msgid "Flip _horizontally" msgid "Flip _horizontally"
msgstr "" msgstr ""
#: ../src/camera.c:724 #: ../src/camera.c:734
msgid "Flip _vertically" msgid "Flip _vertically"
msgstr "" msgstr ""
#: ../src/camera.c:727 #: ../src/camera.c:737
msgid "Keep aspect _ratio" msgid "Keep aspect _ratio"
msgstr "" msgstr ""
#: ../src/camera.c:731 #: ../src/camera.c:741
msgid "Interpolation: " msgid "Interpolation: "
msgstr "" msgstr ""
#: ../src/camera.c:749 #: ../src/camera.c:759
msgid "Picture" msgid "Picture"
msgstr "" msgstr "Imagen"
#: ../src/camera.c:755 #: ../src/camera.c:765
msgid "Format: " msgid "Format: "
msgstr "" msgstr ""
#: ../src/camera.c:774 #: ../src/camera.c:784
msgid "Snapshots" msgid "Snapshots"
msgstr "" msgstr ""
#: ../src/camera.c:906 #: ../src/camera.c:916
msgid "Driver: " msgid "Driver: "
msgstr "" msgstr ""
#: ../src/camera.c:910 #: ../src/camera.c:920
msgid "Card: " msgid "Card: "
msgstr "" msgstr ""
#: ../src/camera.c:914 #: ../src/camera.c:924
msgid "Bus info: " msgid "Bus info: "
msgstr "" msgstr ""
#: ../src/camera.c:918 #: ../src/camera.c:928
msgid "Version: " msgid "Version: "
msgstr "" msgstr ""
#: ../src/camera.c:931 #: ../src/camera.c:941
msgid "Capabilities: " msgid "Capabilities: "
msgstr "" msgstr ""
#: ../src/camera.c:995 ../src/camera.c:999 ../src/camera.c:1018 #: ../src/camera.c:1005 ../src/camera.c:1009 ../src/camera.c:1029
#: ../src/camera.c:1037 ../src/camera.c:1063 ../src/camera.c:1083 #: ../src/camera.c:1048 ../src/camera.c:1074 ../src/camera.c:1094
#: ../src/camera.c:1236 #: ../src/camera.c:1247
msgid "Could not save picture" msgid "Could not save picture"
msgstr "" msgstr ""
#: ../src/camera.c:1085 #: ../src/camera.c:1096
msgid "Unknown error" msgid "Unknown error"
msgstr "" msgstr ""
#: ../src/camera.c:1189 ../src/camera.c:1193 #: ../src/camera.c:1200 ../src/camera.c:1204
msgid "Error" msgid "Error"
msgstr "Error" msgstr "Error"
#: ../src/camera.c:1422 #: ../src/camera.c:1433
msgid "Could not open the video capture device" msgid "Could not open the video capture device"
msgstr "" msgstr ""
#: ../src/camera.c:1463 #: ../src/camera.c:1474
msgid "Could not obtain the capabilities" msgid "Could not obtain the capabilities"
msgstr "" msgstr ""
#: ../src/camera.c:1467 #: ../src/camera.c:1478
msgid "Not a video capture device" msgid "Not a video capture device"
msgstr "" msgstr ""
#: ../src/camera.c:1480 #: ../src/camera.c:1491
msgid "Cropping not supported" msgid "Cropping not supported"
msgstr "" msgstr ""
#: ../src/camera.c:1485 #: ../src/camera.c:1497
msgid "Could not obtain the video capture format" msgid "Could not obtain the video capture format"
msgstr "" msgstr ""
#: ../src/camera.c:1489 #: ../src/camera.c:1501
msgid "Unsupported video capture type" msgid "Unsupported video capture type"
msgstr "" msgstr ""
#: ../src/camera.c:1500 #: ../src/camera.c:1512
msgid "Unsupported capabilities" msgid "Unsupported capabilities"
msgstr "" msgstr ""
#: ../src/camera.c:1535 #: ../src/camera.c:1547
msgid "Could not request buffers" msgid "Could not request buffers"
msgstr "" msgstr ""
#: ../src/camera.c:1538 #: ../src/camera.c:1550
msgid "Could not obtain enough buffers" msgid "Could not obtain enough buffers"
msgstr "" msgstr ""
#: ../src/camera.c:1542 #: ../src/camera.c:1554
msgid "Could not allocate buffers" msgid "Could not allocate buffers"
msgstr "" msgstr ""
#: ../src/camera.c:1558 #: ../src/camera.c:1570
msgid "Could not setup buffers" msgid "Could not setup buffers"
msgstr "" msgstr ""
#: ../src/camera.c:1564 #: ../src/camera.c:1576
msgid "Could not map buffers" msgid "Could not map buffers"
msgstr "" msgstr ""
#: ../src/main.c:142 #: ../src/main.c:152
#, c-format #, c-format
msgid "" msgid ""
"Usage: %s [-d device][-O filename][-HhRrVvx]\n" "Usage: %s [-d device][-O filename][-HhRrVvx]\n"
@ -179,71 +179,71 @@ msgid ""
" -x\tStart in embedded mode\n" " -x\tStart in embedded mode\n"
msgstr "" msgstr ""
#: ../src/window.c:99 #: ../src/window.c:109
msgid "Take _snapshot" msgid "Take _snapshot"
msgstr "" msgstr ""
#: ../src/window.c:102 #: ../src/window.c:112
msgid "_Gallery" msgid "_Gallery"
msgstr "" msgstr ""
#: ../src/window.c:105 #: ../src/window.c:115
msgid "_Properties" msgid "_Properties"
msgstr "_Propriedades" msgstr "_Propriedades"
#: ../src/window.c:108 #: ../src/window.c:118
msgid "_Close" msgid "_Close"
msgstr "_Cerrar" msgstr "_Cerrar"
#: ../src/window.c:115 #: ../src/window.c:125
msgid "_Preferences" msgid "_Preferences"
msgstr "_Preferencias" msgstr "_Preferencias"
#: ../src/window.c:122 #: ../src/window.c:132
msgid "_Fullscreen" msgid "_Fullscreen"
msgstr "" msgstr "_Pantalla completa"
#: ../src/window.c:133 #: ../src/window.c:143
msgid "_Contents" msgid "_Contents"
msgstr "_Contenidos" msgstr "_Contenidos"
#: ../src/window.c:136 ../src/window.c:139 #: ../src/window.c:146 ../src/window.c:149
msgid "_About" msgid "_About"
msgstr "Acerca _de" msgstr "Acerca _de"
#: ../src/window.c:146 #: ../src/window.c:156
msgid "_File" msgid "_File"
msgstr "_Archivo" msgstr "_Archivo"
#: ../src/window.c:147 #: ../src/window.c:157
msgid "_Edit" msgid "_Edit"
msgstr "_Editar" msgstr "_Editar"
#: ../src/window.c:148 #: ../src/window.c:158
msgid "_View" msgid "_View"
msgstr "_Ver" msgstr "_Ver"
#: ../src/window.c:149 #: ../src/window.c:159
msgid "_Help" msgid "_Help"
msgstr "_Ayuda" msgstr "_Ayuda"
#: ../src/window.c:187 #: ../src/window.c:197
msgid "Webcam" msgid "Webcam"
msgstr "" msgstr ""
#: ../src/window.c:192 #: ../src/window.c:202
msgid "Camera" msgid "Camera"
msgstr "" msgstr "Cámara"
#: ../src/window.c:412 #: ../src/window.c:422
msgid "Simple webcam application for the DeforaOS desktop" msgid "Simple webcam application for the DeforaOS desktop"
msgstr "" msgstr ""
#: ../src/window.c:414 #: ../src/window.c:424
msgid "Simple camera application for the DeforaOS desktop" msgid "Simple camera application for the DeforaOS desktop"
msgstr "" msgstr ""
#: ../tools/gallery.c:104 #: ../tools/gallery.c:114
#, c-format #, c-format
msgid "Usage: %s\n" msgid "Usage: %s\n"
msgstr "Usage: %s\n" msgstr "Usage: %s\n"

122
po/fr.po
View File

@ -5,166 +5,166 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Camera 0.1.0\n" "Project-Id-Version: Camera 0.3.1\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-01-18 14:16+0100\n" "POT-Creation-Date: 2024-07-30 02:46+0200\n"
"PO-Revision-Date: 2013-01-18 22:31+0100\n" "PO-Revision-Date: 2025-02-20 17:45+0100\n"
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n" "Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
"Language-Team: French\n" "Language-Team: French\n"
"Language: fr\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Language: fr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: ../src/camera.c:203 #: ../src/camera.c:213
msgid "Snapshot" msgid "Snapshot"
msgstr "Capture" msgstr "Capture"
#: ../src/camera.c:206 #: ../src/camera.c:216
msgid "Gallery" msgid "Gallery"
msgstr "Gallerie" msgstr "Gallerie"
#: ../src/camera.c:210 ../src/camera.c:217 ../src/camera.c:889 #: ../src/camera.c:220 ../src/camera.c:227 ../src/camera.c:899
#: ../src/camera.c:899 #: ../src/camera.c:909
msgid "Properties" msgid "Properties"
msgstr "Propriétés" msgstr "Propriétés"
#: ../src/camera.c:213 ../src/camera.c:706 #: ../src/camera.c:223 ../src/camera.c:716
msgid "Preferences" msgid "Preferences"
msgstr "Préférences" msgstr "Préférences"
#: ../src/camera.c:293 #: ../src/camera.c:303
msgid "Fullscreen" msgid "Fullscreen"
msgstr "Plein écran" msgstr "Plein écran"
#: ../src/camera.c:691 #: ../src/camera.c:701
msgid "Nearest" msgid "Nearest"
msgstr "Approximative" msgstr "Approximative"
#: ../src/camera.c:692 #: ../src/camera.c:702
msgid "Tiles" msgid "Tiles"
msgstr "Mosaïque" msgstr "Mosaïque"
#: ../src/camera.c:693 #: ../src/camera.c:703
msgid "Bilinear" msgid "Bilinear"
msgstr "Bilinéaire" msgstr "Bilinéaire"
#: ../src/camera.c:694 #: ../src/camera.c:704
msgid "Hyperbolic" msgid "Hyperbolic"
msgstr "Hyperbolique" msgstr "Hyperbolique"
#: ../src/camera.c:721 #: ../src/camera.c:731
msgid "Flip _horizontally" msgid "Flip _horizontally"
msgstr "Retourner l'image _horizontalement" msgstr "Retourner l'image _horizontalement"
#: ../src/camera.c:724 #: ../src/camera.c:734
msgid "Flip _vertically" msgid "Flip _vertically"
msgstr "Retourner l'image _verticalement" msgstr "Retourner l'image _verticalement"
#: ../src/camera.c:727 #: ../src/camera.c:737
msgid "Keep aspect _ratio" msgid "Keep aspect _ratio"
msgstr "Préserver l'_aspect" msgstr "Préserver l'_aspect"
#: ../src/camera.c:731 #: ../src/camera.c:741
msgid "Interpolation: " msgid "Interpolation: "
msgstr "Interpolation : " msgstr "Interpolation : "
#: ../src/camera.c:749 #: ../src/camera.c:759
msgid "Picture" msgid "Picture"
msgstr "Image" msgstr "Image"
#: ../src/camera.c:755 #: ../src/camera.c:765
msgid "Format: " msgid "Format: "
msgstr "Format : " msgstr "Format : "
#: ../src/camera.c:774 #: ../src/camera.c:784
msgid "Snapshots" msgid "Snapshots"
msgstr "Captures" msgstr "Captures"
#: ../src/camera.c:906 #: ../src/camera.c:916
msgid "Driver: " msgid "Driver: "
msgstr "Pilote : " msgstr "Pilote : "
#: ../src/camera.c:910 #: ../src/camera.c:920
msgid "Card: " msgid "Card: "
msgstr "Carte : " msgstr "Carte : "
#: ../src/camera.c:914 #: ../src/camera.c:924
msgid "Bus info: " msgid "Bus info: "
msgstr "Bus : " msgstr "Bus : "
#: ../src/camera.c:918 #: ../src/camera.c:928
msgid "Version: " msgid "Version: "
msgstr "Version : " msgstr "Version : "
#: ../src/camera.c:931 #: ../src/camera.c:941
msgid "Capabilities: " msgid "Capabilities: "
msgstr "Capacités : " msgstr "Capacités : "
#: ../src/camera.c:995 ../src/camera.c:999 ../src/camera.c:1018 #: ../src/camera.c:1005 ../src/camera.c:1009 ../src/camera.c:1029
#: ../src/camera.c:1037 ../src/camera.c:1063 ../src/camera.c:1083 #: ../src/camera.c:1048 ../src/camera.c:1074 ../src/camera.c:1094
#: ../src/camera.c:1236 #: ../src/camera.c:1247
msgid "Could not save picture" msgid "Could not save picture"
msgstr "Impossible d'enregistrer l'image" msgstr "Impossible d'enregistrer l'image"
#: ../src/camera.c:1085 #: ../src/camera.c:1096
msgid "Unknown error" msgid "Unknown error"
msgstr "Erreur inconnue" msgstr "Erreur inconnue"
#: ../src/camera.c:1189 ../src/camera.c:1193 #: ../src/camera.c:1200 ../src/camera.c:1204
msgid "Error" msgid "Error"
msgstr "Erreur" msgstr "Erreur"
#: ../src/camera.c:1422 #: ../src/camera.c:1433
msgid "Could not open the video capture device" msgid "Could not open the video capture device"
msgstr "Impossible d'ouvrir le périphérique de capture vidéo" msgstr "Impossible d'ouvrir le périphérique de capture vidéo"
#: ../src/camera.c:1463 #: ../src/camera.c:1474
msgid "Could not obtain the capabilities" msgid "Could not obtain the capabilities"
msgstr "Impossible d'obtenir les capacités" msgstr "Impossible d'obtenir les capacités"
#: ../src/camera.c:1467 #: ../src/camera.c:1478
msgid "Not a video capture device" msgid "Not a video capture device"
msgstr "Pas de périphérique de capture vidéo" msgstr "Pas de périphérique de capture vidéo"
#: ../src/camera.c:1480 #: ../src/camera.c:1491
msgid "Cropping not supported" msgid "Cropping not supported"
msgstr "Recadrage non supporté" msgstr "Recadrage non supporté"
#: ../src/camera.c:1485 #: ../src/camera.c:1497
msgid "Could not obtain the video capture format" msgid "Could not obtain the video capture format"
msgstr "Impossible d'obtenir le format de capture vidéo" msgstr "Impossible d'obtenir le format de capture vidéo"
#: ../src/camera.c:1489 #: ../src/camera.c:1501
msgid "Unsupported video capture type" msgid "Unsupported video capture type"
msgstr "Type de capture vidéo non supporté" msgstr "Type de capture vidéo non supporté"
#: ../src/camera.c:1500 #: ../src/camera.c:1512
msgid "Unsupported capabilities" msgid "Unsupported capabilities"
msgstr "Capacités non supportées" msgstr "Capacités non supportées"
#: ../src/camera.c:1535 #: ../src/camera.c:1547
msgid "Could not request buffers" msgid "Could not request buffers"
msgstr "Impossible de demander le cache" msgstr "Impossible de demander le cache"
#: ../src/camera.c:1538 #: ../src/camera.c:1550
msgid "Could not obtain enough buffers" msgid "Could not obtain enough buffers"
msgstr "Impossible d'obtenir suffisamment de cache" msgstr "Impossible d'obtenir suffisamment de cache"
#: ../src/camera.c:1542 #: ../src/camera.c:1554
msgid "Could not allocate buffers" msgid "Could not allocate buffers"
msgstr "Impossible d'allouer le cache" msgstr "Impossible d'allouer le cache"
#: ../src/camera.c:1558 #: ../src/camera.c:1570
msgid "Could not setup buffers" msgid "Could not setup buffers"
msgstr "Impossible de configurer le cache" msgstr "Impossible de configurer le cache"
#: ../src/camera.c:1564 #: ../src/camera.c:1576
msgid "Could not map buffers" msgid "Could not map buffers"
msgstr "Impossible d'étaler le cache" msgstr "Impossible d'étaler le cache"
#: ../src/main.c:142 #: ../src/main.c:152
#, c-format #, c-format
msgid "" msgid ""
"Usage: %s [-d device][-O filename][-HhRrVvx]\n" "Usage: %s [-d device][-O filename][-HhRrVvx]\n"
@ -189,71 +189,71 @@ msgstr ""
" -v\tNe pas retourner l'image verticalement\n" " -v\tNe pas retourner l'image verticalement\n"
" -x\tDémarrer en mode embarqué\n" " -x\tDémarrer en mode embarqué\n"
#: ../src/window.c:99 #: ../src/window.c:109
msgid "Take _snapshot" msgid "Take _snapshot"
msgstr "_Prendre une photo" msgstr "_Prendre une photo"
#: ../src/window.c:102 #: ../src/window.c:112
msgid "_Gallery" msgid "_Gallery"
msgstr "_Gallerie" msgstr "_Gallerie"
#: ../src/window.c:105 #: ../src/window.c:115
msgid "_Properties" msgid "_Properties"
msgstr "_Propriétés" msgstr "_Propriétés"
#: ../src/window.c:108 #: ../src/window.c:118
msgid "_Close" msgid "_Close"
msgstr "_Fermer" msgstr "_Fermer"
#: ../src/window.c:115 #: ../src/window.c:125
msgid "_Preferences" msgid "_Preferences"
msgstr "_Préférences" msgstr "_Préférences"
#: ../src/window.c:122 #: ../src/window.c:132
msgid "_Fullscreen" msgid "_Fullscreen"
msgstr "_Plein écran" msgstr "_Plein écran"
#: ../src/window.c:133 #: ../src/window.c:143
msgid "_Contents" msgid "_Contents"
msgstr "_Sommaire" msgstr "_Sommaire"
#: ../src/window.c:136 ../src/window.c:139 #: ../src/window.c:146 ../src/window.c:149
msgid "_About" msgid "_About"
msgstr "À _propos" msgstr "À _propos"
#: ../src/window.c:146 #: ../src/window.c:156
msgid "_File" msgid "_File"
msgstr "_Fichier" msgstr "_Fichier"
#: ../src/window.c:147 #: ../src/window.c:157
msgid "_Edit" msgid "_Edit"
msgstr "É_dition" msgstr "É_dition"
#: ../src/window.c:148 #: ../src/window.c:158
msgid "_View" msgid "_View"
msgstr "_Vue" msgstr "_Vue"
#: ../src/window.c:149 #: ../src/window.c:159
msgid "_Help" msgid "_Help"
msgstr "_Aide" msgstr "_Aide"
#: ../src/window.c:187 #: ../src/window.c:197
msgid "Webcam" msgid "Webcam"
msgstr "Webcam" msgstr "Webcam"
#: ../src/window.c:192 #: ../src/window.c:202
msgid "Camera" msgid "Camera"
msgstr "Caméra" msgstr "Caméra"
#: ../src/window.c:412 #: ../src/window.c:422
msgid "Simple webcam application for the DeforaOS desktop" msgid "Simple webcam application for the DeforaOS desktop"
msgstr "Webcam pour l'environnement DeforaOS" msgstr "Webcam pour l'environnement DeforaOS"
#: ../src/window.c:414 #: ../src/window.c:424
msgid "Simple camera application for the DeforaOS desktop" msgid "Simple camera application for the DeforaOS desktop"
msgstr "Caméra photo pour l'environnement DeforaOS" msgstr "Caméra photo pour l'environnement DeforaOS"
#: ../tools/gallery.c:104 #: ../tools/gallery.c:114
#, c-format #, c-format
msgid "Usage: %s\n" msgid "Usage: %s\n"
msgstr "Usage: %s\n" msgstr "Usage: %s\n"

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
#$Id$ #$Id$
#Copyright (c) 2010-2015 Pierre Pronchery <khorben@defora.org> #Copyright (c) 2010-2020 Pierre Pronchery <khorben@defora.org>
# #
#Redistribution and use in source and binary forms, with or without #Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are met: #modification, are permitted provided that the following conditions are met:
@ -25,8 +25,8 @@
#variables #variables
CONFIGSH="${0%/gettext.sh}/../config.sh"
PREFIX="/usr/local" PREFIX="/usr/local"
[ -f "../config.sh" ] && . "../config.sh"
LOCALEDIR="$PREFIX/share/locale" LOCALEDIR="$PREFIX/share/locale"
POTFILES="POTFILES" POTFILES="POTFILES"
PROGNAME="gettext.sh" PROGNAME="gettext.sh"
@ -40,6 +40,8 @@ MSGMERGE="msgmerge"
RM="rm -f" RM="rm -f"
XGETTEXT="xgettext --force-po" XGETTEXT="xgettext --force-po"
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
#functions #functions
#debug #debug
@ -112,7 +114,7 @@ _gettext_pot()
clean=0 clean=0
install=0 install=0
uninstall=0 uninstall=0
while getopts "ciuP:" name; do while getopts "ciO:uP:" name; do
case "$name" in case "$name" in
c) c)
clean=1 clean=1
@ -121,6 +123,9 @@ while getopts "ciuP:" name; do
uninstall=0 uninstall=0
install=1 install=1
;; ;;
O)
export "${OPTARG%%=*}"="${OPTARG#*=}"
;;
u) u)
install=0 install=0
uninstall=1 uninstall=1
@ -135,7 +140,7 @@ while getopts "ciuP:" name; do
esac esac
done done
shift $(($OPTIND - 1)) shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then if [ $# -lt 1 ]; then
_usage _usage
exit $? exit $?
fi fi

View File

@ -1,5 +1,5 @@
package=Camera package=Camera
version=0.2.0 version=0.3.1
vendor=Desktop vendor=Desktop
config=h,sh config=h,sh
@ -7,6 +7,19 @@ subdirs=data,doc,po,src,src/widget,tools,tests
targets=tests targets=tests
dist=COPYING,Makefile,config.h,config.sh dist=COPYING,Makefile,config.h,config.sh
#modes
[mode::debug]
title=Debug
[mode::embedded-debug]
title=Debug (embedded UI)
[mode::embedded-release]
title=Release (embedded UI)
[mode::release]
title=Release
#targets #targets
[tests] [tests]
type=command type=command

View File

@ -1,17 +1,27 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2012-2020 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2012-2024 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Camera */ /* This file is part of DeforaOS Desktop Camera */
/* This program is free software: you can redistribute it and/or modify /* Redistribution and use in source and binary forms, with or without
* it under the terms of the GNU General Public License as published by * modification, are permitted provided that the following conditions are
* the Free Software Foundation, version 3 of the License. * met:
* *
* This program is distributed in the hope that it will be useful, * 1. Redistributions of source code must retain the above copyright notice,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * this list of conditions and the following disclaimer.
* 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 * 2. Redistributions in binary form must reproduce the above copyright notice,
* along with this program. If not, see <http://www.gnu.org/licenses/>. */ * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
@ -84,6 +94,7 @@ struct _Camera
guint source; guint source;
int fd; int fd;
struct v4l2_buffer buf;
struct v4l2_capability cap; struct v4l2_capability cap;
struct v4l2_format format; struct v4l2_format format;
@ -112,7 +123,9 @@ struct _Camera
GtkWidget * widget; GtkWidget * widget;
GtkWidget * window; GtkWidget * window;
PangoFontDescription * bold; PangoFontDescription * bold;
#if !GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 0, 0)
cairo_surface_t * surface;
#else
GdkGC * gc; GdkGC * gc;
#endif #endif
#if GTK_CHECK_VERSION(2, 18, 0) #if GTK_CHECK_VERSION(2, 18, 0)
@ -175,14 +188,14 @@ static gboolean _camera_on_can_mmap(GIOChannel * channel,
GIOCondition condition, gpointer data); GIOCondition condition, gpointer data);
static gboolean _camera_on_can_read(GIOChannel * channel, static gboolean _camera_on_can_read(GIOChannel * channel,
GIOCondition condition, gpointer data); GIOCondition condition, gpointer data);
static gboolean _camera_on_drawing_area_configure(GtkWidget * widget,
GdkEventConfigure * event, gpointer data);
#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 0, 0)
static gboolean _camera_on_drawing_area_draw(GtkWidget * widget, cairo_t * cr, static gboolean _camera_on_drawing_area_draw(GtkWidget * widget, cairo_t * cr,
gpointer data); gpointer data);
static void _camera_on_drawing_area_size_allocate(GtkWidget * widget, static void _camera_on_drawing_area_size_allocate(GtkWidget * widget,
GdkRectangle * allocation, gpointer data); GdkRectangle * allocation, gpointer data);
#else #else
static gboolean _camera_on_drawing_area_configure(GtkWidget * widget,
GdkEventConfigure * event, gpointer data);
static gboolean _camera_on_drawing_area_expose(GtkWidget * widget, static gboolean _camera_on_drawing_area_expose(GtkWidget * widget,
GdkEventExpose * event, gpointer data); GdkEventExpose * event, gpointer data);
#endif #endif
@ -259,7 +272,9 @@ Camera * camera_new(GtkWidget * window, GtkAccelGroup * group,
camera->widget = NULL; camera->widget = NULL;
camera->window = window; camera->window = window;
camera->bold = NULL; camera->bold = NULL;
#if !GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 0, 0)
camera->surface = NULL;
#else
camera->gc = NULL; camera->gc = NULL;
#endif #endif
camera->pr_window = NULL; camera->pr_window = NULL;
@ -318,14 +333,14 @@ Camera * camera_new(GtkWidget * window, GtkAccelGroup * group,
#if !GTK_CHECK_VERSION(3, 0, 0) #if !GTK_CHECK_VERSION(3, 0, 0)
camera->pixmap = NULL; camera->pixmap = NULL;
#endif #endif
g_signal_connect(camera->area, "configure-event", G_CALLBACK(
_camera_on_drawing_area_configure), camera);
#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 0, 0)
g_signal_connect(camera->area, "draw", G_CALLBACK( g_signal_connect(camera->area, "draw", G_CALLBACK(
_camera_on_drawing_area_draw), camera); _camera_on_drawing_area_draw), camera);
g_signal_connect(camera->area, "size-allocate", G_CALLBACK( g_signal_connect(camera->area, "size-allocate", G_CALLBACK(
_camera_on_drawing_area_size_allocate), camera); _camera_on_drawing_area_size_allocate), camera);
#else #else
g_signal_connect(camera->area, "configure-event", G_CALLBACK(
_camera_on_drawing_area_configure), camera);
g_signal_connect(camera->area, "expose-event", G_CALLBACK( g_signal_connect(camera->area, "expose-event", G_CALLBACK(
_camera_on_drawing_area_expose), camera); _camera_on_drawing_area_expose), camera);
#endif #endif
@ -864,20 +879,52 @@ static void _properties_window(Camera * camera)
GtkSizeGroup * group; GtkSizeGroup * group;
GtkWidget * vbox; GtkWidget * vbox;
GtkWidget * hbox; GtkWidget * hbox;
char buf[64]; char buf[256];
const struct const struct
{ {
unsigned int capability; unsigned int capability;
char const * name; char const * name;
} capabilities[] = } capabilities[] =
{ {
{ V4L2_CAP_VIDEO_CAPTURE, "capture" }, { V4L2_CAP_VIDEO_CAPTURE, "video capture" },
{ V4L2_CAP_VIDEO_OUTPUT, "output" }, #ifdef V4L2_CAP_VIDEO_OUTPUT
{ V4L2_CAP_VIDEO_OVERLAY, "overlay" }, { V4L2_CAP_VIDEO_OUTPUT, "video output" },
#endif
#ifdef V4L2_CAP_VIDEO_OVERLAY
{ V4L2_CAP_VIDEO_OVERLAY, "video overlay" },
#endif
#ifdef V4L2_CAP_VBI_CAPTURE
{ V4L2_CAP_VBI_CAPTURE, "VBI capture" },
#endif
#ifdef V4L2_CAP_VBI_OUTPUT
{ V4L2_CAP_VBI_OUTPUT, "VBI output" },
#endif
#ifdef V4L2_CAP_RDS_CAPTURE
{ V4L2_CAP_RDS_CAPTURE, "RDS capture" },
#endif
#ifdef V4L2_CAP_RDS_OUTPUT
{ V4L2_CAP_RDS_OUTPUT, "RDS encoder" },
#endif
#ifdef V4L2_CAP_TUNER
{ V4L2_CAP_TUNER, "tuner" }, { V4L2_CAP_TUNER, "tuner" },
#endif
#ifdef V4L2_CAP_AUDIO
{ V4L2_CAP_AUDIO, "audio" }, { V4L2_CAP_AUDIO, "audio" },
#endif
#ifdef V4L2_CAP_RADIO
{ V4L2_CAP_RADIO, "radio" },
#endif
#ifdef V4L2_CAP_MODULATOR
{ V4L2_CAP_MODULATOR, "modulator" },
#endif
{ V4L2_CAP_READWRITE, "read/write" },
#ifdef V4L2_CAP_ASYNCIO
{ V4L2_CAP_ASYNCIO, "async I/O" },
#endif
{ V4L2_CAP_STREAMING, "streaming" }, { V4L2_CAP_STREAMING, "streaming" },
{ 0, NULL } #ifdef V4L2_CAP_TOUCH
{ V4L2_CAP_TOUCH, "touch" }
#endif
}; };
unsigned int i; unsigned int i;
char const * sep = ""; char const * sep = "";
@ -919,12 +966,12 @@ static void _properties_window(Camera * camera)
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
/* capabilities */ /* capabilities */
buf[0] = '\0'; buf[0] = '\0';
for(i = 0; capabilities[i].name != NULL; i++) for(i = 0; i < sizeof(capabilities) / sizeof(*capabilities); i++)
if(camera->cap.capabilities & capabilities[i].capability) if(camera->cap.capabilities & capabilities[i].capability)
{ {
strncat(buf, sep, sizeof(buf) - strlen(buf)); strncat(buf, sep, sizeof(buf) - strlen(buf) - 1);
strncat(buf, capabilities[i].name, sizeof(buf) strncat(buf, capabilities[i].name, sizeof(buf)
- strlen(buf)); - strlen(buf) - 1);
sep = ", "; sep = ", ";
} }
buf[sizeof(buf) - 1] = '\0'; buf[sizeof(buf) - 1] = '\0';
@ -996,7 +1043,8 @@ static int _snapshot_dcim(Camera * camera, char const * homedir,
if(mkdir(path, 0777) != 0 && errno != EEXIST) if(mkdir(path, 0777) != 0 && errno != EEXIST)
{ {
error_set_code(-errno, "%s: %s: %s", error_set_code(-errno, "%s: %s: %s",
_("Could not save picture"), path, strerror(errno)); _("Could not save picture"), path,
strerror(errno));
free(path); free(path);
return -_camera_error(camera, error_get(NULL), 1); return -_camera_error(camera, error_get(NULL), 1);
} }
@ -1128,7 +1176,11 @@ void camera_stop(Camera * camera)
if(camera->pixbuf != NULL) if(camera->pixbuf != NULL)
g_object_unref(camera->pixbuf); g_object_unref(camera->pixbuf);
camera->pixbuf = NULL; camera->pixbuf = NULL;
#if !GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 0, 0)
if(camera->surface != NULL)
cairo_surface_destroy(camera->surface);
camera->surface = NULL;
#else
if(camera->pixmap != NULL) if(camera->pixmap != NULL)
g_object_unref(camera->pixmap); g_object_unref(camera->pixmap);
camera->pixmap = NULL; camera->pixmap = NULL;
@ -1139,15 +1191,20 @@ void camera_stop(Camera * camera)
if((char *)camera->rgb_buffer != camera->raw_buffer) if((char *)camera->rgb_buffer != camera->raw_buffer)
free(camera->rgb_buffer); free(camera->rgb_buffer);
camera->rgb_buffer = NULL; camera->rgb_buffer = NULL;
for(i = 0; i < camera->buffers_cnt; i++) if(camera->buffers_cnt > 0)
if(camera->buffers[i].start != MAP_FAILED) {
munmap(camera->buffers[i].start, for(i = 0; i < camera->buffers_cnt; i++)
camera->buffers[i].length); if(camera->buffers[i].start != MAP_FAILED)
free(camera->buffers); munmap(camera->buffers[i].start,
camera->buffers = NULL; camera->buffers[i].length);
camera->buffers_cnt = 0; free(camera->buffers);
free(camera->raw_buffer); camera->buffers = NULL;
camera->buffers_cnt = 0;
}
else
free(camera->raw_buffer);
camera->raw_buffer = NULL; camera->raw_buffer = NULL;
camera->raw_buffer_cnt = 0;
} }
@ -1224,29 +1281,38 @@ static gboolean _camera_on_can_mmap(GIOChannel * channel,
GIOCondition condition, gpointer data) GIOCondition condition, gpointer data)
{ {
Camera * camera = data; Camera * camera = data;
struct v4l2_buffer buf;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s()\n", __func__); fprintf(stderr, "DEBUG: %s()\n", __func__);
#endif #endif
if(channel != camera->channel || condition != G_IO_IN) if(channel != camera->channel || condition != G_IO_IN)
return FALSE; return FALSE;
if(_camera_ioctl(camera, VIDIOC_DQBUF, &buf) == -1) memset(&camera->buf, 0, sizeof(camera->buf));
camera->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
camera->buf.memory = V4L2_MEMORY_MMAP;
if(_camera_ioctl(camera, VIDIOC_DQBUF, &camera->buf) == -1)
{ {
_camera_error(camera, _("Could not save picture"), 1); _camera_error(camera, _("Could not dequeue buffer"), 1);
camera->source = 0;
return FALSE; return FALSE;
} }
camera->raw_buffer = camera->buffers[buf.index].start; if(camera->buf.index >= camera->buffers_cnt)
camera->raw_buffer_cnt = buf.bytesused; {
#if 0 /* FIXME the raw buffer is not meant to be free()'d */ #ifdef DEBUG
fprintf(stderr, "DEBUG: %s() %u >= %zu\n", __func__,
camera->buf.index, camera->buffers_cnt);
#endif
_camera_error(camera, _("Invalid buffer index"), 1);
camera->source = 0;
return FALSE;
}
camera->raw_buffer = camera->buffers[camera->buf.index].start;
camera->raw_buffer_cnt = camera->buffers[camera->buf.index].length;
#ifdef DEBUG
fprintf(stderr, "DEBUG: %s() %lu\n", __func__, camera->raw_buffer_cnt);
#endif
camera->source = g_idle_add(_camera_on_refresh, camera); camera->source = g_idle_add(_camera_on_refresh, camera);
return FALSE; return FALSE;
#else
_camera_on_refresh(camera);
camera->raw_buffer = NULL;
camera->raw_buffer_cnt = 0;
return TRUE;
#endif
} }
@ -1264,6 +1330,7 @@ static gboolean _camera_on_can_read(GIOChannel * channel,
#endif #endif
if(channel != camera->channel || condition != G_IO_IN) if(channel != camera->channel || condition != G_IO_IN)
return FALSE; return FALSE;
size = camera->raw_buffer_cnt;
status = g_io_channel_read_chars(channel, camera->raw_buffer, status = g_io_channel_read_chars(channel, camera->raw_buffer,
camera->raw_buffer_cnt, &size, &error); camera->raw_buffer_cnt, &size, &error);
/* this status can be ignored */ /* this status can be ignored */
@ -1299,6 +1366,33 @@ static gboolean _camera_on_can_read(GIOChannel * channel,
#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 0, 0)
/* camera_on_drawing_area_configure */
static gboolean _camera_on_drawing_area_configure(GtkWidget * widget,
GdkEventConfigure * event, gpointer data)
{
Camera * camera = data;
GtkAllocation * allocation = &camera->area_allocation;
cairo_t * cr;
(void) event;
gtk_widget_get_allocation(widget, allocation);
#ifdef DEBUG
fprintf(stderr, "DEBUG: %s() %dx%d\n", __func__, allocation->width,
allocation->height);
#endif
if(camera->surface != NULL)
cairo_surface_destroy(camera->surface);
camera->surface = gdk_window_create_similar_surface(
gtk_widget_get_window(widget), CAIRO_CONTENT_COLOR,
allocation->width, allocation->height);
cr = cairo_create(camera->surface);
cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
cairo_paint(cr);
cairo_destroy(cr);
return TRUE;
}
/* camera_on_drawing_area_draw */ /* camera_on_drawing_area_draw */
static gboolean _camera_on_drawing_area_draw(GtkWidget * widget, cairo_t * cr, static gboolean _camera_on_drawing_area_draw(GtkWidget * widget, cairo_t * cr,
gpointer data) gpointer data)
@ -1307,14 +1401,11 @@ static gboolean _camera_on_drawing_area_draw(GtkWidget * widget, cairo_t * cr,
(void) widget; (void) widget;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s() %p\n", __func__, camera->pixbuf); fprintf(stderr, "DEBUG: %s()\n", __func__);
#endif #endif
if(camera->pixbuf != NULL) cairo_set_source_surface(cr, camera->surface, 0, 0);
{ cairo_paint(cr);
gdk_cairo_set_source_pixbuf(cr, camera->pixbuf, 0, 0); return FALSE;
cairo_paint(cr);
}
return TRUE;
} }
@ -1403,9 +1494,7 @@ static void _camera_on_gallery(gpointer data)
/* camera_on_open */ /* camera_on_open */
static int _open_setup(Camera * camera); static int _open_setup(Camera * camera);
#ifdef NOTYET
static int _open_setup_mmap(Camera * camera); static int _open_setup_mmap(Camera * camera);
#endif
static int _open_setup_read(Camera * camera); static int _open_setup_read(Camera * camera);
static gboolean _camera_on_open(gpointer data) static gboolean _camera_on_open(gpointer data)
@ -1444,9 +1533,6 @@ static gboolean _camera_on_open(gpointer data)
gtk_widget_set_sensitive( gtk_widget_set_sensitive(
GTK_WIDGET(_camera_toolbar[CT_PROPERTIES].widget), GTK_WIDGET(_camera_toolbar[CT_PROPERTIES].widget),
TRUE); TRUE);
/* FIXME allow the window to be smaller */
gtk_widget_set_size_request(camera->area, camera->format.fmt.pix.width,
camera->format.fmt.pix.height);
return FALSE; return FALSE;
} }
@ -1480,19 +1566,36 @@ static int _open_setup(Camera * camera)
_("Cropping not supported")); _("Cropping not supported"));
} }
/* obtain the current format */ /* obtain the current format */
camera->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if(_camera_ioctl(camera, VIDIOC_G_FMT, &camera->format) == -1) if(_camera_ioctl(camera, VIDIOC_G_FMT, &camera->format) == -1)
return -error_set_code(1, "%s: %s", camera->device, return -error_set_code(1, "%s: %s", camera->device,
_("Could not obtain the video capture format")); _("Could not obtain the video capture format"));
/* check the current format */ /* try to set a specific format */
if(camera->format.fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV)
{
camera->format.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
if(_camera_ioctl(camera, VIDIOC_S_FMT, &camera->format) == -1)
return -error_set_code(1, "%s: %s", camera->device,
_("Could not set the video capture format"));
/* refresh the current format */
if(_camera_ioctl(camera, VIDIOC_G_FMT, &camera->format) == -1)
return -error_set_code(1, "%s: %s", camera->device,
_("Could not obtain the video capture format"));
}
/* verify the current format */
if(camera->format.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) if(camera->format.type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -error_set_code(1, "%s: %s", camera->device, return -error_set_code(1, "%s: %s", camera->device,
_("Unsupported video capture type")); _("Unsupported video capture type"));
if((camera->cap.capabilities & V4L2_CAP_STREAMING) != 0) if((camera->cap.capabilities & V4L2_CAP_STREAMING) != 0)
#ifdef NOTYET {
ret = _open_setup_mmap(camera); if((ret = _open_setup_mmap(camera)) != 0
#else && (camera->cap.capabilities
ret = _open_setup_read(camera); & V4L2_CAP_READWRITE) != 0)
#endif {
camera_stop(camera);
ret = _open_setup_read(camera);
}
}
else if((camera->cap.capabilities & V4L2_CAP_READWRITE) != 0) else if((camera->cap.capabilities & V4L2_CAP_READWRITE) != 0)
ret = _open_setup_read(camera); ret = _open_setup_read(camera);
else else
@ -1516,12 +1619,14 @@ static int _open_setup(Camera * camera)
return 0; return 0;
} }
#ifdef NOTYET
static int _open_setup_mmap(Camera * camera) static int _open_setup_mmap(Camera * camera)
{ {
struct v4l2_requestbuffers req; struct v4l2_requestbuffers req;
size_t i; size_t i;
struct v4l2_buffer buf; struct v4l2_buffer buf;
enum v4l2_buf_type type;
size_t cnt;
char * p;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s()\n", __func__); fprintf(stderr, "DEBUG: %s()\n", __func__);
@ -1533,17 +1638,18 @@ static int _open_setup_mmap(Camera * camera)
if(_camera_ioctl(camera, VIDIOC_REQBUFS, &req) == -1) if(_camera_ioctl(camera, VIDIOC_REQBUFS, &req) == -1)
return -error_set_code(1, "%s: %s", camera->device, return -error_set_code(1, "%s: %s", camera->device,
_("Could not request buffers")); _("Could not request buffers"));
#ifdef DEBUG
fprintf(stderr, "DEBUG: %s() frames=%u\n", __func__, req.count);
#endif
if(req.count < 2) if(req.count < 2)
return -error_set_code(1, "%s: %s", camera->device, return -error_set_code(1, "%s: %s", camera->device,
_("Could not obtain enough buffers")); _("Could not obtain enough buffers"));
if((camera->buffers = malloc(sizeof(*camera->buffers) * req.count)) /* initialize the buffers */
if((camera->buffers = calloc(req.count, sizeof(*camera->buffers)))
== NULL) == NULL)
return -error_set_code(1, "%s: %s", camera->device, return -error_set_code(1, "%s: %s", camera->device,
_("Could not allocate buffers")); _("Could not allocate buffers"));
camera->buffers_cnt = req.count; camera->buffers_cnt = req.count;
/* initialize the buffers */
memset(camera->buffers, 0, sizeof(*camera->buffers)
* camera->buffers_cnt);
for(i = 0; i < camera->buffers_cnt; i++) for(i = 0; i < camera->buffers_cnt; i++)
camera->buffers[i].start = MAP_FAILED; camera->buffers[i].start = MAP_FAILED;
/* map the buffers */ /* map the buffers */
@ -1564,9 +1670,30 @@ static int _open_setup_mmap(Camera * camera)
_("Could not map buffers")); _("Could not map buffers"));
camera->buffers[i].length = buf.length; camera->buffers[i].length = buf.length;
} }
for(i = 0; i < camera->buffers_cnt; i++)
{
memset(&camera->buf, 0, sizeof(camera->buf));
camera->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
camera->buf.memory = V4L2_MEMORY_MMAP;
camera->buf.index = i;
if(_camera_ioctl(camera, VIDIOC_QBUF, &camera->buf) == -1)
return -error_set_code(1, "%s: %s", camera->device,
_("Could not queue buffers"));
}
/* start the stream */
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if(_camera_ioctl(camera, VIDIOC_STREAMON, &type) == -1)
return -error_set_code(1, "%s: %s", camera->device,
_("Could not start the stream"));
/* allocate the RGB buffer */
cnt = camera->format.fmt.pix.width * camera->format.fmt.pix.height * 3;
if((p = realloc(camera->rgb_buffer, cnt)) == NULL)
return error_set_code(-errno, "%s: %s", camera->device,
strerror(errno));
camera->rgb_buffer = (unsigned char *)p;
camera->rgb_buffer_cnt = cnt;
return 0; return 0;
} }
#endif
static int _open_setup_read(Camera * camera) static int _open_setup_read(Camera * camera)
{ {
@ -1584,7 +1711,7 @@ static int _open_setup_read(Camera * camera)
strerror(errno)); strerror(errno));
camera->raw_buffer = p; camera->raw_buffer = p;
camera->raw_buffer_cnt = cnt; camera->raw_buffer_cnt = cnt;
/* allocate the rgb buffer */ /* allocate the RGB buffer */
cnt = camera->format.fmt.pix.width * camera->format.fmt.pix.height * 3; cnt = camera->format.fmt.pix.width * camera->format.fmt.pix.height * 3;
if((p = realloc(camera->rgb_buffer, cnt)) == NULL) if((p = realloc(camera->rgb_buffer, cnt)) == NULL)
return error_set_code(-errno, "%s: %s", camera->device, return error_set_code(-errno, "%s: %s", camera->device,
@ -1627,7 +1754,8 @@ static void _refresh_vflip(Camera * camera, GdkPixbuf ** pixbuf);
static gboolean _camera_on_refresh(gpointer data) static gboolean _camera_on_refresh(gpointer data)
{ {
Camera * camera = data; Camera * camera = data;
#if !GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 0, 0)
cairo_t * cr;
GtkAllocation * allocation = &camera->area_allocation; GtkAllocation * allocation = &camera->area_allocation;
#endif #endif
int width = camera->format.fmt.pix.width; int width = camera->format.fmt.pix.width;
@ -1638,22 +1766,32 @@ static gboolean _camera_on_refresh(gpointer data)
camera->format.fmt.pix.pixelformat); camera->format.fmt.pix.pixelformat);
#endif #endif
_refresh_convert(camera); _refresh_convert(camera);
#if !GTK_CHECK_VERSION(3, 0, 0)
if(camera->hflip == FALSE if(camera->hflip == FALSE
&& camera->vflip == FALSE && camera->vflip == FALSE
&& width == allocation->width && width == allocation->width
&& height == allocation->height && height == allocation->height
&& camera->overlays_cnt == 0) && camera->overlays_cnt == 0)
{
/* render directly */ /* render directly */
#if GTK_CHECK_VERSION(3, 0, 0)
cr = cairo_create(camera->surface);
camera->pixbuf = gdk_pixbuf_new_from_data(camera->rgb_buffer,
GDK_COLORSPACE_RGB, FALSE, 8, width, height,
width * 3, NULL, NULL);
gdk_cairo_set_source_pixbuf(cr, camera->pixbuf, 0.0, 0.0);
cairo_paint(cr);
cairo_destroy(cr);
#else
gdk_draw_rgb_image(camera->pixmap, camera->gc, 0, 0, gdk_draw_rgb_image(camera->pixmap, camera->gc, 0, 0,
width, height, GDK_RGB_DITHER_NORMAL, width, height, GDK_RGB_DITHER_NORMAL,
camera->rgb_buffer, width * 3); camera->rgb_buffer, width * 3);
else
#endif #endif
}
else
{ {
/* render after scaling */
if(camera->pixbuf != NULL) if(camera->pixbuf != NULL)
g_object_unref(camera->pixbuf); g_object_unref(camera->pixbuf);
/* render after scaling */
camera->pixbuf = gdk_pixbuf_new_from_data(camera->rgb_buffer, camera->pixbuf = gdk_pixbuf_new_from_data(camera->rgb_buffer,
GDK_COLORSPACE_RGB, FALSE, 8, width, height, GDK_COLORSPACE_RGB, FALSE, 8, width, height,
width * 3, NULL, NULL); width * 3, NULL, NULL);
@ -1661,7 +1799,12 @@ static gboolean _camera_on_refresh(gpointer data)
_refresh_vflip(camera, &camera->pixbuf); _refresh_vflip(camera, &camera->pixbuf);
_refresh_scale(camera, &camera->pixbuf); _refresh_scale(camera, &camera->pixbuf);
_refresh_overlays(camera, camera->pixbuf); _refresh_overlays(camera, camera->pixbuf);
#if !GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 0, 0)
cr = cairo_create(camera->surface);
gdk_cairo_set_source_pixbuf(cr, camera->pixbuf, 0.0, 0.0);
cairo_paint(cr);
cairo_destroy(cr);
#else
gdk_pixbuf_render_to_drawable(camera->pixbuf, camera->pixmap, gdk_pixbuf_render_to_drawable(camera->pixbuf, camera->pixmap,
camera->gc, 0, 0, 0, 0, -1, -1, camera->gc, 0, 0, 0, 0, -1, -1,
GDK_RGB_DITHER_NORMAL, 0, 0); GDK_RGB_DITHER_NORMAL, 0, 0);
@ -1669,9 +1812,20 @@ static gboolean _camera_on_refresh(gpointer data)
} }
/* force a refresh */ /* force a refresh */
gtk_widget_queue_draw(camera->area); gtk_widget_queue_draw(camera->area);
camera->source = g_io_add_watch(camera->channel, G_IO_IN, /* read from the camera again */
(camera->buffers != NULL) ? _camera_on_can_mmap if(camera->buffers != NULL)
: _camera_on_can_read, camera); {
if(_camera_ioctl(camera, VIDIOC_QBUF, &camera->buf) == -1)
{
fprintf(stderr, "%s\n", strerror(errno));
_camera_error(camera, _("Could not queue buffer"), 1);
}
camera->source = g_io_add_watch(camera->channel, G_IO_IN,
_camera_on_can_mmap, camera);
}
else
camera->source = g_io_add_watch(camera->channel, G_IO_IN,
_camera_on_can_read, camera);
return FALSE; return FALSE;
} }

View File

@ -1,17 +1,27 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2012-2018 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2012-2020 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Camera */ /* This file is part of DeforaOS Desktop Camera */
/* This program is free software: you can redistribute it and/or modify /* Redistribution and use in source and binary forms, with or without
* it under the terms of the GNU General Public License as published by * modification, are permitted provided that the following conditions are
* the Free Software Foundation, version 3 of the License. * met:
* *
* This program is distributed in the hope that it will be useful, * 1. Redistributions of source code must retain the above copyright notice,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * this list of conditions and the following disclaimer.
* 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 * 2. Redistributions in binary form must reproduce the above copyright notice,
* along with this program. If not, see <http://www.gnu.org/licenses/>. */ * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

View File

@ -1,17 +1,27 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2012-2018 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2012-2024 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Camera */ /* This file is part of DeforaOS Desktop Camera */
/* This program is free software: you can redistribute it and/or modify /* Redistribution and use in source and binary forms, with or without
* it under the terms of the GNU General Public License as published by * modification, are permitted provided that the following conditions are
* the Free Software Foundation, version 3 of the License. * met:
* *
* This program is distributed in the hope that it will be useful, * 1. Redistributions of source code must retain the above copyright notice,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * this list of conditions and the following disclaimer.
* 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 * 2. Redistributions in binary form must reproduce the above copyright notice,
* along with this program. If not, see <http://www.gnu.org/licenses/>. */ * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
@ -20,8 +30,10 @@
#include <locale.h> #include <locale.h>
#include <libintl.h> #include <libintl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#if GTK_CHECK_VERSION(3, 0, 0) #if defined(GDK_WINDOWING_X11)
# include <gtk/gtkx.h> # if GTK_CHECK_VERSION(3, 0, 0)
# include <gtk/gtkx.h>
# endif
#endif #endif
#include <System.h> #include <System.h>
#include "camera.h" #include "camera.h"
@ -57,7 +69,9 @@ static int _usage(void);
/* camera */ /* camera */
static int _camera_embedded(char const * device, int hflip, int vflip, static int _camera_embedded(char const * device, int hflip, int vflip,
int ratio, char const * overlay); int ratio, char const * overlay);
#if defined(GDK_WINDOWING_X11)
static void _embedded_on_embedded(gpointer data); static void _embedded_on_embedded(gpointer data);
#endif
static int _camera(int embedded, char const * device, int hflip, int vflip, static int _camera(int embedded, char const * device, int hflip, int vflip,
int ratio, char const * overlay) int ratio, char const * overlay)
@ -85,6 +99,16 @@ static int _camera(int embedded, char const * device, int hflip, int vflip,
static int _camera_embedded(char const * device, int hflip, int vflip, static int _camera_embedded(char const * device, int hflip, int vflip,
int ratio, char const * overlay) int ratio, char const * overlay)
{ {
#if !defined(GDK_WINDOWING_X11)
(void) device;
(void) hflip;
(void) vflip;
(void) ratio;
(void) overlay;
error_set_code(-ENOSYS, "%s", strerror(ENOSYS));
return -1;
#else
GtkWidget * window; GtkWidget * window;
GtkWidget * widget; GtkWidget * widget;
Camera * camera; Camera * camera;
@ -117,14 +141,17 @@ static int _camera_embedded(char const * device, int hflip, int vflip,
camera_delete(camera); camera_delete(camera);
gtk_widget_destroy(window); gtk_widget_destroy(window);
return 0; return 0;
#endif
} }
#if defined(GDK_WINDOWING_X11)
static void _embedded_on_embedded(gpointer data) static void _embedded_on_embedded(gpointer data)
{ {
GtkWidget * widget = data; GtkWidget * widget = data;
gtk_widget_show(widget); gtk_widget_show(widget);
} }
#endif
/* error */ /* error */

View File

@ -1,17 +1,27 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2013 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2013-2020 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Camera */ /* This file is part of DeforaOS Desktop Camera */
/* This program is free software: you can redistribute it and/or modify /* Redistribution and use in source and binary forms, with or without
* it under the terms of the GNU General Public License as published by * modification, are permitted provided that the following conditions are
* the Free Software Foundation, version 3 of the License. * met:
* *
* This program is distributed in the hope that it will be useful, * 1. Redistributions of source code must retain the above copyright notice,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * this list of conditions and the following disclaimer.
* 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 * 2. Redistributions in binary form must reproduce the above copyright notice,
* along with this program. If not, see <http://www.gnu.org/licenses/>. */ * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

View File

@ -1,17 +1,27 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2013 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2013-2020 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Camera */ /* This file is part of DeforaOS Desktop Camera */
/* This program is free software: you can redistribute it and/or modify /* Redistribution and use in source and binary forms, with or without
* it under the terms of the GNU General Public License as published by * modification, are permitted provided that the following conditions are
* the Free Software Foundation, version 3 of the License. * met:
* *
* This program is distributed in the hope that it will be useful, * 1. Redistributions of source code must retain the above copyright notice,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * this list of conditions and the following disclaimer.
* 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 * 2. Redistributions in binary form must reproduce the above copyright notice,
* along with this program. If not, see <http://www.gnu.org/licenses/>. */ * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

View File

@ -5,15 +5,27 @@ ldflags_force=`pkg-config --libs libDesktop` -lintl
ldflags=-pie -Wl,-z,relro -Wl,-z,now ldflags=-pie -Wl,-z,relro -Wl,-z,now
dist=Makefile,camera.h,overlay.h,window.h dist=Makefile,camera.h,overlay.h,window.h
#for Gtk+ 3 #modes
cflags_force=`pkg-config --cflags libDesktop gtk+-x11-3.0` [mode::debug]
ldflags_force=`pkg-config --libs libDesktop gtk+-x11-3.0` -lintl
[mode::embedded-debug]
cppflags_force=-DEMBEDDED
[mode::embedded-release]
cppflags_force=-DEMBEDDED -DNDEBUG
cflags=-W -Wall -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
[mode::release]
cppflags_force=-DNDEBUG
cflags=-W -Wall -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
#targets
[camera] [camera]
type=binary type=binary
sources=camera.c,overlay.c,window.c,main.c sources=camera.c,overlay.c,window.c,main.c
install=$(BINDIR) install=$(BINDIR)
#sources
[camera.c] [camera.c]
depends=overlay.h,camera.h,../config.h depends=overlay.h,camera.h,../config.h

View File

@ -1,17 +1,27 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2015-2018 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2015-2020 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Camera */ /* This file is part of DeforaOS Desktop Camera */
/* This program is free software: you can redistribute it and/or modify /* Redistribution and use in source and binary forms, with or without
* it under the terms of the GNU General Public License as published by * modification, are permitted provided that the following conditions are
* the Free Software Foundation, version 3 of the License. * met:
* *
* This program is distributed in the hope that it will be useful, * 1. Redistributions of source code must retain the above copyright notice,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * this list of conditions and the following disclaimer.
* 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 * 2. Redistributions in binary form must reproduce the above copyright notice,
* along with this program. If not, see <http://www.gnu.org/licenses/>. */ * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

View File

@ -1,17 +1,30 @@
targets=camera targets=camera
cflags_force=`pkg-config --cflags libDesktop` -fPIC cflags_force=`pkg-config --cflags libDesktop` -fPIC
cflags=-W -Wall -g -O2 -D_FORTIFY_SOURCE=2 -fstack-protector cflags=-W -Wall -g -O2 -D_FORTIFY_SOURCE=2 -fstack-protector
ldflags_force=`pkg-config --libs libDesktop` -lintl #ldflags_force=`pkg-config --libs libDesktop` -lintl
ldflags=-Wl,-z,relro -Wl,-z,now ldflags=-Wl,-z,relro -Wl,-z,now
#for Gtk+ 3
#cflags_force=-W `pkg-config --cflags libDesktop gtk+-x11-3.0`
#ldflags_force=`pkg-config --libs libDesktop gtk+-x11-3.0` -lintl
dist=Makefile dist=Makefile
#modes
[mode::debug]
[mode::embedded-debug]
cppflags_force=-DEMBEDDED
[mode::embedded-release]
cppflags_force=-DEMBEDDED -DNDEBUG
cflags=-W -Wall -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
[mode::release]
cppflags_force=-DNDEBUG
cflags=-W -Wall -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
#targets
[camera] [camera]
type=plugin type=plugin
sources=camera.c sources=camera.c
install=$(LIBDIR)/Desktop/widget install=$(LIBDIR)/Desktop/widget
#sources
[widget.c] [widget.c]
depends=../camera.h,../camera.c,../overlay.h,../overlay.c depends=../camera.h,../camera.c,../overlay.h,../overlay.c

View File

@ -1,19 +1,29 @@
/* $Id$ */ /* $Id$ */
static char const _copyright[] = static char const _copyright[] =
"Copyright © 2012-2018 Pierre Pronchery <khorben@defora.org>"; "Copyright © 2012-2020 Pierre Pronchery <khorben@defora.org>";
/* This file is part of DeforaOS Desktop Camera */ /* This file is part of DeforaOS Desktop Camera */
static char const _license[] = static char const _license[] =
"This program is free software: you can redistribute it and/or modify\n" "Redistribution and use in source and binary forms, with or without\n"
"it under the terms of the GNU General Public License as published by\n" "modification, are permitted provided that the following conditions are\n"
"the Free Software Foundation, version 3 of the License.\n" "met:\n"
"\n" "\n"
"This program is distributed in the hope that it will be useful,\n" "1. Redistributions of source code must retain the above copyright notice,\n"
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" " this list of conditions and the following disclaimer.\n"
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
"GNU General Public License for more details.\n"
"\n" "\n"
"You should have received a copy of the GNU General Public License\n" "2. Redistributions in binary form must reproduce the above copyright notice,\n"
"along with this program. If not, see <http://www.gnu.org/licenses/>."; " this list of conditions and the following disclaimer in the documentation\n"
" and/or other materials provided with the distribution.\n"
"\n"
"THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS \"AS IS\" AND ANY\n"
"EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n"
"WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n"
"DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY\n"
"DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n"
"(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n"
"LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n"
"ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n"
"(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n"
"THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.";
@ -191,6 +201,7 @@ CameraWindow * camerawindow_new(char const * device)
# endif # endif
gtk_window_set_title(GTK_WINDOW(camera->window), _("Camera")); gtk_window_set_title(GTK_WINDOW(camera->window), _("Camera"));
#endif #endif
gtk_window_set_default_size(GTK_WINDOW(camera->window), 640, 480);
g_signal_connect_swapped(camera->window, "delete-event", G_CALLBACK( g_signal_connect_swapped(camera->window, "delete-event", G_CALLBACK(
_camerawindow_on_closex), camera); _camerawindow_on_closex), camera);
g_signal_connect(camera->window, "window-state-event", G_CALLBACK( g_signal_connect(camera->window, "window-state-event", G_CALLBACK(

View File

@ -1,17 +1,27 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2013-2014 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2013-2020 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Camera */ /* This file is part of DeforaOS Desktop Camera */
/* This program is free software: you can redistribute it and/or modify /* Redistribution and use in source and binary forms, with or without
* it under the terms of the GNU General Public License as published by * modification, are permitted provided that the following conditions are
* the Free Software Foundation, version 3 of the License. * met:
* *
* This program is distributed in the hope that it will be useful, * 1. Redistributions of source code must retain the above copyright notice,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * this list of conditions and the following disclaimer.
* 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 * 2. Redistributions in binary form must reproduce the above copyright notice,
* along with this program. If not, see <http://www.gnu.org/licenses/>. */ * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
#$Id$ #$Id$
#Copyright (c) 2016-2019 Pierre Pronchery <khorben@defora.org> #Copyright (c) 2016-2021 Pierre Pronchery <khorben@defora.org>
# #
#Redistribution and use in source and binary forms, with or without #Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are met: #modification, are permitted provided that the following conditions are met:
@ -25,6 +25,7 @@
#variables #variables
CONFIGSH="${0%/clint.sh}/../config.sh"
CFLAGS= CFLAGS=
CPPFLAGS= CPPFLAGS=
PROGNAME="clint.sh" PROGNAME="clint.sh"
@ -32,19 +33,23 @@ PROJECTCONF="../project.conf"
#executables #executables
DATE="date" DATE="date"
DEBUG="_debug" DEBUG="_debug"
ECHO="/bin/echo"
FIND="find" FIND="find"
GREP="grep" GREP="grep"
LINT="lint -g" LINT="lint -g"
MKDIR="mkdir -p"
SORT="sort -n" SORT="sort -n"
TR="tr" TR="tr"
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
#functions #functions
#clint #clint
_clint() _clint()
{ {
ret=0 res=0
subdirs="data doc src tests tools" subdirs=
$DATE $DATE
while read line; do while read line; do
@ -58,43 +63,58 @@ _clint()
;; ;;
esac esac
done < "$PROJECTCONF" done < "$PROJECTCONF"
if [ ! -n "$subdirs" ]; then
_error "Could not locate directories to analyze"
return $?
fi
for subdir in $subdirs; do for subdir in $subdirs; do
[ -d "../$subdir" ] || continue [ -d "../$subdir" ] || continue
for filename in $($FIND "../$subdir" -type f | $SORT); do while read filename; do
[ -n "$filename" ] || continue
r=0
case "$filename" in case "$filename" in
*.c) *.c)
echo echo
(_clint_lint "$filename"; _clint_lint "$filename" || r=$?
_clint_rtrim "$filename") _clint_rtrim "$filename"|| r=$?
;; ;;
*.h) *.h)
echo echo
echo "$filename:" echo "$filename:"
(_clint_rtrim "$filename") _clint_rtrim "$filename"|| r=$?
;; ;;
*) *)
continue continue
;; ;;
esac esac
if [ $? -ne 0 ]; then if [ $r -eq 0 ]; then
echo " OK"
echo "$PROGNAME: $filename: OK" 1>&2
else
echo "FAIL" echo "FAIL"
echo "$PROGNAME: $filename: FAIL" 1>&2 echo "$PROGNAME: $filename: FAIL" 1>&2
ret=2 res=2
else
echo "OK"
fi fi
done done << EOF
$($FIND "../$subdir" -type f | $SORT)
EOF
done done
return $ret return $res
} }
_clint_lint() _clint_lint()
{ {(
filename="$1" filename="$1"
echo -n "${filename%/*}/" $ECHO -n "${filename%/*}/"
$DEBUG $LINT $CPPFLAGS $CFLAGS "$filename" 2>&1 $DEBUG $LINT $CPPFLAGS $CFLAGS "$filename" 2>&1
} ret=$?
if [ $ret -eq 127 ]; then
#XXX ignore errors when $LINT is not available
ret=0
fi
return $ret
)}
_clint_rtrim() _clint_rtrim()
{ {
@ -110,10 +130,14 @@ _debug()
{ {
echo "$@" 1>&3 echo "$@" 1>&3
"$@" "$@"
res=$? }
#ignore errors when the command is not available
[ $res -eq 127 ] && return 0
return $res #error
_error()
{
echo "$PROGNAME: $@" 1>&2
return 2
} }
@ -125,14 +149,6 @@ _usage()
} }
#warning
_warning()
{
echo "$PROGNAME: $@" 1>&2
return 2
}
#main #main
clean=0 clean=0
while getopts "cO:P:" name; do while getopts "cO:P:" name; do
@ -162,9 +178,15 @@ fi
[ $clean -ne 0 ] && exit 0 [ $clean -ne 0 ] && exit 0
exec 3>&1 exec 3>&1
ret=0
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
target="$1" target="$1"
dirname="${target%/*}"
shift shift
_clint > "$target" || exit 2 if [ -n "$dirname" -a "$dirname" != "$target" ]; then
$MKDIR -- "$dirname" || ret=$?
fi
_clint > "$target" || ret=$?
done done
exit $ret

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
#$Id$ #$Id$
#Copyright (c) 2017-2019 Pierre Pronchery <khorben@defora.org> #Copyright (c) 2017-2022 Pierre Pronchery <khorben@defora.org>
# #
#Redistribution and use in source and binary forms, with or without #Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are met: #modification, are permitted provided that the following conditions are met:
@ -25,23 +25,30 @@
#variables #variables
CONFIGSH="${0%/fixme.sh}/../config.sh"
PROGNAME="fixme.sh" PROGNAME="fixme.sh"
PROJECTCONF="../project.conf" PROJECTCONF="../project.conf"
REGEXP_ERROR="FIXME"
REGEXP_WARNING="\\(TODO\|XXX\\)"
#executables #executables
DATE="date" DATE="date"
DEBUG="_debug" DEBUG="_debug"
FIND="find" FIND="find"
GREP="grep" GREP="grep"
HEAD="head"
MKDIR="mkdir -p" MKDIR="mkdir -p"
SORT="sort -n" SORT="sort -n"
TR="tr" TR="tr"
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
#functions #functions
#fixme #fixme
_fixme() _fixme()
{ {
res=0 res=0
subdirs=
$DATE $DATE
echo echo
@ -56,27 +63,14 @@ _fixme()
;; ;;
esac esac
done < "$PROJECTCONF" done < "$PROJECTCONF"
if [ ! -n "$subdirs" ]; then
_error "Could not locate directories to analyze"
return $?
fi
for subdir in $subdirs; do for subdir in $subdirs; do
[ -d "../$subdir" ] || continue [ -d "../$subdir" ] || continue
for filename in $($FIND "../$subdir" -type f | $SORT); do for filename in $($FIND "../$subdir" -type f | $SORT); do
callback= callback=$(_fixme_callback "$filename")
ext=${filename##*/}
ext=${ext%.in}
ext=${ext##*.}
case "$ext" in
asm|S)
callback="_fixme_asm"
;;
c|cc|cpp|cxx|h|js)
callback="_fixme_c"
;;
conf|sh)
callback="_fixme_sh"
;;
htm|html|xml)
callback="_fixme_xml"
;;
esac
[ -n "$callback" ] || continue [ -n "$callback" ] || continue
($callback "$filename") 2>&1 ($callback "$filename") 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
@ -88,54 +82,114 @@ _fixme()
return $res return $res
} }
_fixme_asm() _fixme_callback()
{
filename="$1"
ext=${filename##*/}
ext=${ext%.in}
ext=${ext##*.}
callback=
case "$ext" in
asm|S)
echo "_fixme_callback_asm"
return 0
;;
c|cc|cpp|cxx|go|h|js|v)
echo "_fixme_callback_c"
return 0
;;
conf|sh)
echo "_fixme_callback_sh"
return 0
;;
py)
echo "_fixme_callback_python"
return 0
;;
htm|html|xml|xsl)
echo "_fixme_callback_xml"
return 0
;;
esac
case $($HEAD -n 1 "$filename") in
"#!/bin/sh"*|"#! /bin/sh"*|\
"#!/usr/bin/env bash"*|"#! /usr/bin/env bash"*)
echo "_fixme_callback_sh"
return 0
;;
"#!/usr/bin/env python"*|"#! /usr/bin/env python"*)
echo "_fixme_callback_python"
return 0
;;
"<!DOCTYPE"*|"<!doctype"*|"<HTML"*|"<html"*|"<?xml"*)
echo "_fixme_callback_xml"
return 0
;;
esac
return 2
}
_fixme_callback_asm()
{ {
res=0 res=0
filename="$1" filename="$1"
#warnings #warnings
$GREP -nH '/\*.*\(TODO\|XXX\)' "$filename" $GREP -nH "/\\*.*$REGEXP_WARNING" "$filename"
#failures #failures
$GREP -nH '/\*.*FIXME' "$filename" && res=2 $GREP -nH "/\\*.*$REGEXP_ERROR" "$filename" && res=2
return $res return $res
} }
_fixme_c() _fixme_callback_c()
{ {
res=0 res=0
filename="$1" filename="$1"
#warnings #warnings
$GREP -nH '/\(/\|\*\).*\(TODO\|XXX\)' "$filename" $GREP -nH "/\\(/\\|\\*\\).*$REGEXP_WARNING" "$filename"
#failures #failures
$GREP -nH '/\(/\|\*\).*FIXME' "$filename" && res=2 $GREP -nH "/\\(/\\|\\*\\).*$REGEXP_ERROR" "$filename" && res=2
return $res return $res
} }
_fixme_sh() _fixme_callback_python()
{ {
res=0 res=0
filename="$1" filename="$1"
#XXX avoid matching the regexp
comment="#" comment="#"
#warnings #warnings
$GREP -nH "$comment.*\\(TODO\\|XXX\\)" "$filename" $GREP -nH "$comment.*$REGEXP_WARNING" "$filename"
#failures #failures
$GREP -nH "$comment.*FIXME" "$filename" && res=2 $GREP -nH "$comment.*$REGEXP_ERROR" "$filename" && res=2
return $res return $res
} }
_fixme_xml() _fixme_callback_sh()
{
res=0
filename="$1"
comment="#"
#warnings
$GREP -nH "$comment.*$REGEXP_WARNING" "$filename"
#failures
$GREP -nH "$comment.*$REGEXP_ERROR" "$filename" && res=2
return $res
}
_fixme_callback_xml()
{ {
res=0 res=0
filename="$1" filename="$1"
#XXX limited to a single line #XXX limited to a single line
#warnings #warnings
$GREP -nH '<!--.*\(TODO\|XXX\)' "$filename" $GREP -nH "<!--.*$REGEXP_WARNING" "$filename"
#failures #failures
$GREP -nH '<!--.*FIXME' "$filename" && res=2 $GREP -nH "<!--.*$REGEXP_ERROR" "$filename" && res=2
return $res return $res
} }
@ -145,10 +199,14 @@ _debug()
{ {
echo "$@" 1>&3 echo "$@" 1>&3
"$@" "$@"
res=$? }
#ignore errors when the command is not available
[ $res -eq 127 ] && return 0
return $res #error
_error()
{
echo "$PROGNAME: $@" 1>&2
return 2
} }

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
#$Id$ #$Id$
#Copyright (c) 2014-2017 Pierre Pronchery <khorben@defora.org> #Copyright (c) 2014-2021 Pierre Pronchery <khorben@defora.org>
# #
#Redistribution and use in source and binary forms, with or without #Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are met: #modification, are permitted provided that the following conditions are met:
@ -25,26 +25,31 @@
#variables #variables
CONFIGSH="${0%/htmllint.sh}/../config.sh"
DEVNULL="/dev/null" DEVNULL="/dev/null"
PROGNAME="htmllint.sh" PROGNAME="htmllint.sh"
PROJECTCONF="../project.conf" PROJECTCONF="../project.conf"
#executables #executables
DATE="date" DATE="date"
DEBUG="_debug" DEBUG="_debug"
ECHO="/bin/echo"
FIND="find" FIND="find"
HTMLLINT="xmllint --html" HTMLLINT="xmllint --html --nonet"
MKDIR="mkdir -p"
SORT="sort -n" SORT="sort -n"
TR="tr" TR="tr"
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
#functions #functions
#htmllint #htmllint
_htmllint() _htmllint()
{ {
ret=0 res=0
subdirs=
$DATE $DATE
echo
while read line; do while read line; do
case "$line" in case "$line" in
"["*) "["*)
@ -56,19 +61,30 @@ _htmllint()
;; ;;
esac esac
done < "$PROJECTCONF" done < "$PROJECTCONF"
if [ ! -n "$subdirs" ]; then
_error "Could not locate directories to analyze"
return $?
fi
for subdir in $subdirs; do for subdir in $subdirs; do
[ -d "../$subdir" ] || continue [ -d "../$subdir" ] || continue
for filename in $($FIND "../$subdir" -iname '*.html' -o -iname '*.htm' | $SORT); do while read filename; do
[ -n "$filename" ] || continue
echo
$ECHO -n "$filename:"
$DEBUG $HTMLLINT "$filename" 2>&1 > "$DEVNULL" $DEBUG $HTMLLINT "$filename" 2>&1 > "$DEVNULL"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "$filename:" echo " OK"
echo "$PROGNAME: $filename: OK" 1>&2
else else
echo "FAIL"
echo "$PROGNAME: $filename: FAIL" 1>&2 echo "$PROGNAME: $filename: FAIL" 1>&2
ret=2 res=2
fi fi
done done << EOF
$($FIND "../$subdir" -type f -a \( -iname '*.html' -o -iname '*.htm' \) | $SORT)
EOF
done done
return $ret return $res
} }
@ -77,10 +93,14 @@ _debug()
{ {
echo "$@" 1>&3 echo "$@" 1>&3
"$@" "$@"
res=$? }
#ignore errors when the command is not available
[ $res -eq 127 ] && return 0
return $res #error
_error()
{
echo "$PROGNAME: $@" 1>&2
return 2
} }
@ -121,9 +141,15 @@ fi
[ $clean -ne 0 ] && exit 0 [ $clean -ne 0 ] && exit 0
exec 3>&1 exec 3>&1
ret=0
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
target="$1" target="$1"
dirname="${target%/*}"
shift shift
_htmllint > "$target" || exit 2 if [ -n "$dirname" -a "$dirname" != "$target" ]; then
$MKDIR -- "$dirname" || ret=$?
fi
_htmllint > "$target" || ret=$?
done done
exit $ret

View File

@ -1,6 +1,7 @@
targets=clint.log,fixme.log,htmllint.log,xmllint.log targets=clint.log,fixme.log,htmllint.log,xmllint.log
dist=Makefile,htmllint.sh,xmllint.sh dist=Makefile,clint.sh,fixme.sh,htmllint.sh,xmllint.sh
#targets
[clint.log] [clint.log]
type=script type=script
script=./clint.sh script=./clint.sh

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
#$Id$ #$Id$
#Copyright (c) 2014-2017 Pierre Pronchery <khorben@defora.org> #Copyright (c) 2014-2021 Pierre Pronchery <khorben@defora.org>
# #
#Redistribution and use in source and binary forms, with or without #Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are met: #modification, are permitted provided that the following conditions are met:
@ -25,26 +25,31 @@
#variables #variables
CONFIGSH="${0%/xmllint.sh}/../config.sh"
DEVNULL="/dev/null" DEVNULL="/dev/null"
PROGNAME="xmllint.sh" PROGNAME="xmllint.sh"
PROJECTCONF="../project.conf" PROJECTCONF="../project.conf"
#executables #executables
DATE="date" DATE="date"
DEBUG="_debug" DEBUG="_debug"
ECHO="/bin/echo"
FIND="find" FIND="find"
MKDIR="mkdir -p"
SORT="sort -n" SORT="sort -n"
TR="tr" TR="tr"
XMLLINT="xmllint" XMLLINT="xmllint --nonet --xinclude"
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
#functions #functions
#xmllint #xmllint
_xmllint() _xmllint()
{ {
ret=0 res=0
subdirs=
$DATE $DATE
echo
while read line; do while read line; do
case "$line" in case "$line" in
"["*) "["*)
@ -56,19 +61,30 @@ _xmllint()
;; ;;
esac esac
done < "$PROJECTCONF" done < "$PROJECTCONF"
if [ ! -n "$subdirs" ]; then
_error "Could not locate directories to analyze"
return $?
fi
for subdir in $subdirs; do for subdir in $subdirs; do
[ -d "../$subdir" ] || continue [ -d "../$subdir" ] || continue
for filename in $($FIND "../$subdir" -name '*.xml' -o -name '*.xsl' | $SORT); do while read filename; do
[ -n "$filename" ] || continue
echo
$ECHO -n "$filename:"
$DEBUG $XMLLINT "$filename" 2>&1 > "$DEVNULL" $DEBUG $XMLLINT "$filename" 2>&1 > "$DEVNULL"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "$filename:" echo " OK"
echo "$PROGNAME: $filename: OK" 1>&2
else else
echo "FAIL"
echo "$PROGNAME: $filename: FAIL" 1>&2 echo "$PROGNAME: $filename: FAIL" 1>&2
ret=2 res=2
fi fi
done done << EOF
$($FIND "../$subdir" -type f -a \( -iname '*.xml' -o -iname '*.xsl' \) | $SORT)
EOF
done done
return $ret return $res
} }
@ -77,10 +93,14 @@ _debug()
{ {
echo "$@" 1>&3 echo "$@" 1>&3
"$@" "$@"
res=$? }
#ignore errors when the command is not available
[ $res -eq 127 ] && return 0
return $res #error
_error()
{
echo "$PROGNAME: $@" 1>&2
return 2
} }
@ -121,9 +141,15 @@ fi
[ $clean -ne 0 ] && exit 0 [ $clean -ne 0 ] && exit 0
exec 3>&1 exec 3>&1
ret=0
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
target="$1" target="$1"
dirname="${target%/*}"
shift shift
_xmllint > "$target" || exit 2 if [ -n "$dirname" -a "$dirname" != "$target" ]; then
$MKDIR -- "$dirname" || ret=$?
fi
_xmllint > "$target" || ret=$?
done done
exit $ret

View File

@ -1,17 +1,27 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2013-2018 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2013-2020 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Camera */ /* This file is part of DeforaOS Desktop Camera */
/* This program is free software: you can redistribute it and/or modify /* Redistribution and use in source and binary forms, with or without
* it under the terms of the GNU General Public License as published by * modification, are permitted provided that the following conditions are
* the Free Software Foundation, version 3 of the License. * met:
* *
* This program is distributed in the hope that it will be useful, * 1. Redistributions of source code must retain the above copyright notice,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * this list of conditions and the following disclaimer.
* 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 * 2. Redistributions in binary form must reproduce the above copyright notice,
* along with this program. If not, see <http://www.gnu.org/licenses/>. */ * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
@ -29,12 +39,12 @@
#define _(string) gettext(string) #define _(string) gettext(string)
/* constants */ /* constants */
#ifndef PROGNAME_BROWSER
# define PROGNAME_BROWSER "browser"
#endif
#ifndef PROGNAME_GALLERY #ifndef PROGNAME_GALLERY
# define PROGNAME_GALLERY "gallery" # define PROGNAME_GALLERY "gallery"
#endif #endif
#ifndef BROWSER_PROGNAME
# define BROWSER_PROGNAME "browser"
#endif
#ifndef PREFIX #ifndef PREFIX
# define PREFIX "/usr/local" # define PREFIX "/usr/local"
#endif #endif
@ -63,14 +73,14 @@ static int _usage(void);
static int _gallery(void) static int _gallery(void)
{ {
char const * homedir; char const * homedir;
char const browser[] = BINDIR "/" BROWSER_PROGNAME; char const browser[] = BINDIR "/" PROGNAME_BROWSER;
char const dcim[] = "DCIM"; char const dcim[] = "DCIM";
char * path; char * path;
#if GTK_CHECK_VERSION(2, 6, 0) #if GTK_CHECK_VERSION(2, 6, 0)
char * argv[] = { BROWSER_PROGNAME, "-T", "--", NULL, NULL }; char * argv[] = { PROGNAME_BROWSER, "-T", "--", NULL, NULL };
const int arg = 3; const int arg = 3;
#else #else
char * argv[] = { BROWSER_PROGNAME, "--", NULL, NULL }; char * argv[] = { PROGNAME_BROWSER, "--", NULL, NULL };
const int arg = 2; const int arg = 2;
#endif #endif

View File

@ -1,17 +1,30 @@
targets=gallery targets=gallery
cflags_force=`pkg-config --cflags gtk+-2.0` cflags_force=`pkg-config --cflags libDesktop`
cflags=-W -Wall -g -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector cflags=-W -Wall -g -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
ldflags_force=`pkg-config --libs glib-2.0` ldflags_force=`pkg-config --libs libDesktop`
ldflags=-pie -Wl,-z,relro -Wl,-z,now ldflags=-pie -Wl,-z,relro -Wl,-z,now
dist=Makefile dist=Makefile
#for Gtk+ 3 #modes
cflags_force=`pkg-config --cflags gtk+-3.0` [mode::debug]
[mode::embedded-debug]
cppflags_force=-DEMBEDDED
[mode::embedded-release]
cppflags_force=-DEMBEDDED -DNDEBUG
cflags=-W -Wall -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
[mode::release]
cppflags_force=-DNDEBUG
cflags=-W -Wall -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
#targets
[gallery] [gallery]
type=binary type=binary
sources=gallery.c sources=gallery.c
install=$(BINDIR) install=$(BINDIR)
#sources
[gallery.c] [gallery.c]
depends=../config.h depends=../config.h