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/usr/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 = PATH_MAX;
58 NodeList Manager::m_openedNodes;
59 std::vector<Manager::WatcherPtr> Manager::m_watchers;
61 bool Manager::fileExists(const std::string &file)
65 memset(&info, 0, sizeof(struct stat));
66 int status = lstat(file.c_str(), &info);
69 } else if (errno == ENOENT) {
72 ThrowMsg(Commons::PlatformException, "Cannot stat file.");
75 bool Manager::getSupportedDeviceCB(int storage, storage_type_e type, storage_state_e state, const char *path, void *user_data)
77 std::vector<StoragePropertiesPtr>* storageVector = (std::vector<StoragePropertiesPtr>*)user_data;
78 StoragePropertiesPtr storageItem(new StorageProperties());
83 std::string fullpath(path);
84 if (type == STORAGE_TYPE_INTERNAL) {
85 snprintf(buf, size, "internal%d", storage);
87 } else if (type == STORAGE_TYPE_EXTERNAL) {
88 snprintf(buf, size, "removable%d", storage);
91 LoggerD(lable << "state" << state);
93 storageItem->setId(storage);
94 storageItem->setLabel(lable);
95 storageItem->setType((short)type);
96 storageItem->setState((short)state);
97 storageItem->setFullPath(fullpath);
99 storageVector->insert(storageVector->end(), storageItem);
104 void Manager::storageStateChangedCB(int storage, storage_state_e state, void *user_data)
106 if (user_data != NULL) {
107 watcherList* m_watcherList = (watcherList *)user_data;
108 watcherList::iterator it = m_watcherList->begin();
109 for(; it!= m_watcherList->end(); ++it) {
110 (*it)->StorageStateHasChanged(storage, state);
115 void Manager::addOpenedNode(const INodePtr& node)
117 NodeListIterator it = m_openedNodes.begin();
118 for (; it != m_openedNodes.end(); ++it) {
119 if (node.Get() == (*it).Get()) {
120 //node is added already
124 m_openedNodes.push_back(node);
127 void Manager::removeOpenedNode(const INodePtr& node)
129 NodeListIterator it = m_openedNodes.begin();
130 for (; it != m_openedNodes.end(); ++it) {
131 if ((*it).Get() == node.Get()) {
132 m_openedNodes.erase(it);
138 bool Manager::checkIfOpened(const IPathPtr& path) const
140 NodeListIterator it = m_openedNodes.begin();
141 for (; it != m_openedNodes.end(); ++it) {
142 if (*path == *(*it)->getPath()) {
151 static bool initialized = init();
159 StorageList Manager::getStorageList() const
164 IPathPtr Manager::getBasePath() const
166 Locations::const_iterator it = m_locations.find(m_subrootlist.find(LT_ROOT)->second);
167 if (it == m_locations.end()) {
168 ThrowMsg(Commons::PlatformException, "Base path not available.");
173 IPathPtr Manager::getLocationPath(LocationType type) const
175 Locations::const_iterator it = m_locations.find(m_subrootlist.find(type)->second);
176 if (it != m_locations.end()) {
177 return it->second->clone();
182 LocationPaths Manager::getLocationPaths() const
184 LocationPaths result;
185 Locations::const_iterator it = m_locations.begin();
186 for (; it != m_locations.end(); ++it) {
187 result.push_back(it->second->clone());
192 LocationTypes Manager::getLocations() const
194 LocationTypes result;
195 SubRootList::const_iterator it = m_subrootlist.begin();
196 for (; it != m_subrootlist.end(); ++it) {
197 result.push_back(it->first);
202 void Manager::getNode(const EventResolvePtr& event)
204 EventRequestReceiver<EventResolve>::PostRequest(event);
207 void Manager::getStorage(const EventGetStoragePtr& event)
209 EventRequestReceiver<EventGetStorage>::PostRequest(event);
212 void Manager::listStorages(const EventListStoragesPtr& event)
214 EventRequestReceiver<EventListStorages>::PostRequest(event);
217 std::size_t Manager::getMaxPathLength() const
219 return m_maxPathLength;
222 void Manager::copy(const EventCopyPtr& event)
224 EventRequestReceiver<EventCopy>::PostRequest(event);
227 void Manager::move(const EventMovePtr& event)
229 EventRequestReceiver<EventMove>::PostRequest(event);
232 void Manager::create(const EventCreatePtr& event)
234 EventRequestReceiver<EventCreate>::PostRequest(event);
237 void Manager::remove(const EventRemovePtr& event)
239 EventRequestReceiver<EventRemove>::PostRequest(event);
242 void Manager::find(const EventFindPtr& event)
244 EventRequestReceiver<EventFind>::PostRequest(event);
247 void Manager::find(const IPathPtr& path,
248 const FiltersMap& filters,
250 const EventFindPtr& event)
253 DIR* dir = opendir(path->getFullPath().c_str());
259 struct dirent* entry = NULL;
260 while ((entry = readdir(dir))) {
261 if (event && event->checkCancelled()) {
264 if (!strcmp(entry->d_name, ".") || !strncmp(entry->d_name, "..", 2)) {
267 IPathPtr childPath = *path + entry->d_name;
269 memset(&info, 0, sizeof(struct stat));
270 if (lstat(childPath->getFullPath().c_str(), &info) == 0) {
271 if (matchFilters(entry->d_name, info, filters)) {
272 result.push_back(Node::resolve(childPath));
274 if (S_ISDIR(info.st_mode)) {
275 find(childPath, filters, result, event);
281 ThrowMsg(Commons::PlatformException,
282 "Error while reading directory.");
285 if (closedir(dir) != 0) {
286 ThrowMsg(Commons::PlatformException,
287 "Could not close platform node.");
290 Catch(WrtDeviceApis::Commons::Exception) {
294 void Manager::copyElement(
295 const std::string &src, const std::string &dest, bool recursive) const
297 LoggerD("Copying src: " << src << " to: " << dest);
300 if (EINA_TRUE != ecore_file_is_dir(src.c_str())) {
301 if (EINA_TRUE != ecore_file_cp(src.c_str(), dest.c_str())) {
302 ThrowMsg(Commons::PlatformException, "Failed to copy file");
306 //element is a directory -> create it:
307 if (EINA_TRUE != ecore_file_is_dir(dest.c_str())) {
308 if (EINA_TRUE != ecore_file_mkdir(dest.c_str())) {
309 LoggerD("Failed to create destination directory");
310 ThrowMsg(Commons::PlatformException, "Failed to copy directory");
313 //copy all elements of directory:
315 Eina_List* list = ecore_file_ls(src.c_str());
317 EINA_LIST_FREE(list, data)
321 copyElement((src + '/' + static_cast<char*>(data)).c_str(),
322 (dest + '/' + static_cast<char*>(data)).c_str());
325 Catch (Commons::Exception)
327 //remove rest of the list
328 EINA_LIST_FREE(list, data)
332 LoggerE("Exception: " << _rethrown_exception.GetMessage());
333 ReThrowMsg(Commons::PlatformException, "Failed to copy element");
341 /*bool Manager::access(const IPathPtr& path,
342 int accessType) const
345 if (accessType & AT_EXISTS) { amode |= F_OK; }
346 if (accessType & AT_READ) { amode |= R_OK; }
347 if (accessType & AT_WRITE) { amode |= W_OK; }
348 if (accessType & AT_EXEC) { amode |= X_OK; }
349 return (::access(path->getFullPath().c_str(), amode) == 0);
352 long Manager::addStorageStateChangeListener(
353 const EventStorageStateChangedEmitterPtr& emitter)
355 RootList::const_iterator it = m_rootlist.begin();
356 WatcherPtr watcher(new Watcher(emitter));
357 Manager::m_watchers.push_back(watcher);
359 for (; it != m_rootlist.end(); ++it) {
360 storage_set_state_changed_cb(it->second, Manager::storageStateChangedCB, (void *)(&m_watchers));
363 watcher->getCurrentStoargeStateForWatch();
364 return static_cast<long>(emitter->getId());
367 void Manager::removeStorageStateChangeListener(EventStorageStateChangedEmitter::IdType id)
369 watcherList::iterator itWatcher = Manager::m_watchers.begin();
371 for (;itWatcher != Manager::m_watchers.end();) {
372 if (id == (*itWatcher)->getEmitter()->getId()) {
373 itWatcher = Manager::m_watchers.erase(itWatcher);
380 if (Manager::m_watchers.size() == 0) {
381 RootList::const_iterator itRoot;
382 for (itRoot = m_rootlist.begin(); itRoot != m_rootlist.end(); ++itRoot) {
383 storage_unset_state_changed_cb(itRoot->second);
387 if (found == false) {
388 // LoggerD("no exist" << id);
389 ThrowMsg(Commons::NotFoundException, "The " << id << "is not exist");
393 bool Manager::matchFilters(const std::string& name,
394 const struct stat& info,
395 const FiltersMap& filters)
397 FiltersMap::const_iterator it = filters.begin();
398 for (; it != filters.end(); ++it) {
399 if (it->first == FF_NAME) {
400 if (!pcrecpp::RE(it->second).PartialMatch(name)) { return false; }
401 } else if (it->first == FF_SIZE) {
403 std::stringstream ss(it->second);
406 (size != static_cast<size_t>(info.st_size))) { return false; }
407 } else if (it->first == FF_CREATED) {
409 std::stringstream ss(it->second);
411 if (!ss || (created != info.st_ctime)) { return false; }
412 } else if (it->first == FF_MODIFIED) {
413 std::time_t modified;
414 std::stringstream ss(it->second);
416 if (!ss || (modified != info.st_mtime)) { return false; }
422 void Manager::OnRequestReceived(const EventResolvePtr& event)
425 INodePtr node = Node::resolve(event->getPath());
426 if (node->checkPermission(event->getPath(), event->getMode(), node->getType()) == false)
428 ThrowMsg(Commons::SecurityException, "Permission Denied Error");
430 event->setResult(node);
432 catch (const Commons::Exception& ex)
434 LoggerE("Exception: " << ex.GetMessage());
435 event->setExceptionCode(ex.getCode());
439 void Manager::OnRequestReceived(const EventGetStoragePtr& event)
443 StoragePropertiesPtr storage(new StorageProperties());
445 RootList::const_iterator it = m_rootlist.find(event->getLabel());
446 if (it == m_rootlist.end()) {
447 Locations::const_iterator itL = m_locations.find(event->getLabel());
448 if (itL == m_locations.end()) {
449 ThrowMsg(Commons::NotFoundException, "Base path not available.");
451 storage->setId(0xff);
452 storage->setLabel(event->getLabel());
453 storage->setType(StorageProperties::TYPE_INTERNAL);
454 storage->setState(StorageProperties::STATE_MOUNTED);
459 storage_type_e currentType;
460 storage_state_e currentState;
462 storage_get_type(id, ¤tType);
463 storage_get_state(id, ¤tState);
466 storage->setLabel(event->getLabel());
467 storage->setType((short)currentType);
468 storage->setState((short)currentState);
471 event->setResult(storage);
472 } catch (const Commons::Exception& ex)
474 event->setExceptionCode(ex.getCode());
478 void Manager::OnRequestReceived(const EventListStoragesPtr& event)
481 std::vector<StoragePropertiesPtr> storageList;
483 storage_foreach_device_supported(Manager::getSupportedDeviceCB, &storageList);
485 SubRootList::const_iterator it = m_subrootlist.begin();
486 for (; it != m_subrootlist.end(); ++it) {
487 if (it->first == LT_ROOT)
489 if (it->first == LT_SDCARD)
491 if (it->first == LT_USBHOST)
494 addLocalStorage(it->second, storageList);
498 event->setResult(storageList);
499 } catch (const Commons::Exception& ex)
501 event->setExceptionCode(ex.getCode());
505 void Manager::OnRequestReceived(const EventCopyPtr& event)
508 INodePtr srcNode = Node::resolve(event->getSource());
509 LoggerD(std::hex << srcNode->getMode() << " " << std::hex << PM_USER_READ);
510 if ((srcNode->getMode() & PM_USER_READ/*PERM_READ*/) == 0) {
511 ThrowMsg(Commons::SecurityException,
512 "Not enough permissions to read source node.");
515 IPathPtr src = event->getSource();
516 IPathPtr dest = event->getDestination();
517 if (!dest->isAbsolute()) {
518 dest = src->getPath() + *dest;
523 parent = Node::resolve(IPath::create(dest->getPath()));
525 Catch(Commons::NotFoundException)
527 event->setExceptionCode(_rethrown_exception.getCode());
528 ReThrowMsg(Commons::NotFoundException, "could not find a destination path.");
530 Catch (Commons::Exception)
532 event->setExceptionCode(_rethrown_exception.getCode());
533 ReThrowMsg(Commons::PlatformException,
534 "Could not get destination's parent node.");
537 if (parent->getType() != NT_DIRECTORY) {
538 ThrowMsg(Commons::PlatformException,
539 "Destination's parent node is not directory.");
542 std::string realSrc = src->getFullPath();
543 std::string realDest = dest->getFullPath();
545 if (realSrc == realDest) {
546 ThrowMsg(Commons::PlatformException,
547 "Destination is same as source.");
553 memset(&info, 0, sizeof(struct stat));
554 int status = lstat(realDest.c_str(), &info);
555 if ((status != 0) && (errno != ENOENT)) {
556 ThrowMsg(Commons::PlatformException,
557 "No access to platform destination node.");
560 if (S_ISDIR(info.st_mode) && srcNode->getType() == NT_FILE) {
561 dest->append("/" + src->getName());
562 realDest = dest->getFullPath();
563 memset(&info, 0, sizeof(struct stat));
564 status = lstat(realDest.c_str(), &info);
565 if ((status != 0) && (errno != ENOENT)) {
566 ThrowMsg(Commons::PlatformException,
567 "No access to platform destination node.");
572 //no owerwrite flag setted -> exception
573 if ((event->getOptions() & OPT_OVERWRITE) == 0) {
574 ThrowMsg(Commons::PlatformException, "Overwrite is not set.");
577 if (event->checkCancelled()) {
578 //file is not copied yet, so we can cancel it now.
579 event->setCancelAllowed(true);
583 //destination exist. Need to be removed
585 INodePtr node = Node::resolve(dest);
587 // only remove if dest is file.
588 if (node->getType() == NT_FILE) {
589 node->remove(event->getOptions());
592 // destination exist and src & dest are directory and dest path ends with '/'
593 if (srcNode->getType() == NT_DIRECTORY && realDest[realDest.length() - 1] == '/') {
594 realDest += src->getName();
598 catch (const Commons::Exception& ex)
600 LoggerE("Exception: " << ex.GetMessage());
601 event->setExceptionCode(ex.getCode());
604 //Destination is not exist. Start copy now.
605 LoggerD(dest->getFullPath().c_str());
606 copyElement(realSrc, realDest);
608 event->setResult(Node::resolve(dest));
610 catch (const Commons::Exception& ex)
612 LoggerE("Exception: " << ex.GetMessage());
613 event->setExceptionCode(ex.getCode());
615 //file is copied already so we don't allow cancelling anymore.
616 event->setCancelAllowed(false);
619 void Manager::OnRequestReceived(const EventMovePtr& event)
622 IPathPtr src = event->getSource();
623 IPathPtr dest = event->getDestination();
625 INodePtr srcNode = Node::resolve(src);
626 LoggerD(std::hex << srcNode->getMode() << " " << std::hex << PM_USER_WRITE);
627 if ((srcNode->getMode() & PM_USER_WRITE/*PERM_WRITE*/) == 0)
629 ThrowMsg(Commons::SecurityException,
630 "Not enough permissions to move source node.");
633 if (!dest->isAbsolute()) {
634 dest = src->getPath() + *dest;
638 ThrowMsg(Commons::PlatformException,
639 "Destination is same as source.");
644 parent = Node::resolve(IPath::create(dest->getPath()));
647 Catch(Commons::NotFoundException)
649 event->setExceptionCode(_rethrown_exception.getCode());
650 ReThrowMsg(Commons::NotFoundException, "could not find a destination path.");
652 Catch(Commons::Exception)
654 LoggerE("Exception: " << _rethrown_exception.GetMessage());
655 ReThrowMsg(Commons::PlatformException,
656 "Could not get destination's parent node.");
659 if (parent->getType() != NT_DIRECTORY) {
660 ThrowMsg(Commons::PlatformException,
661 "Destination's parent node is not directory.");
666 memset(&info, 0, sizeof(info));
667 int status = lstat(dest->getFullPath().c_str(), &info);
668 if ((status != 0) && (errno != ENOENT)) {
669 ThrowMsg(Commons::PlatformException,
670 "No access to platform destination node.");
673 LoggerD(dest->getFullPath().c_str());
675 if (S_ISDIR(info.st_mode) && srcNode->getType() == NT_FILE) {
676 dest->append("/" + src->getName());
677 memset(&info, 0, sizeof(info));
678 status = lstat(dest->getFullPath().c_str(), &info);
679 if ((status != 0) && (errno != ENOENT)) {
680 ThrowMsg(Commons::PlatformException,
681 "No access to platform destination node.");
685 if (status == 0 && 0 == (event->getOptions() & OPT_OVERWRITE)) {
686 ThrowMsg(Commons::PlatformException, "Overwrite is not set.");
689 if (event->checkCancelled()) {
690 //file is not moved yet, so we can cancel it now.
691 event->setCancelAllowed(true);
697 LoggerD(dest->getFullPath().c_str());
699 if (0 != ::rename(src->getFullPath().c_str(), dest->getFullPath().c_str()))
706 LoggerD(std::hex << srcNode->getMode() << " " << std::hex << PM_USER_READ);
707 if ((srcNode->getMode() & PM_USER_READ /*PERM_READ*/) == 0)
709 ThrowMsg(Commons::SecurityException,
710 "Not enough permissions to move source node.");
713 //destination exist. Need to be removed
715 INodePtr node = Node::resolve(dest);
716 node->remove(event->getOptions());
718 catch (const Commons::Exception& ex)
720 LoggerE("Exception: " << ex.GetMessage());
721 event->setExceptionCode(ex.getCode());
722 LoggerE("Exception while removing dest directory");
726 copyElement(src->getFullPath(),
727 dest->getFullPath());
728 //remove source files
730 INodePtr node = Node::resolve(event->getSource());
731 node->remove(event->getOptions());
733 Catch(Commons::Exception) {
734 LoggerE("Exception: "
735 << _rethrown_exception.GetMessage());
741 ThrowMsg(Commons::PlatformException,
742 "Error on rename: " /*<< DPL::GetErrnoString(error)*/);
747 event->setResult(Node::resolve(dest));
749 catch (const Commons::Exception& ex)
751 LoggerE("Exception: " << ex.GetMessage());
752 event->setExceptionCode(ex.getCode());
755 event->setCancelAllowed(false);
758 void Manager::OnRequestReceived(const EventCreatePtr& event)
762 catch (const Commons::Exception& ex)
764 LoggerE("Exception: " << ex.GetMessage());
765 event->setExceptionCode(ex.getCode());
769 void Manager::OnRequestReceived(const EventRemovePtr& event)
771 if (!event->checkCancelled()) {
773 INodePtr node = Node::resolve(event->getPath());
774 node->remove(event->getOptions());
776 catch (const Commons::Exception& ex)
778 LoggerE("Exception: " << ex.GetMessage());
779 event->setExceptionCode(ex.getCode());
781 event->setCancelAllowed(false);
783 event->setCancelAllowed(true);
787 void Manager::OnRequestReceived(const EventFindPtr& event)
791 find(event->getPath(), event->getFilters(), result, event);
792 event->setResult(result);
794 catch (const Commons::Exception& ex) {
795 LoggerE("Exception: " << ex.GetMessage());
796 event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
798 event->setCancelAllowed(true);
801 void Manager::addLocalStorage(std::string label, std::vector<StoragePropertiesPtr> &storageList)
803 StoragePropertiesPtr storage(new StorageProperties());
804 storage->setId(0xff);
805 storage->setLabel(label);
806 storage->setType(StorageProperties::TYPE_INTERNAL);
808 storage_state_e currentState;
809 storage_get_state(0, ¤tState);
810 storage->setState((short)currentState);
812 storageList.insert(storageList.end(), storage);
815 void Manager::addWidgetStorage(const std::string &key, const std::string &value)
817 setupLocation(key, value.c_str());
819 if (key == "wgt-package")
821 m_subrootlist[LT_WGTPKG] = key;
823 else if (key == "wgt-private")
825 m_subrootlist[LT_WGTPRV] = key;
827 else if (key == "wgt-private-tmp")
829 m_subrootlist[LT_WGTPRVTMP] = key;
835 std::vector<StoragePropertiesPtr> storageList;
836 storage_foreach_device_supported(Manager::getSupportedDeviceCB, &storageList);
838 for (size_t i = 0; i < storageList.size(); i++) {
839 m_locations[storageList[i]->getLabel()] = IPath::create(storageList[i]->getFullPath());
840 m_rootlist[storageList[i]->getLabel()] = storageList[i]->getId();
844 setupLocation("downloads", PATH_DOWNLOADS);
845 setupLocation("documents", PATH_DOCUMENTS);
846 setupLocation("music", PATH_SOUNDS);
847 setupLocation("images", PATH_IMAGES);
848 setupLocation("videos", PATH_VIDEOS);
849 setupLocation("ringtones", PATH_RINGTONE);
851 m_subrootlist[LT_ROOT] = "internal0";
852 m_subrootlist[LT_SDCARD] = "removable1";
853 m_subrootlist[LT_USBHOST] = "removable2";
854 m_subrootlist[LT_DOWNLOADS] = "downloads";
855 m_subrootlist[LT_DOCUMENTS] = "documents";
856 m_subrootlist[LT_SOUNDS] = "music";
857 m_subrootlist[LT_IMAGES] = "images";
858 m_subrootlist[LT_VIDEOS] = "videos";
859 m_subrootlist[LT_RINGTONES] = "ringtones";
864 void Manager::setupLocation(std::string location, const char* path)
866 if (!nodeExists(path)) {
868 makePath(path, 0755);
870 catch (const Commons::Exception& ex)
872 LoggerE("Exception: " << ex.GetMessage());
876 m_locations[location] = IPath::create(path);
879 void Manager::Watcher::getCurrentStoargeStateForWatch()
881 std::string label("");
883 storage_state_e state;
884 RootList::const_iterator it = m_rootlist.begin();
885 for (; it != m_rootlist.end(); ++it) {
887 if (label.compare("") != 0) {
888 StoragePropertiesPtr storageItem(new StorageProperties());
890 if (storage_get_type(it->second, &type) != STORAGE_ERROR_NONE) {
891 Throw(Commons::PlatformException);
893 if (storage_get_state(it->second, &state) != STORAGE_ERROR_NONE) {
894 Throw(Commons::PlatformException);
897 storageItem->setId(it->second);
898 storageItem->setLabel(it->first);
899 storageItem->setType(static_cast<short>(type));
900 storageItem->setState(static_cast<short>(state));
902 EventStorageStateChangedPtr event(new EventStorageStateChanged());
904 event->setResult(storageItem);
910 void Manager::Watcher::StorageStateHasChanged(int storage, storage_state_e state)
912 StoragePropertiesPtr storageItem(new StorageProperties());
917 RootList::const_iterator it = m_rootlist.begin();
918 for (; it != m_rootlist.end(); ++it) {
919 if (it->second == storage) {
925 if (storage_get_type(storage, &type) != STORAGE_ERROR_NONE) {
926 Throw(Commons::PlatformException);
929 if (label.compare("") != 0) {
930 storageItem->setId(storage);
931 storageItem->setLabel(label);
932 storageItem->setType(static_cast<short>(type));
933 storageItem->setState(static_cast<short>(state));
935 EventStorageStateChangedPtr event(new EventStorageStateChanged());
937 event->setResult(storageItem);