2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
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.
19 #include "MsgHandle.h"
21 #include "MsgException.h"
23 #include "msg_private.h"
26 /*==================================================================================================
27 FUNCTION IMPLEMENTATION
28 ==================================================================================================*/
29 EXPORT_API int msg_open_msg_handle(msg_handle_t *handle)
33 MSG_FATAL("Input Paramter is NULL");
36 MsgHandle* pHandle = new MsgHandle();
39 *handle = (msg_handle_t)pHandle;
47 pHandle->openHandle();
49 catch (MsgException& e)
51 MSG_FATAL("%s", e.what());
53 if (e.errorCode() == MsgException::SERVER_READY_ERROR)
54 return MSG_ERR_SERVER_NOT_READY;
56 return MSG_ERR_COMMUNICATION_ERROR;
63 EXPORT_API int msg_close_msg_handle(msg_handle_t *handle)
65 if (handle == NULL || *handle == NULL)
67 MSG_FATAL("Input Paramter is NULL");
71 MsgHandle* pHandle = (MsgHandle*)(*handle);
75 // Disconnect to Socket
76 pHandle->closeHandle(pHandle);
78 catch (MsgException& e)
80 MSG_FATAL("%s", e.what());
81 return MSG_ERR_COMMUNICATION_ERROR;
85 delete (MsgHandle*)(*handle);