Bug 124175

Summary: My personnal picture doesn't appear cause of l10n
Product: [Unmaintained] kopete Reporter: fab <mailing.galac>
Component: generalAssignee: Kopete Developers <kopete-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: goneri, sven.burmeister
Priority: NOR    
Version First Reported In: 0.11.1   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description fab 2006-03-24 11:50:28 UTC
Version:           0.11.1 (using KDE 3.5.1, Debian Package 4:3.5.1-4 (testing/unstable))
Compiler:          Target: i486-linux-gnu
OS:                Linux (i686) release 2.6.15.6

Hello,

In the configuration panel, when I set my personnal picture in the identity part, it creates a picture in ~/.kde/share/apps/kopete/globalindentitiespictures called "Identité-par-défaut.png" (french l10n).
To that point it works well.
But when I come back to the configuration panel, I can see ~/.kde/share/apps/kopete/globalindentitiespictures/Identit%E9-par-d%E9faut.png and the picture doesn't display...
So I can't provide a beautifull picture of myself to my friends... snif...
Comment 1 Matt Rogers 2006-04-09 01:57:26 UTC
the name of the identity should not be translated when saving photos, etc. to disk, since the URL escaping will cause problems. That is what is happening here.
Comment 2 Michaël Larouche 2006-04-09 14:28:44 UTC
*** Bug 125215 has been marked as a duplicate of this bug. ***
Comment 3 Michaël Larouche 2006-04-09 14:29:38 UTC
*** Bug 125221 has been marked as a duplicate of this bug. ***
Comment 4 Michaël Larouche 2006-04-09 16:54:58 UTC
SVN commit 527913 by mlarouche:

BUG: 124175

Use MD5 Hash as filename to save custom images in global identity.
So no non-ASCII characters will be in filename.



 M  +15 -2     kopeteidentityconfig.cpp  


--- branches/kopete/0.12/kopete/kopete/config/identity/kopeteidentityconfig.cpp #527912:527913
@@ -26,6 +26,7 @@
 #include <qradiobutton.h>
 #include <qcombobox.h>
 #include <qapplication.h>
+#include <qbuffer.h>
 
 // KDE includes
 #include <kcombobox.h>
@@ -41,6 +42,7 @@
 #include <kurlrequester.h>
 #include <kinputdialog.h>
 #include <kpixmapregionselectordialog.h>
+#include <kmdcodec.h>
 
 // KDE KIO includes
 #include <kio/netaccess.h>
@@ -515,8 +517,8 @@
 
 void KopeteIdentityConfig::slotChangePhoto(const QString &photoUrl)
 {
-	QString saveLocation = locateLocal("appdata", "globalidentitiespictures/"+d->selectedIdentity.replace(" ", "-")+".png");
-
+	QString saveLocation;
+	
 	QImage photo(photoUrl);
 	// use KABC photo size 100x140
 	photo = KPixmapRegionSelectorDialog::getSelectedImage( QPixmap(photo), 100, 140, this );
@@ -531,6 +533,17 @@
 				photo = photo.scaleWidth(100);
 		}
 
+		// Use MD5 hash to save the filename, so no problems will occur with the filename because of non-ASCII characters.
+		// Bug 124175: My personnal picture doesn't appear cause of l10n
+		QByteArray tempArray;
+		QBuffer tempBuffer(tempArray);
+		tempBuffer.open( IO_WriteOnly );
+		photo.save(&tempBuffer, "PNG");
+		KMD5 context(tempArray);
+		// Save the image to a file.
+		saveLocation = context.hexDigest() + ".png";
+		saveLocation = locateLocal( "appdata", QString::fromUtf8("globalidentitiespictures/%1").arg( saveLocation ) );
+
 		if(!photo.save(saveLocation, "PNG"))
 		{
 			KMessageBox::sorry(this, 
Comment 5 Olivier Goffart 2006-04-15 11:44:57 UTC
*** Bug 124847 has been marked as a duplicate of this bug. ***
Comment 6 S. Burmeister 2006-09-01 21:41:06 UTC
This is still valid in 0.12.2. I have set-up a new jabber-account and it does not use the global-identity's photo.