2 * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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)
31 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
34 MSG_FATAL("Input Parameter is NULL");
35 return MSG_ERR_INVALID_PARAMETER;
37 /* Create MsgHandle */
38 MsgHandle* pHandle = new MsgHandle();
41 return MSG_ERR_MEMORY_ERROR;
42 *handle = (msg_handle_t)pHandle;
45 /* Connect to Socket */
46 pHandle->openHandle();
47 } catch (MsgException& e) {
48 MSG_FATAL("%s", e.what());
50 /* Destroy MsgHandle */
54 if (e.errorCode() == MsgException::SERVER_READY_ERROR)
55 return MSG_ERR_SERVER_NOT_READY;
56 else if (e.errorCode() == MsgException::SECURITY_ERROR)
57 return MSG_ERR_PERMISSION_DENIED;
59 return MSG_ERR_COMMUNICATION_ERROR;
66 EXPORT_API int msg_close_msg_handle(msg_handle_t *handle)
68 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
70 if (handle == NULL || *handle == NULL) {
71 MSG_FATAL("Input Parameter is NULL");
72 return MSG_ERR_INVALID_PARAMETER;
75 MsgHandle* pHandle = (MsgHandle*)(*handle);
78 /* Disconnect from Socket */
79 pHandle->closeHandle(pHandle);
80 } catch (MsgException& e) {
81 MSG_FATAL("%s", e.what());
82 return MSG_ERR_COMMUNICATION_ERROR;
85 /* Destroy MsgHandle */