diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2021-01-29 12:00:14 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2021-01-29 12:27:08 +0100 |
commit | 12f4e485351d018c980003cb166479d9f8061ccf (patch) | |
tree | 684bb39524804120117fc686e6a86c302c44ef76 | |
parent | eb4d5366ed6289d75b6bb22ea03a5ecf6bd2e32f (diff) | |
download | libqmi-12f4e485351d018c980003cb166479d9f8061ccf.tar.gz |
libqrtr-glib: remove from the libqmi repository
It's been moved to its own project repository:
https://gitlab.freedesktop.org/mobile-broadband/libqrtr
31 files changed, 46 insertions, 3303 deletions
@@ -27,9 +27,6 @@ Makefile.in /depcomp /data/pkg-config/qmi-glib.pc -/data/pkg-config/qrtr-glib.pc - -/src/libqrtr-glib/qrtr-version.h /src/libqmi-glib/libqmi-glib.la /src/libqmi-glib/qmi-version.h @@ -53,22 +50,6 @@ Makefile.in /build-aux/qmi-codegen/*.pyc -/docs/reference/libqrtr-glib/version.xml -/docs/reference/libqrtr-glib/libqrtr-glib.args -/docs/reference/libqrtr-glib/libqrtr-glib.hierarchy -/docs/reference/libqrtr-glib/libqrtr-glib.interfaces -/docs/reference/libqrtr-glib/libqrtr-glib.prerequisites -/docs/reference/libqrtr-glib/libqrtr-glib.signals -/docs/reference/libqrtr-glib/libqrtr-glib.actions -/docs/reference/libqrtr-glib/libqrtr-glib.types -/docs/reference/libqrtr-glib/*.mstamp -/docs/reference/libqrtr-glib/*.stamp -/docs/reference/libqrtr-glib/*.txt -/docs/reference/libqrtr-glib/*.bak -/docs/reference/libqrtr-glib/html -/docs/reference/libqrtr-glib/tmpl -/docs/reference/libqrtr-glib/xml - /docs/reference/libqmi-glib/version.xml /docs/reference/libqmi-glib/libqmi-glib.args /docs/reference/libqmi-glib/libqmi-glib.hierarchy diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index affe29c7..8f577dec 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,6 +27,13 @@ test-no-mbim-no-qrtr: test-no-mbim: stage: test script: + - git clone --depth 1 https://gitlab.freedesktop.org/mobile-broadband/libqrtr.git + - pushd libqrtr + - NOCONFIGURE=1 ./autogen.sh + - ./configure --prefix=/usr + - make + - make install + - popd - NOCONFIGURE=1 ./autogen.sh - ./configure --prefix=/usr --disable-mbim-qmux --enable-qrtr - make @@ -99,6 +106,13 @@ test-default: - make - make install - popd + - git clone --depth 1 https://gitlab.freedesktop.org/mobile-broadband/libqrtr.git + - pushd libqrtr + - NOCONFIGURE=1 ./autogen.sh + - ./configure --prefix=/usr + - make + - make install + - popd - NOCONFIGURE=1 ./autogen.sh - ./configure --prefix=/usr --enable-gtk-doc --enable-mbim-qmux --enable-qrtr --enable-introspection - make diff --git a/configure.ac b/configure.ac index 05da26fc..8da3cfd9 100644 --- a/configure.ac +++ b/configure.ac @@ -20,18 +20,6 @@ m4_define([qmi_glib_lt_current], [12]) m4_define([qmi_glib_lt_revision], [0]) m4_define([qmi_glib_lt_age], [7]) -dnl libtool versioning for libqrtr-glib (-version-info c:r:a) -dnl If the interface is unchanged, but the implementation has changed or -dnl been fixed, then increment r. -dnl Otherwise, increment c and zero r. -dnl If the interface has grown (that is, the new library is compatible -dnl with old code), increment a. -dnl If the interface has changed in an incompatible way (that is, -dnl functions have changed or been removed), then zero a. -m4_define([qrtr_glib_lt_current], [0]) -m4_define([qrtr_glib_lt_revision], [0]) -m4_define([qrtr_glib_lt_age], [0]) - AC_INIT([libqmi], [qmi_version], [libqmi-devel@lists.freedesktop.org]) AC_CONFIG_SRCDIR([config.h.in]) AC_CONFIG_HEADERS([config.h]) @@ -98,12 +86,6 @@ QMI_GLIB_LT_AGE=qmi_glib_lt_age AC_SUBST(QMI_GLIB_LT_CURRENT) AC_SUBST(QMI_GLIB_LT_REVISION) AC_SUBST(QMI_GLIB_LT_AGE) -QRTR_GLIB_LT_CURRENT=qrtr_glib_lt_current -QRTR_GLIB_LT_REVISION=qrtr_glib_lt_revision -QRTR_GLIB_LT_AGE=qrtr_glib_lt_age -AC_SUBST(QRTR_GLIB_LT_CURRENT) -AC_SUBST(QRTR_GLIB_LT_REVISION) -AC_SUBST(QRTR_GLIB_LT_AGE) dnl Required dependency versions GLIB_VERSION=2.48 @@ -242,13 +224,10 @@ AC_SUBST(QMI_MBIM_QMUX_SUPPORTED) AM_CONDITIONAL([QMI_MBIM_QMUX_SUPPORTED], [test "x$QMI_MBIM_QMUX_SUPPORTED" = "x1"]) # QRTR support -have_qrtr="yes" -AC_CHECK_HEADER(linux/qrtr.h, [], [have_qrtr=no], []) -AC_CHECK_HEADER(linux/if_link.h, [], [have_qrtr=no], []) -AC_CHECK_HEADER(linux/netlink.h, [], [have_qrtr=no], []) -AC_CHECK_HEADER(linux/rtnetlink.h, [], [have_qrtr=no], []) +QRTR_GLIB_VERSION=0.0.1 +PKG_CHECK_MODULES([QRTR], [qrtr-glib >= ${QRTR_GLIB_VERSION}], [have_qrtr=yes], [have_qrtr=no]) AC_ARG_ENABLE(qrtr, - AS_HELP_STRING([--enable-qrtr], [Enable support for QRTR protocol [default=no]]), + AS_HELP_STRING([--enable-qrtr], [Enable support for QMI over QRTR [default=auto]]), [enable_qrtr=$enableval], [enable_qrtr=auto]) @@ -258,9 +237,11 @@ fi if test "x$enable_qrtr" = "xyes"; then if test "x$have_qrtr" = "xno"; then - AC_MSG_ERROR([Couldn't find one of the follwing linux headers (qrtr.h, if_link.h, netlink.h, rtnetlink.h). Install them, or otherwise configure using --disable-qrtr to disable QRTR support.]) + AC_MSG_ERROR([Couldn't find `libqrtr-glib` >= ${QRTR_GLIB_VERSION}. Install it, or otherwise configure using --disable-qrtr to disable the QMI over QRTR support.]) fi - AC_DEFINE(QRTR_ENABLED, 1, [Define if QRTR support enabled]) + AC_DEFINE(QRTR_ENABLED, 1, [Define if QRTR QMUX support enabled]) + AC_SUBST(QRTR_CFLAGS) + AC_SUBST(QRTR_LIBS) QMI_QRTR_SUPPORTED=1 QRTR_PKGCONFIG_NAME="qrtr-glib" else @@ -288,13 +269,10 @@ AC_CONFIG_FILES([Makefile data/Makefile data/pkg-config/Makefile data/pkg-config/qmi-glib.pc - data/pkg-config/qrtr-glib.pc build-aux/Makefile build-aux/templates/Makefile build-aux/qmi-codegen/Makefile src/Makefile - src/libqrtr-glib/Makefile - src/libqrtr-glib/qrtr-version.h src/libqmi-glib/Makefile src/libqmi-glib/qmi-version.h src/libqmi-glib/generated/Makefile @@ -309,8 +287,6 @@ AC_CONFIG_FILES([Makefile examples/simple-tester-python/Makefile docs/Makefile docs/reference/Makefile - docs/reference/libqrtr-glib/Makefile - docs/reference/libqrtr-glib/version.xml docs/reference/libqmi-glib/Makefile docs/reference/libqmi-glib/version.xml docs/man/Makefile]) @@ -340,11 +316,11 @@ echo " udev base directory: ${UDEV_BASE_DIR} Features: - QMUX over MBIM: ${enable_mbim_qmux} + QMI over MBIM: ${enable_mbim_qmux} + QMI over QRTR: ${enable_qrtr} QMI username: ${QMI_USERNAME_ENABLED} (${QMI_USERNAME}) Built items: - libqrtr-glib: ${enable_qrtr} libqmi-glib: yes (${QMI_COLLECTION_NAME}) qmicli: yes qmi-firmware-update: ${build_firmware_update} diff --git a/data/pkg-config/Makefile.am b/data/pkg-config/Makefile.am index b40df97a..530151a7 100644 --- a/data/pkg-config/Makefile.am +++ b/data/pkg-config/Makefile.am @@ -2,7 +2,3 @@ # Set up pkg-config .pc files for exported libraries pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = qmi-glib.pc - -if QMI_QRTR_SUPPORTED -pkgconfig_DATA += qrtr-glib.pc -endif diff --git a/data/pkg-config/qrtr-glib.pc.in b/data/pkg-config/qrtr-glib.pc.in deleted file mode 100644 index bf359cb4..00000000 --- a/data/pkg-config/qrtr-glib.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: qrtr-glib -Description: Library to monitor nodes in the QRTR bus -Version: @VERSION@ -Requires: glib-2.0 gobject-2.0 gio-2.0 -Cflags: -I${includedir}/libqrtr-glib -Libs: -L${libdir} -lqrtr-glib diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am index 37583126..bb7ade73 100644 --- a/docs/reference/Makefile.am +++ b/docs/reference/Makefile.am @@ -1,2 +1,2 @@ -SUBDIRS = libqrtr-glib libqmi-glib +SUBDIRS = libqmi-glib diff --git a/docs/reference/libqmi-glib/Makefile.am b/docs/reference/libqmi-glib/Makefile.am index 65a393ee..a346d4fb 100644 --- a/docs/reference/libqmi-glib/Makefile.am +++ b/docs/reference/libqmi-glib/Makefile.am @@ -90,9 +90,6 @@ expand_content_files = extra_files = -# Extra options to supply to gtkdoc-fixref -FIXXREF_OPTIONS=--extra-dir=$(srcdir)/../libqrtr-glib/html - include $(top_srcdir)/gtk-doc.make EXTRA_DIST += \ diff --git a/docs/reference/libqrtr-glib/Makefile.am b/docs/reference/libqrtr-glib/Makefile.am deleted file mode 100644 index 62e35ef3..00000000 --- a/docs/reference/libqrtr-glib/Makefile.am +++ /dev/null @@ -1,78 +0,0 @@ - -if QMI_QRTR_SUPPORTED - -# The name of the module. -DOC_MODULE = libqrtr-glib - -# The top-level SGML file. -DOC_MAIN_SGML_FILE = $(DOC_MODULE)-docs.xml - -# Extra options to supply to gtkdoc-scan -SCAN_OPTIONS = --rebuild-types --deprecated-guards="QRTR_DISABLE_DEPRECATED" - -# The directory containing the source code. -DOC_SOURCE_DIR = \ - $(top_srcdir)/src/libqrtr-glib \ - $(top_builddir)/src/libqrtr-glib - -# Used for dependencies -HFILE_GLOB = \ - $(top_srcdir)/src/libqrtr-glib/*.h \ - $(top_builddir)/src/libqrtr-glib/*.h -CFILE_GLOB = \ - $(top_srcdir)/src/libqrtr-glib/*.c - -# Headers to ignore -IGNORE_HFILES = - -# CFLAGS and LDFLAGS for compiling scan program. Only needed -# if $(DOC_MODULE).types is non-empty. -AM_CPPFLAGS = \ - -I$(srcdir) \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - $(GLIB_CFLAGS) - -GTKDOC_LIBS = \ - $(GLIB_LIBS) \ - $(top_builddir)/src/libqrtr-glib/libqrtr-glib.la - -# Extra options to supply to gtkdoc-mkdb -MKDB_OPTIONS = --output-format=xml --sgml-mode --name-space=qrtr - -# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE) -content_files = version.xml - -expand_content_files = - -extra_files = - -include $(top_srcdir)/gtk-doc.make - -EXTRA_DIST += \ - $(DOC_MODULE)-sections.txt \ - version.xml.in \ - $(DIAGRAMS) \ - $(NULL) - -CLEANFILES += \ - $(DOC_MODULE)-decl-list.txt \ - $(DOC_MODULE)-decl.txt \ - $(DOC_MODULE)-overrides.txt \ - $(DOC_MODULE)-undeclared.txt \ - $(DOC_MODULE)-undocumented.txt \ - $(DOC_MODULE)-overrides.txt \ - $(DOC_MODULE)-unused.txt \ - $(DOC_MODULE).args \ - $(DOC_MODULE).hierarchy \ - $(DOC_MODULE).interfaces \ - $(DOC_MODULE).prerequisites \ - $(DOC_MODULE).signals \ - $(DOC_MODULE).actions \ - $(DOC_MODULE).types \ - $(DOC_MODULE)-sections.txt \ - *.stamp \ - -rf xml html tmpl \ - $(NULL) - -endif diff --git a/docs/reference/libqrtr-glib/libqrtr-glib-docs.xml b/docs/reference/libqrtr-glib/libqrtr-glib-docs.xml deleted file mode 100644 index 518c5086..00000000 --- a/docs/reference/libqrtr-glib/libqrtr-glib-docs.xml +++ /dev/null @@ -1,66 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" - "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" -[ - <!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'"> - <!ENTITY version SYSTEM "version.xml"> -]> -<book id="libqrtr-glib"> - <bookinfo> - <title>libqrtr-glib Reference Manual</title> - <releaseinfo> - For libqrtr-glib &version;. The latest version of this documentation can be found on-line at - <ulink role="online-location" url="https://www.freedesktop.org/software/libqmi/libqrtr-glib/latest/">https://www.freedesktop.org/software/libqmi/libqrtr-glib/latest/</ulink>. - </releaseinfo> - - <copyright> - <year>2021</year> - <holder>The libqrtr-glib authors</holder> - </copyright> - - <legalnotice> - <para> - Permission is granted to copy, distribute and/or modify this - document under the terms of the <citetitle>GNU Free - Documentation License</citetitle>, Version 1.3 or any later - version published by the Free Software Foundation with no - Invariant Sections, no Front-Cover Texts, and no Back-Cover - Texts. You may obtain a copy of the <citetitle>GNU Free - Documentation License</citetitle> from the Free Software - Foundation by visiting <ulink type="http" - url="http://www.fsf.org">their Web site</ulink> or by writing - to: - <address> - The Free Software Foundation, Inc. - <street>51 Franklin Street</street>, Suite 500 - <city>Boston</city>, <state>MA</state> <postcode>02110-1335</postcode> - <country>USA</country> - </address> - </para> - </legalnotice> - </bookinfo> - - <chapter> - <title>Core</title> - <xi:include href="xml/qrtr-version.xml"/> - <xi:include href="xml/qrtr-bus.xml"/> - <xi:include href="xml/qrtr-node.xml"/> - <xi:include href="xml/qrtr-client.xml"/> - <xi:include href="xml/qrtr-utils.xml"/> - </chapter> - - <chapter id="object-tree"> - <title>Object Hierarchy</title> - <xi:include href="xml/tree_index.sgml"/> - </chapter> - <chapter id="api-index-full"> - <title>Index</title> - <xi:include href="xml/api-index-full.xml"></xi:include> - </chapter> - <chapter id="api-index-1-28" role="1.28"> - <title>Index of new symbols in 1.28</title> - <xi:include href="xml/api-index-1.28.xml"></xi:include> - </chapter> - - <xi:include href="xml/annotation-glossary.xml"></xi:include> -</book> diff --git a/docs/reference/libqrtr-glib/libqrtr-glib-sections.txt b/docs/reference/libqrtr-glib/libqrtr-glib-sections.txt deleted file mode 100644 index 0e0ac905..00000000 --- a/docs/reference/libqrtr-glib/libqrtr-glib-sections.txt +++ /dev/null @@ -1,108 +0,0 @@ - -<SECTION> -<FILE>qrtr-bus</FILE> -<TITLE>QrtrBus</TITLE> -QRTR_BUS_LOOKUP_TIMEOUT -QRTR_BUS_SIGNAL_NODE_ADDED -QRTR_BUS_SIGNAL_NODE_REMOVED -QrtrBus -qrtr_bus_new -qrtr_bus_new_finish -qrtr_bus_peek_node -qrtr_bus_get_node -qrtr_bus_get_nodes -qrtr_bus_peek_nodes -qrtr_bus_wait_for_node -qrtr_bus_wait_for_node_finish -<SUBSECTION Standard> -QRTR_BUS -QRTR_BUS_CLASS -QRTR_BUS_GET_CLASS -QRTR_IS_BUS -QRTR_IS_BUS_CLASS -QRTR_TYPE_BUS -QrtrBusClass -QrtrBusPrivate -qrtr_bus_get_type -</SECTION> - -<SECTION> -<FILE>qrtr-node</FILE> -<TITLE>QrtrNode</TITLE> -<SUBSECTION NodeServiceInfo> -QrtrNodeServiceInfo -qrtr_node_service_info_get_service -qrtr_node_service_info_get_port -qrtr_node_service_info_get_version -qrtr_node_service_info_get_instance -qrtr_node_service_info_free -<SUBSECTION Node> -QRTR_NODE_BUS -QRTR_NODE_ID -QRTR_NODE_SIGNAL_SERVICE_ADDED -QRTR_NODE_SIGNAL_SERVICE_REMOVED -QRTR_NODE_SIGNAL_REMOVED -QrtrNode -qrtr_node_get_id -qrtr_node_peek_bus -qrtr_node_get_bus -qrtr_node_peek_service_info_list -qrtr_node_get_service_info_list -qrtr_node_lookup_port -qrtr_node_lookup_service -qrtr_node_wait_for_services -qrtr_node_wait_for_services_finish -<SUBSECTION Private> -qrtr_node_add_service_info -qrtr_node_remove_service_info -<SUBSECTION Standard> -QRTR_IS_NODE -QRTR_IS_NODE_CLASS -QRTR_NODE -QRTR_NODE_CLASS -QRTR_NODE_GET_CLASS -QRTR_TYPE_NODE -QRTR_TYPE_NODE_SERVICE_INFO -QrtrNodeClass -QrtrNodePrivate -qrtr_node_get_type -qrtr_node_service_info_get_type -</SECTION> - -<SECTION> -<FILE>qrtr-client</FILE> -<TITLE>QrtrClient</TITLE> -QRTR_CLIENT_NODE -QRTR_CLIENT_PORT -QRTR_CLIENT_SIGNAL_MESSAGE -QrtrClient -qrtr_client_new -qrtr_client_peek_node -qrtr_client_get_node -qrtr_client_get_port -qrtr_client_send -<SUBSECTION Standard> -QRTR_CLIENT -QRTR_CLIENT_CLASS -QRTR_CLIENT_GET_CLASS -QRTR_IS_CLIENT -QRTR_IS_CLIENT_CLASS -QRTR_TYPE_CLIENT -QrtrClientClass -QrtrClientPrivate -qrtr_client_get_type -</SECTION> - -<SECTION> -<FILE>qrtr-utils</FILE> -qrtr_get_uri_for_node -qrtr_get_node_for_uri -</SECTION> - -<SECTION> -<FILE>qrtr-version</FILE> -QRTR_MAJOR_VERSION -QRTR_MINOR_VERSION -QRTR_MICRO_VERSION -QRTR_CHECK_VERSION -</SECTION> diff --git a/docs/reference/libqrtr-glib/version.xml.in b/docs/reference/libqrtr-glib/version.xml.in deleted file mode 100644 index d78bda93..00000000 --- a/docs/reference/libqrtr-glib/version.xml.in +++ /dev/null @@ -1 +0,0 @@ -@VERSION@ diff --git a/src/Makefile.am b/src/Makefile.am index 3ffb032d..1ef5d357 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,5 @@ -SUBDIRS = libqrtr-glib libqmi-glib qmicli qmi-proxy +SUBDIRS = libqmi-glib qmicli qmi-proxy if BUILD_FIRMWARE_UPDATE SUBDIRS += qmi-firmware-update diff --git a/src/libqmi-glib/Makefile.am b/src/libqmi-glib/Makefile.am index bd022e6e..47e12fc3 100644 --- a/src/libqmi-glib/Makefile.am +++ b/src/libqmi-glib/Makefile.am @@ -10,6 +10,7 @@ libqmi_glib_compat_la_SOURCES = \ libqmi_glib_compat_la_CPPFLAGS = \ $(WARN_CFLAGS) \ $(GLIB_CFLAGS) \ + $(QRTR_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/src/libqmi-glib \ -I$(top_srcdir)/src/libqmi-glib/generated \ @@ -20,16 +21,10 @@ libqmi_glib_compat_la_CPPFLAGS = \ -Wno-deprecated-declarations \ $(NULL) -if QMI_QRTR_SUPPORTED -libqmi_glib_compat_la_CPPFLAGS += \ - -I$(top_srcdir)/src/libqrtr-glib \ - -I$(top_builddir)/src/libqrtr-glib \ - $(NULL) -endif - libqmi_glib_compat_la_LDFLAGS = \ $(WARN_LDFLAGS) \ $(GLIB_LIBS) \ + $(QRTR_LIBS) \ $(NULL) lib_LTLIBRARIES = libqmi-glib.la @@ -38,6 +33,7 @@ libqmi_glib_la_CPPFLAGS = \ $(WARN_CFLAGS) \ $(GLIB_CFLAGS) \ $(MBIM_CFLAGS) \ + $(QRTR_CFLAGS) \ -I$(top_srcdir) \ -I$(top_builddir) \ -I$(top_srcdir)/src/libqmi-glib \ @@ -97,20 +93,9 @@ libqmi_glib_la_SOURCES += \ endif if QMI_QRTR_SUPPORTED - -libqmi_glib_la_CPPFLAGS += \ - -I$(top_srcdir)/src/libqrtr-glib \ - -I$(top_builddir)/src/libqrtr-glib \ - $(NULL) - libqmi_glib_la_SOURCES += \ qmi-endpoint-qrtr.h qmi-endpoint-qrtr.c \ $(NULL) - -libqmi_glib_la_LIBADD += \ - ${top_builddir}/src/libqrtr-glib/libqrtr-glib.la \ - $(NULL) - endif libqmi_glib_la_LDFLAGS = \ @@ -118,6 +103,7 @@ libqmi_glib_la_LDFLAGS = \ $(WARN_CFLAGS) \ $(GLIB_LIBS) \ $(MBIM_LIBS) \ + $(QRTR_LIBS) \ $(NULL) includedir = @includedir@/libqmi-glib @@ -174,6 +160,9 @@ INTROSPECTION_COMPILER_ARGS = Qmi-1.0.gir: libqmi-glib.la Qmi_1_0_gir_INCLUDES = GLib-2.0 GObject-2.0 Gio-2.0 +if QMI_QRTR_SUPPORTED +Qmi_1_0_gir_INCLUDES += Qrtr-1.0 +endif Qmi_1_0_gir_CFLAGS = $(libqmi_glib_la_CPPFLAGS) Qmi_1_0_gir_LIBS = libqmi-glib.la Qmi_1_0_gir_EXPORT_PACKAGES = qmi-glib @@ -192,16 +181,6 @@ Qmi_1_0_gir_FILES = \ $(wildcard generated/*.c) \ $(NULL) -if QMI_QRTR_SUPPORTED -INTROSPECTION_COMPILER_ARGS += \ - --includedir="$(top_srcdir)/src/libqrtr-glib" \ - --includedir="$(top_builddir)/src/libqrtr-glib" \ - $(NULL) -Qmi_1_0_gir_SCANNERFLAGS += \ - --include-uninstalled="$(top_builddir)/src/libqrtr-glib/Qrtr-1.0.gir" \ - $(NULL) -endif - girdir = $(datadir)/gir-1.0 nodist_gir_DATA = $(INTROSPECTION_GIRS) diff --git a/src/libqmi-glib/generated/Makefile.am b/src/libqmi-glib/generated/Makefile.am index d03ccb05..9116869b 100644 --- a/src/libqmi-glib/generated/Makefile.am +++ b/src/libqmi-glib/generated/Makefile.am @@ -372,6 +372,7 @@ nodist_libqmi_glib_generated_la_SOURCES = \ libqmi_glib_generated_la_CPPFLAGS = \ $(WARN_CFLAGS) \ $(GLIB_CFLAGS) \ + $(QRTR_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/src/libqmi-glib \ -I$(top_builddir)/src/libqmi-glib \ @@ -383,15 +384,9 @@ libqmi_glib_generated_la_CPPFLAGS = \ libqmi_glib_generated_la_LDFLAGS = \ $(WARN_LDFLAGS) \ $(GLIB_LIBS) \ + $(QRTR_LIBS) \ $(NULL) -if QMI_QRTR_SUPPORTED -libqmi_glib_generated_la_CPPFLAGS += \ - -I$(top_srcdir)/src/libqrtr-glib \ - -I$(top_builddir)/src/libqrtr-glib \ - $(NULL) -endif - includedir = @includedir@/libqmi-glib nodist_include_HEADERS = \ qmi-error-types.h \ diff --git a/src/libqmi-glib/test/Makefile.am b/src/libqmi-glib/test/Makefile.am index 23ccece1..7070acb5 100644 --- a/src/libqmi-glib/test/Makefile.am +++ b/src/libqmi-glib/test/Makefile.am @@ -3,6 +3,7 @@ include $(top_srcdir)/gtester.make AM_CFLAGS = \ $(WARN_CFLAGS) \ $(GLIB_CFLAGS) \ + $(QRTR_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/src/libqmi-glib \ -I$(top_srcdir)/src/libqmi-glib/generated \ @@ -11,15 +12,9 @@ AM_CFLAGS = \ -DLIBQMI_GLIB_COMPILATION \ $(NULL) -if QMI_QRTR_SUPPORTED -AM_CFLAGS += \ - -I$(top_srcdir)/src/libqrtr-glib \ - -I$(top_builddir)/src/libqrtr-glib \ - $(NULL) -endif - AM_LDFLAGS = \ $(WARN_LDFLAGS) \ + $(QRTR_LIBS) \ $(GLIB_LIBS) \ $(NULL) diff --git a/src/libqrtr-glib/Makefile.am b/src/libqrtr-glib/Makefile.am deleted file mode 100644 index 7a6833e4..00000000 --- a/src/libqrtr-glib/Makefile.am +++ /dev/null @@ -1,98 +0,0 @@ - -includedir = @includedir@/libqrtr-glib - -if QMI_QRTR_SUPPORTED - -lib_LTLIBRARIES = libqrtr-glib.la - -libqrtr_glib_la_CPPFLAGS = \ - $(WARN_CFLAGS) \ - $(GLIB_CFLAGS) \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - -I$(top_srcdir)/src/libqrtr-glib \ - -I$(top_builddir)/src/libqrtr-glib \ - -DLIBQRTR_GLIB_COMPILATION \ - -DLIBEXEC_PATH=\""$(libexecdir)"\" \ - -DG_LOG_DOMAIN=\"Qrtr\" \ - $(NULL) - -libqrtr_glib_la_SOURCES = \ - libqrtr-glib.h \ - qrtr-bus.h qrtr-bus.c \ - qrtr-node.h qrtr-node.c \ - qrtr-client.h qrtr-client.c \ - qrtr-utils.h qrtr-utils.c \ - $(NULL) - -nodist_libqrtr_glib_la_SOURCES = \ - qrtr-version.h \ - $(NULL) - -libqrtr_glib_la_LDFLAGS = \ - -version-info $(QRTR_GLIB_LT_CURRENT):$(QRTR_GLIB_LT_REVISION):$(QRTR_GLIB_LT_AGE) \ - $(WARN_CFLAGS) \ - $(GLIB_LIBS) \ - $(NULL) - -include_HEADERS = \ - libqrtr-glib.h \ - qrtr-bus.h \ - qrtr-node.h \ - qrtr-client.h \ - qrtr-utils.h \ - $(NULL) - -nodist_include_HEADERS = \ - qrtr-version.h \ - $(NULL) - -EXTRA_DIST = \ - qrtr-version.h.in \ - $(NULL) - -DISTCLEANFILES = \ - qrtr-version.h \ - $(NULL) - -CLEANFILES = - -# Introspection - -if HAVE_INTROSPECTION - -INTROSPECTION_GIRS = Qrtr-1.0.gir -INTROSPECTION_SCANNER_ARGS = --warn-all -INTROSPECTION_COMPILER_ARGS = - -Qrtr-1.0.gir: libqrtr-glib.la -Qrtr_1_0_gir_INCLUDES = GLib-2.0 GObject-2.0 Gio-2.0 -Qrtr_1_0_gir_CFLAGS = $(libqrtr_glib_la_CPPFLAGS) -Qrtr_1_0_gir_LIBS = libqrtr-glib.la -Qrtr_1_0_gir_EXPORT_PACKAGES = libqrtr-glib -Qrtr_1_0_gir_SCANNERFLAGS = \ - $(WARN_SCANNERFLAGS) \ - --c-include "libqrtr-glib.h" \ - --identifier-prefix=QRTR \ - --identifier-prefix=Qrtr \ - --symbol-prefix=qrtr_ \ - $(NULL) -Qrtr_1_0_gir_FILES = \ - $(include_HEADERS) \ - $(filter-out %.h,$(libqrtr_glib_la_SOURCES)) \ - $(filter %.c,$(libqrtr_glib_la_SOURCES)) \ - $(NULL) - -girdir = $(datadir)/gir-1.0 -nodist_gir_DATA = $(INTROSPECTION_GIRS) - -typelibdir = $(libdir)/girepository-1.0 -nodist_typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) - -CLEANFILES += $(nodist_gir_DATA) $(nodist_typelib_DATA) - -endif # HAVE_INTROSPECTION - --include $(INTROSPECTION_MAKEFILE) - -endif diff --git a/src/libqrtr-glib/libqrtr-glib.h b/src/libqrtr-glib/libqrtr-glib.h deleted file mode 100644 index b4a1e2a6..00000000 --- a/src/libqrtr-glib/libqrtr-glib.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * libqrtr-glib -- GLib/GIO based library to control QRTR devices - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2020 Eric Caruso <ejcaruso@chromium.org> - * Copyright (C) 2020 Aleksander Morgado <aleksander@aleksander.es> - */ - -#ifndef _LIBQRTR_GLIB_H_ -#define _LIBQRTR_GLIB_H_ - -#define __LIBQRTR_GLIB_H_INSIDE__ - -#include "qrtr-bus.h" -#include "qrtr-node.h" -#include "qrtr-client.h" -#include "qrtr-utils.h" - -#endif /* _LIBQRTR_GLIB_H_ */ diff --git a/src/libqrtr-glib/qrtr-bus.c b/src/libqrtr-glib/qrtr-bus.c deleted file mode 100644 index 046e7cae..00000000 --- a/src/libqrtr-glib/qrtr-bus.c +++ /dev/null @@ -1,722 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * libqrtr-glib -- GLib/GIO based library to control QRTR devices - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2019-2021 Eric Caruso <ejcaruso@chromium.org> - * Copyright (C) 2020-2021 Aleksander Morgado <aleksander@aleksander.es> - */ - -#include <endian.h> -#include <errno.h> -#include <linux/qrtr.h> -#include <string.h> -#include <sys/socket.h> -#include <sys/types.h> - -#include <gio/gio.h> - -#include "qrtr-bus.h" -#include "qrtr-node.h" -#include "qrtr-utils.h" - -static void async_initable_iface_init (GAsyncInitableIface *iface); - -G_DEFINE_TYPE_EXTENDED (QrtrBus, qrtr_bus, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE, async_initable_iface_init)) - -enum { - PROP_0, - PROP_LOOKUP_TIMEOUT, - PROP_PORT, - PROP_LAST -}; - -enum { - SIGNAL_NODE_ADDED, - SIGNAL_NODE_REMOVED, - SIGNAL_LAST -}; - -static GParamSpec *properties[PROP_LAST]; -static guint signals[SIGNAL_LAST] = { 0 }; - -struct _QrtrBusPrivate { - /* Underlying QRTR socket */ - GSocket *socket; - - /* List with full references to the available QrtrNodes; i.e. the nodes are - * owned by the bus unconditionally. */ - GList *nodes; - - /* Callback source for when NEW_SERVER/DEL_SERVER control packets come in */ - GSource *source; - - /* initial lookup support */ - guint lookup_timeout; - GTask *init_task; - GSource *init_timeout_source; -}; - -/*****************************************************************************/ - -static gint -node_cmp (QrtrNode *a, - QrtrNode *b) -{ - return qrtr_node_get_id (a) - qrtr_node_get_id (b); -} - -static gint -node_find_cmp (QrtrNode *a, - gpointer user_data) -{ - return qrtr_node_get_id (a) - GPOINTER_TO_UINT (user_data); -} - -static void -add_service_info (QrtrBus *self, - guint32 node_id, - guint32 port, - guint32 service, - guint32 version, - guint32 instance) -{ - GList *list_item; - QrtrNode *node; - - list_item = g_list_find_custom (self->priv->nodes, GUINT_TO_POINTER (node_id), (GCompareFunc)node_find_cmp); - if (!list_item) { - /* Node objects are exclusively created at this point */ - node = QRTR_NODE (g_object_new (QRTR_TYPE_NODE, - QRTR_NODE_BUS, self, - QRTR_NODE_ID, node_id, - NULL)); - - self->priv->nodes = g_list_insert_sorted (self->priv->nodes, node, (GCompareFunc)node_cmp); - g_debug ("[qrtr] created new node %u", node_id); - g_signal_emit (self, signals[SIGNAL_NODE_ADDED], 0, node_id); - } else - node = QRTR_NODE (list_item->data); - - qrtr_node_add_service_info (node, service, port, version, instance); -} - -static void -remove_service_info (QrtrBus *self, - guint32 node_id, - guint32 port, - guint32 service, - guint32 version, - guint32 instance) -{ - GList *list_item; - QrtrNode *node; - - list_item = g_list_find_custom (self->priv->nodes, GUINT_TO_POINTER (node_id), (GCompareFunc)node_find_cmp); - if (!list_item) { - g_warning ("[qrtr] cannot remove service info: nonexistent node %u", node_id); - return; - } - - node = QRTR_NODE (list_item->data); - qrtr_node_remove_service_info (node, service, port, version, instance); - - if (!qrtr_node_peek_service_info_list (node)) { - g_debug ("[qrtr] removing node %u", node_id); - g_signal_emit (self, signals[SIGNAL_NODE_REMOVED], 0, node_id); - self->priv->nodes = g_list_delete_link (self->priv->nodes, list_item); - } -} - -/*****************************************************************************/ - -static void initable_complete (QrtrBus *self); - -static gboolean -qrtr_ctrl_message_cb (GSocket *gsocket, - GIOCondition cond, - QrtrBus *self) -{ - GError *error = NULL; - struct qrtr_ctrl_pkt ctrl_packet; - gssize bytes_received; - guint32 type; - guint32 node_id; - guint32 port; - guint32 service; - guint32 version; - guint32 instance; - - /* check for message type and add/remove nodes here */ - - bytes_received = g_socket_receive (gsocket, (gchar *)&ctrl_packet, - sizeof (ctrl_packet), NULL, &error); - if (bytes_received < 0) { - g_warning ("[qrtr] socket i/o failure: %s", error->message); - g_error_free (error); - return FALSE; - } - - if ((gsize)bytes_received < sizeof (ctrl_packet)) { - g_debug ("[qrtr] short packet received: ignoring"); - return TRUE; - } - - type = GUINT32_FROM_LE (ctrl_packet.cmd); - if (type != QRTR_TYPE_NEW_SERVER && type != QRTR_TYPE_DEL_SERVER) { - g_debug ("[qrtr] unknown packet type received: 0x%x", type); - return TRUE; - } - - /* type is something we handle, parse the packet */ - node_id = GUINT32_FROM_LE (ctrl_packet.server.node); - port = GUINT32_FROM_LE (ctrl_packet.server.port); - service = GUINT32_FROM_LE (ctrl_packet.server.service); - version = GUINT32_FROM_LE (ctrl_packet.server.instance) & 0xff; - instance = GUINT32_FROM_LE (ctrl_packet.server.instance) >> 8; - - if (type == QRTR_TYPE_DEL_SERVER) { - g_debug ("[qrtr] removed server on %u:%u -> service %u, version %u, instance %u", - node_id, port, service, version, instance); - remove_service_info (self, node_id, port, service, version, instance); - return TRUE; - } - - g_assert (type == QRTR_TYPE_NEW_SERVER); - - if (!node_id && !port && !service && !version && !instance) { - g_debug ("[qrtr] initial lookup finished"); - initable_complete (self); - return TRUE; - } - - g_debug ("[qrtr] added server on %u:%u -> service %u, version %u, instance %u", - node_id, port, service, version, instance); - add_service_info (self, node_id, port, service, version, instance); - return TRUE; -} - -/*****************************************************************************/ - -QrtrNode * -qrtr_bus_peek_node (QrtrBus *self, - guint32 node_id) -{ - GList *list_item; - - g_return_val_if_fail (QRTR_IS_BUS (self), NULL); - - list_item = g_list_find_custom (self->priv->nodes, GUINT_TO_POINTER (node_id), (GCompareFunc)node_find_cmp); - return (list_item ? QRTR_NODE (list_item->data) : NULL); -} - -QrtrNode * -qrtr_bus_get_node (QrtrBus *self, - guint32 node_id) -{ - QrtrNode *node; - - g_return_val_if_fail (QRTR_IS_BUS (self), NULL); - - node = qrtr_bus_peek_node (self, node_id); - return (node ? g_object_ref (node) : NULL); -} - -GList * -qrtr_bus_peek_nodes (QrtrBus *self) -{ - g_return_val_if_fail (QRTR_IS_BUS (self), NULL); - - return self->priv->nodes; -} - -GList * -qrtr_bus_get_nodes (QrtrBus *self) -{ - g_return_val_if_fail (QRTR_IS_BUS (self), NULL); - - return g_list_copy_deep (self->priv->nodes, (GCopyFunc) g_object_ref, NULL); -} - -/*****************************************************************************/ - -typedef struct { - guint32 node_id; - guint added_id; - GSource *timeout_source; -} WaitForNodeContext; - -static void -wait_for_node_context_cleanup (QrtrBus *self, - WaitForNodeContext *ctx) -{ - if (ctx->timeout_source) { - g_source_destroy (ctx->timeout_source); - g_source_unref (ctx->timeout_source); - ctx->timeout_source = NULL; - } - - if (ctx->added_id) { - g_signal_handler_disconnect (self, ctx->added_id); - ctx->added_id = 0; - } -} - -static void -wait_for_node_context_free (WaitForNodeContext *ctx) -{ - g_assert (!ctx->added_id); - g_assert (!ctx->timeout_source); - g_slice_free (WaitForNodeContext, ctx); -} - -QrtrNode * -qrtr_bus_wait_for_node_finish (QrtrBus *self, - GAsyncResult *res, - GError **error) -{ - return g_task_propagate_pointer (G_TASK (res), error); -} - -static gboolean -wait_for_node_timeout_cb (GTask *task) -{ - QrtrBus *self; - WaitForNodeContext *ctx; - - self = g_task_get_source_object (task); - ctx = g_task_get_task_data (task); - - /* cleanup the context right away, so that we take exclusive ownership - * of the task */ - wait_for_node_context_cleanup (self, ctx); - - g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_TIMED_OUT, - "QRTR node %u did not appear on the bus", ctx->node_id); - g_object_unref (task); - - return G_SOURCE_REMOVE; -} - -static void -wait_for_node_added_cb (QrtrBus *self, - guint node_id, - GTask *task) -{ - WaitForNodeContext *ctx; - QrtrNode *node; - - ctx = g_task_get_task_data (task); - - /* not the one we want, ignore */ - if (node_id != ctx->node_id) - return; - - /* cleanup the context right away, so that we take exclusive ownership - * of the task */ - wait_for_node_context_cleanup (self, ctx); - - /* get a full node reference */ - node = qrtr_bus_get_node (self, node_id); - g_task_return_pointer (task, node, g_object_unref); - g_object_unref (task); -} - -void -qrtr_bus_wait_for_node (QrtrBus *self, - guint32 node_id, - guint timeout_ms, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GTask *task; - WaitForNodeContext *ctx; - QrtrNode *existing_node; - - g_return_if_fail (QRTR_IS_BUS (self)); - g_return_if_fail (timeout_ms > 0); - - task = g_task_new (self, cancellable, callback, user_data); - - /* Nothing to do if it already exists */ - existing_node = qrtr_bus_get_node (self, node_id); - if (existing_node) { - g_task_return_pointer (task, existing_node, (GDestroyNotify)g_object_unref); - g_object_unref (task); - return; - } - - /* The ownership of the task is shared between the signal handler and the timeout; - * we need to make sure that we cancel the other one if we're completing the task - * from one of them. */ - ctx = g_slice_new0 (WaitForNodeContext); - ctx->node_id = node_id; - - /* Monitor added nodes */ - ctx->added_id = g_signal_connect (self, - QRTR_BUS_SIGNAL_NODE_ADDED, - G_CALLBACK (wait_for_node_added_cb), - task); - - /* Setup timeout for the operation */ - ctx->timeout_source = g_timeout_source_new (timeout_ms); - g_source_set_callback (ctx->timeout_source, (GSourceFunc)wait_for_node_timeout_cb, task, NULL); - g_source_attach (ctx->timeout_source, g_main_context_get_thread_default ()); - - g_task_set_task_data (task, ctx, (GDestroyNotify)wait_for_node_context_free); -} - -/*****************************************************************************/ - -static gboolean -send_new_lookup_ctrl_packet (QrtrBus *self, - GError **error) -{ - struct qrtr_ctrl_pkt ctl_packet; - struct sockaddr_qrtr addr; - int sockfd; - socklen_t len; - int rc; - - sockfd = g_socket_get_fd (self->priv->socket); - len = sizeof (addr); - rc = getsockname (sockfd, (struct sockaddr *)&addr, &len); - if (rc < 0) { - g_set_error (error, - G_IO_ERROR, - g_io_error_from_errno (errno), - "Failed to get socket name"); - return FALSE; - } - - g_debug ("[qrtr] socket lookup from %d:%d", addr.sq_node, addr.sq_port); - - g_assert (len == sizeof (addr) && addr.sq_family == AF_QIPCRTR); - addr.sq_port = QRTR_PORT_CTRL; - - memset (&ctl_packet, 0, sizeof (ctl_packet)); - ctl_packet.cmd = GUINT32_TO_LE (QRTR_TYPE_NEW_LOOKUP); - - rc = sendto (sockfd, (void *)&ctl_packet, sizeof (ctl_packet), - 0, (struct sockaddr *)&addr, sizeof (addr)); - if (rc < 0) { - g_set_error (error, - G_IO_ERROR, - g_io_error_from_errno (errno), - "Failed to send lookup control packet"); - return FALSE; - } - - return TRUE; -} - -static void -setup_socket_source (QrtrBus *self) -{ - self->priv->source = g_socket_create_source (self->priv->socket, G_IO_IN, NULL); - g_source_set_callback (self->priv->source, - (GSourceFunc) qrtr_ctrl_message_cb, - self, - NULL); - g_source_attach (self->priv->source, g_main_context_get_thread_default ()); -} - -static gboolean -common_init (QrtrBus *self, - GError **error) -{ - gint fd; - - fd = socket (AF_QIPCRTR, SOCK_DGRAM, 0); - if (fd < 0) { - g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno), - "Failed to create QRTR socket"); - return FALSE; - } - - self->priv->socket = g_socket_new_from_fd (fd, error); - if (!self->priv->socket) { - close (fd); - return FALSE; - } - - g_socket_set_timeout (self->priv->socket, 0); - - if (!send_new_lookup_ctrl_packet (self, error)) { - close (fd); - return FALSE; - } - - setup_socket_source (self); - return TRUE; -} - -/*****************************************************************************/ - -typedef struct { - -} InitContext; - -static gboolean -initable_init_finish (GAsyncInitable *initable, - GAsyncResult *result, - GError **error) -{ - return g_task_propagate_boolean (G_TASK (result), error); -} - -static gboolean -initable_timeout (QrtrBus *self) -{ - g_autoptr(GTask) task = NULL; - - task = g_steal_pointer (&self->priv->init_task); - g_assert (task); - - g_clear_pointer (&self->priv->init_timeout_source, g_source_unref); - - g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_TIMED_OUT, - "Timed out waiting for the initial bus lookup"); - return G_SOURCE_REMOVE; -} - -static void -initable_complete (QrtrBus *self) -{ - g_autoptr(GTask) task = NULL; - - task = g_steal_pointer (&self->priv->init_task); - if (!task) { - g_assert (!self->priv->init_timeout_source); - return; - } - - g_assert (self->priv->init_timeout_source); - g_source_destroy (self->priv->init_timeout_source); - g_clear_pointer (&self->priv->init_timeout_source, g_source_unref); - - g_task_return_boolean (task, TRUE); -} - -static void -initable_init_async (GAsyncInitable *initable, - int io_priority, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) -{ - QrtrBus *self = QRTR_BUS (initable); - GError *error = NULL; - g_autoptr(GTask) task = NULL; - - task = g_task_new (initable, cancellable, callback, user_data); - - if (!common_init (self, &error)) { - g_task_return_error (task, error); - return; - } - - /* if lookup timeout is disabled, we're done */ - if (!self->priv->lookup_timeout) { - g_task_return_boolean (task, TRUE); - return; - } - - /* setup wait for the initial lookup completion */ - self->priv->init_task = g_steal_pointer (&task); - self->priv->init_timeout_source = g_timeout_source_new (self->priv->lookup_timeout); - g_source_set_callback (self->priv->init_timeout_source, (GSourceFunc)initable_timeout, self, NULL); - g_source_attach (self->priv->init_timeout_source, g_main_context_get_thread_default ()); -} - -/*****************************************************************************/ - -QrtrBus * -qrtr_bus_new_finish (GAsyncResult *res, - GError **error) -{ - g_autoptr(GObject) source_object = NULL; - - source_object = g_async_result_get_source_object (res); - return QRTR_BUS (g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error)); -} - -void -qrtr_bus_new (guint lookup_timeout_ms, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) -{ - g_async_initable_new_async (QRTR_TYPE_BUS, - G_PRIORITY_DEFAULT, - cancellable, - callback, - user_data, - QRTR_BUS_LOOKUP_TIMEOUT, lookup_timeout_ms, - NULL); -} - -/*****************************************************************************/ - -static void -qrtr_bus_init (QrtrBus *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - QRTR_TYPE_BUS, - QrtrBusPrivate); -} - -static void -set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - QrtrBus *self = QRTR_BUS (object); - - switch (prop_id) { - case PROP_LOOKUP_TIMEOUT: - self->priv->lookup_timeout = g_value_get_uint (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - QrtrBus *self = QRTR_BUS (object); - - switch (prop_id) { - case PROP_LOOKUP_TIMEOUT: - g_value_set_uint (value, self->priv->lookup_timeout); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -dispose (GObject *object) -{ - QrtrBus *self = QRTR_BUS (object); - - g_assert (!self->priv->init_task); - g_assert (!self->priv->init_timeout_source); - - if (self->priv->source) { - g_source_destroy (self->priv->source); - g_source_unref (self->priv->source); - self->priv->source = NULL; - } - - if (self->priv->socket) { - g_socket_close (self->priv->socket, NULL); - g_clear_object (&self->priv->socket); - } - - g_list_free_full (self->priv->nodes, g_object_unref); - self->priv->nodes = NULL; - - G_OBJECT_CLASS (qrtr_bus_parent_class)->dispose (object); -} - -static void -async_initable_iface_init (GAsyncInitableIface *iface) -{ - iface->init_async = initable_init_async; - iface->init_finish = initable_init_finish; -} - -static void -qrtr_bus_class_init (QrtrBusClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (object_class, sizeof (QrtrBusPrivate)); - - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->dispose = dispose; - - /** - * QrtrBus:lookup-timeout: - * - * Since: 1.28 - */ - properties[PROP_LOOKUP_TIMEOUT] = - g_param_spec_uint (QRTR_BUS_LOOKUP_TIMEOUT, - "lookup timeout", - "Timeout in ms to wait for the initial lookup to finish, or 0 to disable it", - 0, - G_MAXUINT, - 0, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (object_class, PROP_LOOKUP_TIMEOUT, properties[PROP_LOOKUP_TIMEOUT]); - - /** - * QrtrBus::node-added: - * @self: the #QrtrBus - * @node: the node ID of the node that has been added - * - * The ::node-added signal is emitted when a new node registers a service on - * the QRTR bus. - * - * Since: 1.28 - */ - signals[SIGNAL_NODE_ADDED] = - g_signal_new (QRTR_BUS_SIGNAL_NODE_ADDED, - G_OBJECT_CLASS_TYPE (G_OBJECT_CLASS (klass)), - G_SIGNAL_RUN_LAST, - 0, - NULL, - NULL, - NULL, - G_TYPE_NONE, - 1, - G_TYPE_UINT); - - /** - * QrtrBus::node-removed: - * @self: the #QrtrBus - * @node: the node ID of the node that was removed - * - * The ::node-removed signal is emitted when a node deregisters all services - * from the QRTR bus. - * - * Since: 1.28 - */ - signals[SIGNAL_NODE_REMOVED] = - g_signal_new (QRTR_BUS_SIGNAL_NODE_REMOVED, - G_OBJECT_CLASS_TYPE (G_OBJECT_CLASS (klass)), - G_SIGNAL_RUN_LAST, - 0, - NULL, - NULL, - NULL, - G_TYPE_NONE, - 1, - G_TYPE_UINT); -} diff --git a/src/libqrtr-glib/qrtr-bus.h b/src/libqrtr-glib/qrtr-bus.h deleted file mode 100644 index 193a52d1..00000000 --- a/src/libqrtr-glib/qrtr-bus.h +++ /dev/null @@ -1,248 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * libqrtr-glib -- GLib/GIO based library to control QRTR devices - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2019-2021 Eric Caruso <ejcaruso@chromium.org> - * Copyright (C) 2020-2021 Aleksander Morgado <aleksander@aleksander.es> - */ - -#ifndef _LIBQRTR_GLIB_QRTR_BUS_H_ -#define _LIBQRTR_GLIB_QRTR_BUS_H_ - -#if !defined (__LIBQRTR_GLIB_H_INSIDE__) && !defined (LIBQRTR_GLIB_COMPILATION) -#error "Only <libqrtr-glib.h> can be included directly." -#endif - -#include <glib-object.h> -#include <gio/gio.h> - -#include "qrtr-node.h" - -G_BEGIN_DECLS - -/** - * SECTION:qrtr-bus - * @title: QrtrBus - * @short_description: QRTR bus observer and device event listener - * - * #QrtrBus sets up a socket that uses the QRTR IPC protocol and - * can call back into a client to tell them when new devices have appeared on - * the QRTR bus. It holds QrtrNodes that can be used to look up service and - * port information. - */ - -#define QRTR_TYPE_BUS (qrtr_bus_get_type ()) -#define QRTR_BUS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), QRTR_TYPE_BUS, QrtrBus)) -#define QRTR_BUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), QRTR_TYPE_BUS, QrtrBusClass)) -#define QRTR_IS_BUS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), QRTR_TYPE_BUS)) -#define QRTR_IS_BUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), QRTR_TYPE_BUS)) -#define QRTR_BUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), QRTR_TYPE_BUS, QrtrBusClass)) - -typedef struct _QrtrBus QrtrBus; -typedef struct _QrtrBusClass QrtrBusClass; -typedef struct _QrtrBusPrivate QrtrBusPrivate; - -struct _QrtrBus { - GObject parent; - QrtrBusPrivate *priv; -}; - -struct _QrtrBusClass { - GObjectClass parent; -}; - -GType qrtr_bus_get_type (void); -G_DEFINE_AUTOPTR_CLEANUP_FUNC (QrtrBus, g_object_unref) - -/** - * QRTR_BUS_LOOKUP_TIMEOUT: - * - * Symbol defining the #QrtrBus:lookup-timeout property. - * - * Since: 1.28 - */ -#define QRTR_BUS_LOOKUP_TIMEOUT "lookup-timeout" - -/** - * QRTR_BUS_SIGNAL_NODE_ADDED: - * - * Symbol defining the #QrtrBus::node-added signal. - * - * Since: 1.28 - */ -#define QRTR_BUS_SIGNAL_NODE_ADDED "node-added" - -/** - * QRTR_BUS_SIGNAL_NODE_REMOVED: - * - * Symbol defining the #QrtrBus::node-removed signal. - * - * Since: 1.28 - */ -#define QRTR_BUS_SIGNAL_NODE_REMOVED "node-removed" - -/** - * qrtr_bus_new: - * @lookup_timeout_ms: the timeout, in milliseconds, to wait for the initial bus - * lookup to complete. A zero timeout disables the lookup. - * @cancellable: optional #GCancellable object, %NULL to ignore. - * @callback: a #GAsyncReadyCallback to call when the initialization is finished. - * @user_data: the data to pass to callback function. - * - * Asynchronously creates a #QrtrBus object. - * - * This method will fail if the access to the QRTR bus is not possible, or if - * the initial lookup doesn't finish on time. - * - * When @lookup_timeout_ms is 0, this method does not guarantee that the - * initial bus lookup has already finished, the user should wait for the required - * #QrtrBus::node-added or #QrtrBus::service-added signals before assuming the - * nodes are accessible. - * - * When the operation is finished, @callback will be invoked. You can then call - * qrtr_bus_new_finish() to get the result of the operation. - * - * Since: 1.28 - */ -void qrtr_bus_new (guint lookup_timeout_ms, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -/** - * qrtr_bus_new_finish: - * @res: a #GAsyncResult. - * @error: Return location for error or %NULL. - * - * Finishes an operation started with qrtr_bus_new(). - * - * Returns: (transfer full): A newly created #QrtrBus, or %NULL if @error is set. - * - * Since: 1.28 - */ -QrtrBus *qrtr_bus_new_finish (GAsyncResult *res, - GError **error); - -/** - * qrtr_bus_peek_node: - * @self: a #QrtrBus. - * @node_id: the QRTR bus node ID to get - * - * Get the #QrtrNode with node ID @node_id, without increasing the reference count - * on the returned object. - * - * This method will fail if there is no node with the given @node_id in the QRTR bus. - * - * Returns: (transfer none): a #QrtrNode, or %NULL if none available. - * Do not free the returned object, it is owned by @self. - * - * Since: 1.28 - */ -QrtrNode *qrtr_bus_peek_node (QrtrBus *self, - guint32 node_id); - -/** - * qrtr_bus_get_node: - * @self: a #QrtrBus. - * @node_id: the QRTR bus node ID to get - * - * Get the #QrtrNode with node ID @node_id. - * - * This method will fail if there is no node with the given @node_id in the QRTR bus. - * - * Returns: (transfer full): a #QrtrNode that must be freed with g_object_unref(), - * or %NULL if none available - * - * Since: 1.28 - */ -QrtrNode *qrtr_bus_get_node (QrtrBus *self, - guint32 node_id); - -/** - * qrtr_bus_peek_nodes: - * @self: a #QrtrBus. - * - * Gets a list of all the #QrtrNode objects in the bus, without increasing - * the reference count on the returned object or the list. - * - * Returns: (transfer none)(nullable)(element-type QrtrNode): a list of - * #QrtrNode elements. The caller should not free the result, it is - * owned by @self. - * - * Since: 1.28 - */ -GList *qrtr_bus_peek_nodes (QrtrBus *self); - -/** - * qrtr_bus_get_nodes: - * @self: a #QrtrBus. - * - * Gets a list of all the #QrtrNode objects in the bus. - * - * Returns: (transfer full)(nullable)(element-type QrtrNode): a list of - * #QrtrNode elements. The caller should free the result by using - * g_list_free_full() with g_object_unref() as #GDestroyNotify. - * - * Since: 1.28 - */ -GList *qrtr_bus_get_nodes (QrtrBus *self); - -/** - * qrtr_bus_wait_for_node: - * @self: a #QrtrBus. - * @node_id: the QRTR bus node ID to lookup. - * @timeout_ms: the timeout, in milliseconds, to wait for the node to appear in - * the bus. - * @cancellable: a #GCancellable, or #NULL. - * @callback: a #GAsyncReadyCallback to call when the request is satisfied. - * @user_data: user data to pass to @callback. - * - * Asynchronously waits for the node with ID @node_id. - * - * When the operation is finished @callback will be called. You can then call - * qrtr_bus_wait_for_node_finish() to get the result of the - * operation. - * - * Since: 1.28 - */ -void qrtr_bus_wait_for_node (QrtrBus *self, - guint32 node_id, - guint timeout_ms, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -/** - * qrtr_bus_wait_for_node_finish: - * @self: a #QrtrBus. - * @res: a #GAsyncResult. - * @error: Return location for error or %NULL. - * - * Finishes an operation started with qrtr_bus_wait_for_node(). - * - * Returns: (transfer full): A #QrtrNode, or %NULL if @error is set. - * - * Since: 1.28 - */ -QrtrNode *qrtr_bus_wait_for_node_finish (QrtrBus *self, - GAsyncResult *res, - GError **error); - -G_END_DECLS - -#endif /* _LIBQRTR_GLIB_QRTR_BUS_H_ */ diff --git a/src/libqrtr-glib/qrtr-client.c b/src/libqrtr-glib/qrtr-client.c deleted file mode 100644 index 3022a430..00000000 --- a/src/libqrtr-glib/qrtr-client.c +++ /dev/null @@ -1,393 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * libqrtr-glib -- GLib/GIO based library to control QRTR devices - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2019-2021 Eric Caruso <ejcaruso@chromium.org> - * Copyright (C) 2021 Aleksander Morgado <aleksander@aleksander.es> - */ - -#include <endian.h> -#include <errno.h> -#include <linux/qrtr.h> -#include <string.h> -#include <sys/socket.h> -#include <sys/types.h> - -#include <gio/gio.h> - -#include "qrtr-bus.h" -#include "qrtr-node.h" -#include "qrtr-client.h" - -static void initable_iface_init (GInitableIface *iface); - -G_DEFINE_TYPE_EXTENDED (QrtrClient, qrtr_client, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, initable_iface_init)) - -enum { - PROP_0, - PROP_NODE, - PROP_PORT, - PROP_LAST -}; - -enum { - SIGNAL_MESSAGE, - SIGNAL_LAST -}; - -static GParamSpec *properties[PROP_LAST]; -static guint signals [SIGNAL_LAST] = { 0 }; - -struct _QrtrClientPrivate { - QrtrNode *node; - guint node_removed_id; - gboolean removed; - guint port; - - GSocket *socket; - GSource *source; - struct sockaddr_qrtr addr; -}; - -/*****************************************************************************/ - -static void -node_removed_cb (QrtrClient *self) -{ - g_debug ("[qrtr client %u:%u] node removed from bus", - qrtr_node_get_id (self->priv->node), self->priv->port); - self->priv->removed = TRUE; -} - -/*****************************************************************************/ - -guint32 -qrtr_client_get_port (QrtrClient *self) -{ - g_return_val_if_fail (QRTR_IS_CLIENT (self), 0); - - return self->priv->port; -} - -QrtrNode * -qrtr_client_peek_node (QrtrClient *self) -{ - g_return_val_if_fail (QRTR_IS_CLIENT (self), NULL); - - return self->priv->node; -} - -QrtrNode * -qrtr_client_get_node (QrtrClient *self) -{ - g_return_val_if_fail (QRTR_IS_CLIENT (self), NULL); - - return g_object_ref (self->priv->node); -} - -/*****************************************************************************/ - -gboolean -qrtr_client_send (QrtrClient *self, - GByteArray *message, - GCancellable *cancellable, - GError **error) -{ - gint fd; - - if (self->priv->removed) { - g_set_error (error, G_IO_ERROR, G_IO_ERROR_CLOSED, - "QRTR node was removed from the bus"); - return FALSE; - } - - fd = g_socket_get_fd (self->priv->socket); - if (sendto (fd, (void *)message->data, message->len, - 0, (struct sockaddr *)&self->priv->addr, sizeof (self->priv->addr)) < 0) { - g_set_error (error, - G_IO_ERROR, - g_io_error_from_errno (errno), - "Failed to send QRTR message: %s", g_strerror (errno)); - return FALSE; - } - - return TRUE; -} - -/*****************************************************************************/ - -static gboolean -qrtr_message_cb (GSocket *gsocket, - GIOCondition cond, - QrtrClient *self) -{ - g_autoptr(GError) error = NULL; - g_autoptr(GSocketAddress) addr = NULL; - struct sockaddr_qrtr sq; - g_autoptr(GByteArray) buf = NULL; - gssize next_datagram_size; - gssize bytes_received; - - next_datagram_size = g_socket_get_available_bytes (gsocket); - buf = g_byte_array_sized_new (next_datagram_size); - g_byte_array_set_size (buf, next_datagram_size); - - bytes_received = g_socket_receive_from (gsocket, &addr, (gchar *)buf->data, - next_datagram_size, NULL, &error); - if (bytes_received < 0) { - g_warning ("[qrtr client %u:%u] socket i/o failure: %s", - qrtr_node_get_id (self->priv->node), self->priv->port, error->message); - return FALSE; - } - - if (bytes_received != next_datagram_size) { - g_warning ("[qrtr client %u:%u] unexpected message size", - qrtr_node_get_id (self->priv->node), self->priv->port); - return TRUE; - } - - if (!g_socket_address_to_native (addr, &sq, sizeof (sq), &error)) { - g_warning ("[qrtr client %u:%u] could not parse QRTR address: %s", - qrtr_node_get_id (self->priv->node), self->priv->port, error->message); - return TRUE; - } - - if (sq.sq_family != AF_QIPCRTR || - sq.sq_node != qrtr_node_get_id (self->priv->node) || - sq.sq_port != self->priv->port) { - return TRUE; - } - - g_signal_emit (self, signals[SIGNAL_MESSAGE], 0, buf); - - return TRUE; -} - -/*****************************************************************************/ - -static gboolean -initable_init (GInitable *initable, - GCancellable *cancellable, - GError **error) -{ - QrtrClient *self = QRTR_CLIENT (initable); - gint fd; - - if (g_cancellable_is_cancelled (cancellable)) { - g_set_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED, - "Operation cancelled"); - return FALSE; - } - - self->priv->addr.sq_family = AF_QIPCRTR; - self->priv->addr.sq_node = qrtr_node_get_id (self->priv->node); - self->priv->addr.sq_port = (guint) self->priv->port; - - fd = socket (AF_QIPCRTR, SOCK_DGRAM, 0); - if (fd < 0) { - g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno), - "Could not create QRTR socket: %s", g_strerror (errno)); - return FALSE; - } - - self->priv->socket = g_socket_new_from_fd (fd, error); - if (!self->priv->socket) { - g_prefix_error (error, "Could not create QRTR socket: "); - close (fd); - return FALSE; - } - - g_socket_set_timeout (self->priv->socket, 0); - - self->priv->source = g_socket_create_source (self->priv->socket, G_IO_IN, NULL); - g_source_set_callback (self->priv->source, (GSourceFunc) qrtr_message_cb, self, NULL); - g_source_attach (self->priv->source, g_main_context_get_thread_default ()); - - return TRUE; -} - -/*****************************************************************************/ - -QrtrClient * -qrtr_client_new (QrtrNode *node, - guint32 port, - GCancellable *cancellable, - GError **error) -{ - g_return_val_if_fail (QRTR_IS_NODE (node), NULL); - g_return_val_if_fail (port > 0, NULL); - - return g_initable_new (QRTR_TYPE_CLIENT, - cancellable, - error, - QRTR_CLIENT_NODE, node, - QRTR_CLIENT_PORT, port, - NULL); -} - -static void -qrtr_client_init (QrtrClient *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - QRTR_TYPE_CLIENT, - QrtrClientPrivate); -} - -static void -set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - QrtrClient *self = QRTR_CLIENT (object); - - switch (prop_id) { - case PROP_NODE: - g_assert (!self->priv->node); - self->priv->node = g_value_dup_object (value); - self->priv->node_removed_id = g_signal_connect_swapped (self->priv->node, - QRTR_NODE_SIGNAL_REMOVED, - G_CALLBACK (node_removed_cb), - self); - break; - case PROP_PORT: - self->priv->port = (guint32) g_value_get_uint (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - QrtrClient *self = QRTR_CLIENT (object); - - switch (prop_id) { - case PROP_NODE: - g_value_set_object (value, self->priv->node); - break; - case PROP_PORT: - g_value_set_uint (value, (guint) self->priv->port); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -dispose (GObject *object) -{ - QrtrClient *self = QRTR_CLIENT (object); - - if (self->priv->source) { - g_source_destroy (self->priv->source); - g_clear_pointer (&self->priv->source, g_source_unref); - } - if (self->priv->socket) { - if (!g_socket_is_closed (self->priv->socket)) - g_socket_close (self->priv->socket, NULL); - g_clear_object (&self->priv->socket); - } - if (self->priv->node_removed_id) { - g_signal_handler_disconnect (self->priv->node, self->priv->node_removed_id); - self->priv->node_removed_id = 0; - } - g_clear_object (&self->priv->node); - - G_OBJECT_CLASS (qrtr_client_parent_class)->dispose (object); -} - -static void -initable_iface_init (GInitableIface *iface) -{ - iface->init = initable_init; -} - -static void -qrtr_client_class_init (QrtrClientClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (object_class, sizeof (QrtrClientPrivate)); - - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->dispose = dispose; - - /** - * QrtrClient:client-node: - * - * Since: 1.28 - */ - properties[PROP_NODE] = - g_param_spec_object (QRTR_CLIENT_NODE, - "node", - "The QRTR node", - QRTR_TYPE_NODE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (object_class, PROP_NODE, properties[PROP_NODE]); - - /** - * QrtrClient:client-port: - * - * Since: 1.28 - */ - properties[PROP_PORT] = - g_param_spec_uint (QRTR_CLIENT_PORT, - "port", - "The QRTR node port", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (object_class, PROP_PORT, properties[PROP_PORT]); - - /** - * QrtrClient::client-message - * @self: the #QrtrClient - * @message: the message data. - * - * The ::client-message signal is emitted when a message is received - * from the port in the node. - * - * There must be one single user connected to this signal, because it is - * not guaranteed that the contents of the @message byte array aren't - * modified by multiple users. In other words, the user connected to this - * signal may modify the contents of the @message byte array if needed. - * - * Since: 1.28 - */ - signals[SIGNAL_MESSAGE] = - g_signal_new (QRTR_CLIENT_SIGNAL_MESSAGE, - G_OBJECT_CLASS_TYPE (G_OBJECT_CLASS (klass)), - G_SIGNAL_RUN_LAST, - 0, - NULL, - NULL, - NULL, - G_TYPE_NONE, - 1, - G_TYPE_BYTE_ARRAY); -} diff --git a/src/libqrtr-glib/qrtr-client.h b/src/libqrtr-glib/qrtr-client.h deleted file mode 100644 index c32f161f..00000000 --- a/src/libqrtr-glib/qrtr-client.h +++ /dev/null @@ -1,173 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * libqrtr-glib -- GLib/GIO based library to control QRTR devices - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2021 Aleksander Morgado <aleksander@aleksander.es> - */ - -#ifndef _LIBQRTR_GLIB_QRTR_CLIENT_H_ -#define _LIBQRTR_GLIB_QRTR_CLIENT_H_ - -#if !defined (__LIBQRTR_GLIB_H_INSIDE__) && !defined (LIBQRTR_GLIB_COMPILATION) -#error "Only <libqrtr-glib.h> can be included directly." -#endif - -#include <glib-object.h> - -#include "qrtr-node.h" - -G_BEGIN_DECLS - -/** - * SECTION:qrtr-client - * @title: QrtrClient - * @short_description: The QRTR client. - * - * The #QrtrClient object represents a channel that can be used to - * communicate with a #QrtrNode in a given port. - */ - -#define QRTR_TYPE_CLIENT (qrtr_client_get_type ()) -#define QRTR_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), QRTR_TYPE_CLIENT, QrtrClient)) -#define QRTR_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), QRTR_TYPE_CLIENT, QrtrClientClass)) -#define QRTR_IS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), QRTR_TYPE_CLIENT)) -#define QRTR_IS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), QRTR_TYPE_CLIENT)) -#define QRTR_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), QRTR_TYPE_CLIENT, QrtrClientClass)) - -typedef struct _QrtrClient QrtrClient; -typedef struct _QrtrClientClass QrtrClientClass; -typedef struct _QrtrClientPrivate QrtrClientPrivate; - -/** - * QRTR_CLIENT_NODE: - * - * The QRTR node this client refers to. - * - * Since: 1.28 - */ -#define QRTR_CLIENT_NODE "client-node" - -/** - * QRTR_CLIENT_PORT: - * - * The QRTR node port this client refers to. - * - * Since: 1.28 - */ -#define QRTR_CLIENT_PORT "client-port" - -/** - * QRTR_CLIENT_SIGNAL_MESSAGE: - * - * Symbol defining the #QrtrClient::client-message signal. - * - * Since: 1.28 - */ -#define QRTR_CLIENT_SIGNAL_MESSAGE "client-message" - -struct _QrtrClient { - GObject parent; - QrtrClientPrivate *priv; -}; - -struct _QrtrClientClass { - GObjectClass parent; -}; - -GType qrtr_client_get_type (void); -G_DEFINE_AUTOPTR_CLEANUP_FUNC (QrtrClient, g_object_unref) - - -/** - * qrtr_client_new: - * @node: a #QrtrNode. - * @port: a node port. - * @cancellable: optional #GCancellable object, %NULL to ignore. - * @error: rReturn location for error or %NULL. - * - * Creates a new #QrtrClient to communicate with @port at #QrtrNode. - * - * Returns: (transfer full): a newly allocated #QrtrClient, or %NULL if @error is set. - * - * Since: 1.28 - */ -QrtrClient *qrtr_client_new (QrtrNode *node, - guint32 port, - GCancellable *cancellable, - GError **error); - -/** - * qrtr_client_peek_node: - * @self: a #QrtrClient. - * - * Get the #QrtrNode that this client refers to, without increasing the - * reference count on the returned object. - * - * Returns: (transfer none): a #QrtrNode. Do not free the returned object, it is - * owned by @self. - * - * Since: 1.28 - */ -QrtrNode *qrtr_client_peek_node (QrtrClient *self); - -/** - * qrtr_client_get_node: - * @self: a #QrtrClient. - * - * Get the #QrtrNode that this client refers to. - * - * Returns: (transfer full): a #QrtrNode that must be freed with g_object_unref(). - * - * Since: 1.28 - */ -QrtrNode *qrtr_client_get_node (QrtrClient *self); - -/** - * qrtr_client_get_port: - * @self: a #QrtrClient. - * - * Gets the node port where this client communicates. - * - * Returns: the node port. - * - * Since: 1.28 - */ -guint32 qrtr_client_get_port (QrtrClient *self); - - -/** - * qrtr_client_send: - * @self: a #QrtrClient. - * @message: the message. - * @cancellable: a #GCancellable. - * @error: Return location for #GError or %NULL. - * - * Sends a message to the port at the node. - * - * Returns: %TRUE if the message is sent, or %FALSE if @error is set. - * - * Since: 1.28 - */ -gboolean qrtr_client_send (QrtrClient *self, - GByteArray *message, - GCancellable *cancellable, - GError **error); - -G_END_DECLS - -#endif /* _LIBQRTR_GLIB_QRTR_CLIENT_H_ */ diff --git a/src/libqrtr-glib/qrtr-node.c b/src/libqrtr-glib/qrtr-node.c deleted file mode 100644 index ba83b245..00000000 --- a/src/libqrtr-glib/qrtr-node.c +++ /dev/null @@ -1,659 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * libqrtr-glib -- GLib/GIO based library to control QRTR devices - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2019-2020 Eric Caruso <ejcaruso@chromium.org> - * Copyright (C) 2020 Aleksander Morgado <aleksander@aleksander.es> - */ - -#include <endian.h> -#include <errno.h> -#include <linux/qrtr.h> -#include <string.h> -#include <sys/socket.h> -#include <sys/types.h> - -#include <gio/gio.h> -#include <gmodule.h> - -#include "qrtr-bus.h" -#include "qrtr-node.h" - -G_DEFINE_TYPE (QrtrNode, qrtr_node, G_TYPE_OBJECT) - -enum { - PROP_0, - PROP_BUS, - PROP_NODE_ID, - PROP_LAST -}; - -enum { - SIGNAL_SERVICE_ADDED, - SIGNAL_SERVICE_REMOVED, - SIGNAL_REMOVED, - SIGNAL_LAST -}; - -static GParamSpec *properties[PROP_LAST]; -static guint signals [SIGNAL_LAST] = { 0 }; - -struct _QrtrNodePrivate { - QrtrBus *bus; - guint32 node_id; - guint node_removed_id; - gboolean removed; - - /* Holds QrtrNodeServiceInfo entries */ - GList *service_list; - /* Maps service numbers to a list of service entries */ - GHashTable *service_index; - /* Maps port number to service entry (should only be one) */ - GHashTable *port_index; - - /* Array of QrtrServiceWaiters currently registered. */ - GPtrArray *waiters; -}; - -typedef struct { - GArray *services; - GTask *task; - GSource *timeout_source; -} QrtrServiceWaiter; - -/* used to avoid calling the free function when values are overwritten - * in the service index */ -typedef struct { - GList *list; -} ListHolder; - -/*****************************************************************************/ - -static void -node_removed_cb (QrtrNode *self, - guint node_id) -{ - guint i; - - if (node_id != self->priv->node_id) - return; - - self->priv->removed = TRUE; - - for (i = 0; i < self->priv->waiters->len; i++) { - QrtrServiceWaiter *waiter; - - waiter = g_ptr_array_index (self->priv->waiters, i); - g_task_return_new_error (waiter->task, - G_IO_ERROR, - G_IO_ERROR_CLOSED, - "QRTR node was removed from the bus"); - } - /* waiters was instantiated with qrtr_service_waiter_free as its free function, - * so when we get rid of the contents, all of the constitutent waiter entries - * (and their tasks) will be unreffed as well. */ - g_ptr_array_remove_range (self->priv->waiters, 0, self->priv->waiters->len); - - g_signal_emit (self, signals[SIGNAL_REMOVED], 0); -} - -/*****************************************************************************/ - -static void -qrtr_service_waiter_free (QrtrServiceWaiter *waiter) -{ - g_array_unref (waiter->services); - g_object_unref (waiter->task); - if (waiter->timeout_source) { - g_source_destroy (waiter->timeout_source); - g_source_unref (waiter->timeout_source); - } - g_slice_free (QrtrServiceWaiter, waiter); -} - -static gboolean -service_waiter_timeout_cb (QrtrServiceWaiter *waiter) -{ - QrtrNode *self; - - self = g_task_get_source_object (waiter->task); - g_task_return_new_error (waiter->task, - G_IO_ERROR, - G_IO_ERROR_TIMED_OUT, - "QRTR services did not appear on the bus"); - /* This takes care of unreffing the task. */ - g_ptr_array_remove_fast (self->priv->waiters, waiter); - - return G_SOURCE_REMOVE; -} - -static void -dispatch_pending_waiters (QrtrNode *self) -{ - guint i; - - for (i = 0; i < self->priv->waiters->len;) { - QrtrServiceWaiter *waiter; - guint j; - gboolean should_dispatch = TRUE; - - waiter = g_ptr_array_index (self->priv->waiters, i); - for (j = 0; j < waiter->services->len; j++) { - guint32 service; - - service = g_array_index (waiter->services, guint32, j); - if (!g_hash_table_lookup (self->priv->service_index, GUINT_TO_POINTER (service))) { - should_dispatch = FALSE; - break; - } - } - - if (should_dispatch) { - g_task_return_boolean (waiter->task, TRUE); - /* This takes care of unreffing the task. */ - g_ptr_array_remove_index_fast (self->priv->waiters, i); - } else { - i++; - } - } -} - -/*****************************************************************************/ - -struct _QrtrNodeServiceInfo { - guint32 service; - guint32 port; - guint32 version; - guint32 instance; -}; - -void -qrtr_node_service_info_free (QrtrNodeServiceInfo *info) -{ - g_slice_free (QrtrNodeServiceInfo, info); -} - -guint32 -qrtr_node_service_info_get_service (QrtrNodeServiceInfo *info) -{ - g_return_val_if_fail (info != NULL, 0); - - return info->service; -} - -guint32 -qrtr_node_service_info_get_port (QrtrNodeServiceInfo *info) -{ - g_return_val_if_fail (info != NULL, 0); - - return info->port; -} - -guint32 -qrtr_node_service_info_get_version (QrtrNodeServiceInfo *info) -{ - g_return_val_if_fail (info != NULL, 0); - - return info->version; -} - -guint32 -qrtr_node_service_info_get_instance (QrtrNodeServiceInfo *info) -{ - g_return_val_if_fail (info != NULL, 0); - - return info->instance; -} - -static QrtrNodeServiceInfo * -node_service_info_copy (const QrtrNodeServiceInfo *src) -{ - return g_slice_copy (sizeof (QrtrNodeServiceInfo), src); -} - -G_DEFINE_BOXED_TYPE (QrtrNodeServiceInfo, qrtr_node_service_info, (GBoxedCopyFunc)node_service_info_copy, (GBoxedFreeFunc)qrtr_node_service_info_free) - -static gint -sort_services_by_version (const QrtrNodeServiceInfo *a, - const QrtrNodeServiceInfo *b) -{ - return a->version - b->version; -} - -static void -list_holder_free (ListHolder *list_holder) -{ - g_list_free (list_holder->list); - g_slice_free (ListHolder, list_holder); -} - -static void -service_index_add_info (GHashTable *service_index, - guint32 service, - QrtrNodeServiceInfo *info) -{ - ListHolder *service_instances; - - service_instances = g_hash_table_lookup (service_index, GUINT_TO_POINTER (service)); - if (!service_instances) { - service_instances = g_slice_new0 (ListHolder); - g_hash_table_insert (service_index, GUINT_TO_POINTER (service), service_instances); - } - service_instances->list = g_list_insert_sorted (service_instances->list, info, - (GCompareFunc)sort_services_by_version); -} - -static void -service_index_remove_info (GHashTable *service_index, - guint32 service, - QrtrNodeServiceInfo *info) -{ - ListHolder *service_instances; - - service_instances = g_hash_table_lookup (service_index, GUINT_TO_POINTER (service)); - if (!service_instances) - return; - - service_instances->list = g_list_remove (service_instances->list, info); -} - -void -qrtr_node_add_service_info (QrtrNode *self, - guint32 service, - guint32 port, - guint32 version, - guint32 instance) -{ - QrtrNodeServiceInfo *info; - - info = g_slice_new (QrtrNodeServiceInfo); - info->service = service; - info->port = port; - info->version = version; - info->instance = instance; - self->priv->service_list = g_list_append (self->priv->service_list, info); - service_index_add_info (self->priv->service_index, service, info); - g_hash_table_insert (self->priv->port_index, GUINT_TO_POINTER (port), info); - - g_signal_emit (self, signals[SIGNAL_SERVICE_ADDED], 0, service); - dispatch_pending_waiters (self); -} - -void -qrtr_node_remove_service_info (QrtrNode *self, - guint32 service, - guint32 port, - guint32 version, - guint32 instance) -{ - QrtrNodeServiceInfo *info; - - info = g_hash_table_lookup (self->priv->port_index, GUINT_TO_POINTER (port)); - if (!info) { - g_info ("[qrtr node@%u]: tried to remove unknown service %u, port %u", - self->priv->node_id, service, port); - return; - } - - service_index_remove_info (self->priv->service_index, service, info); - g_hash_table_remove (self->priv->port_index, GUINT_TO_POINTER (port)); - self->priv->service_list = g_list_remove (self->priv->service_list, info); - qrtr_node_service_info_free (info); - - g_signal_emit (self, signals[SIGNAL_SERVICE_REMOVED], 0, service); -} - -/*****************************************************************************/ - -gint32 -qrtr_node_lookup_port (QrtrNode *self, - guint32 service) -{ - ListHolder *service_instances; - QrtrNodeServiceInfo *info; - GList *list; - - g_return_val_if_fail (QRTR_IS_NODE (self), -1); - - service_instances = g_hash_table_lookup (self->priv->service_index, - GUINT_TO_POINTER (service)); - if (!service_instances) - return -1; - - list = g_list_last (service_instances->list); - if (!list) - return -1; - - info = list->data; - return (info) ? (gint32)info->port : -1; -} - -gint32 -qrtr_node_lookup_service (QrtrNode *self, - guint32 port) -{ - QrtrNodeServiceInfo *info; - - g_return_val_if_fail (QRTR_IS_NODE (self), -1); - - info = g_hash_table_lookup (self->priv->port_index, GUINT_TO_POINTER (port)); - return info ? (gint32)info->service : -1; -} - -/*****************************************************************************/ - -GList * -qrtr_node_peek_service_info_list (QrtrNode *self) -{ - g_return_val_if_fail (QRTR_IS_NODE (self), NULL); - - return self->priv->service_list; -} - -GList * -qrtr_node_get_service_info_list (QrtrNode *self) -{ - g_return_val_if_fail (QRTR_IS_NODE (self), NULL); - - return g_list_copy_deep (self->priv->service_list, (GCopyFunc)node_service_info_copy, NULL); -} - -guint32 -qrtr_node_get_id (QrtrNode *self) -{ - g_return_val_if_fail (QRTR_IS_NODE (self), 0); - - return self->priv->node_id; -} - -QrtrBus * -qrtr_node_peek_bus (QrtrNode *self) -{ - g_return_val_if_fail (QRTR_IS_NODE (self), NULL); - - return self->priv->bus; -} - -QrtrBus * -qrtr_node_get_bus (QrtrNode *self) -{ - g_return_val_if_fail (QRTR_IS_NODE (self), NULL); - - return g_object_ref (self->priv->bus); -} - -/*****************************************************************************/ - -gboolean -qrtr_node_wait_for_services_finish (QrtrNode *self, - GAsyncResult *result, - GError **error) -{ - return g_task_propagate_boolean (G_TASK (result), error); -} - -void -qrtr_node_wait_for_services (QrtrNode *self, - GArray *services, - guint timeout_ms, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GTask *task; - QrtrServiceWaiter *waiter; - guint i; - gboolean services_present = TRUE; - - g_return_if_fail (QRTR_IS_NODE (self)); - g_return_if_fail (timeout_ms > 0); - - task = g_task_new (self, cancellable, callback, user_data); - - if (self->priv->removed) { - g_task_return_new_error (task, - G_IO_ERROR, - G_IO_ERROR_CLOSED, - "QRTR node was removed from the bus"); - g_object_unref (task); - return; - } - - for (i = 0; i < services->len; i++) { - guint32 service; - - service = g_array_index (services, guint32, i); - if (!g_hash_table_lookup (self->priv->service_index, GUINT_TO_POINTER (service))) { - services_present = FALSE; - break; - } - } - - if (services_present) { - g_task_return_boolean (task, TRUE); - g_object_unref (task); - return; - } - - waiter = g_slice_new0 (QrtrServiceWaiter); - waiter->services = g_array_ref (services); - waiter->task = task; - waiter->timeout_source = g_timeout_source_new (timeout_ms); - g_source_set_callback (waiter->timeout_source, (GSourceFunc)service_waiter_timeout_cb, - waiter, NULL); - g_source_attach (waiter->timeout_source, g_main_context_get_thread_default ()); - - g_ptr_array_add (self->priv->waiters, waiter); -} - -/*****************************************************************************/ - -static void -qrtr_node_init (QrtrNode *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, QRTR_TYPE_NODE, QrtrNodePrivate); - - self->priv->removed = FALSE; - self->priv->service_index = g_hash_table_new_full (g_direct_hash, g_direct_equal, - NULL, (GDestroyNotify)list_holder_free); - self->priv->port_index = g_hash_table_new (g_direct_hash, g_direct_equal); - self->priv->waiters = g_ptr_array_new_with_free_func ((GDestroyNotify)qrtr_service_waiter_free); -} - -static void -set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - QrtrNode *self = QRTR_NODE (object); - - switch (prop_id) { - case PROP_BUS: - g_assert (!self->priv->bus); - self->priv->bus = g_value_dup_object (value); - self->priv->node_removed_id = g_signal_connect_swapped (self->priv->bus, - QRTR_BUS_SIGNAL_NODE_REMOVED, - G_CALLBACK (node_removed_cb), - self); - break; - case PROP_NODE_ID: - self->priv->node_id = (guint32) g_value_get_uint (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - QrtrNode *self = QRTR_NODE (object); - - switch (prop_id) { - case PROP_BUS: - g_value_set_object (value, self->priv->bus); - break; - case PROP_NODE_ID: - g_value_set_uint (value, (guint)self->priv->node_id); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -dispose (GObject *object) -{ - QrtrNode *self = QRTR_NODE (object); - - if (self->priv->node_removed_id) { - g_signal_handler_disconnect (self->priv->bus, self->priv->node_removed_id); - self->priv->node_removed_id = 0; - } - g_clear_object (&self->priv->bus); - - /* We shouldn't have any waiters because they should have been removed when the - * node was removed from the bus, and they hold references to self. */ - g_assert (self->priv->waiters->len == 0); - g_clear_pointer (&self->priv->waiters, (GDestroyNotify)g_ptr_array_unref); - - G_OBJECT_CLASS (qrtr_node_parent_class)->dispose (object); -} - -static void -finalize (GObject *object) -{ - QrtrNode *self = QRTR_NODE (object); - - g_hash_table_unref (self->priv->service_index); - g_hash_table_unref (self->priv->port_index); - g_list_free_full (self->priv->service_list, (GDestroyNotify)qrtr_node_service_info_free); - - G_OBJECT_CLASS (qrtr_node_parent_class)->finalize (object); -} - -static void -qrtr_node_class_init (QrtrNodeClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (object_class, sizeof (QrtrNodePrivate)); - - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->dispose = dispose; - object_class->finalize = finalize; - - /** - * QrtrNode:bus: - * - * Since: 1.28 - */ - properties[PROP_BUS] = - g_param_spec_object (QRTR_NODE_BUS, - "bus", - "QRTR bus", - QRTR_TYPE_BUS, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (object_class, PROP_BUS, properties[PROP_BUS]); - - /** - * QrtrNode:node-id: - * - * Since: 1.28 - */ - properties[PROP_NODE_ID] = - g_param_spec_uint (QRTR_NODE_ID, - "Node ID", - "ID of the QRTR node", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (object_class, PROP_NODE_ID, properties[PROP_NODE_ID]); - - /** - * QrtrNode::service-added: - * @self: the #QrtrNode - * @service: the service ID of the service that has been added - * - * The ::service-added signal is emitted when a new service registers - * on the QRTR node. - * - * Since: 1.28 - */ - signals[SIGNAL_SERVICE_ADDED] = - g_signal_new (QRTR_NODE_SIGNAL_SERVICE_ADDED, - G_OBJECT_CLASS_TYPE (G_OBJECT_CLASS (klass)), - G_SIGNAL_RUN_LAST, - 0, - NULL, - NULL, - NULL, - G_TYPE_NONE, - 1, - G_TYPE_UINT); - - /** - * QrtrNode::service-removed: - * @self: the #QrtrNode - * @service: the service ID of the service that was removed - * - * The ::service-removed signal is emitted when a service deregisters - * from the QRTR node. - * - * Since: 1.28 - */ - signals[SIGNAL_SERVICE_REMOVED] = - g_signal_new (QRTR_NODE_SIGNAL_SERVICE_REMOVED, - G_OBJECT_CLASS_TYPE (G_OBJECT_CLASS (klass)), - G_SIGNAL_RUN_LAST, - 0, - NULL, - NULL, - NULL, - G_TYPE_NONE, - 1, - G_TYPE_UINT); - - /** - * QrtrNode::node-removed: - * @self: the #QrtrNode - * - * The ::node-removed signal is emitted when the node fully disappears from - * the QRTR bus. - * - * Since: 1.28 - */ - signals[SIGNAL_REMOVED] = - g_signal_new (QRTR_NODE_SIGNAL_REMOVED, - G_OBJECT_CLASS_TYPE (G_OBJECT_CLASS (klass)), - G_SIGNAL_RUN_LAST, - 0, - NULL, - NULL, - NULL, - G_TYPE_NONE, - 0); -} diff --git a/src/libqrtr-glib/qrtr-node.h b/src/libqrtr-glib/qrtr-node.h deleted file mode 100644 index 7b320f5f..00000000 --- a/src/libqrtr-glib/qrtr-node.h +++ /dev/null @@ -1,353 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * libqrtr-glib -- GLib/GIO based library to control QRTR devices - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2019-2021 Eric Caruso <ejcaruso@chromium.org> - * Copyright (C) 2020-2021 Aleksander Morgado <aleksander@aleksander.es> - */ - -#ifndef _LIBQRTR_GLIB_QRTR_NODE_H_ -#define _LIBQRTR_GLIB_QRTR_NODE_H_ - -#if !defined (__LIBQRTR_GLIB_H_INSIDE__) && !defined (LIBQRTR_GLIB_COMPILATION) -#error "Only <libqrtr-glib.h> can be included directly." -#endif - -#include <glib-object.h> - -G_BEGIN_DECLS - -/** - * SECTION:qrtr-node - * @title: QrtrNode - * @short_description: QRTR node handler. - * - * #QrtrNode represents a device on the QRTR bus and can be used to look up - * services published by that device. - */ - -#define QRTR_TYPE_NODE (qrtr_node_get_type ()) -#define QRTR_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), QRTR_TYPE_NODE, QrtrNode)) -#define QRTR_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), QRTR_TYPE_NODE, QrtrNodeClass)) -#define QRTR_IS_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), QRTR_TYPE_NODE)) -#define QRTR_IS_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), QRTR_TYPE_NODE)) -#define QRTR_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), QRTR_TYPE_NODE, QrtrNodeClass)) - -typedef struct _QrtrNode QrtrNode; -typedef struct _QrtrNodeClass QrtrNodeClass; -typedef struct _QrtrNodePrivate QrtrNodePrivate; - -/** - * QRTR_NODE_BUS: - * - * The QRTR bus. - * - * Since: 1.28 - */ -#define QRTR_NODE_BUS "bus" - -/** - * QRTR_NODE_ID: - * - * The node id. - * - * Since: 1.28 - */ -#define QRTR_NODE_ID "node-id" - -struct _QrtrNode { - GObject parent; - QrtrNodePrivate *priv; -}; - -struct _QrtrNodeClass { - GObjectClass parent; -}; - -GType qrtr_node_get_type (void); -G_DEFINE_AUTOPTR_CLEANUP_FUNC (QrtrNode, g_object_unref) - -/** - * QRTR_NODE_SIGNAL_SERVICE_ADDED: - * - * Symbol defining the #QrtrNode::service-added signal. - * - * Since: 1.28 - */ -#define QRTR_NODE_SIGNAL_SERVICE_ADDED "service-added" - -/** - * QRTR_NODE_SIGNAL_SERVICE_REMOVED: - * - * Symbol defining the #QrtrNode::service-removed signal. - * - * Since: 1.28 - */ -#define QRTR_NODE_SIGNAL_SERVICE_REMOVED "service-removed" - -/** - * QRTR_NODE_SIGNAL_REMOVED: - * - * Symbol defining the #QrtrNode::node-removed signal. - * - * Since: 1.28 - */ -#define QRTR_NODE_SIGNAL_REMOVED "node-removed" - -/** - * qrtr_node_get_id: - * @self: a #QrtrNode. - * - * Gets the node ID in the QRTR bus. - * - * Returns: the node id. - * - * Since: 1.28 - */ -guint32 qrtr_node_get_id (QrtrNode *self); - -/* forward references for the QrtrBus */ -typedef struct _QrtrBus QrtrBus; -struct _QrtrBus; - -/** - * qrtr_node_peek_bus: - * @self: a #QrtrNode. - * - * Get the #QrtrBus where this node is available, without increasing the - * reference count on the returned object. - * - * Returns: (transfer none): a #QrtrBus. Do not free the returned object, it is - * owned by @self. - * - * Since: 1.28 - */ -QrtrBus *qrtr_node_peek_bus (QrtrNode *self); - -/** - * qrtr_node_get_bus: - * @self: a #QrtrNode. - * - * Get the #QrtrBus where this node is available. - * - * Returns: (transfer full): a #QrtrBus that must be freed with g_object_unref(). - * - * Since: 1.28 - */ -QrtrBus *qrtr_node_get_bus (QrtrNode *self); - -/** - * QrtrNodeServiceInfo: - * - * Information for a service instance in the #QrtrNode. - * - * Since: 1.28 - */ -typedef struct _QrtrNodeServiceInfo QrtrNodeServiceInfo; - -#define QRTR_TYPE_NODE_SERVICE_INFO (qrtr_node_service_info_get_type ()) -GType qrtr_node_service_info_get_type (void); - -/** - * qrtr_node_service_info_get_service: - * @info: a #QrtrNodeServiceInfo. - * - * Get the service number from the #QrtrNodeServiceInfo. - * - * Returns: the service number. - * - * Since: 1.28 - */ -guint32 qrtr_node_service_info_get_service (QrtrNodeServiceInfo *info); - -/** - * qrtr_node_service_info_get_port: - * @info: a #QrtrNodeServiceInfo. - * - * Get the port number from the #QrtrNodeServiceInfo. - * - * Returns: the port number. - * - * Since: 1.28 - */ -guint32 qrtr_node_service_info_get_port (QrtrNodeServiceInfo *info); - -/** - * qrtr_node_service_info_get_version: - * @info: a #QrtrNodeServiceInfo. - * - * Get the version number from the #QrtrNodeServiceInfo. - * - * Returns: the version number. - * - * Since: 1.28 - */ -guint32 qrtr_node_service_info_get_version (QrtrNodeServiceInfo *info); - -/** - * qrtr_node_service_info_get_instance: - * @info: a #QrtrNodeServiceInfo. - * - * Get the instance number from the #QrtrNodeServiceInfo. - * - * Returns: the instance number. - * - * Since: 1.28 - */ -guint32 qrtr_node_service_info_get_instance (QrtrNodeServiceInfo *info); - -/** - * qrtr_node_service_info_free: - * @info: a #QrtrNodeServiceInfo. - * - * Frees a single #QrtrNodeServiceInfo, as returned by qrtr_node_get_service_info_list(). - * - * Since: 1.28 - */ -void qrtr_node_service_info_free (QrtrNodeServiceInfo *info); -G_DEFINE_AUTOPTR_CLEANUP_FUNC (QrtrNodeServiceInfo, qrtr_node_service_info_free) - -/** - * qrtr_node_peek_service_info_list: - * @self: a #QrtrNode. - * - * Get the list of services currently supported by the #QrtrNode. - * - * Returns: (element-type QrtrNodeServiceInfo)(transfer none): a #GList of #QrtrNodeServiceInfo elements. Do not - * free the returned object, it is owned by @self. - * - * Since: 1.28 - */ -GList *qrtr_node_peek_service_info_list (QrtrNode *self); - -/** - * qrtr_node_get_service_info_list: - * @self: a #QrtrNode. - * - * Get the list of services currently supported by the #QrtrNode. - * - * Returns: (element-type QrtrNodeServiceInfo)(transfer full): a #GList of #QrtrNodeServiceInfo elements, that - * must be freed with g_list_free_full() using qrtr_node_service_info_free() - * as #GDestroyNotify. - * - * Since: 1.28 - */ -GList *qrtr_node_get_service_info_list (QrtrNode *self); - -/** - * qrtr_node_lookup_port: - * @self: a #QrtrNode. - * @service: a service number. - * - * If a server has announced itself for the given node and service number, - * return the port number of that service. - * - * If multiple instances are registered, this method returns the port number - * for the service with the highest version number. - * - * Returns: the port number of the service in the node, or -1 if not found. - * - * Since: 1.28 - */ -gint32 qrtr_node_lookup_port (QrtrNode *self, - guint32 service); - -/** - * qrtr_node_lookup_service: - * @self: a #QrtrNode. - * @port: a port number. - * - * If a server has announced itself for the given node and port number, - * return the service it serves. - * - * Returns: the service number, or -1 if not found. - * - * Since: 1.28 - */ -gint32 qrtr_node_lookup_service (QrtrNode *self, - guint32 port); - -/** - * qrtr_node_wait_for_services: - * @self: a #QrtrNode. - * @services: (in)(element-type guint32): a #GArray of service types - * @timeout_ms: the timeout, in milliseconds, to wait for the the services to - * be exposed in the node. - * @cancellable: a #GCancellable, or #NULL. - * @callback: a #GAsyncReadyCallback to call when the request is satisfied. - * @user_data: user data to pass to @callback. - * - * Asynchronously waits until all the services listed in @services are present - * on the node. - * - * The operation may fail if any of the requested services isn't notified, or - * if the node is removed from the bus while waiting. - * - * When the operation is finished @callback will be called. You can then call - * qrtr_node_wait_for_services_finish() to get the result of the - * operation. - * - * Since: 1.28 - */ -void qrtr_node_wait_for_services (QrtrNode *self, - GArray *services, - guint timeout_ms, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -/** - * qrtr_node_wait_for_services_finish: - * @self: a #QrtrNode. - * @result: a #GAsyncResult. - * @error: Return location for #GError or %NULL. - * - * Finishes an operation started with qrtr_node_wait_for_services(). - * - * Returns: %TRUE if all requested services are present on this node, - * or %FALSE if @error is set. - * - * Since: 1.28 - */ -gboolean qrtr_node_wait_for_services_finish (QrtrNode *self, - GAsyncResult *result, - GError **error); - -G_END_DECLS - -/* Other private methods */ - -#if defined (LIBQRTR_GLIB_COMPILATION) - -G_GNUC_INTERNAL -void qrtr_node_add_service_info (QrtrNode *node, - guint32 service, - guint32 port, - guint32 version, - guint32 instance); - -G_GNUC_INTERNAL -void qrtr_node_remove_service_info (QrtrNode *node, - guint32 service, - guint32 port, - guint32 version, - guint32 instance); - -#endif /* defined (LIBQMI_GLIB_COMPILATION) */ - -#endif /* _LIBQRTR_GLIB_QRTR_NODE_H_ */ diff --git a/src/libqrtr-glib/qrtr-utils.c b/src/libqrtr-glib/qrtr-utils.c deleted file mode 100644 index 27c2e6d7..00000000 --- a/src/libqrtr-glib/qrtr-utils.c +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * libqrtr-glib -- GLib/GIO based library to control QRTR devices - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2019-2020 Eric Caruso <ejcaruso@chromium.org> - * Copyright (C) 2020 Aleksander Morgado <aleksander@aleksander.es> - */ - -#include "qrtr-utils.h" - -#include <stdlib.h> -#include <string.h> - -/* Some kernels expose the qrtr header but not the address family macro. */ -#if !defined AF_QIPCRTR -# define AF_QIPCRTR 42 -#endif - -#define QRTR_URI_SCHEME "qrtr" -#define QRTR_URI_PREFIX QRTR_URI_SCHEME "://" - -gchar * -qrtr_get_uri_for_node (guint32 node_id) -{ - return g_strdup_printf (QRTR_URI_PREFIX "%" G_GUINT32_FORMAT, node_id); -} - -gboolean -qrtr_get_node_for_uri (const gchar *name, - guint32 *node_id) -{ - const gchar *start; - gchar *endp = NULL; - guint tmp_node_id; - - if (g_ascii_strncasecmp (name, QRTR_URI_PREFIX, strlen (QRTR_URI_PREFIX)) != 0) - return FALSE; - - start = name + strlen (QRTR_URI_PREFIX); - tmp_node_id = strtoul (start, &endp, 10); - if (endp == start) - return FALSE; - - if (node_id) - *node_id = tmp_node_id; - - return TRUE; -} diff --git a/src/libqrtr-glib/qrtr-utils.h b/src/libqrtr-glib/qrtr-utils.h deleted file mode 100644 index 928905b2..00000000 --- a/src/libqrtr-glib/qrtr-utils.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * libqrtr-glib -- GLib/GIO based library to control QRTR devices - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2019-2020 Eric Caruso <ejcaruso@chromium.org> - * Copyright (C) 2020 Aleksander Morgado <aleksander@aleksander.es> - */ - -#ifndef _LIBQRTR_GLIB_QRTR_UTILS_H_ -#define _LIBQRTR_GLIB_QRTR_UTILS_H_ - -#include <gio/gio.h> -#include <glib.h> - -#include "qrtr-node.h" - -/** - * qrtr_get_uri_for_node: - * @node_id: node id. - * - * Build a URI for the given QRTR node. - * - * Returns: a string with the URI, or %NULL if none given. The returned value - * should be freed with g_free(). - * - * Since: 1.28 - */ -gchar *qrtr_get_uri_for_node (guint32 node_id); - -/** - * qrtr_get_node_for_uri: - * @uri: a URI. - * @node_id: return location for the node id. - * - * Get the QRTR node id from the specified URI. - * - * Returns: %TRUE if @node_id is set, %FALSE otherwise. - * - * Since: 1.28 - */ -gboolean qrtr_get_node_for_uri (const gchar *uri, - guint32 *node_id); - -#endif /* _LIBQRTR_GLIB_QRTR_UTILS_H_ */ diff --git a/src/libqrtr-glib/qrtr-version.h.in b/src/libqrtr-glib/qrtr-version.h.in deleted file mode 100644 index 2313b8e8..00000000 --- a/src/libqrtr-glib/qrtr-version.h.in +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2021 Aleksander Morgado <aleksander@aleksander.es> - */ - -#ifndef _QRTR_VERSION_H_ -#define _QRTR_VERSION_H_ - -/** - * SECTION:qrtr-version - * @short_description: Version information in the API. - * - * This section defines types that are used to identify the libqrtr-glib version. - **/ - -/** - * QRTR_MAJOR_VERSION: - * - * Evaluates to the major version number of libqrtr-glib which this source - * is compiled against. - * - * Since: 1.28 - */ -#define QRTR_MAJOR_VERSION (@QRTR_MAJOR_VERSION@) - -/** - * QRTR_MINOR_VERSION: - * - * Evaluates to the minor version number of libqrtr-glib which this source - * is compiled against. - * - * Since: 1.28 - */ -#define QRTR_MINOR_VERSION (@QRTR_MINOR_VERSION@) - -/** - * QRTR_MICRO_VERSION: - * - * Evaluates to the micro version number of libqrtr-glib which this source - * compiled against. - * - * Since: 1.28 - */ -#define QRTR_MICRO_VERSION (@QRTR_MICRO_VERSION@) - -/** - * QRTR_CHECK_VERSION: - * @major: major version (e.g. 1 for version 1.2.5) - * @minor: minor version (e.g. 2 for version 1.2.5) - * @micro: micro version (e.g. 5 for version 1.2.5) - * - * Checks the version of the libqrtr library that is being compiled against. - * - * Returns: %TRUE if the version of the libqrtr-glib header files - * is the same as or newer than the passed-in version. - * - * Since: 1.28 - */ -#define QRTR_CHECK_VERSION(major,minor,micro) \ - (QRTR_MAJOR_VERSION > (major) || \ - (QRTR_MAJOR_VERSION == (major) && QRTR_MINOR_VERSION > (minor)) || \ - (QRTR_MAJOR_VERSION == (major) && QRTR_MINOR_VERSION == (minor) && QRTR_MICRO_VERSION >= (micro))) - -#endif /* _QRTR_VERSION_H_ */ diff --git a/src/qmi-firmware-update/Makefile.am b/src/qmi-firmware-update/Makefile.am index 04036087..4c196fc8 100644 --- a/src/qmi-firmware-update/Makefile.am +++ b/src/qmi-firmware-update/Makefile.am @@ -10,19 +10,13 @@ libutils_la_SOURCES = \ libutils_la_CPPFLAGS = \ $(WARN_CFLAGS) \ $(GLIB_CFLAGS) \ + $(QRTR_CFLAGS) \ -I$(top_srcdir)/src/libqmi-glib \ -I$(top_srcdir)/src/libqmi-glib/generated \ -I$(top_builddir)/src/libqmi-glib \ -I$(top_builddir)/src/libqmi-glib/generated \ $(NULL) -if QMI_QRTR_SUPPORTED -libutils_la_CPPFLAGS += \ - -I$(top_srcdir)/src/libqrtr-glib \ - -I$(top_builddir)/src/libqrtr-glib \ - $(NULL) -endif - libutils_la_LIBADD = \ $(top_builddir)/src/libqmi-glib/libqmi-glib.la \ $(NULL) @@ -53,6 +47,7 @@ qmi_firmware_update_CPPFLAGS = \ $(GLIB_CFLAGS) \ $(GUDEV_CFLAGS) \ $(MBIM_CFLAGS) \ + $(QRTR_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/src/libqmi-glib \ -I$(top_srcdir)/src/libqmi-glib/generated \ @@ -60,13 +55,6 @@ qmi_firmware_update_CPPFLAGS = \ -I$(top_builddir)/src/libqmi-glib/generated \ $(NULL) -if QMI_QRTR_SUPPORTED -qmi_firmware_update_CPPFLAGS += \ - -I$(top_srcdir)/src/libqrtr-glib \ - -I$(top_builddir)/src/libqrtr-glib \ - $(NULL) -endif - ENUMS = \ $(top_srcdir)/src/qmi-firmware-update/qfu-image.h \ $(top_srcdir)/src/qmi-firmware-update/qfu-qdl-message.h \ diff --git a/src/qmi-firmware-update/test/Makefile.am b/src/qmi-firmware-update/test/Makefile.am index 306e6abc..61f0fa02 100644 --- a/src/qmi-firmware-update/test/Makefile.am +++ b/src/qmi-firmware-update/test/Makefile.am @@ -3,6 +3,7 @@ include $(top_srcdir)/gtester.make AM_CFLAGS = \ $(WARN_CFLAGS) \ $(GLIB_CFLAGS) \ + $(QRTR_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/src/libqmi-glib \ -I$(top_srcdir)/src/libqmi-glib/generated \ @@ -12,13 +13,6 @@ AM_CFLAGS = \ -DLIBQMI_GLIB_COMPILATION \ $(NULL) -if QMI_QRTR_SUPPORTED -AM_CFLAGS += \ - -I$(top_srcdir)/src/libqrtr-glib \ - -I$(top_builddir)/src/libqrtr-glib \ - $(NULL) -endif - AM_LDFLAGS = \ $(WARN_LDFLAGS) \ $(GLIB_LIBS) \ diff --git a/src/qmi-proxy/Makefile.am b/src/qmi-proxy/Makefile.am index b4fc6455..c34a688d 100644 --- a/src/qmi-proxy/Makefile.am +++ b/src/qmi-proxy/Makefile.am @@ -3,6 +3,7 @@ libexec_PROGRAMS = qmi-proxy qmi_proxy_CPPFLAGS = \ $(GLIB_CFLAGS) \ + $(QRTR_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/src/libqmi-glib \ -I$(top_srcdir)/src/libqmi-glib/generated \ @@ -10,17 +11,11 @@ qmi_proxy_CPPFLAGS = \ -I$(top_builddir)/src/libqmi-glib/generated \ $(NULL) -if QMI_QRTR_SUPPORTED -qmi_proxy_CPPFLAGS += \ - -I$(top_srcdir)/src/libqrtr-glib \ - -I$(top_builddir)/src/libqrtr-glib \ - $(NULL) -endif - qmi_proxy_SOURCES = qmi-proxy.c qmi_proxy_LDADD = \ $(GLIB_LIBS) \ + $(QRTR_LIBS) \ $(top_builddir)/src/libqmi-glib/libqmi-glib.la #Install udev rules only if configured with --enable-qmi-username diff --git a/src/qmicli/Makefile.am b/src/qmicli/Makefile.am index c6bef297..1d3d816c 100644 --- a/src/qmicli/Makefile.am +++ b/src/qmicli/Makefile.am @@ -7,6 +7,7 @@ libhelpers_la_CPPFLAGS = \ $(WARN_CFLAGS) \ $(GLIB_CFLAGS) \ $(MBIM_CFLAGS) \ + $(QRTR_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/src/libqmi-glib \ -I$(top_srcdir)/src/libqmi-glib/generated \ @@ -14,13 +15,6 @@ libhelpers_la_CPPFLAGS = \ -I$(top_builddir)/src/libqmi-glib/generated \ $(NULL) -if QMI_QRTR_SUPPORTED -libhelpers_la_CPPFLAGS += \ - -I$(top_srcdir)/src/libqrtr-glib \ - -I$(top_builddir)/src/libqrtr-glib \ - $(NULL) -endif - libhelpers_la_SOURCES = \ qmicli-helpers.c \ qmicli-helpers.h \ @@ -37,6 +31,7 @@ qmicli_CPPFLAGS = \ $(WARN_CFLAGS) \ $(GLIB_CFLAGS) \ $(MBIM_CFLAGS) \ + $(QRTR_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/src/libqmi-glib \ -I$(top_srcdir)/src/libqmi-glib/generated \ @@ -44,13 +39,6 @@ qmicli_CPPFLAGS = \ -I$(top_builddir)/src/libqmi-glib/generated \ $(NULL) -if QMI_QRTR_SUPPORTED -qmicli_CPPFLAGS += \ - -I$(top_srcdir)/src/libqrtr-glib \ - -I$(top_builddir)/src/libqrtr-glib \ - $(NULL) -endif - qmicli_SOURCES = \ qmicli.c \ qmicli.h \ @@ -75,14 +63,9 @@ qmicli_LDADD = \ $(top_builddir)/src/libqmi-glib/libqmi-glib.la \ $(NULL) -if QMI_QRTR_SUPPORTED -qmicli_LDADD += \ - $(top_builddir)/src/libqrtr-glib/libqrtr-glib.la \ - $(NULL) -endif - qmicli_LDFLAGS = \ $(WARN_LDFLAGS) \ + $(QRTR_LIBS) \ $(MBIM_LIBS) \ $(GLIB_LIBS) \ $(NULL) diff --git a/src/qmicli/test/Makefile.am b/src/qmicli/test/Makefile.am index ae35ea5f..33db52fb 100644 --- a/src/qmicli/test/Makefile.am +++ b/src/qmicli/test/Makefile.am @@ -10,19 +10,14 @@ test_helpers_SOURCES = \ test_helpers_CPPFLAGS = \ $(GLIB_CFLAGS) \ + $(QRTR_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/src/qmicli \ -I$(top_srcdir)/src/libqmi-glib \ -I$(top_srcdir)/src/libqmi-glib/generated \ -I$(top_builddir)/src/libqmi-glib \ - -I$(top_builddir)/src/libqmi-glib/generated - -if QMI_QRTR_SUPPORTED -test_helpers_CPPFLAGS += \ - -I$(top_srcdir)/src/libqrtr-glib \ - -I$(top_builddir)/src/libqrtr-glib \ + -I$(top_builddir)/src/libqmi-glib/generated \ $(NULL) -endif test_helpers_LDADD = \ $(GLIB_LIBS) \ |