2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file GalleryRequestManager.cpp
18 * @author Wojciech Bielawski (w.bielawski@samsung.com)
22 #include <commons/Exception.h>
23 #include <API/Gallery/IGallery.h>
24 #include "GalleryRequestManager.h"
27 using namespace WrtPlugins::Commons;
28 using namespace WrtPlugins::Api::Gallery;
30 namespace WrtPlugins {
32 void GalleryRequestManager::OnRequestReceived(
33 const IEventGetGalleriesPtr &event)
35 IGallerySetPtr galleries(new IGallerySet());
36 galleries->push_back(IGalleryPtr(new Gallery("Device")));
37 event->setGalleries(galleries);
38 event->setResult(ExceptionCodes::None);
41 void GalleryRequestManager::OnRequestReceived(const IEventOpenPtr &event)
45 IGalleryPtr gallery(event->getGallery());
47 event->setResult(ExceptionCodes::None);
51 LogError("Gallery exception message: " <<
52 _rethrown_exception.GetMessage() <<
53 " Code: " << _rethrown_exception.getCode());
54 event->setResult(_rethrown_exception.getCode());
58 void GalleryRequestManager::OnRequestReceived(const IEventRefreshPtr &event)
62 IGalleryPtr gallery(event->getGallery());
64 event->setResult(ExceptionCodes::None);
68 LogError("Gallery exception message: " <<
69 _rethrown_exception.GetMessage() <<
70 " Code: " << _rethrown_exception.getCode());
71 event->setResult(_rethrown_exception.getCode());
75 void GalleryRequestManager::OnRequestReceived(const IEventClosePtr &event)
79 IGalleryPtr gallery(event->getGallery());
81 event->setResult(ExceptionCodes::None);
85 LogError("Gallery exception message: " <<
86 _rethrown_exception.GetMessage() <<
87 " Code: " << _rethrown_exception.getCode());
88 event->setResult(_rethrown_exception.getCode());
92 void GalleryRequestManager::OnRequestReceived(const IEventChangeViewPtr &event)
96 IGalleryPtr gallery(event->getGallery());
97 gallery->changeView(event->getProperties());
98 event->setResult(ExceptionCodes::None);
102 LogError("Gallery exception message: " <<
103 _rethrown_exception.GetMessage() <<
104 " Code: " << _rethrown_exception.getCode());
105 event->setResult(_rethrown_exception.getCode());
109 void GalleryRequestManager::OnRequestReceived(
110 const IEventGetMediaItemsPtr &event)
114 IGalleryPtr gallery(event->getGallery());
115 IMediaItemsSetPtr mediaItems(gallery->getMediaItems());
116 event->setMediaItems(mediaItems);
117 event->setResult(ExceptionCodes::None);
121 LogError("Gallery exception message: " <<
122 _rethrown_exception.GetMessage() <<
123 " Code: " << _rethrown_exception.getCode());
124 event->setResult(_rethrown_exception.getCode());
128 void GalleryRequestManager::OnRequestReceived(
129 const IEventGetMediaItemByIdPtr &event)
133 IGalleryPtr gallery(event->getGallery());
134 IMediaItemPtr mediaItem(gallery->getMediaItemById(event->getId()));
135 event->setMediaItem(mediaItem);
136 event->setResult(ExceptionCodes::None);
140 LogError("Gallery exception message: " <<
141 _rethrown_exception.GetMessage() <<
142 " Code: " << _rethrown_exception.getCode());
143 event->setResult(_rethrown_exception.getCode());