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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
|
/*
* Copyright 2012-2013 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://floralicense.org/license/
*
* 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.
*/
#include <stdio.h>
#include <string.h>
#include "MsgDebug.h"
#include "MsgUtilFile.h"
#include "MsgUtilStorage.h"
#include "MsgException.h"
#include "MsgGconfWrapper.h"
#include "MsgPluginManager.h"
#include "MsgStorageHandler.h"
#include "MsgSubmitHandler.h"
extern MsgDbHandler dbHandle;
/*==================================================================================================
FUNCTION IMPLEMENTATION
==================================================================================================*/
msg_error_t MsgSubmitReq(MSG_REQUEST_INFO_S *pReqInfo, bool bScheduled)
{
msg_error_t err = MSG_SUCCESS;
static int reqId = 1;
pReqInfo->reqId = reqId;
reqId++;
MSG_DEBUG("==== Msg ID = [%d] ====", pReqInfo->msgInfo.msgId);
MSG_DEBUG("==== Folder ID = [%d] ====", pReqInfo->msgInfo.folderId);
MSG_DEBUG("==== Main Type = [%d] ====", pReqInfo->msgInfo.msgType.mainType);
MSG_DEBUG("==== Sub Type = [%d] ====", pReqInfo->msgInfo.msgType.subType);
MSG_DEBUG("==== Class Type = [%d] ====", pReqInfo->msgInfo.msgType.classType);
MSG_DEBUG("==== Message Data = [%s] ====", pReqInfo->msgInfo.msgData);
MSG_DEBUG("==== Message Text = [%s] ====", pReqInfo->msgInfo.msgText);
MSG_DEBUG("==== bSetting = [%d] ====", pReqInfo->sendOptInfo.bSetting);
if (pReqInfo->msgInfo.msgType.mainType == MSG_SMS_TYPE)
{
MSG_DEBUG("==== deliver = [%d] ====", pReqInfo->sendOptInfo.bDeliverReq);
MSG_DEBUG("==== keepcopy = [%d] ====", pReqInfo->sendOptInfo.bKeepCopy);
MSG_DEBUG("==== bReplyPath = [%d] ====", pReqInfo->sendOptInfo.option.smsSendOptInfo.bReplyPath);
err = MsgSubmitReqSMS(pReqInfo);
}
else if (pReqInfo->msgInfo.msgType.mainType == MSG_MMS_TYPE)
{
MSG_DEBUG("==== deliver = [%d] ====", pReqInfo->sendOptInfo.bDeliverReq);
MSG_DEBUG("==== keepcopy = [%d] ====", pReqInfo->sendOptInfo.bKeepCopy);
MSG_DEBUG("==== bReadReq = [%d] ====", pReqInfo->sendOptInfo.option.mmsSendOptInfo.bReadReq);
MSG_DEBUG("==== priority = [%d] ====", pReqInfo->sendOptInfo.option.mmsSendOptInfo.priority);
MSG_DEBUG("==== expiryTime = [%d] ====", pReqInfo->sendOptInfo.option.mmsSendOptInfo.expiryTime.time);
err = MsgSubmitReqMMS(pReqInfo);
}
return err;
}
msg_error_t MsgSubmitReqSMS(MSG_REQUEST_INFO_S *pReqInfo)
{
msg_error_t err = MSG_SUCCESS;
// submit request based on msgType;
MSG_MAIN_TYPE_T mainType = pReqInfo->msgInfo.msgType.mainType;
MsgPlugin* plg = MsgPluginManager::instance()->getPlugin(mainType);
if (plg == NULL) {
MSG_DEBUG("No Plugin for %d type", mainType);
return MSG_ERR_UNKNOWN;
}
// If MSG ID > 0 -> MSG in DRAFT
// Move Folder to OUTBOX
if (pReqInfo->msgInfo.msgPort.valid == false) {
pReqInfo->msgInfo.folderId = MSG_OUTBOX_ID;
if (pReqInfo->msgInfo.msgId > 0 && (pReqInfo->msgInfo.folderId == MSG_DRAFT_ID || pReqInfo->msgInfo.folderId == MSG_OUTBOX_ID))
err = MsgStoUpdateMessage(&(pReqInfo->msgInfo), &(pReqInfo->sendOptInfo));
}
err = plg->submitReq(pReqInfo);
return err;
}
msg_error_t MsgSubmitReqMMS(MSG_REQUEST_INFO_S *pReqInfo)
{
msg_error_t err = MSG_SUCCESS;
MSG_RECIPIENTS_LIST_S pRecipientList;
MSG_MAIN_TYPE_T msgMainType = pReqInfo->msgInfo.msgType.mainType;
MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(msgMainType);
if(!plg)
{
MsgStoUpdateNetworkStatus(&dbHandle, &(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL);
MSG_DEBUG("No Plugin for %d type", msgMainType);
return MSG_ERR_INVALID_PLUGIN_HANDLE;
}
// If MSG ID > 0 -> MSG in DRAFT
// Move Folder to OUTBOX
/* reject_msg_support */
MSG_DEBUG("Not scheduled MMS, pReqInfo->msgInfo.msgType.subType [%d]", pReqInfo->msgInfo.msgType.subType);
if(pReqInfo->msgInfo.msgType.subType == MSG_SENDREQ_JAVA_MMS)
{
char fileName[MAX_COMMON_INFO_SIZE+1] = {0};
// copy whole of MMS PDU filepath to msgData
strncpy(fileName, pReqInfo->msgInfo.msgData, MAX_COMMON_INFO_SIZE);
memset(pReqInfo->msgInfo.msgData, 0x00, MAX_MSG_DATA_LEN+1);
snprintf(pReqInfo->msgInfo.msgData, MAX_MSG_DATA_LEN+1, "%s/%s", MSG_IPC_DATA_PATH, fileName);
MSG_DEBUG("JAVA MMS PDU filepath:%s", pReqInfo->msgInfo.msgData);
// submit request
err = plg->submitReq(pReqInfo);
if(err != MSG_SUCCESS)
{
MSG_DEBUG("Update Network Status : [%d]", err);
MsgStoUpdateNetworkStatus(&dbHandle, &(pReqInfo->msgInfo),MSG_NETWORK_SEND_FAIL);
}
return err;
}
else if((pReqInfo->msgInfo.msgType.subType == MSG_SENDREQ_MMS) || (pReqInfo->msgInfo.msgType.subType == MSG_FORWARD_MMS))
{
// update address list in the ase of existing message
if(pReqInfo->msgInfo.msgId > 0)
{
err = MsgStoGetOrgAddressList(&(pReqInfo->msgInfo));
if(err != MSG_SUCCESS)
MSG_DEBUG("[WARNING]MsgStoGetOrgAddressList returned not a MSG_SUCCESS");
}
if(pReqInfo->msgInfo.msgId > 0 && (pReqInfo->msgInfo.folderId == MSG_DRAFT_ID || pReqInfo->msgInfo.folderId == MSG_OUTBOX_ID)) {
MSG_ADDRESS_INFO_S addrInfo = {0,};
int addrIdx = 0;
err = MsgStoGetAddrInfo(pReqInfo->msgInfo.msgId, &addrInfo);
if (err == MSG_SUCCESS) {
for (int i = 0; i < pReqInfo->msgInfo.nAddressCnt; i++) {
//if (pReqInfo->msgInfo.addressList[i].threadId == addrInfo.threadId) {
if (!strcmp(pReqInfo->msgInfo.addressList[i].addressVal, addrInfo.addressVal)) {
addrIdx = i;
MSG_DEBUG("addrIdx = %d, address = [%s]", addrIdx, pReqInfo->msgInfo.addressList[i].addressVal);
break;
}
}
} else {
MSG_DEBUG("[Error]MsgStoGetAddrInfo is failed");
}
pReqInfo->msgInfo.folderId = MSG_OUTBOX_ID;
err = MsgStoUpdateMessage(&(pReqInfo->msgInfo), &(pReqInfo->sendOptInfo));
MsgStoUpdateNetworkStatus(&dbHandle, &(pReqInfo->msgInfo), pReqInfo->msgInfo.networkStatus);
} else {
//new message case
MSG_DEBUG("New Message");
pReqInfo->msgInfo.folderId = MSG_OUTBOX_ID;
err = MsgStoAddMessage(&(pReqInfo->msgInfo), &(pReqInfo->sendOptInfo));
//pReqInfo->msgInfo.msgId = 0;
}
}
else if(pReqInfo->msgInfo.msgType.subType == MSG_READREPLY_MMS)
{
err = MsgStoCheckReadReportStatus(pReqInfo->msgInfo.msgId);
if(err != MSG_SUCCESS)
return err;
err = MsgStoGetRecipientList(pReqInfo->msgInfo.msgId, &pRecipientList);
if(err != MSG_SUCCESS)
return MSG_ERR_PLUGIN_STORAGE;
pReqInfo->msgInfo.nAddressCnt = pRecipientList.recipientCnt;
for(int i = 0; i < pRecipientList.recipientCnt; i++)
{
pReqInfo->msgInfo.addressList[i].addressType = pRecipientList.recipientAddr[i].addressType;
pReqInfo->msgInfo.addressList[i].recipientType = MSG_RECIPIENTS_TYPE_TO;
pReqInfo->msgInfo.addressList[i].contactId = pRecipientList.recipientAddr[i].contactId;
strncpy(pReqInfo->msgInfo.addressList[i].addressVal, pRecipientList.recipientAddr[i].addressVal, MAX_ADDRESS_VAL_LEN);
}
char subject[MAX_SUBJECT_LEN+1];
err = MsgStoGetSubject(pReqInfo->msgInfo.msgId, subject);
if(err != MSG_SUCCESS)
MSG_DEBUG("Getting subject returned not a MSG_SUCCESS");
strncpy(pReqInfo->msgInfo.subject, subject, MAX_SUBJECT_LEN);
err = plg->composeReadReport(&(pReqInfo->msgInfo));
}
else if(pReqInfo->msgInfo.msgType.subType == MSG_RETRIEVE_MMS)
{
MsgStoUpdateNetworkStatus(&dbHandle, &(pReqInfo->msgInfo), pReqInfo->msgInfo.networkStatus);
}
/* reject_msg_support */
if(err != MSG_SUCCESS)
{
MSG_DEBUG("Fail to Add/Update Message : MsgStoMoveMessageToFolder()/MsgStoAddMessage()");
return err;
}
switch(pReqInfo->msgInfo.msgType.subType)
{
case MSG_SENDREQ_MMS:
case MSG_FORWARD_MMS:
MsgDeleteFile(pReqInfo->msgInfo.msgData);
memset(pReqInfo->msgInfo.msgData, 0x00, MAX_MSG_DATA_LEN+1);
snprintf(pReqInfo->msgInfo.msgData, MAX_MSG_DATA_LEN+1, "%s/%d.mms", MSG_DATA_PATH, pReqInfo->msgInfo.msgId);
break;
case MSG_READREPLY_MMS:
case MSG_READRECIND_MMS:
break;
default:
break;
}
// update content location from db
if(pReqInfo->msgInfo.msgType.subType == MSG_RETRIEVE_MMS)
err = MsgStoGetContentLocation(&(pReqInfo->msgInfo));
/* reject_msg_support */
else if(pReqInfo->msgInfo.msgType.subType == MSG_NOTIFYRESPIND_MMS)
err = plg->updateRejectStatus(&(pReqInfo->msgInfo));
/* reject_msg_support */
// Check SIM is present or not
MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(MSG_SIM_CHANGED);
if(simStatus == MSG_SIM_STATUS_NOT_FOUND)
{
MSG_DEBUG("SIM is not present...");
MsgStoUpdateNetworkStatus(&dbHandle, &(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL);
return MSG_ERR_NO_SIM;
}
if(err == MSG_SUCCESS)
err = plg->submitReq(pReqInfo);
if(err == MSG_SUCCESS && ( pReqInfo->msgInfo.msgType.subType == MSG_READREPLY_MMS || pReqInfo->msgInfo.msgType.subType == MSG_READRECIND_MMS ))
MsgStoSetReadReportSendStatus(pReqInfo->msgInfo.msgId, MMS_RECEIVE_READ_REPORT_SENT);
if (err != MSG_SUCCESS)
{
if(pReqInfo->msgInfo.msgType.subType == MSG_RETRIEVE_MMS )
MsgStoUpdateNetworkStatus(&dbHandle, &(pReqInfo->msgInfo), MSG_NETWORK_RETRIEVE_FAIL);
else
MsgStoUpdateNetworkStatus(&dbHandle, &(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL);
}
return err;
}
msg_error_t MsgCancelReq(msg_request_id_t reqId)
{
msg_error_t err = MSG_SUCCESS;
return err;
}
msg_error_t MsgUpdateSentMsg(msg_message_id_t MsgId, msg_network_status_t Status)
{
msg_error_t err = MSG_SUCCESS;
bool bKeepCopy = true;
#ifdef MSG_MMS_KEEPCOPY
MSG_SENDINGOPT_INFO_S sendOpt = {};
if (msgType.mainType == MSG_MMS_TYPE)
{
if (MsgStoGetMmsSendOpt(MsgId, &sendOpt) == MSG_SUCCESS)
{
bKeepCopy = sendOpt.bKeepCopy;
}
else
{
ret = MsgSettingGetBool(MSG_KEEP_COPY, &bKeepCopy);
}
}
#endif
// Move Msg to SENTBOX
if (Status == MSG_NETWORK_SEND_SUCCESS)
{
MSG_DEBUG(" In Status == MSG_NETWORK_SEND_SUCCESS and bKeepCopy is [%d]", bKeepCopy);
if (bKeepCopy == true)
err = MsgStoMoveMessageToFolder(MsgId, MSG_SENTBOX_ID);
else
err = MsgStoDeleteMessage(MsgId, false);
}
return err;
}
void MsgCopyReqInfo(MSG_REQUEST_INFO_S *pSrc, int addrIdx, MSG_REQUEST_INFO_S *pDest)
{
MSG_BEGIN();
memset(pDest, 0x00, sizeof(MSG_REQUEST_INFO_S));
// Copy Request ID
pDest->reqId = pSrc->reqId;
// Copy Msg Info
pDest->msgInfo.msgId = pSrc->msgInfo.msgId;
pDest->msgInfo.threadId = pSrc->msgInfo.threadId;
pDest->msgInfo.folderId = pSrc->msgInfo.folderId;
pDest->msgInfo.msgType.mainType = pSrc->msgInfo.msgType.mainType;
pDest->msgInfo.msgType.subType = pSrc->msgInfo.msgType.subType;
pDest->msgInfo.msgType.classType = pSrc->msgInfo.msgType.classType;
pDest->msgInfo.storageId = pSrc->msgInfo.storageId;
pDest->msgInfo.nAddressCnt = 1;
pDest->msgInfo.addressList[0].addressType = pSrc->msgInfo.addressList[addrIdx].addressType;
pDest->msgInfo.addressList[0].recipientType = pSrc->msgInfo.addressList[addrIdx].recipientType;
pDest->msgInfo.addressList[0].contactId = pSrc->msgInfo.addressList[addrIdx].contactId;
strncpy(pDest->msgInfo.addressList[0].addressVal, pSrc->msgInfo.addressList[addrIdx].addressVal, MAX_ADDRESS_VAL_LEN);
strncpy(pDest->msgInfo.addressList[0].displayName, pSrc->msgInfo.addressList[addrIdx].displayName, MAX_DISPLAY_NAME_LEN);
strncpy(pDest->msgInfo.replyAddress, pSrc->msgInfo.replyAddress, MAX_PHONE_NUMBER_LEN);
strncpy(pDest->msgInfo.subject, pSrc->msgInfo.subject, MAX_SUBJECT_LEN);
pDest->msgInfo.displayTime = pSrc->msgInfo.displayTime;
pDest->msgInfo.networkStatus = pSrc->msgInfo.networkStatus;
pDest->msgInfo.encodeType = pSrc->msgInfo.encodeType;
pDest->msgInfo.bRead = pSrc->msgInfo.bRead;
pDest->msgInfo.bProtected = pSrc->msgInfo.bProtected;
pDest->msgInfo.priority = pSrc->msgInfo.priority;
pDest->msgInfo.direction = pSrc->msgInfo.direction;
pDest->msgInfo.msgPort.valid = pSrc->msgInfo.msgPort.valid;
if (pDest->msgInfo.msgPort.valid == true)
{
pDest->msgInfo.msgPort.dstPort = pSrc->msgInfo.msgPort.dstPort;
pDest->msgInfo.msgPort.srcPort = pSrc->msgInfo.msgPort.srcPort;
}
pDest->msgInfo.bTextSms = pSrc->msgInfo.bTextSms;
pDest->msgInfo.dataSize = pSrc->msgInfo.dataSize;
strncpy(pDest->msgInfo.msgData, pSrc->msgInfo.msgData, MAX_MSG_DATA_LEN);
if (pDest->msgInfo.bTextSms == true)
{
memcpy(pDest->msgInfo.msgText, pSrc->msgInfo.msgText, pDest->msgInfo.dataSize);
pDest->msgInfo.msgText[pDest->msgInfo.dataSize] = '\0';
}
// Set Sending Info
pDest->sendOptInfo.bSetting = pSrc->sendOptInfo.bSetting;
if (pDest->sendOptInfo.bSetting == true)
{
pDest->sendOptInfo.bDeliverReq = pSrc->sendOptInfo.bDeliverReq;
pDest->sendOptInfo.bKeepCopy = pSrc->sendOptInfo.bKeepCopy;
if (pDest->msgInfo.msgType.mainType == MSG_SMS_TYPE)
{
pDest->sendOptInfo.option.smsSendOptInfo.bReplyPath = pSrc->sendOptInfo.option.smsSendOptInfo.bReplyPath;
}
else if (pDest->msgInfo.msgType.mainType == MSG_MMS_TYPE)
{
pDest->sendOptInfo.option.mmsSendOptInfo.priority = pSrc->sendOptInfo.option.mmsSendOptInfo.priority;
pDest->sendOptInfo.option.mmsSendOptInfo.bReadReq = pSrc->sendOptInfo.option.mmsSendOptInfo.bReadReq;
pDest->sendOptInfo.option.mmsSendOptInfo.expiryTime.type = pSrc->sendOptInfo.option.mmsSendOptInfo.expiryTime.type;
pDest->sendOptInfo.option.mmsSendOptInfo.expiryTime.time = pSrc->sendOptInfo.option.mmsSendOptInfo.expiryTime.time;
pDest->sendOptInfo.option.mmsSendOptInfo.bUseDeliveryCustomTime = pSrc->sendOptInfo.option.mmsSendOptInfo.bUseDeliveryCustomTime;
pDest->sendOptInfo.option.mmsSendOptInfo.deliveryTime.type = pSrc->sendOptInfo.option.mmsSendOptInfo.deliveryTime.type;
pDest->sendOptInfo.option.mmsSendOptInfo.deliveryTime.time = pSrc->sendOptInfo.option.mmsSendOptInfo.deliveryTime.time;
}
}
MSG_END();
}
|