void FullInfoMetaRequestPrivate::handleMoreInfo(const DataUnit &data) { quint16 age = data.read<quint16>(LittleEndian); if (age != 0) values.insert(Age, age); { quint8 genderId = data.read<quint8>(); if (genderId) values.insert(Gender, genders().value(genderId)); } readString(Homepage, data); { quint16 y = data.read<quint16>(LittleEndian); quint8 m = data.read<quint8>(); quint8 d = data.read<quint8>(); if (QDate::isValid(y, m, d)) values.insert(Birthday, QDate(y, m, d)); } { QStringList langList; for (int i = 0; i < 3; ++i) { QString lang = languages().value(data.read<quint8>()); if (!lang.isEmpty()) langList << lang; } if (!langList.isEmpty()) values.insert(Languages, langList); } data.skipData(2); // 0x0000 unknown readString(OriginalCity, data); readString(OriginalState, data); readField<quint16>(OriginalCountry, data, countries()); values.insert(GMT, data.read<qint8>()); }
bool FindContactsMetaRequest::handleData(quint16 type, const DataUnit &data) { Q_D(FindContactsMetaRequest); if (type != 0x01A4 && type != 0x01AE) return false; data.skipData(2); // data size FoundContact contact; contact.uin = QString::number(data.read<quint32>(LittleEndian)); contact.nick = readSString(data); contact.firstName = readSString(data); contact.lastName = readSString(data); contact.email = readSString(data); contact.authFlag = data.read<quint8>(); contact.status = static_cast<Status>(data.read<quint16>(LittleEndian)); contact.gender = genders().value(data.read<quint8>()); contact.age = data.read<quint16>(LittleEndian); qDebug() << "Contact found" << contact.uin << contact.nick << contact.firstName << contact.lastName << contact.email << contact.authFlag << contact.status << contact.gender << contact.age; emit contactFound(contact); d->contacts.insert(contact.uin, contact); if (type == 0x01AE) close(true); return true; }
bool ShortInfoMetaRequest::handleData(quint16 type, const DataUnit &data) { Q_D(ShortInfoMetaRequest); if (type != 0x0104) return false; d->readString(Nick, data); d->readString(FirstName, data); d->readString(LastName, data); d->readString(Email, data); d->readFlag(AuthFlag, data); data.skipData(2); // 0x00 unknown { quint8 genderId = data.read<quint8>(); if (genderId) d->values.insert(Gender, genders().value(genderId)); } debug() << d->uin << "short info:"; d->dump(); close(true); return true; }
int main(int argc, char *argv[]) { std::ifstream info(INFO_FILENAME.c_str()); std::ofstream genders(GENDERS_FILENAME.c_str()); while(!info.eof()) { // static int debug = 1; // if(debug++ > 100) break; std::string name; std::getline(info, name, '\t'); FaceDescriptor descriptor; int x, y; info >> x >> y; descriptor.leftEye = cv::Point(x, y); info >> x >> y; descriptor.rightEye = cv::Point(x, y); info >> x >> y; descriptor.nose = cv::Point(x, y); info >> x >> y; descriptor.mouth = cv::Point(x, y); std::string gender; std::getline(info, gender, '\n'); std::stringstream imageFilename; imageFilename << RAWS_PATH << name; cv::Mat image = cv::imread(imageFilename.str(), 0); cv::Mat normalizedImage = FaceNormalizer::Normalize(image, descriptor); std::stringstream normalizedFilename; normalizedFilename << NORMALIZED_PATH << name; cv::imwrite(normalizedFilename.str(), normalizedImage); genders << name << '\t' << gender << std::endl; } info.close(); genders.close(); return 0; }