summaryrefslogtreecommitdiff
path: root/plugin/sms_cdma_plugin/include/SmsCdmaPluginCodec.h
blob: 3396bffe7c21b885667e4f3aa71553ce3fc1e0c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
 * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/

#ifndef SMS_CDMA_PLUGIN_CODEC_H
#define SMS_CDMA_PLUGIN_CODEC_H


/*==================================================================================================
                                         INCLUDE FILES
==================================================================================================*/
#include "SmsCdmaPluginTypes.h"


/*==================================================================================================
                                     CLASS DEFINITIONS
==================================================================================================*/
class SmsPluginMsgCodec
{
public:

	static SmsPluginMsgCodec* instance();

	static bool checkInvalidPDU(const unsigned char *p_pkg_str, const int p_pkg_len);

	static int encodeMsg(const sms_trans_msg_s *pMsg, unsigned char *p_pkg_str);
	static int decodeMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_trans_msg_s *p_msg);

private:
	SmsPluginMsgCodec();
	~SmsPluginMsgCodec();

	static SmsPluginMsgCodec* pInstance;

	static int encodeP2PMsg(const sms_trans_p2p_msg_s *p_msg, unsigned char *p_pkg_str);
	static int encodeAckMsg(const sms_trans_ack_msg_s *p_msg, unsigned char *p_pkg_str);
	static int encodeCBMsg(const sms_trans_broadcast_msg_s *p_msg, unsigned char *p_pkg_str);

	static int encodeTelesvcMsg(const sms_telesvc_msg_s *p_msg, unsigned char *p_pkg_str);

	static int encodeTelesvcCancelMsg(const sms_telesvc_cancel_s *p_msg, unsigned char *p_pkg_str);
	static int encodeTelesvcSubmitMsg(const sms_telesvc_submit_s *p_msg, unsigned char *p_pkg_str);
	static int encodeTelesvcUserAckMsg(const sms_telesvc_user_ack_s *p_msg, unsigned char *p_pkg_str);
	static int encodeTelesvcReadAckMsg(const sms_telesvc_read_ack_s *p_msg, unsigned char *p_pkg_str);
	static int encodeTelesvcDeliverReportMsg(const sms_telesvc_report_s *p_msg, unsigned char *p_pkg_str);

	static int decodeP2PMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_trans_p2p_msg_s *p_p2p);
	static int decodeCBMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_trans_broadcast_msg_s *p_cb);
	static int decodeAckMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_trans_ack_msg_s *p_ack);

	static void decodeP2PTelesvcMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_telesvc_msg_s *p_telesvc);
	static void decodeP2PDeliveryAckMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_telesvc_deliver_ack_s *p_del_ack);
	static void decodeP2PSubmitReportMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_telesvc_report_s *p_sub_report);
	static void decodeP2PUserAckMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_telesvc_user_ack_s *p_user_ack);
	static void decodeP2PReadAckMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_telesvc_read_ack_s *p_read_ack);
	static void decodeP2PDeliverMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_telesvc_deliver_s *p_del);
	static void decodeP2PSubmitMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_telesvc_submit_s *p_sub);
	static void decodeCBBearerData(const unsigned char *p_pkg_str, int p_pkg_len, sms_telesvc_msg_s *p_telesvc, bool isCMAS);

	static int encodeUserData(const unsigned char* src, unsigned char *dest, int src_size);
	static void decodeUserData(unsigned char *p_pkg_str, int p_pkg_len, sms_telesvc_userdata_s *p_user);
	static void decodeCMASData(unsigned char *p_pkg_str, int p_pkg_len, sms_telesvc_cmasdata_s *p_cmas);

	static int decodeTeleId(const unsigned char *p_pkg_str, int p_pkg_len, sms_trans_telesvc_id_t *tele_id);
	static int decodeSvcCtg(const unsigned char *p_pkg_str, int p_pkg_len, sms_trans_svc_ctg_t *svc_ctg);
	static int decodeAddress(const unsigned char *p_pkg_str, int p_pkg_len, sms_trans_addr_s *addr);
	static int decodeSubAddress(const unsigned char *p_pkg_str, int p_pkg_len, sms_trans_sub_addr_s *sub_addr);

	static int decodeMsgId(const unsigned char *p_pkg_str, int pkg_len, sms_trans_msg_id_s *p_msg_id);
	static void decodeCallBackNum(const unsigned char *p_pkg_str, int pkg_len, sms_telesvc_addr_s *p_callback);
	static int decodeAbsTime(const unsigned char *p_pkg_str, sms_time_abs_s *p_time_abs);
	static sms_message_type_t findMsgType(const unsigned char *p_pkg_str, int pkg_len);
};

#endif //SMS_CDMA_PLUGIN_CODEC_H