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