Merge "Change the way to conver Mbs to Wcs and vice versa" into tizen_2.1
[platform/framework/native/appfw.git] / src / app / FApp_AppControlEventArg.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file         FApp_AppControlEventArg.cpp
20  * @brief       This is the implementation for the _AppControlEventArg.cpp class.
21  */
22
23 #include <unique_ptr.h>
24
25 #include <FBaseString.h>
26 #include <FBaseColIMap.h>
27 #include <FBaseColHashMap.h>
28 #include <FBaseSysLog.h>
29
30 #include "FApp_AppControlEventArg.h"
31 #include "FApp_AppArg.h"
32
33 using namespace Tizen::Base;
34 using namespace Tizen::Base::Collection;
35
36 namespace Tizen { namespace App
37 {
38
39 _AppControlEventArg::~_AppControlEventArg(void)
40 {
41         SysLog(NID_APP, "Deleting launch argument...");
42         delete __pArg;
43 }
44
45 _NativeAppControlEventArg::_NativeAppControlEventArg(int reqId, int res, IMap* pArg)
46         : __reqId(reqId)
47         , __result(res)
48         , __pArgs(null)
49 {
50         if (pArg == null)
51         {
52                 return;
53         }
54
55 #if 0
56         HashMap* pMap = new (std::nothrow) HashMap(SingleObjectDeleter);
57         SysTryReturnVoidResult(NID_APP, pMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
58
59         pMap->Construct();
60
61         std::unique_ptr<IMapEnumerator> pMapEnum(pArg->GetMapEnumeratorN());
62
63         while(pMapEnum->MoveNext() == E_SUCCESS)
64         {
65                 String* pKey = dynamic_cast<String*>(pMapEnum->GetKey());
66                 String* pVal = dynamic_cast<String*>(pMapEnum->GetValue());
67
68                 if (pKey == null || pVal == null)
69                 {
70                         continue;
71                 }
72
73                 pMap->Add(new (std::nothrow) String(*pKey), new (std::nothrow) String(*pVal));
74         }
75
76         __pArgs = pMap;
77 #else
78         // ownership is transferred to event
79         __pArgs = pArg;
80 #endif
81
82         return;
83 }
84
85 _NativeAppControlEventArg::~_NativeAppControlEventArg(void)
86 {
87         if (__pArgs)
88         {
89                 SysLog(NID_APP, "Deleting native AppControl argument.");
90                 delete __pArgs;
91         }
92 }
93
94 } } // Tizen::App