blob: 60b29d74a6585dea57a549e91b65f54eb84ef46c [file] [log] [blame]
// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <glib.h>
#include <string>
// Use udev to keep track of additions and removals of devices
struct udev;
struct udev_monitor;
struct udev_device;
typedef void (*DeviceCallback)(void* context,
const char* action,
const char* device);
typedef void (*TimeoutCallback)(void*);
class DeviceWatcher {
explicit DeviceWatcher(const char* subsystem);
void StartMonitoring();
void StopMonitoring();
void StartPolling(int interval_secs,
TimeoutCallback callback,
void* userdata);
void StopPolling();
void HandleUdevEvent();
void HandlePollEvent();
void set_callback(DeviceCallback callback, void* userdata);
std::string subsystem_;
DeviceCallback device_callback_;
void* device_callback_arg_;
TimeoutCallback timeout_callback_;
void* timeout_callback_arg_;
struct udev* udev_;
struct udev_monitor* udev_monitor_;
guint udev_watch_id_;
guint timeout_id_;