core: add FactoryReset method
Cleanups and authorization checks by me (dcbw).
This commit is contained in:

committed by
Dan Williams

parent
88c538314a
commit
89c572e59d
@@ -81,6 +81,17 @@
|
|||||||
</arg>
|
</arg>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
|
<method name="FactoryReset">
|
||||||
|
<tp:docstring>
|
||||||
|
Reset the modem to as close to factory state as possible.
|
||||||
|
</tp:docstring>
|
||||||
|
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||||
|
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_modem_factory_reset"/>
|
||||||
|
<arg name="code" type="s" direction="in">
|
||||||
|
Carrier-supplied code required to reset the modem. Ignored if not required.
|
||||||
|
</arg>
|
||||||
|
</method>
|
||||||
|
|
||||||
<property name="Device" type="s" access="read">
|
<property name="Device" type="s" access="read">
|
||||||
<tp:docstring>
|
<tp:docstring>
|
||||||
The modem port to use for IP configuration and traffic.
|
The modem port to use for IP configuration and traffic.
|
||||||
|
@@ -28,6 +28,7 @@ static void impl_modem_connect (MMModem *modem, const char *number, DBusGMethodI
|
|||||||
static void impl_modem_disconnect (MMModem *modem, DBusGMethodInvocation *context);
|
static void impl_modem_disconnect (MMModem *modem, DBusGMethodInvocation *context);
|
||||||
static void impl_modem_get_ip4_config (MMModem *modem, DBusGMethodInvocation *context);
|
static void impl_modem_get_ip4_config (MMModem *modem, DBusGMethodInvocation *context);
|
||||||
static void impl_modem_get_info (MMModem *modem, DBusGMethodInvocation *context);
|
static void impl_modem_get_info (MMModem *modem, DBusGMethodInvocation *context);
|
||||||
|
static void impl_modem_factory_reset (MMModem *modem, const char *code, DBusGMethodInvocation *context);
|
||||||
|
|
||||||
#include "mm-modem-glue.h"
|
#include "mm-modem-glue.h"
|
||||||
|
|
||||||
@@ -476,6 +477,62 @@ impl_modem_get_info (MMModem *modem,
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void
|
||||||
|
factory_reset_auth_cb (MMAuthRequest *req,
|
||||||
|
GObject *owner,
|
||||||
|
DBusGMethodInvocation *context,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
MMModem *self = MM_MODEM (owner);
|
||||||
|
const char *code = user_data;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
/* Return any authorization error, otherwise try to reset the modem */
|
||||||
|
if (!mm_modem_auth_finish (self, req, &error)) {
|
||||||
|
dbus_g_method_return_error (context, error);
|
||||||
|
g_error_free (error);
|
||||||
|
} else
|
||||||
|
mm_modem_factory_reset (self, code, async_call_done, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
impl_modem_factory_reset (MMModem *modem,
|
||||||
|
const char *code,
|
||||||
|
DBusGMethodInvocation *context)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
/* Make sure the caller is authorized to reset the device */
|
||||||
|
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||||
|
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||||
|
context,
|
||||||
|
factory_reset_auth_cb,
|
||||||
|
g_strdup (code),
|
||||||
|
g_free,
|
||||||
|
&error)) {
|
||||||
|
dbus_g_method_return_error (context, error);
|
||||||
|
g_error_free (error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mm_modem_factory_reset (MMModem *self,
|
||||||
|
const char *code,
|
||||||
|
MMModemFn callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
g_return_if_fail (MM_IS_MODEM (self));
|
||||||
|
g_return_if_fail (callback != NULL);
|
||||||
|
g_return_if_fail (code != NULL);
|
||||||
|
|
||||||
|
if (MM_MODEM_GET_INTERFACE (self)->factory_reset)
|
||||||
|
MM_MODEM_GET_INTERFACE (self)->factory_reset (self, code, callback, user_data);
|
||||||
|
else
|
||||||
|
async_op_not_supported (self, callback, user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
void
|
void
|
||||||
mm_modem_get_supported_charsets (MMModem *self,
|
mm_modem_get_supported_charsets (MMModem *self,
|
||||||
MMModemUIntFn callback,
|
MMModemUIntFn callback,
|
||||||
|
@@ -188,6 +188,11 @@ struct _MMModem {
|
|||||||
MMAuthRequest *req,
|
MMAuthRequest *req,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
void (*factory_reset) (MMModem *self,
|
||||||
|
const char *code,
|
||||||
|
MMModemFn callback,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
/* Signals */
|
/* Signals */
|
||||||
void (*state_changed) (MMModem *self,
|
void (*state_changed) (MMModem *self,
|
||||||
MMModemState new_state,
|
MMModemState new_state,
|
||||||
@@ -246,6 +251,11 @@ void mm_modem_set_charset (MMModem *self,
|
|||||||
MMModemFn callback,
|
MMModemFn callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
|
void mm_modem_factory_reset (MMModem *self,
|
||||||
|
const char *code,
|
||||||
|
MMModemFn callback,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
gboolean mm_modem_get_valid (MMModem *self);
|
gboolean mm_modem_get_valid (MMModem *self);
|
||||||
|
|
||||||
char *mm_modem_get_device (MMModem *self);
|
char *mm_modem_get_device (MMModem *self);
|
||||||
|
Reference in New Issue
Block a user