void buddyPicture::saveAvatar(quint16 length) { quint8 uinLength = convertToInt8(buffer->read(1)); length -= 1; QString uin = QString::fromUtf8(buffer->read(uinLength)); length -= uinLength; buffer->read(4); length -= 4; QByteArray hash = buffer->read(16); length -= 16; buffer->read(21); length -= 21; quint16 iconLength = convertToInt16(buffer->read(2)); length -= 2; if ( iconLength ) { QSettings settings(QSettings::NativeFormat, QSettings::UserScope, "qutim/qutim."+m_profile_name+"/ICQ."+m_mine_uin, "contactlist"); settings.beginGroup(uin); settings.setValue("iconhash", hash.toHex()); settings.endGroup(); QString iconPath = settings.fileName().section('/', 0, -3) + "/icqicons"; QDir iconDir(iconPath); if ( !iconDir.exists() ) iconDir.mkpath(iconPath); QFile iconFile(iconPath + "/" + hash.toHex()); if ( iconFile.open(QIODevice::WriteOnly) ) { iconFile.write(buffer->read(iconLength)); } emit updateAvatar(uin, hash); } length -= iconLength; if ( length ) buffer->read(length); }
TInt16 TDataToInt16(const TData *context) { if (context) return convertToInt16(context->data, context->type); return 0; }