Source code formating unification
[platform/framework/web/wrt.git] / src / view / common / view_logic_storage_support.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 /**
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
20  */
21 #include "view_logic_storage_support.h"
22
23 #include <string>
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>
30
31 namespace ViewModule {
32 namespace StorageSupport {
33 namespace { //anonymous
34 const mode_t TEMPORARY_STORAGE_MODE = 0700;
35 }
36
37 void initializeStorage(WidgetModel *widgetModel)
38 {
39     LogDebug("initializeStorage");
40     Assert(widgetModel && "Passed widgetModel is NULL!");
41
42     // create temporary storage
43     std::string path =
44         DPL::ToUTF8String(widgetModel->TemporaryStoragePath.Get());
45     if (!WrtUtilMakeDir(path, TEMPORARY_STORAGE_MODE)) {
46         ThrowMsg(DPL::CommonException::InternalError,
47                  "Fail to initialize temporary storage");
48     }
49 }
50
51 void deinitializeStorage(WidgetModel *widgetModel)
52 {
53     LogDebug("deinitializeStorage");
54     Assert(widgetModel && "Passed widgetModel is NULL!");
55
56     // remove temporary storage
57     std::string path =
58         DPL::ToUTF8String(widgetModel->TemporaryStoragePath.Get());
59     if (!WrtUtilRemove(path)) {
60         ThrowMsg(DPL::CommonException::InternalError,
61                  "Fail to deinitialize temporary storage");
62     }
63 }
64 } // namespace StorageSupport
65 } // namespace ViewModule