remove crufty unused functions, used constBegin/End for iterations, store itEnd during loop, various other cleanups
This commit is contained in:
parent
e325037fdd
commit
c6d0c57d5f
|
|
@ -24,10 +24,9 @@ ClientPrivate::~ClientPrivate()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientPrivate::init(QObject *parent)
|
void ClientPrivate::init(const QUrl &connectionString)
|
||||||
{
|
{
|
||||||
Q_Q(Client);
|
Q_Q(Client);
|
||||||
q->setParent(parent);
|
|
||||||
if (!network_) {
|
if (!network_) {
|
||||||
network_ = new Network(q);
|
network_ = new Network(q);
|
||||||
QObject::connect(network_.data(), SIGNAL(connected()), q, SIGNAL(connected()));
|
QObject::connect(network_.data(), SIGNAL(connected()), q, SIGNAL(connected()));
|
||||||
|
|
@ -38,42 +37,21 @@ void ClientPrivate::init(QObject *parent)
|
||||||
connection_ = new Connection(q);
|
connection_ = new Connection(q);
|
||||||
network_->setMethodHandlerConnection(connection_);
|
network_->setMethodHandlerConnection(connection_);
|
||||||
|
|
||||||
setAuth(new AMQPlainAuthenticator(QString::fromLatin1(AMQPLOGIN), QString::fromLatin1(AMQPPSWD)));
|
auth_ = QSharedPointer<Authenticator>(
|
||||||
|
new AMQPlainAuthenticator(QString::fromLatin1(AMQPLOGIN), QString::fromLatin1(AMQPPSWD)));
|
||||||
|
|
||||||
QObject::connect(connection_, SIGNAL(connected()), q, SIGNAL(connected()));
|
QObject::connect(connection_, SIGNAL(connected()), q, SIGNAL(connected()));
|
||||||
QObject::connect(connection_, SIGNAL(disconnected()), q, SIGNAL(disconnected()));
|
QObject::connect(connection_, SIGNAL(disconnected()), q, SIGNAL(disconnected()));
|
||||||
}
|
|
||||||
|
|
||||||
void ClientPrivate::init(QObject *parent, const QUrl &connectionString)
|
if (connectionString.isValid()) {
|
||||||
{
|
|
||||||
init(parent);
|
|
||||||
parseConnectionString(connectionString);
|
parseConnectionString(connectionString);
|
||||||
connect();
|
connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientPrivate::setAuth(Authenticator *auth)
|
|
||||||
{
|
|
||||||
auth_ = QSharedPointer<Authenticator>(auth);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClientPrivate::printConnect() const
|
|
||||||
{
|
|
||||||
QTextStream stream(stdout);
|
|
||||||
stream << "port = " << port << endl;
|
|
||||||
stream << "host = " << host << endl;
|
|
||||||
stream << "vhost = " << virtualHost << endl;
|
|
||||||
|
|
||||||
if (auth_ && auth_->type() == QLatin1String("AMQPLAIN")) {
|
|
||||||
QSharedPointer<AMQPlainAuthenticator> a = auth_.staticCast<AMQPlainAuthenticator>();
|
|
||||||
stream << "user = " << a->login() << endl;
|
|
||||||
stream << "passw = " << a->password() << endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientPrivate::connect()
|
void ClientPrivate::connect()
|
||||||
{
|
{
|
||||||
sockConnect();
|
sockConnect();
|
||||||
login();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientPrivate::parseConnectionString(const QUrl &connectionString)
|
void ClientPrivate::parseConnectionString(const QUrl &connectionString)
|
||||||
|
|
@ -100,10 +78,6 @@ void ClientPrivate::sockConnect()
|
||||||
network_->connectTo(host, port);
|
network_->connectTo(host, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientPrivate::login()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClientPrivate::disconnect()
|
void ClientPrivate::disconnect()
|
||||||
{
|
{
|
||||||
if (network_->state() == QAbstractSocket::UnconnectedState) {
|
if (network_->state() == QAbstractSocket::UnconnectedState) {
|
||||||
|
|
@ -121,13 +95,16 @@ Client::Client(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
d_ptr(new ClientPrivate(this))
|
d_ptr(new ClientPrivate(this))
|
||||||
{
|
{
|
||||||
d_ptr->init(parent);
|
Q_D(Client);
|
||||||
|
d->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
Client::Client(const QUrl &connectionString, QObject *parent)
|
Client::Client(const QUrl &connectionString, QObject *parent)
|
||||||
: d_ptr(new ClientPrivate(this))
|
: QObject(parent),
|
||||||
|
d_ptr(new ClientPrivate(this))
|
||||||
{
|
{
|
||||||
d_ptr->init(parent, connectionString);
|
Q_D(Client);
|
||||||
|
d->init(connectionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
Client::~Client()
|
Client::~Client()
|
||||||
|
|
@ -214,18 +191,6 @@ void Client::setPassword(const QString &password)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::printConnect() const
|
|
||||||
{
|
|
||||||
#ifdef _DEBUG
|
|
||||||
Q_D(const Client);
|
|
||||||
d->printConnect();
|
|
||||||
#endif // _DEBUG
|
|
||||||
}
|
|
||||||
|
|
||||||
void Client::closeChannel()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Exchange *Client::createExchange(int channelNumber)
|
Exchange *Client::createExchange(int channelNumber)
|
||||||
{
|
{
|
||||||
return createExchange(QString(), channelNumber);
|
return createExchange(QString(), channelNumber);
|
||||||
|
|
@ -269,7 +234,7 @@ Queue *Client::createQueue(const QString &name, int channelNumber)
|
||||||
void Client::setAuth(Authenticator *auth)
|
void Client::setAuth(Authenticator *auth)
|
||||||
{
|
{
|
||||||
Q_D(Client);
|
Q_D(Client);
|
||||||
d->setAuth(auth);
|
d->auth_ = QSharedPointer<Authenticator>(auth);
|
||||||
}
|
}
|
||||||
|
|
||||||
Authenticator *Client::auth() const
|
Authenticator *Client::auth() const
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,6 @@ public:
|
||||||
Client(const QUrl &connectionString, QObject *parent = 0);
|
Client(const QUrl &connectionString, QObject *parent = 0);
|
||||||
~Client();
|
~Client();
|
||||||
|
|
||||||
void printConnect() const;
|
|
||||||
void closeChannel();
|
|
||||||
|
|
||||||
void addCustomProperty(const QString &name, const QString &value);
|
void addCustomProperty(const QString &name, const QString &value);
|
||||||
QString customProperty(const QString &name) const;
|
QString customProperty(const QString &name) const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,16 +18,11 @@ public:
|
||||||
ClientPrivate(Client *q);
|
ClientPrivate(Client *q);
|
||||||
~ClientPrivate();
|
~ClientPrivate();
|
||||||
|
|
||||||
void init(QObject *parent);
|
void init(const QUrl &connectionString = QUrl());
|
||||||
void init(QObject *parent, const QUrl &connectionString);
|
|
||||||
|
|
||||||
void printConnect() const;
|
|
||||||
void connect();
|
void connect();
|
||||||
void disconnect();
|
void disconnect();
|
||||||
void parseConnectionString(const QUrl &connectionString);
|
void parseConnectionString(const QUrl &connectionString);
|
||||||
void sockConnect();
|
void sockConnect();
|
||||||
void login();
|
|
||||||
void setAuth(Authenticator* auth);
|
|
||||||
|
|
||||||
quint32 port;
|
quint32 port;
|
||||||
QString host;
|
QString host;
|
||||||
|
|
|
||||||
|
|
@ -224,10 +224,10 @@ void ExchangePrivate::publish(const QByteArray &message, const QString &key,
|
||||||
content.setProperty(Frame::Content::cpHeaders, headers);
|
content.setProperty(Frame::Content::cpHeaders, headers);
|
||||||
content.setProperty(Frame::Content::cpMessageId, "0");
|
content.setProperty(Frame::Content::cpMessageId, "0");
|
||||||
|
|
||||||
Exchange::MessageProperties::ConstIterator i;
|
Exchange::MessageProperties::ConstIterator it;
|
||||||
|
Exchange::MessageProperties::ConstIterator itEnd = prop.constEnd();
|
||||||
for (i = prop.begin(); i != prop.end(); ++i)
|
for (it = prop.constBegin(); it != itEnd; ++it)
|
||||||
content.setProperty(i.key(), i.value());
|
content.setProperty(it.key(), it.value());
|
||||||
|
|
||||||
content.setBody(message);
|
content.setBody(message);
|
||||||
sendFrame(content);
|
sendFrame(content);
|
||||||
|
|
|
||||||
|
|
@ -305,10 +305,11 @@ QDataStream & Frame::serialize(QDataStream &stream, const TableField &f)
|
||||||
{
|
{
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
QDataStream s(&data, QIODevice::WriteOnly);
|
QDataStream s(&data, QIODevice::WriteOnly);
|
||||||
TableField::ConstIterator i;
|
TableField::ConstIterator it;
|
||||||
for (i = f.begin(); i != f.end(); ++i) {
|
TableField::ConstIterator itEnd = f.constEnd();
|
||||||
writeField('s', s, i.key());
|
for (it = f.constBegin(); it != itEnd; ++it) {
|
||||||
writeField(s, i.value());
|
writeField('s', s, it.key());
|
||||||
|
writeField(s, it.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
|
|
@ -322,17 +323,18 @@ QDataStream & Frame::serialize(QDataStream &stream, const TableField &f)
|
||||||
|
|
||||||
void Frame::print(const TableField &f)
|
void Frame::print(const TableField &f)
|
||||||
{
|
{
|
||||||
TableField::ConstIterator i;
|
TableField::ConstIterator it;
|
||||||
for (i = f.begin(); i != f.end(); ++i) {
|
TableField::ConstIterator itEnd = f.constEnd();
|
||||||
switch(i.value().type()) {
|
for (it = f.constBegin(); it != itEnd; ++it) {
|
||||||
|
switch(it.value().type()) {
|
||||||
case QVariant::Hash:
|
case QVariant::Hash:
|
||||||
qDebug() << "\t" << qPrintable(i.key()) << ": FIELD_TABLE";
|
qDebug() << "\t" << qPrintable(it.key()) << ": FIELD_TABLE";
|
||||||
break;
|
break;
|
||||||
case QVariant::List:
|
case QVariant::List:
|
||||||
qDebug() << "\t" << qPrintable(i.key()) << ": ARRAY";
|
qDebug() << "\t" << qPrintable(it.key()) << ": ARRAY";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qDebug() << "\t" << qPrintable(i.key()) << ": " << i.value();
|
qDebug() << "\t" << qPrintable(it.key()) << ": " << it.value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -507,9 +507,10 @@ void QueuePrivate::_q_content(const Frame::Content &frame)
|
||||||
|
|
||||||
MessagePtr &message = messages_.last();
|
MessagePtr &message = messages_.last();
|
||||||
message->leftSize = frame.bodySize();
|
message->leftSize = frame.bodySize();
|
||||||
QHash<int, QVariant>::ConstIterator i;
|
QHash<int, QVariant>::ConstIterator it;
|
||||||
for (i = frame.properties_.begin(); i != frame.properties_.end(); ++i)
|
QHash<int, QVariant>::ConstIterator itEnd = frame.properties_.constEnd();
|
||||||
message->property[Message::MessageProperty(i.key())]= i.value();
|
for (it = frame.properties_.constBegin(); it != itEnd; ++it)
|
||||||
|
message->property[Message::MessageProperty(it.key())] = it.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueuePrivate::_q_body(const Frame::ContentBody &frame)
|
void QueuePrivate::_q_body(const Frame::ContentBody &frame)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue