00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifdef HAVE_CONFIG_H
00025 #include <config.h>
00026 #endif
00027
00028 #include <dbus-c++/debug.h>
00029 #include <dbus-c++/property.h>
00030
00031 #include <dbus-c++/introspection.h>
00032
00033 using namespace DBus;
00034
00035 static const char *properties_name = "org.freedesktop.DBus.Properties";
00036
00037 PropertiesAdaptor::PropertiesAdaptor()
00038 : InterfaceAdaptor(properties_name)
00039 {
00040 register_method(PropertiesAdaptor, Get, Get);
00041 register_method(PropertiesAdaptor, Set, Set);
00042 }
00043
00044 Message PropertiesAdaptor::Get(const CallMessage &call)
00045 {
00046 MessageIter ri = call.reader();
00047
00048 std::string iface_name;
00049 std::string property_name;
00050
00051 ri >> iface_name >> property_name;
00052
00053 debug_log("requesting property %s on interface %s", property_name.c_str(), iface_name.c_str());
00054
00055 InterfaceAdaptor *interface = (InterfaceAdaptor *) find_interface(iface_name);
00056
00057 if (!interface)
00058 throw ErrorFailed("requested interface not found");
00059
00060 Variant *value = interface->get_property(property_name);
00061
00062 if (!value)
00063 throw ErrorFailed("requested property not found");
00064
00065 on_get_property(*interface, property_name, *value);
00066
00067 ReturnMessage reply(call);
00068
00069 MessageIter wi = reply.writer();
00070
00071 wi << *value;
00072 return reply;
00073 }
00074
00075 Message PropertiesAdaptor::Set(const CallMessage &call)
00076 {
00077 MessageIter ri = call.reader();
00078
00079 std::string iface_name;
00080 std::string property_name;
00081 Variant value;
00082
00083 ri >> iface_name >> property_name >> value;
00084
00085 InterfaceAdaptor *interface = (InterfaceAdaptor *) find_interface(iface_name);
00086
00087 if (!interface)
00088 throw ErrorFailed("requested interface not found");
00089
00090 on_set_property(*interface, property_name, value);
00091
00092 interface->set_property(property_name, value);
00093
00094 ReturnMessage reply(call);
00095
00096 return reply;
00097 }
00098
00099 IntrospectedInterface *PropertiesAdaptor::introspect() const
00100 {
00101 static IntrospectedArgument Get_args[] =
00102 {
00103 { "interface_name", "s", true },
00104 { "property_name", "s", true },
00105 { "value", "v", false },
00106 { 0, 0, 0 }
00107 };
00108 static IntrospectedArgument Set_args[] =
00109 {
00110 { "interface_name", "s", true },
00111 { "property_name", "s", true },
00112 { "value", "v", true },
00113 { 0, 0, 0 }
00114 };
00115 static IntrospectedMethod Properties_methods[] =
00116 {
00117 { "Get", Get_args },
00118 { "Set", Set_args },
00119 { 0, 0 }
00120 };
00121 static IntrospectedMethod Properties_signals[] =
00122 {
00123 { 0, 0 }
00124 };
00125 static IntrospectedProperty Properties_properties[] =
00126 {
00127 { 0, 0, 0, 0 }
00128 };
00129 static IntrospectedInterface Properties_interface =
00130 {
00131 properties_name,
00132 Properties_methods,
00133 Properties_signals,
00134 Properties_properties
00135 };
00136 return &Properties_interface;
00137 }
00138
00139 PropertiesProxy::PropertiesProxy()
00140 : InterfaceProxy(properties_name)
00141 {
00142 }
00143
00144 Variant PropertiesProxy::Get(const std::string &iface, const std::string &property)
00145 {
00146
00147 Variant v;
00148 return v;
00149 }
00150
00151 void PropertiesProxy::Set(const std::string &iface, const std::string &property, const Variant &value)
00152 {
00153
00154 }
00155