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 CHROMEOS_DBUS_GSM_SMS_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_GSM_SMS_CLIENT_H_ |
6 #define CHROMEOS_DBUS_GSM_SMS_CLIENT_H_ | 6 #define CHROMEOS_DBUS_GSM_SMS_CLIENT_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <string> | 10 #include <string> |
9 | 11 |
10 #include "base/basictypes.h" | |
11 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" |
12 #include "chromeos/chromeos_export.h" | 14 #include "chromeos/chromeos_export.h" |
13 #include "chromeos/dbus/dbus_client.h" | 15 #include "chromeos/dbus/dbus_client.h" |
14 | 16 |
15 namespace base { | 17 namespace base { |
16 class DictionaryValue; | 18 class DictionaryValue; |
17 class ListValue; | 19 class ListValue; |
18 } | 20 } |
19 | 21 |
20 namespace dbus { | 22 namespace dbus { |
21 class ObjectPath; | 23 class ObjectPath; |
22 } | 24 } |
23 | 25 |
24 namespace chromeos { | 26 namespace chromeos { |
25 | 27 |
26 // GsmSMSClient is used to communicate with the | 28 // GsmSMSClient is used to communicate with the |
27 // org.freedesktop.ModemManager.Modem.Gsm.SMS service. | 29 // org.freedesktop.ModemManager.Modem.Gsm.SMS service. |
28 // All methods should be called from the origin thread (UI thread) which | 30 // All methods should be called from the origin thread (UI thread) which |
29 // initializes the DBusThreadManager instance. | 31 // initializes the DBusThreadManager instance. |
30 class CHROMEOS_EXPORT GsmSMSClient : public DBusClient { | 32 class CHROMEOS_EXPORT GsmSMSClient : public DBusClient { |
31 public: | 33 public: |
32 typedef base::Callback<void(uint32 index, bool complete)> SmsReceivedHandler; | 34 typedef base::Callback<void(uint32_t index, bool complete)> |
| 35 SmsReceivedHandler; |
33 typedef base::Callback<void()> DeleteCallback; | 36 typedef base::Callback<void()> DeleteCallback; |
34 typedef base::Callback<void(const base::DictionaryValue& sms)> GetCallback; | 37 typedef base::Callback<void(const base::DictionaryValue& sms)> GetCallback; |
35 typedef base::Callback<void(const base::ListValue& result)> ListCallback; | 38 typedef base::Callback<void(const base::ListValue& result)> ListCallback; |
36 | 39 |
37 ~GsmSMSClient() override; | 40 ~GsmSMSClient() override; |
38 | 41 |
39 // Factory function, creates a new instance and returns ownership. | 42 // Factory function, creates a new instance and returns ownership. |
40 // For normal usage, access the singleton via DBusThreadManager::Get(). | 43 // For normal usage, access the singleton via DBusThreadManager::Get(). |
41 static GsmSMSClient* Create(); | 44 static GsmSMSClient* Create(); |
42 | 45 |
43 // Sets SmsReceived signal handler. | 46 // Sets SmsReceived signal handler. |
44 virtual void SetSmsReceivedHandler(const std::string& service_name, | 47 virtual void SetSmsReceivedHandler(const std::string& service_name, |
45 const dbus::ObjectPath& object_path, | 48 const dbus::ObjectPath& object_path, |
46 const SmsReceivedHandler& handler) = 0; | 49 const SmsReceivedHandler& handler) = 0; |
47 | 50 |
48 // Resets SmsReceived signal handler. | 51 // Resets SmsReceived signal handler. |
49 virtual void ResetSmsReceivedHandler(const std::string& service_name, | 52 virtual void ResetSmsReceivedHandler(const std::string& service_name, |
50 const dbus::ObjectPath& object_path) = 0; | 53 const dbus::ObjectPath& object_path) = 0; |
51 | 54 |
52 // Calls Delete method. |callback| is called after the method call succeeds. | 55 // Calls Delete method. |callback| is called after the method call succeeds. |
53 virtual void Delete(const std::string& service_name, | 56 virtual void Delete(const std::string& service_name, |
54 const dbus::ObjectPath& object_path, | 57 const dbus::ObjectPath& object_path, |
55 uint32 index, | 58 uint32_t index, |
56 const DeleteCallback& callback) = 0; | 59 const DeleteCallback& callback) = 0; |
57 | 60 |
58 // Calls Get method. |callback| is called after the method call succeeds. | 61 // Calls Get method. |callback| is called after the method call succeeds. |
59 virtual void Get(const std::string& service_name, | 62 virtual void Get(const std::string& service_name, |
60 const dbus::ObjectPath& object_path, | 63 const dbus::ObjectPath& object_path, |
61 uint32 index, | 64 uint32_t index, |
62 const GetCallback& callback) = 0; | 65 const GetCallback& callback) = 0; |
63 | 66 |
64 // Calls List method. |callback| is called after the method call succeeds. | 67 // Calls List method. |callback| is called after the method call succeeds. |
65 virtual void List(const std::string& service_name, | 68 virtual void List(const std::string& service_name, |
66 const dbus::ObjectPath& object_path, | 69 const dbus::ObjectPath& object_path, |
67 const ListCallback& callback) = 0; | 70 const ListCallback& callback) = 0; |
68 | 71 |
69 // Requests a check for new messages. In shill this does nothing. The | 72 // Requests a check for new messages. In shill this does nothing. The |
70 // stub implementation uses it to generate a sequence of test messages. | 73 // stub implementation uses it to generate a sequence of test messages. |
71 virtual void RequestUpdate(const std::string& service_name, | 74 virtual void RequestUpdate(const std::string& service_name, |
72 const dbus::ObjectPath& object_path) = 0; | 75 const dbus::ObjectPath& object_path) = 0; |
73 | 76 |
74 protected: | 77 protected: |
75 friend class GsmSMSClientTest; | 78 friend class GsmSMSClientTest; |
76 | 79 |
77 // Create() should be used instead. | 80 // Create() should be used instead. |
78 GsmSMSClient(); | 81 GsmSMSClient(); |
79 | 82 |
80 private: | 83 private: |
81 DISALLOW_COPY_AND_ASSIGN(GsmSMSClient); | 84 DISALLOW_COPY_AND_ASSIGN(GsmSMSClient); |
82 }; | 85 }; |
83 | 86 |
84 } // namespace chromeos | 87 } // namespace chromeos |
85 | 88 |
86 #endif // CHROMEOS_DBUS_GSM_SMS_CLIENT_H_ | 89 #endif // CHROMEOS_DBUS_GSM_SMS_CLIENT_H_ |
OLD | NEW |