示例#1
0
    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,
        })

        conf = self.get_config()
        if con:
            if con_itemid:
                self.set_itemid(con_itemid)
            else:
                logging.debug('Potential new BBContact: %s', con.get_name())

        if folder.get_name():
            self.set_bbdb_folder(folder.get_name())

        if rec:
            self.set_rec(rec)
            self.init_props_from_rec(rec)

        if not self.get_itemid():
            iid = ('%s' % uuid.uuid1())
            logging.debug('Assigning UUID %s for new contact: %s', iid,
                          self.get_name())
            self.set_itemid(iid)

        self.in_init(False)
示例#2
0
    def __init__(self, folder, con=None, vco=None, itemid=None):
        """vco, if not None, should be a valid vCard object (i.e. the contents
        of a vCard file, for e.g. When vco is not None, itemid should also be
        not None"""

        Contact.__init__(self, folder, con)

        self.set_etag(None)
        self.set_uid(None)
        self.set_vco(vco)
        self._group_count = 0

        ## 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:
            try:
                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]
                self.set_itemid(itemid)
            except Exception, e:
                logging.debug('Potential new CDContact: %s', con.get_name())
示例#3
0
    def __init__(self, folder, olprops=None, eid=None, con=None):
        """Constructor for OLContact. The starting properties of the contact
        can be initialized either from an existing Contact object, or from an
        Outlook item property list. It is an error to provide both.

        It is redundant to provide both olprops (array of property tuples) and
        an entryid. The entryid will override the property list.
        """

        if ((olprops and con) or (eid and con)):
            raise OLContactError(
                'Both olprops/eid and con cannot be specified in OLContact()')

        if olprops and eid:
            logging.warning('olprops and eid are not null. Ignoring olprops')
            olprops = None

        Contact.__init__(self, folder, con)

        ## Sometimes we might be creating a contact object from GC or other
        ## entry which might have the Entry 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:
            try:
                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]
                self.set_entryid(base64.b64decode(itemid))
            except Exception, e:
                logging.debug('Potential new OLContact: %s', con.get_name())
示例#4
0
    def __init__ (self, folder, ews_con=None, con=None):
        """Constructor for EXContact. The starting properties of the contact
        can be initialized either from an existing Contact object, or from an
        pyews contact object. It is an error to provide both.
        """

        if (ews_con and con):
            raise EXContactError(
                'Both ews con and con cannot be specified in EXContact()')

        Contact.__init__(self, folder, con)

        ## Sometimes we might be creating a contact object from a remote
        ## source which might have the Entry 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:
            try:
                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]              
                self.set_itemid(itemid)
            except Exception, e:
                logging.debug('Potential new EXContact: %s', con.get_disp_name())
示例#5
0
    def __init__(self, first_name, last_name, phone_number, email, nickname):
        '''
        __init__ method helping us create properties for our objects

        '''
        Contact.__init__(self, first_name, last_name, phone_number, email)
        self.nickname = nickname
示例#6
0
    def __init__ (self, folder, con=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:
            try:
                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]              
                self.set_itemid(itemid)
            except Exception, e:
                logging.debug('Potential new BBContact: %s', con.get_name())

            if folder.get_name():
                self.set_bbdb_folder(folder.get_name())
示例#7
0
    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,})

        conf = self.get_config()
        if con:
            if con_itemid:
                self.set_itemid(con_itemid)
            else:
                logging.debug('Potential new BBContact: %s', con.get_name())

        if folder.get_name():
            self.set_bbdb_folder(folder.get_name())

        if rec:
            self.set_rec(rec)
            self.init_props_from_rec(rec)

        if not self.get_itemid():
            iid = ('%s' % uuid.uuid1())
            logging.debug('Assigning UUID %s for new contact: %s', iid, 
                          self.get_name())
            self.set_itemid(iid)

        self.in_init(False)
示例#8
0
文件: contact_bb.py 项目: moy/ASynK
    def __init__(self, folder, con=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:
            try:
                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]
                self.set_itemid(itemid)
            except Exception, e:
                logging.debug('Potential new BBContact: %s', con.get_name())

            if folder.get_name():
                self.set_bbdb_folder(folder.get_name())
示例#9
0
    def __init__ (self, folder, con=None, con_itemid=None, vco=None, itemid=None,
                  debug_vcf=False):
        """vco, if not None, should be a valid vCard object (i.e. the contents
        of a vCard file, for e.g. When vco is not None, itemid should also be
        not None"""

        Contact.__init__(self, folder, con)

        self.debug_vcf = debug_vcf

        self.set_etag(None)
        self.set_uid(None)
        self.set_vco(vco)
        self._group_count = 0

        conf = self.get_config()
        if con:
            if con_itemid:
                self.set_itemid(self.normalize_cdid(con_itemid))
            else:
                logging.debug('Potential new CDContact: %s', con.get_name())
        elif vco:
            self.init_props_from_vco(vco)
            if not self.debug_vcf:
                assert(itemid)
            self.set_itemid(itemid)

        self.in_init(False)

        if not self.get_uid():
            self.set_uid(str(uuid.uuid1()))
示例#10
0
    def __init__ (self, folder, olprops=None, eid=None, con=None):
        """Constructor for OLContact. The starting properties of the contact
        can be initialized either from an existing Contact object, or from an
        Outlook item property list. It is an error to provide both.

        It is redundant to provide both olprops (array of property tuples) and
        an entryid. The entryid will override the property list.
        """

        if ((olprops and con) or (eid and con)):
            raise OLContactError(
                'Both olprops/eid and con cannot be specified in OLContact()')

        if olprops and eid:
            logging.warning('olprops and eid are not null. Ignoring olprops')
            olprops = None

        Contact.__init__(self, folder, con)

        ## Sometimes we might be creating a contact object from GC or other
        ## entry which might have the Entry 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:
            try:
                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]              
                self.set_entryid(base64.b64decode(itemid))
            except Exception, e:
                logging.debug('Potential new OLContact: %s', con.get_name())
示例#11
0
    def __init__ (self, folder, con=None, vco=None, itemid=None):
        """vco, if not None, should be a valid vCard object (i.e. the contents
        of a vCard file, for e.g. When vco is not None, itemid should also be
        not None"""

        Contact.__init__(self, folder, con)

        self.set_etag(None)
        self.set_uid(None)
        self.set_vco(vco)
        self._group_count = 0

        ## 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:
            try:
                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]              
                self.set_itemid(itemid)
            except Exception, e:
                logging.debug('Potential new CDContact: %s', con.get_name())
示例#12
0
文件: contact_gc.py 项目: xgid/ASynK
    def __init__(self, folder, con=None, con_itemid=None, gce=None):
        Contact.__init__(self, folder, con)

        conf = self.get_config()
        if con:
            if con_itemid:
                self.set_itemid(self.normalize_gcid(con_itemid))
            else:
                logging.debug("Potential new GCContact: %s", con.get_disp_name())

        self.set_gce(gce)
        if gce:
            self.init_props_from_gce(gce)

        self.in_init(False)
示例#13
0
    def __init__(self, folder, con=None, con_itemid=None, gce=None):
        Contact.__init__(self, folder, con)

        conf = self.get_config()
        if con:
            if con_itemid:
                self.set_itemid(self.normalize_gcid(con_itemid))
            else:
                logging.debug('Potential new GCContact: %s',
                              con.get_disp_name())

        self.set_gce(gce)
        if gce:
            self.init_props_from_gce(gce)

        self.in_init(False)
示例#14
0
文件: contact_gc.py 项目: barak/ASynK
    def __init__(self, folder, con=None, gce=None):
        Contact.__init__(self, folder, con)

        ## Sometimes we might be creating a contact object from Outlook or
        ## other entry which might have the google contact 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:
            try:
                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]

                self.set_itemid(self.normalize_gcid(itemid))
            except Exception, e:
                logging.debug("Potential new GCContact: %s", con.get_name())
示例#15
0
    def __init__ (self, folder, con=None, gce=None):
        Contact.__init__(self, folder, con)

        ## Sometimes we might be creating a contact object from Outlook or
        ## other entry which might have the google contact 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:
            try:
                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]

                self.set_itemid(self.normalize_gcid(itemid))
            except Exception, e:
                logging.debug('Potential new GCContact: %s', con.get_name())
示例#16
0
    def __init__ (self, folder, ews_con=None, con=None, con_itemid=None):
        """Constructor for EXContact. The starting properties of the contact
        can be initialized either from an existing Contact object, or from an
        pyews contact object. It is an error to provide both.
        """

        if (ews_con and con):
            raise EXContactError(
                'Both ews con and con cannot be specified in EXContact()')

        Contact.__init__(self, folder, con)

        conf = self.get_config()
        if con:
            if con_itemid:
                self.set_itemid(con_itemid)
            else:
                logging.debug('Potential new EXContact: %s', con.get_disp_name())

        self.set_ews_con(ews_con)
        if ews_con is not None:
            self.init_props_from_ews_con(ews_con)
示例#17
0
    def __init__(self, folder, ews_con=None, con=None, con_itemid=None):
        """Constructor for EXContact. The starting properties of the contact
        can be initialized either from an existing Contact object, or from an
        pyews contact object. It is an error to provide both.
        """

        if (ews_con and con):
            raise EXContactError(
                'Both ews con and con cannot be specified in EXContact()')

        Contact.__init__(self, folder, con)

        conf = self.get_config()
        if con:
            if con_itemid:
                self.set_itemid(con_itemid)
            else:
                logging.debug('Potential new EXContact: %s',
                              con.get_disp_name())

        self.set_ews_con(ews_con)
        if ews_con is not None:
            self.init_props_from_ews_con(ews_con)
示例#18
0
    def __init__(self,
                 folder,
                 con=None,
                 con_itemid=None,
                 vco=None,
                 itemid=None,
                 debug_vcf=False):
        """vco, if not None, should be a valid vCard object (i.e. the contents
        of a vCard file, for e.g. When vco is not None, itemid should also be
        not None"""

        Contact.__init__(self, folder, con)

        self.debug_vcf = debug_vcf

        self.set_etag(None)
        self.set_uid(None)
        self.set_vco(vco)
        self._group_count = 0

        conf = self.get_config()
        if con:
            if con_itemid:
                self.set_itemid(self.normalize_cdid(con_itemid))
            else:
                logging.debug('Potential new CDContact: %s', con.get_name())
        elif vco:
            self.init_props_from_vco(vco)
            if not self.debug_vcf:
                assert (itemid)
            self.set_itemid(itemid)

        self.in_init(False)

        if not self.get_uid():
            self.set_uid(str(uuid.uuid1()))
示例#19
0
    def __init__ (self, folder, con=None, vco=None, itemid=None):
        """vco, if not None, should be a valid vCard object (i.e. the contents
        of a vCard file, for e.g. When vco is not None, itemid should also be
        not None"""

        Contact.__init__(self, folder, con)

        self.set_etag(None)
        self.set_uid(None)
        self.set_vco(vco)
        self._group_count = 0

        ## 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:
            try:
                ## FIXME: The code below works for other DBs quite
                ## well. However with CardDAV there is a problem when the same
                ## item is synched to more than one server. This happens
                ## because the itemid is picked up from the first sync tag,
                ## and the itemid is also assumed to be the full path of the
                ## file on the server. For now we will assume that you will
                ## sync your contacts to a single carddav server... The proper
                ## solution is to pick out the sync tag corresponding to the
                ## profile being synched... That is itself a problem because
                ## this class is not as 'state-less' as it can/should be. WTF.
                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]              
                self.set_itemid(itemid)
            except Exception, e:
                logging.debug('Potential new CDContact: %s', con.get_name())
示例#20
0
    def __init__ (self, folder, olprops=None, eid=None, con=None,
                  con_itemid=None):
        """Constructor for OLContact. The starting properties of the contact
        can be initialized either from an existing Contact object, or from an
        Outlook item property list. It is an error to provide both.

        It is redundant to provide both olprops (array of property tuples) and
        an entryid. The entryid will override the property list.
        """

        if ((olprops and con) or (eid and con)):
            raise OLContactError(
                'Both olprops/eid and con cannot be specified in OLContact()')

        if olprops and eid:
            logging.warning('olprops and eid are not null. Ignoring olprops')
            olprops = None

        Contact.__init__(self, folder, con)

        conf = self.get_config()
        if con:
            if con_itemid:
                self.set_entryid(base64.b64decode(con_itemid))
            else:
                logging.debug('Potential new OLContact: %s', con.get_name())

        ## Set up some of the basis object attributes and parent folder/db
        ## properties to make it easier to access them

        self.set_synchable_fields_list()
        self.set_proptags(folder.get_proptags())
        pvalu = self.get_proptags().valu

        self.addr_map = {
            'work' : {
                'street'  : pvalu('ASYNK_PR_WORK_ADDRESS_STREET'),
                'city'    : pvalu('ASYNK_PR_WORK_ADDRESS_CITY'),
                'state'   : pvalu('ASYNK_PR_WORK_ADDRESS_STATE_OR_PROVINCE'),
                'country' : pvalu('ASYNK_PR_WORK_ADDRESS_COUNTRY'),
                'zip'     : pvalu('ASYNK_PR_WORK_ADDRESS_POSTAL_CODE')
            },

            'home' : {
                'street'  : mt.PR_HOME_ADDRESS_STREET_W,
                'city'    : mt.PR_HOME_ADDRESS_CITY_W,
                'state'   : mt.PR_HOME_ADDRESS_STATE_OR_PROVINCE_W,
                'country' : mt.PR_HOME_ADDRESS_COUNTRY_W,
                'zip'     : mt.PR_HOME_ADDRESS_POSTAL_CODE_W,
            },

            'other' : {
                'street'  : mt.PR_OTHER_ADDRESS_STREET_W,
                'city'    : mt.PR_OTHER_ADDRESS_CITY_W,
                'state'   : mt.PR_OTHER_ADDRESS_STATE_OR_PROVINCE_W,
                'country' : mt.PR_OTHER_ADDRESS_COUNTRY_W,
                'zip'     : mt.PR_OTHER_ADDRESS_POSTAL_CODE_W,
            },
        }

        self.set_olprops(olprops)

        if olprops:
            self.init_props_from_olprops(olprops)
        elif eid:
            self.init_props_from_eid(eid)

        self.in_init(False)
示例#21
0
    def __init__(self,
                 folder,
                 olprops=None,
                 eid=None,
                 con=None,
                 con_itemid=None):
        """Constructor for OLContact. The starting properties of the contact
        can be initialized either from an existing Contact object, or from an
        Outlook item property list. It is an error to provide both.

        It is redundant to provide both olprops (array of property tuples) and
        an entryid. The entryid will override the property list.
        """

        if ((olprops and con) or (eid and con)):
            raise OLContactError(
                'Both olprops/eid and con cannot be specified in OLContact()')

        if olprops and eid:
            logging.warning('olprops and eid are not null. Ignoring olprops')
            olprops = None

        Contact.__init__(self, folder, con)

        conf = self.get_config()
        if con:
            if con_itemid:
                self.set_entryid(base64.b64decode(con_itemid))
            else:
                logging.debug('Potential new OLContact: %s', con.get_name())

        ## Set up some of the basis object attributes and parent folder/db
        ## properties to make it easier to access them

        self.set_synchable_fields_list()
        self.set_proptags(folder.get_proptags())
        pvalu = self.get_proptags().valu

        self.addr_map = {
            'work': {
                'street': pvalu('ASYNK_PR_WORK_ADDRESS_STREET'),
                'city': pvalu('ASYNK_PR_WORK_ADDRESS_CITY'),
                'state': pvalu('ASYNK_PR_WORK_ADDRESS_STATE_OR_PROVINCE'),
                'country': pvalu('ASYNK_PR_WORK_ADDRESS_COUNTRY'),
                'zip': pvalu('ASYNK_PR_WORK_ADDRESS_POSTAL_CODE')
            },
            'home': {
                'street': mt.PR_HOME_ADDRESS_STREET_W,
                'city': mt.PR_HOME_ADDRESS_CITY_W,
                'state': mt.PR_HOME_ADDRESS_STATE_OR_PROVINCE_W,
                'country': mt.PR_HOME_ADDRESS_COUNTRY_W,
                'zip': mt.PR_HOME_ADDRESS_POSTAL_CODE_W,
            },
            'other': {
                'street': mt.PR_OTHER_ADDRESS_STREET_W,
                'city': mt.PR_OTHER_ADDRESS_CITY_W,
                'state': mt.PR_OTHER_ADDRESS_STATE_OR_PROVINCE_W,
                'country': mt.PR_OTHER_ADDRESS_COUNTRY_W,
                'zip': mt.PR_OTHER_ADDRESS_POSTAL_CODE_W,
            },
        }

        self.set_olprops(olprops)

        if olprops:
            self.init_props_from_olprops(olprops)
        elif eid:
            self.init_props_from_eid(eid)

        self.in_init(False)