OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_SMS_WATCHER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_SMS_WATCHER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_CROS_SMS_WATCHER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CROS_SMS_WATCHER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "chrome/browser/chromeos/cros/cros_network_functions.h" | 12 #include "chrome/browser/chromeos/cros/cros_network_functions.h" |
13 #include "chromeos/dbus/dbus_method_call_status.h" | 13 #include "chromeos/dbus/dbus_method_call_status.h" |
14 #include "dbus/object_path.h" | 14 #include "dbus/object_path.h" |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 | 17 |
18 class DictionaryValue; | 18 class DictionaryValue; |
19 class ListValue; | |
20 | 19 |
21 } // namespace base | 20 } // namespace base |
22 | 21 |
23 namespace chromeos { | 22 namespace chromeos { |
24 | 23 |
25 // Class to watch sms without Libcros. | 24 // Class to watch sms without Libcros. |
26 class SMSWatcher : public CrosNetworkWatcher { | 25 class SMSWatcher : public CrosNetworkWatcher { |
27 public: | 26 public: |
28 // Dictionary key constants. | 27 // Dictionary key constants. |
29 static const char kNumberKey[]; | 28 static const char kNumberKey[]; |
30 static const char kTextKey[]; | 29 static const char kTextKey[]; |
31 static const char kTimestampKey[]; | 30 static const char kTimestampKey[]; |
32 static const char kSmscKey[]; | 31 static const char kSmscKey[]; |
33 static const char kValidityKey[]; | 32 static const char kValidityKey[]; |
34 static const char kClassKey[]; | 33 static const char kClassKey[]; |
35 static const char kIndexKey[]; | 34 static const char kIndexKey[]; |
36 | 35 |
| 36 static const char kModemManager1NumberKey[]; |
| 37 static const char kModemManager1TextKey[]; |
| 38 static const char kModemManager1TimestampKey[]; |
| 39 static const char kModemManager1SmscKey[]; |
| 40 static const char kModemManager1ValidityKey[]; |
| 41 static const char kModemManager1ClassKey[]; |
| 42 static const char kModemManager1IndexKey[]; |
| 43 |
| 44 // Base class of watcher implementation classes. Public to allow |
| 45 // derived classes in the anonymous namespace to inherit from it. |
| 46 class WatcherBase; |
| 47 |
37 SMSWatcher(const std::string& modem_device_path, | 48 SMSWatcher(const std::string& modem_device_path, |
38 MonitorSMSCallback callback, | 49 MonitorSMSCallback callback, |
39 void* object); | 50 void* object); |
40 virtual ~SMSWatcher(); | 51 virtual ~SMSWatcher(); |
41 | 52 |
42 private: | 53 private: |
43 // Callback for flimflam device's GetProperties() method. | 54 // Callback for flimflam device's GetProperties() method. |
44 void DevicePropertiesCallback(DBusMethodCallStatus call_status, | 55 void DevicePropertiesCallback(DBusMethodCallStatus call_status, |
45 const base::DictionaryValue& properties); | 56 const base::DictionaryValue& properties); |
46 | 57 |
47 // Callback for SmsReceived signal. | |
48 void OnSmsReceived(uint32 index, bool complete); | |
49 | |
50 // Runs |callback_| with a SMS. | |
51 void RunCallbackWithSMS(const base::DictionaryValue& sms_dictionary); | |
52 | |
53 // Callback for Get() method. | |
54 void GetSMSCallback(uint32 index, | |
55 const base::DictionaryValue& sms_dictionary); | |
56 | |
57 // Callback for List() method. | |
58 void ListSMSCallback(const base::ListValue& result); | |
59 | |
60 // Deletes SMSs in the queue. | |
61 void DeleteSMSInChain(); | |
62 | |
63 base::WeakPtrFactory<SMSWatcher> weak_ptr_factory_; | 58 base::WeakPtrFactory<SMSWatcher> weak_ptr_factory_; |
64 std::string device_path_; | 59 std::string device_path_; |
65 MonitorSMSCallback callback_; | 60 MonitorSMSCallback callback_; |
66 void* object_; | 61 void* object_; |
67 std::string dbus_connection_; | 62 scoped_ptr<WatcherBase> watcher_; |
68 dbus::ObjectPath object_path_; | 63 |
69 std::vector<uint32> delete_queue_; | 64 DISALLOW_COPY_AND_ASSIGN(SMSWatcher); |
70 }; | 65 }; |
71 | 66 |
72 } // namespace | 67 } // namespace |
73 | 68 |
74 #endif // CHROME_BROWSER_CHROMEOS_CROS_SMS_WATCHER_H_ | 69 #endif // CHROME_BROWSER_CHROMEOS_CROS_SMS_WATCHER_H_ |
OLD | NEW |