Open Bug 533552 Opened 11 years ago Updated 4 years ago

Address book does not show photos from LDAP

Categories

(MailNews Core :: LDAP Integration, defect)

defect
Not set
normal

Tracking

(Not tracked)

People

(Reporter: davedash, Unassigned)

References

Details

I don't see photos that are visible in my Mac Addressbook or in LDAP via Thunderbird's address book viewer.

Using mozilla.com for the LDAP.
Mac address book photos is bug 496789. Morphing this into LDAP only as I don't think we've got a bug about that.
Component: Address Book → LDAP Integration
Product: Thunderbird → MailNews Core
QA Contact: address-book → ldap-integration
Summary: Address book does not show photos from LDAP or Mac Addressbook → Address book does not show photos from LDAP
Version: 3.0 → Trunk
Duplicate of this bug: 533733
Duplicate of this bug: 536055
I confirm, that Shredder 3.0.1pre does not include "jpegPhoto" attribute of "inetOrgPerson" class into the list of attributes when searching the LDAP directory.
This bug should be solved together with bug 536053.
Count me in as another person that would love this functionality.  Of course, I'd also like to see the sender photo with message information on received emails.  The problem is that Thunderbird looks and acts like it is supposed to retrieve LDAP photos - it uses the same interface and shows a blank image for each contact.
I can confirm that (unsurprisingly and unfortunately) this is also the case on Vista.
Has anyone looked at working on this bug?  I'm thinking I might see if I can take a crack at it, if not..
I think this stalled. Jonathan, it would be great if you can work on this. Did some searching and found https://bugzilla.mozilla.org/show_bug.cgi?id=119459. This is the source of the photo feature.

Some ideas on how this might be done:

Refer: https://bug119459.bugzilla.mozilla.org/attachment.cgi?id=396697

Code lines:
 // Contact photo
+  cvData.cvPhoto.setAttribute("src", getPhotoURI(card.getProperty("PhotoName")));

else if (type == "web" && document.getElementById("PhotoURI").value)
+    photoURI = document.getElementById("PhotoURI").value;

These can be played with and can map to:

attributetype    ( 0.9.2342.19200300.100.1.60
      NAME 'jpegPhoto'
      DESC 'a JPEG image'
      SYNTAX 1.3.6.1.4.1.1466.115.121.1.28 )

OR

attributetype ( 1.1.2.1.3 NAME 'x-my-PhotoURI'
      DESC 'URI and optional label referring to a photo'
      SUP labeledURI )

in LDAP

There can be a checkbox flag added in the advanced preferences that gives the option to have addressbook photo sync with LDAP photo. The standard is jpegPhoto in LDAP; but Micrsoft uses thumbnailPhoto in AD, if going ahead we need AD sync of photo as well. 

This is what i could find out.

Or this can be done via an add-on? I have no idea if its possible using add-on, still searching.

PS: This is an amazing system of bug/enhancement tracking and implementation. This is my first post here. Got a thunderbird build environment ready using mercury/tools on my laptop.
So excited :D lol

-gs
Found:

function registerPhotoHandler(aType, aPhotoHandler)
{
  gPhotoHandlers[aType] = aPhotoHandler;
}

registerPhotoHandler("generic", genericPhotoHandler);
registerPhotoHandler("web", webPhotoHandler);
registerPhotoHandler("file", filePhotoHandler);

in 

abCardOverlay.js

I think adding, say:

registerPhotoHandler("ldap", ldapPhotoHandler);

would help.

Thanks to whoever put PhotoHandler option :D

-gs
Browsing through addrbook/content/ files.

What i understand is that we have to use a custom attribute of TB address-book (or make new attribute, thus change schema?) and get its value from LDAP (raw jpeg data). The attribute value should render in all IMG tags across TB. How many places is there a IMG tag? I saw at 2 places, address-book contacts browser and the contact editor.

The image type should be either jpeg, png or gif. Too many options would cause complexity and confusion for the user and developers too.

But, what image types can IMG tag render?

Someone say something.. something.. something.. (echo)

-gs
Guys can you look and answers the questions in the previous 3 comments ?
I didn't know about "x-myPhotoURI" (and "x-myPhoto"). Is it really an attribute of an LDAP schema? It seems only to help describe how to set up your own schema's.

The relevant attribute to me seems "jpegPhoto", defined in "organizationalPerson". This would limit the image type to jpeg, I guess. (Also for a first implementation jpeg only would suffice.)

It seems to me you shouldn't have to define new attributes: On the LDAP side the attribute is defined and on the address book side there are facilities to display photos, albeit for the non-LDAP address book. They "just" have to be joined.

These remarks are made from a TB user's point of view. I have a programmer's background, but didn't implement anything for TB.
I agree, jpegPhoto in organizationalPerson is what we care about, but it looks like a modern AD environment would be using thumbnailPhoto.  See http://cjwdev.wordpress.com/2010/11/03/the-thumbnailphoto-attribute-explained/ for details on that attribute.

Gaurav, I've not actually done any coding in Mozilla (I once contributed an image rendering patch for X Mosaic, though..).  It sounds like you're way ahead of me on familiarity with TB's innards, honestly.

It does sound like actually making this change should be easy, the hard part to me would appear to be getting a working Thunderbird build environment set up.
In our address book photos are loaded to 'jpegPhoto' attribute so I would vote for that default attribute. However I believe that limits the image format only to JPEG (unless Thunderbird has image format "autodetect" feature). Would be nice to have this attribute configurable via about:config anyway.
Hey all - I do know that for my EDS Contacts add-on (which prompted me to write the photoHandlers code for the address book), what I ended up doing was using data-url's to inject the images into the image tags.

See:  http://bazaar.launchpad.net/~extension-hackers/thunderbird-eds-extension/thunderbird-eds-integration/view/head:/content/addressbookOverlay.js

This assumed that the card had it's PhotoType attribute set to "eds".

-Mike
Hi all,

Thanks for the comments. I think we started this again :D

So, we can firstly test this out for jpegPhoto i.e. jpeg format only. Then maybe we can see how we can extend it to other formats. 

Jonathan, setting up TB build environment is quite easy. Took me about an hour to setup. Its explained here: https://developer.mozilla.org/en/Simple_Thunderbird_build
You need good Internet connection though.

Hi Mike, thanks for inputs. Can we test your add-on to display jpegPhoto attribute of LDAP?
Given that jpegPhoto has the image data.
Hi folks, thanks for the interest in fixing this bug. There may be better ways, but I think this is where I'd start off:

- Add a preference "ldap_2.servers.default.attrmap.PhotoName" with value "jpegPhoto" in mailnews.js
-- This should be enough to get the attribute from LDAP and store it in the card.
-- You could confirm this by adding a window.alert(card.getProperty("PhotoName")) in the GetCardValues function in mail/components/addrbook/content/abCardOverlay.js

- Next the code needs the "PhotoType" set, as we don't want to force another attribute to be stored in LDAP, I think I'd go for adding an attribute to the card in nsAbLDAPCard::SetMetaProperties - so if PhotoName is in the list of attributes, then add PhotoType with value "ldap" or something like that.

- Then back in GetCardValues we can handle a PhotoType of ldap with whatever translation we need to get from jpegPhoto type to a data uri.


If you need more help just let us know and Mike and I can provider more pointers. We also are frequently in irc (https://wiki.mozilla.org/IRC) in the #maildev channel if you want to chat in real time.
I concur, that sounds like the right way forward.
Hi Mark Banner/Mike,

Thanks for the guideline. I can build on my machine (tested it recently). Now, the first point i understood. I do not understand what is second and third point regarding "PhotoType" needed to be set. Please guide, so I can change the code and do a test build.

Thanks.

-gs
Hi Mike,

Thanks for the help the other day on IRC. I did the changes as suggested by Mark. Made a build. Thunderbird Daily is firing up nicely. But, the addressbook overlay is blank in the photo field. I have a local virtual machine with LDAP (and sample jpegPhoto too). TB doesn't seem to read it. I have to search a solution to get the right test parameters and have a concrete result.
PS: Only step 1 of Mark's guidelines is done.
If you've only done the first bit of adding the pref, nothing will get displayed. Did you try adding the window.alert? Attaching the patch so far would be good (I believe I have a server implementing jpegPhoto here).
Hi Mark,

The LDAP lookup on the virtual server worked. But, no picture is displayed in the vCard contact, not even the default pic. Also, added: 

window.alert(card.getProperty("PhotoName"));

in the function:

GetCardValues(cardproperty, doc)

But, nothing happens.
Hi Mark/Mike,

Please guide further. Bit stuck here..

Thanks.
Can you attach the patch so far as I've previously requested? It is much easier to help if we can see what you're doing.
Hi Mark!!

Sent the patch.. please see.

Thanks.

-gs
(In reply to gauravnetcore from comment #26)
> Hi Mark!!
> 
> Sent the patch.. please see.
> 
> Thanks.
> 
> -gs

Hey, would you mind posting the patch in this bug for me to check out too?

-Mike
There're addons can do this:

https://addons.mozilla.org/en-US/thunderbird/addon/ldap-contact-photo/
https://addons.mozilla.org/en-US/thunderbird/addon/ldapinfoshow/ (this one written by me, some of the codes are from ldap-contact-photo)


But it would be better is Thunderbird can have built-in support.
Patches are certainly welcome.
OS: Mac OS X → All
Hardware: x86 → All
It seems to have been solved in TB v24.0.
Herre de Jonge, it depends on how you test it. For me it does not work. Do you happen to know how TB makes a lookup?

Plugin ldapinfoshow advertized by Opera Wang works just fine: it shows photo both in Address Book card quick view and also on Photo tab of contact information dialog.
It appears TB at least uses the jpegPhoto attribute. I don't know the details of how TB makes the lookup.

As a test I searched for a contact without photo, then added this attribute and checked again. Indeed, there was no image before, but afterwards both in the quick view and detailed information the photo was visible.

OS: W7 64b
Lucky you are. I have run Thunderbird as following (described at https://wiki.mozilla.org/MailNews:Logging):

set NSPR_LOG_MODULES=ldap:5
set NSPR_LOG_FILE=%USERPROFILE%\Desktop\imap.log
"%ProgramFiles(x86)%\Mozilla Thunderbird\thunderbird.exe"

and the log was:

0[220f140]: nsLDAPOperation::SimpleBind(): called; bindName = 'cn=X,cn=persons,cn=root'; 
0[220f140]: pending operation added; total pending operations now = 1
3804[b3e8bc0]: pending operation removed; total pending operations now = 0
0[220f140]: nsLDAPOperation::SearchExt(): called with aBaseDn = 'cn=persons,cn=root'; aFilter = '(&(objectclass=mozillaAbPersonAlpha)(|(mail=*Y*)(cn=*Y*)(givenName=*Y*)(sn=*Y*)))'; aAttributes = mozillaUseHtmlMail,xmozillausehtmlmail,description,notes,title,sn,surname,mozillaHomeLocalityName,givenName,mozillaHomeState,mail,mozillaNickname,xmozillanickname,nsAIMid,nscpaimscreenname,mobile,cellphone,carphone,modifytimestamp,mozillaHomePostalCode,facsimiletelephonenumber,fax,telephoneNumber,birthyear,c,countryname,mozillaHomeStreet,cn,commonname,postalCode,zip,mozillaCustom1,custom1,mozillaHomeCountryName,st,region,mozillaCustom2,custom2,mozillaSecondEmail,xmozillasecondemail,mozillaCustom3,custom3,homePhone,o,company,mozillaHomeStreet2,mozillaWorkUrl,workurl,labeledURI,birthday,street,streetaddress,postOfficeBox,mozillaCustom4,custom4,mozillaHomeUrl,homeurl,l,locality,pager,pagerphone,ou,department,departmentnumber,orgunit,birthmonth,mozillaWorkStreet2,objectClass; aSizeLimit = 100
0[220f140]: pending operation added; total pending operations now = 1
0[220f140]: nsLDAPMessage::GetDn(): dn = 'cn=Y,cn=persons,cn=root'
3804[b3e8bc0]: pending operation removed; total pending operations now = 0

and I don't see jpegPhoto in the list of requested attributes. Could you please make the same exercise?

I am running TBv24 on WinXP x32.
I'm really sorry. I have fooled myself. It seems I had after all installed an add-on (i.e., LDAP contact photo) to do it and forgotten about it.
Removing myslef on all the bugs I'm cced on. Please NI me if you need something on MailNews Core bugs from me.
You need to log in before you can comment on or make changes to this bug.