[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,6 +2,6 @@
<service name="tar_git">
<param name="url">https://github.com/monich/harbour-foilnotes.git</param>
<param name="branch">master</param>
- <param name="revision">58cf946</param>
+ <param name="revision">db5e74f</param>
</service>
</services>
\ No newline at end of file
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/.gitmodules
^
|
@@ -13,3 +13,9 @@
[submodule "foil-ui"]
path = foil-ui
url = https://github.com/monich/foil-ui.git
+[submodule "libgnfcdc"]
+ path = libgnfcdc
+ url = https://github.com/monich/libgnfcdc.git
+[submodule "libqnfcdc"]
+ path = libqnfcdc
+ url = https://github.com/monich/libqnfcdc.git
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/app.pro
^
|
@@ -9,21 +9,21 @@
TARGET = $${PREFIX}-$${NAME}
CONFIG += sailfishapp link_pkgconfig
-PKGCONFIG += sailfishapp mlite5 glib-2.0 gobject-2.0
+PKGCONFIG += sailfishapp mlite5 glib-2.0 gobject-2.0 gio-unix-2.0
QT += qml quick sql
+isEmpty(VERSION) {
+ VERSION = 1.0.28
+}
+
+V1 = $$system(echo $$VERSION | cut -f1 -d.)
+V2 = $$system(echo $$VERSION | cut -f2 -d.)
+V3 = $$system(echo $$VERSION | cut -f3 -d.)
+DEFINES += VERSION_MAJOR=$$V1 VERSION_MINOR=$$V2 VERSION_MICRO=$$V3
+
QMAKE_CXXFLAGS += -Wno-unused-parameter
QMAKE_CFLAGS += -Wno-unused-parameter
-system("pkg-config openssl --atleast-version=1.1") {
- message("Linking OpenSSL dynamically")
- PKGCONFIG += libcrypto
-} else {
- message("Linking OpenSSL statically")
- LIBS += $$[QT_INSTALL_LIBS]/libcrypto.a
- PKGCONFIG += zlib
-}
-
app_settings {
# This path is hardcoded in jolla-settings
TRANSLATIONS_PATH = /usr/share/translations
@@ -35,6 +35,11 @@
DEFINES += DEBUG HARBOUR_DEBUG
}
+equals(QT_ARCH, arm64){
+ message(Linking with OpenSSL)
+ PKGCONFIG += libcrypto
+}
+
# Directories
FOIL_UI_REL = foil-ui
FOIL_UI_DIR = $${_PRO_FILE_PWD_}/$${FOIL_UI_REL}
@@ -47,7 +52,8 @@
HARBOUR_LIB_QML = $${HARBOUR_LIB_DIR}/qml
LIBGLIBUTIL_DIR = $${_PRO_FILE_PWD_}/libglibutil
-LIBGLIBUTIL_INCLUDE = $${LIBGLIBUTIL_DIR}/include
+LIBGNFCDC_DIR = $${_PRO_FILE_PWD_}/libgnfcdc
+LIBQNFCDC_DIR = $${_PRO_FILE_PWD_}/libqnfcdc
FOIL_DIR = $${_PRO_FILE_PWD_}/foil
LIBFOIL_DIR = $${FOIL_DIR}/libfoil
@@ -76,7 +82,6 @@
$${LIBFOIL_SRC} \
$${LIBFOIL_INCLUDE} \
$${LIBFOILMSG_INCLUDE} \
- $${LIBGLIBUTIL_INCLUDE} \
$${LIBQRENCODE_DIR}
HEADERS += \
@@ -85,6 +90,10 @@
src/FoilNotesDefs.h \
src/FoilNotesHints.h \
src/FoilNotesModel.h \
+ src/FoilNotesNfcShare.h \
+ src/FoilNotesNfcShareClient.h \
+ src/FoilNotesNfcShareService.h \
+ src/FoilNotesNfcShareProtocol.h \
src/FoilNotesPlaintextModel.h \
src/FoilNotesSearchModel.h \
src/FoilNotesSettings.h
@@ -94,6 +103,9 @@
src/FoilNotesBaseModel.cpp \
src/FoilNotesHints.cpp \
src/FoilNotesModel.cpp \
+ src/FoilNotesNfcShareClient.cpp \
+ src/FoilNotesNfcShareService.cpp \
+ src/FoilNotesNfcShareProtocol.cpp \
src/FoilNotesPlaintextModel.cpp \
src/FoilNotesSearchModel.cpp \
src/FoilNotesSettings.cpp \
@@ -102,14 +114,109 @@
SOURCES += \
$${LIBFOIL_SRC}/*.c \
$${LIBFOIL_SRC}/openssl/*.c \
- $${LIBFOILMSG_SRC}/*.c \
- $${LIBGLIBUTIL_DIR}/src/*.c
+ $${LIBFOILMSG_SRC}/*.c
HEADERS += \
$${LIBFOIL_INCLUDE}/*.h \
$${LIBFOILMSG_INCLUDE}/*.h \
+
+# NFC stuff
+
+# libqnfcdc
+
+LIBQNFCDC_INCLUDE = $${LIBQNFCDC_DIR}/include
+LIBQNFCDC_SRC = $${LIBQNFCDC_DIR}/src
+
+INCLUDEPATH += \
+ $${LIBQNFCDC_INCLUDE}
+
+HEADERS += \
+ $${LIBQNFCDC_INCLUDE}/NfcAdapter.h \
+ $${LIBQNFCDC_INCLUDE}/NfcMode.h \
+ $${LIBQNFCDC_INCLUDE}/NfcSystem.h \
+ $${LIBQNFCDC_INCLUDE}/NfcPeer.h
+
+SOURCES += \
+ $${LIBQNFCDC_SRC}/NfcAdapter.cpp \
+ $${LIBQNFCDC_SRC}/NfcMode.cpp \
+ $${LIBQNFCDC_SRC}/NfcSystem.cpp \
+ $${LIBQNFCDC_SRC}/NfcPeer.cpp
+
+# libglibutil
+
+LIBGLIBUTIL_SRC = $${LIBGLIBUTIL_DIR}/src
+LIBGLIBUTIL_INCLUDE = $${LIBGLIBUTIL_DIR}/include
+
+INCLUDEPATH += \
+ $${LIBGLIBUTIL_INCLUDE}
+
+HEADERS += \
$${LIBGLIBUTIL_INCLUDE}/*.h
+SOURCES += \
+ $${LIBGLIBUTIL_DIR}/src/*.c
+
+# libgnfcdc
+
+LIBGNFCDC_INCLUDE = $${LIBGNFCDC_DIR}/include
+LIBGNFCDC_SRC = $${LIBGNFCDC_DIR}/src
+LIBGNFCDC_SPEC = $${LIBGNFCDC_DIR}/spec
+
+INCLUDEPATH += \
+ $${LIBGNFCDC_INCLUDE}
+
+HEADERS += \
+ $${LIBGNFCDC_INCLUDE}/*.h \
+ $${LIBGNFCDC_SRC}/*.h
+
+SOURCES += \
+ $${LIBGNFCDC_SRC}/*.c
+
+OTHER_FILES += \
+ $${LIBGNFCDC_SPEC}/*.xml
+
+defineTest(generateStub) {
+ xml = $${LIBGNFCDC_SPEC}/org.sailfishos.nfc.$${1}.xml
+ cmd = gdbus-codegen --generate-c-code org.sailfishos.nfc.$${1} $${xml}
+
+ gen_h = org.sailfishos.nfc.$${1}.h
+ gen_c = org.sailfishos.nfc.$${1}.c
+ target_h = org_sailfishos_nfc_$${1}_h
+ target_c = org_sailfishos_nfc_$${1}_c
+
+ $${target_h}.target = $${gen_h}
+ $${target_h}.depends = $${xml}
+ $${target_h}.commands = $${cmd}
+ export($${target_h}.target)
+ export($${target_h}.depends)
+ export($${target_h}.commands)
+
+ GENERATED_HEADERS += $${gen_h}
+ PRE_TARGETDEPS += $${gen_h}
+ QMAKE_EXTRA_TARGETS += $${target_h}
+
+ $${target_c}.target = $${gen_c}
+ $${target_c}.depends = $${gen_h}
+ export($${target_c}.target)
+ export($${target_c}.depends)
+
+ GENERATED_SOURCES += $${gen_c}
+ QMAKE_EXTRA_TARGETS += $${target_c}
+ PRE_TARGETDEPS += $${gen_c}
+
+ export(QMAKE_EXTRA_TARGETS)
+ export(GENERATED_SOURCES)
+ export(PRE_TARGETDEPS)
+}
+
+generateStub(Adapter)
+generateStub(Daemon)
+generateStub(IsoDep)
+generateStub(LocalService)
+generateStub(Settings)
+generateStub(Peer)
+generateStub(Tag)
+
# foil-ui
FOIL_UI_COMPONENTS = \
@@ -186,6 +293,13 @@
qml_components.path = /usr/share/$${TARGET}/qml/harbour
INSTALLS += qml_components
+# openssl
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/harbour-lib/include/HarbourTheme.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2020 Jolla Ltd.
- * Copyright (C) 2018-2020 Slava Monich <slava@monich.com>
+ * Copyright (C) 2018-2021 Jolla Ltd.
+ * Copyright (C) 2018-2021 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -81,6 +81,8 @@
qreal opacityHigh() const;
qreal opacityOverlay() const;
+ static QRgb invertedRgb(QRgb aRgb);
+
Q_INVOKABLE static QColor invertedColor(const QColor& aColor);
Q_INVOKABLE static qreal colorDifference(const QColor& aColor1, const QColor& aColor2);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/harbour-lib/src/HarbourTheme.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2020 Jolla Ltd.
- * Copyright (C) 2018-2020 Slava Monich <slava@monich.com>
+ * Copyright (C) 2018-2021 Jolla Ltd.
+ * Copyright (C) 2018-2021 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -215,11 +215,15 @@
return invertedColor(Private::primaryColor());
}
+QRgb HarbourTheme::invertedRgb(QRgb aRgb)
+{
+ return ((~(aRgb & RGB_MASK)) & RGB_MASK) | (aRgb & (~RGB_MASK));
+}
+
QColor HarbourTheme::invertedColor(const QColor& aColor)
{
if (aColor.isValid()) {
- const QRgb rgba = aColor.rgba();
- return QColor(((~(rgba & RGB_MASK)) & RGB_MASK) | (rgba & (~RGB_MASK)));
+ return QColor(invertedRgb(aColor.rgba()));
} else {
return aColor;
}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/harbour-lib/src/libcrypto.c
^
|
@@ -0,0 +1,262 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ */
+
+#include "gutil_log.h"
+
+#include <dlfcn.h>
+#include <stdint.h>
+
+#include <openssl/aes.h>
+#include <openssl/des.h>
+#include <openssl/md5.h>
+#include <openssl/rsa.h>
+#include <openssl/sha.h>
+
+/*
+ * What is this code?
+ *
+ * Sailfish OS comes in 3 flavors wrt openssl versions:
+ *
+ * 1. Sailfish OS up to 3.4 had openssl 1.0
+ * 2. Sailfish 4.0..4.2 had both openssl 1.0 and openssl 1.1 libraries
+ * 3. Sailfish 4.3 dropped openssl 1.0 libraries and only has openssl 1.1
+ *
+ * Which means that explicitly linking with any version of openssl
+ * makes your app incompatible with either Sailfish OS <= 3.4 or
+ * Sailfish OS >= 4.3 (nice symmetry).
+ *
+ * If you want to build an app which runs on both Sailfish OS <= 3.4
+ * and Sailfish OS >= 4.3 you have two options:
+ *
+ * 1. Link openssl statically
+ * 2. Load libcrypts.so dynamically with dlopen/dlsym
+ *
+ * This module allows you to implement the second strategy. It works
+ * because openssl 1.0 and 1.1 (luckily!) appear to be binary compatible.
+ * It doesn't load all libcrypto functions, only those referenced by my
+ * apps but the list can be easily expanded.
+ */
+
+#ifndef LIBDIR
+# ifdef __aarch64__
+# define LIBDIR "/usr/lib64"
+# else
+# define LIBDIR "/usr/lib"
+# endif
+#endif
+
+/*
+ * OpenSSL 1.0 headers define ERR_load_crypto_strings as a function:
+ *
+ * void ERR_load_crypto_strings(void);
+ *
+ * and OpenSSL 1.1 as a macro:
+ *
+ * #if OPENSSL_API_COMPAT < 0x10100000L
+ * # define ERR_load_crypto_strings() \
+ * OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)
+ * # define ERR_free_strings() while(0) continue
+ * #endif
+ *
+ * We want to try loading both ERR_load_crypto_strings and
+ * OPENSSL_init_crypto, one of which will probably fail.
+ */
+
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+# undef ERR_load_crypto_strings
+#else
+# define OPENSSL_INIT_SETTINGS void
+#endif
+
+/* f(name,params,args) */
+#define LIBCRYPTO_FUNCTIONS1(f) \
+ f(AES_cbc_encrypt, \
+ (const unsigned char* in, unsigned char* out, size_t length, \
+ const AES_KEY* key, unsigned char* ivec, const int enc), \
+ (in, out, length, key, ivec, enc)) \
+ f(AES_cfb128_encrypt, \
+ (const unsigned char* in, unsigned char* out, size_t length, \
+ const AES_KEY* key,unsigned char* ivec, int* num, const int enc), \
+ (in, out, length, key, ivec, num, enc)) \
+ f(AES_ecb_encrypt, \
+ (const unsigned char* in, unsigned char* out, const AES_KEY* key, \
+ const int enc), \
+ (in, out, key, enc)) \
+ f(BN_free, (BIGNUM *a), (a)) \
+ f(DES_ede3_cbc_encrypt, \
+ (const unsigned char* input, unsigned char* output, long length, \
+ DES_key_schedule* ks1, DES_key_schedule* ks2, DES_key_schedule* ks3, \
+ DES_cblock* ivec, int enc), \
+ (input, output, length, ks1, ks2, ks3, ivec, enc)) \
+ f(ERR_load_crypto_strings, (void), ()) \
+ f(RSA_free, (RSA* r), (r))
+
+/* f(ret,name,params,args,def) */
+#define LIBCRYPTO_FUNCTIONS2(f) \
+ f(int, AES_set_decrypt_key, \
+ (const unsigned char* userKey, const int bits, AES_KEY* key), \
+ (userKey, bits, key), -1) \
+ f(int, AES_set_encrypt_key, \
+ (const unsigned char* userKey, const int bits, AES_KEY* key), \
+ (userKey, bits, key), -1) \
+ f(BIGNUM*, BN_bin2bn, \
+ (const unsigned char* s, int len, BIGNUM* ret), (s, len, ret), NULL) \
+ f(int, BN_bn2bin, \
+ (const BIGNUM* a, unsigned char* to), (a, to), 0) \
+ f(BIGNUM*, BN_new, (void), (), NULL) \
+ f(int, BN_num_bits, (const BIGNUM *a), (a), 0) \
+ f(int, BN_set_word, (BIGNUM* a, BN_ULONG w), (a, w), 0) \
+ f(int, DES_check_key_parity, (const_DES_cblock* key), (key), 0) \
+ f(int, DES_is_weak_key, (const_DES_cblock* key), (key), 0) \
+ f(int, DES_set_key, \
+ (const_DES_cblock* key, DES_key_schedule* schedule), \
+ (key, schedule), -1) \
+ f(char*, ERR_error_string, (unsigned long e, char* buf), (e, buf), NULL) \
+ f(unsigned long, ERR_get_error, (void), (), 0) \
+ f(unsigned char*, MD5, \
+ (const unsigned char* d, size_t n, unsigned char* md), (d, n, md), NULL) \
+ f(int, MD5_Final, (unsigned char* md, MD5_CTX* c), (md, c), 0) \
+ f(int, MD5_Init, (MD5_CTX* c), (c), 0) \
+ f(int, MD5_Update, (MD5_CTX* c, const void* data, size_t len), \
+ (c, data, len), 0) \
+ f(int, OPENSSL_init_crypto, \
+ (uint64_t opts, const OPENSSL_INIT_SETTINGS* settings), \
+ (opts, settings), 0) \
+ f(int, RAND_bytes, (unsigned char* buf, int num), (buf, num), 0) \
+ f(int, RAND_poll, (void), (), 0) \
+ f(RSA*, RSAPrivateKey_dup, (RSA* rsa), (rsa), NULL) \
+ f(RSA*, RSAPublicKey_dup, (RSA* rsa), (rsa), NULL) \
+ f(int, RSA_generate_key_ex, \
+ (RSA* rsa, int bits, BIGNUM* e, BN_GENCB* cb), \
+ (rsa, bits, e, cb), 0) \
+ f(RSA*, RSA_new, (void), (), NULL) \
+ f(int, RSA_private_decrypt, \
+ (int flen, const unsigned char* from, unsigned char* to, RSA* rsa, \
+ int padding), (flen, from, to, rsa, padding), 0) \
+ f(int, RSA_private_encrypt, \
+ (int flen, const unsigned char* from, unsigned char* to, RSA* rsa, \
+ int padding), (flen, from, to, rsa, padding), 0) \
+ f(int, RSA_public_decrypt, \
+ (int flen, const unsigned char* from, unsigned char* to, RSA* rsa, \
+ int padding), (flen, from, to, rsa, padding), 0) \
+ f(int, RSA_public_encrypt, \
+ (int flen, const unsigned char* from, unsigned char* to, RSA* rsa, \
+ int padding), (flen, from, to, rsa, padding), 0) \
+ f(int, RSA_size, (const RSA* rsa), (rsa), 0) \
+ f(unsigned char*, SHA1, (const unsigned char* d, size_t n, \
+ unsigned char* md), (d, n, md), NULL) \
+ f(int, SHA1_Final, (unsigned char* md, SHA_CTX* c), (md, c), 0) \
+ f(int, SHA1_Init, (SHA_CTX* c), (c), 0) \
+ f(int, SHA1_Update, (SHA_CTX* c, const void* data, size_t len), \
+ (c, data, len), 0) \
+ f(unsigned char*, SHA256, (const unsigned char* d, size_t n, \
+ unsigned char* md), (d, n, md), NULL) \
+ f(int, SHA256_Final, (unsigned char* md, SHA256_CTX* c), (md, c), 0) \
+ f(int, SHA256_Init, (SHA256_CTX* c), (c), 0) \
+ f(int, SHA256_Update, (SHA256_CTX* c, const void* data, size_t len), \
+ (c, data, len), 0) \
+ f(unsigned char*, SHA512, (const unsigned char* d, size_t n, \
+ unsigned char* md), (d, n, md), NULL) \
+ f(int, SHA512_Final, (unsigned char* md, SHA512_CTX* c), (md, c), 0) \
+ f(int, SHA512_Init, (SHA512_CTX* c), (c), 0) \
+ f(int, SHA512_Update, (SHA512_CTX* c, const void* data, size_t len), \
+ (c, data, len), 0)
+
+static const char* libcrypto_so_path[] = {
+ LIBDIR "/libcrypto.so.1.1",
+ "/lib/libcrypto.so.10"
+};
+
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc
^
|
+(directory)
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/.gitignore
^
|
@@ -0,0 +1 @@
+build
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/LICENSE
^
|
@@ -0,0 +1,34 @@
+Copyright (C) 2019-2021 Jolla Ltd.
+Copyright (C) 2019-2021 Slava Monich <slava@monich.com>
+
+You may use this file under the terms of the BSD license as follows:
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+ 3. Neither the names of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+OWNER 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.
+
+The views and conclusions contained in the software and documentation
+are those of the authors and should not be interpreted as representing
+any official policies, either expressed or implied.
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/Makefile
^
|
@@ -0,0 +1,301 @@
+# -*- Mode: makefile-gmake -*-
+
+.PHONY: clean all debug release coverage pkgconfig install install-dev
+.PHONY: print_debug_lib print_release_lib print_coverage_lib
+.PHONY: print_debug_link print_release_link
+.PHONY: print_debug_path print_release_path
+
+#
+# Required packages
+#
+
+PKGS = glib-2.0 gio-2.0 gio-unix-2.0 libglibutil
+
+#
+# Default target
+#
+
+all: debug release pkgconfig
+
+#
+# Library version
+#
+
+VERSION_MAJOR = 1
+VERSION_MINOR = 0
+VERSION_RELEASE = 7
+
+# Version for pkg-config
+PCVERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)
+
+#
+# Library name
+#
+
+NAME = gnfcdc
+LIB_NAME = lib$(NAME)
+LIB_DEV_SYMLINK = $(LIB_NAME).so
+LIB_SYMLINK1 = $(LIB_DEV_SYMLINK).$(VERSION_MAJOR)
+LIB_SYMLINK2 = $(LIB_SYMLINK1).$(VERSION_MINOR)
+LIB_SONAME = $(LIB_SYMLINK1)
+LIB = $(LIB_SONAME).$(VERSION_MINOR).$(VERSION_RELEASE)
+STATIC_LIB = $(LIB_NAME).a
+
+#
+# Sources
+#
+
+SRC = \
+ nfcdc_adapter.c \
+ nfcdc_base.c \
+ nfcdc_daemon.c \
+ nfcdc_default_adapter.c \
+ nfcdc_error.c \
+ nfcdc_isodep.c \
+ nfcdc_log.c \
+ nfcdc_peer.c \
+ nfcdc_peer_service.c \
+ nfcdc_tag.c
+
+GEN_SRC = \
+ org.sailfishos.nfc.Adapter.c \
+ org.sailfishos.nfc.Daemon.c \
+ org.sailfishos.nfc.IsoDep.c \
+ org.sailfishos.nfc.LocalService.c \
+ org.sailfishos.nfc.Peer.c \
+ org.sailfishos.nfc.Settings.c \
+ org.sailfishos.nfc.Tag.c
+
+#
+# Directories
+#
+
+SRC_DIR = src
+INCLUDE_DIR = include
+BUILD_DIR = build
+GEN_DIR = $(BUILD_DIR)
+SPEC_DIR = spec
+DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
+RELEASE_BUILD_DIR = $(BUILD_DIR)/release
+COVERAGE_BUILD_DIR = $(BUILD_DIR)/coverage
+
+#
+# Tools and flags
+#
+
+CC = $(CROSS_COMPILE)gcc
+LD = $(CC)
+WARNINGS = -Wall
+INCLUDES = -I$(INCLUDE_DIR) -I$(GEN_DIR)
+BASE_FLAGS = -fPIC
+FULL_CFLAGS = $(BASE_FLAGS) $(CFLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) \
+ -MMD -MP $(shell pkg-config --cflags $(PKGS))
+FULL_LDFLAGS = $(BASE_FLAGS) $(LDFLAGS) -shared -Wl,-soname=$(LIB_SONAME)
+LIBS = $(shell pkg-config --libs $(PKGS))
+DEBUG_FLAGS = -g
+RELEASE_FLAGS =
+COVERAGE_FLAGS = -g
+
+KEEP_SYMBOLS ?= 0
+ifneq ($(KEEP_SYMBOLS),0)
+RELEASE_FLAGS += -g
+endif
+
+DEBUG_LDFLAGS = $(FULL_LDFLAGS) $(DEBUG_FLAGS)
+RELEASE_LDFLAGS = $(FULL_LDFLAGS) $(RELEASE_FLAGS)
+DEBUG_CFLAGS = $(FULL_CFLAGS) $(DEBUG_FLAGS) -DDEBUG
+RELEASE_CFLAGS = $(FULL_CFLAGS) $(RELEASE_FLAGS) -O2
+COVERAGE_CFLAGS = $(FULL_CFLAGS) $(COVERAGE_FLAGS) --coverage
+
+#
+# Files
+#
+
+PKGCONFIG = \
+ $(BUILD_DIR)/$(LIB_NAME).pc
+DEBUG_OBJS = \
+ $(GEN_SRC:%.c=$(DEBUG_BUILD_DIR)/%.o) \
+ $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
+RELEASE_OBJS = \
+ $(GEN_SRC:%.c=$(RELEASE_BUILD_DIR)/%.o) \
+ $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
+COVERAGE_OBJS = \
+ $(GEN_SRC:%.c=$(COVERAGE_BUILD_DIR)/%.o) \
+ $(SRC:%.c=$(COVERAGE_BUILD_DIR)/%.o)
+GEN_FILES = $(GEN_SRC:%=$(GEN_DIR)/%)
+.PRECIOUS: $(GEN_FILES)
+
+DEBUG_LIB = $(DEBUG_BUILD_DIR)/$(LIB)
+RELEASE_LIB = $(RELEASE_BUILD_DIR)/$(LIB)
+DEBUG_LINK = $(DEBUG_BUILD_DIR)/$(LIB_SYMLINK1)
+RELEASE_LINK = $(RELEASE_BUILD_DIR)/$(LIB_SYMLINK1)
+DEBUG_STATIC_LIB = $(DEBUG_BUILD_DIR)/$(STATIC_LIB)
+RELEASE_STATIC_LIB = $(RELEASE_BUILD_DIR)/$(STATIC_LIB)
+COVERAGE_STATIC_LIB = $(COVERAGE_BUILD_DIR)/$(STATIC_LIB)
+
+#
+# Dependencies
+#
+
+DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d) $(COVERAGE_OBJS:%.o=%.d)
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(strip $(DEPS)),)
+-include $(DEPS)
+endif
+endif
+
+$(PKGCONFIG): | $(BUILD_DIR)
+$(GEN_FILES): | $(GEN_DIR)
+$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR) $(GEN_FILES)
+$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR) $(GEN_FILES)
+$(COVERAGE_OBJS): | $(COVERAGE_BUILD_DIR) $(GEN_FILES)
+
+#
+# Rules
+#
+
+DEBUG_LIB = $(DEBUG_BUILD_DIR)/$(LIB)
+RELEASE_LIB = $(RELEASE_BUILD_DIR)/$(LIB)
+DEBUG_LINK = $(DEBUG_BUILD_DIR)/$(LIB_SONAME)
+RELEASE_LINK = $(RELEASE_BUILD_DIR)/$(LIB_SONAME)
+
+debug: $(DEBUG_STATIC_LIB) $(DEBUG_LIB) $(DEBUG_LINK)
+
+release: $(RELEASE_STATIC_LIB) $(RELEASE_LIB) $(RELEASE_LINK)
+
+coverage: $(COVERAGE_STATIC_LIB)
+
+pkgconfig: $(PKGCONFIG)
+
+print_debug_lib:
+ @echo $(DEBUG_STATIC_LIB)
+
+print_release_lib:
+ @echo $(RELEASE_STATIC_LIB)
+
+print_debug_link:
+ @echo $(DEBUG_LINK)
+
+print_coverage_lib:
+ @echo $(COVERAGE_STATIC_LIB)
+
+print_release_link:
+ @echo $(RELEASE_LINK)
+
+print_debug_path:
+ @echo $(DEBUG_BUILD_DIR)
+
+print_release_path:
+ @echo $(RELEASE_BUILD_DIR)
+
+clean:
+ rm -f *~ $(SRC_DIR)/*~ $(INCLUDE_DIR)/*~ rpm/*~
+ rm -fr $(BUILD_DIR) RPMS installroot
+ rm -fr debian/tmp debian/lib$(NAME) debian/lib$(NAME)-dev
+ rm -f documentation.list debian/files debian/*.substvars
+ rm -f debian/*.debhelper.log debian/*.debhelper debian/*~
+
+$(GEN_DIR):
+ mkdir -p $@
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/README
^
|
@@ -0,0 +1 @@
+gnfcdc - Glib based NFC Daemon Client
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/include/nfcdc_adapter.h
^
|
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef NFCDC_ADAPTER_H
+#define NFCDC_ADAPTER_H
+
+#include <nfcdc_types.h>
+
+G_BEGIN_DECLS
+
+typedef enum nfc_adapter_property {
+ NFC_ADAPTER_PROPERTY_ANY,
+ NFC_ADAPTER_PROPERTY_VALID,
+ NFC_ADAPTER_PROPERTY_PRESENT,
+ NFC_ADAPTER_PROPERTY_ENABLED,
+ NFC_ADAPTER_PROPERTY_POWERED,
+ NFC_ADAPTER_PROPERTY_MODE,
+ NFC_ADAPTER_PROPERTY_TARGET_PRESENT,
+ NFC_ADAPTER_PROPERTY_TAGS,
+ /* Since 1.0.6 */
+ NFC_ADAPTER_PROPERTY_PEERS,
+ /* Moving target: */
+ NFC_ADAPTER_PROPERTY_COUNT
+} NFC_ADAPTER_PROPERTY;
+
+/* NFC_ADAPTER_MODE was replaced with NFC_MODE in 1.0.6 */
+#define NFC_ADAPTER_MODE NFC_MODE
+#define NFC_ADAPTER_MODE_NONE NFC_MODE_NONE
+#define NFC_ADAPTER_MODE_P2P_INITIATOR NFC_MODE_P2P_INITIATOR
+#define NFC_ADAPTER_MODE_READER_WRITER NFC_MODE_READER_WRITER
+#define NFC_ADAPTER_MODE_P2P_TARGET NFC_MODE_P2P_TARGET
+#define NFC_ADAPTER_MODE_CARD_EMILATION NFC_MODE_CARD_EMILATION
+
+struct nfc_adapter_client {
+ const char* path;
+ gboolean valid;
+ gboolean present;
+ gboolean enabled;
+ gboolean powered;
+ NFC_MODE supported_modes;
+ NFC_MODE mode;
+ gboolean target_present;
+ const GStrV* tags;
+ /* Since 1.0.6 */
+ const GStrV* peers;
+};
+
+typedef
+void
+(*NfcAdapterPropertyFunc)(
+ NfcAdapterClient* adapter,
+ NFC_ADAPTER_PROPERTY property,
+ void* user_data);
+
+NfcAdapterClient*
+nfc_adapter_client_new(
+ const char* path);
+
+NfcAdapterClient*
+nfc_adapter_client_ref(
+ NfcAdapterClient* adapter);
+
+void
+nfc_adapter_client_unref(
+ NfcAdapterClient* adapter);
+
+gulong
+nfc_adapter_client_add_property_handler(
+ NfcAdapterClient* adapter,
+ NFC_ADAPTER_PROPERTY property,
+ NfcAdapterPropertyFunc callback,
+ void* user_data);
+
+void
+nfc_adapter_client_remove_handler(
+ NfcAdapterClient* adapter,
+ gulong id);
+
+void
+nfc_adapter_client_remove_handlers(
+ NfcAdapterClient* adapter,
+ gulong* ids,
+ guint count);
+
+#define nfc_adapter_client_remove_all_handlers(adapter, ids) \
+ nfc_adapter_client_remove_handlers(adapter, ids, G_N_ELEMENTS(ids))
+
+G_END_DECLS
+
+#endif /* NFCDC_ADAPTER_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/include/nfcdc_daemon.h
^
|
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef NFCDC_DAEMON_H
+#define NFCDC_DAEMON_H
+
+#include <nfcdc_types.h>
+
+G_BEGIN_DECLS
+
+typedef enum nfc_daemon_property {
+ NFC_DAEMON_PROPERTY_ANY,
+ NFC_DAEMON_PROPERTY_VALID,
+ NFC_DAEMON_PROPERTY_PRESENT,
+ NFC_DAEMON_PROPERTY_ERROR,
+ NFC_DAEMON_PROPERTY_ENABLED,
+ NFC_DAEMON_PROPERTY_ADAPTERS,
+ /* Since 1.0.3 */
+ NFC_DAEMON_PROPERTY_VERSION,
+ /* Since 1.0.6 */
+ NFC_DAEMON_PROPERTY_MODE,
+ NFC_DAEMON_PROPERTY_COUNT
+} NFC_DAEMON_PROPERTY;
+
+struct nfc_daemon_client {
+ gboolean valid;
+ gboolean present;
+ gboolean enabled;
+ const GError* error;
+ const GStrV* adapters;
+ /* Since 1.0.3 */
+ int version; /* Zero for nfcd versions < 1.0.26 */
+ /* Since 1.0.6 */
+ NFC_MODE mode; /* Zero for nfcd versions < 1.1.0 */
+};
+
+#define NFC_DAEMON_VERSION(v1,v2,v3) \
+ ((((v1) & 0x7f) << 24) | \
+ (((v2) & 0xfff) << 12) | \
+ ((v3) & 0xfff))
+
+#define NFC_DAEMON_VERSION_MAJOR(v) (((v) >> 24) & 0x7f)
+#define NFC_DAEMON_VERSION_MINOR(v) (((v) >> 12) & 0xfff)
+#define NFC_DAEMON_VERSION_NANO(v) ((v) & 0xfff)
+
+typedef
+void
+(*NfcDaemonPropertyFunc)(
+ NfcDaemonClient* daemon,
+ NFC_DAEMON_PROPERTY property,
+ void* user_data);
+
+NfcDaemonClient*
+nfc_daemon_client_new(
+ void);
+
+NfcDaemonClient*
+nfc_daemon_client_ref(
+ NfcDaemonClient* daemon);
+
+void
+nfc_daemon_client_unref(
+ NfcDaemonClient* daemon);
+
+gulong
+nfc_daemon_client_add_property_handler(
+ NfcDaemonClient* daemon,
+ NFC_DAEMON_PROPERTY property,
+ NfcDaemonPropertyFunc callback,
+ void* user_data);
+
+void
+nfc_daemon_client_remove_handler(
+ NfcDaemonClient* daemon,
+ gulong id);
+
+void
+nfc_daemon_client_remove_handlers(
+ NfcDaemonClient* daemon,
+ gulong* ids,
+ guint count);
+
+#define nfc_daemon_client_remove_all_handlers(daemon, ids) \
+ nfc_daemon_client_remove_handlers(daemon, ids, G_N_ELEMENTS(ids))
+
+/* NfcModeRequest */
+
+struct nfc_mode_request {
+ NFC_MODE enable;
+ NFC_MODE disable;
+};
+
+NfcModeRequest*
+nfc_mode_request_new(
+ NfcDaemonClient* daemon,
+ NFC_MODE enable,
+ NFC_MODE disable); /* Since 1.0.6 */
+
+void
+nfc_mode_request_free(
+ NfcModeRequest* request); /* Since 1.0.6 */
+
+G_END_DECLS
+
+#endif /* NFCDC_DAEMON_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/include/nfcdc_default_adapter.h
^
|
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef NFCDC_DEFAUT_ADAPTER_H
+#define NFCDC_DEFAUT_ADAPTER_H
+
+#include <nfcdc_adapter.h>
+
+G_BEGIN_DECLS
+
+typedef enum nfc_default_adapter_property {
+ NFC_DEFAULT_ADAPTER_PROPERTY_ANY,
+ NFC_DEFAULT_ADAPTER_PROPERTY_ADAPTER,
+ NFC_DEFAULT_ADAPTER_PROPERTY_ENABLED,
+ NFC_DEFAULT_ADAPTER_PROPERTY_POWERED,
+ NFC_DEFAULT_ADAPTER_PROPERTY_SUPPORTED_MODES,
+ NFC_DEFAULT_ADAPTER_PROPERTY_MODE,
+ NFC_DEFAULT_ADAPTER_PROPERTY_TARGET_PRESENT,
+ NFC_DEFAULT_ADAPTER_PROPERTY_TAGS,
+ /* Since 1.0.5 */
+ NFC_DEFAULT_ADAPTER_PROPERTY_VALID,
+ /* Since 1.0.6 */
+ NFC_DEFAULT_ADAPTER_PROPERTY_PEERS,
+ /* Moving target: */
+ NFC_DEFAULT_ADAPTER_PROPERTY_COUNT
+} NFC_DEFAULT_ADAPTER_PROPERTY;
+
+struct nfc_default_adapter {
+ NfcAdapterClient* adapter;
+ gboolean enabled;
+ gboolean powered;
+ NFC_MODE supported_modes;
+ NFC_MODE mode;
+ gboolean target_present;
+ const GStrV* tags;
+ /* Since 1.0.5 */
+ gboolean valid;
+ /* Since 1.0.6 */
+ const GStrV* peers;
+};
+
+typedef
+void
+(*NfcDefaultAdapterPropertyFunc)(
+ NfcDefaultAdapter* adapter,
+ NFC_DEFAULT_ADAPTER_PROPERTY property,
+ void* user_data);
+
+NfcDefaultAdapter*
+nfc_default_adapter_new(
+ void);
+
+NfcDefaultAdapter*
+nfc_default_adapter_ref(
+ NfcDefaultAdapter* adapter);
+
+void
+nfc_default_adapter_unref(
+ NfcDefaultAdapter* adapter);
+
+gulong
+nfc_default_adapter_add_property_handler(
+ NfcDefaultAdapter* adapter,
+ NFC_DEFAULT_ADAPTER_PROPERTY property,
+ NfcDefaultAdapterPropertyFunc callback,
+ void* user_data);
+
+void
+nfc_default_adapter_remove_handler(
+ NfcDefaultAdapter* adapter,
+ gulong id);
+
+void
+nfc_default_adapter_remove_handlers(
+ NfcDefaultAdapter* adapter,
+ gulong* ids,
+ guint count);
+
+#define nfc_default_adapter_remove_all_handlers(adapter, ids) \
+ nfc_default_adapter_remove_handlers(adapter, ids, G_N_ELEMENTS(ids))
+
+G_END_DECLS
+
+#endif /* NFCDC_DEFAUT_ADAPTER_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/include/nfcdc_error.h
^
|
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef NFCDC_ERROR_H
+#define NFCDC_ERROR_H
+
+#include <nfcdc_types.h>
+
+G_BEGIN_DECLS
+
+#define NFCDC_ERROR (nfcdc_error_quark())
+GQuark nfcdc_error_quark(void);
+
+#define NFCDC_ERRORS(e) \
+ e(FAILED, "Failed") \
+ e(ACCESS_DENIED, "AccessDenied") \
+ e(INVALID_ARGS, "InvalidArgs") \
+ e(NOT_FOUND, "NotFound") \
+ e(NOT_SUPPORTED, "NotSupported") \
+ e(ABORTED, "Aborted") \
+ e(NACK, "NACK")
+
+typedef enum nfcdc_error_code {
+ #define NFCDC_ERROR_ENUM_(E,e) NFCDC_ERROR_##E,
+ NFCDC_ERRORS(NFCDC_ERROR_ENUM_)
+ #undef NFCDC_ERROR_ENUM_
+} NFCDC_ERROR_CODE;
+
+gboolean
+nfcdc_error_matches(
+ const GError* error,
+ NFCDC_ERROR_CODE code);
+
+G_END_DECLS
+
+#endif /* NFCDC_ERROR_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/include/nfcdc_isodep.h
^
|
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef NFCDC_ISODEP_H
+#define NFCDC_ISODEP_H
+
+#include <nfcdc_types.h>
+
+#include <gio/gio.h>
+
+#define NFC_ISODEP_SW(sw1,sw2) ((((sw1) << 8) & 0xff00) | ((sw2) & 0xff))
+#define NFC_ISODEP_SW_OK NFC_ISODEP_SW(0x90,00) /* Normal completion */
+
+G_BEGIN_DECLS
+
+typedef enum nfc_isodep_property {
+ NFC_ISODEP_PROPERTY_ANY,
+ NFC_ISODEP_PROPERTY_VALID,
+ NFC_ISODEP_PROPERTY_PRESENT,
+ NFC_ISODEP_PROPERTY_COUNT
+} NFC_ISODEP_PROPERTY;
+
+struct nfc_isodep_client {
+ const char* path;
+ gboolean valid;
+ gboolean present;
+};
+
+typedef struct nfc_isodep_apdu {
+ guint8 cla; /* Class byte */
+ guint8 ins; /* Instruction byte */
+ guint8 p1; /* Parameter byte 1 */
+ guint8 p2; /* Parameter byte 2 */
+ GUtilData data; /* Command data */
+ guint le; /* Expected length, zero if none */
+} NfcIsoDepApdu;
+
+typedef
+void
+(*NfcIsoDepPropertyFunc)(
+ NfcIsoDepClient* isodep,
+ NFC_ISODEP_PROPERTY property,
+ void* user_data);
+
+typedef
+void
+(*NfcIsoDepTransmitFunc)(
+ NfcIsoDepClient* isodep,
+ const GUtilData* response,
+ guint sw, /* 16 bits (SW1 << 8)|SW2 */
+ const GError* error,
+ void* user_data);
+
+NfcIsoDepClient*
+nfc_isodep_client_new(
+ const char* path);
+
+NfcIsoDepClient*
+nfc_isodep_client_ref(
+ NfcIsoDepClient* isodep);
+
+void
+nfc_isodep_client_unref(
+ NfcIsoDepClient* isodep);
+
+gboolean
+nfc_isodep_client_transmit(
+ NfcIsoDepClient* isodep,
+ const NfcIsoDepApdu* apdu,
+ GCancellable* cancel,
+ NfcIsoDepTransmitFunc callback,
+ void* user_data,
+ GDestroyNotify destroy);
+
+gulong
+nfc_isodep_client_add_property_handler(
+ NfcIsoDepClient* isodep,
+ NFC_ISODEP_PROPERTY property,
+ NfcIsoDepPropertyFunc callback,
+ void* user_data);
+
+void
+nfc_isodep_client_remove_handler(
+ NfcIsoDepClient* isodep,
+ gulong id);
+
+void
+nfc_isodep_client_remove_handlers(
+ NfcIsoDepClient* isodep,
+ gulong* ids,
+ guint count);
+
+#define nfc_isodep_client_remove_all_handlers(isodep, ids) \
+ nfc_isodep_client_remove_handlers(isodep, ids, G_N_ELEMENTS(ids))
+
+G_END_DECLS
+
+#endif /* NFCDC_ISODEP_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/include/nfcdc_peer.h
^
|
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef NFCDC_PEER_H
+#define NFCDC_PEER_H
+
+#include <nfcdc_types.h>
+
+#include <gio/gio.h>
+
+/* This API exists since 1.0.6 */
+
+G_BEGIN_DECLS
+
+typedef struct nfc_peer_client_connection NfcPeerClientConnection;
+
+typedef enum nfc_peer_property {
+ NFC_PEER_PROPERTY_ANY,
+ NFC_PEER_PROPERTY_VALID,
+ NFC_PEER_PROPERTY_PRESENT,
+ NFC_PEER_PROPERTY_WKS,
+ NFC_PEER_PROPERTY_COUNT
+} NFC_PEER_PROPERTY;
+
+struct nfc_peer_client {
+ const char* path;
+ gboolean valid;
+ gboolean present;
+ guint wks;
+};
+
+typedef
+void
+(*NfcPeerPropertyFunc)(
+ NfcPeerClient* peer,
+ NFC_PEER_PROPERTY property,
+ void* user_data);
+
+typedef
+void
+(*NfcPeerClientConnectionFunc)(
+ NfcPeerClient* peer,
+ int fd,
+ const GError* error,
+ void* user_data);
+
+NfcPeerClient*
+nfc_peer_client_new(
+ const char* path);
+
+NfcPeerClient*
+nfc_peer_client_ref(
+ NfcPeerClient* peer);
+
+void
+nfc_peer_client_unref(
+ NfcPeerClient* peer);
+
+gboolean
+nfc_peer_client_connect_sap(
+ NfcPeerClient* peer,
+ guint rsap,
+ GCancellable* cancel,
+ NfcPeerClientConnectionFunc callback,
+ void* user_data,
+ GDestroyNotify destroy);
+
+gboolean
+nfc_peer_client_connect_sn(
+ NfcPeerClient* peer,
+ const char* sn,
+ GCancellable* cancel,
+ NfcPeerClientConnectionFunc callback,
+ void* user_data,
+ GDestroyNotify destroy);
+
+gulong
+nfc_peer_client_add_property_handler(
+ NfcPeerClient* peer,
+ NFC_PEER_PROPERTY property,
+ NfcPeerPropertyFunc callback,
+ void* user_data);
+
+void
+nfc_peer_client_remove_handler(
+ NfcPeerClient* peer,
+ gulong id);
+
+void
+nfc_peer_client_remove_handlers(
+ NfcPeerClient* peer,
+ gulong* ids,
+ guint count);
+
+#define nfc_peer_client_remove_all_handlers(peer, ids) \
+ nfc_peer_client_remove_handlers(peer, ids, G_N_ELEMENTS(ids))
+
+G_END_DECLS
+
+#endif /* NFCDC_PEER_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/include/nfcdc_peer_service.h
^
|
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef NFCDC_PEER_SERVICE_H
+#define NFCDC_PEER_SERVICE_H
+
+#include <nfcdc_types.h>
+
+/* This API exists since 1.0.6 */
+
+G_BEGIN_DECLS
+
+typedef enum nfc_peer_service_property {
+ NFC_PEER_SERVICE_PROPERTY_ANY,
+ NFC_PEER_SERVICE_PROPERTY_SAP,
+ NFC_PEER_SERVICE_PROPERTY_COUNT
+} NFC_PEER_SERVICE_PROPERTY;
+
+struct nfc_peer_service {
+ const char* path;
+ const char* sn;
+ guint sap;
+};
+
+typedef
+void
+(*NfcPeerServiceHandlerFunc)(
+ NfcPeerService* service,
+ NfcServiceConnection* connection,
+ void* user_data);
+
+typedef
+void
+(*NfcPeerServicePropertyFunc)(
+ NfcPeerService* service,
+ NFC_PEER_SERVICE_PROPERTY property,
+ void* user_data);
+
+typedef
+void
+(*NfcPeerServicePathFunc)(
+ NfcPeerService* service,
+ const char* path,
+ void* user_data);
+
+NfcPeerService*
+nfc_peer_service_new(
+ const char* path,
+ const char* sn,
+ NfcPeerServiceHandlerFunc handler,
+ void* user_data);
+
+NfcPeerService*
+nfc_peer_service_ref(
+ NfcPeerService* service);
+
+void
+nfc_peer_service_unref(
+ NfcPeerService* service);
+
+gulong
+nfc_peer_service_add_property_handler(
+ NfcPeerService* service,
+ NFC_PEER_SERVICE_PROPERTY property,
+ NfcPeerServicePropertyFunc func,
+ void* user_data);
+
+gulong
+nfc_peer_service_add_peer_arrived_handler(
+ NfcPeerService* service,
+ NfcPeerServicePathFunc func,
+ void* user_data);
+
+gulong
+nfc_peer_service_add_peer_left_handler(
+ NfcPeerService* service,
+ NfcPeerServicePathFunc func,
+ void* user_data);
+
+void
+nfc_peer_service_remove_handler(
+ NfcPeerService* service,
+ gulong id);
+
+void
+nfc_peer_service_remove_handlers(
+ NfcPeerService* service,
+ gulong* ids,
+ guint count);
+
+#define nfc_peer_service_remove_all_handlers(service, ids) \
+ nfc_peer_service_remove_handlers(service, ids, G_N_ELEMENTS(ids))
+
+/*
+ * Incoming connection.
+ *
+ * Passed to NfcPeerServiceHandlerFunc, must be accepted by
+ * nfc_service_connection_accept() which also adds a reference
+ * to the connection. That reference has to be eventauly dropped
+ * with nfc_service_connection_unref().
+ *
+ * Second, or any subsequent nfc_service_connection_accept() call
+ * returns NULL and doesn't change the refcount.
+ *
+ * Not doing anything is equivalent to rejecting the connection.
+ * File descriptor is owned by NfcServiceConnection and closed
+ * when connection is finalized (ref count drops to zero).
+ */
+
+struct nfc_service_connection {
+ int fd;
+ guint rsap;
+};
+
+NfcServiceConnection*
+nfc_service_connection_ref(
+ NfcServiceConnection* conn);
+
+void
+nfc_service_connection_unref(
+ NfcServiceConnection* conn);
+
+NfcServiceConnection*
+nfc_service_connection_accept(
+ NfcServiceConnection* conn);
+
+G_END_DECLS
+
+#endif /* NFCDC_PEER_SERVICE_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/include/nfcdc_tag.h
^
|
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef NFCDC_TAG_H
+#define NFCDC_TAG_H
+
+#include <nfcdc_types.h>
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+#define NFC_TAG_INTERFACE_ISODEP "org.sailfishos.nfc.IsoDep"
+#define NFC_TAG_INTERFACE_TYPE2 "org.sailfishos.nfc.TagType2"
+
+typedef enum nfc_tag_property {
+ NFC_TAG_PROPERTY_ANY,
+ NFC_TAG_PROPERTY_VALID,
+ NFC_TAG_PROPERTY_PRESENT,
+ NFC_TAG_PROPERTY_INTERFACES,
+ NFC_TAG_PROPERTY_NDEF_RECORDS,
+ NFC_TAG_PROPERTY_COUNT
+} NFC_TAG_PROPERTY;
+
+struct nfc_tag_client {
+ const char* path;
+ gboolean valid;
+ gboolean present;
+ const GStrV* interfaces;
+ const GStrV* ndef_records;
+};
+
+typedef struct nfc_tag_client_lock NfcTagClientLock;
+
+typedef
+void
+(*NfcTagPropertyFunc)(
+ NfcTagClient* tag,
+ NFC_TAG_PROPERTY property,
+ void* user_data);
+
+typedef
+void
+(*NfcTagClientLockFunc)(
+ NfcTagClient* tag,
+ NfcTagClientLock* lock,
+ const GError* error,
+ void* user_data);
+
+NfcTagClient*
+nfc_tag_client_new(
+ const char* path);
+
+NfcTagClient*
+nfc_tag_client_ref(
+ NfcTagClient* tag);
+
+void
+nfc_tag_client_unref(
+ NfcTagClient* tag);
+
+gboolean
+nfc_tag_client_acquire_lock(
+ NfcTagClient* tag,
+ gboolean wait,
+ GCancellable* cancel,
+ NfcTagClientLockFunc callback,
+ void* user_data,
+ GDestroyNotify destroy);
+
+gulong
+nfc_tag_client_add_property_handler(
+ NfcTagClient* tag,
+ NFC_TAG_PROPERTY property,
+ NfcTagPropertyFunc callback,
+ void* user_data);
+
+void
+nfc_tag_client_remove_handler(
+ NfcTagClient* tag,
+ gulong id);
+
+void
+nfc_tag_client_remove_handlers(
+ NfcTagClient* tag,
+ gulong* ids,
+ guint count);
+
+#define nfc_tag_client_remove_all_handlers(tag, ids) \
+ nfc_tag_client_remove_handlers(tag, ids, G_N_ELEMENTS(ids))
+
+NfcTagClientLock*
+nfc_tag_client_lock_ref(
+ NfcTagClientLock* lock);
+
+void
+nfc_tag_client_lock_unref(
+ NfcTagClientLock* lock);
+
+G_END_DECLS
+
+#endif /* NFCDC_TAG_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/include/nfcdc_types.h
^
|
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef NFCDC_TYPES_H
+#define NFCDC_TYPES_H
+
+#include <gutil_types.h>
+
+G_BEGIN_DECLS
+
+#define NFCDC_LOG_MODULE nfcdc_log
+
+typedef struct nfc_adapter_client NfcAdapterClient;
+typedef struct nfc_daemon_client NfcDaemonClient;
+typedef struct nfc_default_adapter NfcDefaultAdapter;
+typedef struct nfc_isodep_client NfcIsoDepClient;
+typedef struct nfc_mode_request NfcModeRequest; /* Since 1.0.6 */
+typedef struct nfc_service_connection NfcServiceConnection; /* Since 1.0.6 */
+typedef struct nfc_peer_client NfcPeerClient; /* Since 1.0.6 */
+typedef struct nfc_peer_service NfcPeerService; /* Since 1.0.6 */
+typedef struct nfc_tag_client NfcTagClient;
+
+typedef enum nfc_daemon_mode {
+ NFC_MODE_NONE = 0x00,
+ /* Polling */
+ NFC_MODE_P2P_INITIATOR = 0x01,
+ NFC_MODE_READER_WRITER = 0x02,
+ /* Listening */
+ NFC_MODE_P2P_TARGET = 0x04,
+ NFC_MODE_CARD_EMILATION = 0x08
+} NFC_MODE; /* Since 1.0.6 */
+
+extern GLogModule NFCDC_LOG_MODULE;
+
+G_END_DECLS
+
+#endif /* NFCDC_TYPES_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/libgnfcdc.pc.in
^
|
@@ -0,0 +1,10 @@
+name=gnfcdc
+libdir=@libdir@
+includedir=/usr/include
+
+Name: lib${name}
+Description: Glib based API for nfcd D-Bus interface
+Version: @version@
+Requires.private: glib-2.0 gio-2.0 libglibutil
+Libs: -L${libdir} -l${name}
+Cflags: -I${includedir} -I${includedir}/${name}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/rpm/libgnfcdc.spec
^
|
@@ -0,0 +1,55 @@
+Name: libgnfcdc
+
+Version: 1.0.7
+Release: 0
+Summary: Glib based NFC Daemon Client
+Group: Development/Libraries
+License: BSD
+URL: https://github.com/monich/libgnfcdc
+Source: %{name}-%{version}.tar.bz2
+
+%define libglibutil_version 1.0.49
+%define glib_version 2.32
+
+BuildRequires: pkgconfig
+BuildRequires: pkgconfig(glib-2.0) >= %{glib_version}
+BuildRequires: pkgconfig(libglibutil) >= %{libglibutil_version}
+
+Requires: glib2 >= %{glib_version}
+Requires: libglibutil >= %{libglibutil_version}
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description
+Glib based API for nfcd D-Bus interface.
+
+%package devel
+Summary: Development library for %{name}
+Requires: %{name} = %{version}
+
+%description devel
+This package contains the development library for %{name}.
+
+%prep
+%setup -q
+
+%build
+make %{_smp_mflags} LIBDIR=%{_libdir} KEEP_SYMBOLS=1 release pkgconfig
+
+%install
+rm -rf %{buildroot}
+make LIBDIR=%{_libdir} DESTDIR=%{buildroot} install-dev
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%defattr(-,root,root,-)
+%{_libdir}/%{name}.so.*
+
+%files devel
+%defattr(-,root,root,-)
+%{_libdir}/pkgconfig/*.pc
+%{_libdir}/%{name}.so
+%{_includedir}/gnfcdc/*.h
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/spec/org.sailfishos.nfc.Adapter.xml
^
|
@@ -0,0 +1,84 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <!--
+ Mode is a bitmask.
+
+ Polling bits:
+ 0x01 - P2P Initiator
+ 0x02 - Reader/Writer
+
+ Listening bits:
+ 0x04 - P2P Target
+ 0x08 - Card Emulation
+ -->
+ <interface name="org.sailfishos.nfc.Adapter">
+ <method name="GetAll">
+ <arg name="version" type="i" direction="out"/>
+ <arg name="enabled" type="b" direction="out"/>
+ <arg name="powered" type="b" direction="out"/>
+ <arg name="supported_modes" type="u" direction="out"/>
+ <arg name="mode" type="u" direction="out"/>
+ <arg name="target_present" type="b" direction="out"/>
+ <arg name="tags" type="ao" direction="out"/>
+ </method>
+ <method name="GetInterfaceVersion">
+ <arg name="version" type="i" direction="out"/>
+ </method>
+ <!--
+ <method name="GetEnabled">
+ <arg name="enabled" type="b" direction="out"/>
+ </method>
+ <method name="GetPowered">
+ <arg name="powered" type="b" direction="out"/>
+ </method>
+ <method name="GetSupportedModes">
+ <arg name="mode" type="u" direction="out"/>
+ </method>
+ <method name="GetMode">
+ <arg name="mode" type="u" direction="out"/>
+ </method>
+ <method name="GetTargetPresent">
+ <arg name="target_present" type="b" direction="out"/>
+ </method>
+ <method name="GetTags">
+ <arg name="tags" type="ao" direction="out"/>
+ </method>
+ -->
+ <!-- Signals -->
+ <signal name="EnabledChanged">
+ <arg name="enabled" type="b"/>
+ </signal>
+ <signal name="PoweredChanged">
+ <arg name="powered" type="b"/>
+ </signal>
+ <signal name="ModeChanged">
+ <arg name="mode" type="u"/>
+ </signal>
+ <signal name="TargetPresentChanged">
+ <arg name="target_present" type="b"/>
+ </signal>
+ <signal name="TagsChanged">
+ <arg name="tags" type="ao"/>
+ </signal>
+ <!-- Interface version 2 (since 1.1.0) -->
+ <method name="GetAll2">
+ <arg name="version" type="i" direction="out"/>
+ <arg name="enabled" type="b" direction="out"/>
+ <arg name="powered" type="b" direction="out"/>
+ <arg name="supported_modes" type="u" direction="out"/>
+ <arg name="mode" type="u" direction="out"/>
+ <arg name="present" type="b" direction="out"/>
+ <arg name="tags" type="ao" direction="out"/>
+ <arg name="peers" type="ao" direction="out"/>
+ </method>
+ <!--
+ <method name="GetPeers">
+ <arg name="peers" type="ao" direction="out"/>
+ </method>
+ -->
+ <signal name="PeersChanged">
+ <arg name="peers" type="ao"/>
+ </signal>
+ </interface>
+</node>
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/spec/org.sailfishos.nfc.Daemon.xml
^
|
@@ -0,0 +1,74 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.sailfishos.nfc.Daemon">
+ <method name="GetAll">
+ <arg name="version" type="i" direction="out"/>
+ <arg name="adapters" type="ao" direction="out"/>
+ </method>
+ <!--
+ <method name="GetInterfaceVersion">
+ <arg name="version" type="i" direction="out"/>
+ </method>
+ <method name="GetAdapters">
+ <arg name="adapters" type="ao" direction="out"/>
+ </method>
+ -->
+ <!-- Signals -->
+ <signal name="AdaptersChanged">
+ <arg name="adapters" type="ao"/>
+ </signal>
+ <!-- Interface version 2 (since 1.0.26) -->
+ <method name="GetAll2">
+ <arg name="version" type="i" direction="out"/>
+ <arg name="adapters" type="ao" direction="out"/>
+ <arg name="daemon_version" type="i" direction="out"/>
+ </method>
+ <method name="GetDaemonVersion">
+ <arg name="daemon_version" type="i" direction="out"/>
+ </method>
+ <!-- Interface version 3 (since 1.1.0) -->
+ <method name="GetAll3">
+ <arg name="version" type="i" direction="out"/>
+ <arg name="adapters" type="ao" direction="out"/>
+ <arg name="daemon_version" type="i" direction="out"/>
+ <arg name="mode" type="u" direction="out"/>
+ </method>
+ <!--
+ Mode is a bitmask.
+
+ Polling bits:
+ 0x01 - P2P Initiator
+ 0x02 - Reader/Writer
+
+ Listening bits:
+ 0x04 - P2P Target
+ 0x08 - Card Emulation
+ -->
+ <!--
+ <method name="GetMode">
+ <arg name="mode" type="u" direction="out"/>
+ </method>
+ -->
+ <signal name="ModeChanged">
+ <arg name="mode" type="u"/>
+ </signal>
+ <method name="RequestMode">
+ <arg name="enable" type="u" direction="in"/>
+ <arg name="disable" type="u" direction="in"/>
+ <arg name="id" type="u" direction="out"/>
+ </method>
+ <method name="ReleaseMode">
+ <arg name="id" type="u" direction="in"/>
+ </method>
+ <method name="RegisterLocalService">
+ <!-- Registers instance of org.sailfishos.nfc.LocalService -->
+ <arg name="path" type="o" direction="in"/>
+ <arg name="name" type="s" direction="in"/>
+ <arg name="sap" type="u" direction="out"/>
+ </method>
+ <method name="UnregisterLocalService">
+ <arg name="path" type="o" direction="in"/>
+ </method>
+ </interface>
+</node>
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/spec/org.sailfishos.nfc.IsoDep.xml
^
|
@@ -0,0 +1,30 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <!-- ISO-DEP specific extensions to org.sailfishos.nfc.Tag -->
+ <interface name="org.sailfishos.nfc.IsoDep">
+ <method name="GetAll">
+ <arg name="version" type="i" direction="out"/>
+ </method>
+ <!--
+ <method name="GetInterfaceVersion">
+ <arg name="version" type="i" direction="out"/>
+ </method>
+ -->
+ <method name="Transmit">
+ <arg name="CLA" type="y" direction="in"/>
+ <arg name="INS" type="y" direction="in"/>
+ <arg name="P1" type="y" direction="in"/>
+ <arg name="P2" type="y" direction="in"/>
+ <arg name="data" type="ay" direction="in">
+ <annotation name="org.gtk.GDBus.C.ForceGVariant" value="true"/>
+ </arg>
+ <arg name="Le" type="u" direction="in"/>
+ <arg name="response" type="ay" direction="out">
+ <annotation name="org.gtk.GDBus.C.ForceGVariant" value="true"/>
+ </arg>
+ <arg name="SW1" type="y" direction="out"/>
+ <arg name="SW2" type="y" direction="out"/>
+ </method>
+ </interface>
+</node>
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/spec/org.sailfishos.nfc.LocalService.xml
^
|
@@ -0,0 +1,26 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.sailfishos.nfc.LocalService">
+ <method name="Accept">
+ <annotation name="org.gtk.GDBus.C.UnixFD" value="1"/>
+ <arg name="rsap" type="u" direction="in"/>
+ <arg name="fd" type="h" direction="in"/>
+ <arg name="accepted" type="b" direction="out"/>
+ </method>
+ <!--
+ <method name="DatagramReceived">
+ <arg name="rsap" type="u" direction="in"/>
+ <arg name="data" type="ay" direction="in">
+ <annotation name="org.gtk.GDBus.C.ForceGVariant" value="true"/>
+ </arg>
+ </method>
+ -->
+ <method name="PeerArrived">
+ <arg name="path" type="o" direction="in"/>
+ </method>
+ <method name="PeerLeft">
+ <arg name="path" type="o" direction="in"/>
+ </method>
+ </interface>
+</node>
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/spec/org.sailfishos.nfc.Peer.xml
^
|
@@ -0,0 +1,53 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.sailfishos.nfc.Peer">
+ <!--
+ Technologies:
+
+ 0 - Unknown
+ 1 - NFC-A
+ 4 - NFC-F
+ -->
+ <method name="GetAll">
+ <arg name="version" type="i" direction="out"/>
+ <arg name="present" type="b" direction="out"/>
+ <arg name="technology" type="u" direction="out"/>
+ <arg name="interfaces" type="as" direction="out"/>
+ <arg name="wks" type="u" direction="out"/>
+ </method>
+ <!--
+ <method name="GetInterfaceVersion">
+ <arg name="version" type="i" direction="out"/>
+ </method>
+ <method name="GetPresent">
+ <arg name="present" type="b" direction="out"/>
+ </method>
+ <method name="GetTechnology">
+ <arg name="technology" type="u" direction="out"/>
+ </method>
+ <method name="GetInterfaces">
+ <arg name="interfaces" type="as" direction="out"/>
+ </method>
+ <method name="GetWellKnownServices">
+ <arg name="wks" type="u" direction="out"/>
+ </method>
+ -->
+ <method name="Deactivate"/>
+ <method name="ConnectAccessPoint">
+ <annotation name="org.gtk.GDBus.C.UnixFD" value="1"/>
+ <arg name="rsap" type="u" direction="in"/>
+ <arg name="fd" type="h" direction="out"/>
+ </method>
+ <method name="ConnectServiceName">
+ <annotation name="org.gtk.GDBus.C.UnixFD" value="1"/>
+ <arg name="name" type="s" direction="in"/>
+ <arg name="fd" type="h" direction="out"/>
+ </method>
+ <!-- Signals -->
+ <signal name="Removed"/>
+ <signal name="WellKnownServicesChanged">
+ <arg name="wks" type="u"/>
+ </signal>
+ </interface>
+</node>
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/spec/org.sailfishos.nfc.Settings.xml
^
|
@@ -0,0 +1,27 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.sailfishos.nfc.Settings">
+ <!--
+ <method name="GetAll">
+ <arg name="version" type="i" direction="out"/>
+ <arg name="enabled" type="b" direction="out"/>
+ </method>
+ <method name="GetInterfaceVersion">
+ <arg name="version" type="i" direction="out"/>
+ </method>
+ -->
+ <method name="GetEnabled">
+ <arg name="enabled" type="b" direction="out"/>
+ </method>
+ <!--
+ <method name="SetEnabled">
+ <arg name="enabled" type="b" direction="in"/>
+ </method>
+ -->
+ <!-- Signals -->
+ <signal name="EnabledChanged">
+ <arg name="enabled" type="b"/>
+ </signal>
+ </interface>
+</node>
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/spec/org.sailfishos.nfc.Tag.xml
^
|
@@ -0,0 +1,65 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.sailfishos.nfc.Tag">
+ <!--
+ Technologies:
+
+ 0 - Unknown
+ 1 - NFC-A
+ 2 - NFC-B
+ 4 - NFC-F
+
+ Protocols:
+
+ 0 - Unknown
+ 1 - Type 1 Tag
+ 2 - Type 2 Tag
+ 4 - Type 3 Tag
+ 8 - Type 4A Tag (ISO-DEP, ISO 14443)
+ 16 - Type 4B Tag,(ISO-DEP, ISO 14443)
+ 32 - NFC-DEP Protocol (ISO 18092)
+
+ The above codes are bitmasks elsewhere, but here used as enum values.
+ -->
+ <method name="GetAll">
+ <arg name="version" type="i" direction="out"/>
+ <arg name="present" type="b" direction="out"/>
+ <arg name="technology" type="u" direction="out"/>
+ <arg name="protocol" type="u" direction="out"/>
+ <arg name="type" type="u" direction="out"/>
+ <arg name="interfaces" type="as" direction="out"/>
+ <arg name="ndef_records" type="ao" direction="out"/>
+ </method>
+ <!--
+ <method name="GetInterfaceVersion">
+ <arg name="version" type="i" direction="out"/>
+ </method>
+ <method name="GetPresent">
+ <arg name="present" type="b" direction="out"/>
+ </method>
+ <method name="GetTechnology">
+ <arg name="technology" type="u" direction="out"/>
+ </method>
+ <method name="GetProtocol">
+ <arg name="protocol" type="u" direction="out"/>
+ </method>
+ <method name="GetType">
+ <arg name="type" type="u" direction="out"/>
+ </method>
+ <method name="GetInterfaces">
+ <arg name="interfaces" type="as" direction="out"/>
+ </method>
+ <method name="GetNdefRecords">
+ <arg name="ndef_records" type="ao" direction="out"/>
+ </method>
+ <method name="Deactivate"/>
+ -->
+ <!-- Interface version 2 -->
+ <signal name="Removed"/>
+ <method name="Acquire">
+ <arg name="wait" type="b" direction="in"/>
+ </method>
+ <method name="Release"/>
+ </interface>
+</node>
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/src/nfcdc_adapter.c
^
|
@@ -0,0 +1,753 @@
+/*
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include "nfcdc_adapter_p.h"
+#include "nfcdc_daemon_p.h"
+#include "nfcdc_dbus.h"
+#include "nfcdc_base.h"
+#include "nfcdc_log.h"
+
+#include <gutil_macros.h>
+#include <gutil_misc.h>
+#include <gutil_strv.h>
+
+#include "org.sailfishos.nfc.Adapter.h"
+
+enum nfc_adapter_daemon_signals {
+ DAEMON_VALID_CHANGED,
+ DAEMON_ADAPTERS_CHANGED,
+ DAEMON_SIGNAL_COUNT
+};
+
+enum nfc_adapter_client_proxy_signals {
+ PROXY_ENABLED_CHANGED,
+ PROXY_POWERED_CHANGED,
+ PROXY_MODE_CHANGED,
+ PROXY_TARGET_PRESENT_CHANGED,
+ PROXY_TAGS_CHANGED,
+ PROXY_PEERS_CHANGED,
+ PROXY_SIGNAL_COUNT
+};
+
+typedef NfcClientBaseClass NfcAdapterClientObjectClass;
+typedef struct nfc_adapter_client_object {
+ NfcClientBase base;
+ NfcAdapterClient pub;
+ NfcDaemonClient* daemon;
+ gulong daemon_event_id[DAEMON_SIGNAL_COUNT];
+ const char* name;
+ GStrV* tags;
+ GStrV* peers;
+ GDBusConnection* connection;
+ OrgSailfishosNfcAdapter* proxy;
+ gulong proxy_signal_id[PROXY_SIGNAL_COUNT];
+ gboolean proxy_initializing;
+} NfcAdapterClientObject;
+
+G_DEFINE_TYPE(NfcAdapterClientObject, nfc_adapter_client_object, \
+ NFC_CLIENT_TYPE_BASE)
+#define PARENT_CLASS nfc_adapter_client_object_parent_class
+#define THIS_TYPE nfc_adapter_client_object_get_type()
+#define THIS(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, THIS_TYPE, \
+ NfcAdapterClientObject)
+
+NFC_CLIENT_BASE_ASSERT_VALID(NFC_ADAPTER_PROPERTY_VALID);
+NFC_CLIENT_BASE_ASSERT_COUNT(NFC_ADAPTER_PROPERTY_COUNT);
+
+#define SIGNAL_BIT_(x) NFC_CLIENT_BASE_SIGNAL_BIT(NFC_ADAPTER_PROPERTY_##x)
+
+#define nfc_adapter_client_emit_queued_signals(self) \
+ nfc_client_base_emit_queued_signals(&(self)->base)
+#define nfc_adapter_client_queue_signal(self,NAME) \
+ ((self)->base.queued_signals |= SIGNAL_BIT_(NAME))
+#define nfc_adapter_client_signal_property_change(self,NAME) \
+ nfc_client_base_signal_property_change(&(self)->base, \
+ NFC_ADAPTER_PROPERTY_##NAME)
+
+static char* nfc_adapter_client_empty_strv = NULL;
+static GHashTable* nfc_adapter_client_table;
+
+static
+void
+nfc_adapter_client_reinit(
+ NfcAdapterClientObject* self);
+
+/*==========================================================================*
+ * Implementation
+ *==========================================================================*/
+
+static inline
+NfcAdapterClientObject*
+nfc_adapter_client_object_cast(
+ NfcAdapterClient* adapter)
+{
+ return G_LIKELY(adapter) ?
+ THIS(G_CAST(adapter, NfcAdapterClientObject, pub)) :
+ NULL;
+}
+
+static
+void
+nfc_adapter_client_update_tags(
+ NfcAdapterClientObject* self,
+ const GStrV* tags,
+ char** take_tags)
+{
+ NfcAdapterClient* adapter = &self->pub;
+
+ GASSERT(!take_tags || take_tags == tags);
+ if (!gutil_strv_equal(adapter->tags, tags)) {
+ DUMP_STRV(self->name, "Tags", "=", tags);
+ g_strfreev(self->tags);
+ if (tags && tags[0]) {
+ if (take_tags) {
+ self->tags = take_tags;
+ take_tags = NULL;
+ } else {
+ self->tags = g_strdupv((char**)tags);
+ }
+ adapter->tags = self->tags;
+ } else {
+ adapter->tags = &nfc_adapter_client_empty_strv;
+ self->tags = NULL;
+ }
+ nfc_adapter_client_queue_signal(self, TAGS);
+ }
+ g_strfreev(take_tags);
+}
+
+static
+void
+nfc_adapter_client_update_peers(
+ NfcAdapterClientObject* self,
+ const GStrV* peers,
+ char** take_peers)
+{
+ NfcAdapterClient* adapter = &self->pub;
+
+ GASSERT(!take_peers || take_peers == peers);
+ if (!gutil_strv_equal(adapter->peers, peers)) {
+ DUMP_STRV(self->name, "Peers", "=", peers);
+ g_strfreev(self->peers);
+ if (peers && peers[0]) {
+ if (take_peers) {
+ self->peers = take_peers;
+ take_peers = NULL;
+ } else {
+ self->peers = g_strdupv((char**)peers);
+ }
+ adapter->peers = self->peers;
+ } else {
+ adapter->peers = &nfc_adapter_client_empty_strv;
+ self->peers = NULL;
+ }
+ nfc_adapter_client_queue_signal(self, PEERS);
+ }
+ g_strfreev(take_peers);
+}
+
+static
+void
+nfc_adapter_client_update_valid_and_present(
+ NfcAdapterClientObject* self)
+{
+ NfcAdapterClient* adapter = &self->pub;
+ NfcDaemonClient* daemon = self->daemon;
+ gboolean valid, present;
+
+ if (!daemon->valid || self->proxy_initializing) {
+ valid = FALSE;
+ present = FALSE;
+ } else {
+ valid = TRUE;
+ present = (self->proxy && daemon->present &&
+ gutil_strv_contains(daemon->adapters, adapter->path));
+ }
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/src/nfcdc_adapter_p.h
^
|
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef NFCDC_ADAPTER_PRIVATE_H
+#define NFCDC_ADAPTER_PRIVATE_H
+
+#include "nfcdc_adapter.h"
+
+#include <gio/gio.h>
+
+G_GNUC_INTERNAL
+GDBusConnection*
+nfc_adapter_client_connection(
+ NfcAdapterClient* adapter);
+
+#endif /* NFCDC_ADAPTER_PRIVATE_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/src/nfcdc_base.c
^
|
@@ -0,0 +1,223 @@
+/*
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include "nfcdc_base.h"
+#include "nfcdc_log.h"
+
+G_DEFINE_ABSTRACT_TYPE(NfcClientBase, nfc_client_base, G_TYPE_OBJECT)
+#define NFC_CLIENT_BASE_GET_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), \
+ NFC_CLIENT_TYPE_BASE, NfcClientBaseClass)
+
+typedef struct nfc_client_base_closure {
+ GCClosure cclosure;
+ NfcClientBasePropertyFunc callback;
+ gpointer user_data;
+} NfcClientBaseClosure;
+
+#define nfc_client_base_closure_new() ((NfcClientBaseClosure *) \
+ g_closure_new_simple(sizeof(NfcClientBaseClosure), NULL))
+
+#define SIGNAL_PROPERTY_CHANGED_NAME "nfcdc-base-property-changed"
+#define SIGNAL_PROPERTY_DETAIL "%x"
+#define SIGNAL_PROPERTY_DETAIL_MAX_LEN (8)
+
+#define SIGNAL_BIT_(name) \
+ NFC_CLIENT_BASE_SIGNAL_BIT(NFC_CLIENT_BASE_PROPERTY_##name)
+
+enum nfc_client_base_signal {
+ SIGNAL_PROPERTY_CHANGED,
+ SIGNAL_COUNT
+};
+
+static guint nfc_client_base_signals[SIGNAL_COUNT];
+static GQuark nfc_client_base_property_quarks[NFC_CLIENT_BASE_MAX_PROPERTIES];
+
+static
+GQuark
+nfc_client_base_property_quark(
+ guint property)
+{
+ GASSERT(property < NFC_CLIENT_BASE_MAX_PROPERTIES);
+ /* For ANY property this function is expected to return zero */
+ if (property > 0 && G_LIKELY(property < NFC_CLIENT_BASE_MAX_PROPERTIES)) {
+ const int i = property - 1;
+
+ if (G_UNLIKELY(!nfc_client_base_property_quarks[i])) {
+ char buf[SIGNAL_PROPERTY_DETAIL_MAX_LEN + 1];
+
+ snprintf(buf, sizeof(buf), SIGNAL_PROPERTY_DETAIL, property);
+ buf[sizeof(buf) - 1] = 0;
+ nfc_client_base_property_quarks[i] = g_quark_from_string(buf);
+ }
+ return nfc_client_base_property_quarks[i];
+ }
+ return 0;
+}
+
+static
+void
+nfc_client_base_property_changed(
+ NfcClientBase* self,
+ guint property,
+ NfcClientBaseClosure* closure)
+{
+ const NfcClientBaseClass* klass = NFC_CLIENT_BASE_GET_CLASS(self);
+
+ closure->callback(((guint8*)self) + klass->public_offset, property,
+ closure->user_data);
+}
+
+static
+void
+nfc_client_base_emit_property_changed_signal(
+ NfcClientBase* self,
+ guint property)
+{
+ self->queued_signals &= ~NFC_CLIENT_BASE_SIGNAL_BIT(property);
+ g_signal_emit(self, nfc_client_base_signals[SIGNAL_PROPERTY_CHANGED],
+ nfc_client_base_property_quark(property), property);
+}
+
+void
+nfc_client_base_signal_property_change(
+ NfcClientBase* self,
+ guint property)
+{
+ /* N.B. This may signal more than one property change */
+ self->queued_signals |= NFC_CLIENT_BASE_SIGNAL_BIT(property);
+ nfc_client_base_emit_queued_signals(self);
+}
+
+void
+nfc_client_base_emit_queued_signals(
+ NfcClientBase* self)
+{
+ const NfcClientBaseClass* klass = NFC_CLIENT_BASE_GET_CLASS(self);
+ const guint8* base = (guint8*)self;
+ const gboolean* valid = (gboolean*)(klass->valid_offset ?
+ (base + klass->valid_offset) : NULL);
+ gboolean valid_changed;
+ guint p;
+
+ /* Handlers could drop their references to us */
+ g_object_ref(self);
+
+ /* VALID is the last signals to be emitted if the object BECOMES valid */
+ if (valid && (*valid) && (self->queued_signals & SIGNAL_BIT_(VALID))) {
+ self->queued_signals &= ~SIGNAL_BIT_(VALID);
+ valid_changed = TRUE;
+ } else {
+ valid_changed = FALSE;
+ }
+
+ /*
+ * Emit the signals. Not that in case if valid has become FALSE,
+ * then VALID is emitted first, otherwise it's emitted last.
+ */
+ for (p = valid ? 1 : 0; /* Skip VALID if we have it */
+ self->queued_signals && p < NFC_CLIENT_BASE_MAX_PROPERTIES;
+ p++) {
+ if (self->queued_signals & NFC_CLIENT_BASE_SIGNAL_BIT(p)) {
+ nfc_client_base_emit_property_changed_signal(self, p);
+ }
+ }
+
+ /* Then emit VALID if necessary */
+ if (valid_changed) {
+ nfc_client_base_emit_property_changed_signal(self,
+ NFC_CLIENT_BASE_PROPERTY_VALID);
+ }
+
+ /* And release the temporary reference */
+ g_object_unref(self);
+}
+
+gulong
+nfc_client_base_add_property_handler(
+ NfcClientBase* self,
+ guint property,
+ NfcClientBasePropertyFunc callback,
+ gpointer user_data)
+{
+ if (G_LIKELY(callback)) {
+ /*
+ * We can't directly connect the provided callback because
+ * it expects the first parameter to point to public part
+ * of the object but glib will call it with NfcClientBase as
+ * the first parameter. nfc_client_base_property_changed() will
+ * do the conversion.
+ */
+ NfcClientBaseClosure* closure = nfc_client_base_closure_new();
+ GCClosure* cc = &closure->cclosure;
+
+ cc->closure.data = closure;
+ cc->callback = G_CALLBACK(nfc_client_base_property_changed);
+ closure->callback = callback;
+ closure->user_data = user_data;
+
+ return g_signal_connect_closure_by_id(self,
+ nfc_client_base_signals[SIGNAL_PROPERTY_CHANGED],
+ nfc_client_base_property_quark(property), &cc->closure, FALSE);
+ }
+ return 0;
+}
+
+static
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/src/nfcdc_base.h
^
|
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef NFCDC_BASE_H
+#define NFCDC_BASE_H
+
+#include "nfcdc_types.h"
+
+#include <glib-object.h>
+
+typedef struct nfc_client_base_class {
+ GObjectClass object;
+ int public_offset;
+ int valid_offset;
+} NfcClientBaseClass;
+
+typedef struct nfc_client_base {
+ GObject object;
+ guint32 queued_signals;
+} NfcClientBase;
+
+G_GNUC_INTERNAL GType nfc_client_base_get_type(void);
+#define NFC_CLIENT_TYPE_BASE (nfc_client_base_get_type())
+
+typedef enum nfc_client_base_property {
+ NFC_CLIENT_BASE_PROPERTY_ANY = 0,
+ NFC_CLIENT_BASE_PROPERTY_VALID,
+ NFC_CLIENT_BASE_MAX_PROPERTIES = 32
+} NFC_CLIENT_BASE_PROPERTY;
+
+#define NFC_CLIENT_BASE_ASSERT_VALID(valid) \
+ G_STATIC_ASSERT((int)(valid) == (int)NFC_CLIENT_BASE_PROPERTY_VALID)
+#define NFC_CLIENT_BASE_ASSERT_COUNT(count) \
+ G_STATIC_ASSERT((int)count <= (int)NFC_CLIENT_BASE_MAX_PROPERTIES)
+#define NFC_CLIENT_BASE_SIGNAL_BIT(property) (1 << (property - 1))
+
+typedef
+void
+(*NfcClientBasePropertyFunc)(
+ gpointer source,
+ guint property,
+ gpointer user_data);
+
+gulong
+nfc_client_base_add_property_handler(
+ NfcClientBase* base,
+ guint property,
+ NfcClientBasePropertyFunc callback,
+ gpointer user_data)
+ G_GNUC_INTERNAL;
+
+void
+nfc_client_base_emit_queued_signals(
+ NfcClientBase* base)
+ G_GNUC_INTERNAL;
+
+void
+nfc_client_base_signal_property_change(
+ NfcClientBase* self,
+ guint property)
+ G_GNUC_INTERNAL;
+
+#endif /* NFCDC_BASE_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/src/nfcdc_daemon.c
^
|
@@ -0,0 +1,1076 @@
+/*
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include "nfcdc_base.h"
+#include "nfcdc_dbus.h"
+#include "nfcdc_daemon_p.h"
+#include "nfcdc_log.h"
+#include "nfcdc_peer_service_p.h"
+
+#include <gutil_macros.h>
+#include <gutil_misc.h>
+#include <gutil_strv.h>
+
+#include "org.sailfishos.nfc.Daemon.h"
+#include "org.sailfishos.nfc.Settings.h"
+
+/*
+ * NFCDC_NEED_PEER_SERVICE=0 can be used to avoid compiling in
+ * nfc_peer_service.c and org.sailfishos.nfc.LocalService.c
+ */
+#ifndef NFCDC_NEED_PEER_SERVICE
+# define NFCDC_NEED_PEER_SERVICE 1
+#endif /* NFCDC_NEED_PEER_SERVICE */
+
+typedef NfcClientBaseClass NfcDaemonClientObjectClass;
+typedef struct nfc_daemon_client_object {
+ NfcClientBase base;
+ NfcDaemonClient pub;
+ GStrV* adapters;
+ GError* daemon_error;
+ GDBusConnection* connection;
+
+ /* Daemon interface */
+ OrgSailfishosNfcDaemon* proxy;
+ gulong adapters_changed_id;
+ gboolean daemon_watch_initializing;
+ gboolean daemon_present;
+ guint daemon_watch_id;
+ GError* error;
+
+ /* Settings interface */
+ OrgSailfishosNfcSettings* settings;
+ gulong settings_enabled_changed_id;
+ gboolean settings_watch_initializing;
+ gboolean settings_present;
+ guint settings_watch_id;
+ GError* settings_error;
+} NfcDaemonClientObject;
+
+typedef struct nfc_mode_request_impl {
+ gint refcount;
+ NFC_MODE enable;
+ NFC_MODE disable;
+ NfcDaemonClientObject* daemon;
+ gulong present_id;
+ gboolean pending;
+ gboolean cancelled;
+ guint id;
+} NfcModeRequestImpl;
+
+typedef struct nfc_mode_request_priv {
+ NfcModeRequest pub;
+ NfcModeRequestImpl* impl;
+} NfcModeRequestPriv;
+
+G_DEFINE_TYPE(NfcDaemonClientObject, nfc_daemon_client_object, \
+ NFC_CLIENT_TYPE_BASE)
+#define PARENT_CLASS nfc_daemon_client_object_parent_class
+#define THIS_TYPE nfc_daemon_client_object_get_type()
+#define THIS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
+ THIS_TYPE, NfcDaemonClientObject))
+
+NFC_CLIENT_BASE_ASSERT_VALID(NFC_DAEMON_PROPERTY_VALID);
+NFC_CLIENT_BASE_ASSERT_COUNT(NFC_DAEMON_PROPERTY_COUNT);
+
+#define SIGNAL_BIT_(x) NFC_CLIENT_BASE_SIGNAL_BIT(NFC_DAEMON_PROPERTY_##x)
+
+#define nfc_daemon_client_emit_queued_signals(self) \
+ nfc_client_base_emit_queued_signals(&(self)->base)
+#define nfc_daemon_client_queue_signal(self,property) \
+ ((self)->base.queued_signals |= NFC_CLIENT_BASE_SIGNAL_BIT(property))
+#define nfc_daemon_client_queue_signal_(self,NAME) \
+ ((self)->base.queued_signals |= SIGNAL_BIT_(NAME))
+
+static char* nfc_daemon_client_empty_strv = NULL;
+static NfcDaemonClientObject* nfc_daemon_client_instance = NULL;
+
+/*==========================================================================*
+ * Implementation
+ *==========================================================================*/
+
+static inline
+NfcModeRequestPriv*
+nfc_mode_request_cast(
+ NfcModeRequest* req)
+{
+ return G_LIKELY(req) ?
+ G_CAST(req, NfcModeRequestPriv, pub) :
+ NULL;
+}
+
+static inline
+NfcDaemonClientObject*
+nfc_daemon_client_object_cast(
+ NfcDaemonClient* pub)
+{
+ return G_LIKELY(pub) ?
+ THIS(G_CAST(pub, NfcDaemonClientObject, pub)) :
+ NULL;
+}
+
+static
+void
+nfc_daemon_client_update_valid_and_present(
+ NfcDaemonClientObject* self)
+{
+ NfcDaemonClient* pub = &self->pub;
+ gboolean valid, present;
+
+ if (self->daemon_watch_initializing || self->settings_watch_initializing) {
+ valid = FALSE;
+ present = FALSE;
+ } else if (pub->error || !self->daemon_present || !self->settings_present) {
+ valid = TRUE;
+ present = FALSE;
+ } else if (self->proxy && self->settings) {
+ valid = TRUE;
+ present = TRUE;
+ } else {
+ /* Asynchronous initialization is in progress */
+ valid = FALSE;
+ present = FALSE;
+ }
+ if (pub->valid != valid) {
+ pub->valid = valid;
+ nfc_daemon_client_queue_signal_(self, VALID);
+ }
+ if (pub->present != present) {
+ pub->present = present;
+ nfc_daemon_client_queue_signal_(self, PRESENT);
+ }
+}
+
+static
+void
+nfc_daemon_client_update_public_error(
+ NfcDaemonClientObject* self)
+{
+ NfcDaemonClient* pub = &self->pub;
+ GError* error = self->daemon_error ? self->daemon_error :
+ self->settings_error;
+
+ if (pub->error != error) {
+ pub->error = error;
+ nfc_daemon_client_queue_signal_(self, ERROR);
+ }
+}
+
+static
+void
+nfc_daemon_client_set_daemon_error(
+ NfcDaemonClientObject* self,
+ GError* error)
+{
+ if (!self->daemon_error || !error) {
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/src/nfcdc_daemon_p.h
^
|
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef NFCDC_DAEMON_PRIVATE_H
+#define NFCDC_DAEMON_PRIVATE_H
+
+#include "nfcdc_daemon.h"
+
+#include <gio/gio.h>
+
+GDBusConnection*
+nfc_daemon_client_connection(
+ NfcDaemonClient* daemon)
+ G_GNUC_INTERNAL;
+
+void
+nfc_daemon_client_register_service(
+ NfcDaemonClient* daemon,
+ NfcPeerService* service)
+ G_GNUC_INTERNAL;
+
+void
+nfc_daemon_client_unregister_service(
+ NfcDaemonClient* daemon,
+ const char* path)
+ G_GNUC_INTERNAL;
+
+#endif /* NFCDC_DAEMON_PRIVATE_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/src/nfcdc_dbus.h
^
|
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef NFCDC_DBUS_H
+#define NFCDC_DBUS_H
+
+#include "nfcdc_types.h"
+
+#include <gio/gio.h>
+
+#define NFCD_DBUS_TYPE G_BUS_TYPE_SYSTEM
+
+#define NFCD_DBUS_DAEMON_NAME "org.sailfishos.nfc.daemon"
+#define NFCD_DBUS_DAEMON_PATH "/"
+
+#define NFCD_DBUS_SETTINGS_NAME "org.sailfishos.nfc.settings"
+#define NFCD_DBUS_SETTINGS_PATH "/"
+
+#endif /* NFCDC_DBUS_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/src/nfcdc_default_adapter.c
^
|
@@ -0,0 +1,412 @@
+/*
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include "nfcdc_default_adapter.h"
+#include "nfcdc_daemon.h"
+#include "nfcdc_base.h"
+#include "nfcdc_log.h"
+
+#include <gutil_macros.h>
+#include <gutil_misc.h>
+#include <gutil_strv.h>
+
+enum nfc_default_adapter_daemon_signals {
+ DAEMON_VALID_CHANGED,
+ DAEMON_ADAPTERS_CHANGED,
+ DAEMON_SIGNAL_COUNT
+};
+
+typedef NfcClientBaseClass NfcDefaultAdapterObjectClass;
+typedef struct nfc_default_adapter_object {
+ NfcClientBase base;
+ NfcDefaultAdapter pub;
+ NfcDaemonClient* daemon;
+ NfcAdapterClient* adapter;
+ gulong daemon_event_id[DAEMON_SIGNAL_COUNT];
+ gulong adapter_signal_id;
+ GStrV* tags;
+ GStrV* peers;
+} NfcDefaultAdapterObject;
+
+G_DEFINE_TYPE(NfcDefaultAdapterObject, nfc_default_adapter_object, \
+ NFC_CLIENT_TYPE_BASE)
+#define PARENT_CLASS nfc_default_adapter_object_parent_class
+#define THIS_TYPE (nfc_default_adapter_object_get_type())
+#define THIS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
+ THIS_TYPE, NfcDefaultAdapterObject))
+
+NFC_CLIENT_BASE_ASSERT_COUNT(NFC_DEFAULT_ADAPTER_PROPERTY_COUNT);
+
+#define SIGNAL_BIT_(x) \
+ NFC_CLIENT_BASE_SIGNAL_BIT(NFC_DEFAULT_ADAPTER_PROPERTY_##x)
+
+#define nfc_default_adapter_emit_queued_signals(self) \
+ nfc_client_base_emit_queued_signals(&(self)->base)
+#define nfc_default_adapter_queue_signal(self,NAME) \
+ ((self)->base.queued_signals |= SIGNAL_BIT_(NAME))
+
+static char* nfc_default_adapter_empty_strv = NULL;
+static NfcDefaultAdapterObject* nfc_default_adapter_instance = NULL;
+
+/*==========================================================================*
+ * Implementation
+ *==========================================================================*/
+
+static inline
+NfcDefaultAdapterObject*
+nfc_default_adapter_object_cast(
+ NfcDefaultAdapter* pub)
+{
+ return G_LIKELY(pub) ?
+ THIS(G_CAST(pub, NfcDefaultAdapterObject, pub)) :
+ NULL;
+}
+
+static
+void
+nfc_default_adapter_drop_adapter(
+ NfcDefaultAdapterObject* self)
+{
+ if (self->adapter) {
+ nfc_adapter_client_remove_handlers(self->adapter,
+ &self->adapter_signal_id, 1);
+ nfc_adapter_client_unref(self->adapter);
+ self->adapter = NULL;
+ }
+}
+
+static
+void
+nfc_default_adapter_clear(
+ NfcDefaultAdapterObject* self)
+{
+ NfcDefaultAdapter* pub = &self->pub;
+
+ if (pub->adapter) {
+ pub->adapter = NULL;
+ nfc_default_adapter_queue_signal(self, ADAPTER);
+ }
+ if (pub->enabled) {
+ pub->enabled = FALSE;
+ nfc_default_adapter_queue_signal(self, ENABLED);
+ }
+ if (pub->powered) {
+ pub->powered = FALSE;
+ nfc_default_adapter_queue_signal(self, POWERED);
+ }
+ if (pub->supported_modes) {
+ pub->supported_modes = NFC_MODE_NONE;
+ nfc_default_adapter_queue_signal(self, SUPPORTED_MODES);
+ }
+ if (pub->mode) {
+ pub->mode = NFC_MODE_NONE;
+ nfc_default_adapter_queue_signal(self, MODE);
+ }
+ if (pub->target_present) {
+ pub->target_present = FALSE;
+ nfc_default_adapter_queue_signal(self, TARGET_PRESENT);
+ }
+ if (pub->tags[0]) {
+ g_strfreev(self->tags);
+ self->tags = NULL;
+ pub->tags = &nfc_default_adapter_empty_strv;
+ nfc_default_adapter_queue_signal(self, TAGS);
+ }
+ if (pub->peers[0]) {
+ g_strfreev(self->peers);
+ self->peers = NULL;
+ pub->peers = &nfc_default_adapter_empty_strv;
+ nfc_default_adapter_queue_signal(self, PEERS);
+ }
+}
+
+static
+void
+nfc_default_adapter_sync(
+ NfcDefaultAdapterObject* self)
+{
+ NfcAdapterClient* adapter = self->adapter;
+ NfcDefaultAdapter* pub = &self->pub;
+
+ if (adapter->valid && adapter->present) {
+ if (pub->adapter != adapter) {
+ pub->adapter = adapter;
+ nfc_default_adapter_queue_signal(self, ADAPTER);
+ }
+ } else if (pub->adapter) {
+ pub->adapter = NULL;
+ nfc_default_adapter_queue_signal(self, ADAPTER);
+ }
+ if (pub->enabled != adapter->enabled) {
+ pub->enabled = adapter->enabled;
+ nfc_default_adapter_queue_signal(self, ENABLED);
+ }
+ if (pub->powered != adapter->powered) {
+ pub->powered = adapter->powered;
+ nfc_default_adapter_queue_signal(self, POWERED);
+ }
+ if (pub->supported_modes != adapter->supported_modes) {
+ pub->supported_modes = adapter->supported_modes;
+ nfc_default_adapter_queue_signal(self, SUPPORTED_MODES);
+ }
+ if (pub->mode != adapter->mode) {
+ pub->mode = adapter->mode;
+ nfc_default_adapter_queue_signal(self, MODE);
+ }
+ if (pub->target_present != adapter->target_present) {
+ pub->target_present = adapter->target_present;
+ nfc_default_adapter_queue_signal(self, TARGET_PRESENT);
+ }
+ if (!gutil_strv_equal(pub->tags, adapter->tags)) {
+ g_strfreev(self->tags);
+ if (adapter->tags[0]) {
+ pub->tags = self->tags = g_strdupv((char**)adapter->tags);
+ } else {
+ self->tags = NULL;
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/src/nfcdc_error.c
^
|
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include "nfcdc_error.h"
+
+#include <gio/gio.h>
+
+static const GDBusErrorEntry nfcdc_errors[] = {
+ #define NFCDC_ERROR_ENTRY(E,e) { \
+ NFCDC_ERROR_##E, "org.sailfishos.nfc.Error." e },
+ NFCDC_ERRORS(NFCDC_ERROR_ENTRY)
+ #undef NFCDC_ERROR_ENTRY
+};
+
+GQuark
+nfcdc_error_quark()
+{
+ static volatile gsize nfcdc_error_quark_value = 0;
+
+ g_dbus_error_register_error_domain("nfcdc-error-quark",
+ &nfcdc_error_quark_value, nfcdc_errors, G_N_ELEMENTS(nfcdc_errors));
+ return (GQuark)nfcdc_error_quark_value;
+}
+
+gboolean
+nfcdc_error_matches(
+ const GError* error,
+ NFCDC_ERROR_CODE code)
+{
+ return error && error->domain == NFCDC_ERROR && error->code == (int)code;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/src/nfcdc_isodep.c
^
|
@@ -0,0 +1,534 @@
+/*
+ * Copyright (C) 2019-2020 Jolla Ltd.
+ * Copyright (C) 2019-2020 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include "nfcdc_isodep.h"
+#include "nfcdc_base.h"
+#include "nfcdc_dbus.h"
+#include "nfcdc_tag_p.h"
+#include "nfcdc_log.h"
+
+#include <gutil_macros.h>
+#include <gutil_misc.h>
+#include <gutil_strv.h>
+
+#include "org.sailfishos.nfc.IsoDep.h"
+
+typedef NfcClientBaseClass NfcIsoDepClientObjectClass;
+typedef struct nfc_isodep_client_object {
+ NfcClientBase base;
+ NfcIsoDepClient pub;
+ NfcTagClient* tag;
+ gulong tag_event_id;
+ GDBusConnection* connection;
+ OrgSailfishosNfcIsoDep* proxy;
+ gboolean proxy_initializing;
+ gint version;
+ const char* name;
+} NfcIsoDepClientObject;
+
+G_DEFINE_TYPE(NfcIsoDepClientObject, nfc_isodep_client_object, \
+ NFC_CLIENT_TYPE_BASE)
+#define NFC_CLIENT_TYPE_ISODEP (nfc_isodep_client_object_get_type())
+#define NFC_ISODEP_CLIENT_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
+ NFC_CLIENT_TYPE_ISODEP, NfcIsoDepClientObject))
+
+NFC_CLIENT_BASE_ASSERT_VALID(NFC_ISODEP_PROPERTY_VALID);
+NFC_CLIENT_BASE_ASSERT_COUNT(NFC_ISODEP_PROPERTY_COUNT);
+
+#define SIGNAL_BIT_(x) NFC_CLIENT_BASE_SIGNAL_BIT(NFC_ISODEP_PROPERTY_##x)
+
+#define nfc_isodep_client_emit_queued_signals(self) \
+ nfc_client_base_emit_queued_signals(&(self)->base)
+#define nfc_isodep_client_queue_signal(self,NAME) \
+ ((self)->base.queued_signals |= SIGNAL_BIT_(NAME))
+
+typedef struct nfc_isodep_transmit_data {
+ NfcIsoDepClientObject* object;
+ NfcIsoDepTransmitFunc callback;
+ GDestroyNotify destroy;
+ void* user_data;
+ GCancellable* cancel;
+ gulong cancel_id;
+} NfcIsoDepTransmitData;
+
+static GHashTable* nfc_isodep_client_table;
+
+static
+void
+nfc_isodep_client_reinit(
+ NfcIsoDepClientObject* self);
+
+/*==========================================================================*
+ * Implementation
+ *==========================================================================*/
+
+static inline
+NfcIsoDepClientObject*
+nfc_isodep_client_object_cast(
+ NfcIsoDepClient* pub)
+{
+ return G_LIKELY(pub) ?
+ NFC_ISODEP_CLIENT_OBJECT(G_CAST(pub, NfcIsoDepClientObject, pub)) :
+ NULL;
+}
+
+static
+void
+nfc_isodep_client_transmit_cancelled(
+ GCancellable* cancel,
+ NfcIsoDepTransmitData* data)
+{
+ data->callback = NULL;
+}
+
+static
+void
+nfc_isodep_client_transmit_done(
+ GObject* proxy,
+ GAsyncResult* result,
+ gpointer user_data)
+{
+ NfcIsoDepTransmitData* data = user_data;
+ GVariant* response = NULL;
+ GError* error = NULL;
+ guchar sw1 = 0, sw2 = 0;
+
+ org_sailfishos_nfc_iso_dep_call_transmit_finish(ORG_SAILFISHOS_NFC_ISO_DEP
+ (proxy), &response, &sw1, &sw2, result, &error);
+ if (data->cancel) {
+ g_signal_handler_disconnect(data->cancel, data->cancel_id);
+ g_object_unref(data->cancel);
+ }
+ if (data->callback) {
+ NfcIsoDepTransmitFunc callback = data->callback;
+ NfcIsoDepClient* isodep = &data->object->pub;
+ const GUtilData* resp;
+ GUtilData d;
+
+ if (error) {
+ resp = NULL;
+ } else {
+ d.bytes = g_variant_get_fixed_array(response, &d.size, 1);
+ resp = &d;
+ }
+ data->callback = NULL;
+ callback(isodep, resp, NFC_ISODEP_SW(sw1, sw2), error, data->user_data);
+ }
+ if (data->destroy) {
+ data->destroy(data->user_data);
+ }
+ if (error) {
+ g_error_free(error);
+ } else {
+ g_variant_unref(response);
+ }
+ g_object_unref(data->object);
+ g_slice_free1(sizeof(*data), data);
+}
+
+static
+void
+nfc_isodep_client_update_valid_and_present(
+ NfcIsoDepClientObject* self)
+{
+ NfcIsoDepClient* pub = &self->pub;
+ NfcTagClient* tag = self->tag;
+ gboolean valid, present;
+
+ if (!tag->valid || self->proxy_initializing) {
+ valid = FALSE;
+ present = FALSE;
+ } else {
+ valid = TRUE;
+ present = (self->proxy && tag->present &&
+ gutil_strv_contains(tag->interfaces, NFC_TAG_INTERFACE_ISODEP));
+ }
+ if (pub->valid != valid) {
+ pub->valid = valid;
+ nfc_isodep_client_queue_signal(self, VALID);
+ }
+ if (pub->present != present) {
+ pub->present = present;
+ nfc_isodep_client_queue_signal(self, PRESENT);
+ }
+}
+
+static
+void
+nfc_isodep_client_drop_proxy(
+ NfcIsoDepClientObject* self)
+{
+ NfcIsoDepClient* pub = &self->pub;
+
+ GASSERT(!self->proxy_initializing);
+ if (self->proxy) {
+ g_object_unref(self->proxy);
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/src/nfcdc_log.c
^
|
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include "nfcdc_log.h"
+
+/* Log module */
+GLOG_MODULE_DEFINE("nfc-client");
+
+#if GUTIL_LOG_DEBUG
+
+void
+nfcdc_dump_strv(
+ const char* prefix,
+ const char* name,
+ const char* sep,
+ const GStrV* strv)
+{
+ if (GLOG_ENABLED(GLOG_LEVEL_DEBUG)) {
+ if (strv) {
+ GString* buf = g_string_new(NULL);
+ const GStrV* ptr;
+
+ for (ptr = strv; *ptr; ptr++) {
+ if (buf->len > 0) {
+ g_string_append(buf, ", ");
+ }
+ g_string_append(buf, *ptr);
+ }
+ if (prefix) {
+ GDEBUG("%s: %s %s {%s}", prefix, name, sep, buf->str);
+ } else {
+ GDEBUG("%s %s {%s}", name, sep, buf->str);
+ }
+ g_string_free(buf, TRUE);
+ } else {
+ if (prefix) {
+ GDEBUG("%s: %s %s", prefix, name, sep);
+ } else {
+ GDEBUG("%s %s", name, sep);
+ }
+ }
+ }
+}
+
+void
+nfcdc_dump_bytes(
+ const char* prefix,
+ const char* name,
+ const char* sep,
+ GBytes* bytes)
+{
+ if (GLOG_ENABLED(GLOG_LEVEL_DEBUG)) {
+ if (bytes) {
+ gsize size;
+ const guint8* data = g_bytes_get_data(bytes, &size);
+
+ if (size > 0) {
+ GString* buf = g_string_new(NULL);
+ gsize i;
+
+ g_string_printf(buf, "%02X", data[0]);
+ for (i = 1; i < size; i++) {
+ g_string_append_printf(buf, ":%02X", data[i]);
+ }
+ if (prefix) {
+ GDEBUG("%s: %s %s %s", prefix, name, sep, buf->str);
+ } else {
+ GDEBUG("%s %s %s", name, sep, buf->str);
+ }
+ g_string_free(buf, TRUE);
+ return;
+ }
+ }
+ if (prefix) {
+ GDEBUG("%s: %s %s", prefix, name, sep);
+ } else {
+ GDEBUG("%s %s", name, sep);
+ }
+ }
+}
+
+#endif /* GUTIL_LOG_DEBUG */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/src/nfcdc_log.h
^
|
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef NFCDC_LOG_H
+#define NFCDC_LOG_H
+
+#include "nfcdc_types.h"
+
+#define GLOG_MODULE_NAME NFCDC_LOG_MODULE
+
+#include <gutil_log.h>
+
+#if GUTIL_LOG_DEBUG
+
+G_GNUC_INTERNAL
+void
+nfcdc_dump_strv(
+ const char* prefix,
+ const char* name,
+ const char* sep,
+ const GStrV* strv);
+
+G_GNUC_INTERNAL
+void
+nfcdc_dump_bytes(
+ const char* prefix,
+ const char* name,
+ const char* sep,
+ GBytes* bytes);
+
+# define DUMP_STRV(prefix,name,sep,strv) \
+ nfcdc_dump_strv(prefix,name,sep,strv)
+# define DUMP_BYTES(prefix,name,sep,bytes) \
+ nfcdc_dump_bytes(prefix,name,sep,bytes)
+#else
+# define DUMP_STRV(prefix,name,sep,strv) ((void)0)
+# define DUMP_BYTES(prefix,name,sep,bytes) ((void)0)
+#endif
+
+#endif /* NFCDC_LOG_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/src/nfcdc_peer.c
^
|
@@ -0,0 +1,548 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include "nfcdc_adapter_p.h"
+#include "nfcdc_peer.h"
+#include "nfcdc_base.h"
+#include "nfcdc_dbus.h"
+#include "nfcdc_log.h"
+
+#include <gutil_macros.h>
+#include <gutil_misc.h>
+#include <gutil_strv.h>
+
+#include "org.sailfishos.nfc.Peer.h"
+
+#include <gio/gunixfdlist.h>
+
+enum nfc_peer_client_adapter_signals {
+ ADAPTER_VALID_CHANGED,
+ ADAPTER_PEERS_CHANGED,
+ ADAPTER_SIGNAL_COUNT
+};
+
+typedef NfcClientBaseClass NfcPeerClientObjectClass;
+typedef struct nfc_peer_client_object {
+ NfcClientBase base;
+ NfcPeerClient pub;
+ GDBusConnection* connection;
+ NfcAdapterClient* adapter;
+ gulong adapter_event_id[ADAPTER_SIGNAL_COUNT];
+ OrgSailfishosNfcPeer* proxy;
+ gboolean proxy_initializing;
+} NfcPeerClientObject;
+
+G_DEFINE_TYPE(NfcPeerClientObject, nfc_peer_client_object, \
+ NFC_CLIENT_TYPE_BASE)
+#define PARENT_CLASS nfc_peer_client_object_parent_class
+#define THIS_TYPE nfc_peer_client_object_get_type()
+#define THIS(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), THIS_TYPE, \
+ NfcPeerClientObject)
+
+NFC_CLIENT_BASE_ASSERT_COUNT(NFC_PEER_PROPERTY_VALID);
+NFC_CLIENT_BASE_ASSERT_COUNT(NFC_PEER_PROPERTY_COUNT);
+
+#define SIGNAL_BIT_(x) NFC_CLIENT_BASE_SIGNAL_BIT(NFC_PEER_PROPERTY_##x)
+
+#define nfc_peer_client_emit_queued_signals(self) \
+ nfc_client_base_emit_queued_signals(&(self)->base)
+#define nfc_peer_client_queue_signal(self,NAME) \
+ ((self)->base.queued_signals |= SIGNAL_BIT_(NAME))
+
+typedef struct nfc_peer_client_connect_data {
+ NfcPeerClient* peer;
+ NfcPeerClientConnectionFunc callback;
+ void* user_data;
+ GDestroyNotify destroy;
+ gboolean (*finish_call) (
+ OrgSailfishosNfcPeer* proxy,
+ GVariant** fd,
+ GUnixFDList** fdl,
+ GAsyncResult* result,
+ GError** error);
+} NfcPeerClientConnectData;
+
+static GHashTable* nfc_peer_client_table;
+
+static
+void
+nfc_peer_client_reinit(
+ NfcPeerClientObject* self);
+
+/*==========================================================================*
+ * Implementation
+ *==========================================================================*/
+
+static inline
+NfcPeerClientObject*
+nfc_peer_client_object_cast(
+ NfcPeerClient* peer)
+{
+ return peer ? THIS(G_CAST(peer, NfcPeerClientObject, pub)) : NULL;
+}
+
+static
+void
+nfc_peer_client_update_valid_and_present(
+ NfcPeerClientObject* self)
+{
+ NfcPeerClient* peer = &self->pub;
+ NfcAdapterClient* adapter = self->adapter;
+ gboolean valid, present;
+
+ if (!adapter->valid || self->proxy_initializing) {
+ valid = FALSE;
+ present = FALSE;
+ } else {
+ valid = TRUE;
+ present = (self->proxy && adapter->present &&
+ gutil_strv_contains(adapter->peers, peer->path));
+ }
+ if (peer->valid != valid) {
+ peer->valid = valid;
+ nfc_peer_client_queue_signal(self, VALID);
+ }
+ if (peer->present != present) {
+ peer->present = present;
+ nfc_peer_client_queue_signal(self, PRESENT);
+ }
+}
+
+static
+void
+nfc_peer_client_drop_proxy(
+ NfcPeerClientObject* self)
+{
+ NfcPeerClient* peer = &self->pub;
+
+ GASSERT(!self->proxy_initializing);
+ if (self->proxy) {
+ g_object_unref(self->proxy);
+ self->proxy = NULL;
+ }
+ if (peer->valid) {
+ peer->valid = FALSE;
+ nfc_peer_client_queue_signal(self, VALID);
+ }
+ if (peer->present) {
+ peer->present = FALSE;
+ nfc_peer_client_queue_signal(self, PRESENT);
+ }
+ if (peer->wks) {
+ peer->wks = 0;
+ nfc_peer_client_queue_signal(self, WKS);
+ }
+}
+
+static
+void
+nfc_peer_client_update(
+ NfcPeerClientObject* self)
+{
+ NfcPeerClient* pub = &self->pub;
+
+ if (gutil_strv_contains(self->adapter->peers, pub->path)) {
+ if (!self->proxy && !self->proxy_initializing) {
+ nfc_peer_client_reinit(self);
+ }
+ } else if (!self->proxy_initializing) {
+ nfc_peer_client_drop_proxy(self);
+ }
+ nfc_peer_client_update_valid_and_present(self);
+}
+
+static
+void
+nfc_peer_client_adapter_changed(
+ NfcAdapterClient* adapter,
+ NFC_ADAPTER_PROPERTY property,
+ void* user_data)
+{
+ NfcPeerClientObject* self = THIS(user_data);
+
+ nfc_peer_client_update(self);
+ nfc_peer_client_emit_queued_signals(self);
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/src/nfcdc_peer_service.c
^
|
@@ -0,0 +1,541 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+/* This API exists since 1.0.6 */
+
+#include "nfcdc_base.h"
+#include "nfcdc_daemon_p.h"
+#include "nfcdc_log.h"
+#include "nfcdc_peer_service_p.h"
+
+#include "org.sailfishos.nfc.LocalService.h"
+
+#include <gutil_macros.h>
+#include <gutil_misc.h>
+
+#include <gio/gunixfdlist.h>
+
+#include <sys/socket.h>
+
+enum nfc_peer_service_daemon_events {
+ DAEMON_PRESENT_CHANGED,
+ DAEMON_SIGNAL_COUNT
+};
+
+enum nfc_peer_service_calls {
+ CALL_ACCEPT,
+ CALL_PEER_ARRIVED,
+ CALL_PEER_LEFT,
+ CALL_COUNT
+};
+
+typedef NfcClientBaseClass NfcPeerServiceObjectClass;
+typedef struct nfc_peer_service_object {
+ NfcClientBase base;
+ NfcPeerService pub;
+ NfcDaemonClient* daemon;
+ NfcPeerServiceHandlerFunc handler;
+ void* handler_data;
+ OrgSailfishosNfcLocalService* object;
+ gulong call_id[CALL_COUNT];
+ gulong daemon_event_id[CALL_COUNT];
+ gboolean exported;
+ char* path;
+ char* sn;
+} NfcPeerServiceObject;
+
+typedef struct nfc_service_connection_priv {
+ NfcServiceConnection pub;
+ OrgSailfishosNfcLocalService* object;
+ GDBusMethodInvocation* accept_call;
+ gint refcount;
+} NfcServiceConnectionPriv;
+
+G_DEFINE_TYPE(NfcPeerServiceObject, nfc_peer_service_object, \
+ NFC_CLIENT_TYPE_BASE)
+#define PARENT_CLASS nfc_peer_service_object_parent_class
+#define THIS_TYPE (nfc_peer_service_object_get_type())
+#define THIS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), THIS_TYPE, \
+ NfcPeerServiceObject))
+
+NFC_CLIENT_BASE_ASSERT_COUNT(NFC_PEER_SERVICE_PROPERTY_COUNT);
+
+#define SIGNAL_BIT_(x) \
+ NFC_CLIENT_BASE_SIGNAL_BIT(NFC_PEER_SERVICE_PROPERTY_##x)
+
+#define nfc_peer_service_emit_queued_signals(self) \
+ nfc_client_base_emit_queued_signals(&(self)->base)
+#define nfc_peer_service_signal_property_change(self,NAME) \
+ nfc_client_base_signal_property_change(&(self)->base, \
+ NFC_PEER_SERVICE_PROPERTY_##NAME)
+#define nfc_peer_service_queue_signal(self,property) \
+ ((self)->base.queued_signals |= NFC_CLIENT_BASE_SIGNAL_BIT(property))
+#define nfc_peer_service_queue_signal_(self,NAME) \
+ ((self)->base.queued_signals |= SIGNAL_BIT_(NAME))
+
+enum nfc_peer_service_signal {
+ SIGNAL_PEER_ARRIVED,
+ SIGNAL_PEER_LEFT,
+ SIGNAL_ACCEPT,
+ SIGNAL_COUNT
+};
+
+#define SIGNAL_PEER_ARRIVED_NAME "nfcdc-peer-service-peer-arrived"
+#define SIGNAL_PEER_LEFT_NAME "nfcdc-peer-service-peer-left"
+#define SIGNAL_ACCEPT_NAME "nfcdc-peer-service-accept"
+
+static guint nfc_peer_service_signals[SIGNAL_COUNT];
+
+/*==========================================================================*
+ * Implementation
+ *==========================================================================*/
+
+static inline
+NfcPeerServiceObject*
+nfc_peer_service_object_cast(
+ NfcPeerService* service)
+{
+ return service ? THIS(G_CAST(service, NfcPeerServiceObject, pub)) : NULL;
+}
+
+static inline
+NfcServiceConnectionPriv*
+nfc_service_connection_cast(
+ NfcServiceConnection* conn)
+{
+ return conn ? G_CAST(conn, NfcServiceConnectionPriv, pub) : NULL;
+}
+
+static
+NfcServiceConnectionPriv*
+nfc_service_connection_priv_new(
+ OrgSailfishosNfcLocalService* object,
+ GDBusMethodInvocation* call,
+ GUnixFDList* fdl,
+ guint rsap)
+{
+ NfcServiceConnectionPriv* priv = g_slice_new0(NfcServiceConnectionPriv);
+ NfcServiceConnection* conn = &priv->pub;
+
+ conn->rsap = rsap;
+ conn->fd = g_unix_fd_list_get(fdl, 0, NULL);
+ g_atomic_int_set(&priv->refcount, 1);
+ g_object_ref(priv->object = object);
+ g_object_ref(priv->accept_call = call);
+ return priv;
+}
+
+static
+void
+nfc_service_connection_priv_unref(
+ NfcServiceConnectionPriv* priv)
+{
+ if (g_atomic_int_dec_and_test(&priv->refcount)) {
+ NfcServiceConnection* conn = &priv->pub;
+
+ if (priv->accept_call) {
+ /* Reject the connection */
+ GDEBUG("Rejecting connection from %u", conn->rsap);
+ org_sailfishos_nfc_local_service_complete_accept(priv->object,
+ priv->accept_call, NULL, FALSE);
+ g_object_unref(priv->accept_call);
+ }
+ g_object_unref(priv->object);
+ shutdown(conn->fd, SHUT_RDWR);
+ close(conn->fd);
+ gutil_slice_free(conn);
+ }
+}
+
+static
+void
+nfc_peer_service_try_register(
+ NfcPeerServiceObject* self)
+{
+ NfcPeerService* service = &self->pub;
+
+ if (!service->sap && self->exported) {
+ NfcDaemonClient* daemon = self->daemon;
+
+ if (daemon->valid && daemon->present) {
+ nfc_daemon_client_register_service(daemon, service);
+ }
+ }
+}
+
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/src/nfcdc_peer_service_p.h
^
|
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef NFCDC_PEER_SERVICE_PRIVATE_H
+#define NFCDC_PEER_SERVICE_PRIVATE_H
+
+#include "nfcdc_peer_service.h"
+
+void
+nfc_peer_service_registered(
+ NfcPeerService* service,
+ guint sap)
+ G_GNUC_INTERNAL;
+
+void
+nfc_peer_service_registeration_failed(
+ NfcPeerService* service,
+ const GError* error)
+ G_GNUC_INTERNAL;
+
+#endif /* NFCDC_PEER_SERVICE_PRIVATE_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/src/nfcdc_tag.c
^
|
@@ -0,0 +1,772 @@
+/*
+ * Copyright (C) 2019-2020 Jolla Ltd.
+ * Copyright (C) 2019-2020 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include "nfcdc_adapter_p.h"
+#include "nfcdc_base.h"
+#include "nfcdc_dbus.h"
+#include "nfcdc_tag_p.h"
+#include "nfcdc_log.h"
+
+#include <gutil_macros.h>
+#include <gutil_misc.h>
+#include <gutil_strv.h>
+
+#include "org.sailfishos.nfc.Tag.h"
+
+enum nfc_tag_client_adapter_signals {
+ ADAPTER_VALID_CHANGED,
+ ADAPTER_TAGS_CHANGED,
+ ADAPTER_SIGNAL_COUNT
+};
+
+typedef NfcClientBaseClass NfcTagClientObjectClass;
+typedef struct nfc_tag_client_object {
+ NfcClientBase base;
+ NfcTagClient pub;
+ NfcTagClientLock* lock;
+ GDBusConnection* connection;
+ NfcAdapterClient* adapter;
+ gulong adapter_event_id[ADAPTER_SIGNAL_COUNT];
+ OrgSailfishosNfcTag* proxy;
+ gboolean proxy_initializing;
+ gint version;
+ const char* name;
+ GStrV* interfaces;
+ GStrV* ndef_records;
+} NfcTagClientObject;
+
+G_DEFINE_TYPE(NfcTagClientObject, nfc_tag_client_object, \
+ NFC_CLIENT_TYPE_BASE)
+#define NFC_CLIENT_TYPE_TAG (nfc_tag_client_object_get_type())
+#define NFC_TAG_CLIENT_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
+ NFC_CLIENT_TYPE_TAG, NfcTagClientObject))
+
+NFC_CLIENT_BASE_ASSERT_VALID(NFC_TAG_PROPERTY_VALID);
+NFC_CLIENT_BASE_ASSERT_COUNT(NFC_TAG_PROPERTY_COUNT);
+
+#define SIGNAL_BIT_(x) NFC_CLIENT_BASE_SIGNAL_BIT(NFC_TAG_PROPERTY_##x)
+
+#define nfc_tag_client_emit_queued_signals(self) \
+ nfc_client_base_emit_queued_signals(&(self)->base)
+#define nfc_tag_client_queue_signal(self,NAME) \
+ ((self)->base.queued_signals |= SIGNAL_BIT_(NAME))
+
+static char* nfc_tag_client_empty_strv = NULL;
+static GHashTable* nfc_tag_client_table;
+
+static
+void
+nfc_tag_client_reinit(
+ NfcTagClientObject* self);
+
+/*==========================================================================*
+ * Lock
+ *==========================================================================*/
+
+struct nfc_tag_client_lock {
+ NfcTagClientObject* tag;
+ gint ref_count;
+};
+
+typedef struct nfc_tag_client_lock_data {
+ NfcTagClientObject* tag;
+ NfcTagClientLockFunc callback;
+ GDestroyNotify destroy;
+ void* user_data;
+ GCancellable* cancel;
+ gulong cancel_id;
+} NfcTagClientLockData;
+
+typedef struct nfc_tag_client_lock_data_idle {
+ NfcTagClientLockData data;
+ guint id;
+} NfcTagClientLockDataIdle;
+
+static
+void
+nfc_tag_client_lock_cancelled(
+ GCancellable* cancel,
+ NfcTagClientLockData* data)
+{
+ data->callback = NULL;
+}
+
+static
+void
+nfc_tag_client_lock_data_init(
+ NfcTagClientLockData* data,
+ NfcTagClientObject* tag,
+ NfcTagClientLockFunc callback,
+ GDestroyNotify destroy,
+ void* user_data,
+ GCancellable* cancel)
+{
+ /* The structure is supposed to be zero-initialized by the caller */
+ g_object_ref(data->tag = tag);
+ data->callback = callback;
+ data->destroy = destroy;
+ data->user_data = user_data;
+ if (cancel) {
+ g_object_ref(data->cancel = cancel);
+ data->cancel_id = g_cancellable_connect(cancel,
+ G_CALLBACK(nfc_tag_client_lock_cancelled), data, NULL);
+ }
+}
+
+static
+void
+nfc_tag_client_lock_data_deinit(
+ NfcTagClientLockData* data)
+{
+ if (data->cancel) {
+ g_signal_handler_disconnect(data->cancel, data->cancel_id);
+ g_object_unref(data->cancel);
+ }
+ if (data->destroy) {
+ data->destroy(data->user_data);
+ }
+ g_object_unref(data->tag);
+}
+
+static
+void
+nfc_tag_client_lock_data_idle_free(
+ gpointer user_data)
+{
+ NfcTagClientLockDataIdle* idle = user_data;
+ NfcTagClientLockData* data = &idle->data;
+ NfcTagClientObject* tag = data->tag;
+
+ GASSERT(tag->lock);
+ nfc_tag_client_lock_unref(tag->lock);
+ nfc_tag_client_lock_data_deinit(data);
+ g_slice_free1(sizeof(*idle), idle);
+}
+
+static
+gboolean
+nfc_tag_client_lock_idle_callback(
+ gpointer user_data)
+{
+ NfcTagClientLockDataIdle* idle = user_data;
+ NfcTagClientLockData* data = &idle->data;
+ NfcTagClientObject* tag = data->tag;
+
+ idle->id = 0;
+ GASSERT(tag->lock);
+ if (data->callback) {
+ NfcTagClientLockFunc callback = data->callback;
+
+ data->callback = NULL;
+ callback(&tag->pub, tag->lock, NULL, data->user_data);
+ }
+ return G_SOURCE_REMOVE;
+}
+
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/src/nfcdc_tag_p.h
^
|
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef NFCDC_TAG_PRIVATE_H
+#define NFCDC_TAG_PRIVATE_H
+
+#include "nfcdc_tag.h"
+
+G_GNUC_INTERNAL
+GDBusConnection*
+nfc_tag_client_connection(
+ NfcTagClient* tag);
+
+#endif /* NFCDC_TAG_PRIVATE_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/test/Makefile
^
|
@@ -0,0 +1,8 @@
+# -*- Mode: makefile-gmake -*-
+
+all:
+%:
+ @$(MAKE) -C nfc-adapter $*
+ @$(MAKE) -C nfc-daemon $*
+ @$(MAKE) -C nfc-isodep $*
+ @$(MAKE) -C nfc-tag $*
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/test/nfc-adapter/Makefile
^
|
@@ -0,0 +1,138 @@
+# -*- Mode: makefile-gmake -*-
+
+.PHONY: clean all debug release lib-release lib-debug
+
+#
+# Required packages
+#
+
+PKGS = glib-2.0 gio-2.0 gio-unix-2.0 libglibutil
+
+#
+# Default target
+#
+
+all: debug release
+
+#
+# Executable
+#
+
+EXE = nfc-adapter-test
+
+#
+# Sources
+#
+
+SRC = $(EXE).c
+
+#
+# Directories
+#
+
+SRC_DIR = .
+BUILD_DIR = build
+LIB_DIR = ../..
+DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
+RELEASE_BUILD_DIR = $(BUILD_DIR)/release
+
+#
+# Tools and flags
+#
+
+CC = $(CROSS_COMPILE)gcc
+LD = $(CC)
+WARNINGS = -Wall
+INCLUDES = -I$(LIB_DIR)/include
+BASE_FLAGS = -fPIC
+CFLAGS = $(BASE_FLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) -MMD -MP \
+ $(shell pkg-config --cflags $(PKGS))
+LDFLAGS = $(BASE_FLAGS)
+QUIET_MAKE = make --no-print-directory
+LIBS = $(shell pkg-config --libs $(PKGS))
+DEBUG_FLAGS = -g
+RELEASE_FLAGS =
+
+ifndef KEEP_SYMBOLS
+KEEP_SYMBOLS = 0
+endif
+
+ifneq ($(KEEP_SYMBOLS),0)
+RELEASE_FLAGS += -g
+SUBMAKE_OPTS += KEEP_SYMBOLS=1
+endif
+
+DEBUG_LDFLAGS = $(LDFLAGS) $(DEBUG_FLAGS)
+RELEASE_LDFLAGS = $(LDFLAGS) $(RELEASE_FLAGS)
+DEBUG_CFLAGS = $(CFLAGS) $(DEBUG_FLAGS) -DDEBUG
+RELEASE_CFLAGS = $(CFLAGS) $(RELEASE_FLAGS) -O2
+
+#
+# Files
+#
+
+DEBUG_OBJS = $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
+RELEASE_OBJS = $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
+DEBUG_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_lib)
+RELEASE_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_lib)
+DEBUG_LIB = $(LIB_DIR)/$(DEBUG_LIB_FILE)
+RELEASE_LIB = $(LIB_DIR)/$(RELEASE_LIB_FILE)
+
+#
+# Dependencies
+#
+
+DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(strip $(DEPS)),)
+-include $(DEPS)
+endif
+endif
+
+$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
+$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
+
+#
+# Rules
+#
+
+DEBUG_EXE = $(DEBUG_BUILD_DIR)/$(EXE)
+RELEASE_EXE = $(RELEASE_BUILD_DIR)/$(EXE)
+
+debug: lib-debug $(DEBUG_EXE)
+
+release: lib-release $(RELEASE_EXE)
+
+clean:
+ rm -f *~
+ rm -fr $(BUILD_DIR)
+
+cleaner: clean
+ @make -C $(LIB_DIR) clean
+
+$(DEBUG_BUILD_DIR):
+ mkdir -p $@
+
+$(RELEASE_BUILD_DIR):
+ mkdir -p $@
+
+$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
+ $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
+ $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(DEBUG_EXE): $(DEBUG_OBJS) $(DEBUG_LIB)
+ $(LD) $(DEBUG_LDFLAGS) $^ $(LIBS) -o $@
+
+$(RELEASE_EXE): $(RELEASE_OBJS) $(RELEASE_LIB)
+ $(LD) $(RELEASE_LDFLAGS) $^ $(LIBS) -o $@
+ifeq ($(KEEP_SYMBOLS),0)
+ strip $@
+endif
+
+lib-debug:
+ @make $(SUBMAKE_OPTS) -C $(LIB_DIR) debug
+
+lib-release:
+ @make $(SUBMAKE_OPTS) -C $(LIB_DIR) release
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/test/nfc-adapter/nfc-adapter-test.c
^
|
@@ -0,0 +1,264 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include "nfcdc_default_adapter.h"
+
+#include <gutil_log.h>
+#include <gutil_misc.h>
+#include <gutil_macros.h>
+
+#include <glib-unix.h>
+
+#define RET_OK (0)
+#define RET_ERR (1)
+#define RET_CANCEL (2)
+
+typedef struct app {
+ GMainLoop* loop;
+ gboolean stopped;
+ const char* adapter_path;
+ int ret;
+} App;
+
+static
+gboolean
+app_signal(
+ gpointer user_data)
+{
+ App* app = user_data;
+
+ if (!app->stopped) {
+ app->stopped = TRUE;
+ app->ret = RET_CANCEL;
+ GDEBUG("Signal caught, exiting...");
+ g_main_loop_quit(app->loop);
+ }
+ return G_SOURCE_CONTINUE;
+}
+
+static
+void
+app_adapter_changed(
+ NfcAdapterClient* adapter,
+ NFC_ADAPTER_PROPERTY property,
+ void* user_data)
+{
+ switch (property) {
+ case NFC_ADAPTER_PROPERTY_VALID:
+ GDEBUG("Valid: %s", adapter->valid ? "true" : "false");
+ break;
+ case NFC_ADAPTER_PROPERTY_PRESENT:
+ GDEBUG("Present: %s", adapter->present ? "true" : "false");
+ break;
+ case NFC_ADAPTER_PROPERTY_ENABLED:
+ GDEBUG("Enabled: %s", adapter->enabled ? "true" : "false");
+ break;
+ case NFC_ADAPTER_PROPERTY_POWERED:
+ GDEBUG("Powered: %s", adapter->powered ? "true" : "false");
+ break;
+ case NFC_ADAPTER_PROPERTY_MODE:
+ GDEBUG("Mode: 0x%02X", adapter->mode);
+ break;
+ case NFC_ADAPTER_PROPERTY_TARGET_PRESENT:
+ GDEBUG("Target: %sresent", adapter->target_present ? "P" : "Not p");
+ break;
+ case NFC_ADAPTER_PROPERTY_TAGS:
+ GDEBUG("Tags: %s", adapter->tags[0] ? adapter->tags[0] : "");
+ break;
+ case NFC_ADAPTER_PROPERTY_ANY:
+ case NFC_ADAPTER_PROPERTY_COUNT:
+ break;
+ }
+}
+
+static
+void
+app_default_adapter_changed(
+ NfcDefaultAdapter* da,
+ NFC_DEFAULT_ADAPTER_PROPERTY property,
+ void* user_data)
+{
+ switch (property) {
+ case NFC_DEFAULT_ADAPTER_PROPERTY_ADAPTER:
+ GDEBUG("Adapter: %s", da->adapter ? da->adapter->path : "none");
+ break;
+ case NFC_DEFAULT_ADAPTER_PROPERTY_ENABLED:
+ GDEBUG("Enabled: %s", da->enabled ? "true" : "false");
+ break;
+ case NFC_DEFAULT_ADAPTER_PROPERTY_POWERED:
+ GDEBUG("Powered: %s", da->powered ? "true" : "false");
+ break;
+ case NFC_DEFAULT_ADAPTER_PROPERTY_SUPPORTED_MODES:
+ GDEBUG("Supported modes: 0x%02X", da->supported_modes);
+ break;
+ case NFC_DEFAULT_ADAPTER_PROPERTY_MODE:
+ GDEBUG("Mode: 0x%02X", da->mode);
+ break;
+ case NFC_DEFAULT_ADAPTER_PROPERTY_TARGET_PRESENT:
+ GDEBUG("Target: %sresent", da->target_present ? "P" : "Not p");
+ break;
+ case NFC_DEFAULT_ADAPTER_PROPERTY_TAGS:
+ GDEBUG("Tags: %s", da->tags[0] ? da->tags[0] : "");
+ break;
+ case NFC_DEFAULT_ADAPTER_PROPERTY_ANY:
+ case NFC_DEFAULT_ADAPTER_PROPERTY_COUNT:
+ break;
+ }
+}
+
+static
+int
+app_run(
+ App* app)
+{
+ guint sigterm = g_unix_signal_add(SIGTERM, app_signal, app);
+ guint sigint = g_unix_signal_add(SIGINT, app_signal, app);
+ NfcAdapterClient* adapter = NULL;
+ NfcDefaultAdapter* da = NULL;
+ gulong id;
+
+ if (app->adapter_path) {
+ adapter = nfc_adapter_client_new(app->adapter_path);
+ id = nfc_adapter_client_add_property_handler(adapter,
+ NFC_ADAPTER_PROPERTY_ANY, app_adapter_changed, app);
+ } else {
+ da = nfc_default_adapter_new();
+ id = nfc_default_adapter_add_property_handler(da,
+ NFC_DEFAULT_ADAPTER_PROPERTY_ANY, app_default_adapter_changed,
+ app);
+ }
+
+ app->ret = RET_ERR;
+ app->loop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(app->loop);
+ g_source_remove(sigterm);
+ g_source_remove(sigint);
+ g_main_loop_unref(app->loop);
+ app->loop = NULL;
+
+ if (adapter) {
+ nfc_adapter_client_remove_handler(adapter, id);
+ nfc_adapter_client_unref(adapter);
+ } else {
+ nfc_default_adapter_remove_handler(da, id);
+ nfc_default_adapter_unref(da);
+ }
+ return app->ret;
+}
+
+static
+gboolean
+app_opt_verbose(
+ const gchar* name,
+ const gchar* value,
+ gpointer user_data,
+ GError** error)
+{
+ gutil_log_default.level = GLOG_LEVEL_VERBOSE;
+ return TRUE;
+}
+
+static
+gboolean
+app_opt_quiet(
+ const gchar* name,
+ const gchar* value,
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/test/nfc-daemon/Makefile
^
|
@@ -0,0 +1,138 @@
+# -*- Mode: makefile-gmake -*-
+
+.PHONY: clean all debug release lib-release lib-debug
+
+#
+# Required packages
+#
+
+PKGS = glib-2.0 gio-2.0 gio-unix-2.0 libglibutil
+
+#
+# Default target
+#
+
+all: debug release
+
+#
+# Executable
+#
+
+EXE = nfc-daemon-test
+
+#
+# Sources
+#
+
+SRC = $(EXE).c
+
+#
+# Directories
+#
+
+SRC_DIR = .
+BUILD_DIR = build
+LIB_DIR = ../..
+DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
+RELEASE_BUILD_DIR = $(BUILD_DIR)/release
+
+#
+# Tools and flags
+#
+
+CC = $(CROSS_COMPILE)gcc
+LD = $(CC)
+WARNINGS = -Wall
+INCLUDES = -I$(LIB_DIR)/include
+BASE_FLAGS = -fPIC
+CFLAGS = $(BASE_FLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) -MMD -MP \
+ $(shell pkg-config --cflags $(PKGS))
+LDFLAGS = $(BASE_FLAGS)
+QUIET_MAKE = make --no-print-directory
+LIBS = $(shell pkg-config --libs $(PKGS))
+DEBUG_FLAGS = -g
+RELEASE_FLAGS =
+
+ifndef KEEP_SYMBOLS
+KEEP_SYMBOLS = 0
+endif
+
+ifneq ($(KEEP_SYMBOLS),0)
+RELEASE_FLAGS += -g
+SUBMAKE_OPTS += KEEP_SYMBOLS=1
+endif
+
+DEBUG_LDFLAGS = $(LDFLAGS) $(DEBUG_FLAGS)
+RELEASE_LDFLAGS = $(LDFLAGS) $(RELEASE_FLAGS)
+DEBUG_CFLAGS = $(CFLAGS) $(DEBUG_FLAGS) -DDEBUG
+RELEASE_CFLAGS = $(CFLAGS) $(RELEASE_FLAGS) -O2
+
+#
+# Files
+#
+
+DEBUG_OBJS = $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
+RELEASE_OBJS = $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
+DEBUG_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_lib)
+RELEASE_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_lib)
+DEBUG_LIB = $(LIB_DIR)/$(DEBUG_LIB_FILE)
+RELEASE_LIB = $(LIB_DIR)/$(RELEASE_LIB_FILE)
+
+#
+# Dependencies
+#
+
+DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(strip $(DEPS)),)
+-include $(DEPS)
+endif
+endif
+
+$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
+$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
+
+#
+# Rules
+#
+
+DEBUG_EXE = $(DEBUG_BUILD_DIR)/$(EXE)
+RELEASE_EXE = $(RELEASE_BUILD_DIR)/$(EXE)
+
+debug: lib-debug $(DEBUG_EXE)
+
+release: lib-release $(RELEASE_EXE)
+
+clean:
+ rm -f *~
+ rm -fr $(BUILD_DIR)
+
+cleaner: clean
+ @make -C $(LIB_DIR) clean
+
+$(DEBUG_BUILD_DIR):
+ mkdir -p $@
+
+$(RELEASE_BUILD_DIR):
+ mkdir -p $@
+
+$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
+ $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
+ $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(DEBUG_EXE): $(DEBUG_OBJS) $(DEBUG_LIB)
+ $(LD) $(DEBUG_LDFLAGS) $^ $(LIBS) -o $@
+
+$(RELEASE_EXE): $(RELEASE_OBJS) $(RELEASE_LIB)
+ $(LD) $(RELEASE_LDFLAGS) $^ $(LIBS) -o $@
+ifeq ($(KEEP_SYMBOLS),0)
+ strip $@
+endif
+
+lib-debug:
+ @make $(SUBMAKE_OPTS) -C $(LIB_DIR) debug
+
+lib-release:
+ @make $(SUBMAKE_OPTS) -C $(LIB_DIR) release
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/test/nfc-daemon/nfc-daemon-test.c
^
|
@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include "nfcdc_daemon.h"
+
+#include <gutil_log.h>
+#include <gutil_misc.h>
+#include <gutil_macros.h>
+
+#include <glib-unix.h>
+
+#define RET_OK (0)
+#define RET_ERR (1)
+#define RET_CANCEL (2)
+
+typedef struct app {
+ GMainLoop* loop;
+ gboolean stopped;
+ int ret;
+} App;
+
+static
+gboolean
+app_signal(
+ gpointer user_data)
+{
+ App* app = user_data;
+
+ if (!app->stopped) {
+ app->stopped = TRUE;
+ app->ret = RET_CANCEL;
+ GDEBUG("Signal caught, exiting...");
+ g_main_loop_quit(app->loop);
+ }
+ return G_SOURCE_CONTINUE;
+}
+
+static
+void
+app_property_changed(
+ NfcDaemonClient* daemon,
+ NFC_DAEMON_PROPERTY property,
+ void* user_data)
+{
+ switch (property) {
+ case NFC_DAEMON_PROPERTY_VALID:
+ GDEBUG("Valid: %s", daemon->valid ? "true" : "false");
+ break;
+ case NFC_DAEMON_PROPERTY_PRESENT:
+ GDEBUG("Present: %s", daemon->present ? "true" : "false");
+ break;
+ case NFC_DAEMON_PROPERTY_ERROR:
+ GDEBUG("Error: %s", daemon->error ? daemon->error->message : "none");
+ break;
+ case NFC_DAEMON_PROPERTY_ENABLED:
+ GDEBUG("Enabled: %s", daemon->enabled ? "true" : "false");
+ break;
+ case NFC_DAEMON_PROPERTY_ADAPTERS:
+ GDEBUG("Adapters: %s", daemon->adapters[0] ? daemon->adapters[0] : "");
+ break;
+ case NFC_DAEMON_PROPERTY_ANY:
+ case NFC_DAEMON_PROPERTY_COUNT:
+ break;
+ }
+}
+
+static
+int
+app_run(
+ App* app)
+{
+ guint sigterm = g_unix_signal_add(SIGTERM, app_signal, app);
+ guint sigint = g_unix_signal_add(SIGINT, app_signal, app);
+ NfcDaemonClient* daemon = nfc_daemon_client_new();
+ gulong id = nfc_daemon_client_add_property_handler(daemon,
+ NFC_DAEMON_PROPERTY_ANY, app_property_changed, app);
+
+ app->ret = RET_ERR;
+ app->loop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(app->loop);
+ g_source_remove(sigterm);
+ g_source_remove(sigint);
+ nfc_daemon_client_remove_handler(daemon, id);
+ g_main_loop_unref(app->loop);
+ app->loop = NULL;
+ nfc_daemon_client_unref(daemon);
+ return app->ret;
+}
+
+static
+gboolean
+app_opt_verbose(
+ const gchar* name,
+ const gchar* value,
+ gpointer user_data,
+ GError** error)
+{
+ gutil_log_default.level = GLOG_LEVEL_VERBOSE;
+ return TRUE;
+}
+
+static
+gboolean
+app_opt_quiet(
+ const gchar* name,
+ const gchar* value,
+ gpointer user_data,
+ GError** error)
+{
+ gutil_log_default.level = GLOG_LEVEL_ERR;
+ return TRUE;
+}
+
+static
+gboolean
+app_init(
+ App* app,
+ int argc,
+ char* argv[])
+{
+ gboolean ok = FALSE;
+ GOptionEntry entries[] = {
+ { "verbose", 'v', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
+ app_opt_verbose, "Enable verbose output", NULL },
+ { "quiet", 'q', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
+ app_opt_quiet, "Be quiet", NULL },
+ { NULL }
+ };
+ GError* error = NULL;
+ GOptionContext* options = g_option_context_new(NULL);
+
+ g_option_context_add_main_entries(options, entries, NULL);
+ if (g_option_context_parse(options, &argc, &argv, &error)) {
+ if (argc == 1) {
+ ok = TRUE;
+ } else {
+ char* help = g_option_context_get_help(options, TRUE, NULL);
+
+ fprintf(stderr, "%s", help);
+ g_free(help);
+ }
+ } else {
+ GERR("%s", error->message);
+ g_error_free(error);
+ }
+ g_option_context_free(options);
+ return ok;
+}
+int main(int argc, char* argv[])
+{
+ int ret = RET_ERR;
+ App app;
+
+ memset(&app, 0, sizeof(app));
+ gutil_log_set_type(GLOG_TYPE_STDERR, "nfc-daemon-test");
+ if (app_init(&app, argc, argv)) {
+ ret = app_run(&app);
+ }
+ return ret;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/test/nfc-isodep/Makefile
^
|
@@ -0,0 +1,138 @@
+# -*- Mode: makefile-gmake -*-
+
+.PHONY: clean all debug release lib-release lib-debug
+
+#
+# Required packages
+#
+
+PKGS = glib-2.0 gio-2.0 gio-unix-2.0 libglibutil
+
+#
+# Default target
+#
+
+all: debug release
+
+#
+# Executable
+#
+
+EXE = nfc-isodep-test
+
+#
+# Sources
+#
+
+SRC = $(EXE).c
+
+#
+# Directories
+#
+
+SRC_DIR = .
+BUILD_DIR = build
+LIB_DIR = ../..
+DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
+RELEASE_BUILD_DIR = $(BUILD_DIR)/release
+
+#
+# Tools and flags
+#
+
+CC = $(CROSS_COMPILE)gcc
+LD = $(CC)
+WARNINGS = -Wall
+INCLUDES = -I$(LIB_DIR)/include
+BASE_FLAGS = -fPIC
+CFLAGS = $(BASE_FLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) -MMD -MP \
+ $(shell pkg-config --cflags $(PKGS))
+LDFLAGS = $(BASE_FLAGS)
+QUIET_MAKE = make --no-print-directory
+LIBS = $(shell pkg-config --libs $(PKGS))
+DEBUG_FLAGS = -g
+RELEASE_FLAGS =
+
+ifndef KEEP_SYMBOLS
+KEEP_SYMBOLS = 0
+endif
+
+ifneq ($(KEEP_SYMBOLS),0)
+RELEASE_FLAGS += -g
+SUBMAKE_OPTS += KEEP_SYMBOLS=1
+endif
+
+DEBUG_LDFLAGS = $(LDFLAGS) $(DEBUG_FLAGS)
+RELEASE_LDFLAGS = $(LDFLAGS) $(RELEASE_FLAGS)
+DEBUG_CFLAGS = $(CFLAGS) $(DEBUG_FLAGS) -DDEBUG
+RELEASE_CFLAGS = $(CFLAGS) $(RELEASE_FLAGS) -O2
+
+#
+# Files
+#
+
+DEBUG_OBJS = $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
+RELEASE_OBJS = $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
+DEBUG_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_lib)
+RELEASE_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_lib)
+DEBUG_LIB = $(LIB_DIR)/$(DEBUG_LIB_FILE)
+RELEASE_LIB = $(LIB_DIR)/$(RELEASE_LIB_FILE)
+
+#
+# Dependencies
+#
+
+DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(strip $(DEPS)),)
+-include $(DEPS)
+endif
+endif
+
+$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
+$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
+
+#
+# Rules
+#
+
+DEBUG_EXE = $(DEBUG_BUILD_DIR)/$(EXE)
+RELEASE_EXE = $(RELEASE_BUILD_DIR)/$(EXE)
+
+debug: lib-debug $(DEBUG_EXE)
+
+release: lib-release $(RELEASE_EXE)
+
+clean:
+ rm -f *~
+ rm -fr $(BUILD_DIR)
+
+cleaner: clean
+ @make -C $(LIB_DIR) clean
+
+$(DEBUG_BUILD_DIR):
+ mkdir -p $@
+
+$(RELEASE_BUILD_DIR):
+ mkdir -p $@
+
+$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
+ $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
+ $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(DEBUG_EXE): $(DEBUG_OBJS) $(DEBUG_LIB)
+ $(LD) $(DEBUG_LDFLAGS) $^ $(LIBS) -o $@
+
+$(RELEASE_EXE): $(RELEASE_OBJS) $(RELEASE_LIB)
+ $(LD) $(RELEASE_LDFLAGS) $^ $(LIBS) -o $@
+ifeq ($(KEEP_SYMBOLS),0)
+ strip $@
+endif
+
+lib-debug:
+ @make $(SUBMAKE_OPTS) -C $(LIB_DIR) debug
+
+lib-release:
+ @make $(SUBMAKE_OPTS) -C $(LIB_DIR) release
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/test/nfc-isodep/nfc-isodep-test.c
^
|
@@ -0,0 +1,408 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include "nfcdc_default_adapter.h"
+#include "nfcdc_isodep.h"
+
+#include <gutil_log.h>
+#include <gutil_misc.h>
+#include <gutil_macros.h>
+
+#include <glib-unix.h>
+
+#define RET_OK (0)
+#define RET_ERR (1)
+#define RET_CANCEL (2)
+
+typedef struct app {
+ GMainLoop* loop;
+ gboolean stopped;
+ NfcIsoDepApdu apdu;
+ NfcIsoDepClient* tag;
+ gulong tag_event_id;
+ void* bytes;
+ int ret;
+} App;
+
+static
+gboolean
+app_signal(
+ gpointer user_data)
+{
+ App* app = user_data;
+
+ if (!app->stopped) {
+ app->stopped = TRUE;
+ app->ret = RET_CANCEL;
+ GDEBUG("Signal caught, exiting...");
+ g_main_loop_quit(app->loop);
+ }
+ return G_SOURCE_CONTINUE;
+}
+
+static
+void
+app_debug_hexdump(
+ const GUtilData* data)
+{
+ if (data) {
+ const guint8* ptr = data->bytes;
+ gsize len = data->size;
+ guint off = 0;
+
+ while (len > 0) {
+ char buf[GUTIL_HEXDUMP_BUFSIZE];
+ const guint consumed = gutil_hexdump(buf, ptr + off, len);
+
+ GDEBUG(" %04X: %s", off, buf);
+ len -= consumed;
+ off += consumed;
+ }
+ }
+}
+
+static
+void
+app_transmit_done(
+ NfcIsoDepClient* isodep,
+ const GUtilData* response,
+ guint sw, /* 16 bits (SW1 << 8)|SW2 */
+ const GError* error,
+ void* user_data)
+{
+ if (error) {
+ GERR("%s", GERRMSG(error));
+ } else {
+ GINFO("Response %04X, %u byte(s)", sw, response->size);
+ app_debug_hexdump(response);
+ }
+}
+
+static
+void
+app_transmit(
+ App* app)
+{
+ GDEBUG("Sending APDU");
+ GVERIFY(nfc_isodep_client_transmit(app->tag, &app->apdu, NULL,
+ app_transmit_done, app, NULL));
+}
+
+static
+void
+app_isodep_changed(
+ NfcIsoDepClient* isodep,
+ NFC_ISODEP_PROPERTY property,
+ void* user_data)
+{
+ switch (property) {
+ case NFC_ISODEP_PROPERTY_VALID:
+ GDEBUG("Valid: %s", isodep->valid ? "true" : "false");
+ if (isodep->present) {
+ app_transmit((App*)user_data);
+ } else {
+ GINFO("Not an ISO-DEP tag");
+ }
+ break;
+ case NFC_ISODEP_PROPERTY_PRESENT:
+ GDEBUG("Present: %s", isodep->present ? "true" : "false");
+ break;
+ case NFC_ISODEP_PROPERTY_ANY:
+ case NFC_ISODEP_PROPERTY_COUNT:
+ break;
+ }
+}
+
+static
+void
+app_update_tag(
+ App* app,
+ const GStrV* tags)
+{
+ if (tags && tags[0]) {
+ const char* path = tags[0];
+
+ if (!app->tag || strcmp(app->tag->path, path)) {
+ GDEBUG("Tag %s found", tags[0]);
+ nfc_isodep_client_remove_handlers(app->tag, &app->tag_event_id, 1);
+ nfc_isodep_client_unref(app->tag);
+ app->tag = nfc_isodep_client_new(path);
+ app->tag_event_id = nfc_isodep_client_add_property_handler(app->tag,
+ NFC_ISODEP_PROPERTY_ANY, app_isodep_changed, app);
+ if (app->tag->present) {
+ app_transmit(app);
+ }
+ }
+ } else if (app->tag) {
+ GDEBUG("Tag %s is gone", app->tag->path);
+ nfc_isodep_client_remove_handlers(app->tag, &app->tag_event_id, 1);
+ nfc_isodep_client_unref(app->tag);
+ app->tag = NULL;
+ }
+}
+
+static
+void
+app_tags_changed(
+ NfcDefaultAdapter* da,
+ NFC_DEFAULT_ADAPTER_PROPERTY property,
+ void* user_data)
+{
+ app_update_tag((App*)user_data, da->tags);
+}
+
+static
+int
+app_run(
+ App* app)
+{
+ guint sigterm = g_unix_signal_add(SIGTERM, app_signal, app);
+ guint sigint = g_unix_signal_add(SIGINT, app_signal, app);
+ NfcDefaultAdapter* da = nfc_default_adapter_new();
+ gulong da_id = nfc_default_adapter_add_property_handler(da,
+ NFC_DEFAULT_ADAPTER_PROPERTY_TAGS, app_tags_changed, app);
+
+ app_update_tag(app, da->tags);
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/test/nfc-tag/Makefile
^
|
@@ -0,0 +1,138 @@
+# -*- Mode: makefile-gmake -*-
+
+.PHONY: clean all debug release lib-release lib-debug
+
+#
+# Required packages
+#
+
+PKGS = glib-2.0 gio-2.0 gio-unix-2.0 libglibutil
+
+#
+# Default target
+#
+
+all: debug release
+
+#
+# Executable
+#
+
+EXE = nfc-tag-test
+
+#
+# Sources
+#
+
+SRC = $(EXE).c
+
+#
+# Directories
+#
+
+SRC_DIR = .
+BUILD_DIR = build
+LIB_DIR = ../..
+DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
+RELEASE_BUILD_DIR = $(BUILD_DIR)/release
+
+#
+# Tools and flags
+#
+
+CC = $(CROSS_COMPILE)gcc
+LD = $(CC)
+WARNINGS = -Wall
+INCLUDES = -I$(LIB_DIR)/include
+BASE_FLAGS = -fPIC
+CFLAGS = $(BASE_FLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) -MMD -MP \
+ $(shell pkg-config --cflags $(PKGS))
+LDFLAGS = $(BASE_FLAGS)
+QUIET_MAKE = make --no-print-directory
+LIBS = $(shell pkg-config --libs $(PKGS))
+DEBUG_FLAGS = -g
+RELEASE_FLAGS =
+
+ifndef KEEP_SYMBOLS
+KEEP_SYMBOLS = 0
+endif
+
+ifneq ($(KEEP_SYMBOLS),0)
+RELEASE_FLAGS += -g
+SUBMAKE_OPTS += KEEP_SYMBOLS=1
+endif
+
+DEBUG_LDFLAGS = $(LDFLAGS) $(DEBUG_FLAGS)
+RELEASE_LDFLAGS = $(LDFLAGS) $(RELEASE_FLAGS)
+DEBUG_CFLAGS = $(CFLAGS) $(DEBUG_FLAGS) -DDEBUG
+RELEASE_CFLAGS = $(CFLAGS) $(RELEASE_FLAGS) -O2
+
+#
+# Files
+#
+
+DEBUG_OBJS = $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
+RELEASE_OBJS = $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
+DEBUG_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_lib)
+RELEASE_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_lib)
+DEBUG_LIB = $(LIB_DIR)/$(DEBUG_LIB_FILE)
+RELEASE_LIB = $(LIB_DIR)/$(RELEASE_LIB_FILE)
+
+#
+# Dependencies
+#
+
+DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(strip $(DEPS)),)
+-include $(DEPS)
+endif
+endif
+
+$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
+$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
+
+#
+# Rules
+#
+
+DEBUG_EXE = $(DEBUG_BUILD_DIR)/$(EXE)
+RELEASE_EXE = $(RELEASE_BUILD_DIR)/$(EXE)
+
+debug: lib-debug $(DEBUG_EXE)
+
+release: lib-release $(RELEASE_EXE)
+
+clean:
+ rm -f *~
+ rm -fr $(BUILD_DIR)
+
+cleaner: clean
+ @make -C $(LIB_DIR) clean
+
+$(DEBUG_BUILD_DIR):
+ mkdir -p $@
+
+$(RELEASE_BUILD_DIR):
+ mkdir -p $@
+
+$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
+ $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
+ $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(DEBUG_EXE): $(DEBUG_OBJS) $(DEBUG_LIB)
+ $(LD) $(DEBUG_LDFLAGS) $^ $(LIBS) -o $@
+
+$(RELEASE_EXE): $(RELEASE_OBJS) $(RELEASE_LIB)
+ $(LD) $(RELEASE_LDFLAGS) $^ $(LIBS) -o $@
+ifeq ($(KEEP_SYMBOLS),0)
+ strip $@
+endif
+
+lib-debug:
+ @make $(SUBMAKE_OPTS) -C $(LIB_DIR) debug
+
+lib-release:
+ @make $(SUBMAKE_OPTS) -C $(LIB_DIR) release
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libgnfcdc/test/nfc-tag/nfc-tag-test.c
^
|
@@ -0,0 +1,358 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include "nfcdc_default_adapter.h"
+#include "nfcdc_tag.h"
+
+#include <gutil_log.h>
+#include <gutil_misc.h>
+#include <gutil_macros.h>
+
+#include <glib-unix.h>
+
+#define RET_OK (0)
+#define RET_ERR (1)
+#define RET_CANCEL (2)
+
+#define LOCK_PERIOD_SEC (2)
+
+typedef struct app {
+ GMainLoop* loop;
+ gboolean stopped;
+ gboolean do_lock;
+ NfcTagClient* tag;
+ NfcTagClientLock* lock;
+ GCancellable* lock_cancel;
+ gulong tag_event_id;
+ const char* tag_path;
+ guint lock_timeout;
+ int ret;
+} App;
+
+static
+gboolean
+app_signal(
+ gpointer user_data)
+{
+ App* app = user_data;
+
+ if (!app->stopped) {
+ app->stopped = TRUE;
+ app->ret = RET_CANCEL;
+ GDEBUG("Signal caught, exiting...");
+ g_main_loop_quit(app->loop);
+ }
+ return G_SOURCE_CONTINUE;
+}
+
+static
+void
+app_dump_strv(
+ const char* prefix,
+ const GStrV* sv)
+{
+ GString* buf = g_string_new(NULL);
+
+ while (*sv) {
+ if (buf->len) g_string_append(buf, ", ");
+ g_string_append(buf, *sv++);
+ }
+ GDEBUG("%s: %s", prefix, buf->str);
+ g_string_free(buf, TRUE);
+}
+
+static
+gboolean
+app_tag_lock_expired(
+ gpointer user_data)
+{
+ App* app = user_data;
+
+ GDEBUG("Lock expired");
+ nfc_tag_client_lock_unref(app->lock);
+ app->lock_timeout = 0;
+ app->lock = NULL;
+ return G_SOURCE_REMOVE;
+}
+
+static
+void
+app_tag_locked(
+ NfcTagClient* tag,
+ NfcTagClientLock* lock,
+ const GError* error,
+ void* user_data)
+{
+ App* app = user_data;
+
+ if (lock) {
+ app->lock = nfc_tag_client_lock_ref(lock);
+ app->lock_timeout = g_timeout_add_seconds(LOCK_PERIOD_SEC,
+ app_tag_lock_expired, app);
+ } else {
+ GERR("Failed to lock the tag: %s", GERRMSG(error));
+ }
+ g_object_unref(app->lock_cancel);
+ app->lock_cancel = NULL;
+}
+
+static
+void
+app_drop_lock(
+ App* app)
+{
+ if (app->lock_cancel) {
+ g_cancellable_cancel(app->lock_cancel);
+ g_object_unref(app->lock_cancel);
+ app->lock_cancel = NULL;
+ }
+ if (app->lock) {
+ nfc_tag_client_lock_unref(app->lock);
+ app->lock = NULL;
+ }
+ if (app->lock_timeout) {
+ g_source_remove(app->lock_timeout);
+ app->lock_timeout = 0;
+ }
+}
+
+static
+void
+app_lock_tag(
+ App* app)
+{
+ GDEBUG("Locking the tag");
+ GASSERT(app->tag);
+ GASSERT(!app->lock);
+ GASSERT(!app->lock_cancel);
+ app->lock_cancel = g_cancellable_new();
+ GVERIFY(nfc_tag_client_acquire_lock(app->tag, TRUE, app->lock_cancel,
+ app_tag_locked, app, NULL));
+}
+
+static
+void
+app_tag_changed(
+ NfcTagClient* tag,
+ NFC_TAG_PROPERTY property,
+ void* user_data)
+{
+ App* app = user_data;
+
+ switch (property) {
+ case NFC_TAG_PROPERTY_VALID:
+ GDEBUG("Valid: %s", tag->valid ? "true" : "false");
+ break;
+ case NFC_TAG_PROPERTY_PRESENT:
+ GDEBUG("Present: %s", tag->present ? "true" : "false");
+ if (tag->present && app->do_lock && !app->lock_cancel && !app->lock) {
+ app_lock_tag(app);
+ }
+ break;
+ case NFC_TAG_PROPERTY_INTERFACES:
+ app_dump_strv("Interfaces", tag->interfaces);
+ break;
+ case NFC_TAG_PROPERTY_NDEF_RECORDS:
+ app_dump_strv("NDEF records", tag->ndef_records);
+ break;
+ case NFC_TAG_PROPERTY_ANY:
+ case NFC_TAG_PROPERTY_COUNT:
+ break;
+ }
+}
+
+static
+void
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libqnfcdc
^
|
+(directory)
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libqnfcdc/.gitignore
^
|
@@ -0,0 +1,2 @@
+*.pro.user
+build
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libqnfcdc/LICENSE
^
|
@@ -0,0 +1,34 @@
+Copyright (C) 2019-2021 Jolla Ltd.
+Copyright (C) 2019-2021 Slava Monich <slava@monich.com>
+
+You may use this file under the terms of the BSD license as follows:
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+ 3. Neither the names of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+OWNER 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.
+
+The views and conclusions contained in the software and documentation
+are those of the authors and should not be interpreted as representing
+any official policies, either expressed or implied.
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libqnfcdc/README
^
|
@@ -0,0 +1,5 @@
+libqnfcdc
+==========
+
+A library for talking to use nfcd D-Bus interface from a Qt app.
+It's basically a Qt wrapper for libgnfcdc.
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libqnfcdc/include/NfcAdapter.h
^
|
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef QNFCDC_ADAPTER_H
+#define QNFCDC_ADAPTER_H
+
+#include <QObject>
+
+class QQmlEngine;
+class QJSEngine;
+
+class NfcAdapter : public QObject {
+ Q_OBJECT
+ Q_DISABLE_COPY(NfcAdapter)
+ Q_PROPERTY(bool valid READ valid NOTIFY validChanged)
+ Q_PROPERTY(bool present READ present NOTIFY presentChanged)
+ Q_PROPERTY(bool enabled READ enabled NOTIFY enabledChanged)
+ Q_PROPERTY(bool powered READ powered NOTIFY poweredChanged)
+ Q_PROPERTY(bool targetPresent READ targetPresent NOTIFY targetPresentChanged)
+ Q_PROPERTY(int supportedModes READ supportedModes NOTIFY supportedModesChanged)
+ Q_PROPERTY(int mode READ mode NOTIFY modeChanged)
+ Q_PROPERTY(QString tagPath READ tagPath NOTIFY tagPathChanged)
+ Q_PROPERTY(QString peerPath READ peerPath NOTIFY peerPathChanged)
+
+public:
+ NfcAdapter(QObject* aParent = Q_NULLPTR);
+ ~NfcAdapter();
+
+ // Callback for qmlRegisterSingletonType<NfcAdapter>
+ static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
+
+ bool valid() const;
+ bool present() const;
+ bool enabled() const;
+ bool powered() const;
+ bool targetPresent() const;
+ int supportedModes() const;
+ int mode() const;
+ QString tagPath() const;
+ QString peerPath() const;
+
+Q_SIGNALS:
+ void validChanged();
+ void presentChanged();
+ void enabledChanged();
+ void poweredChanged();
+ void targetPresentChanged();
+ void supportedModesChanged();
+ void modeChanged();
+ void tagPathChanged();
+ void peerPathChanged();
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // QNFCDC_ADAPTER_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libqnfcdc/include/NfcMode.h
^
|
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef QNFCDC_MODE_H
+#define QNFCDC_MODE_H
+
+#include "NfcSystem.h"
+
+class NfcMode : public QObject {
+ Q_OBJECT
+ Q_DISABLE_COPY(NfcMode)
+ Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
+ Q_PROPERTY(int enableModes READ enableModes WRITE setEnableModes NOTIFY enableModesChanged)
+ Q_PROPERTY(int disableModes READ disableModes WRITE setDisableModes NOTIFY disableModesChanged)
+
+public:
+ NfcMode(QObject* aParent = Q_NULLPTR);
+ ~NfcMode();
+
+ bool active() const;
+ void setActive(bool aValue);
+
+ NfcSystem::Mode enableModes() const;
+ void setEnableModes(int aModes);
+
+ NfcSystem::Mode disableModes() const;
+ void setDisableModes(int aModes);
+
+Q_SIGNALS:
+ void activeChanged();
+ void enableModesChanged();
+ void disableModesChanged();
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // QNFCDC_MODE_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libqnfcdc/include/NfcPeer.h
^
|
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef QNFCDC_PEER_H
+#define QNFCDC_PEER_H
+
+#include <QObject>
+
+class NfcPeer : public QObject {
+ Q_OBJECT
+ Q_DISABLE_COPY(NfcPeer)
+ Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
+ Q_PROPERTY(bool valid READ valid NOTIFY validChanged)
+ Q_PROPERTY(bool present READ present NOTIFY presentChanged)
+ Q_PROPERTY(uint wks READ wks NOTIFY wksChanged)
+
+public:
+ NfcPeer(QObject* aParent = Q_NULLPTR);
+ ~NfcPeer();
+
+ void setPath(QString aPath);
+ QString path() const;
+
+ bool valid() const;
+ bool present() const;
+ uint wks() const;
+
+Q_SIGNALS:
+ void pathChanged();
+ void validChanged();
+ void presentChanged();
+ void wksChanged();
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // QNFCDC_PEER_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libqnfcdc/include/NfcSystem.h
^
|
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef QNFCDC_SYSTEM_H
+#define QNFCDC_SYSTEM_H
+
+#include <QObject>
+
+class QQmlEngine;
+class QJSEngine;
+
+class NfcSystem : public QObject {
+ Q_OBJECT
+ Q_DISABLE_COPY(NfcSystem)
+ Q_PROPERTY(bool valid READ valid NOTIFY validChanged)
+ Q_PROPERTY(bool present READ present NOTIFY presentChanged)
+ Q_PROPERTY(bool enabled READ enabled NOTIFY enabledChanged)
+ Q_PROPERTY(int version READ version NOTIFY versionChanged)
+ Q_PROPERTY(int mode READ mode NOTIFY modeChanged)
+ Q_ENUMS(DaemonVersions)
+ Q_ENUMS(Mode)
+
+public:
+ enum DaemonVersions {
+ Version_1_0_26 = 0x0100001a, // Fixed ISO-DEP initialization
+ Version_1_1_0 = 0x01001000 // NFC-DEP (peer-to-peer) support
+ };
+
+ enum Mode {
+ None = 0x00,
+ P2PInitiator = 0x01,
+ ReaderWriter = 0x02,
+ P2PTarget = 0x04,
+ CardEmulation = 0x08
+ };
+
+ NfcSystem(QObject* aParent = Q_NULLPTR);
+ ~NfcSystem();
+
+ // Callback for qmlRegisterSingletonType<NfcSystem>
+ static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
+
+ bool valid() const;
+ bool present() const;
+ bool enabled() const;
+ int version() const;
+ int mode() const;
+
+Q_SIGNALS:
+ void validChanged();
+ void presentChanged();
+ void enabledChanged();
+ void versionChanged();
+ void modeChanged();
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // QNFCDC_SYSTEM_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libqnfcdc/include/NfcTag.h
^
|
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef QNFCDC_TAG_H
+#define QNFCDC_TAG_H
+
+#include <QObject>
+
+class NfcTag : public QObject {
+ Q_OBJECT
+ Q_DISABLE_COPY(NfcTag)
+ Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
+ Q_PROPERTY(bool valid READ valid NOTIFY validChanged)
+ Q_PROPERTY(bool present READ present NOTIFY presentChanged)
+ Q_PROPERTY(Type type READ type NOTIFY typeChanged)
+ Q_ENUMS(Type)
+
+public:
+ enum Type {
+ Unknown,
+ Type2,
+ IsoDep
+ };
+
+ NfcTag(QObject* aParent = Q_NULLPTR);
+ ~NfcTag();
+
+ void setPath(QString aPath);
+ QString path() const;
+
+ bool valid() const;
+ bool present() const;
+ Type type() const;
+
+Q_SIGNALS:
+ void pathChanged();
+ void validChanged();
+ void presentChanged();
+ void typeChanged();
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // QNFCDC_TAG_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libqnfcdc/libqnfcdc.pro
^
|
@@ -0,0 +1,63 @@
+TARGET = qnfcdc
+TEMPLATE = lib
+CONFIG += create_pc create_prl no_install_prl link_pkgconfig
+PKGCONFIG += libgnfcdc libglibutil
+QT -= gui
+
+include(version.pri)
+
+QMAKE_CXXFLAGS += -Wno-unused-parameter
+
+DEFINES += QNFCDC_LIBRARY
+INCLUDEPATH += include
+
+PKGCONFIG_NAME = $${TARGET}
+
+isEmpty(PREFIX) {
+ PREFIX=/usr
+}
+
+CONFIG(debug, debug|release) {
+ DEFINES += DEBUG HARBOUR_DEBUG
+}
+
+OTHER_FILES += \
+ $${PKGCONFIG_NAME}.prf \
+ rpm/libqnfcdc.spec \
+ LICENSE \
+ README
+
+SOURCES += \
+ src/NfcAdapter.cpp \
+ src/NfcMode.cpp \
+ src/NfcPeer.cpp \
+ src/NfcSystem.cpp \
+ src/NfcTag.cpp
+
+PUBLIC_HEADERS += \
+ include/NfcAdapter.h \
+ include/NfcMode.h \
+ include/NfcPeer.h \
+ include/NfcSystem.h \
+ include/NfcTag.h
+
+HEADERS += \
+ src/Debug.h \
+ $${PUBLIC_HEADERS}
+
+target.path = $$[QT_INSTALL_LIBS]
+
+headers.files = $${PUBLIC_HEADERS}
+headers.path = $${INSTALL_ROOT}$${PREFIX}/include/$${TARGET}
+
+pkgconfig.files = $${PKGCONFIG_NAME}.pc
+pkgconfig.path = $$[QT_INSTALL_LIBS]/pkgconfig
+
+QMAKE_PKGCONFIG_NAME = $${PKGCONFIG_NAME}
+QMAKE_PKGCONFIG_DESTDIR = pkgconfig
+QMAKE_PKGCONFIG_INCDIR = $$headers.path
+QMAKE_PKGCONFIG_DESCRIPTION = D-Bus client for nfcd
+QMAKE_PKGCONFIG_PREFIX = $${PREFIX}
+QMAKE_PKGCONFIG_VERSION = $${VERSION}
+
+INSTALLS += target headers pkgconfig
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libqnfcdc/qnfcdc.prf
^
|
@@ -0,0 +1,5 @@
+prefix=/usr
+exec_prefix=$${prefix}
+
+INCLUDEPATH += $${prefix}/include/qnfcdc
+LIBS += -L $${exec_prefix}/lib -lqnfcdc
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libqnfcdc/rpm/libqnfcdc.spec
^
|
@@ -0,0 +1,58 @@
+Name: libqnfcdc
+
+Summary: Qt interface to nfcd
+Version: 1.0.0
+Release: 1
+License: BSD
+URL: https://github.com/monich/libqnfcdc
+Source0: %{name}-%{version}.tar.bz2
+
+%define libgnfcdc_version 1.0.6
+
+Requires: libgnfcdc >= %{libgnfcdc_version}
+BuildRequires: pkgconfig
+BuildRequires: pkgconfig(Qt5Core)
+BuildRequires: pkgconfig(libglibutil)
+BuildRequires: pkgconfig(libgnfcdc) >= %{libgnfcdc_version}
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%{!?qtc_qmake5:%define qtc_qmake5 %qmake5}
+%{!?qtc_make:%define qtc_make make}
+
+%description
+Qt interface to nfcd
+
+%package devel
+Summary: Development files for %{name}
+Requires: %{name} = %{version}-%{release}
+Requires: %{name} = %{version}
+
+%description devel
+This package contains the development header files for %{name}
+
+%prep
+%setup -q -n %{name}-%{version}
+
+%build
+%qtc_qmake5
+%qtc_make %{?_smp_mflags}
+
+%install
+rm -rf %{buildroot}
+%qmake5_install
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%defattr(-,root,root,-)
+%license LICENSE
+%{_libdir}/%{name}.so.*
+
+%files devel
+%defattr(-,root,root,-)
+%{_libdir}/%{name}.so
+%{_libdir}/pkgconfig/qnfcdc.pc
+%{_includedir}/qnfcdc/*.h
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libqnfcdc/src/Debug.h
^
|
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ */
+
+#ifndef QNFCDC_DEBUG_H
+#define QNFCDC_DEBUG_H
+
+#ifndef HARBOUR_DEBUG
+# define HARBOUR_DEBUG 0
+#endif // HARBOUR_DEBUG
+
+#ifndef HARBOUR_VERBOSE
+# define HARBOUR_VERBOSE 0
+#endif // HARBOUR_VERBOSE
+
+#include <QDebug>
+
+#if HARBOUR_VERBOSE
+#if QT_VERSION >= 0x050000
+# define HVERBOSE(x) qDebug() << x
+#else
+# define HVERBOSE(x) qDebug() << Q_FUNC_INFO << x
+#endif
+#else
+# define HVERBOSE(expr) ((void)0)
+#endif // HARBOUR_VERBOSE
+
+#if HARBOUR_DEBUG
+#if QT_VERSION >= 0x050000
+# define HDEBUG(x) qDebug() << x
+#else
+# define HDEBUG(x) qDebug() << Q_FUNC_INFO << x
+#endif
+# define HASSERT(x) ((x) ? ((void)0) : qt_assert(#x,__FILE__,__LINE__))
+# define HVERIFY(x) HASSERT(x)
+#else
+# define HDEBUG(expr) ((void)0)
+# define HASSERT(expr) ((void)0)
+# define HVERIFY(x) (x)
+#endif // HARBOUR_DEBUG
+
+#endif // QNFCDC_DEBUG_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libqnfcdc/src/NfcAdapter.cpp
^
|
@@ -0,0 +1,174 @@
+/*
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include <nfcdc_default_adapter.h>
+
+#include "NfcAdapter.h"
+
+#include "Debug.h"
+
+// ==========================================================================
+// NfcAdapter::Private
+// ==========================================================================
+
+class NfcAdapter::Private {
+public:
+
+ Private(NfcAdapter* aParent);
+ ~Private();
+
+ static const char* SIGNAL_NAME[];
+ static void propertyChanged(NfcDefaultAdapter* aAdapter,
+ NFC_DEFAULT_ADAPTER_PROPERTY aProperty, void* aTarget);
+
+public:
+ NfcDefaultAdapter* iAdapter;
+ gulong iAdapterEventId[9]; // Must match number of non-NULLs below:
+};
+
+const char* NfcAdapter::Private::SIGNAL_NAME[] = {
+ NULL, // NFC_DEFAULT_ADAPTER_PROPERTY_ANY
+ "presentChanged", // NFC_DEFAULT_ADAPTER_PROPERTY_ADAPTER
+ "enabledChanged", // NFC_DEFAULT_ADAPTER_PROPERTY_ENABLED
+ "poweredChanged", // NFC_DEFAULT_ADAPTER_PROPERTY_POWERED
+ "supportedModesChanged", // NFC_DEFAULT_ADAPTER_PROPERTY_SUPPORTED_MODES
+ "modeChanged", // NFC_DEFAULT_ADAPTER_PROPERTY_MODE
+ "targetPresentChanged", // NFC_DEFAULT_ADAPTER_PROPERTY_TARGET_PRESENT
+ "tagPathChanged", // NFC_DEFAULT_ADAPTER_PROPERTY_TAGS
+ "validChanged", // NFC_DEFAULT_ADAPTER_PROPERTY_VALID
+ "peerPathChanged", // NFC_DEFAULT_ADAPTER_PROPERTY_PEERS
+ // Remember to update iAdapterEventId count when adding new handlers!
+};
+
+NfcAdapter::Private::Private(NfcAdapter* aParent) :
+ iAdapter(nfc_default_adapter_new())
+{
+ memset(iAdapterEventId, 0, sizeof(iAdapterEventId));
+ int k = 0;
+ for (int i = 0; i < NFC_DEFAULT_ADAPTER_PROPERTY_COUNT; i++) {
+ if (SIGNAL_NAME[i]) {
+ iAdapterEventId[k++] =
+ nfc_default_adapter_add_property_handler(iAdapter,
+ (NFC_DEFAULT_ADAPTER_PROPERTY)i, propertyChanged,
+ aParent);
+ }
+ }
+ HASSERT(k == G_N_ELEMENTS(iAdapterEventId));
+ Q_STATIC_ASSERT(G_N_ELEMENTS(SIGNAL_NAME) == NFC_DEFAULT_ADAPTER_PROPERTY_COUNT);
+}
+
+NfcAdapter::Private::~Private()
+{
+ nfc_default_adapter_remove_all_handlers(iAdapter, iAdapterEventId);
+ nfc_default_adapter_unref(iAdapter);
+}
+
+// Qt calls from glib callbacks better go through QMetaObject::invokeMethod
+// See https://bugreports.qt.io/browse/QTBUG-18434 for details
+
+void NfcAdapter::Private::propertyChanged(NfcDefaultAdapter*,
+ NFC_DEFAULT_ADAPTER_PROPERTY aProperty, void* aTarget)
+{
+ QMetaObject::invokeMethod((QObject*)aTarget, SIGNAL_NAME[aProperty]);
+}
+
+// ==========================================================================
+// NfcAdapter
+// ==========================================================================
+
+NfcAdapter::NfcAdapter(QObject* aParent) :
+ QObject(aParent),
+ iPrivate(new Private(this))
+{
+}
+
+NfcAdapter::~NfcAdapter()
+{
+ delete iPrivate;
+}
+
+QObject* NfcAdapter::createSingleton(QQmlEngine* aEngine, QJSEngine* aScript)
+{
+ return new NfcAdapter;
+}
+
+bool NfcAdapter::valid() const
+{
+ return iPrivate->iAdapter->valid;
+}
+
+bool NfcAdapter::present() const
+{
+ return iPrivate->iAdapter->adapter != NULL;
+}
+
+bool NfcAdapter::enabled() const
+{
+ return iPrivate->iAdapter->enabled;
+}
+
+bool NfcAdapter::powered() const
+{
+ return iPrivate->iAdapter->powered;
+}
+
+bool NfcAdapter::targetPresent() const
+{
+ return iPrivate->iAdapter->target_present;
+}
+
+int NfcAdapter::supportedModes() const
+{
+ return iPrivate->iAdapter->supported_modes;
+}
+
+int NfcAdapter::mode() const
+{
+ return iPrivate->iAdapter->mode;
+}
+
+QString NfcAdapter::tagPath() const
+{
+ const char* tag = iPrivate->iAdapter->tags[0];
+ return tag ? QString(tag) : QString();
+}
+
+QString NfcAdapter::peerPath() const
+{
+ const char* peer = iPrivate->iAdapter->peers[0];
+ return peer ? QString(peer) : QString();
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libqnfcdc/src/NfcMode.cpp
^
|
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include <nfcdc_daemon.h>
+
+#include "NfcMode.h"
+
+#include "Debug.h"
+
+// ==========================================================================
+// NfcMode::Private
+// ==========================================================================
+
+class NfcMode::Private {
+public:
+ Private();
+ ~Private();
+
+ bool needRequest() const;
+ void updateRequest();
+
+public:
+ NfcDaemonClient* iDaemon;
+ NfcModeRequest* iRequest;
+ NfcSystem::Mode iEnableModes;
+ NfcSystem::Mode iDisableModes;
+ bool iActive;
+};
+
+NfcMode::Private::Private() :
+ iDaemon(nfc_daemon_client_new()),
+ iRequest(Q_NULLPTR),
+ iEnableModes(NfcSystem::None),
+ iDisableModes(NfcSystem::None),
+ iActive(false)
+{
+}
+
+NfcMode::Private::~Private()
+{
+ nfc_mode_request_free(iRequest);
+ nfc_daemon_client_unref(iDaemon);
+}
+
+inline bool NfcMode::Private::needRequest() const
+{
+ return iActive && (iEnableModes || iDisableModes);
+}
+
+void NfcMode::Private::updateRequest()
+{
+ if (needRequest()) {
+ nfc_mode_request_free(iRequest);
+ iRequest = nfc_mode_request_new(iDaemon, (NFC_MODE)iEnableModes,
+ (NFC_MODE)iDisableModes);
+ } else if (iRequest) {
+ nfc_mode_request_free(iRequest);
+ iRequest = Q_NULLPTR;
+ }
+}
+
+// ==========================================================================
+// NfcModeRequest
+// ==========================================================================
+
+NfcMode::NfcMode(QObject* aParent) :
+ QObject(aParent),
+ iPrivate(new Private)
+{
+}
+
+NfcMode::~NfcMode()
+{
+ delete iPrivate;
+}
+
+bool NfcMode::active() const
+{
+ return iPrivate->iActive;
+}
+
+void NfcMode::setActive(bool aActive)
+{
+ if (iPrivate->iActive != aActive) {
+ iPrivate->iActive = aActive;
+ iPrivate->updateRequest();
+ Q_EMIT activeChanged();
+ }
+}
+
+NfcSystem::Mode NfcMode::enableModes() const
+{
+ return iPrivate->iEnableModes;
+}
+
+void NfcMode::setEnableModes(int aModes)
+{
+ if (iPrivate->iEnableModes != (NfcSystem::Mode)aModes) {
+ const bool didNeedRequest = iPrivate->needRequest();
+ iPrivate->iEnableModes = (NfcSystem::Mode)aModes;
+ if (didNeedRequest != iPrivate->needRequest()) {
+ iPrivate->updateRequest();
+ }
+ Q_EMIT enableModesChanged();
+ }
+}
+
+NfcSystem::Mode NfcMode::disableModes() const
+{
+ return iPrivate->iDisableModes;
+}
+
+void NfcMode::setDisableModes(int aModes)
+{
+ if (iPrivate->iDisableModes != (NfcSystem::Mode)aModes) {
+ const bool didNeedRequest = iPrivate->needRequest();
+ iPrivate->iDisableModes = (NfcSystem::Mode)aModes;
+ if (didNeedRequest != iPrivate->needRequest()) {
+ iPrivate->updateRequest();
+ }
+ Q_EMIT disableModesChanged();
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libqnfcdc/src/NfcPeer.cpp
^
|
@@ -0,0 +1,199 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include <nfcdc_peer.h>
+
+#include "NfcPeer.h"
+
+#include "Debug.h"
+
+// ==========================================================================
+// NfcPeer::Private
+// ==========================================================================
+
+class NfcPeer::Private {
+public:
+
+ Private(NfcPeer* aParent);
+ ~Private();
+
+ void setPath(const char* aPath);
+
+ static const char* SIGNAL_NAME[];
+ static void propertyChanged(NfcPeerClient* aPeer,
+ NFC_PEER_PROPERTY aProperty, void* aTarget);
+
+public:
+ NfcPeer* iParent;
+ NfcPeerClient* iPeer;
+ gulong iPeerEventId[3]; // Must match number of non-NULLs below:
+};
+
+const char* NfcPeer::Private::SIGNAL_NAME[] = {
+ NULL, // NFC_PEER_PROPERTY_ANY
+ "validChanged", // NFC_PEER_PROPERTY_VALID
+ "presentChanged", // NFC_PEER_PROPERTY_PRESENT
+ "wksChanged", // NFC_PEER_PROPERTY_WKS
+ // Remember to update iPeerEventId count when adding new handlers!
+};
+
+NfcPeer::Private::Private(NfcPeer* aParent) :
+ iParent(aParent),
+ iPeer(Q_NULLPTR)
+{
+ memset(iPeerEventId, 0, sizeof(iPeerEventId));
+ Q_STATIC_ASSERT(G_N_ELEMENTS(SIGNAL_NAME) == NFC_PEER_PROPERTY_COUNT);
+}
+
+NfcPeer::Private::~Private()
+{
+ nfc_peer_client_remove_all_handlers(iPeer, iPeerEventId);
+ nfc_peer_client_unref(iPeer);
+}
+
+void NfcPeer::Private::setPath(const char* aPath)
+{
+ gboolean valid = FALSE;
+ gboolean present = FALSE;
+ guint wks = 0;
+
+ if (iPeer) {
+ valid = iPeer->valid;
+ present = iPeer->present;
+ wks = iPeer->wks;
+ nfc_peer_client_remove_all_handlers(iPeer, iPeerEventId);
+ nfc_peer_client_unref(iPeer);
+ iPeer = Q_NULLPTR;
+ }
+
+ if (aPath) {
+ int i, k;
+ bool changed[NFC_PEER_PROPERTY_COUNT];
+
+ iPeer = nfc_peer_client_new(aPath);
+ for (i = 1, k = 0; i < NFC_PEER_PROPERTY_COUNT; i++) {
+ if (SIGNAL_NAME[i]) {
+ iPeerEventId[k++] =
+ nfc_peer_client_add_property_handler(iPeer,
+ (NFC_PEER_PROPERTY)i, propertyChanged, iParent);
+ }
+ }
+ HASSERT(k == G_N_ELEMENTS(iPeerEventId));
+ // Signal the changes
+ memset(changed, 0, sizeof(changed));
+ changed[NFC_PEER_PROPERTY_VALID] = (valid != iPeer->valid);
+ changed[NFC_PEER_PROPERTY_PRESENT] = (present != iPeer->present);
+ changed[NFC_PEER_PROPERTY_WKS] = (wks != iPeer->wks);
+ for (i = 1; i < NFC_PEER_PROPERTY_COUNT; i++) {
+ if (changed[i]) {
+ QMetaObject::invokeMethod(iParent, SIGNAL_NAME[i]);
+ }
+ }
+ } else {
+ if (valid) {
+ QMetaObject::invokeMethod(iParent,
+ SIGNAL_NAME[NFC_PEER_PROPERTY_VALID]);
+ }
+ if (present) {
+ QMetaObject::invokeMethod(iParent,
+ SIGNAL_NAME[NFC_PEER_PROPERTY_PRESENT]);
+ }
+ if (wks) {
+ QMetaObject::invokeMethod(iParent,
+ SIGNAL_NAME[NFC_PEER_PROPERTY_WKS]);
+ }
+ }
+}
+
+// Qt calls from glib callbacks better go through QMetaObject::invokeMethod
+// See https://bugreports.qt.io/browse/QTBUG-18434 for details
+
+void NfcPeer::Private::propertyChanged(NfcPeerClient*,
+ NFC_PEER_PROPERTY aProperty, void* aTarget)
+{
+ QMetaObject::invokeMethod((QObject*)aTarget, SIGNAL_NAME[aProperty]);
+}
+
+// ==========================================================================
+// NfcPeer
+// ==========================================================================
+
+NfcPeer::NfcPeer(QObject* aParent) :
+ QObject(aParent),
+ iPrivate(new Private(this))
+{
+}
+
+NfcPeer::~NfcPeer()
+{
+ delete iPrivate;
+}
+
+void NfcPeer::setPath(QString aPath)
+{
+ const QString currentPath(path());
+ if (currentPath != aPath) {
+ HDEBUG(aPath);
+ if (aPath.isEmpty()) {
+ iPrivate->setPath(NULL);
+ } else {
+ QByteArray bytes(aPath.toLatin1());
+ iPrivate->setPath(bytes.constData());
+ }
+ Q_EMIT pathChanged();
+ }
+}
+
+QString NfcPeer::path() const
+{
+ return iPrivate->iPeer ? QString(iPrivate->iPeer->path) : QString();
+}
+
+bool NfcPeer::valid() const
+{
+ return iPrivate->iPeer && iPrivate->iPeer->valid;
+}
+
+bool NfcPeer::present() const
+{
+ return iPrivate->iPeer && iPrivate->iPeer->present;
+}
+
+uint NfcPeer::wks() const
+{
+ return iPrivate->iPeer ? iPrivate->iPeer->wks : 0;
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libqnfcdc/src/NfcSystem.cpp
^
|
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include <nfcdc_daemon.h>
+
+#include "NfcSystem.h"
+
+#include "Debug.h"
+
+Q_STATIC_ASSERT(NfcSystem::Version_1_0_26 == NFC_DAEMON_VERSION(1,0,26));
+Q_STATIC_ASSERT(NfcSystem::Version_1_1_0 == NFC_DAEMON_VERSION(1,1,0));
+
+Q_STATIC_ASSERT((int)NfcSystem::None == (int)NFC_MODE_NONE);
+Q_STATIC_ASSERT((int)NfcSystem::P2PInitiator == (int)NFC_MODE_P2P_INITIATOR);
+Q_STATIC_ASSERT((int)NfcSystem::ReaderWriter == (int)NFC_MODE_READER_WRITER);
+Q_STATIC_ASSERT((int)NfcSystem::P2PTarget == (int)NFC_MODE_P2P_TARGET);
+Q_STATIC_ASSERT((int)NfcSystem::CardEmulation == (int)NFC_MODE_CARD_EMILATION);
+
+// ==========================================================================
+// NfcSystem::Private
+// ==========================================================================
+
+class NfcSystem::Private {
+public:
+
+ Private(NfcSystem* aParent);
+ ~Private();
+
+ static const char* SIGNAL_NAME[];
+ static void propertyChanged(NfcDaemonClient* aDaemon,
+ NFC_DAEMON_PROPERTY aProperty, void* aTarget);
+
+public:
+ NfcDaemonClient* iDaemon;
+ gulong iDaemonEventId[5]; // Must match number of non-NULLs below:
+};
+
+const char* NfcSystem::Private::SIGNAL_NAME[] = {
+ NULL, // NFC_DAEMON_PROPERTY_ANY
+ "validChanged", // NFC_DAEMON_PROPERTY_VALID
+ "presentChanged", // NFC_DAEMON_PROPERTY_PRESENT
+ NULL, // NFC_DAEMON_PROPERTY_ERROR
+ "enabledChanged", // NFC_DAEMON_PROPERTY_ENABLED
+ NULL, // NFC_DAEMON_PROPERTY_ADAPTERS
+ "versionChanged", // NFC_DAEMON_PROPERTY_VERSION
+ "modeChanged" // NFC_DAEMON_PROPERTY_MODE
+ // Remember to update iDaemonEventId count when adding new handlers!
+};
+
+NfcSystem::Private::Private(NfcSystem* aParent) :
+ iDaemon(nfc_daemon_client_new())
+{
+ int k = 0;
+ for (int i = 0; i < NFC_DAEMON_PROPERTY_COUNT; i++) {
+ if (SIGNAL_NAME[i]) {
+ iDaemonEventId[k++] =
+ nfc_daemon_client_add_property_handler(iDaemon,
+ (NFC_DAEMON_PROPERTY)i, propertyChanged, aParent);
+ }
+ }
+ HASSERT(k == G_N_ELEMENTS(iDaemonEventId));
+ Q_STATIC_ASSERT(G_N_ELEMENTS(NfcSystem::Private::SIGNAL_NAME) ==
+ NFC_DAEMON_PROPERTY_COUNT);
+}
+
+NfcSystem::Private::~Private()
+{
+ nfc_daemon_client_remove_all_handlers(iDaemon, iDaemonEventId);
+ nfc_daemon_client_unref(iDaemon);
+}
+
+// Qt calls from glib callbacks better go through QMetaObject::invokeMethod
+// See https://bugreports.qt.io/browse/QTBUG-18434 for details
+
+void NfcSystem::Private::propertyChanged(NfcDaemonClient*,
+ NFC_DAEMON_PROPERTY aProperty, void* aTarget)
+{
+ QMetaObject::invokeMethod((QObject*)aTarget, SIGNAL_NAME[aProperty]);
+}
+
+// ==========================================================================
+// NfcSystem
+// ==========================================================================
+
+NfcSystem::NfcSystem(QObject* aParent) :
+ QObject(aParent),
+ iPrivate(new Private(this))
+{
+}
+
+NfcSystem::~NfcSystem()
+{
+ delete iPrivate;
+}
+
+QObject* NfcSystem::createSingleton(QQmlEngine* aEngine, QJSEngine* aScript)
+{
+ return new NfcSystem;
+}
+
+bool NfcSystem::valid() const
+{
+ return iPrivate->iDaemon->valid;
+}
+
+bool NfcSystem::present() const
+{
+ return iPrivate->iDaemon->present;
+}
+
+bool NfcSystem::enabled() const
+{
+ return iPrivate->iDaemon->enabled;
+}
+
+int NfcSystem::version() const
+{
+ return iPrivate->iDaemon->version;
+}
+
+int NfcSystem::mode() const
+{
+ return iPrivate->iDaemon->mode;
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libqnfcdc/src/NfcTag.cpp
^
|
@@ -0,0 +1,255 @@
+/*
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include "nfcdc_tag.h"
+
+#include <gutil_strv.h>
+
+#include "NfcTag.h"
+
+#include "Debug.h"
+
+enum tag_events {
+ TAG_EVENT_VALID,
+ TAG_EVENT_PRESENT,
+ TAG_EVENT_INTERFACES,
+ TAG_EVENT_COUNT
+};
+
+// ==========================================================================
+// NfcTag::Private
+// ==========================================================================
+
+class NfcTag::Private {
+public:
+
+ Private(NfcTag* aParent);
+ ~Private();
+
+ void setPath(const char* aPath);
+ bool updateType();
+ void updateTypeAndEmitSignal();
+
+ void emitValidChanged();
+ void emitPresentChanged();
+ void emitTypeChanged();
+
+ static void validChanged(NfcTagClient*, NFC_TAG_PROPERTY, void*);
+ static void presentChanged(NfcTagClient*, NFC_TAG_PROPERTY, void*);
+ static void interfacesChanged(NfcTagClient*, NFC_TAG_PROPERTY, void*);
+
+public:
+ NfcTag* iParent;
+ NfcTagClient* iTag;
+ gulong iTagEventId[TAG_EVENT_COUNT];
+ Type iType;
+};
+
+NfcTag::Private::Private(NfcTag* aParent) :
+ iParent(aParent),
+ iTag(NULL),
+ iType(Unknown)
+{
+ memset(iTagEventId, 0, sizeof(iTagEventId));
+}
+
+NfcTag::Private::~Private()
+{
+ nfc_tag_client_remove_all_handlers(iTag, iTagEventId);
+ nfc_tag_client_unref(iTag);
+}
+
+void NfcTag::Private::setPath(const char* aPath)
+{
+ nfc_tag_client_remove_all_handlers(iTag, iTagEventId);
+ nfc_tag_client_unref(iTag);
+ if (aPath) {
+ iTag = nfc_tag_client_new(aPath);
+ iTagEventId[TAG_EVENT_VALID] =
+ nfc_tag_client_add_property_handler(iTag,
+ NFC_TAG_PROPERTY_VALID, validChanged, this);
+ iTagEventId[TAG_EVENT_PRESENT] =
+ nfc_tag_client_add_property_handler(iTag,
+ NFC_TAG_PROPERTY_PRESENT, presentChanged, this);
+ iTagEventId[TAG_EVENT_INTERFACES] =
+ nfc_tag_client_add_property_handler(iTag,
+ NFC_TAG_PROPERTY_INTERFACES, interfacesChanged, this);
+ } else {
+ iTag = NULL;
+ }
+ updateType();
+}
+
+bool NfcTag::Private::updateType()
+{
+ Type type = Unknown;
+ if (iTag) {
+ if (gutil_strv_contains(iTag->interfaces,
+ NFC_TAG_INTERFACE_ISODEP)) {
+ type = IsoDep;
+ } else if (gutil_strv_contains(iTag->interfaces,
+ NFC_TAG_INTERFACE_TYPE2)) {
+ type = Type2;
+ }
+ }
+ if (iType != type) {
+ iType = type;
+ return true;
+ } else {
+ return false;
+ }
+}
+
+// Qt calls from glib callbacks better go through QMetaObject::invokeMethod
+// See https://bugreports.qt.io/browse/QTBUG-18434 for details
+
+inline void NfcTag::Private::emitValidChanged()
+{
+ QMetaObject::invokeMethod(iParent, "validChanged");
+}
+
+inline void NfcTag::Private::emitPresentChanged()
+{
+ QMetaObject::invokeMethod(iParent, "presentChanged");
+}
+
+inline void NfcTag::Private::emitTypeChanged()
+{
+ QMetaObject::invokeMethod(iParent, "typeChanged");
+}
+
+inline void NfcTag::Private::updateTypeAndEmitSignal()
+{
+ if (updateType()) {
+ emitTypeChanged();
+ }
+}
+
+void NfcTag::Private::validChanged(NfcTagClient* aTag,
+ NFC_TAG_PROPERTY, void* aPrivate)
+{
+ Private* self = (Private*)aPrivate;
+ if (aTag->valid) {
+ self->updateTypeAndEmitSignal();
+ self->emitValidChanged();
+ } else {
+ self->emitValidChanged();
+ self->updateTypeAndEmitSignal();
+ }
+}
+
+void NfcTag::Private::presentChanged(NfcTagClient*,
+ NFC_TAG_PROPERTY, void* aPrivate)
+{
+ Private* self = (Private*)aPrivate;
+ self->updateTypeAndEmitSignal();
+ self->emitPresentChanged();
+}
+
+void NfcTag::Private::interfacesChanged(NfcTagClient*,
+ NFC_TAG_PROPERTY, void* aPrivate)
+{
+ ((Private*)aPrivate)->updateTypeAndEmitSignal();
+}
+
+// ==========================================================================
+// NfcTag
+// ==========================================================================
+
+NfcTag::NfcTag(QObject* aParent) :
+ QObject(aParent),
+ iPrivate(new Private(this))
+{
+}
+
+NfcTag::~NfcTag()
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/libqnfcdc/version.pri
^
|
@@ -0,0 +1 @@
+VERSION = 1.0.0
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/qml/NfcSharePage.qml
^
|
@@ -0,0 +1,139 @@
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+import harbour.foilnotes 1.0
+
+import "harbour"
+
+Dialog {
+ id: thisPage
+
+ acceptDestinationAction: PageStackAction.Pop
+ forwardNavigation: false
+
+ property color noteColor
+ property string noteText
+
+ Component.onCompleted: {
+ shareClient.sharePlaintext(noteColor, noteText)
+ }
+
+ NfcMode {
+ enableModes: NfcSystem.P2PTarget + NfcSystem.P2PInitiator
+ disableModes: NfcSystem.ReaderWriter
+ active: Qt.application.active && thisPage.status === PageStatus.Active
+ }
+
+ NfcPeer {
+ id: peer
+ path: NfcAdapter.peerPath
+ }
+
+ FoilNotesNfcShareClient {
+ id: shareClient
+ onDone: {
+ backNavigation = false
+ forwardNavigation = true
+ accept()
+ }
+ }
+
+ Item {
+ id: iconArea
+
+ anchors {
+ top: parent.top
+ bottom: parent.bottom
+ bottomMargin: isLandscape ? 0 : Math.round(2 * thisPage.height / 3)
+ left: parent.left
+ right: parent.right
+ rightMargin: isLandscape ? Math.round(2 * thisPage.width / 3) : 0
+ }
+
+ HarbourHighlightIcon {
+ anchors.centerIn: parent
+ sourceSize.height: Theme.itemSizeHuge
+ highlightColor: !NfcSystem.enabled ? Theme.secondaryColor :
+ peer.present ? Theme.highlightColor :
+ Theme.primaryColor
+ scale: peer.present ? 1.2 : 1
+ source: "images/nfc.svg"
+
+ Behavior on scale {
+ SpringAnimation {
+ spring: 5
+ mass: 0.5
+ damping: 0.1
+ duration: 200
+ }
+ }
+ }
+ }
+
+ Item {
+ id: contentArea
+
+ anchors {
+ bottom: parent.bottom
+ right: parent.right
+ }
+
+ InfoLabel {
+ id: infoLabel
+
+ // Something like ViewPlaceholder but without a pulley hint
+ visible: opacity > 0
+ verticalAlignment: Text.AlignVCenter
+ anchors {
+ top: parent.top
+ bottom: parent.bottom
+ }
+ // NOTE: if NFC is completely unavailable we should
+ // never get here in the first place
+ text:(!NfcSystem.enabled || !NfcSystem.present) ?
+ //: Full screen info label
+ //% "NFC is off"
+ qsTrId("foilnotes-nfc_share-info-nfc_off") :
+ shareClient.state === FoilNotesNfcShareClient.Idle ?
+ //: Full screen info label
+ //% "Touch another NFC capable device with Foil Notes running full screen."
+ qsTrId("foilnotes-nfc_share-info-ready") :
+ ""
+ Behavior on opacity { FadeAnimation { duration: 150 } }
+ }
+
+ BusyIndicator {
+ anchors.centerIn: parent
+ size: BusyIndicatorSize.Large
+ running: infoLabel.text === ""
+ }
+ }
+
+ states: [
+ State {
+ name: "portrait"
+ when: !isLandscape
+ changes: [
+ AnchorChanges {
+ target: contentArea
+ anchors {
+ left: thisPage.left
+ top: iconArea.bottom
+ }
+ }
+ ]
+ },
+ State {
+ name: "landscape"
+ when: isLandscape
+ changes: [
+ AnchorChanges {
+ target: contentArea
+ anchors {
+ left: iconArea.right
+ top: thisPage.top
+ }
+ }
+ ]
+ }
+ ]
+}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/qml/NotePage.qml
^
|
@@ -112,6 +112,23 @@
onClicked: page.performAction()
}
MenuItem {
+ id: nfcShareMenuItem
+
+ //: Share current note via NFC
+ //% "Share via NFC"
+ text: qsTrId("foilnotes-menu-nfc_share")
+ visible: NfcSystem.present && NfcSystem.enabled
+ onClicked: {
+ pageStack.push(Qt.resolvedUrl("NfcSharePage.qml"), {
+ allowedOrientations: page.allowedOrientations,
+ noteColor: page.color,
+ noteText: page.body
+ })
+ }
+ }
+ MenuItem {
+ id: qrCodeMenuItem
+
//: Show QR code for the current note
//% "Show QR code"
text: qsTrId("foilnotes-menu-show_qrcode")
@@ -126,6 +143,8 @@
//% "Select color"
text: qsTrId("foilnotes-menu-select_color")
onClicked: page.pickColor()
+ // Don't show more than 4 menu items in landscape
+ visible: isPortrait || !actionMenuItem.visible || !nfcShareMenuItem.visible || !qrCodeMenuItem.visible
}
MenuItem {
//: Delete this note from note page
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/qml/NotesGridView.qml
^
|
@@ -30,6 +30,26 @@
contextMenuItem.modelIndex - (contextMenuItem.modelIndex % columnCount) + columnCount : 0
readonly property int expandHeight: contextMenu ? contextMenu.height : 0
+ function openNote(index,pagenr,color,body,transition) {
+ model.textIndex = index
+ currentIndex = index
+ var notePage = pageStack.push(notePageComponent, {
+ pagenr: pagenr,
+ color: color,
+ body: body,
+ secret: secret,
+ allowedOrientations: allowedOrientations,
+ actionMenuText: noteActionMenuText
+ }, transition)
+ notePage.colorChanged.connect(function() { model.setColorAt(index,notePage.color) })
+ notePage.saveBody.connect(function(body) { model.setBodyAt(index,body) })
+ notePage.deleteNote.connect(function() {
+ currentItem.deleteNote()
+ pageStack.pop()
+ })
+ notePage.performAction.connect(function() { grid.performNoteAction(currentItem) })
+ }
+
function newNote(model,transition) {
var noteCreated = false
var notePage = pageStack.push(notePageComponent, {
@@ -165,24 +185,7 @@
onClicked: {
if (!model.busy) {
- // Make sure delegate doesn't get destroyed
- grid.model.textIndex = modelIndex
- grid.currentIndex = modelIndex
- var notePage = pageStack.push(notePageComponent, {
- pagenr: model.pagenr,
- color: model.color,
- body: modelText,
- secret: grid.secret,
- allowedOrientations: page.allowedOrientations,
- actionMenuText: noteActionMenuText
- })
- notePage.colorChanged.connect(function() { model.color = notePage.color })
- notePage.saveBody.connect(function(body) { model.body = body })
- notePage.deleteNote.connect(function() {
- noteDelegate.deleteNote()
- pageStack.pop()
- })
- notePage.performAction.connect(function() { grid.performNoteAction(noteDelegate) })
+ openNote(modelIndex, model.pagenr, model.color, modelText, PageStackAction.Animated)
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/qml/PlaintextPage.qml
^
|
@@ -21,6 +21,10 @@
readonly property bool isCurrentPage: status === PageStatus.Active || status === PageStatus.Activating ||
pageStack.find(function (pageOnStack) { return (thisPage === pageOnStack) })
+ function openNote(index, pagenr, color, body, transition) {
+ grid.openNote(index, pagenr, color, body, transition)
+ }
+
function encryptNoteAt(row) {
if (row >= 0 && foilModel.keyAvailable) {
grid.removeAnimationDuration = 500
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/qml/images/nfc.svg
^
|
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<svg
+ version="1.1"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ x="0px"
+ y="0px"
+ width="64"
+ height="64"
+ viewBox="0 0 64 64"
+ style="enable-background:new 0 0 64 64">
+ <g>
+ <rect
+ style="opacity:0;fill:#ffffff"
+ width="64"
+ height="64"/>
+ <g>
+ <g style="opacity:0.6;">
+ <path
+ style="fill:#ffffff"
+ d="M50.529,55H13.471C11.557,55,10,53.443,10,51.529V14.471C10,12.557,11.557,11,13.471,11h37.059 C52.443,11,54,12.557,54,14.471v37.059C54,53.443,52.443,55,50.529,55z M13.471,13C12.66,13,12,13.66,12,14.471v37.059 C12,52.34,12.66,53,13.471,53h37.059C51.34,53,52,52.34,52,51.529V14.471C52,13.66,51.34,13,50.529,13H13.471z"/>
+ </g>
+ <path
+ style="fill:#ffffff"
+ d="M43.05,48.646c-0.372,0-0.863-0.132-1.411-0.614L24.685,33.104 c-0.369-0.325-0.405-0.887-0.08-1.256c0.324-0.369,0.887-0.406,1.256-0.08l16.954,14.929c0.008,0.007,0.016,0.014,0.022,0.02 c0.001-0.01,0.001-0.02,0.001-0.03V19.603c0-0.492,0.398-0.89,0.89-0.89s0.89,0.398,0.89,0.89v27.083 c0,1.264-0.674,1.704-0.964,1.835C43.53,48.576,43.321,48.646,43.05,48.646z"/>
+ <path
+ style="fill:#ffffff"
+ d="M20.272,47.432c-0.492,0-0.89-0.398-0.89-0.89V19.458c0-1.263,0.674-1.704,0.964-1.835 c0.291-0.131,1.067-0.346,2.015,0.489L39.315,33.04c0.369,0.325,0.404,0.887,0.08,1.256c-0.326,0.369-0.889,0.402-1.256,0.08 L21.186,19.448c-0.008-0.007-0.016-0.014-0.023-0.02c0,0.01,0,0.02,0,0.03v27.083C21.162,47.033,20.764,47.432,20.272,47.432z"/>
+ </g>
+ </g>
+</svg>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/qml/main.qml
^
|
@@ -1,5 +1,6 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
+import org.nemomobile.notifications 1.0
import harbour.foilnotes 1.0
ApplicationWindow {
@@ -20,8 +21,28 @@
readonly property int appPortraitCellSize: Math.floor(_portraitWidth/appPortraitColumnCount)
readonly property int appLandscapeCellSize: Math.floor(_landscapeWidth/appLandscapeColumnCount)
+ //: Placeholder name for note filename
+ //% "note"
+ readonly property string appDefaultFileName: qsTrId("foilnotes-default_file_name")
+
signal newNoteFromCover()
+ function popAll() {
+ var firstPage = pageStack.currentPage
+ var prevPage = pageStack.previousPage(firstPage)
+ while (prevPage) {
+ firstPage = prevPage
+ prevPage = pageStack.previousPage(prevPage)
+ }
+ pageStack.pop(firstPage, PageStackAction.Immediate)
+ }
+
+ Binding {
+ target: FoilNotesNfcShareService
+ property: "active"
+ value: !jailed && NfcSystem.version >= NfcSystem.Version_1_1_0 && Qt.application.active
+ }
+
Timer {
id: lockTimer
@@ -60,10 +81,6 @@
}
}
- //: Placeholder name for note filename
- //% "note"
- readonly property string appDefaultFileName: qsTrId("foilnotes-default_file_name")
-
Component {
id: encryptedPageComponent
@@ -103,6 +120,7 @@
hints: FoilNotesHints
foilModel: FoilNotesModel
plaintextModel: FoilNotesPlaintextModel
+
onIsCurrentPageChanged: {
encryptedPageSelected = !isCurrentPage
FoilNotesSettings.plaintextView = isCurrentPage
@@ -111,18 +129,37 @@
Connections {
target: appWindow
onNewNoteFromCover: {
- var firstPage = pageStack.currentPage
- var prevPage = pageStack.previousPage(firstPage)
- while (prevPage) {
- firstPage = prevPage
- prevPage = pageStack.previousPage(prevPage)
- }
- pageStack.pop(firstPage, PageStackAction.Immediate)
+ popAll()
pageStack.navigateForward(PageStackAction.Immediate)
plaintextPage.newNoteFromCover()
activate()
}
}
+
+ Notification {
+ id: nfcNoteNotification
+
+ expireTimeout: 2000
+ //: Pop-up notification
+ //% "Note received via NFC"
+ previewBody: qsTrId("foilnotes-notification-nfc_note_received")
+ Component.onCompleted: {
+ if ('icon' in nfcNoteNotification) {
+ nfcNoteNotification.icon = "icon-m-nfc"
+ }
+ }
+ }
+
+ Connections {
+ target: FoilNotesNfcShareService
+ onNewNote: {
+ popAll()
+ pageStack.navigateForward(PageStackAction.Immediate)
+ FoilNotesPlaintextModel.addNote(color, body)
+ plaintextPage.openNote(0, 1, color, body, PageStackAction.Immediate)
+ nfcNoteNotification.publish()
+ }
+ }
}
}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/src/FoilNotesNfcShare.cpp
^
|
@@ -0,0 +1,295 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ */
+
+#include "nfcdc_peer.h"
+#include "nfcdc_peer_service.h"
+
+#include "FoilNotesNfcShare.h"
+
+#include "HarbourDebug.h"
+
+#include <unistd.h>
+#include <sys/socket.h>
+
+#define FOILNOTES_NFCSHARE_SN "foilnotes:share"
+#define FOILNOTES_NFCSHARE_DBUSPATH "/foilnotes/share"
+
+// ==========================================================================
+// FoilNotesNfcShare::Private
+// ==========================================================================
+
+class FoilNotesNfcShare::Private {
+ enum client_events {
+ CLIENT_EVENT_PRESENT,
+ CLIENT_EVENT_COUNT
+ };
+
+ enum service_events {
+ SERVICE_EVENT_SAP_CHANGED,
+ SERVICE_EVENT_PEER_ARRIVED,
+ SERVICE_EVENT_PEER_LEFT,
+ SERVICE_EVENT_COUNT
+ };
+
+public:
+ Private(FoilNotesNfcShare* aShare);
+ ~Private();
+
+ void setAccept(bool aAccept);
+
+private:
+ void peerPresenceChanged();
+ void propertyChange(NFC_PEER_SERVICE_PROPERTY);
+ void connectionHandler(NfcServiceConnection*);
+ void peerArrived(const char*);
+ void peerLeft(const char*);
+ void clientConnected(int aFd);
+
+ static void propertyChangeCB(NfcPeerService*, NFC_PEER_SERVICE_PROPERTY, void*);
+ static void connectionHandlerCB(NfcPeerService*, NfcServiceConnection*, void*);
+ static void peerArrivedCB(NfcPeerService*, const char*, void*);
+ static void peerLeftCB(NfcPeerService*, const char*, void*);
+
+ static void clientPresentCB(NfcPeerClient*, NFC_PEER_PROPERTY, void*);
+ static void clientConnectionCB(NfcPeerClient*, int fd, const GError* error, void* user_data);
+
+public:
+ FoilNotesNfcShare* iShare;
+ NfcPeerService* iService;
+ NfcServiceConnection* iServiceConnection;
+ gulong iServiceEventIds[SERVICE_EVENT_COUNT];
+ NfcPeerClient* iClient;
+ gulong iClientEventIds[CLIENT_EVENT_COUNT];
+ int iFd;
+};
+
+FoilNotesNfcShare::Private::Private(FoilNotesNfcShare* aShare) :
+ iShare(aShare),
+ iService(Q_NULLPTR),
+ iServiceConnection(Q_NULLPTR),
+ iClient(Q_NULLPTR),
+ iFd(-1)
+{
+ memset(iServiceEventIds, 0, sizeof(iServiceEventIds));
+ memset(iClientEventIds, 0, sizeof(iClientEventIds));
+}
+
+FoilNotesNfcShare::Private::~Private()
+{
+ nfc_service_connection_unref(iServiceConnection);
+ nfc_peer_service_remove_all_handlers(iService, iServiceEventIds);
+ nfc_peer_service_unref(iService);
+ nfc_peer_client_remove_all_handlers(iClient, iClientEventIds);
+ nfc_peer_client_unref(iClient);
+ if (iFd >= 0) {
+ shutdown(iFd, SHUT_RDWR);
+ close(iFd);
+ }
+}
+
+void FoilNotesNfcShare::Private::setAccept(bool aAccept)
+{
+ if (aAccept) {
+ if (!iService) {
+ iService = nfc_peer_service_new(FOILNOTES_NFCSHARE_DBUSPATH,
+ FOILNOTES_NFCSHARE_SN, connectionHandlerCB, this);
+ iServiceEventIds[SERVICE_EVENT_SAP_CHANGED] =
+ nfc_peer_service_add_property_handler(iService,
+ NFC_PEER_SERVICE_PROPERTY_SAP, propertyChangeCB, this);
+ iServiceEventIds[SERVICE_EVENT_PEER_ARRIVED] =
+ nfc_peer_service_add_peer_arrived_handler(iService,
+ peerArrivedCB, this);
+ iServiceEventIds[SERVICE_EVENT_PEER_LEFT] =
+ nfc_peer_service_add_peer_left_handler(iService,
+ peerLeftCB, this);
+ Q_EMIT iShare->acceptChanged();
+ }
+ } else if (iService) {
+ nfc_peer_service_remove_all_handlers(iService, iServiceEventIds);
+ nfc_peer_service_unref(iService);
+ iService = Q_NULLPTR;
+ if (iServiceConnection) {
+ nfc_service_connection_unref(iServiceConnection);
+ iServiceConnection = Q_NULLPTR;
+ Q_EMIT iShare->receivingChanged();
+ }
+ Q_EMIT iShare->acceptChanged();
+ }
+}
+
+#define FOILNOTES_NFCSHARE_SERVICE_CALLBACK_IMPL(name,type) \
+void FoilNotesNfcShare::Private::name##CB(NfcPeerService* aService, type aArg, void* aThis) \
+{ ((Private*)aThis)->name(aArg); }
+
+FOILNOTES_NFCSHARE_SERVICE_CALLBACK_IMPL(propertyChange, NFC_PEER_SERVICE_PROPERTY)
+FOILNOTES_NFCSHARE_SERVICE_CALLBACK_IMPL(connectionHandler, NfcServiceConnection*)
+FOILNOTES_NFCSHARE_SERVICE_CALLBACK_IMPL(peerArrived, const char*)
+FOILNOTES_NFCSHARE_SERVICE_CALLBACK_IMPL(peerLeft,const char*)
+
+void FoilNotesNfcShare::Private::propertyChange(NFC_PEER_SERVICE_PROPERTY aProperty)
+{
+ HDEBUG("NFC service SAP" << iService->sap);
+ Q_EMIT iShare->registeredChanged();
+}
+
+void FoilNotesNfcShare::Private::connectionHandler(NfcServiceConnection* aConnection)
+{
+ HDEBUG("Accepting connection from" << aConnection->rsap);
+ const bool hadConnection = (iServiceConnection != Q_NULLPTR);
+ nfc_service_connection_unref(iServiceConnection);
+ iServiceConnection = nfc_service_connection_accept(aConnection);
+ if (!hadConnection) {
+ Q_EMIT iShare->receivingChanged();
+ }
+}
+
+void FoilNotesNfcShare::Private::peerArrived(const char* aPath)
+{
+ HDEBUG("Peer" << aPath << "arrived");
+ nfc_peer_client_remove_all_handlers(iClient, iClientEventIds);
+ nfc_peer_client_unref(iClient);
+ iClient = nfc_peer_client_new(aPath);
+ if (iClient->present) {
+ HDEBUG("Connecting to" << FOILNOTES_NFCSHARE_SN);
+ nfc_peer_client_connect_sn(iClient, FOILNOTES_NFCSHARE_SN, NULL,
+ clientConnectionCB, this, NULL);
+ } else {
+ // Wait for the client to initialize
+ HDEBUG("Waiting for peer for initialize");
+ iClientEventIds[CLIENT_EVENT_PRESENT] =
+ nfc_peer_client_add_property_handler(iClient,
+ NFC_PEER_PROPERTY_PRESENT, clientPresentCB, this);
+ }
+}
+
+void FoilNotesNfcShare::Private::peerLeft(const char* aPath)
+{
+ HDEBUG("Peer" << aPath << "left");
+ if (iFd >= 0) {
+ shutdown(iFd, SHUT_RDWR);
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/src/FoilNotesNfcShare.h
^
|
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ */
+
+#ifndef FOILNOTES_NFCSHARE_H
+#define FOILNOTES_NFCSHARE_H
+
+#define FOILNOTES_NFCSHARE_SN "foilnotes:share"
+
+#endif // FOILNOTES_NFCSHARE_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/src/FoilNotesNfcShareClient.cpp
^
|
@@ -0,0 +1,344 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ */
+
+#include "nfcdc_peer.h"
+#include "nfcdc_default_adapter.h"
+
+#include "FoilNotesNfcShare.h"
+#include "FoilNotesNfcShareClient.h"
+#include "FoilNotesNfcShareProtocol.h"
+
+#include "HarbourDebug.h"
+
+#include <unistd.h>
+#include <sys/socket.h>
+
+class FoilNotesNfcShareClient::Private {
+ class Note {
+ public:
+ Note(QColor aColor, QString aText) :
+ iColor(aColor), iText(aText) {}
+
+ QColor iColor;
+ QString iText;
+ };
+
+ enum {
+ ADAPTER_EVENT_PEERS,
+ ADAPTER_EVENT_COUNT
+ };
+
+ enum {
+ CLIENT_EVENT_PRESENT,
+ CLIENT_EVENT_COUNT
+ };
+
+public:
+ class Protocol;
+
+ Private(FoilNotesNfcShareClient* aShare);
+ ~Private();
+
+ void sendPlaintextNote(const QColor& aColor, const QString& aText);
+
+private:
+ void adapterPeersChanged();
+ void peerPresenceChanged();
+ void cancelConnection();
+ void connectionFailed();
+ void connected(int);
+ void connect();
+
+ static void adapterPeersCB(NfcDefaultAdapter*, NFC_DEFAULT_ADAPTER_PROPERTY, void*);
+ static void clientPresentCB(NfcPeerClient*, NFC_PEER_PROPERTY, void*);
+ static void clientConnectionCB(NfcPeerClient*, int, const GError*, void*);
+
+public:
+ FoilNotesNfcShareClient* iParent;
+ Note* iNote;
+ Protocol* iConnection;
+ NfcDefaultAdapter* iAdapter;
+ NfcPeerClient* iClient;
+ GCancellable* iConnecting;
+ gulong iAdapterEventIds[ADAPTER_EVENT_COUNT];
+ gulong iClientEventIds[CLIENT_EVENT_COUNT];
+ bool iError;
+};
+
+// ==========================================================================
+// FoilNotesNfcShareClient::Private::Protocol
+// ==========================================================================
+
+class FoilNotesNfcShareClient::Private::Protocol: public FoilNotesNfcShareProtocol {
+public:
+ Protocol(int aFd, FoilNotesNfcShareClient::Private* aPrivate);
+
+ void sendNote(const Note*);
+
+ void handleHelloEvent(ProtocolVersion, const AppVersion*) Q_DECL_OVERRIDE;
+ void handleRequestSendProgress(uint, uint, uint) Q_DECL_OVERRIDE;
+ void handleResponse(uint, const uchar*, uint) Q_DECL_OVERRIDE;
+ void handleError() Q_DECL_OVERRIDE;
+
+public:
+ FoilNotesNfcShareClient::Private* iPrivate;
+ uint iSendReqId;
+ uint iAckReqId;
+};
+
+FoilNotesNfcShareClient::Private::Protocol::Protocol(int aFd,
+ FoilNotesNfcShareClient::Private* aPrivate) :
+ FoilNotesNfcShareProtocol(aFd),
+ iPrivate(aPrivate),
+ iSendReqId(0),
+ iAckReqId(0)
+{
+}
+
+void FoilNotesNfcShareClient::Private::Protocol::sendNote(const Note* aNote)
+{
+ if (aNote) {
+ iSendReqId = sendPlaintextRequest(aNote->iColor, aNote->iText);
+ }
+}
+
+void FoilNotesNfcShareClient::Private::Protocol::handleHelloEvent(ProtocolVersion aProtocol,
+ const AppVersion* aApp)
+{
+ HDEBUG("Protocol" << aProtocol << "app" << aApp->v1 << aApp->v2 << aApp->v3);
+ sendNote(iPrivate->iNote);
+ Q_EMIT iPrivate->iParent->stateChanged();
+}
+
+void FoilNotesNfcShareClient::Private::Protocol::handleRequestSendProgress(uint aId,
+ uint aBytesSent, uint aBytesTotal)
+{
+ HDEBUG(aBytesSent << "bytes sent out of" << aBytesTotal);
+}
+
+void FoilNotesNfcShareClient::Private::Protocol::handleResponse(uint aReqId, const uchar*, uint)
+{
+ HDEBUG(aReqId << "ack'ed");
+ iAckReqId = aReqId;
+ if (iAckReqId == iSendReqId) {
+ // Note has been sent successfully
+ delete iPrivate->iNote;
+ iPrivate->iNote = Q_NULLPTR;
+ Q_EMIT iPrivate->iParent->stateChanged();
+ Q_EMIT iPrivate->iParent->done();
+ }
+}
+
+void FoilNotesNfcShareClient::Private::Protocol::handleError()
+{
+ if (!iPrivate->iError) {
+ iPrivate->iError = true;
+ Q_EMIT iPrivate->iParent->stateChanged();
+ }
+}
+
+// ==========================================================================
+// FoilNotesNfcShareClient::Private
+// ==========================================================================
+
+FoilNotesNfcShareClient::Private::Private(FoilNotesNfcShareClient* aParent) :
+ iParent(aParent),
+ iNote(Q_NULLPTR),
+ iConnection(Q_NULLPTR),
+ iAdapter(nfc_default_adapter_new()),
+ iClient(Q_NULLPTR),
+ iConnecting(Q_NULLPTR),
+ iError(false)
+{
+ memset(iAdapterEventIds, 0, sizeof(iAdapterEventIds));
+ memset(iClientEventIds, 0, sizeof(iClientEventIds));
+ iAdapterEventIds[ADAPTER_EVENT_PEERS] =
+ nfc_default_adapter_add_property_handler(iAdapter,
+ NFC_DEFAULT_ADAPTER_PROPERTY_PEERS, adapterPeersCB, this);
+}
+
+FoilNotesNfcShareClient::Private::~Private()
+{
+ cancelConnection();
+ nfc_default_adapter_remove_all_handlers(iAdapter, iAdapterEventIds);
+ nfc_default_adapter_unref(iAdapter);
+ nfc_peer_client_remove_all_handlers(iClient, iClientEventIds);
+ nfc_peer_client_unref(iClient);
+ delete iConnection;
+ delete iNote;
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/src/FoilNotesNfcShareClient.h
^
|
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ */
+
+#ifndef FOILNOTES_NFCSHARE_CLIENT_H
+#define FOILNOTES_NFCSHARE_CLIENT_H
+
+#include "foil_types.h"
+
+#include <QObject>
+#include <QColor>
+#include <QString>
+
+class QQmlEngine;
+class QJSEngine;
+
+class FoilNotesNfcShareClient : public QObject {
+ Q_OBJECT
+ Q_DISABLE_COPY(FoilNotesNfcShareClient)
+ Q_PROPERTY(int state READ state NOTIFY stateChanged)
+ Q_ENUMS(State)
+
+public:
+ enum State {
+ Idle,
+ Connecting,
+ Connected,
+ Sending,
+ Sent,
+ Error
+ };
+
+ FoilNotesNfcShareClient(QObject* aParent = Q_NULLPTR);
+ ~FoilNotesNfcShareClient();
+
+ State state() const;
+
+ Q_INVOKABLE void sharePlaintext(QColor aColor, QString aText);
+
+Q_SIGNALS:
+ void stateChanged();
+ void done();
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // FOILNOTES_NFCSHARE_CLIENT_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/src/FoilNotesNfcShareProtocol.cpp
^
|
@@ -0,0 +1,547 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ */
+
+#include "FoilNotesNfcShare.h"
+#include "FoilNotesNfcShareProtocol.h"
+
+#include <QSocketNotifier>
+
+#include "HarbourDebug.h"
+
+#include <errno.h>
+#include <unistd.h>
+#include <sys/socket.h>
+
+// ==========================================================================
+// FoilNotesNfcShareProtocol::Private
+// ==========================================================================
+
+class FoilNotesNfcShareProtocol::Private : public QObject {
+ Q_OBJECT
+
+ static const char HELLO_MAGIC[];
+
+ enum {
+ HeaderSize = 4,
+ EventHeaderSize = 5,
+ RequestHeaderSize = 8,
+ ResponseHeaderSize = 7,
+ HelloEventPayloadSize = 20
+ };
+
+public:
+ class Packet {
+ public:
+ QByteArray iHeader;
+ QByteArray iData;
+ Packet* iNext;
+ public:
+ Packet() : iNext(Q_NULLPTR) {}
+ ~Packet() { delete iNext; }
+
+ OpCode opCode() const { return (OpCode)iHeader.constData()[0]; }
+ bool isRequest() const { return opCode() == OpCodeRequest; }
+ uint requestId() const { return be3((uchar*)iHeader.constData() + 4); }
+ };
+
+ Private(int, FoilNotesNfcShareProtocol*);
+ ~Private();
+
+ static uint be3(const uchar*);
+
+ static Packet* newRequest(uint, RequestCode, const QByteArray&);
+ static Packet* newResponse(uint, const QByteArray&);
+ static Packet* newEvent(EventCode, const QByteArray&);
+ static Packet* newHelloEvent();
+ void submitPacket(Packet*);
+
+ bool tryToRead(size_t);
+ void handleEvent(uchar, const uchar*, uint);
+ void error();
+
+public Q_SLOTS:
+ void canRead();
+ void tryToWrite();
+
+public:
+ FoilNotesNfcShareProtocol* iProtocol;
+ int iFd;
+ bool iStarted;
+ uint iLastId;
+ QSocketNotifier* iReadNotifier;
+ QSocketNotifier* iWriteNotifier;
+ QByteArray iReadBuf;
+ Packet* iWriteQueue;
+ Packet* iWriteQueueTail;
+ Packet* iWritePacket;
+ int iWritePacketOffset;
+};
+
+const char FoilNotesNfcShareProtocol::Private::HELLO_MAGIC[] = "foilnotes:share";
+
+FoilNotesNfcShareProtocol::Private::Private(int aFd, FoilNotesNfcShareProtocol* aProtocol) :
+ iProtocol(aProtocol),
+ iFd(dup(aFd)),
+ iStarted(false),
+ iLastId(0),
+ iReadNotifier(new QSocketNotifier(iFd, QSocketNotifier::Read, this)),
+ iWriteNotifier(new QSocketNotifier(iFd, QSocketNotifier::Write, this)),
+ iWriteQueue(Q_NULLPTR),
+ iWriteQueueTail(Q_NULLPTR),
+ iWritePacket(Q_NULLPTR),
+ iWritePacketOffset(0)
+{
+ connect(iReadNotifier, SIGNAL(activated(int)), SLOT(canRead()));
+ connect(iWriteNotifier, SIGNAL(activated(int)), SLOT(tryToWrite()));
+ submitPacket(newHelloEvent());
+ tryToWrite();
+}
+
+FoilNotesNfcShareProtocol::Private::~Private()
+{
+ delete iReadNotifier;
+ delete iWriteNotifier;
+ delete iWritePacket;
+ delete iWriteQueue;
+ if (iFd >= 0) {
+ shutdown(iFd, SHUT_RDWR);
+ close(iFd);
+ }
+}
+
+inline uint FoilNotesNfcShareProtocol::Private::be3(const uchar* aBuffer)
+{
+ // Big engian 3-byte unsigned int
+ return ((uint)aBuffer[0] << 16) + ((uint)aBuffer[1] << 8) + aBuffer[2];
+}
+
+void FoilNotesNfcShareProtocol::Private::error()
+{
+ iReadNotifier->setEnabled(false);
+ iWriteNotifier->setEnabled(false);
+ iProtocol->handleError();
+}
+
+void FoilNotesNfcShareProtocol::Private::submitPacket(Packet* aPacket)
+{
+ // Takes ownership of the packet
+ if (!iWritePacket) {
+ // Nothing is being written
+ iWritePacket = aPacket;
+ iWritePacketOffset = 0;
+ // Disabled iReadNotifier means an error
+ if (iStarted && iReadNotifier->isEnabled()) {
+ iWriteNotifier->setEnabled(true);
+ tryToWrite();
+ }
+ } else if (iWriteQueueTail) {
+ // Append to the queue
+ iWriteQueueTail->iNext = aPacket;
+ } else {
+ // First packet to queue
+ iWriteQueue = iWriteQueueTail = aPacket;
+ }
+}
+
+void FoilNotesNfcShareProtocol::Private::tryToWrite()
+{
+ if (!iWritePacket) {
+ if (iWriteQueue) {
+ // Pick the next one from the queue
+ iWritePacket = iWriteQueue;
+ iWriteQueue = iWritePacket->iNext;
+ iWritePacket->iNext = Q_NULLPTR;
+ if (!iWriteQueue) iWriteQueueTail = Q_NULLPTR;
+ iWritePacketOffset = 0;
+ if (iWritePacket->isRequest()) {
+ iProtocol->handleRequestSendProgress(iWritePacket->requestId(),
+ 0, iWritePacket->iData.size());
+ }
+ } else {
+ // Nothing else to write, shut notifier off
+ iWriteNotifier->setEnabled(false);
+ }
+ }
+
+ if (iWritePacket) {
+ if (iWritePacketOffset < iWritePacket->iHeader.size()) {
+ const char* data = iWritePacket->iHeader.constData() + iWritePacketOffset;
+ ssize_t numBytes = iWritePacket->iHeader.size() - iWritePacketOffset;
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/src/FoilNotesNfcShareProtocol.h
^
|
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ */
+
+#ifndef FOILNOTES_NFCSHARE_PROTOCOL_H
+#define FOILNOTES_NFCSHARE_PROTOCOL_H
+
+#include "foil_types.h"
+
+#include <QColor>
+#include <QString>
+
+//
+// Wire format
+// ===========
+//
+// +--------+--------+--------+--------+
+// | OPCODE | N (Big endian) |
+// +--------+--------+--------+--------+
+// | Payload N bytes (optional)
+// +-------->
+//
+// OPCODE:
+// 0: Event
+// 1: Request
+// 2: Response
+//
+// Event
+// =====
+//
+// +--------+--------+--------+--------+
+// | 0 | N (>= 1) |
+// +--------+--------+--------+--------+
+// | CODE | Data N-1 bytes (optional)
+// +--------+-------->
+//
+// Event codes:
+// 0: HELLO
+//
+// Request
+// =======
+//
+// +--------+--------+--------+--------+
+// | 1 | N (>= 4) |
+// +--------+--------+--------+--------+
+// | ID | CODE |
+// +--------+--------+--------+--------+
+// | Data N-4 bytes (optional)
+// +-------->
+//
+// Event codes:
+// 0: SEND_PLAINTEXT
+//
+// Response
+// ========
+//
+// +--------+--------+--------+--------+
+// | 2 | N (>= 3) |
+// +--------+--------+--------+--------+
+// | ID | Data N-3 bytes (optional)
+// +--------+--------+--------+-------->
+//
+//
+
+class FoilNotesNfcShareProtocol {
+ Q_DISABLE_COPY(FoilNotesNfcShareProtocol)
+
+public:
+ struct AppVersion { uint v1, v2, v3; };
+
+ enum OpCode {
+ OpCodeEvent,
+ OpCodeRequest,
+ OpCodeResponse
+ };
+
+ enum EventCode {
+ EventHello
+ };
+
+ enum RequestCode {
+ RequestSendPlaintext
+ };
+
+ enum ProtocolVersion {
+ Version = 1
+ };
+
+ FoilNotesNfcShareProtocol(int aFd);
+ virtual ~FoilNotesNfcShareProtocol();
+
+ bool started() const;
+ uint sendRequest(RequestCode, const QByteArray&);
+ uint sendPlaintextRequest(const QColor& aColor, const QString& aText);
+ void sendResponse(uint, const QByteArray& aData = QByteArray());
+
+protected:
+ virtual void handleEvent(EventCode, const uchar*, uint);
+ virtual void handleHelloEvent(ProtocolVersion, const AppVersion*);
+ virtual void handleRequestSendProgress(uint, uint, uint);
+ virtual void handleIncomingRequest(RequestCode, uint, const uchar*, uint);
+ virtual void handleResponse(uint, const uchar*, uint);
+ virtual void handleError();
+
+private:
+ class Private;
+ friend class Private;
+ Private* iPrivate;
+};
+
+#endif // FOILNOTES_NFCSHARE_PROTOCOL_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/src/FoilNotesNfcShareService.cpp
^
|
@@ -0,0 +1,257 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ */
+
+#include "nfcdc_peer_service.h"
+
+#include "FoilNotesNfcShare.h"
+#include "FoilNotesNfcShareProtocol.h"
+#include "FoilNotesNfcShareService.h"
+
+#include "HarbourDebug.h"
+
+#define FOILNOTES_NFCSHARE_DBUSPATH "/foilnotes/share"
+
+class FoilNotesNfcShareService::Private {
+ class Protocol;
+ friend class Protocol;
+
+ enum {
+ SERVICE_EVENT_SAP_CHANGED,
+ SERVICE_EVENT_PEER_LEFT,
+ SERVICE_EVENT_COUNT
+ };
+
+public:
+ Private(FoilNotesNfcShareService* aShare);
+ ~Private();
+
+ void setActive(bool);
+
+private:
+ void peerPresenceChanged();
+ void propertyChange(NFC_PEER_SERVICE_PROPERTY);
+ void connectionHandler(NfcServiceConnection*);
+ void peerLeft(const char*);
+ void clientConnected(int);
+
+ static void propertyChangeCB(NfcPeerService*, NFC_PEER_SERVICE_PROPERTY, void*);
+ static void connectionHandlerCB(NfcPeerService*, NfcServiceConnection*, void*);
+ static void peerLeftCB(NfcPeerService*, const char*, void*);
+
+public:
+ FoilNotesNfcShareService* iParent;
+ Protocol* iConnection;
+ NfcPeerService* iService;
+ gulong iServiceEventIds[SERVICE_EVENT_COUNT];
+};
+
+// ==========================================================================
+// FoilNotesNfcShareService::Private::Protocol
+// ==========================================================================
+
+class FoilNotesNfcShareService::Private::Protocol: public FoilNotesNfcShareProtocol {
+public:
+ Protocol(NfcServiceConnection* aConnection, FoilNotesNfcShareService* aParent);
+ ~Protocol();
+
+ void handleHelloEvent(ProtocolVersion, const AppVersion*) Q_DECL_OVERRIDE;
+ void handleIncomingRequest(RequestCode, uint, const uchar*, uint) Q_DECL_OVERRIDE;
+
+public:
+ FoilNotesNfcShareService* iParent;
+ NfcServiceConnection* iConnection;
+};
+
+FoilNotesNfcShareService::Private::Protocol::Protocol(NfcServiceConnection* aConnection,
+ FoilNotesNfcShareService* aParent) :
+ FoilNotesNfcShareProtocol(aConnection->fd),
+ iParent(aParent),
+ iConnection(nfc_service_connection_accept(aConnection))
+{
+}
+
+FoilNotesNfcShareService::Private::Protocol::~Protocol()
+{
+ nfc_service_connection_unref(iConnection);
+}
+
+void FoilNotesNfcShareService::Private::Protocol::handleHelloEvent(ProtocolVersion aProtocol,
+ const AppVersion* aApp)
+{
+ HDEBUG("Protocol" << aProtocol << "app" << aApp->v1 << aApp->v2 << aApp->v3);
+ Q_EMIT iParent->connectedChanged();
+ FoilNotesNfcShareProtocol::handleHelloEvent(aProtocol, aApp);
+}
+
+void FoilNotesNfcShareService::Private::Protocol::handleIncomingRequest(RequestCode aCode,
+ uint aReqId, const uchar* aData, uint aLength)
+{
+ HDEBUG("Incoming request" << aCode << "id" << aReqId << "length" << aLength);
+ const char* sep = (char*) memchr(aData, 0, aLength);
+ if (sep) {
+ const QString colorString(QString::fromLatin1((char*)aData));
+ const QString text(QString::fromUtf8(sep + 1));
+ HDEBUG("Color" << colorString);
+ HDEBUG("Text" << text);
+ Q_EMIT iParent->newNote(QColor(colorString), text);
+ }
+ sendResponse(aReqId);
+}
+
+// ==========================================================================
+// FoilNotesNfcShareService::Private
+// ==========================================================================
+
+FoilNotesNfcShareService::Private::Private(FoilNotesNfcShareService* aParent) :
+ iParent(aParent),
+ iConnection(Q_NULLPTR),
+ iService(Q_NULLPTR)
+{
+ memset(iServiceEventIds, 0, sizeof(iServiceEventIds));
+}
+
+FoilNotesNfcShareService::Private::~Private()
+{
+ delete iConnection;
+ nfc_peer_service_remove_all_handlers(iService, iServiceEventIds);
+ nfc_peer_service_unref(iService);
+}
+
+void FoilNotesNfcShareService::Private::setActive(bool aActive)
+{
+ if (aActive) {
+ if (!iService) {
+ iService = nfc_peer_service_new(FOILNOTES_NFCSHARE_DBUSPATH,
+ FOILNOTES_NFCSHARE_SN, connectionHandlerCB, this);
+ iServiceEventIds[SERVICE_EVENT_SAP_CHANGED] =
+ nfc_peer_service_add_property_handler(iService,
+ NFC_PEER_SERVICE_PROPERTY_SAP, propertyChangeCB, this);
+ iServiceEventIds[SERVICE_EVENT_PEER_LEFT] =
+ nfc_peer_service_add_peer_left_handler(iService,
+ peerLeftCB, this);
+ Q_EMIT iParent->activeChanged();
+ }
+ } else if (iService) {
+ nfc_peer_service_remove_all_handlers(iService, iServiceEventIds);
+ nfc_peer_service_unref(iService);
+ iService = Q_NULLPTR;
+ if (iConnection) {
+ const bool wasStarted = iConnection->started();
+ delete iConnection;
+ iConnection = Q_NULLPTR;
+ if (wasStarted) {
+ Q_EMIT iParent->connectedChanged();
+ }
+ }
+ Q_EMIT iParent->activeChanged();
+ }
+}
+
+#define FOILNOTES_NFCSHARE_SERVICE_CALLBACK_IMPL(name,type) \
+void FoilNotesNfcShareService::Private::name##CB(NfcPeerService*, type aArg, void* aThis) \
+{ ((Private*)aThis)->name(aArg); }
+
+FOILNOTES_NFCSHARE_SERVICE_CALLBACK_IMPL(propertyChange, NFC_PEER_SERVICE_PROPERTY)
+FOILNOTES_NFCSHARE_SERVICE_CALLBACK_IMPL(connectionHandler, NfcServiceConnection*)
+FOILNOTES_NFCSHARE_SERVICE_CALLBACK_IMPL(peerLeft,const char*)
+
+void FoilNotesNfcShareService::Private::propertyChange(NFC_PEER_SERVICE_PROPERTY)
+{
+ HDEBUG("NFC service SAP" << iService->sap);
+ Q_EMIT iParent->registeredChanged();
+}
+
+void FoilNotesNfcShareService::Private::connectionHandler(NfcServiceConnection* aConnection)
+{
+ HDEBUG("Accepting connection from" << aConnection->rsap);
+ const bool wasStarted = (iConnection && iConnection->started());
+ delete iConnection;
+ iConnection = new Protocol(aConnection, iParent);
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/src/FoilNotesNfcShareService.h
^
|
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ */
+
+#ifndef FOILNOTES_NFCSHARE_SERVICE_H
+#define FOILNOTES_NFCSHARE_SERVICE_H
+
+#include "foil_types.h"
+
+#include <QObject>
+#include <QColor>
+#include <QString>
+
+class QQmlEngine;
+class QJSEngine;
+
+class FoilNotesNfcShareService : public QObject {
+ Q_OBJECT
+ Q_DISABLE_COPY(FoilNotesNfcShareService)
+ Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
+ Q_PROPERTY(bool registered READ registered NOTIFY registeredChanged)
+ Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
+
+public:
+ FoilNotesNfcShareService(QObject* aParent = Q_NULLPTR);
+ ~FoilNotesNfcShareService();
+
+ // Callback for qmlRegisterSingletonType<FoilNotesNfcShareService>
+ static QObject* createSingleton(QQmlEngine*, QJSEngine*);
+
+ bool active() const;
+ void setActive(bool);
+
+ bool registered() const;
+ bool connected() const;
+
+Q_SIGNALS:
+ void activeChanged();
+ void registeredChanged();
+ void connectedChanged();
+ void newNote(QColor color, QString body);
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // FOILNOTES_NFCSHARE_SERVICE_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/src/FoilNotesPlaintextModel.cpp
^
|
@@ -845,6 +845,7 @@
{
if (!aRows.isEmpty()) {
qSort(aRows);
+ HDEBUG(aRows);
bool selectionChanged = false;
int deleted = 0;
int lastRowToRemove = -1;
@@ -858,28 +859,28 @@
iPrivate->iSelected--;
selectionChanged = true;
}
- HDEBUG(data->pagenr());
- iPrivate->iModelData.removeAt(i);
+ HDEBUG("deleting" << data->pagenr());
+ iPrivate->iModelData.removeAt(pos);
deleted++;
if (lastRowToRemove < 0) {
- lastRowToRemove = firstRowToRemove = i;
- } else {
- HASSERT((firstRowToRemove - 1) == i);
+ lastRowToRemove = firstRowToRemove = pos;
+ } else if (pos == (firstRowToRemove - 1)) {
firstRowToRemove--;
+ } else {
+ HDEBUG("removed" << firstRowToRemove << ".." << lastRowToRemove);
+ beginRemoveRows(QModelIndex(), firstRowToRemove, lastRowToRemove);
+ firstRowToRemove = lastRowToRemove = pos;
+ endRemoveRows();
}
- } else if (firstRowToRemove >= 0) {
- HDEBUG(firstRowToRemove << lastRowToRemove);
- beginRemoveRows(QModelIndex(), firstRowToRemove, lastRowToRemove);
- firstRowToRemove = lastRowToRemove = -1;
- endRemoveRows();
}
}
if (firstRowToRemove >= 0) {
- HDEBUG(firstRowToRemove << lastRowToRemove);
+ HDEBUG("removed" << firstRowToRemove << ".." << lastRowToRemove);
beginRemoveRows(QModelIndex(), firstRowToRemove, lastRowToRemove);
endRemoveRows();
}
if (deleted > 0) {
+ iPrivate->updatePageNr(aRows.at(0));
if (selectionChanged) {
Q_EMIT selectedChanged();
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/src/main.cpp
^
|
@@ -34,11 +34,18 @@
#include "FoilNotesDefs.h"
#include "FoilNotesHints.h"
#include "FoilNotesModel.h"
+#include "FoilNotesNfcShareClient.h"
+#include "FoilNotesNfcShareService.h"
#include "FoilNotesPlaintextModel.h"
#include "FoilNotesSearchModel.h"
#include "FoilNotesSettings.h"
#include "FoilNotes.h"
+#include "NfcAdapter.h"
+#include "NfcMode.h"
+#include "NfcSystem.h"
+#include "NfcPeer.h"
+
#include "HarbourQrCodeGenerator.h"
#include "HarbourQrCodeImageProvider.h"
@@ -64,8 +71,16 @@
qmlRegisterSingletonType<FoilNotesSettings>(uri, v1, v2, "FoilNotesSettings", FoilNotesSettings::createSingleton);
qmlRegisterSingletonType<FoilNotes>(uri, v1, v2, "FoilNotes", FoilNotes::createSingleton);
qmlRegisterSingletonType<FoilNotesModel>(uri, v1, v2, "FoilNotesModel", FoilNotesModel::createSingleton);
+ qmlRegisterSingletonType<FoilNotesNfcShareService>(uri, v1, v2, "FoilNotesNfcShareService", FoilNotesNfcShareService::createSingleton);
qmlRegisterSingletonType<FoilNotesPlaintextModel>(uri, v1, v2, "FoilNotesPlaintextModel", FoilNotesPlaintextModel::createSingleton);
+ qmlRegisterType<FoilNotesNfcShareClient>(uri, v1, v2, "FoilNotesNfcShareClient");
qmlRegisterType<FoilNotesSearchModel>(uri, v1, v2, "FoilNotesSearchModel");
+
+ qmlRegisterSingletonType<NfcAdapter>(uri, v1, v2, "NfcAdapter", NfcAdapter::createSingleton);
+ qmlRegisterSingletonType<NfcSystem>(uri, v1, v2, "NfcSystem", NfcSystem::createSingleton);
+ qmlRegisterType<NfcMode>(uri, v1, v2, "NfcMode");
+ qmlRegisterType<NfcPeer>(uri, v1, v2, "NfcPeer");
+
qmlRegisterType<HarbourColorEditorModel>(uri, v1, v2, "HarbourColorEditorModel");
qmlRegisterType<HarbourOrganizeListModel>(uri, v1, v2, "HarbourOrganizeListModel");
qmlRegisterType<HarbourQrCodeGenerator>(uri, v1, v2, "HarbourQrCodeGenerator");
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/translations/harbour-foilnotes-de.ts
^
|
@@ -38,6 +38,11 @@
<extracomment>Create a new secret note ready for editing</extracomment>
<translation>Neue verschlüsselte Notiz</translation>
</message>
+ <message id="foilnotes-menu-nfc_share">
+ <source>Share via NFC</source>
+ <extracomment>Share current note via NFC</extracomment>
+ <translation type="unfinished">Über NFC teilen</translation>
+ </message>
<message id="foilnotes-menu-show_qrcode">
<source>Show QR code</source>
<extracomment>Show QR code for the current note</extracomment>
@@ -151,6 +156,11 @@
<extracomment>Pop-up notification</extracomment>
<translation>Password ändern</translation>
</message>
+ <message id="foilnotes-notification-nfc_note_received">
+ <source>Note received via NFC</source>
+ <extracomment>Pop-up notification</extracomment>
+ <translation type="unfinished">Notiz kam über NFC</translation>
+ </message>
<message id="foilnotes-enter_password_view-label-enter_password">
<source>Secret notes are locked. Please enter your password</source>
<extracomment>Password prompt label (long)</extracomment>
@@ -377,5 +387,15 @@
<extracomment>Text field description</extracomment>
<translation type="unfinished">Hex-Notation</translation>
</message>
+ <message id="foilnotes-nfc_share-info-nfc_off">
+ <source>NFC is off</source>
+ <extracomment>Full screen info label</extracomment>
+ <translation type="unfinished">NFC ist aus.</translation>
+ </message>
+ <message id="foilnotes-nfc_share-info-ready">
+ <source>Touch another NFC capable device with Foil Notes running full screen.</source>
+ <extracomment>Full screen info label</extracomment>
+ <translation type="unfinished">Berühren Sie ein anderes NFC-fähiges Gerät, während Foil Notes im Vollbildmodus ausgeführt wird.</translation>
+ </message>
</context>
</TS>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/translations/harbour-foilnotes-es.ts
^
|
@@ -38,6 +38,11 @@
<extracomment>Create a new secret note ready for editing</extracomment>
<translation>Nueva nota secreta</translation>
</message>
+ <message id="foilnotes-menu-nfc_share">
+ <source>Share via NFC</source>
+ <extracomment>Share current note via NFC</extracomment>
+ <translation type="unfinished">Compartir a través de NFC</translation>
+ </message>
<message id="foilnotes-menu-show_qrcode">
<source>Show QR code</source>
<extracomment>Show QR code for the current note</extracomment>
@@ -151,6 +156,11 @@
<extracomment>Pop-up notification</extracomment>
<translation>Contraseña cambiada</translation>
</message>
+ <message id="foilnotes-notification-nfc_note_received">
+ <source>Note received via NFC</source>
+ <extracomment>Pop-up notification</extracomment>
+ <translation type="unfinished">La nota llegó a través de NFC</translation>
+ </message>
<message id="foilnotes-enter_password_view-label-enter_password">
<source>Secret notes are locked. Please enter your password</source>
<extracomment>Password prompt label (long)</extracomment>
@@ -377,5 +387,15 @@
<extracomment>Text field description</extracomment>
<translation type="unfinished">Notación hexadecimal</translation>
</message>
+ <message id="foilnotes-nfc_share-info-nfc_off">
+ <source>NFC is off</source>
+ <extracomment>Full screen info label</extracomment>
+ <translation type="unfinished">NFC está apagado.</translation>
+ </message>
+ <message id="foilnotes-nfc_share-info-ready">
+ <source>Touch another NFC capable device with Foil Notes running full screen.</source>
+ <extracomment>Full screen info label</extracomment>
+ <translation type="unfinished">Toque otro dispositivo compatible con NFC con Foil Notes en pantalla completa.</translation>
+ </message>
</context>
</TS>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/translations/harbour-foilnotes-fr.ts
^
|
@@ -38,6 +38,11 @@
<extracomment>Create a new secret note ready for editing</extracomment>
<translation>Nouvelle note secrète</translation>
</message>
+ <message id="foilnotes-menu-nfc_share">
+ <source>Share via NFC</source>
+ <extracomment>Share current note via NFC</extracomment>
+ <translation type="unfinished">Partager via NFC</translation>
+ </message>
<message id="foilnotes-menu-show_qrcode">
<source>Show QR code</source>
<extracomment>Show QR code for the current note</extracomment>
@@ -151,6 +156,11 @@
<extracomment>Pop-up notification</extracomment>
<translation>Mot de passe modifié</translation>
</message>
+ <message id="foilnotes-notification-nfc_note_received">
+ <source>Note received via NFC</source>
+ <extracomment>Pop-up notification</extracomment>
+ <translation type="unfinished">La note est arrivée via NFC</translation>
+ </message>
<message id="foilnotes-enter_password_view-label-enter_password">
<source>Secret notes are locked. Please enter your password</source>
<extracomment>Password prompt label (long)</extracomment>
@@ -377,5 +387,15 @@
<extracomment>Text field description</extracomment>
<translation type="unfinished">Notation hexadécimale</translation>
</message>
+ <message id="foilnotes-nfc_share-info-nfc_off">
+ <source>NFC is off</source>
+ <extracomment>Full screen info label</extracomment>
+ <translation type="unfinished">NFC est désactivé.</translation>
+ </message>
+ <message id="foilnotes-nfc_share-info-ready">
+ <source>Touch another NFC capable device with Foil Notes running full screen.</source>
+ <extracomment>Full screen info label</extracomment>
+ <translation type="unfinished">Touchez un autre appareil compatible NFC avec Foil Notes en plein écran.</translation>
+ </message>
</context>
</TS>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/translations/harbour-foilnotes-pl.ts
^
|
@@ -11,22 +11,22 @@
<message id="foilnotes-search-placeholder">
<source>Sorry, couldn't find anything</source>
<extracomment>Placeholder text</extracomment>
- <translation>Przepraszamy, nic nie znaleziono</translation>
+ <translation>Przepraszamy, nic nie znaleziono.</translation>
</message>
<message id="foilnotes-plaintext_view-placeholder">
<source>You do not have any notes.</source>
<extracomment>Placeholder text</extracomment>
- <translation>Nie masz żadnych notatek</translation>
+ <translation>Nie masz żadnych notatek.</translation>
</message>
<message id="foilnotes-encrypted_view-placeholder">
<source>You do not have any encrypted notes</source>
<extracomment>Placeholder text</extracomment>
- <translation>Nie masz żadnych zaszyfrowanych notatek</translation>
+ <translation>Nie masz żadnych zaszyfrowanych notatek.</translation>
</message>
<message id="foilnotes-plaintext_view-placeholder_hint">
<source>Open pulley menu to add one.</source>
<extracomment>Placeholder hint</extracomment>
- <translation>Otwórz menu wysuwane aby dodać notatkę. </translation>
+ <translation>Otwórz menu wysuwane aby dodać notatkę.</translation>
</message>
<message id="foilnotes-menu-new_note">
<source>New note</source>
@@ -38,6 +38,11 @@
<extracomment>Create a new secret note ready for editing</extracomment>
<translation>Nowa sekretna notatka</translation>
</message>
+ <message id="foilnotes-menu-nfc_share">
+ <source>Share via NFC</source>
+ <extracomment>Share current note via NFC</extracomment>
+ <translation type="unfinished">Udostępnij przez NFC</translation>
+ </message>
<message id="foilnotes-menu-show_qrcode">
<source>Show QR code</source>
<extracomment>Show QR code for the current note</extracomment>
@@ -152,6 +157,11 @@
<extracomment>Pop-up notification</extracomment>
<translation>Hasło zmienione</translation>
</message>
+ <message id="foilnotes-notification-nfc_note_received">
+ <source>Note received via NFC</source>
+ <extracomment>Pop-up notification</extracomment>
+ <translation type="unfinished">Notatka przyszła przez NFC</translation>
+ </message>
<message id="foilnotes-enter_password_view-label-enter_password">
<source>Secret notes are locked. Please enter your password</source>
<extracomment>Password prompt label (long)</extracomment>
@@ -380,5 +390,15 @@
<extracomment>Text field description</extracomment>
<translation>Format szesnastkowy</translation>
</message>
+ <message id="foilnotes-nfc_share-info-nfc_off">
+ <source>NFC is off</source>
+ <extracomment>Full screen info label</extracomment>
+ <translation type="unfinished">NFC jest wyłączone.</translation>
+ </message>
+ <message id="foilnotes-nfc_share-info-ready">
+ <source>Touch another NFC capable device with Foil Notes running full screen.</source>
+ <extracomment>Full screen info label</extracomment>
+ <translation type="unfinished">Przyłóż czujnik NFC do innego urządzenia z Foil Notes otwartą na pełnym ekranie.</translation>
+ </message>
</context>
</TS>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/translations/harbour-foilnotes-ru.ts
^
|
@@ -11,7 +11,7 @@
<message id="foilnotes-search-placeholder">
<source>Sorry, couldn't find anything</source>
<extracomment>Placeholder text</extracomment>
- <translation>Извините, ничего не нашлось</translation>
+ <translation>Извините, ничего не нашлось.</translation>
</message>
<message id="foilnotes-plaintext_view-placeholder">
<source>You do not have any notes.</source>
@@ -21,22 +21,27 @@
<message id="foilnotes-plaintext_view-placeholder_hint">
<source>Open pulley menu to add one.</source>
<extracomment>Placeholder hint</extracomment>
- <translation>Используйте меню, чтобы создать новую запись.</translation>
+ <translation>Используйте меню, чтобы создать новую заметку.</translation>
</message>
<message id="foilnotes-encrypted_view-placeholder">
<source>You do not have any encrypted notes</source>
<extracomment>Placeholder text</extracomment>
- <translation>Ни одной записи не зашифровано</translation>
+ <translation>Ни одной заметки не зашифровано</translation>
</message>
<message id="foilnotes-menu-new_note">
<source>New note</source>
<extracomment>Create a new note ready for editing</extracomment>
- <translation>Добавить запись</translation>
+ <translation>Добавить заметку</translation>
</message>
<message id="foilnotes-menu-new_secret_note">
<source>New secret note</source>
<extracomment>Create a new secret note ready for editing</extracomment>
- <translation>Добавить секретную запись</translation>
+ <translation>Добавить секретную заметку</translation>
+ </message>
+ <message id="foilnotes-menu-nfc_share">
+ <source>Share via NFC</source>
+ <extracomment>Share current note via NFC</extracomment>
+ <translation>Поделиться через NFC</translation>
</message>
<message id="foilnotes-menu-show_qrcode">
<source>Show QR code</source>
@@ -51,7 +56,7 @@
<message id="foilnotes-menu-delete_note">
<source>Delete note</source>
<extracomment>Delete this note from note page</extracomment>
- <translation>Удалить запись</translation>
+ <translation>Удалить заметку</translation>
</message>
<message id="foilnotes-menu-encrypt">
<source>Encrypt</source>
@@ -81,7 +86,7 @@
<message id="foilnotes-remorse-deleting">
<source>Deleting</source>
<extracomment>Remorse item text, will delete note when timer expires</extracomment>
- <translation>Запись будет удалена</translation>
+ <translation>Заметка будет удалена</translation>
</message>
<message id="foilnotes-default_file_name">
<source>note</source>
@@ -101,7 +106,7 @@
<message id="foilnotes-menu-select">
<source>Select</source>
<extracomment>Pulley menu item</extracomment>
- <translation>Выбрать записи</translation>
+ <translation>Выбрать заметки</translation>
</message>
<message id="foilnotes-menu-select_all">
<source>Select all</source>
@@ -117,20 +122,20 @@
<source>Deleting %0 selected notes</source>
<extracomment>Generic remorse popup text</extracomment>
<translation>
- <numerusform>%0 запись будет удалена</numerusform>
- <numerusform>%0 записи будут удалены</numerusform>
- <numerusform>%0 записей будут удалены</numerusform>
+ <numerusform>%0 заметка будет удалена</numerusform>
+ <numerusform>%0 заметки будут удалены</numerusform>
+ <numerusform>%0 заметок будут удалены</numerusform>
</translation>
</message>
<message id="foilnotes-organize_page-plaintext_header">
<source>Organize notes</source>
<extracomment>Page header</extracomment>
- <translation>Упорядочить записи</translation>
+ <translation>Упорядочить заметки</translation>
</message>
<message id="foilnotes-organize_page-secret_header">
<source>Organize secret notes</source>
<extracomment>Page header</extracomment>
- <translation>Упорядочить секретные записи</translation>
+ <translation>Упорядочить секретные заметки</translation>
</message>
<message id="foilnotes-organize_page-description">
<source>Press and drag to reorder</source>
@@ -140,7 +145,7 @@
<message id="foilnotes-select_page-header">
<source>Select notes</source>
<extracomment>Page header</extracomment>
- <translation>Выберите записи</translation>
+ <translation>Выберите заметки</translation>
</message>
<message id="foilnotes-notification-generated_key">
<source>Generated new key</source>
@@ -152,6 +157,11 @@
<extracomment>Pop-up notification</extracomment>
<translation>Пароль сменён</translation>
</message>
+ <message id="foilnotes-notification-nfc_note_received">
+ <source>Note received via NFC</source>
+ <extracomment>Pop-up notification</extracomment>
+ <translation>Вам что-то пришло через NFC</translation>
+ </message>
<message id="foilnotes-enter_password_view-label-enter_password">
<source>Secret notes are locked. Please enter your password</source>
<extracomment>Password prompt label (long)</extracomment>
@@ -264,7 +274,7 @@
<message id="foilnotes-confirm_password_page-description">
<source>Make sure you don't forget your password. It's impossible to either recover it or to access the encrypted notes without knowing it. Better take it seriously.</source>
<extracomment>Password confirmation description</extracomment>
- <translation>Если вы забудете пароль, восстановить его будет невозможно и таким образом доступ к зашифрованным записям будет утерян. Так что лучше отнеситесь к этому серьёзно.</translation>
+ <translation>Если вы забудете пароль, восстановить его будет невозможно и таким образом доступ к зашифрованным заметкам будет утерян. Так что лучше отнеситесь к этому серьёзно.</translation>
</message>
<message id="foilnotes-confirm_password_page-text_field_placeholder-new_password">
<source>New password again</source>
@@ -290,9 +300,9 @@
<source>Decrypting %0 selected notes</source>
<extracomment>Generic remorse popup text</extracomment>
<translation>
- <numerusform>Расшифровка %0 записи</numerusform>
- <numerusform>Расшифровка %0 записей</numerusform>
- <numerusform>Расшифровка %0 записей</numerusform>
+ <numerusform>Расшифровка %0 заметки</numerusform>
+ <numerusform>Расшифровка %0 заметок</numerusform>
+ <numerusform>Расшифровка %0 заметок</numerusform>
</translation>
</message>
<message id="foilnotes-foil_apps_warning">
@@ -303,32 +313,32 @@
<message id="foilnotes-hint-delete_selected">
<source>Delete selected notes</source>
<extracomment>Hint text</extracomment>
- <translation>Удалить выбранные записи</translation>
+ <translation>Удалить выбранные заметки</translation>
</message>
<message id="foilnotes-hint-encrypt_selected">
<source>Encrypt selected notes</source>
<extracomment>Hint text</extracomment>
- <translation>Зашифровать выбранные записи</translation>
+ <translation>Зашифровать выбранные заметки</translation>
</message>
<message id="foilnotes-hint-decrypt_selected">
<source>Decrypt selected notes</source>
<extracomment>Hint text</extracomment>
- <translation>Расшифровать выбранные записи</translation>
+ <translation>Расшифровать выбранные заметки</translation>
</message>
<message id="foilnotes-hint-swipe_left_to_plaintext">
<source>Swipe left to access plaintext notes</source>
<extracomment>Left swipe hint text</extracomment>
- <translation>Там справа незашифрованные записи</translation>
+ <translation>Там справа незашифрованные заметки</translation>
</message>
<message id="foilnotes-hint-swipe_right_to_encrypted">
<source>Encrypted pictures are moved there to the left</source>
<extracomment>Right swipe hint text</extracomment>
- <translation>Зашифрованные записи попадают туда, налево</translation>
+ <translation>Зашифрованные заметки попадают туда, налево</translation>
</message>
<message id="foilnotes-hint-swipe_left_to_decrypted">
<source>Decrypted notes are moved back to the right</source>
<extracomment>Left swipe hint text</extracomment>
- <translation>Расшифрованные записи попадают обратно направо</translation>
+ <translation>Расшифрованные заметки попадают обратно направо</translation>
</message>
<message id="foilnotes-hint-undo">
<source>Undo</source>
@@ -380,5 +390,15 @@
<extracomment>Text field description</extracomment>
<translation>Текстовый формат</translation>
</message>
+ <message id="foilnotes-nfc_share-info-nfc_off">
+ <source>NFC is off</source>
+ <extracomment>Full screen info label</extracomment>
+ <translation>Извините, но кажется NFC выключен.</translation>
+ </message>
+ <message id="foilnotes-nfc_share-info-ready">
+ <source>Touch another NFC capable device with Foil Notes running full screen.</source>
+ <extracomment>Full screen info label</extracomment>
+ <translation>Прикоснитесь NFC сенсором к другому устройству, на котором приложение Foil Notes открыто на весь экран. Возможно, произойдёт чудо!</translation>
+ </message>
</context>
</TS>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/translations/harbour-foilnotes-sv.ts
^
|
@@ -38,6 +38,11 @@
<extracomment>Create a new secret note ready for editing</extracomment>
<translation>Ny krypterad anteckning</translation>
</message>
+ <message id="foilnotes-menu-nfc_share">
+ <source>Share via NFC</source>
+ <extracomment>Share current note via NFC</extracomment>
+ <translation type="unfinished">Dela via NFC</translation>
+ </message>
<message id="foilnotes-menu-show_qrcode">
<source>Show QR code</source>
<extracomment>Show QR code for the current note</extracomment>
@@ -151,6 +156,11 @@
<extracomment>Pop-up notification</extracomment>
<translation>Lösenord ändrat</translation>
</message>
+ <message id="foilnotes-notification-nfc_note_received">
+ <source>Note received via NFC</source>
+ <extracomment>Pop-up notification</extracomment>
+ <translation type="unfinished">Anteckning kom via NFC</translation>
+ </message>
<message id="foilnotes-enter_password_view-label-enter_password">
<source>Secret notes are locked. Please enter your password</source>
<extracomment>Password prompt label (long)</extracomment>
@@ -377,5 +387,15 @@
<extracomment>Text field description</extracomment>
<translation type="unfinished">Hex-format</translation>
</message>
+ <message id="foilnotes-nfc_share-info-nfc_off">
+ <source>NFC is off</source>
+ <extracomment>Full screen info label</extracomment>
+ <translation type="unfinished">NFC är avstängt.</translation>
+ </message>
+ <message id="foilnotes-nfc_share-info-ready">
+ <source>Touch another NFC capable device with Foil Notes running full screen.</source>
+ <extracomment>Full screen info label</extracomment>
+ <translation type="unfinished">Tryck på en annan NFC-kompatibel enhet med Foil Notes på helskärm.</translation>
+ </message>
</context>
</TS>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/translations/harbour-foilnotes-zh_CN.ts
^
|
@@ -38,6 +38,11 @@
<extracomment>Create a new secret note ready for editing</extracomment>
<translation>新秘密笔记</translation>
</message>
+ <message id="foilnotes-menu-nfc_share">
+ <source>Share via NFC</source>
+ <extracomment>Share current note via NFC</extracomment>
+ <translation type="unfinished">通过 NFC 分享</translation>
+ </message>
<message id="foilnotes-menu-show_qrcode">
<source>Show QR code</source>
<extracomment>Show QR code for the current note</extracomment>
@@ -150,6 +155,11 @@
<extracomment>Pop-up notification</extracomment>
<translation>密码已更改</translation>
</message>
+ <message id="foilnotes-notification-nfc_note_received">
+ <source>Note received via NFC</source>
+ <extracomment>Pop-up notification</extracomment>
+ <translation type="unfinished">笔记来自 NFC</translation>
+ </message>
<message id="foilnotes-enter_password_view-label-enter_password">
<source>Secret notes are locked. Please enter your password</source>
<extracomment>Password prompt label (long)</extracomment>
@@ -374,5 +384,15 @@
<extracomment>Text field description</extracomment>
<translation type="unfinished">十六进制表示法</translation>
</message>
+ <message id="foilnotes-nfc_share-info-nfc_off">
+ <source>NFC is off</source>
+ <extracomment>Full screen info label</extracomment>
+ <translation type="unfinished">NFC 关闭</translation>
+ </message>
+ <message id="foilnotes-nfc_share-info-ready">
+ <source>Touch another NFC capable device with Foil Notes running full screen.</source>
+ <extracomment>Full screen info label</extracomment>
+ <translation type="unfinished">在 Foil Notes 全屏运行时触摸另一个支持 NFC 的设备</translation>
+ </message>
</context>
</TS>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.28.tar.gz/translations/harbour-foilnotes.ts
^
|
@@ -38,6 +38,11 @@
<extracomment>Create a new secret note ready for editing</extracomment>
<translation>New secret note</translation>
</message>
+ <message id="foilnotes-menu-nfc_share">
+ <source>Share via NFC</source>
+ <extracomment>Share current note via NFC</extracomment>
+ <translation>Share via NFC</translation>
+ </message>
<message id="foilnotes-menu-show_qrcode">
<source>Show QR code</source>
<extracomment>Show QR code for the current note</extracomment>
@@ -151,6 +156,11 @@
<extracomment>Pop-up notification</extracomment>
<translation>Password changed</translation>
</message>
+ <message id="foilnotes-notification-nfc_note_received">
+ <source>Note received via NFC</source>
+ <extracomment>Pop-up notification</extracomment>
+ <translation>Note received via NFC</translation>
+ </message>
<message id="foilnotes-enter_password_view-label-enter_password">
<source>Secret notes are locked. Please enter your password</source>
<extracomment>Password prompt label (long)</extracomment>
@@ -377,5 +387,15 @@
<extracomment>Text field description</extracomment>
<translation>Hex notation</translation>
</message>
+ <message id="foilnotes-nfc_share-info-nfc_off">
+ <source>NFC is off</source>
+ <extracomment>Full screen info label</extracomment>
+ <translation>NFC is off.</translation>
+ </message>
+ <message id="foilnotes-nfc_share-info-ready">
+ <source>Touch another NFC capable device with Foil Notes running full screen.</source>
+ <extracomment>Full screen info label</extracomment>
+ <translation>Touch another NFC capable device with Foil Notes running full screen.</translation>
+ </message>
</context>
</TS>
|