QT绑定D-Bus程序实例
?
参考自:
http://laurii.info/articles/2007/03/22/dbus-and-qt-programmin
?
http://blog.chinaunix.net/u2/69889/showart_2316513.html
?
?
根据第二个BLOG,我改动了部分代码,使用dbus interface调用方式,一步一步建立C/S结构代码:
[socol@localhost testdbus]$ ll
client
hotelibs
service
?
1. 建立库函数hotelibs
[socol@localhost testdbus]$ cd hotelibs
[socol@localhost hotelibs]$ ll
hotel.pro
hotel.cpp
hotel.h
[socol@localhost hotelibs]$cat hotel.h
qdbuscpp2xml -A hotel.h -o com.test.hotel.xml[socol@localhost hotelibs]$ qdbusxml2cpp com.test.hotel.xml?-i hotel.h -p hotelInterface
[socol@localhost hotelibs]$ll
com.test.hotel.xml
hotel.cpp
hotel.h
hotelibs.pro
hotelInterface.cpp
hotelInterface.h[socol@localhost hotelibs]$cat com.test.hotel.xml
?
[socol@localhost hotelibs]$cat hotelibs.pro?[socol@localhost client]$cat hotelclient.pro
QT += dbusQT -= guiTARGET = hotelclientCONFIG += consoleCONFIG -= app_bundleTEMPLATE = appLIBS += -L../hotelibs -lhotelibsINCLUDEPATH += ../hotelibsSOURCES += main.cpp?
4.测试
[socol@localhost client]$d-feet
// select query() execut, result 10
[socol@localhost client]$./hotelclient
Got 1 room
[socol@localhost client]$d-feet
// select query() execut, result 9