package obus
Pure Ocaml implementation of the D-Bus protocol
Install
Dune Dependency
Authors
Maintainers
Sources
obus-1.2.5.tar.gz
md5=81eb1034c6ef4421a2368a9b352199de
sha512=4b540497188a7d78f4f14f94c6b7fdff47dd06436a34e650ff378dd77bb3e2acb7afd45cd72daf4ddba06e732e9944d560c2882dc37862f1b1f1bb6df37e6205
doc/src/obus.hal/hal_device.ml.html
Source file hal_device.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
(* * hal_device.ml * ------------- * Copyright : (c) 2009, Jeremie Dimino <jeremie@dimino.org> * Licence : BSD3 * * This file is a part of obus, an ocaml implementation of D-Bus. *) open Lwt open OBus_value open Hal_interfaces include OBus_proxy.Private type udi = OBus_path.t let udi = OBus_proxy.path let computer () = let%lwt bus = OBus_bus.system () in return (OBus_proxy.make (OBus_peer.make bus "org.freedesktop.Hal") ["org"; "freedesktop"; "Hal"; "devices"; "computer"]) type property = | Pstring of string | Pstrlist of string list | Pint of int32 | Puint64 of int64 | Pbool of bool | Pdouble of float let property_of_variant = function | V.Basic(V.String s) -> Pstring s | V.Array(T.Basic T.String, _) as l -> Pstrlist(C.cast_single (C.array C.basic_string) l) | V.Basic(V.Int32 x) -> Pint x | V.Basic(V.Uint64 x) -> Puint64 x | V.Basic(V.Boolean x) -> Pbool x | V.Basic(V.Double x) -> Pdouble x | v -> Printf.ksprintf failwith "Hal_device.property_of_variant: invalid device property: %s" (V.string_of_single v) let variant_of_property = function | Pstring s -> V.basic_string s | Pstrlist l -> C.make_single (C.array C.basic_string) l | Pint x -> V.basic_int32 x | Puint64 x -> V.basic_uint64 x | Pbool x -> V.basic_boolean x | Pdouble x -> V.basic_double x open Org_freedesktop_Hal_Device let get_all_properties proxy = let%lwt l = OBus_method.call m_GetAllProperties proxy () in return (List.map (fun (name, value) -> (name, property_of_variant value)) l) let set_multiple_properties proxy properties = OBus_method.call m_SetMultipleProperties proxy (List.map (fun (name, property) -> (name, variant_of_property property)) properties) let get_property proxy key = OBus_method.call m_GetProperty proxy key >|= property_of_variant let get_property_string proxy key = OBus_method.call m_GetPropertyString proxy key let get_property_string_list proxy key = OBus_method.call m_GetPropertyStringList proxy key let get_property_integer proxy key = let%lwt value = OBus_method.call m_GetPropertyInteger proxy key in let value = Int32.to_int value in return value let get_property_boolean proxy key = OBus_method.call m_GetPropertyBoolean proxy key let get_property_double proxy key = OBus_method.call m_GetPropertyDouble proxy key let set_property proxy key value = OBus_method.call m_SetProperty proxy (key, variant_of_property value) let set_property_string proxy key value = OBus_method.call m_SetPropertyString proxy (key, value) let set_property_string_list proxy key value = OBus_method.call m_SetPropertyStringList proxy (key, value) let set_property_integer proxy key value = let value = Int32.of_int value in OBus_method.call m_SetPropertyInteger proxy (key, value) let set_property_boolean proxy key value = OBus_method.call m_SetPropertyBoolean proxy (key, value) let set_property_double proxy key value = OBus_method.call m_SetPropertyDouble proxy (key, value) let remove_property proxy key = OBus_method.call m_RemoveProperty proxy key let get_property_type proxy key = let%lwt typ = OBus_method.call m_GetPropertyType proxy key in let typ = Int32.to_int typ in return typ let property_exists proxy key = OBus_method.call m_PropertyExists proxy key let add_capability proxy capability = OBus_method.call m_AddCapability proxy capability let query_capability proxy capability = OBus_method.call m_QueryCapability proxy capability let lock proxy reason = OBus_method.call m_Lock proxy reason let unlock proxy = OBus_method.call m_Unlock proxy () let acquire_interface_lock proxy interface_name exclusive = OBus_method.call m_AcquireInterfaceLock proxy (interface_name, exclusive) let release_interface_lock proxy interface_name = OBus_method.call m_ReleaseInterfaceLock proxy interface_name let is_caller_locked_out proxy interface_name caller_sysbus_name = OBus_method.call m_IsCallerLockedOut proxy (interface_name, caller_sysbus_name) let is_caller_privileged proxy action caller_sysbus_name = OBus_method.call m_IsCallerPrivileged proxy (action, caller_sysbus_name) let is_locked_by_others proxy interface_name = OBus_method.call m_IsLockedByOthers proxy interface_name let string_list_append proxy key value = OBus_method.call m_StringListAppend proxy (key, value) let string_list_prepend proxy key value = OBus_method.call m_StringListPrepend proxy (key, value) let string_list_remove proxy key value = OBus_method.call m_StringListRemove proxy (key, value) let emit_condition proxy condition_name condition_details = OBus_method.call m_EmitCondition proxy (condition_name, condition_details) let rescan proxy = OBus_method.call m_Rescan proxy () let reprobe proxy = OBus_method.call m_Reprobe proxy () let claim_interface proxy interface_name introspection_xml = OBus_method.call m_ClaimInterface proxy (interface_name, introspection_xml) let addon_is_ready proxy = OBus_method.call m_AddonIsReady proxy () let property_modified proxy = OBus_signal.map (fun (num_updates, updates) -> let num_updates = Int32.to_int num_updates in (num_updates, updates)) (OBus_signal.make s_PropertyModified proxy) let condition proxy = OBus_signal.make s_Condition proxy let interface_lock_acquired proxy = OBus_signal.map (fun (interface_name, lock_holder, num_locks) -> let num_locks = Int32.to_int num_locks in (interface_name, lock_holder, num_locks)) (OBus_signal.make s_InterfaceLockAcquired proxy) let interface_lock_released proxy = OBus_signal.map (fun (interface_name, lock_holder, num_locks) -> let num_locks = Int32.to_int num_locks in (interface_name, lock_holder, num_locks)) (OBus_signal.make s_InterfaceLockReleased proxy) module Volume = struct open Org_freedesktop_Hal_Device_Volume let mount proxy mount_point fstype extra_options = let%lwt return_code = OBus_method.call m_Mount proxy (mount_point, fstype, extra_options) in let return_code = Int32.to_int return_code in return return_code let unmount proxy extra_options = let%lwt return_code = OBus_method.call m_Unmount proxy extra_options in let return_code = Int32.to_int return_code in return return_code let eject proxy extra_options = let%lwt return_code = OBus_method.call m_Eject proxy extra_options in let return_code = Int32.to_int return_code in return return_code end module Storage = struct open Org_freedesktop_Hal_Device_Storage let eject proxy extra_options = let%lwt return_code = OBus_method.call m_Eject proxy extra_options in let return_code = Int32.to_int return_code in return return_code let close_tray proxy extra_options = let%lwt return_code = OBus_method.call m_CloseTray proxy extra_options in let return_code = Int32.to_int return_code in return return_code end module Storage_removable = struct open Org_freedesktop_Hal_Device_Storage_Removable let check_for_media proxy = OBus_method.call m_CheckForMedia proxy () end module Wake_on_lan = struct open Org_freedesktop_Hal_Device_WakeOnLan let get_supported proxy = let%lwt return_code = OBus_method.call m_GetSupported proxy () in let return_code = Int32.to_int return_code in return return_code let get_enabled proxy = let%lwt return_code = OBus_method.call m_GetEnabled proxy () in let return_code = Int32.to_int return_code in return return_code let set_enabled proxy enable = let%lwt return_code = OBus_method.call m_SetEnabled proxy enable in let return_code = Int32.to_int return_code in return return_code end module System_power_management = struct open Org_freedesktop_Hal_Device_SystemPowerManagement let suspend proxy num_seconds_to_sleep = let num_seconds_to_sleep = Int32.of_int num_seconds_to_sleep in let%lwt return_code = OBus_method.call m_Suspend proxy num_seconds_to_sleep in let return_code = Int32.to_int return_code in return return_code let suspend_hybrid proxy num_seconds_to_sleep = let num_seconds_to_sleep = Int32.of_int num_seconds_to_sleep in let%lwt return_code = OBus_method.call m_SuspendHybrid proxy num_seconds_to_sleep in let return_code = Int32.to_int return_code in return return_code let hibernate proxy = let%lwt return_code = OBus_method.call m_Hibernate proxy () in let return_code = Int32.to_int return_code in return return_code let shutdown proxy = let%lwt return_code = OBus_method.call m_Shutdown proxy () in let return_code = Int32.to_int return_code in return return_code let reboot proxy = let%lwt return_code = OBus_method.call m_Reboot proxy () in let return_code = Int32.to_int return_code in return return_code let set_power_save proxy enable_power_save = let%lwt return_code = OBus_method.call m_SetPowerSave proxy enable_power_save in let return_code = Int32.to_int return_code in return return_code end module Cpufreq = struct open Org_freedesktop_Hal_Device_CPUFreq let set_cpufreq_governor proxy governor_string = OBus_method.call m_SetCPUFreqGovernor proxy governor_string let set_cpufreq_performance proxy value = let value = Int32.of_int value in OBus_method.call m_SetCPUFreqPerformance proxy value let set_cpufreq_consider_nice proxy value = OBus_method.call m_SetCPUFreqConsiderNice proxy value let get_cpufreq_governor proxy = OBus_method.call m_GetCPUFreqGovernor proxy () let get_cpufreq_performance proxy = let%lwt return_code = OBus_method.call m_GetCPUFreqPerformance proxy () in let return_code = Int32.to_int return_code in return return_code let get_cpufreq_consider_nice proxy = OBus_method.call m_GetCPUFreqConsiderNice proxy () let get_cpufreq_available_governors proxy = OBus_method.call m_GetCPUFreqAvailableGovernors proxy () end module Laptop_panel = struct open Org_freedesktop_Hal_Device_LaptopPanel let set_brightness proxy brightness_value = let brightness_value = Int32.of_int brightness_value in let%lwt return_code = OBus_method.call m_SetBrightness proxy brightness_value in let return_code = Int32.to_int return_code in return return_code let get_brightness proxy = let%lwt brightness_value = OBus_method.call m_GetBrightness proxy () in let brightness_value = Int32.to_int brightness_value in return brightness_value end module Kill_switch = struct open Org_freedesktop_Hal_Device_KillSwitch let set_power proxy value = let%lwt return_code = OBus_method.call m_SetPower proxy value in let return_code = Int32.to_int return_code in return return_code let get_power proxy = let%lwt value = OBus_method.call m_GetPower proxy () in let value = Int32.to_int value in return value end
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>