20 #include "objectnotificationmessage.h"
22 using namespace Akonadi;
24 ObjectNotificationMessage::ObjectNotificationMessage(
const Akonadi::NotificationMessage &message)
25 : m_parentCollection(message.parentCollection()),
26 m_parentDestCollection(message.parentDestCollection()),
29 if ( message.type() == NotificationMessage::Collection ) {
31 col.
setResource( QString::fromUtf8( message.resource() ) );
32 col.setRemoteId( message.remoteId() );
33 col.setParentCollection( message.operation() == NotificationMessage::Move ? m_parentDestCollection : m_parentCollection );
35 if ( message.operation() == NotificationMessage::Remove ) {
36 const QString remoteRevision = QString::fromUtf8( message.itemParts().toList().first() );
37 col.setRemoteRevision( remoteRevision );
39 m_collections.append( col );
40 }
else if ( message.type() == NotificationMessage::Item ) {
41 Item item( message.uid() );
43 item.setMimeType( message.mimeType() );
44 item.setParentCollection( message.operation() == NotificationMessage::Move ? m_parentDestCollection : m_parentCollection );
48 if ( message.operation() == NotificationMessage::Remove ) {
49 const QString remoteRevision = QString::fromUtf8( message.itemParts().toList().first() );
50 item.setRemoteRevision( remoteRevision );
53 m_items.append( item );
57 if ( message.operation() == NotificationMessage::Move &&
58 !message.itemParts().isEmpty() ) {
59 m_parentDestCollection.setResource( QString::fromLatin1( *( message.itemParts().begin() ) ) );
62 m_parentCollection.setResource( QString::fromUtf8( message.resource() ) );
65 Item::List ObjectNotificationMessage::items()
const
75 NotificationMessage ObjectNotificationMessage::message()
const
80 NotificationMessage::Operation ObjectNotificationMessage::operation()
const
82 return m_message.operation();
85 NotificationMessage::Type ObjectNotificationMessage::type()
const
87 return m_message.type();
90 QByteArray ObjectNotificationMessage::resource()
const
92 return m_message.resource();
95 QString ObjectNotificationMessage::remoteId()
const
97 return m_message.remoteId();
100 QSet<QByteArray> ObjectNotificationMessage::itemParts()
const
102 return m_message.itemParts();
105 QString ObjectNotificationMessage::mimeType()
const
107 return m_message.mimeType();
110 Collection ObjectNotificationMessage::parentCollection()
const
112 return m_parentCollection;
115 Collection ObjectNotificationMessage::parentDestCollection()
const
117 return m_parentDestCollection;
122 m_collections.append( list );
127 m_items.append( list );
130 template<
typename Container>
133 if ( container.isEmpty() ) {
134 container.push_back( message );
138 if ( lastMessage.message().type() == message.message().type() &&
139 lastMessage.message().operation() == message.message().operation() &&
140 lastMessage.parentCollection() == message.parentCollection() &&
141 lastMessage.parentDestCollection() == message.parentDestCollection() ) {
142 container.last().appendCollections( message.collections() );
143 container.last().appendItems( message.items() );
145 container.push_back( message );
153 return do_appendAndCompress( vector, message );
158 return do_appendAndCompress( list, message );