void buddyPicture::readSnac(quint16 length) { snac snacPacket; snacPacket.readData(buffer); length -= 10; switch ( snacPacket.getFamily()) { case 0x0001: switch(snacPacket.getSubType()) { case 0x0003: buffer->read(length); length = 0; if ( !alreadySentCap) sendCapab(); break; case 0x0007: buffer->read(length); length = 0; sendRateInfoClientReady(); break; case 0x0018: buffer->read(length); length = 0; sendInfoReq(); break; default: ; } break; case 0x0010: switch(snacPacket.getSubType()) { case 0x0007: saveAvatar(length); length = 0; break; default: ; } break; default: ; } if (length) buffer->read(length); if ( buffer->bytesAvailable() ) { readDataFromSocket(); } }
void Profile::setPassword(QString newPassword) { QList<HistoryKeeper::HistMessage> oldMessages = HistoryKeeper::exportMessagesDeleteFile(); QByteArray avatar = loadAvatarData(core->getSelfId().publicKey); password = newPassword; passkey = *core->createPasskey(password); saveToxSave(); HistoryKeeper::getInstance()->importMessages(oldMessages); Nexus::getDesktopGUI()->reloadHistory(); saveAvatar(avatar, core->getSelfId().publicKey); }
void BusinessCardHandling::storeAvatarToContact(QString phoneNumber, QString filename, QPixmap pixmap) { // Create QContactManager if (!m_contactManager) { createContactManager(); } // Search contacts and save avatar QContact contact; if (findContact(phoneNumber, contact)) { saveAvatar(filename, pixmap, contact); } }
/** * @brief Changes the encryption password and re-saves everything with it * @param newPassword Password for encryption. */ void Profile::setPassword(const QString& newPassword) { QByteArray avatar = loadAvatarData(core->getSelfId().publicKey); QString oldPassword = password; password = newPassword; passkey = *core->createPasskey(password); saveToxSave(); if (database) { database->setPassword(newPassword); } Nexus::getDesktopGUI()->reloadHistory(); saveAvatar(avatar, core->getSelfId().publicKey); QVector<uint32_t> friendList = core->getFriendList(); QVectorIterator<uint32_t> i(friendList); while (i.hasNext()) { QString friendPublicKey = core->getFriendPublicKey(i.next()); saveAvatar(loadAvatarData(friendPublicKey,oldPassword),friendPublicKey); } }
void HistoryKeeper::importAvatarToDatabase(const QString& ownerId) { if (needImport) { QString puth (Settings::getInstance().getSettingsDirPath() + QString("avatars") + QDir::separator() + ownerId +".png"); qDebug() << QString("Try import avatar for: %1.").arg(ownerId); getAliasID(ownerId); if (QFile::exists(puth) && !hasAvatar(ownerId)) { QPixmap pic(puth); saveAvatar(pic,ownerId); qDebug() << QString("Import avatar for: %1.").arg(ownerId); } } }
QPixmap Settings::getSavedAvatar(const QString &ownerId) { QDir dir(getSettingsDirPath()); QString filePath = dir.filePath("avatars/"+ownerId.left(64)+".png"); QFileInfo info(filePath); QPixmap pic; if (!info.exists()) { QString filePath = dir.filePath("avatar_"+ownerId.left(64)); if (!QFileInfo(filePath).exists()) // try without truncation, for old self avatars filePath = dir.filePath("avatar_"+ownerId); pic.load(filePath); saveAvatar(pic, ownerId); QFile::remove(filePath); } else pic.load(filePath); return pic; }
CardEditor::CardEditor(QWidget *parent) : QMainWindow(parent) { setWindowTitle(tr("Card editor")); QHBoxLayout *layout = new QHBoxLayout; QGraphicsView *view = new QGraphicsView; view->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing); card_scene = new CardScene; connect(card_scene, SIGNAL(avatar_snapped(QRectF)), this, SLOT(saveAvatar(QRectF))); view->setScene(card_scene); view->setFixedSize(card_scene->sceneRect().width() + 2, card_scene->sceneRect().height() + 2); layout->addWidget(createLeft()); layout->addWidget(view); QWidget *central_widget = new QWidget; central_widget->setLayout(layout); setCentralWidget(central_widget); QMenuBar *menu_bar = new QMenuBar; setMenuBar(menu_bar); QMenu *file_menu = new QMenu(tr("File")); QAction *import = new QAction(tr("Import ..."), file_menu); import->setShortcut(Qt::CTRL + Qt::Key_O); QAction *save = new QAction(tr("Save ..."), file_menu); save->setShortcut(Qt::CTRL + Qt::Key_S); QAction *exit = new QAction(tr("Exit"), file_menu); exit->setShortcut(Qt::CTRL + Qt::Key_Q); file_menu->addAction(import); file_menu->addAction(save); file_menu->addSeparator(); file_menu->addAction(exit); menu_bar->addMenu(file_menu); connect(import, SIGNAL(triggered()), this, SLOT(import())); connect(save, SIGNAL(triggered()), this, SLOT(saveImage())); connect(exit, SIGNAL(triggered()), this, SLOT(close())); QMenu *tool_menu = new QMenu(tr("Tool")); QAction *making_big = new QAction(tr("Make big avatar"), tool_menu); making_big->setShortcut(Qt::ALT + Qt::Key_B); connect(making_big, SIGNAL(triggered()), card_scene, SLOT(makeBigAvatar())); tool_menu->addAction(making_big); QAction *making_small = new QAction(tr("Make small avatar"), tool_menu); making_small->setShortcut(Qt::ALT + Qt::Key_M); connect(making_small, SIGNAL(triggered()), card_scene, SLOT(makeSmallAvatar())); tool_menu->addAction(making_small); QAction *making_tiny = new QAction(tr("Make tiny avatar"), tool_menu); making_tiny->setShortcut(Qt::ALT + Qt::Key_T); connect(making_tiny, SIGNAL(triggered()), card_scene, SLOT(makeTinyAvatar())); tool_menu->addAction(making_tiny); QAction *hiding_rect = new QAction(tr("Hide avatar rect"), tool_menu); hiding_rect->setShortcut(Qt::ALT + Qt::Key_H); connect(hiding_rect, SIGNAL(triggered()), card_scene, SLOT(hideAvatarRects())); tool_menu->addAction(hiding_rect); tool_menu->addSeparator(); QAction *reset_photo = new QAction(tr("Reset photo"), tool_menu); reset_photo->setShortcut(Qt::ALT + Qt::Key_R); connect(reset_photo, SIGNAL(triggered()), card_scene, SLOT(resetPhoto())); tool_menu->addAction(reset_photo); QAction *copy_photo = new QAction(tr("Copy photo to clipboard"), tool_menu); copy_photo->setShortcut(Qt::CTRL + Qt::Key_C); connect(copy_photo, SIGNAL(triggered()), this, SLOT(copyPhoto())); tool_menu->addAction(copy_photo); menu_bar->addMenu(tool_menu); card_scene->setMenu(tool_menu); }