Commit 17e480d9 authored by Sriram Karra's avatar Sriram Karra

Fix BBDB sync to use get_itemid_from_synctags at folder level

Previously we were doing some hacky stuff in the contact
constructor that involved finding a sync label of the right
dbid. However with the move to Collections and with the ability
to sync between two dbs of same type this was not working any more
we also needed the profile name to do this, and it was getting
more hacky to this processing inside the constructor. With this
change we just do it at the higher level where we have all the
context to do this properly.

With this fix we take care of BBDB. The other DBs will follow in
parent 39a7122f
......@@ -61,31 +61,22 @@ class BBContact(Contact):
"""This class extends the Contact abstract base class to wrap a BBDB
def __init__ (self, folder, con=None, rec=None):
def __init__ (self, folder, con=None, con_itemid=None, rec=None):
"""rec is the native string vector representation of a BBDB contact
entry on disk."""
Contact.__init__(self, folder, con)
self.atts.update({'bbdb_folder' : None,})
## Sometimes we might be creating a contact object from a Google
## contact object or other entry which might have the ID in its sync
## tags field. if that is present, we should use it to initialize the
## itemid field for the current object
conf = self.get_config()
if con:
pname_re = conf.get_profile_name_re()
label = conf.make_sync_label(pname_re, self.get_dbid())
tag, itemid = con.get_sync_tags(label)[0]
except Exception, e:
if con_itemid:
logging.debug('Potential new BBContact: %s', con.get_name())
if folder.get_name():
if folder.get_name():
if rec:
......@@ -729,9 +720,15 @@ class BBContact(Contact):
ret = ''
i = 0
for key, val in self.get_sync_tags().iteritems():
# Skip any sync tag with BBDB IDs as values.
if, key) or not val:
## FIXME: This was put in here for a reason. I think it had
## something to do with "reproducing" sync labels containing the
## ID on the local end itself. This was the easiest fix,
## IIRC. This clearly conflicts with the present need. We need to
## solve this problem - and apply it for all the DBs.
# # Skip any sync tag with BBDB IDs as values.
# if, key) or not val:
# continue
if i > 0:
ret += ' '
......@@ -19,7 +19,7 @@
import codecs, logging, re, string, traceback
from folder import Folder
from contact_bb import BBContact
from contact_bb import BBContact, BBDBParseError
import pimdb_bb, utils
class BBContactsFolder(Folder):
......@@ -146,7 +146,8 @@ class BBContactsFolder(Folder):
for item in items:
bbc = BBContact(self, con=item)
con_itemid = item.get_itemid_from_synctags(pname, 'bb')
bbc = BBContact(self, con=item, con_itemid=con_itemid)
bbc.update_sync_tags(src_tag, item.get_itemid())
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