remove badge dependency for legacy NotificationManager
[platform/framework/native/appfw.git] / src / io / FIo_ChannelServiceManager.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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 /**
18  * @file        FIo_ChannelServiceManager.cpp
19  * @brief       This is the implementation file for the _ChannelServiceManager class.
20  *
21  */
22
23 #include <FBaseSysLog.h>
24 #include "FIo_ChannelServiceManager.h"
25 #include "FIo_ChannelServiceProxy.h"
26
27 namespace Tizen { namespace Io
28 {
29
30 _ChannelServiceManager* _ChannelServiceManager::__pChannnelServiceManager = null;
31
32 _ChannelServiceManager::_ChannelServiceManager(void)
33         : __pIChannelService(null)
34 {
35
36 }
37
38 _ChannelServiceManager::~_ChannelServiceManager(void)
39 {
40
41 }
42
43 _ChannelServiceManager*
44 _ChannelServiceManager::GetInstance(void)
45 {
46         // FIXME:
47         // Use lock to prevent duplicated creation.
48         if (__pChannnelServiceManager == null)
49         {
50                 __pChannnelServiceManager = new (std::nothrow) _ChannelServiceManager;
51                 SysTryReturn(NID_IO, __pChannnelServiceManager != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
52         }
53
54         return __pChannnelServiceManager;
55 }
56
57 // This method is called by channel daemon.
58 // Cahnnel daemon should call this before GetChanelService is called.
59 void
60 _ChannelServiceManager::SetChannelService(_IChannelService* pIChannelService)
61 {
62         __pIChannelService = pIChannelService;
63 }
64
65 // This method returns an _IChannelService interface.
66 // If this is called by application process a proxy implementation is returned.
67 // Or if this is called by channel daemon the service implementation is returned.
68 _IChannelService*
69 _ChannelServiceManager::GetChannelService(void)
70 {
71         if (__pIChannelService == null)
72         {
73                 result r = E_SUCCESS;
74
75                 _ChannelServiceProxy* pProxy = new (std::nothrow) _ChannelServiceProxy();
76                 SysTryReturn(NID_IO, pProxy, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
77
78                 r = pProxy->Construct();
79                 SysTryCatch(NID_IO, !IsFailed(r), , E_SYSTEM, "[E_SYSTEM] Failed to initialize channel proxy.");
80
81                 __pIChannelService = pProxy;
82         }
83
84         return __pIChannelService;
85
86 CATCH:
87         delete __pIChannelService;
88         __pIChannelService = null;
89
90         return null;
91 }
92
93 }}