Beispiel #1
0
void BrowserApplication::saveSession()
{
    if (quiting)
        return;
    QSettings settings;
    settings.beginGroup(QLatin1String("MainWindow"));
    settings.setValue(QLatin1String("restoring"), false);
    settings.endGroup();

    QWebSettings *globalSettings = QWebSettings::globalSettings();
    if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
        return;

    clean();

    settings.beginGroup(QLatin1String("sessions"));

    int version = 2;

    QByteArray data;
    QBuffer buffer(&data);
    QDataStream stream(&buffer);
    buffer.open(QIODevice::WriteOnly);

    stream << qint32(BrowserApplicationMagic);
    stream << qint32(version);

    stream << qint32(m_mainWindows.count());
    for (int i = 0; i < m_mainWindows.count(); ++i)
        stream << m_mainWindows.at(i)->saveState();
    settings.setValue(QLatin1String("lastSession"), data);
    settings.endGroup();
}
Beispiel #2
0
void MyServer::sendFriendGroup(const QVector<groupInfo>& groups,socketClients* client)
{
    int size = groups.count();
   QTcpSocket* socket = client->getSocket();

   QByteArray data;
   QDataStream in(&data,QIODevice::WriteOnly);
   in.setVersion(QDataStream::Qt_5_0);

   in<<qint32(0)<<qint8(respondType::friendGroup);
    QVector<int> friendsID;
    for (int i=0;i<size;i++) {
        in<<groups[i].name;
        // 将每一个分组下的所有好友信息封装在一起,再发送出去
        if (groups[i].total<=0) continue;
        model.getFriendsID(friendsID, groups[i].id);
        for (int j=0;j<friendsID.count();j++) {
            userInfo* info = model.getFriendsInfo(friendsID[j]);
            if ( hx.contains(info->account) ) {
                makeFriendInfo(in,info,clients.at( hx[ info->account ] )->getUserState() );
            }
            else {
                makeFriendInfo(in,info,userStateType::offline );
            }
            delete info;
        }
    }
    in.device()->seek(0);
    in<<qint32(data.size()-sizeof(qint32));
    socket->write(data);
}
void QNodeViewCanvas::drawBackground(QPainter* painter, const QRectF& rect)
{
    // GW-TODO: Expose this to QStyle
    painter->fillRect(rect, QBrush(QColor(50, 50, 50)));

    const qint32 gridInterval = 50;
    painter->setWorldMatrixEnabled(true);

    // GW-TODO: Expose this to QStyle
    QPen linePen(QColor(80, 80, 80), 1, Qt::DotLine, Qt::FlatCap, Qt::RoundJoin);
    linePen.setCosmetic(true); // Performance optimization
    painter->setPen(linePen);

    const qreal left = qint32(rect.left()) - (qint32(rect.left()) % gridInterval);
    const qreal top  = qint32(rect.top())  - (qint32(rect.top())  % gridInterval);

    QVarLengthArray<QLineF, 100> linesX;
    for (qreal x = left; x < rect.right(); x += gridInterval)
        linesX.append(QLineF(x, rect.top(), x, rect.bottom()));

    QVarLengthArray<QLineF, 100> linesY;
    for (qreal y = top; y < rect.bottom(); y += gridInterval)
        linesY.append(QLineF(rect.left(), y, rect.right(), y));

    painter->drawLines(linesX.data(), linesX.size());
    painter->drawLines(linesY.data(), linesY.size());
}
Beispiel #4
0
QDataStream &operator<<(QDataStream &stream, const Stitch &stitch)
{
    stream << qint32(stitch.version);
    stream << qint32(stitch.type);
    stream << qint32(stitch.colorIndex);
    return stream;
}
Beispiel #5
0
	void writeDraftPositions(const PeerId &peer, const MessageCursor &cur) {
		if (!_working()) return;

		if (cur.position == 0 && cur.anchor == 0 && cur.scroll == 0) {
			DraftsMap::iterator i = _draftsPositionsMap.find(peer);
			if (i != _draftsPositionsMap.cend()) {
				clearKey(i.value());
				_draftsPositionsMap.erase(i);
				_mapChanged = true;
				_writeMap();
			}
		} else {
			DraftsMap::const_iterator i = _draftsPositionsMap.constFind(peer);
			if (i == _draftsPositionsMap.cend()) {
				i = _draftsPositionsMap.insert(peer, genKey());
				_mapChanged = true;
				_writeMap(WriteMapFast);
			}
			QString to = _basePath + toFilePart(i.value());
			EncryptedDescriptor data(sizeof(quint64) + sizeof(qint32) * 3);
			data.stream << quint64(peer) << qint32(cur.position) << qint32(cur.anchor) << qint32(cur.scroll);
			FileWriteDescriptor file(i.value());
			file.writeEncrypted(data);
		}
	}
Beispiel #6
0
QByteArray DcOptions::serialize() const {
	if (_immutable) {
		// Don't write the overriden options to our settings.
		return DcOptions().serialize();
	}

	QReadLocker lock(&_mutex);

	auto size = sizeof(qint32);
	for (auto &item : _data) {
		size += sizeof(qint32) + sizeof(qint32) + sizeof(qint32); // id + flags + port
		size += sizeof(qint32) + item.second.ip.size();
	}

	auto result = QByteArray();
	result.reserve(size);
	{
		QBuffer buffer(&result);
		if (!buffer.open(QIODevice::WriteOnly)) {
			LOG(("MTP Error: Can't open data for DcOptions::serialize()"));
			return result;
		}

		QDataStream stream(&buffer);
		stream.setVersion(QDataStream::Qt_5_1);
		stream << qint32(_data.size());
		for (auto &item : _data) {
			stream << qint32(item.second.id) << qint32(item.second.flags) << qint32(item.second.port);
			stream << qint32(item.second.ip.size());
			stream.writeRawData(item.second.ip.data(), item.second.ip.size());
		}
	}
	return result;
}
QDataStream& operator<<(QDataStream& s, const CommandlineOptions& a) {
  s << qint32(a.player_action_) << qint32(a.url_list_action_) << a.set_volume_
    << a.volume_modifier_ << a.seek_to_ << a.seek_by_ << a.play_track_at_
    << a.show_osd_ << a.urls_ << a.log_levels_ << a.toggle_pretty_osd_;

  return s;
}
void BattleCommunicator::spectatingChat(int player, int battle, const QString &chat)
{
    if (!contains(battle)) {
        return;
    }

    relay->notify(SpectatingBattleChat, qint32(battle), qint32(player), chat);
}
void BattleCommunicator::resendBattleInfos(int player, int battle)
{
    if (!contains(battle)) {
        return;
    }

    relay->notify(SpectateBattle, qint32(battle), true, qint32(player));
}
Beispiel #10
0
void MyServer::makeUserInfo(qint64 id)
{
    QDataStream in(&bufBlock,QIODevice::WriteOnly);
    in.setVersion(QDataStream::Qt_5_0);
    in<<qint32(0)<<qint8(respondType::registeOk);
    in<<qint64(id+N)<<qint8(1)<<QString("编辑个性签名")<<QString("head1.png");
    in.device()->seek(0);
    in<<qint32(bufBlock.size() - sizeof(qint32));
}
Beispiel #11
0
void QCacheItem::writeHeader(QFile *device) const
{
    QDataStream out(device);

    out << qint32(CacheMagic);
    out << qint32(CurrentCacheVersion);
    out << metaData;
    bool compressed = canCompress();
    out << compressed;
}
Beispiel #12
0
QByteArray *sql::sendDescriptor(int descrip)
{
    QByteArray *data=new QByteArray;
    QDataStream in(data,QIODevice::WriteOnly);
    in.setVersion(QDataStream::Qt_5_0);
    in<<qint32(0)<<qint8(respondType::descriptor)<<qint32(descrip);
    in.device()->seek(0);
    in<<qint32(data->size() - sizeof(qint32));
    return data;
}
void BattleCommunicator::playerForfeit(int battleid, int forfeiter)
{
    relay->notify(BattleFinished, qint32(battleid), uchar(Forfeit), qint32(forfeiter));

    /* Manually send the forfeit to everyone since we're going to remove the battle soon and so not forward anymore of its messages */
    if (contains(battleid)) {
        mybattles[battleid]->finished() = true;
        showResult(battleid, Forfeit, forfeiter);
    }
}
void BattleCommunicator::removeSpectator(int idOfBattle, int id)
{
    if (!contains(idOfBattle)) {
        qFatal("Critical bug needing to be solved: BattleCommunicator::removeSpectator, player %d and non-existent battle %d", id, idOfBattle);
    } else {
        mybattles[idOfBattle]->spectators.remove(id);

        relay->notify(SpectateBattle, qint32(idOfBattle), false, qint32(id));
    }
}
Beispiel #15
0
QByteArray *sql::getErrorData(QString str, int type)
{
    QByteArray *data = new QByteArray;
    QDataStream in(data,QIODevice::WriteOnly);
    in.setVersion(QDataStream::Qt_5_0);
    in<<qint32(0)<<qint8(type)<<str;
    in.device()->seek(0);
    in<<qint32(data->size() - sizeof(qint32));
    return data;
}
QByteArray NetworkCookieJar::saveState () const
{
    int version = 1;
    QByteArray data;
    QDataStream stream(&data, QIODevice::WriteOnly);

    stream << qint32(NetworkCookieJarMagic);
    stream << qint32(version);
    stream << d->tree;
    return data;
}
Beispiel #17
0
QByteArray QRecentFilesMenu::saveState() const
{
    int version = 0;
    QByteArray data;
    QDataStream stream(&data, QIODevice::WriteOnly);

    stream << qint32(RecentFilesMenuMagic);
    stream << qint32(version);
    stream << m_files;

    return data;
}
void DouyuTcpSocket::messageWrite(QString &content)
{
    const char *content_ptr = content.toStdString().c_str();
    QDataStream sendOut(&outBlock,QIODevice::WriteOnly);
    qint32 length = 4 + 4 + content.length() + 1;// 2个uint32字段长度+内容长度+'\0'
    sendOut<<qint32(hexReverse_qint32(length))<<qint32(hexReverse_qint32(length))<<qint32(_Douyu_CTS_Num);
    outBlock.append(content_ptr);
    outBlock.append('\0');
    tcpDanmuSoc.write(outBlock);
    outBlock.resize(0);
    delete content_ptr;
}
Beispiel #19
0
QDataStream&operator<<(QDataStream& out, const Slab& slab)
{
    out << qint32(slab.typeID());
    out << slab.name();
    out << qint32(slab.width());
    out << qint32(slab.height());
    out << slab.colour();
    out << slab.isCollided();
    out << qint32(slab.zValue());

    return out;
}
Beispiel #20
0
// 用于返回好友列表    封装用户基本信息>>bufBlock
void MyServer::makeUserInfo(userInfo *info, qint8 state, qint8 type)
{
    bufBlock.resize(0);
    QDataStream in(&bufBlock,QIODevice::WriteOnly);
    in.setVersion(QDataStream::Qt_5_0);
    in<<qint32(0)<<type;
    in<<info->account<<info->nick<<qint8(info->level) <<info->signatrue<<qint8(state);
    QPixmap pix(QString(":/image/") +  info->headImage);
    in<<pix;
    in.device()->seek(0);
    in<<qint32(bufBlock.size() - sizeof(qint32));
}
Beispiel #21
0
QDataStream &operator<<(QDataStream &out, const GameState::State &data)
{
   out << qint8(data.eastPosition)
       << qint8(data.winnerPosition);

   for (int i = 0; i < 4; ++i)
   {
       out <<        data.playersSet[i]
           << qint32(data.scores    [i])
           << qint32(data.overall   [i]);
   }
   return out;
}
Beispiel #22
0
void MyServer::makeTextChat(QMap<QString, QVariant> map)
{
    bufBlock.resize(0);
    QDataStream in(&bufBlock,QIODevice::WriteOnly);
    in.setVersion(QDataStream::Qt_5_0);

    in<<qint32(0)<<qint8(respondType::chat)<<qint8(respondType::textChat);
    in<<map["fromAccount"].toString()<<map["content"].toString();
    in<<map["time"].toDateTime();

    in.device()->seek(0);
    in<<qint32(bufBlock.size() - sizeof(qint32));
}
Beispiel #23
0
/*******************************************************************************
    QDataStream operator
*******************************************************************************/
QDataStream& operator<<(QDataStream& s, const CommandlineOptions& a)
{
    s << qint32(a._player_action)
      << qint32(a._playlist_action)
      << a._set_volume
      << a._volume_modifier
      << a._seek_to
      << a._seek_by
      << a._play_track_at
      << a._urls;

    return s;
}
QDataStream &operator<<(QDataStream &out, const QScriptScriptData &data)
{
    const QScriptScriptDataPrivate *d = data.d_ptr.data();
    if (d) {
        out << d->contents;
        out << d->fileName;
        out << qint32(d->baseLineNumber);
    } else {
        out << QString();
        out << QString();
        out << qint32(0);
    }
    return out;
}
Beispiel #25
0
void MyServer::makeUserRecommd(userInfo *info,int limit, int type)
{
    bufBlock.resize(0);
    QDataStream in(&bufBlock,QIODevice::WriteOnly);
    in.setVersion(QDataStream::Qt_5_0);
    in<<qint32(0)<<qint8(type) <<qint8(limit) ;
    for (int i=0;i<limit;i++ ) {
        in<<qint32(info[i].id)<<info[i].nick;   qDebug()<<" for "<<info[i].id<<" "<<info[i].nick<<" "<<info[i].headImage;
        QPixmap pix(QString(":/image/") +  info[i].headImage);
        in<<pix;
    }
    in.device()->seek(0);
    in<<qint32(bufBlock.size() - sizeof(qint32));
}
Beispiel #26
0
void KeyboardPrivate::keyboard_repeat_info(int32_t rate, int32_t delay)
{
    Q_Q(Keyboard);

    if (qint32(repeatRate) != rate) {
        repeatRate = qMax(rate, 0);
        Q_EMIT q->repeatRateChanged();
    }

    if (qint32(repeatDelay) != delay) {
        repeatDelay = qMax(delay, 0);
        Q_EMIT q->repeatDelayChanged();
    }
}
Beispiel #27
0
void MyServer::makeUserInfo(userInfo *info,qint8 state)
{
    bufBlock.resize(0);
    QDataStream in(&bufBlock,QIODevice::WriteOnly);
    in.setVersion(QDataStream::Qt_5_0);
    in<<qint32(0)<<qint8(respondType::loginOk);
    in<<info->nick<<qint8(info->level) <<info->signatrue<<qint8(state);
    QByteArray data = getHeadImage( QString(":/image/") +  info->headImage);
    in<<qint32(data.size());
    bufBlock.append( data );

    in.device()->seek(0);
    in<<qint32(bufBlock.size() - sizeof(qint32));
}
Beispiel #28
0
QDataStream &operator<<(QDataStream &out, const ImageContainer &container)
{
    out << container.instanceId();

    const QImage image = container.image();
    const QByteArray data(reinterpret_cast<const char*>(image.constBits()), image.byteCount());

    out << qint32(image.bytesPerLine());
    out << image.size();
    out << qint32(image.format());
    out << qint32(image.byteCount());
    out.writeRawData(reinterpret_cast<const char*>(image.constBits()), image.byteCount());

    return out;
}
Beispiel #29
0
void MyServer::sendGroupSize(const QVector<groupInfo> &groups, socketClients *client)
{
    int size = groups.count();
    QDataStream in(&bufBlock,QIODevice::WriteOnly);
    in.setVersion(QDataStream::Qt_5_0);

    // 	好友分组个数上限 : qint8
    in<<qint32(0)<<qint8(respondType::friendGroupSize)<<qint8(size);
    for (int i=0;i<size;i++) {     //  qDebug()<<size<<" ,  "<<groups[i].name<<" , "<<groups[i].total;
        in<<qint32(groups[i].total)<<groups[i].name;
    }
    bufferHead(in);
    client->getSocket()->write(bufBlock);
    bufBlock.resize(0);
}
inline bool QStorageIterator::next()
{
    BVolume volume;

    if (m_volumeRoster.GetNextVolume(&volume) != B_OK)
        return false;

    BDirectory directory;
    if (volume.GetRootDirectory(&directory) != B_OK)
        return false;

    const BPath path(&directory);

    fs_info fsInfo;
    memset(&fsInfo, 0, sizeof(fsInfo));

    if (fs_stat_dev(volume.Device(), &fsInfo) != 0)
        return false;

    m_rootPath = path.Path();
    m_fileSystemType = QByteArray(fsInfo.fsh_name);

    const QByteArray deviceName(fsInfo.device_name);
    m_device = (deviceName.isEmpty() ? QByteArray::number(qint32(volume.Device())) : deviceName);

    return true;
}