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->setParent(parent);
|
||||
if (!network_) {
|
||||
network_ = new Network(q);
|
||||
QObject::connect(network_.data(), SIGNAL(connected()), q, SIGNAL(connected()));
|
||||
|
|
@ -38,42 +37,21 @@ void ClientPrivate::init(QObject *parent)
|
|||
connection_ = new Connection(q);
|
||||
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(disconnected()), q, SIGNAL(disconnected()));
|
||||
}
|
||||
|
||||
void ClientPrivate::init(QObject *parent, const QUrl &connectionString)
|
||||
{
|
||||
init(parent);
|
||||
if (connectionString.isValid()) {
|
||||
parseConnectionString(connectionString);
|
||||
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()
|
||||
{
|
||||
sockConnect();
|
||||
login();
|
||||
}
|
||||
|
||||
void ClientPrivate::parseConnectionString(const QUrl &connectionString)
|
||||
|
|
@ -100,10 +78,6 @@ void ClientPrivate::sockConnect()
|
|||
network_->connectTo(host, port);
|
||||
}
|
||||
|
||||
void ClientPrivate::login()
|
||||
{
|
||||
}
|
||||
|
||||
void ClientPrivate::disconnect()
|
||||
{
|
||||
if (network_->state() == QAbstractSocket::UnconnectedState) {
|
||||
|
|
@ -121,13 +95,16 @@ Client::Client(QObject *parent)
|
|||
: QObject(parent),
|
||||
d_ptr(new ClientPrivate(this))
|
||||
{
|
||||
d_ptr->init(parent);
|
||||
Q_D(Client);
|
||||
d->init();
|
||||
}
|
||||
|
||||
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()
|
||||
|
|
@ -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)
|
||||
{
|
||||
return createExchange(QString(), channelNumber);
|
||||
|
|
@ -269,7 +234,7 @@ Queue *Client::createQueue(const QString &name, int channelNumber)
|
|||
void Client::setAuth(Authenticator *auth)
|
||||
{
|
||||
Q_D(Client);
|
||||
d->setAuth(auth);
|
||||
d->auth_ = QSharedPointer<Authenticator>(auth);
|
||||
}
|
||||
|
||||
Authenticator *Client::auth() const
|
||||
|
|
|
|||
|
|
@ -32,9 +32,6 @@ public:
|
|||
Client(const QUrl &connectionString, QObject *parent = 0);
|
||||
~Client();
|
||||
|
||||
void printConnect() const;
|
||||
void closeChannel();
|
||||
|
||||
void addCustomProperty(const QString &name, const QString &value);
|
||||
QString customProperty(const QString &name) const;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,16 +18,11 @@ public:
|
|||
ClientPrivate(Client *q);
|
||||
~ClientPrivate();
|
||||
|
||||
void init(QObject *parent);
|
||||
void init(QObject *parent, const QUrl &connectionString);
|
||||
|
||||
void printConnect() const;
|
||||
void init(const QUrl &connectionString = QUrl());
|
||||
void connect();
|
||||
void disconnect();
|
||||
void parseConnectionString(const QUrl &connectionString);
|
||||
void sockConnect();
|
||||
void login();
|
||||
void setAuth(Authenticator* auth);
|
||||
|
||||
quint32 port;
|
||||
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::cpMessageId, "0");
|
||||
|
||||
Exchange::MessageProperties::ConstIterator i;
|
||||
|
||||
for (i = prop.begin(); i != prop.end(); ++i)
|
||||
content.setProperty(i.key(), i.value());
|
||||
Exchange::MessageProperties::ConstIterator it;
|
||||
Exchange::MessageProperties::ConstIterator itEnd = prop.constEnd();
|
||||
for (it = prop.constBegin(); it != itEnd; ++it)
|
||||
content.setProperty(it.key(), it.value());
|
||||
|
||||
content.setBody(message);
|
||||
sendFrame(content);
|
||||
|
|
|
|||
|
|
@ -305,10 +305,11 @@ QDataStream & Frame::serialize(QDataStream &stream, const TableField &f)
|
|||
{
|
||||
QByteArray data;
|
||||
QDataStream s(&data, QIODevice::WriteOnly);
|
||||
TableField::ConstIterator i;
|
||||
for (i = f.begin(); i != f.end(); ++i) {
|
||||
writeField('s', s, i.key());
|
||||
writeField(s, i.value());
|
||||
TableField::ConstIterator it;
|
||||
TableField::ConstIterator itEnd = f.constEnd();
|
||||
for (it = f.constBegin(); it != itEnd; ++it) {
|
||||
writeField('s', s, it.key());
|
||||
writeField(s, it.value());
|
||||
}
|
||||
|
||||
if (data.isEmpty()) {
|
||||
|
|
@ -322,17 +323,18 @@ QDataStream & Frame::serialize(QDataStream &stream, const TableField &f)
|
|||
|
||||
void Frame::print(const TableField &f)
|
||||
{
|
||||
TableField::ConstIterator i;
|
||||
for (i = f.begin(); i != f.end(); ++i) {
|
||||
switch(i.value().type()) {
|
||||
TableField::ConstIterator it;
|
||||
TableField::ConstIterator itEnd = f.constEnd();
|
||||
for (it = f.constBegin(); it != itEnd; ++it) {
|
||||
switch(it.value().type()) {
|
||||
case QVariant::Hash:
|
||||
qDebug() << "\t" << qPrintable(i.key()) << ": FIELD_TABLE";
|
||||
qDebug() << "\t" << qPrintable(it.key()) << ": FIELD_TABLE";
|
||||
break;
|
||||
case QVariant::List:
|
||||
qDebug() << "\t" << qPrintable(i.key()) << ": ARRAY";
|
||||
qDebug() << "\t" << qPrintable(it.key()) << ": ARRAY";
|
||||
break;
|
||||
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();
|
||||
message->leftSize = frame.bodySize();
|
||||
QHash<int, QVariant>::ConstIterator i;
|
||||
for (i = frame.properties_.begin(); i != frame.properties_.end(); ++i)
|
||||
message->property[Message::MessageProperty(i.key())]= i.value();
|
||||
QHash<int, QVariant>::ConstIterator it;
|
||||
QHash<int, QVariant>::ConstIterator itEnd = frame.properties_.constEnd();
|
||||
for (it = frame.properties_.constBegin(); it != itEnd; ++it)
|
||||
message->property[Message::MessageProperty(it.key())] = it.value();
|
||||
}
|
||||
|
||||
void QueuePrivate::_q_body(const Frame::ContentBody &frame)
|
||||
|
|
|
|||
Loading…
Reference in New Issue