signal_emitter_c.cpp
- Signal emission with the dbus C API signal_emitter_raw.cpp
- Signal emission with a manually created message signal_emitter.cpp
- Signal emission with a DBus::signal signal_emitter_2.cpp
- Signal emission with a DBus::signal and a local connection as well signal_emitter_3.cpp
- Dispatched signal emission and a local connection signal_emitter_object.cpp
- Signal emission with a DBus::Object derived class signal_receiver_c.cpp
- Signal handling with the dbus C API signal_receiver_raw.cpp
- Signal handling with a manual loop similar to the C API example signal_receiver.cpp
- Signal handling with a dispatcher and raw DBus signal demarshalling signal_receiver_2.cpp
- Signal handling with a dispatcher and automatic demarshalling signal_receiver_object.cpp
- Signal handling with a DBus::ObjectProxy derived class Here is this example:
/*************************************************************************** * Copyright (C) 2007,2008,2009 by Rick L. Vinyard, Jr. * * rvinyard@cs.nmsu.edu * * * * This file is part of the dbus-cxx library. * * * * The dbus-cxx library is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * * version 3 as published by the Free Software Foundation. * * * * The dbus-cxx library is distributed in the hope that it will be * * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this software. If not see <http://www.gnu.org/licenses/>. * ***************************************************************************/ #include <dbus-cxx.h> #include <stdio.h> #include <unistd.h> void callback(std::string); int main() { int ret; DBus::init(); DBus::Dispatcher dispatcher; DBus::Connection::pointer connection = dispatcher.create_connection( DBus::BUS_SESSION ); DBus::signal<void,std::string>::pointer signal = connection->create_signal<void,std::string>("/test/signal/Object", "test.signal.Type", "Test"); dispatcher.start(); const char* sigvalue1 = "Hello"; std::string sigvalue2("World"); signal->connect( sigc::ptr_fun(callback) ); signal->emit( sigvalue1 ); signal->emit( sigvalue2 ); usleep(250000); dispatcher.stop(); return 0; } void callback(std::string s) { std::cout << "signal-emitter-2 callback: " << s << std::endl; }