Commit 055fa2d6 authored by Sriram Karra's avatar Sriram Karra

Take care of write time details related to BBDB file format ver 9 support

Ensure that the created and updated fields are written in the
correct format for ver 9 if that is the database version we found.

Also if ASynK is writing out to a new or blank BBDB database, then
the default format version will be 9 from here on. There is no
easy way to change that except fixing it in the code (but it is a
one line code change, easily indicated by the current commit diffs)
parent a368aa95
......@@ -152,7 +152,8 @@ class BBContact(Contact):
rec += self._get_phones_as_string() + ' '
rec += self._get_postal_as_string() + ' '
rec += self._get_emails_as_string() + ' '
rec += self._get_notes_as_string()
rec += self._get_notes_as_string() + ' '
rec += self._get_created_updated_as_string() + ' '
rec += ' nil]'
self.dirty(False)
......@@ -561,7 +562,7 @@ class BBContact(Contact):
comp.insert(0, comp1)
return unchompq('; '.join(comp))
elif ver == '7':
else:
if comp and len(comp) > 0:
comp = demjson.decode(comp)
comp.insert(0, unchompq(comp1))
......@@ -686,14 +687,19 @@ class BBContact(Contact):
return ret
def _get_notes_as_string (self):
bbdb_ver = self.get_store().get_file_format()
noted = self.get_notes_map()
if not noted:
logging.error('_ge(): Error in Config. No notes_map field for bb')
return
ret = '(bbdb-id . %s) ' % unchompq(self.get_itemid())
ret += '(%s . %s) ' % (noted['created'], unchompq(self.get_created()))
ret += '(%s . %s) ' % (noted['updated'], unchompq(self.get_updated()))
if int(bbdb_ver) <= 9:
ret += '(%s . %s) ' % (noted['created'],
unchompq(self.get_created()))
ret += '(%s . %s) ' % (noted['updated'],
unchompq(self.get_updated()))
p = esc_str(self.get_prefix())
g = esc_str(self.get_gender())
......@@ -742,6 +748,19 @@ class BBContact(Contact):
return '(' + ret + ')'
def _get_created_updated_as_string (self):
"""Prior to file format ver 9 these fields were embedded in the notes
section. Ver 9 onwards they are first class citizens, so we
need to handle them separately and make sure they are
available in the record at the appropriate level."""
bbdb_ver = int(self.get_store().get_file_format())
if bbdb_ver < 9:
print 'Hi Karl WTF'
return ' ' # Handled via the notes section
return ' '.join([self.get_created(), self.get_updated()])
def _get_sync_tags_as_str (self):
conf = self.get_config()
pname_re = conf.get_profile_name_re()
......
......@@ -235,7 +235,8 @@ class MessageStore:
return None
def _set_default_preamble (self):
ver = '7'
ver = '9' # There is no real difference in the
# preamble itself
self.append_preamble(';; -*-coding: utf-8-emacs;-*-\n')
self.append_preamble(';;; file-format: %s\n' % ver)
self.set_file_format(ver)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment