Fix issue : fail to make thumbnail
[platform/core/messaging/msg-service.git] / plugin / sms_cdma_plugin / include / SmsCdmaPluginEventHandler.h
1 /*
2  * Copyright (c) 2015 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_CDMA_PLUGIN_EVENT_HANDLER_H
18 #define SMS_CDMA_PLUGIN_EVENT_HANDLER_H
19
20
21 /*==================================================================================================
22                                          INCLUDE FILES
23 ==================================================================================================*/
24 #include <string>
25 #include <map>
26 #include <vector>
27 #include <list>
28
29 using namespace std;
30
31 #include "MsgMutex.h"
32 #include "MsgTextConvert.h"
33 #include "MsgPluginInterface.h"
34 #include "SmsCdmaPluginTypes.h"
35
36
37 /*==================================================================================================
38                                      VARIABLES AND DEFINES
39 ==================================================================================================*/
40 struct wap_data_s {
41         int     length;
42         char data[SMS_MAX_USER_DATA_LEN+1];
43 };
44
45 typedef map<unsigned char, wap_data_s> wapDataMap;
46
47 typedef struct _sms_wap_msg_s {
48         unsigned short  msgId;
49         unsigned char           totalSeg;
50         unsigned char           segNum;
51 } sms_wap_msg_s;
52
53 typedef struct _sms_wap_info_s {
54         unsigned short  msgId;
55         unsigned char           totalSeg;
56         unsigned char           segNum;
57
58         unsigned int            totalSize;
59         wapDataMap                      data;
60 } sms_wap_info_s;
61
62
63 /*==================================================================================================
64                                      CLASS DEFINITIONS
65 ==================================================================================================*/
66 class SmsPluginEventHandler
67 {
68 public:
69         static SmsPluginEventHandler* instance();
70
71         void registerListener(MSG_PLUGIN_LISTENER_S *pListener);
72         void handleSentStatus(msg_network_status_t NetStatus);
73         void handleMsgIncoming(sms_trans_p2p_msg_s *p_p2p_msg);
74         void handleCbMsgIncoming(sms_trans_broadcast_msg_s *p_cb_msg);
75         void handleWapMsgIncoming(sms_trans_p2p_msg_s *p_p2p_msg);
76
77         void handleResendMessage(void);
78
79         msg_error_t callbackMsgIncoming(MSG_MESSAGE_INFO_S *pMsgInfo);
80         msg_error_t callbackStorageChange(msg_storage_change_type_t storageChangeType, MSG_MESSAGE_INFO_S *pMsgInfo);
81
82         void convertTpduToMsginfo(sms_trans_p2p_msg_s *p_p2p_msg, MSG_MESSAGE_INFO_S *p_msg_info);
83         void convertTpduToMsginfo(sms_trans_broadcast_msg_s *p_cb_msg, MSG_MESSAGE_INFO_S *p_msg_info);
84
85         void SetSentInfo(sms_sent_info_s *pSentInfo);
86
87         void setDeviceStatus();
88         bool getDeviceStatus();
89         void setNeedInitConfig(bool bNeeded);
90         bool getNeedInitConfig();
91
92         void handleSyncMLMsgIncoming(msg_syncml_message_type_t msgType, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen);
93         void handleLBSMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen);
94         void handlePushMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen, char *app_id, char *content_type);
95
96 private:
97         SmsPluginEventHandler();
98         virtual ~SmsPluginEventHandler();
99
100         static SmsPluginEventHandler* pInstance;
101
102         MSG_PLUGIN_LISTENER_S listener;
103
104         sms_sent_info_s sentInfo;
105
106         bool devStatus;
107         bool bNeedInitConfig;
108
109         MsgMutex mx;
110         MsgCndVar cv;
111         vector<sms_wap_info_s> wapList;
112
113         void convertDeliverMsgToMsgInfo(sms_telesvc_deliver_s *p_deliver, MSG_MESSAGE_INFO_S *p_msg_info);
114         void convertCMASMsgToMsgInfo(sms_telesvc_deliver_s *p_deliver, MSG_MESSAGE_INFO_S *p_msg_info);
115         void convertAckMsgToMsgInfo(sms_telesvc_deliver_ack_s *p_deliver, MSG_MESSAGE_INFO_S *p_msg_info);
116         void convertReportMsgToMsgInfo(sms_telesvc_report_s *p_deliver, MSG_MESSAGE_INFO_S *p_msg_info);
117
118         msg_encode_type_t getEncodeType(sms_encoding_type_t encode_type);
119
120         unsigned short checkWapMsg(sms_wap_msg_s *pMsg, sms_telesvc_userdata_s *pUserdata);
121         int MakeWapUserData(unsigned short msgId, char **ppTotalData);
122
123         bool checkCbOpt(sms_trans_svc_ctg_t svc_ctg);
124 };
125
126 #endif /* SMS_CDMA_PLUGIN_EVENT_HANDLER_H */