diff options
author | Guido Günther <agx@sigxcpu.org> | 2014-02-05 08:38:30 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2014-02-05 08:38:30 +0100 |
commit | 13ed135b9ae78c692dc359976eb8b54d0a3629b8 (patch) | |
tree | ae2ea713ad51d73980cf83db1411d6589dac5e8b /libmm-glib | |
parent | 14d771b90f5a7d3887e5e900d1fb4737477ad305 (diff) |
Imported Upstream version 0.7.991upstream/0.7.991
Diffstat (limited to 'libmm-glib')
72 files changed, 28006 insertions, 0 deletions
diff --git a/libmm-glib/Makefile.am b/libmm-glib/Makefile.am new file mode 100644 index 0000000..b189b91 --- /dev/null +++ b/libmm-glib/Makefile.am @@ -0,0 +1,108 @@ +SUBDIRS = generated . tests + +lib_LTLIBRARIES = libmm-glib.la + +libmm_glib_la_SOURCES = \ + libmm-glib.h \ + mm-helpers.h \ + mm-helper-types.h \ + mm-manager.h \ + mm-manager.c \ + mm-object.h \ + mm-object.c \ + mm-modem.h \ + mm-modem.c \ + mm-modem-3gpp.h \ + mm-modem-3gpp.c \ + mm-modem-3gpp-ussd.h \ + mm-modem-3gpp-ussd.c \ + mm-modem-cdma.h \ + mm-modem-cdma.c \ + mm-modem-simple.h \ + mm-modem-simple.c \ + mm-modem-location.h \ + mm-modem-location.c \ + mm-modem-time.h \ + mm-modem-time.c \ + mm-modem-firmware.h \ + mm-modem-firmware.c \ + mm-sim.h \ + mm-sim.c \ + mm-sms.h \ + mm-sms.c \ + mm-modem-messaging.h \ + mm-modem-messaging.c \ + mm-bearer.h \ + mm-bearer.c \ + mm-common-helpers.h \ + mm-common-helpers.c \ + mm-simple-status.h \ + mm-simple-status.c \ + mm-simple-connect-properties.h \ + mm-simple-connect-properties.c \ + mm-bearer-properties.h \ + mm-bearer-properties.c \ + mm-sms-properties.h \ + mm-sms-properties.c \ + mm-bearer-ip-config.h \ + mm-bearer-ip-config.c \ + mm-location-common.h \ + mm-location-3gpp.h \ + mm-location-3gpp.c \ + mm-location-gps-raw.h \ + mm-location-gps-raw.c \ + mm-location-gps-nmea.h \ + mm-location-gps-nmea.c \ + mm-location-cdma-bs.h \ + mm-location-cdma-bs.c \ + mm-unlock-retries.h \ + mm-unlock-retries.c \ + mm-network-timezone.h \ + mm-network-timezone.c \ + mm-firmware-properties.h \ + mm-firmware-properties.c + +libmm_glib_la_CPPFLAGS = \ + $(LIBMM_GLIB_CFLAGS) \ + -I$(top_srcdir) \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ + -I${top_srcdir}/libmm-glib/generated \ + -I${top_builddir}/libmm-glib/generated \ + -DLIBMM_GLIB_COMPILATION + +libmm_glib_la_LIBADD = \ + ${top_builddir}/libmm-glib/generated/libmm-generated.la \ + $(LIBMM_GLIB_LIBS) + +includedir = @includedir@/libmm-glib +include_HEADERS = \ + libmm-glib.h \ + mm-helper-types.h \ + mm-manager.h \ + mm-object.h \ + mm-modem.h \ + mm-modem-3gpp.h \ + mm-modem-3gpp-ussd.h \ + mm-modem-cdma.h \ + mm-modem-messaging.h \ + mm-modem-location.h \ + mm-modem-time.h \ + mm-modem-firmware.h \ + mm-modem-simple.h \ + mm-sim.h \ + mm-sms.h \ + mm-bearer.h \ + mm-simple-status.h \ + mm-simple-connect-properties.h \ + mm-bearer-properties.h \ + mm-sms-properties.h \ + mm-bearer-ip-config.h \ + mm-location-common.h \ + mm-location-3gpp.h \ + mm-location-gps-nmea.h \ + mm-location-gps-raw.h \ + mm-location-cdma-bs.h \ + mm-unlock-retries.h \ + mm-network-timezone.h \ + mm-firmware-properties.h diff --git a/libmm-glib/Makefile.in b/libmm-glib/Makefile.in new file mode 100644 index 0000000..830f3ed --- /dev/null +++ b/libmm-glib/Makefile.in @@ -0,0 +1,1188 @@ +# Makefile.in generated by automake 1.13.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2013 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = libmm-glib +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(top_srcdir)/depcomp $(include_HEADERS) +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \ + $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/gtk-doc.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \ + $(top_srcdir)/m4/intltool.m4 $(top_srcdir)/m4/lib-ld.m4 \ + $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)" +LTLIBRARIES = $(lib_LTLIBRARIES) +am__DEPENDENCIES_1 = +libmm_glib_la_DEPENDENCIES = \ + ${top_builddir}/libmm-glib/generated/libmm-generated.la \ + $(am__DEPENDENCIES_1) +am_libmm_glib_la_OBJECTS = libmm_glib_la-mm-manager.lo \ + libmm_glib_la-mm-object.lo libmm_glib_la-mm-modem.lo \ + libmm_glib_la-mm-modem-3gpp.lo \ + libmm_glib_la-mm-modem-3gpp-ussd.lo \ + libmm_glib_la-mm-modem-cdma.lo \ + libmm_glib_la-mm-modem-simple.lo \ + libmm_glib_la-mm-modem-location.lo \ + libmm_glib_la-mm-modem-time.lo \ + libmm_glib_la-mm-modem-firmware.lo libmm_glib_la-mm-sim.lo \ + libmm_glib_la-mm-sms.lo libmm_glib_la-mm-modem-messaging.lo \ + libmm_glib_la-mm-bearer.lo libmm_glib_la-mm-common-helpers.lo \ + libmm_glib_la-mm-simple-status.lo \ + libmm_glib_la-mm-simple-connect-properties.lo \ + libmm_glib_la-mm-bearer-properties.lo \ + libmm_glib_la-mm-sms-properties.lo \ + libmm_glib_la-mm-bearer-ip-config.lo \ + libmm_glib_la-mm-location-3gpp.lo \ + libmm_glib_la-mm-location-gps-raw.lo \ + libmm_glib_la-mm-location-gps-nmea.lo \ + libmm_glib_la-mm-location-cdma-bs.lo \ + libmm_glib_la-mm-unlock-retries.lo \ + libmm_glib_la-mm-network-timezone.lo \ + libmm_glib_la-mm-firmware-properties.lo +libmm_glib_la_OBJECTS = $(am_libmm_glib_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(libmm_glib_la_SOURCES) +DIST_SOURCES = $(libmm_glib_la_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ + ctags-recursive dvi-recursive html-recursive info-recursive \ + install-data-recursive install-dvi-recursive \ + install-exec-recursive install-html-recursive \ + install-info-recursive install-pdf-recursive \ + install-ps-recursive install-recursive installcheck-recursive \ + installdirs-recursive pdf-recursive ps-recursive \ + tags-recursive uninstall-recursive +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +HEADERS = $(include_HEADERS) +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +am__recursive_targets = \ + $(RECURSIVE_TARGETS) \ + $(RECURSIVE_CLEAN_TARGETS) \ + $(am__extra_recursive_targets) +AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ + distdir +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" +ACLOCAL = @ACLOCAL@ +ALL_LINGUAS = @ALL_LINGUAS@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DBUS_SYS_DIR = @DBUS_SYS_DIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GLIB_MKENUMS = @GLIB_MKENUMS@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GREP = @GREP@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +GUDEV_CFLAGS = @GUDEV_CFLAGS@ +GUDEV_LIBS = @GUDEV_LIBS@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTOBJEXT = @INSTOBJEXT@ +INTLLIBS = @INTLLIBS@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ +INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ +INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ +INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBMM_GLIB_CFLAGS = @LIBMM_GLIB_CFLAGS@ +LIBMM_GLIB_LIBS = @LIBMM_GLIB_LIBS@ +LIBMM_LIBS = @LIBMM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MBIM_CFLAGS = @MBIM_CFLAGS@ +MBIM_LIBS = @MBIM_LIBS@ +MKDIR_P = @MKDIR_P@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MMCLI_CFLAGS = @MMCLI_CFLAGS@ +MMCLI_LIBS = @MMCLI_LIBS@ +MM_CFLAGS = @MM_CFLAGS@ +MM_LIBS = @MM_LIBS@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGFMT_OPTS = @MSGFMT_OPTS@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +POFILES = @POFILES@ +POLKIT_CFLAGS = @POLKIT_CFLAGS@ +POLKIT_LIBS = @POLKIT_LIBS@ +POSUB = @POSUB@ +PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ +PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ +PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +QMI_CFLAGS = @QMI_CFLAGS@ +QMI_LIBS = @QMI_LIBS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SYSTEMD_UNIT_DIR = @SYSTEMD_UNIT_DIR@ +UDEV_BASE_DIR = @UDEV_BASE_DIR@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@/libmm-glib +infodir = @infodir@ +install_sh = @install_sh@ +intltool__v_merge_options_ = @intltool__v_merge_options_@ +intltool__v_merge_options_0 = @intltool__v_merge_options_0@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +SUBDIRS = generated . tests +lib_LTLIBRARIES = libmm-glib.la +libmm_glib_la_SOURCES = \ + libmm-glib.h \ + mm-helpers.h \ + mm-helper-types.h \ + mm-manager.h \ + mm-manager.c \ + mm-object.h \ + mm-object.c \ + mm-modem.h \ + mm-modem.c \ + mm-modem-3gpp.h \ + mm-modem-3gpp.c \ + mm-modem-3gpp-ussd.h \ + mm-modem-3gpp-ussd.c \ + mm-modem-cdma.h \ + mm-modem-cdma.c \ + mm-modem-simple.h \ + mm-modem-simple.c \ + mm-modem-location.h \ + mm-modem-location.c \ + mm-modem-time.h \ + mm-modem-time.c \ + mm-modem-firmware.h \ + mm-modem-firmware.c \ + mm-sim.h \ + mm-sim.c \ + mm-sms.h \ + mm-sms.c \ + mm-modem-messaging.h \ + mm-modem-messaging.c \ + mm-bearer.h \ + mm-bearer.c \ + mm-common-helpers.h \ + mm-common-helpers.c \ + mm-simple-status.h \ + mm-simple-status.c \ + mm-simple-connect-properties.h \ + mm-simple-connect-properties.c \ + mm-bearer-properties.h \ + mm-bearer-properties.c \ + mm-sms-properties.h \ + mm-sms-properties.c \ + mm-bearer-ip-config.h \ + mm-bearer-ip-config.c \ + mm-location-common.h \ + mm-location-3gpp.h \ + mm-location-3gpp.c \ + mm-location-gps-raw.h \ + mm-location-gps-raw.c \ + mm-location-gps-nmea.h \ + mm-location-gps-nmea.c \ + mm-location-cdma-bs.h \ + mm-location-cdma-bs.c \ + mm-unlock-retries.h \ + mm-unlock-retries.c \ + mm-network-timezone.h \ + mm-network-timezone.c \ + mm-firmware-properties.h \ + mm-firmware-properties.c + +libmm_glib_la_CPPFLAGS = \ + $(LIBMM_GLIB_CFLAGS) \ + -I$(top_srcdir) \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ + -I${top_srcdir}/libmm-glib/generated \ + -I${top_builddir}/libmm-glib/generated \ + -DLIBMM_GLIB_COMPILATION + +libmm_glib_la_LIBADD = \ + ${top_builddir}/libmm-glib/generated/libmm-generated.la \ + $(LIBMM_GLIB_LIBS) + +include_HEADERS = \ + libmm-glib.h \ + mm-helper-types.h \ + mm-manager.h \ + mm-object.h \ + mm-modem.h \ + mm-modem-3gpp.h \ + mm-modem-3gpp-ussd.h \ + mm-modem-cdma.h \ + mm-modem-messaging.h \ + mm-modem-location.h \ + mm-modem-time.h \ + mm-modem-firmware.h \ + mm-modem-simple.h \ + mm-sim.h \ + mm-sms.h \ + mm-bearer.h \ + mm-simple-status.h \ + mm-simple-connect-properties.h \ + mm-bearer-properties.h \ + mm-sms-properties.h \ + mm-bearer-ip-config.h \ + mm-location-common.h \ + mm-location-3gpp.h \ + mm-location-gps-nmea.h \ + mm-location-gps-raw.h \ + mm-location-cdma-bs.h \ + mm-unlock-retries.h \ + mm-network-timezone.h \ + mm-firmware-properties.h + +all: all-recursive + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libmm-glib/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu libmm-glib/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +libmm-glib.la: $(libmm_glib_la_OBJECTS) $(libmm_glib_la_DEPENDENCIES) $(EXTRA_libmm_glib_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) -rpath $(libdir) $(libmm_glib_la_OBJECTS) $(libmm_glib_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-bearer-ip-config.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-bearer-properties.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-bearer.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-common-helpers.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-firmware-properties.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-location-3gpp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-location-cdma-bs.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-location-gps-nmea.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-location-gps-raw.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-manager.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-modem-3gpp-ussd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-modem-3gpp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-modem-cdma.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-modem-firmware.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-modem-location.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-modem-messaging.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-modem-simple.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-modem-time.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-modem.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-network-timezone.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-object.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-sim.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-simple-connect-properties.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-simple-status.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-sms-properties.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-sms.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_glib_la-mm-unlock-retries.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +libmm_glib_la-mm-manager.lo: mm-manager.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-manager.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-manager.Tpo -c -o libmm_glib_la-mm-manager.lo `test -f 'mm-manager.c' || echo '$(srcdir)/'`mm-manager.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-manager.Tpo $(DEPDIR)/libmm_glib_la-mm-manager.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-manager.c' object='libmm_glib_la-mm-manager.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-manager.lo `test -f 'mm-manager.c' || echo '$(srcdir)/'`mm-manager.c + +libmm_glib_la-mm-object.lo: mm-object.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-object.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-object.Tpo -c -o libmm_glib_la-mm-object.lo `test -f 'mm-object.c' || echo '$(srcdir)/'`mm-object.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-object.Tpo $(DEPDIR)/libmm_glib_la-mm-object.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-object.c' object='libmm_glib_la-mm-object.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-object.lo `test -f 'mm-object.c' || echo '$(srcdir)/'`mm-object.c + +libmm_glib_la-mm-modem.lo: mm-modem.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-modem.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-modem.Tpo -c -o libmm_glib_la-mm-modem.lo `test -f 'mm-modem.c' || echo '$(srcdir)/'`mm-modem.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-modem.Tpo $(DEPDIR)/libmm_glib_la-mm-modem.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-modem.c' object='libmm_glib_la-mm-modem.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-modem.lo `test -f 'mm-modem.c' || echo '$(srcdir)/'`mm-modem.c + +libmm_glib_la-mm-modem-3gpp.lo: mm-modem-3gpp.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-modem-3gpp.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-modem-3gpp.Tpo -c -o libmm_glib_la-mm-modem-3gpp.lo `test -f 'mm-modem-3gpp.c' || echo '$(srcdir)/'`mm-modem-3gpp.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-modem-3gpp.Tpo $(DEPDIR)/libmm_glib_la-mm-modem-3gpp.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-modem-3gpp.c' object='libmm_glib_la-mm-modem-3gpp.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-modem-3gpp.lo `test -f 'mm-modem-3gpp.c' || echo '$(srcdir)/'`mm-modem-3gpp.c + +libmm_glib_la-mm-modem-3gpp-ussd.lo: mm-modem-3gpp-ussd.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-modem-3gpp-ussd.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-modem-3gpp-ussd.Tpo -c -o libmm_glib_la-mm-modem-3gpp-ussd.lo `test -f 'mm-modem-3gpp-ussd.c' || echo '$(srcdir)/'`mm-modem-3gpp-ussd.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-modem-3gpp-ussd.Tpo $(DEPDIR)/libmm_glib_la-mm-modem-3gpp-ussd.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-modem-3gpp-ussd.c' object='libmm_glib_la-mm-modem-3gpp-ussd.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-modem-3gpp-ussd.lo `test -f 'mm-modem-3gpp-ussd.c' || echo '$(srcdir)/'`mm-modem-3gpp-ussd.c + +libmm_glib_la-mm-modem-cdma.lo: mm-modem-cdma.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-modem-cdma.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-modem-cdma.Tpo -c -o libmm_glib_la-mm-modem-cdma.lo `test -f 'mm-modem-cdma.c' || echo '$(srcdir)/'`mm-modem-cdma.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-modem-cdma.Tpo $(DEPDIR)/libmm_glib_la-mm-modem-cdma.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-modem-cdma.c' object='libmm_glib_la-mm-modem-cdma.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-modem-cdma.lo `test -f 'mm-modem-cdma.c' || echo '$(srcdir)/'`mm-modem-cdma.c + +libmm_glib_la-mm-modem-simple.lo: mm-modem-simple.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-modem-simple.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-modem-simple.Tpo -c -o libmm_glib_la-mm-modem-simple.lo `test -f 'mm-modem-simple.c' || echo '$(srcdir)/'`mm-modem-simple.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-modem-simple.Tpo $(DEPDIR)/libmm_glib_la-mm-modem-simple.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-modem-simple.c' object='libmm_glib_la-mm-modem-simple.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-modem-simple.lo `test -f 'mm-modem-simple.c' || echo '$(srcdir)/'`mm-modem-simple.c + +libmm_glib_la-mm-modem-location.lo: mm-modem-location.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-modem-location.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-modem-location.Tpo -c -o libmm_glib_la-mm-modem-location.lo `test -f 'mm-modem-location.c' || echo '$(srcdir)/'`mm-modem-location.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-modem-location.Tpo $(DEPDIR)/libmm_glib_la-mm-modem-location.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-modem-location.c' object='libmm_glib_la-mm-modem-location.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-modem-location.lo `test -f 'mm-modem-location.c' || echo '$(srcdir)/'`mm-modem-location.c + +libmm_glib_la-mm-modem-time.lo: mm-modem-time.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-modem-time.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-modem-time.Tpo -c -o libmm_glib_la-mm-modem-time.lo `test -f 'mm-modem-time.c' || echo '$(srcdir)/'`mm-modem-time.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-modem-time.Tpo $(DEPDIR)/libmm_glib_la-mm-modem-time.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-modem-time.c' object='libmm_glib_la-mm-modem-time.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-modem-time.lo `test -f 'mm-modem-time.c' || echo '$(srcdir)/'`mm-modem-time.c + +libmm_glib_la-mm-modem-firmware.lo: mm-modem-firmware.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-modem-firmware.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-modem-firmware.Tpo -c -o libmm_glib_la-mm-modem-firmware.lo `test -f 'mm-modem-firmware.c' || echo '$(srcdir)/'`mm-modem-firmware.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-modem-firmware.Tpo $(DEPDIR)/libmm_glib_la-mm-modem-firmware.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-modem-firmware.c' object='libmm_glib_la-mm-modem-firmware.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-modem-firmware.lo `test -f 'mm-modem-firmware.c' || echo '$(srcdir)/'`mm-modem-firmware.c + +libmm_glib_la-mm-sim.lo: mm-sim.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-sim.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-sim.Tpo -c -o libmm_glib_la-mm-sim.lo `test -f 'mm-sim.c' || echo '$(srcdir)/'`mm-sim.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-sim.Tpo $(DEPDIR)/libmm_glib_la-mm-sim.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-sim.c' object='libmm_glib_la-mm-sim.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-sim.lo `test -f 'mm-sim.c' || echo '$(srcdir)/'`mm-sim.c + +libmm_glib_la-mm-sms.lo: mm-sms.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-sms.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-sms.Tpo -c -o libmm_glib_la-mm-sms.lo `test -f 'mm-sms.c' || echo '$(srcdir)/'`mm-sms.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-sms.Tpo $(DEPDIR)/libmm_glib_la-mm-sms.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-sms.c' object='libmm_glib_la-mm-sms.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-sms.lo `test -f 'mm-sms.c' || echo '$(srcdir)/'`mm-sms.c + +libmm_glib_la-mm-modem-messaging.lo: mm-modem-messaging.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-modem-messaging.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-modem-messaging.Tpo -c -o libmm_glib_la-mm-modem-messaging.lo `test -f 'mm-modem-messaging.c' || echo '$(srcdir)/'`mm-modem-messaging.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-modem-messaging.Tpo $(DEPDIR)/libmm_glib_la-mm-modem-messaging.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-modem-messaging.c' object='libmm_glib_la-mm-modem-messaging.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-modem-messaging.lo `test -f 'mm-modem-messaging.c' || echo '$(srcdir)/'`mm-modem-messaging.c + +libmm_glib_la-mm-bearer.lo: mm-bearer.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-bearer.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-bearer.Tpo -c -o libmm_glib_la-mm-bearer.lo `test -f 'mm-bearer.c' || echo '$(srcdir)/'`mm-bearer.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-bearer.Tpo $(DEPDIR)/libmm_glib_la-mm-bearer.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-bearer.c' object='libmm_glib_la-mm-bearer.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-bearer.lo `test -f 'mm-bearer.c' || echo '$(srcdir)/'`mm-bearer.c + +libmm_glib_la-mm-common-helpers.lo: mm-common-helpers.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-common-helpers.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-common-helpers.Tpo -c -o libmm_glib_la-mm-common-helpers.lo `test -f 'mm-common-helpers.c' || echo '$(srcdir)/'`mm-common-helpers.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-common-helpers.Tpo $(DEPDIR)/libmm_glib_la-mm-common-helpers.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-common-helpers.c' object='libmm_glib_la-mm-common-helpers.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-common-helpers.lo `test -f 'mm-common-helpers.c' || echo '$(srcdir)/'`mm-common-helpers.c + +libmm_glib_la-mm-simple-status.lo: mm-simple-status.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-simple-status.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-simple-status.Tpo -c -o libmm_glib_la-mm-simple-status.lo `test -f 'mm-simple-status.c' || echo '$(srcdir)/'`mm-simple-status.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-simple-status.Tpo $(DEPDIR)/libmm_glib_la-mm-simple-status.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-simple-status.c' object='libmm_glib_la-mm-simple-status.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-simple-status.lo `test -f 'mm-simple-status.c' || echo '$(srcdir)/'`mm-simple-status.c + +libmm_glib_la-mm-simple-connect-properties.lo: mm-simple-connect-properties.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-simple-connect-properties.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-simple-connect-properties.Tpo -c -o libmm_glib_la-mm-simple-connect-properties.lo `test -f 'mm-simple-connect-properties.c' || echo '$(srcdir)/'`mm-simple-connect-properties.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-simple-connect-properties.Tpo $(DEPDIR)/libmm_glib_la-mm-simple-connect-properties.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-simple-connect-properties.c' object='libmm_glib_la-mm-simple-connect-properties.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-simple-connect-properties.lo `test -f 'mm-simple-connect-properties.c' || echo '$(srcdir)/'`mm-simple-connect-properties.c + +libmm_glib_la-mm-bearer-properties.lo: mm-bearer-properties.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-bearer-properties.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-bearer-properties.Tpo -c -o libmm_glib_la-mm-bearer-properties.lo `test -f 'mm-bearer-properties.c' || echo '$(srcdir)/'`mm-bearer-properties.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-bearer-properties.Tpo $(DEPDIR)/libmm_glib_la-mm-bearer-properties.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-bearer-properties.c' object='libmm_glib_la-mm-bearer-properties.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-bearer-properties.lo `test -f 'mm-bearer-properties.c' || echo '$(srcdir)/'`mm-bearer-properties.c + +libmm_glib_la-mm-sms-properties.lo: mm-sms-properties.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-sms-properties.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-sms-properties.Tpo -c -o libmm_glib_la-mm-sms-properties.lo `test -f 'mm-sms-properties.c' || echo '$(srcdir)/'`mm-sms-properties.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-sms-properties.Tpo $(DEPDIR)/libmm_glib_la-mm-sms-properties.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-sms-properties.c' object='libmm_glib_la-mm-sms-properties.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-sms-properties.lo `test -f 'mm-sms-properties.c' || echo '$(srcdir)/'`mm-sms-properties.c + +libmm_glib_la-mm-bearer-ip-config.lo: mm-bearer-ip-config.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-bearer-ip-config.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-bearer-ip-config.Tpo -c -o libmm_glib_la-mm-bearer-ip-config.lo `test -f 'mm-bearer-ip-config.c' || echo '$(srcdir)/'`mm-bearer-ip-config.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-bearer-ip-config.Tpo $(DEPDIR)/libmm_glib_la-mm-bearer-ip-config.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-bearer-ip-config.c' object='libmm_glib_la-mm-bearer-ip-config.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-bearer-ip-config.lo `test -f 'mm-bearer-ip-config.c' || echo '$(srcdir)/'`mm-bearer-ip-config.c + +libmm_glib_la-mm-location-3gpp.lo: mm-location-3gpp.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-location-3gpp.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-location-3gpp.Tpo -c -o libmm_glib_la-mm-location-3gpp.lo `test -f 'mm-location-3gpp.c' || echo '$(srcdir)/'`mm-location-3gpp.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-location-3gpp.Tpo $(DEPDIR)/libmm_glib_la-mm-location-3gpp.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-location-3gpp.c' object='libmm_glib_la-mm-location-3gpp.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-location-3gpp.lo `test -f 'mm-location-3gpp.c' || echo '$(srcdir)/'`mm-location-3gpp.c + +libmm_glib_la-mm-location-gps-raw.lo: mm-location-gps-raw.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-location-gps-raw.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-location-gps-raw.Tpo -c -o libmm_glib_la-mm-location-gps-raw.lo `test -f 'mm-location-gps-raw.c' || echo '$(srcdir)/'`mm-location-gps-raw.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-location-gps-raw.Tpo $(DEPDIR)/libmm_glib_la-mm-location-gps-raw.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-location-gps-raw.c' object='libmm_glib_la-mm-location-gps-raw.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-location-gps-raw.lo `test -f 'mm-location-gps-raw.c' || echo '$(srcdir)/'`mm-location-gps-raw.c + +libmm_glib_la-mm-location-gps-nmea.lo: mm-location-gps-nmea.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-location-gps-nmea.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-location-gps-nmea.Tpo -c -o libmm_glib_la-mm-location-gps-nmea.lo `test -f 'mm-location-gps-nmea.c' || echo '$(srcdir)/'`mm-location-gps-nmea.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-location-gps-nmea.Tpo $(DEPDIR)/libmm_glib_la-mm-location-gps-nmea.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-location-gps-nmea.c' object='libmm_glib_la-mm-location-gps-nmea.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-location-gps-nmea.lo `test -f 'mm-location-gps-nmea.c' || echo '$(srcdir)/'`mm-location-gps-nmea.c + +libmm_glib_la-mm-location-cdma-bs.lo: mm-location-cdma-bs.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-location-cdma-bs.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-location-cdma-bs.Tpo -c -o libmm_glib_la-mm-location-cdma-bs.lo `test -f 'mm-location-cdma-bs.c' || echo '$(srcdir)/'`mm-location-cdma-bs.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-location-cdma-bs.Tpo $(DEPDIR)/libmm_glib_la-mm-location-cdma-bs.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-location-cdma-bs.c' object='libmm_glib_la-mm-location-cdma-bs.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-location-cdma-bs.lo `test -f 'mm-location-cdma-bs.c' || echo '$(srcdir)/'`mm-location-cdma-bs.c + +libmm_glib_la-mm-unlock-retries.lo: mm-unlock-retries.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-unlock-retries.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-unlock-retries.Tpo -c -o libmm_glib_la-mm-unlock-retries.lo `test -f 'mm-unlock-retries.c' || echo '$(srcdir)/'`mm-unlock-retries.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-unlock-retries.Tpo $(DEPDIR)/libmm_glib_la-mm-unlock-retries.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-unlock-retries.c' object='libmm_glib_la-mm-unlock-retries.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-unlock-retries.lo `test -f 'mm-unlock-retries.c' || echo '$(srcdir)/'`mm-unlock-retries.c + +libmm_glib_la-mm-network-timezone.lo: mm-network-timezone.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-network-timezone.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-network-timezone.Tpo -c -o libmm_glib_la-mm-network-timezone.lo `test -f 'mm-network-timezone.c' || echo '$(srcdir)/'`mm-network-timezone.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-network-timezone.Tpo $(DEPDIR)/libmm_glib_la-mm-network-timezone.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-network-timezone.c' object='libmm_glib_la-mm-network-timezone.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-network-timezone.lo `test -f 'mm-network-timezone.c' || echo '$(srcdir)/'`mm-network-timezone.c + +libmm_glib_la-mm-firmware-properties.lo: mm-firmware-properties.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_glib_la-mm-firmware-properties.lo -MD -MP -MF $(DEPDIR)/libmm_glib_la-mm-firmware-properties.Tpo -c -o libmm_glib_la-mm-firmware-properties.lo `test -f 'mm-firmware-properties.c' || echo '$(srcdir)/'`mm-firmware-properties.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_glib_la-mm-firmware-properties.Tpo $(DEPDIR)/libmm_glib_la-mm-firmware-properties.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-firmware-properties.c' object='libmm_glib_la-mm-firmware-properties.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_glib_la-mm-firmware-properties.lo `test -f 'mm-firmware-properties.c' || echo '$(srcdir)/'`mm-firmware-properties.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-includeHEADERS: $(include_HEADERS) + @$(NORMAL_INSTALL) + @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ + done + +uninstall-includeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) + +# This directory's subdirectories are mostly independent; you can cd +# into them and run 'make' without going through this Makefile. +# To change the values of 'make' variables: instead of editing Makefiles, +# (1) if the variable is set in 'config.status', edit 'config.status' +# (which will cause the Makefiles to be regenerated when you run 'make'); +# (2) otherwise, pass the desired values on the 'make' command line. +$(am__recursive_targets): + @fail=; \ + if $(am__make_keepgoing); then \ + failcom='fail=yes'; \ + else \ + failcom='exit 1'; \ + fi; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-recursive +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-recursive + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-recursive + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + $(am__make_dryrun) \ + || test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ + mostlyclean-am + +distclean: distclean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +html-am: + +info: info-recursive + +info-am: + +install-data-am: install-includeHEADERS + +install-dvi: install-dvi-recursive + +install-dvi-am: + +install-exec-am: install-libLTLIBRARIES + +install-html: install-html-recursive + +install-html-am: + +install-info: install-info-recursive + +install-info-am: + +install-man: + +install-pdf: install-pdf-recursive + +install-pdf-am: + +install-ps: install-ps-recursive + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES + +.MAKE: $(am__recursive_targets) install-am install-strip + +.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ + check-am clean clean-generic clean-libLTLIBRARIES \ + clean-libtool cscopelist-am ctags ctags-am distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-includeHEADERS install-info \ + install-info-am install-libLTLIBRARIES install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ + uninstall-includeHEADERS uninstall-libLTLIBRARIES + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libmm-glib/generated/Makefile.am b/libmm-glib/generated/Makefile.am new file mode 100644 index 0000000..c0429b1 --- /dev/null +++ b/libmm-glib/generated/Makefile.am @@ -0,0 +1,189 @@ + +noinst_LTLIBRARIES = libmm-generated.la + +GENERATED_H = \ + mm-enums-types.h \ + mm-errors-types.h \ + mm-gdbus-manager.h \ + mm-gdbus-sim.h \ + mm-gdbus-sms.h \ + mm-gdbus-bearer.h \ + mm-gdbus-modem.h + +GENERATED_C = \ + mm-enums-types.c \ + mm-errors-types.c \ + mm-errors-quarks.c \ + mm-gdbus-manager.c \ + mm-gdbus-sim.c \ + mm-gdbus-sms.c \ + mm-gdbus-bearer.c \ + mm-gdbus-modem.c + +GENERATED_DOC = \ + mm-gdbus-doc-org.freedesktop.ModemManager1.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Sim.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Sms.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Bearer.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Messaging.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Location.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Time.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Firmware.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Contacts.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.ModemCdma.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Modem3gpp.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Simple.xml + +BUILT_SOURCES = $(GENERATED_H) $(GENERATED_C) $(GENERATED_DOC) + +# Enum types +mm-enums-types.h: Makefile.am $(top_srcdir)/include/ModemManager-enums.h $(top_srcdir)/build-aux/mm-enums-template.h + $(AM_V_GEN) $(GLIB_MKENUMS) \ + --fhead "#include <ModemManager.h>\n#ifndef __MM_ENUMS_TYPES_H__\n#define __MM_ENUMS_TYPES_H__\n" \ + --template $(top_srcdir)/build-aux/mm-enums-template.h \ + --ftail "#endif /* __MM_ENUMS_TYPES_H__ */\n" \ + $(top_srcdir)/include/ModemManager-enums.h > $@ + +mm-enums-types.c: Makefile.am $(top_srcdir)/include/ModemManager-enums.h $(top_srcdir)/build-aux/mm-enums-template.c mm-enums-types.h + $(AM_V_GEN) $(GLIB_MKENUMS) \ + --fhead "#include \"mm-enums-types.h\"\n" \ + --template $(top_srcdir)/build-aux/mm-enums-template.c \ + $(top_srcdir)/include/ModemManager-enums.h > $@ + +# Error types & quarks +mm-errors-types.h: Makefile.am $(top_srcdir)/include/ModemManager-errors.h $(top_srcdir)/build-aux/mm-errors-template.h + $(AM_V_GEN) $(GLIB_MKENUMS) \ + --fhead "#ifndef __MM_ERRORS_TYPES_H__\n#define __MM_ERRORS_TYPES_H__\n" \ + --template $(top_srcdir)/build-aux/mm-errors-template.h \ + --ftail "#endif /* __MM_ERRORS_TYPES_H__ */\n" \ + $(top_srcdir)/include/ModemManager-errors.h > $@ + +mm-errors-types.c: Makefile.am $(top_srcdir)/include/ModemManager-errors.h $(top_srcdir)/build-aux/mm-errors-template.c mm-errors-types.h + $(AM_V_GEN) $(GLIB_MKENUMS) \ + --fhead "#include <ModemManager.h>\n#include \"mm-errors-types.h\"\n" \ + --template $(top_srcdir)/build-aux/mm-errors-template.c \ + $(top_srcdir)/include/ModemManager-errors.h > $@ + +mm-errors-quarks.c: Makefile.am $(top_srcdir)/include/ModemManager-errors.h $(top_srcdir)/build-aux/mm-errors-quarks-template.c $(top_builddir)/include/ModemManager-names.h mm-errors-types.h + $(AM_V_GEN) $(GLIB_MKENUMS) \ + --fhead "#include <ModemManager.h>\n#include \"mm-errors-types.h\"\n" \ + --template $(top_srcdir)/build-aux/mm-errors-quarks-template.c \ + $(top_srcdir)/include/ModemManager-errors.h > $@ + +# Manager interface +mm_gdbus_manager_generated = \ + mm-gdbus-manager.h \ + mm-gdbus-manager.c \ + mm-gdbus-doc-org.freedesktop.ModemManager1.xml +$(mm_gdbus_manager_generated): $(top_srcdir)/introspection/org.freedesktop.ModemManager1.xml + $(AM_V_GEN) gdbus-codegen \ + --interface-prefix org.freedesktop.ModemManager1. \ + --c-namespace=MmGdbus \ + --generate-docbook mm-gdbus-doc \ + --generate-c-code mm-gdbus-manager \ + $< \ + $(NULL) + +# Modem interfaces +mm_gdbus_modem_generated = \ + mm-gdbus-modem.h \ + mm-gdbus-modem.c \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Messaging.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Location.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Time.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Firmware.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Contacts.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.ModemCdma.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Modem3gpp.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Simple.xml +mm_gdbus_modem_deps = \ + $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.xml \ + $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.Messaging.xml \ + $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.Location.xml \ + $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.Time.xml \ + $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.Firmware.xml \ + $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.Contacts.xml \ + $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.ModemCdma.xml \ + $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.Modem3gpp.xml \ + $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd.xml \ + $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.Simple.xml +$(mm_gdbus_modem_generated): $(mm_gdbus_modem_deps) + $(AM_V_GEN) gdbus-codegen \ + --interface-prefix org.freedesktop.ModemManager1. \ + --c-namespace=MmGdbus \ + --generate-docbook mm-gdbus-doc \ + --generate-c-code mm-gdbus-modem \ + --c-generate-object-manager \ + --annotate "org.freedesktop.ModemManager1.Modem.ModemCdma" org.gtk.GDBus.C.Name ModemCdma \ + --annotate "org.freedesktop.ModemManager1.Modem.Modem3gpp" org.gtk.GDBus.C.Name Modem3gpp \ + --annotate "org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd" org.gtk.GDBus.C.Name Modem3gppUssd \ + $^ \ + $(NULL) + +# SIM interface +mm_gdbus_sim_generated = \ + mm-gdbus-sim.h \ + mm-gdbus-sim.c \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Sim.xml +$(mm_gdbus_sim_generated): $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Sim.xml + $(AM_V_GEN) gdbus-codegen \ + --interface-prefix org.freedesktop.ModemManager1. \ + --c-namespace=MmGdbus \ + --generate-docbook mm-gdbus-doc \ + --generate-c-code mm-gdbus-sim \ + $< \ + $(NULL) + +# Bearer interface +mm_gdbus_bearer_generated = \ + mm-gdbus-bearer.h \ + mm-gdbus-bearer.c \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Bearer.xml +$(mm_gdbus_bearer_generated): $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Bearer.xml + $(AM_V_GEN) gdbus-codegen \ + --interface-prefix org.freedesktop.ModemManager1. \ + --c-namespace=MmGdbus \ + --generate-docbook mm-gdbus-doc \ + --generate-c-code mm-gdbus-bearer \ + $< \ + $(NULL) + +# SMS interface +mm_gdbus_sms_generated = \ + mm-gdbus-sms.h \ + mm-gdbus-sms.c \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Sms.xml +$(mm_gdbus_sms_generated): $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Sms.xml + $(AM_V_GEN) gdbus-codegen \ + --interface-prefix org.freedesktop.ModemManager1. \ + --c-namespace=MmGdbus \ + --generate-docbook mm-gdbus-doc \ + --generate-c-code mm-gdbus-sms \ + --annotate "org.freedesktop.ModemManager1.Sms:Data" org.gtk.GDBus.C.ForceGVariant True \ + $< \ + $(NULL) + +nodist_libmm_generated_la_SOURCES = \ + $(GENERATED_H) \ + $(GENERATED_C) + +libmm_generated_la_CPPFLAGS = \ + $(LIBMM_GLIB_CFLAGS) \ + -I$(top_srcdir) \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ + -Wno-unused-function \ + -Wno-float-equal \ + -Wno-shadow + +libmm_generated_la_LIBADD = \ + $(LIBMM_GLIB_LIBS) + +includedir = @includedir@/libmm-glib +include_HEADERS = $(GENERATED_H) + +CLEANFILES = $(GENERATED_H) $(GENERATED_C) $(GENERATED_DOC) diff --git a/libmm-glib/generated/Makefile.in b/libmm-glib/generated/Makefile.in new file mode 100644 index 0000000..66ff5f6 --- /dev/null +++ b/libmm-glib/generated/Makefile.in @@ -0,0 +1,970 @@ +# Makefile.in generated by automake 1.13.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2013 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = libmm-glib/generated +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(top_srcdir)/depcomp $(include_HEADERS) +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \ + $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/gtk-doc.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \ + $(top_srcdir)/m4/intltool.m4 $(top_srcdir)/m4/lib-ld.m4 \ + $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +am__DEPENDENCIES_1 = +libmm_generated_la_DEPENDENCIES = $(am__DEPENDENCIES_1) +am__objects_1 = +am__objects_2 = libmm_generated_la-mm-enums-types.lo \ + libmm_generated_la-mm-errors-types.lo \ + libmm_generated_la-mm-errors-quarks.lo \ + libmm_generated_la-mm-gdbus-manager.lo \ + libmm_generated_la-mm-gdbus-sim.lo \ + libmm_generated_la-mm-gdbus-sms.lo \ + libmm_generated_la-mm-gdbus-bearer.lo \ + libmm_generated_la-mm-gdbus-modem.lo +nodist_libmm_generated_la_OBJECTS = $(am__objects_1) $(am__objects_2) +libmm_generated_la_OBJECTS = $(nodist_libmm_generated_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(nodist_libmm_generated_la_SOURCES) +DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(includedir)" +HEADERS = $(include_HEADERS) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALL_LINGUAS = @ALL_LINGUAS@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DBUS_SYS_DIR = @DBUS_SYS_DIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GLIB_MKENUMS = @GLIB_MKENUMS@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GREP = @GREP@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +GUDEV_CFLAGS = @GUDEV_CFLAGS@ +GUDEV_LIBS = @GUDEV_LIBS@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTOBJEXT = @INSTOBJEXT@ +INTLLIBS = @INTLLIBS@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ +INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ +INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ +INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBMM_GLIB_CFLAGS = @LIBMM_GLIB_CFLAGS@ +LIBMM_GLIB_LIBS = @LIBMM_GLIB_LIBS@ +LIBMM_LIBS = @LIBMM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MBIM_CFLAGS = @MBIM_CFLAGS@ +MBIM_LIBS = @MBIM_LIBS@ +MKDIR_P = @MKDIR_P@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MMCLI_CFLAGS = @MMCLI_CFLAGS@ +MMCLI_LIBS = @MMCLI_LIBS@ +MM_CFLAGS = @MM_CFLAGS@ +MM_LIBS = @MM_LIBS@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGFMT_OPTS = @MSGFMT_OPTS@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +POFILES = @POFILES@ +POLKIT_CFLAGS = @POLKIT_CFLAGS@ +POLKIT_LIBS = @POLKIT_LIBS@ +POSUB = @POSUB@ +PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ +PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ +PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +QMI_CFLAGS = @QMI_CFLAGS@ +QMI_LIBS = @QMI_LIBS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SYSTEMD_UNIT_DIR = @SYSTEMD_UNIT_DIR@ +UDEV_BASE_DIR = @UDEV_BASE_DIR@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@/libmm-glib +infodir = @infodir@ +install_sh = @install_sh@ +intltool__v_merge_options_ = @intltool__v_merge_options_@ +intltool__v_merge_options_0 = @intltool__v_merge_options_0@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +noinst_LTLIBRARIES = libmm-generated.la +GENERATED_H = \ + mm-enums-types.h \ + mm-errors-types.h \ + mm-gdbus-manager.h \ + mm-gdbus-sim.h \ + mm-gdbus-sms.h \ + mm-gdbus-bearer.h \ + mm-gdbus-modem.h + +GENERATED_C = \ + mm-enums-types.c \ + mm-errors-types.c \ + mm-errors-quarks.c \ + mm-gdbus-manager.c \ + mm-gdbus-sim.c \ + mm-gdbus-sms.c \ + mm-gdbus-bearer.c \ + mm-gdbus-modem.c + +GENERATED_DOC = \ + mm-gdbus-doc-org.freedesktop.ModemManager1.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Sim.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Sms.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Bearer.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Messaging.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Location.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Time.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Firmware.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Contacts.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.ModemCdma.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Modem3gpp.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Simple.xml + +BUILT_SOURCES = $(GENERATED_H) $(GENERATED_C) $(GENERATED_DOC) + +# Manager interface +mm_gdbus_manager_generated = \ + mm-gdbus-manager.h \ + mm-gdbus-manager.c \ + mm-gdbus-doc-org.freedesktop.ModemManager1.xml + + +# Modem interfaces +mm_gdbus_modem_generated = \ + mm-gdbus-modem.h \ + mm-gdbus-modem.c \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Messaging.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Location.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Time.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Firmware.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Contacts.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.ModemCdma.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Modem3gpp.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd.xml \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Simple.xml + +mm_gdbus_modem_deps = \ + $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.xml \ + $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.Messaging.xml \ + $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.Location.xml \ + $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.Time.xml \ + $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.Firmware.xml \ + $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.Contacts.xml \ + $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.ModemCdma.xml \ + $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.Modem3gpp.xml \ + $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd.xml \ + $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.Simple.xml + + +# SIM interface +mm_gdbus_sim_generated = \ + mm-gdbus-sim.h \ + mm-gdbus-sim.c \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Sim.xml + + +# Bearer interface +mm_gdbus_bearer_generated = \ + mm-gdbus-bearer.h \ + mm-gdbus-bearer.c \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Bearer.xml + + +# SMS interface +mm_gdbus_sms_generated = \ + mm-gdbus-sms.h \ + mm-gdbus-sms.c \ + mm-gdbus-doc-org.freedesktop.ModemManager1.Sms.xml + +nodist_libmm_generated_la_SOURCES = \ + $(GENERATED_H) \ + $(GENERATED_C) + +libmm_generated_la_CPPFLAGS = \ + $(LIBMM_GLIB_CFLAGS) \ + -I$(top_srcdir) \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ + -Wno-unused-function \ + -Wno-float-equal \ + -Wno-shadow + +libmm_generated_la_LIBADD = \ + $(LIBMM_GLIB_LIBS) + +include_HEADERS = $(GENERATED_H) +CLEANFILES = $(GENERATED_H) $(GENERATED_C) $(GENERATED_DOC) +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libmm-glib/generated/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu libmm-glib/generated/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +libmm-generated.la: $(libmm_generated_la_OBJECTS) $(libmm_generated_la_DEPENDENCIES) $(EXTRA_libmm_generated_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) $(libmm_generated_la_OBJECTS) $(libmm_generated_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_generated_la-mm-enums-types.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_generated_la-mm-errors-quarks.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_generated_la-mm-errors-types.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_generated_la-mm-gdbus-bearer.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_generated_la-mm-gdbus-manager.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_generated_la-mm-gdbus-modem.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_generated_la-mm-gdbus-sim.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmm_generated_la-mm-gdbus-sms.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +libmm_generated_la-mm-enums-types.lo: mm-enums-types.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_generated_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_generated_la-mm-enums-types.lo -MD -MP -MF $(DEPDIR)/libmm_generated_la-mm-enums-types.Tpo -c -o libmm_generated_la-mm-enums-types.lo `test -f 'mm-enums-types.c' || echo '$(srcdir)/'`mm-enums-types.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_generated_la-mm-enums-types.Tpo $(DEPDIR)/libmm_generated_la-mm-enums-types.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-enums-types.c' object='libmm_generated_la-mm-enums-types.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_generated_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_generated_la-mm-enums-types.lo `test -f 'mm-enums-types.c' || echo '$(srcdir)/'`mm-enums-types.c + +libmm_generated_la-mm-errors-types.lo: mm-errors-types.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_generated_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_generated_la-mm-errors-types.lo -MD -MP -MF $(DEPDIR)/libmm_generated_la-mm-errors-types.Tpo -c -o libmm_generated_la-mm-errors-types.lo `test -f 'mm-errors-types.c' || echo '$(srcdir)/'`mm-errors-types.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_generated_la-mm-errors-types.Tpo $(DEPDIR)/libmm_generated_la-mm-errors-types.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-errors-types.c' object='libmm_generated_la-mm-errors-types.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_generated_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_generated_la-mm-errors-types.lo `test -f 'mm-errors-types.c' || echo '$(srcdir)/'`mm-errors-types.c + +libmm_generated_la-mm-errors-quarks.lo: mm-errors-quarks.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_generated_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_generated_la-mm-errors-quarks.lo -MD -MP -MF $(DEPDIR)/libmm_generated_la-mm-errors-quarks.Tpo -c -o libmm_generated_la-mm-errors-quarks.lo `test -f 'mm-errors-quarks.c' || echo '$(srcdir)/'`mm-errors-quarks.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_generated_la-mm-errors-quarks.Tpo $(DEPDIR)/libmm_generated_la-mm-errors-quarks.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-errors-quarks.c' object='libmm_generated_la-mm-errors-quarks.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_generated_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_generated_la-mm-errors-quarks.lo `test -f 'mm-errors-quarks.c' || echo '$(srcdir)/'`mm-errors-quarks.c + +libmm_generated_la-mm-gdbus-manager.lo: mm-gdbus-manager.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_generated_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_generated_la-mm-gdbus-manager.lo -MD -MP -MF $(DEPDIR)/libmm_generated_la-mm-gdbus-manager.Tpo -c -o libmm_generated_la-mm-gdbus-manager.lo `test -f 'mm-gdbus-manager.c' || echo '$(srcdir)/'`mm-gdbus-manager.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_generated_la-mm-gdbus-manager.Tpo $(DEPDIR)/libmm_generated_la-mm-gdbus-manager.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-gdbus-manager.c' object='libmm_generated_la-mm-gdbus-manager.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_generated_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_generated_la-mm-gdbus-manager.lo `test -f 'mm-gdbus-manager.c' || echo '$(srcdir)/'`mm-gdbus-manager.c + +libmm_generated_la-mm-gdbus-sim.lo: mm-gdbus-sim.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_generated_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_generated_la-mm-gdbus-sim.lo -MD -MP -MF $(DEPDIR)/libmm_generated_la-mm-gdbus-sim.Tpo -c -o libmm_generated_la-mm-gdbus-sim.lo `test -f 'mm-gdbus-sim.c' || echo '$(srcdir)/'`mm-gdbus-sim.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_generated_la-mm-gdbus-sim.Tpo $(DEPDIR)/libmm_generated_la-mm-gdbus-sim.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-gdbus-sim.c' object='libmm_generated_la-mm-gdbus-sim.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_generated_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_generated_la-mm-gdbus-sim.lo `test -f 'mm-gdbus-sim.c' || echo '$(srcdir)/'`mm-gdbus-sim.c + +libmm_generated_la-mm-gdbus-sms.lo: mm-gdbus-sms.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_generated_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_generated_la-mm-gdbus-sms.lo -MD -MP -MF $(DEPDIR)/libmm_generated_la-mm-gdbus-sms.Tpo -c -o libmm_generated_la-mm-gdbus-sms.lo `test -f 'mm-gdbus-sms.c' || echo '$(srcdir)/'`mm-gdbus-sms.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_generated_la-mm-gdbus-sms.Tpo $(DEPDIR)/libmm_generated_la-mm-gdbus-sms.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-gdbus-sms.c' object='libmm_generated_la-mm-gdbus-sms.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_generated_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_generated_la-mm-gdbus-sms.lo `test -f 'mm-gdbus-sms.c' || echo '$(srcdir)/'`mm-gdbus-sms.c + +libmm_generated_la-mm-gdbus-bearer.lo: mm-gdbus-bearer.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_generated_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_generated_la-mm-gdbus-bearer.lo -MD -MP -MF $(DEPDIR)/libmm_generated_la-mm-gdbus-bearer.Tpo -c -o libmm_generated_la-mm-gdbus-bearer.lo `test -f 'mm-gdbus-bearer.c' || echo '$(srcdir)/'`mm-gdbus-bearer.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_generated_la-mm-gdbus-bearer.Tpo $(DEPDIR)/libmm_generated_la-mm-gdbus-bearer.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-gdbus-bearer.c' object='libmm_generated_la-mm-gdbus-bearer.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_generated_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_generated_la-mm-gdbus-bearer.lo `test -f 'mm-gdbus-bearer.c' || echo '$(srcdir)/'`mm-gdbus-bearer.c + +libmm_generated_la-mm-gdbus-modem.lo: mm-gdbus-modem.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_generated_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmm_generated_la-mm-gdbus-modem.lo -MD -MP -MF $(DEPDIR)/libmm_generated_la-mm-gdbus-modem.Tpo -c -o libmm_generated_la-mm-gdbus-modem.lo `test -f 'mm-gdbus-modem.c' || echo '$(srcdir)/'`mm-gdbus-modem.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmm_generated_la-mm-gdbus-modem.Tpo $(DEPDIR)/libmm_generated_la-mm-gdbus-modem.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mm-gdbus-modem.c' object='libmm_generated_la-mm-gdbus-modem.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmm_generated_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmm_generated_la-mm-gdbus-modem.lo `test -f 'mm-gdbus-modem.c' || echo '$(srcdir)/'`mm-gdbus-modem.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-includeHEADERS: $(include_HEADERS) + @$(NORMAL_INSTALL) + @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ + done + +uninstall-includeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(includedir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-includeHEADERS + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-includeHEADERS + +.MAKE: all check install install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \ + ctags-am distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am \ + install-includeHEADERS install-info install-info-am \ + install-man install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ + uninstall-am uninstall-includeHEADERS + + +# Enum types +mm-enums-types.h: Makefile.am $(top_srcdir)/include/ModemManager-enums.h $(top_srcdir)/build-aux/mm-enums-template.h + $(AM_V_GEN) $(GLIB_MKENUMS) \ + --fhead "#include <ModemManager.h>\n#ifndef __MM_ENUMS_TYPES_H__\n#define __MM_ENUMS_TYPES_H__\n" \ + --template $(top_srcdir)/build-aux/mm-enums-template.h \ + --ftail "#endif /* __MM_ENUMS_TYPES_H__ */\n" \ + $(top_srcdir)/include/ModemManager-enums.h > $@ + +mm-enums-types.c: Makefile.am $(top_srcdir)/include/ModemManager-enums.h $(top_srcdir)/build-aux/mm-enums-template.c mm-enums-types.h + $(AM_V_GEN) $(GLIB_MKENUMS) \ + --fhead "#include \"mm-enums-types.h\"\n" \ + --template $(top_srcdir)/build-aux/mm-enums-template.c \ + $(top_srcdir)/include/ModemManager-enums.h > $@ + +# Error types & quarks +mm-errors-types.h: Makefile.am $(top_srcdir)/include/ModemManager-errors.h $(top_srcdir)/build-aux/mm-errors-template.h + $(AM_V_GEN) $(GLIB_MKENUMS) \ + --fhead "#ifndef __MM_ERRORS_TYPES_H__\n#define __MM_ERRORS_TYPES_H__\n" \ + --template $(top_srcdir)/build-aux/mm-errors-template.h \ + --ftail "#endif /* __MM_ERRORS_TYPES_H__ */\n" \ + $(top_srcdir)/include/ModemManager-errors.h > $@ + +mm-errors-types.c: Makefile.am $(top_srcdir)/include/ModemManager-errors.h $(top_srcdir)/build-aux/mm-errors-template.c mm-errors-types.h + $(AM_V_GEN) $(GLIB_MKENUMS) \ + --fhead "#include <ModemManager.h>\n#include \"mm-errors-types.h\"\n" \ + --template $(top_srcdir)/build-aux/mm-errors-template.c \ + $(top_srcdir)/include/ModemManager-errors.h > $@ + +mm-errors-quarks.c: Makefile.am $(top_srcdir)/include/ModemManager-errors.h $(top_srcdir)/build-aux/mm-errors-quarks-template.c $(top_builddir)/include/ModemManager-names.h mm-errors-types.h + $(AM_V_GEN) $(GLIB_MKENUMS) \ + --fhead "#include <ModemManager.h>\n#include \"mm-errors-types.h\"\n" \ + --template $(top_srcdir)/build-aux/mm-errors-quarks-template.c \ + $(top_srcdir)/include/ModemManager-errors.h > $@ +$(mm_gdbus_manager_generated): $(top_srcdir)/introspection/org.freedesktop.ModemManager1.xml + $(AM_V_GEN) gdbus-codegen \ + --interface-prefix org.freedesktop.ModemManager1. \ + --c-namespace=MmGdbus \ + --generate-docbook mm-gdbus-doc \ + --generate-c-code mm-gdbus-manager \ + $< \ + $(NULL) +$(mm_gdbus_modem_generated): $(mm_gdbus_modem_deps) + $(AM_V_GEN) gdbus-codegen \ + --interface-prefix org.freedesktop.ModemManager1. \ + --c-namespace=MmGdbus \ + --generate-docbook mm-gdbus-doc \ + --generate-c-code mm-gdbus-modem \ + --c-generate-object-manager \ + --annotate "org.freedesktop.ModemManager1.Modem.ModemCdma" org.gtk.GDBus.C.Name ModemCdma \ + --annotate "org.freedesktop.ModemManager1.Modem.Modem3gpp" org.gtk.GDBus.C.Name Modem3gpp \ + --annotate "org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd" org.gtk.GDBus.C.Name Modem3gppUssd \ + $^ \ + $(NULL) +$(mm_gdbus_sim_generated): $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Sim.xml + $(AM_V_GEN) gdbus-codegen \ + --interface-prefix org.freedesktop.ModemManager1. \ + --c-namespace=MmGdbus \ + --generate-docbook mm-gdbus-doc \ + --generate-c-code mm-gdbus-sim \ + $< \ + $(NULL) +$(mm_gdbus_bearer_generated): $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Bearer.xml + $(AM_V_GEN) gdbus-codegen \ + --interface-prefix org.freedesktop.ModemManager1. \ + --c-namespace=MmGdbus \ + --generate-docbook mm-gdbus-doc \ + --generate-c-code mm-gdbus-bearer \ + $< \ + $(NULL) +$(mm_gdbus_sms_generated): $(top_srcdir)/introspection/org.freedesktop.ModemManager1.Sms.xml + $(AM_V_GEN) gdbus-codegen \ + --interface-prefix org.freedesktop.ModemManager1. \ + --c-namespace=MmGdbus \ + --generate-docbook mm-gdbus-doc \ + --generate-c-code mm-gdbus-sms \ + --annotate "org.freedesktop.ModemManager1.Sms:Data" org.gtk.GDBus.C.ForceGVariant True \ + $< \ + $(NULL) + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libmm-glib/generated/mm-enums-types.h b/libmm-glib/generated/mm-enums-types.h new file mode 100644 index 0000000..c95b8e7 --- /dev/null +++ b/libmm-glib/generated/mm-enums-types.h @@ -0,0 +1,450 @@ + +/* Generated data (by glib-mkenums) */ + +#include <ModemManager.h> +#ifndef __MM_ENUMS_TYPES_H__ +#define __MM_ENUMS_TYPES_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS + +/* enumerations from "../../include/ModemManager-enums.h" */ +GType mm_modem_capability_get_type (void) G_GNUC_CONST; +#define MM_TYPE_MODEM_CAPABILITY (mm_modem_capability_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_FLAGS__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_modem_capability_get_string (MMModemCapability val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_modem_capability_build_string_from_mask (MMModemCapability mask); +#endif + +GType mm_modem_lock_get_type (void) G_GNUC_CONST; +#define MM_TYPE_MODEM_LOCK (mm_modem_lock_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_ENUM__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_modem_lock_get_string (MMModemLock val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_modem_lock_build_string_from_mask (MMModemLock mask); +#endif + +GType mm_modem_state_get_type (void) G_GNUC_CONST; +#define MM_TYPE_MODEM_STATE (mm_modem_state_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_ENUM__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_modem_state_get_string (MMModemState val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_modem_state_build_string_from_mask (MMModemState mask); +#endif + +GType mm_modem_state_failed_reason_get_type (void) G_GNUC_CONST; +#define MM_TYPE_MODEM_STATE_FAILED_REASON (mm_modem_state_failed_reason_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_ENUM__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_modem_state_failed_reason_get_string (MMModemStateFailedReason val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_modem_state_failed_reason_build_string_from_mask (MMModemStateFailedReason mask); +#endif + +GType mm_modem_power_state_get_type (void) G_GNUC_CONST; +#define MM_TYPE_MODEM_POWER_STATE (mm_modem_power_state_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_ENUM__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_modem_power_state_get_string (MMModemPowerState val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_modem_power_state_build_string_from_mask (MMModemPowerState mask); +#endif + +GType mm_modem_state_change_reason_get_type (void) G_GNUC_CONST; +#define MM_TYPE_MODEM_STATE_CHANGE_REASON (mm_modem_state_change_reason_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_ENUM__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_modem_state_change_reason_get_string (MMModemStateChangeReason val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_modem_state_change_reason_build_string_from_mask (MMModemStateChangeReason mask); +#endif + +GType mm_modem_access_technology_get_type (void) G_GNUC_CONST; +#define MM_TYPE_MODEM_ACCESS_TECHNOLOGY (mm_modem_access_technology_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_FLAGS__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_modem_access_technology_get_string (MMModemAccessTechnology val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_modem_access_technology_build_string_from_mask (MMModemAccessTechnology mask); +#endif + +GType mm_modem_mode_get_type (void) G_GNUC_CONST; +#define MM_TYPE_MODEM_MODE (mm_modem_mode_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_FLAGS__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_modem_mode_get_string (MMModemMode val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_modem_mode_build_string_from_mask (MMModemMode mask); +#endif + +GType mm_modem_band_get_type (void) G_GNUC_CONST; +#define MM_TYPE_MODEM_BAND (mm_modem_band_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_ENUM__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_modem_band_get_string (MMModemBand val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_modem_band_build_string_from_mask (MMModemBand mask); +#endif + +GType mm_sms_pdu_type_get_type (void) G_GNUC_CONST; +#define MM_TYPE_SMS_PDU_TYPE (mm_sms_pdu_type_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_ENUM__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_sms_pdu_type_get_string (MMSmsPduType val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_sms_pdu_type_build_string_from_mask (MMSmsPduType mask); +#endif + +GType mm_sms_state_get_type (void) G_GNUC_CONST; +#define MM_TYPE_SMS_STATE (mm_sms_state_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_ENUM__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_sms_state_get_string (MMSmsState val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_sms_state_build_string_from_mask (MMSmsState mask); +#endif + +GType mm_sms_delivery_state_get_type (void) G_GNUC_CONST; +#define MM_TYPE_SMS_DELIVERY_STATE (mm_sms_delivery_state_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_ENUM__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_sms_delivery_state_get_string (MMSmsDeliveryState val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_sms_delivery_state_build_string_from_mask (MMSmsDeliveryState mask); +#endif + +GType mm_sms_storage_get_type (void) G_GNUC_CONST; +#define MM_TYPE_SMS_STORAGE (mm_sms_storage_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_ENUM__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_sms_storage_get_string (MMSmsStorage val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_sms_storage_build_string_from_mask (MMSmsStorage mask); +#endif + +GType mm_sms_validity_type_get_type (void) G_GNUC_CONST; +#define MM_TYPE_SMS_VALIDITY_TYPE (mm_sms_validity_type_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_ENUM__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_sms_validity_type_get_string (MMSmsValidityType val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_sms_validity_type_build_string_from_mask (MMSmsValidityType mask); +#endif + +GType mm_modem_location_source_get_type (void) G_GNUC_CONST; +#define MM_TYPE_MODEM_LOCATION_SOURCE (mm_modem_location_source_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_FLAGS__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_modem_location_source_get_string (MMModemLocationSource val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_modem_location_source_build_string_from_mask (MMModemLocationSource mask); +#endif + +GType mm_modem_contacts_storage_get_type (void) G_GNUC_CONST; +#define MM_TYPE_MODEM_CONTACTS_STORAGE (mm_modem_contacts_storage_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_ENUM__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_modem_contacts_storage_get_string (MMModemContactsStorage val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_modem_contacts_storage_build_string_from_mask (MMModemContactsStorage mask); +#endif + +GType mm_bearer_ip_method_get_type (void) G_GNUC_CONST; +#define MM_TYPE_BEARER_IP_METHOD (mm_bearer_ip_method_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_ENUM__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_bearer_ip_method_get_string (MMBearerIpMethod val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_bearer_ip_method_build_string_from_mask (MMBearerIpMethod mask); +#endif + +GType mm_bearer_ip_family_get_type (void) G_GNUC_CONST; +#define MM_TYPE_BEARER_IP_FAMILY (mm_bearer_ip_family_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_FLAGS__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_bearer_ip_family_get_string (MMBearerIpFamily val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_bearer_ip_family_build_string_from_mask (MMBearerIpFamily mask); +#endif + +GType mm_bearer_allowed_auth_get_type (void) G_GNUC_CONST; +#define MM_TYPE_BEARER_ALLOWED_AUTH (mm_bearer_allowed_auth_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_FLAGS__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_bearer_allowed_auth_get_string (MMBearerAllowedAuth val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_bearer_allowed_auth_build_string_from_mask (MMBearerAllowedAuth mask); +#endif + +GType mm_modem_cdma_registration_state_get_type (void) G_GNUC_CONST; +#define MM_TYPE_MODEM_CDMA_REGISTRATION_STATE (mm_modem_cdma_registration_state_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_ENUM__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_modem_cdma_registration_state_get_string (MMModemCdmaRegistrationState val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_modem_cdma_registration_state_build_string_from_mask (MMModemCdmaRegistrationState mask); +#endif + +GType mm_modem_cdma_activation_state_get_type (void) G_GNUC_CONST; +#define MM_TYPE_MODEM_CDMA_ACTIVATION_STATE (mm_modem_cdma_activation_state_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_ENUM__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_modem_cdma_activation_state_get_string (MMModemCdmaActivationState val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_modem_cdma_activation_state_build_string_from_mask (MMModemCdmaActivationState mask); +#endif + +GType mm_modem_cdma_rm_protocol_get_type (void) G_GNUC_CONST; +#define MM_TYPE_MODEM_CDMA_RM_PROTOCOL (mm_modem_cdma_rm_protocol_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_ENUM__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_modem_cdma_rm_protocol_get_string (MMModemCdmaRmProtocol val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_modem_cdma_rm_protocol_build_string_from_mask (MMModemCdmaRmProtocol mask); +#endif + +GType mm_modem_3gpp_registration_state_get_type (void) G_GNUC_CONST; +#define MM_TYPE_MODEM_3GPP_REGISTRATION_STATE (mm_modem_3gpp_registration_state_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_ENUM__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_modem_3gpp_registration_state_get_string (MMModem3gppRegistrationState val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_modem_3gpp_registration_state_build_string_from_mask (MMModem3gppRegistrationState mask); +#endif + +GType mm_modem_3gpp_facility_get_type (void) G_GNUC_CONST; +#define MM_TYPE_MODEM_3GPP_FACILITY (mm_modem_3gpp_facility_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_FLAGS__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_modem_3gpp_facility_get_string (MMModem3gppFacility val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_modem_3gpp_facility_build_string_from_mask (MMModem3gppFacility mask); +#endif + +GType mm_modem_3gpp_network_availability_get_type (void) G_GNUC_CONST; +#define MM_TYPE_MODEM_3GPP_NETWORK_AVAILABILITY (mm_modem_3gpp_network_availability_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_ENUM__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_modem_3gpp_network_availability_get_string (MMModem3gppNetworkAvailability val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_modem_3gpp_network_availability_build_string_from_mask (MMModem3gppNetworkAvailability mask); +#endif + +GType mm_modem_3gpp_ussd_session_state_get_type (void) G_GNUC_CONST; +#define MM_TYPE_MODEM_3GPP_USSD_SESSION_STATE (mm_modem_3gpp_ussd_session_state_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_ENUM__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_modem_3gpp_ussd_session_state_get_string (MMModem3gppUssdSessionState val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_modem_3gpp_ussd_session_state_build_string_from_mask (MMModem3gppUssdSessionState mask); +#endif + +GType mm_firmware_image_type_get_type (void) G_GNUC_CONST; +#define MM_TYPE_FIRMWARE_IMAGE_TYPE (mm_firmware_image_type_get_type ()) + +/* Define type-specific symbols */ +#undef __MM_IS_ENUM__ +#undef __MM_IS_FLAGS__ +#define __MM_IS_ENUM__ + +#if defined __MM_IS_ENUM__ +const gchar *mm_firmware_image_type_get_string (MMFirmwareImageType val); +#endif + +#if defined __MM_IS_FLAGS__ +gchar *mm_firmware_image_type_build_string_from_mask (MMFirmwareImageType mask); +#endif + +G_END_DECLS + +#endif /* __MM_ENUMS_TYPES_H__ */ + +/* Generated data ends here */ + diff --git a/libmm-glib/generated/mm-errors-types.h b/libmm-glib/generated/mm-errors-types.h new file mode 100644 index 0000000..431a18c --- /dev/null +++ b/libmm-glib/generated/mm-errors-types.h @@ -0,0 +1,41 @@ + +/* Generated data (by glib-mkenums) */ + +#ifndef __MM_ERRORS_TYPES_H__ +#define __MM_ERRORS_TYPES_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS + +/* enumerations from "../../include/ModemManager-errors.h" */ +GQuark mm_core_error_quark (void); /* implemented in mm-errors-quarks.c */ +GType mm_core_error_get_type (void) G_GNUC_CONST; +#define MM_CORE_ERROR (mm_core_error_quark ()) +#define MM_TYPE_CORE_ERROR (mm_core_error_get_type ()) +GQuark mm_mobile_equipment_error_quark (void); /* implemented in mm-errors-quarks.c */ +GType mm_mobile_equipment_error_get_type (void) G_GNUC_CONST; +#define MM_MOBILE_EQUIPMENT_ERROR (mm_mobile_equipment_error_quark ()) +#define MM_TYPE_MOBILE_EQUIPMENT_ERROR (mm_mobile_equipment_error_get_type ()) +GQuark mm_connection_error_quark (void); /* implemented in mm-errors-quarks.c */ +GType mm_connection_error_get_type (void) G_GNUC_CONST; +#define MM_CONNECTION_ERROR (mm_connection_error_quark ()) +#define MM_TYPE_CONNECTION_ERROR (mm_connection_error_get_type ()) +GQuark mm_serial_error_quark (void); /* implemented in mm-errors-quarks.c */ +GType mm_serial_error_get_type (void) G_GNUC_CONST; +#define MM_SERIAL_ERROR (mm_serial_error_quark ()) +#define MM_TYPE_SERIAL_ERROR (mm_serial_error_get_type ()) +GQuark mm_message_error_quark (void); /* implemented in mm-errors-quarks.c */ +GType mm_message_error_get_type (void) G_GNUC_CONST; +#define MM_MESSAGE_ERROR (mm_message_error_quark ()) +#define MM_TYPE_MESSAGE_ERROR (mm_message_error_get_type ()) +GQuark mm_cdma_activation_error_quark (void); /* implemented in mm-errors-quarks.c */ +GType mm_cdma_activation_error_get_type (void) G_GNUC_CONST; +#define MM_CDMA_ACTIVATION_ERROR (mm_cdma_activation_error_quark ()) +#define MM_TYPE_CDMA_ACTIVATION_ERROR (mm_cdma_activation_error_get_type ()) +G_END_DECLS + +#endif /* __MM_ERRORS_TYPES_H__ */ + +/* Generated data ends here */ + diff --git a/libmm-glib/generated/mm-gdbus-bearer.h b/libmm-glib/generated/mm-gdbus-bearer.h new file mode 100644 index 0000000..2d8b36b --- /dev/null +++ b/libmm-glib/generated/mm-gdbus-bearer.h @@ -0,0 +1,233 @@ +/* + * Generated by gdbus-codegen 2.36.2. DO NOT EDIT. + * + * The license of this code is the same as for the source it was derived from. + */ + +#ifndef __MM_GDBUS_BEARER_H__ +#define __MM_GDBUS_BEARER_H__ + +#include <gio/gio.h> + +G_BEGIN_DECLS + + +/* ------------------------------------------------------------------------ */ +/* Declarations for org.freedesktop.ModemManager1.Bearer */ + +#define MM_GDBUS_TYPE_BEARER (mm_gdbus_bearer_get_type ()) +#define MM_GDBUS_BEARER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_BEARER, MmGdbusBearer)) +#define MM_GDBUS_IS_BEARER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_BEARER)) +#define MM_GDBUS_BEARER_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), MM_GDBUS_TYPE_BEARER, MmGdbusBearerIface)) + +struct _MmGdbusBearer; +typedef struct _MmGdbusBearer MmGdbusBearer; +typedef struct _MmGdbusBearerIface MmGdbusBearerIface; + +struct _MmGdbusBearerIface +{ + GTypeInterface parent_iface; + + + gboolean (*handle_connect) ( + MmGdbusBearer *object, + GDBusMethodInvocation *invocation); + + gboolean (*handle_disconnect) ( + MmGdbusBearer *object, + GDBusMethodInvocation *invocation); + + gboolean (*get_connected) (MmGdbusBearer *object); + + const gchar * (*get_interface) (MmGdbusBearer *object); + + GVariant * (*get_ip4_config) (MmGdbusBearer *object); + + GVariant * (*get_ip6_config) (MmGdbusBearer *object); + + guint (*get_ip_timeout) (MmGdbusBearer *object); + + GVariant * (*get_properties) (MmGdbusBearer *object); + + gboolean (*get_suspended) (MmGdbusBearer *object); + +}; + +GType mm_gdbus_bearer_get_type (void) G_GNUC_CONST; + +GDBusInterfaceInfo *mm_gdbus_bearer_interface_info (void); +guint mm_gdbus_bearer_override_properties (GObjectClass *klass, guint property_id_begin); + + +/* D-Bus method call completion functions: */ +void mm_gdbus_bearer_complete_connect ( + MmGdbusBearer *object, + GDBusMethodInvocation *invocation); + +void mm_gdbus_bearer_complete_disconnect ( + MmGdbusBearer *object, + GDBusMethodInvocation *invocation); + + + +/* D-Bus method calls: */ +void mm_gdbus_bearer_call_connect ( + MmGdbusBearer *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_bearer_call_connect_finish ( + MmGdbusBearer *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_bearer_call_connect_sync ( + MmGdbusBearer *proxy, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_bearer_call_disconnect ( + MmGdbusBearer *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_bearer_call_disconnect_finish ( + MmGdbusBearer *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_bearer_call_disconnect_sync ( + MmGdbusBearer *proxy, + GCancellable *cancellable, + GError **error); + + + +/* D-Bus property accessors: */ +const gchar *mm_gdbus_bearer_get_interface (MmGdbusBearer *object); +gchar *mm_gdbus_bearer_dup_interface (MmGdbusBearer *object); +void mm_gdbus_bearer_set_interface (MmGdbusBearer *object, const gchar *value); + +gboolean mm_gdbus_bearer_get_connected (MmGdbusBearer *object); +void mm_gdbus_bearer_set_connected (MmGdbusBearer *object, gboolean value); + +gboolean mm_gdbus_bearer_get_suspended (MmGdbusBearer *object); +void mm_gdbus_bearer_set_suspended (MmGdbusBearer *object, gboolean value); + +GVariant *mm_gdbus_bearer_get_ip4_config (MmGdbusBearer *object); +GVariant *mm_gdbus_bearer_dup_ip4_config (MmGdbusBearer *object); +void mm_gdbus_bearer_set_ip4_config (MmGdbusBearer *object, GVariant *value); + +GVariant *mm_gdbus_bearer_get_ip6_config (MmGdbusBearer *object); +GVariant *mm_gdbus_bearer_dup_ip6_config (MmGdbusBearer *object); +void mm_gdbus_bearer_set_ip6_config (MmGdbusBearer *object, GVariant *value); + +guint mm_gdbus_bearer_get_ip_timeout (MmGdbusBearer *object); +void mm_gdbus_bearer_set_ip_timeout (MmGdbusBearer *object, guint value); + +GVariant *mm_gdbus_bearer_get_properties (MmGdbusBearer *object); +GVariant *mm_gdbus_bearer_dup_properties (MmGdbusBearer *object); +void mm_gdbus_bearer_set_properties (MmGdbusBearer *object, GVariant *value); + + +/* ---- */ + +#define MM_GDBUS_TYPE_BEARER_PROXY (mm_gdbus_bearer_proxy_get_type ()) +#define MM_GDBUS_BEARER_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_BEARER_PROXY, MmGdbusBearerProxy)) +#define MM_GDBUS_BEARER_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_BEARER_PROXY, MmGdbusBearerProxyClass)) +#define MM_GDBUS_BEARER_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_BEARER_PROXY, MmGdbusBearerProxyClass)) +#define MM_GDBUS_IS_BEARER_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_BEARER_PROXY)) +#define MM_GDBUS_IS_BEARER_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_BEARER_PROXY)) + +typedef struct _MmGdbusBearerProxy MmGdbusBearerProxy; +typedef struct _MmGdbusBearerProxyClass MmGdbusBearerProxyClass; +typedef struct _MmGdbusBearerProxyPrivate MmGdbusBearerProxyPrivate; + +struct _MmGdbusBearerProxy +{ + /*< private >*/ + GDBusProxy parent_instance; + MmGdbusBearerProxyPrivate *priv; +}; + +struct _MmGdbusBearerProxyClass +{ + GDBusProxyClass parent_class; +}; + +GType mm_gdbus_bearer_proxy_get_type (void) G_GNUC_CONST; + +void mm_gdbus_bearer_proxy_new ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusBearer *mm_gdbus_bearer_proxy_new_finish ( + GAsyncResult *res, + GError **error); +MmGdbusBearer *mm_gdbus_bearer_proxy_new_sync ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_bearer_proxy_new_for_bus ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusBearer *mm_gdbus_bearer_proxy_new_for_bus_finish ( + GAsyncResult *res, + GError **error); +MmGdbusBearer *mm_gdbus_bearer_proxy_new_for_bus_sync ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + + +/* ---- */ + +#define MM_GDBUS_TYPE_BEARER_SKELETON (mm_gdbus_bearer_skeleton_get_type ()) +#define MM_GDBUS_BEARER_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_BEARER_SKELETON, MmGdbusBearerSkeleton)) +#define MM_GDBUS_BEARER_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_BEARER_SKELETON, MmGdbusBearerSkeletonClass)) +#define MM_GDBUS_BEARER_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_BEARER_SKELETON, MmGdbusBearerSkeletonClass)) +#define MM_GDBUS_IS_BEARER_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_BEARER_SKELETON)) +#define MM_GDBUS_IS_BEARER_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_BEARER_SKELETON)) + +typedef struct _MmGdbusBearerSkeleton MmGdbusBearerSkeleton; +typedef struct _MmGdbusBearerSkeletonClass MmGdbusBearerSkeletonClass; +typedef struct _MmGdbusBearerSkeletonPrivate MmGdbusBearerSkeletonPrivate; + +struct _MmGdbusBearerSkeleton +{ + /*< private >*/ + GDBusInterfaceSkeleton parent_instance; + MmGdbusBearerSkeletonPrivate *priv; +}; + +struct _MmGdbusBearerSkeletonClass +{ + GDBusInterfaceSkeletonClass parent_class; +}; + +GType mm_gdbus_bearer_skeleton_get_type (void) G_GNUC_CONST; + +MmGdbusBearer *mm_gdbus_bearer_skeleton_new (void); + + +G_END_DECLS + +#endif /* __MM_GDBUS_BEARER_H__ */ diff --git a/libmm-glib/generated/mm-gdbus-manager.h b/libmm-glib/generated/mm-gdbus-manager.h new file mode 100644 index 0000000..85d3b66 --- /dev/null +++ b/libmm-glib/generated/mm-gdbus-manager.h @@ -0,0 +1,194 @@ +/* + * Generated by gdbus-codegen 2.36.2. DO NOT EDIT. + * + * The license of this code is the same as for the source it was derived from. + */ + +#ifndef __MM_GDBUS_MANAGER_H__ +#define __MM_GDBUS_MANAGER_H__ + +#include <gio/gio.h> + +G_BEGIN_DECLS + + +/* ------------------------------------------------------------------------ */ +/* Declarations for org.freedesktop.ModemManager1 */ + +#define MM_GDBUS_TYPE_ORG_FREEDESKTOP_MODEM_MANAGER1 (mm_gdbus_org_freedesktop_modem_manager1_get_type ()) +#define MM_GDBUS_ORG_FREEDESKTOP_MODEM_MANAGER1(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_ORG_FREEDESKTOP_MODEM_MANAGER1, MmGdbusOrgFreedesktopModemManager1)) +#define MM_GDBUS_IS_ORG_FREEDESKTOP_MODEM_MANAGER1(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_ORG_FREEDESKTOP_MODEM_MANAGER1)) +#define MM_GDBUS_ORG_FREEDESKTOP_MODEM_MANAGER1_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), MM_GDBUS_TYPE_ORG_FREEDESKTOP_MODEM_MANAGER1, MmGdbusOrgFreedesktopModemManager1Iface)) + +struct _MmGdbusOrgFreedesktopModemManager1; +typedef struct _MmGdbusOrgFreedesktopModemManager1 MmGdbusOrgFreedesktopModemManager1; +typedef struct _MmGdbusOrgFreedesktopModemManager1Iface MmGdbusOrgFreedesktopModemManager1Iface; + +struct _MmGdbusOrgFreedesktopModemManager1Iface +{ + GTypeInterface parent_iface; + + gboolean (*handle_scan_devices) ( + MmGdbusOrgFreedesktopModemManager1 *object, + GDBusMethodInvocation *invocation); + + gboolean (*handle_set_logging) ( + MmGdbusOrgFreedesktopModemManager1 *object, + GDBusMethodInvocation *invocation, + const gchar *arg_level); + +}; + +GType mm_gdbus_org_freedesktop_modem_manager1_get_type (void) G_GNUC_CONST; + +GDBusInterfaceInfo *mm_gdbus_org_freedesktop_modem_manager1_interface_info (void); +guint mm_gdbus_org_freedesktop_modem_manager1_override_properties (GObjectClass *klass, guint property_id_begin); + + +/* D-Bus method call completion functions: */ +void mm_gdbus_org_freedesktop_modem_manager1_complete_scan_devices ( + MmGdbusOrgFreedesktopModemManager1 *object, + GDBusMethodInvocation *invocation); + +void mm_gdbus_org_freedesktop_modem_manager1_complete_set_logging ( + MmGdbusOrgFreedesktopModemManager1 *object, + GDBusMethodInvocation *invocation); + + + +/* D-Bus method calls: */ +void mm_gdbus_org_freedesktop_modem_manager1_call_scan_devices ( + MmGdbusOrgFreedesktopModemManager1 *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_org_freedesktop_modem_manager1_call_scan_devices_finish ( + MmGdbusOrgFreedesktopModemManager1 *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_org_freedesktop_modem_manager1_call_scan_devices_sync ( + MmGdbusOrgFreedesktopModemManager1 *proxy, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_org_freedesktop_modem_manager1_call_set_logging ( + MmGdbusOrgFreedesktopModemManager1 *proxy, + const gchar *arg_level, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_org_freedesktop_modem_manager1_call_set_logging_finish ( + MmGdbusOrgFreedesktopModemManager1 *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_org_freedesktop_modem_manager1_call_set_logging_sync ( + MmGdbusOrgFreedesktopModemManager1 *proxy, + const gchar *arg_level, + GCancellable *cancellable, + GError **error); + + + +/* ---- */ + +#define MM_GDBUS_TYPE_ORG_FREEDESKTOP_MODEM_MANAGER1_PROXY (mm_gdbus_org_freedesktop_modem_manager1_proxy_get_type ()) +#define MM_GDBUS_ORG_FREEDESKTOP_MODEM_MANAGER1_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_ORG_FREEDESKTOP_MODEM_MANAGER1_PROXY, MmGdbusOrgFreedesktopModemManager1Proxy)) +#define MM_GDBUS_ORG_FREEDESKTOP_MODEM_MANAGER1_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_ORG_FREEDESKTOP_MODEM_MANAGER1_PROXY, MmGdbusOrgFreedesktopModemManager1ProxyClass)) +#define MM_GDBUS_ORG_FREEDESKTOP_MODEM_MANAGER1_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_ORG_FREEDESKTOP_MODEM_MANAGER1_PROXY, MmGdbusOrgFreedesktopModemManager1ProxyClass)) +#define MM_GDBUS_IS_ORG_FREEDESKTOP_MODEM_MANAGER1_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_ORG_FREEDESKTOP_MODEM_MANAGER1_PROXY)) +#define MM_GDBUS_IS_ORG_FREEDESKTOP_MODEM_MANAGER1_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_ORG_FREEDESKTOP_MODEM_MANAGER1_PROXY)) + +typedef struct _MmGdbusOrgFreedesktopModemManager1Proxy MmGdbusOrgFreedesktopModemManager1Proxy; +typedef struct _MmGdbusOrgFreedesktopModemManager1ProxyClass MmGdbusOrgFreedesktopModemManager1ProxyClass; +typedef struct _MmGdbusOrgFreedesktopModemManager1ProxyPrivate MmGdbusOrgFreedesktopModemManager1ProxyPrivate; + +struct _MmGdbusOrgFreedesktopModemManager1Proxy +{ + /*< private >*/ + GDBusProxy parent_instance; + MmGdbusOrgFreedesktopModemManager1ProxyPrivate *priv; +}; + +struct _MmGdbusOrgFreedesktopModemManager1ProxyClass +{ + GDBusProxyClass parent_class; +}; + +GType mm_gdbus_org_freedesktop_modem_manager1_proxy_get_type (void) G_GNUC_CONST; + +void mm_gdbus_org_freedesktop_modem_manager1_proxy_new ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusOrgFreedesktopModemManager1 *mm_gdbus_org_freedesktop_modem_manager1_proxy_new_finish ( + GAsyncResult *res, + GError **error); +MmGdbusOrgFreedesktopModemManager1 *mm_gdbus_org_freedesktop_modem_manager1_proxy_new_sync ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_org_freedesktop_modem_manager1_proxy_new_for_bus ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusOrgFreedesktopModemManager1 *mm_gdbus_org_freedesktop_modem_manager1_proxy_new_for_bus_finish ( + GAsyncResult *res, + GError **error); +MmGdbusOrgFreedesktopModemManager1 *mm_gdbus_org_freedesktop_modem_manager1_proxy_new_for_bus_sync ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + + +/* ---- */ + +#define MM_GDBUS_TYPE_ORG_FREEDESKTOP_MODEM_MANAGER1_SKELETON (mm_gdbus_org_freedesktop_modem_manager1_skeleton_get_type ()) +#define MM_GDBUS_ORG_FREEDESKTOP_MODEM_MANAGER1_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_ORG_FREEDESKTOP_MODEM_MANAGER1_SKELETON, MmGdbusOrgFreedesktopModemManager1Skeleton)) +#define MM_GDBUS_ORG_FREEDESKTOP_MODEM_MANAGER1_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_ORG_FREEDESKTOP_MODEM_MANAGER1_SKELETON, MmGdbusOrgFreedesktopModemManager1SkeletonClass)) +#define MM_GDBUS_ORG_FREEDESKTOP_MODEM_MANAGER1_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_ORG_FREEDESKTOP_MODEM_MANAGER1_SKELETON, MmGdbusOrgFreedesktopModemManager1SkeletonClass)) +#define MM_GDBUS_IS_ORG_FREEDESKTOP_MODEM_MANAGER1_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_ORG_FREEDESKTOP_MODEM_MANAGER1_SKELETON)) +#define MM_GDBUS_IS_ORG_FREEDESKTOP_MODEM_MANAGER1_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_ORG_FREEDESKTOP_MODEM_MANAGER1_SKELETON)) + +typedef struct _MmGdbusOrgFreedesktopModemManager1Skeleton MmGdbusOrgFreedesktopModemManager1Skeleton; +typedef struct _MmGdbusOrgFreedesktopModemManager1SkeletonClass MmGdbusOrgFreedesktopModemManager1SkeletonClass; +typedef struct _MmGdbusOrgFreedesktopModemManager1SkeletonPrivate MmGdbusOrgFreedesktopModemManager1SkeletonPrivate; + +struct _MmGdbusOrgFreedesktopModemManager1Skeleton +{ + /*< private >*/ + GDBusInterfaceSkeleton parent_instance; + MmGdbusOrgFreedesktopModemManager1SkeletonPrivate *priv; +}; + +struct _MmGdbusOrgFreedesktopModemManager1SkeletonClass +{ + GDBusInterfaceSkeletonClass parent_class; +}; + +GType mm_gdbus_org_freedesktop_modem_manager1_skeleton_get_type (void) G_GNUC_CONST; + +MmGdbusOrgFreedesktopModemManager1 *mm_gdbus_org_freedesktop_modem_manager1_skeleton_new (void); + + +G_END_DECLS + +#endif /* __MM_GDBUS_MANAGER_H__ */ diff --git a/libmm-glib/generated/mm-gdbus-modem.h b/libmm-glib/generated/mm-gdbus-modem.h new file mode 100644 index 0000000..4545c82 --- /dev/null +++ b/libmm-glib/generated/mm-gdbus-modem.h @@ -0,0 +1,2803 @@ +/* + * Generated by gdbus-codegen 2.36.2. DO NOT EDIT. + * + * The license of this code is the same as for the source it was derived from. + */ + +#ifndef __MM_GDBUS_MODEM_H__ +#define __MM_GDBUS_MODEM_H__ + +#include <gio/gio.h> + +G_BEGIN_DECLS + + +/* ------------------------------------------------------------------------ */ +/* Declarations for org.freedesktop.ModemManager1.Modem */ + +#define MM_GDBUS_TYPE_MODEM (mm_gdbus_modem_get_type ()) +#define MM_GDBUS_MODEM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM, MmGdbusModem)) +#define MM_GDBUS_IS_MODEM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM)) +#define MM_GDBUS_MODEM_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), MM_GDBUS_TYPE_MODEM, MmGdbusModemIface)) + +struct _MmGdbusModem; +typedef struct _MmGdbusModem MmGdbusModem; +typedef struct _MmGdbusModemIface MmGdbusModemIface; + +struct _MmGdbusModemIface +{ + GTypeInterface parent_iface; + + + + gboolean (*handle_command) ( + MmGdbusModem *object, + GDBusMethodInvocation *invocation, + const gchar *arg_cmd, + guint arg_timeout); + + gboolean (*handle_create_bearer) ( + MmGdbusModem *object, + GDBusMethodInvocation *invocation, + GVariant *arg_properties); + + gboolean (*handle_delete_bearer) ( + MmGdbusModem *object, + GDBusMethodInvocation *invocation, + const gchar *arg_bearer); + + gboolean (*handle_enable) ( + MmGdbusModem *object, + GDBusMethodInvocation *invocation, + gboolean arg_enable); + + gboolean (*handle_factory_reset) ( + MmGdbusModem *object, + GDBusMethodInvocation *invocation, + const gchar *arg_code); + + gboolean (*handle_list_bearers) ( + MmGdbusModem *object, + GDBusMethodInvocation *invocation); + + gboolean (*handle_reset) ( + MmGdbusModem *object, + GDBusMethodInvocation *invocation); + + gboolean (*handle_set_current_bands) ( + MmGdbusModem *object, + GDBusMethodInvocation *invocation, + GVariant *arg_bands); + + gboolean (*handle_set_current_capabilities) ( + MmGdbusModem *object, + GDBusMethodInvocation *invocation, + guint arg_capabilities); + + gboolean (*handle_set_current_modes) ( + MmGdbusModem *object, + GDBusMethodInvocation *invocation, + GVariant *arg_modes); + + gboolean (*handle_set_power_state) ( + MmGdbusModem *object, + GDBusMethodInvocation *invocation, + guint arg_state); + + guint (*get_access_technologies) (MmGdbusModem *object); + + GVariant * (*get_current_bands) (MmGdbusModem *object); + + guint (*get_current_capabilities) (MmGdbusModem *object); + + GVariant * (*get_current_modes) (MmGdbusModem *object); + + const gchar * (*get_device) (MmGdbusModem *object); + + const gchar * (*get_device_identifier) (MmGdbusModem *object); + + const gchar *const * (*get_drivers) (MmGdbusModem *object); + + const gchar * (*get_equipment_identifier) (MmGdbusModem *object); + + const gchar * (*get_manufacturer) (MmGdbusModem *object); + + guint (*get_max_active_bearers) (MmGdbusModem *object); + + guint (*get_max_bearers) (MmGdbusModem *object); + + const gchar * (*get_model) (MmGdbusModem *object); + + const gchar *const * (*get_own_numbers) (MmGdbusModem *object); + + const gchar * (*get_plugin) (MmGdbusModem *object); + + guint (*get_power_state) (MmGdbusModem *object); + + const gchar * (*get_primary_port) (MmGdbusModem *object); + + const gchar * (*get_revision) (MmGdbusModem *object); + + GVariant * (*get_signal_quality) (MmGdbusModem *object); + + const gchar * (*get_sim) (MmGdbusModem *object); + + gint (*get_state) (MmGdbusModem *object); + + guint (*get_state_failed_reason) (MmGdbusModem *object); + + GVariant * (*get_supported_bands) (MmGdbusModem *object); + + GVariant * (*get_supported_capabilities) (MmGdbusModem *object); + + guint (*get_supported_ip_families) (MmGdbusModem *object); + + GVariant * (*get_supported_modes) (MmGdbusModem *object); + + guint (*get_unlock_required) (MmGdbusModem *object); + + GVariant * (*get_unlock_retries) (MmGdbusModem *object); + + void (*state_changed) ( + MmGdbusModem *object, + gint arg_old, + gint arg_new, + guint arg_reason); + +}; + +GType mm_gdbus_modem_get_type (void) G_GNUC_CONST; + +GDBusInterfaceInfo *mm_gdbus_modem_interface_info (void); +guint mm_gdbus_modem_override_properties (GObjectClass *klass, guint property_id_begin); + + +/* D-Bus method call completion functions: */ +void mm_gdbus_modem_complete_enable ( + MmGdbusModem *object, + GDBusMethodInvocation *invocation); + +void mm_gdbus_modem_complete_list_bearers ( + MmGdbusModem *object, + GDBusMethodInvocation *invocation, + const gchar *const *bearers); + +void mm_gdbus_modem_complete_create_bearer ( + MmGdbusModem *object, + GDBusMethodInvocation *invocation, + const gchar *path); + +void mm_gdbus_modem_complete_delete_bearer ( + MmGdbusModem *object, + GDBusMethodInvocation *invocation); + +void mm_gdbus_modem_complete_reset ( + MmGdbusModem *object, + GDBusMethodInvocation *invocation); + +void mm_gdbus_modem_complete_factory_reset ( + MmGdbusModem *object, + GDBusMethodInvocation *invocation); + +void mm_gdbus_modem_complete_set_power_state ( + MmGdbusModem *object, + GDBusMethodInvocation *invocation); + +void mm_gdbus_modem_complete_set_current_capabilities ( + MmGdbusModem *object, + GDBusMethodInvocation *invocation); + +void mm_gdbus_modem_complete_set_current_modes ( + MmGdbusModem *object, + GDBusMethodInvocation *invocation); + +void mm_gdbus_modem_complete_set_current_bands ( + MmGdbusModem *object, + GDBusMethodInvocation *invocation); + +void mm_gdbus_modem_complete_command ( + MmGdbusModem *object, + GDBusMethodInvocation *invocation, + const gchar *response); + + + +/* D-Bus signal emissions functions: */ +void mm_gdbus_modem_emit_state_changed ( + MmGdbusModem *object, + gint arg_old, + gint arg_new, + guint arg_reason); + + + +/* D-Bus method calls: */ +void mm_gdbus_modem_call_enable ( + MmGdbusModem *proxy, + gboolean arg_enable, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_call_enable_finish ( + MmGdbusModem *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_call_enable_sync ( + MmGdbusModem *proxy, + gboolean arg_enable, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_call_list_bearers ( + MmGdbusModem *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_call_list_bearers_finish ( + MmGdbusModem *proxy, + gchar ***out_bearers, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_call_list_bearers_sync ( + MmGdbusModem *proxy, + gchar ***out_bearers, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_call_create_bearer ( + MmGdbusModem *proxy, + GVariant *arg_properties, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_call_create_bearer_finish ( + MmGdbusModem *proxy, + gchar **out_path, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_call_create_bearer_sync ( + MmGdbusModem *proxy, + GVariant *arg_properties, + gchar **out_path, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_call_delete_bearer ( + MmGdbusModem *proxy, + const gchar *arg_bearer, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_call_delete_bearer_finish ( + MmGdbusModem *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_call_delete_bearer_sync ( + MmGdbusModem *proxy, + const gchar *arg_bearer, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_call_reset ( + MmGdbusModem *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_call_reset_finish ( + MmGdbusModem *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_call_reset_sync ( + MmGdbusModem *proxy, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_call_factory_reset ( + MmGdbusModem *proxy, + const gchar *arg_code, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_call_factory_reset_finish ( + MmGdbusModem *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_call_factory_reset_sync ( + MmGdbusModem *proxy, + const gchar *arg_code, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_call_set_power_state ( + MmGdbusModem *proxy, + guint arg_state, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_call_set_power_state_finish ( + MmGdbusModem *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_call_set_power_state_sync ( + MmGdbusModem *proxy, + guint arg_state, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_call_set_current_capabilities ( + MmGdbusModem *proxy, + guint arg_capabilities, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_call_set_current_capabilities_finish ( + MmGdbusModem *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_call_set_current_capabilities_sync ( + MmGdbusModem *proxy, + guint arg_capabilities, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_call_set_current_modes ( + MmGdbusModem *proxy, + GVariant *arg_modes, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_call_set_current_modes_finish ( + MmGdbusModem *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_call_set_current_modes_sync ( + MmGdbusModem *proxy, + GVariant *arg_modes, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_call_set_current_bands ( + MmGdbusModem *proxy, + GVariant *arg_bands, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_call_set_current_bands_finish ( + MmGdbusModem *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_call_set_current_bands_sync ( + MmGdbusModem *proxy, + GVariant *arg_bands, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_call_command ( + MmGdbusModem *proxy, + const gchar *arg_cmd, + guint arg_timeout, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_call_command_finish ( + MmGdbusModem *proxy, + gchar **out_response, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_call_command_sync ( + MmGdbusModem *proxy, + const gchar *arg_cmd, + guint arg_timeout, + gchar **out_response, + GCancellable *cancellable, + GError **error); + + + +/* D-Bus property accessors: */ +const gchar *mm_gdbus_modem_get_sim (MmGdbusModem *object); +gchar *mm_gdbus_modem_dup_sim (MmGdbusModem *object); +void mm_gdbus_modem_set_sim (MmGdbusModem *object, const gchar *value); + +GVariant *mm_gdbus_modem_get_supported_capabilities (MmGdbusModem *object); +GVariant *mm_gdbus_modem_dup_supported_capabilities (MmGdbusModem *object); +void mm_gdbus_modem_set_supported_capabilities (MmGdbusModem *object, GVariant *value); + +guint mm_gdbus_modem_get_current_capabilities (MmGdbusModem *object); +void mm_gdbus_modem_set_current_capabilities (MmGdbusModem *object, guint value); + +guint mm_gdbus_modem_get_max_bearers (MmGdbusModem *object); +void mm_gdbus_modem_set_max_bearers (MmGdbusModem *object, guint value); + +guint mm_gdbus_modem_get_max_active_bearers (MmGdbusModem *object); +void mm_gdbus_modem_set_max_active_bearers (MmGdbusModem *object, guint value); + +const gchar *mm_gdbus_modem_get_manufacturer (MmGdbusModem *object); +gchar *mm_gdbus_modem_dup_manufacturer (MmGdbusModem *object); +void mm_gdbus_modem_set_manufacturer (MmGdbusModem *object, const gchar *value); + +const gchar *mm_gdbus_modem_get_model (MmGdbusModem *object); +gchar *mm_gdbus_modem_dup_model (MmGdbusModem *object); +void mm_gdbus_modem_set_model (MmGdbusModem *object, const gchar *value); + +const gchar *mm_gdbus_modem_get_revision (MmGdbusModem *object); +gchar *mm_gdbus_modem_dup_revision (MmGdbusModem *object); +void mm_gdbus_modem_set_revision (MmGdbusModem *object, const gchar *value); + +const gchar *mm_gdbus_modem_get_device_identifier (MmGdbusModem *object); +gchar *mm_gdbus_modem_dup_device_identifier (MmGdbusModem *object); +void mm_gdbus_modem_set_device_identifier (MmGdbusModem *object, const gchar *value); + +const gchar *mm_gdbus_modem_get_device (MmGdbusModem *object); +gchar *mm_gdbus_modem_dup_device (MmGdbusModem *object); +void mm_gdbus_modem_set_device (MmGdbusModem *object, const gchar *value); + +const gchar *const *mm_gdbus_modem_get_drivers (MmGdbusModem *object); +gchar **mm_gdbus_modem_dup_drivers (MmGdbusModem *object); +void mm_gdbus_modem_set_drivers (MmGdbusModem *object, const gchar *const *value); + +const gchar *mm_gdbus_modem_get_plugin (MmGdbusModem *object); +gchar *mm_gdbus_modem_dup_plugin (MmGdbusModem *object); +void mm_gdbus_modem_set_plugin (MmGdbusModem *object, const gchar *value); + +const gchar *mm_gdbus_modem_get_primary_port (MmGdbusModem *object); +gchar *mm_gdbus_modem_dup_primary_port (MmGdbusModem *object); +void mm_gdbus_modem_set_primary_port (MmGdbusModem *object, const gchar *value); + +const gchar *mm_gdbus_modem_get_equipment_identifier (MmGdbusModem *object); +gchar *mm_gdbus_modem_dup_equipment_identifier (MmGdbusModem *object); +void mm_gdbus_modem_set_equipment_identifier (MmGdbusModem *object, const gchar *value); + +guint mm_gdbus_modem_get_unlock_required (MmGdbusModem *object); +void mm_gdbus_modem_set_unlock_required (MmGdbusModem *object, guint value); + +GVariant *mm_gdbus_modem_get_unlock_retries (MmGdbusModem *object); +GVariant *mm_gdbus_modem_dup_unlock_retries (MmGdbusModem *object); +void mm_gdbus_modem_set_unlock_retries (MmGdbusModem *object, GVariant *value); + +gint mm_gdbus_modem_get_state (MmGdbusModem *object); +void mm_gdbus_modem_set_state (MmGdbusModem *object, gint value); + +guint mm_gdbus_modem_get_state_failed_reason (MmGdbusModem *object); +void mm_gdbus_modem_set_state_failed_reason (MmGdbusModem *object, guint value); + +guint mm_gdbus_modem_get_access_technologies (MmGdbusModem *object); +void mm_gdbus_modem_set_access_technologies (MmGdbusModem *object, guint value); + +GVariant *mm_gdbus_modem_get_signal_quality (MmGdbusModem *object); +GVariant *mm_gdbus_modem_dup_signal_quality (MmGdbusModem *object); +void mm_gdbus_modem_set_signal_quality (MmGdbusModem *object, GVariant *value); + +const gchar *const *mm_gdbus_modem_get_own_numbers (MmGdbusModem *object); +gchar **mm_gdbus_modem_dup_own_numbers (MmGdbusModem *object); +void mm_gdbus_modem_set_own_numbers (MmGdbusModem *object, const gchar *const *value); + +guint mm_gdbus_modem_get_power_state (MmGdbusModem *object); +void mm_gdbus_modem_set_power_state (MmGdbusModem *object, guint value); + +GVariant *mm_gdbus_modem_get_supported_modes (MmGdbusModem *object); +GVariant *mm_gdbus_modem_dup_supported_modes (MmGdbusModem *object); +void mm_gdbus_modem_set_supported_modes (MmGdbusModem *object, GVariant *value); + +GVariant *mm_gdbus_modem_get_current_modes (MmGdbusModem *object); +GVariant *mm_gdbus_modem_dup_current_modes (MmGdbusModem *object); +void mm_gdbus_modem_set_current_modes (MmGdbusModem *object, GVariant *value); + +GVariant *mm_gdbus_modem_get_supported_bands (MmGdbusModem *object); +GVariant *mm_gdbus_modem_dup_supported_bands (MmGdbusModem *object); +void mm_gdbus_modem_set_supported_bands (MmGdbusModem *object, GVariant *value); + +GVariant *mm_gdbus_modem_get_current_bands (MmGdbusModem *object); +GVariant *mm_gdbus_modem_dup_current_bands (MmGdbusModem *object); +void mm_gdbus_modem_set_current_bands (MmGdbusModem *object, GVariant *value); + +guint mm_gdbus_modem_get_supported_ip_families (MmGdbusModem *object); +void mm_gdbus_modem_set_supported_ip_families (MmGdbusModem *object, guint value); + + +/* ---- */ + +#define MM_GDBUS_TYPE_MODEM_PROXY (mm_gdbus_modem_proxy_get_type ()) +#define MM_GDBUS_MODEM_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_PROXY, MmGdbusModemProxy)) +#define MM_GDBUS_MODEM_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_MODEM_PROXY, MmGdbusModemProxyClass)) +#define MM_GDBUS_MODEM_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_MODEM_PROXY, MmGdbusModemProxyClass)) +#define MM_GDBUS_IS_MODEM_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_PROXY)) +#define MM_GDBUS_IS_MODEM_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_MODEM_PROXY)) + +typedef struct _MmGdbusModemProxy MmGdbusModemProxy; +typedef struct _MmGdbusModemProxyClass MmGdbusModemProxyClass; +typedef struct _MmGdbusModemProxyPrivate MmGdbusModemProxyPrivate; + +struct _MmGdbusModemProxy +{ + /*< private >*/ + GDBusProxy parent_instance; + MmGdbusModemProxyPrivate *priv; +}; + +struct _MmGdbusModemProxyClass +{ + GDBusProxyClass parent_class; +}; + +GType mm_gdbus_modem_proxy_get_type (void) G_GNUC_CONST; + +void mm_gdbus_modem_proxy_new ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusModem *mm_gdbus_modem_proxy_new_finish ( + GAsyncResult *res, + GError **error); +MmGdbusModem *mm_gdbus_modem_proxy_new_sync ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_proxy_new_for_bus ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusModem *mm_gdbus_modem_proxy_new_for_bus_finish ( + GAsyncResult *res, + GError **error); +MmGdbusModem *mm_gdbus_modem_proxy_new_for_bus_sync ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + + +/* ---- */ + +#define MM_GDBUS_TYPE_MODEM_SKELETON (mm_gdbus_modem_skeleton_get_type ()) +#define MM_GDBUS_MODEM_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_SKELETON, MmGdbusModemSkeleton)) +#define MM_GDBUS_MODEM_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_MODEM_SKELETON, MmGdbusModemSkeletonClass)) +#define MM_GDBUS_MODEM_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_MODEM_SKELETON, MmGdbusModemSkeletonClass)) +#define MM_GDBUS_IS_MODEM_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_SKELETON)) +#define MM_GDBUS_IS_MODEM_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_MODEM_SKELETON)) + +typedef struct _MmGdbusModemSkeleton MmGdbusModemSkeleton; +typedef struct _MmGdbusModemSkeletonClass MmGdbusModemSkeletonClass; +typedef struct _MmGdbusModemSkeletonPrivate MmGdbusModemSkeletonPrivate; + +struct _MmGdbusModemSkeleton +{ + /*< private >*/ + GDBusInterfaceSkeleton parent_instance; + MmGdbusModemSkeletonPrivate *priv; +}; + +struct _MmGdbusModemSkeletonClass +{ + GDBusInterfaceSkeletonClass parent_class; +}; + +GType mm_gdbus_modem_skeleton_get_type (void) G_GNUC_CONST; + +MmGdbusModem *mm_gdbus_modem_skeleton_new (void); + + +/* ------------------------------------------------------------------------ */ +/* Declarations for org.freedesktop.ModemManager1.Modem.Messaging */ + +#define MM_GDBUS_TYPE_MODEM_MESSAGING (mm_gdbus_modem_messaging_get_type ()) +#define MM_GDBUS_MODEM_MESSAGING(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_MESSAGING, MmGdbusModemMessaging)) +#define MM_GDBUS_IS_MODEM_MESSAGING(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_MESSAGING)) +#define MM_GDBUS_MODEM_MESSAGING_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), MM_GDBUS_TYPE_MODEM_MESSAGING, MmGdbusModemMessagingIface)) + +struct _MmGdbusModemMessaging; +typedef struct _MmGdbusModemMessaging MmGdbusModemMessaging; +typedef struct _MmGdbusModemMessagingIface MmGdbusModemMessagingIface; + +struct _MmGdbusModemMessagingIface +{ + GTypeInterface parent_iface; + + + + gboolean (*handle_create) ( + MmGdbusModemMessaging *object, + GDBusMethodInvocation *invocation, + GVariant *arg_properties); + + gboolean (*handle_delete) ( + MmGdbusModemMessaging *object, + GDBusMethodInvocation *invocation, + const gchar *arg_path); + + gboolean (*handle_list) ( + MmGdbusModemMessaging *object, + GDBusMethodInvocation *invocation); + + guint (*get_default_storage) (MmGdbusModemMessaging *object); + + GVariant * (*get_supported_storages) (MmGdbusModemMessaging *object); + + void (*added) ( + MmGdbusModemMessaging *object, + const gchar *arg_path, + gboolean arg_received); + + void (*deleted) ( + MmGdbusModemMessaging *object, + const gchar *arg_path); + +}; + +GType mm_gdbus_modem_messaging_get_type (void) G_GNUC_CONST; + +GDBusInterfaceInfo *mm_gdbus_modem_messaging_interface_info (void); +guint mm_gdbus_modem_messaging_override_properties (GObjectClass *klass, guint property_id_begin); + + +/* D-Bus method call completion functions: */ +void mm_gdbus_modem_messaging_complete_list ( + MmGdbusModemMessaging *object, + GDBusMethodInvocation *invocation, + const gchar *const *result); + +void mm_gdbus_modem_messaging_complete_delete ( + MmGdbusModemMessaging *object, + GDBusMethodInvocation *invocation); + +void mm_gdbus_modem_messaging_complete_create ( + MmGdbusModemMessaging *object, + GDBusMethodInvocation *invocation, + const gchar *path); + + + +/* D-Bus signal emissions functions: */ +void mm_gdbus_modem_messaging_emit_added ( + MmGdbusModemMessaging *object, + const gchar *arg_path, + gboolean arg_received); + +void mm_gdbus_modem_messaging_emit_deleted ( + MmGdbusModemMessaging *object, + const gchar *arg_path); + + + +/* D-Bus method calls: */ +void mm_gdbus_modem_messaging_call_list ( + MmGdbusModemMessaging *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_messaging_call_list_finish ( + MmGdbusModemMessaging *proxy, + gchar ***out_result, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_messaging_call_list_sync ( + MmGdbusModemMessaging *proxy, + gchar ***out_result, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_messaging_call_delete ( + MmGdbusModemMessaging *proxy, + const gchar *arg_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_messaging_call_delete_finish ( + MmGdbusModemMessaging *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_messaging_call_delete_sync ( + MmGdbusModemMessaging *proxy, + const gchar *arg_path, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_messaging_call_create ( + MmGdbusModemMessaging *proxy, + GVariant *arg_properties, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_messaging_call_create_finish ( + MmGdbusModemMessaging *proxy, + gchar **out_path, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_messaging_call_create_sync ( + MmGdbusModemMessaging *proxy, + GVariant *arg_properties, + gchar **out_path, + GCancellable *cancellable, + GError **error); + + + +/* D-Bus property accessors: */ +GVariant *mm_gdbus_modem_messaging_get_supported_storages (MmGdbusModemMessaging *object); +GVariant *mm_gdbus_modem_messaging_dup_supported_storages (MmGdbusModemMessaging *object); +void mm_gdbus_modem_messaging_set_supported_storages (MmGdbusModemMessaging *object, GVariant *value); + +guint mm_gdbus_modem_messaging_get_default_storage (MmGdbusModemMessaging *object); +void mm_gdbus_modem_messaging_set_default_storage (MmGdbusModemMessaging *object, guint value); + + +/* ---- */ + +#define MM_GDBUS_TYPE_MODEM_MESSAGING_PROXY (mm_gdbus_modem_messaging_proxy_get_type ()) +#define MM_GDBUS_MODEM_MESSAGING_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_MESSAGING_PROXY, MmGdbusModemMessagingProxy)) +#define MM_GDBUS_MODEM_MESSAGING_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_MODEM_MESSAGING_PROXY, MmGdbusModemMessagingProxyClass)) +#define MM_GDBUS_MODEM_MESSAGING_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_MODEM_MESSAGING_PROXY, MmGdbusModemMessagingProxyClass)) +#define MM_GDBUS_IS_MODEM_MESSAGING_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_MESSAGING_PROXY)) +#define MM_GDBUS_IS_MODEM_MESSAGING_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_MODEM_MESSAGING_PROXY)) + +typedef struct _MmGdbusModemMessagingProxy MmGdbusModemMessagingProxy; +typedef struct _MmGdbusModemMessagingProxyClass MmGdbusModemMessagingProxyClass; +typedef struct _MmGdbusModemMessagingProxyPrivate MmGdbusModemMessagingProxyPrivate; + +struct _MmGdbusModemMessagingProxy +{ + /*< private >*/ + GDBusProxy parent_instance; + MmGdbusModemMessagingProxyPrivate *priv; +}; + +struct _MmGdbusModemMessagingProxyClass +{ + GDBusProxyClass parent_class; +}; + +GType mm_gdbus_modem_messaging_proxy_get_type (void) G_GNUC_CONST; + +void mm_gdbus_modem_messaging_proxy_new ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusModemMessaging *mm_gdbus_modem_messaging_proxy_new_finish ( + GAsyncResult *res, + GError **error); +MmGdbusModemMessaging *mm_gdbus_modem_messaging_proxy_new_sync ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_messaging_proxy_new_for_bus ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusModemMessaging *mm_gdbus_modem_messaging_proxy_new_for_bus_finish ( + GAsyncResult *res, + GError **error); +MmGdbusModemMessaging *mm_gdbus_modem_messaging_proxy_new_for_bus_sync ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + + +/* ---- */ + +#define MM_GDBUS_TYPE_MODEM_MESSAGING_SKELETON (mm_gdbus_modem_messaging_skeleton_get_type ()) +#define MM_GDBUS_MODEM_MESSAGING_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_MESSAGING_SKELETON, MmGdbusModemMessagingSkeleton)) +#define MM_GDBUS_MODEM_MESSAGING_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_MODEM_MESSAGING_SKELETON, MmGdbusModemMessagingSkeletonClass)) +#define MM_GDBUS_MODEM_MESSAGING_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_MODEM_MESSAGING_SKELETON, MmGdbusModemMessagingSkeletonClass)) +#define MM_GDBUS_IS_MODEM_MESSAGING_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_MESSAGING_SKELETON)) +#define MM_GDBUS_IS_MODEM_MESSAGING_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_MODEM_MESSAGING_SKELETON)) + +typedef struct _MmGdbusModemMessagingSkeleton MmGdbusModemMessagingSkeleton; +typedef struct _MmGdbusModemMessagingSkeletonClass MmGdbusModemMessagingSkeletonClass; +typedef struct _MmGdbusModemMessagingSkeletonPrivate MmGdbusModemMessagingSkeletonPrivate; + +struct _MmGdbusModemMessagingSkeleton +{ + /*< private >*/ + GDBusInterfaceSkeleton parent_instance; + MmGdbusModemMessagingSkeletonPrivate *priv; +}; + +struct _MmGdbusModemMessagingSkeletonClass +{ + GDBusInterfaceSkeletonClass parent_class; +}; + +GType mm_gdbus_modem_messaging_skeleton_get_type (void) G_GNUC_CONST; + +MmGdbusModemMessaging *mm_gdbus_modem_messaging_skeleton_new (void); + + +/* ------------------------------------------------------------------------ */ +/* Declarations for org.freedesktop.ModemManager1.Modem.Location */ + +#define MM_GDBUS_TYPE_MODEM_LOCATION (mm_gdbus_modem_location_get_type ()) +#define MM_GDBUS_MODEM_LOCATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_LOCATION, MmGdbusModemLocation)) +#define MM_GDBUS_IS_MODEM_LOCATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_LOCATION)) +#define MM_GDBUS_MODEM_LOCATION_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), MM_GDBUS_TYPE_MODEM_LOCATION, MmGdbusModemLocationIface)) + +struct _MmGdbusModemLocation; +typedef struct _MmGdbusModemLocation MmGdbusModemLocation; +typedef struct _MmGdbusModemLocationIface MmGdbusModemLocationIface; + +struct _MmGdbusModemLocationIface +{ + GTypeInterface parent_iface; + + + gboolean (*handle_get_location) ( + MmGdbusModemLocation *object, + GDBusMethodInvocation *invocation); + + gboolean (*handle_setup) ( + MmGdbusModemLocation *object, + GDBusMethodInvocation *invocation, + guint arg_sources, + gboolean arg_signal_location); + + guint (*get_capabilities) (MmGdbusModemLocation *object); + + guint (*get_enabled) (MmGdbusModemLocation *object); + + GVariant * (*get_location) (MmGdbusModemLocation *object); + + gboolean (*get_signals_location) (MmGdbusModemLocation *object); + +}; + +GType mm_gdbus_modem_location_get_type (void) G_GNUC_CONST; + +GDBusInterfaceInfo *mm_gdbus_modem_location_interface_info (void); +guint mm_gdbus_modem_location_override_properties (GObjectClass *klass, guint property_id_begin); + + +/* D-Bus method call completion functions: */ +void mm_gdbus_modem_location_complete_setup ( + MmGdbusModemLocation *object, + GDBusMethodInvocation *invocation); + +void mm_gdbus_modem_location_complete_get_location ( + MmGdbusModemLocation *object, + GDBusMethodInvocation *invocation, + GVariant *Location); + + + +/* D-Bus method calls: */ +void mm_gdbus_modem_location_call_setup ( + MmGdbusModemLocation *proxy, + guint arg_sources, + gboolean arg_signal_location, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_location_call_setup_finish ( + MmGdbusModemLocation *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_location_call_setup_sync ( + MmGdbusModemLocation *proxy, + guint arg_sources, + gboolean arg_signal_location, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_location_call_get_location ( + MmGdbusModemLocation *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_location_call_get_location_finish ( + MmGdbusModemLocation *proxy, + GVariant **out_Location, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_location_call_get_location_sync ( + MmGdbusModemLocation *proxy, + GVariant **out_Location, + GCancellable *cancellable, + GError **error); + + + +/* D-Bus property accessors: */ +guint mm_gdbus_modem_location_get_capabilities (MmGdbusModemLocation *object); +void mm_gdbus_modem_location_set_capabilities (MmGdbusModemLocation *object, guint value); + +guint mm_gdbus_modem_location_get_enabled (MmGdbusModemLocation *object); +void mm_gdbus_modem_location_set_enabled (MmGdbusModemLocation *object, guint value); + +gboolean mm_gdbus_modem_location_get_signals_location (MmGdbusModemLocation *object); +void mm_gdbus_modem_location_set_signals_location (MmGdbusModemLocation *object, gboolean value); + +GVariant *mm_gdbus_modem_location_get_location (MmGdbusModemLocation *object); +GVariant *mm_gdbus_modem_location_dup_location (MmGdbusModemLocation *object); +void mm_gdbus_modem_location_set_location (MmGdbusModemLocation *object, GVariant *value); + + +/* ---- */ + +#define MM_GDBUS_TYPE_MODEM_LOCATION_PROXY (mm_gdbus_modem_location_proxy_get_type ()) +#define MM_GDBUS_MODEM_LOCATION_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_LOCATION_PROXY, MmGdbusModemLocationProxy)) +#define MM_GDBUS_MODEM_LOCATION_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_MODEM_LOCATION_PROXY, MmGdbusModemLocationProxyClass)) +#define MM_GDBUS_MODEM_LOCATION_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_MODEM_LOCATION_PROXY, MmGdbusModemLocationProxyClass)) +#define MM_GDBUS_IS_MODEM_LOCATION_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_LOCATION_PROXY)) +#define MM_GDBUS_IS_MODEM_LOCATION_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_MODEM_LOCATION_PROXY)) + +typedef struct _MmGdbusModemLocationProxy MmGdbusModemLocationProxy; +typedef struct _MmGdbusModemLocationProxyClass MmGdbusModemLocationProxyClass; +typedef struct _MmGdbusModemLocationProxyPrivate MmGdbusModemLocationProxyPrivate; + +struct _MmGdbusModemLocationProxy +{ + /*< private >*/ + GDBusProxy parent_instance; + MmGdbusModemLocationProxyPrivate *priv; +}; + +struct _MmGdbusModemLocationProxyClass +{ + GDBusProxyClass parent_class; +}; + +GType mm_gdbus_modem_location_proxy_get_type (void) G_GNUC_CONST; + +void mm_gdbus_modem_location_proxy_new ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusModemLocation *mm_gdbus_modem_location_proxy_new_finish ( + GAsyncResult *res, + GError **error); +MmGdbusModemLocation *mm_gdbus_modem_location_proxy_new_sync ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_location_proxy_new_for_bus ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusModemLocation *mm_gdbus_modem_location_proxy_new_for_bus_finish ( + GAsyncResult *res, + GError **error); +MmGdbusModemLocation *mm_gdbus_modem_location_proxy_new_for_bus_sync ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + + +/* ---- */ + +#define MM_GDBUS_TYPE_MODEM_LOCATION_SKELETON (mm_gdbus_modem_location_skeleton_get_type ()) +#define MM_GDBUS_MODEM_LOCATION_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_LOCATION_SKELETON, MmGdbusModemLocationSkeleton)) +#define MM_GDBUS_MODEM_LOCATION_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_MODEM_LOCATION_SKELETON, MmGdbusModemLocationSkeletonClass)) +#define MM_GDBUS_MODEM_LOCATION_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_MODEM_LOCATION_SKELETON, MmGdbusModemLocationSkeletonClass)) +#define MM_GDBUS_IS_MODEM_LOCATION_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_LOCATION_SKELETON)) +#define MM_GDBUS_IS_MODEM_LOCATION_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_MODEM_LOCATION_SKELETON)) + +typedef struct _MmGdbusModemLocationSkeleton MmGdbusModemLocationSkeleton; +typedef struct _MmGdbusModemLocationSkeletonClass MmGdbusModemLocationSkeletonClass; +typedef struct _MmGdbusModemLocationSkeletonPrivate MmGdbusModemLocationSkeletonPrivate; + +struct _MmGdbusModemLocationSkeleton +{ + /*< private >*/ + GDBusInterfaceSkeleton parent_instance; + MmGdbusModemLocationSkeletonPrivate *priv; +}; + +struct _MmGdbusModemLocationSkeletonClass +{ + GDBusInterfaceSkeletonClass parent_class; +}; + +GType mm_gdbus_modem_location_skeleton_get_type (void) G_GNUC_CONST; + +MmGdbusModemLocation *mm_gdbus_modem_location_skeleton_new (void); + + +/* ------------------------------------------------------------------------ */ +/* Declarations for org.freedesktop.ModemManager1.Modem.Time */ + +#define MM_GDBUS_TYPE_MODEM_TIME (mm_gdbus_modem_time_get_type ()) +#define MM_GDBUS_MODEM_TIME(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_TIME, MmGdbusModemTime)) +#define MM_GDBUS_IS_MODEM_TIME(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_TIME)) +#define MM_GDBUS_MODEM_TIME_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), MM_GDBUS_TYPE_MODEM_TIME, MmGdbusModemTimeIface)) + +struct _MmGdbusModemTime; +typedef struct _MmGdbusModemTime MmGdbusModemTime; +typedef struct _MmGdbusModemTimeIface MmGdbusModemTimeIface; + +struct _MmGdbusModemTimeIface +{ + GTypeInterface parent_iface; + + + + gboolean (*handle_get_network_time) ( + MmGdbusModemTime *object, + GDBusMethodInvocation *invocation); + + GVariant * (*get_network_timezone) (MmGdbusModemTime *object); + + void (*network_time_changed) ( + MmGdbusModemTime *object, + const gchar *arg_time); + +}; + +GType mm_gdbus_modem_time_get_type (void) G_GNUC_CONST; + +GDBusInterfaceInfo *mm_gdbus_modem_time_interface_info (void); +guint mm_gdbus_modem_time_override_properties (GObjectClass *klass, guint property_id_begin); + + +/* D-Bus method call completion functions: */ +void mm_gdbus_modem_time_complete_get_network_time ( + MmGdbusModemTime *object, + GDBusMethodInvocation *invocation, + const gchar *time); + + + +/* D-Bus signal emissions functions: */ +void mm_gdbus_modem_time_emit_network_time_changed ( + MmGdbusModemTime *object, + const gchar *arg_time); + + + +/* D-Bus method calls: */ +void mm_gdbus_modem_time_call_get_network_time ( + MmGdbusModemTime *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_time_call_get_network_time_finish ( + MmGdbusModemTime *proxy, + gchar **out_time, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_time_call_get_network_time_sync ( + MmGdbusModemTime *proxy, + gchar **out_time, + GCancellable *cancellable, + GError **error); + + + +/* D-Bus property accessors: */ +GVariant *mm_gdbus_modem_time_get_network_timezone (MmGdbusModemTime *object); +GVariant *mm_gdbus_modem_time_dup_network_timezone (MmGdbusModemTime *object); +void mm_gdbus_modem_time_set_network_timezone (MmGdbusModemTime *object, GVariant *value); + + +/* ---- */ + +#define MM_GDBUS_TYPE_MODEM_TIME_PROXY (mm_gdbus_modem_time_proxy_get_type ()) +#define MM_GDBUS_MODEM_TIME_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_TIME_PROXY, MmGdbusModemTimeProxy)) +#define MM_GDBUS_MODEM_TIME_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_MODEM_TIME_PROXY, MmGdbusModemTimeProxyClass)) +#define MM_GDBUS_MODEM_TIME_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_MODEM_TIME_PROXY, MmGdbusModemTimeProxyClass)) +#define MM_GDBUS_IS_MODEM_TIME_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_TIME_PROXY)) +#define MM_GDBUS_IS_MODEM_TIME_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_MODEM_TIME_PROXY)) + +typedef struct _MmGdbusModemTimeProxy MmGdbusModemTimeProxy; +typedef struct _MmGdbusModemTimeProxyClass MmGdbusModemTimeProxyClass; +typedef struct _MmGdbusModemTimeProxyPrivate MmGdbusModemTimeProxyPrivate; + +struct _MmGdbusModemTimeProxy +{ + /*< private >*/ + GDBusProxy parent_instance; + MmGdbusModemTimeProxyPrivate *priv; +}; + +struct _MmGdbusModemTimeProxyClass +{ + GDBusProxyClass parent_class; +}; + +GType mm_gdbus_modem_time_proxy_get_type (void) G_GNUC_CONST; + +void mm_gdbus_modem_time_proxy_new ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusModemTime *mm_gdbus_modem_time_proxy_new_finish ( + GAsyncResult *res, + GError **error); +MmGdbusModemTime *mm_gdbus_modem_time_proxy_new_sync ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_time_proxy_new_for_bus ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusModemTime *mm_gdbus_modem_time_proxy_new_for_bus_finish ( + GAsyncResult *res, + GError **error); +MmGdbusModemTime *mm_gdbus_modem_time_proxy_new_for_bus_sync ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + + +/* ---- */ + +#define MM_GDBUS_TYPE_MODEM_TIME_SKELETON (mm_gdbus_modem_time_skeleton_get_type ()) +#define MM_GDBUS_MODEM_TIME_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_TIME_SKELETON, MmGdbusModemTimeSkeleton)) +#define MM_GDBUS_MODEM_TIME_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_MODEM_TIME_SKELETON, MmGdbusModemTimeSkeletonClass)) +#define MM_GDBUS_MODEM_TIME_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_MODEM_TIME_SKELETON, MmGdbusModemTimeSkeletonClass)) +#define MM_GDBUS_IS_MODEM_TIME_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_TIME_SKELETON)) +#define MM_GDBUS_IS_MODEM_TIME_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_MODEM_TIME_SKELETON)) + +typedef struct _MmGdbusModemTimeSkeleton MmGdbusModemTimeSkeleton; +typedef struct _MmGdbusModemTimeSkeletonClass MmGdbusModemTimeSkeletonClass; +typedef struct _MmGdbusModemTimeSkeletonPrivate MmGdbusModemTimeSkeletonPrivate; + +struct _MmGdbusModemTimeSkeleton +{ + /*< private >*/ + GDBusInterfaceSkeleton parent_instance; + MmGdbusModemTimeSkeletonPrivate *priv; +}; + +struct _MmGdbusModemTimeSkeletonClass +{ + GDBusInterfaceSkeletonClass parent_class; +}; + +GType mm_gdbus_modem_time_skeleton_get_type (void) G_GNUC_CONST; + +MmGdbusModemTime *mm_gdbus_modem_time_skeleton_new (void); + + +/* ------------------------------------------------------------------------ */ +/* Declarations for org.freedesktop.ModemManager1.Modem.Firmware */ + +#define MM_GDBUS_TYPE_MODEM_FIRMWARE (mm_gdbus_modem_firmware_get_type ()) +#define MM_GDBUS_MODEM_FIRMWARE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_FIRMWARE, MmGdbusModemFirmware)) +#define MM_GDBUS_IS_MODEM_FIRMWARE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_FIRMWARE)) +#define MM_GDBUS_MODEM_FIRMWARE_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), MM_GDBUS_TYPE_MODEM_FIRMWARE, MmGdbusModemFirmwareIface)) + +struct _MmGdbusModemFirmware; +typedef struct _MmGdbusModemFirmware MmGdbusModemFirmware; +typedef struct _MmGdbusModemFirmwareIface MmGdbusModemFirmwareIface; + +struct _MmGdbusModemFirmwareIface +{ + GTypeInterface parent_iface; + + gboolean (*handle_list) ( + MmGdbusModemFirmware *object, + GDBusMethodInvocation *invocation); + + gboolean (*handle_select) ( + MmGdbusModemFirmware *object, + GDBusMethodInvocation *invocation, + const gchar *arg_uniqueid); + +}; + +GType mm_gdbus_modem_firmware_get_type (void) G_GNUC_CONST; + +GDBusInterfaceInfo *mm_gdbus_modem_firmware_interface_info (void); +guint mm_gdbus_modem_firmware_override_properties (GObjectClass *klass, guint property_id_begin); + + +/* D-Bus method call completion functions: */ +void mm_gdbus_modem_firmware_complete_list ( + MmGdbusModemFirmware *object, + GDBusMethodInvocation *invocation, + const gchar *selected, + GVariant *installed); + +void mm_gdbus_modem_firmware_complete_select ( + MmGdbusModemFirmware *object, + GDBusMethodInvocation *invocation); + + + +/* D-Bus method calls: */ +void mm_gdbus_modem_firmware_call_list ( + MmGdbusModemFirmware *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_firmware_call_list_finish ( + MmGdbusModemFirmware *proxy, + gchar **out_selected, + GVariant **out_installed, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_firmware_call_list_sync ( + MmGdbusModemFirmware *proxy, + gchar **out_selected, + GVariant **out_installed, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_firmware_call_select ( + MmGdbusModemFirmware *proxy, + const gchar *arg_uniqueid, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_firmware_call_select_finish ( + MmGdbusModemFirmware *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_firmware_call_select_sync ( + MmGdbusModemFirmware *proxy, + const gchar *arg_uniqueid, + GCancellable *cancellable, + GError **error); + + + +/* ---- */ + +#define MM_GDBUS_TYPE_MODEM_FIRMWARE_PROXY (mm_gdbus_modem_firmware_proxy_get_type ()) +#define MM_GDBUS_MODEM_FIRMWARE_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_FIRMWARE_PROXY, MmGdbusModemFirmwareProxy)) +#define MM_GDBUS_MODEM_FIRMWARE_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_MODEM_FIRMWARE_PROXY, MmGdbusModemFirmwareProxyClass)) +#define MM_GDBUS_MODEM_FIRMWARE_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_MODEM_FIRMWARE_PROXY, MmGdbusModemFirmwareProxyClass)) +#define MM_GDBUS_IS_MODEM_FIRMWARE_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_FIRMWARE_PROXY)) +#define MM_GDBUS_IS_MODEM_FIRMWARE_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_MODEM_FIRMWARE_PROXY)) + +typedef struct _MmGdbusModemFirmwareProxy MmGdbusModemFirmwareProxy; +typedef struct _MmGdbusModemFirmwareProxyClass MmGdbusModemFirmwareProxyClass; +typedef struct _MmGdbusModemFirmwareProxyPrivate MmGdbusModemFirmwareProxyPrivate; + +struct _MmGdbusModemFirmwareProxy +{ + /*< private >*/ + GDBusProxy parent_instance; + MmGdbusModemFirmwareProxyPrivate *priv; +}; + +struct _MmGdbusModemFirmwareProxyClass +{ + GDBusProxyClass parent_class; +}; + +GType mm_gdbus_modem_firmware_proxy_get_type (void) G_GNUC_CONST; + +void mm_gdbus_modem_firmware_proxy_new ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusModemFirmware *mm_gdbus_modem_firmware_proxy_new_finish ( + GAsyncResult *res, + GError **error); +MmGdbusModemFirmware *mm_gdbus_modem_firmware_proxy_new_sync ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_firmware_proxy_new_for_bus ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusModemFirmware *mm_gdbus_modem_firmware_proxy_new_for_bus_finish ( + GAsyncResult *res, + GError **error); +MmGdbusModemFirmware *mm_gdbus_modem_firmware_proxy_new_for_bus_sync ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + + +/* ---- */ + +#define MM_GDBUS_TYPE_MODEM_FIRMWARE_SKELETON (mm_gdbus_modem_firmware_skeleton_get_type ()) +#define MM_GDBUS_MODEM_FIRMWARE_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_FIRMWARE_SKELETON, MmGdbusModemFirmwareSkeleton)) +#define MM_GDBUS_MODEM_FIRMWARE_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_MODEM_FIRMWARE_SKELETON, MmGdbusModemFirmwareSkeletonClass)) +#define MM_GDBUS_MODEM_FIRMWARE_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_MODEM_FIRMWARE_SKELETON, MmGdbusModemFirmwareSkeletonClass)) +#define MM_GDBUS_IS_MODEM_FIRMWARE_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_FIRMWARE_SKELETON)) +#define MM_GDBUS_IS_MODEM_FIRMWARE_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_MODEM_FIRMWARE_SKELETON)) + +typedef struct _MmGdbusModemFirmwareSkeleton MmGdbusModemFirmwareSkeleton; +typedef struct _MmGdbusModemFirmwareSkeletonClass MmGdbusModemFirmwareSkeletonClass; +typedef struct _MmGdbusModemFirmwareSkeletonPrivate MmGdbusModemFirmwareSkeletonPrivate; + +struct _MmGdbusModemFirmwareSkeleton +{ + /*< private >*/ + GDBusInterfaceSkeleton parent_instance; + MmGdbusModemFirmwareSkeletonPrivate *priv; +}; + +struct _MmGdbusModemFirmwareSkeletonClass +{ + GDBusInterfaceSkeletonClass parent_class; +}; + +GType mm_gdbus_modem_firmware_skeleton_get_type (void) G_GNUC_CONST; + +MmGdbusModemFirmware *mm_gdbus_modem_firmware_skeleton_new (void); + + +/* ------------------------------------------------------------------------ */ +/* Declarations for org.freedesktop.ModemManager1.Modem.Contacts */ + +#define MM_GDBUS_TYPE_MODEM_CONTACTS (mm_gdbus_modem_contacts_get_type ()) +#define MM_GDBUS_MODEM_CONTACTS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_CONTACTS, MmGdbusModemContacts)) +#define MM_GDBUS_IS_MODEM_CONTACTS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_CONTACTS)) +#define MM_GDBUS_MODEM_CONTACTS_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), MM_GDBUS_TYPE_MODEM_CONTACTS, MmGdbusModemContactsIface)) + +struct _MmGdbusModemContacts; +typedef struct _MmGdbusModemContacts MmGdbusModemContacts; +typedef struct _MmGdbusModemContactsIface MmGdbusModemContactsIface; + +struct _MmGdbusModemContactsIface +{ + GTypeInterface parent_iface; + + + gboolean (*handle_add) ( + MmGdbusModemContacts *object, + GDBusMethodInvocation *invocation, + GVariant *arg_properties); + + gboolean (*handle_delete) ( + MmGdbusModemContacts *object, + GDBusMethodInvocation *invocation, + guint arg_index); + + gboolean (*handle_find) ( + MmGdbusModemContacts *object, + GDBusMethodInvocation *invocation, + const gchar *arg_pattern); + + gboolean (*handle_get) ( + MmGdbusModemContacts *object, + GDBusMethodInvocation *invocation, + guint arg_index); + + gboolean (*handle_get_count) ( + MmGdbusModemContacts *object, + GDBusMethodInvocation *invocation); + + gboolean (*handle_list) ( + MmGdbusModemContacts *object, + GDBusMethodInvocation *invocation); + + void (*added) ( + MmGdbusModemContacts *object, + guint arg_index, + GVariant *arg_properties); + + void (*deleted) ( + MmGdbusModemContacts *object, + guint arg_index); + +}; + +GType mm_gdbus_modem_contacts_get_type (void) G_GNUC_CONST; + +GDBusInterfaceInfo *mm_gdbus_modem_contacts_interface_info (void); +guint mm_gdbus_modem_contacts_override_properties (GObjectClass *klass, guint property_id_begin); + + +/* D-Bus method call completion functions: */ +void mm_gdbus_modem_contacts_complete_add ( + MmGdbusModemContacts *object, + GDBusMethodInvocation *invocation, + guint index); + +void mm_gdbus_modem_contacts_complete_delete ( + MmGdbusModemContacts *object, + GDBusMethodInvocation *invocation); + +void mm_gdbus_modem_contacts_complete_get ( + MmGdbusModemContacts *object, + GDBusMethodInvocation *invocation, + GVariant *properties); + +void mm_gdbus_modem_contacts_complete_list ( + MmGdbusModemContacts *object, + GDBusMethodInvocation *invocation, + GVariant *results); + +void mm_gdbus_modem_contacts_complete_find ( + MmGdbusModemContacts *object, + GDBusMethodInvocation *invocation, + GVariant *results); + +void mm_gdbus_modem_contacts_complete_get_count ( + MmGdbusModemContacts *object, + GDBusMethodInvocation *invocation, + guint count); + + + +/* D-Bus signal emissions functions: */ +void mm_gdbus_modem_contacts_emit_added ( + MmGdbusModemContacts *object, + guint arg_index, + GVariant *arg_properties); + +void mm_gdbus_modem_contacts_emit_deleted ( + MmGdbusModemContacts *object, + guint arg_index); + + + +/* D-Bus method calls: */ +void mm_gdbus_modem_contacts_call_add ( + MmGdbusModemContacts *proxy, + GVariant *arg_properties, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_contacts_call_add_finish ( + MmGdbusModemContacts *proxy, + guint *out_index, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_contacts_call_add_sync ( + MmGdbusModemContacts *proxy, + GVariant *arg_properties, + guint *out_index, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_contacts_call_delete ( + MmGdbusModemContacts *proxy, + guint arg_index, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_contacts_call_delete_finish ( + MmGdbusModemContacts *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_contacts_call_delete_sync ( + MmGdbusModemContacts *proxy, + guint arg_index, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_contacts_call_get ( + MmGdbusModemContacts *proxy, + guint arg_index, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_contacts_call_get_finish ( + MmGdbusModemContacts *proxy, + GVariant **out_properties, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_contacts_call_get_sync ( + MmGdbusModemContacts *proxy, + guint arg_index, + GVariant **out_properties, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_contacts_call_list ( + MmGdbusModemContacts *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_contacts_call_list_finish ( + MmGdbusModemContacts *proxy, + GVariant **out_results, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_contacts_call_list_sync ( + MmGdbusModemContacts *proxy, + GVariant **out_results, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_contacts_call_find ( + MmGdbusModemContacts *proxy, + const gchar *arg_pattern, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_contacts_call_find_finish ( + MmGdbusModemContacts *proxy, + GVariant **out_results, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_contacts_call_find_sync ( + MmGdbusModemContacts *proxy, + const gchar *arg_pattern, + GVariant **out_results, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_contacts_call_get_count ( + MmGdbusModemContacts *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_contacts_call_get_count_finish ( + MmGdbusModemContacts *proxy, + guint *out_count, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_contacts_call_get_count_sync ( + MmGdbusModemContacts *proxy, + guint *out_count, + GCancellable *cancellable, + GError **error); + + + +/* ---- */ + +#define MM_GDBUS_TYPE_MODEM_CONTACTS_PROXY (mm_gdbus_modem_contacts_proxy_get_type ()) +#define MM_GDBUS_MODEM_CONTACTS_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_CONTACTS_PROXY, MmGdbusModemContactsProxy)) +#define MM_GDBUS_MODEM_CONTACTS_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_MODEM_CONTACTS_PROXY, MmGdbusModemContactsProxyClass)) +#define MM_GDBUS_MODEM_CONTACTS_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_MODEM_CONTACTS_PROXY, MmGdbusModemContactsProxyClass)) +#define MM_GDBUS_IS_MODEM_CONTACTS_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_CONTACTS_PROXY)) +#define MM_GDBUS_IS_MODEM_CONTACTS_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_MODEM_CONTACTS_PROXY)) + +typedef struct _MmGdbusModemContactsProxy MmGdbusModemContactsProxy; +typedef struct _MmGdbusModemContactsProxyClass MmGdbusModemContactsProxyClass; +typedef struct _MmGdbusModemContactsProxyPrivate MmGdbusModemContactsProxyPrivate; + +struct _MmGdbusModemContactsProxy +{ + /*< private >*/ + GDBusProxy parent_instance; + MmGdbusModemContactsProxyPrivate *priv; +}; + +struct _MmGdbusModemContactsProxyClass +{ + GDBusProxyClass parent_class; +}; + +GType mm_gdbus_modem_contacts_proxy_get_type (void) G_GNUC_CONST; + +void mm_gdbus_modem_contacts_proxy_new ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusModemContacts *mm_gdbus_modem_contacts_proxy_new_finish ( + GAsyncResult *res, + GError **error); +MmGdbusModemContacts *mm_gdbus_modem_contacts_proxy_new_sync ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_contacts_proxy_new_for_bus ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusModemContacts *mm_gdbus_modem_contacts_proxy_new_for_bus_finish ( + GAsyncResult *res, + GError **error); +MmGdbusModemContacts *mm_gdbus_modem_contacts_proxy_new_for_bus_sync ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + + +/* ---- */ + +#define MM_GDBUS_TYPE_MODEM_CONTACTS_SKELETON (mm_gdbus_modem_contacts_skeleton_get_type ()) +#define MM_GDBUS_MODEM_CONTACTS_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_CONTACTS_SKELETON, MmGdbusModemContactsSkeleton)) +#define MM_GDBUS_MODEM_CONTACTS_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_MODEM_CONTACTS_SKELETON, MmGdbusModemContactsSkeletonClass)) +#define MM_GDBUS_MODEM_CONTACTS_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_MODEM_CONTACTS_SKELETON, MmGdbusModemContactsSkeletonClass)) +#define MM_GDBUS_IS_MODEM_CONTACTS_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_CONTACTS_SKELETON)) +#define MM_GDBUS_IS_MODEM_CONTACTS_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_MODEM_CONTACTS_SKELETON)) + +typedef struct _MmGdbusModemContactsSkeleton MmGdbusModemContactsSkeleton; +typedef struct _MmGdbusModemContactsSkeletonClass MmGdbusModemContactsSkeletonClass; +typedef struct _MmGdbusModemContactsSkeletonPrivate MmGdbusModemContactsSkeletonPrivate; + +struct _MmGdbusModemContactsSkeleton +{ + /*< private >*/ + GDBusInterfaceSkeleton parent_instance; + MmGdbusModemContactsSkeletonPrivate *priv; +}; + +struct _MmGdbusModemContactsSkeletonClass +{ + GDBusInterfaceSkeletonClass parent_class; +}; + +GType mm_gdbus_modem_contacts_skeleton_get_type (void) G_GNUC_CONST; + +MmGdbusModemContacts *mm_gdbus_modem_contacts_skeleton_new (void); + + +/* ------------------------------------------------------------------------ */ +/* Declarations for org.freedesktop.ModemManager1.Modem.ModemCdma */ + +#define MM_GDBUS_TYPE_MODEM_CDMA (mm_gdbus_modem_cdma_get_type ()) +#define MM_GDBUS_MODEM_CDMA(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_CDMA, MmGdbusModemCdma)) +#define MM_GDBUS_IS_MODEM_CDMA(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_CDMA)) +#define MM_GDBUS_MODEM_CDMA_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), MM_GDBUS_TYPE_MODEM_CDMA, MmGdbusModemCdmaIface)) + +struct _MmGdbusModemCdma; +typedef struct _MmGdbusModemCdma MmGdbusModemCdma; +typedef struct _MmGdbusModemCdmaIface MmGdbusModemCdmaIface; + +struct _MmGdbusModemCdmaIface +{ + GTypeInterface parent_iface; + + + + gboolean (*handle_activate) ( + MmGdbusModemCdma *object, + GDBusMethodInvocation *invocation, + const gchar *arg_carrier_code); + + gboolean (*handle_activate_manual) ( + MmGdbusModemCdma *object, + GDBusMethodInvocation *invocation, + GVariant *arg_properties); + + guint (*get_activation_state) (MmGdbusModemCdma *object); + + guint (*get_cdma1x_registration_state) (MmGdbusModemCdma *object); + + const gchar * (*get_esn) (MmGdbusModemCdma *object); + + guint (*get_evdo_registration_state) (MmGdbusModemCdma *object); + + const gchar * (*get_meid) (MmGdbusModemCdma *object); + + guint (*get_nid) (MmGdbusModemCdma *object); + + guint (*get_sid) (MmGdbusModemCdma *object); + + void (*activation_state_changed) ( + MmGdbusModemCdma *object, + guint arg_activation_state, + guint arg_activation_error, + GVariant *arg_status_changes); + +}; + +GType mm_gdbus_modem_cdma_get_type (void) G_GNUC_CONST; + +GDBusInterfaceInfo *mm_gdbus_modem_cdma_interface_info (void); +guint mm_gdbus_modem_cdma_override_properties (GObjectClass *klass, guint property_id_begin); + + +/* D-Bus method call completion functions: */ +void mm_gdbus_modem_cdma_complete_activate ( + MmGdbusModemCdma *object, + GDBusMethodInvocation *invocation); + +void mm_gdbus_modem_cdma_complete_activate_manual ( + MmGdbusModemCdma *object, + GDBusMethodInvocation *invocation); + + + +/* D-Bus signal emissions functions: */ +void mm_gdbus_modem_cdma_emit_activation_state_changed ( + MmGdbusModemCdma *object, + guint arg_activation_state, + guint arg_activation_error, + GVariant *arg_status_changes); + + + +/* D-Bus method calls: */ +void mm_gdbus_modem_cdma_call_activate ( + MmGdbusModemCdma *proxy, + const gchar *arg_carrier_code, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_cdma_call_activate_finish ( + MmGdbusModemCdma *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_cdma_call_activate_sync ( + MmGdbusModemCdma *proxy, + const gchar *arg_carrier_code, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_cdma_call_activate_manual ( + MmGdbusModemCdma *proxy, + GVariant *arg_properties, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_cdma_call_activate_manual_finish ( + MmGdbusModemCdma *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_cdma_call_activate_manual_sync ( + MmGdbusModemCdma *proxy, + GVariant *arg_properties, + GCancellable *cancellable, + GError **error); + + + +/* D-Bus property accessors: */ +guint mm_gdbus_modem_cdma_get_activation_state (MmGdbusModemCdma *object); +void mm_gdbus_modem_cdma_set_activation_state (MmGdbusModemCdma *object, guint value); + +const gchar *mm_gdbus_modem_cdma_get_meid (MmGdbusModemCdma *object); +gchar *mm_gdbus_modem_cdma_dup_meid (MmGdbusModemCdma *object); +void mm_gdbus_modem_cdma_set_meid (MmGdbusModemCdma *object, const gchar *value); + +const gchar *mm_gdbus_modem_cdma_get_esn (MmGdbusModemCdma *object); +gchar *mm_gdbus_modem_cdma_dup_esn (MmGdbusModemCdma *object); +void mm_gdbus_modem_cdma_set_esn (MmGdbusModemCdma *object, const gchar *value); + +guint mm_gdbus_modem_cdma_get_sid (MmGdbusModemCdma *object); +void mm_gdbus_modem_cdma_set_sid (MmGdbusModemCdma *object, guint value); + +guint mm_gdbus_modem_cdma_get_nid (MmGdbusModemCdma *object); +void mm_gdbus_modem_cdma_set_nid (MmGdbusModemCdma *object, guint value); + +guint mm_gdbus_modem_cdma_get_cdma1x_registration_state (MmGdbusModemCdma *object); +void mm_gdbus_modem_cdma_set_cdma1x_registration_state (MmGdbusModemCdma *object, guint value); + +guint mm_gdbus_modem_cdma_get_evdo_registration_state (MmGdbusModemCdma *object); +void mm_gdbus_modem_cdma_set_evdo_registration_state (MmGdbusModemCdma *object, guint value); + + +/* ---- */ + +#define MM_GDBUS_TYPE_MODEM_CDMA_PROXY (mm_gdbus_modem_cdma_proxy_get_type ()) +#define MM_GDBUS_MODEM_CDMA_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_CDMA_PROXY, MmGdbusModemCdmaProxy)) +#define MM_GDBUS_MODEM_CDMA_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_MODEM_CDMA_PROXY, MmGdbusModemCdmaProxyClass)) +#define MM_GDBUS_MODEM_CDMA_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_MODEM_CDMA_PROXY, MmGdbusModemCdmaProxyClass)) +#define MM_GDBUS_IS_MODEM_CDMA_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_CDMA_PROXY)) +#define MM_GDBUS_IS_MODEM_CDMA_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_MODEM_CDMA_PROXY)) + +typedef struct _MmGdbusModemCdmaProxy MmGdbusModemCdmaProxy; +typedef struct _MmGdbusModemCdmaProxyClass MmGdbusModemCdmaProxyClass; +typedef struct _MmGdbusModemCdmaProxyPrivate MmGdbusModemCdmaProxyPrivate; + +struct _MmGdbusModemCdmaProxy +{ + /*< private >*/ + GDBusProxy parent_instance; + MmGdbusModemCdmaProxyPrivate *priv; +}; + +struct _MmGdbusModemCdmaProxyClass +{ + GDBusProxyClass parent_class; +}; + +GType mm_gdbus_modem_cdma_proxy_get_type (void) G_GNUC_CONST; + +void mm_gdbus_modem_cdma_proxy_new ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusModemCdma *mm_gdbus_modem_cdma_proxy_new_finish ( + GAsyncResult *res, + GError **error); +MmGdbusModemCdma *mm_gdbus_modem_cdma_proxy_new_sync ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_cdma_proxy_new_for_bus ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusModemCdma *mm_gdbus_modem_cdma_proxy_new_for_bus_finish ( + GAsyncResult *res, + GError **error); +MmGdbusModemCdma *mm_gdbus_modem_cdma_proxy_new_for_bus_sync ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + + +/* ---- */ + +#define MM_GDBUS_TYPE_MODEM_CDMA_SKELETON (mm_gdbus_modem_cdma_skeleton_get_type ()) +#define MM_GDBUS_MODEM_CDMA_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_CDMA_SKELETON, MmGdbusModemCdmaSkeleton)) +#define MM_GDBUS_MODEM_CDMA_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_MODEM_CDMA_SKELETON, MmGdbusModemCdmaSkeletonClass)) +#define MM_GDBUS_MODEM_CDMA_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_MODEM_CDMA_SKELETON, MmGdbusModemCdmaSkeletonClass)) +#define MM_GDBUS_IS_MODEM_CDMA_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_CDMA_SKELETON)) +#define MM_GDBUS_IS_MODEM_CDMA_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_MODEM_CDMA_SKELETON)) + +typedef struct _MmGdbusModemCdmaSkeleton MmGdbusModemCdmaSkeleton; +typedef struct _MmGdbusModemCdmaSkeletonClass MmGdbusModemCdmaSkeletonClass; +typedef struct _MmGdbusModemCdmaSkeletonPrivate MmGdbusModemCdmaSkeletonPrivate; + +struct _MmGdbusModemCdmaSkeleton +{ + /*< private >*/ + GDBusInterfaceSkeleton parent_instance; + MmGdbusModemCdmaSkeletonPrivate *priv; +}; + +struct _MmGdbusModemCdmaSkeletonClass +{ + GDBusInterfaceSkeletonClass parent_class; +}; + +GType mm_gdbus_modem_cdma_skeleton_get_type (void) G_GNUC_CONST; + +MmGdbusModemCdma *mm_gdbus_modem_cdma_skeleton_new (void); + + +/* ------------------------------------------------------------------------ */ +/* Declarations for org.freedesktop.ModemManager1.Modem.Modem3gpp */ + +#define MM_GDBUS_TYPE_MODEM3GPP (mm_gdbus_modem3gpp_get_type ()) +#define MM_GDBUS_MODEM3GPP(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM3GPP, MmGdbusModem3gpp)) +#define MM_GDBUS_IS_MODEM3GPP(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM3GPP)) +#define MM_GDBUS_MODEM3GPP_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), MM_GDBUS_TYPE_MODEM3GPP, MmGdbusModem3gppIface)) + +struct _MmGdbusModem3gpp; +typedef struct _MmGdbusModem3gpp MmGdbusModem3gpp; +typedef struct _MmGdbusModem3gppIface MmGdbusModem3gppIface; + +struct _MmGdbusModem3gppIface +{ + GTypeInterface parent_iface; + + + gboolean (*handle_register) ( + MmGdbusModem3gpp *object, + GDBusMethodInvocation *invocation, + const gchar *arg_operator_id); + + gboolean (*handle_scan) ( + MmGdbusModem3gpp *object, + GDBusMethodInvocation *invocation); + + guint (*get_enabled_facility_locks) (MmGdbusModem3gpp *object); + + const gchar * (*get_imei) (MmGdbusModem3gpp *object); + + const gchar * (*get_operator_code) (MmGdbusModem3gpp *object); + + const gchar * (*get_operator_name) (MmGdbusModem3gpp *object); + + guint (*get_registration_state) (MmGdbusModem3gpp *object); + +}; + +GType mm_gdbus_modem3gpp_get_type (void) G_GNUC_CONST; + +GDBusInterfaceInfo *mm_gdbus_modem3gpp_interface_info (void); +guint mm_gdbus_modem3gpp_override_properties (GObjectClass *klass, guint property_id_begin); + + +/* D-Bus method call completion functions: */ +void mm_gdbus_modem3gpp_complete_register ( + MmGdbusModem3gpp *object, + GDBusMethodInvocation *invocation); + +void mm_gdbus_modem3gpp_complete_scan ( + MmGdbusModem3gpp *object, + GDBusMethodInvocation *invocation, + GVariant *results); + + + +/* D-Bus method calls: */ +void mm_gdbus_modem3gpp_call_register ( + MmGdbusModem3gpp *proxy, + const gchar *arg_operator_id, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem3gpp_call_register_finish ( + MmGdbusModem3gpp *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem3gpp_call_register_sync ( + MmGdbusModem3gpp *proxy, + const gchar *arg_operator_id, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem3gpp_call_scan ( + MmGdbusModem3gpp *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem3gpp_call_scan_finish ( + MmGdbusModem3gpp *proxy, + GVariant **out_results, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem3gpp_call_scan_sync ( + MmGdbusModem3gpp *proxy, + GVariant **out_results, + GCancellable *cancellable, + GError **error); + + + +/* D-Bus property accessors: */ +const gchar *mm_gdbus_modem3gpp_get_imei (MmGdbusModem3gpp *object); +gchar *mm_gdbus_modem3gpp_dup_imei (MmGdbusModem3gpp *object); +void mm_gdbus_modem3gpp_set_imei (MmGdbusModem3gpp *object, const gchar *value); + +guint mm_gdbus_modem3gpp_get_registration_state (MmGdbusModem3gpp *object); +void mm_gdbus_modem3gpp_set_registration_state (MmGdbusModem3gpp *object, guint value); + +const gchar *mm_gdbus_modem3gpp_get_operator_code (MmGdbusModem3gpp *object); +gchar *mm_gdbus_modem3gpp_dup_operator_code (MmGdbusModem3gpp *object); +void mm_gdbus_modem3gpp_set_operator_code (MmGdbusModem3gpp *object, const gchar *value); + +const gchar *mm_gdbus_modem3gpp_get_operator_name (MmGdbusModem3gpp *object); +gchar *mm_gdbus_modem3gpp_dup_operator_name (MmGdbusModem3gpp *object); +void mm_gdbus_modem3gpp_set_operator_name (MmGdbusModem3gpp *object, const gchar *value); + +guint mm_gdbus_modem3gpp_get_enabled_facility_locks (MmGdbusModem3gpp *object); +void mm_gdbus_modem3gpp_set_enabled_facility_locks (MmGdbusModem3gpp *object, guint value); + + +/* ---- */ + +#define MM_GDBUS_TYPE_MODEM3GPP_PROXY (mm_gdbus_modem3gpp_proxy_get_type ()) +#define MM_GDBUS_MODEM3GPP_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM3GPP_PROXY, MmGdbusModem3gppProxy)) +#define MM_GDBUS_MODEM3GPP_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_MODEM3GPP_PROXY, MmGdbusModem3gppProxyClass)) +#define MM_GDBUS_MODEM3GPP_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_MODEM3GPP_PROXY, MmGdbusModem3gppProxyClass)) +#define MM_GDBUS_IS_MODEM3GPP_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM3GPP_PROXY)) +#define MM_GDBUS_IS_MODEM3GPP_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_MODEM3GPP_PROXY)) + +typedef struct _MmGdbusModem3gppProxy MmGdbusModem3gppProxy; +typedef struct _MmGdbusModem3gppProxyClass MmGdbusModem3gppProxyClass; +typedef struct _MmGdbusModem3gppProxyPrivate MmGdbusModem3gppProxyPrivate; + +struct _MmGdbusModem3gppProxy +{ + /*< private >*/ + GDBusProxy parent_instance; + MmGdbusModem3gppProxyPrivate *priv; +}; + +struct _MmGdbusModem3gppProxyClass +{ + GDBusProxyClass parent_class; +}; + +GType mm_gdbus_modem3gpp_proxy_get_type (void) G_GNUC_CONST; + +void mm_gdbus_modem3gpp_proxy_new ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusModem3gpp *mm_gdbus_modem3gpp_proxy_new_finish ( + GAsyncResult *res, + GError **error); +MmGdbusModem3gpp *mm_gdbus_modem3gpp_proxy_new_sync ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem3gpp_proxy_new_for_bus ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusModem3gpp *mm_gdbus_modem3gpp_proxy_new_for_bus_finish ( + GAsyncResult *res, + GError **error); +MmGdbusModem3gpp *mm_gdbus_modem3gpp_proxy_new_for_bus_sync ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + + +/* ---- */ + +#define MM_GDBUS_TYPE_MODEM3GPP_SKELETON (mm_gdbus_modem3gpp_skeleton_get_type ()) +#define MM_GDBUS_MODEM3GPP_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM3GPP_SKELETON, MmGdbusModem3gppSkeleton)) +#define MM_GDBUS_MODEM3GPP_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_MODEM3GPP_SKELETON, MmGdbusModem3gppSkeletonClass)) +#define MM_GDBUS_MODEM3GPP_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_MODEM3GPP_SKELETON, MmGdbusModem3gppSkeletonClass)) +#define MM_GDBUS_IS_MODEM3GPP_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM3GPP_SKELETON)) +#define MM_GDBUS_IS_MODEM3GPP_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_MODEM3GPP_SKELETON)) + +typedef struct _MmGdbusModem3gppSkeleton MmGdbusModem3gppSkeleton; +typedef struct _MmGdbusModem3gppSkeletonClass MmGdbusModem3gppSkeletonClass; +typedef struct _MmGdbusModem3gppSkeletonPrivate MmGdbusModem3gppSkeletonPrivate; + +struct _MmGdbusModem3gppSkeleton +{ + /*< private >*/ + GDBusInterfaceSkeleton parent_instance; + MmGdbusModem3gppSkeletonPrivate *priv; +}; + +struct _MmGdbusModem3gppSkeletonClass +{ + GDBusInterfaceSkeletonClass parent_class; +}; + +GType mm_gdbus_modem3gpp_skeleton_get_type (void) G_GNUC_CONST; + +MmGdbusModem3gpp *mm_gdbus_modem3gpp_skeleton_new (void); + + +/* ------------------------------------------------------------------------ */ +/* Declarations for org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd */ + +#define MM_GDBUS_TYPE_MODEM3GPP_USSD (mm_gdbus_modem3gpp_ussd_get_type ()) +#define MM_GDBUS_MODEM3GPP_USSD(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM3GPP_USSD, MmGdbusModem3gppUssd)) +#define MM_GDBUS_IS_MODEM3GPP_USSD(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM3GPP_USSD)) +#define MM_GDBUS_MODEM3GPP_USSD_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), MM_GDBUS_TYPE_MODEM3GPP_USSD, MmGdbusModem3gppUssdIface)) + +struct _MmGdbusModem3gppUssd; +typedef struct _MmGdbusModem3gppUssd MmGdbusModem3gppUssd; +typedef struct _MmGdbusModem3gppUssdIface MmGdbusModem3gppUssdIface; + +struct _MmGdbusModem3gppUssdIface +{ + GTypeInterface parent_iface; + + + gboolean (*handle_cancel) ( + MmGdbusModem3gppUssd *object, + GDBusMethodInvocation *invocation); + + gboolean (*handle_initiate) ( + MmGdbusModem3gppUssd *object, + GDBusMethodInvocation *invocation, + const gchar *arg_command); + + gboolean (*handle_respond) ( + MmGdbusModem3gppUssd *object, + GDBusMethodInvocation *invocation, + const gchar *arg_response); + + const gchar * (*get_network_notification) (MmGdbusModem3gppUssd *object); + + const gchar * (*get_network_request) (MmGdbusModem3gppUssd *object); + + guint (*get_state) (MmGdbusModem3gppUssd *object); + +}; + +GType mm_gdbus_modem3gpp_ussd_get_type (void) G_GNUC_CONST; + +GDBusInterfaceInfo *mm_gdbus_modem3gpp_ussd_interface_info (void); +guint mm_gdbus_modem3gpp_ussd_override_properties (GObjectClass *klass, guint property_id_begin); + + +/* D-Bus method call completion functions: */ +void mm_gdbus_modem3gpp_ussd_complete_initiate ( + MmGdbusModem3gppUssd *object, + GDBusMethodInvocation *invocation, + const gchar *reply); + +void mm_gdbus_modem3gpp_ussd_complete_respond ( + MmGdbusModem3gppUssd *object, + GDBusMethodInvocation *invocation, + const gchar *reply); + +void mm_gdbus_modem3gpp_ussd_complete_cancel ( + MmGdbusModem3gppUssd *object, + GDBusMethodInvocation *invocation); + + + +/* D-Bus method calls: */ +void mm_gdbus_modem3gpp_ussd_call_initiate ( + MmGdbusModem3gppUssd *proxy, + const gchar *arg_command, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem3gpp_ussd_call_initiate_finish ( + MmGdbusModem3gppUssd *proxy, + gchar **out_reply, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem3gpp_ussd_call_initiate_sync ( + MmGdbusModem3gppUssd *proxy, + const gchar *arg_command, + gchar **out_reply, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem3gpp_ussd_call_respond ( + MmGdbusModem3gppUssd *proxy, + const gchar *arg_response, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem3gpp_ussd_call_respond_finish ( + MmGdbusModem3gppUssd *proxy, + gchar **out_reply, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem3gpp_ussd_call_respond_sync ( + MmGdbusModem3gppUssd *proxy, + const gchar *arg_response, + gchar **out_reply, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem3gpp_ussd_call_cancel ( + MmGdbusModem3gppUssd *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem3gpp_ussd_call_cancel_finish ( + MmGdbusModem3gppUssd *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem3gpp_ussd_call_cancel_sync ( + MmGdbusModem3gppUssd *proxy, + GCancellable *cancellable, + GError **error); + + + +/* D-Bus property accessors: */ +guint mm_gdbus_modem3gpp_ussd_get_state (MmGdbusModem3gppUssd *object); +void mm_gdbus_modem3gpp_ussd_set_state (MmGdbusModem3gppUssd *object, guint value); + +const gchar *mm_gdbus_modem3gpp_ussd_get_network_notification (MmGdbusModem3gppUssd *object); +gchar *mm_gdbus_modem3gpp_ussd_dup_network_notification (MmGdbusModem3gppUssd *object); +void mm_gdbus_modem3gpp_ussd_set_network_notification (MmGdbusModem3gppUssd *object, const gchar *value); + +const gchar *mm_gdbus_modem3gpp_ussd_get_network_request (MmGdbusModem3gppUssd *object); +gchar *mm_gdbus_modem3gpp_ussd_dup_network_request (MmGdbusModem3gppUssd *object); +void mm_gdbus_modem3gpp_ussd_set_network_request (MmGdbusModem3gppUssd *object, const gchar *value); + + +/* ---- */ + +#define MM_GDBUS_TYPE_MODEM3GPP_USSD_PROXY (mm_gdbus_modem3gpp_ussd_proxy_get_type ()) +#define MM_GDBUS_MODEM3GPP_USSD_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM3GPP_USSD_PROXY, MmGdbusModem3gppUssdProxy)) +#define MM_GDBUS_MODEM3GPP_USSD_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_MODEM3GPP_USSD_PROXY, MmGdbusModem3gppUssdProxyClass)) +#define MM_GDBUS_MODEM3GPP_USSD_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_MODEM3GPP_USSD_PROXY, MmGdbusModem3gppUssdProxyClass)) +#define MM_GDBUS_IS_MODEM3GPP_USSD_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM3GPP_USSD_PROXY)) +#define MM_GDBUS_IS_MODEM3GPP_USSD_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_MODEM3GPP_USSD_PROXY)) + +typedef struct _MmGdbusModem3gppUssdProxy MmGdbusModem3gppUssdProxy; +typedef struct _MmGdbusModem3gppUssdProxyClass MmGdbusModem3gppUssdProxyClass; +typedef struct _MmGdbusModem3gppUssdProxyPrivate MmGdbusModem3gppUssdProxyPrivate; + +struct _MmGdbusModem3gppUssdProxy +{ + /*< private >*/ + GDBusProxy parent_instance; + MmGdbusModem3gppUssdProxyPrivate *priv; +}; + +struct _MmGdbusModem3gppUssdProxyClass +{ + GDBusProxyClass parent_class; +}; + +GType mm_gdbus_modem3gpp_ussd_proxy_get_type (void) G_GNUC_CONST; + +void mm_gdbus_modem3gpp_ussd_proxy_new ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusModem3gppUssd *mm_gdbus_modem3gpp_ussd_proxy_new_finish ( + GAsyncResult *res, + GError **error); +MmGdbusModem3gppUssd *mm_gdbus_modem3gpp_ussd_proxy_new_sync ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem3gpp_ussd_proxy_new_for_bus ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusModem3gppUssd *mm_gdbus_modem3gpp_ussd_proxy_new_for_bus_finish ( + GAsyncResult *res, + GError **error); +MmGdbusModem3gppUssd *mm_gdbus_modem3gpp_ussd_proxy_new_for_bus_sync ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + + +/* ---- */ + +#define MM_GDBUS_TYPE_MODEM3GPP_USSD_SKELETON (mm_gdbus_modem3gpp_ussd_skeleton_get_type ()) +#define MM_GDBUS_MODEM3GPP_USSD_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM3GPP_USSD_SKELETON, MmGdbusModem3gppUssdSkeleton)) +#define MM_GDBUS_MODEM3GPP_USSD_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_MODEM3GPP_USSD_SKELETON, MmGdbusModem3gppUssdSkeletonClass)) +#define MM_GDBUS_MODEM3GPP_USSD_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_MODEM3GPP_USSD_SKELETON, MmGdbusModem3gppUssdSkeletonClass)) +#define MM_GDBUS_IS_MODEM3GPP_USSD_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM3GPP_USSD_SKELETON)) +#define MM_GDBUS_IS_MODEM3GPP_USSD_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_MODEM3GPP_USSD_SKELETON)) + +typedef struct _MmGdbusModem3gppUssdSkeleton MmGdbusModem3gppUssdSkeleton; +typedef struct _MmGdbusModem3gppUssdSkeletonClass MmGdbusModem3gppUssdSkeletonClass; +typedef struct _MmGdbusModem3gppUssdSkeletonPrivate MmGdbusModem3gppUssdSkeletonPrivate; + +struct _MmGdbusModem3gppUssdSkeleton +{ + /*< private >*/ + GDBusInterfaceSkeleton parent_instance; + MmGdbusModem3gppUssdSkeletonPrivate *priv; +}; + +struct _MmGdbusModem3gppUssdSkeletonClass +{ + GDBusInterfaceSkeletonClass parent_class; +}; + +GType mm_gdbus_modem3gpp_ussd_skeleton_get_type (void) G_GNUC_CONST; + +MmGdbusModem3gppUssd *mm_gdbus_modem3gpp_ussd_skeleton_new (void); + + +/* ------------------------------------------------------------------------ */ +/* Declarations for org.freedesktop.ModemManager1.Modem.Simple */ + +#define MM_GDBUS_TYPE_MODEM_SIMPLE (mm_gdbus_modem_simple_get_type ()) +#define MM_GDBUS_MODEM_SIMPLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_SIMPLE, MmGdbusModemSimple)) +#define MM_GDBUS_IS_MODEM_SIMPLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_SIMPLE)) +#define MM_GDBUS_MODEM_SIMPLE_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), MM_GDBUS_TYPE_MODEM_SIMPLE, MmGdbusModemSimpleIface)) + +struct _MmGdbusModemSimple; +typedef struct _MmGdbusModemSimple MmGdbusModemSimple; +typedef struct _MmGdbusModemSimpleIface MmGdbusModemSimpleIface; + +struct _MmGdbusModemSimpleIface +{ + GTypeInterface parent_iface; + + gboolean (*handle_connect) ( + MmGdbusModemSimple *object, + GDBusMethodInvocation *invocation, + GVariant *arg_properties); + + gboolean (*handle_disconnect) ( + MmGdbusModemSimple *object, + GDBusMethodInvocation *invocation, + const gchar *arg_bearer); + + gboolean (*handle_get_status) ( + MmGdbusModemSimple *object, + GDBusMethodInvocation *invocation); + +}; + +GType mm_gdbus_modem_simple_get_type (void) G_GNUC_CONST; + +GDBusInterfaceInfo *mm_gdbus_modem_simple_interface_info (void); +guint mm_gdbus_modem_simple_override_properties (GObjectClass *klass, guint property_id_begin); + + +/* D-Bus method call completion functions: */ +void mm_gdbus_modem_simple_complete_connect ( + MmGdbusModemSimple *object, + GDBusMethodInvocation *invocation, + const gchar *bearer); + +void mm_gdbus_modem_simple_complete_disconnect ( + MmGdbusModemSimple *object, + GDBusMethodInvocation *invocation); + +void mm_gdbus_modem_simple_complete_get_status ( + MmGdbusModemSimple *object, + GDBusMethodInvocation *invocation, + GVariant *properties); + + + +/* D-Bus method calls: */ +void mm_gdbus_modem_simple_call_connect ( + MmGdbusModemSimple *proxy, + GVariant *arg_properties, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_simple_call_connect_finish ( + MmGdbusModemSimple *proxy, + gchar **out_bearer, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_simple_call_connect_sync ( + MmGdbusModemSimple *proxy, + GVariant *arg_properties, + gchar **out_bearer, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_simple_call_disconnect ( + MmGdbusModemSimple *proxy, + const gchar *arg_bearer, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_simple_call_disconnect_finish ( + MmGdbusModemSimple *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_simple_call_disconnect_sync ( + MmGdbusModemSimple *proxy, + const gchar *arg_bearer, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_simple_call_get_status ( + MmGdbusModemSimple *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_modem_simple_call_get_status_finish ( + MmGdbusModemSimple *proxy, + GVariant **out_properties, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_modem_simple_call_get_status_sync ( + MmGdbusModemSimple *proxy, + GVariant **out_properties, + GCancellable *cancellable, + GError **error); + + + +/* ---- */ + +#define MM_GDBUS_TYPE_MODEM_SIMPLE_PROXY (mm_gdbus_modem_simple_proxy_get_type ()) +#define MM_GDBUS_MODEM_SIMPLE_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_SIMPLE_PROXY, MmGdbusModemSimpleProxy)) +#define MM_GDBUS_MODEM_SIMPLE_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_MODEM_SIMPLE_PROXY, MmGdbusModemSimpleProxyClass)) +#define MM_GDBUS_MODEM_SIMPLE_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_MODEM_SIMPLE_PROXY, MmGdbusModemSimpleProxyClass)) +#define MM_GDBUS_IS_MODEM_SIMPLE_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_SIMPLE_PROXY)) +#define MM_GDBUS_IS_MODEM_SIMPLE_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_MODEM_SIMPLE_PROXY)) + +typedef struct _MmGdbusModemSimpleProxy MmGdbusModemSimpleProxy; +typedef struct _MmGdbusModemSimpleProxyClass MmGdbusModemSimpleProxyClass; +typedef struct _MmGdbusModemSimpleProxyPrivate MmGdbusModemSimpleProxyPrivate; + +struct _MmGdbusModemSimpleProxy +{ + /*< private >*/ + GDBusProxy parent_instance; + MmGdbusModemSimpleProxyPrivate *priv; +}; + +struct _MmGdbusModemSimpleProxyClass +{ + GDBusProxyClass parent_class; +}; + +GType mm_gdbus_modem_simple_proxy_get_type (void) G_GNUC_CONST; + +void mm_gdbus_modem_simple_proxy_new ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusModemSimple *mm_gdbus_modem_simple_proxy_new_finish ( + GAsyncResult *res, + GError **error); +MmGdbusModemSimple *mm_gdbus_modem_simple_proxy_new_sync ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_modem_simple_proxy_new_for_bus ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusModemSimple *mm_gdbus_modem_simple_proxy_new_for_bus_finish ( + GAsyncResult *res, + GError **error); +MmGdbusModemSimple *mm_gdbus_modem_simple_proxy_new_for_bus_sync ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + + +/* ---- */ + +#define MM_GDBUS_TYPE_MODEM_SIMPLE_SKELETON (mm_gdbus_modem_simple_skeleton_get_type ()) +#define MM_GDBUS_MODEM_SIMPLE_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_MODEM_SIMPLE_SKELETON, MmGdbusModemSimpleSkeleton)) +#define MM_GDBUS_MODEM_SIMPLE_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_MODEM_SIMPLE_SKELETON, MmGdbusModemSimpleSkeletonClass)) +#define MM_GDBUS_MODEM_SIMPLE_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_MODEM_SIMPLE_SKELETON, MmGdbusModemSimpleSkeletonClass)) +#define MM_GDBUS_IS_MODEM_SIMPLE_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_MODEM_SIMPLE_SKELETON)) +#define MM_GDBUS_IS_MODEM_SIMPLE_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_MODEM_SIMPLE_SKELETON)) + +typedef struct _MmGdbusModemSimpleSkeleton MmGdbusModemSimpleSkeleton; +typedef struct _MmGdbusModemSimpleSkeletonClass MmGdbusModemSimpleSkeletonClass; +typedef struct _MmGdbusModemSimpleSkeletonPrivate MmGdbusModemSimpleSkeletonPrivate; + +struct _MmGdbusModemSimpleSkeleton +{ + /*< private >*/ + GDBusInterfaceSkeleton parent_instance; + MmGdbusModemSimpleSkeletonPrivate *priv; +}; + +struct _MmGdbusModemSimpleSkeletonClass +{ + GDBusInterfaceSkeletonClass parent_class; +}; + +GType mm_gdbus_modem_simple_skeleton_get_type (void) G_GNUC_CONST; + +MmGdbusModemSimple *mm_gdbus_modem_simple_skeleton_new (void); + + +/* ---- */ + +#define MM_GDBUS_TYPE_OBJECT (mm_gdbus_object_get_type ()) +#define MM_GDBUS_OBJECT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_OBJECT, MmGdbusObject)) +#define MM_GDBUS_IS_OBJECT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_OBJECT)) +#define MM_GDBUS_OBJECT_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), MM_GDBUS_TYPE_OBJECT, MmGdbusObject)) + +struct _MmGdbusObject; +typedef struct _MmGdbusObject MmGdbusObject; +typedef struct _MmGdbusObjectIface MmGdbusObjectIface; + +struct _MmGdbusObjectIface +{ + GTypeInterface parent_iface; +}; + +GType mm_gdbus_object_get_type (void) G_GNUC_CONST; + +MmGdbusModem *mm_gdbus_object_get_modem (MmGdbusObject *object); +MmGdbusModemMessaging *mm_gdbus_object_get_modem_messaging (MmGdbusObject *object); +MmGdbusModemLocation *mm_gdbus_object_get_modem_location (MmGdbusObject *object); +MmGdbusModemTime *mm_gdbus_object_get_modem_time (MmGdbusObject *object); +MmGdbusModemFirmware *mm_gdbus_object_get_modem_firmware (MmGdbusObject *object); +MmGdbusModemContacts *mm_gdbus_object_get_modem_contacts (MmGdbusObject *object); +MmGdbusModemCdma *mm_gdbus_object_get_modem_cdma (MmGdbusObject *object); +MmGdbusModem3gpp *mm_gdbus_object_get_modem3gpp (MmGdbusObject *object); +MmGdbusModem3gppUssd *mm_gdbus_object_get_modem3gpp_ussd (MmGdbusObject *object); +MmGdbusModemSimple *mm_gdbus_object_get_modem_simple (MmGdbusObject *object); +MmGdbusModem *mm_gdbus_object_peek_modem (MmGdbusObject *object); +MmGdbusModemMessaging *mm_gdbus_object_peek_modem_messaging (MmGdbusObject *object); +MmGdbusModemLocation *mm_gdbus_object_peek_modem_location (MmGdbusObject *object); +MmGdbusModemTime *mm_gdbus_object_peek_modem_time (MmGdbusObject *object); +MmGdbusModemFirmware *mm_gdbus_object_peek_modem_firmware (MmGdbusObject *object); +MmGdbusModemContacts *mm_gdbus_object_peek_modem_contacts (MmGdbusObject *object); +MmGdbusModemCdma *mm_gdbus_object_peek_modem_cdma (MmGdbusObject *object); +MmGdbusModem3gpp *mm_gdbus_object_peek_modem3gpp (MmGdbusObject *object); +MmGdbusModem3gppUssd *mm_gdbus_object_peek_modem3gpp_ussd (MmGdbusObject *object); +MmGdbusModemSimple *mm_gdbus_object_peek_modem_simple (MmGdbusObject *object); + +#define MM_GDBUS_TYPE_OBJECT_PROXY (mm_gdbus_object_proxy_get_type ()) +#define MM_GDBUS_OBJECT_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_OBJECT_PROXY, MmGdbusObjectProxy)) +#define MM_GDBUS_OBJECT_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_OBJECT_PROXY, MmGdbusObjectProxyClass)) +#define MM_GDBUS_OBJECT_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_OBJECT_PROXY, MmGdbusObjectProxyClass)) +#define MM_GDBUS_IS_OBJECT_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_OBJECT_PROXY)) +#define MM_GDBUS_IS_OBJECT_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_OBJECT_PROXY)) + +typedef struct _MmGdbusObjectProxy MmGdbusObjectProxy; +typedef struct _MmGdbusObjectProxyClass MmGdbusObjectProxyClass; +typedef struct _MmGdbusObjectProxyPrivate MmGdbusObjectProxyPrivate; + +struct _MmGdbusObjectProxy +{ + /*< private >*/ + GDBusObjectProxy parent_instance; + MmGdbusObjectProxyPrivate *priv; +}; + +struct _MmGdbusObjectProxyClass +{ + GDBusObjectProxyClass parent_class; +}; + +GType mm_gdbus_object_proxy_get_type (void) G_GNUC_CONST; +MmGdbusObjectProxy *mm_gdbus_object_proxy_new (GDBusConnection *connection, const gchar *object_path); + +#define MM_GDBUS_TYPE_OBJECT_SKELETON (mm_gdbus_object_skeleton_get_type ()) +#define MM_GDBUS_OBJECT_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_OBJECT_SKELETON, MmGdbusObjectSkeleton)) +#define MM_GDBUS_OBJECT_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_OBJECT_SKELETON, MmGdbusObjectSkeletonClass)) +#define MM_GDBUS_OBJECT_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_OBJECT_SKELETON, MmGdbusObjectSkeletonClass)) +#define MM_GDBUS_IS_OBJECT_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_OBJECT_SKELETON)) +#define MM_GDBUS_IS_OBJECT_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_OBJECT_SKELETON)) + +typedef struct _MmGdbusObjectSkeleton MmGdbusObjectSkeleton; +typedef struct _MmGdbusObjectSkeletonClass MmGdbusObjectSkeletonClass; +typedef struct _MmGdbusObjectSkeletonPrivate MmGdbusObjectSkeletonPrivate; + +struct _MmGdbusObjectSkeleton +{ + /*< private >*/ + GDBusObjectSkeleton parent_instance; + MmGdbusObjectSkeletonPrivate *priv; +}; + +struct _MmGdbusObjectSkeletonClass +{ + GDBusObjectSkeletonClass parent_class; +}; + +GType mm_gdbus_object_skeleton_get_type (void) G_GNUC_CONST; +MmGdbusObjectSkeleton *mm_gdbus_object_skeleton_new (const gchar *object_path); +void mm_gdbus_object_skeleton_set_modem (MmGdbusObjectSkeleton *object, MmGdbusModem *interface_); +void mm_gdbus_object_skeleton_set_modem_messaging (MmGdbusObjectSkeleton *object, MmGdbusModemMessaging *interface_); +void mm_gdbus_object_skeleton_set_modem_location (MmGdbusObjectSkeleton *object, MmGdbusModemLocation *interface_); +void mm_gdbus_object_skeleton_set_modem_time (MmGdbusObjectSkeleton *object, MmGdbusModemTime *interface_); +void mm_gdbus_object_skeleton_set_modem_firmware (MmGdbusObjectSkeleton *object, MmGdbusModemFirmware *interface_); +void mm_gdbus_object_skeleton_set_modem_contacts (MmGdbusObjectSkeleton *object, MmGdbusModemContacts *interface_); +void mm_gdbus_object_skeleton_set_modem_cdma (MmGdbusObjectSkeleton *object, MmGdbusModemCdma *interface_); +void mm_gdbus_object_skeleton_set_modem3gpp (MmGdbusObjectSkeleton *object, MmGdbusModem3gpp *interface_); +void mm_gdbus_object_skeleton_set_modem3gpp_ussd (MmGdbusObjectSkeleton *object, MmGdbusModem3gppUssd *interface_); +void mm_gdbus_object_skeleton_set_modem_simple (MmGdbusObjectSkeleton *object, MmGdbusModemSimple *interface_); + +/* ---- */ + +#define MM_GDBUS_TYPE_OBJECT_MANAGER_CLIENT (mm_gdbus_object_manager_client_get_type ()) +#define MM_GDBUS_OBJECT_MANAGER_CLIENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_OBJECT_MANAGER_CLIENT, MmGdbusObjectManagerClient)) +#define MM_GDBUS_OBJECT_MANAGER_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_OBJECT_MANAGER_CLIENT, MmGdbusObjectManagerClientClass)) +#define MM_GDBUS_OBJECT_MANAGER_CLIENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_OBJECT_MANAGER_CLIENT, MmGdbusObjectManagerClientClass)) +#define MM_GDBUS_IS_OBJECT_MANAGER_CLIENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_OBJECT_MANAGER_CLIENT)) +#define MM_GDBUS_IS_OBJECT_MANAGER_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_OBJECT_MANAGER_CLIENT)) + +typedef struct _MmGdbusObjectManagerClient MmGdbusObjectManagerClient; +typedef struct _MmGdbusObjectManagerClientClass MmGdbusObjectManagerClientClass; +typedef struct _MmGdbusObjectManagerClientPrivate MmGdbusObjectManagerClientPrivate; + +struct _MmGdbusObjectManagerClient +{ + /*< private >*/ + GDBusObjectManagerClient parent_instance; + MmGdbusObjectManagerClientPrivate *priv; +}; + +struct _MmGdbusObjectManagerClientClass +{ + GDBusObjectManagerClientClass parent_class; +}; + +GType mm_gdbus_object_manager_client_get_type (void) G_GNUC_CONST; + +GType mm_gdbus_object_manager_client_get_proxy_type (GDBusObjectManagerClient *manager, const gchar *object_path, const gchar *interface_name, gpointer user_data); + +void mm_gdbus_object_manager_client_new ( + GDBusConnection *connection, + GDBusObjectManagerClientFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GDBusObjectManager *mm_gdbus_object_manager_client_new_finish ( + GAsyncResult *res, + GError **error); +GDBusObjectManager *mm_gdbus_object_manager_client_new_sync ( + GDBusConnection *connection, + GDBusObjectManagerClientFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_object_manager_client_new_for_bus ( + GBusType bus_type, + GDBusObjectManagerClientFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GDBusObjectManager *mm_gdbus_object_manager_client_new_for_bus_finish ( + GAsyncResult *res, + GError **error); +GDBusObjectManager *mm_gdbus_object_manager_client_new_for_bus_sync ( + GBusType bus_type, + GDBusObjectManagerClientFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + + +G_END_DECLS + +#endif /* __MM_GDBUS_MODEM_H__ */ diff --git a/libmm-glib/generated/mm-gdbus-sim.h b/libmm-glib/generated/mm-gdbus-sim.h new file mode 100644 index 0000000..9353037 --- /dev/null +++ b/libmm-glib/generated/mm-gdbus-sim.h @@ -0,0 +1,287 @@ +/* + * Generated by gdbus-codegen 2.36.2. DO NOT EDIT. + * + * The license of this code is the same as for the source it was derived from. + */ + +#ifndef __MM_GDBUS_SIM_H__ +#define __MM_GDBUS_SIM_H__ + +#include <gio/gio.h> + +G_BEGIN_DECLS + + +/* ------------------------------------------------------------------------ */ +/* Declarations for org.freedesktop.ModemManager1.Sim */ + +#define MM_GDBUS_TYPE_SIM (mm_gdbus_sim_get_type ()) +#define MM_GDBUS_SIM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_SIM, MmGdbusSim)) +#define MM_GDBUS_IS_SIM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_SIM)) +#define MM_GDBUS_SIM_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), MM_GDBUS_TYPE_SIM, MmGdbusSimIface)) + +struct _MmGdbusSim; +typedef struct _MmGdbusSim MmGdbusSim; +typedef struct _MmGdbusSimIface MmGdbusSimIface; + +struct _MmGdbusSimIface +{ + GTypeInterface parent_iface; + + + gboolean (*handle_change_pin) ( + MmGdbusSim *object, + GDBusMethodInvocation *invocation, + const gchar *arg_old_pin, + const gchar *arg_new_pin); + + gboolean (*handle_enable_pin) ( + MmGdbusSim *object, + GDBusMethodInvocation *invocation, + const gchar *arg_pin, + gboolean arg_enabled); + + gboolean (*handle_send_pin) ( + MmGdbusSim *object, + GDBusMethodInvocation *invocation, + const gchar *arg_pin); + + gboolean (*handle_send_puk) ( + MmGdbusSim *object, + GDBusMethodInvocation *invocation, + const gchar *arg_puk, + const gchar *arg_pin); + + const gchar * (*get_imsi) (MmGdbusSim *object); + + const gchar * (*get_operator_identifier) (MmGdbusSim *object); + + const gchar * (*get_operator_name) (MmGdbusSim *object); + + const gchar * (*get_sim_identifier) (MmGdbusSim *object); + +}; + +GType mm_gdbus_sim_get_type (void) G_GNUC_CONST; + +GDBusInterfaceInfo *mm_gdbus_sim_interface_info (void); +guint mm_gdbus_sim_override_properties (GObjectClass *klass, guint property_id_begin); + + +/* D-Bus method call completion functions: */ +void mm_gdbus_sim_complete_send_pin ( + MmGdbusSim *object, + GDBusMethodInvocation *invocation); + +void mm_gdbus_sim_complete_send_puk ( + MmGdbusSim *object, + GDBusMethodInvocation *invocation); + +void mm_gdbus_sim_complete_enable_pin ( + MmGdbusSim *object, + GDBusMethodInvocation *invocation); + +void mm_gdbus_sim_complete_change_pin ( + MmGdbusSim *object, + GDBusMethodInvocation *invocation); + + + +/* D-Bus method calls: */ +void mm_gdbus_sim_call_send_pin ( + MmGdbusSim *proxy, + const gchar *arg_pin, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_sim_call_send_pin_finish ( + MmGdbusSim *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_sim_call_send_pin_sync ( + MmGdbusSim *proxy, + const gchar *arg_pin, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_sim_call_send_puk ( + MmGdbusSim *proxy, + const gchar *arg_puk, + const gchar *arg_pin, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_sim_call_send_puk_finish ( + MmGdbusSim *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_sim_call_send_puk_sync ( + MmGdbusSim *proxy, + const gchar *arg_puk, + const gchar *arg_pin, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_sim_call_enable_pin ( + MmGdbusSim *proxy, + const gchar *arg_pin, + gboolean arg_enabled, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_sim_call_enable_pin_finish ( + MmGdbusSim *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_sim_call_enable_pin_sync ( + MmGdbusSim *proxy, + const gchar *arg_pin, + gboolean arg_enabled, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_sim_call_change_pin ( + MmGdbusSim *proxy, + const gchar *arg_old_pin, + const gchar *arg_new_pin, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_sim_call_change_pin_finish ( + MmGdbusSim *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_sim_call_change_pin_sync ( + MmGdbusSim *proxy, + const gchar *arg_old_pin, + const gchar *arg_new_pin, + GCancellable *cancellable, + GError **error); + + + +/* D-Bus property accessors: */ +const gchar *mm_gdbus_sim_get_sim_identifier (MmGdbusSim *object); +gchar *mm_gdbus_sim_dup_sim_identifier (MmGdbusSim *object); +void mm_gdbus_sim_set_sim_identifier (MmGdbusSim *object, const gchar *value); + +const gchar *mm_gdbus_sim_get_imsi (MmGdbusSim *object); +gchar *mm_gdbus_sim_dup_imsi (MmGdbusSim *object); +void mm_gdbus_sim_set_imsi (MmGdbusSim *object, const gchar *value); + +const gchar *mm_gdbus_sim_get_operator_identifier (MmGdbusSim *object); +gchar *mm_gdbus_sim_dup_operator_identifier (MmGdbusSim *object); +void mm_gdbus_sim_set_operator_identifier (MmGdbusSim *object, const gchar *value); + +const gchar *mm_gdbus_sim_get_operator_name (MmGdbusSim *object); +gchar *mm_gdbus_sim_dup_operator_name (MmGdbusSim *object); +void mm_gdbus_sim_set_operator_name (MmGdbusSim *object, const gchar *value); + + +/* ---- */ + +#define MM_GDBUS_TYPE_SIM_PROXY (mm_gdbus_sim_proxy_get_type ()) +#define MM_GDBUS_SIM_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_SIM_PROXY, MmGdbusSimProxy)) +#define MM_GDBUS_SIM_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_SIM_PROXY, MmGdbusSimProxyClass)) +#define MM_GDBUS_SIM_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_SIM_PROXY, MmGdbusSimProxyClass)) +#define MM_GDBUS_IS_SIM_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_SIM_PROXY)) +#define MM_GDBUS_IS_SIM_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_SIM_PROXY)) + +typedef struct _MmGdbusSimProxy MmGdbusSimProxy; +typedef struct _MmGdbusSimProxyClass MmGdbusSimProxyClass; +typedef struct _MmGdbusSimProxyPrivate MmGdbusSimProxyPrivate; + +struct _MmGdbusSimProxy +{ + /*< private >*/ + GDBusProxy parent_instance; + MmGdbusSimProxyPrivate *priv; +}; + +struct _MmGdbusSimProxyClass +{ + GDBusProxyClass parent_class; +}; + +GType mm_gdbus_sim_proxy_get_type (void) G_GNUC_CONST; + +void mm_gdbus_sim_proxy_new ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusSim *mm_gdbus_sim_proxy_new_finish ( + GAsyncResult *res, + GError **error); +MmGdbusSim *mm_gdbus_sim_proxy_new_sync ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_sim_proxy_new_for_bus ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusSim *mm_gdbus_sim_proxy_new_for_bus_finish ( + GAsyncResult *res, + GError **error); +MmGdbusSim *mm_gdbus_sim_proxy_new_for_bus_sync ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + + +/* ---- */ + +#define MM_GDBUS_TYPE_SIM_SKELETON (mm_gdbus_sim_skeleton_get_type ()) +#define MM_GDBUS_SIM_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_SIM_SKELETON, MmGdbusSimSkeleton)) +#define MM_GDBUS_SIM_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_SIM_SKELETON, MmGdbusSimSkeletonClass)) +#define MM_GDBUS_SIM_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_SIM_SKELETON, MmGdbusSimSkeletonClass)) +#define MM_GDBUS_IS_SIM_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_SIM_SKELETON)) +#define MM_GDBUS_IS_SIM_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_SIM_SKELETON)) + +typedef struct _MmGdbusSimSkeleton MmGdbusSimSkeleton; +typedef struct _MmGdbusSimSkeletonClass MmGdbusSimSkeletonClass; +typedef struct _MmGdbusSimSkeletonPrivate MmGdbusSimSkeletonPrivate; + +struct _MmGdbusSimSkeleton +{ + /*< private >*/ + GDBusInterfaceSkeleton parent_instance; + MmGdbusSimSkeletonPrivate *priv; +}; + +struct _MmGdbusSimSkeletonClass +{ + GDBusInterfaceSkeletonClass parent_class; +}; + +GType mm_gdbus_sim_skeleton_get_type (void) G_GNUC_CONST; + +MmGdbusSim *mm_gdbus_sim_skeleton_new (void); + + +G_END_DECLS + +#endif /* __MM_GDBUS_SIM_H__ */ diff --git a/libmm-glib/generated/mm-gdbus-sms.h b/libmm-glib/generated/mm-gdbus-sms.h new file mode 100644 index 0000000..9167ce2 --- /dev/null +++ b/libmm-glib/generated/mm-gdbus-sms.h @@ -0,0 +1,274 @@ +/* + * Generated by gdbus-codegen 2.36.2. DO NOT EDIT. + * + * The license of this code is the same as for the source it was derived from. + */ + +#ifndef __MM_GDBUS_SMS_H__ +#define __MM_GDBUS_SMS_H__ + +#include <gio/gio.h> + +G_BEGIN_DECLS + + +/* ------------------------------------------------------------------------ */ +/* Declarations for org.freedesktop.ModemManager1.Sms */ + +#define MM_GDBUS_TYPE_SMS (mm_gdbus_sms_get_type ()) +#define MM_GDBUS_SMS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_SMS, MmGdbusSms)) +#define MM_GDBUS_IS_SMS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_SMS)) +#define MM_GDBUS_SMS_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), MM_GDBUS_TYPE_SMS, MmGdbusSmsIface)) + +struct _MmGdbusSms; +typedef struct _MmGdbusSms MmGdbusSms; +typedef struct _MmGdbusSmsIface MmGdbusSmsIface; + +struct _MmGdbusSmsIface +{ + GTypeInterface parent_iface; + + + gboolean (*handle_send) ( + MmGdbusSms *object, + GDBusMethodInvocation *invocation); + + gboolean (*handle_store) ( + MmGdbusSms *object, + GDBusMethodInvocation *invocation, + guint arg_storage); + + gint (*get_class) (MmGdbusSms *object); + + GVariant * (*get_data) (MmGdbusSms *object); + + gboolean (*get_delivery_report_request) (MmGdbusSms *object); + + guint (*get_delivery_state) (MmGdbusSms *object); + + const gchar * (*get_discharge_timestamp) (MmGdbusSms *object); + + guint (*get_message_reference) (MmGdbusSms *object); + + const gchar * (*get_number) (MmGdbusSms *object); + + guint (*get_pdu_type) (MmGdbusSms *object); + + const gchar * (*get_smsc) (MmGdbusSms *object); + + guint (*get_state) (MmGdbusSms *object); + + guint (*get_storage) (MmGdbusSms *object); + + const gchar * (*get_text) (MmGdbusSms *object); + + const gchar * (*get_timestamp) (MmGdbusSms *object); + + GVariant * (*get_validity) (MmGdbusSms *object); + +}; + +GType mm_gdbus_sms_get_type (void) G_GNUC_CONST; + +GDBusInterfaceInfo *mm_gdbus_sms_interface_info (void); +guint mm_gdbus_sms_override_properties (GObjectClass *klass, guint property_id_begin); + + +/* D-Bus method call completion functions: */ +void mm_gdbus_sms_complete_send ( + MmGdbusSms *object, + GDBusMethodInvocation *invocation); + +void mm_gdbus_sms_complete_store ( + MmGdbusSms *object, + GDBusMethodInvocation *invocation); + + + +/* D-Bus method calls: */ +void mm_gdbus_sms_call_send ( + MmGdbusSms *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_sms_call_send_finish ( + MmGdbusSms *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_sms_call_send_sync ( + MmGdbusSms *proxy, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_sms_call_store ( + MmGdbusSms *proxy, + guint arg_storage, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean mm_gdbus_sms_call_store_finish ( + MmGdbusSms *proxy, + GAsyncResult *res, + GError **error); + +gboolean mm_gdbus_sms_call_store_sync ( + MmGdbusSms *proxy, + guint arg_storage, + GCancellable *cancellable, + GError **error); + + + +/* D-Bus property accessors: */ +guint mm_gdbus_sms_get_state (MmGdbusSms *object); +void mm_gdbus_sms_set_state (MmGdbusSms *object, guint value); + +guint mm_gdbus_sms_get_pdu_type (MmGdbusSms *object); +void mm_gdbus_sms_set_pdu_type (MmGdbusSms *object, guint value); + +const gchar *mm_gdbus_sms_get_number (MmGdbusSms *object); +gchar *mm_gdbus_sms_dup_number (MmGdbusSms *object); +void mm_gdbus_sms_set_number (MmGdbusSms *object, const gchar *value); + +const gchar *mm_gdbus_sms_get_text (MmGdbusSms *object); +gchar *mm_gdbus_sms_dup_text (MmGdbusSms *object); +void mm_gdbus_sms_set_text (MmGdbusSms *object, const gchar *value); + +GVariant *mm_gdbus_sms_get_data (MmGdbusSms *object); +GVariant *mm_gdbus_sms_dup_data (MmGdbusSms *object); +void mm_gdbus_sms_set_data (MmGdbusSms *object, GVariant *value); + +const gchar *mm_gdbus_sms_get_smsc (MmGdbusSms *object); +gchar *mm_gdbus_sms_dup_smsc (MmGdbusSms *object); +void mm_gdbus_sms_set_smsc (MmGdbusSms *object, const gchar *value); + +GVariant *mm_gdbus_sms_get_validity (MmGdbusSms *object); +GVariant *mm_gdbus_sms_dup_validity (MmGdbusSms *object); +void mm_gdbus_sms_set_validity (MmGdbusSms *object, GVariant *value); + +gint mm_gdbus_sms_get_class (MmGdbusSms *object); +void mm_gdbus_sms_set_class (MmGdbusSms *object, gint value); + +gboolean mm_gdbus_sms_get_delivery_report_request (MmGdbusSms *object); +void mm_gdbus_sms_set_delivery_report_request (MmGdbusSms *object, gboolean value); + +guint mm_gdbus_sms_get_message_reference (MmGdbusSms *object); +void mm_gdbus_sms_set_message_reference (MmGdbusSms *object, guint value); + +const gchar *mm_gdbus_sms_get_timestamp (MmGdbusSms *object); +gchar *mm_gdbus_sms_dup_timestamp (MmGdbusSms *object); +void mm_gdbus_sms_set_timestamp (MmGdbusSms *object, const gchar *value); + +const gchar *mm_gdbus_sms_get_discharge_timestamp (MmGdbusSms *object); +gchar *mm_gdbus_sms_dup_discharge_timestamp (MmGdbusSms *object); +void mm_gdbus_sms_set_discharge_timestamp (MmGdbusSms *object, const gchar *value); + +guint mm_gdbus_sms_get_delivery_state (MmGdbusSms *object); +void mm_gdbus_sms_set_delivery_state (MmGdbusSms *object, guint value); + +guint mm_gdbus_sms_get_storage (MmGdbusSms *object); +void mm_gdbus_sms_set_storage (MmGdbusSms *object, guint value); + + +/* ---- */ + +#define MM_GDBUS_TYPE_SMS_PROXY (mm_gdbus_sms_proxy_get_type ()) +#define MM_GDBUS_SMS_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_SMS_PROXY, MmGdbusSmsProxy)) +#define MM_GDBUS_SMS_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_SMS_PROXY, MmGdbusSmsProxyClass)) +#define MM_GDBUS_SMS_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_SMS_PROXY, MmGdbusSmsProxyClass)) +#define MM_GDBUS_IS_SMS_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_SMS_PROXY)) +#define MM_GDBUS_IS_SMS_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_SMS_PROXY)) + +typedef struct _MmGdbusSmsProxy MmGdbusSmsProxy; +typedef struct _MmGdbusSmsProxyClass MmGdbusSmsProxyClass; +typedef struct _MmGdbusSmsProxyPrivate MmGdbusSmsProxyPrivate; + +struct _MmGdbusSmsProxy +{ + /*< private >*/ + GDBusProxy parent_instance; + MmGdbusSmsProxyPrivate *priv; +}; + +struct _MmGdbusSmsProxyClass +{ + GDBusProxyClass parent_class; +}; + +GType mm_gdbus_sms_proxy_get_type (void) G_GNUC_CONST; + +void mm_gdbus_sms_proxy_new ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusSms *mm_gdbus_sms_proxy_new_finish ( + GAsyncResult *res, + GError **error); +MmGdbusSms *mm_gdbus_sms_proxy_new_sync ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + +void mm_gdbus_sms_proxy_new_for_bus ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MmGdbusSms *mm_gdbus_sms_proxy_new_for_bus_finish ( + GAsyncResult *res, + GError **error); +MmGdbusSms *mm_gdbus_sms_proxy_new_for_bus_sync ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + + +/* ---- */ + +#define MM_GDBUS_TYPE_SMS_SKELETON (mm_gdbus_sms_skeleton_get_type ()) +#define MM_GDBUS_SMS_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MM_GDBUS_TYPE_SMS_SKELETON, MmGdbusSmsSkeleton)) +#define MM_GDBUS_SMS_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MM_GDBUS_TYPE_SMS_SKELETON, MmGdbusSmsSkeletonClass)) +#define MM_GDBUS_SMS_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MM_GDBUS_TYPE_SMS_SKELETON, MmGdbusSmsSkeletonClass)) +#define MM_GDBUS_IS_SMS_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MM_GDBUS_TYPE_SMS_SKELETON)) +#define MM_GDBUS_IS_SMS_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MM_GDBUS_TYPE_SMS_SKELETON)) + +typedef struct _MmGdbusSmsSkeleton MmGdbusSmsSkeleton; +typedef struct _MmGdbusSmsSkeletonClass MmGdbusSmsSkeletonClass; +typedef struct _MmGdbusSmsSkeletonPrivate MmGdbusSmsSkeletonPrivate; + +struct _MmGdbusSmsSkeleton +{ + /*< private >*/ + GDBusInterfaceSkeleton parent_instance; + MmGdbusSmsSkeletonPrivate *priv; +}; + +struct _MmGdbusSmsSkeletonClass +{ + GDBusInterfaceSkeletonClass parent_class; +}; + +GType mm_gdbus_sms_skeleton_get_type (void) G_GNUC_CONST; + +MmGdbusSms *mm_gdbus_sms_skeleton_new (void); + + +G_END_DECLS + +#endif /* __MM_GDBUS_SMS_H__ */ diff --git a/libmm-glib/libmm-glib.h b/libmm-glib/libmm-glib.h new file mode 100644 index 0000000..8b5e920 --- /dev/null +++ b/libmm-glib/libmm-glib.h @@ -0,0 +1,79 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2011 - 2012 Google, Inc. + */ + +#ifndef _LIBMM_GLIB_H_ +#define _LIBMM_GLIB_H_ + +#define __LIBMM_GLIB_H_INSIDE__ + +/* ModemManager generic headers */ +#include <ModemManager.h> + +/* libmm-glib headers */ + +#if !defined (_LIBMM_INSIDE_MM) +/* This headers are not exported within ModemManager */ +# include <mm-manager.h> +# include <mm-object.h> +# include <mm-modem.h> +# include <mm-modem-3gpp.h> +# include <mm-modem-3gpp-ussd.h> +# include <mm-modem-cdma.h> +# include <mm-modem-simple.h> +# include <mm-modem-location.h> +# include <mm-modem-messaging.h> +# include <mm-modem-time.h> +# include <mm-modem-firmware.h> +#endif + +#if defined (_LIBMM_INSIDE_MM) || \ + defined (_LIBMM_INSIDE_MMCLI) || \ + defined (LIBMM_GLIB_COMPILATION) +/* This one is not even installed */ +# include <mm-common-helpers.h> +#endif + +#include <mm-helper-types.h> +#include <mm-simple-status.h> +#include <mm-simple-connect-properties.h> +#include <mm-sms-properties.h> +#include <mm-bearer-properties.h> +#include <mm-bearer-ip-config.h> +#include <mm-location-common.h> +#include <mm-location-3gpp.h> +#include <mm-location-gps-raw.h> +#include <mm-location-gps-nmea.h> +#include <mm-location-cdma-bs.h> +#include <mm-unlock-retries.h> +#include <mm-network-timezone.h> +#include <mm-firmware-properties.h> + +/* generated */ +#include <mm-errors-types.h> +#include <mm-enums-types.h> +#include <mm-gdbus-manager.h> +#include <mm-gdbus-modem.h> +#include <mm-gdbus-bearer.h> +#include <mm-gdbus-sim.h> +#include <mm-gdbus-sms.h> + +#endif /* _LIBMM_GLIB_H_ */ diff --git a/libmm-glib/mm-bearer-ip-config.c b/libmm-glib/mm-bearer-ip-config.c new file mode 100644 index 0000000..14f99f3 --- /dev/null +++ b/libmm-glib/mm-bearer-ip-config.c @@ -0,0 +1,391 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2012 Google, Inc. + */ + +#include <string.h> + +#include "mm-errors-types.h" +#include "mm-bearer-ip-config.h" + +/** + * SECTION: mm-bearer-ip-config + * @title: MMBearerIpConfig + * @short_description: Helper object to handle IP configuration. + * + * The #MMBearerIpConfig is an object handling the IP configuration required by + * the bearer to finish the connection. + * + * This object is retrieved with either mm_bearer_get_ipv4_config(), + * mm_bearer_peek_ipv4_config(), mm_bearer_get_ipv6_config() or + * mm_bearer_peek_ipv6_config(). + */ + +G_DEFINE_TYPE (MMBearerIpConfig, mm_bearer_ip_config, G_TYPE_OBJECT); + +#define PROPERTY_METHOD "method" +#define PROPERTY_ADDRESS "address" +#define PROPERTY_PREFIX "prefix" +#define PROPERTY_DNS1 "dns1" +#define PROPERTY_DNS2 "dns2" +#define PROPERTY_DNS3 "dns3" +#define PROPERTY_GATEWAY "gateway" + +struct _MMBearerIpConfigPrivate { + MMBearerIpMethod method; + gchar *address; + guint prefix; + gchar **dns; + gchar *gateway; +}; + +/*****************************************************************************/ + +/** + * mm_bearer_ip_config_get_method: + * @self: a #MMBearerIpConfig. + * + * Gets the IP method to be used with this bearer. + * + * Returns: a #MMBearerIpMethod. + */ +MMBearerIpMethod +mm_bearer_ip_config_get_method (MMBearerIpConfig *self) +{ + g_return_val_if_fail (MM_IS_BEARER_IP_CONFIG (self), MM_BEARER_IP_METHOD_UNKNOWN); + + return self->priv->method; +} + +void +mm_bearer_ip_config_set_method (MMBearerIpConfig *self, + MMBearerIpMethod method) +{ + g_return_if_fail (MM_IS_BEARER_IP_CONFIG (self)); + + self->priv->method = method; +} + +/*****************************************************************************/ + +/** + * mm_bearer_ip_config_get_address: + * @self: a #MMBearerIpConfig. + * + * Gets the IP address to be used with this bearer. + * + * Returns: a string with the IP address, or #NULL if unknown. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_bearer_ip_config_get_address (MMBearerIpConfig *self) +{ + g_return_val_if_fail (MM_IS_BEARER_IP_CONFIG (self), NULL); + + return self->priv->address; +} + +void +mm_bearer_ip_config_set_address (MMBearerIpConfig *self, + const gchar *address) +{ + g_return_if_fail (MM_IS_BEARER_IP_CONFIG (self)); + + g_free (self->priv->address); + self->priv->address = g_strdup (address); +} + +/*****************************************************************************/ + +/** + * mm_bearer_ip_config_get_prefix: + * @self: a #MMBearerIpConfig. + * + * Gets the network prefix to be used with this bearer. + * + * Returns: the network prefix. + */ +guint +mm_bearer_ip_config_get_prefix (MMBearerIpConfig *self) +{ + g_return_val_if_fail (MM_IS_BEARER_IP_CONFIG (self), 0); + + return self->priv->prefix; +} + +void +mm_bearer_ip_config_set_prefix (MMBearerIpConfig *self, + guint prefix) +{ + g_return_if_fail (MM_IS_BEARER_IP_CONFIG (self)); + + self->priv->prefix = prefix; +} + +/*****************************************************************************/ + +/** + * mm_bearer_ip_config_get_dns: + * @self: a #MMBearerIpConfig. + * + * Gets the list of IP addresses of DNS servers to be used with this bearer. + * + * Returns: a NULL-terminated array of strings. Do not free the returned value, it is owned by @self. + */ +const gchar ** +mm_bearer_ip_config_get_dns (MMBearerIpConfig *self) +{ + g_return_val_if_fail (MM_IS_BEARER_IP_CONFIG (self), NULL); + + return (const gchar **)self->priv->dns; +} + +void +mm_bearer_ip_config_set_dns (MMBearerIpConfig *self, + const gchar **dns) +{ + g_return_if_fail (MM_IS_BEARER_IP_CONFIG (self)); + + g_strfreev (self->priv->dns); + self->priv->dns = g_strdupv ((gchar **)dns); +} + +/*****************************************************************************/ + +/** + * mm_bearer_ip_config_get_gateway: + * @self: a #MMBearerIpConfig. + * + * Gets the IP address of the gateway to be used with this bearer. + * + * Returns: a string with the IP address, or #NULL if unknown. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_bearer_ip_config_get_gateway (MMBearerIpConfig *self) +{ + g_return_val_if_fail (MM_IS_BEARER_IP_CONFIG (self), NULL); + + return self->priv->gateway; +} + +void +mm_bearer_ip_config_set_gateway (MMBearerIpConfig *self, + const gchar *gateway) +{ + g_return_if_fail (MM_IS_BEARER_IP_CONFIG (self)); + + g_free (self->priv->gateway); + self->priv->gateway = g_strdup (gateway); +} + +/*****************************************************************************/ + +GVariant * +mm_bearer_ip_config_get_dictionary (MMBearerIpConfig *self) +{ + GVariantBuilder builder; + + /* We do allow self==NULL. We'll just report method=unknown in this case */ + if (self) + g_return_val_if_fail (MM_IS_BEARER_IP_CONFIG (self), NULL); + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_METHOD, + g_variant_new_uint32 (self ? + self->priv->method : + MM_BEARER_IP_METHOD_UNKNOWN)); + + /* If static IP method, report remaining configuration */ + if (self && + self->priv->method == MM_BEARER_IP_METHOD_STATIC) { + if (self->priv->address) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_ADDRESS, + g_variant_new_string (self->priv->address)); + + if (self->priv->prefix) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_PREFIX, + g_variant_new_uint32 (self->priv->prefix)); + + if (self->priv->dns && + self->priv->dns[0]) { + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_DNS1, + g_variant_new_string (self->priv->dns[0])); + if (self->priv->dns[1]) { + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_DNS2, + g_variant_new_string (self->priv->dns[1])); + if (self->priv->dns[2]) { + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_DNS3, + g_variant_new_string (self->priv->dns[2])); + } + } + } + + if (self->priv->gateway) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_GATEWAY, + g_variant_new_string (self->priv->gateway)); + } + + return g_variant_builder_end (&builder); +} + +/*****************************************************************************/ + +MMBearerIpConfig * +mm_bearer_ip_config_new_from_dictionary (GVariant *dictionary, + GError **error) +{ + GVariantIter iter; + gchar *key; + GVariant *value; + MMBearerIpConfig *self; + gchar *dns_array[4] = { 0 }; + gboolean method_received = FALSE; + + self = mm_bearer_ip_config_new (); + if (!dictionary) + return self; + + if (!g_variant_is_of_type (dictionary, G_VARIANT_TYPE ("a{sv}"))) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Cannot create IP config from dictionary: " + "invalid variant type received"); + g_object_unref (self); + return NULL; + } + + g_variant_iter_init (&iter, dictionary); + while (g_variant_iter_next (&iter, "{sv}", &key, &value)) { + if (g_str_equal (key, PROPERTY_METHOD)) { + method_received = TRUE; + mm_bearer_ip_config_set_method ( + self, + (MMBearerIpMethod) g_variant_get_uint32 (value)); + } else if (g_str_equal (key, PROPERTY_ADDRESS)) + mm_bearer_ip_config_set_address ( + self, + g_variant_get_string (value, NULL)); + else if (g_str_equal (key, PROPERTY_PREFIX)) + mm_bearer_ip_config_set_prefix ( + self, + g_variant_get_uint32 (value)); + else if (g_str_equal (key, PROPERTY_DNS1)) { + g_free (dns_array[0]); + dns_array[0] = g_variant_dup_string (value, NULL); + } else if (g_str_equal (key, PROPERTY_DNS2)) { + g_free (dns_array[1]); + dns_array[1] = g_variant_dup_string (value, NULL); + } else if (g_str_equal (key, PROPERTY_DNS3)) { + g_free (dns_array[2]); + dns_array[2] = g_variant_dup_string (value, NULL); + } else if (g_str_equal (key, PROPERTY_GATEWAY)) + mm_bearer_ip_config_set_gateway ( + self, + g_variant_get_string (value, NULL)); + + g_free (key); + g_variant_unref (value); + } + + if (dns_array[0]) + mm_bearer_ip_config_set_dns (self, (const gchar **)dns_array); + + if (!method_received) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Couldn't create IP config from dictionary: 'method not given'"); + g_clear_object (&self); + } + + g_free (dns_array[0]); + g_free (dns_array[1]); + g_free (dns_array[2]); + + return self; +} + +/*****************************************************************************/ + +MMBearerIpConfig * +mm_bearer_ip_config_dup (MMBearerIpConfig *orig) +{ + GVariant *dict; + MMBearerIpConfig *copy; + GError *error = NULL; + + g_return_val_if_fail (MM_IS_BEARER_IP_CONFIG (orig), NULL); + + dict = mm_bearer_ip_config_get_dictionary (orig); + copy = mm_bearer_ip_config_new_from_dictionary (dict, &error); + g_assert_no_error (error); + g_variant_unref (dict); + + return copy; +} + +/*****************************************************************************/ + +MMBearerIpConfig * +mm_bearer_ip_config_new (void) +{ + return (MM_BEARER_IP_CONFIG ( + g_object_new (MM_TYPE_BEARER_IP_CONFIG, NULL))); +} + +static void +mm_bearer_ip_config_init (MMBearerIpConfig *self) +{ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), + MM_TYPE_BEARER_IP_CONFIG, + MMBearerIpConfigPrivate); + + /* Some defaults */ + self->priv->method = MM_BEARER_IP_METHOD_UNKNOWN; +} + +static void +finalize (GObject *object) +{ + MMBearerIpConfig *self = MM_BEARER_IP_CONFIG (object); + + g_free (self->priv->address); + g_free (self->priv->gateway); + g_strfreev (self->priv->dns); + + G_OBJECT_CLASS (mm_bearer_ip_config_parent_class)->finalize (object); +} + +static void +mm_bearer_ip_config_class_init (MMBearerIpConfigClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (MMBearerIpConfigPrivate)); + + object_class->finalize = finalize; +} diff --git a/libmm-glib/mm-bearer-ip-config.h b/libmm-glib/mm-bearer-ip-config.h new file mode 100644 index 0000000..bfd2ea7 --- /dev/null +++ b/libmm-glib/mm-bearer-ip-config.h @@ -0,0 +1,94 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2012 Google, Inc. + */ + +#ifndef MM_BEARER_IP_CONFIG_H +#define MM_BEARER_IP_CONFIG_H + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> +#include <glib-object.h> + +G_BEGIN_DECLS + +#define MM_TYPE_BEARER_IP_CONFIG (mm_bearer_ip_config_get_type ()) +#define MM_BEARER_IP_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BEARER_IP_CONFIG, MMBearerIpConfig)) +#define MM_BEARER_IP_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BEARER_IP_CONFIG, MMBearerIpConfigClass)) +#define MM_IS_BEARER_IP_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BEARER_IP_CONFIG)) +#define MM_IS_BEARER_IP_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BEARER_IP_CONFIG)) +#define MM_BEARER_IP_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BEARER_IP_CONFIG, MMBearerIpConfigClass)) + +typedef struct _MMBearerIpConfig MMBearerIpConfig; +typedef struct _MMBearerIpConfigClass MMBearerIpConfigClass; +typedef struct _MMBearerIpConfigPrivate MMBearerIpConfigPrivate; + +/** + * MMBearerIpConfig: + * + * The #MMBearerIpConfig structure contains private data and should + * only be accessed using the provided API. + */ +struct _MMBearerIpConfig { + /*< private >*/ + GObject parent; + MMBearerIpConfigPrivate *priv; +}; + +struct _MMBearerIpConfigClass { + /*< private >*/ + GObjectClass parent; +}; + +GType mm_bearer_ip_config_get_type (void); + +MMBearerIpMethod mm_bearer_ip_config_get_method (MMBearerIpConfig *self); +const gchar *mm_bearer_ip_config_get_address (MMBearerIpConfig *self); +guint mm_bearer_ip_config_get_prefix (MMBearerIpConfig *self); +const gchar **mm_bearer_ip_config_get_dns (MMBearerIpConfig *self); +const gchar *mm_bearer_ip_config_get_gateway (MMBearerIpConfig *self); + +/*****************************************************************************/ +/* ModemManager/libmm-glib/mmcli specific methods */ + +#if defined (_LIBMM_INSIDE_MM) || \ + defined (_LIBMM_INSIDE_MMCLI) || \ + defined (LIBMM_GLIB_COMPILATION) + +MMBearerIpConfig *mm_bearer_ip_config_new (void); +MMBearerIpConfig *mm_bearer_ip_config_new_from_dictionary (GVariant *dictionary, + GError **error); + +MMBearerIpConfig *mm_bearer_ip_config_dup (MMBearerIpConfig *orig); + +void mm_bearer_ip_config_set_method (MMBearerIpConfig *self, + MMBearerIpMethod ip_method); +void mm_bearer_ip_config_set_address (MMBearerIpConfig *self, + const gchar *address); +void mm_bearer_ip_config_set_prefix (MMBearerIpConfig *self, + guint prefix); +void mm_bearer_ip_config_set_dns (MMBearerIpConfig *self, + const gchar **dns); +void mm_bearer_ip_config_set_gateway (MMBearerIpConfig *self, + const gchar *gateway); + +GVariant *mm_bearer_ip_config_get_dictionary (MMBearerIpConfig *self); + +#endif + +G_END_DECLS + +#endif /* MM_BEARER_IP_CONFIG_H */ diff --git a/libmm-glib/mm-bearer-properties.c b/libmm-glib/mm-bearer-properties.c new file mode 100644 index 0000000..c4f4ba2 --- /dev/null +++ b/libmm-glib/mm-bearer-properties.c @@ -0,0 +1,701 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2011 Aleksander Morgado <aleksander@gnu.org> + */ + +#include <string.h> + +#include "mm-errors-types.h" +#include "mm-common-helpers.h" +#include "mm-bearer-properties.h" + +/** + * SECTION: mm-bearer-properties + * @title: MMBearerProperties + * @short_description: Helper object to handle bearer properties. + * + * The #MMBearerProperties is an object handling the properties requested + * to ModemManager when creating a new bearer. + * + * This object is created by the user and passed to ModemManager with either + * mm_modem_create_bearer() or mm_modem_create_bearer_sync(). + */ + +G_DEFINE_TYPE (MMBearerProperties, mm_bearer_properties, G_TYPE_OBJECT); + +#define PROPERTY_APN "apn" +#define PROPERTY_ALLOWED_AUTH "allowed-auth" +#define PROPERTY_USER "user" +#define PROPERTY_PASSWORD "password" +#define PROPERTY_IP_TYPE "ip-type" +#define PROPERTY_NUMBER "number" +#define PROPERTY_ALLOW_ROAMING "allow-roaming" +#define PROPERTY_RM_PROTOCOL "rm-protocol" + +struct _MMBearerPropertiesPrivate { + /* APN */ + gchar *apn; + /* IP type */ + MMBearerIpFamily ip_type; + /* Allowed auth */ + MMBearerAllowedAuth allowed_auth; + /* Number */ + gchar *number; + /* User */ + gchar *user; + /* Password */ + gchar *password; + /* Roaming allowance */ + gboolean allow_roaming_set; + gboolean allow_roaming; + /* Protocol of the Rm interface */ + MMModemCdmaRmProtocol rm_protocol; +}; + +/*****************************************************************************/ + +/** + * mm_bearer_properties_set_apn: + * @self: a #MMBearerProperties. + * @apn: Name of the access point. + * + * Sets the name of the access point to use when connecting. + */ +void +mm_bearer_properties_set_apn (MMBearerProperties *self, + const gchar *apn) +{ + g_return_if_fail (MM_IS_BEARER_PROPERTIES (self)); + + g_free (self->priv->apn); + self->priv->apn = g_strdup (apn); +} + +/** + * mm_bearer_properties_get_apn: + * @self: a #MMBearerProperties. + * + * Gets the name of the access point to use when connecting. + * + * Returns: (transfer none): the access point, or #NULL if not set. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_bearer_properties_get_apn (MMBearerProperties *self) +{ + g_return_val_if_fail (MM_IS_BEARER_PROPERTIES (self), NULL); + + return self->priv->apn; +} + +/*****************************************************************************/ + +/** + * mm_bearer_properties_set_allowed_auth: + * @self: a #MMBearerProperties. + * @allowed_auth: a bitmask of #MMBearerAllowedAuth values. %MM_BEARER_ALLOWED_AUTH_UNKNOWN may be given to request the modem-default method. + * + * Sets the authentication method to use. + */ +void +mm_bearer_properties_set_allowed_auth (MMBearerProperties *self, + MMBearerAllowedAuth allowed_auth) +{ + g_return_if_fail (MM_IS_BEARER_PROPERTIES (self)); + + self->priv->allowed_auth = allowed_auth; +} + +/** + * mm_bearer_properties_get_allowed_auth: + * @self: a #MMBearerProperties. + * + * Gets the authentication methods allowed in the connection. + * + * Returns: a bitmask of #MMBearerAllowedAuth values, or %MM_BEARER_ALLOWED_AUTH_UNKNOWN to request the modem-default method. + */ +MMBearerAllowedAuth +mm_bearer_properties_get_allowed_auth (MMBearerProperties *self) +{ + g_return_val_if_fail (MM_IS_BEARER_PROPERTIES (self), MM_BEARER_ALLOWED_AUTH_UNKNOWN); + + return self->priv->allowed_auth; +} + +/*****************************************************************************/ + +/** + * mm_bearer_properties_set_user: + * @self: a #MMBearerProperties. + * @user: the username + * + * Sets the username used to authenticate with the access point. + */ +void +mm_bearer_properties_set_user (MMBearerProperties *self, + const gchar *user) +{ + g_return_if_fail (MM_IS_BEARER_PROPERTIES (self)); + + g_free (self->priv->user); + self->priv->user = g_strdup (user); +} + +/** + * mm_bearer_properties_get_user: + * @self: a #MMBearerProperties. + * + * Gets the username used to authenticate with the access point. + * + * Returns: (transfer none): the username, or #NULL if not set. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_bearer_properties_get_user (MMBearerProperties *self) +{ + g_return_val_if_fail (MM_IS_BEARER_PROPERTIES (self), NULL); + + return self->priv->user; +} + +/*****************************************************************************/ + +/** + * mm_bearer_properties_set_password: + * @self: a #MMBearerProperties. + * @password: the password + * + * Sets the password used to authenticate with the access point. + */ +void +mm_bearer_properties_set_password (MMBearerProperties *self, + const gchar *password) +{ + g_return_if_fail (MM_IS_BEARER_PROPERTIES (self)); + + g_free (self->priv->password); + self->priv->password = g_strdup (password); +} + +/** + * mm_bearer_properties_get_password: + * @self: a #MMBearerProperties. + * + * Gets the password used to authenticate with the access point. + * + * Returns: (transfer none): the password, or #NULL if not set. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_bearer_properties_get_password (MMBearerProperties *self) +{ + g_return_val_if_fail (MM_IS_BEARER_PROPERTIES (self), NULL); + + return self->priv->password; +} + +/*****************************************************************************/ + +/** + * mm_bearer_properties_set_ip_type: + * @self: a #MMBearerProperties. + * @ip_type: a #MMBearerIpFamily. + * + * Sets the IP type to use. + */ +void +mm_bearer_properties_set_ip_type (MMBearerProperties *self, + MMBearerIpFamily ip_type) +{ + g_return_if_fail (MM_IS_BEARER_PROPERTIES (self)); + + self->priv->ip_type = ip_type; +} + +/** + * mm_bearer_properties_get_ip_type: + * @self: a #MMBearerProperties. + * + * Sets the IP type to use. + * + * Returns: a #MMBearerIpFamily. + */ +MMBearerIpFamily +mm_bearer_properties_get_ip_type (MMBearerProperties *self) +{ + g_return_val_if_fail (MM_IS_BEARER_PROPERTIES (self), MM_BEARER_IP_FAMILY_NONE); + + return self->priv->ip_type; +} + +/*****************************************************************************/ + +/** + * mm_bearer_properties_set_allow_roaming: + * @self: a #MMBearerProperties. + * @allow_roaming: boolean value. + * + * Sets the flag to indicate whether roaming is allowed or not in the + * connection. + */ +void +mm_bearer_properties_set_allow_roaming (MMBearerProperties *self, + gboolean allow_roaming) +{ + g_return_if_fail (MM_IS_BEARER_PROPERTIES (self)); + + self->priv->allow_roaming = allow_roaming; + self->priv->allow_roaming_set = TRUE; +} + +/** + * mm_bearer_properties_get_allow_roaming: + * @self: a #MMBearerProperties. + * + * Checks whether roaming is allowed in the connection. + * + * Returns: %TRUE if roaming is allowed, %FALSE otherwise.. + */ +gboolean +mm_bearer_properties_get_allow_roaming (MMBearerProperties *self) +{ + g_return_val_if_fail (MM_IS_BEARER_PROPERTIES (self), FALSE); + + return self->priv->allow_roaming; +} + +/*****************************************************************************/ + +/** + * mm_bearer_properties_set_number: + * @self: a #MMBearerProperties. + * @number: the number. + * + * Sets the number to use when performing the connection. + */ +void +mm_bearer_properties_set_number (MMBearerProperties *self, + const gchar *number) +{ + g_return_if_fail (MM_IS_BEARER_PROPERTIES (self)); + + g_free (self->priv->number); + self->priv->number = g_strdup (number); +} + +/** + * mm_bearer_properties_get_number: + * @self: a #MMBearerProperties. + * + * Gets the number to use when performing the connection. + * + * Returns: (transfer none): the number, or #NULL if not set. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_bearer_properties_get_number (MMBearerProperties *self) +{ + g_return_val_if_fail (MM_IS_BEARER_PROPERTIES (self), NULL); + + return self->priv->number; +} + +/*****************************************************************************/ + +/** + * mm_simple_connect_properties_set_rm_protocol: + * @self: a #MMBearerProperties. + * @protocol: a #MMModemCdmaRmProtocol. + * + * Sets the RM protocol to use in the CDMA connection. + */ +void +mm_bearer_properties_set_rm_protocol (MMBearerProperties *self, + MMModemCdmaRmProtocol protocol) +{ + g_return_if_fail (MM_IS_BEARER_PROPERTIES (self)); + + self->priv->rm_protocol = protocol; +} + +/** + * mm_bearer_properties_get_rm_protocol: + * @self: a #MMBearerProperties. + * + * Gets the RM protocol requested to use in the CDMA connection. + * + * Returns: a #MMModemCdmaRmProtocol. + */ +MMModemCdmaRmProtocol +mm_bearer_properties_get_rm_protocol (MMBearerProperties *self) +{ + g_return_val_if_fail (MM_IS_BEARER_PROPERTIES (self), MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN); + + return self->priv->rm_protocol; +} + +/*****************************************************************************/ + +GVariant * +mm_bearer_properties_get_dictionary (MMBearerProperties *self) +{ + GVariantBuilder builder; + + /* We do allow NULL */ + if (!self) + return NULL; + + g_return_val_if_fail (MM_IS_BEARER_PROPERTIES (self), NULL); + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); + + if (self->priv->apn) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_APN, + g_variant_new_string (self->priv->apn)); + + if (self->priv->allowed_auth != MM_BEARER_ALLOWED_AUTH_UNKNOWN) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_ALLOWED_AUTH, + g_variant_new_uint32 (self->priv->allowed_auth)); + + if (self->priv->user) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_USER, + g_variant_new_string (self->priv->user)); + + if (self->priv->password) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_PASSWORD, + g_variant_new_string (self->priv->password)); + + if (self->priv->ip_type != MM_BEARER_IP_FAMILY_NONE) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_IP_TYPE, + g_variant_new_uint32 (self->priv->ip_type)); + + if (self->priv->number) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_NUMBER, + g_variant_new_string (self->priv->number)); + + if (self->priv->allow_roaming_set) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_ALLOW_ROAMING, + g_variant_new_boolean (self->priv->allow_roaming)); + + if (self->priv->rm_protocol) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_RM_PROTOCOL, + g_variant_new_uint32 (self->priv->rm_protocol)); + + return g_variant_ref_sink (g_variant_builder_end (&builder)); +} + +/*****************************************************************************/ + +gboolean +mm_bearer_properties_consume_string (MMBearerProperties *self, + const gchar *key, + const gchar *value, + GError **error) +{ + g_return_val_if_fail (MM_IS_BEARER_PROPERTIES (self), FALSE); + + if (g_str_equal (key, PROPERTY_APN)) + mm_bearer_properties_set_apn (self, value); + else if (g_str_equal (key, PROPERTY_ALLOWED_AUTH)) { + GError *inner_error = NULL; + MMBearerAllowedAuth allowed_auth; + + allowed_auth = mm_common_get_allowed_auth_from_string (value, &inner_error); + if (inner_error) { + g_propagate_error (error, inner_error); + return FALSE; + } + mm_bearer_properties_set_allowed_auth (self, allowed_auth); + } else if (g_str_equal (key, PROPERTY_USER)) + mm_bearer_properties_set_user (self, value); + else if (g_str_equal (key, PROPERTY_PASSWORD)) + mm_bearer_properties_set_password (self, value); + else if (g_str_equal (key, PROPERTY_IP_TYPE)) { + GError *inner_error = NULL; + MMBearerIpFamily ip_type; + + ip_type = mm_common_get_ip_type_from_string (value, &inner_error); + if (inner_error) { + g_propagate_error (error, inner_error); + return FALSE; + } + mm_bearer_properties_set_ip_type (self, ip_type); + } else if (g_str_equal (key, PROPERTY_ALLOW_ROAMING)) { + GError *inner_error = NULL; + gboolean allow_roaming; + + allow_roaming = mm_common_get_boolean_from_string (value, &inner_error); + if (inner_error) { + g_propagate_error (error, inner_error); + return FALSE; + } + mm_bearer_properties_set_allow_roaming (self, allow_roaming); + } else if (g_str_equal (key, PROPERTY_NUMBER)) + mm_bearer_properties_set_number (self, value); + else if (g_str_equal (key, PROPERTY_RM_PROTOCOL)) { + GError *inner_error = NULL; + MMModemCdmaRmProtocol protocol; + + protocol = mm_common_get_rm_protocol_from_string (value, &inner_error); + if (inner_error) { + g_propagate_error (error, inner_error); + return FALSE; + } + mm_bearer_properties_set_rm_protocol (self, protocol); + } else { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Invalid properties string, unexpected key '%s'", + key); + return FALSE; + } + + return TRUE; +} + +typedef struct { + MMBearerProperties *properties; + GError *error; +} ParseKeyValueContext; + +static gboolean +key_value_foreach (const gchar *key, + const gchar *value, + ParseKeyValueContext *ctx) +{ + return mm_bearer_properties_consume_string (ctx->properties, + key, + value, + &ctx->error); +} + +MMBearerProperties * +mm_bearer_properties_new_from_string (const gchar *str, + GError **error) +{ + ParseKeyValueContext ctx; + + ctx.error = NULL; + ctx.properties = mm_bearer_properties_new (); + + mm_common_parse_key_value_string (str, + &ctx.error, + (MMParseKeyValueForeachFn)key_value_foreach, + &ctx); + /* If error, destroy the object */ + if (ctx.error) { + g_propagate_error (error, ctx.error); + g_object_unref (ctx.properties); + ctx.properties = NULL; + } + + return ctx.properties; +} + +/*****************************************************************************/ + +gboolean +mm_bearer_properties_consume_variant (MMBearerProperties *properties, + const gchar *key, + GVariant *value, + GError **error) +{ + g_return_val_if_fail (MM_IS_BEARER_PROPERTIES (properties), FALSE); + + if (g_str_equal (key, PROPERTY_APN)) + mm_bearer_properties_set_apn ( + properties, + g_variant_get_string (value, NULL)); + else if (g_str_equal (key, PROPERTY_ALLOWED_AUTH)) + mm_bearer_properties_set_allowed_auth ( + properties, + g_variant_get_uint32 (value)); + else if (g_str_equal (key, PROPERTY_USER)) + mm_bearer_properties_set_user ( + properties, + g_variant_get_string (value, NULL)); + else if (g_str_equal (key, PROPERTY_PASSWORD)) + mm_bearer_properties_set_password ( + properties, + g_variant_get_string (value, NULL)); + else if (g_str_equal (key, PROPERTY_IP_TYPE)) + mm_bearer_properties_set_ip_type ( + properties, + g_variant_get_uint32 (value)); + else if (g_str_equal (key, PROPERTY_NUMBER)) + mm_bearer_properties_set_number ( + properties, + g_variant_get_string (value, NULL)); + else if (g_str_equal (key, PROPERTY_ALLOW_ROAMING)) + mm_bearer_properties_set_allow_roaming ( + properties, + g_variant_get_boolean (value)); + else { + /* Set error */ + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Invalid properties dictionary, unexpected key '%s'", + key); + return FALSE; + } + + return TRUE; +} + +MMBearerProperties * +mm_bearer_properties_new_from_dictionary (GVariant *dictionary, + GError **error) +{ + GError *inner_error = NULL; + GVariantIter iter; + gchar *key; + GVariant *value; + MMBearerProperties *properties; + + properties = mm_bearer_properties_new (); + if (!dictionary) + return properties; + + if (!g_variant_is_of_type (dictionary, G_VARIANT_TYPE ("a{sv}"))) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Cannot create Bearer properties from dictionary: " + "invalid variant type received"); + g_object_unref (properties); + return NULL; + } + + g_variant_iter_init (&iter, dictionary); + while (!inner_error && + g_variant_iter_next (&iter, "{sv}", &key, &value)) { + mm_bearer_properties_consume_variant (properties, + key, + value, + &inner_error); + g_free (key); + g_variant_unref (value); + } + + /* If error, destroy the object */ + if (inner_error) { + g_propagate_error (error, inner_error); + g_object_unref (properties); + properties = NULL; + } + + return properties; +} + +/*****************************************************************************/ + +MMBearerProperties * +mm_bearer_properties_dup (MMBearerProperties *orig) +{ + GVariant *dict; + MMBearerProperties *copy; + GError *error = NULL; + + g_return_val_if_fail (MM_IS_BEARER_PROPERTIES (orig), NULL); + + dict = mm_bearer_properties_get_dictionary (orig); + copy = mm_bearer_properties_new_from_dictionary (dict, &error); + g_assert_no_error (error); + g_variant_unref (dict); + + return copy; +} + +/*****************************************************************************/ + +gboolean +mm_bearer_properties_cmp (MMBearerProperties *a, + MMBearerProperties *b) +{ + return ((!g_strcmp0 (a->priv->apn, b->priv->apn)) && + (a->priv->ip_type == b->priv->ip_type) && + (!g_strcmp0 (a->priv->number, b->priv->number)) && + (a->priv->allowed_auth == b->priv->allowed_auth) && + (!g_strcmp0 (a->priv->user, b->priv->user)) && + (!g_strcmp0 (a->priv->password, b->priv->password)) && + (a->priv->allow_roaming == b->priv->allow_roaming) && + (a->priv->allow_roaming_set == b->priv->allow_roaming_set) && + (a->priv->rm_protocol == b->priv->rm_protocol)); +} + +/*****************************************************************************/ + +/** + * mm_bearer_properties_new: + * + * Creates a new empty #MMBearerProperties. + * + * Returns: (transfer full): a #MMBearerProperties. The returned value should be freed with g_object_unref(). + */ +MMBearerProperties * +mm_bearer_properties_new (void) +{ + return (MM_BEARER_PROPERTIES ( + g_object_new (MM_TYPE_BEARER_PROPERTIES, NULL))); +} + +static void +mm_bearer_properties_init (MMBearerProperties *self) +{ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), + MM_TYPE_BEARER_PROPERTIES, + MMBearerPropertiesPrivate); + + /* Some defaults */ + self->priv->allow_roaming = TRUE; + self->priv->rm_protocol = MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN; + self->priv->allowed_auth = MM_BEARER_ALLOWED_AUTH_UNKNOWN; + self->priv->ip_type = MM_BEARER_IP_FAMILY_NONE; +} + +static void +finalize (GObject *object) +{ + MMBearerProperties *self = MM_BEARER_PROPERTIES (object); + + g_free (self->priv->apn); + g_free (self->priv->user); + g_free (self->priv->password); + g_free (self->priv->number); + + G_OBJECT_CLASS (mm_bearer_properties_parent_class)->finalize (object); +} + +static void +mm_bearer_properties_class_init (MMBearerPropertiesClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (MMBearerPropertiesPrivate)); + + object_class->finalize = finalize; +} diff --git a/libmm-glib/mm-bearer-properties.h b/libmm-glib/mm-bearer-properties.h new file mode 100644 index 0000000..852d16e --- /dev/null +++ b/libmm-glib/mm-bearer-properties.h @@ -0,0 +1,119 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2011 Aleksander Morgado <aleksander@gnu.org> + */ + +#ifndef MM_BEARER_PROPERTIES_H +#define MM_BEARER_PROPERTIES_H + +#include <ModemManager.h> +#include <glib-object.h> + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +G_BEGIN_DECLS + +#define MM_TYPE_BEARER_PROPERTIES (mm_bearer_properties_get_type ()) +#define MM_BEARER_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BEARER_PROPERTIES, MMBearerProperties)) +#define MM_BEARER_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BEARER_PROPERTIES, MMBearerPropertiesClass)) +#define MM_IS_BEARER_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BEARER_PROPERTIES)) +#define MM_IS_BEARER_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BEARER_PROPERTIES)) +#define MM_BEARER_PROPERTIES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BEARER_PROPERTIES, MMBearerPropertiesClass)) + +typedef struct _MMBearerProperties MMBearerProperties; +typedef struct _MMBearerPropertiesClass MMBearerPropertiesClass; +typedef struct _MMBearerPropertiesPrivate MMBearerPropertiesPrivate; + +/** + * MMBearerProperties: + * + * The #MMBearerProperties structure contains private data and should + * only be accessed using the provided API. + */ +struct _MMBearerProperties { + /*< private >*/ + GObject parent; + MMBearerPropertiesPrivate *priv; +}; + +struct _MMBearerPropertiesClass { + /*< private >*/ + GObjectClass parent; +}; + +GType mm_bearer_properties_get_type (void); + +MMBearerProperties *mm_bearer_properties_new (void); + +void mm_bearer_properties_set_apn (MMBearerProperties *self, + const gchar *apn); +void mm_bearer_properties_set_allowed_auth (MMBearerProperties *self, + MMBearerAllowedAuth allowed_auth); +void mm_bearer_properties_set_user (MMBearerProperties *self, + const gchar *user); +void mm_bearer_properties_set_password (MMBearerProperties *self, + const gchar *password); +void mm_bearer_properties_set_ip_type (MMBearerProperties *self, + MMBearerIpFamily ip_type); +void mm_bearer_properties_set_allow_roaming (MMBearerProperties *self, + gboolean allow_roaming); +void mm_bearer_properties_set_number (MMBearerProperties *self, + const gchar *number); +void mm_bearer_properties_set_rm_protocol (MMBearerProperties *self, + MMModemCdmaRmProtocol protocol); + +const gchar *mm_bearer_properties_get_apn (MMBearerProperties *self); +MMBearerAllowedAuth mm_bearer_properties_get_allowed_auth (MMBearerProperties *self); +const gchar *mm_bearer_properties_get_user (MMBearerProperties *self); +const gchar *mm_bearer_properties_get_password (MMBearerProperties *self); +MMBearerIpFamily mm_bearer_properties_get_ip_type (MMBearerProperties *self); +gboolean mm_bearer_properties_get_allow_roaming (MMBearerProperties *self); +const gchar *mm_bearer_properties_get_number (MMBearerProperties *self); +MMModemCdmaRmProtocol mm_bearer_properties_get_rm_protocol (MMBearerProperties *self); + +/*****************************************************************************/ +/* ModemManager/libmm-glib/mmcli specific methods */ + +#if defined (_LIBMM_INSIDE_MM) || \ + defined (_LIBMM_INSIDE_MMCLI) || \ + defined (LIBMM_GLIB_COMPILATION) + +MMBearerProperties *mm_bearer_properties_new_from_string (const gchar *str, + GError **error); +MMBearerProperties *mm_bearer_properties_new_from_dictionary (GVariant *dictionary, + GError **error); + +MMBearerProperties *mm_bearer_properties_dup (MMBearerProperties *orig); + +gboolean mm_bearer_properties_consume_string (MMBearerProperties *self, + const gchar *key, + const gchar *value, + GError **error); + +gboolean mm_bearer_properties_consume_variant (MMBearerProperties *self, + const gchar *key, + GVariant *value, + GError **error); + +GVariant *mm_bearer_properties_get_dictionary (MMBearerProperties *self); + +gboolean mm_bearer_properties_cmp (MMBearerProperties *a, + MMBearerProperties *b); + +#endif + +G_END_DECLS + +#endif /* MM_BEARER_PROPERTIES_H */ diff --git a/libmm-glib/mm-bearer.c b/libmm-glib/mm-bearer.c new file mode 100644 index 0000000..36da4f7 --- /dev/null +++ b/libmm-glib/mm-bearer.c @@ -0,0 +1,726 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2011 - 2012 Aleksander Morgado <aleksander@gnu.org> + * Copyright (C) 2012 Google, Inc. + */ + +#include "mm-helpers.h" +#include "mm-bearer.h" + +/** + * SECTION: mm-bearer + * @title: MMBearer + * @short_description: The Bearer interface + * + * The #MMBearer is an object providing access to the methods, signals and + * properties of the Bearer interface. + * + * When the bearer is exposed and available in the bus, it is ensured that at + * least this interface is also available. + */ + +G_DEFINE_TYPE (MMBearer, mm_bearer, MM_GDBUS_TYPE_BEARER_PROXY) + +struct _MMBearerPrivate { + /* IPv4 config */ + GMutex ipv4_config_mutex; + guint ipv4_config_id; + MMBearerIpConfig *ipv4_config; + + /* IPv6 config */ + GMutex ipv6_config_mutex; + guint ipv6_config_id; + MMBearerIpConfig *ipv6_config; + + /* Properties */ + GMutex properties_mutex; + guint properties_id; + MMBearerProperties *properties; +}; + +/*****************************************************************************/ + +/** + * mm_bearer_get_path: + * @self: A #MMBearer. + * + * Gets the DBus path of the #MMBearer object. + * + * Returns: (transfer none): The DBus path of the #MMBearer object. + */ +const gchar * +mm_bearer_get_path (MMBearer *self) +{ + g_return_val_if_fail (MM_IS_BEARER (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + g_dbus_proxy_get_object_path (G_DBUS_PROXY (self))); +} + +/** + * mm_bearer_dup_path: + * @self: A #MMBearer. + * + * Gets a copy of the DBus path of the #MMBearer object. + * + * Returns: (transfer full): The DBus path of the #MMBearer object. The returned value should be freed with g_free(). + */ +gchar * +mm_bearer_dup_path (MMBearer *self) +{ + gchar *value; + + g_return_val_if_fail (MM_IS_BEARER (self), NULL); + + g_object_get (G_OBJECT (self), + "g-object-path", &value, + NULL); + + RETURN_NON_EMPTY_STRING (value); +} + +/*****************************************************************************/ + +/** + * mm_bearer_get_interface: + * @self: A #MMBearer. + * + * Gets the operating system name for the network data interface that provides + * packet data using this #MMBearer. This will only be available once the #MMBearer + * is in connected state. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_bearer_dup_interface() if on another + * thread.</warning> + * + * Returns: (transfer none): The name of the interface, or %NULL if it couldn't be retrieved. + */ +const gchar * +mm_bearer_get_interface (MMBearer *self) +{ + g_return_val_if_fail (MM_IS_BEARER (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_bearer_get_interface (MM_GDBUS_BEARER (self))); +} + +/** + * mm_bearer_dup_interface: + * @self: A #MMBearer. + * + * Gets a copy of the operating system name for the network data interface that provides + * packet data using this #MMBearer. This will only be available once the #MMBearer + * is in connected state. + * + * Returns: (transfer full): The name of the interface, or %NULL if it couldn't be retrieved. The returned value should be freed with g_free(). + */ +gchar * +mm_bearer_dup_interface (MMBearer *self) +{ + g_return_val_if_fail (MM_IS_BEARER (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_bearer_dup_interface (MM_GDBUS_BEARER (self))); +} + +/*****************************************************************************/ + +/** + * mm_bearer_get_connected: + * @self: A #MMBearer. + * + * Checks whether or not the #MMBearer is connected and thus whether packet data + * communication is possible. + * + * Returns: %TRUE if the #MMBearer is connected, #FALSE otherwise. + */ +gboolean +mm_bearer_get_connected (MMBearer *self) +{ + g_return_val_if_fail (MM_IS_BEARER (self), FALSE); + + return mm_gdbus_bearer_get_connected (MM_GDBUS_BEARER (self)); +} + +/*****************************************************************************/ + +/** + * mm_bearer_get_suspended: + * @self: A #MMBearer. + * + * Checks whether or not the #MMBearer is suspended (but not deactivated) while the + * device is handling other communications, like a voice call. + * + * Returns: %TRUE if packet data service is suspended in the #MMBearer, #FALSE otherwise. + */ +gboolean +mm_bearer_get_suspended (MMBearer *self) +{ + g_return_val_if_fail (MM_IS_BEARER (self), FALSE); + + return mm_gdbus_bearer_get_suspended (MM_GDBUS_BEARER (self)); +} + +/*****************************************************************************/ + +/** + * mm_bearer_get_ip_timeout: + * @self: A #MMBearer. + * + * Gets the maximum time to wait for the bearer to retrieve a valid IP address. + * + * Returns: The IP timeout, or 0 if no specific one given. + */ +guint +mm_bearer_get_ip_timeout (MMBearer *self) +{ + g_return_val_if_fail (MM_IS_BEARER (self), 0); + + return mm_gdbus_bearer_get_ip_timeout (MM_GDBUS_BEARER (self)); +} + +/*****************************************************************************/ + +static void +ipv4_config_updated (MMBearer *self, + GParamSpec *pspec) +{ + g_mutex_lock (&self->priv->ipv4_config_mutex); + { + GVariant *dictionary; + + g_clear_object (&self->priv->ipv4_config); + + /* TODO: update existing object instead of re-creating? */ + dictionary = mm_gdbus_bearer_get_ip4_config (MM_GDBUS_BEARER (self)); + if (dictionary) { + GError *error = NULL; + + self->priv->ipv4_config = mm_bearer_ip_config_new_from_dictionary (dictionary, &error); + if (error) { + g_warning ("Invalid IPv4 configuration update received: %s", error->message); + g_error_free (error); + } + } + } + g_mutex_unlock (&self->priv->ipv4_config_mutex); +} + +static void +ensure_internal_ipv4_config (MMBearer *self, + MMBearerIpConfig **dup) +{ + g_mutex_lock (&self->priv->ipv4_config_mutex); + { + /* If this is the first time ever asking for the object, setup the + * update listener and the initial object, if any. */ + if (!self->priv->ipv4_config_id) { + GVariant *dictionary; + + dictionary = mm_gdbus_bearer_dup_ip4_config (MM_GDBUS_BEARER (self)); + if (dictionary) { + GError *error = NULL; + + self->priv->ipv4_config = mm_bearer_ip_config_new_from_dictionary (dictionary, &error); + if (error) { + g_warning ("Invalid initial IPv4 configuration: %s", error->message); + g_error_free (error); + } + g_variant_unref (dictionary); + } + + /* No need to clear this signal connection when freeing self */ + self->priv->ipv4_config_id = + g_signal_connect (self, + "notify::ip4-config", + G_CALLBACK (ipv4_config_updated), + NULL); + } + + if (dup && self->priv->ipv4_config) + *dup = g_object_ref (self->priv->ipv4_config); + } + g_mutex_unlock (&self->priv->ipv4_config_mutex); +} + +/** + * mm_bearer_get_ipv4_config: + * @self: A #MMBearer. + * + * Gets a #MMBearerIpConfig object specifying the IPv4 configuration to use in + * the bearer. + * + * <warning>The values reported by @self are not updated when the values in the + * interface change. Instead, the client is expected to call + * mm_bearer_get_ipv4_config() again to get a new #MMBearerIpConfig with the + * new values.</warning> + * + * Returns: (transfer full) A #MMBearerIpConfig that must be freed with g_object_unref() or %NULL if unknown. + */ +MMBearerIpConfig * +mm_bearer_get_ipv4_config (MMBearer *self) +{ + MMBearerIpConfig *config = NULL; + + g_return_val_if_fail (MM_IS_BEARER (self), NULL); + + ensure_internal_ipv4_config (self, &config); + return config; +} + +/** + * mm_bearer_peek_ipv4_config: + * @self: A #MMBearer. + * + * Gets a #MMBearerIpConfig object specifying the IPv4 configuration to use in + * the bearer. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_bearer_get_ipv4_config() if on another + * thread.</warning> + * + * Returns: (transfer none) A #MMBearerIpConfig. Do not free the returned value, it belongs to @self. + */ +MMBearerIpConfig * +mm_bearer_peek_ipv4_config (MMBearer *self) +{ + g_return_val_if_fail (MM_IS_BEARER (self), NULL); + + ensure_internal_ipv4_config (self, NULL); + return self->priv->ipv4_config; +} + +/*****************************************************************************/ + +static void +ipv6_config_updated (MMBearer *self, + GParamSpec *pspec) +{ + g_mutex_lock (&self->priv->ipv6_config_mutex); + { + GVariant *dictionary; + + g_clear_object (&self->priv->ipv6_config); + + /* TODO: update existing object instead of re-creating? */ + dictionary = mm_gdbus_bearer_get_ip6_config (MM_GDBUS_BEARER (self)); + if (dictionary) { + GError *error = NULL; + + self->priv->ipv6_config = mm_bearer_ip_config_new_from_dictionary (dictionary, &error); + if (error) { + g_warning ("Invalid IPv6 configuration update received: %s", error->message); + g_error_free (error); + } + } + } + g_mutex_unlock (&self->priv->ipv6_config_mutex); +} + +static void +ensure_internal_ipv6_config (MMBearer *self, + MMBearerIpConfig **dup) +{ + g_mutex_lock (&self->priv->ipv6_config_mutex); + { + /* If this is the first time ever asking for the object, setup the + * update listener and the initial object, if any. */ + if (!self->priv->ipv6_config_id) { + GVariant *dictionary; + + dictionary = mm_gdbus_bearer_dup_ip6_config (MM_GDBUS_BEARER (self)); + if (dictionary) { + GError *error = NULL; + + self->priv->ipv6_config = mm_bearer_ip_config_new_from_dictionary (dictionary, &error); + if (error) { + g_warning ("Invalid initial IPv6 configuration: %s", error->message); + g_error_free (error); + } + g_variant_unref (dictionary); + } + + /* No need to clear this signal connection when freeing self */ + self->priv->ipv6_config_id = + g_signal_connect (self, + "notify::ip6-config", + G_CALLBACK (ipv6_config_updated), + NULL); + } + + if (dup && self->priv->ipv6_config) + *dup = g_object_ref (self->priv->ipv6_config); + } + g_mutex_unlock (&self->priv->ipv6_config_mutex); +} + +/** + * mm_bearer_get_ipv6_config: + * @self: A #MMBearer. + * + * Gets a #MMBearerIpConfig object specifying the IPv6 configuration to use in + * the bearer. + * + * <warning>The values reported by @self are not updated when the values in the + * interface change. Instead, the client is expected to call + * mm_bearer_get_ipv6_config() again to get a new #MMBearerIpConfig with the + * new values.</warning> + * + * Returns: (transfer full) A #MMBearerIpConfig that must be freed with g_object_unref() or %NULL if unknown. + */ +MMBearerIpConfig * +mm_bearer_get_ipv6_config (MMBearer *self) +{ + MMBearerIpConfig *config = NULL; + + g_return_val_if_fail (MM_IS_BEARER (self), NULL); + + ensure_internal_ipv6_config (self, &config); + return config; +} + +/** + * mm_bearer_peek_ipv6_config: + * @self: A #MMBearer. + * + * Gets a #MMBearerIpConfig object specifying the IPv6 configuration to use in + * the bearer. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_bearer_get_ipv6_config() if on another + * thread.</warning> + * + * Returns: (transfer none) A #MMBearerIpConfig. Do not free the returned value, it belongs to @self. + */ +MMBearerIpConfig * +mm_bearer_peek_ipv6_config (MMBearer *self) +{ + g_return_val_if_fail (MM_IS_BEARER (self), NULL); + + ensure_internal_ipv6_config (self, NULL); + return self->priv->ipv6_config; +} + +/*****************************************************************************/ + +static void +properties_updated (MMBearer *self, + GParamSpec *pspec) +{ + g_mutex_lock (&self->priv->properties_mutex); + { + GVariant *dictionary; + + g_clear_object (&self->priv->properties); + + /* TODO: update existing object instead of re-creating? */ + dictionary = mm_gdbus_bearer_get_properties (MM_GDBUS_BEARER (self)); + if (dictionary) { + GError *error = NULL; + + self->priv->properties = mm_bearer_properties_new_from_dictionary (dictionary, &error); + if (error) { + g_warning ("Invalid bearer properties received: %s", error->message); + g_error_free (error); + } + } + } + g_mutex_unlock (&self->priv->properties_mutex); +} + +static void +ensure_internal_properties (MMBearer *self, + MMBearerProperties **dup) +{ + g_mutex_lock (&self->priv->properties_mutex); + { + /* If this is the first time ever asking for the object, setup the + * update listener and the initial object, if any. */ + if (!self->priv->properties_id) { + GVariant *dictionary; + + dictionary = mm_gdbus_bearer_dup_properties (MM_GDBUS_BEARER (self)); + if (dictionary) { + GError *error = NULL; + + self->priv->properties = mm_bearer_properties_new_from_dictionary (dictionary, &error); + if (error) { + g_warning ("Invalid initial bearer properties: %s", error->message); + g_error_free (error); + } + g_variant_unref (dictionary); + } + + /* No need to clear this signal connection when freeing self */ + self->priv->properties_id = + g_signal_connect (self, + "notify::properties", + G_CALLBACK (properties_updated), + NULL); + } + + if (dup && self->priv->properties) + *dup = g_object_ref (self->priv->properties); + } + g_mutex_unlock (&self->priv->properties_mutex); +} + +/** + * mm_bearer_get_properties: + * @self: A #MMBearer. + * + * Gets a #MMBearerProperties object specifying the properties which were used + * to create the bearer. + * + * <warning>The values reported by @self are not updated when the values in the + * interface change. Instead, the client is expected to call + * mm_bearer_get_properties() again to get a new #MMBearerProperties with the + * new values.</warning> + * + * Returns: (transfer full) A #MMBearerProperties that must be freed with g_object_unref() or %NULL if unknown. + */ +MMBearerProperties * +mm_bearer_get_properties (MMBearer *self) +{ + MMBearerProperties *props = NULL; + + g_return_val_if_fail (MM_IS_BEARER (self), NULL); + + ensure_internal_properties (self, &props); + return props; +} + +/** + * mm_bearer_peek_properties: + * @self: A #MMBearer. + * + * Gets a #MMBearerProperties object specifying the properties which were used + * to create the bearer. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_bearer_get_properties() if on another + * thread.</warning> + * + * Returns: (transfer none) A #MMBearerProperties. Do not free the returned value, it belongs to @self. + */ +MMBearerProperties * +mm_bearer_peek_properties (MMBearer *self) +{ + g_return_val_if_fail (MM_IS_BEARER (self), NULL); + + ensure_internal_properties (self, NULL); + return self->priv->properties; +} + +/*****************************************************************************/ + +/** + * mm_bearer_connect_finish: + * @self: A #MMBearer. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_bearer_connect(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_bearer_connect(). + * + * Returns: %TRUE if the operation succeded, %FALSE if @error is set. + */ +gboolean +mm_bearer_connect_finish (MMBearer *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_BEARER (self), FALSE); + + return mm_gdbus_bearer_call_connect_finish (MM_GDBUS_BEARER (self), res, error); +} + +/** + * mm_bearer_connect: + * @self: A #MMBearer. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously requests activation of a packet data connection with the + * network using this #MMBearer properties. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_bearer_connect_finish() to get the result of the operation. + * + * See mm_bearer_connect_sync() for the synchronous, blocking version of this method. + */ +void +mm_bearer_connect (MMBearer *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_BEARER (self)); + + mm_gdbus_bearer_call_connect (MM_GDBUS_BEARER (self), cancellable, callback, user_data); +} + +/** + * mm_bearer_connect_sync: + * @self: A #MMBearer. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously requests activation of a packet data connection with the + * network using this #MMBearer properties. + * + * The calling thread is blocked until a reply is received. + * See mm_bearer_connect() for the asynchronous version of this method. + * + * Returns: %TRUE if the operation succeded, %FALSE if @error is set. + */ +gboolean +mm_bearer_connect_sync (MMBearer *self, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_BEARER (self), FALSE); + + return mm_gdbus_bearer_call_connect_sync (MM_GDBUS_BEARER (self), cancellable, error); +} + +/*****************************************************************************/ + +/** + * mm_bearer_disconnect: + * @self: A #MMBearer. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Synchronously requests disconnection and deactivation of the packet data connection. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_bearer_disconnect_finish() to get the result of the operation. + * + * See mm_bearer_disconnect_sync() for the synchronous, blocking version of this method. + */ +void +mm_bearer_disconnect (MMBearer *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_BEARER (self)); + + mm_gdbus_bearer_call_disconnect (MM_GDBUS_BEARER (self), cancellable, callback, user_data); +} + +/** + * mm_bearer_disconnect_finish: + * @self: A #MMBearer. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_bearer_disconnect(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_bearer_disconnect(). + * + * Returns: %TRUE if the operation succeded, %FALSE if @error is set. + */ +gboolean +mm_bearer_disconnect_finish (MMBearer *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_BEARER (self), FALSE); + + return mm_gdbus_bearer_call_disconnect_finish (MM_GDBUS_BEARER (self), res, error); +} + +/** + * mm_bearer_disconnect_sync: + * @self: A #MMBearer. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously requests disconnection and deactivation of the packet data connection. + * + * The calling thread is blocked until a reply is received. + * See mm_bearer_disconnect() for the asynchronous version of this method. + * + * Returns: %TRUE if the operation succeded, %FALSE if @error is set. + */ +gboolean +mm_bearer_disconnect_sync (MMBearer *self, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_BEARER (self), FALSE); + + return mm_gdbus_bearer_call_disconnect_sync (MM_GDBUS_BEARER (self), cancellable, error); +} + +/*****************************************************************************/ + +static void +mm_bearer_init (MMBearer *self) +{ + /* Setup private data */ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, + MM_TYPE_BEARER, + MMBearerPrivate); + g_mutex_init (&self->priv->ipv4_config_mutex); + g_mutex_init (&self->priv->ipv6_config_mutex); + g_mutex_init (&self->priv->properties_mutex); +} + +static void +finalize (GObject *object) +{ + MMBearer *self = MM_BEARER (object); + + g_mutex_clear (&self->priv->ipv4_config_mutex); + g_mutex_clear (&self->priv->ipv6_config_mutex); + g_mutex_clear (&self->priv->properties_mutex); + + G_OBJECT_CLASS (mm_bearer_parent_class)->finalize (object); +} + +static void +dispose (GObject *object) +{ + MMBearer *self = MM_BEARER (object); + + g_clear_object (&self->priv->ipv4_config); + g_clear_object (&self->priv->ipv6_config); + g_clear_object (&self->priv->properties); + + G_OBJECT_CLASS (mm_bearer_parent_class)->dispose (object); +} + +static void +mm_bearer_class_init (MMBearerClass *bearer_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (bearer_class); + + g_type_class_add_private (object_class, sizeof (MMBearerPrivate)); + + /* Virtual methods */ + object_class->dispose = dispose; + object_class->finalize = finalize; +} diff --git a/libmm-glib/mm-bearer.h b/libmm-glib/mm-bearer.h new file mode 100644 index 0000000..dbaf497 --- /dev/null +++ b/libmm-glib/mm-bearer.h @@ -0,0 +1,114 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2011 - 2012 Aleksander Morgado <aleksander@gnu.org> + * Copyright (C) 2012 Google, Inc. + */ + +#ifndef _MM_BEARER_H_ +#define _MM_BEARER_H_ + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> + +#include "mm-gdbus-bearer.h" +#include "mm-bearer-properties.h" +#include "mm-bearer-ip-config.h" + +G_BEGIN_DECLS + +#define MM_TYPE_BEARER (mm_bearer_get_type ()) +#define MM_BEARER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BEARER, MMBearer)) +#define MM_BEARER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BEARER, MMBearerClass)) +#define MM_IS_BEARER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BEARER)) +#define MM_IS_BEARER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), MM_TYPE_BEARER)) +#define MM_BEARER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BEARER, MMBearerClass)) + +typedef struct _MMBearer MMBearer; +typedef struct _MMBearerClass MMBearerClass; +typedef struct _MMBearerPrivate MMBearerPrivate; + +/** + * MMBearer: + * + * The #MMBearer structure contains private data and should only be accessed + * using the provided API. + */ +struct _MMBearer { + /*< private >*/ + MmGdbusBearerProxy parent; + MMBearerPrivate *priv; +}; + +struct _MMBearerClass { + /*< private >*/ + MmGdbusBearerProxyClass parent; +}; + +GType mm_bearer_get_type (void); + +const gchar *mm_bearer_get_path (MMBearer *self); +gchar *mm_bearer_dup_path (MMBearer *self); + +const gchar *mm_bearer_get_interface (MMBearer *self); +gchar *mm_bearer_dup_interface (MMBearer *self); + +gboolean mm_bearer_get_connected (MMBearer *self); + +gboolean mm_bearer_get_suspended (MMBearer *self); + +guint mm_bearer_get_ip_timeout (MMBearer *self); + +void mm_bearer_connect (MMBearer *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_bearer_connect_finish (MMBearer *self, + GAsyncResult *res, + GError **error); +gboolean mm_bearer_connect_sync (MMBearer *self, + GCancellable *cancellable, + GError **error); + +void mm_bearer_disconnect (MMBearer *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_bearer_disconnect_finish (MMBearer *self, + GAsyncResult *res, + GError **error); +gboolean mm_bearer_disconnect_sync (MMBearer *self, + GCancellable *cancellable, + GError **error); + +MMBearerProperties *mm_bearer_get_properties (MMBearer *self); +MMBearerProperties *mm_bearer_peek_properties (MMBearer *self); + +MMBearerIpConfig *mm_bearer_get_ipv4_config (MMBearer *self); +MMBearerIpConfig *mm_bearer_peek_ipv4_config (MMBearer *self); + +MMBearerIpConfig *mm_bearer_get_ipv6_config (MMBearer *self); +MMBearerIpConfig *mm_bearer_peek_ipv6_config (MMBearer *self); + +G_END_DECLS + +#endif /* _MM_BEARER_H_ */ diff --git a/libmm-glib/mm-common-helpers.c b/libmm-glib/mm-common-helpers.c new file mode 100644 index 0000000..838e09f --- /dev/null +++ b/libmm-glib/mm-common-helpers.c @@ -0,0 +1,1284 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2010 - 2012 Red Hat, Inc. + * Copyright (C) 2011 - 2012 Google, Inc. + */ + +#include <string.h> +#include <errno.h> +#include <stdlib.h> +#include <gio/gio.h> + +#include <ModemManager.h> + +#include "mm-enums-types.h" +#include "mm-errors-types.h" +#include "mm-common-helpers.h" + +gchar * +mm_common_build_capabilities_string (const MMModemCapability *capabilities, + guint n_capabilities) +{ + gboolean first = TRUE; + GString *str; + guint i; + + if (!capabilities || !n_capabilities) + return g_strdup ("none"); + + str = g_string_new (""); + for (i = 0; i < n_capabilities; i++) { + gchar *tmp; + + tmp = mm_modem_capability_build_string_from_mask (capabilities[i]); + g_string_append_printf (str, "%s%s", + first ? "" : "\n", + tmp); + g_free (tmp); + + if (first) + first = FALSE; + } + + return g_string_free (str, FALSE); +} + +gchar * +mm_common_build_bands_string (const MMModemBand *bands, + guint n_bands) +{ + gboolean first = TRUE; + GString *str; + guint i; + + if (!bands || !n_bands) + return g_strdup ("none"); + + str = g_string_new (""); + for (i = 0; i < n_bands; i++) { + g_string_append_printf (str, "%s%s", + first ? "" : ", ", + mm_modem_band_get_string (bands[i])); + + if (first) + first = FALSE; + } + + return g_string_free (str, FALSE); +} + +gchar * +mm_common_build_sms_storages_string (const MMSmsStorage *storages, + guint n_storages) +{ + gboolean first = TRUE; + GString *str; + guint i; + + if (!storages || !n_storages) + return g_strdup ("none"); + + str = g_string_new (""); + for (i = 0; i < n_storages; i++) { + g_string_append_printf (str, "%s%s", + first ? "" : ", ", + mm_sms_storage_get_string (storages[i])); + + if (first) + first = FALSE; + } + + return g_string_free (str, FALSE); +} + +gchar * +mm_common_build_mode_combinations_string (const MMModemModeCombination *modes, + guint n_modes) +{ + gboolean first = TRUE; + GString *str; + guint i; + + if (!modes || !n_modes) + return g_strdup ("none"); + + str = g_string_new (""); + for (i = 0; i < n_modes; i++) { + gchar *allowed; + gchar *preferred; + + allowed = mm_modem_mode_build_string_from_mask (modes[i].allowed); + preferred = mm_modem_mode_build_string_from_mask (modes[i].preferred); + g_string_append_printf (str, "%sallowed: %s; preferred: %s", + first ? "" : "\n", + allowed, + preferred); + g_free (allowed); + g_free (preferred); + + if (first) + first = FALSE; + } + + return g_string_free (str, FALSE); +} + +GArray * +mm_common_sms_storages_variant_to_garray (GVariant *variant) +{ + GArray *array = NULL; + + if (variant) { + GVariantIter iter; + guint n; + + g_variant_iter_init (&iter, variant); + n = g_variant_iter_n_children (&iter); + + if (n > 0) { + guint32 storage; + + array = g_array_sized_new (FALSE, FALSE, sizeof (MMSmsStorage), n); + while (g_variant_iter_loop (&iter, "u", &storage)) + g_array_append_val (array, storage); + } + } + + return array; +} + +MMSmsStorage * +mm_common_sms_storages_variant_to_array (GVariant *variant, + guint *n_storages) +{ + GArray *array; + + array = mm_common_sms_storages_variant_to_garray (variant); + if (n_storages) + *n_storages = array->len; + return (MMSmsStorage *) g_array_free (array, FALSE); +} + +GVariant * +mm_common_sms_storages_array_to_variant (const MMSmsStorage *storages, + guint n_storages) +{ + GVariantBuilder builder; + guint i; + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("au")); + + for (i = 0; i < n_storages; i++) + g_variant_builder_add_value (&builder, + g_variant_new_uint32 ((guint32)storages[i])); + return g_variant_builder_end (&builder); +} + +GVariant * +mm_common_sms_storages_garray_to_variant (GArray *array) +{ + if (array) + return mm_common_sms_storages_array_to_variant ((const MMSmsStorage *)array->data, + array->len); + + return mm_common_sms_storages_array_to_variant (NULL, 0); +} + +MMModemCapability +mm_common_get_capabilities_from_string (const gchar *str, + GError **error) +{ + GError *inner_error = NULL; + MMModemCapability capabilities; + gchar **capability_strings; + GFlagsClass *flags_class; + + capabilities = MM_MODEM_CAPABILITY_NONE; + + flags_class = G_FLAGS_CLASS (g_type_class_ref (MM_TYPE_MODEM_CAPABILITY)); + capability_strings = g_strsplit (str, "|", -1); + + if (capability_strings) { + guint i; + + for (i = 0; capability_strings[i]; i++) { + guint j; + gboolean found = FALSE; + + for (j = 0; flags_class->values[j].value_nick; j++) { + if (!g_ascii_strcasecmp (capability_strings[i], flags_class->values[j].value_nick)) { + capabilities |= flags_class->values[j].value; + found = TRUE; + break; + } + } + + if (!found) { + inner_error = g_error_new ( + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Couldn't match '%s' with a valid MMModemCapability value", + capability_strings[i]); + break; + } + } + } + + if (inner_error) { + g_propagate_error (error, inner_error); + capabilities = MM_MODEM_CAPABILITY_NONE; + } + + g_type_class_unref (flags_class); + g_strfreev (capability_strings); + return capabilities; +} + +MMModemMode +mm_common_get_modes_from_string (const gchar *str, + GError **error) +{ + GError *inner_error = NULL; + MMModemMode modes; + gchar **mode_strings; + GFlagsClass *flags_class; + + modes = MM_MODEM_MODE_NONE; + + flags_class = G_FLAGS_CLASS (g_type_class_ref (MM_TYPE_MODEM_MODE)); + mode_strings = g_strsplit (str, "|", -1); + + if (mode_strings) { + guint i; + + for (i = 0; mode_strings[i]; i++) { + guint j; + gboolean found = FALSE; + + for (j = 0; flags_class->values[j].value_nick; j++) { + if (!g_ascii_strcasecmp (mode_strings[i], flags_class->values[j].value_nick)) { + modes |= flags_class->values[j].value; + found = TRUE; + break; + } + } + + if (!found) { + inner_error = g_error_new ( + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Couldn't match '%s' with a valid MMModemMode value", + mode_strings[i]); + break; + } + } + } + + if (inner_error) { + g_propagate_error (error, inner_error); + modes = MM_MODEM_MODE_NONE; + } + + g_type_class_unref (flags_class); + g_strfreev (mode_strings); + return modes; +} + +GArray * +mm_common_capability_combinations_variant_to_garray (GVariant *variant) +{ + GArray *array = NULL; + + if (variant) { + GVariantIter iter; + guint n; + + g_variant_iter_init (&iter, variant); + n = g_variant_iter_n_children (&iter); + + if (n > 0) { + guint32 capability; + + array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemCapability), n); + while (g_variant_iter_loop (&iter, "u", &capability)) + g_array_append_val (array, capability); + } + } + + /* If nothing set, fallback to default */ + if (!array) { + guint32 capability = MM_MODEM_CAPABILITY_NONE; + + array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemCapability), 1); + g_array_append_val (array, capability); + } + + return array; +} + +MMModemCapability * +mm_common_capability_combinations_variant_to_array (GVariant *variant, + guint *n_capabilities) +{ + GArray *array; + + array = mm_common_capability_combinations_variant_to_garray (variant); + if (n_capabilities) + *n_capabilities = array->len; + return (MMModemCapability *) g_array_free (array, FALSE); +} + +GVariant * +mm_common_capability_combinations_array_to_variant (const MMModemCapability *capabilities, + guint n_capabilities) +{ + GVariantBuilder builder; + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("au")); + + if (n_capabilities > 0) { + guint i; + + for (i = 0; i < n_capabilities; i++) + g_variant_builder_add_value (&builder, + g_variant_new_uint32 ((guint32)capabilities[i])); + } else + g_variant_builder_add_value (&builder, + g_variant_new_uint32 (MM_MODEM_CAPABILITY_NONE)); + + return g_variant_builder_end (&builder); +} + +GVariant * +mm_common_capability_combinations_garray_to_variant (GArray *array) +{ + if (array) + return mm_common_capability_combinations_array_to_variant ((const MMModemCapability *)array->data, + array->len); + + return mm_common_capability_combinations_array_to_variant (NULL, 0); +} + +GVariant * +mm_common_build_capability_combinations_none (void) +{ + GVariantBuilder builder; + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("au")); + g_variant_builder_add_value (&builder, + g_variant_new_uint32 (MM_MODEM_CAPABILITY_NONE)); + return g_variant_builder_end (&builder); +} + +GVariant * +mm_common_build_capability_combinations_any (void) +{ + GVariantBuilder builder; + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("au")); + g_variant_builder_add_value (&builder, + g_variant_new_uint32 (MM_MODEM_CAPABILITY_ANY)); + return g_variant_builder_end (&builder); +} + +void +mm_common_get_bands_from_string (const gchar *str, + MMModemBand **bands, + guint *n_bands, + GError **error) +{ + GError *inner_error = NULL; + GArray *array; + gchar **band_strings; + GEnumClass *enum_class; + + array = g_array_new (FALSE, FALSE, sizeof (MMModemBand)); + + enum_class = G_ENUM_CLASS (g_type_class_ref (MM_TYPE_MODEM_BAND)); + band_strings = g_strsplit (str, "|", -1); + + if (band_strings) { + guint i; + + for (i = 0; band_strings[i]; i++) { + guint j; + gboolean found = FALSE; + + for (j = 0; enum_class->values[j].value_nick; j++) { + if (!g_ascii_strcasecmp (band_strings[i], enum_class->values[j].value_nick)) { + g_array_append_val (array, enum_class->values[j].value); + found = TRUE; + break; + } + } + + if (!found) { + inner_error = g_error_new (MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Couldn't match '%s' with a valid MMModemBand value", + band_strings[i]); + break; + } + } + } + + if (inner_error) { + g_propagate_error (error, inner_error); + g_array_free (array, TRUE); + *n_bands = 0; + *bands = NULL; + } else { + if (!array->len) { + GEnumValue *value; + + value = g_enum_get_value (enum_class, MM_MODEM_BAND_UNKNOWN); + g_array_append_val (array, value->value); + } + + *n_bands = array->len; + *bands = (MMModemBand *)g_array_free (array, FALSE); + } + + g_type_class_unref (enum_class); + g_strfreev (band_strings); +} + +GArray * +mm_common_bands_variant_to_garray (GVariant *variant) +{ + GArray *array = NULL; + + if (variant) { + GVariantIter iter; + guint n; + + g_variant_iter_init (&iter, variant); + n = g_variant_iter_n_children (&iter); + + if (n > 0) { + guint32 band; + + array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), n); + while (g_variant_iter_loop (&iter, "u", &band)) + g_array_append_val (array, band); + } + } + + /* If nothing set, fallback to default */ + if (!array) { + guint32 band = MM_MODEM_BAND_UNKNOWN; + + array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 1); + g_array_append_val (array, band); + } + + return array; +} + +MMModemBand * +mm_common_bands_variant_to_array (GVariant *variant, + guint *n_bands) +{ + GArray *array; + + array = mm_common_bands_variant_to_garray (variant); + if (n_bands) + *n_bands = array->len; + return (MMModemBand *) g_array_free (array, FALSE); +} + +GVariant * +mm_common_bands_array_to_variant (const MMModemBand *bands, + guint n_bands) +{ + if (n_bands > 0) { + GVariantBuilder builder; + guint i; + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("au")); + + for (i = 0; i < n_bands; i++) + g_variant_builder_add_value (&builder, + g_variant_new_uint32 ((guint32)bands[i])); + return g_variant_builder_end (&builder); + } + + return mm_common_build_bands_unknown (); +} + +GVariant * +mm_common_bands_garray_to_variant (GArray *array) +{ + if (array) + return mm_common_bands_array_to_variant ((const MMModemBand *)array->data, + array->len); + + return mm_common_bands_array_to_variant (NULL, 0); +} + +static guint +cmp_band (MMModemBand *a, MMModemBand *b) +{ + return (*a - *b); +} + +gboolean +mm_common_bands_garray_cmp (GArray *a, GArray *b) +{ + GArray *dup_a; + GArray *dup_b; + guint i; + gboolean different; + + if (a->len != b->len) + return FALSE; + + dup_a = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), a->len); + g_array_append_vals (dup_a, a->data, a->len); + + dup_b = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), b->len); + g_array_append_vals (dup_b, b->data, b->len); + + g_array_sort (dup_a, (GCompareFunc)cmp_band); + g_array_sort (dup_b, (GCompareFunc)cmp_band); + + different = FALSE; + for (i = 0; !different && i < a->len; i++) { + if (g_array_index (dup_a, MMModemBand, i) != g_array_index (dup_b, MMModemBand, i)) + different = TRUE; + } + + g_array_unref (dup_a); + g_array_unref (dup_b); + + return !different; +} + +GArray * +mm_common_mode_combinations_variant_to_garray (GVariant *variant) +{ + GArray *array = NULL; + + if (variant) { + GVariantIter iter; + guint n; + + g_variant_iter_init (&iter, variant); + n = g_variant_iter_n_children (&iter); + + if (n > 0) { + MMModemModeCombination mode; + + array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemModeCombination), n); + while (g_variant_iter_loop (&iter, "(uu)", &mode.allowed, &mode.preferred)) + g_array_append_val (array, mode); + } + } + + /* If nothing set, fallback to default */ + if (!array) { + MMModemModeCombination default_mode; + + default_mode.allowed = MM_MODEM_MODE_ANY; + default_mode.preferred = MM_MODEM_MODE_NONE; + array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemModeCombination), 1); + g_array_append_val (array, default_mode); + } + + return array; +} + +MMModemModeCombination * +mm_common_mode_combinations_variant_to_array (GVariant *variant, + guint *n_modes) +{ + GArray *array; + + array = mm_common_mode_combinations_variant_to_garray (variant); + if (n_modes) + *n_modes = array->len; + return (MMModemModeCombination *) g_array_free (array, FALSE); +} + +GVariant * +mm_common_mode_combinations_array_to_variant (const MMModemModeCombination *modes, + guint n_modes) +{ + if (n_modes > 0) { + GVariantBuilder builder; + guint i; + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(uu)")); + + for (i = 0; i < n_modes; i++) + g_variant_builder_add_value (&builder, + g_variant_new ("(uu)", + ((guint32)modes[i].allowed), + ((guint32)modes[i].preferred))); + return g_variant_builder_end (&builder); + } + + return mm_common_build_mode_combinations_default (); +} + +GVariant * +mm_common_mode_combinations_garray_to_variant (GArray *array) +{ + if (array) + return mm_common_mode_combinations_array_to_variant ((const MMModemModeCombination *)array->data, + array->len); + + return mm_common_mode_combinations_array_to_variant (NULL, 0); +} + +GVariant * +mm_common_build_mode_combinations_default (void) +{ + GVariantBuilder builder; + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(uu)")); + g_variant_builder_add_value (&builder, + g_variant_new ("(uu)", + MM_MODEM_MODE_ANY, + MM_MODEM_MODE_NONE)); + return g_variant_builder_end (&builder); +} + +gboolean +mm_common_get_boolean_from_string (const gchar *value, + GError **error) +{ + if (!g_ascii_strcasecmp (value, "true") || g_str_equal (value, "1")) + return TRUE; + + if (g_ascii_strcasecmp (value, "false") && g_str_equal (value, "0")) + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Cannot get boolean from string '%s'", value); + + return FALSE; +} + +MMModemCdmaRmProtocol +mm_common_get_rm_protocol_from_string (const gchar *str, + GError **error) +{ + GEnumClass *enum_class; + guint i; + + enum_class = G_ENUM_CLASS (g_type_class_ref (MM_TYPE_MODEM_CDMA_RM_PROTOCOL)); + + for (i = 0; enum_class->values[i].value_nick; i++) { + if (!g_ascii_strcasecmp (str, enum_class->values[i].value_nick)) + return enum_class->values[i].value; + } + + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Couldn't match '%s' with a valid MMModemCdmaRmProtocol value", + str); + return MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN; +} + +MMBearerIpFamily +mm_common_get_ip_type_from_string (const gchar *str, + GError **error) +{ + GFlagsClass *flags_class; + guint i; + + flags_class = G_FLAGS_CLASS (g_type_class_ref (MM_TYPE_BEARER_IP_FAMILY)); + + for (i = 0; flags_class->values[i].value_nick; i++) { + if (!g_ascii_strcasecmp (str, flags_class->values[i].value_nick)) + return flags_class->values[i].value; + } + + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Couldn't match '%s' with a valid MMBearerIpFamily value", + str); + return MM_BEARER_IP_FAMILY_NONE; +} + +MMBearerAllowedAuth +mm_common_get_allowed_auth_from_string (const gchar *str, + GError **error) +{ + GError *inner_error = NULL; + MMBearerAllowedAuth allowed_auth; + gchar **strings; + GFlagsClass *flags_class; + + allowed_auth = MM_BEARER_ALLOWED_AUTH_UNKNOWN; + + flags_class = G_FLAGS_CLASS (g_type_class_ref (MM_TYPE_BEARER_ALLOWED_AUTH)); + strings = g_strsplit (str, "|", -1); + + if (strings) { + guint i; + + for (i = 0; strings[i]; i++) { + guint j; + gboolean found = FALSE; + + for (j = 0; flags_class->values[j].value_nick; j++) { + if (!g_ascii_strcasecmp (strings[i], flags_class->values[j].value_nick)) { + allowed_auth |= flags_class->values[j].value; + found = TRUE; + break; + } + } + + if (!found) { + inner_error = g_error_new ( + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Couldn't match '%s' with a valid MMBearerAllowedAuth value", + strings[i]); + break; + } + } + } + + if (inner_error) { + g_propagate_error (error, inner_error); + allowed_auth = MM_BEARER_ALLOWED_AUTH_UNKNOWN; + } + + g_type_class_unref (flags_class); + g_strfreev (strings); + return allowed_auth; +} + +MMSmsStorage +mm_common_get_sms_storage_from_string (const gchar *str, + GError **error) +{ + GEnumClass *enum_class; + guint i; + + enum_class = G_ENUM_CLASS (g_type_class_ref (MM_TYPE_SMS_STORAGE)); + + for (i = 0; enum_class->values[i].value_nick; i++) { + if (!g_ascii_strcasecmp (str, enum_class->values[i].value_nick)) + return enum_class->values[i].value; + } + + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Couldn't match '%s' with a valid MMSmsStorage value", + str); + return MM_SMS_STORAGE_UNKNOWN; +} + +GVariant * +mm_common_build_bands_unknown (void) +{ + GVariantBuilder builder; + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("au")); + g_variant_builder_add_value (&builder, + g_variant_new_uint32 (MM_MODEM_BAND_UNKNOWN)); + return g_variant_builder_end (&builder); +} + +GVariant * +mm_common_build_bands_any (void) +{ + GVariantBuilder builder; + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("au")); + g_variant_builder_add_value (&builder, + g_variant_new_uint32 (MM_MODEM_BAND_ANY)); + return g_variant_builder_end (&builder); +} + +/* Expecting input as: + * key1=string,key2=true,key3=false... + * Strings may also be passed enclosed between double or single quotes, like: + * key1="this is a string", key2='and so is this' + */ +gboolean +mm_common_parse_key_value_string (const gchar *str, + GError **error, + MMParseKeyValueForeachFn callback, + gpointer user_data) +{ + GError *inner_error = NULL; + gchar *dup, *p, *key, *key_end, *value, *value_end, quote; + + g_return_val_if_fail (callback != NULL, FALSE); + g_return_val_if_fail (str != NULL, FALSE); + + /* Allow empty strings, we'll just return with success */ + while (g_ascii_isspace (*str)) + str++; + if (!str[0]) + return TRUE; + + dup = g_strdup (str); + p = dup; + + while (TRUE) { + gboolean keep_iteration = FALSE; + + /* Skip leading spaces */ + while (g_ascii_isspace (*p)) + p++; + + /* Key start */ + key = p; + if (!g_ascii_isalnum (*key)) { + inner_error = g_error_new (MM_CORE_ERROR, + MM_CORE_ERROR_FAILED, + "Key must start with alpha/num, starts with '%c'", + *key); + break; + } + + /* Key end */ + while (g_ascii_isalnum (*p) || (*p == '-') || (*p == '_')) + p++; + key_end = p; + if (key_end == key) { + inner_error = g_error_new (MM_CORE_ERROR, + MM_CORE_ERROR_FAILED, + "Couldn't find a proper key"); + break; + } + + /* Skip whitespaces, if any */ + while (g_ascii_isspace (*p)) + p++; + + /* Equal sign must be here */ + if (*p != '=') { + inner_error = g_error_new (MM_CORE_ERROR, + MM_CORE_ERROR_FAILED, + "Couldn't find equal sign separator"); + break; + } + /* Skip the equal */ + p++; + + /* Skip whitespaces, if any */ + while (g_ascii_isspace (*p)) + p++; + + /* Do we have a quote-enclosed string? */ + if (*p == '\"' || *p == '\'') { + quote = *p; + /* Skip the quote */ + p++; + /* Value start */ + value = p; + /* Find the closing quote */ + p = strchr (p, quote); + if (!p) { + inner_error = g_error_new (MM_CORE_ERROR, + MM_CORE_ERROR_FAILED, + "Unmatched quotes in string value"); + break; + } + + /* Value end */ + value_end = p; + /* Skip the quote */ + p++; + } else { + /* Value start */ + value = p; + + /* Value end */ + while ((*p != ',') && (*p != '\0') && !g_ascii_isspace (*p)) + p++; + value_end = p; + } + + /* Note that we allow value == value_end here */ + + /* Skip whitespaces, if any */ + while (g_ascii_isspace (*p)) + p++; + + /* If a comma is found, we should keep the iteration */ + if (*p == ',') { + /* skip the comma */ + p++; + keep_iteration = TRUE; + } + + /* Got key and value, prepare them and run the callback */ + *value_end = '\0'; + *key_end = '\0'; + if (!callback (key, value, user_data)) { + /* We were told to abort */ + break; + } + + if (keep_iteration) + continue; + + /* Check if no more key/value pairs expected */ + if (*p == '\0') + break; + + inner_error = g_error_new (MM_CORE_ERROR, + MM_CORE_ERROR_FAILED, + "Unexpected content (%s) after value", + p); + break; + } + + g_free (dup); + + if (inner_error) { + g_propagate_error (error, inner_error); + return FALSE; + } + + return TRUE; +} + +/*****************************************************************************/ + +gboolean +mm_get_int_from_str (const gchar *str, + gint *out) +{ + glong num; + + if (!str || !str[0]) + return FALSE; + + for (num = 0; str[num]; num++) { + if (str[num] != '-' && !g_ascii_isdigit (str[num])) + return FALSE; + } + + errno = 0; + num = strtol (str, NULL, 10); + if (!errno && num >= G_MININT && num <= G_MAXINT) { + *out = (gint)num; + return TRUE; + } + return FALSE; +} + +gboolean +mm_get_int_from_match_info (GMatchInfo *match_info, + guint32 match_index, + gint *out) +{ + gchar *s; + gboolean ret; + + s = g_match_info_fetch (match_info, match_index); + g_return_val_if_fail (s != NULL, FALSE); + + ret = mm_get_int_from_str (s, out); + g_free (s); + + return ret; +} + +/** + * mm_get_uint_from_str: + * @str: the string to convert to an unsigned int + * @out: on success, the number + * + * Converts a string to an unsigned number. All characters in the string + * MUST be valid digits (0 - 9), otherwise FALSE is returned. + * + * Returns: %TRUE if the string was converted, %FALSE if it was not or if it + * did not contain only digits. + */ +gboolean +mm_get_uint_from_str (const gchar *str, + guint *out) +{ + gulong num; + + if (!str || !str[0]) + return FALSE; + + for (num = 0; str[num]; num++) { + if (!g_ascii_isdigit (str[num])) + return FALSE; + } + + errno = 0; + num = strtoul (str, NULL, 10); + if (!errno && num <= G_MAXUINT) { + *out = (guint)num; + return TRUE; + } + return FALSE; +} + +gboolean +mm_get_uint_from_match_info (GMatchInfo *match_info, + guint32 match_index, + guint *out) +{ + gchar *s; + gboolean ret; + + s = g_match_info_fetch (match_info, match_index); + g_return_val_if_fail (s != NULL, FALSE); + + ret = mm_get_uint_from_str (s, out); + g_free (s); + + return ret; +} + +gboolean +mm_get_double_from_str (const gchar *str, + gdouble *out) +{ + gdouble num; + guint i; + + if (!str || !str[0]) + return FALSE; + + for (i = 0; str[i]; i++) { + /* we don't really expect numbers in scientific notation, so + * don't bother looking for exponents and such */ + if (str[i] != '-' && + str[i] != '.' && + !g_ascii_isdigit (str[i])) + return FALSE; + } + + errno = 0; + num = strtod (str, NULL); + if (!errno) { + *out = num; + return TRUE; + } + return FALSE; +} + +gboolean +mm_get_double_from_match_info (GMatchInfo *match_info, + guint32 match_index, + gdouble *out) +{ + gchar *s; + gboolean ret; + + s = g_match_info_fetch (match_info, match_index); + g_return_val_if_fail (s != NULL, FALSE); + + ret = mm_get_double_from_str (s, out); + g_free (s); + + return ret; +} + +gchar * +mm_get_string_unquoted_from_match_info (GMatchInfo *match_info, + guint32 match_index) +{ + gchar *str; + gsize len; + + str = g_match_info_fetch (match_info, match_index); + if (!str) + return NULL; + + len = strlen (str); + + /* Unquote the item if needed */ + if ((len >= 2) && (str[0] == '"') && (str[len - 1] == '"')) { + str[0] = ' '; + str[len - 1] = ' '; + str = g_strstrip (str); + } + + if (!str[0]) { + g_free (str); + return NULL; + } + + return str; +} + +/*****************************************************************************/ + +const gchar * +mm_sms_delivery_state_get_string_extended (guint delivery_state) +{ + if (delivery_state > 0x02 && delivery_state < 0x20) { + if (delivery_state < 0x10) + return "completed-reason-reserved"; + else + return "completed-sc-specific-reason"; + } + + if (delivery_state > 0x25 && delivery_state < 0x40) { + if (delivery_state < 0x30) + return "temporary-error-reason-reserved"; + else + return "temporary-error-sc-specific-reason"; + } + + if (delivery_state > 0x49 && delivery_state < 0x60) { + if (delivery_state < 0x50) + return "error-reason-reserved"; + else + return "error-sc-specific-reason"; + } + + if (delivery_state > 0x65 && delivery_state < 0x80) { + if (delivery_state < 0x70) + return "temporary-fatal-error-reason-reserved"; + else + return "temporary-fatal-error-sc-specific-reason"; + } + + if (delivery_state >= 0x80 && delivery_state < 0x100) + return "unknown-reason-reserved"; + + if (delivery_state >= 0x100) + return "unknown"; + + /* Otherwise, use the MMSmsDeliveryState enum as we can match the known + * value */ + return mm_sms_delivery_state_get_string ((MMSmsDeliveryState)delivery_state); +} + +/*****************************************************************************/ + +/* From hostap, Copyright (c) 2002-2005, Jouni Malinen <jkmaline@cc.hut.fi> */ + +static gint +hex2num (gchar c) +{ + if (c >= '0' && c <= '9') + return c - '0'; + if (c >= 'a' && c <= 'f') + return c - 'a' + 10; + if (c >= 'A' && c <= 'F') + return c - 'A' + 10; + return -1; +} + +gint +mm_utils_hex2byte (const gchar *hex) +{ + gint a, b; + + a = hex2num (*hex++); + if (a < 0) + return -1; + b = hex2num (*hex++); + if (b < 0) + return -1; + return (a << 4) | b; +} + +gchar * +mm_utils_hexstr2bin (const gchar *hex, gsize *out_len) +{ + const gchar *ipos = hex; + gchar *buf = NULL; + gsize i; + gint a; + gchar *opos; + gsize len; + + len = strlen (hex); + + /* Length must be a multiple of 2 */ + g_return_val_if_fail ((len % 2) == 0, NULL); + + opos = buf = g_malloc0 ((len / 2) + 1); + for (i = 0; i < len; i += 2) { + a = mm_utils_hex2byte (ipos); + if (a < 0) { + g_free (buf); + return NULL; + } + *opos++ = a; + ipos += 2; + } + *out_len = len / 2; + return buf; +} + +/* End from hostap */ + +gboolean +mm_utils_ishexstr (const gchar *hex) +{ + gsize len; + gsize i; + + /* Length not multiple of 2? */ + len = strlen (hex); + if (len % 2 != 0) + return FALSE; + + for (i = 0; i < len; i++) { + /* Non-hex char? */ + if (hex[i] >= '0' && hex[i] <= '9') + continue; + if (hex[i] >= 'a' && hex[i] <= 'f') + continue; + if (hex[i] >= 'A' && hex[i] <= 'F') + continue; + return FALSE; + } + + return TRUE; +} + +gchar * +mm_utils_bin2hexstr (const guint8 *bin, gsize len) +{ + GString *ret; + gsize i; + + g_return_val_if_fail (bin != NULL, NULL); + + ret = g_string_sized_new (len * 2 + 1); + for (i = 0; i < len; i++) + g_string_append_printf (ret, "%.2X", bin[i]); + return g_string_free (ret, FALSE); +} + +gboolean +mm_utils_check_for_single_value (guint32 value) +{ + gboolean found = FALSE; + guint32 i; + + for (i = 1; i <= 32; i++) { + if (value & 0x1) { + if (found) + return FALSE; /* More than one bit set */ + found = TRUE; + } + value >>= 1; + } + + return TRUE; +} diff --git a/libmm-glib/mm-common-helpers.h b/libmm-glib/mm-common-helpers.h new file mode 100644 index 0000000..161d903 --- /dev/null +++ b/libmm-glib/mm-common-helpers.h @@ -0,0 +1,132 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2010 - 2012 Red Hat, Inc. + * Copyright (C) 2011 - 2012 Google, Inc. + * Copyright (C) 2012 Aleksander Morgado <aleksander@gnu.org> + */ + +#include <glib.h> +#include <ModemManager.h> +#include "mm-helper-types.h" + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#ifndef MM_COMMON_HELPERS_H +#define MM_COMMON_HELPERS_H + +gchar *mm_common_build_capabilities_string (const MMModemCapability *capabilities, + guint n_capabilities); + +gchar *mm_common_build_bands_string (const MMModemBand *bands, + guint n_bands); + +gchar *mm_common_build_sms_storages_string (const MMSmsStorage *storages, + guint n_storages); + +gchar *mm_common_build_mode_combinations_string (const MMModemModeCombination *modes, + guint n_modes); + +MMModemCapability mm_common_get_capabilities_from_string (const gchar *str, + GError **error); +MMModemMode mm_common_get_modes_from_string (const gchar *str, + GError **error); +void mm_common_get_bands_from_string (const gchar *str, + MMModemBand **bands, + guint *n_bands, + GError **error); +gboolean mm_common_get_boolean_from_string (const gchar *value, + GError **error); +MMModemCdmaRmProtocol mm_common_get_rm_protocol_from_string (const gchar *str, + GError **error); +MMBearerIpFamily mm_common_get_ip_type_from_string (const gchar *str, + GError **error); +MMBearerAllowedAuth mm_common_get_allowed_auth_from_string (const gchar *str, + GError **error); +MMSmsStorage mm_common_get_sms_storage_from_string (const gchar *str, + GError **error); + +GArray *mm_common_sms_storages_variant_to_garray (GVariant *variant); +MMSmsStorage *mm_common_sms_storages_variant_to_array (GVariant *variant, + guint *n_storages); +GVariant *mm_common_sms_storages_array_to_variant (const MMSmsStorage *storages, + guint n_storages); +GVariant *mm_common_sms_storages_garray_to_variant (GArray *array); + +GArray *mm_common_bands_variant_to_garray (GVariant *variant); +MMModemBand *mm_common_bands_variant_to_array (GVariant *variant, + guint *n_bands); +GVariant *mm_common_bands_array_to_variant (const MMModemBand *bands, + guint n_bands); +GVariant *mm_common_bands_garray_to_variant (GArray *array); + +GVariant *mm_common_build_bands_any (void); +GVariant *mm_common_build_bands_unknown (void); + +gboolean mm_common_bands_garray_cmp (GArray *a, GArray *b); + +GArray *mm_common_mode_combinations_variant_to_garray (GVariant *variant); +MMModemModeCombination *mm_common_mode_combinations_variant_to_array (GVariant *variant, + guint *n_modes); +GVariant *mm_common_mode_combinations_array_to_variant (const MMModemModeCombination *modes, + guint n_modes); +GVariant *mm_common_mode_combinations_garray_to_variant (GArray *array); +GVariant *mm_common_build_mode_combinations_default (void); + +GArray *mm_common_capability_combinations_variant_to_garray (GVariant *variant); +MMModemCapability *mm_common_capability_combinations_variant_to_array (GVariant *variant, + guint *n_capabilities); +GVariant *mm_common_capability_combinations_array_to_variant (const MMModemCapability *capabilities, + guint n_capabilities); +GVariant *mm_common_capability_combinations_garray_to_variant (GArray *array); +GVariant *mm_common_build_capability_combinations_any (void); +GVariant *mm_common_build_capability_combinations_none (void); + +typedef gboolean (*MMParseKeyValueForeachFn) (const gchar *key, + const gchar *value, + gpointer user_data); +gboolean mm_common_parse_key_value_string (const gchar *str, + GError **error, + MMParseKeyValueForeachFn callback, + gpointer user_data); + +/* Common parsers */ +gboolean mm_get_int_from_str (const gchar *str, + gint *out); +gboolean mm_get_int_from_match_info (GMatchInfo *match_info, + guint32 match_index, + gint *out); +gboolean mm_get_uint_from_str (const gchar *str, + guint *out); +gboolean mm_get_uint_from_match_info (GMatchInfo *match_info, + guint32 match_index, + guint *out); +gboolean mm_get_double_from_str (const gchar *str, + gdouble *out); +gboolean mm_get_double_from_match_info (GMatchInfo *match_info, + guint32 match_index, + gdouble *out); +gchar *mm_get_string_unquoted_from_match_info (GMatchInfo *match_info, + guint32 match_index); + +const gchar *mm_sms_delivery_state_get_string_extended (guint delivery_state); + +gint mm_utils_hex2byte (const gchar *hex); +gchar *mm_utils_hexstr2bin (const gchar *hex, gsize *out_len); +gchar *mm_utils_bin2hexstr (const guint8 *bin, gsize len); +gboolean mm_utils_ishexstr (const gchar *hex); + +gboolean mm_utils_check_for_single_value (guint32 value); + +#endif /* MM_COMMON_HELPERS_H */ diff --git a/libmm-glib/mm-firmware-properties.c b/libmm-glib/mm-firmware-properties.c new file mode 100644 index 0000000..c145122 --- /dev/null +++ b/libmm-glib/mm-firmware-properties.c @@ -0,0 +1,491 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2012 Google Inc. + */ + +#include <string.h> + +#include "mm-errors-types.h" +#include "mm-common-helpers.h" +#include "mm-firmware-properties.h" + +/** + * SECTION: mm-firmware-properties + * @title: MMFirmwareProperties + * @short_description: Helper object to handle firmware information. + * + * The #MMFirmwareProperties is an object handling the properties exposed for + * available firmware images. + * + * This object is retrieved with either mm_modem_firmware_list() + * or mm_modem_firmware_list_sync(). + */ + +G_DEFINE_TYPE (MMFirmwareProperties, mm_firmware_properties, G_TYPE_OBJECT); + +#define PROPERTY_UNIQUE_ID "unique-id" +#define PROPERTY_IMAGE_TYPE "image-type" +#define PROPERTY_GOBI_PRI_VERSION "gobi-pri-version" +#define PROPERTY_GOBI_PRI_INFO "gobi-pri-info" +#define PROPERTY_GOBI_BOOT_VERSION "gobi-boot-version" +#define PROPERTY_GOBI_PRI_UNIQUE_ID "gobi-pri-unique-id" +#define PROPERTY_GOBI_MODEM_UNIQUE_ID "gobi-modem-unique-id" + +struct _MMFirmwarePropertiesPrivate { + /* Mandatory parameters */ + MMFirmwareImageType image_type; + gchar *unique_id; + + /* Gobi specific */ + gchar *gobi_pri_version; + gchar *gobi_pri_info; + gchar *gobi_boot_version; + gchar *gobi_pri_unique_id; + gchar *gobi_modem_unique_id; +}; + +static MMFirmwareProperties *firmware_properties_new_empty (void); + +/*****************************************************************************/ + +/** + * mm_firmware_properties_get_unique_id: + * @self: A #MMFirmwareProperties. + * + * Gets the unique ID of the firmare image. + * + * Returns: (transfer none): The ID of the image. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_firmware_properties_get_unique_id (MMFirmwareProperties *self) +{ + g_return_val_if_fail (MM_IS_FIRMWARE_PROPERTIES (self), NULL); + + return self->priv->unique_id; +} + +/*****************************************************************************/ + +/** + * mm_firmware_properties_get_image_type: + * @self: A #MMFirmwareProperties. + * + * Gets the type of the firmare image. + * + * Returns: A #MMFirmwareImageType specifying The type of the image. + */ +MMFirmwareImageType +mm_firmware_properties_get_image_type (MMFirmwareProperties *self) +{ + g_return_val_if_fail (MM_IS_FIRMWARE_PROPERTIES (self), MM_FIRMWARE_IMAGE_TYPE_UNKNOWN); + + return self->priv->image_type; +} + +/*****************************************************************************/ + +/** + * mm_firmware_properties_get_gobi_pri_version: + * @self: a #MMFirmwareProperties. + * + * Gets the PRI version of a firmware image of type %MM_FIRMWARE_IMAGE_TYPE_GOBI. + * + * Returns: The PRI version, or %NULL if unknown. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_firmware_properties_get_gobi_pri_version (MMFirmwareProperties *self) +{ + g_return_val_if_fail (MM_IS_FIRMWARE_PROPERTIES (self), NULL); + g_return_val_if_fail (self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_GOBI, NULL); + + return self->priv->gobi_pri_version; +} + +void +mm_firmware_properties_set_gobi_pri_version (MMFirmwareProperties *self, + const gchar *version) +{ + g_return_if_fail (MM_IS_FIRMWARE_PROPERTIES (self)); + g_return_if_fail (self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_GOBI); + + g_free (self->priv->gobi_pri_version); + self->priv->gobi_pri_version = g_strdup (version); +} + +/*****************************************************************************/ + +/** + * mm_firmware_properties_get_gobi_pri_info: + * @self: a #MMFirmwareProperties. + * + * Gets the PRI info of a firmware image of type %MM_FIRMWARE_IMAGE_TYPE_GOBI. + * + * Returns: The PRI info, or %NULL if unknown. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_firmware_properties_get_gobi_pri_info (MMFirmwareProperties *self) +{ + g_return_val_if_fail (MM_IS_FIRMWARE_PROPERTIES (self), NULL); + g_return_val_if_fail (self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_GOBI, NULL); + + return self->priv->gobi_pri_info; +} + +void +mm_firmware_properties_set_gobi_pri_info (MMFirmwareProperties *self, + const gchar *info) +{ + g_return_if_fail (MM_IS_FIRMWARE_PROPERTIES (self)); + g_return_if_fail (self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_GOBI); + + g_free (self->priv->gobi_pri_info); + self->priv->gobi_pri_info = g_strdup (info); +} + +/** + * mm_firmware_properties_get_gobi_boot_version: + * @self: a #MMFirmwareProperties. + * + * Gets the boot version of a firmware image of type %MM_FIRMWARE_IMAGE_TYPE_GOBI. + * + * Returns: The boot version, or %NULL if unknown. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_firmware_properties_get_gobi_boot_version (MMFirmwareProperties *self) +{ + g_return_val_if_fail (MM_IS_FIRMWARE_PROPERTIES (self), NULL); + g_return_val_if_fail (self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_GOBI, NULL); + + return self->priv->gobi_boot_version; +} + +void +mm_firmware_properties_set_gobi_boot_version (MMFirmwareProperties *self, + const gchar *version) +{ + g_return_if_fail (MM_IS_FIRMWARE_PROPERTIES (self)); + g_return_if_fail (self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_GOBI); + + g_free (self->priv->gobi_boot_version); + self->priv->gobi_boot_version = g_strdup (version); +} + +/*****************************************************************************/ + +/** + * mm_firmware_properties_get_gobi_pri_unique_id: + * @self: a #MMFirmwareProperties. + * + * Gets the PRI unique ID of a firmware image of type %MM_FIRMWARE_IMAGE_TYPE_GOBI. + * + * Returns: The PRI unique ID, or %NULL if unknown. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_firmware_properties_get_gobi_pri_unique_id (MMFirmwareProperties *self) +{ + g_return_val_if_fail (MM_IS_FIRMWARE_PROPERTIES (self), NULL); + g_return_val_if_fail (self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_GOBI, NULL); + + return self->priv->gobi_pri_unique_id; +} + +void +mm_firmware_properties_set_gobi_pri_unique_id (MMFirmwareProperties *self, + const gchar *unique_id) +{ + g_return_if_fail (MM_IS_FIRMWARE_PROPERTIES (self)); + g_return_if_fail (self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_GOBI); + + g_free (self->priv->gobi_pri_unique_id); + self->priv->gobi_pri_unique_id = g_strdup (unique_id); +} + +/*****************************************************************************/ + +/** + * mm_firmware_properties_get_gobi_modem_unique_id: + * @self: a #MMFirmwareProperties. + * + * Gets the MODEM unique ID of a firmware image of type %MM_FIRMWARE_IMAGE_TYPE_GOBI. + * + * Returns: The PRI unique ID, or %NULL if unknown. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_firmware_properties_get_gobi_modem_unique_id (MMFirmwareProperties *self) +{ + g_return_val_if_fail (MM_IS_FIRMWARE_PROPERTIES (self), NULL); + g_return_val_if_fail (self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_GOBI, NULL); + + return self->priv->gobi_modem_unique_id; +} + +void +mm_firmware_properties_set_gobi_modem_unique_id (MMFirmwareProperties *self, + const gchar *unique_id) +{ + g_return_if_fail (MM_IS_FIRMWARE_PROPERTIES (self)); + g_return_if_fail (self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_GOBI); + + g_free (self->priv->gobi_modem_unique_id); + self->priv->gobi_modem_unique_id = g_strdup (unique_id); +} + +/*****************************************************************************/ + +/** + * mm_firmware_properties_get_dictionary: + * @self: A #MMFirmwareProperties. + * + * Gets a variant dictionary with the contents of @self. + * + * Returns: (transfer full): A dictionary with the image properties. The returned value should be freed with g_variant_unref(). + */ +GVariant * +mm_firmware_properties_get_dictionary (MMFirmwareProperties *self) +{ + GVariantBuilder builder; + + g_return_val_if_fail (MM_IS_FIRMWARE_PROPERTIES (self), NULL); + + /* We do allow NULL */ + if (!self) + return NULL; + + g_return_val_if_fail (MM_IS_FIRMWARE_PROPERTIES (self), NULL); + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); + + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_UNIQUE_ID, + g_variant_new_string (self->priv->unique_id)); + + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_IMAGE_TYPE, + g_variant_new_uint32 (self->priv->image_type)); + + if (self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_GOBI) { + if (self->priv->gobi_pri_version) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_GOBI_PRI_VERSION, + g_variant_new_string (self->priv->gobi_pri_version)); + if (self->priv->gobi_pri_info) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_GOBI_PRI_INFO, + g_variant_new_string (self->priv->gobi_pri_info)); + if (self->priv->gobi_boot_version) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_GOBI_BOOT_VERSION, + g_variant_new_string (self->priv->gobi_boot_version)); + if (self->priv->gobi_pri_unique_id) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_GOBI_PRI_UNIQUE_ID, + g_variant_new_string (self->priv->gobi_pri_unique_id)); + if (self->priv->gobi_modem_unique_id) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_GOBI_MODEM_UNIQUE_ID, + g_variant_new_string (self->priv->gobi_modem_unique_id)); + } + + return g_variant_ref_sink (g_variant_builder_end (&builder)); +} + +/*****************************************************************************/ + +static gboolean +consume_variant (MMFirmwareProperties *self, + const gchar *key, + GVariant *value, + GError **error) +{ + if (g_str_equal (key, PROPERTY_UNIQUE_ID)) { + g_free (self->priv->unique_id); + self->priv->unique_id = g_variant_dup_string (value, NULL); + } else if (g_str_equal (key, PROPERTY_IMAGE_TYPE)) { + self->priv->image_type = g_variant_get_uint32 (value); + } else if (g_str_equal (key, PROPERTY_GOBI_PRI_VERSION)) { + g_free (self->priv->gobi_pri_version); + self->priv->gobi_pri_version = g_variant_dup_string (value, NULL); + } else if (g_str_equal (key, PROPERTY_GOBI_PRI_INFO)) { + g_free (self->priv->gobi_pri_info); + self->priv->gobi_pri_info = g_variant_dup_string (value, NULL); + } else if (g_str_equal (key, PROPERTY_GOBI_BOOT_VERSION)) { + g_free (self->priv->gobi_boot_version); + self->priv->gobi_boot_version = g_variant_dup_string (value, NULL); + } else if (g_str_equal (key, PROPERTY_GOBI_PRI_UNIQUE_ID)) { + g_free (self->priv->gobi_pri_unique_id); + self->priv->gobi_pri_unique_id = g_variant_dup_string (value, NULL); + } else if (g_str_equal (key, PROPERTY_GOBI_MODEM_UNIQUE_ID)) { + g_free (self->priv->gobi_modem_unique_id); + self->priv->gobi_modem_unique_id = g_variant_dup_string (value, NULL); + } + else { + /* Set error */ + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Invalid properties dictionary, unexpected key '%s'", + key); + return FALSE; + } + + return TRUE; +} + +/** + * mm_firmware_properties_new_from_dictionary: + * @dictionary: A variant dictionary with the properties of the image. + * @error: Return location for error or %NULL. + * + * Creates a new #MMFirmwareProperties object with the properties exposed in + * the dictionary. + * + * Returns: (transfer full): A #MMFirmwareProperties or %NULL if @error is set. The returned value should be freed with g_object_unref(). + */ +MMFirmwareProperties * +mm_firmware_properties_new_from_dictionary (GVariant *dictionary, + GError **error) +{ + GError *inner_error = NULL; + GVariantIter iter; + gchar *key; + GVariant *value; + MMFirmwareProperties *self; + + if (!dictionary) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Cannot create Firmware properties from empty dictionary"); + return NULL; + } + + if (!g_variant_is_of_type (dictionary, G_VARIANT_TYPE ("a{sv}"))) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Cannot create Firmware properties from dictionary: " + "invalid variant type received"); + return NULL; + } + + self = firmware_properties_new_empty (); + + g_variant_iter_init (&iter, dictionary); + while (!inner_error && + g_variant_iter_next (&iter, "{sv}", &key, &value)) { + consume_variant (self, + key, + value, + &inner_error); + g_free (key); + g_variant_unref (value); + } + + /* If error, destroy the object */ + if (inner_error) { + g_propagate_error (error, inner_error); + g_object_unref (self); + return NULL; + } + + /* If mandatory properties missing, destroy the object */ + if (!self->priv->unique_id || + self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_UNKNOWN) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Cannot create Firmware properties from dictionary: " + "mandatory parameter missing"); + g_object_unref (self); + return NULL; + } + + return self; +} + +/*****************************************************************************/ + +/** + * mm_firmware_properties_new: + * @image_type: A #MMFirmwareImageType specifying the type of the image. + * @unique_id: The unique ID of the image. + * + * Creates a new #MMFirmwareProperties object with the properties specified. + * + * Returns: (transfer full): A #MMFirmwareProperties or %NULL if @error is set. The returned value should be freed with g_object_unref(). + */ +MMFirmwareProperties * +mm_firmware_properties_new (MMFirmwareImageType image_type, + const gchar *unique_id) +{ + MMFirmwareProperties *self; + + g_return_val_if_fail (image_type != MM_FIRMWARE_IMAGE_TYPE_UNKNOWN, NULL); + g_return_val_if_fail (unique_id != NULL, NULL); + + self = firmware_properties_new_empty (); + self->priv->image_type = image_type; + self->priv->unique_id = g_strdup (unique_id); + + return self; +} + +static MMFirmwareProperties * +firmware_properties_new_empty (void) +{ + return (MM_FIRMWARE_PROPERTIES ( + g_object_new (MM_TYPE_FIRMWARE_PROPERTIES, NULL))); +} + +static void +mm_firmware_properties_init (MMFirmwareProperties *self) +{ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, + MM_TYPE_FIRMWARE_PROPERTIES, + MMFirmwarePropertiesPrivate); + + /* Some defaults */ + self->priv->image_type = MM_FIRMWARE_IMAGE_TYPE_UNKNOWN; +} + +static void +finalize (GObject *object) +{ + MMFirmwareProperties *self = MM_FIRMWARE_PROPERTIES (object); + + g_free (self->priv->unique_id); + g_free (self->priv->gobi_pri_version); + g_free (self->priv->gobi_pri_info); + g_free (self->priv->gobi_boot_version); + g_free (self->priv->gobi_pri_unique_id); + g_free (self->priv->gobi_modem_unique_id); + + G_OBJECT_CLASS (mm_firmware_properties_parent_class)->finalize (object); +} + +static void +mm_firmware_properties_class_init (MMFirmwarePropertiesClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (MMFirmwarePropertiesPrivate)); + + object_class->finalize = finalize; +} diff --git a/libmm-glib/mm-firmware-properties.h b/libmm-glib/mm-firmware-properties.h new file mode 100644 index 0000000..33fffc3 --- /dev/null +++ b/libmm-glib/mm-firmware-properties.h @@ -0,0 +1,98 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2012 Google Inc. + */ + +#ifndef MM_FIRMWARE_PROPERTIES_H +#define MM_FIRMWARE_PROPERTIES_H + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> +#include <glib-object.h> + +G_BEGIN_DECLS + +#define MM_TYPE_FIRMWARE_PROPERTIES (mm_firmware_properties_get_type ()) +#define MM_FIRMWARE_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_FIRMWARE_PROPERTIES, MMFirmwareProperties)) +#define MM_FIRMWARE_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_FIRMWARE_PROPERTIES, MMFirmwarePropertiesClass)) +#define MM_IS_FIRMWARE_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_FIRMWARE_PROPERTIES)) +#define MM_IS_FIRMWARE_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_FIRMWARE_PROPERTIES)) +#define MM_FIRMWARE_PROPERTIES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_FIRMWARE_PROPERTIES, MMFirmwarePropertiesClass)) + +typedef struct _MMFirmwareProperties MMFirmwareProperties; +typedef struct _MMFirmwarePropertiesClass MMFirmwarePropertiesClass; +typedef struct _MMFirmwarePropertiesPrivate MMFirmwarePropertiesPrivate; + +/** + * MMFirmwareProperties: + * + * The #MMFirmwareProperties structure contains private data and should only be accessed + * using the provided API. + */ +struct _MMFirmwareProperties { + /*< private >*/ + GObject parent; + MMFirmwarePropertiesPrivate *priv; +}; + +struct _MMFirmwarePropertiesClass { + /*< private >*/ + GObjectClass parent; +}; + +GType mm_firmware_properties_get_type (void); + +const gchar *mm_firmware_properties_get_unique_id (MMFirmwareProperties *self); +MMFirmwareImageType mm_firmware_properties_get_image_type (MMFirmwareProperties *self); + +/* Gobi specific */ +const gchar *mm_firmware_properties_get_gobi_pri_version (MMFirmwareProperties *self); +const gchar *mm_firmware_properties_get_gobi_pri_info (MMFirmwareProperties *self); +const gchar *mm_firmware_properties_get_gobi_boot_version (MMFirmwareProperties *self); +const gchar *mm_firmware_properties_get_gobi_pri_unique_id (MMFirmwareProperties *self); +const gchar *mm_firmware_properties_get_gobi_modem_unique_id (MMFirmwareProperties *self); + +/*****************************************************************************/ +/* ModemManager/libmm-glib/mmcli specific methods */ + +#if defined (_LIBMM_INSIDE_MM) || \ + defined (_LIBMM_INSIDE_MMCLI) || \ + defined (LIBMM_GLIB_COMPILATION) + +MMFirmwareProperties *mm_firmware_properties_new (MMFirmwareImageType image_type, + const gchar *unique_id); +MMFirmwareProperties *mm_firmware_properties_new_from_dictionary (GVariant *dictionary, + GError **error); + +/* Gobi specific */ +void mm_firmware_properties_set_gobi_pri_version (MMFirmwareProperties *self, + const gchar *version); +void mm_firmware_properties_set_gobi_pri_info (MMFirmwareProperties *self, + const gchar *info); +void mm_firmware_properties_set_gobi_boot_version (MMFirmwareProperties *self, + const gchar *version); +void mm_firmware_properties_set_gobi_pri_unique_id (MMFirmwareProperties *self, + const gchar *id); +void mm_firmware_properties_set_gobi_modem_unique_id (MMFirmwareProperties *self, + const gchar *id); + +GVariant *mm_firmware_properties_get_dictionary (MMFirmwareProperties *self); + +#endif + +G_END_DECLS + +#endif /* MM_FIRMWARE_PROPERTIES_H */ diff --git a/libmm-glib/mm-helper-types.h b/libmm-glib/mm-helper-types.h new file mode 100644 index 0000000..129b01d --- /dev/null +++ b/libmm-glib/mm-helper-types.h @@ -0,0 +1,44 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2013 Aleksander Morgado <aleksander@gnu.org> + */ + +#include <ModemManager.h> + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#ifndef _MM_HELPER_TYPES_H_ +#define _MM_HELPER_TYPES_H_ + +/** + * MMModemModeCombination: + * @allowed: Mask of #MMModemMode values specifying allowed modes. + * @preferred: A single #MMModemMode value specifying the preferred mode. + * + * #MMModemModeCombination is a simple struct holding a pair of #MMModemMode values. + */ +typedef struct _MMModemModeCombination { + MMModemMode allowed; + MMModemMode preferred; +} MMModemModeCombination; + +#endif /* _MM_HELPER_TYPES_H_ */ diff --git a/libmm-glib/mm-helpers.h b/libmm-glib/mm-helpers.h new file mode 100644 index 0000000..2e8cb58 --- /dev/null +++ b/libmm-glib/mm-helpers.h @@ -0,0 +1,45 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2011 Aleksander Morgado <aleksander@gnu.org> + */ + +#ifndef _MM_HELPERS_H_ +#define _MM_HELPERS_H_ + +#define RETURN_NON_EMPTY_CONSTANT_STRING(input) do { \ + const gchar *str; \ + \ + str = (input); \ + if (str && str[0]) \ + return str; \ + } while (0); \ + return NULL + +#define RETURN_NON_EMPTY_STRING(input) do { \ + gchar *str; \ + \ + str = (input); \ + if (str && str[0]) \ + return str; \ + g_free (str); \ + } while (0); \ + return NULL + +#endif /* _MM_HELPERS_H_ */ diff --git a/libmm-glib/mm-location-3gpp.c b/libmm-glib/mm-location-3gpp.c new file mode 100644 index 0000000..2de2bab --- /dev/null +++ b/libmm-glib/mm-location-3gpp.c @@ -0,0 +1,330 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2012 Google, Inc. + */ + +#include <string.h> +#include <ctype.h> +#include <stdlib.h> + +#include "mm-errors-types.h" +#include "mm-common-helpers.h" +#include "mm-location-3gpp.h" + +/** + * SECTION: mm-location-3gpp + * @title: MMLocation3gpp + * @short_description: Helper object to handle 3GPP location information. + * + * The #MMLocation3gpp is an object handling the location information of the + * modem when this is reported by the 3GPP network. + * + * This object is retrieved with either mm_modem_location_get_3gpp(), + * mm_modem_location_get_3gpp_sync(), mm_modem_location_get_full() or + * mm_modem_location_get_full_sync(). + */ + +G_DEFINE_TYPE (MMLocation3gpp, mm_location_3gpp, G_TYPE_OBJECT); + +struct _MMLocation3gppPrivate { + guint mobile_country_code; + guint mobile_network_code; + gulong location_area_code; + gulong cell_id; +}; + +/*****************************************************************************/ + +/** + * mm_location_3gpp_get_mobile_country_code: + * @self: a #MMLocation3gpp. + * + * Gets the Mobile Country Code of the 3GPP network. + * + * Returns: the MCC, or 0 if unknown. + */ +guint +mm_location_3gpp_get_mobile_country_code (MMLocation3gpp *self) +{ + g_return_val_if_fail (MM_IS_LOCATION_3GPP (self), 0); + + return self->priv->mobile_country_code; +} + +gboolean +mm_location_3gpp_set_mobile_country_code (MMLocation3gpp *self, + guint mobile_country_code) +{ + g_return_val_if_fail (MM_IS_LOCATION_3GPP (self), FALSE); + + /* If no change in the location info, don't do anything */ + if (self->priv->mobile_country_code == mobile_country_code) + return FALSE; + + self->priv->mobile_country_code = mobile_country_code; + return TRUE; +} + +/*****************************************************************************/ + +/** + * mm_location_3gpp_get_mobile_network_code: + * @self: a #MMLocation3gpp. + * + * Gets the Mobile Network Code of the 3GPP network. + * + * Returns: the MNC, or 0 if unknown. + */ +guint +mm_location_3gpp_get_mobile_network_code (MMLocation3gpp *self) +{ + g_return_val_if_fail (MM_IS_LOCATION_3GPP (self), 0); + + return self->priv->mobile_network_code; +} + +gboolean +mm_location_3gpp_set_mobile_network_code (MMLocation3gpp *self, + guint mobile_network_code) +{ + g_return_val_if_fail (MM_IS_LOCATION_3GPP (self), FALSE); + + /* If no change in the location info, don't do anything */ + if (self->priv->mobile_network_code == mobile_network_code) + return FALSE; + + self->priv->mobile_network_code = mobile_network_code; + return TRUE; +} + +/*****************************************************************************/ + +/** + * mm_location_3gpp_get_location_area_code: + * @self: a #MMLocation3gpp. + * + * Gets the location area code of the 3GPP network. + * + * Returns: the location area code, or 0 if unknown. + */ +gulong +mm_location_3gpp_get_location_area_code (MMLocation3gpp *self) +{ + g_return_val_if_fail (MM_IS_LOCATION_3GPP (self), 0); + + return self->priv->location_area_code; +} + +gboolean +mm_location_3gpp_set_location_area_code (MMLocation3gpp *self, + gulong location_area_code) +{ + g_return_val_if_fail (MM_IS_LOCATION_3GPP (self), FALSE); + + /* If no change in the location info, don't do anything */ + if (self->priv->location_area_code == location_area_code) + return FALSE; + + self->priv->location_area_code = location_area_code; + return TRUE; +} + +/*****************************************************************************/ + +/** + * mm_location_3gpp_get_cell_id: + * @self: a #MMLocation3gpp. + * + * Gets the cell ID of the 3GPP network. + * + * Returns: the cell ID, or 0 if unknown. + */ +gulong +mm_location_3gpp_get_cell_id (MMLocation3gpp *self) +{ + g_return_val_if_fail (MM_IS_LOCATION_3GPP (self), 0); + + return self->priv->cell_id; +} + +gboolean +mm_location_3gpp_set_cell_id (MMLocation3gpp *self, + gulong cell_id) +{ + g_return_val_if_fail (MM_IS_LOCATION_3GPP (self), FALSE); + + /* If no change in the location info, don't do anything */ + if (self->priv->cell_id == cell_id) + return FALSE; + + self->priv->cell_id = cell_id; + return TRUE; +} + +/*****************************************************************************/ + +GVariant * +mm_location_3gpp_get_string_variant (MMLocation3gpp *self) +{ + GVariant *variant = NULL; + + g_return_val_if_fail (MM_IS_LOCATION_3GPP (self), NULL); + + if (self->priv->mobile_country_code && + self->priv->mobile_network_code && + self->priv->location_area_code && + self->priv->cell_id) { + gchar *str; + + str = g_strdup_printf ("%u,%u,%lX,%lX", + self->priv->mobile_country_code, + self->priv->mobile_network_code, + self->priv->location_area_code, + self->priv->cell_id); + + variant = g_variant_new_string (str); + g_free (str); + } + + return variant; +} + +/*****************************************************************************/ + +static gboolean +validate_string_length (const gchar *display, + const gchar *str, + guint max_length, + GError **error) +{ + /* Avoid empty strings */ + if (!str || !str[0]) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Invalid %s: none given", + display); + return FALSE; + } + + /* Check max length of the field */ + if (strlen (str) > max_length) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Invalid %s: longer than the maximum expected (%u): '%s'", + display, + max_length, + str); + return FALSE; + } + + return TRUE; +} + +static gboolean +validate_numeric_string_content (const gchar *display, + const gchar *str, + gboolean hex, + GError **error) +{ + guint i; + + for (i = 0; str[i]; i++) { + if ((hex && !g_ascii_isxdigit (str[i])) || + (!hex && !g_ascii_isdigit (str[i]))) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Invalid %s: unexpected char (%c): '%s'", + display, + str[i], + str); + return FALSE; + } + } + + return TRUE; +} + +MMLocation3gpp * +mm_location_3gpp_new_from_string_variant (GVariant *string, + GError **error) +{ + MMLocation3gpp *self = NULL; + gchar **split; + + if (!g_variant_is_of_type (string, G_VARIANT_TYPE_STRING)) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Cannot create 3GPP location from string: " + "invalid variant type received"); + return NULL; + } + + split = g_strsplit (g_variant_get_string (string, NULL), ",", -1); + if (!split) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Invalid 3GPP location string: '%s'", + g_variant_get_string (string, NULL)); + return NULL; + } + + /* Validate fields */ + if (validate_string_length ("MCC", split[0], 3, error) && + validate_numeric_string_content ("MCC", split[0], FALSE, error) && + validate_string_length ("MNC", split[1], 3, error) && + validate_numeric_string_content ("MNC", split[1], FALSE, error) && + validate_string_length ("Location area code", split[2], 4, error) && + validate_numeric_string_content ("Location area code", split[2], TRUE, error) && + validate_string_length ("Cell ID", split[3], 8, error) && + validate_numeric_string_content ("Cell ID", split[3], TRUE, error)) { + /* Create new location object */ + self = mm_location_3gpp_new (); + self->priv->mobile_country_code = strtol (split[0], NULL, 10); + self->priv->mobile_network_code = strtol (split[1], NULL, 10); + self->priv->location_area_code = strtol (split[2], NULL, 16); + self->priv->cell_id = strtol (split[3], NULL, 16); + } + + g_strfreev (split); + return self; +} + +/*****************************************************************************/ + +MMLocation3gpp * +mm_location_3gpp_new (void) +{ + return (MM_LOCATION_3GPP ( + g_object_new (MM_TYPE_LOCATION_3GPP, NULL))); +} + +static void +mm_location_3gpp_init (MMLocation3gpp *self) +{ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), + MM_TYPE_LOCATION_3GPP, + MMLocation3gppPrivate); +} + +static void +mm_location_3gpp_class_init (MMLocation3gppClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (MMLocation3gppPrivate)); +} diff --git a/libmm-glib/mm-location-3gpp.h b/libmm-glib/mm-location-3gpp.h new file mode 100644 index 0000000..99e65a2 --- /dev/null +++ b/libmm-glib/mm-location-3gpp.h @@ -0,0 +1,89 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2012 Google, Inc. + */ + +#ifndef MM_LOCATION_3GPP_H +#define MM_LOCATION_3GPP_H + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> +#include <glib-object.h> + +G_BEGIN_DECLS + +#define MM_TYPE_LOCATION_3GPP (mm_location_3gpp_get_type ()) +#define MM_LOCATION_3GPP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_LOCATION_3GPP, MMLocation3gpp)) +#define MM_LOCATION_3GPP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_LOCATION_3GPP, MMLocation3gppClass)) +#define MM_IS_LOCATION_3GPP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_LOCATION_3GPP)) +#define MM_IS_LOCATION_3GPP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_LOCATION_3GPP)) +#define MM_LOCATION_3GPP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_LOCATION_3GPP, MMLocation3gppClass)) + +typedef struct _MMLocation3gpp MMLocation3gpp; +typedef struct _MMLocation3gppClass MMLocation3gppClass; +typedef struct _MMLocation3gppPrivate MMLocation3gppPrivate; + +/** + * MMLocation3gpp: + * + * The #MMLocation3gpp structure contains private data and should + * only be accessed using the provided API. + */ +struct _MMLocation3gpp { + /*< private >*/ + GObject parent; + MMLocation3gppPrivate *priv; +}; + +struct _MMLocation3gppClass { + /*< private >*/ + GObjectClass parent; +}; + +GType mm_location_3gpp_get_type (void); + +guint mm_location_3gpp_get_mobile_country_code (MMLocation3gpp *self); +guint mm_location_3gpp_get_mobile_network_code (MMLocation3gpp *self); +gulong mm_location_3gpp_get_location_area_code (MMLocation3gpp *self); +gulong mm_location_3gpp_get_cell_id (MMLocation3gpp *self); + +/*****************************************************************************/ +/* ModemManager/libmm-glib/mmcli specific methods */ + +#if defined (_LIBMM_INSIDE_MM) || \ + defined (_LIBMM_INSIDE_MMCLI) || \ + defined (LIBMM_GLIB_COMPILATION) + +GVariant *mm_location_3gpp_get_string_variant (MMLocation3gpp *self); + +MMLocation3gpp *mm_location_3gpp_new (void); +MMLocation3gpp *mm_location_3gpp_new_from_string_variant (GVariant *string, + GError **error); + +gboolean mm_location_3gpp_set_mobile_country_code (MMLocation3gpp *self, + guint mobile_country_code); +gboolean mm_location_3gpp_set_mobile_network_code (MMLocation3gpp *self, + guint mobile_network_code); +gboolean mm_location_3gpp_set_location_area_code (MMLocation3gpp *self, + gulong location_area_code); +gboolean mm_location_3gpp_set_cell_id (MMLocation3gpp *self, + gulong cell_id); + +#endif + +G_END_DECLS + +#endif /* MM_LOCATION_3GPP_H */ diff --git a/libmm-glib/mm-location-cdma-bs.c b/libmm-glib/mm-location-cdma-bs.c new file mode 100644 index 0000000..993f6be --- /dev/null +++ b/libmm-glib/mm-location-cdma-bs.c @@ -0,0 +1,219 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2012 Lanedo GmbH <aleksander@lanedo.com> + */ + +#include <string.h> +#include <ctype.h> +#include <stdlib.h> + +#include "mm-common-helpers.h" +#include "mm-errors-types.h" +#include "mm-location-cdma-bs.h" + +/** + * SECTION: mm-location-cdma-bs + * @title: MMLocationCdmaBs + * @short_description: Helper object to handle CDMA Base Station location information. + * + * The #MMLocationCdmaBs is an object handling the location information of the + * CDMA base station in which the modem is registered. + * + * This object is retrieved with either mm_modem_location_get_cdma_bs(), + * mm_modem_location_get_cdma_bs_sync(), mm_modem_location_get_full() or + * mm_modem_location_get_full_sync(). + */ + +G_DEFINE_TYPE (MMLocationCdmaBs, mm_location_cdma_bs, G_TYPE_OBJECT); + +#define PROPERTY_LATITUDE "latitude" +#define PROPERTY_LONGITUDE "longitude" + +struct _MMLocationCdmaBsPrivate { + gdouble latitude; + gdouble longitude; +}; + +/*****************************************************************************/ + +/** + * mm_location_cdma_bs_get_longitude: + * @self: a #MMLocationCdmaBs. + * + * Gets the longitude, in the [-180,180] range. + * + * Returns: the longitude, or %MM_LOCATION_LONGITUDE_UNKNOWN if unknown. + */ +gdouble +mm_location_cdma_bs_get_longitude (MMLocationCdmaBs *self) +{ + g_return_val_if_fail (MM_IS_LOCATION_CDMA_BS (self), + MM_LOCATION_LONGITUDE_UNKNOWN); + + return self->priv->longitude; +} + +/*****************************************************************************/ + +/** + * mm_location_cdma_bs_get_latitude: + * @self: a #MMLocationCdmaBs. + * + * Gets the latitude, in the [-90,90] range. + * + * Returns: the latitude, or %MM_LOCATION_LATITUDE_UNKNOWN if unknown. + */ +gdouble +mm_location_cdma_bs_get_latitude (MMLocationCdmaBs *self) +{ + g_return_val_if_fail (MM_IS_LOCATION_CDMA_BS (self), + MM_LOCATION_LATITUDE_UNKNOWN); + + return self->priv->latitude; +} + +/*****************************************************************************/ + +gboolean +mm_location_cdma_bs_set (MMLocationCdmaBs *self, + gdouble longitude, + gdouble latitude) +{ + g_return_val_if_fail ((longitude == MM_LOCATION_LONGITUDE_UNKNOWN || + (longitude >= -180.0 && longitude <= 180.0)), + FALSE); + g_return_val_if_fail ((latitude == MM_LOCATION_LATITUDE_UNKNOWN || + (latitude >= -90.0 && latitude <= 90.0)), + FALSE); + + if (self->priv->longitude == longitude && + self->priv->latitude == latitude) + return FALSE; + + self->priv->longitude = longitude; + self->priv->latitude = latitude; + return TRUE; +} + +/*****************************************************************************/ + +GVariant * +mm_location_cdma_bs_get_dictionary (MMLocationCdmaBs *self) +{ + GVariantBuilder builder; + + /* We do allow NULL */ + if (!self) + return NULL; + + g_return_val_if_fail (MM_IS_LOCATION_CDMA_BS (self), NULL); + + /* If mandatory parameters are not found, return NULL */ + if (self->priv->longitude == MM_LOCATION_LONGITUDE_UNKNOWN || + self->priv->latitude == MM_LOCATION_LATITUDE_UNKNOWN) + return NULL; + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_LONGITUDE, + g_variant_new_double (self->priv->longitude)); + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_LATITUDE, + g_variant_new_double (self->priv->latitude)); + + return g_variant_ref_sink (g_variant_builder_end (&builder)); +} + +/*****************************************************************************/ + +MMLocationCdmaBs * +mm_location_cdma_bs_new_from_dictionary (GVariant *dictionary, + GError **error) +{ + GError *inner_error = NULL; + MMLocationCdmaBs *self; + GVariantIter iter; + gchar *key; + GVariant *value; + + self = mm_location_cdma_bs_new (); + if (!dictionary) + return self; + + if (!g_variant_is_of_type (dictionary, G_VARIANT_TYPE ("a{sv}"))) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Cannot create CDMA BS location from dictionary: " + "invalid variant type received"); + g_object_unref (self); + return NULL; + } + + g_variant_iter_init (&iter, dictionary); + while (!inner_error && + g_variant_iter_next (&iter, "{sv}", &key, &value)) { + if (g_str_equal (key, PROPERTY_LONGITUDE)) + self->priv->longitude = g_variant_get_double (value); + else if (g_str_equal (key, PROPERTY_LATITUDE)) + self->priv->latitude = g_variant_get_double (value); + g_free (key); + g_variant_unref (value); + } + + /* If any of the mandatory parameters is missing, cleanup */ + if (self->priv->longitude == MM_LOCATION_LONGITUDE_UNKNOWN || + self->priv->latitude == MM_LOCATION_LATITUDE_UNKNOWN) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Cannot create CDMA BS location from dictionary: " + "mandatory parameters missing " + "(longitude: %s, latitude: %s)", + (self->priv->longitude != MM_LOCATION_LONGITUDE_UNKNOWN) ? "yes" : "missing", + (self->priv->latitude != MM_LOCATION_LATITUDE_UNKNOWN) ? "yes" : "missing"); + g_clear_object (&self); + } + + return self; +} + +/*****************************************************************************/ + +MMLocationCdmaBs * +mm_location_cdma_bs_new (void) +{ + return (MM_LOCATION_CDMA_BS ( + g_object_new (MM_TYPE_LOCATION_CDMA_BS, NULL))); +} + +static void +mm_location_cdma_bs_init (MMLocationCdmaBs *self) +{ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), + MM_TYPE_LOCATION_CDMA_BS, + MMLocationCdmaBsPrivate); + + self->priv->latitude = MM_LOCATION_LATITUDE_UNKNOWN; + self->priv->longitude = MM_LOCATION_LONGITUDE_UNKNOWN; +} + +static void +mm_location_cdma_bs_class_init (MMLocationCdmaBsClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (MMLocationCdmaBsPrivate)); +} diff --git a/libmm-glib/mm-location-cdma-bs.h b/libmm-glib/mm-location-cdma-bs.h new file mode 100644 index 0000000..ca34e2f --- /dev/null +++ b/libmm-glib/mm-location-cdma-bs.h @@ -0,0 +1,84 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2012 Lanedo GmbH <aleksander@lanedo.com> + */ + +#ifndef MM_LOCATION_CDMA_BS_H +#define MM_LOCATION_CDMA_BS_H + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> +#include <glib-object.h> + +#include "mm-location-common.h" + +G_BEGIN_DECLS + +#define MM_TYPE_LOCATION_CDMA_BS (mm_location_cdma_bs_get_type ()) +#define MM_LOCATION_CDMA_BS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_LOCATION_CDMA_BS, MMLocationCdmaBs)) +#define MM_LOCATION_CDMA_BS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_LOCATION_CDMA_BS, MMLocationCdmaBsClass)) +#define MM_IS_LOCATION_CDMA_BS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_LOCATION_CDMA_BS)) +#define MM_IS_LOCATION_CDMA_BS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_LOCATION_CDMA_BS)) +#define MM_LOCATION_CDMA_BS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_LOCATION_CDMA_BS, MMLocationCdmaBsClass)) + +typedef struct _MMLocationCdmaBs MMLocationCdmaBs; +typedef struct _MMLocationCdmaBsClass MMLocationCdmaBsClass; +typedef struct _MMLocationCdmaBsPrivate MMLocationCdmaBsPrivate; + +/** + * MMLocationCdmaBs: + * + * The #MMLocationCdmaBs structure contains private data and should + * only be accessed using the provided API. + */ +struct _MMLocationCdmaBs { + /*< private >*/ + GObject parent; + MMLocationCdmaBsPrivate *priv; +}; + +struct _MMLocationCdmaBsClass { + /*< private >*/ + GObjectClass parent; +}; + +GType mm_location_cdma_bs_get_type (void); + +gdouble mm_location_cdma_bs_get_longitude (MMLocationCdmaBs *self); +gdouble mm_location_cdma_bs_get_latitude (MMLocationCdmaBs *self); + +/*****************************************************************************/ +/* ModemManager/libmm-glib/mmcli specific methods */ + +#if defined (_LIBMM_INSIDE_MM) || \ + defined (_LIBMM_INSIDE_MMCLI) || \ + defined (LIBMM_GLIB_COMPILATION) + +MMLocationCdmaBs *mm_location_cdma_bs_new (void); +MMLocationCdmaBs *mm_location_cdma_bs_new_from_dictionary (GVariant *string, + GError **error); + +gboolean mm_location_cdma_bs_set (MMLocationCdmaBs *self, + gdouble longitude, + gdouble latitude); + +GVariant *mm_location_cdma_bs_get_dictionary (MMLocationCdmaBs *self); + +#endif + +G_END_DECLS + +#endif /* MM_LOCATION_CDMA_BS_H */ diff --git a/libmm-glib/mm-location-common.h b/libmm-glib/mm-location-common.h new file mode 100644 index 0000000..6397dc6 --- /dev/null +++ b/libmm-glib/mm-location-common.h @@ -0,0 +1,48 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2012 Lanedo GmbH <aleksander@lanedo.com> + */ + +#ifndef MM_LOCATION_COMMON_H +#define MM_LOCATION_COMMON_H + +#if !defined (__MODEM_MANAGER_H_INSIDE__) +#error "Only <ModemManager.h> can be included directly." +#endif + +/** + * MM_LOCATION_LONGITUDE_UNKNOWN: + * + * Identifier for an unknown longitude value. + * + * Proper longitude values fall in the [-180,180] range. + */ +#define MM_LOCATION_LONGITUDE_UNKNOWN G_MINDOUBLE + +/** + * MM_LOCATION_LATITUDE_UNKNOWN: + * + * Identifier for an unknown latitude value. + * + * Proper latitude values fall in the [-90,90] range. + */ +#define MM_LOCATION_LATITUDE_UNKNOWN G_MINDOUBLE + +/** + * MM_LOCATION_ALTITUDE_UNKNOWN: + * + * Identifier for an unknown altitude value. + */ +#define MM_LOCATION_ALTITUDE_UNKNOWN G_MINDOUBLE + +#endif /* MM_LOCATION_COMMON_H */ diff --git a/libmm-glib/mm-location-gps-nmea.c b/libmm-glib/mm-location-gps-nmea.c new file mode 100644 index 0000000..2070eeb --- /dev/null +++ b/libmm-glib/mm-location-gps-nmea.c @@ -0,0 +1,278 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2012 Lanedo GmbH <aleksander@lanedo.com> + */ + +#include <string.h> +#include <ctype.h> +#include <stdlib.h> + +#include "mm-common-helpers.h" +#include "mm-errors-types.h" +#include "mm-location-gps-nmea.h" + +/** + * SECTION: mm-location-gps-nmea + * @title: MMLocationGpsNmea + * @short_description: Helper object to handle NMEA-based GPS location information. + * + * The #MMLocationGpsNmea is an object handling the location information of the + * modem when this is reported by GPS. + * + * This object is retrieved with either mm_modem_location_get_gps_nmea(), + * mm_modem_location_get_gps_nmea_sync(), mm_modem_location_get_full() or + * mm_modem_location_get_full_sync(). + */ + +G_DEFINE_TYPE (MMLocationGpsNmea, mm_location_gps_nmea, G_TYPE_OBJECT); + +struct _MMLocationGpsNmeaPrivate { + GHashTable *traces; + GRegex *sequence_regex; +}; + +/*****************************************************************************/ + +static gboolean +check_append_or_replace (MMLocationGpsNmea *self, + const gchar *trace) +{ + /* By default, replace */ + gboolean append_or_replace = FALSE; + GMatchInfo *match_info = NULL; + + if (G_UNLIKELY (!self->priv->sequence_regex)) + self->priv->sequence_regex = g_regex_new ("\\$GPGSV,(\\d),(\\d).*", + G_REGEX_RAW | G_REGEX_OPTIMIZE, + 0, + NULL); + + if (g_regex_match (self->priv->sequence_regex, trace, 0, &match_info)) { + guint index; + + /* If we don't have the first element of a sequence, append */ + if (mm_get_uint_from_match_info (match_info, 2, &index) && index != 1) + append_or_replace = TRUE; + } + g_match_info_free (match_info); + + return append_or_replace; +} + +static gboolean +location_gps_nmea_take_trace (MMLocationGpsNmea *self, + gchar *trace) +{ + gchar *i; + gchar *trace_type; + + i = strchr (trace, ','); + if (!i || i == trace) + return FALSE; + + trace_type = g_malloc (i - trace + 1); + memcpy (trace_type, trace, i - trace); + trace_type[i - trace] = '\0'; + + /* Some traces are part of a SEQUENCE; so we need to decide whether we + * completely replace the previous trace, or we append the new one to + * the already existing list */ + if (check_append_or_replace (self, trace)) { + /* Append */ + const gchar *previous; + + previous = g_hash_table_lookup (self->priv->traces, trace_type); + if (previous) { + gchar *sequence; + + /* Skip the trace if we already have it there */ + if (strstr (previous, trace)) + return TRUE; + + sequence = g_strdup_printf ("%s%s%s", + previous, + g_str_has_suffix (previous, "\r\n") ? "" : "\r\n", + trace); + g_free (trace); + trace = sequence; + } + } + + g_hash_table_replace (self->priv->traces, + trace_type, + trace); + return TRUE; +} + +gboolean +mm_location_gps_nmea_add_trace (MMLocationGpsNmea *self, + const gchar *trace) +{ + return location_gps_nmea_take_trace (self, g_strdup (trace)); +} + +/*****************************************************************************/ + +/** + * mm_location_gps_nmea_get_trace: + * @self: a #MMLocationGpsNmea. + * @trace_type: specific NMEA trace type to gather. + * + * Gets the last cached value of the specific @trace_type given. + * + * Returns: the NMEA trace, or %NULL if not available. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_location_gps_nmea_get_trace (MMLocationGpsNmea *self, + const gchar *trace_type) +{ + return (const gchar *)g_hash_table_lookup (self->priv->traces, trace_type); +} + +/*****************************************************************************/ + +static void +build_full_foreach (const gchar *trace_type, + const gchar *trace, + GString **built) +{ + if ((*built)->len == 0 || g_str_has_suffix ((*built)->str, "\r\n")) + g_string_append (*built, trace); + else + g_string_append_printf (*built, "\r\n%s", trace); +} + +/** + * mm_location_gps_nmea_build_full: + * @self: a #MMLocationGpsNmea. + * + * Gets a compilation of all cached traces. + * + * Returns: (transfer full) a string containing all traces, or #NULL if none available. The returned value should be freed with g_free(). + */ +gchar * +mm_location_gps_nmea_build_full (MMLocationGpsNmea *self) +{ + GString *built; + + built = g_string_new (""); + g_hash_table_foreach (self->priv->traces, + (GHFunc)build_full_foreach, + &built); + return g_string_free (built, FALSE); +} + +/*****************************************************************************/ + +GVariant * +mm_location_gps_nmea_get_string_variant (MMLocationGpsNmea *self) +{ + GVariant *variant = NULL; + gchar *built; + + g_return_val_if_fail (MM_IS_LOCATION_GPS_NMEA (self), NULL); + + built = mm_location_gps_nmea_build_full (self); + variant = g_variant_new_string (built); + g_free (built); + + return variant; +} + +/*****************************************************************************/ + +MMLocationGpsNmea * +mm_location_gps_nmea_new_from_string_variant (GVariant *string, + GError **error) +{ + MMLocationGpsNmea *self = NULL; + gchar **split; + guint i; + + if (!g_variant_is_of_type (string, G_VARIANT_TYPE_STRING)) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Cannot create GPS NMEA location from string: " + "invalid variant type received"); + return NULL; + } + + split = g_strsplit (g_variant_get_string (string, NULL), "\r\n", -1); + if (!split) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Invalid GPS NMEA location string: '%s'", + g_variant_get_string (string, NULL)); + return NULL; + } + + /* Create new location object */ + self = mm_location_gps_nmea_new (); + + for (i = 0; split[i]; i++) { + if (!location_gps_nmea_take_trace (self, split[i])) + g_free (split[i]); + } + + /* Note that the strings in the array of strings were already taken + * or freed */ + g_free (split); + + return self; +} + +/*****************************************************************************/ + +MMLocationGpsNmea * +mm_location_gps_nmea_new (void) +{ + return (MM_LOCATION_GPS_NMEA ( + g_object_new (MM_TYPE_LOCATION_GPS_NMEA, NULL))); +} + +static void +mm_location_gps_nmea_init (MMLocationGpsNmea *self) +{ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), + MM_TYPE_LOCATION_GPS_NMEA, + MMLocationGpsNmeaPrivate); + + self->priv->traces = g_hash_table_new_full (g_str_hash, + g_str_equal, + g_free, + g_free); +} + +static void +finalize (GObject *object) +{ + MMLocationGpsNmea *self = MM_LOCATION_GPS_NMEA (object); + + g_hash_table_destroy (self->priv->traces); + if (self->priv->sequence_regex) + g_regex_unref (self->priv->sequence_regex); + + G_OBJECT_CLASS (mm_location_gps_nmea_parent_class)->finalize (object); +} + +static void +mm_location_gps_nmea_class_init (MMLocationGpsNmeaClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (MMLocationGpsNmeaPrivate)); + + object_class->finalize = finalize; +} diff --git a/libmm-glib/mm-location-gps-nmea.h b/libmm-glib/mm-location-gps-nmea.h new file mode 100644 index 0000000..3317074 --- /dev/null +++ b/libmm-glib/mm-location-gps-nmea.h @@ -0,0 +1,82 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2012 Lanedo GmbH <aleksander@lanedo.com> + */ + +#ifndef MM_LOCATION_GPS_NMEA_H +#define MM_LOCATION_GPS_NMEA_H + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> +#include <glib-object.h> + +G_BEGIN_DECLS + +#define MM_TYPE_LOCATION_GPS_NMEA (mm_location_gps_nmea_get_type ()) +#define MM_LOCATION_GPS_NMEA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_LOCATION_GPS_NMEA, MMLocationGpsNmea)) +#define MM_LOCATION_GPS_NMEA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_LOCATION_GPS_NMEA, MMLocationGpsNmeaClass)) +#define MM_IS_LOCATION_GPS_NMEA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_LOCATION_GPS_NMEA)) +#define MM_IS_LOCATION_GPS_NMEA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_LOCATION_GPS_NMEA)) +#define MM_LOCATION_GPS_NMEA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_LOCATION_GPS_NMEA, MMLocationGpsNmeaClass)) + +typedef struct _MMLocationGpsNmea MMLocationGpsNmea; +typedef struct _MMLocationGpsNmeaClass MMLocationGpsNmeaClass; +typedef struct _MMLocationGpsNmeaPrivate MMLocationGpsNmeaPrivate; + +/** + * MMLocationGpsNmea: + * + * The #MMLocationGpsNmea structure contains private data and should + * only be accessed using the provided API. + */ +struct _MMLocationGpsNmea { + /*< private >*/ + GObject parent; + MMLocationGpsNmeaPrivate *priv; +}; + +struct _MMLocationGpsNmeaClass { + /*< private >*/ + GObjectClass parent; +}; + +GType mm_location_gps_nmea_get_type (void); + +const gchar *mm_location_gps_nmea_get_trace (MMLocationGpsNmea *self, + const gchar *trace_type); +gchar *mm_location_gps_nmea_build_full (MMLocationGpsNmea *self); + +/*****************************************************************************/ +/* ModemManager/libmm-glib/mmcli specific methods */ + +#if defined (_LIBMM_INSIDE_MM) || \ + defined (_LIBMM_INSIDE_MMCLI) || \ + defined (LIBMM_GLIB_COMPILATION) + +MMLocationGpsNmea *mm_location_gps_nmea_new (void); +MMLocationGpsNmea *mm_location_gps_nmea_new_from_string_variant (GVariant *string, + GError **error); + +gboolean mm_location_gps_nmea_add_trace (MMLocationGpsNmea *self, + const gchar *trace); + +GVariant *mm_location_gps_nmea_get_string_variant (MMLocationGpsNmea *self); + +#endif + +G_END_DECLS + +#endif /* MM_LOCATION_GPS_NMEA_H */ diff --git a/libmm-glib/mm-location-gps-raw.c b/libmm-glib/mm-location-gps-raw.c new file mode 100644 index 0000000..4418eff --- /dev/null +++ b/libmm-glib/mm-location-gps-raw.c @@ -0,0 +1,388 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2012 Lanedo GmbH <aleksander@lanedo.com> + */ + +#include <string.h> +#include <ctype.h> +#include <stdlib.h> + +#include "mm-common-helpers.h" +#include "mm-errors-types.h" +#include "mm-location-gps-raw.h" + +/** + * SECTION: mm-location-gps-raw + * @title: MMLocationGpsRaw + * @short_description: Helper object to handle generic GPS location information. + * + * The #MMLocationGpsRaw is an object handling the location information of the + * modem when this is reported by GPS. + * + * This object is retrieved with either mm_modem_location_get_gps_raw(), + * mm_modem_location_get_gps_raw_sync(), mm_modem_location_get_full() or + * mm_modem_location_get_full_sync(). + */ + +G_DEFINE_TYPE (MMLocationGpsRaw, mm_location_gps_raw, G_TYPE_OBJECT); + +#define PROPERTY_UTC_TIME "utc-time" +#define PROPERTY_LATITUDE "latitude" +#define PROPERTY_LONGITUDE "longitude" +#define PROPERTY_ALTITUDE "altitude" + +struct _MMLocationGpsRawPrivate { + GRegex *gpgga_regex; + + gchar *utc_time; + gdouble latitude; + gdouble longitude; + gdouble altitude; +}; + +/*****************************************************************************/ + +/** + * mm_location_gps_raw_get_utc_time: + * @self: a #MMLocationGpsRaw. + * + * Gets the UTC time of the location being reported. + * + * Returns: a string with the UTC time, or #NULL if unknown. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_location_gps_raw_get_utc_time (MMLocationGpsRaw *self) +{ + g_return_val_if_fail (MM_IS_LOCATION_GPS_RAW (self), NULL); + + return self->priv->utc_time; +} + +/*****************************************************************************/ + +/** + * mm_location_gps_raw_get_longitude: + * @self: a #MMLocationGpsRaw. + * + * Gets the longitude, in the [-180,180] range. + * + * Returns: the longitude, or %MM_LOCATION_LONGITUDE_UNKNOWN if unknown. + */ +gdouble +mm_location_gps_raw_get_longitude (MMLocationGpsRaw *self) +{ + g_return_val_if_fail (MM_IS_LOCATION_GPS_RAW (self), + MM_LOCATION_LONGITUDE_UNKNOWN); + + return self->priv->longitude; +} + +/*****************************************************************************/ + +/** + * mm_location_gps_raw_get_latitude: + * @self: a #MMLocationGpsRaw. + * + * Gets the latitude, in the [-90,90] range. + * + * Returns: the latitude, or %MM_LOCATION_LATITUDE_UNKNOWN if unknown. + */ +gdouble +mm_location_gps_raw_get_latitude (MMLocationGpsRaw *self) +{ + g_return_val_if_fail (MM_IS_LOCATION_GPS_RAW (self), + MM_LOCATION_LATITUDE_UNKNOWN); + + return self->priv->latitude; +} + +/*****************************************************************************/ + +/** + * mm_location_gps_raw_get_altitude: + * @self: a #MMLocationGpsRaw. + * + * Gets the altitude, in the [-90,90] range. + * + * Returns: the altitude, or %MM_LOCATION_ALTITUDE_UNKNOWN if unknown. + */ +gdouble +mm_location_gps_raw_get_altitude (MMLocationGpsRaw *self) +{ + g_return_val_if_fail (MM_IS_LOCATION_GPS_RAW (self), + MM_LOCATION_ALTITUDE_UNKNOWN); + + return self->priv->altitude; +} + +/*****************************************************************************/ + +static gboolean +get_longitude_or_latitude_from_match_info (GMatchInfo *match_info, + guint32 match_index, + gdouble *out) +{ + gchar *aux; + gchar *s; + gboolean ret = FALSE; + gdouble minutes; + gdouble degrees; + + s = g_match_info_fetch (match_info, match_index); + if (!s) + goto out; + + /* 4533.35 is 45 degrees and 33.35 minutes */ + + aux = strchr (s, '.'); + if (!aux || ((aux - s) < 3)) + goto out; + + aux -= 2; + if (!mm_get_double_from_str (aux, &minutes)) + goto out; + + aux[0] = '\0'; + if (!mm_get_double_from_str (s, °rees)) + goto out; + + /* Include the minutes as part of the degrees */ + *out = degrees + (minutes / 60.0); + ret = TRUE; + +out: + g_free (s); + + return ret; +} + +gboolean +mm_location_gps_raw_add_trace (MMLocationGpsRaw *self, + const gchar *trace) +{ + GMatchInfo *match_info = NULL; + + /* Current implementation works only with $GPGGA traces */ + if (!g_str_has_prefix (trace, "$GPGGA")) + return FALSE; + + /* + * $GPGGA,hhmmss.ss,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx*hh + * 1 = UTC of Position + * 2 = Latitude + * 3 = N or S + * 4 = Longitude + * 5 = E or W + * 6 = GPS quality indicator (0=invalid; 1=GPS fix; 2=Diff. GPS fix) + * 7 = Number of satellites in use [not those in view] + * 8 = Horizontal dilution of position + * 9 = Antenna altitude above/below mean sea level (geoid) + * 10 = Meters (Antenna height unit) + * 11 = Geoidal separation (Diff. between WGS-84 earth ellipsoid and + * mean sea level. -=geoid is below WGS-84 ellipsoid) + * 12 = Meters (Units of geoidal separation) + * 13 = Age in seconds since last update from diff. reference station + * 14 = Diff. reference station ID# + * 15 = Checksum + */ + if (G_UNLIKELY (!self->priv->gpgga_regex)) + self->priv->gpgga_regex = g_regex_new ("\\$GPGGA,(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*)\\*(.*).*", + G_REGEX_RAW | G_REGEX_OPTIMIZE, + 0, + NULL); + + if (g_regex_match (self->priv->gpgga_regex, trace, 0, &match_info)) { + /* UTC time */ + if (self->priv->utc_time) + g_free (self->priv->utc_time); + self->priv->utc_time = g_match_info_fetch (match_info, 1); + + /* Latitude */ + self->priv->latitude = MM_LOCATION_LATITUDE_UNKNOWN; + if (get_longitude_or_latitude_from_match_info (match_info, 2, &self->priv->latitude)) { + gchar *str; + + /* N/S */ + str = g_match_info_fetch (match_info, 3); + if (str && str[0] == 'S') + self->priv->latitude *= -1; + g_free (str); + } + + /* Longitude */ + self->priv->longitude = MM_LOCATION_LONGITUDE_UNKNOWN; + if (get_longitude_or_latitude_from_match_info (match_info, 4, &self->priv->longitude)) { + gchar *str; + + /* N/S */ + str = g_match_info_fetch (match_info, 5); + if (str && str[0] == 'W') + self->priv->longitude *= -1; + g_free (str); + } + + /* Altitude */ + self->priv->altitude = MM_LOCATION_ALTITUDE_UNKNOWN; + mm_get_double_from_match_info (match_info, 9, &self->priv->altitude); + } + + g_match_info_free (match_info); + + return TRUE; +} + +/*****************************************************************************/ + +GVariant * +mm_location_gps_raw_get_dictionary (MMLocationGpsRaw *self) +{ + GVariantBuilder builder; + + /* We do allow NULL */ + if (!self) + return NULL; + + g_return_val_if_fail (MM_IS_LOCATION_GPS_RAW (self), NULL); + + /* If mandatory parameters are not found, return NULL */ + if (!self->priv->utc_time || + self->priv->longitude == MM_LOCATION_LONGITUDE_UNKNOWN || + self->priv->latitude == MM_LOCATION_LATITUDE_UNKNOWN) + return NULL; + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_UTC_TIME, + g_variant_new_string (self->priv->utc_time)); + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_LONGITUDE, + g_variant_new_double (self->priv->longitude)); + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_LATITUDE, + g_variant_new_double (self->priv->latitude)); + + /* Altitude is optional */ + if (self->priv->altitude != MM_LOCATION_ALTITUDE_UNKNOWN) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_ALTITUDE, + g_variant_new_double (self->priv->altitude)); + + return g_variant_ref_sink (g_variant_builder_end (&builder)); +} + +/*****************************************************************************/ + +MMLocationGpsRaw * +mm_location_gps_raw_new_from_dictionary (GVariant *dictionary, + GError **error) +{ + GError *inner_error = NULL; + MMLocationGpsRaw *self; + GVariantIter iter; + gchar *key; + GVariant *value; + + self = mm_location_gps_raw_new (); + if (!dictionary) + return self; + + if (!g_variant_is_of_type (dictionary, G_VARIANT_TYPE ("a{sv}"))) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Cannot create GPS RAW location from dictionary: " + "invalid variant type received"); + g_object_unref (self); + return NULL; + } + + g_variant_iter_init (&iter, dictionary); + while (!inner_error && + g_variant_iter_next (&iter, "{sv}", &key, &value)) { + if (g_str_equal (key, PROPERTY_UTC_TIME)) + self->priv->utc_time = g_variant_dup_string (value, NULL); + else if (g_str_equal (key, PROPERTY_LONGITUDE)) + self->priv->longitude = g_variant_get_double (value); + else if (g_str_equal (key, PROPERTY_LATITUDE)) + self->priv->latitude = g_variant_get_double (value); + else if (g_str_equal (key, PROPERTY_ALTITUDE)) + self->priv->altitude = g_variant_get_double (value); + g_free (key); + g_variant_unref (value); + } + + /* If any of the mandatory parameters is missing, cleanup */ + if (!self->priv->utc_time || + self->priv->longitude == MM_LOCATION_LONGITUDE_UNKNOWN || + self->priv->latitude == MM_LOCATION_LATITUDE_UNKNOWN) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Cannot create GPS RAW location from dictionary: " + "mandatory parameters missing " + "(utc-time: %s, longitude: %s, latitude: %s)", + self->priv->utc_time ? "yes" : "missing", + (self->priv->longitude != MM_LOCATION_LONGITUDE_UNKNOWN) ? "yes" : "missing", + (self->priv->latitude != MM_LOCATION_LATITUDE_UNKNOWN) ? "yes" : "missing"); + g_clear_object (&self); + } + + return self; +} + +/*****************************************************************************/ + +MMLocationGpsRaw * +mm_location_gps_raw_new (void) +{ + return (MM_LOCATION_GPS_RAW ( + g_object_new (MM_TYPE_LOCATION_GPS_RAW, NULL))); +} + +static void +mm_location_gps_raw_init (MMLocationGpsRaw *self) +{ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), + MM_TYPE_LOCATION_GPS_RAW, + MMLocationGpsRawPrivate); + + self->priv->utc_time = NULL; + self->priv->latitude = MM_LOCATION_LATITUDE_UNKNOWN; + self->priv->longitude = MM_LOCATION_LONGITUDE_UNKNOWN; + self->priv->altitude = MM_LOCATION_ALTITUDE_UNKNOWN; +} + +static void +finalize (GObject *object) +{ + MMLocationGpsRaw *self = MM_LOCATION_GPS_RAW (object); + + if (self->priv->gpgga_regex) + g_regex_unref (self->priv->gpgga_regex); + + G_OBJECT_CLASS (mm_location_gps_raw_parent_class)->finalize (object); +} + +static void +mm_location_gps_raw_class_init (MMLocationGpsRawClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (MMLocationGpsRawPrivate)); + + object_class->finalize = finalize; +} diff --git a/libmm-glib/mm-location-gps-raw.h b/libmm-glib/mm-location-gps-raw.h new file mode 100644 index 0000000..8ef3747 --- /dev/null +++ b/libmm-glib/mm-location-gps-raw.h @@ -0,0 +1,85 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2012 Lanedo GmbH <aleksander@lanedo.com> + */ + +#ifndef MM_LOCATION_GPS_RAW_H +#define MM_LOCATION_GPS_RAW_H + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> +#include <glib-object.h> + +#include "mm-location-common.h" + +G_BEGIN_DECLS + +#define MM_TYPE_LOCATION_GPS_RAW (mm_location_gps_raw_get_type ()) +#define MM_LOCATION_GPS_RAW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_LOCATION_GPS_RAW, MMLocationGpsRaw)) +#define MM_LOCATION_GPS_RAW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_LOCATION_GPS_RAW, MMLocationGpsRawClass)) +#define MM_IS_LOCATION_GPS_RAW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_LOCATION_GPS_RAW)) +#define MM_IS_LOCATION_GPS_RAW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_LOCATION_GPS_RAW)) +#define MM_LOCATION_GPS_RAW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_LOCATION_GPS_RAW, MMLocationGpsRawClass)) + +typedef struct _MMLocationGpsRaw MMLocationGpsRaw; +typedef struct _MMLocationGpsRawClass MMLocationGpsRawClass; +typedef struct _MMLocationGpsRawPrivate MMLocationGpsRawPrivate; + +/** + * MMLocationGpsRaw: + * + * The #MMLocationGpsRaw structure contains private data and should + * only be accessed using the provided API. + */ +struct _MMLocationGpsRaw { + /*< private >*/ + GObject parent; + MMLocationGpsRawPrivate *priv; +}; + +struct _MMLocationGpsRawClass { + /*< private >*/ + GObjectClass parent; +}; + +GType mm_location_gps_raw_get_type (void); + +const gchar *mm_location_gps_raw_get_utc_time (MMLocationGpsRaw *self); +gdouble mm_location_gps_raw_get_longitude (MMLocationGpsRaw *self); +gdouble mm_location_gps_raw_get_latitude (MMLocationGpsRaw *self); +gdouble mm_location_gps_raw_get_altitude (MMLocationGpsRaw *self); + +/*****************************************************************************/ +/* ModemManager/libmm-glib/mmcli specific methods */ + +#if defined (_LIBMM_INSIDE_MM) || \ + defined (_LIBMM_INSIDE_MMCLI) || \ + defined (LIBMM_GLIB_COMPILATION) + +MMLocationGpsRaw *mm_location_gps_raw_new (void); +MMLocationGpsRaw *mm_location_gps_raw_new_from_dictionary (GVariant *string, + GError **error); + +gboolean mm_location_gps_raw_add_trace (MMLocationGpsRaw *self, + const gchar *trace); + +GVariant *mm_location_gps_raw_get_dictionary (MMLocationGpsRaw *self); + +#endif + +G_END_DECLS + +#endif /* MM_LOCATION_GPS_RAW_H */ diff --git a/libmm-glib/mm-manager.c b/libmm-glib/mm-manager.c new file mode 100644 index 0000000..efea9b0 --- /dev/null +++ b/libmm-glib/mm-manager.c @@ -0,0 +1,544 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2011 - 2012 Aleksander Morgado <aleksander@gnu.org> + * Copyright (C) 2011 - 2012 Google, Inc. + * + * Author: Aleksander Morgado <aleksander@lanedo.com> + */ + +#include <ModemManager.h> + +#include "mm-errors-types.h" +#include "mm-gdbus-manager.h" +#include "mm-manager.h" +#include "mm-object.h" + +/** + * SECTION: mm-manager + * @title: MMManager + * @short_description: The Manager object + * + * The #MMManager is the object allowing access to the Manager interface. + * + * This object is also a #GDBusObjectManagerClient, and therefore it allows to + * use the standard ObjectManager interface to list and handle the managed + * modem objects. + */ + +G_DEFINE_TYPE (MMManager, mm_manager, MM_GDBUS_TYPE_OBJECT_MANAGER_CLIENT) + +struct _MMManagerPrivate { + /* The proxy for the Manager interface */ + MmGdbusOrgFreedesktopModemManager1 *manager_iface_proxy; +}; + +/*****************************************************************************/ + +static GType +get_proxy_type (GDBusObjectManagerClient *manager, + const gchar *object_path, + const gchar *interface_name, + gpointer user_data) +{ + static gsize once_init_value = 0; + static GHashTable *lookup_hash; + GType ret; + + if (interface_name == NULL) + return MM_TYPE_OBJECT; + + if (g_once_init_enter (&once_init_value)) { + lookup_hash = g_hash_table_new (g_str_hash, g_str_equal); + g_hash_table_insert (lookup_hash, "org.freedesktop.ModemManager1.Modem", GSIZE_TO_POINTER (MM_TYPE_MODEM)); + g_hash_table_insert (lookup_hash, "org.freedesktop.ModemManager1.Modem.Messaging", GSIZE_TO_POINTER (MM_TYPE_MODEM_MESSAGING)); + g_hash_table_insert (lookup_hash, "org.freedesktop.ModemManager1.Modem.Location", GSIZE_TO_POINTER (MM_TYPE_MODEM_LOCATION)); + g_hash_table_insert (lookup_hash, "org.freedesktop.ModemManager1.Modem.Time", GSIZE_TO_POINTER (MM_TYPE_MODEM_TIME)); + g_hash_table_insert (lookup_hash, "org.freedesktop.ModemManager1.Modem.Firmware", GSIZE_TO_POINTER (MM_TYPE_MODEM_FIRMWARE)); + g_hash_table_insert (lookup_hash, "org.freedesktop.ModemManager1.Modem.Contacts", GSIZE_TO_POINTER (MM_GDBUS_TYPE_MODEM_CONTACTS_PROXY)); + g_hash_table_insert (lookup_hash, "org.freedesktop.ModemManager1.Modem.ModemCdma", GSIZE_TO_POINTER (MM_TYPE_MODEM_CDMA)); + g_hash_table_insert (lookup_hash, "org.freedesktop.ModemManager1.Modem.Modem3gpp", GSIZE_TO_POINTER (MM_TYPE_MODEM_3GPP)); + g_hash_table_insert (lookup_hash, "org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd", GSIZE_TO_POINTER (MM_TYPE_MODEM_3GPP_USSD)); + g_hash_table_insert (lookup_hash, "org.freedesktop.ModemManager1.Modem.Simple", GSIZE_TO_POINTER (MM_TYPE_MODEM_SIMPLE)); + g_once_init_leave (&once_init_value, 1); + } + + ret = (GType) GPOINTER_TO_SIZE (g_hash_table_lookup (lookup_hash, interface_name)); + if (ret == (GType) 0) + ret = G_TYPE_DBUS_PROXY; + return ret; +} + +/*****************************************************************************/ + +static gboolean +ensure_modem_manager1_proxy (MMManager *self, + GError **error) +{ + gchar *name = NULL; + gchar *object_path = NULL; + GDBusProxyFlags flags = G_DBUS_PROXY_FLAGS_NONE; + GDBusConnection *connection = NULL; + + if (self->priv->manager_iface_proxy) + return TRUE; + + /* Get the Manager proxy created synchronously now */ + g_object_get (self, + "name", &name, + "object-path", &object_path, + "flags", &flags, + "connection", &connection, + NULL); + + self->priv->manager_iface_proxy = + mm_gdbus_org_freedesktop_modem_manager1_proxy_new_sync (connection, + flags, + name, + object_path, + NULL, + error); + g_object_unref (connection); + g_free (object_path); + g_free (name); + + return !!self->priv->manager_iface_proxy; +} + +/*****************************************************************************/ + +/** + * mm_manager_new_finish: + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_manager_new(). + * @error: Return location for error or %NULL + * + * Finishes an operation started with mm_manager_new(). + * + * Returns: (transfer full) (type MMManager): The constructed object manager client or %NULL if @error is set. + */ +MMManager * +mm_manager_new_finish (GAsyncResult *res, + GError **error) +{ + GDBusObjectManager *ret; + + ret = mm_gdbus_object_manager_client_new_finish (res, error); + return (ret ? MM_MANAGER (ret) : NULL); +} + +/** + * mm_manager_new: + * @connection: A #GDBusConnection. + * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied. + * @user_data: User data to pass to @callback. + * + * Asynchronously creates a #MMManager. + * + * When the operation is finished, @callback will be invoked in the + * <link linkend="g-main-context-push-thread-default">thread-default main loop</link> + * of the thread you are calling this method from. + * + * You can then call mm_manager_new_finish() to get the result of the operation. + * + * See mm_manager_new_sync() for the synchronous, blocking version of this constructor. + */ +void +mm_manager_new (GDBusConnection *connection, + GDBusObjectManagerClientFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_async_initable_new_async (MM_TYPE_MANAGER, + G_PRIORITY_DEFAULT, + cancellable, + callback, + user_data, + "name", MM_DBUS_SERVICE, + "object-path", MM_DBUS_PATH, + "flags", flags, + "connection", connection, + "get-proxy-type-func", get_proxy_type, + NULL); +} + +/** + * mm_manager_new_sync: + * @connection: A #GDBusConnection. + * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL + * + * Synchronously creates a #MMManager. + * + * The calling thread is blocked until a reply is received. + * + * See mm_manager_new() for the asynchronous version of this constructor. + * + * Returns: (transfer full) (type MMManager): The constructed object manager client or %NULL if @error is set. + */ +MMManager * +mm_manager_new_sync (GDBusConnection *connection, + GDBusObjectManagerClientFlags flags, + GCancellable *cancellable, + GError **error) +{ + GInitable *ret; + + ret = g_initable_new (MM_TYPE_MANAGER, + cancellable, + error, + "name", MM_DBUS_SERVICE, + "object-path", MM_DBUS_PATH, + "flags", flags, + "connection", connection, + "get-proxy-type-func", get_proxy_type, + NULL); + + return (ret ? MM_MANAGER (ret) : NULL); +} + +/*****************************************************************************/ + +/** + * mm_manager_peek_proxy: + * @manager: A #MMManager. + * + * Gets the #GDBusProxy interface of the @manager. + * + * Returns: (transfer none): The #GDBusProxy interface of @manager, or #NULL if none. Do not free the returned object, it is owned by @manager. + */ +GDBusProxy * +mm_manager_peek_proxy (MMManager *manager) +{ + g_return_val_if_fail (MM_IS_MANAGER (manager), NULL); + + if (!ensure_modem_manager1_proxy (manager, NULL)) + return NULL; + + return G_DBUS_PROXY (manager->priv->manager_iface_proxy); +} + +/** + * mm_manager_get_proxy: + * @manager: A #MMManager. + * + * Gets the #GDBusProxy interface of the @manager. + * + * Returns: (transfer full): The #GDBusProxy interface of @manager, or #NULL if none. The returned object must be freed with g_object_unref(). + */ +GDBusProxy * +mm_manager_get_proxy (MMManager *manager) +{ + g_return_val_if_fail (MM_IS_MANAGER (manager), NULL); + + if (!ensure_modem_manager1_proxy (manager, NULL)) + return NULL; + + return G_DBUS_PROXY (g_object_ref (manager->priv->manager_iface_proxy)); +} + +/*****************************************************************************/ + +/** + * mm_manager_set_logging_finish: + * @manager: A #MMManager. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_manager_set_logging(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_manager_set_logging(). + * + * Returns: %TRUE if the call succeded, %FALSE if @error is set. + */ +gboolean +mm_manager_set_logging_finish (MMManager *manager, + GAsyncResult *res, + GError **error) +{ + return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error); +} + +static void +set_logging_ready (MmGdbusOrgFreedesktopModemManager1 *manager_iface_proxy, + GAsyncResult *res, + GSimpleAsyncResult *simple) +{ + GError *error = NULL; + + if (mm_gdbus_org_freedesktop_modem_manager1_call_set_logging_finish ( + manager_iface_proxy, + res, + &error)) + g_simple_async_result_take_error (simple, error); + else + g_simple_async_result_set_op_res_gboolean (simple, TRUE); + + g_simple_async_result_complete (simple); + g_object_unref (simple); +} + +/** + * mm_manager_set_logging: + * @manager: A #MMManager. + * @level: the login level to set. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously requests to set the specified logging level in the daemon. + * + * When the operation is finished, @callback will be invoked in the + * <link linkend="g-main-context-push-thread-default">thread-default main loop</link> + * of the thread you are calling this method from. You can then call + * mm_manager_set_logging_finish() to get the result of the operation. + * + * See mm_manager_set_logging_sync() for the synchronous, blocking version of this method. + */ +void +mm_manager_set_logging (MMManager *manager, + const gchar *level, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GSimpleAsyncResult *result; + GError *inner_error = NULL; + + g_return_if_fail (MM_IS_MANAGER (manager)); + + result = g_simple_async_result_new (G_OBJECT (manager), + callback, + user_data, + mm_manager_set_logging); + + if (!ensure_modem_manager1_proxy (manager, &inner_error)) { + g_simple_async_result_take_error (result, inner_error); + g_simple_async_result_complete_in_idle (result); + g_object_unref (result); + return; + } + + mm_gdbus_org_freedesktop_modem_manager1_call_set_logging ( + manager->priv->manager_iface_proxy, + level, + cancellable, + (GAsyncReadyCallback)set_logging_ready, + result); +} + +/** + * mm_manager_set_logging_sync: + * @manager: A #MMManager. + * @level: the login level to set. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously requests to set the specified logging level in the daemon.. + * + * The calling thread is blocked until a reply is received. + * + * See mm_manager_set_logging() for the asynchronous version of this method. + * + * Returns: %TRUE if the call succeded, %FALSE if @error is set. + */ +gboolean +mm_manager_set_logging_sync (MMManager *manager, + const gchar *level, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_MANAGER (manager), FALSE); + + if (!ensure_modem_manager1_proxy (manager, error)) + return FALSE; + + return (mm_gdbus_org_freedesktop_modem_manager1_call_set_logging_sync ( + manager->priv->manager_iface_proxy, + level, + cancellable, + error)); +} + +/*****************************************************************************/ + +/** + * mm_manager_scan_devices_finish: + * @manager: A #MMManager. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_manager_scan_devices(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_manager_scan_devices(). + * + * Returns: %TRUE if the call succeded, %FALSE if @error is set. + */ +gboolean +mm_manager_scan_devices_finish (MMManager *manager, + GAsyncResult *res, + GError **error) +{ + return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error); +} + +static void +scan_devices_ready (MmGdbusOrgFreedesktopModemManager1 *manager_iface_proxy, + GAsyncResult *res, + GSimpleAsyncResult *simple) +{ + GError *error = NULL; + + if (mm_gdbus_org_freedesktop_modem_manager1_call_scan_devices_finish ( + manager_iface_proxy, + res, + &error)) + g_simple_async_result_take_error (simple, error); + else + g_simple_async_result_set_op_res_gboolean (simple, TRUE); + + g_simple_async_result_complete (simple); + g_object_unref (simple); +} + +/** + * mm_manager_scan_devices: + * @manager: A #MMManager. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously requests to scan looking for devices. + * + * When the operation is finished, @callback will be invoked in the + * <link linkend="g-main-context-push-thread-default">thread-default main loop</link> + * of the thread you are calling this method from. You can then call + * mm_manager_scan_devices_finish() to get the result of the operation. + * + * See mm_manager_scan_devices_sync() for the synchronous, blocking version of this method. + */ +void +mm_manager_scan_devices (MMManager *manager, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GSimpleAsyncResult *result; + GError *inner_error = NULL; + + g_return_if_fail (MM_IS_MANAGER (manager)); + + result = g_simple_async_result_new (G_OBJECT (manager), + callback, + user_data, + mm_manager_scan_devices); + + if (!ensure_modem_manager1_proxy (manager, &inner_error)) { + g_simple_async_result_take_error (result, inner_error); + g_simple_async_result_complete_in_idle (result); + g_object_unref (result); + return; + } + + mm_gdbus_org_freedesktop_modem_manager1_call_scan_devices ( + manager->priv->manager_iface_proxy, + cancellable, + (GAsyncReadyCallback)scan_devices_ready, + result); +} + +/** + * mm_manager_scan_devices_sync: + * @manager: A #MMManager. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously requests to scan looking for devices. + * + * The calling thread is blocked until a reply is received. + * + * See mm_manager_scan_devices() for the asynchronous version of this method. + * + * Returns: %TRUE if the call succeded, %FALSE if @error is set. + */ +gboolean +mm_manager_scan_devices_sync (MMManager *manager, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_MANAGER (manager), FALSE); + + if (!ensure_modem_manager1_proxy (manager, error)) + return FALSE; + + return (mm_gdbus_org_freedesktop_modem_manager1_call_scan_devices_sync ( + manager->priv->manager_iface_proxy, + cancellable, + error)); +} + +/*****************************************************************************/ + +static void +register_dbus_errors (void) +{ + static volatile guint32 aux = 0; + + if (aux) + return; + + /* Register all known own errors */ + aux |= MM_CORE_ERROR; + aux |= MM_MOBILE_EQUIPMENT_ERROR; + aux |= MM_CONNECTION_ERROR; + aux |= MM_SERIAL_ERROR; + aux |= MM_MESSAGE_ERROR; + aux |= MM_CDMA_ACTIVATION_ERROR; +} + +static void +mm_manager_init (MMManager *manager) +{ + register_dbus_errors (); + + /* Setup private data */ + manager->priv = G_TYPE_INSTANCE_GET_PRIVATE ((manager), + MM_TYPE_MANAGER, + MMManagerPrivate); +} + +static void +dispose (GObject *object) +{ + MMManager *self = MM_MANAGER (object); + + g_clear_object (&self->priv->manager_iface_proxy); + + G_OBJECT_CLASS (mm_manager_parent_class)->dispose (object); +} + +static void +mm_manager_class_init (MMManagerClass *manager_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (manager_class); + + g_type_class_add_private (object_class, sizeof (MMManagerPrivate)); + + /* Virtual methods */ + object_class->dispose = dispose; +} diff --git a/libmm-glib/mm-manager.h b/libmm-glib/mm-manager.h new file mode 100644 index 0000000..96c3066 --- /dev/null +++ b/libmm-glib/mm-manager.h @@ -0,0 +1,113 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2011 - 2012 Aleksander Morgado <aleksander@gnu.org> + * Copyright (C) 2011 - 2012 Google, Inc. + * + * Author: Aleksander Morgado <aleksander@lanedo.com> + */ + +#ifndef _MM_MANAGER_H_ +#define _MM_MANAGER_H_ + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> + +#include "mm-gdbus-modem.h" + +G_BEGIN_DECLS + +#define MM_TYPE_MANAGER (mm_manager_get_type ()) +#define MM_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_MANAGER, MMManager)) +#define MM_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_MANAGER, MMManagerClass)) +#define MM_IS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_MANAGER)) +#define MM_IS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), MM_TYPE_MANAGER)) +#define MM_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_MANAGER, MMManagerClass)) + +typedef struct _MMManager MMManager; +typedef struct _MMManagerClass MMManagerClass; +typedef struct _MMManagerPrivate MMManagerPrivate; + +/** + * MMManager: + * + * The #MMManager structure contains private data and should only be accessed + * using the provided API. + */ +struct _MMManager { + /*< private >*/ + MmGdbusObjectManagerClient parent; + MMManagerPrivate *priv; +}; + +struct _MMManagerClass { + /*< private >*/ + MmGdbusObjectManagerClientClass parent; +}; + +GType mm_manager_get_type (void); + +void mm_manager_new ( + GDBusConnection *connection, + GDBusObjectManagerClientFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MMManager *mm_manager_new_finish ( + GAsyncResult *res, + GError **error); +MMManager *mm_manager_new_sync ( + GDBusConnection *connection, + GDBusObjectManagerClientFlags flags, + GCancellable *cancellable, + GError **error); + +GDBusProxy *mm_manager_peek_proxy (MMManager *manager); +GDBusProxy *mm_manager_get_proxy (MMManager *manager); + +void mm_manager_set_logging (MMManager *manager, + const gchar *level, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_manager_set_logging_finish (MMManager *manager, + GAsyncResult *res, + GError **error); +gboolean mm_manager_set_logging_sync (MMManager *manager, + const gchar *level, + GCancellable *cancellable, + GError **error); + +void mm_manager_scan_devices (MMManager *manager, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_manager_scan_devices_finish (MMManager *manager, + GAsyncResult *res, + GError **error); +gboolean mm_manager_scan_devices_sync (MMManager *manager, + GCancellable *cancellable, + GError **error); + +G_END_DECLS + +#endif /* _MM_MANAGER_H_ */ diff --git a/libmm-glib/mm-modem-3gpp-ussd.c b/libmm-glib/mm-modem-3gpp-ussd.c new file mode 100644 index 0000000..f77a7f7 --- /dev/null +++ b/libmm-glib/mm-modem-3gpp-ussd.c @@ -0,0 +1,439 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2011 - 2012 Aleksander Morgado <aleksander@gnu.org> + * Copyright (C) 2012 Google, Inc. + */ + +#include <gio/gio.h> + +#include "mm-helpers.h" +#include "mm-errors-types.h" +#include "mm-modem-3gpp-ussd.h" + +/** + * SECTION: mm-modem-3gpp-ussd + * @title: MMModem3gppUssd + * @short_description: The 3GPP USSD interface + * + * The #MMModem3gppUssd is an object providing access to the methods, signals and + * properties of the 3GPP USSD interface. + * + * This interface is only exposed when the 3GPP modem is known to handle USSD operations. + */ + +G_DEFINE_TYPE (MMModem3gppUssd, mm_modem_3gpp_ussd, MM_GDBUS_TYPE_MODEM3GPP_USSD_PROXY) + +/*****************************************************************************/ + +/** + * mm_modem_3gpp_ussd_get_path: + * @self: A #MMModem3gppUssd. + * + * Gets the DBus path of the #MMObject which implements this interface. + * + * Returns: (transfer none): The DBus path of the #MMObject object. + */ +const gchar * +mm_modem_3gpp_ussd_get_path (MMModem3gppUssd *self) +{ + g_return_val_if_fail (MM_IS_MODEM_3GPP_USSD (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + g_dbus_proxy_get_object_path (G_DBUS_PROXY (self))); +} + +/** + * mm_modem_3gpp_ussd_dup_path: + * @self: A #MMModem3gppUssd. + * + * Gets a copy of the DBus path of the #MMObject object which implements this interface. + * + * Returns: (transfer full): The DBus path of the #MMObject. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_3gpp_ussd_dup_path (MMModem3gppUssd *self) +{ + gchar *value; + + g_return_val_if_fail (MM_IS_MODEM_3GPP_USSD (self), NULL); + + g_object_get (G_OBJECT (self), + "g-object-path", &value, + NULL); + RETURN_NON_EMPTY_STRING (value); +} + +/*****************************************************************************/ + +/** + * mm_modem_3gpp_ussd_get_network_request: + * @self: A #MMModem3gppUssd. + * + * Gets any pending network-initiated request. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_modem_3gpp_ussd_dup_network_request() if on another + * thread.</warning> + * + * Returns: (transfer none): The network request, or %NULL if none available. + */ +const gchar * +mm_modem_3gpp_ussd_get_network_request (MMModem3gppUssd *self) +{ + g_return_val_if_fail (MM_IS_MODEM_3GPP_USSD (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_modem3gpp_ussd_get_network_request (MM_GDBUS_MODEM3GPP_USSD (self))); +} + +/** + * mm_modem_3gpp_ussd_dup_network_request: + * @self: A #MMModem3gppUssd. + * + * Gets a copy of any pending network-initiated request. + * + * Returns: (transfer full): The network request, or %NULL if none available. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_3gpp_ussd_dup_network_request (MMModem3gppUssd *self) +{ + g_return_val_if_fail (MM_IS_MODEM_3GPP_USSD (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_modem3gpp_ussd_dup_network_request (MM_GDBUS_MODEM3GPP_USSD (self))); +} + +/*****************************************************************************/ + +/** + * mm_modem_3gpp_ussd_get_network_notification: + * @self: A #MMModem3gppUssd. + * + * Gets any pending network-initiated request to which no USSD response is required. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_modem_3gpp_ussd_dup_network_notification() if on another + * thread.</warning> + * + * Returns: (transfer none): The network notification, or %NULL if none available. + */ +const gchar * +mm_modem_3gpp_ussd_get_network_notification (MMModem3gppUssd *self) +{ + g_return_val_if_fail (MM_IS_MODEM_3GPP_USSD (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_modem3gpp_ussd_get_network_notification (MM_GDBUS_MODEM3GPP_USSD (self))); +} + +/** + * mm_modem_3gpp_ussd_dup_network_notification: + * @self: A #MMModem3gppUssd. + * + * Gets a copy of any pending network-initiated request to which no USSD response is required. + * + * Returns: (transfer full): The network notification, or %NULL if none available. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_3gpp_ussd_dup_network_notification (MMModem3gppUssd *self) +{ + g_return_val_if_fail (MM_IS_MODEM_3GPP_USSD (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_modem3gpp_ussd_dup_network_notification (MM_GDBUS_MODEM3GPP_USSD (self))); +} + +/*****************************************************************************/ + +/** + * mm_modem_3gpp_ussd_get_state: + * @self: A #MMModem. + * + * Get the state of the ongoing USSD session, if any. + * + * Returns: A #MMModem3gppUssdSessionState value, specifying the current state. + */ +MMModem3gppUssdSessionState +mm_modem_3gpp_ussd_get_state (MMModem3gppUssd *self) +{ + g_return_val_if_fail (MM_IS_MODEM_3GPP_USSD (self), MM_MODEM_3GPP_USSD_SESSION_STATE_UNKNOWN); + + return mm_gdbus_modem3gpp_ussd_get_state (MM_GDBUS_MODEM3GPP_USSD (self)); +} + +/*****************************************************************************/ + +/** + * mm_modem_3gpp_ussd_initiate_finish: + * @self: A #MMModem3gppUssd. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_3gpp_ussd_initiate(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_3gpp_ussd_initiate(). + * + * Returns: The response from the network, if any. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_3gpp_ussd_initiate_finish (MMModem3gppUssd *self, + GAsyncResult *res, + GError **error) +{ + gchar *reply = NULL; + + g_return_val_if_fail (MM_IS_MODEM_3GPP_USSD (self), NULL); + + mm_gdbus_modem3gpp_ussd_call_initiate_finish (MM_GDBUS_MODEM3GPP_USSD (self), &reply, res, error); + + return reply; +} + +/** + * mm_modem_3gpp_ussd_initiate: + * @self: A #MMModem3gppUssd. + * @command: The command to start the USSD session with. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously sends a USSD command string to the network initiating a USSD session. + * + * When the request is handled by the network, the method returns the + * response or an appropriate error. The network may be awaiting further + * response from the ME after returning from this method and no new command. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_3gpp_ussd_initiate_finish() to get the result of the operation. + * + * See mm_modem_3gpp_ussd_initiate_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_3gpp_ussd_initiate (MMModem3gppUssd *self, + const gchar *command, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM_3GPP_USSD (self)); + + mm_gdbus_modem3gpp_ussd_call_initiate (MM_GDBUS_MODEM3GPP_USSD (self), command, cancellable, callback, user_data); +} + +/** + * mm_modem_3gpp_ussd_initiate_sync: + * @self: A #MMModem3gppUssd. + * @command: The command to start the USSD session with. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously sends a USSD command string to the network initiating a USSD session. + * + * When the request is handled by the network, the method returns the + * response or an appropriate error. The network may be awaiting further + * response from the ME after returning from this method and no new command. + * + * The calling thread is blocked until a reply is received. See mm_modem_3gpp_ussd_initiate() + * for the asynchronous version of this method. + * + * Returns: The response from the network, if any. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_3gpp_ussd_initiate_sync (MMModem3gppUssd *self, + const gchar *command, + GCancellable *cancellable, + GError **error) +{ + gchar *reply = NULL; + + g_return_val_if_fail (MM_IS_MODEM_3GPP_USSD (self), NULL); + + mm_gdbus_modem3gpp_ussd_call_initiate_sync (MM_GDBUS_MODEM3GPP_USSD (self), command, &reply, cancellable, error); + + return reply; +} + +/*****************************************************************************/ + +/** + * mm_modem_3gpp_ussd_respond_finish: + * @self: A #MMModem3gppUssd. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_3gpp_ussd_respond(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_3gpp_ussd_respond(). + * + * Returns: The network reply to this response to the network-initiated USSD command. The reply may require further responses. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_3gpp_ussd_respond_finish (MMModem3gppUssd *self, + GAsyncResult *res, + GError **error) +{ + gchar *reply = NULL; + + g_return_val_if_fail (MM_IS_MODEM_3GPP_USSD (self), NULL); + + mm_gdbus_modem3gpp_ussd_call_respond_finish (MM_GDBUS_MODEM3GPP_USSD (self), &reply, res, error); + + return reply; +} + +/** + * mm_modem_3gpp_ussd_respond: + * @self: A #MMModem3gppUssd. + * @response: The response to network-initiated USSD command, or a response to a request for further input. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously responds to a USSD request that is either initiated by the + * mobile network, or that is awaiting further input after a previous call to + * mm_modem_3gpp_ussd_initiate(). + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_3gpp_ussd_respond_finish() to get the result of the operation. + * + * See mm_modem_3gpp_ussd_respond_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_3gpp_ussd_respond (MMModem3gppUssd *self, + const gchar *response, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM_3GPP_USSD (self)); + + mm_gdbus_modem3gpp_ussd_call_respond (MM_GDBUS_MODEM3GPP_USSD (self), response, cancellable, callback, user_data); +} + +/** + * mm_modem_3gpp_ussd_respond_sync: + * @self: A #MMModem3gppUssd. + * @response: The response to network-initiated USSD command, or a response to a request for further input. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously responds to a USSD request that is either initiated by the + * mobile network, or that is awaiting further input after a previous call to + * mm_modem_3gpp_ussd_initiate(). + * + * The calling thread is blocked until a reply is received. See mm_modem_3gpp_ussd_respond() + * for the asynchronous version of this method. + * + * Returns: The network reply to this response to the network-initiated USSD command. The reply may require further responses. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_3gpp_ussd_respond_sync (MMModem3gppUssd *self, + const gchar *response, + GCancellable *cancellable, + GError **error) +{ + gchar *reply = NULL; + + g_return_val_if_fail (MM_IS_MODEM_3GPP_USSD (self), NULL); + + mm_gdbus_modem3gpp_ussd_call_respond_sync (MM_GDBUS_MODEM3GPP_USSD (self), response, &reply, cancellable, error); + + return reply; +} + +/*****************************************************************************/ + +/** + * mm_modem_3gpp_ussd_cancel_finish: + * @self: A #MMModem3gppUssd. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_3gpp_ussd_cancel(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_3gpp_ussd_cancel(). + * + * Returns: %TRUE if the session was successfully cancelled, %FALSE if @error is set. + */ +gboolean +mm_modem_3gpp_ussd_cancel_finish (MMModem3gppUssd *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM_3GPP_USSD (self), FALSE); + + return mm_gdbus_modem3gpp_ussd_call_cancel_finish (MM_GDBUS_MODEM3GPP_USSD (self), res, error); +} + +/** + * mm_modem_3gpp_ussd_cancel: + * @self: A #MMModem3gppUssd. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously cancels an ongoing USSD session, either mobile or network initiated. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_3gpp_ussd_cancel_finish() to get the result of the operation. + * + * See mm_modem_3gpp_ussd_cancel_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_3gpp_ussd_cancel (MMModem3gppUssd *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM_3GPP_USSD (self)); + + mm_gdbus_modem3gpp_ussd_call_cancel (MM_GDBUS_MODEM3GPP_USSD (self), cancellable, callback, user_data); +} + +/** + * mm_modem_3gpp_ussd_cancel_sync: + * @self: A #MMModem3gppUssd. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously cancels an ongoing USSD session, either mobile or network initiated. + * + * The calling thread is blocked until a reply is received. See mm_modem_3gpp_ussd_cancel() + * for the asynchronous version of this method. + * + * Returns: %TRUE if the session was successfully cancelled, %FALSE if @error is set. + */ +gboolean +mm_modem_3gpp_ussd_cancel_sync (MMModem3gppUssd *self, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM_3GPP_USSD (self), FALSE); + + return mm_gdbus_modem3gpp_ussd_call_cancel_sync (MM_GDBUS_MODEM3GPP_USSD (self), cancellable, error); +} + +/*****************************************************************************/ + +static void +mm_modem_3gpp_ussd_init (MMModem3gppUssd *self) +{ +} + +static void +mm_modem_3gpp_ussd_class_init (MMModem3gppUssdClass *modem_class) +{ +} diff --git a/libmm-glib/mm-modem-3gpp-ussd.h b/libmm-glib/mm-modem-3gpp-ussd.h new file mode 100644 index 0000000..ee7522a --- /dev/null +++ b/libmm-glib/mm-modem-3gpp-ussd.h @@ -0,0 +1,116 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2011 - 2012 Aleksander Morgado <aleksander@gnu.org> + * Copyright (C) 2012 Google, Inc. + */ + +#ifndef _MM_MODEM_3GPP_USSD_H_ +#define _MM_MODEM_3GPP_USSD_H_ + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> + +#include "mm-gdbus-modem.h" + +G_BEGIN_DECLS + +#define MM_TYPE_MODEM_3GPP_USSD (mm_modem_3gpp_ussd_get_type ()) +#define MM_MODEM_3GPP_USSD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_MODEM_3GPP_USSD, MMModem3gppUssd)) +#define MM_MODEM_3GPP_USSD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_MODEM_3GPP_USSD, MMModem3gppUssdClass)) +#define MM_IS_MODEM_3GPP_USSD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_MODEM_3GPP_USSD)) +#define MM_IS_MODEM_3GPP_USSD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), MM_TYPE_MODEM_3GPP_USSD)) +#define MM_MODEM_3GPP_USSD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_MODEM_3GPP_USSD, MMModem3gppUssdClass)) + +typedef struct _MMModem3gppUssd MMModem3gppUssd; +typedef struct _MMModem3gppUssdClass MMModem3gppUssdClass; + +/** + * MMModem3gppUssd: + * + * The #MMModem3gppUssd structure contains private data and should only be accessed + * using the provided API. + */ +struct _MMModem3gppUssd { + /*< private >*/ + MmGdbusModem3gppUssdProxy parent; + gpointer unused; +}; + +struct _MMModem3gppUssdClass { + /*< private >*/ + MmGdbusModem3gppUssdProxyClass parent; +}; + +GType mm_modem_3gpp_ussd_get_type (void); + +const gchar *mm_modem_3gpp_ussd_get_path (MMModem3gppUssd *self); +gchar *mm_modem_3gpp_ussd_dup_path (MMModem3gppUssd *self); + +MMModem3gppUssdSessionState mm_modem_3gpp_ussd_get_state (MMModem3gppUssd *self); + +const gchar *mm_modem_3gpp_ussd_get_network_notification (MMModem3gppUssd *self); +gchar *mm_modem_3gpp_ussd_dup_network_notification (MMModem3gppUssd *self); + +const gchar *mm_modem_3gpp_ussd_get_network_request (MMModem3gppUssd *self); +gchar *mm_modem_3gpp_ussd_dup_network_request (MMModem3gppUssd *self); + +void mm_modem_3gpp_ussd_initiate (MMModem3gppUssd *self, + const gchar *command, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gchar *mm_modem_3gpp_ussd_initiate_finish (MMModem3gppUssd *self, + GAsyncResult *res, + GError **error); +gchar *mm_modem_3gpp_ussd_initiate_sync (MMModem3gppUssd *self, + const gchar *command, + GCancellable *cancellable, + GError **error); + +void mm_modem_3gpp_ussd_respond (MMModem3gppUssd *self, + const gchar *response, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gchar *mm_modem_3gpp_ussd_respond_finish (MMModem3gppUssd *self, + GAsyncResult *res, + GError **error); +gchar *mm_modem_3gpp_ussd_respond_sync (MMModem3gppUssd *self, + const gchar *response, + GCancellable *cancellable, + GError **error); + +void mm_modem_3gpp_ussd_cancel (MMModem3gppUssd *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_modem_3gpp_ussd_cancel_finish (MMModem3gppUssd *self, + GAsyncResult *res, + GError **error); +gboolean mm_modem_3gpp_ussd_cancel_sync (MMModem3gppUssd *self, + GCancellable *cancellable, + GError **error); + +G_END_DECLS + +#endif /* _MM_MODEM_3GPP_USSD_H_ */ diff --git a/libmm-glib/mm-modem-3gpp.c b/libmm-glib/mm-modem-3gpp.c new file mode 100644 index 0000000..40c7e86 --- /dev/null +++ b/libmm-glib/mm-modem-3gpp.c @@ -0,0 +1,582 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2011 - 2012 Aleksander Morgado <aleksander@gnu.org> + * Copyright (C) 2012 Google, Inc. + */ + +#include <gio/gio.h> + +#include "mm-helpers.h" +#include "mm-errors-types.h" +#include "mm-modem-3gpp.h" + +/** + * SECTION: mm-modem-3gpp + * @title: MMModem3gpp + * @short_description: The 3GPP interface + * + * The #MMModem3gpp is an object providing access to the methods, signals and + * properties of the 3GPP interface. + * + * The 3GPP interface is exposed whenever a modem has any of the 3GPP + * capabilities (%MM_MODEM_CAPABILITY_GSM_UMTS, %MM_MODEM_CAPABILITY_LTE or %MM_MODEM_CAPABILITY_LTE_ADVANCED). + */ + +G_DEFINE_TYPE (MMModem3gpp, mm_modem_3gpp, MM_GDBUS_TYPE_MODEM3GPP_PROXY) + +/*****************************************************************************/ + +/** + * mm_modem_3gpp_get_path: + * @self: A #MMModem3gpp. + * + * Gets the DBus path of the #MMObject which implements this interface. + * + * Returns: (transfer none): The DBus path of the #MMObject object. + */ +const gchar * +mm_modem_3gpp_get_path (MMModem3gpp *self) +{ + g_return_val_if_fail (MM_IS_MODEM_3GPP (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + g_dbus_proxy_get_object_path (G_DBUS_PROXY (self))); +} + +/** + * mm_modem_3gpp_dup_path: + * @self: A #MMModem3gpp. + * + * Gets a copy of the DBus path of the #MMObject object which implements this interface. + * + * Returns: (transfer full): The DBus path of the #MMObject. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_3gpp_dup_path (MMModem3gpp *self) +{ + gchar *value; + + g_return_val_if_fail (MM_IS_MODEM_3GPP (self), NULL); + + g_object_get (G_OBJECT (self), + "g-object-path", &value, + NULL); + RETURN_NON_EMPTY_STRING (value); +} + +/*****************************************************************************/ + +/** + * mm_modem_3gpp_get_imei: + * @self: A #MMModem3gpp. + * + * Gets the <ulink url="http://en.wikipedia.org/wiki/Imei">IMEI</ulink>, + * as reported by this #MMModem3gpp. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_modem_3gpp_dup_imei() if on another + * thread.</warning> + * + * Returns: (transfer none): The IMEI, or %NULL if none available. + */ +const gchar * +mm_modem_3gpp_get_imei (MMModem3gpp *self) +{ + g_return_val_if_fail (MM_IS_MODEM_3GPP (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_modem3gpp_get_imei (MM_GDBUS_MODEM3GPP (self))); +} + +/** + * mm_modem_3gpp_dup_imei: + * @self: A #MMModem3gpp. + * + * Gets a copy of the <ulink url="http://en.wikipedia.org/wiki/Imei">IMEI</ulink>, + * as reported by this #MMModem3gpp. + * + * Returns: (transfer full): The IMEI, or %NULL if none available. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_3gpp_dup_imei (MMModem3gpp *self) +{ + g_return_val_if_fail (MM_IS_MODEM_3GPP (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_modem3gpp_dup_imei (MM_GDBUS_MODEM3GPP (self))); +} + +/*****************************************************************************/ + +/** + * mm_modem_3gpp_get_operator_code: + * @self: A #MMModem3gpp. + * + * Gets the code of the operator to which the mobile is + * currently registered. + * + * Returned in the format <literal>"MCCMNC"</literal>, where + * <literal>MCC</literal> is the three-digit ITU E.212 Mobile Country Code + * and <literal>MNC</literal> is the two- or three-digit GSM Mobile Network + * Code. e.g. e<literal>"31026"</literal> or <literal>"310260"</literal>. + * + * If the <literal>MCC</literal> and <literal>MNC</literal> are not known + * or the mobile is not registered to a mobile network, this property will + * be a zero-length (blank) string. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_modem_3gpp_dup_operator_code() if on another + * thread.</warning> + * + * Returns: (transfer none): The operator code, or %NULL if none available. + */ +const gchar * +mm_modem_3gpp_get_operator_code (MMModem3gpp *self) +{ + g_return_val_if_fail (MM_IS_MODEM_3GPP (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_modem3gpp_get_operator_code (MM_GDBUS_MODEM3GPP (self))); +} + +/** + * mm_modem_3gpp_dup_operator_code: + * @self: A #MMModem3gpp. + * + * Gets a copy of the code of the operator to which the mobile is + * currently registered. + * + * Returned in the format <literal>"MCCMNC"</literal>, where + * <literal>MCC</literal> is the three-digit ITU E.212 Mobile Country Code + * and <literal>MNC</literal> is the two- or three-digit GSM Mobile Network + * Code. e.g. e<literal>"31026"</literal> or <literal>"310260"</literal>. + * + * Returns: (transfer full): The operator code, or %NULL if none available. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_3gpp_dup_operator_code (MMModem3gpp *self) +{ + g_return_val_if_fail (MM_IS_MODEM_3GPP (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_modem3gpp_dup_operator_code (MM_GDBUS_MODEM3GPP (self))); +} + +/*****************************************************************************/ + +/** + * mm_modem_3gpp_get_operator_name: + * @self: A #MMModem3gpp. + * + * Gets the name of the operator to which the mobile is + * currently registered. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_modem_3gpp_dup_operator_name() if on another + * thread.</warning> + * + * Returns: (transfer none): The operator name, or %NULL if none available. + */ +const gchar * +mm_modem_3gpp_get_operator_name (MMModem3gpp *self) +{ + g_return_val_if_fail (MM_IS_MODEM_3GPP (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_modem3gpp_get_operator_name (MM_GDBUS_MODEM3GPP (self))); +} + +/** + * mm_modem_3gpp_dup_operator_name: + * @self: A #MMModem3gpp. + * + * Gets a copy of the name of the operator to which the mobile is + * currently registered. + * + * Returns: (transfer full): The operator name, or %NULL if none available. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_3gpp_dup_operator_name (MMModem3gpp *self) +{ + g_return_val_if_fail (MM_IS_MODEM_3GPP (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_modem3gpp_dup_operator_name (MM_GDBUS_MODEM3GPP (self))); +} + +/*****************************************************************************/ + +/** + * mm_modem_3gpp_get_registration_state: + * @self: A #MMModem. + * + * Get the the mobile registration status as defined in 3GPP TS 27.007 + * section 10.1.19. + * + * Returns: A #MMModem3gppRegistrationState value, specifying the current registration state. + */ +MMModem3gppRegistrationState +mm_modem_3gpp_get_registration_state (MMModem3gpp *self) +{ + g_return_val_if_fail (MM_IS_MODEM_3GPP (self), MM_MODEM_3GPP_REGISTRATION_STATE_IDLE); + + return mm_gdbus_modem3gpp_get_registration_state (MM_GDBUS_MODEM3GPP (self)); +} + +/*****************************************************************************/ + +/** + * mm_modem_3gpp_get_enabled_facility_locks: + * @self: A #MMModem3gpp. + * + * Get the list of facilities for which PIN locking is enabled. + * + * Returns: A bitmask of #MMModem3gppFacility flags, specifying which facilities have locks enabled. + */ +MMModem3gppFacility +mm_modem_3gpp_get_enabled_facility_locks (MMModem3gpp *self) +{ + g_return_val_if_fail (MM_IS_MODEM_3GPP (self), MM_MODEM_3GPP_FACILITY_NONE); + + return mm_gdbus_modem3gpp_get_enabled_facility_locks (MM_GDBUS_MODEM3GPP (self)); +} + +/*****************************************************************************/ + +/** + * mm_modem_3gpp_register_finish: + * @self: A #MMModem3gpp. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_3gpp_register(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_3gpp_register(). + * + * Returns: %TRUE if the modem was registered, %FALSE if @error is set. + */ +gboolean +mm_modem_3gpp_register_finish (MMModem3gpp *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM_3GPP (self), FALSE); + + return mm_gdbus_modem3gpp_call_register_finish (MM_GDBUS_MODEM3GPP (self), res, error); +} + +/** + * mm_modem_3gpp_register: + * @self: A #MMModem3gpp. + * @network_id: The operator ID to register. An empty string can be used to register to the home network. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously requests registration with a given mobile network. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_3gpp_register_finish() to get the result of the operation. + * + * See mm_modem_3gpp_register_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_3gpp_register (MMModem3gpp *self, + const gchar *network_id, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM_3GPP (self)); + + mm_gdbus_modem3gpp_call_register (MM_GDBUS_MODEM3GPP (self), network_id, cancellable, callback, user_data); +} + +/** + * mm_modem_3gpp_register_sync: + * @self: A #MMModem3gpp. + * @network_id: The operator ID to register. An empty string can be used to register to the home network. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously requests registration with a given mobile network. + * + * The calling thread is blocked until a reply is received. See mm_modem_3gpp_register() + * for the asynchronous version of this method. + * + * Returns: %TRUE if the modem was registered, %FALSE if @error is set. + */ +gboolean +mm_modem_3gpp_register_sync (MMModem3gpp *self, + const gchar *network_id, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM_3GPP (self), FALSE); + + return mm_gdbus_modem3gpp_call_register_sync (MM_GDBUS_MODEM3GPP (self), network_id, cancellable, error); +} + +/*****************************************************************************/ + +struct _MMModem3gppNetwork { + MMModem3gppNetworkAvailability availability; + gchar *operator_long; + gchar *operator_short; + gchar *operator_code; + MMModemAccessTechnology access_technology; +}; + +/** + * mm_modem_3gpp_network_free: + * @network: A #MMModem3gppNetwork. + * + * Frees a #MMModem3gppNetwork. + */ +void +mm_modem_3gpp_network_free (MMModem3gppNetwork *network) +{ + if (!network) + return; + + g_free (network->operator_long); + g_free (network->operator_short); + g_free (network->operator_code); + g_slice_free (MMModem3gppNetwork, network); +} + +/** + * mm_modem_3gpp_network_get_availability: + * @network: A #MMModem3gppNetwork. + * + * Get availability of the 3GPP network. + * + * Returns: A #MMModem3gppNetworkAvailability. + */ +MMModem3gppNetworkAvailability +mm_modem_3gpp_network_get_availability (const MMModem3gppNetwork *network) +{ + g_return_val_if_fail (network != NULL, MM_MODEM_3GPP_NETWORK_AVAILABILITY_UNKNOWN); + + return network->availability; +} + +/** + * mm_modem_3gpp_network_get_operator_long: + * @network: A #MMModem3gppNetwork. + * + * Get the long operator name of the 3GPP network. + * + * Returns: (transfer none): The long operator name, or %NULL if none available. + */ +const gchar * +mm_modem_3gpp_network_get_operator_long (const MMModem3gppNetwork *network) +{ + g_return_val_if_fail (network != NULL, NULL); + + return network->operator_long; +} + +/** + * mm_modem_3gpp_network_get_operator_short: + * @network: A #MMModem3gppNetwork. + * + * Get the short operator name of the 3GPP network. + * + * Returns: (transfer none): The long operator name, or %NULL if none available. + */ +const gchar * +mm_modem_3gpp_network_get_operator_short (const MMModem3gppNetwork *network) +{ + g_return_val_if_fail (network != NULL, NULL); + + return network->operator_short; +} + +/** + * mm_modem_3gpp_network_get_operator_code: + * @network: A #MMModem3gppNetwork. + * + * Get the operator code (MCCMNC) of the 3GPP network. + * + * Returns: (transfer none): The operator code, or %NULL if none available. + */ +const gchar * +mm_modem_3gpp_network_get_operator_code (const MMModem3gppNetwork *network) +{ + g_return_val_if_fail (network != NULL, NULL); + + return network->operator_code; +} + +/** + * mm_modem_3gpp_network_get_access_technology: + * @network: A #MMModem3gppNetwork. + * + * Get the technology used to access the 3GPP network. + * + * Returns: A #MMModemAccessTechnology. + */ +MMModemAccessTechnology +mm_modem_3gpp_network_get_access_technology (const MMModem3gppNetwork *network) +{ + g_return_val_if_fail (network != NULL, MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN); + + return network->access_technology; +} + +/*****************************************************************************/ + +static GList * +create_networks_list (GVariant *variant) +{ + GList *list = NULL; + GVariantIter dict_iter; + GVariant *dict; + + /* Input is aa{sv} */ + g_variant_iter_init (&dict_iter, variant); + while ((dict = g_variant_iter_next_value (&dict_iter))) { + GVariantIter iter; + gchar *key; + GVariant *value; + MMModem3gppNetwork *network; + + network = g_slice_new0 (MMModem3gppNetwork); + + g_variant_iter_init (&iter, dict); + while (g_variant_iter_next (&iter, "{sv}", &key, &value)) { + if (g_str_equal (key, "status")) { + network->availability = (MMModem3gppNetworkAvailability)g_variant_get_uint32 (value); + } else if (g_str_equal (key, "operator-long")) { + g_warn_if_fail (network->operator_long == NULL); + network->operator_long = g_variant_dup_string (value, NULL); + } else if (g_str_equal (key, "operator-short")) { + g_warn_if_fail (network->operator_short == NULL); + network->operator_short = g_variant_dup_string (value, NULL); + } else if (g_str_equal (key, "operator-code")) { + g_warn_if_fail (network->operator_code == NULL); + network->operator_code = g_variant_dup_string (value, NULL); + } else if (g_str_equal (key, "access-technology")) { + network->access_technology = (MMModemAccessTechnology)g_variant_get_uint32 (value); + } else + g_warning ("Unexpected property '%s' found in Network info", key); + + g_free (key); + g_variant_unref (value); + } + + list = g_list_prepend (list, network); + g_variant_unref (dict); + } + + return list; +} + +/** + * mm_modem_3gpp_scan_finish: + * @self: A #MMModem3gpp. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_3gpp_scan(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_3gpp_scan(). + * + * Returns: a list of #MMModem3gppNetwork structs, or #NULL if @error is set. The returned value should be freed with g_list_free_full() using mm_modem_3gpp_network_free() as #GDestroyNotify function. + */ +GList * +mm_modem_3gpp_scan_finish (MMModem3gpp *self, + GAsyncResult *res, + GError **error) +{ + GVariant *result = NULL; + + g_return_val_if_fail (MM_IS_MODEM_3GPP (self), FALSE); + + if (!mm_gdbus_modem3gpp_call_scan_finish (MM_GDBUS_MODEM3GPP (self), &result, res, error)) + return NULL; + + return create_networks_list (result); +} + +/** + * mm_modem_3gpp_scan: + * @self: A #MMModem3gpp. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously requests to scan available 3GPP networks. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_3gpp_scan_finish() to get the result of the operation. + * + * See mm_modem_3gpp_scan_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_3gpp_scan (MMModem3gpp *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM_3GPP (self)); + + mm_gdbus_modem3gpp_call_scan (MM_GDBUS_MODEM3GPP (self), cancellable, callback, user_data); +} + +/** + * mm_modem_3gpp_scan_sync: + * @self: A #MMModem3gpp. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously requests to scan available 3GPP networks. + * + * The calling thread is blocked until a reply is received. See mm_modem_3gpp_scan() + * for the asynchronous version of this method. + * + * Returns: a list of #MMModem3gppNetwork structs, or #NULL if @error is set. The returned value should be freed with g_list_free_full() using mm_modem_3gpp_network_free() as #GDestroyNotify function. + */ +GList * +mm_modem_3gpp_scan_sync (MMModem3gpp *self, + GCancellable *cancellable, + GError **error) +{ + GVariant *result = NULL; + + g_return_val_if_fail (MM_IS_MODEM_3GPP (self), FALSE); + + if (!mm_gdbus_modem3gpp_call_scan_sync (MM_GDBUS_MODEM3GPP (self), &result,cancellable, error)) + return NULL; + + return create_networks_list (result); +} + +/*****************************************************************************/ + +static void +mm_modem_3gpp_init (MMModem3gpp *self) +{ +} + +static void +mm_modem_3gpp_class_init (MMModem3gppClass *modem_class) +{ +} diff --git a/libmm-glib/mm-modem-3gpp.h b/libmm-glib/mm-modem-3gpp.h new file mode 100644 index 0000000..bb055dc --- /dev/null +++ b/libmm-glib/mm-modem-3gpp.h @@ -0,0 +1,124 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2011 - 2012 Aleksander Morgado <aleksander@gnu.org> + * Copyright (C) 2012 Google, Inc. + */ + +#ifndef _MM_MODEM_3GPP_H_ +#define _MM_MODEM_3GPP_H_ + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> + +#include "mm-gdbus-modem.h" + +G_BEGIN_DECLS + +#define MM_TYPE_MODEM_3GPP (mm_modem_3gpp_get_type ()) +#define MM_MODEM_3GPP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_MODEM_3GPP, MMModem3gpp)) +#define MM_MODEM_3GPP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_MODEM_3GPP, MMModem3gppClass)) +#define MM_IS_MODEM_3GPP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_MODEM_3GPP)) +#define MM_IS_MODEM_3GPP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), MM_TYPE_MODEM_3GPP)) +#define MM_MODEM_3GPP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_MODEM_3GPP, MMModem3gppClass)) + +typedef struct _MMModem3gpp MMModem3gpp; +typedef struct _MMModem3gppClass MMModem3gppClass; + +/** + * MMModem3gpp: + * + * The #MMModem3gpp structure contains private data and should only be accessed + * using the provided API. + */ +struct _MMModem3gpp { + /*< private >*/ + MmGdbusModem3gppProxy parent; + gpointer unused; +}; + +struct _MMModem3gppClass { + /*< private >*/ + MmGdbusModem3gppProxyClass parent; +}; + +GType mm_modem_3gpp_get_type (void); + +const gchar *mm_modem_3gpp_get_path (MMModem3gpp *self); +gchar *mm_modem_3gpp_dup_path (MMModem3gpp *self); + +const gchar *mm_modem_3gpp_get_imei (MMModem3gpp *self); +gchar *mm_modem_3gpp_dup_imei (MMModem3gpp *self); + +const gchar *mm_modem_3gpp_get_operator_code (MMModem3gpp *self); +gchar *mm_modem_3gpp_dup_operator_code (MMModem3gpp *self); + +const gchar *mm_modem_3gpp_get_operator_name (MMModem3gpp *self); +gchar *mm_modem_3gpp_dup_operator_name (MMModem3gpp *self); + +MMModem3gppRegistrationState mm_modem_3gpp_get_registration_state (MMModem3gpp *self); + +MMModem3gppFacility mm_modem_3gpp_get_enabled_facility_locks (MMModem3gpp *self); + + +void mm_modem_3gpp_register (MMModem3gpp *self, + const gchar *network_id, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_modem_3gpp_register_finish (MMModem3gpp *self, + GAsyncResult *res, + GError **error); +gboolean mm_modem_3gpp_register_sync (MMModem3gpp *self, + const gchar *network_id, + GCancellable *cancellable, + GError **error); + +/** + * MMModem3gppNetwork: + * + * The #MMModem3gppNetwork structure contains private data and should only be accessed + * using the provided API. + */ +typedef struct _MMModem3gppNetwork MMModem3gppNetwork; + +MMModem3gppNetworkAvailability mm_modem_3gpp_network_get_availability (const MMModem3gppNetwork *network); +const gchar *mm_modem_3gpp_network_get_operator_long (const MMModem3gppNetwork *network); +const gchar *mm_modem_3gpp_network_get_operator_short (const MMModem3gppNetwork *network); +const gchar *mm_modem_3gpp_network_get_operator_code (const MMModem3gppNetwork *network); +MMModemAccessTechnology mm_modem_3gpp_network_get_access_technology (const MMModem3gppNetwork *network); +void mm_modem_3gpp_network_free (MMModem3gppNetwork *network); + +void mm_modem_3gpp_scan (MMModem3gpp *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GList *mm_modem_3gpp_scan_finish (MMModem3gpp *self, + GAsyncResult *res, + GError **error); +GList *mm_modem_3gpp_scan_sync (MMModem3gpp *self, + GCancellable *cancellable, + GError **error); + +G_END_DECLS + +#endif /* _MM_MODEM_3GPP_H_ */ diff --git a/libmm-glib/mm-modem-cdma.c b/libmm-glib/mm-modem-cdma.c new file mode 100644 index 0000000..6f042c0 --- /dev/null +++ b/libmm-glib/mm-modem-cdma.c @@ -0,0 +1,352 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2011 - 2012 Aleksander Morgado <aleksander@gnu.org> + * Copyright (C) 2012 Google, Inc. + */ + +#include <gio/gio.h> + +#include "mm-helpers.h" +#include "mm-errors-types.h" +#include "mm-modem-cdma.h" + +/** + * SECTION: mm-modem-cdma + * @title: MMModemCdma + * @short_description: The CDMA interface + * + * The #MMModemCdma is an object providing access to the methods, signals and + * properties of the CDMA interface. + * + * The CDMA interface is exposed whenever a modem has CDMA capabilities + * (%MM_MODEM_CAPABILITY_CDMA_EVDO). + */ + +G_DEFINE_TYPE (MMModemCdma, mm_modem_cdma, MM_GDBUS_TYPE_MODEM_CDMA_PROXY) + +/*****************************************************************************/ + +/** + * mm_modem_cdma_get_path: + * @self: A #MMModemCdma. + * + * Gets the DBus path of the #MMObject which implements this interface. + * + * Returns: (transfer none): The DBus path of the #MMObject object. + */ +const gchar * +mm_modem_cdma_get_path (MMModemCdma *self) +{ + g_return_val_if_fail (MM_IS_MODEM_CDMA (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + g_dbus_proxy_get_object_path (G_DBUS_PROXY (self))); +} + +/** + * mm_modem_cdma_dup_path: + * @self: A #MMModemCdma. + * + * Gets a copy of the DBus path of the #MMObject object which implements this interface. + * + * Returns: (transfer full): The DBus path of the #MMObject. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_cdma_dup_path (MMModemCdma *self) +{ + gchar *value; + + g_return_val_if_fail (MM_IS_MODEM_CDMA (self), NULL); + + g_object_get (G_OBJECT (self), + "g-object-path", &value, + NULL); + RETURN_NON_EMPTY_STRING (value); +} + +/*****************************************************************************/ + +/** + * mm_modem_cdma_get_meid: + * @self: A #MMModemCdma. + * + * Gets the <ulink url="http://en.wikipedia.org/wiki/MEID">Mobile Equipment Identifier</ulink>, + * as reported by this #MMModemCdma. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_modem_cdma_dup_meid() if on another + * thread.</warning> + * + * Returns: (transfer none): The MEID, or %NULL if none available. + */ +const gchar * +mm_modem_cdma_get_meid (MMModemCdma *self) +{ + g_return_val_if_fail (MM_IS_MODEM_CDMA (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_modem_cdma_get_meid (MM_GDBUS_MODEM_CDMA (self))); +} + +/** + * mm_modem_cdma_dup_meid: + * @self: A #MMModemCdma. + * + * Gets a copy of the <ulink url="http://en.wikipedia.org/wiki/MEID">Mobile Equipment Identifier</ulink>, + * as reported by this #MMModemCdma. + * + * Returns: (transfer full): The MEID, or %NULL if none available. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_cdma_dup_meid (MMModemCdma *self) +{ + g_return_val_if_fail (MM_IS_MODEM_CDMA (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_modem_cdma_dup_meid (MM_GDBUS_MODEM_CDMA (self))); +} + +/*****************************************************************************/ + +/** + * mm_modem_cdma_get_esn: + * @self: A #MMModemCdma. + * + * Gets the <ulink url="http://en.wikipedia.org/wiki/Electronic_serial_number">Electronic Serial Number</ulink>, + * as reported by this #MMModemCdma. + * + * The ESN is superceded by MEID, but still used in older devices. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_modem_cdma_dup_esn() if on another + * thread.</warning> + * + * Returns: (transfer none): The ESN, or %NULL if none available. + */ +const gchar * +mm_modem_cdma_get_esn (MMModemCdma *self) +{ + g_return_val_if_fail (MM_IS_MODEM_CDMA (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_modem_cdma_get_esn (MM_GDBUS_MODEM_CDMA (self))); +} + +/** + * mm_modem_cdma_dup_esn: + * @self: A #MMModemCdma. + * + * Gets a copy of the <ulink url="http://en.wikipedia.org/wiki/Electronic_serial_number">Electronic Serial Number</ulink>, + * as reported by this #MMModemCdma. + * + * The ESN is superceded by MEID, but still used in older devices. + * + * Returns: (transfer full): The ESN, or %NULL if none available. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_cdma_dup_esn (MMModemCdma *self) +{ + g_return_val_if_fail (MM_IS_MODEM_CDMA (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_modem_cdma_dup_esn (MM_GDBUS_MODEM_CDMA (self))); +} + +/*****************************************************************************/ + +/** + * mm_modem_cdma_get_sid: + * @self: A #MMModemCdma. + * + * Gets the <ulink url="http://en.wikipedia.org/wiki/System_Identification_Number">System Identifier</ulink> + * of the serving CDMA 1x network, if known, and if the modem is registered with + * a CDMA 1x network. + * + * Returns: The SID, or %MM_MODEM_CDMA_SID_UNKNOWN. + */ +guint +mm_modem_cdma_get_sid (MMModemCdma *self) +{ + g_return_val_if_fail (MM_IS_MODEM_CDMA (self), MM_MODEM_CDMA_SID_UNKNOWN); + + return mm_gdbus_modem_cdma_get_sid (MM_GDBUS_MODEM_CDMA (self)); +} + +/*****************************************************************************/ + +/** + * mm_modem_cdma_get_nid: + * @self: A #MMModemCdma. + * + * Gets the <ulink url="http://en.wikipedia.org/wiki/Network_Identification_Number">Network Identifier</ulink> + * of the serving CDMA 1x network, if known, and if the modem is registered with + * a CDMA 1x network. + * + * Returns: The NID, or %MM_MODEM_CDMA_NID_UNKNOWN. + */ +guint +mm_modem_cdma_get_nid (MMModemCdma *self) +{ + g_return_val_if_fail (MM_IS_MODEM_CDMA (self), MM_MODEM_CDMA_NID_UNKNOWN); + + return mm_gdbus_modem_cdma_get_nid (MM_GDBUS_MODEM_CDMA (self)); +} + +/*****************************************************************************/ + +/** + * mm_modem_cdma_get_cdma1x_registration_state: + * @self: A #MMModemCdma. + * + * Gets the state of the registration in the CDMA 1x network. + * + * Returns: a #MMModemCdmaRegistrationState. + */ +MMModemCdmaRegistrationState +mm_modem_cdma_get_cdma1x_registration_state (MMModemCdma *self) +{ + g_return_val_if_fail (MM_IS_MODEM_CDMA (self), MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN); + + return mm_gdbus_modem_cdma_get_cdma1x_registration_state (MM_GDBUS_MODEM_CDMA (self)); +} + +/** + * mm_modem_cdma_get_evdo_registration_state: + * @self: A #MMModemCdma. + * + * Gets the state of the registration in the EV-DO network. + * + * Returns: a #MMModemCdmaRegistrationState. + */ +MMModemCdmaRegistrationState +mm_modem_cdma_get_evdo_registration_state (MMModemCdma *self) +{ + g_return_val_if_fail (MM_IS_MODEM_CDMA (self), MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN); + + return mm_gdbus_modem_cdma_get_evdo_registration_state (MM_GDBUS_MODEM_CDMA (self)); +} + +/*****************************************************************************/ + +/** + * mm_modem_cdma_get_activation_state: + * @self: A #MMModemCdma. + * + * Gets the state of the activation in the 3GPP2 network. + * + * Returns: a #MMModemCdmaActivationState. + */ +MMModemCdmaActivationState +mm_modem_cdma_get_activation_state (MMModemCdma *self) +{ + g_return_val_if_fail (MM_IS_MODEM_CDMA (self), MM_MODEM_CDMA_ACTIVATION_STATE_UNKNOWN); + + return mm_gdbus_modem_cdma_get_activation_state (MM_GDBUS_MODEM_CDMA (self)); +} + +/*****************************************************************************/ + +/** + * mm_modem_cdma_activate_finish: + * @self: A #MMModemCdma. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_cdma_activate(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_cdma_activate(). + * + * Returns: %TRUE if the activation was successful, %FALSE if @error is set. + */ +gboolean +mm_modem_cdma_activate_finish (MMModemCdma *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM_CDMA (self), FALSE); + + return mm_gdbus_modem_cdma_call_activate_finish (MM_GDBUS_MODEM_CDMA (self), res, error); +} + +/** + * mm_modem_cdma_activate: + * @self: A #MMModemCdma. + * @carrier: Name of the carrier. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously requests to provision the modem for use with a given carrier + * using the modem's OTA activation functionality, if any. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_cdma_activate_finish() to get the result of the operation. + * + * See mm_modem_cdma_activate_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_cdma_activate (MMModemCdma *self, + const gchar *carrier, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM_CDMA (self)); + + mm_gdbus_modem_cdma_call_activate (MM_GDBUS_MODEM_CDMA (self), carrier, cancellable, callback, user_data); +} + +/** + * mm_modem_cdma_activate_sync: + * @self: A #MMModemCdma. + * @carrier: Name of the carrier. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously requests to provision the modem for use with a given carrier + * using the modem's OTA activation functionality, if any. + * + * The calling thread is blocked until a reply is received. See mm_modem_cdma_activate() + * for the asynchronous version of this method. + * + * Returns: %TRUE if the activation was successful, %FALSE if @error is set. + */ +gboolean +mm_modem_cdma_activate_sync (MMModemCdma *self, + const gchar *carrier, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM_CDMA (self), FALSE); + + return mm_gdbus_modem_cdma_call_activate_sync (MM_GDBUS_MODEM_CDMA (self), carrier, cancellable, error); +} + +/*****************************************************************************/ + +static void +mm_modem_cdma_init (MMModemCdma *self) +{ +} + +static void +mm_modem_cdma_class_init (MMModemCdmaClass *modem_class) +{ +} diff --git a/libmm-glib/mm-modem-cdma.h b/libmm-glib/mm-modem-cdma.h new file mode 100644 index 0000000..8c7cb9c --- /dev/null +++ b/libmm-glib/mm-modem-cdma.h @@ -0,0 +1,110 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2011 - 2012 Aleksander Morgado <aleksander@gnu.org> + * Copyright (C) 2012 Google, Inc. + */ + +#ifndef _MM_MODEM_CDMA_H_ +#define _MM_MODEM_CDMA_H_ + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> + +#include "mm-gdbus-modem.h" + +G_BEGIN_DECLS + +#define MM_TYPE_MODEM_CDMA (mm_modem_cdma_get_type ()) +#define MM_MODEM_CDMA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_MODEM_CDMA, MMModemCdma)) +#define MM_MODEM_CDMA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_MODEM_CDMA, MMModemCdmaClass)) +#define MM_IS_MODEM_CDMA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_MODEM_CDMA)) +#define MM_IS_MODEM_CDMA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), MM_TYPE_MODEM_CDMA)) +#define MM_MODEM_CDMA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_MODEM_CDMA, MMModemCdmaClass)) + +typedef struct _MMModemCdma MMModemCdma; +typedef struct _MMModemCdmaClass MMModemCdmaClass; + +/** + * MMModemCdma: + * + * The #MMModemCdma structure contains private data and should only be accessed + * using the provided API. + */ +struct _MMModemCdma { + /*< private >*/ + MmGdbusModemCdmaProxy parent; + gpointer unused; +}; + +struct _MMModemCdmaClass { + /*< private >*/ + MmGdbusModemCdmaProxyClass parent; +}; + +GType mm_modem_cdma_get_type (void); + +const gchar *mm_modem_cdma_get_path (MMModemCdma *self); +gchar *mm_modem_cdma_dup_path (MMModemCdma *self); + +const gchar *mm_modem_cdma_get_meid (MMModemCdma *self); +gchar *mm_modem_cdma_dup_meid (MMModemCdma *self); + +const gchar *mm_modem_cdma_get_esn (MMModemCdma *self); +gchar *mm_modem_cdma_dup_esn (MMModemCdma *self); + +/** + * MM_MODEM_CDMA_SID_UNKNOWN: + * + * Identifier for an unknown SID. + */ +#define MM_MODEM_CDMA_SID_UNKNOWN 99999 +guint mm_modem_cdma_get_sid (MMModemCdma *self); + +/** + * MM_MODEM_CDMA_NID_UNKNOWN: + * + * Identifier for an unknown NID. + */ +#define MM_MODEM_CDMA_NID_UNKNOWN 99999 +guint mm_modem_cdma_get_nid (MMModemCdma *self); + +MMModemCdmaRegistrationState mm_modem_cdma_get_cdma1x_registration_state (MMModemCdma *self); +MMModemCdmaRegistrationState mm_modem_cdma_get_evdo_registration_state (MMModemCdma *self); +MMModemCdmaActivationState mm_modem_cdma_get_activation_state (MMModemCdma *self); + +void mm_modem_cdma_activate (MMModemCdma *self, + const gchar *carrier, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_modem_cdma_activate_finish (MMModemCdma *self, + GAsyncResult *res, + GError **error); +gboolean mm_modem_cdma_activate_sync (MMModemCdma *self, + const gchar *carrier, + GCancellable *cancellable, + GError **error); + +G_END_DECLS + +#endif /* _MM_MODEM_CDMA_H_ */ diff --git a/libmm-glib/mm-modem-firmware.c b/libmm-glib/mm-modem-firmware.c new file mode 100644 index 0000000..c52f316 --- /dev/null +++ b/libmm-glib/mm-modem-firmware.c @@ -0,0 +1,380 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2012 Google, Inc. + * Copyright (C) 2012 Lanedo GmbH <aleksander@lanedo.com> + */ + +#include <gio/gio.h> + +#include "mm-helpers.h" +#include "mm-errors-types.h" +#include "mm-modem-firmware.h" + +/** + * SECTION: mm-modem-firmware + * @title: MMModemFirmware + * @short_description: The Firmware interface + * + * The #MMModemFirmware is an object providing access to the methods, signals and + * properties of the Firmware interface. + * + * The Firmware interface is exposed whenever a modem has firmware capabilities. + */ + +G_DEFINE_TYPE (MMModemFirmware, mm_modem_firmware, MM_GDBUS_TYPE_MODEM_FIRMWARE_PROXY) + +/*****************************************************************************/ + +/** + * mm_modem_firmware_get_path: + * @self: A #MMModemFirmware. + * + * Gets the DBus path of the #MMObject which implements this interface. + * + * Returns: (transfer none): The DBus path of the #MMObject object. + */ +const gchar * +mm_modem_firmware_get_path (MMModemFirmware *self) +{ + g_return_val_if_fail (MM_IS_MODEM_FIRMWARE (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + g_dbus_proxy_get_object_path (G_DBUS_PROXY (self))); +} + +/** + * mm_modem_firmware_dup_path: + * @self: A #MMModemFirmware. + * + * Gets a copy of the DBus path of the #MMObject object which implements this interface. + * + * Returns: (transfer full): The DBus path of the #MMObject. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_firmware_dup_path (MMModemFirmware *self) +{ + gchar *value; + + g_return_val_if_fail (MM_IS_MODEM_FIRMWARE (self), NULL); + + g_object_get (G_OBJECT (self), + "g-object-path", &value, + NULL); + RETURN_NON_EMPTY_STRING (value); +} + +/*****************************************************************************/ + +/** + * mm_modem_firmware_select_finish: + * @self: A #MMModemFirmware. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_firmware_select(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_firmware_select(). + * + * Returns: %TRUE if the selection was successful, %FALSE if @error is set. + */ +gboolean +mm_modem_firmware_select_finish (MMModemFirmware *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM_FIRMWARE (self), FALSE); + + return mm_gdbus_modem_firmware_call_select_finish (MM_GDBUS_MODEM_FIRMWARE (self), res, error); +} + +/** + * mm_modem_firmware_select: + * @self: A #MMModemFirmware. + * @unique_id: Unique ID of the firmware image to select. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously selects a firmware image to boot. + * + * <warning>The modem will possibly disappear once this action is run, as it + * needs to reboot in order to select the new image.</warning> + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_firmware_select_finish() to get the result of the operation. + * + * See mm_modem_firmware_select_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_firmware_select (MMModemFirmware *self, + const gchar *unique_id, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM_FIRMWARE (self)); + g_return_if_fail (unique_id != NULL || unique_id[0] == '\0'); + + mm_gdbus_modem_firmware_call_select (MM_GDBUS_MODEM_FIRMWARE (self), unique_id, cancellable, callback, user_data); +} + +/** + * mm_modem_firmware_select_sync: + * @self: A #MMModemFirmware. + * @unique_id: Unique ID of the firmware image to select. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously selects a firmware image to boot. + * + * <warning>The modem will possibly disappear once this action is run, as it + * needs to reboot in order to select the new image.</warning> + * + * The calling thread is blocked until a reply is received. See mm_modem_firmware_select() + * for the asynchronous version of this method. + * + * Returns: %TRUE if the selection was successful, %FALSE if @error is set. + */ +gboolean +mm_modem_firmware_select_sync (MMModemFirmware *self, + const gchar *unique_id, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM_FIRMWARE (self), FALSE); + g_return_val_if_fail (unique_id != NULL || unique_id[0] == '\0', FALSE); + + return mm_gdbus_modem_firmware_call_select_sync (MM_GDBUS_MODEM_FIRMWARE (self), unique_id, cancellable, error); +} + +/*****************************************************************************/ + +static gboolean +build_results (const gchar *str_selected, + GVariant *dictionaries_installed, + MMFirmwareProperties **selected, + GList **installed, + GError **error) +{ + GError *saved_error = NULL; + GVariantIter iter; + guint n; + + g_assert (selected != NULL); + g_assert (installed != NULL); + + *installed = NULL; + *selected = NULL; + + if (!dictionaries_installed) { + if (str_selected && str_selected[0]) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Selected image specified but no installed images listed"); + return FALSE; + } + + /* Nothing else to do */ + return TRUE; + } + + /* Parse array of dictionaries */ + g_variant_iter_init (&iter, dictionaries_installed); + n = g_variant_iter_n_children (&iter); + + if (n > 0) { + GVariant *dictionary = NULL; + + while ((dictionary = g_variant_iter_next_value (&iter))) { + MMFirmwareProperties *firmware; + GError *inner_error = NULL; + + firmware = mm_firmware_properties_new_from_dictionary (dictionary, &inner_error); + if (!firmware) { + g_warning ("Couldn't create firmware properties: %s", + inner_error->message); + if (!saved_error) + saved_error = inner_error; + else + g_error_free (inner_error); + } else { + /* Save the firmware properties */ + *installed = g_list_append (*installed, firmware); + + if (str_selected && str_selected[0] && + g_str_equal (mm_firmware_properties_get_unique_id (firmware), str_selected)) + *selected = g_object_ref (firmware); + } + + g_variant_unref (dictionary); + } + } + + if (str_selected && str_selected[0] && *selected == NULL) + g_warning ("Selected image '%s' was not found in the list of installed images", + str_selected); + + if (saved_error) { + if (*installed == NULL) { + g_propagate_error (error, saved_error); + return FALSE; + } + g_error_free (saved_error); + } + + return TRUE; +} + +/** + * mm_modem_firmware_list_finish: + * @self: A #MMModemFirmware. + * @selected: (out) (allow-none) (transfer full): The selected firmware slot, or NULL if no slot is selected (such as if all slots are empty, or no slots exist). The returned value should be freed with g_object_unref(). + * @installed: (out) (allow-none) (transfer full): A list of #MMFirmwareProperties objects specifying the installed images. The returned value should be freed with g_list_free_full() using g_object_unref() as #GDestroyNotify. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_firmware_list(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_firmware_list(). + * + * Returns: %TRUE if the list was correctly retrieved, %FALSE if @error is set. + */ +gboolean +mm_modem_firmware_list_finish (MMModemFirmware *self, + GAsyncResult *res, + MMFirmwareProperties **selected, + GList **installed, + GError **error) +{ + gboolean parsed; + GVariant *dictionaries_installed = NULL; + gchar *str_selected = NULL; + + g_return_val_if_fail (MM_IS_MODEM_FIRMWARE (self), FALSE); + + g_return_val_if_fail (selected != NULL, FALSE); + g_return_val_if_fail (installed != NULL, FALSE); + + if (!mm_gdbus_modem_firmware_call_list_finish (MM_GDBUS_MODEM_FIRMWARE (self), + &str_selected, + &dictionaries_installed, + res, + error)) + return FALSE; + + parsed = build_results (str_selected, + dictionaries_installed, + selected, + installed, + error); + + if (dictionaries_installed) + g_variant_unref (dictionaries_installed); + g_free (str_selected); + + return parsed; +} + +/** + * mm_modem_firmware_list: + * @self: A #MMModemFirmware. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously gets the list of available firmware images. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_firmware_list_finish() to get the result of the operation. + * + * See mm_modem_firmware_list_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_firmware_list (MMModemFirmware *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM_FIRMWARE (self)); + + mm_gdbus_modem_firmware_call_list (MM_GDBUS_MODEM_FIRMWARE (self), + cancellable, + callback, + user_data); +} + +/** + * mm_modem_firmware_list_sync: + * @self: A #MMModemFirmware. + * @selected: (out) (allow-none) (transfer full): The selected firmware slot, or NULL if no slot is selected (such as if all slots are empty, or no slots exist). The returned value should be freed with g_object_unref(). + * @installed: (out) (allow-none) (transfer full): A list of #MMFirmwareProperties objects specifying the installed images. The returned value should be freed with g_list_free_full() using g_object_unref() as #GDestroyNotify. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return firmware for error or %NULL. + * + * Synchronously gets the list of available firmware images. + * + * The calling thread is blocked until a reply is received. See mm_modem_firmware_list() + * for the asynchronous version of this method. + * + * Returns: %TRUE if the list was correctly retrieved, %FALSE if @error is set. + */ +gboolean +mm_modem_firmware_list_sync (MMModemFirmware *self, + MMFirmwareProperties **selected, + GList **installed, + GCancellable *cancellable, + GError **error) +{ + GVariant *dictionaries_installed = NULL; + gchar *str_selected = NULL; + gboolean parsed; + + g_return_val_if_fail (MM_IS_MODEM_FIRMWARE (self), FALSE); + g_return_val_if_fail (selected != NULL, FALSE); + g_return_val_if_fail (installed != NULL, FALSE); + + if (!mm_gdbus_modem_firmware_call_list_sync (MM_GDBUS_MODEM_FIRMWARE (self), + &str_selected, + &dictionaries_installed, + cancellable, + error)) + return FALSE; + + parsed = build_results (str_selected, + dictionaries_installed, + selected, + installed, + error); + + if (dictionaries_installed) + g_variant_unref (dictionaries_installed); + g_free (str_selected); + + return parsed; +} + +/*****************************************************************************/ + +static void +mm_modem_firmware_init (MMModemFirmware *self) +{ +} + +static void +mm_modem_firmware_class_init (MMModemFirmwareClass *modem_class) +{ +} diff --git a/libmm-glib/mm-modem-firmware.h b/libmm-glib/mm-modem-firmware.h new file mode 100644 index 0000000..b600ad8 --- /dev/null +++ b/libmm-glib/mm-modem-firmware.h @@ -0,0 +1,99 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2012 Google, Inc. + */ + +#ifndef _MM_MODEM_FIRMWARE_H_ +#define _MM_MODEM_FIRMWARE_H_ + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> + +#include "mm-gdbus-modem.h" +#include "mm-firmware-properties.h" + +G_BEGIN_DECLS + +#define MM_TYPE_MODEM_FIRMWARE (mm_modem_firmware_get_type ()) +#define MM_MODEM_FIRMWARE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_MODEM_FIRMWARE, MMModemFirmware)) +#define MM_MODEM_FIRMWARE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_MODEM_FIRMWARE, MMModemFirmwareClass)) +#define MM_IS_MODEM_FIRMWARE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_MODEM_FIRMWARE)) +#define MM_IS_MODEM_FIRMWARE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), MM_TYPE_MODEM_FIRMWARE)) +#define MM_MODEM_FIRMWARE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_MODEM_FIRMWARE, MMModemFirmwareClass)) + +typedef struct _MMModemFirmware MMModemFirmware; +typedef struct _MMModemFirmwareClass MMModemFirmwareClass; + +/** + * MMModemFirmware: + * + * The #MMModemFirmware structure contains private data and should only be accessed + * using the provided API. + */ +struct _MMModemFirmware { + /*< private >*/ + MmGdbusModemFirmwareProxy parent; + gpointer unused; +}; + +struct _MMModemFirmwareClass { + /*< private >*/ + MmGdbusModemFirmwareProxyClass parent; +}; + +GType mm_modem_firmware_get_type (void); + +const gchar *mm_modem_firmware_get_path (MMModemFirmware *self); +gchar *mm_modem_firmware_dup_path (MMModemFirmware *self); + +void mm_modem_firmware_list (MMModemFirmware *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_modem_firmware_list_finish (MMModemFirmware *self, + GAsyncResult *res, + MMFirmwareProperties **selected, + GList **installed, + GError **error); +gboolean mm_modem_firmware_list_sync (MMModemFirmware *self, + MMFirmwareProperties **selected, + GList **installed, + GCancellable *cancellable, + GError **error); + +void mm_modem_firmware_select (MMModemFirmware *self, + const gchar *unique_id, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_modem_firmware_select_finish (MMModemFirmware *self, + GAsyncResult *res, + GError **error); +gboolean mm_modem_firmware_select_sync (MMModemFirmware *self, + const gchar *unique_id, + GCancellable *cancellable, + GError **error); + +G_END_DECLS + +#endif /* _MM_MODEM_FIRMWARE_H_ */ diff --git a/libmm-glib/mm-modem-location.c b/libmm-glib/mm-modem-location.c new file mode 100644 index 0000000..1e5541a --- /dev/null +++ b/libmm-glib/mm-modem-location.c @@ -0,0 +1,680 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2012 Google, Inc. + * Copyright (C) 2012 Lanedo GmbH <aleksander@lanedo.com> + */ + +#include <gio/gio.h> + +#include "mm-helpers.h" +#include "mm-errors-types.h" +#include "mm-modem-location.h" + +/** + * SECTION: mm-modem-location + * @title: MMModemLocation + * @short_description: The Location interface + * + * The #MMModemLocation is an object providing access to the methods, signals and + * properties of the Location interface. + * + * The Location interface is exposed whenever a modem has location capabilities. + */ + +G_DEFINE_TYPE (MMModemLocation, mm_modem_location, MM_GDBUS_TYPE_MODEM_LOCATION_PROXY) + +/*****************************************************************************/ + +/** + * mm_modem_location_get_path: + * @self: A #MMModemLocation. + * + * Gets the DBus path of the #MMObject which implements this interface. + * + * Returns: (transfer none): The DBus path of the #MMObject object. + */ +const gchar * +mm_modem_location_get_path (MMModemLocation *self) +{ + g_return_val_if_fail (MM_IS_MODEM_LOCATION (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + g_dbus_proxy_get_object_path (G_DBUS_PROXY (self))); +} + +/** + * mm_modem_location_dup_path: + * @self: A #MMModemLocation. + * + * Gets a copy of the DBus path of the #MMObject object which implements this interface. + * + * Returns: (transfer full): The DBus path of the #MMObject. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_location_dup_path (MMModemLocation *self) +{ + gchar *value; + + g_return_val_if_fail (MM_IS_MODEM_LOCATION (self), NULL); + + g_object_get (G_OBJECT (self), + "g-object-path", &value, + NULL); + RETURN_NON_EMPTY_STRING (value); +} + +/*****************************************************************************/ + +/** + * mm_modem_location_get_capabilities: + * @self: A #MMModemLocation. + * + * Gets a bitmask of the location capabilities supported by this #MMModemLocation. + * + * Returns: A #MMModemLocationSource. + */ +MMModemLocationSource +mm_modem_location_get_capabilities (MMModemLocation *self) +{ + g_return_val_if_fail (MM_IS_MODEM_LOCATION (self), MM_MODEM_LOCATION_SOURCE_NONE); + + return (MMModemLocationSource) mm_gdbus_modem_location_get_capabilities (MM_GDBUS_MODEM_LOCATION (self)); +} + +/*****************************************************************************/ + +/** + * mm_modem_location_get_capabilities: + * @self: A #MMModemLocation. + * + * Gets a bitmask of the location capabilities which are enabled in this #MMModemLocation. + * + * Returns: A #MMModemLocationSource. + */ +MMModemLocationSource +mm_modem_location_get_enabled (MMModemLocation *self) +{ + g_return_val_if_fail (MM_IS_MODEM_LOCATION (self), FALSE); + + return (MMModemLocationSource) mm_gdbus_modem_location_get_enabled (MM_GDBUS_MODEM_LOCATION (self)); +} + +/*****************************************************************************/ + +/** + * mm_modem_location_signals_location: + * @self: A #MMModemLocation. + * + * Gets the status of the location signaling in the #MMModemLocation. + * + * Returns: %TRUE if location changes are signaled, %FALSE otherwise.. + */ +gboolean +mm_modem_location_signals_location (MMModemLocation *self) +{ + g_return_val_if_fail (MM_IS_MODEM_LOCATION (self), FALSE); + + return mm_gdbus_modem_location_get_signals_location (MM_GDBUS_MODEM_LOCATION (self)); +} + +/*****************************************************************************/ + +/** + * mm_modem_location_setup_finish: + * @self: A #MMModemLocation. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_location_setup(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_location_setup(). + * + * Returns: %TRUE if the setup was successful, %FALSE if @error is set. + */ +gboolean +mm_modem_location_setup_finish (MMModemLocation *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM_LOCATION (self), FALSE); + + return mm_gdbus_modem_location_call_setup_finish (MM_GDBUS_MODEM_LOCATION (self), res, error); +} + +/** + * mm_modem_location_setup: + * @self: A #MMModemLocation. + * @sources: Bitmask of #MMModemLocationSource values specifying which locations should get enabled. + * @signal_location: Flag to enable or disable location signaling. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously configures the location sources to use when gathering location + * information. Also enable or disable location information gathering. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_location_setup_finish() to get the result of the operation. + * + * See mm_modem_location_setup_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_location_setup (MMModemLocation *self, + MMModemLocationSource sources, + gboolean signal_location, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM_LOCATION (self)); + + mm_gdbus_modem_location_call_setup (MM_GDBUS_MODEM_LOCATION (self), + sources, + signal_location, + cancellable, + callback, + user_data); +} + +/** + * mm_modem_location_setup_sync: + * @self: A #MMModemLocation. + * @sources: Bitmask of #MMModemLocationSource values specifying which locations should get enabled. + * @signal_location: Flag to enable or disable location signaling. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously configures the location sources to use when gathering location + * information. Also enable or disable location information gathering. + * + * The calling thread is blocked until a reply is received. See mm_modem_location_setup() + * for the asynchronous version of this method. + * + * Returns: %TRUE if the setup was successful, %FALSE if @error is set. + */ +gboolean +mm_modem_location_setup_sync (MMModemLocation *self, + MMModemLocationSource sources, + gboolean signal_location, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM_LOCATION (self), FALSE); + + return mm_gdbus_modem_location_call_setup_sync (MM_GDBUS_MODEM_LOCATION (self), + sources, + signal_location, + cancellable, + error); +} + +/*****************************************************************************/ + +static gboolean +build_locations (GVariant *dictionary, + MMLocation3gpp **location_3gpp, + MMLocationGpsNmea **location_gps_nmea, + MMLocationGpsRaw **location_gps_raw, + MMLocationCdmaBs **location_cdma_bs, + GError **error) +{ + GError *inner_error = NULL; + GVariant *value; + guint source; + GVariantIter iter; + + if (!dictionary) + /* No location provided. Not actually an error. */ + return TRUE; + + g_variant_iter_init (&iter, dictionary); + while (!inner_error && + g_variant_iter_next (&iter, "{uv}", &source, &value)) { + switch (source) { + case MM_MODEM_LOCATION_SOURCE_3GPP_LAC_CI: + if (location_3gpp) + *location_3gpp = mm_location_3gpp_new_from_string_variant (value, &inner_error); + break; + case MM_MODEM_LOCATION_SOURCE_GPS_NMEA: + if (location_gps_nmea) + *location_gps_nmea = mm_location_gps_nmea_new_from_string_variant (value, &inner_error); + break; + case MM_MODEM_LOCATION_SOURCE_GPS_RAW: + if (location_gps_raw) + *location_gps_raw = mm_location_gps_raw_new_from_dictionary (value, &inner_error); + break; + case MM_MODEM_LOCATION_SOURCE_CDMA_BS: + if (location_cdma_bs) + *location_cdma_bs = mm_location_cdma_bs_new_from_dictionary (value, &inner_error); + break; + default: + g_warn_if_reached (); + break; + } + + g_variant_unref (value); + } + + g_variant_unref (dictionary); + + if (inner_error) { + g_propagate_error (error, inner_error); + g_prefix_error (error, + "Couldn't build locations result: "); + return FALSE; + } + + return TRUE; +} + +/** + * mm_modem_location_get_full_finish: + * @self: A #MMModemLocation. + * @location_3gpp: (out) (allow-none) (transfer full): Return location for a #MMLocation3gpp if 3GPP location is requested, or #NULL if not required. The returned value should be freed with g_object_unref(). + * @location_gps_nmea: (out) (allow-none) (transfer full): Return location for a #MMLocationGpsNmea if GPS NMEA location is requested, or #NULL if not required. The returned value should be freed with g_object_unref(). + * @location_gps_raw: (out) (allow-none) (transfer full): Return location for a #MMLocationGpsRaw if GPS raw location is requested, or #NULL if not required. The returned value should be freed with g_object_unref(). + * @location_cdma_bs: (out) (allow-none) (transfer full): Return location for a #MMLocationCdmaBs if CDMA Base Station location is requested, or #NULL if not required. The returned value should be freed with g_object_unref(). + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_location_get_full(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_location_get_full(). + * + * Returns: %TRUE if the retrieval was successful, %FALSE if @error is set. + */ +gboolean +mm_modem_location_get_full_finish (MMModemLocation *self, + GAsyncResult *res, + MMLocation3gpp **location_3gpp, + MMLocationGpsNmea **location_gps_nmea, + MMLocationGpsRaw **location_gps_raw, + MMLocationCdmaBs **location_cdma_bs, + GError **error) +{ + GVariant *dictionary = NULL; + + g_return_val_if_fail (MM_IS_MODEM_LOCATION (self), FALSE); + + if (!mm_gdbus_modem_location_call_get_location_finish (MM_GDBUS_MODEM_LOCATION (self), &dictionary, res, error)) + return FALSE; + + return build_locations (dictionary, location_3gpp, location_gps_nmea, location_gps_raw, location_cdma_bs, error); +} + +/** + * mm_modem_location_get_full: + * @self: A #MMModemLocation. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously gets the current location information. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_location_get_full_finish() to get the result of the operation. + * + * See mm_modem_location_get_full_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_location_get_full (MMModemLocation *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM_LOCATION (self)); + + mm_gdbus_modem_location_call_get_location (MM_GDBUS_MODEM_LOCATION (self), + cancellable, + callback, + user_data); +} + +/** + * mm_modem_location_get_full_sync: + * @self: A #MMModemLocation. + * @location_3gpp: (out) (allow-none) (transfer full): Return location for a #MMLocation3gpp if 3GPP location is requested, or #NULL if not required. The returned value should be freed with g_object_unref(). + * @location_gps_nmea: (out) (allow-none) (transfer full): Return location for a #MMLocationGpsNmea if GPS NMEA location is requested, or #NULL if not required. The returned value should be freed with g_object_unref(). + * @location_gps_raw: (out) (allow-none) (transfer full): Return location for a #MMLocationGpsRaw if GPS raw location is requested, or #NULL if not required. The returned value should be freed with g_object_unref(). + * @location_cdma_bs: (out) (allow-none) (transfer full): Return location for a #MMLocationCdmaBs if CDMA Base Station location is requested, or #NULL if not required. The returned value should be freed with g_object_unref(). + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously gets the current location information. + * + * The calling thread is blocked until a reply is received. See mm_modem_location_get_full() + * for the asynchronous version of this method. + * + * Returns: %TRUE if the setup was successful, %FALSE if @error is set. + */ +gboolean +mm_modem_location_get_full_sync (MMModemLocation *self, + MMLocation3gpp **location_3gpp, + MMLocationGpsNmea **location_gps_nmea, + MMLocationGpsRaw **location_gps_raw, + MMLocationCdmaBs **location_cdma_bs, + GCancellable *cancellable, + GError **error) +{ + GVariant *dictionary = NULL; + + g_return_val_if_fail (MM_IS_MODEM_LOCATION (self), FALSE); + + if (!mm_gdbus_modem_location_call_get_location_sync (MM_GDBUS_MODEM_LOCATION (self), &dictionary, cancellable, error)) + return FALSE; + + return build_locations (dictionary, location_3gpp, location_gps_nmea, location_gps_raw, location_cdma_bs, error); +} + +/*****************************************************************************/ + +/** + * mm_modem_location_get_3gpp_finish: + * @self: A #MMModemLocation. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_location_get_3gpp(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_location_get_3gpp(). + * + * Returns: (transfer full) A #MMLocation3gpp, or #NULL if not available. The returned value should be freed with g_object_unref(). + */ +MMLocation3gpp * +mm_modem_location_get_3gpp_finish (MMModemLocation *self, + GAsyncResult *res, + GError **error) +{ + MMLocation3gpp *location = NULL; + + mm_modem_location_get_full_finish (self, res, &location, NULL, NULL, NULL, error); + + return location; +} + +/** + * mm_modem_location_get_3gpp: + * @self: A #MMModemLocation. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously gets the current 3GPP location information. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_location_get_3gpp_finish() to get the result of the operation. + * + * See mm_modem_location_get_3gpp_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_location_get_3gpp (MMModemLocation *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + mm_modem_location_get_full (self, cancellable, callback, user_data); +} + +/** + * mm_modem_location_get_3gpp_sync: + * @self: A #MMModemLocation. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously gets the current 3GPP location information. + * + * The calling thread is blocked until a reply is received. See mm_modem_location_get_3gpp() + * for the asynchronous version of this method. + * + * Returns: (transfer full) A #MMLocation3gpp, or #NULL if not available. The returned value should be freed with g_object_unref(). + */ +MMLocation3gpp * +mm_modem_location_get_3gpp_sync (MMModemLocation *self, + GCancellable *cancellable, + GError **error) +{ + MMLocation3gpp *location = NULL; + + mm_modem_location_get_full_sync (self, &location, NULL, NULL, NULL, cancellable, error); + + return location; +} + +/*****************************************************************************/ + +/** + * mm_modem_location_get_gps_nmea_finish: + * @self: A #MMModemLocation. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_location_get_gps_nmea(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_location_get_gps_nmea(). + * + * Returns: (transfer full) A #MMLocationGpsNmea, or #NULL if not available. The returned value should be freed with g_object_unref(). + */ +MMLocationGpsNmea * +mm_modem_location_get_gps_nmea_finish (MMModemLocation *self, + GAsyncResult *res, + GError **error) +{ + MMLocationGpsNmea *location = NULL; + + mm_modem_location_get_full_finish (self, res, NULL, &location, NULL, NULL, error); + + return location; +} + +/** + * mm_modem_location_get_gps_nmea: + * @self: A #MMModemLocation. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously gets the current GPS NMEA location information. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_location_get_gps_nmea_finish() to get the result of the operation. + * + * See mm_modem_location_get_gps_nmea_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_location_get_gps_nmea (MMModemLocation *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + mm_modem_location_get_full (self, cancellable, callback, user_data); +} + +/** + * mm_modem_location_get_gps_nmea_sync: + * @self: A #MMModemLocation. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously gets the current GPS NMEA location information. + * + * The calling thread is blocked until a reply is received. See mm_modem_location_get_gps_nmea() + * for the asynchronous version of this method. + * + * Returns: (transfer full) A #MMLocationGpsNmea, or #NULL if not available. The returned value should be freed with g_object_unref(). + */ +MMLocationGpsNmea * +mm_modem_location_get_gps_nmea_sync (MMModemLocation *self, + GCancellable *cancellable, + GError **error) +{ + MMLocationGpsNmea *location = NULL; + + mm_modem_location_get_full_sync (self, NULL, &location, NULL, NULL, cancellable, error); + + return location; +} + +/*****************************************************************************/ + +/** + * mm_modem_location_get_gps_raw_finish: + * @self: A #MMModemLocation. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_location_get_gps_raw(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_location_get_gps_raw(). + * + * Returns: (transfer full) A #MMLocationGpsRaw, or #NULL if not available. The returned value should be freed with g_object_unref(). + */ +MMLocationGpsRaw * +mm_modem_location_get_gps_raw_finish (MMModemLocation *self, + GAsyncResult *res, + GError **error) +{ + MMLocationGpsRaw *location = NULL; + + mm_modem_location_get_full_finish (self, res, NULL, NULL, &location, NULL, error); + + return location; +} + +/** + * mm_modem_location_get_gps_raw: + * @self: A #MMModemLocation. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously gets the current GPS raw location information. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_location_get_gps_raw_finish() to get the result of the operation. + * + * See mm_modem_location_get_gps_raw_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_location_get_gps_raw (MMModemLocation *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + mm_modem_location_get_full (self, cancellable, callback, user_data); +} + +/** + * mm_modem_location_get_gps_raw_sync: + * @self: A #MMModemLocation. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously gets the current GPS raw location information. + * + * The calling thread is blocked until a reply is received. See mm_modem_location_get_gps_raw() + * for the asynchronous version of this method. + * + * Returns: (transfer full) A #MMLocationGpsRaw, or #NULL if not available. The returned value should be freed with g_object_unref(). + */ +MMLocationGpsRaw * +mm_modem_location_get_gps_raw_sync (MMModemLocation *self, + GCancellable *cancellable, + GError **error) +{ + MMLocationGpsRaw *location = NULL; + + mm_modem_location_get_full_sync (self, NULL, NULL, &location, NULL, cancellable, error); + + return location; +} + +/*****************************************************************************/ + +/** + * mm_modem_location_get_cdma_bs_finish: + * @self: A #MMModemLocation. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_location_get_cdma_bs(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_location_get_cdma_bs(). + * + * Returns: (transfer full) A #MMLocationCdmaBs, or #NULL if not available. The returned value should be freed with g_object_unref(). + */ +MMLocationCdmaBs * +mm_modem_location_get_cdma_bs_finish (MMModemLocation *self, + GAsyncResult *res, + GError **error) +{ + MMLocationCdmaBs *location = NULL; + + mm_modem_location_get_full_finish (self, res, NULL, NULL, NULL, &location, error); + + return location; +} + +/** + * mm_modem_location_get_cdma_bs: + * @self: A #MMModemLocation. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously gets the current CDMA base station location information. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_location_get_cdma_bs_finish() to get the result of the operation. + * + * See mm_modem_location_get_cdma_bs_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_location_get_cdma_bs (MMModemLocation *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + mm_modem_location_get_full (self, cancellable, callback, user_data); +} + +/** + * mm_modem_location_get_cdma_bs_sync: + * @self: A #MMModemLocation. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously gets the current CDMA base station location information. + * + * The calling thread is blocked until a reply is received. See mm_modem_location_get_cdma_bs() + * for the asynchronous version of this method. + * + * Returns: (transfer full) A #MMLocationCdmaBs, or #NULL if not available. The returned value should be freed with g_object_unref(). + */ +MMLocationCdmaBs * +mm_modem_location_get_cdma_bs_sync (MMModemLocation *self, + GCancellable *cancellable, + GError **error) +{ + MMLocationCdmaBs *location = NULL; + + mm_modem_location_get_full_sync (self, NULL, NULL, NULL, &location, cancellable, error); + + return location; +} + +/*****************************************************************************/ + +static void +mm_modem_location_init (MMModemLocation *self) +{ +} + +static void +mm_modem_location_class_init (MMModemLocationClass *modem_class) +{ +} diff --git a/libmm-glib/mm-modem-location.h b/libmm-glib/mm-modem-location.h new file mode 100644 index 0000000..5f6393d --- /dev/null +++ b/libmm-glib/mm-modem-location.h @@ -0,0 +1,159 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2012 Google, Inc. + * Copyright (C) 2012 Lanedo GmbH <aleksander@lanedo.com> + */ + +#ifndef _MM_MODEM_LOCATION_H_ +#define _MM_MODEM_LOCATION_H_ + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> + +#include "mm-gdbus-modem.h" +#include "mm-location-3gpp.h" +#include "mm-location-gps-nmea.h" +#include "mm-location-gps-raw.h" +#include "mm-location-cdma-bs.h" + +G_BEGIN_DECLS + +#define MM_TYPE_MODEM_LOCATION (mm_modem_location_get_type ()) +#define MM_MODEM_LOCATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_MODEM_LOCATION, MMModemLocation)) +#define MM_MODEM_LOCATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_MODEM_LOCATION, MMModemLocationClass)) +#define MM_IS_MODEM_LOCATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_MODEM_LOCATION)) +#define MM_IS_MODEM_LOCATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), MM_TYPE_MODEM_LOCATION)) +#define MM_MODEM_LOCATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_MODEM_LOCATION, MMModemLocationClass)) + +typedef struct _MMModemLocation MMModemLocation; +typedef struct _MMModemLocationClass MMModemLocationClass; + +/** + * MMModemLocation: + * + * The #MMModemLocation structure contains private data and should only be accessed + * using the provided API. + */ +struct _MMModemLocation { + /*< private >*/ + MmGdbusModemLocationProxy parent; + gpointer unused; +}; + +struct _MMModemLocationClass { + /*< private >*/ + MmGdbusModemLocationProxyClass parent; +}; + +GType mm_modem_location_get_type (void); + +const gchar *mm_modem_location_get_path (MMModemLocation *self); +gchar *mm_modem_location_dup_path (MMModemLocation *self); + +MMModemLocationSource mm_modem_location_get_capabilities (MMModemLocation *self); + +MMModemLocationSource mm_modem_location_get_enabled (MMModemLocation *self); + +gboolean mm_modem_location_signals_location (MMModemLocation *self); + +void mm_modem_location_setup (MMModemLocation *self, + MMModemLocationSource sources, + gboolean signal_location, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_modem_location_setup_finish (MMModemLocation *self, + GAsyncResult *res, + GError **error); +gboolean mm_modem_location_setup_sync (MMModemLocation *self, + MMModemLocationSource sources, + gboolean signal_location, + GCancellable *cancellable, + GError **error); + +void mm_modem_location_get_3gpp (MMModemLocation *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MMLocation3gpp *mm_modem_location_get_3gpp_finish (MMModemLocation *self, + GAsyncResult *res, + GError **error); +MMLocation3gpp *mm_modem_location_get_3gpp_sync (MMModemLocation *self, + GCancellable *cancellable, + GError **error); + +void mm_modem_location_get_gps_nmea (MMModemLocation *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MMLocationGpsNmea *mm_modem_location_get_gps_nmea_finish (MMModemLocation *self, + GAsyncResult *res, + GError **error); +MMLocationGpsNmea *mm_modem_location_get_gps_nmea_sync (MMModemLocation *self, + GCancellable *cancellable, + GError **error); + +void mm_modem_location_get_gps_raw (MMModemLocation *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MMLocationGpsRaw *mm_modem_location_get_gps_raw_finish (MMModemLocation *self, + GAsyncResult *res, + GError **error); +MMLocationGpsRaw *mm_modem_location_get_gps_raw_sync (MMModemLocation *self, + GCancellable *cancellable, + GError **error); + +void mm_modem_location_get_cdma_bs (MMModemLocation *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MMLocationCdmaBs *mm_modem_location_get_cdma_bs_finish (MMModemLocation *self, + GAsyncResult *res, + GError **error); +MMLocationCdmaBs *mm_modem_location_get_cdma_bs_sync (MMModemLocation *self, + GCancellable *cancellable, + GError **error); + +void mm_modem_location_get_full (MMModemLocation *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_modem_location_get_full_finish (MMModemLocation *self, + GAsyncResult *res, + MMLocation3gpp **location_3gpp, + MMLocationGpsNmea **location_gps_nmea, + MMLocationGpsRaw **location_gps_raw, + MMLocationCdmaBs **location_cdma_bs, + GError **error); +gboolean mm_modem_location_get_full_sync (MMModemLocation *self, + MMLocation3gpp **location_3gpp, + MMLocationGpsNmea **location_gps_nmea, + MMLocationGpsRaw **location_gps_raw, + MMLocationCdmaBs **location_cdma_bs, + GCancellable *cancellable, + GError **error); + +G_END_DECLS + +#endif /* _MM_MODEM_LOCATION_H_ */ diff --git a/libmm-glib/mm-modem-messaging.c b/libmm-glib/mm-modem-messaging.c new file mode 100644 index 0000000..50c525c --- /dev/null +++ b/libmm-glib/mm-modem-messaging.c @@ -0,0 +1,765 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2012 Aleksander Morgado <aleksander@gnu.org> + * Copyright (C) 2012 Google, Inc. + */ + +#include <gio/gio.h> + +#include "mm-helpers.h" +#include "mm-common-helpers.h" +#include "mm-errors-types.h" +#include "mm-modem-messaging.h" + +/** + * SECTION: mm-modem-messaging + * @title: MMModemMessaging + * @short_description: The Messaging interface + * + * The #MMModemMessaging is an object providing access to the methods, signals and + * properties of the Messaging interface. + * + * The Messaging interface is exposed whenever a modem has messaging capabilities. + */ + +G_DEFINE_TYPE (MMModemMessaging, mm_modem_messaging, MM_GDBUS_TYPE_MODEM_MESSAGING_PROXY) + +struct _MMModemMessagingPrivate { + /* Supported Storage */ + GMutex supported_storages_mutex; + guint supported_storages_id; + GArray *supported_storages; +}; + +/*****************************************************************************/ + +/** + * mm_modem_messaging_get_path: + * @self: A #MMModemMessaging. + * + * Gets the DBus path of the #MMObject which implements this interface. + * + * Returns: (transfer none): The DBus path of the #MMObject object. + */ +const gchar * +mm_modem_messaging_get_path (MMModemMessaging *self) +{ + g_return_val_if_fail (MM_IS_MODEM_MESSAGING (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + g_dbus_proxy_get_object_path (G_DBUS_PROXY (self))); +} + +/** + * mm_modem_messaging_dup_path: + * @self: A #MMModemMessaging. + * + * Gets a copy of the DBus path of the #MMObject object which implements this interface. + * + * Returns: (transfer full): The DBus path of the #MMObject. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_messaging_dup_path (MMModemMessaging *self) +{ + gchar *value; + + g_return_val_if_fail (MM_IS_MODEM_MESSAGING (self), NULL); + + g_object_get (G_OBJECT (self), + "g-object-path", &value, + NULL); + RETURN_NON_EMPTY_STRING (value); +} + +/*****************************************************************************/ + +static void +supported_storages_updated (MMModemMessaging *self, + GParamSpec *pspec) +{ + g_mutex_lock (&self->priv->supported_storages_mutex); + { + GVariant *dictionary; + + if (self->priv->supported_storages) + g_array_unref (self->priv->supported_storages); + + dictionary = mm_gdbus_modem_messaging_get_supported_storages (MM_GDBUS_MODEM_MESSAGING (self)); + self->priv->supported_storages = (dictionary ? + mm_common_sms_storages_variant_to_garray (dictionary) : + NULL); + } + g_mutex_unlock (&self->priv->supported_storages_mutex); +} + +static void +ensure_internal_supported_storages (MMModemMessaging *self, + GArray **dup) +{ + g_mutex_lock (&self->priv->supported_storages_mutex); + { + /* If this is the first time ever asking for the array, setup the + * update listener and the initial array, if any. */ + if (!self->priv->supported_storages_id) { + GVariant *dictionary; + + dictionary = mm_gdbus_modem_messaging_dup_supported_storages (MM_GDBUS_MODEM_MESSAGING (self)); + if (dictionary) { + self->priv->supported_storages = mm_common_sms_storages_variant_to_garray (dictionary); + g_variant_unref (dictionary); + } + + /* No need to clear this signal connection when freeing self */ + self->priv->supported_storages_id = + g_signal_connect (self, + "notify::supported-storages", + G_CALLBACK (supported_storages_updated), + NULL); + } + + if (dup && self->priv->supported_storages) + *dup = g_array_ref (self->priv->supported_storages); + } + g_mutex_unlock (&self->priv->supported_storages_mutex); +} + +/** + * mm_modem_messaging_get_supported_storages: + * @self: A #MMModem. + * @storages: (out) (array length=n_storages): Return location for the array of #MMSmsStorage values. The returned array should be freed with g_free() when no longer needed. + * @n_storages: (out): Return location for the number of values in @storages. + * + * Gets the list of SMS storages supported by the #MMModem. + * + * Returns: %TRUE if @storages and @n_storages are set, %FALSE otherwise. + */ +gboolean +mm_modem_messaging_get_supported_storages (MMModemMessaging *self, + MMSmsStorage **storages, + guint *n_storages) +{ + GArray *array; + + g_return_val_if_fail (MM_IS_MODEM_MESSAGING (self), FALSE); + g_return_val_if_fail (storages != NULL, FALSE); + g_return_val_if_fail (n_storages != NULL, FALSE); + + ensure_internal_supported_storages (self, &array); + if (!array) + return FALSE; + + *n_storages = array->len; + *storages = (MMSmsStorage *)g_array_free (array, FALSE); + return TRUE; +} + +/** + * mm_modem_messaging_peek_supported_storages: + * @self: A #MMModem. + * @storages: (out): Return location for the array of #MMSmsStorage values. Do not free the returned array, it is owned by @self. + * @n_storages: (out): Return location for the number of values in @storages. + * + * Gets the list of SMS storages supported by the #MMModem. + * + * Returns: %TRUE if @storages and @n_storages are set, %FALSE otherwise. + */ +gboolean +mm_modem_messaging_peek_supported_storages (MMModemMessaging *self, + const MMSmsStorage **storages, + guint *n_storages) +{ + g_return_val_if_fail (MM_IS_MODEM_MESSAGING (self), FALSE); + g_return_val_if_fail (storages != NULL, FALSE); + g_return_val_if_fail (n_storages != NULL, FALSE); + + ensure_internal_supported_storages (self, NULL); + if (!self->priv->supported_storages) + return FALSE; + + *n_storages = self->priv->supported_storages->len; + *storages = (MMSmsStorage *)self->priv->supported_storages->data; + return TRUE; +} + +/*****************************************************************************/ + +/** + * mm_modem_messaging_get_default_storage: + * @self: A #MMModem. + * + * Gets the default SMS storage used when storing or receiving SMS messages. + * + * Returns: the default #MMSmsStorage. + */ +MMSmsStorage +mm_modem_messaging_get_default_storage (MMModemMessaging *self) +{ + g_return_val_if_fail (MM_IS_MODEM_MESSAGING (self), MM_SMS_STORAGE_UNKNOWN); + + return (MMSmsStorage)mm_gdbus_modem_messaging_get_default_storage (MM_GDBUS_MODEM_MESSAGING (self)); +} + +/*****************************************************************************/ + +typedef struct { + MMModemMessaging *self; + GSimpleAsyncResult *result; + GCancellable *cancellable; + gchar **sms_paths; + GList *sms_objects; + guint i; +} ListSmsContext; + +static void +sms_object_list_free (GList *list) +{ + g_list_free_full (list, (GDestroyNotify) g_object_unref); +} + +static void +list_sms_context_complete_and_free (ListSmsContext *ctx) +{ + g_simple_async_result_complete (ctx->result); + + g_strfreev (ctx->sms_paths); + sms_object_list_free (ctx->sms_objects); + g_object_unref (ctx->result); + if (ctx->cancellable) + g_object_unref (ctx->cancellable); + g_object_ref (ctx->self); + g_slice_free (ListSmsContext, ctx); +} + +/** + * mm_modem_messaging_list_finish: + * @self: A #MMModem. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_messaging_list(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_messaging_list(). + * + * Returns: (element-type MM.Sms) (transfer full): A list of #MMSms objects, or #NULL if either not found or @error is set. The returned value should be freed with g_list_free_full() using g_object_unref() as #GDestroyNotify function. + */ +GList * +mm_modem_messaging_list_finish (MMModemMessaging *self, + GAsyncResult *res, + GError **error) +{ + GList *list; + + g_return_val_if_fail (MM_IS_MODEM_MESSAGING (self), FALSE); + + if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error)) + return NULL; + + list = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)); + + /* The list we got, including the objects within, is owned by the async result; + * so we'll make sure we return a new list */ + g_list_foreach (list, (GFunc)g_object_ref, NULL); + return g_list_copy (list); +} + +static void create_next_sms (ListSmsContext *ctx); + +static void +list_build_object_ready (GDBusConnection *connection, + GAsyncResult *res, + ListSmsContext *ctx) +{ + GError *error = NULL; + GObject *sms; + GObject *source_object; + + source_object = g_async_result_get_source_object (res); + sms = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, &error); + g_object_unref (source_object); + + if (error) { + g_simple_async_result_take_error (ctx->result, error); + list_sms_context_complete_and_free (ctx); + return; + } + + /* Keep the object */ + ctx->sms_objects = g_list_prepend (ctx->sms_objects, sms); + + /* If no more smss, just end here. */ + if (!ctx->sms_paths[++ctx->i]) { + g_simple_async_result_set_op_res_gpointer (ctx->result, + ctx->sms_objects, + (GDestroyNotify)sms_object_list_free); + ctx->sms_objects = NULL; + list_sms_context_complete_and_free (ctx); + return; + } + + /* Keep on creating next object */ + create_next_sms (ctx); +} + +static void +create_next_sms (ListSmsContext *ctx) +{ + g_async_initable_new_async (MM_TYPE_SMS, + G_PRIORITY_DEFAULT, + ctx->cancellable, + (GAsyncReadyCallback)list_build_object_ready, + ctx, + "g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + "g-name", MM_DBUS_SERVICE, + "g-connection", g_dbus_proxy_get_connection (G_DBUS_PROXY (ctx->self)), + "g-object-path", ctx->sms_paths[ctx->i], + "g-interface-name", "org.freedesktop.ModemManager1.Sms", + NULL); +} + +static void +list_ready (MMModemMessaging *self, + GAsyncResult *res, + ListSmsContext *ctx) +{ + GError *error = NULL; + + mm_gdbus_modem_messaging_call_list_finish (MM_GDBUS_MODEM_MESSAGING (self), &ctx->sms_paths, res, &error); + if (error) { + g_simple_async_result_take_error (ctx->result, error); + list_sms_context_complete_and_free (ctx); + return; + } + + /* If no SMS, just end here. */ + if (!ctx->sms_paths || !ctx->sms_paths[0]) { + g_simple_async_result_set_op_res_gpointer (ctx->result, NULL, NULL); + list_sms_context_complete_and_free (ctx); + return; + } + + /* Got list of paths. If at least one found, start creating objects for each */ + ctx->i = 0; + create_next_sms (ctx); +} + +/** + * mm_modem_messaging_list: + * @self: A #MMModemMessaging. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously lists the #MMSms objects in the modem. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_messaging_list_finish() to get the result of the operation. + * + * See mm_modem_messaging_list_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_messaging_list (MMModemMessaging *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + ListSmsContext *ctx; + + g_return_if_fail (MM_IS_MODEM_MESSAGING (self)); + + ctx = g_slice_new0 (ListSmsContext); + ctx->self = g_object_ref (self); + ctx->result = g_simple_async_result_new (G_OBJECT (self), + callback, + user_data, + mm_modem_messaging_list); + if (cancellable) + ctx->cancellable = g_object_ref (cancellable); + + mm_gdbus_modem_messaging_call_list (MM_GDBUS_MODEM_MESSAGING (self), + cancellable, + (GAsyncReadyCallback)list_ready, + ctx); +} + +/** + * mm_modem_messaging_list_sync: + * @self: A #MMModemMessaging. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously lists the #MMSms objects in the modem. + * + * The calling thread is blocked until a reply is received. See mm_modem_messaging_list() + * for the asynchronous version of this method. + * + * Returns: (element-type MM.Sms) (transfer full): A list of #MMSms objects, or #NULL if either not found or @error is set. The returned value should be freed with g_list_free_full() using g_object_unref() as #GDestroyNotify function. + */ +GList * +mm_modem_messaging_list_sync (MMModemMessaging *self, + GCancellable *cancellable, + GError **error) +{ + GList *sms_objects = NULL; + gchar **sms_paths = NULL; + guint i; + + g_return_val_if_fail (MM_IS_MODEM_MESSAGING (self), NULL); + + if (!mm_gdbus_modem_messaging_call_list_sync (MM_GDBUS_MODEM_MESSAGING (self), + &sms_paths, + cancellable, + error)) + return NULL; + + /* Only non-empty lists are returned */ + if (!sms_paths) + return NULL; + + for (i = 0; sms_paths[i]; i++) { + GObject *sms; + + sms = g_initable_new (MM_TYPE_SMS, + cancellable, + error, + "g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + "g-name", MM_DBUS_SERVICE, + "g-connection", g_dbus_proxy_get_connection (G_DBUS_PROXY (self)), + "g-object-path", sms_paths[i], + "g-interface-name", "org.freedesktop.ModemManager1.Sms", + NULL); + if (!sms) { + sms_object_list_free (sms_objects); + g_strfreev (sms_paths); + return NULL; + } + + /* Keep the object */ + sms_objects = g_list_prepend (sms_objects, sms); + } + + g_strfreev (sms_paths); + return sms_objects; +} + +/*****************************************************************************/ + +typedef struct { + GSimpleAsyncResult *result; + GCancellable *cancellable; +} CreateSmsContext; + +static void +create_sms_context_complete_and_free (CreateSmsContext *ctx) +{ + g_simple_async_result_complete (ctx->result); + g_object_unref (ctx->result); + if (ctx->cancellable) + g_object_unref (ctx->cancellable); + g_slice_free (CreateSmsContext, ctx); +} + +/** + * mm_modem_messaging_create_finish: + * @self: A #MMModemMessaging. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_messaging_create(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_messaging_create(). + * + * Returns: (transfer full): A newly created #MMSms, or %NULL if @error is set. The returned value should be freed with g_object_unref(). + */ +MMSms * +mm_modem_messaging_create_finish (MMModemMessaging *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM_MESSAGING (self), NULL); + + if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error)) + return NULL; + + return g_object_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res))); +} + +static void +new_sms_object_ready (GDBusConnection *connection, + GAsyncResult *res, + CreateSmsContext *ctx) +{ + GError *error = NULL; + GObject *sms; + GObject *source_object; + + source_object = g_async_result_get_source_object (res); + sms = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, &error); + g_object_unref (source_object); + + if (error) + g_simple_async_result_take_error (ctx->result, error); + else + g_simple_async_result_set_op_res_gpointer (ctx->result, + sms, + (GDestroyNotify)g_object_unref); + + create_sms_context_complete_and_free (ctx); +} + +static void +create_sms_ready (MMModemMessaging *self, + GAsyncResult *res, + CreateSmsContext *ctx) +{ + GError *error = NULL; + gchar *sms_path = NULL; + + if (!mm_gdbus_modem_messaging_call_create_finish (MM_GDBUS_MODEM_MESSAGING (self), + &sms_path, + res, + &error)) { + g_simple_async_result_take_error (ctx->result, error); + create_sms_context_complete_and_free (ctx); + g_free (sms_path); + return; + } + + g_async_initable_new_async (MM_TYPE_SMS, + G_PRIORITY_DEFAULT, + ctx->cancellable, + (GAsyncReadyCallback)new_sms_object_ready, + ctx, + "g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + "g-name", MM_DBUS_SERVICE, + "g-connection", g_dbus_proxy_get_connection (G_DBUS_PROXY (self)), + "g-object-path", sms_path, + "g-interface-name", "org.freedesktop.ModemManager1.Sms", + NULL); + g_free (sms_path); +} + +/** + * mm_modem_messaging_create_sms: + * @self: A #MMModemMessaging. + * @properties: A ##MMSmsProperties object with the properties to use. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously creates a new #MMSms in the modem. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_messaging_create_finish() to get the result of the operation. + * + * See mm_modem_messaging_create_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_messaging_create (MMModemMessaging *self, + MMSmsProperties *properties, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + CreateSmsContext *ctx; + GVariant *dictionary; + + g_return_if_fail (MM_IS_MODEM_MESSAGING (self)); + + ctx = g_slice_new0 (CreateSmsContext); + ctx->result = g_simple_async_result_new (G_OBJECT (self), + callback, + user_data, + mm_modem_messaging_create); + if (cancellable) + ctx->cancellable = g_object_ref (cancellable); + + dictionary = (mm_sms_properties_get_dictionary (properties)); + mm_gdbus_modem_messaging_call_create ( + MM_GDBUS_MODEM_MESSAGING (self), + dictionary, + cancellable, + (GAsyncReadyCallback)create_sms_ready, + ctx); + + g_variant_unref (dictionary); +} + +/** + * mm_modem_create_sms_sync: + * @self: A #MMModemMessaging. + * @properties: A ##MMSmsProperties object with the properties to use. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously creates a new #MMSms in the modem. + * + * The calling thread is blocked until a reply is received. See mm_modem_messaging_create() + * for the asynchronous version of this method. + * + * Returns: (transfer full): A newly created #MMSms, or %NULL if @error is set. The returned value should be freed with g_object_unref(). + */ +MMSms * +mm_modem_messaging_create_sync (MMModemMessaging *self, + MMSmsProperties *properties, + GCancellable *cancellable, + GError **error) +{ + MMSms *sms = NULL; + gchar *sms_path = NULL; + GVariant *dictionary; + + g_return_val_if_fail (MM_IS_MODEM_MESSAGING (self), NULL); + + dictionary = (mm_sms_properties_get_dictionary (properties)); + mm_gdbus_modem_messaging_call_create_sync (MM_GDBUS_MODEM_MESSAGING (self), + dictionary, + &sms_path, + cancellable, + error); + if (sms_path) { + sms = g_initable_new (MM_TYPE_SMS, + cancellable, + error, + "g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + "g-name", MM_DBUS_SERVICE, + "g-connection", g_dbus_proxy_get_connection (G_DBUS_PROXY (self)), + "g-object-path", sms_path, + "g-interface-name", "org.freedesktop.ModemManager1.Sms", + NULL); + g_free (sms_path); + } + + g_variant_unref (dictionary); + + return (sms ? MM_SMS (sms) : NULL); +} + +/*****************************************************************************/ + +/** + * mm_modem_messaging_delete_finish: + * @self: A #MMModemMessaging. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_messaging_delete(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_messaging_delete(). + * + * Returns: %TRUE if the sms was deleted, %FALSE if @error is set. + */ +gboolean +mm_modem_messaging_delete_finish (MMModemMessaging *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM_MESSAGING (self), FALSE); + + return mm_gdbus_modem_messaging_call_delete_finish (MM_GDBUS_MODEM_MESSAGING (self), res, error); +} + +/** + * mm_modem_messaging_delete: + * @self: A #MMModemMessaging. + * @sms: Path of the #MMSms to delete. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously deletes a given #MMSms from the modem. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_messaging_delete_finish() to get the result of the operation. + * + * See mm_modem_messaging_delete_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_messaging_delete (MMModemMessaging *self, + const gchar *sms, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM_MESSAGING (self)); + + mm_gdbus_modem_messaging_call_delete (MM_GDBUS_MODEM_MESSAGING (self), + sms, + cancellable, + callback, + user_data); +} + +/** + * mm_modem_messaging_delete_sync: + * @self: A #MMModemMessaging. + * @sms: Path of the #MMSms to delete. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + + * Synchronously deletes a given #MMSms from the modem. + * + * The calling thread is blocked until a reply is received. See mm_modem_messaging_delete() + * for the asynchronous version of this method. + * + * Returns: %TRUE if the SMS was deleted, %FALSE if @error is set. + */ +gboolean +mm_modem_messaging_delete_sync (MMModemMessaging *self, + const gchar *sms, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM_MESSAGING (self), FALSE); + + return mm_gdbus_modem_messaging_call_delete_sync (MM_GDBUS_MODEM_MESSAGING (self), + sms, + cancellable, + error); +} + +/*****************************************************************************/ + +static void +mm_modem_messaging_init (MMModemMessaging *self) +{ + /* Setup private data */ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, + MM_TYPE_MODEM_MESSAGING, + MMModemMessagingPrivate); + g_mutex_init (&self->priv->supported_storages_mutex); +} + +static void +finalize (GObject *object) +{ + MMModemMessaging *self = MM_MODEM_MESSAGING (object); + + g_mutex_clear (&self->priv->supported_storages_mutex); + + if (self->priv->supported_storages) + g_array_unref (self->priv->supported_storages); + + G_OBJECT_CLASS (mm_modem_messaging_parent_class)->finalize (object); +} + +static void +mm_modem_messaging_class_init (MMModemMessagingClass *modem_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (modem_class); + + g_type_class_add_private (object_class, sizeof (MMModemMessagingPrivate)); + + /* Virtual methods */ + object_class->finalize = finalize; +} diff --git a/libmm-glib/mm-modem-messaging.h b/libmm-glib/mm-modem-messaging.h new file mode 100644 index 0000000..0162a85 --- /dev/null +++ b/libmm-glib/mm-modem-messaging.h @@ -0,0 +1,120 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2012 Aleksander Morgado <aleksander@gnu.org> + * Copyright (C) 2012 Google, Inc. + */ + +#ifndef _MM_MODEM_MESSAGING_H_ +#define _MM_MODEM_MESSAGING_H_ + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> + +#include "mm-gdbus-modem.h" +#include "mm-sms.h" +#include "mm-sms-properties.h" + +G_BEGIN_DECLS + +#define MM_TYPE_MODEM_MESSAGING (mm_modem_messaging_get_type ()) +#define MM_MODEM_MESSAGING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_MODEM_MESSAGING, MMModemMessaging)) +#define MM_MODEM_MESSAGING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_MODEM_MESSAGING, MMModemMessagingClass)) +#define MM_IS_MODEM_MESSAGING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_MODEM_MESSAGING)) +#define MM_IS_MODEM_MESSAGING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), MM_TYPE_MODEM_MESSAGING)) +#define MM_MODEM_MESSAGING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_MODEM_MESSAGING, MMModemMessagingClass)) + +typedef struct _MMModemMessaging MMModemMessaging; +typedef struct _MMModemMessagingClass MMModemMessagingClass; +typedef struct _MMModemMessagingPrivate MMModemMessagingPrivate; + +/** + * MMModemMessaging: + * + * The #MMModemMessaging structure contains private data and should only be accessed + * using the provided API. + */ +struct _MMModemMessaging { + /*< private >*/ + MmGdbusModemMessagingProxy parent; + MMModemMessagingPrivate *priv; +}; + +struct _MMModemMessagingClass { + /*< private >*/ + MmGdbusModemMessagingProxyClass parent; +}; + +GType mm_modem_messaging_get_type (void); + +const gchar *mm_modem_messaging_get_path (MMModemMessaging *self); +gchar *mm_modem_messaging_dup_path (MMModemMessaging *self); + +gboolean mm_modem_messaging_get_supported_storages (MMModemMessaging *self, + MMSmsStorage **storages, + guint *n_storages); +gboolean mm_modem_messaging_peek_supported_storages (MMModemMessaging *self, + const MMSmsStorage **storages, + guint *n_storages); + +MMSmsStorage mm_modem_messaging_get_default_storage (MMModemMessaging *self); + +void mm_modem_messaging_create (MMModemMessaging *self, + MMSmsProperties *properties, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MMSms *mm_modem_messaging_create_finish (MMModemMessaging *self, + GAsyncResult *res, + GError **error); +MMSms *mm_modem_messaging_create_sync (MMModemMessaging *self, + MMSmsProperties *properties, + GCancellable *cancellable, + GError **error); + +void mm_modem_messaging_list (MMModemMessaging *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GList *mm_modem_messaging_list_finish (MMModemMessaging *self, + GAsyncResult *res, + GError **error); +GList *mm_modem_messaging_list_sync (MMModemMessaging *self, + GCancellable *cancellable, + GError **error); + +void mm_modem_messaging_delete (MMModemMessaging *self, + const gchar *sms, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_modem_messaging_delete_finish (MMModemMessaging *self, + GAsyncResult *res, + GError **error); +gboolean mm_modem_messaging_delete_sync (MMModemMessaging *self, + const gchar *sms, + GCancellable *cancellable, + GError **error); + +G_END_DECLS + +#endif /* _MM_MODEM_MESSAGING_H_ */ diff --git a/libmm-glib/mm-modem-simple.c b/libmm-glib/mm-modem-simple.c new file mode 100644 index 0000000..b96e31d --- /dev/null +++ b/libmm-glib/mm-modem-simple.c @@ -0,0 +1,452 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2011 - 2012 Aleksander Morgado <aleksander@gnu.org> + * Copyright (C) 2012 Google, Inc. + */ + +#include <gio/gio.h> + +#include "mm-helpers.h" +#include "mm-errors-types.h" +#include "mm-modem-simple.h" + +/** + * SECTION: mm-modem-simple + * @title: MMModemSimple + * @short_description: The Simple interface + * + * The #MMModemSimple is an object providing access to the methods, signals and + * properties of the Simple interface. + * + * The Simple interface is exposed on modems which are not in %MM_MODEM_STATE_FAILED state. + */ + +G_DEFINE_TYPE (MMModemSimple, mm_modem_simple, MM_GDBUS_TYPE_MODEM_SIMPLE_PROXY) + +/*****************************************************************************/ + +/** + * mm_modem_simple_get_path: + * @self: A #MMModemSimple. + * + * Gets the DBus path of the #MMObject which implements this interface. + * + * Returns: (transfer none): The DBus path of the #MMObject object. + */ +const gchar * +mm_modem_simple_get_path (MMModemSimple *self) +{ + g_return_val_if_fail (MM_IS_MODEM_SIMPLE (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + g_dbus_proxy_get_object_path (G_DBUS_PROXY (self))); +} + +/** + * mm_modem_simple_dup_path: + * @self: A #MMModemSimple. + * + * Gets a copy of the DBus path of the #MMObject object which implements this interface. + * + * Returns: (transfer full): The DBus path of the #MMObject. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_simple_dup_path (MMModemSimple *self) +{ + gchar *value; + + g_return_val_if_fail (MM_IS_MODEM_SIMPLE (self), NULL); + + g_object_get (G_OBJECT (self), + "g-object-path", &value, + NULL); + RETURN_NON_EMPTY_STRING (value); +} + +/*****************************************************************************/ + +typedef struct { + GSimpleAsyncResult *result; + GCancellable *cancellable; +} ConnectContext; + +static void +connect_context_complete_and_free (ConnectContext *ctx) +{ + g_simple_async_result_complete (ctx->result); + g_object_unref (ctx->result); + if (ctx->cancellable) + g_object_unref (ctx->cancellable); + g_slice_free (ConnectContext, ctx); +} + +/** + * mm_modem_simple_connect_finish: + * @self: A #MMModemSimple. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_simple_connect(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_simple_connect(). + * + * Returns: (transfer full): A #MMBearer, or %FALSE if @error is set. The returned value must be freed with g_object_ref(). + */ +MMBearer * +mm_modem_simple_connect_finish (MMModemSimple *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM_SIMPLE (self), NULL); + + if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error)) + return NULL; + + return g_object_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res))); +} + +static void +new_bearer_ready (GDBusConnection *connection, + GAsyncResult *res, + ConnectContext *ctx) +{ + GError *error = NULL; + GObject *bearer; + GObject *source_object; + + source_object = g_async_result_get_source_object (res); + bearer = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, &error); + g_object_unref (source_object); + + if (error) + g_simple_async_result_take_error (ctx->result, error); + else + g_simple_async_result_set_op_res_gpointer (ctx->result, + bearer, + (GDestroyNotify)g_object_unref); + + connect_context_complete_and_free (ctx); +} + +static void +simple_connect_ready (MMModemSimple *self, + GAsyncResult *res, + ConnectContext *ctx) +{ + GError *error = NULL; + gchar *bearer_path = NULL; + + if (!mm_gdbus_modem_simple_call_connect_finish (MM_GDBUS_MODEM_SIMPLE (self), + &bearer_path, + res, + &error)) { + g_simple_async_result_take_error (ctx->result, error); + connect_context_complete_and_free (ctx); + return; + } + + g_async_initable_new_async (MM_TYPE_BEARER, + G_PRIORITY_DEFAULT, + ctx->cancellable, + (GAsyncReadyCallback)new_bearer_ready, + ctx, + "g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + "g-name", MM_DBUS_SERVICE, + "g-connection", g_dbus_proxy_get_connection (G_DBUS_PROXY (self)), + "g-object-path", bearer_path, + "g-interface-name", "org.freedesktop.ModemManager1.Bearer", + NULL); +} + +/** + * mm_modem_simple_connect: + * @self: A #MMModemSimple. + * @properties: (transfer none): A #MMSimpleConnectProperties bundle. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously requests to connect the modem using the given @properties. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_simple_connect_finish() to get the result of the operation. + * + * See mm_modem_simple_connect_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_simple_connect (MMModemSimple *self, + MMSimpleConnectProperties *properties, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + ConnectContext *ctx; + GVariant *variant; + + g_return_if_fail (MM_IS_MODEM_SIMPLE (self)); + + ctx = g_slice_new0 (ConnectContext); + ctx->result = g_simple_async_result_new (G_OBJECT (self), + callback, + user_data, + mm_modem_simple_connect); + if (cancellable) + ctx->cancellable = g_object_ref (cancellable); + + variant = mm_simple_connect_properties_get_dictionary (properties); + mm_gdbus_modem_simple_call_connect ( + MM_GDBUS_MODEM_SIMPLE (self), + variant, + cancellable, + (GAsyncReadyCallback)simple_connect_ready, + ctx); + + g_variant_unref (variant); +} + +/** + * mm_modem_simple_connect_sync: + * @self: A #MMModemSimple. + * @properties: (transfer none): A #MMSimpleConnectProperties bundle. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously requests to connect the modem using the given @properties. + * + * The calling thread is blocked until a reply is received. See mm_modem_simple_connect() + * for the asynchronous version of this method. + * + * Returns: (transfer full): A #MMBearer, or %FALSE if @error is set. The returned value must be freed with g_object_ref(). + */ +MMBearer * +mm_modem_simple_connect_sync (MMModemSimple *self, + MMSimpleConnectProperties *properties, + GCancellable *cancellable, + GError **error) +{ + GObject *bearer = NULL; + gchar *bearer_path = NULL; + GVariant *variant; + + g_return_val_if_fail (MM_IS_MODEM_SIMPLE (self), NULL); + + variant = mm_simple_connect_properties_get_dictionary (properties); + mm_gdbus_modem_simple_call_connect_sync (MM_GDBUS_MODEM_SIMPLE (self), + variant, + &bearer_path, + cancellable, + error); + if (bearer_path) { + bearer = g_initable_new (MM_TYPE_BEARER, + cancellable, + error, + "g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + "g-name", MM_DBUS_SERVICE, + "g-connection", g_dbus_proxy_get_connection (G_DBUS_PROXY (self)), + "g-object-path", bearer_path, + "g-interface-name", "org.freedesktop.ModemManager1.Bearer", + NULL); + g_free (bearer_path); + } + + g_variant_unref (variant); + + return (bearer ? MM_BEARER (bearer) : NULL); +} + +/*****************************************************************************/ + +/** + * mm_modem_simple_disconnect_finish: + * @self: A #MMModemSimple. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_simple_disconnect(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_simple_disconnect(). + * + * Returns: %TRUE if the modem is successfully disconnected, %FALSE if @error is set. + */ +gboolean +mm_modem_simple_disconnect_finish (MMModemSimple *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM_SIMPLE (self), FALSE); + + return mm_gdbus_modem_simple_call_disconnect_finish (MM_GDBUS_MODEM_SIMPLE (self), res, error); +} + +/** + * mm_modem_simple_disconnect: + * @self: A #MMModemSimple. + * @bearer: Path of the bearer to disconnect, or %NULL to disconnect all connected bearers. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously requests to disconnect the modem. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_simple_disconnect_finish() to get the result of the operation. + * + * See mm_modem_simple_disconnect_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_simple_disconnect (MMModemSimple *self, + const gchar *bearer, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM_SIMPLE (self)); + + mm_gdbus_modem_simple_call_disconnect (MM_GDBUS_MODEM_SIMPLE (self), + bearer ? bearer : "/", + cancellable, + callback, + user_data); +} + +/** + * mm_modem_simple_disconnect_sync: + * @self: A #MMModemSimple. + * @bearer: Path of the bearer to disconnect, or %NULL to disconnect all connected bearers. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously requests to disconnect the modem. + * + * The calling thread is blocked until a reply is received. See mm_modem_simple_disconnect() + * for the asynchronous version of this method. + * + * Returns: %TRUE if the modem is successfully disconnected, %FALSE if @error is set. + */ +gboolean +mm_modem_simple_disconnect_sync (MMModemSimple *self, + const gchar *bearer, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM_SIMPLE (self), FALSE); + + return mm_gdbus_modem_simple_call_disconnect_sync (MM_GDBUS_MODEM_SIMPLE (self), + bearer ? bearer : "/", + cancellable, + error); +} + +/*****************************************************************************/ + +/** + * mm_modem_simple_get_status_finish: + * @self: A #MMModemSimple. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_simple_connect(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_simple_get_status(). + * + * Returns: (transfer full): A #MMSimpleStatus, or %FALSE if @error is set. The returned value must be freed with g_object_ref(). + */ +MMSimpleStatus * +mm_modem_simple_get_status_finish (MMModemSimple *self, + GAsyncResult *res, + GError **error) +{ + MMSimpleStatus *status; + GVariant *dictionary = NULL; + + g_return_val_if_fail (MM_IS_MODEM_SIMPLE (self), NULL); + + if (!mm_gdbus_modem_simple_call_get_status_finish (MM_GDBUS_MODEM_SIMPLE (self), &dictionary, res, error)) + return NULL; + + status = mm_simple_status_new_from_dictionary (dictionary, error); + g_variant_unref (dictionary); + return status; +} + +/** + * mm_modem_simple_get_status: + * @self: A #MMModemSimple. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously requests a compilation of the status of the modem. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_simple_get_status_finish() to get the result of the operation. + * + * See mm_modem_simple_get_status_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_simple_get_status (MMModemSimple *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM_SIMPLE (self)); + + mm_gdbus_modem_simple_call_get_status (MM_GDBUS_MODEM_SIMPLE (self), + cancellable, + callback, + user_data); +} + +/** + * mm_modem_simple_get_status_sync: + * @self: A #MMModemSimple. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously requests a compilation of the status of the modem. + * + * The calling thread is blocked until a reply is received. See mm_modem_simple_get_status() + * for the asynchronous version of this method. + * + * Returns: (transfer full): A #MMSimpleStatus, or %FALSE if @error is set. The returned value must be freed with g_object_ref(). + */ +MMSimpleStatus * +mm_modem_simple_get_status_sync (MMModemSimple *self, + GCancellable *cancellable, + GError **error) +{ + MMSimpleStatus *status; + GVariant *dictionary = NULL; + + g_return_val_if_fail (MM_IS_MODEM_SIMPLE (self), NULL); + + if (!mm_gdbus_modem_simple_call_get_status_sync (MM_GDBUS_MODEM_SIMPLE (self), &dictionary, cancellable, error)) + return NULL; + + status = mm_simple_status_new_from_dictionary (dictionary, error); + g_variant_unref (dictionary); + return status; +} + +/*****************************************************************************/ + +static void +mm_modem_simple_init (MMModemSimple *self) +{ +} + +static void +mm_modem_simple_class_init (MMModemSimpleClass *modem_class) +{ +} diff --git a/libmm-glib/mm-modem-simple.h b/libmm-glib/mm-modem-simple.h new file mode 100644 index 0000000..0503a87 --- /dev/null +++ b/libmm-glib/mm-modem-simple.h @@ -0,0 +1,110 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2011 - 2012 Aleksander Morgado <aleksander@gnu.org> + * Copyright (C) 2012 Google, Inc. + */ + +#ifndef _MM_MODEM_SIMPLE_H_ +#define _MM_MODEM_SIMPLE_H_ + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> + +#include "mm-gdbus-modem.h" +#include "mm-simple-connect-properties.h" +#include "mm-simple-status.h" +#include "mm-bearer.h" + +G_BEGIN_DECLS + +#define MM_TYPE_MODEM_SIMPLE (mm_modem_simple_get_type ()) +#define MM_MODEM_SIMPLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_MODEM_SIMPLE, MMModemSimple)) +#define MM_MODEM_SIMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_MODEM_SIMPLE, MMModemSimpleClass)) +#define MM_IS_MODEM_SIMPLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_MODEM_SIMPLE)) +#define MM_IS_MODEM_SIMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), MM_TYPE_MODEM_SIMPLE)) +#define MM_MODEM_SIMPLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_MODEM_SIMPLE, MMModemSimpleClass)) + +typedef struct _MMModemSimple MMModemSimple; +typedef struct _MMModemSimpleClass MMModemSimpleClass; + +/** + * MMModemSimple: + * + * The #MMModemSimple structure contains private data and should only be accessed + * using the provided API. + */ +struct _MMModemSimple { + /*< private >*/ + MmGdbusModemSimpleProxy parent; + gpointer unused; +}; + +struct _MMModemSimpleClass { + /*< private >*/ + MmGdbusModemSimpleProxyClass parent; +}; + +GType mm_modem_simple_get_type (void); + +const gchar *mm_modem_simple_get_path (MMModemSimple *self); +gchar *mm_modem_simple_dup_path (MMModemSimple *self); + +void mm_modem_simple_connect (MMModemSimple *self, + MMSimpleConnectProperties *properties, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MMBearer *mm_modem_simple_connect_finish (MMModemSimple *self, + GAsyncResult *res, + GError **error); +MMBearer *mm_modem_simple_connect_sync (MMModemSimple *self, + MMSimpleConnectProperties *properties, + GCancellable *cancellable, + GError **error); + +void mm_modem_simple_disconnect (MMModemSimple *self, + const gchar *bearer, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_modem_simple_disconnect_finish (MMModemSimple *self, + GAsyncResult *res, + GError **error); +gboolean mm_modem_simple_disconnect_sync (MMModemSimple *self, + const gchar *bearer, + GCancellable *cancellable, + GError **error); + +void mm_modem_simple_get_status (MMModemSimple *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MMSimpleStatus *mm_modem_simple_get_status_finish (MMModemSimple *self, + GAsyncResult *res, + GError **error); +MMSimpleStatus *mm_modem_simple_get_status_sync (MMModemSimple *self, + GCancellable *cancellable, + GError **error); +G_END_DECLS + +#endif /* _MM_MODEM_SIMPLE_H_ */ diff --git a/libmm-glib/mm-modem-time.c b/libmm-glib/mm-modem-time.c new file mode 100644 index 0000000..c2d16d4 --- /dev/null +++ b/libmm-glib/mm-modem-time.c @@ -0,0 +1,311 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2012 Aleksander Morgado <aleksander@gnu.org> + * Copyright (C) 2012 Google, Inc. + */ + +#include <gio/gio.h> + +#include "mm-helpers.h" +#include "mm-errors-types.h" +#include "mm-modem-time.h" + +/** + * SECTION: mm-modem-time + * @title: MMModemTime + * @short_description: The Time interface + * + * The #MMModemTime is an object providing access to the methods, signals and + * properties of the Time interface. + * + * The Time interface is exposed on modems which support network time retrieval. + */ + +G_DEFINE_TYPE (MMModemTime, mm_modem_time, MM_GDBUS_TYPE_MODEM_TIME_PROXY) + +struct _MMModemTimePrivate { + /* Timezone */ + GMutex timezone_mutex; + guint timezone_id; + MMNetworkTimezone *timezone; +}; + +/*****************************************************************************/ + +/** + * mm_modem_time_get_path: + * @self: A #MMModemTime. + * + * Gets the DBus path of the #MMObject which implements this interface. + * + * Returns: (transfer none): The DBus path of the #MMObject object. + */ +const gchar * +mm_modem_time_get_path (MMModemTime *self) +{ + g_return_val_if_fail (MM_IS_MODEM_TIME (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + g_dbus_proxy_get_object_path (G_DBUS_PROXY (self))); +} + +/** + * mm_modem_time_dup_path: + * @self: A #MMModemTime. + * + * Gets a copy of the DBus path of the #MMObject object which implements this interface. + * + * Returns: (transfer full): The DBus path of the #MMObject. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_time_dup_path (MMModemTime *self) +{ + gchar *value; + + g_return_val_if_fail (MM_IS_MODEM_TIME (self), NULL); + + g_object_get (G_OBJECT (self), + "g-object-path", &value, + NULL); + RETURN_NON_EMPTY_STRING (value); +} + +/*****************************************************************************/ + +/** + * mm_modem_time_get_network_time_finish: + * @self: A #MMModemTime. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_enable(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_time_get_network_time(). + * + * Returns: A string containing the network time, or %NULL if @error is set. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_time_get_network_time_finish (MMModemTime *self, + GAsyncResult *res, + GError **error) +{ + gchar *network_time = NULL; + + g_return_val_if_fail (MM_IS_MODEM_TIME (self), NULL); + + if (!mm_gdbus_modem_time_call_get_network_time_finish (MM_GDBUS_MODEM_TIME (self), &network_time, res, error)) + return NULL; + + return network_time; +} + +/** + * mm_modem_time_get_network_time: + * @self: A #MMModemTime. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously requests the current network time. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_time_get_network_time_finish() to get the result of the operation. + * + * See mm_modem_time_get_network_time_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_time_get_network_time (MMModemTime *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM_TIME (self)); + + mm_gdbus_modem_time_call_get_network_time (MM_GDBUS_MODEM_TIME (self), + cancellable, + callback, + user_data); +} + +/** + * mm_modem_time_get_network_time_sync: + * @self: A #MMModemTime. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously requests the current network time. + * + * The calling thread is blocked until a reply is received. See mm_modem_time_get_network_time() + * for the asynchronous version of this method. + * + * Returns: A string containing the network time, or %NULL if @error is set. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_time_get_network_time_sync (MMModemTime *self, + GCancellable *cancellable, + GError **error) +{ + gchar *network_time = NULL; + + g_return_val_if_fail (MM_IS_MODEM_TIME (self), NULL); + + if (!mm_gdbus_modem_time_call_get_network_time_sync (MM_GDBUS_MODEM_TIME (self), &network_time, cancellable, error)) + return NULL; + + return network_time; +} + +/*****************************************************************************/ + +static void +timezone_updated (MMModemTime *self, + GParamSpec *pspec) +{ + g_mutex_lock (&self->priv->timezone_mutex); + { + GVariant *dictionary; + + g_clear_object (&self->priv->timezone); + dictionary = mm_gdbus_modem_time_get_network_timezone (MM_GDBUS_MODEM_TIME (self)); + self->priv->timezone = (dictionary ? + mm_network_timezone_new_from_dictionary (dictionary, NULL) : + NULL); + } + g_mutex_unlock (&self->priv->timezone_mutex); +} + +static void +ensure_internal_timezone (MMModemTime *self, + MMNetworkTimezone **dup) +{ + g_mutex_lock (&self->priv->timezone_mutex); + { + /* If this is the first time ever asking for the object, setup the + * update listener and the initial object, if any. */ + if (!self->priv->timezone_id) { + GVariant *dictionary; + + dictionary = mm_gdbus_modem_time_dup_network_timezone (MM_GDBUS_MODEM_TIME (self)); + if (dictionary) { + self->priv->timezone = mm_network_timezone_new_from_dictionary (dictionary, NULL); + g_variant_unref (dictionary); + } + + /* No need to clear this signal connection when freeing self */ + self->priv->timezone_id = + g_signal_connect (self, + "notify::network-timezone", + G_CALLBACK (timezone_updated), + NULL); + } + + if (dup && self->priv->timezone) + *dup = g_object_ref (self->priv->timezone); + } + g_mutex_unlock (&self->priv->timezone_mutex); +} + +/** + * mm_modem_get_network_timezone: + * @self: A #MMModem. + * + * Gets the network timezone information. + * + * <warning>The values reported by @self are not updated when the values in the + * interface change. Instead, the client is expected to call + * mm_modem_get_network_timezone() again to get a new #MMNetworkTimezone with the + * new values.</warning> + * + * Returns: (transfer full) A #MMNetworkTimezone that must be freed with g_object_unref() or %NULL if unknown. + */ +MMNetworkTimezone * +mm_modem_time_get_network_timezone (MMModemTime *self) +{ + MMNetworkTimezone *tz = NULL; + + g_return_val_if_fail (MM_IS_MODEM_TIME (self), NULL); + + ensure_internal_timezone (self, &tz); + return tz; +} + +/** + * mm_modem_peek_network_timezone: + * @self: A #MMModem. + * + * Gets the network timezone information. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_modem_get_network_timezone() if on another + * thread.</warning> + * + * Returns: (transfer none) A #MMNetworkTimezone. Do not free the returned value, it belongs to @self. + */ +MMNetworkTimezone * +mm_modem_time_peek_network_timezone (MMModemTime *self) +{ + g_return_val_if_fail (MM_IS_MODEM_TIME (self), NULL); + + ensure_internal_timezone (self, NULL); + return self->priv->timezone; +} + +/*****************************************************************************/ + +static void +mm_modem_time_init (MMModemTime *self) +{ + /* Setup private data */ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, + MM_TYPE_MODEM_TIME, + MMModemTimePrivate); + g_mutex_init (&self->priv->timezone_mutex); +} + +static void +dispose (GObject *object) +{ + MMModemTime *self = MM_MODEM_TIME (object); + + g_clear_object (&self->priv->timezone); + + G_OBJECT_CLASS (mm_modem_time_parent_class)->dispose (object); +} + +static void +finalize (GObject *object) +{ + MMModemTime *self = MM_MODEM_TIME (object); + + g_mutex_clear (&self->priv->timezone_mutex); + + G_OBJECT_CLASS (mm_modem_time_parent_class)->finalize (object); +} + +static void +mm_modem_time_class_init (MMModemTimeClass *modem_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (modem_class); + + g_type_class_add_private (object_class, sizeof (MMModemTimePrivate)); + + /* Virtual methods */ + object_class->finalize = finalize; + object_class->dispose = dispose; +} diff --git a/libmm-glib/mm-modem-time.h b/libmm-glib/mm-modem-time.h new file mode 100644 index 0000000..c021179 --- /dev/null +++ b/libmm-glib/mm-modem-time.h @@ -0,0 +1,87 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2012 Aleksander Morgado <aleksander@gnu.org> + * Copyright (C) 2012 Google, Inc. + */ + +#ifndef _MM_MODEM_TIME_H_ +#define _MM_MODEM_TIME_H_ + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> + +#include "mm-gdbus-modem.h" +#include "mm-network-timezone.h" + +G_BEGIN_DECLS + +#define MM_TYPE_MODEM_TIME (mm_modem_time_get_type ()) +#define MM_MODEM_TIME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_MODEM_TIME, MMModemTime)) +#define MM_MODEM_TIME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_MODEM_TIME, MMModemTimeClass)) +#define MM_IS_MODEM_TIME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_MODEM_TIME)) +#define MM_IS_MODEM_TIME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), MM_TYPE_MODEM_TIME)) +#define MM_MODEM_TIME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_MODEM_TIME, MMModemTimeClass)) + +typedef struct _MMModemTime MMModemTime; +typedef struct _MMModemTimeClass MMModemTimeClass; +typedef struct _MMModemTimePrivate MMModemTimePrivate; + +/** + * MMModemTime: + * + * The #MMModemTime structure contains private data and should only be accessed + * using the provided API. + */ +struct _MMModemTime { + /*< private >*/ + MmGdbusModemTimeProxy parent; + MMModemTimePrivate *priv; +}; + +struct _MMModemTimeClass { + /*< private >*/ + MmGdbusModemTimeProxyClass parent; +}; + +GType mm_modem_time_get_type (void); + +const gchar *mm_modem_time_get_path (MMModemTime *self); +gchar *mm_modem_time_dup_path (MMModemTime *self); + +void mm_modem_time_get_network_time (MMModemTime *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gchar *mm_modem_time_get_network_time_finish (MMModemTime *self, + GAsyncResult *res, + GError **error); +gchar *mm_modem_time_get_network_time_sync (MMModemTime *self, + GCancellable *cancellable, + GError **error); + +MMNetworkTimezone *mm_modem_time_peek_network_timezone (MMModemTime *self); +MMNetworkTimezone *mm_modem_time_get_network_timezone (MMModemTime *self); + +G_END_DECLS + +#endif /* _MM_MODEM_TIME_H_ */ diff --git a/libmm-glib/mm-modem.c b/libmm-glib/mm-modem.c new file mode 100644 index 0000000..95685e6 --- /dev/null +++ b/libmm-glib/mm-modem.c @@ -0,0 +1,2873 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2011 - 2012 Aleksander Morgado <aleksander@gnu.org> + * Copyright (C) 2012 Google, Inc. + */ + +#include <gio/gio.h> +#include <string.h> + +#include "mm-common-helpers.h" +#include "mm-errors-types.h" +#include "mm-helpers.h" +#include "mm-modem.h" + +/** + * SECTION: mm-modem + * @title: MMModem + * @short_description: The Modem interface + * + * The #MMModem is an object providing access to the methods, signals and + * properties of the Modem interface. + * + * When the modem is exposed and available in the bus, it is ensured that at + * least this interface is also available. + */ + +G_DEFINE_TYPE (MMModem, mm_modem, MM_GDBUS_TYPE_MODEM_PROXY) + +struct _MMModemPrivate { + /* UnlockRetries */ + GMutex unlock_retries_mutex; + guint unlock_retries_id; + MMUnlockRetries *unlock_retries; + + /* Supported Modes */ + GMutex supported_modes_mutex; + guint supported_modes_id; + GArray *supported_modes; + + /* Supported Capabilities */ + GMutex supported_capabilities_mutex; + guint supported_capabilities_id; + GArray *supported_capabilities; + + /* Supported Bands */ + GMutex supported_bands_mutex; + guint supported_bands_id; + GArray *supported_bands; + + /* Current Bands */ + GMutex current_bands_mutex; + guint current_bands_id; + GArray *current_bands; +}; + +/*****************************************************************************/ + +/** + * mm_modem_get_path: (skip) + * @self: A #MMModem. + * + * Gets the DBus path of the #MMObject which implements this interface. + * + * Returns: (transfer none): The DBus path of the #MMObject object. Do not free the returned value, it belongs to @self. + */ +const gchar * +mm_modem_get_path (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + g_dbus_proxy_get_object_path (G_DBUS_PROXY (self))); +} + +/** + * mm_modem_dup_path: + * @self: A #MMModem. + * + * Gets a copy of the DBus path of the #MMObject object which implements this interface. + * + * Returns: (transfer full): The DBus path of the #MMObject. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_dup_path (MMModem *self) +{ + gchar *value; + + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + g_object_get (G_OBJECT (self), + "g-object-path", &value, + NULL); + + RETURN_NON_EMPTY_STRING (value); +} + +/*****************************************************************************/ + +/** + * mm_modem_get_sim_path: (skip) + * @self: A #MMModem. + * + * Gets the DBus path of the #MMSim handled in this #MMModem. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_modem_dup_sim_path() if on another + * thread.</warning> + * + * Returns: (transfer none): The DBus path of the #MMSim handled in this #MMModem, or %NULL if none available. Do not free the returned value, it belongs to @self. + */ +const gchar * +mm_modem_get_sim_path (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING (mm_gdbus_modem_get_sim (MM_GDBUS_MODEM (self))); +} + +/** + * mm_modem_dup_sim_path: + * @self: A #MMModem. + * + * Gets a copy of the DBus path of the #MMSim handled in this #MMModem. + * + * Returns: (transfer full): The DBus path of the #MMSim handled in this #MMModem, or %NULL if none available. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_dup_sim_path (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_modem_dup_sim (MM_GDBUS_MODEM (self))); +} + +/*****************************************************************************/ + +static void +supported_capabilities_updated (MMModem *self, + GParamSpec *pspec) +{ + g_mutex_lock (&self->priv->supported_capabilities_mutex); + { + GVariant *dictionary; + + if (self->priv->supported_capabilities) + g_array_unref (self->priv->supported_capabilities); + + dictionary = mm_gdbus_modem_get_supported_capabilities (MM_GDBUS_MODEM (self)); + self->priv->supported_capabilities = (dictionary ? + mm_common_capability_combinations_variant_to_garray (dictionary) : + NULL); + } + g_mutex_unlock (&self->priv->supported_capabilities_mutex); +} + +static gboolean +ensure_internal_supported_capabilities (MMModem *self, + MMModemCapability **dup_capabilities, + guint *dup_capabilities_n) +{ + gboolean ret; + + g_mutex_lock (&self->priv->supported_capabilities_mutex); + { + /* If this is the first time ever asking for the array, setup the + * update listener and the initial array, if any. */ + if (!self->priv->supported_capabilities_id) { + GVariant *dictionary; + + dictionary = mm_gdbus_modem_dup_supported_capabilities (MM_GDBUS_MODEM (self)); + if (dictionary) { + self->priv->supported_capabilities = mm_common_capability_combinations_variant_to_garray (dictionary); + g_variant_unref (dictionary); + } + + /* No need to clear this signal connection when freeing self */ + self->priv->supported_capabilities_id = + g_signal_connect (self, + "notify::supported-capabilities", + G_CALLBACK (supported_capabilities_updated), + NULL); + } + + if (!self->priv->supported_capabilities) + ret = FALSE; + else { + ret = TRUE; + + if (dup_capabilities && dup_capabilities_n) { + *dup_capabilities_n = self->priv->supported_capabilities->len; + if (self->priv->supported_capabilities->len > 0) { + *dup_capabilities = g_malloc (sizeof (MMModemCapability) * self->priv->supported_capabilities->len); + memcpy (*dup_capabilities, self->priv->supported_capabilities->data, sizeof (MMModemCapability) * self->priv->supported_capabilities->len); + } else + *dup_capabilities = NULL; + } + } + } + g_mutex_unlock (&self->priv->supported_capabilities_mutex); + + return ret; +} + +/** + * mm_modem_get_supported_capabilities: + * @self: A #MMModem. + * @capabilities: (out) (array length=n_capabilities): Return location for the array of #MMModemCapability values. The returned array should be freed with g_free() when no longer needed. + * @n_capabilities: (out): Return location for the number of values in @capabilities. + * + * Gets the list of combinations of generic families of access technologies supported by this #MMModem. + * + * Returns: %TRUE if @capabilities and @n_capabilities are set, %FALSE otherwise. + */ +gboolean +mm_modem_get_supported_capabilities (MMModem *self, + MMModemCapability **capabilities, + guint *n_capabilities) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + + return ensure_internal_supported_capabilities (self, capabilities, n_capabilities); +} + +/** + * mm_modem_peek_supported_capabilities: + * @self: A #MMModem. + * @capabilities: (out) (array length=n_capabilities): Return location for the array of #MMModemCapability values. Do not free the returned array, it is owned by @self. + * @n_capabilities: (out): Return location for the number of values in @capabilities. + * + * Gets the list of combinations of generic families of access technologies supported by this #MMModem. + * + * Returns: %TRUE if @capabilities and @n_capabilities are set, %FALSE otherwise. + */ +gboolean +mm_modem_peek_supported_capabilities (MMModem *self, + const MMModemCapability **capabilities, + guint *n_capabilities) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + g_return_val_if_fail (capabilities != NULL, FALSE); + g_return_val_if_fail (n_capabilities != NULL, FALSE); + + if (!ensure_internal_supported_capabilities (self, NULL, NULL)) + return FALSE; + + *n_capabilities = self->priv->supported_capabilities->len; + *capabilities = (MMModemCapability *)self->priv->supported_capabilities->data; + return TRUE; +} + +/*****************************************************************************/ + +/** + * mm_modem_get_current_capabilities: + * @self: A #MMModem. + * + * Gets the list of generic families of access technologies supported by this #MMModem + * without a firmware reload or reinitialization. + * + * Returns: A bitmask of #MMModemCapability flags. + */ +MMModemCapability +mm_modem_get_current_capabilities (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), MM_MODEM_CAPABILITY_NONE); + + return mm_gdbus_modem_get_current_capabilities (MM_GDBUS_MODEM (self)); +} + +/*****************************************************************************/ + +/** + * mm_modem_get_max_bearers: + * @self: a #MMModem. + * + * Gets the maximum number of defined packet data bearers this #MMModem supports. + * + * This is not the number of active/connected bearers the modem supports, + * but simply the number of bearers that may be defined at any given time. + * For example, POTS and CDMA2000-only devices support only one bearer, + * while GSM/UMTS devices typically support three or more, and any + * LTE-capable device (whether LTE-only, GSM/UMTS-capable, and/or + * CDMA2000-capable) also typically support three or more. + * + * Returns: the maximum number of defined packet data bearers. + */ +guint +mm_modem_get_max_bearers (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), 0); + + return mm_gdbus_modem_get_max_bearers (MM_GDBUS_MODEM (self)); +} + +/*****************************************************************************/ + +/** + * mm_modem_get_max_active_bearers: + * @self: a #MMModem. + * + * Gets the maximum number of active packet data bearers this #MMModem supports. + * + * POTS and CDMA2000-only devices support one active bearer, while GSM/UMTS + * and LTE-capable devices (including LTE/CDMA devices) typically support + * at least two active bearers. + * + * Returns: the maximum number of defined packet data bearers. + */ +guint +mm_modem_get_max_active_bearers (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), 0); + + return mm_gdbus_modem_get_max_active_bearers (MM_GDBUS_MODEM (self)); +} + +/*****************************************************************************/ + +/** + * mm_modem_get_manufacturer: + * @self: A #MMModem. + * + * Gets the equipment manufacturer, as reported by this #MMModem. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_modem_dup_manufacturer() if on another + * thread.</warning> + * + * Returns: (transfer none): The equipment manufacturer, or %NULL if none available. Do not free the returned value, it belongs to @self. + */ +const gchar * +mm_modem_get_manufacturer (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_modem_get_manufacturer (MM_GDBUS_MODEM (self))); +} + +/** + * mm_modem_dup_manufacturer: + * @self: A #MMModem. + * + * Gets a copy of the equipment manufacturer, as reported by this #MMModem. + * + * Returns: (transfer full): The equipment manufacturer, or %NULL if none available. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_dup_manufacturer (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_modem_dup_manufacturer (MM_GDBUS_MODEM (self))); +} + +/*****************************************************************************/ + +/** + * mm_modem_get_model: + * @self: A #MMModem. + * + * Gets the equipment model, as reported by this #MMModem. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_modem_dup_model() if on another + * thread.</warning> + * + * Returns: (transfer none): The equipment model, or %NULL if none available. Do not free the returned value, it belongs to @self. + */ +const gchar * +mm_modem_get_model (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_modem_get_model (MM_GDBUS_MODEM (self))); +} + +/** + * mm_modem_dup_model: + * @self: A #MMModem. + * + * Gets a copy of the equipment model, as reported by this #MMModem. + * + * Returns: (transfer full): The equipment model, or %NULL if none available. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_dup_model (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_modem_dup_model (MM_GDBUS_MODEM (self))); +} + +/*****************************************************************************/ + +/** + * mm_modem_get_revision: + * @self: A #MMModem. + * + * Gets the equipment revision, as reported by this #MMModem. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_modem_dup_revision() if on another + * thread.</warning> + * + * Returns: (transfer none): The equipment revision, or %NULL if none available. Do not free the returned value, it belongs to @self. + */ +const gchar * +mm_modem_get_revision (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_modem_get_revision (MM_GDBUS_MODEM (self))); +} + +/** + * mm_modem_dup_revision: + * @self: A #MMModem. + * + * Gets a copy of the equipment revision, as reported by this #MMModem. + * + * Returns: (transfer full): The equipment revision, or %NULL if none available. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_dup_revision (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_modem_dup_revision (MM_GDBUS_MODEM (self))); +} + +/*****************************************************************************/ + +/** + * mm_modem_get_device_identifier: + * @self: A #MMModem. + * + * Gets a best-effort device identifier based on various device information like + * model name, firmware revision, USB/PCI/PCMCIA IDs, and other properties. + * + * This ID is not guaranteed to be unique and may be shared between + * identical devices with the same firmware, but is intended to be "unique + * enough" for use as a casual device identifier for various user + * experience operations. + * + * This is not the device's IMEI or ESN since those may not be available + * before unlocking the device via a PIN. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_modem_dup_device_identifier() if on another + * thread.</warning> + * + * Returns: (transfer none): The device identifier, or %NULL if none available. Do not free the returned value, it belongs to @self. + */ +const gchar * +mm_modem_get_device_identifier (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_modem_get_device_identifier (MM_GDBUS_MODEM (self))); +} + +/** + * mm_modem_dup_device_identifier: + * @self: A #MMModem. + * + * Gets a copy of a best-effort device identifier based on various device information + * like model name, firmware revision, USB/PCI/PCMCIA IDs, and other properties. + * + * This ID is not guaranteed to be unique and may be shared between + * identical devices with the same firmware, but is intended to be "unique + * enough" for use as a casual device identifier for various user + * experience operations. + * + * This is not the device's IMEI or ESN since those may not be available + * before unlocking the device via a PIN. + * + * Returns: (transfer full): The device identifier, or %NULL if none available. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_dup_device_identifier (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_modem_dup_device_identifier (MM_GDBUS_MODEM (self))); +} + +/*****************************************************************************/ + +/** + * mm_modem_get_device: + * @self: A #MMModem. + * + * Gets the physical modem device reference (ie, USB, PCI, PCMCIA device), which + * may be dependent upon the operating system. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_modem_dup_device() if on another + * thread.</warning> + * + * Returns: (transfer none): The device, or %NULL if none available. Do not free the returned value, it belongs to @self. + */ +const gchar * +mm_modem_get_device (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_modem_get_device (MM_GDBUS_MODEM (self))); +} + +/** + * mm_modem_dup_device: + * @self: A #MMModem. + * + * Gets a copy of the physical modem device reference (ie, USB, PCI, PCMCIA device), which + * may be dependent upon the operating system. + * + * Returns: (transfer full): The device, or %NULL if none available. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_dup_device (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_modem_dup_device (MM_GDBUS_MODEM (self))); +} + +/*****************************************************************************/ + +/** + * mm_modem_get_drivers: + * @self: A #MMModem. + * + * Gets the Operating System device drivers handling communication with the modem + * hardware. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_modem_dup_drivers() if on another + * thread.</warning> + * + * Returns: (transfer none): The drivers, or %NULL if none available. Do not free the returned value, it belongs to @self. + */ +const gchar * const * +mm_modem_get_drivers (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + return mm_gdbus_modem_get_drivers (MM_GDBUS_MODEM (self)); +} + +/** + * mm_modem_dup_drivers: + * @self: A #MMModem. + * + * Gets a copy of the Operating System device driver handling communication with the modem + * hardware. + * + * Returns: (transfer full): The drivers, or %NULL if none available. The returned value should be freed with g_strfreev(). + */ +gchar ** +mm_modem_dup_drivers (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + return mm_gdbus_modem_dup_drivers (MM_GDBUS_MODEM (self)); +} + +/*****************************************************************************/ + +/** + * mm_modem_get_plugin: + * @self: A #MMModem. + * + * Gets the name of the plugin handling this #MMModem. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_modem_dup_plugin() if on another + * thread.</warning> + * + * Returns: (transfer none): The name of the plugin, or %NULL if none available. Do not free the returned value, it belongs to @self. + */ +const gchar * +mm_modem_get_plugin (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_modem_get_plugin (MM_GDBUS_MODEM (self))); +} + +/** + * mm_modem_dup_plugin: + * @self: A #MMModem. + * + * Gets a copy of the name of the plugin handling this #MMModem. + * + * Returns: (transfer full): The name of the plugin, or %NULL if none available. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_dup_plugin (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_modem_dup_plugin (MM_GDBUS_MODEM (self))); +} + +/*****************************************************************************/ + +/** + * mm_modem_get_primary_port: + * @self: A #MMModem. + * + * Gets the name of the primary port controlling this #MMModem. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_modem_dup_primary_port() if on another + * thread.</warning> + * + * Returns: (transfer none): The name of the primary port. Do not free the returned value, it belongs to @self. + */ +const gchar * +mm_modem_get_primary_port (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_modem_get_primary_port (MM_GDBUS_MODEM (self))); +} + +/** + * mm_modem_dup_primary_port: + * @self: A #MMModem. + * + * Gets a copy of the name of the primary port controlling this #MMModem. + * + * Returns: (transfer full): The name of the primary port. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_dup_primary_port (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_modem_dup_primary_port (MM_GDBUS_MODEM (self))); +} + +/*****************************************************************************/ + +/** + * mm_modem_get_equipment_identifier: + * @self: A #MMModem. + * + * Gets the identity of the #MMModem. + * + * This will be the IMEI number for GSM devices and the hex-format ESN/MEID + * for CDMA devices. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_modem_dup_plugin() if on another + * thread.</warning> + * + * Returns: (transfer none): The equipment identifier, or %NULL if none available. Do not free the returned value, it belongs to @self. + */ +const gchar * +mm_modem_get_equipment_identifier (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_modem_get_equipment_identifier (MM_GDBUS_MODEM (self))); +} + +/** + * mm_modem_dup_equipment_identifier: + * @self: A #MMModem. + * + * Gets a copy of the identity of the #MMModem. + * + * This will be the IMEI number for GSM devices and the hex-format ESN/MEID + * for CDMA devices. + * + * Returns: (transfer full): The equipment identifier, or %NULL if none available. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_dup_equipment_identifier (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_modem_dup_equipment_identifier (MM_GDBUS_MODEM (self))); +} + +/*****************************************************************************/ + +/** + * mm_modem_get_own_numbers: (skip) + * @self: A #MMModem. + * + * Gets the list of numbers (e.g. MSISDN in 3GPP) being currently handled by + * this modem. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_modem_dup_own_numbers() if on another + * thread.</warning> + * + * Returns: (transfer none): The list of own numbers or %NULL if none available. Do not free the returned value, it belongs to @self. + */ +const gchar *const * +mm_modem_get_own_numbers (MMModem *self) +{ + const gchar *const *own; + + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + own = mm_gdbus_modem_get_own_numbers (MM_GDBUS_MODEM (self)); + + return (own && own[0] ? own : NULL); +} + +/** + * mm_modem_dup_own_numbers: + * @self: A #MMModem. + * + * Gets a copy of the list of numbers (e.g. MSISDN in 3GPP) being currently + * handled by this modem. + * + * Returns: (transfer full): The list of own numbers or %NULL if none is available. The returned value should be freed with g_strfreev(). + */ +gchar ** +mm_modem_dup_own_numbers (MMModem *self) +{ + gchar **own; + + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + own = mm_gdbus_modem_dup_own_numbers (MM_GDBUS_MODEM (self)); + if (own && own[0]) + return own; + + g_strfreev (own); + return NULL; +} + +/*****************************************************************************/ + +/** + * mm_modem_get_unlock_required: + * @self: A #MMModem. + * + * Gets current lock state of the #MMModem. + * + * Returns: A #MMModemLock value, specifying the current lock state. + */ +MMModemLock +mm_modem_get_unlock_required (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), MM_MODEM_LOCK_UNKNOWN); + + return (MMModemLock) mm_gdbus_modem_get_unlock_required (MM_GDBUS_MODEM (self)); +} + +/*****************************************************************************/ + +static void +unlock_retries_updated (MMModem *self, + GParamSpec *pspec) +{ + g_mutex_lock (&self->priv->unlock_retries_mutex); + { + GVariant *dictionary; + + g_clear_object (&self->priv->unlock_retries); + + /* TODO: update existing object instead of re-creating? */ + dictionary = mm_gdbus_modem_get_unlock_retries (MM_GDBUS_MODEM (self)); + if (dictionary) + self->priv->unlock_retries = mm_unlock_retries_new_from_dictionary (dictionary); + } + g_mutex_unlock (&self->priv->unlock_retries_mutex); +} + +static void +ensure_internal_unlock_retries (MMModem *self, + MMUnlockRetries **dup) +{ + g_mutex_lock (&self->priv->unlock_retries_mutex); + { + /* If this is the first time ever asking for the object, setup the + * update listener and the initial object, if any. */ + if (!self->priv->unlock_retries_id) { + GVariant *dictionary; + + dictionary = mm_gdbus_modem_dup_unlock_retries (MM_GDBUS_MODEM (self)); + if (dictionary) { + self->priv->unlock_retries = mm_unlock_retries_new_from_dictionary (dictionary); + g_variant_unref (dictionary); + } + + /* No need to clear this signal connection when freeing self */ + self->priv->unlock_retries_id = + g_signal_connect (self, + "notify::unlock-retries", + G_CALLBACK (unlock_retries_updated), + NULL); + } + + if (dup && self->priv->unlock_retries) + *dup = g_object_ref (self->priv->unlock_retries); + } + g_mutex_unlock (&self->priv->unlock_retries_mutex); +} + +/** + * mm_modem_get_unlock_retries: + * @self: A #MMModem. + * + * Gets a #MMUnlockRetries object, which provides, for each + * <link linkend="MMModemLock">MMModemLock</link> handled by the modem, the + * number of PIN tries remaining before the code becomes blocked (requiring a PUK) + * or permanently blocked. + * + * <warning>The values reported by @self are not updated when the values in the + * interface change. Instead, the client is expected to call + * mm_modem_get_unlock_retries() again to get a new #MMUnlockRetries with the + * new values.</warning> + * + * Returns: (transfer full) A #MMUnlockRetries that must be freed with g_object_unref() or %NULL if unknown. + */ +MMUnlockRetries * +mm_modem_get_unlock_retries (MMModem *self) +{ + MMUnlockRetries *unlock_retries = NULL; + + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + ensure_internal_unlock_retries (self, &unlock_retries); + return unlock_retries; +} + +/** + * mm_modem_peek_unlock_retries: + * @self: A #MMModem. + * + * Gets a #MMUnlockRetries object, which provides, for each + * <link linkend="MMModemLock">MMModemLock</link> handled by the modem, the + * number of PIN tries remaining before the code becomes blocked (requiring a PUK) + * or permanently blocked. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_modem_get_unlock_retries() if on another + * thread.</warning> + * + * Returns: (transfer none) A #MMUnlockRetries. Do not free the returned value, it belongs to @self. + */ +MMUnlockRetries * +mm_modem_peek_unlock_retries (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + ensure_internal_unlock_retries (self, NULL); + return self->priv->unlock_retries; +} + +/*****************************************************************************/ + +/** + * mm_modem_get_state: + * @self: A #MMModem. + * + * Gets the overall state of the #MMModem. + * + * Returns: A #MMModemState value. + */ +MMModemState +mm_modem_get_state (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), MM_MODEM_STATE_UNKNOWN); + + return (MMModemState) mm_gdbus_modem_get_state (MM_GDBUS_MODEM (self)); +} + +/*****************************************************************************/ + +/** + * mm_modem_get_state_failed_reason: + * @self: A #MMModem. + * + * Gets the reason specifying why the modem is in #MM_MODEM_STATE_FAILED state. + * + * Returns: A #MMModemStateFailedReason value. + */ +MMModemStateFailedReason +mm_modem_get_state_failed_reason (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), MM_MODEM_STATE_FAILED_REASON_UNKNOWN); + + return (MMModemStateFailedReason) mm_gdbus_modem_get_state_failed_reason (MM_GDBUS_MODEM (self)); +} + +/*****************************************************************************/ + +/** + * mm_modem_get_power_state: + * @self: A #MMModem. + * + * Gets the power state of the #MMModem. + * + * Returns: A #MMModemPowerState value. + */ +MMModemPowerState +mm_modem_get_power_state (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), MM_MODEM_POWER_STATE_UNKNOWN); + + return (MMModemPowerState) mm_gdbus_modem_get_power_state (MM_GDBUS_MODEM (self)); +} + +/*****************************************************************************/ + +/** + * mm_modem_get_access_technology: + * @self: A #MMModem. + * + * Gets the current network access technology used by the #MMModem to communicate + * with the network. + * + * Returns: A ##MMModemAccessTechnology value. + */ +MMModemAccessTechnology +mm_modem_get_access_technologies (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN); + + return (MMModemAccessTechnology) mm_gdbus_modem_get_access_technologies (MM_GDBUS_MODEM (self)); +} + +/*****************************************************************************/ + +/** + * mm_modem_get_signal_quality: + * @self: A #MMModem. + * @recent: (out): Return location for the flag specifying if the signal quality value was recent or not. + * + * Gets the signal quality value in percent (0 - 100) of the dominant access technology + * the #MMModem is using to communicate with the network. + * + * Always 0 for POTS devices. + * + * Returns: The signal quality. + */ +guint +mm_modem_get_signal_quality (MMModem *self, + gboolean *recent) +{ + GVariant *variant; + gboolean is_recent = FALSE; + guint quality = 0; + + g_return_val_if_fail (MM_IS_MODEM (self), 0); + + variant = mm_gdbus_modem_dup_signal_quality (MM_GDBUS_MODEM (self)); + if (variant) { + g_variant_get (variant, + "(ub)", + &quality, + &is_recent); + g_variant_unref (variant); + } + + if (recent) + *recent = is_recent; + return quality; +} + +/*****************************************************************************/ + +static void +supported_modes_updated (MMModem *self, + GParamSpec *pspec) +{ + g_mutex_lock (&self->priv->supported_modes_mutex); + { + GVariant *dictionary; + + if (self->priv->supported_modes) + g_array_unref (self->priv->supported_modes); + + dictionary = mm_gdbus_modem_get_supported_modes (MM_GDBUS_MODEM (self)); + self->priv->supported_modes = (dictionary ? + mm_common_mode_combinations_variant_to_garray (dictionary) : + NULL); + } + g_mutex_unlock (&self->priv->supported_modes_mutex); +} + +static gboolean +ensure_internal_supported_modes (MMModem *self, + MMModemModeCombination **dup_modes, + guint *dup_modes_n) +{ + gboolean ret; + + g_mutex_lock (&self->priv->supported_modes_mutex); + { + /* If this is the first time ever asking for the array, setup the + * update listener and the initial array, if any. */ + if (!self->priv->supported_modes_id) { + GVariant *dictionary; + + dictionary = mm_gdbus_modem_dup_supported_modes (MM_GDBUS_MODEM (self)); + if (dictionary) { + self->priv->supported_modes = mm_common_mode_combinations_variant_to_garray (dictionary); + g_variant_unref (dictionary); + } + + /* No need to clear this signal connection when freeing self */ + self->priv->supported_modes_id = + g_signal_connect (self, + "notify::supported-modes", + G_CALLBACK (supported_modes_updated), + NULL); + } + + if (!self->priv->supported_modes) + ret = FALSE; + else { + ret = TRUE; + + if (dup_modes && dup_modes_n) { + *dup_modes_n = self->priv->supported_modes->len; + if (self->priv->supported_modes->len > 0) { + *dup_modes = g_malloc (sizeof (MMModemModeCombination) * self->priv->supported_modes->len); + memcpy (*dup_modes, self->priv->supported_modes->data, sizeof (MMModemModeCombination) * self->priv->supported_modes->len); + } else + *dup_modes = NULL; + } + } + } + g_mutex_unlock (&self->priv->supported_modes_mutex); + + return ret; +} + +/** + * mm_modem_get_supported_modes: + * @self: A #MMModem. + * @modes: (out) (array length=n_modes): Return location for the array of #MMModemModeCombination structs. The returned array should be freed with g_free() when no longer needed. + * @n_modes: (out): Return location for the number of values in @modes. + * + * Gets the list of supported mode combinations. + * + * Returns: %TRUE if @modes and @n_modes are set, %FALSE otherwise. + */ +gboolean +mm_modem_get_supported_modes (MMModem *self, + MMModemModeCombination **modes, + guint *n_modes) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + g_return_val_if_fail (modes != NULL, FALSE); + g_return_val_if_fail (n_modes != NULL, FALSE); + + return ensure_internal_supported_modes (self, modes, n_modes); +} + +/** + * mm_modem_peek_supported_modes: + * @self: A #MMModem. + * @modes: (out) (array length=n_modes): Return location for the array of #MMModemModeCombination values. Do not free the returned array, it is owned by @self. + * @n_modes: (out): Return location for the number of values in @modes. + * + * Gets the list of supported mode combinations. + * + * Returns: %TRUE if @modes and @n_modes are set, %FALSE otherwise. + */ +gboolean +mm_modem_peek_supported_modes (MMModem *self, + const MMModemModeCombination **modes, + guint *n_modes) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + g_return_val_if_fail (modes != NULL, FALSE); + g_return_val_if_fail (n_modes != NULL, FALSE); + + if (!ensure_internal_supported_modes (self, NULL, NULL)) + return FALSE; + + *n_modes = self->priv->supported_modes->len; + *modes = (MMModemModeCombination *)self->priv->supported_modes->data; + return TRUE; +} + +/*****************************************************************************/ + +/** + * mm_modem_get_current_modes: + * @self: A #MMModem. + * @allowed: (out): Return location for a bitmask of #MMModemMode values. + * @preferred: (out): Return location for a #MMModemMode value. + * + * Gets the list of modes specifying the access technologies (eg 2G/3G/4G) + * the #MMModem is currently allowed to use when connecting to a network, as + * well as the preferred one, if any. + * + * Returns: %TRUE if @allowed and @preferred are set, %FALSE otherwise. + */ +gboolean +mm_modem_get_current_modes (MMModem *self, + MMModemMode *allowed, + MMModemMode *preferred) +{ + GVariant *variant; + + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + g_return_val_if_fail (allowed != NULL, FALSE); + g_return_val_if_fail (preferred != NULL, FALSE); + + variant = mm_gdbus_modem_dup_current_modes (MM_GDBUS_MODEM (self)); + if (variant) { + g_variant_get (variant, + "(uu)", + allowed, + preferred); + g_variant_unref (variant); + return TRUE; + } + + return FALSE; +} + +/*****************************************************************************/ + +static void +supported_bands_updated (MMModem *self, + GParamSpec *pspec) +{ + g_mutex_lock (&self->priv->supported_bands_mutex); + { + GVariant *dictionary; + + if (self->priv->supported_bands) + g_array_unref (self->priv->supported_bands); + + dictionary = mm_gdbus_modem_get_supported_bands (MM_GDBUS_MODEM (self)); + self->priv->supported_bands = (dictionary ? + mm_common_bands_variant_to_garray (dictionary) : + NULL); + } + g_mutex_unlock (&self->priv->supported_bands_mutex); +} + +static gboolean +ensure_internal_supported_bands (MMModem *self, + MMModemBand **dup_bands, + guint *dup_bands_n) +{ + gboolean ret; + + g_mutex_lock (&self->priv->supported_bands_mutex); + { + /* If this is the first time ever asking for the array, setup the + * update listener and the initial array, if any. */ + if (!self->priv->supported_bands_id) { + GVariant *dictionary; + + dictionary = mm_gdbus_modem_dup_supported_bands (MM_GDBUS_MODEM (self)); + if (dictionary) { + self->priv->supported_bands = mm_common_bands_variant_to_garray (dictionary); + g_variant_unref (dictionary); + } + + /* No need to clear this signal connection when freeing self */ + self->priv->supported_bands_id = + g_signal_connect (self, + "notify::supported-bands", + G_CALLBACK (supported_bands_updated), + NULL); + } + + if (!self->priv->supported_bands) + ret = FALSE; + else { + ret = TRUE; + + if (dup_bands && dup_bands_n) { + *dup_bands_n = self->priv->supported_bands->len; + if (self->priv->supported_bands->len > 0) { + *dup_bands = g_malloc (sizeof (MMModemBand) * self->priv->supported_bands->len); + memcpy (*dup_bands, self->priv->supported_bands->data, sizeof (MMModemBand) * self->priv->supported_bands->len); + } else + *dup_bands = NULL; + } + } + } + g_mutex_unlock (&self->priv->supported_bands_mutex); + + return ret; +} + +/** + * mm_modem_get_supported_bands: + * @self: A #MMModem. + * @bands: (out) (array length=n_bands): Return location for the array of #MMModemBand values. The returned array should be freed with g_free() when no longer needed. + * @n_bands: (out): Return location for the number of values in @bands. + * + * Gets the list of radio frequency and technology bands supported by the #MMModem. + * + * For POTS devices, only #MM_MODEM_BAND_ANY will be returned in @bands. + * + * Returns: %TRUE if @bands and @n_bands are set, %FALSE otherwise. + */ +gboolean +mm_modem_get_supported_bands (MMModem *self, + MMModemBand **bands, + guint *n_bands) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + g_return_val_if_fail (bands != NULL, FALSE); + g_return_val_if_fail (n_bands != NULL, FALSE); + + return ensure_internal_supported_bands (self, bands, n_bands); +} + +/** + * mm_modem_peek_supported_bands: + * @self: A #MMModem. + * @bands: (out) (array length=n_bands): Return location for the array of #MMModemBand values. Do not free the returned array, it is owned by @self. + * @n_bands: (out): Return location for the number of values in @bands. + * + * Gets the list of radio frequency and technology bands supported by the #MMModem. + * + * For POTS devices, only #MM_MODEM_BAND_ANY will be returned in @bands. + * + * Returns: %TRUE if @bands and @n_bands are set, %FALSE otherwise. + */ +gboolean +mm_modem_peek_supported_bands (MMModem *self, + const MMModemBand **bands, + guint *n_bands) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + g_return_val_if_fail (bands != NULL, FALSE); + g_return_val_if_fail (n_bands != NULL, FALSE); + + if (!ensure_internal_supported_bands (self, NULL, NULL)) + return FALSE; + + *n_bands = self->priv->supported_bands->len; + *bands = (MMModemBand *)self->priv->supported_bands->data; + return TRUE; +} + +/*****************************************************************************/ + +static void +current_bands_updated (MMModem *self, + GParamSpec *pspec) +{ + g_mutex_lock (&self->priv->current_bands_mutex); + { + GVariant *dictionary; + + if (self->priv->current_bands) + g_array_unref (self->priv->current_bands); + + dictionary = mm_gdbus_modem_get_current_bands (MM_GDBUS_MODEM (self)); + self->priv->current_bands = (dictionary ? + mm_common_bands_variant_to_garray (dictionary) : + NULL); + } + g_mutex_unlock (&self->priv->current_bands_mutex); +} + +static gboolean +ensure_internal_current_bands (MMModem *self, + MMModemBand **dup_bands, + guint *dup_bands_n) +{ + gboolean ret; + + g_mutex_lock (&self->priv->current_bands_mutex); + { + /* If this is the first time ever asking for the array, setup the + * update listener and the initial array, if any. */ + if (!self->priv->current_bands_id) { + GVariant *dictionary; + + dictionary = mm_gdbus_modem_dup_current_bands (MM_GDBUS_MODEM (self)); + if (dictionary) { + self->priv->current_bands = mm_common_bands_variant_to_garray (dictionary); + g_variant_unref (dictionary); + } + + /* No need to clear this signal connection when freeing self */ + self->priv->current_bands_id = + g_signal_connect (self, + "notify::current-bands", + G_CALLBACK (current_bands_updated), + NULL); + } + + if (!self->priv->current_bands) + ret = FALSE; + else { + ret = TRUE; + + if (dup_bands && dup_bands_n) { + *dup_bands_n = self->priv->current_bands->len; + if (self->priv->current_bands->len > 0) { + *dup_bands = g_malloc (sizeof (MMModemBand) * self->priv->current_bands->len); + memcpy (*dup_bands, self->priv->current_bands->data, sizeof (MMModemBand) * self->priv->current_bands->len); + } else + *dup_bands = NULL; + } + } + } + g_mutex_unlock (&self->priv->current_bands_mutex); + + return ret; +} + +/** + * mm_modem_get_current_bands: + * @self: A #MMModem. + * @bands: (out) (array length=n_bands): Return location for the array of #MMModemBand values. The returned array should be freed with g_free() when no longer needed. + * @n_bands: (out): Return location for the number of values in @bands. + * + * Gets the list of radio frequency and technology bands the #MMModem is currently + * using when connecting to a network. + * + * For POTS devices, only the #MM_MODEM_BAND_ANY band is supported. + * + * Returns: %TRUE if @bands and @n_bands are set, %FALSE otherwise. + */ +gboolean +mm_modem_get_current_bands (MMModem *self, + MMModemBand **bands, + guint *n_bands) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + g_return_val_if_fail (bands != NULL, FALSE); + g_return_val_if_fail (n_bands != NULL, FALSE); + + return ensure_internal_current_bands (self, bands, n_bands); +} + +/** + * mm_modem_peek_current_bands: + * @self: A #MMModem. + * @bands: (out) (array length=n_storages): Return location for the array of #MMModemBand values. Do not free the returned value, it is owned by @self. + * @n_bands: (out): Return location for the number of values in @bands. + * + * Gets the list of radio frequency and technology bands the #MMModem is currently + * using when connecting to a network. + * + * For POTS devices, only the #MM_MODEM_BAND_ANY band is supported. + * + * Returns: %TRUE if @bands and @n_bands are set, %FALSE otherwise. + */ +gboolean +mm_modem_peek_current_bands (MMModem *self, + const MMModemBand **bands, + guint *n_bands) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + g_return_val_if_fail (bands != NULL, FALSE); + g_return_val_if_fail (n_bands != NULL, FALSE); + + if (!ensure_internal_current_bands (self, NULL, NULL)) + return FALSE; + + *n_bands = self->priv->current_bands->len; + *bands = (MMModemBand *)self->priv->current_bands->data; + return TRUE; +} + +/*****************************************************************************/ + +/** + * mm_modem_get_supported_ip_families: + * @self: A #MMModem. + * + * Gets the list of supported IP families. + * + * Returns: A bitmask of #MMBearerIpFamily values. + */ +MMBearerIpFamily +mm_modem_get_supported_ip_families (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), MM_BEARER_IP_FAMILY_NONE); + + return (MMBearerIpFamily) mm_gdbus_modem_get_supported_ip_families (MM_GDBUS_MODEM (self)); +} + +/*****************************************************************************/ + +/** + * mm_modem_enable_finish: + * @self: A #MMModem. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_enable(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_enable(). + * + * Returns: %TRUE if the modem was properly enabled, %FALSE if @error is set. + */ +gboolean +mm_modem_enable_finish (MMModem *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + + return mm_gdbus_modem_call_enable_finish (MM_GDBUS_MODEM (self), res, error); +} + +/** + * mm_modem_enable: + * @self: A #MMModem. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously tries to enable the #MMModem. When enabled, the modem's radio is + * powered on and data sessions, voice calls, location services, and Short Message + * Service may be available. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_enable_finish() to get the result of the operation. + * + * See mm_modem_enable_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_enable (MMModem *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM (self)); + + mm_gdbus_modem_call_enable (MM_GDBUS_MODEM (self), TRUE, cancellable, callback, user_data); +} + +/** + * mm_modem_enable_sync: + * @self: A #MMModem. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously tries to enable the #MMModem. When enabled, the modem's radio is + * powered on and data sessions, voice calls, location services, and Short Message + * Service may be available. + * + * The calling thread is blocked until a reply is received. See mm_modem_enable() + * for the asynchronous version of this method. + * + * Returns: %TRUE if the modem was properly enabled, %FALSE if @error is set. + */ +gboolean +mm_modem_enable_sync (MMModem *self, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + + return mm_gdbus_modem_call_enable_sync (MM_GDBUS_MODEM (self), TRUE, cancellable, error); +} + +/*****************************************************************************/ + +/** + * mm_modem_disable_finish: + * @self: A #MMModem. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_disable(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_disable(). + * + * Returns: %TRUE if the modem was properly disabled, %FALSE if @error is set. + */ +gboolean +mm_modem_disable_finish (MMModem *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + + return mm_gdbus_modem_call_enable_finish (MM_GDBUS_MODEM (self), res, error); +} + +/** + * mm_modem_disable: + * @self: A #MMModem. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously tries to disable the #MMModem. When disabled, the modem enters + * low-power state and no network-related operations are available. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_disable_finish() to get the result of the operation. + * + * See mm_modem_disable_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_disable (MMModem *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM (self)); + + mm_gdbus_modem_call_enable (MM_GDBUS_MODEM (self), FALSE, cancellable, callback, user_data); +} + +/** + * mm_modem_disable_sync: + * @self: A #MMModem. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously tries to disable the #MMModem. When disabled, the modem enters + * low-power state and no network-related operations are available. + * + * The calling thread is blocked until a reply is received. See mm_modem_disable() + * for the asynchronous version of this method. + * + * Returns: %TRUE if the modem was properly disabled, %FALSE if @error is set. + */ +gboolean +mm_modem_disable_sync (MMModem *self, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + + return mm_gdbus_modem_call_enable_sync (MM_GDBUS_MODEM (self), FALSE, cancellable, error); +} + +/*****************************************************************************/ + +typedef struct { + MMModem *self; + GSimpleAsyncResult *result; + GCancellable *cancellable; + gchar **bearer_paths; + GList *bearer_objects; + guint i; +} ListBearersContext; + +static void +bearer_object_list_free (GList *list) +{ + g_list_free_full (list, (GDestroyNotify) g_object_unref); +} + +static void +list_bearers_context_complete_and_free (ListBearersContext *ctx) +{ + g_simple_async_result_complete (ctx->result); + + g_strfreev (ctx->bearer_paths); + bearer_object_list_free (ctx->bearer_objects); + g_object_unref (ctx->result); + if (ctx->cancellable) + g_object_unref (ctx->cancellable); + g_object_ref (ctx->self); + g_slice_free (ListBearersContext, ctx); +} + +/** + * mm_modem_list_bearers_finish: + * @self: A #MMModem. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_list_bearers(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_list_bearers(). + * + * Returns: (transfer full): The list of #MMBearer objects, or %NULL if either none found or if @error is set. + */ +GList * +mm_modem_list_bearers_finish (MMModem *self, + GAsyncResult *res, + GError **error) +{ + GList *list; + + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error)) + return NULL; + + list = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)); + + /* The list we got, including the objects within, is owned by the async result; + * so we'll make sure we return a new list */ + g_list_foreach (list, (GFunc)g_object_ref, NULL); + return g_list_copy (list); +} + +static void create_next_bearer (ListBearersContext *ctx); + +static void +modem_list_bearers_build_object_ready (GDBusConnection *connection, + GAsyncResult *res, + ListBearersContext *ctx) +{ + GObject *bearer; + GError *error = NULL; + GObject *source_object; + + source_object = g_async_result_get_source_object (res); + bearer = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, &error); + g_object_unref (source_object); + + if (error) { + g_simple_async_result_take_error (ctx->result, error); + list_bearers_context_complete_and_free (ctx); + return; + } + + /* Keep the object */ + ctx->bearer_objects = g_list_prepend (ctx->bearer_objects, bearer); + + /* If no more bearers, just end here. */ + if (!ctx->bearer_paths[++ctx->i]) { + g_simple_async_result_set_op_res_gpointer (ctx->result, + ctx->bearer_objects, + (GDestroyNotify)bearer_object_list_free); + ctx->bearer_objects = NULL; + list_bearers_context_complete_and_free (ctx); + return; + } + + /* Keep on creating next object */ + create_next_bearer (ctx); +} + +static void +create_next_bearer (ListBearersContext *ctx) +{ + g_async_initable_new_async (MM_TYPE_BEARER, + G_PRIORITY_DEFAULT, + ctx->cancellable, + (GAsyncReadyCallback)modem_list_bearers_build_object_ready, + ctx, + "g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + "g-name", MM_DBUS_SERVICE, + "g-connection", g_dbus_proxy_get_connection (G_DBUS_PROXY (ctx->self)), + "g-object-path", ctx->bearer_paths[ctx->i], + "g-interface-name", "org.freedesktop.ModemManager1.Bearer", + NULL); +} + +static void +modem_list_bearers_ready (MMModem *self, + GAsyncResult *res, + ListBearersContext *ctx) +{ + GError *error = NULL; + + mm_gdbus_modem_call_list_bearers_finish (MM_GDBUS_MODEM (self), &ctx->bearer_paths, res, &error); + if (error) { + g_simple_async_result_take_error (ctx->result, error); + list_bearers_context_complete_and_free (ctx); + return; + } + + /* If no bearers, just end here. */ + if (!ctx->bearer_paths || !ctx->bearer_paths[0]) { + g_simple_async_result_set_op_res_gpointer (ctx->result, NULL, NULL); + list_bearers_context_complete_and_free (ctx); + return; + } + + /* Got list of paths. If at least one found, start creating objects for each */ + ctx->i = 0; + create_next_bearer (ctx); +} + +/** + * mm_modem_list_bearers: + * @self: A #MMModem. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously lists the packet data bearers in the #MMModem. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_list_bearers_finish() to get the result of the operation. + * + * See mm_modem_list_bearers_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_list_bearers (MMModem *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + ListBearersContext *ctx; + + g_return_if_fail (MM_IS_MODEM (self)); + + ctx = g_slice_new0 (ListBearersContext); + ctx->self = g_object_ref (self); + ctx->result = g_simple_async_result_new (G_OBJECT (self), + callback, + user_data, + mm_modem_list_bearers); + if (cancellable) + ctx->cancellable = g_object_ref (cancellable); + + mm_gdbus_modem_call_list_bearers (MM_GDBUS_MODEM (self), + cancellable, + (GAsyncReadyCallback)modem_list_bearers_ready, + ctx); +} + +/** + * mm_modem_list_bearers_sync: + * @self: A #MMModem. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously lists the packet data bearers in the #MMModem. + * + * The calling thread is blocked until a reply is received. See mm_modem_list_bearers() + * for the asynchronous version of this method. + * + * Returns: (transfer full): The list of #MMBearer objects, or %NULL if either none found or if @error is set. + */ +GList * +mm_modem_list_bearers_sync (MMModem *self, + GCancellable *cancellable, + GError **error) +{ + GList *bearer_objects = NULL; + gchar **bearer_paths = NULL; + guint i; + + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + if (!mm_gdbus_modem_call_list_bearers_sync (MM_GDBUS_MODEM (self), + &bearer_paths, + cancellable, + error)) + return NULL; + + /* Only non-empty lists are returned */ + if (!bearer_paths) + return NULL; + + for (i = 0; bearer_paths[i]; i++) { + GObject *bearer; + + bearer = g_initable_new (MM_TYPE_BEARER, + cancellable, + error, + "g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + "g-name", MM_DBUS_SERVICE, + "g-connection", g_dbus_proxy_get_connection (G_DBUS_PROXY (self)), + "g-object-path", bearer_paths[i], + "g-interface-name", "org.freedesktop.ModemManager1.Bearer", + NULL); + if (!bearer) { + bearer_object_list_free (bearer_objects); + g_strfreev (bearer_paths); + return NULL; + } + + /* Keep the object */ + bearer_objects = g_list_prepend (bearer_objects, bearer); + } + + g_strfreev (bearer_paths); + return bearer_objects; +} + +/*****************************************************************************/ + +typedef struct { + GSimpleAsyncResult *result; + GCancellable *cancellable; +} CreateBearerContext; + +static void +create_bearer_context_complete_and_free (CreateBearerContext *ctx) +{ + g_simple_async_result_complete (ctx->result); + g_object_unref (ctx->result); + if (ctx->cancellable) + g_object_unref (ctx->cancellable); + g_slice_free (CreateBearerContext, ctx); +} + +/** + * mm_modem_create_bearer_finish: + * @self: A #MMModem. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_create_bearer(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_create_bearer(). + * + * Returns: (transfer full): A newly created #MMBearer, or %NULL if @error is set. + */ +MMBearer * +mm_modem_create_bearer_finish (MMModem *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error)) + return NULL; + + return g_object_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res))); +} + +static void +modem_new_bearer_ready (GDBusConnection *connection, + GAsyncResult *res, + CreateBearerContext *ctx) +{ + GError *error = NULL; + GObject *bearer; + GObject *source_object; + + source_object = g_async_result_get_source_object (res); + bearer = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, &error); + g_object_unref (source_object); + + if (error) + g_simple_async_result_take_error (ctx->result, error); + else + g_simple_async_result_set_op_res_gpointer (ctx->result, + bearer, + (GDestroyNotify)g_object_unref); + + create_bearer_context_complete_and_free (ctx); +} + +static void +modem_create_bearer_ready (MMModem *self, + GAsyncResult *res, + CreateBearerContext *ctx) +{ + GError *error = NULL; + gchar *bearer_path = NULL; + + if (!mm_gdbus_modem_call_create_bearer_finish (MM_GDBUS_MODEM (self), + &bearer_path, + res, + &error)) { + g_simple_async_result_take_error (ctx->result, error); + create_bearer_context_complete_and_free (ctx); + g_free (bearer_path); + return; + } + + g_async_initable_new_async (MM_TYPE_BEARER, + G_PRIORITY_DEFAULT, + ctx->cancellable, + (GAsyncReadyCallback)modem_new_bearer_ready, + ctx, + "g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + "g-name", MM_DBUS_SERVICE, + "g-connection", g_dbus_proxy_get_connection (G_DBUS_PROXY (self)), + "g-object-path", bearer_path, + "g-interface-name", "org.freedesktop.ModemManager1.Bearer", + NULL); + g_free (bearer_path); +} + +/** + * mm_modem_create_bearer: + * @self: A #MMModem. + * @properties: A #MMBearerProperties object with the properties to use. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously creates a new packet data bearer in the #MMModem. + * + * This request may fail if the modem does not support additional bearers, + * if too many bearers are already defined, or if @properties are invalid. + * + * See <link linkend="gdbus-method-org-freedesktop-ModemManager1-Modem.CreateBearer">CreateBearer</link> to check which properties may be passed. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_create_bearer_finish() to get the result of the operation. + * + * See mm_modem_create_bearer_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_create_bearer (MMModem *self, + MMBearerProperties *properties, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + CreateBearerContext *ctx; + GVariant *dictionary; + + g_return_if_fail (MM_IS_MODEM (self)); + + ctx = g_slice_new0 (CreateBearerContext); + ctx->result = g_simple_async_result_new (G_OBJECT (self), + callback, + user_data, + mm_modem_create_bearer); + if (cancellable) + ctx->cancellable = g_object_ref (cancellable); + + dictionary = mm_bearer_properties_get_dictionary (properties); + + mm_gdbus_modem_call_create_bearer ( + MM_GDBUS_MODEM (self), + dictionary, + cancellable, + (GAsyncReadyCallback)modem_create_bearer_ready, + ctx); + + g_variant_unref (dictionary); +} + +/** + * mm_modem_create_bearer_sync: + * @self: A #MMModem. + * @properties: A #MMBearerProperties object with the properties to use. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously creates a new packet data bearer in the #MMModem. + * + * This request may fail if the modem does not support additional bearers, + * if too many bearers are already defined, or if @properties are invalid. + * + * See <link linkend="gdbus-method-org-freedesktop-ModemManager1-Modem.CreateBearer">CreateBearer</link> to check which properties may be passed. + * + * The calling thread is blocked until a reply is received. See mm_modem_create_bearer() + * for the asynchronous version of this method. + * + * Returns: (transfer full): A newly created #MMBearer, or %NULL if @error is set. + */ +MMBearer * +mm_modem_create_bearer_sync (MMModem *self, + MMBearerProperties *properties, + GCancellable *cancellable, + GError **error) +{ + GObject *bearer = NULL; + gchar *bearer_path = NULL; + GVariant *dictionary; + + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + dictionary = mm_bearer_properties_get_dictionary (properties); + mm_gdbus_modem_call_create_bearer_sync (MM_GDBUS_MODEM (self), + dictionary, + &bearer_path, + cancellable, + error); + if (bearer_path) { + bearer = g_initable_new (MM_TYPE_BEARER, + cancellable, + error, + "g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + "g-name", MM_DBUS_SERVICE, + "g-connection", g_dbus_proxy_get_connection (G_DBUS_PROXY (self)), + "g-object-path", bearer_path, + "g-interface-name", "org.freedesktop.ModemManager1.Bearer", + NULL); + g_free (bearer_path); + } + + g_variant_unref (dictionary); + + return (bearer ? MM_BEARER (bearer) : NULL); +} + +/*****************************************************************************/ + +/** + * mm_modem_delete_bearer_finish: + * @self: A #MMModem. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_delete_bearer(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_delete_bearer(). + * + * Returns: %TRUE if the bearer was deleted, %FALSE if @error is set. + */ +gboolean +mm_modem_delete_bearer_finish (MMModem *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + + return mm_gdbus_modem_call_delete_bearer_finish (MM_GDBUS_MODEM (self), res, error); +} + +/** + * mm_modem_delete_bearer: + * @self: A #MMModem. + * @bearer: Path of the bearer to delete. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously deletes a given bearer from the #MMModem. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_delete_bearer_finish() to get the result of the operation. + * + * See mm_modem_delete_bearer_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_delete_bearer (MMModem *self, + const gchar *bearer, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM (self)); + + mm_gdbus_modem_call_delete_bearer (MM_GDBUS_MODEM (self), bearer, cancellable, callback, user_data); +} + +/** + * mm_modem_delete_bearer_sync: + * @self: A #MMModem. + * @bearer: Path of the bearer to delete. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + + * Synchronously deletes a given bearer from the #MMModem. + * + * The calling thread is blocked until a reply is received. See mm_modem_delete_bearer() + * for the asynchronous version of this method. + * + * Returns: %TRUE if the bearer was deleted, %FALSE if @error is set. + */ +gboolean +mm_modem_delete_bearer_sync (MMModem *self, + const gchar *bearer, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + + return mm_gdbus_modem_call_delete_bearer_sync (MM_GDBUS_MODEM (self), bearer, cancellable, error); +} + +/*****************************************************************************/ + +/** + * mm_modem_reset_finish: + * @self: A #MMModem. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_reset(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_reset(). + * + * Returns: %TRUE if the reset was successful, %FALSE if @error is set. + */ +gboolean +mm_modem_reset_finish (MMModem *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + + return mm_gdbus_modem_call_reset_finish (MM_GDBUS_MODEM (self), res, error); +} + +/** + * mm_modem_reset: + * @self: A #MMModem. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously clears non-persistent configuration and state, and returns the device to + * a newly-powered-on state. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_reset_finish() to get the result of the operation. + * + * See mm_modem_reset_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_reset (MMModem *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM (self)); + + mm_gdbus_modem_call_reset (MM_GDBUS_MODEM (self), cancellable, callback, user_data); +} + +/** + * mm_modem_reset_sync: + * @self: A #MMModem. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously clears non-persistent configuration and state, and returns the device to + * a newly-powered-on state. + * + * The calling thread is blocked until a reply is received. See mm_modem_reset() + * for the asynchronous version of this method. + * + * Returns: %TRUE if the reset was successful, %FALSE if @error is set. + */ +gboolean +mm_modem_reset_sync (MMModem *self, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + + return mm_gdbus_modem_call_reset_sync (MM_GDBUS_MODEM (self), cancellable, error); +} + +/*****************************************************************************/ + +/** + * mm_modem_factory_reset_finish: + * @self: A #MMModem. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_factory_reset(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_factory_reset(). + * + * Returns: %TRUE if the factory_reset was successful, %FALSE if @error is set. + */ +gboolean +mm_modem_factory_reset_finish (MMModem *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + + return mm_gdbus_modem_call_factory_reset_finish (MM_GDBUS_MODEM (self), res, error); +} + +/** + * mm_modem_factory_reset: + * @self: A #MMModem. + * @code: Carrier-supplied code required to reset the modem. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously clears the modem's configuration (including persistent configuration and + * state), and returns the device to a factory-default state. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_factory_reset_finish() to get the result of the operation. + * + * See mm_modem_factory_reset_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_factory_reset (MMModem *self, + const gchar *code, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM (self)); + + mm_gdbus_modem_call_factory_reset (MM_GDBUS_MODEM (self), code, cancellable, callback, user_data); +} + +/** + * mm_modem_factory_reset_sync: + * @self: A #MMModem. + * @code: Carrier-supplied code required to reset the modem. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously clears the modem's configuration (including persistent configuration and + * state), and returns the device to a factory-default state. + * + * The calling thread is blocked until a reply is received. See mm_modem_factory_reset() + * for the asynchronous version of this method. + * + * Returns: %TRUE if the factory reset was successful, %FALSE if @error is set. + */ +gboolean +mm_modem_factory_reset_sync (MMModem *self, + const gchar *code, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + + return mm_gdbus_modem_call_factory_reset_sync (MM_GDBUS_MODEM (self), code, cancellable, error); +} + +/*****************************************************************************/ + +/** + * mm_modem_command_finish: + * @self: A #MMModem. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_command(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_command(). + * + * Returns: (transfer full) A newly allocated string with the reply to the command, or #NULL if @error is set. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_command_finish (MMModem *self, + GAsyncResult *res, + GError **error) +{ + gchar *result; + + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + + if (!mm_gdbus_modem_call_command_finish (MM_GDBUS_MODEM (self), &result, res, error)) + return NULL; + + return result; +} + +/** + * mm_modem_command: + * @self: A #MMModem. + * @cmd: AT command to run. + * @timeout: Maximum time to wait for the response, in seconds. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously runs an AT command in the modem. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_command_finish() to get the result of the operation. + * + * See mm_modem_command_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_command (MMModem *self, + const gchar *cmd, + guint timeout, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + + g_return_if_fail (MM_IS_MODEM (self)); + + if (g_dbus_proxy_get_default_timeout (G_DBUS_PROXY (self)) < timeout) + g_warning ("Requested command timeout is shorter than the default DBus timeout"); + mm_gdbus_modem_call_command (MM_GDBUS_MODEM (self), cmd, timeout, cancellable, callback, user_data); +} + +/** + * mm_modem_command_sync: + * @self: A #MMModem. + * @cmd: AT command to run. + * @timeout: Maximum time to wait for the response, in seconds. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously runs an AT command in the modem. + * + * The calling thread is blocked until a reply is received. See mm_modem_command() + * for the asynchronous version of this method. + * + * Returns: (transfer full) A newly allocated string with the reply to the command, or #NULL if @error is set. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_command_sync (MMModem *self, + const gchar *cmd, + guint timeout, + GCancellable *cancellable, + GError **error) +{ + gchar *result; + + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + if (g_dbus_proxy_get_default_timeout (G_DBUS_PROXY (self)) < timeout) + g_warning ("Requested command timeout is shorter than the default DBus timeout"); + + if (!mm_gdbus_modem_call_command_sync (MM_GDBUS_MODEM (self), cmd, timeout, &result, cancellable, error)) + return NULL; + + return result; +} + +/*****************************************************************************/ + +/** + * mm_modem_set_power_state_finish: + * @self: A #MMModem. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_set_power_state(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_set_power_state(). + * + * Returns: %TRUE if the power state was successfully set, %FALSE if @error is set. + */ +gboolean +mm_modem_set_power_state_finish (MMModem *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + + return mm_gdbus_modem_call_set_power_state_finish (MM_GDBUS_MODEM (self), res, error); +} + +/** + * mm_modem_set_power_state: + * @self: A #MMModem. + * @state: Either %MM_MODEM_POWER_STATE_LOW or %MM_MODEM_POWER_STATE_ON. Every other #MMModemPowerState value is not allowed. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously sets the power state of the device. This method can only be + * used while the modem is in %MM_MODEM_STATE_DISABLED state. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_set_power_state_finish() to get the result of the operation. + * + * See mm_modem_set_power_state_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_set_power_state (MMModem *self, + MMModemPowerState state, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM (self)); + + mm_gdbus_modem_call_set_power_state (MM_GDBUS_MODEM (self), state, cancellable, callback, user_data); +} + +/** + * mm_modem_set_power_state_sync: + * @self: A #MMModem. + * @state: Either %MM_MODEM_POWER_STATE_LOW or %MM_MODEM_POWER_STATE_ON. Every other #MMModemPowerState value is not allowed. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously sets the power state of the device. This method can only be + * used while the modem is in %MM_MODEM_STATE_DISABLED state. + * + * The calling thread is blocked until a reply is received. See mm_modem_set_power_state() + * for the asynchronous version of this method. + * + * Returns: %TRUE if the power state was successfully set, %FALSE if @error is set. + */ +gboolean +mm_modem_set_power_state_sync (MMModem *self, + MMModemPowerState state, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + + return mm_gdbus_modem_call_set_power_state_sync (MM_GDBUS_MODEM (self), state, cancellable, error); +} + +/*****************************************************************************/ + +/** + * mm_modem_set_current_capabilities_finish: + * @self: A #MMModem. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_set_current_capabilities(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_set_current_capabilities(). + * + * Returns: %TRUE if the capabilities were successfully set, %FALSE if @error is set. + */ +gboolean +mm_modem_set_current_capabilities_finish (MMModem *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + + return mm_gdbus_modem_call_set_current_capabilities_finish (MM_GDBUS_MODEM (self), res, error); +} + +/** + * mm_modem_set_current_capabilities: + * @self: A #MMModem. + * @capabilities: A #MMModemCapability mask. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously sets the capabilities of the device. A restart of the modem may be required. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_set_current_capabilities_finish() to get the result of the operation. + * + * See mm_modem_set_current_capabilities_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_set_current_capabilities (MMModem *self, + MMModemCapability capabilities, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM (self)); + + mm_gdbus_modem_call_set_current_capabilities (MM_GDBUS_MODEM (self), + capabilities, + cancellable, + callback, + user_data); +} + +/** + * mm_modem_set_current_capabilities_sync: + * @self: A #MMModem. + * @capabilities: A #MMModemCapability mask. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously sets the capabilities of the device. A restart of the modem may be required. + * + * The calling thread is blocked until a reply is received. See mm_modem_set_current_capabilities() + * for the asynchronous version of this method. + * + * Returns: %TRUE if the capabilities were successfully set, %FALSE if @error is set. + */ +gboolean +mm_modem_set_current_capabilities_sync (MMModem *self, + MMModemCapability capabilities, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + + return (mm_gdbus_modem_call_set_current_capabilities_sync ( + MM_GDBUS_MODEM (self), + capabilities, + cancellable, + error)); +} + +/*****************************************************************************/ + +/** + * mm_modem_set_current_modes_finish: + * @self: A #MMModem. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_set_current_modes(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_set_current_modes(). + * + * Returns: %TRUE if the allowed modes were successfully set, %FALSE if @error is set. + */ +gboolean +mm_modem_set_current_modes_finish (MMModem *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + + return mm_gdbus_modem_call_set_current_modes_finish (MM_GDBUS_MODEM (self), res, error); +} + +/** + * mm_modem_set_current_modes: + * @self: A #MMModem. + * @modes: Mask of #MMModemMode values specifying which modes are allowed. + * @preferred: A #MMModemMode value specifying which of the modes given in @modes is the preferred one, or #MM_MODEM_MODE_NONE if none. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously sets the access technologies (e.g. 2G/3G/4G preference) the device is + * currently allowed to use when connecting to a network. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_set_current_modes_finish() to get the result of the operation. + * + * See mm_modem_set_current_modes_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_set_current_modes (MMModem *self, + MMModemMode modes, + MMModemMode preferred, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM (self)); + + mm_gdbus_modem_call_set_current_modes (MM_GDBUS_MODEM (self), + g_variant_new ("(uu)", modes, preferred), + cancellable, + callback, + user_data); +} + +/** + * mm_modem_set_current_modes_sync: + * @self: A #MMModem. + * @modes: Mask of #MMModemMode values specifying which modes are allowed. + * @preferred: A #MMModemMode value specifying which of the modes given in @modes is the preferred one, or #MM_MODEM_MODE_NONE if none. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously sets the access technologies (e.g. 2G/3G/4G preference) the device is + * currently allowed to use when connecting to a network. + * + * The calling thread is blocked until a reply is received. See mm_modem_set_current_modes() + * for the asynchronous version of this method. + * + * Returns: %TRUE if the allowed modes were successfully set, %FALSE if @error is set. + */ +gboolean +mm_modem_set_current_modes_sync (MMModem *self, + MMModemMode modes, + MMModemMode preferred, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + + return mm_gdbus_modem_call_set_current_modes_sync (MM_GDBUS_MODEM (self), + g_variant_new ("(uu)", modes, preferred), + cancellable, + error); +} + +/*****************************************************************************/ + +/** + * mm_modem_set_current_bands_finish: + * @self: A #MMModem. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_set_current_bands(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_set_current_bands(). + * + * Returns: %TRUE if the bands were successfully set, %FALSE if @error is set. + */ +gboolean +mm_modem_set_current_bands_finish (MMModem *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + + return mm_gdbus_modem_call_set_current_bands_finish (MM_GDBUS_MODEM (self), res, error); +} + +/** + * mm_modem_set_current_bands: + * @self: A #MMModem. + * @bands: An array of #MMModemBand values specifying which bands are allowed. + * @n_bands: Number of elements in @bands. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously sets the radio frequency and technology bands the device is currently + * allowed to use when connecting to a network. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_set_current_bands_finish() to get the result of the operation. + * + * See mm_modem_set_current_bands_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_set_current_bands (MMModem *self, + const MMModemBand *bands, + guint n_bands, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM (self)); + + mm_gdbus_modem_call_set_current_bands (MM_GDBUS_MODEM (self), + mm_common_bands_array_to_variant (bands, n_bands), + cancellable, + callback, + user_data); +} + +/** + * mm_modem_set_current_bands_sync: + * @self: A #MMModem. + * @bands: An array of #MMModemBand values specifying which bands are allowed. + * @n_bands: Number of elements in @bands. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously sets the radio frequency and technology bands the device is currently + * allowed to use when connecting to a network. + * + * The calling thread is blocked until a reply is received. See mm_modem_set_current_bands() + * for the asynchronous version of this method. + * + * Returns: %TRUE if the bands were successfully set, %FALSE if @error is set. + */ +gboolean +mm_modem_set_current_bands_sync (MMModem *self, + const MMModemBand *bands, + guint n_bands, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_MODEM (self), FALSE); + + return (mm_gdbus_modem_call_set_current_bands_sync ( + MM_GDBUS_MODEM (self), + mm_common_bands_array_to_variant (bands, n_bands), + cancellable, + error)); +} + +/*****************************************************************************/ + +/** + * mm_modem_get_sim_finish: + * @self: A #MMModem. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_get_sim(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_modem_get_sim(). + * + * Returns: a #MMSim or #NULL if none available. The returned value should be freed with g_object_unref(). + */ +MMSim * +mm_modem_get_sim_finish (MMModem *self, + GAsyncResult *res, + GError **error) +{ + MMSim *sim; + + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error)) + return NULL; + + sim = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)); + return (sim ? (MMSim *)g_object_ref (sim) : NULL); +} + +static void +modem_get_sim_ready (GDBusConnection *connection, + GAsyncResult *res, + GSimpleAsyncResult *simple) +{ + GError *error = NULL; + GObject *sim; + GObject *source_object; + + source_object = g_async_result_get_source_object (res); + sim = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, &error); + g_object_unref (source_object); + + if (error) + g_simple_async_result_take_error (simple, error); + else + g_simple_async_result_set_op_res_gpointer (simple, + sim, + (GDestroyNotify)g_object_unref); + + g_simple_async_result_complete (simple); + g_object_unref (simple); +} + +/** + * mm_modem_get_sim: + * @self: A #MMModem. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Synchronously gets the #MMSim object managed by this #MMModem. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_modem_get_sim_finish() to get the result of the operation. + * + * See mm_modem_get_sim_sync() for the synchronous, blocking version of this method. + */ +void +mm_modem_get_sim (MMModem *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GSimpleAsyncResult *result; + const gchar *sim_path; + + g_return_if_fail (MM_IS_MODEM (self)); + + result = g_simple_async_result_new (G_OBJECT (self), + callback, + user_data, + mm_modem_get_sim); + + sim_path = mm_modem_get_sim_path (self); + if (!sim_path) { + g_simple_async_result_set_op_res_gpointer (result, NULL, NULL); + g_simple_async_result_complete_in_idle (result); + g_object_unref (result); + return; + } + + g_async_initable_new_async (MM_TYPE_SIM, + G_PRIORITY_DEFAULT, + cancellable, + (GAsyncReadyCallback)modem_get_sim_ready, + result, + "g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + "g-name", MM_DBUS_SERVICE, + "g-connection", g_dbus_proxy_get_connection (G_DBUS_PROXY (self)), + "g-object-path", sim_path, + "g-interface-name", "org.freedesktop.ModemManager1.Sim", + NULL); +} + +/** + * mm_modem_get_sim_sync: + * @self: A #MMModem. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously gets the #MMSim object managed by this #MMModem. + * + * The calling thread is blocked until a reply is received. See mm_modem_get_sim() + * for the asynchronous version of this method. + * + * Returns: a #MMSim or #NULL if none available. The returned value should be freed with g_object_unref(). + */ +MMSim * +mm_modem_get_sim_sync (MMModem *self, + GCancellable *cancellable, + GError **error) +{ + GObject *sim; + const gchar *sim_path; + + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + sim_path = mm_modem_get_sim_path (self); + if (!sim_path) + return NULL; + + sim = g_initable_new (MM_TYPE_SIM, + cancellable, + error, + "g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + "g-name", MM_DBUS_SERVICE, + "g-connection", g_dbus_proxy_get_connection (G_DBUS_PROXY (self)), + "g-object-path", sim_path, + "g-interface-name", "org.freedesktop.ModemManager1.Sim", + NULL); + + return (sim ? MM_SIM (sim) : NULL); +} + +/*****************************************************************************/ + +static void +mm_modem_init (MMModem *self) +{ + /* Setup private data */ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, + MM_TYPE_MODEM, + MMModemPrivate); + g_mutex_init (&self->priv->unlock_retries_mutex); + g_mutex_init (&self->priv->supported_modes_mutex); + g_mutex_init (&self->priv->supported_capabilities_mutex); + g_mutex_init (&self->priv->supported_bands_mutex); + g_mutex_init (&self->priv->current_bands_mutex); +} + +static void +finalize (GObject *object) +{ + MMModem *self = MM_MODEM (object); + + g_mutex_clear (&self->priv->unlock_retries_mutex); + g_mutex_clear (&self->priv->supported_modes_mutex); + g_mutex_clear (&self->priv->supported_bands_mutex); + g_mutex_clear (&self->priv->current_bands_mutex); + + if (self->priv->supported_modes) + g_array_unref (self->priv->supported_modes); + if (self->priv->supported_capabilities) + g_array_unref (self->priv->supported_capabilities); + if (self->priv->supported_bands) + g_array_unref (self->priv->supported_bands); + if (self->priv->current_bands) + g_array_unref (self->priv->current_bands); + + G_OBJECT_CLASS (mm_modem_parent_class)->finalize (object); +} + +static void +dispose (GObject *object) +{ + MMModem *self = MM_MODEM (object); + + g_clear_object (&self->priv->unlock_retries); + + G_OBJECT_CLASS (mm_modem_parent_class)->dispose (object); +} + +static void +mm_modem_class_init (MMModemClass *modem_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (modem_class); + + g_type_class_add_private (object_class, sizeof (MMModemPrivate)); + + /* Virtual methods */ + object_class->dispose = dispose; + object_class->finalize = finalize; +} diff --git a/libmm-glib/mm-modem.h b/libmm-glib/mm-modem.h new file mode 100644 index 0000000..a2ece5a --- /dev/null +++ b/libmm-glib/mm-modem.h @@ -0,0 +1,330 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2011 - 2012 Aleksander Morgado <aleksander@gnu.org> + * Copyright (C) 2012 Google, Inc. + */ + +#ifndef _MM_MODEM_H_ +#define _MM_MODEM_H_ + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> + +#include "mm-gdbus-modem.h" +#include "mm-unlock-retries.h" +#include "mm-sim.h" +#include "mm-bearer.h" +#include "mm-helper-types.h" + +G_BEGIN_DECLS + +#define MM_TYPE_MODEM (mm_modem_get_type ()) +#define MM_MODEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_MODEM, MMModem)) +#define MM_MODEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_MODEM, MMModemClass)) +#define MM_IS_MODEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_MODEM)) +#define MM_IS_MODEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), MM_TYPE_MODEM)) +#define MM_MODEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_MODEM, MMModemClass)) + +typedef struct _MMModem MMModem; +typedef struct _MMModemClass MMModemClass; +typedef struct _MMModemPrivate MMModemPrivate; + +/** + * MMModem: + * + * The #MMModem structure contains private data and should only be accessed + * using the provided API. + */ +struct _MMModem { + /*< private >*/ + MmGdbusModemProxy parent; + MMModemPrivate *priv; +}; + +struct _MMModemClass { + /*< private >*/ + MmGdbusModemProxyClass parent; +}; + +GType mm_modem_get_type (void); + +const gchar *mm_modem_get_path (MMModem *self); +gchar *mm_modem_dup_path (MMModem *self); + +const gchar *mm_modem_get_sim_path (MMModem *self); +gchar *mm_modem_dup_sim_path (MMModem *self); + +gboolean mm_modem_peek_supported_capabilities (MMModem *self, + const MMModemCapability **capabilities, + guint *n_capabilities); +gboolean mm_modem_get_supported_capabilities (MMModem *self, + MMModemCapability **capabilities, + guint *n_capabilities); + +MMModemCapability mm_modem_get_current_capabilities (MMModem *self); + +guint mm_modem_get_max_bearers (MMModem *self); + +guint mm_modem_get_max_active_bearers (MMModem *self); + +const gchar *mm_modem_get_manufacturer (MMModem *self); +gchar *mm_modem_dup_manufacturer (MMModem *self); + +const gchar *mm_modem_get_model (MMModem *self); +gchar *mm_modem_dup_model (MMModem *self); + +const gchar *mm_modem_get_revision (MMModem *self); +gchar *mm_modem_dup_revision (MMModem *self); + +const gchar *mm_modem_get_device_identifier (MMModem *self); +gchar *mm_modem_dup_device_identifier (MMModem *self); + +const gchar *mm_modem_get_device (MMModem *self); +gchar *mm_modem_dup_device (MMModem *self); + +const gchar * const *mm_modem_get_drivers (MMModem *self); +gchar **mm_modem_dup_drivers (MMModem *self); + +const gchar *mm_modem_get_plugin (MMModem *self); +gchar *mm_modem_dup_plugin (MMModem *self); + +const gchar *mm_modem_get_primary_port (MMModem *self); +gchar *mm_modem_dup_primary_port (MMModem *self); + +const gchar *mm_modem_get_equipment_identifier (MMModem *self); +gchar *mm_modem_dup_equipment_identifier (MMModem *self); + +const gchar *const *mm_modem_get_own_numbers (MMModem *self); +gchar **mm_modem_dup_own_numbers (MMModem *self); + +MMModemLock mm_modem_get_unlock_required (MMModem *self); + +MMUnlockRetries *mm_modem_get_unlock_retries (MMModem *self); +MMUnlockRetries *mm_modem_peek_unlock_retries (MMModem *self); + +MMModemState mm_modem_get_state (MMModem *self); + +MMModemStateFailedReason mm_modem_get_state_failed_reason (MMModem *self); + +MMModemPowerState mm_modem_get_power_state (MMModem *self); + +MMModemAccessTechnology mm_modem_get_access_technologies (MMModem *self); + +guint mm_modem_get_signal_quality (MMModem *self, + gboolean *recent); + +gboolean mm_modem_peek_supported_modes (MMModem *self, + const MMModemModeCombination **modes, + guint *n_modes); +gboolean mm_modem_get_supported_modes (MMModem *self, + MMModemModeCombination **modes, + guint *n_modes); + +gboolean mm_modem_get_current_modes (MMModem *self, + MMModemMode *allowed, + MMModemMode *preferred); + +gboolean mm_modem_peek_supported_bands (MMModem *self, + const MMModemBand **bands, + guint *n_bands); +gboolean mm_modem_get_supported_bands (MMModem *self, + MMModemBand **bands, + guint *n_bands); + +gboolean mm_modem_peek_current_bands (MMModem *self, + const MMModemBand **bands, + guint *n_bands); +gboolean mm_modem_get_current_bands (MMModem *self, + MMModemBand **bands, + guint *n_bands); + +MMBearerIpFamily mm_modem_get_supported_ip_families (MMModem *self); + +void mm_modem_enable (MMModem *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_modem_enable_finish (MMModem *self, + GAsyncResult *res, + GError **error); +gboolean mm_modem_enable_sync (MMModem *self, + GCancellable *cancellable, + GError **error); + +void mm_modem_disable (MMModem *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_modem_disable_finish (MMModem *self, + GAsyncResult *res, + GError **error); +gboolean mm_modem_disable_sync (MMModem *self, + GCancellable *cancellable, + GError **error); + +void mm_modem_list_bearers (MMModem *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GList *mm_modem_list_bearers_finish (MMModem *self, + GAsyncResult *res, + GError **error); +GList *mm_modem_list_bearers_sync (MMModem *self, + GCancellable *cancellable, + GError **error); + +void mm_modem_create_bearer (MMModem *self, + MMBearerProperties *properties, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MMBearer *mm_modem_create_bearer_finish (MMModem *self, + GAsyncResult *res, + GError **error); +MMBearer *mm_modem_create_bearer_sync (MMModem *self, + MMBearerProperties *properties, + GCancellable *cancellable, + GError **error); + +void mm_modem_delete_bearer (MMModem *self, + const gchar *bearer, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_modem_delete_bearer_finish (MMModem *self, + GAsyncResult *res, + GError **error); +gboolean mm_modem_delete_bearer_sync (MMModem *self, + const gchar *bearer, + GCancellable *cancellable, + GError **error); + +void mm_modem_reset (MMModem *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_modem_reset_finish (MMModem *self, + GAsyncResult *res, + GError **error); +gboolean mm_modem_reset_sync (MMModem *self, + GCancellable *cancellable, + GError **error); + +void mm_modem_factory_reset (MMModem *self, + const gchar *code, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_modem_factory_reset_finish (MMModem *self, + GAsyncResult *res, + GError **error); +gboolean mm_modem_factory_reset_sync (MMModem *self, + const gchar *code, + GCancellable *cancellable, + GError **error); + +void mm_modem_command (MMModem *self, + const gchar *cmd, + guint timeout, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gchar *mm_modem_command_finish (MMModem *self, + GAsyncResult *res, + GError **error); +gchar *mm_modem_command_sync (MMModem *self, + const gchar *cmd, + guint timeout, + GCancellable *cancellable, + GError **error); + +void mm_modem_set_power_state (MMModem *self, + MMModemPowerState state, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_modem_set_power_state_finish (MMModem *self, + GAsyncResult *res, + GError **error); +gboolean mm_modem_set_power_state_sync (MMModem *self, + MMModemPowerState state, + GCancellable *cancellable, + GError **error); + +void mm_modem_set_current_capabilities (MMModem *self, + MMModemCapability capabilities, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_modem_set_current_capabilities_finish (MMModem *self, + GAsyncResult *res, + GError **error); +gboolean mm_modem_set_current_capabilities_sync (MMModem *self, + MMModemCapability capabilities, + GCancellable *cancellable, + GError **error); + +void mm_modem_set_current_modes (MMModem *self, + MMModemMode modes, + MMModemMode preferred, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_modem_set_current_modes_finish (MMModem *self, + GAsyncResult *res, + GError **error); +gboolean mm_modem_set_current_modes_sync (MMModem *self, + MMModemMode modes, + MMModemMode preferred, + GCancellable *cancellable, + GError **error); + +void mm_modem_set_current_bands (MMModem *self, + const MMModemBand *bands, + guint n_bands, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_modem_set_current_bands_finish (MMModem *self, + GAsyncResult *res, + GError **error); +gboolean mm_modem_set_current_bands_sync (MMModem *self, + const MMModemBand *bands, + guint n_bands, + GCancellable *cancellable, + GError **error); + +void mm_modem_get_sim (MMModem *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MMSim *mm_modem_get_sim_finish (MMModem *self, + GAsyncResult *res, + GError **error); +MMSim *mm_modem_get_sim_sync (MMModem *self, + GCancellable *cancellable, + GError **error); + +G_END_DECLS + +#endif /* _MM_MODEM_H_ */ diff --git a/libmm-glib/mm-network-timezone.c b/libmm-glib/mm-network-timezone.c new file mode 100644 index 0000000..0a37c0e --- /dev/null +++ b/libmm-glib/mm-network-timezone.c @@ -0,0 +1,255 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2012 Google, Inc. + */ + +#include <string.h> + +#include "mm-errors-types.h" +#include "mm-network-timezone.h" + +/** + * SECTION: mm-network-timezone + * @title: MMNetworkTimezone + * @short_description: Helper object to handle network timezone information. + * + * The #MMNetworkTimezone is an object handling the timezone information + * reported by the network. + * + * This object is retrieved with either mm_modem_time_peek_network_timezone() + * or mm_modem_time_get_network_timezone(). + */ + +G_DEFINE_TYPE (MMNetworkTimezone, mm_network_timezone, G_TYPE_OBJECT); + +struct _MMNetworkTimezonePrivate { + gint32 offset; + gint32 dst_offset; + gint32 leap_seconds; +}; + +/*****************************************************************************/ + +/** + * mm_network_timezone_get_offset: + * @self: a #MMNetworkTimezone. + * + * Gets the timezone offset (in minutes) reported by the network. + * + * Returns: the offset, or %MM_NETWORK_TIMEZONE_OFFSET_UNKNOWN if unknown. + */ +gint +mm_network_timezone_get_offset (MMNetworkTimezone *self) +{ + g_return_val_if_fail (MM_IS_NETWORK_TIMEZONE (self), + MM_NETWORK_TIMEZONE_OFFSET_UNKNOWN); + + return self->priv->offset; +} + +void +mm_network_timezone_set_offset (MMNetworkTimezone *self, + gint offset) +{ + g_return_if_fail (MM_IS_NETWORK_TIMEZONE (self)); + + self->priv->offset = offset; +} + +/*****************************************************************************/ + +/** + * mm_network_timezone_get_dst_offset: + * @self: a #MMNetworkTimezone. + * + * Gets the timezone offset due to daylight saving time (in minutes) reported by + * the network. + * + * Returns: the offset, or %MM_NETWORK_TIMEZONE_OFFSET_UNKNOWN if unknown. + */ +gint +mm_network_timezone_get_dst_offset (MMNetworkTimezone *self) +{ + g_return_val_if_fail (MM_IS_NETWORK_TIMEZONE (self), + MM_NETWORK_TIMEZONE_OFFSET_UNKNOWN); + + return self->priv->dst_offset; +} + +void +mm_network_timezone_set_dst_offset (MMNetworkTimezone *self, + gint dst_offset) +{ + g_return_if_fail (MM_IS_NETWORK_TIMEZONE (self)); + + self->priv->dst_offset = dst_offset; +} + +/*****************************************************************************/ + +/** + * mm_network_timezone_get_leap_seconds: + * @self: a #MMNetworkTimezone. + * + * Gets the number of leap seconds (TAI-UTC), as reported by the network. + * + * Returns: the number of leap seconds, or %MM_NETWORK_TIMEZONE_LEAP_SECONDS_UNKNOWN if unknown. + */ +gint +mm_network_timezone_get_leap_seconds (MMNetworkTimezone *self) +{ + g_return_val_if_fail (MM_IS_NETWORK_TIMEZONE (self), + MM_NETWORK_TIMEZONE_LEAP_SECONDS_UNKNOWN); + + return self->priv->leap_seconds; +} + +void +mm_network_timezone_set_leap_seconds (MMNetworkTimezone *self, + gint leap_seconds) +{ + g_return_if_fail (MM_IS_NETWORK_TIMEZONE (self)); + + self->priv->leap_seconds = leap_seconds; +} + +/*****************************************************************************/ + +GVariant * +mm_network_timezone_get_dictionary (MMNetworkTimezone *self) +{ + GVariantBuilder builder; + + /* Allow NULL */ + if (!self) + return NULL; + + g_return_val_if_fail (MM_IS_NETWORK_TIMEZONE (self), NULL); + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); + + if (self->priv->offset != MM_NETWORK_TIMEZONE_OFFSET_UNKNOWN) + g_variant_builder_add (&builder, + "{sv}", + "offset", + g_variant_new_int32 (self->priv->offset)); + + if (self->priv->dst_offset != MM_NETWORK_TIMEZONE_OFFSET_UNKNOWN) + g_variant_builder_add (&builder, + "{sv}", + "dst-offset", + g_variant_new_int32 (self->priv->dst_offset)); + + if (self->priv->leap_seconds != MM_NETWORK_TIMEZONE_LEAP_SECONDS_UNKNOWN) + g_variant_builder_add (&builder, + "{sv}", + "leap-seconds", + g_variant_new_int32 (self->priv->leap_seconds)); + + return g_variant_ref_sink (g_variant_builder_end (&builder)); +} + +/*****************************************************************************/ + +MMNetworkTimezone * +mm_network_timezone_new_from_dictionary (GVariant *dictionary, + GError **error) +{ + GError *inner_error = NULL; + GVariantIter iter; + gchar *key; + GVariant *value; + MMNetworkTimezone *self; + + self = mm_network_timezone_new (); + if (!dictionary) + return self; + + if (!g_variant_is_of_type (dictionary, G_VARIANT_TYPE ("a{sv}"))) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Cannot create Network Timezone from dictionary: " + "invalid variant type received"); + g_object_unref (self); + return NULL; + } + + g_variant_iter_init (&iter, dictionary); + while (!inner_error && + g_variant_iter_next (&iter, "{sv}", &key, &value)) { + /* All currently supported properties are signed integers, + * so we just check the value type here */ + if (!g_variant_is_of_type (value, G_VARIANT_TYPE_INT32)) { + /* Set inner error, will stop the loop */ + inner_error = g_error_new (MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Invalid status dictionary, unexpected value type '%s'", + g_variant_get_type_string (value)); + } else if (g_str_equal (key, "offset")) + self->priv->offset = g_variant_get_int32 (value); + else if (g_str_equal (key, "dst-offset")) + self->priv->dst_offset = g_variant_get_int32 (value); + else if (g_str_equal (key, "leap-seconds")) + self->priv->leap_seconds = g_variant_get_int32 (value); + else { + /* Set inner error, will stop the loop */ + inner_error = g_error_new (MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Invalid status dictionary, unexpected key '%s'", + key); + } + + g_free (key); + g_variant_unref (value); + } + + /* If error, destroy the object */ + if (inner_error) { + g_propagate_error (error, inner_error); + g_object_unref (self); + return NULL; + } + + return self; +} + +/*****************************************************************************/ + +MMNetworkTimezone * +mm_network_timezone_new (void) +{ + return (MM_NETWORK_TIMEZONE ( + g_object_new (MM_TYPE_NETWORK_TIMEZONE, NULL))); +} + +static void +mm_network_timezone_init (MMNetworkTimezone *self) +{ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), + MM_TYPE_NETWORK_TIMEZONE, + MMNetworkTimezonePrivate); + + /* Some defaults */ + self->priv->offset = MM_NETWORK_TIMEZONE_OFFSET_UNKNOWN; + self->priv->dst_offset = MM_NETWORK_TIMEZONE_OFFSET_UNKNOWN; + self->priv->leap_seconds = MM_NETWORK_TIMEZONE_LEAP_SECONDS_UNKNOWN; +} + +static void +mm_network_timezone_class_init (MMNetworkTimezoneClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (MMNetworkTimezonePrivate)); +} diff --git a/libmm-glib/mm-network-timezone.h b/libmm-glib/mm-network-timezone.h new file mode 100644 index 0000000..2bbb305 --- /dev/null +++ b/libmm-glib/mm-network-timezone.h @@ -0,0 +1,100 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2012 Google, Inc. + */ + +#ifndef MM_NETWORK_TIMEZONE_H +#define MM_NETWORK_TIMEZONE_H + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> +#include <glib-object.h> + +G_BEGIN_DECLS + +#define MM_TYPE_NETWORK_TIMEZONE (mm_network_timezone_get_type ()) +#define MM_NETWORK_TIMEZONE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_NETWORK_TIMEZONE, MMNetworkTimezone)) +#define MM_NETWORK_TIMEZONE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_NETWORK_TIMEZONE, MMNetworkTimezoneClass)) +#define MM_IS_NETWORK_TIMEZONE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_NETWORK_TIMEZONE)) +#define MM_IS_NETWORK_TIMEZONE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_NETWORK_TIMEZONE)) +#define MM_NETWORK_TIMEZONE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_NETWORK_TIMEZONE, MMNetworkTimezoneClass)) + +/** + * MM_NETWORK_TIMEZONE_OFFSET_UNKNOWN: + * + * Identifier for an unknown timezone offset. + */ +#define MM_NETWORK_TIMEZONE_OFFSET_UNKNOWN G_MAXINT32 + +/** + * MM_NETWORK_TIMEZONE_LEAP_SECONDS_UNKNOWN: + * + * Identifier for an unknown leap seconds value. + */ +#define MM_NETWORK_TIMEZONE_LEAP_SECONDS_UNKNOWN G_MAXINT32 + +typedef struct _MMNetworkTimezone MMNetworkTimezone; +typedef struct _MMNetworkTimezoneClass MMNetworkTimezoneClass; +typedef struct _MMNetworkTimezonePrivate MMNetworkTimezonePrivate; + +/** + * MMNetworkTimezone: + * + * The #MMNetworkTimezone structure contains private data and should + * only be accessed using the provided API. + */ +struct _MMNetworkTimezone { + /*< private >*/ + GObject parent; + MMNetworkTimezonePrivate *priv; +}; + +struct _MMNetworkTimezoneClass { + /*< private >*/ + GObjectClass parent; +}; + +GType mm_network_timezone_get_type (void); + +gint32 mm_network_timezone_get_offset (MMNetworkTimezone *self); +gint32 mm_network_timezone_get_dst_offset (MMNetworkTimezone *self); +gint32 mm_network_timezone_get_leap_seconds (MMNetworkTimezone *self); + +/*****************************************************************************/ +/* ModemManager/libmm-glib/mmcli specific methods */ + +#if defined (_LIBMM_INSIDE_MM) || \ + defined (_LIBMM_INSIDE_MMCLI) || \ + defined (LIBMM_GLIB_COMPILATION) + +MMNetworkTimezone *mm_network_timezone_new (void); +MMNetworkTimezone *mm_network_timezone_new_from_dictionary (GVariant *dictionary, + GError **error); + +void mm_network_timezone_set_offset (MMNetworkTimezone *self, + gint offset); +void mm_network_timezone_set_dst_offset (MMNetworkTimezone *self, + gint dst_offset); +void mm_network_timezone_set_leap_seconds (MMNetworkTimezone *self, + gint leap_seconds); + +GVariant *mm_network_timezone_get_dictionary (MMNetworkTimezone *self); + +#endif + +G_END_DECLS + +#endif /* MM_NETWORK_TIMEZONE_H */ diff --git a/libmm-glib/mm-object.c b/libmm-glib/mm-object.c new file mode 100644 index 0000000..8d549bc --- /dev/null +++ b/libmm-glib/mm-object.c @@ -0,0 +1,423 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2011 - 2012 Aleksander Morgado <aleksander@gnu.org> + * Copyright (C) 2012 Google, Inc. + */ + +#include "mm-errors-types.h" +#include "mm-object.h" + +/** + * SECTION: mm-object + * @title: MMObject + * @short_description: Generic object representing a modem in ModemManager + * + * The #MMObject is a generic object which represents any kind of modem exposed + * in ModemManager, and allows accessing the exported interfaces one by one. + * + * When this object is available, it is ensured that at least the Modem + * interface is also available. + */ + +G_DEFINE_TYPE (MMObject, mm_object, MM_GDBUS_TYPE_OBJECT_PROXY) + +/*****************************************************************************/ + +/** + * mm_object_get_path: (skip) + * @self: A #MMObject. + * + * Gets the DBus path of the #MMObject object. + * + * Returns: (transfer none): The DBus path of the #MMObject object. + */ +const gchar * +mm_object_get_path (MMObject *self) +{ + g_return_val_if_fail (MM_IS_OBJECT (self), NULL); + + return g_dbus_object_get_object_path (G_DBUS_OBJECT (self)); +} + +/** + * mm_object_dup_path: + * @self: A #MMObject. + * + * Gets a copy of the DBus path of the #MMObject object. + * + * Returns: (transfer full): The DBus path of the #MMObject. The returned value should be freed with g_free(). + */ +gchar * +mm_object_dup_path (MMObject *self) +{ + gchar *value; + + g_return_val_if_fail (MM_IS_OBJECT (self), NULL); + + g_object_get (G_OBJECT (self), + "g-object-path", &value, + NULL); + + return value; +} + +/*****************************************************************************/ + +/** + * mm_object_get_modem: + * @self: A #MMModem + * + * Gets the #MMModem instance for the D-Bus interface org.freedesktop.ModemManager1.Modem on @self, if any. + * + * Returns: (transfer full): A #MMModem that must be freed with g_object_unref() or %NULL if @self does not implement the interface. + */ +MMModem * +mm_object_get_modem (MMObject *self) +{ + MMModem *modem; + + g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL); + + modem = (MMModem *)mm_gdbus_object_get_modem (MM_GDBUS_OBJECT (self)); + g_warn_if_fail (MM_IS_MODEM (modem)); + return modem; +} + +/** + * mm_object_peek_modem: (skip) + * @self: A #MMObject. + * + * Like mm_object_get_modem() but doesn't increase the reference count on the returned object. + * + * <warning>It is not safe to use the returned object if you are on another thread than the one where the #MMManager is running.</warning> + * + * Returns: (transfer none): A #MMModem or %NULL if @self does not implement the interface. Do not free the returned object, it is owned by @self. + */ +MMModem * +mm_object_peek_modem (MMObject *self) +{ + MMModem *modem; + + g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL); + + modem = (MMModem *) mm_gdbus_object_peek_modem (MM_GDBUS_OBJECT (self)); + g_warn_if_fail (MM_IS_MODEM (modem)); + return modem; +} + +/*****************************************************************************/ + +/** + * mm_object_get_modem_3gpp: + * @self: A #MMObject. + * + * Gets the #MMModem3gpp instance for the D-Bus interface org.freedesktop.ModemManager1.Modem.Modem3gpp on @self, if any. + * + * Returns: (transfer full): A #MMModem3gpp that must be freed with g_object_unref() or %NULL if @self does not implement the interface. + */ +MMModem3gpp * +mm_object_get_modem_3gpp (MMObject *self) +{ + g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL); + + return (MMModem3gpp *)mm_gdbus_object_get_modem3gpp (MM_GDBUS_OBJECT (self)); +} + +/** + * mm_object_peek_modem_3gpp: (skip) + * @self: A #MMObject. + * + * Like mm_object_get_modem_3gpp() but doesn't increase the reference count on the returned object. + * + * <warning>It is not safe to use the returned object if you are on another thread than the one where the #MMManager is running.</warning> + * + * Returns: (transfer none): A #MMModem3gpp or %NULL if @self does not implement the interface. Do not free the returned object, it is owned by @self. + */ +MMModem3gpp * +mm_object_peek_modem_3gpp (MMObject *self) +{ + g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL); + + return (MMModem3gpp *)mm_gdbus_object_peek_modem3gpp (MM_GDBUS_OBJECT (self)); +} + +/*****************************************************************************/ + +/** + * mm_object_get_modem_3gpp_ussd: + * @self: A #MMObject. + * + * Gets the #MMModem3gppUssd instance for the D-Bus interface org.freedesktop.ModemManager1.Modem.Modem3gpp-Ussd on @self, if any. + * + * Returns: (transfer full): A #MMModem3gppUssd that must be freed with g_object_unref() or %NULL if @self does not implement the interface. + */ +MMModem3gppUssd * +mm_object_get_modem_3gpp_ussd (MMObject *self) +{ + g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL); + + return (MMModem3gppUssd *)mm_gdbus_object_get_modem3gpp_ussd (MM_GDBUS_OBJECT (self)); +} + +/** + * mm_object_peek_modem_3gpp_ussd: (skip) + * @self: A #MMObject. + * + * Like mm_object_get_modem_3gpp_ussd() but doesn't increase the reference count on the returned object. + * + * <warning>It is not safe to use the returned object if you are on another thread than the one where the #MMManager is running.</warning> + * + * Returns: (transfer none): A #MMModem3gppUssd or %NULL if @self does not implement the interface. Do not free the returned object, it is owned by @self. + */ +MMModem3gppUssd * +mm_object_peek_modem_3gpp_ussd (MMObject *self) +{ + g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL); + + return (MMModem3gppUssd *)mm_gdbus_object_peek_modem3gpp_ussd (MM_GDBUS_OBJECT (self)); +} + +/*****************************************************************************/ + +/** + * mm_object_get_modem_cdma: + * @self: A #MMObject. + * + * Gets the #MMModemCdma instance for the D-Bus interface org.freedesktop.ModemManager1.Modem.ModemCdma on @self, if any. + * + * Returns: (transfer full): A #MMModemCdma that must be freed with g_object_unref() or %NULL if @self does not implement the interface. + */ +MMModemCdma * +mm_object_get_modem_cdma (MMObject *self) +{ + g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL); + + return (MMModemCdma *)mm_gdbus_object_get_modem_cdma (MM_GDBUS_OBJECT (self)); +} + +/** + * mm_object_peek_modem_cdma: (skip) + * @self: A #MMObject. + * + * Like mm_object_get_modem_cdma() but doesn't increase the reference count on the returned object. + * + * <warning>It is not safe to use the returned object if you are on another thread than the one where the #MMManager is running.</warning> + * + * Returns: (transfer none): A #MMModemCdma or %NULL if @self does not implement the interface. Do not free the returned object, it is owned by @self. + */ +MMModemCdma * +mm_object_peek_modem_cdma (MMObject *self) +{ + g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL); + + return (MMModemCdma *)mm_gdbus_object_peek_modem_cdma (MM_GDBUS_OBJECT (self)); +} + +/*****************************************************************************/ + +/** + * mm_object_get_modem_simple: + * @self: A #MMObject. + * + * Gets the #MMModemSimple instance for the D-Bus interface org.freedesktop.ModemManager1.Modem.Modemsimple on @self, if any. + * + * Returns: (transfer full): A #MMModemSimple that must be freed with g_object_unref() or %NULL if @self does not implement the interface. + */ +MMModemSimple * +mm_object_get_modem_simple (MMObject *self) +{ + g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL); + + return (MMModemSimple *)mm_gdbus_object_get_modem_simple (MM_GDBUS_OBJECT (self)); +} + +/** + * mm_object_peek_modem_simple: (skip) + * @self: A #MMObject. + * + * Like mm_object_get_modem_simple() but doesn't increase the reference count on the returned object. + * + * <warning>It is not safe to use the returned object if you are on another thread than the one where the #MMManager is running.</warning> + * + * Returns: (transfer none): A #MMModemSimple or %NULL if @self does not implement the interface. Do not free the returned object, it is owned by @self. + */ +MMModemSimple * +mm_object_peek_modem_simple (MMObject *self) +{ + g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL); + + return (MMModemSimple *)mm_gdbus_object_peek_modem_simple (MM_GDBUS_OBJECT (self)); +} + +/*****************************************************************************/ + +/** + * mm_object_get_modem_location: + * @self: A #MMObject. + * + * Gets the #MMModemLocation instance for the D-Bus interface org.freedesktop.ModemManager1.Modem.Modemlocation on @self, if any. + * + * Returns: (transfer full): A #MMModemLocation that must be freed with g_object_unref() or %NULL if @self does not implement the interface. + */ +MMModemLocation * +mm_object_get_modem_location (MMObject *self) +{ + g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL); + + return (MMModemLocation *)mm_gdbus_object_get_modem_location (MM_GDBUS_OBJECT (self)); +} + +/** + * mm_object_peek_modem_location: (skip) + * @self: A #MMObject. + * + * Like mm_object_get_modem_location() but doesn't increase the reference count on the returned object. + * + * <warning>It is not safe to use the returned object if you are on another thread than the one where the #MMManager is running.</warning> + * + * Returns: (transfer none): A #MMModemLocation or %NULL if @self does not implement the interface. Do not free the returned object, it is owned by @self. + */ +MMModemLocation * +mm_object_peek_modem_location (MMObject *self) +{ + g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL); + + return (MMModemLocation *)mm_gdbus_object_peek_modem_location (MM_GDBUS_OBJECT (self)); +} + +/*****************************************************************************/ + +/** + * mm_object_get_modem_messaging: + * @self: A #MMObject. + * + * Gets the #MMModemMessaging instance for the D-Bus interface org.freedesktop.ModemManager1.Modem.Modemmessaging on @self, if any. + * + * Returns: (transfer full): A #MMModemMessaging that must be freed with g_object_unref() or %NULL if @self does not implement the interface. + */ +MMModemMessaging * +mm_object_get_modem_messaging (MMObject *self) +{ + g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL); + + return (MMModemMessaging *)mm_gdbus_object_get_modem_messaging (MM_GDBUS_OBJECT (self)); +} + +/** + * mm_object_peek_modem_messaging: (skip) + * @self: A #MMObject. + * + * Like mm_object_get_modem_messaging() but doesn't increase the reference count on the returned object. + * + * <warning>It is not safe to use the returned object if you are on another thread than the one where the #MMManager is running.</warning> + * + * Returns: (transfer none): A #MMModemMessaging or %NULL if @self does not implement the interface. Do not free the returned object, it is owned by @self. + */ +MMModemMessaging * +mm_object_peek_modem_messaging (MMObject *self) +{ + g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL); + + return (MMModemMessaging *)mm_gdbus_object_peek_modem_messaging (MM_GDBUS_OBJECT (self)); +} + +/*****************************************************************************/ + +/** + * mm_object_get_modem_time: + * @self: A #MMObject. + * + * Gets the #MMModemTime instance for the D-Bus interface org.freedesktop.ModemManager1.Modem.Time on @self, if any. + * + * Returns: (transfer full): A #MMModemTime that must be freed with g_object_unref() or %NULL if @self does not implement the interface. + */ +MMModemTime * +mm_object_get_modem_time (MMObject *self) +{ + g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL); + + return (MMModemTime *)mm_gdbus_object_get_modem_time (MM_GDBUS_OBJECT (self)); +} + +/** + * mm_object_peek_modem_time: (skip) + * @self: A #MMObject. + * + * Like mm_object_get_modem_time() but doesn't increase the reference count on the returned object. + * + * <warning>It is not safe to use the returned object if you are on another thread than the one where the #MMManager is running.</warning> + * + * Returns: (transfer none): A #MMModemTime or %NULL if @self does not implement the interface. Do not free the returned object, it is owned by @self. + */ +MMModemTime * +mm_object_peek_modem_time (MMObject *self) +{ + g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL); + + return (MMModemTime *)mm_gdbus_object_peek_modem_time (MM_GDBUS_OBJECT (self)); +} + +/*****************************************************************************/ + +/** + * mm_object_get_modem_firmware: + * @self: A #MMObject. + * + * Gets the #MMModemFirmware instance for the D-Bus interface org.freedesktop.ModemManager1.Modem.Firmware on @self, if any. + * + * Returns: (transfer full): A #MMModemFirmware that must be freed with g_object_unref() or %NULL if @self does not implement the interface. + */ +MMModemFirmware * +mm_object_get_modem_firmware (MMObject *self) +{ + g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL); + + return (MMModemFirmware *)mm_gdbus_object_get_modem_firmware (MM_GDBUS_OBJECT (self)); +} + +/** + * mm_object_peek_modem_firmware: (skip) + * @self: A #MMObject. + * + * Like mm_object_get_modem_firmware() but doesn't increase the reference count on the returned object. + * + * <warning>It is not safe to use the returned object if you are on another thread than the one where the #MMManager is running.</warning> + * + * Returns: (transfer none): A #MMModemFirmware or %NULL if @self does not implement the interface. Do not free the returned object, it is owned by @self. + */ +MMModemFirmware * +mm_object_peek_modem_firmware (MMObject *self) +{ + g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL); + + return (MMModemFirmware *)mm_gdbus_object_peek_modem_firmware (MM_GDBUS_OBJECT (self)); +} + +/*****************************************************************************/ + +static void +mm_object_init (MMObject *self) +{ +} + +static void +mm_object_class_init (MMObjectClass *object_class) +{ +} diff --git a/libmm-glib/mm-object.h b/libmm-glib/mm-object.h new file mode 100644 index 0000000..e2a758f --- /dev/null +++ b/libmm-glib/mm-object.h @@ -0,0 +1,100 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2011 - 2012 Aleksander Morgado <aleksander@gnu.org> + * Copyright (C) 2012 Google, Inc. + */ + +#ifndef _MM_OBJECT_H_ +#define _MM_OBJECT_H_ + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> + +#include "mm-gdbus-modem.h" +#include "mm-modem.h" +#include "mm-modem-3gpp.h" +#include "mm-modem-3gpp-ussd.h" +#include "mm-modem-cdma.h" +#include "mm-modem-simple.h" +#include "mm-modem-location.h" +#include "mm-modem-messaging.h" +#include "mm-modem-time.h" +#include "mm-modem-firmware.h" + +G_BEGIN_DECLS + +#define MM_TYPE_OBJECT (mm_object_get_type ()) +#define MM_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_OBJECT, MMObject)) +#define MM_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_OBJECT, MMObjectClass)) +#define MM_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_OBJECT)) +#define MM_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), MM_TYPE_OBJECT)) +#define MM_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_OBJECT, MMObjectClass)) + +typedef struct _MMObject MMObject; +typedef struct _MMObjectClass MMObjectClass; + +/** + * MMObject: + * + * The #MMObject structure contains private data and should only be accessed + * using the provided API. + */ +struct _MMObject { + /*< private >*/ + MmGdbusObjectProxy parent; + gpointer unused; +}; + +struct _MMObjectClass { + /*< private >*/ + MmGdbusObjectProxyClass parent; +}; + +GType mm_object_get_type (void); + +const gchar *mm_object_get_path (MMObject *self); +gchar *mm_object_dup_path (MMObject *self); + +MMModem *mm_object_get_modem (MMObject *self); +MMModem3gpp *mm_object_get_modem_3gpp (MMObject *self); +MMModem3gppUssd *mm_object_get_modem_3gpp_ussd (MMObject *self); +MMModemCdma *mm_object_get_modem_cdma (MMObject *self); +MMModemSimple *mm_object_get_modem_simple (MMObject *self); +MMModemLocation *mm_object_get_modem_location (MMObject *self); +MMModemMessaging *mm_object_get_modem_messaging (MMObject *self); +MMModemTime *mm_object_get_modem_time (MMObject *self); +MMModemFirmware *mm_object_get_modem_firmware (MMObject *self); + +MMModem *mm_object_peek_modem (MMObject *self); +MMModem3gpp *mm_object_peek_modem_3gpp (MMObject *self); +MMModem3gppUssd *mm_object_peek_modem_3gpp_ussd (MMObject *self); +MMModemCdma *mm_object_peek_modem_cdma (MMObject *self); +MMModemSimple *mm_object_peek_modem_simple (MMObject *self); +MMModemLocation *mm_object_peek_modem_location (MMObject *self); +MMModemMessaging *mm_object_peek_modem_messaging (MMObject *self); +MMModemTime *mm_object_peek_modem_time (MMObject *self); +MMModemFirmware *mm_object_peek_modem_firmware (MMObject *self); + +G_END_DECLS + +#endif /* _MM_OBJECT_H_ */ diff --git a/libmm-glib/mm-sim.c b/libmm-glib/mm-sim.c new file mode 100644 index 0000000..74cb3f0 --- /dev/null +++ b/libmm-glib/mm-sim.c @@ -0,0 +1,677 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2011 - 2012 Aleksander Morgado <aleksander@gnu.org> + * Copyright (C) 2012 Google, Inc. + */ + +#include "mm-helpers.h" +#include "mm-sim.h" + +/** + * SECTION: mm-sim + * @title: MMSim + * @short_description: The SIM interface + * + * The #MMSim is an object providing access to the methods, signals and + * properties of the SIM interface. + * + * When the SIM is exposed and available in the bus, it is ensured that at + * least this interface is also available. + */ + +G_DEFINE_TYPE (MMSim, mm_sim, MM_GDBUS_TYPE_SIM_PROXY) + +/*****************************************************************************/ + +/** + * mm_sim_get_path: + * @self: A #MMSim. + * + * Gets the DBus path of the #MMSim object. + * + * Returns: (transfer none): The DBus path of the #MMSim object. + */ +const gchar * +mm_sim_get_path (MMSim *self) +{ + g_return_val_if_fail (MM_IS_SIM (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + g_dbus_proxy_get_object_path (G_DBUS_PROXY (self))); +} + +/** + * mm_sim_dup_path: + * @self: A #MMSim. + * + * Gets a copy of the DBus path of the #MMSim object. + * + * Returns: (transfer full): The DBus path of the #MMSim object. The returned value should be freed with g_free(). + */ +gchar * +mm_sim_dup_path (MMSim *self) +{ + gchar *value; + + g_return_val_if_fail (MM_IS_SIM (self), NULL); + + g_object_get (G_OBJECT (self), + "g-object-path", &value, + NULL); + + RETURN_NON_EMPTY_STRING (value); +} + +/*****************************************************************************/ + +/** + * mm_sim_get_identifier: + * @self: A #MMSim. + * + * Gets the unique SIM identifier of the #MMSim object. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_sim_dup_identifier() if on another + * thread.</warning> + * + * Returns: (transfer none): The unique identifier of the #MMSim object, or %NULL if it couldn't be retrieved. + */ +const gchar * +mm_sim_get_identifier (MMSim *self) +{ + g_return_val_if_fail (MM_IS_SIM (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_sim_get_sim_identifier (MM_GDBUS_SIM (self))); +} + +/** + * mm_sim_dup_identifier: + * @self: A #MMSim. + * + * Gets a copy of the unique SIM identifier of the #MMSim object. + * + * Returns: (transfer full): The unique identifier of the #MMSim object, or %NULL if it couldn't be retrieved. The returned value should be freed with g_free(). + */ +gchar * +mm_sim_dup_identifier (MMSim *self) +{ + g_return_val_if_fail (MM_IS_SIM (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_sim_dup_sim_identifier (MM_GDBUS_SIM (self))); +} + +/*****************************************************************************/ + +/** + * mm_sim_get_imsi: + * @self: A #MMSim. + * + * Gets the International Mobile Subscriber Identity (IMSI) of the #MMSim object. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_sim_dup_imsi() if on another + * thread.</warning> + * + * Returns: (transfer none): The IMSI of the #MMSim object, or %NULL if it couldn't be retrieved. + */ +const gchar * +mm_sim_get_imsi (MMSim *self) +{ + g_return_val_if_fail (MM_IS_SIM (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_sim_get_imsi (MM_GDBUS_SIM (self))); +} + +/** + * mm_sim_dup_imsi: + * @self: A #MMSim. + * + * Gets a copy of the International Mobile Subscriber Identity (IMSI) of the #MMSim object. + * + * Returns: (transfer full): The IMSI of the #MMSim object, or %NULL if it couldn't be retrieved. The returned value should be freed with g_free(). + */ +gchar * +mm_sim_dup_imsi (MMSim *self) +{ + g_return_val_if_fail (MM_IS_SIM (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_sim_dup_imsi (MM_GDBUS_SIM (self))); +} + +/*****************************************************************************/ + +/** + * mm_sim_get_operator_identifier: + * @self: A #MMSim. + * + * Gets the Operator Identifier of the #MMSim object. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_sim_dup_operator_identifier() if on another + * thread.</warning> + * + * Returns: (transfer none): The Operator Identifier of the #MMSim object, or %NULL if it couldn't be retrieved. + */ +const gchar * +mm_sim_get_operator_identifier (MMSim *self) +{ + g_return_val_if_fail (MM_IS_SIM (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_sim_get_operator_identifier (MM_GDBUS_SIM (self))); +} + +/** + * mm_sim_dup_operator_identifier: + * @self: A #MMSim. + * + * Gets a copy of the Operator Identifier of the #MMSim object. + * + * Returns: (transfer full): The Operator Identifier of the #MMSim object, or %NULL if it couldn't be retrieved. The returned value should be freed with g_free(). + */ +gchar * +mm_sim_dup_operator_identifier (MMSim *self) +{ + g_return_val_if_fail (MM_IS_SIM (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_sim_dup_operator_identifier (MM_GDBUS_SIM (self))); +} + +/*****************************************************************************/ + +/** + * mm_sim_get_operator_name: + * @self: A #MMSim. + * + * Gets the Operator Name of the #MMSim object. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_sim_dup_operator_name() if on another + * thread.</warning> + * + * Returns: (transfer none): The Operator Name of the #MMSim object, or %NULL if it couldn't be retrieved. + */ +const gchar * +mm_sim_get_operator_name (MMSim *self) +{ + g_return_val_if_fail (MM_IS_SIM (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_sim_get_operator_name (MM_GDBUS_SIM (self))); +} + +/** + * mm_sim_dup_operator_name: + * @self: A #MMSim. + * + * Gets a copy of the Operator Name of the #MMSim object. + * + * Returns: (transfer full): The Operator Name of the #MMSim object, or %NULL if it couldn't be retrieved. The returned value should be freed with g_free(). + */ +gchar * +mm_sim_dup_operator_name (MMSim *self) +{ + g_return_val_if_fail (MM_IS_SIM (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_sim_dup_operator_name (MM_GDBUS_SIM (self))); +} + +/*****************************************************************************/ + +/** + * mm_sim_send_pin_finish: + * @self: A #MMSim. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_sim_send_pin(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_sim_send_pin(). + * + * Returns: %TRUE if the operation succeded, %FALSE if @error is set. + */ +gboolean +mm_sim_send_pin_finish (MMSim *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_SIM (self), FALSE); + + return mm_gdbus_sim_call_send_pin_finish (MM_GDBUS_SIM (self), res, error); +} + +/** + * mm_sim_send_pin: + * @self: A #MMSim. + * @pin: The PIN code. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously sends the PIN code to the SIM card. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_sim_send_pin_finish() to get the result of the operation. + * + * See mm_sim_send_pin_sync() for the synchronous, blocking version of this method. + */ +void +mm_sim_send_pin (MMSim *self, + const gchar *pin, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_SIM (self)); + + mm_gdbus_sim_call_send_pin (MM_GDBUS_SIM (self), + pin, + cancellable, + callback, + user_data); +} + +/** + * mm_sim_send_pin_sync: + * @self: A #MMSim. + * @pin: The PIN code. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously sends the PIN to the SIM card. + * + * The calling thread is blocked until a reply is received. + * See mm_sim_send_pin() for the asynchronous version of this method. + * + * Returns: %TRUE if the operation succeded, %FALSE if @error is set. + */ +gboolean +mm_sim_send_pin_sync (MMSim *self, + const gchar *pin, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_SIM (self), FALSE); + + return (mm_gdbus_sim_call_send_pin_sync (MM_GDBUS_SIM (self), + pin, + cancellable, + error)); +} + +/*****************************************************************************/ + +/** + * mm_sim_send_puk_finish: + * @self: A #MMSim. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_sim_send_puk(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_sim_send_puk(). + * + * Returns: %TRUE if the operation succeded, %FALSE if @error is set. + */ +gboolean +mm_sim_send_puk_finish (MMSim *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_SIM (self), FALSE); + + return mm_gdbus_sim_call_send_puk_finish (MM_GDBUS_SIM (self), res, error); +} + +/** + * mm_sim_send_puk: + * @self: A #MMSim. + * @puk: The PUK code. + * @pin: The PIN code. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously sends the PUK code to the SIM card. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_sim_send_puk_finish() to get the result of the operation. + * + * See mm_sim_send_puk_sync() for the synchronous, blocking version of this method. + */ +void +mm_sim_send_puk (MMSim *self, + const gchar *puk, + const gchar *pin, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_SIM (self)); + + mm_gdbus_sim_call_send_puk (MM_GDBUS_SIM (self), + puk, + pin, + cancellable, + callback, + user_data); +} + +/** + * mm_sim_send_puk_sync: + * @self: A #MMSim. + * @puk: The PUK code. + * @pin: The PIN code. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously sends the PUK to the SIM card. + * + * The calling thread is blocked until a reply is received. + * See mm_sim_send_puk() for the asynchronous version of this method. + * + * Returns: %TRUE if the operation succeded, %FALSE if @error is set. + */ +gboolean +mm_sim_send_puk_sync (MMSim *self, + const gchar *puk, + const gchar *pin, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_SIM (self), FALSE); + + return (mm_gdbus_sim_call_send_puk_sync (MM_GDBUS_SIM (self), + puk, + pin, + cancellable, + error)); +} + +/*****************************************************************************/ + +/** + * mm_sim_enable_pin_finish: + * @self: A #MMSim. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_sim_enable_pin(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_sim_enable_pin(). + * + * Returns: %TRUE if the operation succeded, %FALSE if @error is set. + */ +gboolean +mm_sim_enable_pin_finish (MMSim *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_SIM (self), FALSE); + + return mm_gdbus_sim_call_enable_pin_finish (MM_GDBUS_SIM (self), res, error); +} + +/** + * mm_sim_enable_pin: + * @self: A #MMSim. + * @pin: The PIN code. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously enables requesting the PIN code in the SIM card. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_sim_enable_pin_finish() to get the result of the operation. + * + * See mm_sim_enable_pin_sync() for the synchronous, blocking version of this method. + */ +void +mm_sim_enable_pin (MMSim *self, + const gchar *pin, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_SIM (self)); + + mm_gdbus_sim_call_enable_pin (MM_GDBUS_SIM (self), + pin, + TRUE, + cancellable, + callback, + user_data); +} + +/** + * mm_sim_enable_pin_sync: + * @self: A #MMSim. + * @pin: The PIN code. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously enables requesting the PIN code in the SIM card. + * + * The calling thread is blocked until a reply is received. + * See mm_sim_enable_pin() for the asynchronous version of this method. + * + * Returns: %TRUE if the operation succeded, %FALSE if @error is set. + */ +gboolean +mm_sim_enable_pin_sync (MMSim *self, + const gchar *pin, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_SIM (self), FALSE); + + return (mm_gdbus_sim_call_enable_pin_sync (MM_GDBUS_SIM (self), + pin, + TRUE, + cancellable, + error)); +} + +/*****************************************************************************/ + +/** + * mm_sim_disable_pin_finish: + * @self: A #MMSim. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_sim_disable_pin(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_sim_disable_pin(). + * + * Returns: %TRUE if the operation succeded, %FALSE if @error is set. + */ +gboolean +mm_sim_disable_pin_finish (MMSim *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_SIM (self), FALSE); + + return mm_gdbus_sim_call_enable_pin_finish (MM_GDBUS_SIM (self), res, error); +} + +/** + * mm_sim_disable_pin: + * @self: A #MMSim. + * @pin: The PIN code. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously disables requesting the PIN code in the SIM card. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_sim_disable_pin_finish() to get the result of the operation. + * + * See mm_sim_disable_pin_sync() for the synchronous, blocking version of this method. + */ +void +mm_sim_disable_pin (MMSim *self, + const gchar *pin, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_SIM (self)); + + mm_gdbus_sim_call_enable_pin (MM_GDBUS_SIM (self), + pin, + FALSE, + cancellable, + callback, + user_data); +} + +/** + * mm_sim_disable_pin_sync: + * @self: A #MMSim. + * @pin: The PIN code. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously disables requesting the PIN code in the SIM card. + * + * The calling thread is blocked until a reply is received. + * See mm_sim_disable_pin() for the asynchronous version of this method. + * + * Returns: %TRUE if the operation succeded, %FALSE if @error is set. + */ +gboolean +mm_sim_disable_pin_sync (MMSim *self, + const gchar *pin, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_SIM (self), FALSE); + + return (mm_gdbus_sim_call_enable_pin_sync (MM_GDBUS_SIM (self), + pin, + FALSE, + cancellable, + error)); +} + +/*****************************************************************************/ + +/** + * mm_sim_change_pin_finish: + * @self: A #MMSim. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_sim_change_pin(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_sim_change_pin(). + * + * Returns: %TRUE if the operation succeded, %FALSE if @error is set. + */ +gboolean +mm_sim_change_pin_finish (MMSim *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_SIM (self), FALSE); + + return mm_gdbus_sim_call_change_pin_finish (MM_GDBUS_SIM (self), res, error); +} + +/** + * mm_sim_change_pin: + * @self: A #MMSim. + * @old_pin: The current PIN code. + * @new_pin: The new PIN code to be set. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously changes the PIN code in the SIM card. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_sim_change_pin_finish() to get the result of the operation. + * + * See mm_sim_change_pin_sync() for the synchronous, blocking version of this method. + */ +void +mm_sim_change_pin (MMSim *self, + const gchar *old_pin, + const gchar *new_pin, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_SIM (self)); + + mm_gdbus_sim_call_change_pin (MM_GDBUS_SIM (self), + old_pin, + new_pin, + cancellable, + callback, + user_data); +} + +/** + * mm_sim_change_pin_sync: + * @self: A #MMSim. + * @old_pin: The current PIN code. + * @new_pin: The new PIN code to be set. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously changes the PIN code in the SIM card. + * + * The calling thread is blocked until a reply is received. + * See mm_sim_change_pin() for the asynchronous version of this method. + * + * Returns: %TRUE if the operation succeded, %FALSE if @error is set. + */ +gboolean +mm_sim_change_pin_sync (MMSim *self, + const gchar *old_pin, + const gchar *new_pin, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_SIM (self), FALSE); + + return (mm_gdbus_sim_call_change_pin_sync (MM_GDBUS_SIM (self), + old_pin, + new_pin, + cancellable, + error)); +} + +/*****************************************************************************/ + +static void +mm_sim_init (MMSim *self) +{ +} + +static void +mm_sim_class_init (MMSimClass *sim_class) +{ +} diff --git a/libmm-glib/mm-sim.h b/libmm-glib/mm-sim.h new file mode 100644 index 0000000..1998bf6 --- /dev/null +++ b/libmm-glib/mm-sim.h @@ -0,0 +1,153 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2011 - 2012 Aleksander Morgado <aleksander@gnu.org> + * Copyright (C) 2012 Google, Inc. + */ + +#ifndef _MM_SIM_H_ +#define _MM_SIM_H_ + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> + +#include "mm-gdbus-sim.h" + +G_BEGIN_DECLS + +#define MM_TYPE_SIM (mm_sim_get_type ()) +#define MM_SIM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SIM, MMSim)) +#define MM_SIM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_SIM, MMSimClass)) +#define MM_IS_SIM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_SIM)) +#define MM_IS_SIM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), MM_TYPE_SIM)) +#define MM_SIM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_SIM, MMSimClass)) + +typedef struct _MMSim MMSim; +typedef struct _MMSimClass MMSimClass; + +/** + * MMSim: + * + * The #MMSim structure contains private data and should only be accessed + * using the provided API. + */ +struct _MMSim { + /*< private >*/ + MmGdbusSimProxy parent; + gpointer unused; +}; + +struct _MMSimClass { + /*< private >*/ + MmGdbusSimProxyClass parent; +}; + +GType mm_sim_get_type (void); + +const gchar *mm_sim_get_path (MMSim *self); +gchar *mm_sim_dup_path (MMSim *self); + +const gchar *mm_sim_get_identifier (MMSim *self); +gchar *mm_sim_dup_identifier (MMSim *self); + +const gchar *mm_sim_get_imsi (MMSim *self); +gchar *mm_sim_dup_imsi (MMSim *self); + +const gchar *mm_sim_get_operator_identifier (MMSim *self); +gchar *mm_sim_dup_operator_identifier (MMSim *self); + +const gchar *mm_sim_get_operator_name (MMSim *self); +gchar *mm_sim_dup_operator_name (MMSim *self); + +void mm_sim_send_pin (MMSim *self, + const gchar *pin, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_sim_send_pin_finish (MMSim *self, + GAsyncResult *res, + GError **error); +gboolean mm_sim_send_pin_sync (MMSim *self, + const gchar *pin, + GCancellable *cancellable, + GError **error); + +void mm_sim_send_puk (MMSim *self, + const gchar *puk, + const gchar *pin, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_sim_send_puk_finish (MMSim *self, + GAsyncResult *res, + GError **error); +gboolean mm_sim_send_puk_sync (MMSim *self, + const gchar *puk, + const gchar *pin, + GCancellable *cancellable, + GError **error); + +void mm_sim_enable_pin (MMSim *self, + const gchar *pin, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_sim_enable_pin_finish (MMSim *self, + GAsyncResult *res, + GError **error); +gboolean mm_sim_enable_pin_sync (MMSim *self, + const gchar *pin, + GCancellable *cancellable, + GError **error); + + +void mm_sim_disable_pin (MMSim *self, + const gchar *pin, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_sim_disable_pin_finish (MMSim *self, + GAsyncResult *res, + GError **error); +gboolean mm_sim_disable_pin_sync (MMSim *self, + const gchar *pin, + GCancellable *cancellable, + GError **error); + +void mm_sim_change_pin (MMSim *self, + const gchar *old_pin, + const gchar *new_pin, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_sim_change_pin_finish (MMSim *self, + GAsyncResult *res, + GError **error); +gboolean mm_sim_change_pin_sync (MMSim *self, + const gchar *old_pin, + const gchar *new_pin, + GCancellable *cancellable, + GError **error); + +G_END_DECLS + +#endif /* _MM_SIM_H_ */ diff --git a/libmm-glib/mm-simple-connect-properties.c b/libmm-glib/mm-simple-connect-properties.c new file mode 100644 index 0000000..f57cc4f --- /dev/null +++ b/libmm-glib/mm-simple-connect-properties.c @@ -0,0 +1,591 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2011 Aleksander Morgado <aleksander@gnu.org> + */ + +#include <string.h> + +#include "mm-errors-types.h" +#include "mm-common-helpers.h" +#include "mm-simple-connect-properties.h" + +/** + * SECTION: mm-simple-connect-properties + * @title: MMSimpleConnectProperties + * @short_description: Helper object to handle connection properties. + * + * The #MMSimpleConnectProperties is an object handling the properties requested + * to ModemManager when launching a connection with the Simple interface. + * + * This object is created by the user and passed to ModemManager with either + * mm_modem_simple_connect() or mm_modem_simple_connect_sync(). + */ + +G_DEFINE_TYPE (MMSimpleConnectProperties, mm_simple_connect_properties, G_TYPE_OBJECT); + +#define PROPERTY_PIN "pin" +#define PROPERTY_OPERATOR_ID "operator-id" + +struct _MMSimpleConnectPropertiesPrivate { + /* PIN */ + gchar *pin; + /* Operator ID */ + gchar *operator_id; + /* Bearer properties */ + MMBearerProperties *bearer_properties; +}; + +/*****************************************************************************/ + +/** + * mm_simple_connect_properties_set_pin: + * @self: a #MMSimpleConnectProperties. + * @pin: PIN code. + * + * Sets the PIN code to use when unlocking the modem. + */ +void +mm_simple_connect_properties_set_pin (MMSimpleConnectProperties *self, + const gchar *pin) +{ + g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self)); + + g_free (self->priv->pin); + self->priv->pin = g_strdup (pin); +} + +/** + * mm_simple_connect_properties_get_pin: + * @self: a #MMSimpleConnectProperties. + * + * Gets the PIN code to use when unlocking the modem. + * + * Returns: (transfer none): the PIN, or #NULL if not set. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_simple_connect_properties_get_pin (MMSimpleConnectProperties *self) +{ + g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), NULL); + + return self->priv->pin; +} + +/*****************************************************************************/ + +/** + * mm_simple_connect_properties_set_operator_id: + * @self: a #MMSimpleConnectProperties. + * @operator_id: operator ID, given as MCC/MNC. + * + * Sets the ID of the network to which register before connecting. + */ +void +mm_simple_connect_properties_set_operator_id (MMSimpleConnectProperties *self, + const gchar *operator_id) +{ + g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self)); + + g_free (self->priv->operator_id); + self->priv->operator_id = g_strdup (operator_id); +} + +/** + * mm_simple_connect_properties_get_operator_id: + * @self: a #MMSimpleConnectProperties. + * + * Gets the ID of the network to which register before connecting. + * + * Returns: (transfer none): the operator ID, or #NULL if not set. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_simple_connect_properties_get_operator_id (MMSimpleConnectProperties *self) +{ + g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), NULL); + + return self->priv->operator_id; +} + +/*****************************************************************************/ + +/** + * mm_simple_connect_properties_set_apn: + * @self: a #MMSimpleConnectProperties. + * @apn: Name of the access point. + * + * Sets the name of the access point to use when connecting. + */ +void +mm_simple_connect_properties_set_apn (MMSimpleConnectProperties *self, + const gchar *apn) +{ + g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self)); + + mm_bearer_properties_set_apn (self->priv->bearer_properties, + apn); +} + +/** + * mm_simple_connect_properties_get_apn: + * @self: a #MMSimpleConnectProperties. + * + * Gets the name of the access point to use when connecting. + * + * Returns: (transfer none): the access point, or #NULL if not set. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_simple_connect_properties_get_apn (MMSimpleConnectProperties *self) +{ + g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), NULL); + + return mm_bearer_properties_get_apn (self->priv->bearer_properties); +} + +/*****************************************************************************/ + +/** + * mm_simple_connect_properties_set_allowed_auth: + * @self: a #MMSimpleConnectProperties. + * @allowed_auth: a bitmask of #MMBearerAllowedAuth values. %MM_BEARER_ALLOWED_AUTH_UNKNOWN may be given to request the modem-default method. + * + * Sets the authentication method to use. + */ +void +mm_simple_connect_properties_set_allowed_auth (MMSimpleConnectProperties *self, + MMBearerAllowedAuth allowed_auth) +{ + g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self)); + + mm_bearer_properties_set_allowed_auth (self->priv->bearer_properties, allowed_auth); +} + +/** + * mm_simple_connect_properties_get_allowed_auth: + * @self: a #MMSimpleConnectProperties. + * + * Gets the authentication methods allowed in the connection. + * + * Returns: a bitmask of #MMBearerAllowedAuth values, or %MM_BEARER_ALLOWED_AUTH_UNKNOWN to request the modem-default method. + */ +MMBearerAllowedAuth +mm_simple_connect_properties_get_allowed_auth (MMSimpleConnectProperties *self) +{ + g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), MM_BEARER_ALLOWED_AUTH_UNKNOWN); + + return mm_bearer_properties_get_allowed_auth (self->priv->bearer_properties); +} + +/*****************************************************************************/ + +/** + * mm_simple_connect_properties_set_user: + * @self: a #MMSimpleConnectProperties. + * @user: the username + * + * Sets the username used to authenticate with the access point. + */ +void +mm_simple_connect_properties_set_user (MMSimpleConnectProperties *self, + const gchar *user) +{ + g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self)); + + mm_bearer_properties_set_user (self->priv->bearer_properties, + user); +} + +/** + * mm_simple_connect_properties_get_user: + * @self: a #MMSimpleConnectProperties. + * + * Gets the username used to authenticate with the access point. + * + * Returns: (transfer none): the username, or #NULL if not set. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_simple_connect_properties_get_user (MMSimpleConnectProperties *self) +{ + g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), NULL); + + return mm_bearer_properties_get_user (self->priv->bearer_properties); +} + +/*****************************************************************************/ + +/** + * mm_simple_connect_properties_set_password: + * @self: a #MMSimpleConnectProperties. + * @password: the password + * + * Sets the password used to authenticate with the access point. + */ +void +mm_simple_connect_properties_set_password (MMSimpleConnectProperties *self, + const gchar *password) +{ + g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self)); + + mm_bearer_properties_set_password (self->priv->bearer_properties, + password); +} + +/** + * mm_simple_connect_properties_get_password: + * @self: a #MMSimpleConnectProperties. + * + * Gets the password used to authenticate with the access point. + * + * Returns: (transfer none): the password, or #NULL if not set. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_simple_connect_properties_get_password (MMSimpleConnectProperties *self) +{ + g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), NULL); + + return mm_bearer_properties_get_password (self->priv->bearer_properties); +} + +/*****************************************************************************/ + +/** + * mm_simple_connect_properties_set_ip_type: + * @self: a #MMSimpleConnectProperties. + * @ip_type: a #MMBearerIpFamily. + * + * Sets the IP type to use. + */ +void +mm_simple_connect_properties_set_ip_type (MMSimpleConnectProperties *self, + MMBearerIpFamily ip_type) +{ + g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self)); + + mm_bearer_properties_set_ip_type (self->priv->bearer_properties, + ip_type); +} + +/** + * mm_simple_connect_properties_get_ip_type: + * @self: a #MMSimpleConnectProperties. + * + * Sets the IP type to use. + * + * Returns: a #MMBearerIpFamily. + */ +MMBearerIpFamily +mm_simple_connect_properties_get_ip_type (MMSimpleConnectProperties *self) +{ + g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), MM_BEARER_IP_FAMILY_NONE); + + return mm_bearer_properties_get_ip_type (self->priv->bearer_properties); +} + +/*****************************************************************************/ + +/** + * mm_simple_connect_properties_set_allow_roaming: + * @self: a #MMSimpleConnectProperties. + * @allow_roaming: boolean value. + * + * Sets the flag to indicate whether roaming is allowed or not in the + * connection. + */ +void +mm_simple_connect_properties_set_allow_roaming (MMSimpleConnectProperties *self, + gboolean allow_roaming) +{ + g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self)); + + mm_bearer_properties_set_allow_roaming (self->priv->bearer_properties, + allow_roaming); +} + +/** + * mm_simple_connect_properties_get_allow_roaming: + * @self: a #MMSimpleConnectProperties. + * + * Checks whether roaming is allowed in the connection. + * + * Returns: %TRUE if roaming is allowed, %FALSE otherwise.. + */ +gboolean +mm_simple_connect_properties_get_allow_roaming (MMSimpleConnectProperties *self) +{ + g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), FALSE); + + return mm_bearer_properties_get_allow_roaming (self->priv->bearer_properties); +} + + +/*****************************************************************************/ + +/** + * mm_simple_connect_properties_set_number: + * @self: a #MMSimpleConnectProperties. + * @number: the number. + * + * Sets the number to use when performing the connection. + */ +void +mm_simple_connect_properties_set_number (MMSimpleConnectProperties *self, + const gchar *number) +{ + g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self)); + + mm_bearer_properties_set_number (self->priv->bearer_properties, + number); +} + +/** + * mm_simple_connect_properties_get_number: + * @self: a #MMSimpleConnectProperties. + * + * Gets the number to use when performing the connection. + * + * Returns: (transfer none): the number, or #NULL if not set. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_simple_connect_properties_get_number (MMSimpleConnectProperties *self) +{ + g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), NULL); + + return mm_bearer_properties_get_number (self->priv->bearer_properties); +} + +/*****************************************************************************/ + +MMBearerProperties * +mm_simple_connect_properties_get_bearer_properties (MMSimpleConnectProperties *self) +{ + g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), NULL); + + return g_object_ref (self->priv->bearer_properties); +} + +/*****************************************************************************/ + +GVariant * +mm_simple_connect_properties_get_dictionary (MMSimpleConnectProperties *self) +{ + GVariantBuilder builder; + GVariantIter iter; + gchar *key; + GVariant *value; + GVariant *bearer_properties_dictionary; + + /* We do allow NULL */ + if (!self) + return NULL; + + g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), NULL); + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); + + if (self->priv->pin) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_PIN, + g_variant_new_string (self->priv->pin)); + + if (self->priv->operator_id) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_OPERATOR_ID, + g_variant_new_string (self->priv->operator_id)); + + /* Merge dictionaries */ + bearer_properties_dictionary = mm_bearer_properties_get_dictionary (self->priv->bearer_properties); + g_variant_iter_init (&iter, bearer_properties_dictionary); + while (g_variant_iter_next (&iter, "{sv}", &key, &value)) { + g_variant_builder_add (&builder, + "{sv}", + key, + value); + g_variant_unref (value); + g_free (key); + } + g_variant_unref (bearer_properties_dictionary); + + return g_variant_ref_sink (g_variant_builder_end (&builder)); +} + +/*****************************************************************************/ + +typedef struct { + MMSimpleConnectProperties *self; + GError *error; + gchar *allowed_modes_str; + gchar *preferred_mode_str; +} ParseKeyValueContext; + +static gboolean +key_value_foreach (const gchar *key, + const gchar *value, + ParseKeyValueContext *ctx) +{ + /* First, check if we can consume this as bearer properties */ + if (mm_bearer_properties_consume_string (ctx->self->priv->bearer_properties, + key, value, + NULL)) + return TRUE; + + if (g_str_equal (key, PROPERTY_PIN)) + mm_simple_connect_properties_set_pin (ctx->self, value); + else if (g_str_equal (key, PROPERTY_OPERATOR_ID)) + mm_simple_connect_properties_set_operator_id (ctx->self, value); + else { + ctx->error = g_error_new (MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Invalid properties string, unexpected key '%s'", + key); + } + + return !ctx->error; +} + +MMSimpleConnectProperties * +mm_simple_connect_properties_new_from_string (const gchar *str, + GError **error) +{ + ParseKeyValueContext ctx; + + ctx.error = NULL; + ctx.self = mm_simple_connect_properties_new (); + + mm_common_parse_key_value_string (str, + &ctx.error, + (MMParseKeyValueForeachFn)key_value_foreach, + &ctx); + + /* If error, destroy the object */ + if (ctx.error) { + g_propagate_error (error, ctx.error); + g_object_unref (ctx.self); + ctx.self = NULL; + } + + return ctx.self; +} + +/*****************************************************************************/ + +MMSimpleConnectProperties * +mm_simple_connect_properties_new_from_dictionary (GVariant *dictionary, + GError **error) +{ + GError *inner_error = NULL; + GVariantIter iter; + gchar *key; + GVariant *value; + MMSimpleConnectProperties *self; + + self = mm_simple_connect_properties_new (); + if (!dictionary) + return self; + + if (!g_variant_is_of_type (dictionary, G_VARIANT_TYPE ("a{sv}"))) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Cannot create Simple Connect properties from dictionary: " + "invalid variant type received"); + g_object_unref (self); + return NULL; + } + + g_variant_iter_init (&iter, dictionary); + while (!inner_error && + g_variant_iter_next (&iter, "{sv}", &key, &value)) { + + /* First, check if we can consume this as bearer properties */ + if (!mm_bearer_properties_consume_variant (self->priv->bearer_properties, + key, value, + NULL)) { + if (g_str_equal (key, PROPERTY_PIN)) + mm_simple_connect_properties_set_pin ( + self, + g_variant_get_string (value, NULL)); + else if (g_str_equal (key, PROPERTY_OPERATOR_ID)) + mm_simple_connect_properties_set_operator_id ( + self, + g_variant_get_string (value, NULL)); + else { + /* Set inner error, will stop the loop */ + inner_error = g_error_new (MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Invalid properties dictionary, unexpected key '%s'", + key); + } + } + + g_free (key); + g_variant_unref (value); + } + + /* If error, destroy the object */ + if (inner_error) { + g_propagate_error (error, inner_error); + g_object_unref (self); + self = NULL; + } + + return self; +} + +/*****************************************************************************/ + +/** + * mm_simple_connect_properties_new: + * + * Creates a new empty #MMSimpleConnectProperties. + * + * Returns: (transfer full): a #MMSimpleConnectProperties. The returned value should be freed with g_object_unref(). + */ +MMSimpleConnectProperties * +mm_simple_connect_properties_new (void) +{ + return (MM_SIMPLE_CONNECT_PROPERTIES ( + g_object_new (MM_TYPE_SIMPLE_CONNECT_PROPERTIES, NULL))); +} + +static void +mm_simple_connect_properties_init (MMSimpleConnectProperties *self) +{ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), + MM_TYPE_SIMPLE_CONNECT_PROPERTIES, + MMSimpleConnectPropertiesPrivate); + + /* Some defaults */ + self->priv->bearer_properties = mm_bearer_properties_new (); +} + +static void +finalize (GObject *object) +{ + MMSimpleConnectProperties *self = MM_SIMPLE_CONNECT_PROPERTIES (object); + + g_free (self->priv->pin); + g_free (self->priv->operator_id); + g_object_unref (self->priv->bearer_properties); + + G_OBJECT_CLASS (mm_simple_connect_properties_parent_class)->finalize (object); +} + +static void +mm_simple_connect_properties_class_init (MMSimpleConnectPropertiesClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (MMSimpleConnectPropertiesPrivate)); + + object_class->finalize = finalize; +} diff --git a/libmm-glib/mm-simple-connect-properties.h b/libmm-glib/mm-simple-connect-properties.h new file mode 100644 index 0000000..e9c09ae --- /dev/null +++ b/libmm-glib/mm-simple-connect-properties.h @@ -0,0 +1,111 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2011 Aleksander Morgado <aleksander@gnu.org> + */ + +#ifndef MM_SIMPLE_CONNECT_PROPERTIES_H +#define MM_SIMPLE_CONNECT_PROPERTIES_H + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> +#include <glib-object.h> + +#include "mm-bearer-properties.h" + +G_BEGIN_DECLS + +#define MM_TYPE_SIMPLE_CONNECT_PROPERTIES (mm_simple_connect_properties_get_type ()) +#define MM_SIMPLE_CONNECT_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SIMPLE_CONNECT_PROPERTIES, MMSimpleConnectProperties)) +#define MM_SIMPLE_CONNECT_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_SIMPLE_CONNECT_PROPERTIES, MMSimpleConnectPropertiesClass)) +#define MM_IS_SIMPLE_CONNECT_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_SIMPLE_CONNECT_PROPERTIES)) +#define MM_IS_SIMPLE_CONNECT_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_SIMPLE_CONNECT_PROPERTIES)) +#define MM_SIMPLE_CONNECT_PROPERTIES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_SIMPLE_CONNECT_PROPERTIES, MMSimpleConnectPropertiesClass)) + +typedef struct _MMSimpleConnectProperties MMSimpleConnectProperties; +typedef struct _MMSimpleConnectPropertiesClass MMSimpleConnectPropertiesClass; +typedef struct _MMSimpleConnectPropertiesPrivate MMSimpleConnectPropertiesPrivate; + +/** + * MMSimpleConnectProperties: + * + * The #MMSimpleConnectProperties structure contains private data and should + * only be accessed using the provided API. + */ +struct _MMSimpleConnectProperties { + /*< private >*/ + GObject parent; + MMSimpleConnectPropertiesPrivate *priv; +}; + +struct _MMSimpleConnectPropertiesClass { + /*< private >*/ + GObjectClass parent; +}; + +GType mm_simple_connect_properties_get_type (void); + +MMSimpleConnectProperties *mm_simple_connect_properties_new (void); + +void mm_simple_connect_properties_set_pin (MMSimpleConnectProperties *self, + const gchar *pin); +void mm_simple_connect_properties_set_operator_id (MMSimpleConnectProperties *self, + const gchar *operator_id); +void mm_simple_connect_properties_set_apn (MMSimpleConnectProperties *self, + const gchar *apn); +void mm_simple_connect_properties_set_allowed_auth (MMSimpleConnectProperties *self, + MMBearerAllowedAuth allowed_auth); +void mm_simple_connect_properties_set_user (MMSimpleConnectProperties *self, + const gchar *user); +void mm_simple_connect_properties_set_password (MMSimpleConnectProperties *self, + const gchar *password); +void mm_simple_connect_properties_set_ip_type (MMSimpleConnectProperties *self, + MMBearerIpFamily ip_type); +void mm_simple_connect_properties_set_allow_roaming (MMSimpleConnectProperties *self, + gboolean allow_roaming); +void mm_simple_connect_properties_set_number (MMSimpleConnectProperties *self, + const gchar *number); + +const gchar *mm_simple_connect_properties_get_pin (MMSimpleConnectProperties *self); +const gchar *mm_simple_connect_properties_get_operator_id (MMSimpleConnectProperties *self); +const gchar *mm_simple_connect_properties_get_apn (MMSimpleConnectProperties *self); +MMBearerAllowedAuth mm_simple_connect_properties_get_allowed_auth (MMSimpleConnectProperties *self); +const gchar *mm_simple_connect_properties_get_user (MMSimpleConnectProperties *self); +const gchar *mm_simple_connect_properties_get_password (MMSimpleConnectProperties *self); +MMBearerIpFamily mm_simple_connect_properties_get_ip_type (MMSimpleConnectProperties *self); +gboolean mm_simple_connect_properties_get_allow_roaming (MMSimpleConnectProperties *self); +const gchar *mm_simple_connect_properties_get_number (MMSimpleConnectProperties *self); + +/*****************************************************************************/ +/* ModemManager/libmm-glib/mmcli specific methods */ + +#if defined (_LIBMM_INSIDE_MM) || \ + defined (_LIBMM_INSIDE_MMCLI) || \ + defined (LIBMM_GLIB_COMPILATION) + +MMSimpleConnectProperties *mm_simple_connect_properties_new_from_string (const gchar *str, + GError **error); +MMSimpleConnectProperties *mm_simple_connect_properties_new_from_dictionary (GVariant *dictionary, + GError **error); + +MMBearerProperties *mm_simple_connect_properties_get_bearer_properties (MMSimpleConnectProperties *properties); + +GVariant *mm_simple_connect_properties_get_dictionary (MMSimpleConnectProperties *self); +#endif + + +G_END_DECLS + +#endif /* MM_SIMPLE_CONNECT_PROPERTIES_H */ diff --git a/libmm-glib/mm-simple-status.c b/libmm-glib/mm-simple-status.c new file mode 100644 index 0000000..10dfee3 --- /dev/null +++ b/libmm-glib/mm-simple-status.c @@ -0,0 +1,718 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2011 Google, Inc. + */ + +#include <string.h> + +#include "mm-enums-types.h" +#include "mm-errors-types.h" +#include "mm-common-helpers.h" +#include "mm-simple-status.h" +#include "mm-modem-cdma.h" + +/** + * SECTION: mm-simple-status + * @title: MMSimpleStatus + * @short_description: Helper object to handle overall modem status. + * + * The #MMSimpleStatus is an object handling the general modem status properties, + * available in the Simple interface. + * + * This object is retrieved with either mm_modem_simple_get_status() or + * mm_modem_simple_get_status_sync(). + */ + +G_DEFINE_TYPE (MMSimpleStatus, mm_simple_status, G_TYPE_OBJECT); + +enum { + PROP_0, + PROP_STATE, + PROP_SIGNAL_QUALITY, + PROP_CURRENT_BANDS, + PROP_ACCESS_TECHNOLOGIES, + PROP_3GPP_REGISTRATION_STATE, + PROP_3GPP_OPERATOR_CODE, + PROP_3GPP_OPERATOR_NAME, + PROP_CDMA_CDMA1X_REGISTRATION_STATE, + PROP_CDMA_EVDO_REGISTRATION_STATE, + PROP_CDMA_SID, + PROP_CDMA_NID, + PROP_LAST +}; + +static GParamSpec *properties[PROP_LAST]; + +struct _MMSimpleStatusPrivate { + /* <--- From the Modem interface ---> */ + /* Overall modem state, signature 'u' */ + MMModemState state; + /* Signal quality, given only when registered, signature '(ub)' */ + GVariant *signal_quality; + /* List of bands, given only when registered, signature: au */ + GVariant *current_bands; + GArray *current_bands_array; + /* Access technologies, given only when registered, signature: u */ + MMModemAccessTechnology access_technologies; + + /* <--- From the Modem 3GPP interface ---> */ + /* 3GPP registration state, signature 'u' */ + MMModem3gppRegistrationState modem_3gpp_registration_state; + /* 3GPP operator code, given only when registered, signature 's' */ + gchar *modem_3gpp_operator_code; + /* 3GPP operator name, given only when registered, signature 's' */ + gchar *modem_3gpp_operator_name; + + /* <--- From the Modem CDMA interface ---> */ + /* CDMA/CDMA1x registration state, signature 'u' */ + MMModemCdmaRegistrationState modem_cdma_cdma1x_registration_state; + /* CDMA/EV-DO registration state, signature 'u' */ + MMModemCdmaRegistrationState modem_cdma_evdo_registration_state; + /* SID, signature 'u' */ + guint modem_cdma_sid; + /* NID, signature 'u' */ + guint modem_cdma_nid; +}; + +/*****************************************************************************/ + +/** + * mm_simple_status_get_state: + * @self: a #MMSimpleStatus. + * + * Gets the state of the modem. + * + * Returns: a #MMModemState. + */ +MMModemState +mm_simple_status_get_state (MMSimpleStatus *self) +{ + g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), MM_MODEM_STATE_UNKNOWN); + + return self->priv->state; +} + +/*****************************************************************************/ + +/** + * mm_simple_status_get_signal_quality: + * @self: a #MMSimpleStatus. + * @recent: (out) (allow-none): indication of whether the given signal quality is considered recent. + * + * Gets the signal quality. + * + * Returns: the signal quality. + */ +guint32 +mm_simple_status_get_signal_quality (MMSimpleStatus *self, + gboolean *recent) +{ + guint32 signal_quality = 0; + gboolean signal_quality_recent = FALSE; + + g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), 0); + + if (self->priv->signal_quality) { + g_variant_get (self->priv->signal_quality, + "(ub)", + &signal_quality, + &signal_quality_recent); + } + + if (recent) + *recent = signal_quality_recent; + return signal_quality; +} + +/*****************************************************************************/ + +/** + * mm_simple_status_get_current_bands: + * @self: a #MMSimpleStatus. + * @bands: (out): location for an array of #MMModemBand values. Do not free the returned value, it is owned by @self. + * @n_bands: (out): number of elements in @bands. + * + * Gets the currently used frequency bands. + */ +void +mm_simple_status_get_current_bands (MMSimpleStatus *self, + const MMModemBand **bands, + guint *n_bands) +{ + g_return_if_fail (MM_IS_SIMPLE_STATUS (self)); + + if (!self->priv->current_bands_array) + self->priv->current_bands_array = mm_common_bands_variant_to_garray (self->priv->current_bands); + + *n_bands = self->priv->current_bands_array->len; + *bands = (const MMModemBand *)self->priv->current_bands_array->data; +} + +/*****************************************************************************/ + +/** + * mm_simple_status_get_access_technologies: + * @self: a #MMSimpleStatus. + * + * Gets the currently used access technologies. + * + * Returns: a bitmask of #MMModemAccessTechnology values. + */ +MMModemAccessTechnology +mm_simple_status_get_access_technologies (MMSimpleStatus *self) +{ + g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN); + + return self->priv->access_technologies; +} + +/*****************************************************************************/ + +/** + * mm_simple_status_get_3gpp_registration_state: + * @self: a #MMSimpleStatus. + * + * Gets the current state of the registration in the 3GPP network. + * + * Returns: a #MMModem3gppRegistrationState. + */ +MMModem3gppRegistrationState +mm_simple_status_get_3gpp_registration_state (MMSimpleStatus *self) +{ + g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), MM_MODEM_3GPP_REGISTRATION_STATE_UNKNOWN); + + return self->priv->modem_3gpp_registration_state; +} + +/*****************************************************************************/ + +/** + * mm_simple_status_get_3gpp_operator_code: + * @self: a #MMSimpleStatus. + * + * Gets the MCC/MNC of the operator of the 3GPP network where the modem is registered. + * + * Returns: the operator code, or %NULL if unknown. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_simple_status_get_3gpp_operator_code (MMSimpleStatus *self) +{ + g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), NULL); + + return self->priv->modem_3gpp_operator_code; +} + +/*****************************************************************************/ + +/** + * mm_simple_status_get_3gpp_operator_name: + * @self: a #MMSimpleStatus. + * + * Gets the name of the operator of the 3GPP network where the modem is registered. + * + * Returns: the operator name, or %NULL if unknown. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_simple_status_get_3gpp_operator_name (MMSimpleStatus *self) +{ + g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), NULL); + + return self->priv->modem_3gpp_operator_name; +} + +/*****************************************************************************/ + +/** + * mm_simple_status_get_cdma_cdma1x_registration_state: + * @self: a #MMSimpleStatus. + * + * Gets the current state of the registration in the CDMA-1x network. + * + * Returns: a #MMModemCdmaRegistrationState. + */ +MMModemCdmaRegistrationState +mm_simple_status_get_cdma_cdma1x_registration_state (MMSimpleStatus *self) +{ + g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN); + + return self->priv->modem_cdma_cdma1x_registration_state; +} + +/*****************************************************************************/ + +/** + * mm_simple_status_get_cdma_evdo_registration_state: + * @self: a #MMSimpleStatus. + * + * Gets the current state of the registration in the EV-DO network. + * + * Returns: a #MMModemCdmaRegistrationState. + */ +MMModemCdmaRegistrationState +mm_simple_status_get_cdma_evdo_registration_state (MMSimpleStatus *self) +{ + g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN); + + return self->priv->modem_cdma_evdo_registration_state; +} + +/*****************************************************************************/ + +/** + * mm_simple_status_get_cdma_sid: + * @self: a #MMSimpleStatus. + * + * Gets the System Identification number of the CDMA network. + * + * Returns: the SID, or %MM_MODEM_CDMA_SID_UNKNOWN if unknown. + */ +guint +mm_simple_status_get_cdma_sid (MMSimpleStatus *self) +{ + g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), MM_MODEM_CDMA_SID_UNKNOWN); + + return self->priv->modem_cdma_sid; +} + +/*****************************************************************************/ + +/** + * mm_simple_status_get_cdma_nid: + * @self: a #MMSimpleStatus. + * + * Gets the Network Identification number of the CDMA network. + * + * Returns: the NID, or %MM_MODEM_CDMA_NID_UNKNOWN if unknown. + */ +guint +mm_simple_status_get_cdma_nid (MMSimpleStatus *self) +{ + g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), MM_MODEM_CDMA_NID_UNKNOWN); + + return self->priv->modem_cdma_nid; +} + +/*****************************************************************************/ + +GVariant * +mm_simple_status_get_dictionary (MMSimpleStatus *self) +{ + GVariantBuilder builder; + + /* Allow NULL */ + if (!self) + return NULL; + + g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), NULL); + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); + g_variant_builder_add (&builder, + "{sv}", + MM_SIMPLE_PROPERTY_STATE, + g_variant_new_uint32 (self->priv->state)); + + /* Next ones, only when registered */ + if (self->priv->state >= MM_MODEM_STATE_REGISTERED) { + g_variant_builder_add (&builder, + "{sv}", + MM_SIMPLE_PROPERTY_SIGNAL_QUALITY, + self->priv->signal_quality); + g_variant_builder_add (&builder, + "{sv}", + MM_SIMPLE_PROPERTY_CURRENT_BANDS, + self->priv->current_bands); + g_variant_builder_add (&builder, + "{sv}", + MM_SIMPLE_PROPERTY_ACCESS_TECHNOLOGIES, + g_variant_new_uint32 (self->priv->access_technologies)); + + g_variant_builder_add (&builder, + "{sv}", + MM_SIMPLE_PROPERTY_3GPP_REGISTRATION_STATE, + g_variant_new_uint32 (self->priv->modem_3gpp_registration_state)); + if (self->priv->modem_3gpp_operator_code) + g_variant_builder_add (&builder, + "{sv}", + MM_SIMPLE_PROPERTY_3GPP_OPERATOR_CODE, + g_variant_new_string (self->priv->modem_3gpp_operator_code)); + if (self->priv->modem_3gpp_operator_name) + g_variant_builder_add (&builder, + "{sv}", + MM_SIMPLE_PROPERTY_3GPP_OPERATOR_NAME, + g_variant_new_string (self->priv->modem_3gpp_operator_name)); + + if (self->priv->modem_cdma_cdma1x_registration_state != MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN) { + g_variant_builder_add (&builder, + "{sv}", + MM_SIMPLE_PROPERTY_CDMA_CDMA1X_REGISTRATION_STATE, + g_variant_new_uint32 (self->priv->modem_cdma_cdma1x_registration_state)); + if (self->priv->modem_cdma_sid != MM_MODEM_CDMA_SID_UNKNOWN) + g_variant_builder_add (&builder, + "{sv}", + MM_SIMPLE_PROPERTY_CDMA_SID, + g_variant_new_uint32 (self->priv->modem_cdma_sid)); + if (self->priv->modem_cdma_nid != MM_MODEM_CDMA_NID_UNKNOWN) + g_variant_builder_add (&builder, + "{sv}", + MM_SIMPLE_PROPERTY_CDMA_NID, + g_variant_new_uint32 (self->priv->modem_cdma_nid)); + } + if (self->priv->modem_cdma_evdo_registration_state != MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN) + g_variant_builder_add (&builder, + "{sv}", + MM_SIMPLE_PROPERTY_CDMA_EVDO_REGISTRATION_STATE, + g_variant_new_uint32 (self->priv->modem_cdma_evdo_registration_state)); + + } + + return g_variant_ref_sink (g_variant_builder_end (&builder)); +} + +/*****************************************************************************/ + +MMSimpleStatus * +mm_simple_status_new_from_dictionary (GVariant *dictionary, + GError **error) +{ + GError *inner_error = NULL; + GVariantIter iter; + gchar *key; + GVariant *value; + MMSimpleStatus *properties; + + properties = mm_simple_status_new (); + if (!dictionary) + return properties; + + if (!g_variant_is_of_type (dictionary, G_VARIANT_TYPE ("a{sv}"))) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Cannot create Simple status from dictionary: " + "invalid variant type received"); + g_object_unref (properties); + return NULL; + } + + g_variant_iter_init (&iter, dictionary); + while (!inner_error && + g_variant_iter_next (&iter, "{sv}", &key, &value)) { + /* Note: we could do a more efficient matching by checking the variant type + * and just g_object_set()-ing they specific 'key' and value, but we do want + * to check which input keys we receive, in order to propagate the error. + */ + if (g_str_equal (key, MM_SIMPLE_PROPERTY_STATE) || + g_str_equal (key, MM_SIMPLE_PROPERTY_ACCESS_TECHNOLOGIES) || + g_str_equal (key, MM_SIMPLE_PROPERTY_3GPP_REGISTRATION_STATE) || + g_str_equal (key, MM_SIMPLE_PROPERTY_CDMA_CDMA1X_REGISTRATION_STATE) || + g_str_equal (key, MM_SIMPLE_PROPERTY_CDMA_EVDO_REGISTRATION_STATE) || + g_str_equal (key, MM_SIMPLE_PROPERTY_CDMA_SID) || + g_str_equal (key, MM_SIMPLE_PROPERTY_CDMA_NID)) { + /* uint properties */ + g_object_set (properties, + key, g_variant_get_uint32 (value), + NULL); + } else if (g_str_equal (key, MM_SIMPLE_PROPERTY_3GPP_OPERATOR_CODE) || + g_str_equal (key, MM_SIMPLE_PROPERTY_3GPP_OPERATOR_NAME)) { + /* string properties */ + g_object_set (properties, + key, g_variant_get_string (value, NULL), + NULL); + } else if (g_str_equal (key, MM_SIMPLE_PROPERTY_CURRENT_BANDS) || + g_str_equal (key, MM_SIMPLE_PROPERTY_SIGNAL_QUALITY)) { + /* remaining complex types, as variant */ + g_object_set (properties, + key, value, + NULL); + } else { + /* Set inner error, will stop the loop */ + inner_error = g_error_new (MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Invalid status dictionary, unexpected key '%s'", + key); + } + + g_free (key); + g_variant_unref (value); + } + + /* If error, destroy the object */ + if (inner_error) { + g_propagate_error (error, inner_error); + g_object_unref (properties); + properties = NULL; + } + + return properties; +} + +/*****************************************************************************/ + +MMSimpleStatus * +mm_simple_status_new (void) +{ + return (MM_SIMPLE_STATUS ( + g_object_new (MM_TYPE_SIMPLE_STATUS, NULL))); +} + +static void +set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + MMSimpleStatus *self = MM_SIMPLE_STATUS (object); + + switch (prop_id) { + case PROP_STATE: + self->priv->state = g_value_get_enum (value); + break; + case PROP_SIGNAL_QUALITY: + if (self->priv->signal_quality) + g_variant_unref (self->priv->signal_quality); + self->priv->signal_quality = g_value_dup_variant (value); + break; + case PROP_CURRENT_BANDS: + if (self->priv->current_bands) + g_variant_unref (self->priv->current_bands); + if (self->priv->current_bands_array) { + g_array_unref (self->priv->current_bands_array); + self->priv->current_bands_array = NULL; + } + self->priv->current_bands = g_value_dup_variant (value); + break; + case PROP_ACCESS_TECHNOLOGIES: + self->priv->access_technologies = g_value_get_flags (value); + break; + case PROP_3GPP_REGISTRATION_STATE: + self->priv->modem_3gpp_registration_state = g_value_get_enum (value); + break; + case PROP_3GPP_OPERATOR_CODE: + g_free (self->priv->modem_3gpp_operator_code); + self->priv->modem_3gpp_operator_code = g_value_dup_string (value); + break; + case PROP_3GPP_OPERATOR_NAME: + g_free (self->priv->modem_3gpp_operator_name); + self->priv->modem_3gpp_operator_name = g_value_dup_string (value); + break; + case PROP_CDMA_CDMA1X_REGISTRATION_STATE: + self->priv->modem_cdma_cdma1x_registration_state = g_value_get_enum (value); + break; + case PROP_CDMA_EVDO_REGISTRATION_STATE: + self->priv->modem_cdma_evdo_registration_state = g_value_get_enum (value); + break; + case PROP_CDMA_SID: + self->priv->modem_cdma_sid = g_value_get_uint (value); + break; + case PROP_CDMA_NID: + self->priv->modem_cdma_nid = 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) +{ + MMSimpleStatus *self = MM_SIMPLE_STATUS (object); + + switch (prop_id) { + case PROP_STATE: + g_value_set_enum (value, self->priv->state); + break; + case PROP_SIGNAL_QUALITY: + g_value_set_variant (value, self->priv->signal_quality); + break; + case PROP_CURRENT_BANDS: + g_value_set_variant (value, self->priv->current_bands); + break; + case PROP_ACCESS_TECHNOLOGIES: + g_value_set_flags (value, self->priv->access_technologies); + break; + case PROP_3GPP_REGISTRATION_STATE: + g_value_set_enum (value, self->priv->modem_3gpp_registration_state); + break; + case PROP_3GPP_OPERATOR_CODE: + g_value_set_string (value, self->priv->modem_3gpp_operator_code); + break; + case PROP_3GPP_OPERATOR_NAME: + g_value_set_string (value, self->priv->modem_3gpp_operator_name); + break; + case PROP_CDMA_CDMA1X_REGISTRATION_STATE: + g_value_set_enum (value, self->priv->modem_cdma_cdma1x_registration_state); + break; + case PROP_CDMA_EVDO_REGISTRATION_STATE: + g_value_set_enum (value, self->priv->modem_cdma_evdo_registration_state); + break; + case PROP_CDMA_SID: + g_value_set_uint (value, self->priv->modem_cdma_sid); + break; + case PROP_CDMA_NID: + g_value_set_uint (value, self->priv->modem_cdma_nid); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +mm_simple_status_init (MMSimpleStatus *self) +{ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), + MM_TYPE_SIMPLE_STATUS, + MMSimpleStatusPrivate); + + /* Some defaults */ + self->priv->state = MM_MODEM_STATE_UNKNOWN; + self->priv->access_technologies = MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN; + self->priv->modem_3gpp_registration_state = MM_MODEM_3GPP_REGISTRATION_STATE_UNKNOWN; + self->priv->current_bands = g_variant_ref_sink (mm_common_build_bands_unknown ()); + self->priv->signal_quality = g_variant_ref_sink (g_variant_new ("(ub)", 0, 0)); + self->priv->modem_cdma_cdma1x_registration_state = MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN; + self->priv->modem_cdma_evdo_registration_state = MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN; + self->priv->modem_cdma_sid = MM_MODEM_CDMA_SID_UNKNOWN; + self->priv->modem_cdma_nid = MM_MODEM_CDMA_NID_UNKNOWN; +} + +static void +finalize (GObject *object) +{ + MMSimpleStatus *self = MM_SIMPLE_STATUS (object); + + g_variant_unref (self->priv->signal_quality); + g_variant_unref (self->priv->current_bands); + if (self->priv->current_bands_array) + g_array_unref (self->priv->current_bands_array); + g_free (self->priv->modem_3gpp_operator_code); + g_free (self->priv->modem_3gpp_operator_name); + + G_OBJECT_CLASS (mm_simple_status_parent_class)->finalize (object); +} + +static void +mm_simple_status_class_init (MMSimpleStatusClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (MMSimpleStatusPrivate)); + + /* Virtual methods */ + object_class->set_property = set_property; + object_class->get_property = get_property; + object_class->finalize = finalize; + + properties[PROP_STATE] = + g_param_spec_enum (MM_SIMPLE_PROPERTY_STATE, + "State", + "State of the modem", + MM_TYPE_MODEM_STATE, + MM_MODEM_STATE_UNKNOWN, + G_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_STATE, properties[PROP_STATE]); + + properties[PROP_SIGNAL_QUALITY] = + g_param_spec_variant (MM_SIMPLE_PROPERTY_SIGNAL_QUALITY, + "Signal quality", + "Signal quality reported by the modem", + G_VARIANT_TYPE ("(ub)"), + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_SIGNAL_QUALITY, properties[PROP_SIGNAL_QUALITY]); + + properties[PROP_CURRENT_BANDS] = + g_param_spec_variant (MM_SIMPLE_PROPERTY_CURRENT_BANDS, + "Current Bands", + "Frequency bands used by the modem", + G_VARIANT_TYPE ("au"), + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_CURRENT_BANDS, properties[PROP_CURRENT_BANDS]); + + properties[PROP_ACCESS_TECHNOLOGIES] = + g_param_spec_flags (MM_SIMPLE_PROPERTY_ACCESS_TECHNOLOGIES, + "Access Technologies", + "Access technologies used by the modem", + MM_TYPE_MODEM_ACCESS_TECHNOLOGY, + MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN, + G_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_ACCESS_TECHNOLOGIES, properties[PROP_ACCESS_TECHNOLOGIES]); + + properties[PROP_3GPP_REGISTRATION_STATE] = + g_param_spec_enum (MM_SIMPLE_PROPERTY_3GPP_REGISTRATION_STATE, + "3GPP registration state", + "Registration state in the 3GPP network", + MM_TYPE_MODEM_3GPP_REGISTRATION_STATE, + MM_MODEM_3GPP_REGISTRATION_STATE_UNKNOWN, + G_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_3GPP_REGISTRATION_STATE, properties[PROP_3GPP_REGISTRATION_STATE]); + + properties[PROP_3GPP_OPERATOR_CODE] = + g_param_spec_string (MM_SIMPLE_PROPERTY_3GPP_OPERATOR_CODE, + "3GPP operator code", + "Code of the current operator in the 3GPP network", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_3GPP_OPERATOR_CODE, properties[PROP_3GPP_OPERATOR_CODE]); + + properties[PROP_3GPP_OPERATOR_NAME] = + g_param_spec_string (MM_SIMPLE_PROPERTY_3GPP_OPERATOR_NAME, + "3GPP operator name", + "Name of the current operator in the 3GPP network", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_3GPP_OPERATOR_NAME, properties[PROP_3GPP_OPERATOR_NAME]); + + properties[PROP_CDMA_CDMA1X_REGISTRATION_STATE] = + g_param_spec_enum (MM_SIMPLE_PROPERTY_CDMA_CDMA1X_REGISTRATION_STATE, + "CDMA1x registration state", + "Registration state in the CDMA1x network", + MM_TYPE_MODEM_CDMA_REGISTRATION_STATE, + MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN, + G_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_CDMA_CDMA1X_REGISTRATION_STATE, properties[PROP_CDMA_CDMA1X_REGISTRATION_STATE]); + + properties[PROP_CDMA_EVDO_REGISTRATION_STATE] = + g_param_spec_enum (MM_SIMPLE_PROPERTY_CDMA_EVDO_REGISTRATION_STATE, + "EV-DO registration state", + "Registration state in the EV-DO network", + MM_TYPE_MODEM_CDMA_REGISTRATION_STATE, + MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN, + G_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_CDMA_EVDO_REGISTRATION_STATE, properties[PROP_CDMA_EVDO_REGISTRATION_STATE]); + + properties[PROP_CDMA_SID] = + g_param_spec_uint (MM_SIMPLE_PROPERTY_CDMA_SID, + "CDMA1x SID", + "System Identifier of the serving CDMA1x network", + 0, + MM_MODEM_CDMA_SID_UNKNOWN, + MM_MODEM_CDMA_SID_UNKNOWN, + G_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_CDMA_SID, properties[PROP_CDMA_SID]); + + properties[PROP_CDMA_NID] = + g_param_spec_uint (MM_SIMPLE_PROPERTY_CDMA_NID, + "CDMA1x NID", + "Network Identifier of the serving CDMA1x network", + 0, + MM_MODEM_CDMA_NID_UNKNOWN, + MM_MODEM_CDMA_NID_UNKNOWN, + G_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_CDMA_NID, properties[PROP_CDMA_NID]); +} diff --git a/libmm-glib/mm-simple-status.h b/libmm-glib/mm-simple-status.h new file mode 100644 index 0000000..8292fdb --- /dev/null +++ b/libmm-glib/mm-simple-status.h @@ -0,0 +1,107 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2011 Google, Inc. + */ + +#ifndef MM_SIMPLE_STATUS_H +#define MM_SIMPLE_STATUS_H + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> +#include <glib-object.h> + +G_BEGIN_DECLS + +#define MM_TYPE_SIMPLE_STATUS (mm_simple_status_get_type ()) +#define MM_SIMPLE_STATUS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SIMPLE_STATUS, MMSimpleStatus)) +#define MM_SIMPLE_STATUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_SIMPLE_STATUS, MMSimpleStatusClass)) +#define MM_IS_SIMPLE_STATUS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_SIMPLE_STATUS)) +#define MM_IS_SIMPLE_STATUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_SIMPLE_STATUS)) +#define MM_SIMPLE_STATUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_SIMPLE_STATUS, MMSimpleStatusClass)) + +typedef struct _MMSimpleStatus MMSimpleStatus; +typedef struct _MMSimpleStatusClass MMSimpleStatusClass; +typedef struct _MMSimpleStatusPrivate MMSimpleStatusPrivate; + +/** + * MMSimpleStatus: + * + * The #MMSimpleStatus structure contains private data and should + * only be accessed using the provided API. + */ +struct _MMSimpleStatus { + /*< private >*/ + GObject parent; + MMSimpleStatusPrivate *priv; +}; + +struct _MMSimpleStatusClass { + /*< private >*/ + GObjectClass parent; +}; + +GType mm_simple_status_get_type (void); + + +MMModemState mm_simple_status_get_state (MMSimpleStatus *self); +guint32 mm_simple_status_get_signal_quality (MMSimpleStatus *self, + gboolean *recent); +void mm_simple_status_get_current_bands (MMSimpleStatus *self, + const MMModemBand **bands, + guint *n_bands); +MMModemAccessTechnology mm_simple_status_get_access_technologies (MMSimpleStatus *self); + +MMModem3gppRegistrationState mm_simple_status_get_3gpp_registration_state (MMSimpleStatus *self); +const gchar *mm_simple_status_get_3gpp_operator_code (MMSimpleStatus *self); +const gchar *mm_simple_status_get_3gpp_operator_name (MMSimpleStatus *self); + +MMModemCdmaRegistrationState mm_simple_status_get_cdma_cdma1x_registration_state (MMSimpleStatus *self); +MMModemCdmaRegistrationState mm_simple_status_get_cdma_evdo_registration_state (MMSimpleStatus *self); +guint mm_simple_status_get_cdma_sid (MMSimpleStatus *self); +guint mm_simple_status_get_cdma_nid (MMSimpleStatus *self); + +/*****************************************************************************/ +/* ModemManager/libmm-glib/mmcli specific methods */ + +#if defined (_LIBMM_INSIDE_MM) || \ + defined (_LIBMM_INSIDE_MMCLI) || \ + defined (LIBMM_GLIB_COMPILATION) + +#define MM_SIMPLE_PROPERTY_STATE "state" +#define MM_SIMPLE_PROPERTY_SIGNAL_QUALITY "signal-quality" +#define MM_SIMPLE_PROPERTY_CURRENT_BANDS "current-bands" +#define MM_SIMPLE_PROPERTY_ACCESS_TECHNOLOGIES "access-technologies" + +#define MM_SIMPLE_PROPERTY_3GPP_REGISTRATION_STATE "m3gpp-registration-state" +#define MM_SIMPLE_PROPERTY_3GPP_OPERATOR_CODE "m3gpp-operator-code" +#define MM_SIMPLE_PROPERTY_3GPP_OPERATOR_NAME "m3gpp-operator-name" + +#define MM_SIMPLE_PROPERTY_CDMA_CDMA1X_REGISTRATION_STATE "cdma-cdma1x-registration-state" +#define MM_SIMPLE_PROPERTY_CDMA_EVDO_REGISTRATION_STATE "cdma-evdo-registration-state" +#define MM_SIMPLE_PROPERTY_CDMA_SID "cdma-sid" +#define MM_SIMPLE_PROPERTY_CDMA_NID "cdma-nid" + +MMSimpleStatus *mm_simple_status_new (void); +MMSimpleStatus *mm_simple_status_new_from_dictionary (GVariant *dictionary, + GError **error); + +GVariant *mm_simple_status_get_dictionary (MMSimpleStatus *self); + +#endif + +G_END_DECLS + +#endif /* MM_SIMPLE_STATUS_H */ diff --git a/libmm-glib/mm-sms-properties.c b/libmm-glib/mm-sms-properties.c new file mode 100644 index 0000000..d6a7416 --- /dev/null +++ b/libmm-glib/mm-sms-properties.c @@ -0,0 +1,775 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2011 Aleksander Morgado <aleksander@gnu.org> + */ + +#include <string.h> +#include <errno.h> +#include <stdlib.h> + +#include "mm-errors-types.h" +#include "mm-enums-types.h" +#include "mm-common-helpers.h" +#include "mm-sms-properties.h" + +/** + * SECTION: mm-sms-properties + * @title: MMSmsProperties + * @short_description: Helper object to handle SMS properties. + * + * The #MMSmsProperties is an object handling the properties to be set + * in newly created SMS objects. + * + * This object is created by the user and passed to ModemManager with either + * mm_modem_messaging_create() or mm_modem_messaging_create_sync(). + */ + +G_DEFINE_TYPE (MMSmsProperties, mm_sms_properties, G_TYPE_OBJECT); + +#define PROPERTY_TEXT "text" +#define PROPERTY_DATA "data" +#define PROPERTY_NUMBER "number" +#define PROPERTY_SMSC "smsc" +#define PROPERTY_VALIDITY "validity" +#define PROPERTY_CLASS "class" +#define PROPERTY_DELIVERY_REPORT_REQUEST "delivery-report-request" + +struct _MMSmsPropertiesPrivate { + gchar *text; + GByteArray *data; + gchar *number; + gchar *smsc; + MMSmsValidityType validity_type; + guint validity_relative; + gint class; + gboolean delivery_report_request_set; + gboolean delivery_report_request; +}; + +/*****************************************************************************/ + +/** + * mm_sms_properties_set_text: + * @self: A #MMSmsProperties. + * @text: The text to set, in UTF-8. + * + * Sets the message text. + */ +void +mm_sms_properties_set_text (MMSmsProperties *self, + const gchar *text) +{ + g_return_if_fail (MM_IS_SMS_PROPERTIES (self)); + + g_free (self->priv->text); + self->priv->text = g_strdup (text); +} + +/** + * mm_sms_properties_get_text: + * @self: A #MMSmsProperties. + * + * Gets the message text, in UTF-8. + * + * Returns: (transfer none): The message text, or %NULL if it doesn't contain any (e.g. contains data instead). Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_sms_properties_get_text (MMSmsProperties *self) +{ + g_return_val_if_fail (MM_IS_SMS_PROPERTIES (self), NULL); + + return self->priv->text; +} + +/*****************************************************************************/ + +/** + * mm_sms_properties_set_data: + * @self: A #MMSmsProperties. + * @data: The data to set. + * @data_length: Length of @data. + * + * Sets the message data. + */ +void +mm_sms_properties_set_data (MMSmsProperties *self, + const guint8 *data, + gsize data_length) +{ + g_return_if_fail (MM_IS_SMS_PROPERTIES (self)); + + if (self->priv->data) + g_byte_array_unref (self->priv->data); + + if (data && data_length) + self->priv->data = g_byte_array_append (g_byte_array_sized_new (data_length), + data, + data_length); + else + self->priv->data = NULL; +} + +/** + * mm_sms_properties_set_data_bytearray: + * @self: A #MMSmsProperties. + * @data: A #GByteArray with the data to set. This method takes a new reference of @data. + * + * Sets the message data. + */ +void +mm_sms_properties_set_data_bytearray (MMSmsProperties *self, + GByteArray *data) +{ + g_return_if_fail (MM_IS_SMS_PROPERTIES (self)); + + if (self->priv->data) + g_byte_array_unref (self->priv->data); + + self->priv->data = (data ? g_byte_array_ref (data) : NULL); +} + +/** + * mm_sms_properties_get_data: + * @self: A #MMSmsProperties. + * @data_len: (out): Size of the output data, if any given. + * + * Gets the message data. + * + * Returns: (transfer none): The message data, or %NULL if it doesn't contain any (e.g. contains text instead). + */ +const guint8 * +mm_sms_properties_get_data (MMSmsProperties *self, + gsize *data_len) +{ + g_return_val_if_fail (MM_IS_SMS_PROPERTIES (self), NULL); + + if (self->priv->data && data_len) + *data_len = self->priv->data->len; + + return self->priv->data->data; +} + +/** + * mm_sms_properties_peek_data_bytearray: + * @self: A #MMSmsProperties. + * + * Gets the message data. + * + * Returns: (transfer none): A #GByteArray with the message data, or %NULL if it doesn't contain any (e.g. contains text instead). Do not free the returned value, it is owned by @self. + */ +GByteArray * +mm_sms_properties_peek_data_bytearray (MMSmsProperties *self) +{ + g_return_val_if_fail (MM_IS_SMS_PROPERTIES (self), NULL); + + return self->priv->data; +} + +/** + * mm_sms_properties_get_data_bytearray: + * @self: A #MMSmsProperties. + * + * Gets the message data. + * + * Returns: (transfer none): A #GByteArray with the message data, or %NULL if it doesn't contain any (e.g. contains text instead). The returned value should be freed with g_byte_array_unref(). + */ +GByteArray * +mm_sms_properties_get_data_bytearray (MMSmsProperties *self) +{ + g_return_val_if_fail (MM_IS_SMS_PROPERTIES (self), NULL); + + return (self->priv->data ? g_byte_array_ref (self->priv->data) : NULL); +} + +/*****************************************************************************/ + +/** + * mm_sms_properties_set_number: + * @self: A #MMSmsProperties. + * @number: The number. + * + * Sets the number to which the message is addressed. + */ +void +mm_sms_properties_set_number (MMSmsProperties *self, + const gchar *number) +{ + g_return_if_fail (MM_IS_SMS_PROPERTIES (self)); + + g_free (self->priv->number); + self->priv->number = g_strdup (number); +} + +/** + * mm_sms_properties_get_number: + * @self: A #MMSmsProperties. + * + * Gets the number to which the message is addressed. + * + * Returns: (transfer none): The number, or %NULL if it couldn't be retrieved. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_sms_properties_get_number (MMSmsProperties *self) +{ + g_return_val_if_fail (MM_IS_SMS_PROPERTIES (self), NULL); + + return self->priv->number; +} + +/*****************************************************************************/ + +/** + * mm_sms_properties_set_smsc: + * @self: A #MMSmsProperties. + * @smsc: The SMSC number. + * + * Sets the SMS service center number. + */ +void +mm_sms_properties_set_smsc (MMSmsProperties *self, + const gchar *smsc) +{ + g_return_if_fail (MM_IS_SMS_PROPERTIES (self)); + + g_free (self->priv->smsc); + self->priv->smsc = g_strdup (smsc); +} + +/** + * mm_sms_properties_get_smsc: + * @self: A #MMSmsProperties. + * + * Gets the SMS service center number. + * + * Returns: (transfer none): The number of the SMSC, or %NULL if it couldn't be retrieved. Do not free the returned value, it is owned by @self. + */ +const gchar * +mm_sms_properties_get_smsc (MMSmsProperties *self) +{ + g_return_val_if_fail (MM_IS_SMS_PROPERTIES (self), NULL); + + return self->priv->smsc; +} + +/*****************************************************************************/ + +/** + * mm_sms_properties_set_validity_relative: + * @self: A #MMSmsProperties. + * @validity: The validity of %MM_SMS_VALIDITY_TYPE_RELATIVE type. + * + * Sets the relative validity time of the SMS. + */ +void +mm_sms_properties_set_validity_relative (MMSmsProperties *self, + guint validity) +{ + g_return_if_fail (MM_IS_SMS_PROPERTIES (self)); + + self->priv->validity_type = MM_SMS_VALIDITY_TYPE_RELATIVE; + self->priv->validity_relative = validity; +} + +/** + * mm_sms_properties_get_validity_type: + * @self: A #MMSmsProperties. + * + * Gets the relative validity type the SMS. + * + * Returns: a #MMSmsValidityType. + */ +MMSmsValidityType +mm_sms_properties_get_validity_type (MMSmsProperties *self) +{ + g_return_val_if_fail (MM_IS_SMS_PROPERTIES (self), 0); + + return self->priv->validity_type; +} + +/** + * mm_sms_properties_get_validity_relative: + * @self: A #MMSmsProperties. + * + * Gets the relative validity time of the SMS. + * + * Returns: the validity time or 0 if unknown. + */ +guint +mm_sms_properties_get_validity_relative (MMSmsProperties *self) +{ + g_return_val_if_fail (MM_IS_SMS_PROPERTIES (self), 0); + g_return_val_if_fail (self->priv->validity_type == MM_SMS_VALIDITY_TYPE_RELATIVE, 0); + + return self->priv->validity_relative; +} + +/*****************************************************************************/ + +/** + * mm_sms_properties_set_class: + * @self: A #MMSmsProperties. + * @class: The message class (0..3), or -1 for invalid/unset class. + * + * Sets the 3GPP message class of the SMS. + */ +void +mm_sms_properties_set_class (MMSmsProperties *self, + gint class) +{ + g_return_if_fail (MM_IS_SMS_PROPERTIES (self)); + g_return_if_fail (class >= -1 && class <= 3); + + self->priv->class = class; +} + +/** + * mm_sms_properties_get_class: + * @self: A #MMSmsProperties. + * + * Gets the 3GPP message class of the SMS. + * + * Returns: the message class, or -1 for invalid/unset class. + */ +gint +mm_sms_properties_get_class (MMSmsProperties *self) +{ + g_return_val_if_fail (MM_IS_SMS_PROPERTIES (self), -1); + + return self->priv->class; +} + +/*****************************************************************************/ + +/** + * mm_sms_properties_set_delivery_report_request: + * @self: A #MMSmsProperties. + * @request: %TRUE if delivery report is requested, %FALSE otherwise. + * + * Sets whether delivery report is requested for the SMS. + */ +void +mm_sms_properties_set_delivery_report_request (MMSmsProperties *self, + gboolean request) +{ + g_return_if_fail (MM_IS_SMS_PROPERTIES (self)); + + self->priv->delivery_report_request_set = TRUE; + self->priv->delivery_report_request = request; +} + +/** + * mm_sms_properties_get_delivery_report_request: + * @self: A #MMSmsProperties. + * + * Checks whether delivery report is requested for the SMS. + * + * Returns: %TRUE if delivery report is requested, %FALSE otherwise. + */ +gboolean +mm_sms_properties_get_delivery_report_request (MMSmsProperties *self) +{ + g_return_val_if_fail (MM_IS_SMS_PROPERTIES (self), FALSE); + + return self->priv->delivery_report_request; +} + +/*****************************************************************************/ + +GVariant * +mm_sms_properties_get_dictionary (MMSmsProperties *self) +{ + GVariantBuilder builder; + + /* We do allow NULL */ + if (!self) + return NULL; + + g_return_val_if_fail (MM_IS_SMS_PROPERTIES (self), NULL); + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); + + if (self->priv->text) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_TEXT, + g_variant_new_string (self->priv->text)); + + if (self->priv->data) + g_variant_builder_add ( + &builder, + "{sv}", + PROPERTY_DATA, + g_variant_new_from_data (G_VARIANT_TYPE ("ay"), + self->priv->data->data, + self->priv->data->len * sizeof (guint8), + TRUE, + NULL, + NULL)); + + if (self->priv->number) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_NUMBER, + g_variant_new_string (self->priv->number)); + + if (self->priv->smsc) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_SMSC, + g_variant_new_string (self->priv->smsc)); + + if (self->priv->validity_type == MM_SMS_VALIDITY_TYPE_RELATIVE) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_VALIDITY, + g_variant_new ("(uv)", MM_SMS_VALIDITY_TYPE_RELATIVE, g_variant_new_uint32 (self->priv->validity_relative))); + + if (self->priv->class >= 0) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_CLASS, + g_variant_new_int32 (self->priv->class)); + + if (self->priv->delivery_report_request_set) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_DELIVERY_REPORT_REQUEST, + g_variant_new_boolean (self->priv->delivery_report_request)); + + return g_variant_ref_sink (g_variant_builder_end (&builder)); +} + +/*****************************************************************************/ + +static guint +parse_uint (const gchar *str, + GError **error) +{ + guint num; + + errno = 0; + num = strtoul (str, NULL, 10); + if ((num < G_MAXUINT32) && (errno == 0)) + return num; + + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Invalid properties string, cannot parse '%s' as uint", + str); + return 0; +} + +static gboolean +parse_boolean (const gchar *str, + GError **error) +{ + if (g_ascii_strcasecmp (str, "yes") == 0 || + g_ascii_strcasecmp (str, "true") == 0 || + g_str_equal (str, "1")) + return TRUE; + + if (g_ascii_strcasecmp (str, "no") == 0 || + g_ascii_strcasecmp (str, "false") == 0 || + g_str_equal (str, "0")) + return FALSE; + + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Invalid properties string, cannot parse '%s' as boolean", + str); + return FALSE; +} + +static gboolean +consume_string (MMSmsProperties *self, + const gchar *key, + const gchar *value, + GError **error) +{ + if (g_str_equal (key, PROPERTY_TEXT)) + mm_sms_properties_set_text (self, value); + else if (g_str_equal (key, PROPERTY_NUMBER)) + mm_sms_properties_set_number (self, value); + else if (g_str_equal (key, PROPERTY_SMSC)) + mm_sms_properties_set_smsc (self, value); + else if (g_str_equal (key, PROPERTY_VALIDITY)) { + GError *inner_error = NULL; + guint n; + + n = parse_uint (value, &inner_error); + if (inner_error) { + g_propagate_error (error, inner_error); + return FALSE; + } + + mm_sms_properties_set_validity_relative (self, n); + } else if (g_str_equal (key, PROPERTY_CLASS)) { + gint n = 0; + + if (!mm_get_int_from_str (value, &n)) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Invalid properties string, cannot parse '%s' as int", + value); + return FALSE; + } + + mm_sms_properties_set_class (self, n); + } else if (g_str_equal (key, PROPERTY_DELIVERY_REPORT_REQUEST)) { + GError *inner_error = NULL; + gboolean request; + + request = parse_boolean (value, &inner_error); + if (inner_error) { + g_propagate_error (error, inner_error); + return FALSE; + } + + mm_sms_properties_set_delivery_report_request (self, request); + } else if (g_str_equal (key, PROPERTY_DATA)) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Invalid properties string, key '%s' cannot be given in a string", + key); + return FALSE; + } else { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Invalid properties string, unexpected key '%s'", + key); + return FALSE; + } + + return TRUE; +} + +typedef struct { + MMSmsProperties *properties; + GError *error; +} ParseKeyValueContext; + +static gboolean +key_value_foreach (const gchar *key, + const gchar *value, + ParseKeyValueContext *ctx) +{ + return consume_string (ctx->properties, + key, + value, + &ctx->error); +} + +MMSmsProperties * +mm_sms_properties_new_from_string (const gchar *str, + GError **error) +{ + ParseKeyValueContext ctx; + + ctx.properties = mm_sms_properties_new (); + ctx.error = NULL; + + mm_common_parse_key_value_string (str, + &ctx.error, + (MMParseKeyValueForeachFn)key_value_foreach, + &ctx); + + /* If error, destroy the object */ + if (ctx.error) { + g_propagate_error (error, ctx.error); + g_object_unref (ctx.properties); + ctx.properties = NULL; + } + + return ctx.properties; +} + +/*****************************************************************************/ + +static gboolean +consume_variant (MMSmsProperties *properties, + const gchar *key, + GVariant *value, + GError **error) +{ + if (g_str_equal (key, PROPERTY_TEXT)) + mm_sms_properties_set_text ( + properties, + g_variant_get_string (value, NULL)); + else if (g_str_equal (key, PROPERTY_DATA)) { + const guint8 *data; + gsize data_len = 0; + + data = g_variant_get_fixed_array (value, &data_len, sizeof (guint8)); + mm_sms_properties_set_data ( + properties, + data, + data_len); + } else if (g_str_equal (key, PROPERTY_NUMBER)) + mm_sms_properties_set_number ( + properties, + g_variant_get_string (value, NULL)); + else if (g_str_equal (key, PROPERTY_SMSC)) + mm_sms_properties_set_smsc ( + properties, + g_variant_get_string (value, NULL)); + else if (g_str_equal (key, PROPERTY_VALIDITY)) { + guint type; + GVariant *val; + + g_variant_get (value, "(uv)", &type, &val); + if (type == MM_SMS_VALIDITY_TYPE_RELATIVE) { + mm_sms_properties_set_validity_relative ( + properties, + g_variant_get_uint32 (val)); + } else if (type != MM_SMS_VALIDITY_TYPE_UNKNOWN) + g_warning ("SMS validity type '%s' not supported yet", + mm_sms_validity_type_get_string (type)); + g_variant_unref (val); + } else if (g_str_equal (key, PROPERTY_CLASS)) + mm_sms_properties_set_class ( + properties, + g_variant_get_int32 (value)); + else if (g_str_equal (key, PROPERTY_DELIVERY_REPORT_REQUEST)) + mm_sms_properties_set_delivery_report_request ( + properties, + g_variant_get_boolean (value)); + else { + /* Set error */ + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Invalid properties dictionary, unexpected key '%s'", + key); + return FALSE; + } + + return TRUE; +} + +MMSmsProperties * +mm_sms_properties_new_from_dictionary (GVariant *dictionary, + GError **error) +{ + GError *inner_error = NULL; + GVariantIter iter; + gchar *key; + GVariant *value; + MMSmsProperties *properties; + + properties = mm_sms_properties_new (); + if (!dictionary) + return properties; + + if (!g_variant_is_of_type (dictionary, G_VARIANT_TYPE ("a{sv}"))) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Cannot create SMS properties from dictionary: " + "invalid variant type received"); + g_object_unref (properties); + return NULL; + } + + g_variant_iter_init (&iter, dictionary); + while (!inner_error && + g_variant_iter_next (&iter, "{sv}", &key, &value)) { + consume_variant (properties, + key, + value, + &inner_error); + g_free (key); + g_variant_unref (value); + } + + /* If error, destroy the object */ + if (inner_error) { + g_propagate_error (error, inner_error); + g_object_unref (properties); + properties = NULL; + } + + return properties; +} + +/*****************************************************************************/ + +MMSmsProperties * +mm_sms_properties_dup (MMSmsProperties *orig) +{ + GVariant *dict; + MMSmsProperties *copy; + GError *error = NULL; + + g_return_val_if_fail (MM_IS_SMS_PROPERTIES (orig), NULL); + + dict = mm_sms_properties_get_dictionary (orig); + copy = mm_sms_properties_new_from_dictionary (dict, &error); + g_assert_no_error (error); + g_variant_unref (dict); + + return copy; +} + +/*****************************************************************************/ + +/** + * mm_sms_properties_new: + * + * Creates a new empty #MMSmsProperties. + * + * Returns: (transfer full): a #MMSmsProperties. The returned value should be freed with g_object_unref(). + */ +MMSmsProperties * +mm_sms_properties_new (void) +{ + return (MM_SMS_PROPERTIES (g_object_new (MM_TYPE_SMS_PROPERTIES, NULL))); +} + +static void +mm_sms_properties_init (MMSmsProperties *self) +{ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), + MM_TYPE_SMS_PROPERTIES, + MMSmsPropertiesPrivate); + self->priv->validity_type = MM_SMS_VALIDITY_TYPE_UNKNOWN; + self->priv->class = -1; +} + +static void +finalize (GObject *object) +{ + MMSmsProperties *self = MM_SMS_PROPERTIES (object); + + g_free (self->priv->text); + g_free (self->priv->number); + g_free (self->priv->smsc); + if (self->priv->data) + g_byte_array_unref (self->priv->data); + + G_OBJECT_CLASS (mm_sms_properties_parent_class)->finalize (object); +} + +static void +mm_sms_properties_class_init (MMSmsPropertiesClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (MMSmsPropertiesPrivate)); + + object_class->finalize = finalize; +} diff --git a/libmm-glib/mm-sms-properties.h b/libmm-glib/mm-sms-properties.h new file mode 100644 index 0000000..b0c290a --- /dev/null +++ b/libmm-glib/mm-sms-properties.h @@ -0,0 +1,110 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2012 Google, Inc. + */ + +#ifndef MM_SMS_PROPERTIES_H +#define MM_SMS_PROPERTIES_H + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> +#include <glib-object.h> + +G_BEGIN_DECLS + +#define MM_TYPE_SMS_PROPERTIES (mm_sms_properties_get_type ()) +#define MM_SMS_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SMS_PROPERTIES, MMSmsProperties)) +#define MM_SMS_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_SMS_PROPERTIES, MMSmsPropertiesClass)) +#define MM_IS_SMS_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_SMS_PROPERTIES)) +#define MM_IS_SMS_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_SMS_PROPERTIES)) +#define MM_SMS_PROPERTIES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_SMS_PROPERTIES, MMSmsPropertiesClass)) + +typedef struct _MMSmsProperties MMSmsProperties; +typedef struct _MMSmsPropertiesClass MMSmsPropertiesClass; +typedef struct _MMSmsPropertiesPrivate MMSmsPropertiesPrivate; + +/** + * MMSmsProperties: + * + * The #MMSmsProperties structure contains private data and should only be + * accessed using the provided API. + */ +struct _MMSmsProperties { + /*< private >*/ + GObject parent; + MMSmsPropertiesPrivate *priv; +}; + +struct _MMSmsPropertiesClass { + /*< private >*/ + GObjectClass parent; +}; + +GType mm_sms_properties_get_type (void); + +MMSmsProperties *mm_sms_properties_new (void); + +void mm_sms_properties_set_text (MMSmsProperties *self, + const gchar *text); +void mm_sms_properties_set_data (MMSmsProperties *self, + const guint8 *data, + gsize data_length); +void mm_sms_properties_set_data_bytearray (MMSmsProperties *self, + GByteArray *data); +void mm_sms_properties_set_number (MMSmsProperties *self, + const gchar *number); +void mm_sms_properties_set_smsc (MMSmsProperties *self, + const gchar *smsc); +void mm_sms_properties_set_validity_relative (MMSmsProperties *self, + guint validity); +void mm_sms_properties_set_class (MMSmsProperties *self, + gint class); +void mm_sms_properties_set_delivery_report_request (MMSmsProperties *self, + gboolean request); + +const gchar *mm_sms_properties_get_text (MMSmsProperties *self); +const guint8 *mm_sms_properties_get_data (MMSmsProperties *self, + gsize *data_len); +GByteArray *mm_sms_properties_peek_data_bytearray (MMSmsProperties *self); +GByteArray *mm_sms_properties_get_data_bytearray (MMSmsProperties *self); +const gchar *mm_sms_properties_get_number (MMSmsProperties *self); +const gchar *mm_sms_properties_get_smsc (MMSmsProperties *self); +MMSmsValidityType mm_sms_properties_get_validity_type (MMSmsProperties *self); +guint mm_sms_properties_get_validity_relative (MMSmsProperties *self); +gint mm_sms_properties_get_class (MMSmsProperties *self); +gboolean mm_sms_properties_get_delivery_report_request (MMSmsProperties *self); + +/*****************************************************************************/ +/* ModemManager/libmm-glib/mmcli specific methods */ + +#if defined (_LIBMM_INSIDE_MM) || \ + defined (_LIBMM_INSIDE_MMCLI) || \ + defined (LIBMM_GLIB_COMPILATION) + +MMSmsProperties *mm_sms_properties_new_from_string (const gchar *str, + GError **error); +MMSmsProperties *mm_sms_properties_new_from_dictionary (GVariant *dictionary, + GError **error); + +MMSmsProperties *mm_sms_properties_dup (MMSmsProperties *orig); + +GVariant *mm_sms_properties_get_dictionary (MMSmsProperties *self); + +#endif + +G_END_DECLS + +#endif /* MM_SMS_PROPERTIES_H */ diff --git a/libmm-glib/mm-sms.c b/libmm-glib/mm-sms.c new file mode 100644 index 0000000..8229021 --- /dev/null +++ b/libmm-glib/mm-sms.c @@ -0,0 +1,745 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2012 Google, Inc. + */ + +#include "string.h" + +#include "mm-helpers.h" +#include "mm-sms.h" +#include "mm-modem.h" + +/** + * SECTION: mm-sms + * @title: MMSms + * @short_description: The SMS interface + * + * The #MMSms is an object providing access to the methods, signals and + * properties of the SMS interface. + * + * When the SMS is exposed and available in the bus, it is ensured that at + * least this interface is also available. + */ + +G_DEFINE_TYPE (MMSms, mm_sms, MM_GDBUS_TYPE_SMS_PROXY) + +/*****************************************************************************/ + +/** + * mm_sms_get_path: + * @self: A #MMSms. + * + * Gets the DBus path of the #MMSms object. + * + * Returns: (transfer none): The DBus path of the #MMSms object. + */ +const gchar * +mm_sms_get_path (MMSms *self) +{ + g_return_val_if_fail (MM_IS_SMS (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + g_dbus_proxy_get_object_path (G_DBUS_PROXY (self))); +} + +/** + * mm_sms_dup_path: + * @self: A #MMSms. + * + * Gets a copy of the DBus path of the #MMSms object. + * + * Returns: (transfer full): The DBus path of the #MMSms object. The returned value should be freed with g_free(). + */ +gchar * +mm_sms_dup_path (MMSms *self) +{ + gchar *value; + + g_return_val_if_fail (MM_IS_SMS (self), NULL); + + g_object_get (G_OBJECT (self), + "g-object-path", &value, + NULL); + + RETURN_NON_EMPTY_STRING (value); +} + +/*****************************************************************************/ + +/** + * mm_sms_get_text: + * @self: A #MMSms. + * + * Gets the message text, in UTF-8. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_sms_dup_text() if on another + * thread.</warning> + * + * Returns: (transfer none): The message text, or %NULL if it doesn't contain any (e.g. contains data instead). + */ +const gchar * +mm_sms_get_text (MMSms *self) +{ + g_return_val_if_fail (MM_IS_SMS (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_sms_get_text (MM_GDBUS_SMS (self))); +} + +/** + * mm_sms_dup_text: + * @self: A #MMSms. + * + * Gets the message text, in UTF-8. + * + * Returns: (transfer full): The message text, or %NULL if it doesn't contain any (e.g. contains data instead). The returned value should be freed with g_free(). + */ +gchar * +mm_sms_dup_text (MMSms *self) +{ + g_return_val_if_fail (MM_IS_SMS (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_sms_dup_text (MM_GDBUS_SMS (self))); +} + +/*****************************************************************************/ + +/** + * mm_sms_get_data: + * @self: A #MMSms. + * @data_len: (out): Size of the output data, if any given. + * + * Gets the message data. + * + * Returns: (transfer none): The message data, or %NULL if it doesn't contain any (e.g. contains text instead). + */ +const guint8 * +mm_sms_get_data (MMSms *self, + gsize *data_len) +{ + GVariant *data; + + g_return_val_if_fail (MM_IS_SMS (self), NULL); + g_return_val_if_fail (data_len != NULL, NULL); + + data = mm_gdbus_sms_get_data (MM_GDBUS_SMS (self)); + return (data ? + g_variant_get_fixed_array ( + mm_gdbus_sms_get_data (MM_GDBUS_SMS (self)), + data_len, + sizeof (guchar)): + NULL); +} + +/** + * mm_sms_dup_data: + * @self: A #MMSms. + * @data_len: (out) Size of the output data, if any given. + * + * Gets the message data. + * + * Returns: (transfer full): The message data, or %NULL if it doesn't contain any (e.g. contains text instead). The returned value should be freed with g_free(). + */ +guint8 * +mm_sms_dup_data (MMSms *self, + gsize *data_len) +{ + guint8 *out; + GVariant *data_variant; + const guint8 *orig_data; + gsize orig_data_len = 0; + + g_return_val_if_fail (MM_IS_SMS (self), NULL); + + /* Get a ref to ensure the variant is valid as long as we use it */ + data_variant = mm_gdbus_sms_dup_data (MM_GDBUS_SMS (self)); + if (!data_variant) + return NULL; + + orig_data = (g_variant_get_fixed_array ( + mm_gdbus_sms_get_data (MM_GDBUS_SMS (self)), + &orig_data_len, + sizeof (guchar))); + + out = g_new (guint8, orig_data_len); + memcpy (out, orig_data, orig_data_len); + g_variant_unref (data_variant); + + if (data_len) + *data_len = orig_data_len; + return out; +} + +/*****************************************************************************/ + +/** + * mm_sms_get_number: + * @self: A #MMSms. + * + * Gets the number to which the message is addressed. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_sms_dup_number() if on another + * thread.</warning> + * + * Returns: (transfer none): The number, or %NULL if it couldn't be retrieved. + */ +const gchar * +mm_sms_get_number (MMSms *self) +{ + g_return_val_if_fail (MM_IS_SMS (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_sms_get_number (MM_GDBUS_SMS (self))); +} + +/** + * mm_sms_dup_number: + * @self: A #MMSms. + * + * Gets the number to which the message is addressed. + * + * Returns: (transfer full): The number, or %NULL if it couldn't be retrieved. The returned value should be freed with g_free(). + */ +gchar * +mm_sms_dup_number (MMSms *self) +{ + g_return_val_if_fail (MM_IS_SMS (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_sms_dup_number (MM_GDBUS_SMS (self))); +} + +/*****************************************************************************/ + +/** + * mm_sms_get_smsc: + * @self: A #MMSms. + * + * Gets the SMS service center number. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_sms_dup_smsc() if on another + * thread.</warning> + * + * Returns: (transfer none): The number of the SMSC, or %NULL if it couldn't be retrieved. + */ +const gchar * +mm_sms_get_smsc (MMSms *self) +{ + g_return_val_if_fail (MM_IS_SMS (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_sms_get_smsc (MM_GDBUS_SMS (self))); +} + +/** + * mm_sms_dup_smsc: + * @self: A #MMSms. + * + * Gets the SMS service center number. + * + * Returns: (transfer full): The number of the SMSC, or %NULL if it couldn't be retrieved. The returned value should be freed with g_free(). + */ +gchar * +mm_sms_dup_smsc (MMSms *self) +{ + g_return_val_if_fail (MM_IS_SMS (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_sms_dup_smsc (MM_GDBUS_SMS (self))); +} + +/*****************************************************************************/ + +/** + * mm_sms_get_timestamp: + * @self: A #MMSms. + * + * Gets the time when the first PDU of the SMS message arrived the SMSC, in + * <ulink url="http://en.wikipedia.org/wiki/ISO_8601">ISO8601</ulink> + * format. + * + * This field is only applicable if the PDU type is %MM_SMS_PDU_TYPE_DELIVER or + * %MM_SMS_PDU_TYPE_STATUS_REPORT. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_sms_dup_timestamp() if on another + * thread.</warning> + * + * Returns: (transfer none): The timestamp, or %NULL if it couldn't be retrieved. + */ +const gchar * +mm_sms_get_timestamp (MMSms *self) +{ + g_return_val_if_fail (MM_IS_SMS (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_sms_get_timestamp (MM_GDBUS_SMS (self))); +} + +/** + * mm_sms_dup_timestamp: + * @self: A #MMSms. + * + * Gets the time when the first PDU of the SMS message arrived the SMSC, in + * <ulink url="http://en.wikipedia.org/wiki/ISO_8601">ISO8601</ulink> + * format. + * + * This field is only applicable if the PDU type is %MM_SMS_PDU_TYPE_DELIVER or + * %MM_SMS_PDU_TYPE_STATUS_REPORT. + * + * Returns: (transfer full): The timestamp, or %NULL if it couldn't be retrieved. The returned value should be freed with g_free(). + */ +gchar * +mm_sms_dup_timestamp (MMSms *self) +{ + g_return_val_if_fail (MM_IS_SMS (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_sms_dup_timestamp (MM_GDBUS_SMS (self))); +} + +/*****************************************************************************/ + +/** + * mm_sms_get_discharge_timestamp: + * @self: A #MMSms. + * + * Gets the time when the first PDU of the SMS message left the SMSC, in + * <ulink url="http://en.wikipedia.org/wiki/ISO_8601">ISO8601</ulink> + * format. + * + * This field is only applicable if the PDU type is %MM_SMS_PDU_TYPE_STATUS_REPORT. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_sms_dup_discharge_timestamp() if on another + * thread.</warning> + * + * Returns: (transfer none): The timestamp, or %NULL if it couldn't be retrieved. + */ +const gchar * +mm_sms_get_discharge_timestamp (MMSms *self) +{ + g_return_val_if_fail (MM_IS_SMS (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_sms_get_discharge_timestamp (MM_GDBUS_SMS (self))); +} + +/** + * mm_sms_dup_discharge_timestamp: + * @self: A #MMSms. + * + * Gets the time when the first PDU of the SMS message left the SMSC, in + * <ulink url="http://en.wikipedia.org/wiki/ISO_8601">ISO8601</ulink> + * format. + * + * This field is only applicable if the PDU type is %MM_SMS_PDU_TYPE_STATUS_REPORT. + * + * Returns: (transfer full): The timestamp, or %NULL if it couldn't be retrieved. The returned value should be freed with g_free(). + */ +gchar * +mm_sms_dup_discharge_timestamp (MMSms *self) +{ + g_return_val_if_fail (MM_IS_SMS (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_sms_dup_discharge_timestamp (MM_GDBUS_SMS (self))); +} + +/*****************************************************************************/ + +/** + * mm_sms_get_validity_type: + * @self: A #MMSms. + * + * Gets the type of validity information in the SMS. + * + * Returns: the validity type or #MM_SMS_VALIDITY_TYPE_UNKNOWN. + */ +MMSmsValidityType +mm_sms_get_validity_type (MMSms *self) +{ + GVariant *variant; + guint type; + GVariant *value; + + g_return_val_if_fail (MM_IS_SMS (self), MM_SMS_VALIDITY_TYPE_UNKNOWN); + + variant = mm_gdbus_sms_dup_validity (MM_GDBUS_SMS (self)); + if (!variant) + return MM_SMS_VALIDITY_TYPE_UNKNOWN; + + g_variant_get (variant, "(uv)", &type, &value); + g_variant_unref (variant); + g_variant_unref (value); + + return (MMSmsValidityType)type; +} + +/** + * mm_sms_get_validity_relative: + * @self: A #MMSms. + * + * Gets the length of the validity period, in minutes. + * + * Only applicable if the type of validity is #MM_SMS_VALIDITY_TYPE_RELATIVE. + * + * Returns: the length of the validity period, or 0 if unknown. + */ +guint +mm_sms_get_validity_relative (MMSms *self) +{ + GVariant *variant; + guint type; + GVariant *value; + guint value_integer = 0; + + g_return_val_if_fail (MM_IS_SMS (self), MM_SMS_VALIDITY_TYPE_UNKNOWN); + + variant = mm_gdbus_sms_dup_validity (MM_GDBUS_SMS (self)); + if (!variant) + return 0; + + g_variant_get (variant, "(uv)", &type, &value); + + if (type == MM_SMS_VALIDITY_TYPE_RELATIVE) + value_integer = g_variant_get_uint32 (value); + + g_variant_unref (variant); + g_variant_unref (value); + + return value_integer; +} + +/*****************************************************************************/ + +/** + * mm_sms_get_class: + * @self: A #MMSms. + * + * Gets the 3GPP message class of the SMS. + * + * Returns: the message class, or -1 for invalid/unset class. + */ +gint +mm_sms_get_class (MMSms *self) +{ + g_return_val_if_fail (MM_IS_SMS (self), -1); + + return mm_gdbus_sms_get_class (MM_GDBUS_SMS (self)); +} + +/*****************************************************************************/ + +/** + * mm_sms_get_message_reference: + * @self: A #MMSms. + * + * Gets the message reference of the last PDU sent/received within this SMS. + * + * If the PDU type is %MM_SMS_PDU_TYPE_STATUS_REPORT, this field identifies the + * message reference of the PDU associated to the status report. + * + * Returns: The message reference. + */ +guint +mm_sms_get_message_reference (MMSms *self) +{ + g_return_val_if_fail (MM_IS_SMS (self), 0); + + return mm_gdbus_sms_get_message_reference (MM_GDBUS_SMS (self)); +} + +/*****************************************************************************/ + +/** + * mm_sms_get_delivery_report_request: + * @self: A #MMSms. + * + * Checks whether delivery report is requested for this SMS. + * + * Returns: %TRUE if delivery report is requested, %FALSE otherwise. + */ +gboolean +mm_sms_get_delivery_report_request (MMSms *self) +{ + g_return_val_if_fail (MM_IS_SMS (self), FALSE); + + return mm_gdbus_sms_get_delivery_report_request (MM_GDBUS_SMS (self)); +} + +/*****************************************************************************/ + +/** + * mm_sms_get_delivery_state: + * @self: A #MMSms. + * + * Gets the delivery state of this SMS. + * + * This field is only applicable if the PDU type is %MM_SMS_PDU_TYPE_STATUS_REPORT. + * + * Returns: A #MMSmsDeliveryState specifying the delivery state. + */ +guint +mm_sms_get_delivery_state (MMSms *self) +{ + g_return_val_if_fail (MM_IS_SMS (self), MM_SMS_DELIVERY_STATE_UNKNOWN); + + return mm_gdbus_sms_get_delivery_state (MM_GDBUS_SMS (self)); +} + +/*****************************************************************************/ + +/** + * mm_sms_get_state: + * @self: A #MMSms. + * + * Gets the state of this SMS. + * + * Returns: A #MMSmsState specifying the state. + */ +MMSmsState +mm_sms_get_state (MMSms *self) +{ + g_return_val_if_fail (MM_IS_SMS (self), MM_SMS_STATE_UNKNOWN); + + return (MMSmsState)mm_gdbus_sms_get_state (MM_GDBUS_SMS (self)); +} + +/*****************************************************************************/ + +/** + * mm_sms_get_storage: + * @self: A #MMSms. + * + * Gets the storage in which this SMS is kept. + * + * Returns: A #MMSmsStorage specifying the storage. + */ +MMSmsStorage +mm_sms_get_storage (MMSms *self) +{ + g_return_val_if_fail (MM_IS_SMS (self), MM_SMS_STORAGE_UNKNOWN); + + return (MMSmsStorage)mm_gdbus_sms_get_storage (MM_GDBUS_SMS (self)); +} + +/*****************************************************************************/ + +/** + * mm_sms_get_pdu_type: + * @self: A #MMSms. + * + * Gets the PDU type on which this SMS is based. + * + * Returns: A #MMSmsPduType specifying the PDU type. + */ +MMSmsPduType +mm_sms_get_pdu_type (MMSms *self) +{ + g_return_val_if_fail (MM_IS_SMS (self), MM_SMS_PDU_TYPE_UNKNOWN); + + return (MMSmsPduType)mm_gdbus_sms_get_pdu_type (MM_GDBUS_SMS (self)); +} + +/*****************************************************************************/ + +/** + * mm_sms_send_finish: + * @self: A #MMSms. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_sms_send(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_sms_send(). + * + * Returns: %TRUE if the operation succeded, %FALSE if @error is set. + */ +gboolean +mm_sms_send_finish (MMSms *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_SMS (self), FALSE); + + return mm_gdbus_sms_call_send_finish (MM_GDBUS_SMS (self), res, error); +} + +/** + * mm_sms_send: + * @self: A #MMSms. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously requests to queue the message for delivery. + * + * SMS objects can only be sent once. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_sms_send_finish() to get the result of the operation. + * + * See mm_sms_send_sync() for the synchronous, blocking version of this method. + */ +void +mm_sms_send (MMSms *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_SMS (self)); + + mm_gdbus_sms_call_send (MM_GDBUS_SMS (self), + cancellable, + callback, + user_data); +} + +/** + * mm_sms_send_sync: + * @self: A #MMSms. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously requests to queue the message for delivery. + * + * SMS objects can only be sent once. + * + * The calling thread is blocked until a reply is received. + * See mm_sms_send() for the asynchronous version of this method. + * + * Returns: %TRUE if the operation succeded, %FALSE if @error is set. + */ +gboolean +mm_sms_send_sync (MMSms *self, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_SMS (self), FALSE); + + return mm_gdbus_sms_call_send_sync (MM_GDBUS_SMS (self), + cancellable, + error); +} + +/*****************************************************************************/ + +/** + * mm_sms_store_finish: + * @self: A #MMSms. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_sms_store(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with mm_sms_store(). + * + * Returns: %TRUE if the operation succeded, %FALSE if @error is set. + */ +gboolean +mm_sms_store_finish (MMSms *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (MM_IS_SMS (self), FALSE); + + return mm_gdbus_sms_call_store_finish (MM_GDBUS_SMS (self), res, error); +} + +/** + * mm_sms_store: + * @self: A #MMSms. + * @storage: A #MMSmsStorage specifying where to store the SMS, or #MM_SMS_STORAGE_UNKNOWN to use the default. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronoulsy requests to store the message in the device if not already done. + * + * SMS objects can only be stored once. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call mm_sms_store_finish() to get the result of the operation. + * + * See mm_sms_store_sync() for the synchronous, blocking version of this method. + */ +void +mm_sms_store (MMSms *self, + MMSmsStorage storage, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_SMS (self)); + + mm_gdbus_sms_call_store (MM_GDBUS_SMS (self), + storage, + cancellable, + callback, + user_data); +} + +/** + * mm_sms_store_sync: + * @self: A #MMSms. + * @storage: A #MMSmsStorage specifying where to store the SMS, or #MM_SMS_STORAGE_UNKNOWN to use the default. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronoulsy requests to store the message in the device if not already done. + * + * SMS objects can only be stored once. + * + * The calling thread is blocked until a reply is received. + * See mm_sms_store() for the asynchronous version of this method. + * + * Returns: %TRUE if the operation succeded, %FALSE if @error is set. + */ +gboolean +mm_sms_store_sync (MMSms *self, + MMSmsStorage storage, + GCancellable *cancellable, + GError **error) +{ + g_return_val_if_fail (MM_IS_SMS (self), FALSE); + + return mm_gdbus_sms_call_store_sync (MM_GDBUS_SMS (self), + storage, + cancellable, + error); +} + +/*****************************************************************************/ + +static void +mm_sms_init (MMSms *self) +{ +} + +static void +mm_sms_class_init (MMSmsClass *sms_class) +{ +} diff --git a/libmm-glib/mm-sms.h b/libmm-glib/mm-sms.h new file mode 100644 index 0000000..def70c1 --- /dev/null +++ b/libmm-glib/mm-sms.h @@ -0,0 +1,132 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem status & information from glib applications + * + * 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) 2012 Google, Inc. + */ + +#ifndef _MM_SMS_H_ +#define _MM_SMS_H_ + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> + +#include "mm-gdbus-sms.h" +#include "mm-sms-properties.h" + +G_BEGIN_DECLS + +#define MM_TYPE_SMS (mm_sms_get_type ()) +#define MM_SMS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SMS, MMSms)) +#define MM_SMS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_SMS, MMSmsClass)) +#define MM_IS_SMS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_SMS)) +#define MM_IS_SMS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), MM_TYPE_SMS)) +#define MM_SMS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_SMS, MMSmsClass)) + +typedef struct _MMSms MMSms; +typedef struct _MMSmsClass MMSmsClass; + +/** + * MMSms: + * + * The #MMSms structure contains private data and should only be accessed + * using the provided API. + */ +struct _MMSms { + /*< private >*/ + MmGdbusSmsProxy parent; + gpointer unused; +}; + +struct _MMSmsClass { + /*< private >*/ + MmGdbusSmsProxyClass parent; +}; + +GType mm_sms_get_type (void); + +const gchar *mm_sms_get_path (MMSms *self); +gchar *mm_sms_dup_path (MMSms *self); + +const gchar *mm_sms_get_text (MMSms *self); +gchar *mm_sms_dup_text (MMSms *self); + +const guint8 *mm_sms_get_data (MMSms *self, + gsize *data_len); +guint8 *mm_sms_dup_data (MMSms *self, + gsize *data_len); + +const gchar *mm_sms_get_number (MMSms *self); +gchar *mm_sms_dup_number (MMSms *self); + +const gchar *mm_sms_get_smsc (MMSms *self); +gchar *mm_sms_dup_smsc (MMSms *self); + +const gchar *mm_sms_get_timestamp (MMSms *self); +gchar *mm_sms_dup_timestamp (MMSms *self); + +const gchar *mm_sms_get_discharge_timestamp (MMSms *self); +gchar *mm_sms_dup_discharge_timestamp (MMSms *self); + +MMSmsValidityType mm_sms_get_validity_type (MMSms *self); +guint mm_sms_get_validity_relative (MMSms *self); + +gint mm_sms_get_class (MMSms *self); + +guint mm_sms_get_message_reference (MMSms *self); + +gboolean mm_sms_get_delivery_report_request (MMSms *self); + +guint mm_sms_get_delivery_state (MMSms *self); + +MMSmsState mm_sms_get_state (MMSms *self); + +MMSmsStorage mm_sms_get_storage (MMSms *self); + +MMSmsPduType mm_sms_get_pdu_type (MMSms *self); + +void mm_sms_send (MMSms *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_sms_send_finish (MMSms *self, + GAsyncResult *res, + GError **error); +gboolean mm_sms_send_sync (MMSms *self, + GCancellable *cancellable, + GError **error); + +void mm_sms_store (MMSms *self, + MMSmsStorage storage, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_sms_store_finish (MMSms *self, + GAsyncResult *res, + GError **error); +gboolean mm_sms_store_sync (MMSms *self, + MMSmsStorage storage, + GCancellable *cancellable, + GError **error); + +G_END_DECLS + +#endif /* _MM_SMS_H_ */ diff --git a/libmm-glib/mm-unlock-retries.c b/libmm-glib/mm-unlock-retries.c new file mode 100644 index 0000000..4ce6c32 --- /dev/null +++ b/libmm-glib/mm-unlock-retries.c @@ -0,0 +1,249 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2012 Google, Inc. + */ + +#include <string.h> +#include <errno.h> +#include <stdlib.h> + +#include "mm-enums-types.h" +#include "mm-unlock-retries.h" + +/** + * SECTION: mm-unlock-retries + * @title: MMUnlockRetries + * @short_description: Helper object to report unlock retries. + * + * The #MMUnlockRetries is an object exposing the unlock retry counts for + * different #MMModemLock values. + * + * This object is retrieved from the #MMModem object with either + * mm_modem_get_unlock_retries() or mm_modem_peek_unlock_retries(). + */ + +G_DEFINE_TYPE (MMUnlockRetries, mm_unlock_retries, G_TYPE_OBJECT); + +struct _MMUnlockRetriesPrivate { + GHashTable *ht; +}; + +/*****************************************************************************/ + +void +mm_unlock_retries_set (MMUnlockRetries *self, + MMModemLock lock, + guint retries) +{ + g_hash_table_replace (self->priv->ht, + GUINT_TO_POINTER (lock), + GUINT_TO_POINTER (retries)); +} + +void +mm_unlock_retries_unset (MMUnlockRetries *self, + MMModemLock lock) +{ + g_hash_table_remove (self->priv->ht, + GUINT_TO_POINTER (lock)); +} + +/*****************************************************************************/ + +/** + * mm_unlock_retries_get: + * @self: a #MMUnlockRetries. + * @lock: a #MMModemLock. + * + * Gets the unlock retries for the given @lock. + * + * Returns: the unlock retries or %MM_UNLOCK_RETRIES_UNKNOWN if unknown. + */ +guint +mm_unlock_retries_get (MMUnlockRetries *self, + MMModemLock lock) +{ + gpointer value = NULL; + + return (g_hash_table_lookup_extended (self->priv->ht, + GUINT_TO_POINTER (lock), + NULL, /* original key not needed */ + &value) ? + GPOINTER_TO_UINT (value) : + MM_UNLOCK_RETRIES_UNKNOWN); +} + +/*****************************************************************************/ + +gboolean +mm_unlock_retries_cmp (MMUnlockRetries *a, + MMUnlockRetries *b) +{ + GHashTableIter iter; + gpointer key, value; + + if (g_hash_table_size (a->priv->ht) != g_hash_table_size (b->priv->ht)) + return FALSE; + + g_hash_table_iter_init (&iter, a->priv->ht); + while (g_hash_table_iter_next (&iter, &key, &value)) { + g_assert (GPOINTER_TO_UINT (value) != MM_UNLOCK_RETRIES_UNKNOWN); + + if (GPOINTER_TO_UINT (value) != mm_unlock_retries_get (b, GPOINTER_TO_UINT (key))) + return FALSE; + } + + /* All equal! */ + return TRUE; +} + +/*****************************************************************************/ + +/** + * mm_unlock_retries_foreach: + * @self: a @MMUnlockRetries. + * @callback: callback to call for each available lock. + * @user_data: data to pass to @callback. + * + * Executes @callback for each lock information found in @self. + */ +void +mm_unlock_retries_foreach (MMUnlockRetries *self, + MMUnlockRetriesForeachCb callback, + gpointer user_data) +{ + GHashTableIter iter; + gpointer key, value; + + g_hash_table_iter_init (&iter, self->priv->ht); + while (g_hash_table_iter_next (&iter, &key, &value)) { + callback (GPOINTER_TO_UINT (key), + GPOINTER_TO_UINT (value), + user_data); + } +} + +/*****************************************************************************/ + +GVariant * +mm_unlock_retries_get_dictionary (MMUnlockRetries *self) +{ + GVariantBuilder builder; + GHashTableIter iter; + gpointer key, value; + + /* We do allow NULL */ + if (!self) + return NULL; + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{uu}")); + + g_hash_table_iter_init (&iter, self->priv->ht); + while (g_hash_table_iter_next (&iter, &key, &value)) { + g_variant_builder_add (&builder, + "{uu}", + GPOINTER_TO_UINT (key), + GPOINTER_TO_UINT (value)); + } + + return g_variant_ref_sink (g_variant_builder_end (&builder)); +} + +/*****************************************************************************/ + +MMUnlockRetries * +mm_unlock_retries_new_from_dictionary (GVariant *dictionary) +{ + GVariantIter iter; + guint key, value; + MMUnlockRetries *self; + + self = mm_unlock_retries_new (); + if (!dictionary) + return self; + + g_variant_iter_init (&iter, dictionary); + while (g_variant_iter_next (&iter, "{uu}", &key, &value)) { + mm_unlock_retries_set (self, + (MMModemLock)key, + value); + } + + return self; +} + +/*****************************************************************************/ + +gchar * +mm_unlock_retries_build_string (MMUnlockRetries *self) +{ + GString *str = NULL; + GHashTableIter iter; + gpointer key, value; + + g_hash_table_iter_init (&iter, self->priv->ht); + while (g_hash_table_iter_next (&iter, &key, &value)) { + const gchar *lock_name; + guint retries; + + lock_name = mm_modem_lock_get_string ((MMModemLock)GPOINTER_TO_UINT (key)); + retries = GPOINTER_TO_UINT (value); + + if (!str) { + str = g_string_new (""); + g_string_append_printf (str, "%s (%u)", lock_name, retries); + } else + g_string_append_printf (str, ", %s (%u)", lock_name, retries); + } + + return (str ? g_string_free (str, FALSE) : NULL); +} + +/*****************************************************************************/ + +MMUnlockRetries * +mm_unlock_retries_new (void) +{ + return (MM_UNLOCK_RETRIES ( + g_object_new (MM_TYPE_UNLOCK_RETRIES, NULL))); +} + +static void +mm_unlock_retries_init (MMUnlockRetries *self) +{ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), + MM_TYPE_UNLOCK_RETRIES, + MMUnlockRetriesPrivate); + self->priv->ht = g_hash_table_new (g_direct_hash, + g_direct_equal); +} + +static void +finalize (GObject *object) +{ + MMUnlockRetries *self = MM_UNLOCK_RETRIES (object); + + g_hash_table_destroy (self->priv->ht); + + G_OBJECT_CLASS (mm_unlock_retries_parent_class)->finalize (object); +} + +static void +mm_unlock_retries_class_init (MMUnlockRetriesClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (MMUnlockRetriesPrivate)); + + object_class->finalize = finalize; +} diff --git a/libmm-glib/mm-unlock-retries.h b/libmm-glib/mm-unlock-retries.h new file mode 100644 index 0000000..babdcbb --- /dev/null +++ b/libmm-glib/mm-unlock-retries.h @@ -0,0 +1,112 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2012 Google, Inc. + */ + +#ifndef MM_UNLOCK_RETRIES_H +#define MM_UNLOCK_RETRIES_H + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> +#include <glib-object.h> + +G_BEGIN_DECLS + +#define MM_TYPE_UNLOCK_RETRIES (mm_unlock_retries_get_type ()) +#define MM_UNLOCK_RETRIES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_UNLOCK_RETRIES, MMUnlockRetries)) +#define MM_UNLOCK_RETRIES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_UNLOCK_RETRIES, MMUnlockRetriesClass)) +#define MM_IS_UNLOCK_RETRIES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_UNLOCK_RETRIES)) +#define MM_IS_UNLOCK_RETRIES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_UNLOCK_RETRIES)) +#define MM_UNLOCK_RETRIES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_UNLOCK_RETRIES, MMUnlockRetriesClass)) + +/** + * MM_UNLOCK_RETRIES_UNKNOWN: + * + * Identifier for reporting unknown unlock retries. + */ +#define MM_UNLOCK_RETRIES_UNKNOWN 999 + +typedef struct _MMUnlockRetries MMUnlockRetries; +typedef struct _MMUnlockRetriesClass MMUnlockRetriesClass; +typedef struct _MMUnlockRetriesPrivate MMUnlockRetriesPrivate; + +/** + * MMUnlockRetries: + * + * The #MMUnlockRetries structure contains private data and should only be accessed + * using the provided API. + */ +struct _MMUnlockRetries { + /*< private >*/ + GObject parent; + MMUnlockRetriesPrivate *priv; +}; + +struct _MMUnlockRetriesClass { + /*< private >*/ + GObjectClass parent; +}; + +GType mm_unlock_retries_get_type (void); + +guint mm_unlock_retries_get (MMUnlockRetries *self, + MMModemLock lock); + +/** + * MMUnlockRetriesForeachCb: + * @lock: a #MMModemLock. + * @count: the number of retries left for @lock. + * @user_data: data passed to the function. + * + * Specifies the type of function passed to mm_unlock_retries_foreach(). + */ +typedef void (* MMUnlockRetriesForeachCb) (MMModemLock lock, + guint count, + gpointer user_data); + +void mm_unlock_retries_foreach (MMUnlockRetries *self, + MMUnlockRetriesForeachCb callback, + gpointer user_data); + +/*****************************************************************************/ +/* ModemManager/libmm-glib/mmcli specific methods */ + +#if defined (_LIBMM_INSIDE_MM) || \ + defined (_LIBMM_INSIDE_MMCLI) || \ + defined (LIBMM_GLIB_COMPILATION) + +MMUnlockRetries *mm_unlock_retries_new (void); +MMUnlockRetries *mm_unlock_retries_new_from_dictionary (GVariant *dictionary); + +void mm_unlock_retries_set (MMUnlockRetries *self, + MMModemLock lock, + guint retries); + +void mm_unlock_retries_unset (MMUnlockRetries *self, + MMModemLock lock); + +gboolean mm_unlock_retries_cmp (MMUnlockRetries *a, + MMUnlockRetries *b); + +GVariant *mm_unlock_retries_get_dictionary (MMUnlockRetries *self); + +gchar *mm_unlock_retries_build_string (MMUnlockRetries *self); + +#endif + +G_END_DECLS + +#endif /* MM_UNLOCK_RETRIES_H */ diff --git a/libmm-glib/tests/Makefile.am b/libmm-glib/tests/Makefile.am new file mode 100644 index 0000000..92c77d8 --- /dev/null +++ b/libmm-glib/tests/Makefile.am @@ -0,0 +1,28 @@ + +noinst_PROGRAMS = \ + test-common-helpers + +test_common_helpers_SOURCES = \ + test-common-helpers.c + +test_common_helpers_CPPFLAGS = \ + $(MM_CFLAGS) \ + -I$(top_srcdir) \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ + -I$(top_srcdir)/libmm-glib \ + -I$(top_builddir)/libmm-glib \ + -I${top_srcdir}/libmm-glib/generated \ + -I${top_builddir}/libmm-glib/generated \ + -DLIBMM_GLIB_COMPILATION + +test_common_helpers_LDADD = \ + $(top_builddir)/libmm-glib/libmm-glib.la \ + $(MM_LIBS) + +if WITH_TESTS + +check-local: test-common-helpers + $(abs_builddir)/test-common-helpers + +endif diff --git a/libmm-glib/tests/Makefile.in b/libmm-glib/tests/Makefile.in new file mode 100644 index 0000000..58b3e97 --- /dev/null +++ b/libmm-glib/tests/Makefile.in @@ -0,0 +1,687 @@ +# Makefile.in generated by automake 1.13.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2013 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +noinst_PROGRAMS = test-common-helpers$(EXEEXT) +subdir = libmm-glib/tests +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(top_srcdir)/depcomp +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \ + $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/gtk-doc.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \ + $(top_srcdir)/m4/intltool.m4 $(top_srcdir)/m4/lib-ld.m4 \ + $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +PROGRAMS = $(noinst_PROGRAMS) +am_test_common_helpers_OBJECTS = \ + test_common_helpers-test-common-helpers.$(OBJEXT) +test_common_helpers_OBJECTS = $(am_test_common_helpers_OBJECTS) +am__DEPENDENCIES_1 = +test_common_helpers_DEPENDENCIES = \ + $(top_builddir)/libmm-glib/libmm-glib.la $(am__DEPENDENCIES_1) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(test_common_helpers_SOURCES) +DIST_SOURCES = $(test_common_helpers_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALL_LINGUAS = @ALL_LINGUAS@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DBUS_SYS_DIR = @DBUS_SYS_DIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GLIB_MKENUMS = @GLIB_MKENUMS@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GREP = @GREP@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +GUDEV_CFLAGS = @GUDEV_CFLAGS@ +GUDEV_LIBS = @GUDEV_LIBS@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTOBJEXT = @INSTOBJEXT@ +INTLLIBS = @INTLLIBS@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ +INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ +INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ +INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBMM_GLIB_CFLAGS = @LIBMM_GLIB_CFLAGS@ +LIBMM_GLIB_LIBS = @LIBMM_GLIB_LIBS@ +LIBMM_LIBS = @LIBMM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MBIM_CFLAGS = @MBIM_CFLAGS@ +MBIM_LIBS = @MBIM_LIBS@ +MKDIR_P = @MKDIR_P@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MMCLI_CFLAGS = @MMCLI_CFLAGS@ +MMCLI_LIBS = @MMCLI_LIBS@ +MM_CFLAGS = @MM_CFLAGS@ +MM_LIBS = @MM_LIBS@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGFMT_OPTS = @MSGFMT_OPTS@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +POFILES = @POFILES@ +POLKIT_CFLAGS = @POLKIT_CFLAGS@ +POLKIT_LIBS = @POLKIT_LIBS@ +POSUB = @POSUB@ +PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ +PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ +PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +QMI_CFLAGS = @QMI_CFLAGS@ +QMI_LIBS = @QMI_LIBS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SYSTEMD_UNIT_DIR = @SYSTEMD_UNIT_DIR@ +UDEV_BASE_DIR = @UDEV_BASE_DIR@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +intltool__v_merge_options_ = @intltool__v_merge_options_@ +intltool__v_merge_options_0 = @intltool__v_merge_options_0@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +test_common_helpers_SOURCES = \ + test-common-helpers.c + +test_common_helpers_CPPFLAGS = \ + $(MM_CFLAGS) \ + -I$(top_srcdir) \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ + -I$(top_srcdir)/libmm-glib \ + -I$(top_builddir)/libmm-glib \ + -I${top_srcdir}/libmm-glib/generated \ + -I${top_builddir}/libmm-glib/generated \ + -DLIBMM_GLIB_COMPILATION + +test_common_helpers_LDADD = \ + $(top_builddir)/libmm-glib/libmm-glib.la \ + $(MM_LIBS) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libmm-glib/tests/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu libmm-glib/tests/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +test-common-helpers$(EXEEXT): $(test_common_helpers_OBJECTS) $(test_common_helpers_DEPENDENCIES) $(EXTRA_test_common_helpers_DEPENDENCIES) + @rm -f test-common-helpers$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_common_helpers_OBJECTS) $(test_common_helpers_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_common_helpers-test-common-helpers.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +test_common_helpers-test-common-helpers.o: test-common-helpers.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_common_helpers_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_common_helpers-test-common-helpers.o -MD -MP -MF $(DEPDIR)/test_common_helpers-test-common-helpers.Tpo -c -o test_common_helpers-test-common-helpers.o `test -f 'test-common-helpers.c' || echo '$(srcdir)/'`test-common-helpers.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_common_helpers-test-common-helpers.Tpo $(DEPDIR)/test_common_helpers-test-common-helpers.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-common-helpers.c' object='test_common_helpers-test-common-helpers.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_common_helpers_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_common_helpers-test-common-helpers.o `test -f 'test-common-helpers.c' || echo '$(srcdir)/'`test-common-helpers.c + +test_common_helpers-test-common-helpers.obj: test-common-helpers.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_common_helpers_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_common_helpers-test-common-helpers.obj -MD -MP -MF $(DEPDIR)/test_common_helpers-test-common-helpers.Tpo -c -o test_common_helpers-test-common-helpers.obj `if test -f 'test-common-helpers.c'; then $(CYGPATH_W) 'test-common-helpers.c'; else $(CYGPATH_W) '$(srcdir)/test-common-helpers.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_common_helpers-test-common-helpers.Tpo $(DEPDIR)/test_common_helpers-test-common-helpers.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-common-helpers.c' object='test_common_helpers-test-common-helpers.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_common_helpers_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_common_helpers-test-common-helpers.obj `if test -f 'test-common-helpers.c'; then $(CYGPATH_W) 'test-common-helpers.c'; else $(CYGPATH_W) '$(srcdir)/test-common-helpers.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +@WITH_TESTS_FALSE@check-local: +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-local +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: check-am install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am check check-am check-local clean \ + clean-generic clean-libtool clean-noinstPROGRAMS cscopelist-am \ + ctags ctags-am distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am + + +@WITH_TESTS_TRUE@check-local: test-common-helpers +@WITH_TESTS_TRUE@ $(abs_builddir)/test-common-helpers + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libmm-glib/tests/test-common-helpers.c b/libmm-glib/tests/test-common-helpers.c new file mode 100644 index 0000000..9b71e6b --- /dev/null +++ b/libmm-glib/tests/test-common-helpers.c @@ -0,0 +1,529 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details: + * + * Copyright (C) 2012 Google, Inc. + */ + +#include <glib-object.h> + +#include <libmm-glib.h> + +/********************* KEY VALUE PARSER TESTS *********************/ + +typedef struct { + const gchar *key; + const gchar *value; +} KeyValueEntry; + +/* ---- Expected cases ---- */ + +typedef struct { + const KeyValueEntry *entries; + guint n_entries; + guint i; +} CommonKeyValueTestContext; + +static gboolean +common_key_value_test_foreach (const gchar *key, + const gchar *value, + CommonKeyValueTestContext *ctx) +{ + g_assert_cmpuint (ctx->i, <, ctx->n_entries); + + g_assert_cmpstr (key, ==, ctx->entries[ctx->i].key); + g_assert_cmpstr (value, ==, ctx->entries[ctx->i].value); + ctx->i++; + + return TRUE; +} + +static void +common_key_value_test (const gchar *str, + const KeyValueEntry *entries, + guint n_entries) +{ + GError *error = NULL; + CommonKeyValueTestContext ctx; + + ctx.entries = entries; + ctx.n_entries = n_entries; + ctx.i = 0; + + mm_common_parse_key_value_string (str, + &error, + (MMParseKeyValueForeachFn)common_key_value_test_foreach, + &ctx); + g_assert_no_error (error); + g_assert_cmpuint (ctx.i, ==, ctx.n_entries); +} + +static void +key_value_test_standard (void) +{ + const gchar *str = + "key1=value1," + "key2=value2," + "key3=value3"; + const KeyValueEntry entries[] = { + { "key1", "value1" }, + { "key2", "value2" }, + { "key3", "value3" } + }; + + common_key_value_test (str, entries, G_N_ELEMENTS (entries)); +} + +static void +key_value_test_spaces (void) +{ + const gchar *str = + " key1 = value1 , " + "\t\tkey2\t=\tvalue2\t,\t" + "\n\nkey3\n=\nvalue3\n"; + const KeyValueEntry entries[] = { + { "key1", "value1" }, + { "key2", "value2" }, + { "key3", "value3" } + }; + + common_key_value_test (str, entries, G_N_ELEMENTS (entries)); +} + +static void +key_value_test_double_quotes (void) +{ + const gchar *str = + "key1=\"this is a string\"," + "key2=\"and so is this\""; + const KeyValueEntry entries[] = { + { "key1", "this is a string" }, + { "key2", "and so is this" } + }; + + common_key_value_test (str, entries, G_N_ELEMENTS (entries)); +} + +static void +key_value_test_single_quotes (void) +{ + const gchar *str = + "key1='this is a string'," + "key2='and so is this'"; + const KeyValueEntry entries[] = { + { "key1", "this is a string" }, + { "key2", "and so is this" } + }; + + common_key_value_test (str, entries, G_N_ELEMENTS (entries)); +} + +static void +key_value_test_empty_value (void) +{ + const gchar *str = + "key1=," + "key2=\"\""; + const KeyValueEntry entries[] = { + { "key1", "" }, + { "key2", "" } + }; + + common_key_value_test (str, entries, G_N_ELEMENTS (entries)); +} + +static void +key_value_test_empty_string (void) +{ + const gchar *str = ""; + const KeyValueEntry entries[] = { }; + + common_key_value_test (str, entries, G_N_ELEMENTS (entries)); +} + +/* ---- Unexpected cases ---- */ + +static gboolean +common_key_value_error_test_foreach (const gchar *key, + const gchar *value, + gpointer none) +{ + /* no op */ + return TRUE; +} + +static void +common_key_value_error_test (const gchar *str) +{ + GError *error = NULL; + + mm_common_parse_key_value_string (str, + &error, + (MMParseKeyValueForeachFn)common_key_value_error_test_foreach, + NULL); + + /* We don't really care about the specific error type */ + g_assert (error != NULL); + g_error_free (error); +} + +static void +key_value_error_test_no_first_key (void) +{ + common_key_value_error_test ("=value1"); +} + +static void +key_value_error_test_no_key (void) +{ + common_key_value_error_test ("key1=value1," + "=value2"); +} + +static void +key_value_error_test_missing_double_quotes_0 (void) +{ + common_key_value_error_test ("key1=\"value1"); +} + +static void +key_value_error_test_missing_double_quotes_1 (void) +{ + common_key_value_error_test ("key1=\"value1," + "key2=\"value2\""); +} + +static void +key_value_error_test_missing_double_quotes_2 (void) +{ + common_key_value_error_test ("key1=\"value1\"," + "key2=\"value2"); +} + +static void +key_value_error_test_missing_single_quotes_0 (void) +{ + common_key_value_error_test ("key1='value1"); +} + +static void +key_value_error_test_missing_single_quotes_1 (void) +{ + common_key_value_error_test ("key1='value1," + "key2='value2'"); +} + +static void +key_value_error_test_missing_single_quotes_2 (void) +{ + common_key_value_error_test ("key1='value1'," + "key2='value2"); +} + +static void +key_value_error_test_missing_comma_0 (void) +{ + common_key_value_error_test ("key1=value1 " + "key2=value2"); +} + +static void +key_value_error_test_missing_comma_1 (void) +{ + common_key_value_error_test ("key1=\"value1\" " + "key2=\"value2\""); +} + +static void +key_value_error_test_missing_comma_2 (void) +{ + common_key_value_error_test ("key1='value1' " + "key2='value2'"); +} + +/********************* BAND ARRAY TESTS *********************/ + +static void +common_band_array_cmp_test (gboolean equal, + const MMModemBand *bands_a, + guint n_bands_a, + const MMModemBand *bands_b, + guint n_bands_b) +{ + GArray *a; + GArray *b; + + a = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), n_bands_a); + g_array_append_vals (a, bands_a, n_bands_a); + + b = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), n_bands_b); + g_array_append_vals (b, bands_b, n_bands_b); + + g_assert_cmpuint (equal, ==, mm_common_bands_garray_cmp (a, b)); + g_assert_cmpuint (equal, ==, mm_common_bands_garray_cmp (b, a)); + + g_array_unref (a); + g_array_unref (b); +} + +static void +band_array_cmp_test_equal_empty (void) +{ + const MMModemBand a[] = { }; + const MMModemBand b[] = { }; + + common_band_array_cmp_test (TRUE, a, G_N_ELEMENTS (a), b, G_N_ELEMENTS (b)); +} + +static void +band_array_cmp_test_equal_one (void) +{ + const MMModemBand a[] = { MM_MODEM_BAND_EGSM }; + const MMModemBand b[] = { MM_MODEM_BAND_EGSM }; + + common_band_array_cmp_test (TRUE, a, G_N_ELEMENTS (a), b, G_N_ELEMENTS (b)); +} + +static void +band_array_cmp_test_equal_multiple_same_order (void) +{ + const MMModemBand a[] = { MM_MODEM_BAND_EGSM, MM_MODEM_BAND_DCS, MM_MODEM_BAND_PCS }; + const MMModemBand b[] = { MM_MODEM_BAND_EGSM, MM_MODEM_BAND_DCS, MM_MODEM_BAND_PCS }; + + common_band_array_cmp_test (TRUE, a, G_N_ELEMENTS (a), b, G_N_ELEMENTS (b)); +} + +static void +band_array_cmp_test_equal_multiple_different_order (void) +{ + const MMModemBand a[] = { MM_MODEM_BAND_EGSM, MM_MODEM_BAND_DCS, MM_MODEM_BAND_PCS }; + const MMModemBand b[] = { MM_MODEM_BAND_DCS, MM_MODEM_BAND_PCS, MM_MODEM_BAND_EGSM }; + + common_band_array_cmp_test (TRUE, a, G_N_ELEMENTS (a), b, G_N_ELEMENTS (b)); +} + +static void +band_array_cmp_test_different_one (void) +{ + const MMModemBand a[] = { MM_MODEM_BAND_EGSM }; + const MMModemBand b[] = { MM_MODEM_BAND_DCS }; + + common_band_array_cmp_test (FALSE, a, G_N_ELEMENTS (a), b, G_N_ELEMENTS (b)); +} + +static void +band_array_cmp_test_different_none (void) +{ + const MMModemBand a[] = { }; + const MMModemBand b[] = { MM_MODEM_BAND_EGSM }; + + common_band_array_cmp_test (FALSE, a, G_N_ELEMENTS (a), b, G_N_ELEMENTS (b)); +} + +static void +band_array_cmp_test_different_multiple_1 (void) +{ + const MMModemBand a[] = { MM_MODEM_BAND_EGSM }; + const MMModemBand b[] = { MM_MODEM_BAND_EGSM, MM_MODEM_BAND_DCS }; + + common_band_array_cmp_test (FALSE, a, G_N_ELEMENTS (a), b, G_N_ELEMENTS (b)); +} + +static void +band_array_cmp_test_different_multiple_2 (void) +{ + const MMModemBand a[] = { MM_MODEM_BAND_EGSM }; + const MMModemBand b[] = { MM_MODEM_BAND_DCS, MM_MODEM_BAND_EGSM }; + + common_band_array_cmp_test (FALSE, a, G_N_ELEMENTS (a), b, G_N_ELEMENTS (b)); +} + +/********************* FIELD PARSERS TESTS *********************/ + +static void +field_parser_int (void) +{ + gint num; + gchar *str; + + /* Failures */ + + g_assert (mm_get_int_from_str (NULL, &num) == FALSE); + + g_assert (mm_get_int_from_str ("", &num) == FALSE); + + g_assert (mm_get_int_from_str ("a", &num) == FALSE); + + g_assert (mm_get_int_from_str ("a100", &num) == FALSE); + + g_assert (mm_get_int_from_str ("100a", &num) == FALSE); + + str = g_strdup_printf ("%" G_GINT64_FORMAT, (gint64)G_MAXINT + 1); + g_assert (mm_get_int_from_str (str, &num) == FALSE); + g_free (str); + + str = g_strdup_printf ("%" G_GINT64_FORMAT, (gint64)(G_MININT) - 1); + g_assert (mm_get_int_from_str (str, &num) == FALSE); + g_free (str); + + /* Successes */ + + g_assert (mm_get_int_from_str ("0", &num) == TRUE); + g_assert_cmpint (num, ==, 0); + + g_assert (mm_get_int_from_str ("-100", &num) == TRUE); + g_assert_cmpint (num, ==, -100); + + g_assert (mm_get_int_from_str ("100", &num) == TRUE); + g_assert_cmpint (num, ==, 100); + + str = g_strdup_printf ("%" G_GINT64_FORMAT, (gint64)G_MAXINT); + g_assert (mm_get_int_from_str (str, &num) == TRUE); + g_assert_cmpint (num, ==, G_MAXINT); + g_free (str); + + str = g_strdup_printf ("%" G_GINT64_FORMAT, (gint64)G_MININT); + g_assert (mm_get_int_from_str (str, &num) == TRUE); + g_assert_cmpint (num, ==, G_MININT); + g_free (str); +} + +static void +field_parser_uint (void) +{ + gchar *str; + guint num; + + /* Failures */ + + g_assert (mm_get_uint_from_str (NULL, &num) == FALSE); + + g_assert (mm_get_uint_from_str ("", &num) == FALSE); + + g_assert (mm_get_uint_from_str ("a", &num) == FALSE); + + g_assert (mm_get_uint_from_str ("a100", &num) == FALSE); + + g_assert (mm_get_uint_from_str ("100a", &num) == FALSE); + + g_assert (mm_get_uint_from_str ("-100", &num) == FALSE); + + str = g_strdup_printf ("%" G_GUINT64_FORMAT, (guint64)(G_MAXUINT) + 1); + g_assert (mm_get_uint_from_str (str, &num) == FALSE); + g_free (str); + + /* Successes */ + + g_assert (mm_get_uint_from_str ("0", &num) == TRUE); + g_assert_cmpuint (num, ==, 0); + + g_assert (mm_get_uint_from_str ("100", &num) == TRUE); + g_assert_cmpuint (num, ==, 100); + + str = g_strdup_printf ("%" G_GUINT64_FORMAT, (guint64)G_MAXUINT); + g_assert (mm_get_uint_from_str (str, &num) == TRUE); + g_assert_cmpuint (num, ==, G_MAXUINT); + g_free (str); +} + +static void +field_parser_double (void) +{ + gchar *str; + gdouble num; + + /* Failures */ + + g_assert (mm_get_double_from_str (NULL, &num) == FALSE); + + g_assert (mm_get_double_from_str ("", &num) == FALSE); + + g_assert (mm_get_double_from_str ("a", &num) == FALSE); + + g_assert (mm_get_double_from_str ("a100", &num) == FALSE); + + g_assert (mm_get_double_from_str ("100a", &num) == FALSE); + + /* Successes */ + + g_assert (mm_get_double_from_str ("-100", &num) == TRUE); + g_assert (num - (-100.0) < 0000000.1); + + g_assert (mm_get_double_from_str ("-100.7567", &num) == TRUE); + g_assert (num - (-100.7567) < 0000000.1); + + g_assert (mm_get_double_from_str ("0", &num) == TRUE); + g_assert (num < 0000000.1); + + g_assert (mm_get_double_from_str ("-0.0", &num) == TRUE); + g_assert (num < 0000000.1); + + g_assert (mm_get_double_from_str ("0.0", &num) == TRUE); + g_assert (num < 0000000.1); + + g_assert (mm_get_double_from_str ("100", &num) == TRUE); + g_assert (num - (100.0) < 0000000.1); + + g_assert (mm_get_double_from_str ("100.7567", &num) == TRUE); + g_assert (num - (100.7567) < 0000000.1); + + str = g_strdup_printf ("%lf", (gdouble)G_MINDOUBLE); + g_assert (mm_get_double_from_str (str, &num) == TRUE); + g_assert (num - G_MINDOUBLE < 0000000.1); + g_free (str); + + str = g_strdup_printf ("%lf", (gdouble)G_MAXDOUBLE); + g_assert (mm_get_double_from_str (str, &num) == TRUE); + g_assert (num - G_MAXDOUBLE < 0000000.1); + g_free (str); +} + +/**************************************************************/ + +int main (int argc, char **argv) +{ + g_type_init (); + g_test_init (&argc, &argv, NULL); + + g_test_add_func ("/MM/Common/KeyValue/standard", key_value_test_standard); + g_test_add_func ("/MM/Common/KeyValue/spaces", key_value_test_spaces); + g_test_add_func ("/MM/Common/KeyValue/double-quotes", key_value_test_double_quotes); + g_test_add_func ("/MM/Common/KeyValue/single-quotes", key_value_test_single_quotes); + g_test_add_func ("/MM/Common/KeyValue/empty-value", key_value_test_empty_value); + g_test_add_func ("/MM/Common/KeyValue/empty-string", key_value_test_empty_string); + + g_test_add_func ("/MM/Common/KeyValue/Error/no-first-key", key_value_error_test_no_first_key); + g_test_add_func ("/MM/Common/KeyValue/Error/no-key", key_value_error_test_no_key); + g_test_add_func ("/MM/Common/KeyValue/Error/missing-double-quotes-0", key_value_error_test_missing_double_quotes_0); + g_test_add_func ("/MM/Common/KeyValue/Error/missing-double-quotes-1", key_value_error_test_missing_double_quotes_1); + g_test_add_func ("/MM/Common/KeyValue/Error/missing-double-quotes-2", key_value_error_test_missing_double_quotes_2); + g_test_add_func ("/MM/Common/KeyValue/Error/missing-single-quotes-0", key_value_error_test_missing_single_quotes_0); + g_test_add_func ("/MM/Common/KeyValue/Error/missing-single-quotes-1", key_value_error_test_missing_single_quotes_1); + g_test_add_func ("/MM/Common/KeyValue/Error/missing-single-quotes-2", key_value_error_test_missing_single_quotes_2); + g_test_add_func ("/MM/Common/KeyValue/Error/missing-comma-0", key_value_error_test_missing_comma_0); + g_test_add_func ("/MM/Common/KeyValue/Error/missing-comma-1", key_value_error_test_missing_comma_1); + g_test_add_func ("/MM/Common/KeyValue/Error/missing-comma-2", key_value_error_test_missing_comma_2); + + g_test_add_func ("/MM/Common/BandArray/Cmp/equal-empty", band_array_cmp_test_equal_empty); + g_test_add_func ("/MM/Common/BandArray/Cmp/equal-one", band_array_cmp_test_equal_one); + g_test_add_func ("/MM/Common/BandArray/Cmp/equal-multiple-same-order", band_array_cmp_test_equal_multiple_same_order); + g_test_add_func ("/MM/Common/BandArray/Cmp/equal-multiple-different-order", band_array_cmp_test_equal_multiple_different_order); + g_test_add_func ("/MM/Common/BandArray/Cmp/different-one", band_array_cmp_test_different_one); + g_test_add_func ("/MM/Common/BandArray/Cmp/different-none", band_array_cmp_test_different_none); + g_test_add_func ("/MM/Common/BandArray/Cmp/different-multiple-1", band_array_cmp_test_different_multiple_1); + g_test_add_func ("/MM/Common/BandArray/Cmp/different-multiple-2", band_array_cmp_test_different_multiple_2); + + g_test_add_func ("/MM/Common/FieldParsers/Int", field_parser_int); + g_test_add_func ("/MM/Common/FieldParsers/Uint", field_parser_uint); + g_test_add_func ("/MM/Common/FieldParsers/Double", field_parser_double); + + return g_test_run (); +} |