Changeset 1793
- Timestamp:
- 02/21/07 11:05:18 (2 years ago)
- Files:
-
- plugins/moto-sync/motosync.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/moto-sync/motosync.py
r1785 r1793 396 396 397 397 def connect(self): 398 """Connect to the phone and initiate communication.""" 398 """Connect to the phone and initiate communication. 399 400 Returns True on success, False if already connected. 401 """ 402 if (self.__fd or self.__btsock): 403 return False # already connected 404 399 405 if BT_MAC_RE.match(self.devstr): 400 406 assert(USE_BLUETOOTH_MODULE, … … 437 443 self.contact_data_len = contactlen 438 444 self.contact_name_len = namelen 445 446 return True 439 447 440 448 def disconnect(self): … … 452 460 data = self.__do_cmd('AT+CGSN') 453 461 return self.__parse_results('CGSN', data)[0][0] 462 463 def read_version(self): 464 """read the phone's software version number""" 465 data = self.__do_cmd('AT+CGMR') 466 return self.__parse_results('CGMR', data)[0][0] 467 468 def read_model(self): 469 """read the phone's hardware model number""" 470 data = self.__do_cmd('AT+CGMM') 471 for s in self.__parse_results('CGMM', data)[0]: 472 if s.startswith("MODEL="): 473 return s.split("=", 1)[1] 474 return None 454 475 455 476 def read_time(self): … … 1492 1513 self.categories = {} 1493 1514 self.revcategories = {} 1515 self.objformats = {} 1494 1516 1495 1517 # find ObjFormat objects for our types 1496 self.objformats = {}1497 1518 for objtype in SUPPORTED_OBJTYPES: 1498 formatstr = "xml-%s-doc" % objtype 1499 self.objformats[objtype] = info.format_env.find_objformat(formatstr) 1519 formatstr = "xmlformat-%s-doc" % objtype 1520 formatobj = info.format_env.find_objformat(formatstr) 1521 if not formatobj: 1522 raise opensync.Error('object format %s unknown' % formatstr) 1523 self.objformats[objtype] = formatobj 1500 1524 1501 1525 def connect(self): 1502 1526 """Connect to the phone and setup our data structures.""" 1503 self.comms.connect() 1527 if not self.comms.connect(): 1528 return # already connected 1504 1529 self.serial = self.comms.read_serial() 1505 1530 … … 1694 1719 opensync.ObjTypeSinkCallbacks.__init__(self, objtype) 1695 1720 self.objtype = objtype 1696 self.sink.add_objformat("xml -%s-doc" % objtype)1721 self.sink.add_objformat("xmlformat-%s-doc" % objtype) 1697 1722 self.access = access 1698 1723 hashpath = os.path.join(info.configdir, "%s-hash.db" % objtype) … … 1766 1791 """Called by python-module plugin wrapper, registers sync classes.""" 1767 1792 comms = PhoneComms(parse_config(info.config)) 1768 access = PhoneAccess(comms )1793 access = PhoneAccess(comms, info) 1769 1794 for objtype in SUPPORTED_OBJTYPES: 1770 1795 info.add_objtype(MotoSink(objtype, info, access).sink) … … 1772 1797 def discover(info): 1773 1798 """Called by python-module wrapper, discovers capabilities of device.""" 1799 # HACK HACK, grab the comms object out of the initialised sink 1800 comms = info.nth_objtype(0).callback_obj.access.comms 1801 comms.connect() 1802 version = opensync.Version() 1803 version.plugin = "moto-sync" 1804 version.softwareversion = str(comms.read_version()) 1805 version.modelversion = str(comms.read_model()) 1806 version.identifier = str(comms.read_serial()) 1807 # FIXME: discover and set capabilities 1808 comms.disconnect() 1809 info.version = version 1810 1811 # for now, all objtypes are supported on all devices 1774 1812 for sink in info.objtypes: 1775 1813 sink.available = True 1776 info.version = opensync.Version()1777 info.version.plugin = "moto-sync"1778 1814 1779 1815 def get_sync_info(plugin):
