Commit 9de38d0e authored by Guido Gunther's avatar Guido Gunther

Initial wwan plugin

Heavily based on code from nm-applet.

Follow-Ups:
   - Allow to store SIM in keyring
   - Handle PUKs? (or do that in g-c-c)

(cherry picked from commit 94baaea843db9d92e5f2ba1b99516f0bac4a6feb)
parent d316efe0
......@@ -12,6 +12,10 @@ schemas = [
'org.gnome.settings-daemon.plugins.xsettings.gschema.xml'
]
if enable_wwan
schemas += 'org.gnome.settings-daemon.plugins.wwan.gschema.xml'
endif
schema_conf = configuration_data()
schema_conf.set('GETTEXT_PACKAGE', meson.project_name())
......
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.settings-daemon.plugins.wwan" path="/org/gnome/settings-daemon/plugins/wwan/">
<key name="unlock-sim" type="b">
<default>false</default>
<summary>Unlock sim cards</summary>
<description>Unlock any sim cards right away.</description>
</key>
</schema>
</schemalist>
......@@ -192,6 +192,13 @@ if enable_rfkill
endif
endif
# wwan
enable_wwan = get_option('wwan')
if enable_wwan
gcr_base_dep = dependency('gcr-base-3', version: '>= 3.7.5')
mm_glib_dep = dependency('mm-glib', version: '>= 1.0')
endif
# Sharing plugin
enable_network_manager = get_option('network_manager')
assert(enable_network_manager or not host_is_linux, 'NetworkManager support is not optional on Linux platforms')
......
......@@ -8,5 +8,7 @@ option('network_manager', type: 'boolean', value: true, description: 'build with
option('rfkill', type: 'boolean', value: true, description: 'build with rfkill support (not optional on Linux platforms)')
option('smartcard', type: 'boolean', value: true, description: 'build with smartcard support')
option('wayland', type: 'boolean', value: true, description: 'build with Wayland support')
<<<<<<< HEAD
Please register or sign in to reply
option('experimental_suspend_then_hibernate', type: 'boolean', value: false, description: 'use suspend-then-hibernate if available (NOT recommended)')
option('wwan', type: 'boolean', value: true, description: 'build with WWAN support')
......@@ -31,6 +31,10 @@ if enable_rfkill
enabled_plugins += [['rfkill', 'Rfkill']]
endif
if enable_wwan
enabled_plugins += [['wwan', 'Wwan']]
endif
plugins_conf = configuration_data()
plugins_conf.set('libexecdir', gsd_libexecdir)
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2019 Purism SPC
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Guido Günther <agx@sigxcpu.org>
*
*/
#include "config.h"
#include <gio/gio.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <libmm-glib.h>
#include "gsd-wwan-device.h"
struct _GsdWwanDevice
{
GObject parent;
MMModem *mm_modem;
MMSim *mm_sim;
MMObject *mm_object;
};
enum {
PROP_0,
PROP_MM_OBJECT,
PROP_MM_MODEM,
PROP_MM_SIM,
PROP_LAST_PROP,
};
static GParamSpec *props[PROP_LAST_PROP];
enum {
SIM_NEEDS_UNLOCK,
N_SIGNALS
};
static guint signals[N_SIGNALS];
G_DEFINE_TYPE (GsdWwanDevice, gsd_wwan_device, G_TYPE_OBJECT)
static void
modem_get_sim_ready (MMModem *modem, GAsyncResult *res, GsdWwanDevice *self)
{
self->mm_sim = mm_modem_get_sim_finish (modem, res, NULL);
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_MM_SIM]);
g_return_if_fail (MM_IS_SIM (self->mm_sim));
g_debug ("Need to unlock sim %s (%s)",
mm_sim_get_path (self->mm_sim),
mm_sim_get_identifier (self->mm_sim));
g_signal_emit(self, signals[SIM_NEEDS_UNLOCK], 0);
}
static void
fetch_modem_info (GsdWwanDevice *self)
{
self->mm_modem = mm_object_get_modem (MM_OBJECT(self->mm_object));
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_MM_MODEM]);
g_return_if_fail (self->mm_modem);
g_debug ("Found modem %s (%s)",
mm_modem_get_path (self->mm_modem),
mm_modem_get_device (self->mm_modem));
if (mm_modem_get_state (self->mm_modem) != MM_MODEM_STATE_LOCKED)
return;
/* The sim card will be valid as long as the modem exists */
mm_modem_get_sim (self->mm_modem, NULL, (GAsyncReadyCallback)modem_get_sim_ready, self);
  • /* The sim card will be valid as long as the modem exists */

    Likely no, if the modem has sim card missing. In that case, sim can be NULL. It may also happen if the sim card got removed from modem (but the modem is still present)

Please register or sign in to reply
}
static void
gsd_wwan_device_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GsdWwanDevice *self = GSD_WWAN_DEVICE (object);
switch (prop_id) {
case PROP_MM_OBJECT:
self->mm_object = g_value_dup_object (value);
fetch_modem_info (self);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gsd_wwan_device_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GsdWwanDevice *self = GSD_WWAN_DEVICE (object);
switch (prop_id) {
case PROP_MM_OBJECT:
g_value_set_object (value, self->mm_object);
break;
case PROP_MM_MODEM:
g_value_set_object (value, self->mm_modem);
break;
case PROP_MM_SIM:
g_value_set_object (value, self->mm_sim);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gsd_wwan_device_dispose (GObject *object)
{
GsdWwanDevice *self = GSD_WWAN_DEVICE (object);
g_clear_object (&self->mm_modem);
g_clear_object (&self->mm_sim);
g_clear_object (&self->mm_object);
G_OBJECT_CLASS (gsd_wwan_device_parent_class)->dispose (object);
}
static void
gsd_wwan_device_class_init (GsdWwanDeviceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = gsd_wwan_device_get_property;
object_class->set_property = gsd_wwan_device_set_property;
object_class->dispose = gsd_wwan_device_dispose;
signals[SIM_NEEDS_UNLOCK] =
g_signal_new ("sim-needs-unlock",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0,
NULL, NULL, NULL,
G_TYPE_NONE, 0);
props[PROP_MM_OBJECT] =
g_param_spec_object ("mm-object",
"mm-object",
"The MMObject representing a modem",
MM_TYPE_OBJECT,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
props[PROP_MM_MODEM] =
g_param_spec_object ("mm-modem",
"mm-modem",
"The MMModem interface object",
MM_TYPE_MODEM,
G_PARAM_READABLE |
G_PARAM_EXPLICIT_NOTIFY |
G_PARAM_STATIC_STRINGS);
props[PROP_MM_SIM] =
g_param_spec_object ("mm-sim",
"mm-sim",
"The MMSim interface object",
MM_TYPE_SIM,
G_PARAM_READABLE |
G_PARAM_EXPLICIT_NOTIFY |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
}
static void
gsd_wwan_device_init (GsdWwanDevice *self)
{
}
GsdWwanDevice *
gsd_wwan_device_new (MMObject *object)
{
return g_object_new (GSD_TYPE_WWAN_DEVICE, "mm-object", object, NULL);
}
MMObject *
gsd_wwan_device_get_mm_object (GsdWwanDevice *self)
{
g_return_val_if_fail (GSD_IS_WWAN_DEVICE (self), NULL);
return self->mm_object;
}
MMModem *
gsd_wwan_device_get_mm_modem (GsdWwanDevice *self)
{
g_return_val_if_fail (GSD_IS_WWAN_DEVICE (self), NULL);
return self->mm_modem;
}
MMSim *
gsd_wwan_device_get_mm_sim (GsdWwanDevice *self)
{
g_return_val_if_fail (GSD_IS_WWAN_DEVICE (self), NULL);
return self->mm_sim;
}
gboolean
gsd_wwan_device_needs_unlock (GsdWwanDevice *self)
{
g_return_val_if_fail (GSD_IS_WWAN_DEVICE (self), FALSE);
return (mm_modem_get_state (self->mm_modem) == MM_MODEM_STATE_LOCKED &&
self->mm_sim);
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2019 Purism SPC
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Guido Günther <agx@sigxcpu.org>
*
*/
# pragma once
#include <glib-object.h>
#include <libmm-glib.h>
G_BEGIN_DECLS
#define GSD_TYPE_WWAN_DEVICE (gsd_wwan_device_get_type())
G_DECLARE_FINAL_TYPE (GsdWwanDevice, gsd_wwan_device, GSD, WWAN_DEVICE, GObject)
GsdWwanDevice *gsd_wwan_device_new (MMObject *object);
MMObject *gsd_wwan_device_get_mm_object (GsdWwanDevice *self);
MMModem *gsd_wwan_device_get_mm_modem (GsdWwanDevice *self);
MMSim *gsd_wwan_device_get_mm_sim (GsdWwanDevice *self);
gboolean gsd_wwan_device_needs_unlock (GsdWwanDevice *self);
G_END_DECLS
This diff is collapsed.
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2019 Purism SPC
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Guido Günther <agx@sigxcpu.org>
*
*/
# pragma once
#include <glib-object.h>
G_BEGIN_DECLS
#define GSD_TYPE_WWAN_MANAGER (gsd_wwan_manager_get_type())
G_DECLARE_FINAL_TYPE (GsdWwanManager, gsd_wwan_manager, GSD, WWAN_MANAGER, GObject)
GsdWwanManager * gsd_wwan_manager_new (void);
gboolean gsd_wwan_manager_start (GsdWwanManager *manager,
GError **error);
void gsd_wwan_manager_stop (GsdWwanManager *manager);
G_END_DECLS
This diff is collapsed.
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2019 Purism SPC
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Guido Günther <agx@sigxcpu.org>
*
*/
#pragma once
#include "gsd-wwan-device.h"
#include "gsd-wwan-manager.h"
void gsd_wwan_pinentry_unlock_sim (GsdWwanDevice *device, const char *error_msg);
void gsd_wwan_pinentry_unlock_sim_error (GsdWwanDevice *device, const char *error_msg);
#define NEW gsd_wwan_manager_new
#define START gsd_wwan_manager_start
#define STOP gsd_wwan_manager_stop
#define MANAGER GsdWwanManager
#include "gsd-wwan-manager.h"
#include "daemon-skeleton.h"
sources = files(
'gsd-wwan-device.c',
'gsd-wwan-manager.c',
'gsd-wwan-pinentry.c',
'main.c'
)
deps = plugins_deps + [gio_dep, gcr_base_dep, mm_glib_dep]
cflags += ['-DGNOMECC_DATA_DIR="@0@"'.format(gsd_pkgdatadir)]
executable(
'gsd-' + plugin_name,
sources,
include_directories: [top_inc, common_inc],
dependencies: deps,
c_args: cflags,
install: true,
install_rpath: gsd_pkglibdir,
install_dir: gsd_libexecdir
)
[Desktop Entry]
Type=Application
Name=GNOME Settings Daemon's Wwan plugin
Exec=@libexecdir@/gsd-wwan
OnlyShowIn=GNOME;
NoDisplay=true
X-GNOME-Autostart-Phase=Initialization
X-GNOME-Autostart-Notify=true
X-GNOME-AutoRestart=true
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment