예제 #1
0
static gboolean
initable_init (GInitable *initable,
               GCancellable *cancellable,
               GError **error)
{
    MMManagerPrivate *priv = MM_MANAGER (initable)->priv;

    /* Create plugin manager */
    priv->plugin_manager = mm_plugin_manager_new (error);
    if (!priv->plugin_manager)
        return FALSE;

    /* Export the manager interface */
    if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (initable),
                                           priv->connection,
                                           MM_DBUS_PATH,
                                           error))
        return FALSE;

    /* Export the Object Manager interface */
    g_dbus_object_manager_server_set_connection (priv->object_manager,
                                                 priv->connection);

    /* All good */
    return TRUE;
}
예제 #2
0
static void
finalize (GObject *object)
{
    MMManagerPrivate *priv = MM_MANAGER (object)->priv;

    g_hash_table_destroy (priv->devices);

    if (priv->udev)
        g_object_unref (priv->udev);

    if (priv->plugin_manager)
        g_object_unref (priv->plugin_manager);

    if (priv->object_manager)
        g_object_unref (priv->object_manager);

    if (priv->connection)
        g_object_unref (priv->connection);

    if (priv->authp)
        g_object_unref (priv->authp);

    if (priv->authp_cancellable)
        g_object_unref (priv->authp_cancellable);

    G_OBJECT_CLASS (mm_manager_parent_class)->finalize (object);
}
예제 #3
0
static void
handle_uevent (GUdevClient *client,
               const char *action,
               GUdevDevice *device,
               gpointer user_data)
{
    MMManager *self = MM_MANAGER (user_data);
    const char *subsys;

    g_return_if_fail (action != NULL);

    /* A bit paranoid */
    subsys = g_udev_device_get_subsystem (device);
    g_return_if_fail (subsys != NULL);

    g_return_if_fail (!strcmp (subsys, "tty") || !strcmp (subsys, "net") || !strcmp (subsys, "usb"));

    /* We only care about tty/net devices when adding modem ports,
     * but for remove, also handle usb parent device remove events
     */
    if (   (!strcmp (action, "add") || !strcmp (action, "move") || !strcmp (action, "change"))
        && (strcmp (subsys, "usb") != 0))
        device_added (self, device);
    else if (!strcmp (action, "remove"))
        device_removed (self, device);
}
예제 #4
0
static void
handle_uevent (GUdevClient *client,
               const char *action,
               GUdevDevice *device,
               gpointer user_data)
{
    MMManager *self = MM_MANAGER (user_data);
    const gchar *subsys;
    const gchar *name;

    g_return_if_fail (action != NULL);

    /* A bit paranoid */
    subsys = g_udev_device_get_subsystem (device);
    g_return_if_fail (subsys != NULL);
    g_return_if_fail (g_str_equal (subsys, "tty") || g_str_equal (subsys, "net") || g_str_has_prefix (subsys, "usb"));

    /* We only care about tty/net and usb/cdc-wdm devices when adding modem ports,
     * but for remove, also handle usb parent device remove events
     */
    name = g_udev_device_get_name (device);
    if (   (g_str_equal (action, "add") || g_str_equal (action, "move") || g_str_equal (action, "change"))
        && (!g_str_has_prefix (subsys, "usb") || (name && g_str_has_prefix (name, "cdc-wdm"))))
        device_added (self, device, TRUE);
    else if (g_str_equal (action, "remove"))
        device_removed (self, device);
}
예제 #5
0
static void
finalize (GObject *object)
{
    MMManagerPrivate *priv = MM_MANAGER (object)->priv;

    if (priv->manager_iface_proxy)
        g_object_unref (priv->manager_iface_proxy);

    G_OBJECT_CLASS (mm_manager_parent_class)->finalize (object);
}
예제 #6
0
static void
modem_valid (MMBaseModem *modem,
             GParamSpec *pspec,
             gpointer user_data)
{
    MMManager *manager = MM_MANAGER (user_data);

    if (mm_base_modem_get_valid (modem))
        check_export_modem (manager, modem);
    else
        remove_modem (manager, modem);
}
예제 #7
0
static void
get_property (GObject *object,
              guint prop_id,
              GValue *value,
              GParamSpec *pspec)
{
    MMManagerPrivate *priv = MM_MANAGER (object)->priv;

    switch (prop_id) {
    case PROP_CONNECTION:
        g_value_set_object (value, priv->connection);
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        break;
    }
}
예제 #8
0
static gboolean
initable_init_sync (GInitable     *initable,
                    GCancellable  *cancellable,
                    GError       **error)
{
    MMManagerPrivate *priv = MM_MANAGER (initable)->priv;
	GError *inner_error = NULL;
    gchar *name = NULL;
    gchar *object_path = NULL;
    GDBusObjectManagerClientFlags flags = G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE;
    GDBusConnection *connection = NULL;

	/* Chain up parent's initable callback before calling child's one */
	if (!initable_parent_iface->init (initable, cancellable, &inner_error)) {
		g_propagate_error (error, inner_error);
		return FALSE;
	}

    /* Get the Manager proxy created synchronously now */
    g_object_get (initable,
                  "name", &name,
                  "object-path", &object_path,
                  "flags", &flags,
                  "connection", &connection,
                  NULL);
    priv->manager_iface_proxy =
        mm_gdbus_org_freedesktop_modem_manager1_proxy_new_sync (connection,
                                                                flags,
                                                                name,
                                                                object_path,
                                                                cancellable,
                                                                error);
    g_object_unref (connection);
    g_free (object_path);
    g_free (name);

    if (!priv->manager_iface_proxy) {
		g_propagate_error (error, inner_error);
		return FALSE;
    }

    /* All good */
	return TRUE;
}
예제 #9
0
static void
scan_devices_auth_ready (MMAuthProvider *authp,
                         GAsyncResult *res,
                         ScanDevicesContext *ctx)
{
    GError *error = NULL;

    if (!mm_auth_provider_authorize_finish (authp, res, &error))
        g_dbus_method_invocation_take_error (ctx->invocation, error);
    else {
        /* Otherwise relaunch device scan */
        mm_manager_start (MM_MANAGER (ctx->self));
        mm_gdbus_org_freedesktop_modem_manager1_complete_scan_devices (
            MM_GDBUS_ORG_FREEDESKTOP_MODEM_MANAGER1 (ctx->self),
            ctx->invocation);
    }

    scan_devices_context_free (ctx);
}
예제 #10
0
/**
 * 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", mm_gdbus_object_manager_client_get_proxy_type,
                          NULL);

    return (ret ? MM_MANAGER (ret) : NULL);
}
예제 #11
0
static gboolean
start_manager (gpointer user_data)
{
    mm_manager_start (MM_MANAGER (user_data));
    return FALSE;
}
예제 #12
0
/**
 * 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)
{
    return MM_MANAGER (mm_gdbus_object_manager_client_new_finish (res, error));
}