Package thirdparty :: Package conduit :: Module pysyncml
[hide private]
[frames] | no frames]

Source Code for Module thirdparty.conduit.pysyncml

  1  from ctypes import * 
  2   
  3  lib = CDLL('libsyncml.so.2') 
  4  #lib = CDLL('/usr/lib/libsyncml.so') 
  5  libc = CDLL('libc.so.6') 
6 7 -def instancemethod(method):
8 def _(self, *args, **kwargs): 9 return method(self, *args, **kwargs)
10 return _ 11
12 -class DataStore(c_void_p):
13 14 new = staticmethod(lib.smlDevInfDataStoreNew) 15 get_source_ref = instancemethod(lib.smlDevInfDataStoreGetSourceRef) 16 set_source_ref = instancemethod(lib.smlDevInfDataStoreSetSourceRef) 17 source_ref = property(fget=get_source_ref, fset=set_source_ref) 18 get_display_name = instancemethod(lib.smlDevInfDataStoreGetDisplayName) 19 set_display_name = instancemethod(lib.smlDevInfDataStoreSetDisplayName) 20 display_name = property(fget=get_display_name, fset=set_display_name) 21 get_max_guid_size = instancemethod(lib.smlDevInfGetMaxGUIDSize) 22 set_max_guid_size = instancemethod(lib.smlDevInfSetMaxGUIDSize) 23 max_guid_size = property(fget=get_max_guid_size, fset=set_max_guid_size)
24
25 26 -class Info(c_void_p):
27 28 new = staticmethod(lib.smlDevInfNew) 29 add_datastore = instancemethod(lib.smlDevInfAddDataStore) 30 num_datastores = instancemethod(lib.smlDevInfNumDataStores) 31 get_nth_datastore = instancemethod(lib.smlDevInfGetNthDataStore) 32 get_manufacturer = instancemethod(lib.smlDevInfGetManufacturer) 33 set_manufacturer = instancemethod(lib.smlDevInfSetManufacturer) 34 manufacturer = property(fget=get_manufacturer, fset=set_manufacturer) 35 get_model = instancemethod(lib.smlDevInfGetModel) 36 set_model = instancemethod(lib.smlDevInfSetModel) 37 model = property(fget=get_model, fset=set_model) 38 get_oem = instancemethod(lib.smlDevInfGetOEM) 39 set_oem = instancemethod(lib.smlDevInfSetOEM) 40 oem = property(fget=get_oem, fset=set_oem) 41 get_firmware_version = instancemethod(lib.smlDevInfGetFirmwareVersion) 42 set_firmware_version = instancemethod(lib.smlDevInfSetFirmwareVersion) 43 firmware_version = property(fget=get_firmware_version, fset=set_firmware_version) 44 get_software_version = instancemethod(lib.smlDevInfGetSoftwareVersion) 45 set_software_version = instancemethod(lib.smlDevInfSetSoftwareVersion) 46 software_version = property(fget=get_software_version, fset=set_software_version) 47 get_hardware_version = instancemethod(lib.smlDevInfGetHardwareVersion) 48 set_hardware_version = instancemethod(lib.smlDevInfSetHardwareVersion) 49 hardware_version = property(fget=get_hardware_version, fset=set_hardware_version) 50 get_device_id = instancemethod(lib.smlDevInfGetDeviceID) 51 set_device_id = instancemethod(lib.smlDevInfSetDeviceID) 52 device_id = property(fget=get_device_id, fset=set_device_id) 53 get_device_type = instancemethod(lib.smlDevInfGetDeviceType) 54 set_device_type = instancemethod(lib.smlDevInfSetDeviceType) 55 device_type = property(fget=get_device_type, fset=set_device_type) 56 get_supports_utc = instancemethod(lib.smlDevInfSupportsUTC) 57 set_supports_utc = instancemethod(lib.smlDevInfSetSupportsUTC) 58 supports_utc = property(fget=get_supports_utc, fset=set_supports_utc) 59 get_supports_large_objs = instancemethod(lib.smlDevInfSupportsLargeObjs) 60 set_supports_large_objs = instancemethod(lib.smlDevInfSetSupportsLargeObjs) 61 supports_large_objs = property(fget=get_supports_large_objs, fset=set_supports_large_objs) 62 get_supports_num_changes = instancemethod(lib.smlDevInfSupportsNumberOfChanges) 63 set_supports_num_changes = instancemethod(lib.smlDevInfSetSupportsNumberOfChanges) 64 supports_num_changes = property(fget=get_supports_num_changes, fset=set_supports_num_changes)
65
66 67 -class SyncObject(c_void_p):
68 69 unref = lib.smlDataSyncObjectUnref 70 new = staticmethod(lib.smlDataSyncNew) 71 set_option = instancemethod(lib.smlDataSyncSetOption) 72 add_datastore = instancemethod(lib.smlDataSyncAddDatastore) 73 init = instancemethod(lib.smlDataSyncInit) 74 run = instancemethod(lib.smlDataSyncRun) 75 add_change = instancemethod(lib.smlDataSyncAddChange) 76 send_changes = instancemethod(lib.smlDataSyncSendChanges) 77 add_mapping = instancemethod(lib.smlDataSyncAddMapping) 78 get_target = instancemethod(lib.smlDataSyncGetTarget) 79 80 register_event_callback = instancemethod(lib.smlDataSyncRegisterEventCallback) 81 register_get_alert_type_callback = instancemethod(lib.smlDataSyncRegisterGetAlertTypeCallback) 82 register_change_callback = instancemethod(lib.smlDataSyncRegisterChangeCallback) 83 register_get_anchor_callback = instancemethod(lib.smlDataSyncRegisterGetAnchorCallback) 84 register_set_anchor_callback = instancemethod(lib.smlDataSyncRegisterSetAnchorCallback) 85 register_write_devinf_callback = instancemethod(lib.smlDataSyncRegisterWriteDevInfCallback) 86 register_read_devinf_callback = instancemethod(lib.smlDataSyncRegisterReadDevInfCallback) 87 register_handle_remote_devinf_callback = instancemethod(lib.smlDataSyncRegisterHandleRemoteDevInfCallback) 88 register_change_status_callback = instancemethod(lib.smlDataSyncRegisterChangeStatusCallback)
89
90 91 -class Location(c_void_p):
92 93 new = staticmethod(lib.smlLocationNew) 94 get_uri = instancemethod(lib.smlLocationGetURI) 95 get_name = instancemethod(lib.smlLocationGetName) 96 set_name = instancemethod(lib.smlLocationSetName)
97
98 99 -class Error(c_void_p):
100 101 @property
102 - def message(self):
103 return lib.smlErrorPrint(byref(self))
104 105 unref = lib.smlErrorDeref
106 107 108 g_thread_init = lib.g_thread_init 109 EventCallback = CFUNCTYPE(None, SyncObject, c_int, c_void_p, Error) 110 GetAlertTypeCallback = CFUNCTYPE(c_int, SyncObject, c_char_p, c_int, c_void_p, POINTER(Error)) 111 ChangeCallback = CFUNCTYPE(c_int, SyncObject, c_char_p, c_int, c_char_p, c_char_p, c_uint, c_void_p, POINTER(Error)) 112 ChangeStatusCallback = CFUNCTYPE(c_int, SyncObject, c_uint, c_char_p, c_char_p, POINTER(Error)) 113 GetAnchorCallback = CFUNCTYPE(c_void_p, SyncObject, c_char_p, c_void_p, POINTER(Error)) 114 SetAnchorCallback = CFUNCTYPE(c_int, SyncObject, c_char_p, c_char_p, c_void_p, POINTER(Error)) 115 WriteDevInfCallback = CFUNCTYPE(c_int, SyncObject, Info, c_void_p, POINTER(Error)) 116 ReadDevInfCallback = CFUNCTYPE(Info, SyncObject, c_char_p, c_void_p, POINTER(Error)) 117 HandleRemoteDevInfCallback = CFUNCTYPE(c_int, SyncObject, Info, c_void_p, POINTER(Error)) 118 lib.smlDevInfDataStoreNew.argtypes = [c_char_p, POINTER(Error)] 119 lib.smlDevInfDataStoreNew.restype = DataStore 120 121 lib.smlDevInfDataStoreGetSourceRef.argtypes = [] 122 lib.smlDevInfDataStoreGetSourceRef.restype = c_char_p 123 124 lib.smlDevInfDataStoreGetDisplayName.argtypes = [] 125 lib.smlDevInfDataStoreGetDisplayName.restype = c_char_p 126 127 lib.smlDevInfGetMaxGUIDSize.argtypes = [] 128 lib.smlDevInfGetMaxGUIDSize.restype = c_char_p 129 130 lib.smlDevInfNew.argtypes = [c_char_p, c_int, POINTER(Error)] 131 lib.smlDevInfNew.restype = Info 132 133 lib.smlDevInfAddDataStore.argtypes = [Info, DataStore] 134 lib.smlDevInfAddDataStore.restype = None 135 136 lib.smlDevInfNumDataStores.argtypes = [Info] 137 lib.smlDevInfNumDataStores.restype = c_uint 138 139 lib.smlDevInfGetNthDataStore.argtypes = [Info, c_uint] 140 lib.smlDevInfGetNthDataStore.restype = DataStore 141 142 lib.smlDevInfGetManufacturer.argtypes = [] 143 lib.smlDevInfGetManufacturer.restype = c_char_p 144 145 lib.smlDevInfGetModel.argtypes = [] 146 lib.smlDevInfGetModel.restype = c_char_p 147 148 lib.smlDevInfGetOEM.argtypes = [] 149 lib.smlDevInfGetOEM.restype = c_char_p 150 151 lib.smlDevInfGetFirmwareVersion.argtypes = [] 152 lib.smlDevInfGetFirmwareVersion.restype = c_char_p 153 154 lib.smlDevInfGetSoftwareVersion.argtypes = [] 155 lib.smlDevInfGetSoftwareVersion.restype = c_char_p 156 157 lib.smlDevInfGetHardwareVersion.argtypes = [] 158 lib.smlDevInfGetHardwareVersion.restype = c_char_p 159 160 lib.smlDevInfGetDeviceID.argtypes = [] 161 lib.smlDevInfGetDeviceID.restype = c_char_p 162 163 lib.smlDevInfGetDeviceType.argtypes = [] 164 lib.smlDevInfGetDeviceType.restype = c_int 165 166 lib.smlDevInfSupportsUTC.argtypes = [] 167 lib.smlDevInfSupportsUTC.restype = c_int 168 169 lib.smlDevInfSupportsLargeObjs.argtypes = [] 170 lib.smlDevInfSupportsLargeObjs.restype = c_int 171 172 lib.smlDevInfSupportsNumberOfChanges.argtypes = [] 173 lib.smlDevInfSupportsNumberOfChanges.restype = c_int 174 175 lib.smlDataSyncObjectUnref.argtypes = [POINTER(SyncObject)] 176 lib.smlDataSyncObjectUnref.restype = None 177 178 lib.smlDataSyncNew.argtypes = [c_int, c_int, POINTER(Error)] 179 lib.smlDataSyncNew.restype = SyncObject 180 181 lib.smlDataSyncSetOption.argtypes = [SyncObject, c_char_p, c_char_p, POINTER(Error)] 182 lib.smlDataSyncSetOption.restype = c_int 183 184 lib.smlDataSyncAddDatastore.argtypes = [SyncObject, c_char_p, c_char_p, c_char_p, POINTER(Error)] 185 lib.smlDataSyncAddDatastore.restype = c_int 186 187 lib.smlDataSyncInit.argtypes = [SyncObject, POINTER(Error)] 188 lib.smlDataSyncInit.restype = c_int 189 190 lib.smlDataSyncRun.argtypes = [SyncObject, POINTER(Error)] 191 lib.smlDataSyncRun.restype = c_int 192 193 lib.smlDataSyncAddChange.argtypes = [SyncObject, c_char_p, c_int, c_char_p, c_char_p, c_uint, c_void_p, POINTER(Error)] 194 lib.smlDataSyncAddChange.restype = c_int 195 196 lib.smlDataSyncSendChanges.argtypes = [SyncObject, POINTER(Error)] 197 lib.smlDataSyncSendChanges.restype = c_int 198 199 lib.smlDataSyncAddMapping.argtypes = [SyncObject, c_char_p, c_char_p, c_char_p, POINTER(Error)] 200 lib.smlDataSyncAddMapping.restype = c_int 201 202 lib.smlDataSyncGetTarget.argtypes = [SyncObject, POINTER(Error)] 203 lib.smlDataSyncGetTarget.restype = Location 204 205 lib.smlDataSyncRegisterEventCallback.argtypes = [SyncObject, EventCallback] 206 lib.smlDataSyncRegisterEventCallback.restype = None 207 208 lib.smlDataSyncRegisterGetAlertTypeCallback.argtypes = [SyncObject, GetAlertTypeCallback] 209 lib.smlDataSyncRegisterGetAlertTypeCallback.restype = None 210 211 lib.smlDataSyncRegisterChangeCallback.argtypes = [SyncObject, ChangeCallback] 212 lib.smlDataSyncRegisterChangeCallback.restype = None 213 214 lib.smlDataSyncRegisterGetAnchorCallback.argtypes = [SyncObject, GetAnchorCallback] 215 lib.smlDataSyncRegisterGetAnchorCallback.restype = None 216 217 lib.smlDataSyncRegisterSetAnchorCallback.argtypes = [SyncObject, SetAnchorCallback] 218 lib.smlDataSyncRegisterSetAnchorCallback.restype = None 219 220 lib.smlDataSyncRegisterWriteDevInfCallback.argtypes = [SyncObject, WriteDevInfCallback] 221 lib.smlDataSyncRegisterWriteDevInfCallback.restype = None 222 223 lib.smlDataSyncRegisterReadDevInfCallback.argtypes = [SyncObject, ReadDevInfCallback] 224 lib.smlDataSyncRegisterReadDevInfCallback.restype = None 225 226 lib.smlDataSyncRegisterHandleRemoteDevInfCallback.argtypes = [SyncObject, HandleRemoteDevInfCallback] 227 lib.smlDataSyncRegisterHandleRemoteDevInfCallback.restype = None 228 229 lib.smlDataSyncRegisterChangeStatusCallback.argtypes = [SyncObject, ChangeStatusCallback] 230 lib.smlDataSyncRegisterChangeStatusCallback.restype = None 231 232 lib.smlLocationNew.argtypes = [c_char_p, c_char_p, POINTER(Error)] 233 lib.smlLocationNew.restype = Location 234 235 lib.smlLocationGetURI.argtypes = [Location] 236 lib.smlLocationGetURI.restype = c_char_p 237 238 lib.smlLocationGetName.argtypes = [Location] 239 lib.smlLocationGetName.restype = c_char_p 240 241 lib.smlLocationSetName.argtypes = [Location, c_char_p] 242 lib.smlLocationSetName.restype = None 243 244 lib.smlErrorDeref.argtypes = [POINTER(Error)] 245 lib.smlErrorDeref.restype = None 246 247 lib.smlErrorPrint.argtypes = [POINTER(Error)] 248 lib.smlErrorPrint.restype = c_char_p 249 250 lib.g_thread_init.argtypes = [c_void_p] 251 lib.g_thread_init.restype = None 252 253 libc.strdup.argtypes = [c_char_p] 254 libc.strdup.restype = c_void_p 255 strdup = libc.strdup 256