apply tizen c coding rule
[platform/core/messaging/msg-service.git] / plugin / sms_plugin / include / SmsPluginCbMsgHandler.h
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
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 #ifndef SMS_PLUGIN_CBMSG_HANDLER_H
18 #define SMS_PLUGIN_CBMSG_HANDLER_H
19
20
21 /*==================================================================================================
22                                                                                         INCLUDE FILES
23 ==================================================================================================*/
24 #include <map>
25 #include <vector>
26
27 using namespace std;
28
29 #include "MsgTextConvert.h"
30 #include "SmsPluginTypes.h"
31
32 extern "C"
33 {
34         #include <tapi_common.h>
35         #include <TelSms.h>
36         #include <ITapiNetText.h>
37 }
38
39
40 /*==================================================================================================
41                                                                                         VARIABLES
42 ==================================================================================================*/
43 typedef map<unsigned char, SMS_CBMSG_PAGE_S> cbPageMap;
44
45
46 typedef struct _CB_PAGE_INFO_S {
47         unsigned char           geoScope;
48         unsigned char           updateNum;
49         unsigned short          msgCode;
50         unsigned short          msgId;
51         unsigned char           totalPages;
52
53         unsigned char           pageCnt;
54         unsigned int            totalSize;
55         cbPageMap               data;
56 } CB_PAGE_INFO_S;
57
58
59 /*==================================================================================================
60                                                                                         CLASS DEFINITIONS
61 ==================================================================================================*/
62 class SmsPluginCbMsgHandler
63 {
64 public:
65         static SmsPluginCbMsgHandler* instance();
66
67         void handleCbMsg(TapiHandle *handle, TelSmsCbMsg_t *pCbMsg);
68         void handleEtwsMsg(TapiHandle *handle, TelSmsEtwsMsg_t *pEtwsMsg);
69
70 private:
71         SmsPluginCbMsgHandler();
72         virtual ~SmsPluginCbMsgHandler();
73
74         static SmsPluginCbMsgHandler* pInstance;
75
76         void Decode2gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_S *pCbPage);
77         void Decode3gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_S *pCbPage);
78         void DecodeEtwsMsg(TelSmsEtwsMsg_t *pEtwsMsg, SMS_ETWS_PRIMARY_S *pEtwsPn);
79         unsigned short encodeCbSerialNum(SMS_CBMSG_SERIAL_NUM_S snFields);
80         int CMAS_class(unsigned short message_id);
81
82         bool checkCbOpt(SMS_CBMSG_PAGE_S *CbPage, bool *pJavaMsg, msg_sim_slot_id_t simIndex);
83         unsigned char checkCbPage(SMS_CBMSG_PAGE_S *CbPage);
84         void MakeCbMsg(SMS_CBMSG_PAGE_S *CbPage, SMS_CBMSG_S *pCbMsg);
85         void convertCbMsgToMsginfo(SMS_CBMSG_S *pCbMsg, MSG_MESSAGE_INFO_S *pMsgInfo, msg_sim_slot_id_t simIndex);
86         void convertEtwsMsgToMsginfo(SMS_CBMSG_PAGE_S *EtwsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, msg_sim_slot_id_t simIndex);
87         int convertTextToUtf8(unsigned char* outBuf, int outBufSize, SMS_CBMSG_S* pCbMsg);
88         void addToPageList(SMS_CBMSG_PAGE_S *CbPage);
89         void removeFromPageList(SMS_CBMSG_PAGE_S *CbPage);
90
91         void decodeCbMsgDCS(unsigned char dcsData, const unsigned char *pMsgData, SMS_CBMSG_DCS_S* pDcs);
92         void convertLangType(SMS_CBMSG_LANG_TYPE_T InType , MSG_CB_LANGUAGE_TYPE_T *pOutType);
93         unsigned long getRecvTime();
94         void getDisplayName(unsigned short      MsgId, char *pDisplayName, msg_sim_slot_id_t simIndex);
95
96         vector<CB_PAGE_INFO_S> pageList;
97 };
98
99 #endif /* SMS_PLUGIN_CBMSG_HANDLER_H */
100