2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
28 #include <dpl/scoped_ptr.h>
30 #include <Commons/Exception.h>
31 #include <Commons/Regex.h>
32 #include "PathUtils.h"
33 #include "StorageProperties.h"
40 const char* PATH_DOWNLOADS = "/opt/usr/media/Downloads";
41 const char* PATH_DOCUMENTS = "/opt/usr/media/Documents";
42 const char* PATH_SOUNDS = "/opt/usr/media/Sounds";
43 const char* PATH_IMAGES = "/opt/usr/media/Images";
44 const char* PATH_VIDEOS = "/opt/usr/media/Videos";
45 const char* PATH_RINGTONE = "/opt/share/settings/Ringtones/";
48 using namespace WrtDeviceApis;
49 using namespace WrtDeviceApis::Commons;
52 namespace Filesystem {
53 Manager::Locations Manager::m_locations;
54 Manager::RootList Manager::m_rootlist;
55 Manager::SubRootList Manager::m_subrootlist;
56 const std::size_t Manager::m_maxPathLength = 256;
57 NodeList Manager::m_openedNodes;
58 std::vector<Manager::WatcherPtr> Manager::m_watchers;
60 bool Manager::fileExists(const std::string &file)
64 memset(&info, 0, sizeof(struct stat));
65 int status = lstat(file.c_str(), &info);
68 } else if (errno == ENOENT) {
71 ThrowMsg(Commons::PlatformException, "Cannot stat file.");
74 bool Manager::getSupportedDeviceCB(int storage, storage_type_e type, storage_state_e state, const char *path, void *user_data)
76 std::vector<StoragePropertiesPtr>* storageVector = (std::vector<StoragePropertiesPtr>*)user_data;
77 StoragePropertiesPtr storageItem(new StorageProperties());
82 std::string fullpath(path);
83 if (type == STORAGE_TYPE_INTERNAL) {
84 snprintf(buf, size, "internal%d", storage);
86 } else if (type == STORAGE_TYPE_EXTERNAL) {
87 snprintf(buf, size, "removable%d", storage);
90 LoggerD(lable << "state" << state);
92 storageItem->setId(storage);
93 storageItem->setLabel(lable);
94 storageItem->setType((short)type);
95 storageItem->setState((short)state);
96 storageItem->setFullPath(fullpath);
98 storageVector->insert(storageVector->end(), storageItem);
103 void Manager::storageStateChangedCB(int storage, storage_state_e state, void *user_data)
105 if (user_data != NULL) {
106 watcherList* m_watcherList = (watcherList *)user_data;
107 watcherList::iterator it = m_watcherList->begin();
108 for(; it!= m_watcherList->end(); ++it) {
109 (*it)->StorageStateHasChanged(storage, state);
114 void Manager::addOpenedNode(const INodePtr& node)
116 NodeListIterator it = m_openedNodes.begin();
117 for (; it != m_openedNodes.end(); ++it) {
118 if (node.Get() == (*it).Get()) {
119 //node is added already
123 m_openedNodes.push_back(node);
126 void Manager::removeOpenedNode(const INodePtr& node)
128 NodeListIterator it = m_openedNodes.begin();
129 for (; it != m_openedNodes.end(); ++it) {
130 if ((*it).Get() == node.Get()) {
131 m_openedNodes.erase(it);
137 bool Manager::checkIfOpened(const IPathPtr& path) const
139 NodeListIterator it = m_openedNodes.begin();
140 for (; it != m_openedNodes.end(); ++it) {
141 if (*path == *(*it)->getPath()) {
150 static bool initialized = init();
158 StorageList Manager::getStorageList() const
163 IPathPtr Manager::getBasePath() const
165 Locations::const_iterator it = m_locations.find(m_subrootlist.find(LT_ROOT)->second);
166 if (it == m_locations.end()) {
167 ThrowMsg(Commons::PlatformException, "Base path not available.");
172 IPathPtr Manager::getLocationPath(LocationType type) const
174 Locations::const_iterator it = m_locations.find(m_subrootlist.find(type)->second);
175 if (it != m_locations.end()) {
176 return it->second->clone();
181 LocationPaths Manager::getLocationPaths() const
183 LocationPaths result;
184 Locations::const_iterator it = m_locations.begin();
185 for (; it != m_locations.end(); ++it) {
186 result.push_back(it->second->clone());
191 LocationTypes Manager::getLocations() const
193 LocationTypes result;
194 SubRootList::const_iterator it = m_subrootlist.begin();
195 for (; it != m_subrootlist.end(); ++it) {
196 result.push_back(it->first);
201 void Manager::getNode(const EventResolvePtr& event)
203 EventRequestReceiver<EventResolve>::PostRequest(event);
206 void Manager::getStorage(const EventGetStoragePtr& event)
208 EventRequestReceiver<EventGetStorage>::PostRequest(event);
211 void Manager::listStorages(const EventListStoragesPtr& event)
213 EventRequestReceiver<EventListStorages>::PostRequest(event);
216 std::size_t Manager::getMaxPathLength() const
218 return m_maxPathLength;
221 void Manager::copy(const EventCopyPtr& event)
223 EventRequestReceiver<EventCopy>::PostRequest(event);
226 void Manager::move(const EventMovePtr& event)
228 EventRequestReceiver<EventMove>::PostRequest(event);
231 void Manager::create(const EventCreatePtr& event)
233 EventRequestReceiver<EventCreate>::PostRequest(event);
236 void Manager::remove(const EventRemovePtr& event)
238 EventRequestReceiver<EventRemove>::PostRequest(event);
241 void Manager::find(const EventFindPtr& event)
243 EventRequestReceiver<EventFind>::PostRequest(event);
246 void Manager::find(const IPathPtr& path,
247 const FiltersMap& filters,
249 const EventFindPtr& event)
252 DIR* dir = opendir(path->getFullPath().c_str());
258 struct dirent* entry = NULL;
259 while ((entry = readdir(dir))) {
260 if (event && event->checkCancelled()) {
263 if (!strcmp(entry->d_name, ".") || !strncmp(entry->d_name, "..", 2)) {
266 IPathPtr childPath = *path + entry->d_name;
268 memset(&info, 0, sizeof(struct stat));
269 if (lstat(childPath->getFullPath().c_str(), &info) == 0) {
270 if (matchFilters(entry->d_name, info, filters)) {
271 result.push_back(Node::resolve(childPath));
273 if (S_ISDIR(info.st_mode)) {
274 find(childPath, filters, result, event);
280 ThrowMsg(Commons::PlatformException,
281 "Error while reading directory.");
284 if (closedir(dir) != 0) {
285 ThrowMsg(Commons::PlatformException,
286 "Could not close platform node.");
289 Catch(WrtDeviceApis::Commons::Exception) {
293 void Manager::copyElement(
294 const std::string &src, const std::string &dest, bool recursive) const
296 LoggerD("Copying src: " << src << " to: " << dest);
299 if (EINA_TRUE != ecore_file_is_dir(src.c_str())) {
300 if (EINA_TRUE != ecore_file_cp(src.c_str(), dest.c_str())) {
301 ThrowMsg(Commons::PlatformException, "Failed to copy file");
305 //element is a directory -> create it:
306 if (EINA_TRUE != ecore_file_is_dir(dest.c_str())) {
307 if (EINA_TRUE != ecore_file_mkdir(dest.c_str())) {
308 LoggerD("Failed to create destination directory");
309 ThrowMsg(Commons::PlatformException, "Failed to copy directory");
312 //copy all elements of directory:
314 Eina_List* list = ecore_file_ls(src.c_str());
316 EINA_LIST_FREE(list, data)
320 copyElement((src + '/' + static_cast<char*>(data)).c_str(),
321 (dest + '/' + static_cast<char*>(data)).c_str());
324 Catch (Commons::Exception)
326 //remove rest of the list
327 EINA_LIST_FREE(list, data)
331 LoggerE("Exception: " << _rethrown_exception.GetMessage());
332 ReThrowMsg(Commons::PlatformException, "Failed to copy element");
340 /*bool Manager::access(const IPathPtr& path,
341 int accessType) const
344 if (accessType & AT_EXISTS) { amode |= F_OK; }
345 if (accessType & AT_READ) { amode |= R_OK; }
346 if (accessType & AT_WRITE) { amode |= W_OK; }
347 if (accessType & AT_EXEC) { amode |= X_OK; }
348 return (::access(path->getFullPath().c_str(), amode) == 0);
351 long Manager::addStorageStateChangeListener(
352 const EventStorageStateChangedEmitterPtr& emitter)
354 RootList::const_iterator it = m_rootlist.begin();
355 WatcherPtr watcher(new Watcher(emitter));
356 Manager::m_watchers.push_back(watcher);
358 for (; it != m_rootlist.end(); ++it) {
359 storage_set_state_changed_cb(it->second, Manager::storageStateChangedCB, (void *)(&m_watchers));
362 watcher->getCurrentStoargeStateForWatch();
363 return static_cast<long>(emitter->getId());
366 void Manager::removeStorageStateChangeListener(EventStorageStateChangedEmitter::IdType id)
368 watcherList::iterator itWatcher = Manager::m_watchers.begin();
370 for (;itWatcher != Manager::m_watchers.end();) {
371 if (id == (*itWatcher)->getEmitter()->getId()) {
372 itWatcher = Manager::m_watchers.erase(itWatcher);
379 if (Manager::m_watchers.size() == 0) {
380 RootList::const_iterator itRoot;
381 for (itRoot = m_rootlist.begin(); itRoot != m_rootlist.end(); ++itRoot) {
382 storage_unset_state_changed_cb(itRoot->second);
386 if (found == false) {
387 // LoggerD("no exist" << id);
388 ThrowMsg(Commons::NotFoundException, "The " << id << "is not exist");
392 bool Manager::matchFilters(const std::string& name,
393 const struct stat& info,
394 const FiltersMap& filters)
396 FiltersMap::const_iterator it = filters.begin();
397 for (; it != filters.end(); ++it) {
398 if (it->first == FF_NAME) {
399 if (!pcrecpp::RE(it->second).PartialMatch(name)) { return false; }
400 } else if (it->first == FF_SIZE) {
402 std::stringstream ss(it->second);
405 (size != static_cast<size_t>(info.st_size))) { return false; }
406 } else if (it->first == FF_CREATED) {
408 std::stringstream ss(it->second);
410 if (!ss || (created != info.st_ctime)) { return false; }
411 } else if (it->first == FF_MODIFIED) {
412 std::time_t modified;
413 std::stringstream ss(it->second);
415 if (!ss || (modified != info.st_mtime)) { return false; }
421 void Manager::OnRequestReceived(const EventResolvePtr& event)
424 event->setResult(Node::resolve(event->getPath()));
426 catch (const Commons::Exception& ex)
428 LoggerE("Exception: " << ex.GetMessage());
429 event->setExceptionCode(ex.getCode());
433 void Manager::OnRequestReceived(const EventGetStoragePtr& event)
437 StoragePropertiesPtr storage(new StorageProperties());
439 RootList::const_iterator it = m_rootlist.find(event->getLabel());
440 if (it == m_rootlist.end()) {
441 Locations::const_iterator itL = m_locations.find(event->getLabel());
442 if (itL == m_locations.end()) {
443 ThrowMsg(Commons::NotFoundException, "Base path not available.");
445 storage->setId(0xff);
446 storage->setLabel(event->getLabel());
447 storage->setType(StorageProperties::TYPE_INTERNAL);
448 storage->setState(StorageProperties::STATE_MOUNTED);
453 storage_type_e currentType;
454 storage_state_e currentState;
456 storage_get_type(id, ¤tType);
457 storage_get_state(id, ¤tState);
460 storage->setLabel(event->getLabel());
461 storage->setType((short)currentType);
462 storage->setState((short)currentState);
465 event->setResult(storage);
466 } catch (const Commons::Exception& ex)
468 event->setExceptionCode(ex.getCode());
472 void Manager::OnRequestReceived(const EventListStoragesPtr& event)
475 std::vector<StoragePropertiesPtr> storageList;
477 storage_foreach_device_supported(Manager::getSupportedDeviceCB, &storageList);
479 SubRootList::const_iterator it = m_subrootlist.begin();
480 for (; it != m_subrootlist.end(); ++it) {
481 if (it->first == LT_ROOT)
483 if (it->first == LT_SDCARD)
485 if (it->first == LT_USBHOST)
488 addLocalStorage(it->second, storageList);
492 event->setResult(storageList);
493 } catch (const Commons::Exception& ex)
495 event->setExceptionCode(ex.getCode());
499 void Manager::OnRequestReceived(const EventCopyPtr& event)
502 INodePtr srcNode = Node::resolve(event->getSource());
503 LoggerD(std::hex << srcNode->getMode() << " " << std::hex << PM_USER_READ);
504 if ((srcNode->getMode() & PM_USER_READ/*PERM_READ*/) == 0) {
505 ThrowMsg(Commons::SecurityException,
506 "Not enough permissions to read source node.");
509 IPathPtr src = event->getSource();
510 IPathPtr dest = event->getDestination();
511 if (!dest->isAbsolute()) {
512 dest = src->getPath() + *dest;
517 parent = Node::resolve(IPath::create(dest->getPath()));
519 Catch(Commons::NotFoundException)
521 event->setExceptionCode(_rethrown_exception.getCode());
522 ReThrowMsg(Commons::NotFoundException, "could not find a destination path.");
524 Catch (Commons::Exception)
526 event->setExceptionCode(_rethrown_exception.getCode());
527 ReThrowMsg(Commons::PlatformException,
528 "Could not get destination's parent node.");
531 if (parent->getType() != NT_DIRECTORY) {
532 ThrowMsg(Commons::PlatformException,
533 "Destination's parent node is not directory.");
536 std::string realSrc = src->getFullPath();
537 std::string realDest = dest->getFullPath();
539 if (realSrc == realDest) {
540 ThrowMsg(Commons::PlatformException,
541 "Destination is same as source.");
547 memset(&info, 0, sizeof(struct stat));
548 int status = lstat(realDest.c_str(), &info);
549 if ((status != 0) && (errno != ENOENT)) {
550 ThrowMsg(Commons::PlatformException,
551 "No access to platform destination node.");
554 if (S_ISDIR(info.st_mode) && srcNode->getType() == NT_FILE) {
555 dest->append("/" + src->getName());
556 realDest = dest->getFullPath();
557 memset(&info, 0, sizeof(struct stat));
558 status = lstat(realDest.c_str(), &info);
559 if ((status != 0) && (errno != ENOENT)) {
560 ThrowMsg(Commons::PlatformException,
561 "No access to platform destination node.");
566 //no owerwrite flag setted -> exception
567 if ((event->getOptions() & OPT_OVERWRITE) == 0) {
568 ThrowMsg(Commons::PlatformException, "Overwrite is not set.");
571 if (event->checkCancelled()) {
572 //file is not copied yet, so we can cancel it now.
573 event->setCancelAllowed(true);
577 //destination exist. Need to be removed
579 INodePtr node = Node::resolve(dest);
581 // only remove if dest is file.
582 if (node->getType() == NT_FILE) {
583 node->remove(event->getOptions());
586 // destination exist and src & dest are directory and dest path ends with '/'
587 if (srcNode->getType() == NT_DIRECTORY && realDest[realDest.length() - 1] == '/') {
588 realDest += src->getName();
592 catch (const Commons::Exception& ex)
594 LoggerE("Exception: " << ex.GetMessage());
595 event->setExceptionCode(ex.getCode());
598 //Destination is not exist. Start copy now.
599 LoggerD(dest->getFullPath().c_str());
600 copyElement(realSrc, realDest);
602 event->setResult(Node::resolve(dest));
604 catch (const Commons::Exception& ex)
606 LoggerE("Exception: " << ex.GetMessage());
607 event->setExceptionCode(ex.getCode());
609 //file is copied already so we don't allow cancelling anymore.
610 event->setCancelAllowed(false);
613 void Manager::OnRequestReceived(const EventMovePtr& event)
616 IPathPtr src = event->getSource();
617 IPathPtr dest = event->getDestination();
619 INodePtr srcNode = Node::resolve(src);
620 LoggerD(std::hex << srcNode->getMode() << " " << std::hex << PM_USER_WRITE);
621 if ((srcNode->getMode() & PM_USER_WRITE/*PERM_WRITE*/) == 0)
623 ThrowMsg(Commons::SecurityException,
624 "Not enough permissions to move source node.");
627 if (!dest->isAbsolute()) {
628 dest = src->getPath() + *dest;
632 ThrowMsg(Commons::PlatformException,
633 "Destination is same as source.");
638 parent = Node::resolve(IPath::create(dest->getPath()));
641 Catch(Commons::NotFoundException)
643 event->setExceptionCode(_rethrown_exception.getCode());
644 ReThrowMsg(Commons::NotFoundException, "could not find a destination path.");
646 Catch(Commons::Exception)
648 LoggerE("Exception: " << _rethrown_exception.GetMessage());
649 ReThrowMsg(Commons::PlatformException,
650 "Could not get destination's parent node.");
653 if (parent->getType() != NT_DIRECTORY) {
654 ThrowMsg(Commons::PlatformException,
655 "Destination's parent node is not directory.");
660 memset(&info, 0, sizeof(info));
661 int status = lstat(dest->getFullPath().c_str(), &info);
662 if ((status != 0) && (errno != ENOENT)) {
663 ThrowMsg(Commons::PlatformException,
664 "No access to platform destination node.");
667 LoggerD(dest->getFullPath().c_str());
669 if (S_ISDIR(info.st_mode) && srcNode->getType() == NT_FILE) {
670 dest->append("/" + src->getName());
671 memset(&info, 0, sizeof(info));
672 status = lstat(dest->getFullPath().c_str(), &info);
673 if ((status != 0) && (errno != ENOENT)) {
674 ThrowMsg(Commons::PlatformException,
675 "No access to platform destination node.");
679 if (status == 0 && 0 == (event->getOptions() & OPT_OVERWRITE)) {
680 ThrowMsg(Commons::PlatformException, "Overwrite is not set.");
683 if (event->checkCancelled()) {
684 //file is not moved yet, so we can cancel it now.
685 event->setCancelAllowed(true);
691 LoggerD(dest->getFullPath().c_str());
693 if (0 != ::rename(src->getFullPath().c_str(), dest->getFullPath().c_str()))
700 LoggerD(std::hex << srcNode->getMode() << " " << std::hex << PM_USER_READ);
701 if ((srcNode->getMode() & PM_USER_READ /*PERM_READ*/) == 0)
703 ThrowMsg(Commons::SecurityException,
704 "Not enough permissions to move source node.");
707 //destination exist. Need to be removed
709 INodePtr node = Node::resolve(dest);
710 node->remove(event->getOptions());
712 catch (const Commons::Exception& ex)
714 LoggerE("Exception: " << ex.GetMessage());
715 event->setExceptionCode(ex.getCode());
716 LoggerE("Exception while removing dest directory");
720 copyElement(src->getFullPath(),
721 dest->getFullPath());
722 //remove source files
724 INodePtr node = Node::resolve(event->getSource());
725 node->remove(event->getOptions());
727 Catch(Commons::Exception) {
728 LoggerE("Exception: "
729 << _rethrown_exception.GetMessage());
735 ThrowMsg(Commons::PlatformException,
736 "Error on rename: " /*<< DPL::GetErrnoString(error)*/);
741 event->setResult(Node::resolve(dest));
743 catch (const Commons::Exception& ex)
745 LoggerE("Exception: " << ex.GetMessage());
746 event->setExceptionCode(ex.getCode());
749 event->setCancelAllowed(false);
752 void Manager::OnRequestReceived(const EventCreatePtr& event)
756 catch (const Commons::Exception& ex)
758 LoggerE("Exception: " << ex.GetMessage());
759 event->setExceptionCode(ex.getCode());
763 void Manager::OnRequestReceived(const EventRemovePtr& event)
765 if (!event->checkCancelled()) {
767 INodePtr node = Node::resolve(event->getPath());
768 node->remove(event->getOptions());
770 catch (const Commons::Exception& ex)
772 LoggerE("Exception: " << ex.GetMessage());
773 event->setExceptionCode(ex.getCode());
775 event->setCancelAllowed(false);
777 event->setCancelAllowed(true);
781 void Manager::OnRequestReceived(const EventFindPtr& event)
785 find(event->getPath(), event->getFilters(), result, event);
786 event->setResult(result);
788 catch (const Commons::Exception& ex) {
789 LoggerE("Exception: " << ex.GetMessage());
790 event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
792 event->setCancelAllowed(true);
795 void Manager::addLocalStorage(std::string label, std::vector<StoragePropertiesPtr> &storageList)
797 StoragePropertiesPtr storage(new StorageProperties());
798 storage->setId(0xff);
799 storage->setLabel(label);
800 storage->setType(StorageProperties::TYPE_INTERNAL);
802 storage_state_e currentState;
803 storage_get_state(0, ¤tState);
804 storage->setState((short)currentState);
806 storageList.insert(storageList.end(), storage);
809 void Manager::addWidgetStorage(const std::string &key, const std::string &value)
811 setupLocation(key, value.c_str());
813 if (key == "wgt-package")
815 m_subrootlist[LT_WGTPKG] = key;
817 else if (key == "wgt-private")
819 m_subrootlist[LT_WGTPRV] = key;
821 else if (key == "wgt-private-tmp")
823 m_subrootlist[LT_WGTPRVTMP] = key;
829 std::vector<StoragePropertiesPtr> storageList;
830 storage_foreach_device_supported(Manager::getSupportedDeviceCB, &storageList);
832 for (size_t i = 0; i < storageList.size(); i++) {
833 m_locations[storageList[i]->getLabel()] = IPath::create(storageList[i]->getFullPath());
834 m_rootlist[storageList[i]->getLabel()] = storageList[i]->getId();
838 setupLocation("downloads", PATH_DOWNLOADS);
839 setupLocation("documents", PATH_DOCUMENTS);
840 setupLocation("music", PATH_SOUNDS);
841 setupLocation("images", PATH_IMAGES);
842 setupLocation("videos", PATH_VIDEOS);
843 setupLocation("ringtones", PATH_RINGTONE);
845 m_subrootlist[LT_ROOT] = "internal0";
846 m_subrootlist[LT_SDCARD] = "removable1";
847 m_subrootlist[LT_USBHOST] = "removable2";
848 m_subrootlist[LT_DOWNLOADS] = "downloads";
849 m_subrootlist[LT_DOCUMENTS] = "documents";
850 m_subrootlist[LT_SOUNDS] = "music";
851 m_subrootlist[LT_IMAGES] = "images";
852 m_subrootlist[LT_VIDEOS] = "videos";
853 m_subrootlist[LT_RINGTONES] = "ringtones";
858 void Manager::setupLocation(std::string location, const char* path)
860 if (!nodeExists(path)) {
862 makePath(path, 0755);
864 catch (const Commons::Exception& ex)
866 LoggerE("Exception: " << ex.GetMessage());
870 m_locations[location] = IPath::create(path);
873 void Manager::Watcher::getCurrentStoargeStateForWatch()
875 std::string label("");
877 storage_state_e state;
878 RootList::const_iterator it = m_rootlist.begin();
879 for (; it != m_rootlist.end(); ++it) {
881 if (label.compare("") != 0) {
882 StoragePropertiesPtr storageItem(new StorageProperties());
884 if (storage_get_type(it->second, &type) != STORAGE_ERROR_NONE) {
885 Throw(Commons::PlatformException);
887 if (storage_get_state(it->second, &state) != STORAGE_ERROR_NONE) {
888 Throw(Commons::PlatformException);
891 storageItem->setId(it->second);
892 storageItem->setLabel(it->first);
893 storageItem->setType(static_cast<short>(type));
894 storageItem->setState(static_cast<short>(state));
896 EventStorageStateChangedPtr event(new EventStorageStateChanged());
898 event->setResult(storageItem);
904 void Manager::Watcher::StorageStateHasChanged(int storage, storage_state_e state)
906 StoragePropertiesPtr storageItem(new StorageProperties());
911 RootList::const_iterator it = m_rootlist.begin();
912 for (; it != m_rootlist.end(); ++it) {
913 if (it->second == storage) {
919 if (storage_get_type(storage, &type) != STORAGE_ERROR_NONE) {
920 Throw(Commons::PlatformException);
923 if (label.compare("") != 0) {
924 storageItem->setId(storage);
925 storageItem->setLabel(label);
926 storageItem->setType(static_cast<short>(type));
927 storageItem->setState(static_cast<short>(state));
929 EventStorageStateChangedPtr event(new EventStorageStateChanged());
931 event->setResult(storageItem);