Class com.gContactSync.GContact
Defined in: GContact.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Makes a new GContact object that has functions to get and set various values
for a Google Contact's Atom/XML representation.
|
Field Attributes | Field Name and Description |
---|---|
The current element being modified or returned (internal use only)
|
|
The groups that this contact is in
|
|
The URI of a photo to add to this contact
|
Method Attributes | Method Name and Description |
---|---|
addToGroup(aGroupURL)
Adds the contact to the given, existing, group.
|
|
Checks for an invalid IM address as explained here:
http://pi3141.wordpress.com/2008/07/30/update-2/
|
|
Removes all groups from this contact.
|
|
getAttribute(aTagName, aNamespace, aIndex, aAttributeName)
Gets the value of a given attribute for the ith element with the given
tag name and namespace.
|
|
getElementValue(aElement, aIndex, aType)
Returns the value of an element with a type where the value is in the
value of the child node.
|
|
getExtendedProperty(aName)
Returns the value of the extended property with a matching name attribute.
|
|
Returns an array of the names of the groups to which this contact belongs.
|
|
getID(aFull)
Returns the last portion of this contact's ID, or optionally, the full ID.
|
|
Gets the last modified date from an contacts's XML feed in milliseconds
since 1970.
|
|
getName()
Gets the name and e-mail address of a contact from it's Atom
representation.
|
|
Returns an object with information about this contact's photo.
|
|
getValue(aName, aIndex, aType)
Returns the value of the XML Element with the supplied tag name at the
given index of the given type (home, work, other, etc.
|
|
isMatch(aElement, aXmlElem, aType, aDontSkip)
Returns true if the given XML Element is a match for the GElement object
and the type (ie home, work, other, etc.
|
|
Removes all extended properties from this contact.
|
|
removeFromGroup(aGroup)
Removes the contact from the given group element.
|
|
setAddress(aElement, aValue, aType, aIndex)
Google's contacts schema puts several components of an address into a
separate element, so this function handles those attributes separately.
|
|
setAttribute(aTagName, aNamespace, aIndex, aAttributeName, aValue)
Sets the value of a given attribute for the ith element with the given
tag name and namespace.
|
|
setElementValue(aElement, aIndex, aType, aValue)
Sets the value of the specified element.
|
|
setExtendedProperty(aName, aValue)
Sets an extended property with the given name and value if there are less
than 10 existing.
|
|
setGroups(aGroups)
Sets the groups of that this contact is in based on the array of IDs.
|
|
setName(aElement, aValue)
Google's contacts schema puts several components of a name into a
separate element, so this function handles those attributes separately.
|
|
setOrg(aElement, aValue)
Google's contacts schema puts the organization name and job title in a
separate element, so this function handles those two attributes separately.
|
|
setPhoto(aURI)
Sets the photo for this contact.
|
|
setValue(aName, aIndex, aType, aValue)
Sets the value with the name aName to the value aValue based on the type
and index.
|
|
writePhoto(aAuthToken)
Fetches and saves a local copy of this contact's photo, if present.
|
Class Detail
com.gContactSync.GContact(aXml)
Makes a new GContact object that has functions to get and set various values
for a Google Contact's Atom/XML representation. If the parameter aXml is not
supplied, this constructor will make a new contact.
- Parameters:
- aXml
- Optional. The Atom/XML representation of this contact. If not supplied, will make a new contact.
Field Detail
mCurrentElement
The current element being modified or returned (internal use only)
mGroups
The groups that this contact is in
mNewPhotoURI
The URI of a photo to add to this contact
Method Detail
addToGroup(aGroupURL)
Adds the contact to the given, existing, group.
- Parameters:
- aGroupURL
- {string} The URL of an existing group to which the contact will be added.
checkIMAddress()
Checks for an invalid IM address as explained here:
http://pi3141.wordpress.com/2008/07/30/update-2/
clearGroups()
Removes all groups from this contact.
{boolean}
getAttribute(aTagName, aNamespace, aIndex, aAttributeName)
Gets the value of a given attribute for the ith element with the given
tag name and namespace.
- Parameters:
- aTagName
- {string} The name of the tag.
- aNamespace
- {string} The namespace of the tag.
- aIndex
- {int} The index of the element whose attribute is to be returned.
- aAttributeName
- {string} The name of the attribute to get.
- Returns:
- {boolean} The value of the attribute for the described element.
{Property}
getElementValue(aElement, aIndex, aType)
Returns the value of an element with a type where the value is in the
value of the child node.
- Parameters:
- aElement
- {GElement} The GElement object with information about the value to get.
- aIndex
- {int} The index of the value (ie 0 for primary email, 1 for second...). Set to 0 if not supplied.
- aType
- {string} The type, if the element can have types.
- Returns:
- {Property} A new Property object with the value of the element, if found. The type of the Property will be aType.
{Property}
getExtendedProperty(aName)
Returns the value of the extended property with a matching name attribute.
- Parameters:
- aName
- {string} The name of the extended property to return.
- Returns:
- {Property} A Property object with the value of the extended property with the name attribute aName.
getGroups()
Returns an array of the names of the groups to which this contact belongs.
{string}
getID(aFull)
Returns the last portion of this contact's ID, or optionally, the full ID.
- Parameters:
- {boolean} aFull
- Set this to true to return the complete ID for this contact (the entire URL). Otherwise just the portion after the last / is returned.
- Returns:
- {string} The ID of this contact.
{int}
getLastModifiedDate()
Gets the last modified date from an contacts's XML feed in milliseconds
since 1970.
- Returns:
- {int} The last modified date of the entry in milliseconds from 1970
getName()
Gets the name and e-mail address of a contact from it's Atom
representation.
getPhotoInfo()
Returns an object with information about this contact's photo.
- Returns:
- An object containing the following properties: - url - The URL of the contact's photo - type - The type of photo (ex "image/*") - etag - The etag of the photo (if a photo exists). If there was no photo found (no etag) the etag is blank. If this contact is new then this function returns null.
{Property}
getValue(aName, aIndex, aType)
Returns the value of the XML Element with the supplied tag name at the
given index of the given type (home, work, other, etc.)
- Parameters:
- aName
- {string} The tag name of the value to get. See gdata for valid tag names.
- aIndex
- {int} Optional. The index, if non-zero, of the value to get.
- aType
- {string} The type of element to get if the tag name has different types (home, work, other, etc.).
- Returns:
- {Property} A new Property object with the value and type, if applicable. If aName is groupMembership info, returns an array of the group IDs
isMatch(aElement, aXmlElem, aType, aDontSkip)
Returns true if the given XML Element is a match for the GElement object
and the type (ie home, work, other, etc.)
- Parameters:
- aElement
- {GElement} The GElement object (@see GElement.js)
- aXmlElem
- {XML Element} The XML Element to check
- aType
- {string} The type (home, work, other, etc.)
- aDontSkip
removeExtendedProperties()
Removes all extended properties from this contact.
removeFromGroup(aGroup)
Removes the contact from the given group element.
- Parameters:
- aGroup
- {Group} The group from which the contact should be removed.
setAddress(aElement, aValue, aType, aIndex)
Google's contacts schema puts several components of an address into a
separate element, so this function handles those attributes separately.
- Parameters:
- aElement
- {GElement} The GElement object with a valid gd:structuredPostalAddress tag name
- aValue
- {string} The value to set. Null if the XML Element should be removed.
- aType
- {string} The 'type' of address (home, work, or other)
- aIndex
- {int} The index of the address (0 for the first, 1 for the second, etc)
{boolean}
setAttribute(aTagName, aNamespace, aIndex, aAttributeName, aValue)
Sets the value of a given attribute for the ith element with the given
tag name and namespace.
- Parameters:
- aTagName
- {string} The name of the tag.
- aNamespace
- {string} The namespace of the tag.
- aIndex
- {int} The index of the element whose attribute is to be set.
- aAttributeName
- {string} The name of the attribute to set.
- aValue
- {string} The value to set.
- Returns:
- {boolean} True if the element was found and the attribute was set.
setElementValue(aElement, aIndex, aType, aValue)
Sets the value of the specified element.
- Parameters:
- aElement
- {GElement} The GElement object with information about the value to get.
- aIndex
- {int} The index of the value (ie 0 for primary email, 1 for second...). Set to 0 if not supplied.
- aType
- {string} The type, if the element can have types.
- aValue
- {string} The value to set for the element.
setExtendedProperty(aName, aValue)
Sets an extended property with the given name and value if there are less
than 10 existing. Logs a warning if there are already 10 or more.
- Parameters:
- aName
- {string} The name of the property.
- aValue
- {string} The value of the property.
setGroups(aGroups)
Sets the groups of that this contact is in based on the array of IDs.
- Parameters:
- aGroups
- {array} An array of the IDs of the groups to which the contact should belong.
setName(aElement, aValue)
Google's contacts schema puts several components of a name into a
separate element, so this function handles those attributes separately.
- Parameters:
- aElement
- {GElement} The GElement object with a valid gd:name tag (givenName, additionalName, familyName, namePrefix, nameSuffix, or fullName).
- aValue
- {string} The value to set. Null if the XML Element should be removed.
setOrg(aElement, aValue)
Google's contacts schema puts the organization name and job title in a
separate element, so this function handles those two attributes separately.
- Parameters:
- aElement
- {GElement} The GElement object with a valid org tag name (orgDepartment, orgJobDescription, orgName, orgSymbol, or orgTitle)
- aValue
- {string} The value to set. Null if the XML Element should be removed.
setPhoto(aURI)
Sets the photo for this contact. Note that this may not immediately take
effect as contacts must be added to Google and then retrieved before a
photo can be added.
- Parameters:
- aURI
- {string|nsIURI} A string with the URI of a contact photo.
setValue(aName, aIndex, aType, aValue)
Sets the value with the name aName to the value aValue based on the type
and index.
- Parameters:
- aName
- {string} The tag name of the value to set.
- aIndex
- {int} The index of the element whose value is set.
- aType
- {string} The type of the element (home, work, other, etc.).
- aValue
- {string} The value to set. null if the element should be removed.
writePhoto(aAuthToken)
Fetches and saves a local copy of this contact's photo, if present.
NOTE: Portions of this code are from Thunderbird written by me (Josh Geenen)
See https://bugzilla.mozilla.org/show_bug.cgi?id=119459
TODO - merge w/ com.gContactSync.writePhoto
- Parameters:
- aAuthToken
- {string} The authentication token for the account to which this contact belongs.