move QAMQP::Frame to private API

QAMQP::Frame used to be public API mostly for MessageProperties. There
is no longer a need to keep this API public, as it should all be wrapped
with the cleaner Message/Queue/Exchange/Client API set
This commit is contained in:
Matt Broadstone 2014-08-26 09:57:08 -04:00
parent 0bc1c32bd8
commit 0ccb3035cd
17 changed files with 66 additions and 69 deletions

View File

@ -1,5 +1,5 @@
#include "amqp_table.h"
#include "amqp_frame.h"
#include "amqp_frame_p.h"
#include "amqp_authenticator.h"
using namespace QAMQP;

View File

@ -2,7 +2,7 @@
#define amqp_channel_h__
#include <QObject>
#include "amqp_frame.h"
#include "amqp_global.h"
namespace QAMQP
{

View File

@ -2,7 +2,7 @@
#define amqp_channel_p_h__
#include <QPointer>
#include "amqp_frame.h"
#include "amqp_frame_p.h"
#define METHOD_ID_ENUM(name, id) name = id, name ## Ok

View File

@ -319,7 +319,7 @@ bool ClientPrivate::_q_method(const Frame::Method &frame)
closeOk(frame);
break;
default:
qWarning("Unknown method-id %d", frame.id());
qAmqpDebug("Unknown method-id %d", frame.id());
}
return true;

View File

@ -12,7 +12,7 @@
#endif
#include "amqp_table.h"
#include "amqp_frame.h"
#include "amqp_frame_p.h"
#define METHOD_ID_ENUM(name, id) name = id, name ## Ok

View File

@ -216,22 +216,22 @@ void Exchange::remove(int options)
}
void Exchange::publish(const QString &message, const QString &routingKey,
const MessageProperties &properties, int publishOptions)
const Message::PropertyHash &properties, int publishOptions)
{
publish(message.toUtf8(), routingKey, QLatin1String("text.plain"),
QVariantHash(), properties, publishOptions);
Table(), properties, publishOptions);
}
void Exchange::publish(const QByteArray &message, const QString &routingKey,
const QString &mimeType, const MessageProperties &properties,
const QString &mimeType, const Message::PropertyHash &properties,
int publishOptions)
{
publish(message, routingKey, mimeType, QVariantHash(), properties, publishOptions);
publish(message, routingKey, mimeType, Table(), properties, publishOptions);
}
void Exchange::publish(const QByteArray &message, const QString &routingKey,
const QString &mimeType, const Table &headers,
const MessageProperties &properties, int publishOptions)
const Message::PropertyHash &properties, int publishOptions)
{
Q_D(Exchange);
Frame::Method frame(Frame::fcBasic, ExchangePrivate::bmPublish);
@ -255,10 +255,10 @@ void Exchange::publish(const QByteArray &message, const QString &routingKey,
content.setProperty(Frame::Content::cpHeaders, headers);
content.setProperty(Frame::Content::cpMessageId, "0");
MessageProperties::ConstIterator it;
MessageProperties::ConstIterator itEnd = properties.constEnd();
Message::PropertyHash::ConstIterator it;
Message::PropertyHash::ConstIterator itEnd = properties.constEnd();
for (it = properties.constBegin(); it != itEnd; ++it)
content.setProperty(it.key(), it.value());
content.setProperty(static_cast<Frame::Content::Property>(it.key()), it.value());
content.setBodySize(message.size());
d->sendFrame(content);

View File

@ -3,6 +3,7 @@
#include "amqp_table.h"
#include "amqp_channel.h"
#include "amqp_message.h"
namespace QAMQP
{
@ -65,14 +66,14 @@ public:
// AMQP Basic
void publish(const QString &message, const QString &routingKey,
const MessageProperties &properties = MessageProperties(),
const Message::PropertyHash &properties = Message::PropertyHash(),
int publishOptions = poNoOptions);
void publish(const QByteArray &message, const QString &routingKey,
const QString &mimeType, const MessageProperties &properties = MessageProperties(),
void publish(const QByteArray &message, const QString &routingKey, const QString &mimeType,
const Message::PropertyHash &properties = Message::PropertyHash(),
int publishOptions = poNoOptions);
void publish(const QByteArray &message, const QString &routingKey,
const QString &mimeType, const Table &headers,
const MessageProperties &properties = MessageProperties(),
const Message::PropertyHash &properties = Message::PropertyHash(),
int publishOptions = poNoOptions);
Q_SIGNALS:

View File

@ -1,11 +1,10 @@
#include "amqp_frame.h"
#include <QDateTime>
#include <QList>
#include <QDebug>
#include "amqp_table.h"
#include "amqp_global.h"
#include "amqp_frame_p.h"
using namespace QAMQP;
using namespace QAMQP::Frame;
@ -72,7 +71,7 @@ void Base::readEnd(QDataStream &stream)
unsigned char end_ = 0;
stream.readRawData(reinterpret_cast<char*>(&end_), sizeof(end_));
if (end_ != FRAME_END)
qWarning("Wrong end of frame");
qAmqpDebug("Wrong end of frame");
}
*/
void Base::toStream(QDataStream &stream) const
@ -208,7 +207,7 @@ QVariant Frame::readAmqpField(QDataStream &s, QAMQP::ValueType type)
case Void:
return QVariant();
default:
qWarning() << Q_FUNC_INFO << "unsupported value type: " << type;
qAmqpDebug() << Q_FUNC_INFO << "unsupported value type: " << type;
}
return QVariant();
@ -260,7 +259,7 @@ void Frame::writeAmqpField(QDataStream &s, QAMQP::ValueType type, const QVariant
}
break;
default:
qWarning() << Q_FUNC_INFO << "unsupported value type: " << type;
qAmqpDebug() << Q_FUNC_INFO << "unsupported value type: " << type;
}
}

View File

@ -59,12 +59,6 @@ namespace Frame
fcTx = 90,
};
struct decimal
{
qint8 scale;
quint32 value;
};
QVariant readAmqpField(QDataStream &s, QAMQP::ValueType type);
void writeAmqpField(QDataStream &s, QAMQP::ValueType type, const QVariant &value);
@ -383,12 +377,6 @@ namespace Frame
} // namespace Frame
typedef QHash<Frame::Content::Property, QVariant> MessageProperties;
typedef Frame::Content::Property MessageProperty;
} // namespace QAMQP
Q_DECLARE_METATYPE(QAMQP::Frame::decimal)
//Q_DECLARE_METATYPE(QAMQP::Frame::TableField)
#endif // amqp_frame_h__

View File

@ -98,8 +98,15 @@ enum Error
InternalError = 541
};
struct decimal
{
qint8 scale;
quint32 value;
};
} // namespace QAMQP
Q_DECLARE_METATYPE(QAMQP::Error);
Q_DECLARE_METATYPE(QAMQP::Error)
Q_DECLARE_METATYPE(QAMQP::decimal)
#endif // qamqp_global_h__

View File

@ -4,8 +4,8 @@
#include <QByteArray>
#include <QHash>
#include <QSharedDataPointer>
#include <QVariant>
#include "amqp_frame.h"
#include "amqp_global.h"
namespace QAMQP
@ -37,18 +37,18 @@ public:
ClusterID = AMQP_BASIC_CLUSTER_ID_FLAG
};
Q_DECLARE_FLAGS(Properties, Property)
typedef QHash<Property, QVariant> PropertyHash;
bool hasProperty(Property property) const;
void setProperty(Property property, const QVariant &value);
QVariant property(Property property, const QVariant &defaultValue = QString()) const;
QVariant property(Property property, const QVariant &defaultValue = QVariant()) const;
bool hasHeader(const QString &header) const;
void setHeader(const QString &header, const QVariant &value);
QVariant header(const QString &header, const QVariant &defaultValue = QString()) const;
QVariant header(const QString &header, const QVariant &defaultValue = QVariant()) const;
bool isValid() const;
bool isRedelivered() const;
qlonglong deliveryTag() const;
QString exchangeName() const;
QString routingKey() const;
@ -63,4 +63,6 @@ private:
} // namespace QAMQP
Q_DECLARE_METATYPE(QAMQP::Message::PropertyHash)
#endif // amqp_message_h__

View File

@ -4,7 +4,7 @@
#include <QHash>
#include <QSharedData>
#include "amqp_frame.h"
#include "amqp_frame_p.h"
#include "amqp_message.h"
namespace QAMQP {

View File

@ -3,7 +3,7 @@
#include <QDateTime>
#include <QDebug>
#include "amqp_frame.h"
#include "amqp_frame_p.h"
#include "amqp_table.h"
using namespace QAMQP;
@ -137,7 +137,7 @@ void Table::writeFieldValue(QDataStream &stream, const QVariant &value)
type = Void;
break;
default:
if (value.userType() == qMetaTypeId<Frame::decimal>()) {
if (value.userType() == qMetaTypeId<QAMQP::decimal>()) {
type = Decimal;
break;
} else if (!value.isValid()) {
@ -200,7 +200,7 @@ void Table::writeFieldValue(QDataStream &stream, ValueType type, const QVariant
break;
case Decimal:
{
Frame::decimal v(value.value<Frame::decimal>());
QAMQP::decimal v(value.value<QAMQP::decimal>());
stream << v.scale;
stream << v.value;
}
@ -294,10 +294,10 @@ QVariant Table::readFieldValue(QDataStream &stream, ValueType type)
}
case Decimal:
{
Frame::decimal v;
QAMQP::decimal v;
stream >> v.scale;
stream >> v.value;
return QVariant::fromValue<Frame::decimal>(v);
return QVariant::fromValue<QAMQP::decimal>(v);
}
case Array:
{

View File

@ -14,6 +14,7 @@ PRIVATE_HEADERS += \
amqp_channel_p.h \
amqp_client_p.h \
amqp_exchange_p.h \
amqp_frame_p.h \
amqp_message_p.h \
amqp_queue_p.h
@ -22,7 +23,6 @@ INSTALL_HEADERS += \
amqp_channel.h \
amqp_client.h \
amqp_exchange.h \
amqp_frame.h \
amqp_global.h \
amqp_message.h \
amqp_queue.h \

View File

@ -155,7 +155,7 @@ void tst_QAMQPExchange::removeIfUnused()
void tst_QAMQPExchange::invalidMandatoryRouting()
{
Exchange *defaultExchange = client->createExchange();
defaultExchange->publish("some message", "unroutable-key", MessageProperties(), Exchange::poMandatory);
defaultExchange->publish("some message", "unroutable-key", Message::PropertyHash(), Exchange::poMandatory);
QVERIFY(waitForSignal(defaultExchange, SIGNAL(error(QAMQP::Error))));
QCOMPARE(defaultExchange->error(), QAMQP::UnroutableKey);
}
@ -163,7 +163,7 @@ void tst_QAMQPExchange::invalidMandatoryRouting()
void tst_QAMQPExchange::invalidImmediateRouting()
{
Exchange *defaultExchange = client->createExchange();
defaultExchange->publish("some message", "unroutable-key", MessageProperties(), Exchange::poImmediate);
defaultExchange->publish("some message", "unroutable-key", Message::PropertyHash(), Exchange::poImmediate);
QVERIFY(waitForSignal(client.data(), SIGNAL(error(QAMQP::Error))));
QCOMPARE(client->error(), QAMQP::NotImplementedError);
}

View File

@ -436,8 +436,8 @@ void tst_QAMQPQueue::verifyContentEncodingIssue33()
declareQueueAndVerifyConsuming(queue);
Exchange *defaultExchange = client->createExchange();
MessageProperties properties;
properties.insert(Frame::Content::cpContentEncoding, "fakeContentEncoding");
Message::PropertyHash properties;
properties.insert(Message::ContentEncoding, "fakeContentEncoding");
defaultExchange->publish("some data", "test-issue-33", properties);
QVERIFY(waitForSignal(queue, SIGNAL(messageReceived())));
@ -525,10 +525,10 @@ void tst_QAMQPQueue::tableFieldDataTypes()
Queue *queue = client->createQueue("test-table-field-data-types");
declareQueueAndVerifyConsuming(queue);
Frame::decimal decimal;
QAMQP::decimal decimal;
decimal.scale = 2;
decimal.value = 12345;
QVariant decimalVariant = QVariant::fromValue<Frame::decimal>(decimal);
QVariant decimalVariant = QVariant::fromValue<QAMQP::decimal>(decimal);
Table nestedTable;
nestedTable.insert("boolean", true);
@ -593,7 +593,7 @@ void tst_QAMQPQueue::tableFieldDataTypes()
QVariantList compareArray = message.header("array").toList();
QCOMPARE(array, compareArray);
Frame::decimal receivedDecimal = message.header("decimal-value").value<Frame::decimal>();
QAMQP::decimal receivedDecimal = message.header("decimal-value").value<QAMQP::decimal>();
QCOMPARE(receivedDecimal.scale, qint8(2));
QCOMPARE(receivedDecimal.value, quint32(12345));
}
@ -604,20 +604,20 @@ void tst_QAMQPQueue::messageProperties()
declareQueueAndVerifyConsuming(queue);
QDateTime timestamp = QDateTime::currentDateTime();
MessageProperties properties;
properties.insert(Frame::Content::cpContentType, "some-content-type");
properties.insert(Frame::Content::cpContentEncoding, "some-content-encoding");
properties.insert(Frame::Content::cpDeliveryMode, 2);
properties.insert(Frame::Content::cpPriority, 5);
properties.insert(Frame::Content::cpCorrelationId, 42);
properties.insert(Frame::Content::cpReplyTo, "another-queue");
properties.insert(Frame::Content::cpMessageId, "some-message-id");
properties.insert(Frame::Content::cpExpiration, "60000");
properties.insert(Frame::Content::cpTimestamp, timestamp);
properties.insert(Frame::Content::cpType, "some-message-type");
properties.insert(Frame::Content::cpUserId, "guest");
properties.insert(Frame::Content::cpAppId, "some-app-id");
properties.insert(Frame::Content::cpClusterID, "some-cluster-id");
Message::PropertyHash properties;
properties.insert(Message::ContentType, "some-content-type");
properties.insert(Message::ContentEncoding, "some-content-encoding");
properties.insert(Message::DeliveryMode, 2);
properties.insert(Message::Priority, 5);
properties.insert(Message::CorrelationId, 42);
properties.insert(Message::ReplyTo, "another-queue");
properties.insert(Message::MessageId, "some-message-id");
properties.insert(Message::Expiration, "60000");
properties.insert(Message::Timestamp, timestamp);
properties.insert(Message::Type, "some-message-type");
properties.insert(Message::UserId, "guest");
properties.insert(Message::AppId, "some-app-id");
properties.insert(Message::ClusterID, "some-cluster-id");
Exchange *defaultExchange = client->createExchange();
defaultExchange->publish("dummy", "test-message-properties", properties);

View File

@ -33,8 +33,8 @@ private Q_SLOTS:
return;
Exchange *defaultExchange = m_client.createExchange();
MessageProperties properties;
properties[Frame::Content::cpDeliveryMode] = "2"; // make message persistent
Message::PropertyHash properties;
properties[Message::DeliveryMode] = "2"; // make message persistent
QString message;
if (qApp->arguments().size() < 2)