blob: a51d875bb0646ec3b6b421002524fcffdbb7ad49 [file] [log] [blame]
Darin Petkov5c97ac52011-07-19 16:30:49 -07001// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef SHILL_MODEM_
6#define SHILL_MODEM_
7
8#include <string>
9
10#include <base/basictypes.h>
11#include <base/memory/scoped_ptr.h>
Darin Petkov67d8ecf2011-07-26 16:03:30 -070012#include <base/task.h>
Darin Petkove0a312e2011-07-20 13:45:28 -070013#include <gtest/gtest_prod.h> // for FRIEND_TEST
14
15#include "shill/dbus_properties_proxy_interface.h"
16#include "shill/refptr_types.h"
Darin Petkov5c97ac52011-07-19 16:30:49 -070017
18namespace shill {
19
20class ControlInterface;
Darin Petkov5c97ac52011-07-19 16:30:49 -070021class EventDispatcher;
22class Manager;
23
Darin Petkove0a312e2011-07-20 13:45:28 -070024// Handles an instance of ModemManager.Modem and an instance of a Cellular
25// device.
Darin Petkov5c97ac52011-07-19 16:30:49 -070026class Modem {
27 public:
Darin Petkove0a312e2011-07-20 13:45:28 -070028 // |owner| is the ModemManager DBus service owner (e.g., ":1.17"). |path| is
29 // the ModemManager.Modem DBus object path (e.g.,
30 // "/org/chromium/ModemManager/Gobi/0").
Darin Petkov5c97ac52011-07-19 16:30:49 -070031 Modem(const std::string &owner,
32 const std::string &path,
33 ControlInterface *control_interface,
34 EventDispatcher *dispatcher,
35 Manager *manager);
36 ~Modem();
37
Darin Petkove0a312e2011-07-20 13:45:28 -070038 // Initializes support for the modem, possibly constructing a Cellular device.
39 void Init();
40
Darin Petkov5c97ac52011-07-19 16:30:49 -070041 private:
Darin Petkove0a312e2011-07-20 13:45:28 -070042 friend class ModemManagerTest;
43 friend class ModemTest;
44 FRIEND_TEST(ModemTest, CreateCellularDevice);
45 FRIEND_TEST(ModemTest, Init);
46
47 static const char kPropertyLinkName[];
48 static const char kPropertyIPMethod[];
49 static const char kPropertyType[];
50 static const char kPropertyUnlockRequired[];
51 static const char kPropertyUnlockRetries[];
52
Darin Petkov67d8ecf2011-07-26 16:03:30 -070053 // Creates and registers a Cellular device in |device_| based on
54 // ModemManager.Modem's |properties|. The device may not be created if the
55 // properties are invalid.
Darin Petkove0a312e2011-07-20 13:45:28 -070056 void CreateCellularDevice(const DBusPropertiesMap &properties);
57
58 // A proxy to the org.freedesktop.DBus.Properties interface used to obtain
59 // ModemManager.Modem properties and watch for property changes.
Darin Petkov5c97ac52011-07-19 16:30:49 -070060 scoped_ptr<DBusPropertiesProxyInterface> dbus_properties_proxy_;
61
Darin Petkove0a312e2011-07-20 13:45:28 -070062 const std::string owner_;
63 const std::string path_;
64
65 CellularRefPtr device_;
66
Darin Petkov67d8ecf2011-07-26 16:03:30 -070067 ScopedRunnableMethodFactory<Modem> task_factory_;
Darin Petkov5c97ac52011-07-19 16:30:49 -070068 ControlInterface *control_interface_;
69 EventDispatcher *dispatcher_;
70 Manager *manager_;
71
72 DISALLOW_COPY_AND_ASSIGN(Modem);
73};
74
75} // namespace shill
76
77#endif // SHILL_MODEM_