[Bug 20034] Avatar cache reference implementation

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Wed Sep 8 12:56:14 CEST 2010


https://bugs.freedesktop.org/show_bug.cgi?id=20034

--- Comment #10 from Andre Moreira Magalhaes <andrunko at gmail.com> 2010-09-08 03:56:13 PDT ---
+#define RAND_STR_LEN 6
+    gchar randStr[RAND_STR_LEN + 1];
+    for (int i = 0; i < RAND_STR_LEN; i++)
+      randStr[i] = letters[qrand() % qstrlen(letters)];
+    QString tmpDir = QDir::tempPath() + QString::fromLatin1("/") +
+        QString::fromLatin1(randStr);
A more Qt/C++ code for this would be:

static const int DirNameLength = 6;
QString dirName;
for (i = 0; i < DirNameLength; ++i) {
    dirName += QLatin1String(letters[qrand() % qstrlen(letters)]);
}
QString dirPath =
QString(QLatin1String("%1/%2")).arg(QDir::tempPath()).arg(dirName));

+        cacheDir = QString::fromLatin1(qgetenv("HOME") + "/.cache");
This should be:
cacheDir = QString(QLatin1String("%1/.cache").arg(qgetenv("HOME")));

+    QString path = QString::fromLatin1("%1/telepathy/avatars/%2/%3").
+       
arg(cacheDir).arg(connection->cmName()).arg(connection->protocolName());
should be:
QString path = QString(QLatin1String("%1/telepathy/avatars/%2/%3"))
    .arg(cacheDir).arg(connection->cmName()).arg(connection->protocolName());

In other words do not use QString::fromLatin1 anywhere.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.



More information about the telepathy-bugs mailing list