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 view_logic_storage_support.cpp
18 * @author Pawel Sikorski (p.sikorski@samsung.com)
19 * @brief Implementation file of StorageSupport API used by ViewLogic
21 #include "view_logic_storage_support.h"
24 #include <dpl/assert.h>
25 #include <dpl/exception.h>
26 #include <dpl/log/log.h>
27 #include <dpl/string.h>
28 #include <dpl/utils/wrt_utility.h>
29 #include <widget_model.h>
31 namespace ViewModule {
32 namespace StorageSupport {
36 const mode_t TEMPORARY_STORAGE_MODE = 0700;
39 void initializeStorage(WidgetModel *widgetModel)
41 LogDebug("initializeStorage");
42 Assert(widgetModel && "Passed widgetModel is NULL!");
44 // create temporary storage
46 DPL::ToUTF8String(widgetModel->TemporaryStoragePath.Get());
47 if(!WrtUtilMakeDir(path, TEMPORARY_STORAGE_MODE)){
48 ThrowMsg(DPL::CommonException::InternalError,
49 "Fail to initialize temporary storage");
53 void deinitializeStorage(WidgetModel *widgetModel)
55 LogDebug("deinitializeStorage");
56 Assert(widgetModel && "Passed widgetModel is NULL!");
58 // remove temporary storage
60 DPL::ToUTF8String(widgetModel->TemporaryStoragePath.Get());
61 if(!WrtUtilRemove(path)){
62 ThrowMsg(DPL::CommonException::InternalError,
63 "Fail to deinitialize temporary storage");
67 } // namespace StorageSupport
68 } // namespace ViewModule