Changeset View
Changeset View
Standalone View
Standalone View
autotests/libs/fakeserverdata.cpp
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | 55 | connect(session, &FakeSession::jobAdded, | |||
---|---|---|---|---|---|
56 | [this](Akonadi::Job *) { | 56 | [this](Akonadi::Job *) { | ||
57 | QTimer::singleShot(0, [this]() { | 57 | QTimer::singleShot(0, [this]() { | ||
58 | jobAdded(); | 58 | jobAdded(); | ||
59 | }); | 59 | }); | ||
60 | }); | 60 | }); | ||
61 | } | 61 | } | ||
62 | 62 | | |||
63 | 63 | | |||
64 | void FakeServerData::setCommands(QList< FakeAkonadiServerCommand * > list) | 64 | void FakeServerData::setCommands(const QList<FakeAkonadiServerCommand *> &list) | ||
65 | { | 65 | { | ||
66 | m_communicationQueue.clear(); | 66 | m_communicationQueue.clear(); | ||
67 | Q_FOREACH (FakeAkonadiServerCommand *command, list) { | 67 | for (FakeAkonadiServerCommand *command : list) { | ||
68 | m_communicationQueue << command; | 68 | m_communicationQueue << command; | ||
69 | } | 69 | } | ||
70 | } | 70 | } | ||
71 | 71 | | |||
72 | void FakeServerData::processNotifications() | 72 | void FakeServerData::processNotifications() | ||
73 | { | 73 | { | ||
74 | while (!m_communicationQueue.isEmpty()) { | 74 | while (!m_communicationQueue.isEmpty()) { | ||
75 | FakeAkonadiServerCommand::Type respondTo = m_communicationQueue.head()->respondTo(); | 75 | FakeAkonadiServerCommand::Type respondTo = m_communicationQueue.head()->respondTo(); | ||
76 | if (respondTo == FakeAkonadiServerCommand::Notification) { | 76 | if (respondTo == FakeAkonadiServerCommand::Notification) { | ||
77 | FakeAkonadiServerCommand *command = m_communicationQueue.dequeue(); | 77 | FakeAkonadiServerCommand *command = m_communicationQueue.dequeue(); | ||
78 | command->doCommand(); | 78 | command->doCommand(); | ||
79 | delete command; | ||||
79 | } else { | 80 | } else { | ||
80 | return; | 81 | return; | ||
81 | } | 82 | } | ||
82 | } | 83 | } | ||
83 | } | 84 | } | ||
84 | 85 | | |||
85 | void FakeServerData::jobAdded(qint64 fetchColId) | 86 | void FakeServerData::jobAdded(qint64 fetchColId) | ||
86 | { | 87 | { | ||
Show All 31 Lines | 112 | { | |||
118 | 119 | | |||
119 | if (commType == FakeAkonadiServerCommand::RespondToCollectionFetch | 120 | if (commType == FakeAkonadiServerCommand::RespondToCollectionFetch | ||
120 | && fetchColId == fetchCollection.id()) { | 121 | && fetchColId == fetchCollection.id()) { | ||
121 | FakeAkonadiServerCommand *command = m_communicationQueue.dequeue(); | 122 | FakeAkonadiServerCommand *command = m_communicationQueue.dequeue(); | ||
122 | command->doCommand(); | 123 | command->doCommand(); | ||
123 | if (!m_communicationQueue.isEmpty()) { | 124 | if (!m_communicationQueue.isEmpty()) { | ||
124 | returnEntities(fetchColId); | 125 | returnEntities(fetchColId); | ||
125 | } | 126 | } | ||
127 | delete command; | ||||
126 | return true; | 128 | return true; | ||
127 | } | 129 | } | ||
128 | return false; | 130 | return false; | ||
129 | } | 131 | } | ||
130 | 132 | | |||
131 | void FakeServerData::returnItems(Item::Id fetchColId) | 133 | void FakeServerData::returnItems(Item::Id fetchColId) | ||
132 | { | 134 | { | ||
133 | FakeAkonadiServerCommand::Type commType = m_communicationQueue.head()->respondTo(); | 135 | FakeAkonadiServerCommand::Type commType = m_communicationQueue.head()->respondTo(); | ||
134 | 136 | | |||
135 | if (commType == FakeAkonadiServerCommand::RespondToItemFetch) { | 137 | if (commType == FakeAkonadiServerCommand::RespondToItemFetch) { | ||
136 | FakeAkonadiServerCommand *command = m_communicationQueue.dequeue(); | 138 | FakeAkonadiServerCommand *command = m_communicationQueue.dequeue(); | ||
137 | command->doCommand(); | 139 | command->doCommand(); | ||
138 | if (!m_communicationQueue.isEmpty()) { | 140 | if (!m_communicationQueue.isEmpty()) { | ||
139 | returnEntities(fetchColId); | 141 | returnEntities(fetchColId); | ||
140 | } | 142 | } | ||
143 | delete command; | ||||
141 | } | 144 | } | ||
142 | } | 145 | } | ||
143 | 146 | | |||
144 | void FakeServerData::returnTags() | 147 | void FakeServerData::returnTags() | ||
145 | { | 148 | { | ||
146 | FakeAkonadiServerCommand::Type commType = m_communicationQueue.head()->respondTo(); | 149 | FakeAkonadiServerCommand::Type commType = m_communicationQueue.head()->respondTo(); | ||
147 | 150 | | |||
148 | if (commType == FakeAkonadiServerCommand::RespondToTagFetch) { | 151 | if (commType == FakeAkonadiServerCommand::RespondToTagFetch) { | ||
149 | FakeAkonadiServerCommand *command = m_communicationQueue.dequeue(); | 152 | FakeAkonadiServerCommand *command = m_communicationQueue.dequeue(); | ||
150 | command->doCommand(); | 153 | command->doCommand(); | ||
154 | delete command; | ||||
151 | } | 155 | } | ||
152 | } | 156 | } |