OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS 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_H_ | 5 #ifndef CHROMEOS_DBUS_H_ |
6 #define CHROMEOS_DBUS_H_ | 6 #define CHROMEOS_DBUS_H_ |
7 | 7 |
8 #include <dbus/dbus-glib.h> | 8 #include <dbus/dbus-glib.h> |
9 #include <glib-object.h> | 9 #include <glib-object.h> |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "chromeos/glib/object.h" | 15 #include "chromeos/glib/object.h" |
16 | 16 |
17 struct DBusMessage; | |
18 struct DBusConnection; | |
19 | |
17 namespace chromeos { | 20 namespace chromeos { |
18 | 21 |
19 // \precondition No functions in the dbus namespace can be called before | 22 // \precondition No functions in the dbus namespace can be called before |
20 // ::g_type_init(); | 23 // ::g_type_init(); |
21 | 24 |
22 namespace dbus { | 25 namespace dbus { |
23 | 26 |
24 // \brief BusConnection manages the ref-count for a ::DBusGConnection*. | 27 // \brief BusConnection manages the ref-count for a ::DBusGConnection*. |
25 // | 28 // |
26 // A BusConnection has reference semantics bound to a particular communication | 29 // A BusConnection has reference semantics bound to a particular communication |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 | 412 |
410 BusConnection GetPrivateBusConnection(const char* address); | 413 BusConnection GetPrivateBusConnection(const char* address); |
411 | 414 |
412 // \brief Sends a signal named |signal_name| with no arguments to the | 415 // \brief Sends a signal named |signal_name| with no arguments to the |
413 // system bus per the given |path| and |interface_name|. | 416 // system bus per the given |path| and |interface_name|. |
414 | 417 |
415 void SendSignalWithNoArgumentsToSystemBus(const char* path, | 418 void SendSignalWithNoArgumentsToSystemBus(const char* path, |
416 const char* interface_name, | 419 const char* interface_name, |
417 const char* signal_name); | 420 const char* signal_name); |
418 | 421 |
422 // \brief Low-level signal monitor base class. | |
423 // | |
424 // Used when there is no definite named signal sender (that Proxy | |
425 // could be used for). | |
426 | |
427 class SignalWatcher { | |
428 public: | |
429 SignalWatcher() : interface_(NULL), signal_(NULL) {} | |
430 ~SignalWatcher(); | |
431 void StartMonitoring(const char* interface, const char* signal); | |
432 private: | |
433 | |
434 // Callback invoked on the given signal arrival. | |
435 virtual void OnSignal(DBusMessage* message) = 0; | |
436 | |
437 // Returns a string matching the D-Bus messages that we want to listen for. | |
438 std::string GetDBusMatchString() const; | |
439 | |
440 // A D-Bus message filter to receive signals. | |
441 static DBusHandlerResult FilterDBusMessage(DBusConnection* dbus_conn, | |
442 DBusMessage* message, | |
443 void* data); | |
444 const char* interface_; | |
Daniel Erat
2011/02/11 18:31:45
use std::string instead for these so you don't cra
glotov
2011/02/11 18:55:49
Done.
| |
445 const char* signal_; | |
446 }; | |
447 | |
419 } // namespace dbus | 448 } // namespace dbus |
420 } // namespace chromeos | 449 } // namespace chromeos |
421 | 450 |
422 #endif // CHROMEOS_DBUS_H_ | 451 #endif // CHROMEOS_DBUS_H_ |
OLD | NEW |