Remove uninitialised bytes
[platform/framework/native/channel-service.git] / src / ChannelService.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         ChannelService.cpp
20  * @brief       This is the implementation for the ChannelService class.
21  */
22
23 #include "ChannelService.h"
24
25 #include <FBaseSysLog.h>
26 #include <FIo_ChannelService.h>
27 #include <FIo_ChannelServiceStub.h>
28 #include <FIo_ChannelServiceManager.h>
29
30 #include <FIo_MessagePortStub.h>
31 #include <FIo_MessagePortService.h>
32
33 using namespace Tizen::Base;
34 using namespace Tizen::Io;
35 using namespace Tizen::App;
36
37 ChannelService::ChannelService()
38 : __pChannelService(null)
39 , __pChannelServiceStub(null)
40 , __pMessagePortService(null)
41 , __pMessagePortStub(null)
42 {
43         SysLog(NID_IO, "Enter.");
44 }
45
46 ChannelService::~ChannelService()
47 {
48         SysLog(NID_IO, "Exit.");
49
50         delete __pChannelService;
51         delete __pChannelServiceStub;
52
53         delete __pMessagePortService;
54         delete __pMessagePortStub;
55 }
56
57 ServiceApp*
58 ChannelService::CreateInstance(void)
59 {
60         // Create the instance through the constructor.
61         return new ChannelService();
62 }
63
64 bool
65 ChannelService::OnAppInitializing(AppRegistry& appRegistry)
66 {
67         result r = E_SUCCESS;
68
69         __pChannelServiceStub = new (std::nothrow) _ChannelServiceStub();
70         if (__pChannelServiceStub == null)
71         {
72                 return false;
73         }
74
75         r = __pChannelServiceStub->Construct();
76         if (IsFailed(r))
77         {
78                 delete __pChannelServiceStub;
79                 __pChannelServiceStub = null;
80
81                 return false;
82         }
83
84         __pChannelService = new (std::nothrow) _ChannelService;
85         if (__pChannelService == null)
86         {
87                 delete __pChannelServiceStub;
88                 __pChannelServiceStub = null;
89
90                 return false;
91         }
92
93         r = __pChannelService->Construct(*__pChannelServiceStub);
94         if (IsFailed(r))
95         {
96                 delete __pChannelService;
97                 __pChannelService = null;
98
99                 delete __pChannelServiceStub;
100                 __pChannelServiceStub = null;
101
102                 return false;
103         }
104
105         _ChannelServiceManager::GetInstance()->SetChannelService(__pChannelService);
106
107
108         // Message Port
109         __pMessagePortStub = new (std::nothrow) _MessagePortStub();
110         if (__pMessagePortStub == null)
111         {
112                 return false;
113         }
114
115         r = __pMessagePortStub->Construct();
116         if (IsFailed(r))
117         {
118                 delete __pMessagePortStub;
119                 __pMessagePortStub = null;
120
121                 return false;
122         }
123
124         __pMessagePortService = new (std::nothrow) _MessagePortService();
125         if (__pMessagePortService == null)
126         {
127                 delete __pMessagePortStub;
128                 __pMessagePortStub = null;
129
130                 return false;
131         }
132
133         r = __pMessagePortService->Construct(*__pMessagePortStub);
134         if (IsFailed(r))
135         {
136                 delete __pMessagePortService;
137                 __pMessagePortService = null;
138
139                 delete __pMessagePortStub;
140                 __pMessagePortStub = null;
141
142                 return false;
143         }
144
145         __pMessagePortStub->SetMessagePortService(*__pMessagePortService);
146
147         return true;
148 }
149
150 bool
151 ChannelService::OnAppInitialized(void)
152 {
153         return true;
154 }
155
156 bool
157 ChannelService::OnAppWillTerminate(void)
158 {
159         return true;
160 }
161
162 bool
163 ChannelService::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
164 {
165         return true;
166 }
167
168 void
169 ChannelService::OnLowMemory(void)
170 {
171 }
172