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 {
33 namespace { //anonymous
34 const mode_t TEMPORARY_STORAGE_MODE = 0700;
37 void initializeStorage(WidgetModel *widgetModel)
39 LogDebug("initializeStorage");
40 Assert(widgetModel && "Passed widgetModel is NULL!");
42 // create temporary storage
44 DPL::ToUTF8String(widgetModel->TemporaryStoragePath.Get());
45 if (!WrtUtilMakeDir(path, TEMPORARY_STORAGE_MODE)) {
46 ThrowMsg(DPL::CommonException::InternalError,
47 "Fail to initialize temporary storage");
51 void deinitializeStorage(WidgetModel *widgetModel)
53 LogDebug("deinitializeStorage");
54 Assert(widgetModel && "Passed widgetModel is NULL!");
56 // remove temporary storage
58 DPL::ToUTF8String(widgetModel->TemporaryStoragePath.Get());
59 if (!WrtUtilRemove(path)) {
60 ThrowMsg(DPL::CommonException::InternalError,
61 "Fail to deinitialize temporary storage");
64 } // namespace StorageSupport
65 } // namespace ViewModule