connect(this, SIGNAL(fetchImage(QUrl)), m_imageFetcher, SLOT(fetchImage(QUrl)));
connect(m_imageFetcher, SIGNAL(imageReceived(QUrl,QPixmap)), this,
SLOT(imageReceived(QUrl, QPixmap)));
+ connect(m_imageFetcher, SIGNAL(error(QString)), this, SIGNAL(error(QString)));
m_user = NULL;
}
if (reply->error()) {
qDebug() << reply->errorString();
emit error(reply->errorString());
- // ToDo: some general http error handling etc, signal UI?
}
else {
qint64 max = reply->size();
// -> we get only error for wrong lon
if(replyArray == ERROR_LAT.toAscii()) {
qDebug() << "Error: " << ERROR_LAT;
- // ToDo: signal UI?
emit error(replyArray);
}
else if(replyArray == ERROR_LON.toAscii()) {
qDebug() << "Error: " << ERROR_LON;
- // ToDo: signal UI?
emit error(replyArray);
}
else if(replyArray.contains(ERROR_SESSION.toAscii())) {
qDebug() << "Error: " << ERROR_SESSION;
- // ToDo: signal UI?
emit error(replyArray);
}
else if(replyArray.startsWith(OPENING_BRACE_MARK.toAscii())) {
}
else if(replyArray == "") {
qDebug() << "No error, update was successful";
+ // ToDo: signal UI?
}
else {
// Street address ready
m_visited = 0;
m_nbrOfImages = 0;
+ m_defaultImage = false;
qDeleteAll(m_friendsList.begin(), m_friendsList.end());
m_friendsList.clear();
QUrl imageUrl = userMap["profile_pic"].toUrl();
+ if(imageUrl.isEmpty()) {
+ m_defaultImage = true;
+ }
+
m_user = new User(userMap["address"].toString(), coordinates, userMap["name"].toString(),
userMap["note"].toString(), imageUrl, userMap["timestamp"].toString(),
true, userMap["uid"].toString());
QUrl imageUrl = friendMap["profile_pic"].toUrl();
+ if(imageUrl.isEmpty()) {
+ m_defaultImage = true;
+ }
+
User *user = new User(friendMap["address"].toString(), coordinates, friendMap["name"].toString(),
friendMap["note"].toString(), imageUrl, friendMap["timestamp"].toString(),
false, friendMap["uid"].toString(), distanceMap["units"].toString(),
qDebug() << __PRETTY_FUNCTION__;
qDebug() << "Image URL: " << url << " size :" << image.size();
+ // assign facebook silhouette image to all who doesn't have a profile image
+ if(url == QUrl(SILHOUETTE_URL)) {
+ if(m_user->profileImageUrl().isEmpty()) {
+ m_user->setProfileImage(image);
+ }
+ for(int i=0;i < m_friendsList.count();i++) {
+ if(m_friendsList.at(i)->profileImageUrl().isEmpty()) {
+ m_friendsList.at(i)->setProfileImage(image);
+ }
+ }
+ }
+
if(m_user->profileImageUrl() == url) {
m_user->setProfileImage(image);
}
{
qDebug() << __PRETTY_FUNCTION__;
- if(!m_user->profileImageUrl().isEmpty() && m_user->profileImageUrl().isValid()) {
+ // reduce net traffic by sending only one download request for facebook silhouette image
+ if(m_defaultImage) {
+ emit fetchImage(QUrl(SILHOUETTE_URL));
+ }
+
+ if(!m_user->profileImageUrl().isEmpty()) {
emit fetchImage(m_user->profileImageUrl());
}
for(int i=0;i<m_friendsList.count();i++) {
- if(!m_friendsList.at(i)->profileImageUrl().isEmpty() && m_user->profileImageUrl().isValid()) {
+ if(!m_friendsList.at(i)->profileImageUrl().isEmpty()) {
m_visited++; // indicates how many friends that have profile image
emit fetchImage(m_friendsList.at(i)->profileImageUrl());
}