3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
5 * This file is part of msg-service.
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 * Sangkoo Kim <sangkoo.kim@samsung.com>
9 * Seunghwan Lee <sh.cat.lee@samsung.com>
10 * SoonMin Jung <sm0415.jung@samsung.com>
11 * Jae-Young Lee <jy4710.lee@samsung.com>
12 * KeeBum Kim <keebum.kim@samsung.com>
14 * PROPRIETARY/CONFIDENTIAL
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
31 #ifndef MMS_PLUGIN_MESSAGE_H
32 #define MMS_PLUGIN_MESSAGE_H
35 /*==================================================================================================
37 ==================================================================================================*/
39 #include "MsgInternalTypes.h"
40 #include "MsgMmsTypes.h"
41 #include "MsgSettingTypes.h"
42 #include "MmsPluginMIME.h"
43 #include "MsgMmsTypes.h"
45 /*==================================================================================================
47 ==================================================================================================*/
48 #define MMS_CONTENT_ID_LEN 100
49 #define MMS_LOCALE_RESP_TEXT_LEN 90
50 #define MMS_TEXT_LEN 2000
51 #define MMS_READ_REPORT_STRING_READ "Read:"
52 #define MMS_READ_REPORT_STRING_DELETED "Deleted:"
54 #define MSG_ATTACH_MAX 20
55 #define MSG_LINE_LEN 1024
56 #define MSG_SUBJ_LEN 40
57 #define MSG_DATE_LEN 50
58 #define MSG_BOUNDARY_LEN 70
59 #define MSG_LOCALE_NAME_LEN 150
60 #define MSG_LOCALE_SUBJ_LEN (3 * MSG_SUBJ_LEN)
61 #define MSG_ADDR_LEN MAX_ADDRESS_VAL_LEN
62 #define MSG_LOCALE_ADDR_LEN (3 * MAX_ADDRESS_VAL_LEN)
63 #define MSG_LOCALE_FILENAME_LEN_MAX (3 * 255)
64 #define MSG_LOCALE_SIGN_LEN (3 * MAX_SIGN_VAL_LEN)
65 #define MSG_MAILBOX_NAME_LEN 10
67 #define MsgContentType MimeType
68 #define MsgRecipientType MSG_RECIPIENT_TYPE_T
69 #define MMS_VERSION 0x92
70 #define MSG_STR_ADDR_DELIMETER ";"
71 #define MSG_CH_ADDR_DELIMETER ';'
72 #ifdef __SUPPORT_DRM__
73 #define MSG_DRM_MAX_CMD (2 * 1024)
76 #define MSG_MMS_DECODE_BUFFER_MAX (2 * 1024)
77 #define MSG_MMS_ENCODE_BUFFER_MAX (2 * 1024)
79 /*==================================================================================================
81 ==================================================================================================*/
82 typedef unsigned int UINT;
83 typedef unsigned long int UINT32;
84 typedef unsigned char UINT8;
85 typedef unsigned short int UINT16;
86 typedef unsigned long ULONG;
87 typedef unsigned char UCHAR;
88 typedef unsigned short MCHAR;
89 typedef unsigned short USHORT;
93 typedef struct _MsgAddress MsgAddress;
94 typedef struct _MsgBody MsgBody;
95 typedef struct _MsgMultipart MsgMultipart;
96 typedef struct _MsgMessage MsgMessage;
98 typedef struct _MsgHeaderAddress MsgHeaderAddress;
100 /*==================================================================================================
102 ==================================================================================================*/
105 MMS_DATATYPE_NONE = -1,
106 MMS_DATATYPE_READ = 0,
107 MMS_DATATYPE_SENT = 1,
108 MMS_DATATYPE_NOTIFY = 2,
109 MMS_DATATYPE_UNSENT = 3,
110 MMS_DATATYPE_DRAFT = 4,
111 MMS_DATATYPE_SENDING = 6,
112 MMS_DATATYPE_RETRIEVING = 7,
113 MMS_DATATYPE_UNRETV = 8,
114 MMS_DATATYPE_TEMPLATE = 9,
115 MMS_DATATYPE_DRM_RO_WAITING = 10 // DRM RO WAITING
120 MMS_MSGTYPE_ERROR = -1, // error return in Get method
121 MMS_MSGTYPE_SEND_REQ = 0, // default
122 MMS_MSGTYPE_SEND_CONF = 1,
123 MMS_MSGTYPE_NOTIFICATION_IND = 2,
124 MMS_MSGTYPE_NOTIFYRESP_IND = 3,
125 MMS_MSGTYPE_RETRIEVE_CONF = 4,
126 MMS_MSGTYPE_ACKNOWLEDGE_IND = 5,
127 MMS_MSGTYPE_DELIVERY_IND = 6,
128 MMS_MSGTYPE_READREC_IND = 7,
129 MMS_MSGTYPE_READORG_IND = 8,
130 MMS_MSGTYPE_FORWARD_REQ = 9,
131 MMS_MSGTYPE_FORWARD_CONF = 10,
132 MMS_MSGTYPE_READ_REPLY = 11, // for internal use
138 MMS_PRIORITY_ERROR = -1, // error return in Get method
139 MMS_PRIORITY_LOW = 0, // default
140 MMS_PRIORITY_NORMAL = 1,
141 MMS_PRIORITY_HIGH = 2
146 MMS_SENDER_VISIBLE_ERROR = -1, // error return in Get method
153 MMS_REPORT_ERROR = -1, // error return in Get method
160 MMS_REPORTALLOWED_ERROR = -1, // error return in Get method
161 MMS_REPORTALLOWED_YES = 0,
162 MMS_REPORTALLOWED_NO = 1
167 MMS_RECEIVE_READ_REPORT_ALLOWED,
168 MMS_RECEIVE_READ_REPORT_PROMPT,
169 MMS_RECEIVE_READ_REPORT_NOT_ALLOWED,
170 } MmsRecvReadReportType ;
174 MMS_MSGSTATUS_NONE = -1, // backward compatibility
175 MMS_MSGSTATUS_ERROR = -1, // error return in Get method
176 MMS_MSGSTATUS_EXPIRED = 0,
177 MMS_MSGSTATUS_RETRIEVED = 1,
178 MMS_MSGSTATUS_REJECTED = 2,
179 MMS_MSGSTATUS_DEFERRED = 3,
180 MMS_MSGSTATUS_UNRECOGNISED = 4, // This value SHALL not be used in the M-Delivery.ind PDU.
181 MMS_MSGSTATUS_INDETERMINATE = 5,
182 MMS_MSGSTATUS_FORWARDED = 6,
183 MMS_MSGSTATUS_UNREACHABLE = 7
188 MMS_READSTATUS_NONE = -1, // no touch status
195 MMS_ADDRESS_PRESENT_TOKEN,
196 MMS_INSERT_ADDRESS_TOKEN
200 MSG_PARAM_REPORT_TYPE_DELIVERY_STATUS,
201 MSG_PARAM_REPORT_TYPE_NUM,
202 MSG_PARAM_REPORT_TYPE_UNKNOWN,
203 } MsgParamReportType;
205 /* Response status */
207 MMS_RESPSTATUS_ERROR = -1, // error return in Get method
208 MMS_RESPSTATUS_OK = 0, // default value
209 MMS_RESPSTAUTS_ERROR_UNSPECIFIED = 1,
210 MMS_RESPSTAUTS_ERROR_SERVICEDENIED = 2,
211 MMS_RESPSTAUTS_ERROR_MESSAGEFORMATCORRUPT = 3,
212 MMS_RESPSTAUTS_ERROR_SENDINGADDRESSUNRESOLVED = 4,
213 MMS_RESPSTAUTS_ERROR_MESSAGENOTFOUND = 5,
214 MMS_RESPSTAUTS_ERROR_NETWORKPROBLEM = 6,
215 MMS_RESPSTAUTS_ERROR_CONTENTNOTACCEPTED = 7,
216 MMS_RESPSTAUTS_ERROR_UNSUPPORTEDMESSAGE = 8,
218 MMS_RESPSTAUTS_ERROR_TRANSIENT_FAILURE = 9,
219 MMS_RESPSTAUTS_ERROR_TRANSIENT_SENDING_ADDRESS_UNRESOLVED = 10,
220 MMS_RESPSTAUTS_ERROR_TRANSIENT_MESSAGE_NOT_FOUND = 11,
221 MMS_RESPSTAUTS_ERROR_TRANSIENT_NETWORK_PROBLEM = 12,
223 MMS_RESPSTAUTS_ERROR_PERMANENT_FAILURE = 13,
224 MMS_RESPSTAUTS_ERROR_PERMANENT_SERVICE_DENIED = 14,
225 MMS_RESPSTAUTS_ERROR_PERMANENT_MESSAGE_FORMAT_CORRUPT = 15,
226 MMS_RESPSTAUTS_ERROR_PERMANENT_SENDING_ADDRESS_UNRESOLVED = 16,
227 MMS_RESPSTAUTS_ERROR_PERMANENT_MESSAGE_NOT_FOUND = 17,
228 MMS_RESPSTAUTS_ERROR_PERMANENT_CONTENT_NOT_ACCEPTED = 18,
229 MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_LIMITATIONS_NOT_MET = 19,
230 MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_REQUEST_NOT_ACCEPTED = 20,
231 MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_FORWARDING_DENIED = 21,
232 MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_NOT_SUPPORTED = 22
237 MMS_RETRSTATUS_ERROR = -1, // error return in Get method
238 MMS_RETRSTATUS_OK = 0,
239 MMS_RETRSTATUS_TRANSIENT_FAILURE = 1,
240 MMS_RETRSTATUS_TRANSIENT_MESSAGE_NOT_FOUND = 2,
241 MMS_RETRSTATUS_TRANSIENT_NETWORK_PROBLEM = 3,
242 MMS_RETRSTATUS_PERMANENT_FAILURE = 4,
243 MMS_RETRSTATUS_PERMANENT_SERVICE_DENIED = 5,
244 MMS_RETRSTATUS_PERMANENT_MESSAGE_NOT_FOUND = 6,
245 MMS_RETRSTATUS_PERMANENT_CONTENT_UNSUPPORT = 7
250 MMS_REPLY_NONE = -1, // error return in Get method
251 MMS_REPLY_REQUESTED = 0,
252 MMS_REPLY_REQUESTED_TEXT_ONLY = 1,
253 MMS_REPLY_ACCEPTED = 2,
254 MMS_REPLY_ACCEPTED_TEXT_ONLY = 3
255 } MmsReplyChargeType;
259 MMS_STATUS_ERROR = -1, // error return in Get method
260 MMS_STATUS_INITIAL = 0,
261 MMS_STATUS_REQUESTING = 1,
262 MMS_STATUS_SUCCESS = 2,
269 MMS_EDIT_STYLE_THIS_PAGE = 0,
270 MMS_EDIT_STYLE_ALL_PAGE,
274 MMS_SPECIAL_MSG_TYPE_NONE = 0,
275 MMS_SPECIAL_MSG_TYPE_SYSTEM_TEMPLATE, // system template .
276 MMS_SPECIAL_MSG_TYPE_VOICE_MESSAGE, //voice message service
278 MMS_SPECIAL_MSG_TYPE_VDF_POSTCARD, //postcard service, or Generic Postcard Service
279 MMS_SPECIAL_MSG_TYPE_POSTCARD_EXT1, //Stickers Service
280 MMS_SPECIAL_MSG_TYPE_POSTCARD_EXT2, //Photo 10x15
281 MMS_SPECIAL_MSG_TYPE_POSTCARD_EXT3, //8 Photos
282 MMS_SPECIAL_MSG_TYPE_POSTCARD_EXT4, // 4 Photos
287 MMS_MM_CLASS_IMAGE_BASIC,
288 MMS_MM_CLASS_IMAGE_RICH,
289 MMS_MM_CLASS_VIDEO_BASIC,
290 MMS_MM_CLASS_VIDEO_RICH,
291 MMS_MM_CLASS_MEGAPIXEL,
292 MMS_MM_CLASS_CONTENT_BASIC,
293 MMS_MM_CLASS_CONTENT_RICH,
298 MMS_MSGCLASS_ERROR = -1, // error return in Get method
299 MMS_MSGCLASS_PERSONAL = 0, // default
300 MMS_MSGCLASS_ADVERTISEMENT = 1,
301 MMS_MSGCLASS_INFORMATIONAL = 2,
302 MMS_MSGCLASS_AUTO = 3
306 /*==================================================================================================
308 ==================================================================================================*/
311 MmsReplyChargeType chargeType;
312 MmsTimeStruct deadLine;
314 char szChargeID[MMS_MSG_ID_LEN + 1];
318 typedef struct _MmsMsgMultiStatus {
319 char szTo[MAX_ADDRESS_VAL_LEN + 1];
320 bool bDeliveryReportIsRead;
321 bool bDeliveyrReportIsLast;
322 MSG_DELIVERY_REPORT_STATUS_T msgStatus;
325 bool bReadReplyIsRead;
326 bool bReadReplyIsLast;
327 MSG_READ_REPORT_STATUS_T readStatus;
330 struct _MmsMsgMultiStatus *pNext;
333 typedef struct _MMS_ATTRIB_S {
334 MsgContentType contentType;
335 MmsDataType dataType;
339 char szFrom[MSG_LOCALE_ADDR_LEN + 11]; //"/TYPE=PLMN", /"TYPE=IPv4", "/TYPE=IPv6"
340 char szSubject[MSG_LOCALE_SUBJ_LEN + 1];
345 MmsPriority priority;
347 MmsReplyCharge replyCharge;
348 bool bChargingMsgReplied;
351 bool bAskDeliveryReport;
353 MmsRecvReadReportType readReportAllowedType;
358 MmsRecvReadReportSendStatus readReportSendStatus;
360 bool bReadReportSent;
363 bool bUseExpiryCustomTime; // for expiry custom time
364 bool bUseDeliveryCustomTime; // for expiry custom time
365 MmsEditStyleMode editStyleMode; //editStyle on All Page
367 MmsSpecialMsgType specialMsgType; // instead of bPostcard
369 #ifdef __SUPPORT_DRM__
371 int roWaitingTimerMax; // DRM RO WAITING
372 char *pszDrmData; // DRM Data to draw mailbox icon
376 MmsMsgClass msgClass;
377 MmsTimeStruct expiryTime;
378 MmsTimeStruct expiryCustomTime; // for expiry custom time,
379 MmsTimeStruct deliveryTime;
380 MmsTimeStruct deliveryCustomTime; // for expiry custom time
382 //for ReadMsg, When Sending notifyResp.ind
383 MSG_DELIVERY_REPORT_STATUS_T msgStatus;
385 MmsResponseStatus responseStatus;
386 MmsRetrieveStatus retrieveStatus;
387 char szResponseText[MMS_LOCALE_RESP_TEXT_LEN + 1];
388 char szRetrieveText[MMS_LOCALE_RESP_TEXT_LEN + 1];
390 MmsMsgMultiStatus *pMultiStatus;
395 typedef struct _MsgContentParam {
397 char szBoundary[MSG_BOUNDARY_LEN + 1];
398 char szFileName[MSG_FILENAME_LEN_MAX + 1];
399 char szName[MSG_LOCALE_FILENAME_LEN_MAX + 1];
401 #ifdef FEATURE_JAVA_MMS
402 char *szApplicationID;
403 char *szReplyToApplicationID;
408 char szStart[MSG_MSG_ID_LEN + 1];
409 char szStartInfo[MSG_MSG_ID_LEN + 1];
411 MsgParamReportType reportType; //only used as parameter of Content-Type: multipart/report; report-type=delivery-status;
414 #ifdef __SUPPORT_DRM__
415 typedef struct _MsgDRMInfo {
417 MsgContentType contentType;
420 char *szContentDescription;
421 char *szContentVendor;
423 char *szDrm2FullPath;
424 int roWaitingTimerMax; // DRM RO WAITING
426 char *pszContentType;
432 typedef struct _MsgType {
438 #ifdef __SUPPORT_DRM__
443 char szContentID[MSG_MSG_ID_LEN + 1];
444 char szContentLocation[MSG_MSG_ID_LEN + 1];
445 char szOrgFilePath[MSG_FILEPATH_LEN_MAX];
447 char szContentRepPos[30];
448 char szContentRepSize[30];
449 char szContentRepIndex[8];
450 #ifdef __SUPPORT_DRM__
451 int nDrmConvertedStatus;
454 MsgContentParam param;
458 int type; //MSG_ADDR_TYPE_PHONE/EMAIL/IPV4/IPV6
459 MsgRecipientType recipientType; // TO, CC, BCC
460 char szName[MSG_LOCALE_NAME_LEN + 1];
461 char szAddr[MSG_ADDR_LEN + 1];
463 bool bDoNotShow; // temporary clip
466 ULONG uLastRecentTime; // last recent time save item
467 ULONG uMostUseCount; // most use count item.
468 int index; // index sorting..
471 typedef struct _MsgHeader {
475 char szReturnPath[MSG_ADDR_LEN + 1];
476 char szDate[MSG_DATE_LEN];
477 char szSubject[MSG_LOCALE_SUBJ_LEN + 1];
478 char szMsgID[MSG_MSG_ID_LEN + 1];
485 char szOrgFilePath[MSG_FILEPATH_LEN_MAX];
486 MsgType presentationType;
487 MsgBody *pPresentationBody;
492 MsgMultipart *pMultipart;
493 MsgMessage *pMessage;
497 struct _MsgMultipart {
510 typedef struct _MMS_MESSAGE_S {
512 MSG_MESSAGE_ID_T msgID;
513 int mailbox; // mailbox type,MMS_MAILBOX_XXX
514 char szFileName[MSG_FILENAME_LEN_MAX];
515 char szTrID[MMS_TR_ID_LEN + 1];
516 char szMsgID[MMS_MSG_ID_LEN + 1];
517 char szForwardMsgID[MMS_MSG_ID_LEN + 1];
518 char szContentLocation[MMS_LOCATION_LEN + 1];
524 struct _MsgHeaderAddress {
526 MsgHeaderAddress *pNext;
530 bool MmsInitMsgType(MsgType *pMsgType);
531 bool MmsInitMsgBody(MsgBody *pMsgBody);
532 bool MmsInitMsgContentParam(MsgContentParam *pMsgContentParam);
533 bool MmsInitMsgAttrib(MmsAttrib *pAttrib);
534 bool MmsSetMsgAddressList(MmsAttrib *pAttrib, const MSG_MESSAGE_INFO_S *pMsgInfo);
535 char *MmsComposeAddress(const MSG_MESSAGE_INFO_S *pMsgInfo, int recipientType);
536 bool MmsGetMsgBodyfromMsgInfo(const MSG_MESSAGE_INFO_S *pMsgInfo, MMS_MESSAGE_DATA_S *pMsgBody, char *pFileData);
537 bool MmsGetSmilRawData(MMS_MESSAGE_DATA_S *pMsgBody, char *pRawData, int *nSize);
538 bool MmsInsertPresentation(MmsMsg *pMsg, MsgContentType mimeType, char *pData, int size);
539 bool MmsInsertPartFromFile(MmsMsg *pMsg, char *szTitleName, char *szOrgFilePath, char *szContentID);
540 bool MmsIsMultipart(int type);
541 bool MmsGetTypeByFileName(int *type, char *szFileName);
542 MsgMultipart *MmsMakeMultipart(MsgContentType mimeType, char *szTitleName, char *szOrgFilePath, void *pData, int offset, int size, char *szContentID);
543 bool MmsIsText(int type);
544 bool MmsIsVitemContent(int type, char *pszName);
545 bool MmsComposeMessage(MmsMsg *pMmsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMsgData, char *pFileData);
546 void MmsComposeNotiMessage(MmsMsg *pMmsMsg, MSG_MESSAGE_ID_T msgID);
547 bool MmsGetMmsMessageBody(MmsMsg *pMmsMsg, char *retrievedFilePath);
548 bool MmsComposeForwardHeader(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsgInfo);
549 bool MmsComposeForwardMessage(MmsMsg *pMmsMsg, char *retrievedFilePath);
550 #ifdef MMS_DELIEVERY_IND_ENABLED
551 MmsMsgMultiStatus *MmsComposeDeliveryIndMessage(MmsMsg *pMmsMsg, MSG_MESSAGE_ID_T msgId);
553 void MmsComposeReadReportMessage(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsgInfo, MSG_MESSAGE_ID_T selectedMsgId);
554 MmsMsgMultiStatus *MmsGetMultiStatus(MSG_MESSAGE_ID_T msgId);
555 int MmsSearchMsgId(char *toNumber, char *szMsgID);
556 void MmsUpdateDeliveryReport(MSG_MESSAGE_ID_T msgId, MmsMsgMultiStatus *pStatus);
557 void MmsUpdateReadReport(MSG_MESSAGE_ID_T msgId, MmsMsgMultiStatus *pStatus);
558 MsgMultipart *MmsAllocMultipart(void);
559 bool _MsgIsASCII(char *pszText);
560 bool _MsgReplaceNonAscii(char *szInText, char **szOutText, char replaceChar);
561 bool _MsgIsSpace(char *pszText);
562 bool _MsgReplaceSpecialChar(char *szInText, char **szOutText, char specialChar);
563 char *MsgStrAppend(char *szInputStr1, char *szInputStr2);
564 char *MsgStrCopy(const char *string);
565 char *MsgStrNCopy(const char *string, int length);
566 int MsgStrlen(char *pStr);
567 bool _MsgConvertCharToHex(char pSrc, char *pDest);
568 MSG_ERROR_T MmsAddAttachment(MMS_MESSAGE_DATA_S *pMsgData, MMS_MEDIA_S *pMedia);
569 bool MmsCheckAdditionalMedia(MMS_MESSAGE_DATA_S *pMsgData, MsgType *partHeader);
570 #ifdef __SUPPORT_DRM__
571 bool __MsgInitMsgDRMInfo(MsgDRMInfo *pMsgDrmInfo);