blob: 110d8f76245edfc2fb0ffa7e86b568c2f63c57f9 [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 Petkove0a312e2011-07-20 13:45:28 -070012#include <gtest/gtest_prod.h> // for FRIEND_TEST
13
14#include "shill/dbus_properties_proxy_interface.h"
15#include "shill/refptr_types.h"
Darin Petkov5c97ac52011-07-19 16:30:49 -070016
17namespace shill {
18
19class ControlInterface;
Darin Petkov5c97ac52011-07-19 16:30:49 -070020class EventDispatcher;
21class Manager;
22
Darin Petkove0a312e2011-07-20 13:45:28 -070023// Handles an instance of ModemManager.Modem and an instance of a Cellular
24// device.
Darin Petkov5c97ac52011-07-19 16:30:49 -070025class Modem {
26 public:
Darin Petkove0a312e2011-07-20 13:45:28 -070027 // |owner| is the ModemManager DBus service owner (e.g., ":1.17"). |path| is
28 // the ModemManager.Modem DBus object path (e.g.,
29 // "/org/chromium/ModemManager/Gobi/0").
Darin Petkov5c97ac52011-07-19 16:30:49 -070030 Modem(const std::string &owner,
31 const std::string &path,
32 ControlInterface *control_interface,
33 EventDispatcher *dispatcher,
34 Manager *manager);
35 ~Modem();
36
Darin Petkove0a312e2011-07-20 13:45:28 -070037 // Initializes support for the modem, possibly constructing a Cellular device.
38 void Init();
39
Darin Petkov5c97ac52011-07-19 16:30:49 -070040 private:
Darin Petkove0a312e2011-07-20 13:45:28 -070041 friend class ModemManagerTest;
42 friend class ModemTest;
43 FRIEND_TEST(ModemTest, CreateCellularDevice);
44 FRIEND_TEST(ModemTest, Init);
45
46 static const char kPropertyLinkName[];
47 static const char kPropertyIPMethod[];
48 static const char kPropertyType[];
49 static const char kPropertyUnlockRequired[];
50 static const char kPropertyUnlockRetries[];
51
52 void CreateCellularDevice(const DBusPropertiesMap &properties);
53
54 // A proxy to the org.freedesktop.DBus.Properties interface used to obtain
55 // ModemManager.Modem properties and watch for property changes.
Darin Petkov5c97ac52011-07-19 16:30:49 -070056 scoped_ptr<DBusPropertiesProxyInterface> dbus_properties_proxy_;
57
Darin Petkove0a312e2011-07-20 13:45:28 -070058 const std::string owner_;
59 const std::string path_;
60
61 CellularRefPtr device_;
62
Darin Petkov5c97ac52011-07-19 16:30:49 -070063 ControlInterface *control_interface_;
64 EventDispatcher *dispatcher_;
65 Manager *manager_;
66
67 DISALLOW_COPY_AND_ASSIGN(Modem);
68};
69
70} // namespace shill
71
72#endif // SHILL_MODEM_