Changeset View
Changeset View
Standalone View
Standalone View
src/server/handler.cpp
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | |||||
51 | #include "handler/tagfetchhandler.h" | 51 | #include "handler/tagfetchhandler.h" | ||
52 | #include "handler/tagmodifyhandler.h" | 52 | #include "handler/tagmodifyhandler.h" | ||
53 | #include "handler/transactionhandler.h" | 53 | #include "handler/transactionhandler.h" | ||
54 | #include "storage/querybuilder.h" | 54 | #include "storage/querybuilder.h" | ||
55 | 55 | | |||
56 | using namespace Akonadi; | 56 | using namespace Akonadi; | ||
57 | using namespace Akonadi::Server; | 57 | using namespace Akonadi::Server; | ||
58 | 58 | | |||
59 | Handler *Handler::findHandlerForCommandNonAuthenticated(Protocol::Command::Type cmd) | 59 | std::unique_ptr<Handler> Handler::findHandlerForCommandNonAuthenticated(Protocol::Command::Type cmd) | ||
60 | { | 60 | { | ||
61 | // allowed are LOGIN | 61 | // allowed are LOGIN | ||
62 | if (cmd == Protocol::Command::Login) { | 62 | if (cmd == Protocol::Command::Login) { | ||
63 | return new LoginHandler(); | 63 | return std::make_unique<LoginHandler>(); | ||
64 | } | 64 | } | ||
65 | 65 | | |||
66 | return nullptr; | 66 | return {}; | ||
67 | } | 67 | } | ||
68 | 68 | | |||
69 | Handler *Handler::findHandlerForCommandAlwaysAllowed(Protocol::Command::Type cmd) | 69 | std::unique_ptr<Handler> Handler::findHandlerForCommandAlwaysAllowed(Protocol::Command::Type cmd) | ||
70 | { | 70 | { | ||
71 | // allowed is LOGOUT | 71 | // allowed is LOGOUT | ||
72 | if (cmd == Protocol::Command::Logout) { | 72 | if (cmd == Protocol::Command::Logout) { | ||
73 | return new LogoutHandler(); | 73 | return std::make_unique<LogoutHandler>(); | ||
74 | } | 74 | } | ||
75 | return nullptr; | 75 | return nullptr; | ||
76 | } | 76 | } | ||
77 | 77 | | |||
78 | Handler *Handler::findHandlerForCommandAuthenticated(Protocol::Command::Type cmd) | 78 | std::unique_ptr<Handler> Handler::findHandlerForCommandAuthenticated(Protocol::Command::Type cmd) | ||
79 | { | 79 | { | ||
80 | switch (cmd) { | 80 | switch (cmd) { | ||
81 | case Protocol::Command::Invalid: | 81 | case Protocol::Command::Invalid: | ||
82 | Q_ASSERT_X(cmd != Protocol::Command::Invalid, __FUNCTION__, | 82 | Q_ASSERT_X(cmd != Protocol::Command::Invalid, __FUNCTION__, | ||
83 | "Invalid command is not allowed"); | 83 | "Invalid command is not allowed"); | ||
84 | return nullptr; | 84 | return {}; | ||
85 | case Protocol::Command::Hello: | 85 | case Protocol::Command::Hello: | ||
86 | Q_ASSERT_X(cmd != Protocol::Command::Hello, __FUNCTION__, | 86 | Q_ASSERT_X(cmd != Protocol::Command::Hello, __FUNCTION__, | ||
87 | "Hello command is not allowed in this context"); | 87 | "Hello command is not allowed in this context"); | ||
88 | return nullptr; | 88 | return {}; | ||
89 | case Protocol::Command::Login: | 89 | case Protocol::Command::Login: | ||
90 | return nullptr; | 90 | return {}; | ||
91 | case Protocol::Command::Logout: | 91 | case Protocol::Command::Logout: | ||
92 | return nullptr; | 92 | return {}; | ||
93 | case Protocol::Command::_ResponseBit: | 93 | case Protocol::Command::_ResponseBit: | ||
94 | Q_ASSERT_X(cmd != Protocol::Command::_ResponseBit, __FUNCTION__, | 94 | Q_ASSERT_X(cmd != Protocol::Command::_ResponseBit, __FUNCTION__, | ||
95 | "ResponseBit is not a valid command type"); | 95 | "ResponseBit is not a valid command type"); | ||
96 | return nullptr; | 96 | return {}; | ||
97 | 97 | | |||
98 | case Protocol::Command::Transaction: | 98 | case Protocol::Command::Transaction: | ||
99 | return new TransactionHandler(); | 99 | return std::make_unique<TransactionHandler>(); | ||
100 | 100 | | |||
101 | case Protocol::Command::CreateItem: | 101 | case Protocol::Command::CreateItem: | ||
102 | return new ItemCreateHandler(); | 102 | return std::make_unique<ItemCreateHandler>(); | ||
103 | case Protocol::Command::CopyItems: | 103 | case Protocol::Command::CopyItems: | ||
104 | return new ItemCopyHandler(); | 104 | return std::make_unique<ItemCopyHandler>(); | ||
105 | case Protocol::Command::DeleteItems: | 105 | case Protocol::Command::DeleteItems: | ||
106 | return new ItemDeleteHandler(); | 106 | return std::make_unique<ItemDeleteHandler>(); | ||
107 | case Protocol::Command::FetchItems: | 107 | case Protocol::Command::FetchItems: | ||
108 | return new ItemFetchHandler(); | 108 | return std::make_unique<ItemFetchHandler>(); | ||
109 | case Protocol::Command::LinkItems: | 109 | case Protocol::Command::LinkItems: | ||
110 | return new ItemLinkHandler(); | 110 | return std::make_unique<ItemLinkHandler>(); | ||
111 | case Protocol::Command::ModifyItems: | 111 | case Protocol::Command::ModifyItems: | ||
112 | return new ItemModifyHandler(); | 112 | return std::make_unique<ItemModifyHandler>(); | ||
113 | case Protocol::Command::MoveItems: | 113 | case Protocol::Command::MoveItems: | ||
114 | return new ItemMoveHandler(); | 114 | return std::make_unique<ItemMoveHandler>(); | ||
115 | 115 | | |||
116 | case Protocol::Command::CreateCollection: | 116 | case Protocol::Command::CreateCollection: | ||
117 | return new CollectionCreateHandler(); | 117 | return std::make_unique<CollectionCreateHandler>(); | ||
118 | case Protocol::Command::CopyCollection: | 118 | case Protocol::Command::CopyCollection: | ||
119 | return new CollectionCopyHandler(); | 119 | return std::make_unique<CollectionCopyHandler>(); | ||
120 | case Protocol::Command::DeleteCollection: | 120 | case Protocol::Command::DeleteCollection: | ||
121 | return new CollectionDeleteHandler(); | 121 | return std::make_unique<CollectionDeleteHandler>(); | ||
122 | case Protocol::Command::FetchCollections: | 122 | case Protocol::Command::FetchCollections: | ||
123 | return new CollectionFetchHandler(); | 123 | return std::make_unique<CollectionFetchHandler>(); | ||
124 | case Protocol::Command::FetchCollectionStats: | 124 | case Protocol::Command::FetchCollectionStats: | ||
125 | return new CollectionStatsFetchHandler(); | 125 | return std::make_unique<CollectionStatsFetchHandler>(); | ||
126 | case Protocol::Command::ModifyCollection: | 126 | case Protocol::Command::ModifyCollection: | ||
127 | return new CollectionModifyHandler(); | 127 | return std::make_unique<CollectionModifyHandler>(); | ||
128 | case Protocol::Command::MoveCollection: | 128 | case Protocol::Command::MoveCollection: | ||
129 | return new CollectionMoveHandler(); | 129 | return std::make_unique<CollectionMoveHandler>(); | ||
130 | 130 | | |||
131 | case Protocol::Command::Search: | 131 | case Protocol::Command::Search: | ||
132 | return new SearchHandler(); | 132 | return std::make_unique<SearchHandler>(); | ||
133 | case Protocol::Command::SearchResult: | 133 | case Protocol::Command::SearchResult: | ||
134 | return new SearchResultHandler(); | 134 | return std::make_unique<SearchResultHandler>(); | ||
135 | case Protocol::Command::StoreSearch: | 135 | case Protocol::Command::StoreSearch: | ||
136 | return new SearchCreateHandler(); | 136 | return std::make_unique<SearchCreateHandler>(); | ||
137 | 137 | | |||
138 | case Protocol::Command::CreateTag: | 138 | case Protocol::Command::CreateTag: | ||
139 | return new TagCreateHandler(); | 139 | return std::make_unique<TagCreateHandler>(); | ||
140 | case Protocol::Command::DeleteTag: | 140 | case Protocol::Command::DeleteTag: | ||
141 | return new TagDeleteHandler(); | 141 | return std::make_unique<TagDeleteHandler>(); | ||
142 | case Protocol::Command::FetchTags: | 142 | case Protocol::Command::FetchTags: | ||
143 | return new TagFetchHandler(); | 143 | return std::make_unique<TagFetchHandler>(); | ||
144 | case Protocol::Command::ModifyTag: | 144 | case Protocol::Command::ModifyTag: | ||
145 | return new TagModifyHandler(); | 145 | return std::make_unique<TagModifyHandler>(); | ||
146 | 146 | | |||
147 | case Protocol::Command::FetchRelations: | 147 | case Protocol::Command::FetchRelations: | ||
148 | return new RelationFetchHandler(); | 148 | return std::make_unique<RelationFetchHandler>(); | ||
149 | case Protocol::Command::ModifyRelation: | 149 | case Protocol::Command::ModifyRelation: | ||
150 | return new RelationModifyHandler(); | 150 | return std::make_unique<RelationModifyHandler>(); | ||
151 | case Protocol::Command::RemoveRelations: | 151 | case Protocol::Command::RemoveRelations: | ||
152 | return new RelationRemoveHandler(); | 152 | return std::make_unique<RelationRemoveHandler>(); | ||
153 | 153 | | |||
154 | case Protocol::Command::SelectResource: | 154 | case Protocol::Command::SelectResource: | ||
155 | return new ResourceSelectHandler(); | 155 | return std::make_unique<ResourceSelectHandler>(); | ||
156 | 156 | | |||
157 | case Protocol::Command::StreamPayload: | 157 | case Protocol::Command::StreamPayload: | ||
158 | Q_ASSERT_X(cmd != Protocol::Command::StreamPayload, __FUNCTION__, | 158 | Q_ASSERT_X(cmd != Protocol::Command::StreamPayload, __FUNCTION__, | ||
159 | "StreamPayload command is not allowed in this context"); | 159 | "StreamPayload command is not allowed in this context"); | ||
160 | return nullptr; | 160 | return {}; | ||
161 | 161 | | |||
162 | case Protocol::Command::ItemChangeNotification: | 162 | case Protocol::Command::ItemChangeNotification: | ||
163 | Q_ASSERT_X(cmd != Protocol::Command::ItemChangeNotification, __FUNCTION__, | 163 | Q_ASSERT_X(cmd != Protocol::Command::ItemChangeNotification, __FUNCTION__, | ||
164 | "ItemChangeNotification command is not allowed on this connection"); | 164 | "ItemChangeNotification command is not allowed on this connection"); | ||
165 | return nullptr; | 165 | return {}; | ||
166 | case Protocol::Command::CollectionChangeNotification: | 166 | case Protocol::Command::CollectionChangeNotification: | ||
167 | Q_ASSERT_X(cmd != Protocol::Command::CollectionChangeNotification, __FUNCTION__, | 167 | Q_ASSERT_X(cmd != Protocol::Command::CollectionChangeNotification, __FUNCTION__, | ||
168 | "CollectionChangeNotification command is not allowed on this connection"); | 168 | "CollectionChangeNotification command is not allowed on this connection"); | ||
169 | return nullptr; | 169 | return {}; | ||
170 | case Protocol::Command::TagChangeNotification: | 170 | case Protocol::Command::TagChangeNotification: | ||
171 | Q_ASSERT_X(cmd != Protocol::Command::TagChangeNotification, __FUNCTION__, | 171 | Q_ASSERT_X(cmd != Protocol::Command::TagChangeNotification, __FUNCTION__, | ||
172 | "TagChangeNotification command is not allowed on this connection"); | 172 | "TagChangeNotification command is not allowed on this connection"); | ||
173 | return nullptr; | 173 | return {}; | ||
174 | case Protocol::Command::RelationChangeNotification: | 174 | case Protocol::Command::RelationChangeNotification: | ||
175 | Q_ASSERT_X(cmd != Protocol::Command::RelationChangeNotification, __FUNCTION__, | 175 | Q_ASSERT_X(cmd != Protocol::Command::RelationChangeNotification, __FUNCTION__, | ||
176 | "RelationChangeNotification command is not allowed on this connection"); | 176 | "RelationChangeNotification command is not allowed on this connection"); | ||
177 | return nullptr; | 177 | return {}; | ||
178 | case Protocol::Command::SubscriptionChangeNotification: | 178 | case Protocol::Command::SubscriptionChangeNotification: | ||
179 | Q_ASSERT_X(cmd != Protocol::Command::SubscriptionChangeNotification, __FUNCTION__, | 179 | Q_ASSERT_X(cmd != Protocol::Command::SubscriptionChangeNotification, __FUNCTION__, | ||
180 | "SubscriptionChangeNotification command is not allowed on this connection"); | 180 | "SubscriptionChangeNotification command is not allowed on this connection"); | ||
181 | return nullptr; | 181 | return {}; | ||
182 | case Protocol::Command::DebugChangeNotification: | 182 | case Protocol::Command::DebugChangeNotification: | ||
183 | Q_ASSERT_X(cmd != Protocol::Command::DebugChangeNotification, __FUNCTION__, | 183 | Q_ASSERT_X(cmd != Protocol::Command::DebugChangeNotification, __FUNCTION__, | ||
184 | "DebugChangeNotification command is not allowed on this connection"); | 184 | "DebugChangeNotification command is not allowed on this connection"); | ||
185 | return nullptr; | 185 | return {}; | ||
186 | case Protocol::Command::ModifySubscription: | 186 | case Protocol::Command::ModifySubscription: | ||
187 | Q_ASSERT_X(cmd != Protocol::Command::ModifySubscription, __FUNCTION__, | 187 | Q_ASSERT_X(cmd != Protocol::Command::ModifySubscription, __FUNCTION__, | ||
188 | "ModifySubscription command is not allowed on this connection"); | 188 | "ModifySubscription command is not allowed on this connection"); | ||
189 | return nullptr; | 189 | return {}; | ||
190 | case Protocol::Command::CreateSubscription: | 190 | case Protocol::Command::CreateSubscription: | ||
191 | Q_ASSERT_X(cmd != Protocol::Command::CreateSubscription, __FUNCTION__, | 191 | Q_ASSERT_X(cmd != Protocol::Command::CreateSubscription, __FUNCTION__, | ||
192 | "CreateSubscription command is not allowed on this connection"); | 192 | "CreateSubscription command is not allowed on this connection"); | ||
193 | return nullptr; | 193 | return {}; | ||
194 | } | 194 | } | ||
195 | 195 | | |||
196 | return nullptr; | 196 | return {}; | ||
197 | } | 197 | } | ||
198 | 198 | | |||
199 | void Handler::setTag(quint64 tag) | 199 | void Handler::setTag(quint64 tag) | ||
200 | { | 200 | { | ||
201 | m_tag = tag; | 201 | m_tag = tag; | ||
202 | } | 202 | } | ||
203 | 203 | | |||
204 | quint64 Handler::tag() const | 204 | quint64 Handler::tag() const | ||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |