00001 /*************************************************************************** 00002 * Copyright (C) 2009 by Rick L. Vinyard, Jr. * 00003 * rvinyard@cs.nmsu.edu * 00004 * * 00005 * This file is part of the dbus-cxx library. * 00006 * * 00007 * The dbus-cxx library is free software; you can redistribute it and/or * 00008 * modify it under the terms of the GNU General Public License * 00009 * version 3 as published by the Free Software Foundation. * 00010 * * 00011 * The dbus-cxx library is distributed in the hope that it will be * 00012 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * 00013 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License * 00017 * along with this software. If not see <http://www.gnu.org/licenses/>. * 00018 ***************************************************************************/ 00019 #ifndef DBUSSIGNALRECEIVER_H 00020 #define DBUSSIGNALRECEIVER_H 00021 00022 #include <dbus-cxx/messagehandler.h> 00023 00024 namespace DBus 00025 { 00026 00043 class SignalReceiver : public MessageHandler 00044 { 00045 protected: 00046 SignalReceiver(const std::string& path, const std::string& interface, const std::string& member); 00047 00048 public: 00049 00050 typedef DBusCxxPointer<SignalReceiver> pointer; 00051 00052 typedef DBusCxxWeakPointer<SignalReceiver> weak_pointer; 00053 00054 static pointer create(const std::string& interface, const std::string& member); 00055 00056 static pointer create(const std::string& path, const std::string& interface, const std::string& member); 00057 00058 ~SignalReceiver(); 00059 00060 virtual HandlerResult handle_message( DBusCxxPointer<Connection>, Message::const_pointer ); 00061 00062 const std::string& sender(); 00063 00064 void set_sender(const std::string& s); 00065 00066 const std::string& interface(); 00067 00068 void set_interface(const std::string& s); 00069 00070 const std::string& member(); 00071 00072 void set_member(const std::string& s); 00073 00074 const std::string& path(); 00075 00076 void set_path(const std::string& s); 00077 00078 const std::string& destination(); 00079 00080 void set_destination(const std::string& s); 00081 00082 sigc::signal<void>& signal_sender_changed(); 00083 00084 sigc::signal<void>& signal_interface_changed(); 00085 00086 sigc::signal<void>& signal_member_changed(); 00087 00088 sigc::signal<void>& signal_path_changed(); 00089 00090 sigc::signal<void>& signal_destination_changed(); 00091 00092 const std::string& match_rule(); 00093 00094 bool matches(Message::const_pointer msg); 00095 00096 protected: 00097 00098 std::string m_sender; 00099 00100 std::string m_interface; 00101 00102 std::string m_member; 00103 00104 std::string m_path; 00105 00106 std::string m_destination; 00107 00108 sigc::signal<void> m_signal_sender_changed; 00109 00110 sigc::signal<void> m_signal_interface_changed; 00111 00112 sigc::signal<void> m_signal_member_changed; 00113 00114 sigc::signal<void> m_signal_path_changed; 00115 00116 sigc::signal<void> m_signal_destination_changed; 00117 00118 std::string m_match_rule; 00119 00120 }; 00121 00122 } 00123 00124 #endif