2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.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
8 * http://www.tizenopensource.org/license
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.
17 #ifndef MMS_PLUGIN_MESSAGE_H
18 #define MMS_PLUGIN_MESSAGE_H
21 /*==================================================================================================
23 ==================================================================================================*/
25 #include "MsgInternalTypes.h"
26 #include "MsgMmsTypes.h"
27 #include "MsgSettingTypes.h"
28 #include "MmsPluginMIME.h"
29 #include "MsgMmsTypes.h"
31 /*==================================================================================================
33 ==================================================================================================*/
34 #define MMS_CONTENT_ID_LEN 100
35 #define MMS_LOCALE_RESP_TEXT_LEN 90
36 #define MMS_TEXT_LEN 2000
37 #define MMS_READ_REPORT_STRING_READ "Read:"
38 #define MMS_READ_REPORT_STRING_DELETED "Deleted:"
40 #define MSG_ATTACH_MAX 20
41 #define MSG_LINE_LEN 1024
42 #define MSG_SUBJ_LEN 40
43 #define MSG_DATE_LEN 50
44 #define MSG_BOUNDARY_LEN 70
45 #define MSG_LOCALE_NAME_LEN 150
46 #define MSG_LOCALE_SUBJ_LEN (3 * MSG_SUBJ_LEN)
47 #define MSG_ADDR_LEN MAX_ADDRESS_VAL_LEN
48 #define MSG_LOCALE_ADDR_LEN (3 * MAX_ADDRESS_VAL_LEN)
49 #define MSG_LOCALE_FILENAME_LEN_MAX (3 * 255)
50 #define MSG_LOCALE_SIGN_LEN (3 * MAX_SIGN_VAL_LEN)
51 #define MSG_MAILBOX_NAME_LEN 10
53 #define MsgContentType MimeType
54 #define MsgRecipientType msg_recipient_type_t
55 #define MMS_VERSION 0x92
56 #define MSG_STR_ADDR_DELIMETER ";"
57 #define MSG_CH_ADDR_DELIMETER ';'
58 #ifdef __SUPPORT_DRM__
59 #define MSG_DRM_MAX_CMD (2 * 1024)
62 #define MSG_MMS_DECODE_BUFFER_MAX (2 * 1024)
63 #define MSG_MMS_ENCODE_BUFFER_MAX (2 * 1024)
65 /*==================================================================================================
67 ==================================================================================================*/
68 typedef unsigned int UINT;
69 typedef unsigned long int UINT32;
70 typedef unsigned char UINT8;
71 typedef unsigned short int UINT16;
72 typedef unsigned long ULONG;
73 typedef unsigned char UCHAR;
74 typedef unsigned short MCHAR;
75 typedef unsigned short USHORT;
79 typedef struct _MsgAddress MsgAddress;
80 typedef struct _MsgBody MsgBody;
81 typedef struct _MsgMultipart MsgMultipart;
82 typedef struct _MsgMessage MsgMessage;
84 typedef struct _MsgHeaderAddress MsgHeaderAddress;
86 /*==================================================================================================
88 ==================================================================================================*/
91 MMS_DATATYPE_NONE = -1,
92 MMS_DATATYPE_READ = 0,
93 MMS_DATATYPE_SENT = 1,
94 MMS_DATATYPE_NOTIFY = 2,
95 MMS_DATATYPE_UNSENT = 3,
96 MMS_DATATYPE_DRAFT = 4,
97 MMS_DATATYPE_SENDING = 6,
98 MMS_DATATYPE_RETRIEVING = 7,
99 MMS_DATATYPE_UNRETV = 8,
100 MMS_DATATYPE_TEMPLATE = 9,
101 MMS_DATATYPE_DRM_RO_WAITING = 10 // DRM RO WAITING
106 MMS_MSGTYPE_ERROR = -1, // error return in Get method
107 MMS_MSGTYPE_SEND_REQ = 0, // default
108 MMS_MSGTYPE_SEND_CONF = 1,
109 MMS_MSGTYPE_NOTIFICATION_IND = 2,
110 MMS_MSGTYPE_NOTIFYRESP_IND = 3,
111 MMS_MSGTYPE_RETRIEVE_CONF = 4,
112 MMS_MSGTYPE_ACKNOWLEDGE_IND = 5,
113 MMS_MSGTYPE_DELIVERY_IND = 6,
114 MMS_MSGTYPE_READREC_IND = 7,
115 MMS_MSGTYPE_READORG_IND = 8,
116 MMS_MSGTYPE_FORWARD_REQ = 9,
117 MMS_MSGTYPE_FORWARD_CONF = 10,
118 MMS_MSGTYPE_READ_REPLY = 11, // for internal use
124 MMS_PRIORITY_ERROR = -1, // error return in Get method
125 MMS_PRIORITY_LOW = 0, // default
126 MMS_PRIORITY_NORMAL = 1,
127 MMS_PRIORITY_HIGH = 2
132 MMS_SENDER_VISIBLE_ERROR = -1, // error return in Get method
139 MMS_REPORT_ERROR = -1, // error return in Get method
146 MMS_REPORTALLOWED_ERROR = -1, // error return in Get method
147 MMS_REPORTALLOWED_YES = 0,
148 MMS_REPORTALLOWED_NO = 1
153 MMS_RECEIVE_READ_REPORT_ALLOWED,
154 MMS_RECEIVE_READ_REPORT_PROMPT,
155 MMS_RECEIVE_READ_REPORT_NOT_ALLOWED,
156 } MmsRecvReadReportType ;
160 MMS_MSGSTATUS_NONE = -1, // backward compatibility
161 MMS_MSGSTATUS_ERROR = -1, // error return in Get method
162 MMS_MSGSTATUS_EXPIRED = 0, // This value SHOULD not be used in the M-NotifyResp.ind PDU.
163 MMS_MSGSTATUS_RETRIEVED = 1,
164 MMS_MSGSTATUS_REJECTED = 2,
165 MMS_MSGSTATUS_DEFERRED = 3,
166 MMS_MSGSTATUS_UNRECOGNISED = 4, // This value SHALL not be used in the M-Delivery.ind PDU.
167 MMS_MSGSTATUS_INDETERMINATE = 5,
168 MMS_MSGSTATUS_FORWARDED = 6,
169 MMS_MSGSTATUS_UNREACHABLE = 7
174 MMS_READSTATUS_NONE = -1, // no touch status
176 MMS_IS_DELETED = 1 // Deleted without being read
181 MMS_ADDRESS_PRESENT_TOKEN,
182 MMS_INSERT_ADDRESS_TOKEN
186 MSG_PARAM_REPORT_TYPE_DELIVERY_STATUS,
187 MSG_PARAM_REPORT_TYPE_NUM,
188 MSG_PARAM_REPORT_TYPE_UNKNOWN,
189 } MsgParamReportType;
191 /* Response status */
193 MMS_RESPSTATUS_ERROR = -1, // error return in Get method
194 MMS_RESPSTATUS_OK = 0, // default value
195 MMS_RESPSTAUTS_ERROR_UNSPECIFIED = 1,
196 MMS_RESPSTAUTS_ERROR_SERVICEDENIED = 2,
197 MMS_RESPSTAUTS_ERROR_MESSAGEFORMATCORRUPT = 3,
198 MMS_RESPSTAUTS_ERROR_SENDINGADDRESSUNRESOLVED = 4,
199 MMS_RESPSTAUTS_ERROR_MESSAGENOTFOUND = 5,
200 MMS_RESPSTAUTS_ERROR_NETWORKPROBLEM = 6,
201 MMS_RESPSTAUTS_ERROR_CONTENTNOTACCEPTED = 7,
202 MMS_RESPSTAUTS_ERROR_UNSUPPORTEDMESSAGE = 8,
204 MMS_RESPSTAUTS_ERROR_TRANSIENT_FAILURE = 9,
205 MMS_RESPSTAUTS_ERROR_TRANSIENT_SENDING_ADDRESS_UNRESOLVED = 10,
206 MMS_RESPSTAUTS_ERROR_TRANSIENT_MESSAGE_NOT_FOUND = 11,
207 MMS_RESPSTAUTS_ERROR_TRANSIENT_NETWORK_PROBLEM = 12,
209 MMS_RESPSTAUTS_ERROR_PERMANENT_FAILURE = 13,
210 MMS_RESPSTAUTS_ERROR_PERMANENT_SERVICE_DENIED = 14,
211 MMS_RESPSTAUTS_ERROR_PERMANENT_MESSAGE_FORMAT_CORRUPT = 15,
212 MMS_RESPSTAUTS_ERROR_PERMANENT_SENDING_ADDRESS_UNRESOLVED = 16,
213 MMS_RESPSTAUTS_ERROR_PERMANENT_MESSAGE_NOT_FOUND = 17,
214 MMS_RESPSTAUTS_ERROR_PERMANENT_CONTENT_NOT_ACCEPTED = 18,
215 MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_LIMITATIONS_NOT_MET = 19,
216 MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_REQUEST_NOT_ACCEPTED = 20,
217 MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_FORWARDING_DENIED = 21,
218 MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_NOT_SUPPORTED = 22
223 MMS_RETRSTATUS_ERROR = -1, // error return in Get method
224 MMS_RETRSTATUS_OK = 0,
225 MMS_RETRSTATUS_TRANSIENT_FAILURE = 1,
226 MMS_RETRSTATUS_TRANSIENT_MESSAGE_NOT_FOUND = 2,
227 MMS_RETRSTATUS_TRANSIENT_NETWORK_PROBLEM = 3,
228 MMS_RETRSTATUS_PERMANENT_FAILURE = 4,
229 MMS_RETRSTATUS_PERMANENT_SERVICE_DENIED = 5,
230 MMS_RETRSTATUS_PERMANENT_MESSAGE_NOT_FOUND = 6,
231 MMS_RETRSTATUS_PERMANENT_CONTENT_UNSUPPORT = 7
236 MMS_REPLY_NONE = -1, // error return in Get method
237 MMS_REPLY_REQUESTED = 0,
238 MMS_REPLY_REQUESTED_TEXT_ONLY = 1,
239 MMS_REPLY_ACCEPTED = 2,
240 MMS_REPLY_ACCEPTED_TEXT_ONLY = 3
241 } MmsReplyChargeType;
245 MMS_STATUS_ERROR = -1, // error return in Get method
246 MMS_STATUS_INITIAL = 0,
247 MMS_STATUS_REQUESTING = 1,
248 MMS_STATUS_SUCCESS = 2,
255 MMS_EDIT_STYLE_THIS_PAGE = 0,
256 MMS_EDIT_STYLE_ALL_PAGE,
260 MMS_SPECIAL_MSG_TYPE_NONE = 0,
261 MMS_SPECIAL_MSG_TYPE_SYSTEM_TEMPLATE, // system template .
262 MMS_SPECIAL_MSG_TYPE_VOICE_MESSAGE, //voice message service
264 MMS_SPECIAL_MSG_TYPE_VDF_POSTCARD, //postcard service, or Generic Postcard Service
265 MMS_SPECIAL_MSG_TYPE_POSTCARD_EXT1, //Stickers Service
266 MMS_SPECIAL_MSG_TYPE_POSTCARD_EXT2, //Photo 10x15
267 MMS_SPECIAL_MSG_TYPE_POSTCARD_EXT3, //8 Photos
268 MMS_SPECIAL_MSG_TYPE_POSTCARD_EXT4, // 4 Photos
273 MMS_MM_CLASS_IMAGE_BASIC,
274 MMS_MM_CLASS_IMAGE_RICH,
275 MMS_MM_CLASS_VIDEO_BASIC,
276 MMS_MM_CLASS_VIDEO_RICH,
277 MMS_MM_CLASS_MEGAPIXEL,
278 MMS_MM_CLASS_CONTENT_BASIC,
279 MMS_MM_CLASS_CONTENT_RICH,
284 MMS_MSGCLASS_ERROR = -1, // error return in Get method
285 MMS_MSGCLASS_PERSONAL = 0, // default
286 MMS_MSGCLASS_ADVERTISEMENT = 1,
287 MMS_MSGCLASS_INFORMATIONAL = 2,
288 MMS_MSGCLASS_AUTO = 3
292 /*==================================================================================================
294 ==================================================================================================*/
297 MmsReplyChargeType chargeType;
298 MmsTimeStruct deadLine;
300 char szChargeID[MMS_MSG_ID_LEN + 1];
304 typedef struct _MmsMsgMultiStatus {
305 char szTo[MAX_ADDRESS_VAL_LEN + 1];
306 bool bDeliveryReportIsRead;
307 bool bDeliveyrReportIsLast;
308 msg_delivery_report_status_t msgStatus;
311 bool bReadReplyIsRead;
312 bool bReadReplyIsLast;
313 msg_read_report_status_t readStatus;
316 struct _MmsMsgMultiStatus *pNext;
319 typedef struct _MMS_ATTRIB_S {
320 MsgContentType contentType;
321 MmsDataType dataType;
325 char szFrom[MSG_LOCALE_ADDR_LEN + 11]; //"/TYPE=PLMN", /"TYPE=IPv4", "/TYPE=IPv6"
326 char szSubject[MSG_LOCALE_SUBJ_LEN + 1];
331 MmsPriority priority;
333 MmsReplyCharge replyCharge;
334 bool bChargingMsgReplied;
337 bool bAskDeliveryReport;
339 MmsRecvReadReportType readReportAllowedType;
344 MmsRecvReadReportSendStatus readReportSendStatus;
346 bool bReadReportSent;
349 bool bUseExpiryCustomTime; // for expiry custom time
350 bool bUseDeliveryCustomTime; // for expiry custom time
351 MmsEditStyleMode editStyleMode; //editStyle on All Page
353 MmsSpecialMsgType specialMsgType; // instead of bPostcard
355 #ifdef __SUPPORT_DRM__
357 int roWaitingTimerMax; // DRM RO WAITING
358 char *pszDrmData; // DRM Data to draw mailbox icon
362 MmsMsgClass msgClass;
363 MmsTimeStruct expiryTime;
364 MmsTimeStruct expiryCustomTime;
365 MmsTimeStruct deliveryTime;
366 MmsTimeStruct deliveryCustomTime;
368 //for ReadMsg, When Sending notifyResp.ind
369 msg_delivery_report_status_t msgStatus;
371 MmsResponseStatus responseStatus;
372 MmsRetrieveStatus retrieveStatus;
373 char szResponseText[MMS_LOCALE_RESP_TEXT_LEN + 1];
374 char szRetrieveText[MMS_LOCALE_RESP_TEXT_LEN + 1];
376 MmsMsgMultiStatus *pMultiStatus;
381 typedef struct _MsgContentParam {
383 char szBoundary[MSG_BOUNDARY_LEN + 1];
384 char szFileName[MSG_FILENAME_LEN_MAX + 1];
385 char szName[MSG_LOCALE_FILENAME_LEN_MAX + 1];
387 #ifdef FEATURE_JAVA_MMS
388 char *szApplicationID;
389 char *szReplyToApplicationID;
394 char szStart[MSG_MSG_ID_LEN + 1];
395 char szStartInfo[MSG_MSG_ID_LEN + 1];
397 MsgParamReportType reportType; //only used as parameter of Content-Type: multipart/report; report-type=delivery-status;
400 #ifdef __SUPPORT_DRM__
401 typedef struct _MsgDRMInfo {
403 MsgContentType contentType;
406 char *szContentDescription;
407 char *szContentVendor;
409 char *szDrm2FullPath;
410 int roWaitingTimerMax; // DRM RO WAITING
412 char *pszContentType;
418 typedef struct _MsgType {
424 #ifdef __SUPPORT_DRM__
429 char szContentID[MSG_MSG_ID_LEN + 1];
430 char szContentLocation[MSG_MSG_ID_LEN + 1];
431 char szOrgFilePath[MSG_FILEPATH_LEN_MAX];
433 char szContentRepPos[30];
434 char szContentRepSize[30];
435 char szContentRepIndex[8];
436 #ifdef __SUPPORT_DRM__
437 int nDrmConvertedStatus;
440 MsgContentParam param;
444 int type; //MSG_ADDR_TYPE_PHONE/EMAIL/IPV4/IPV6
445 MsgRecipientType recipientType; // TO, CC, BCC
446 char szName[MSG_LOCALE_NAME_LEN + 1];
447 char szAddr[MSG_ADDR_LEN + 1];
449 bool bDoNotShow; // temporary clip
452 ULONG uLastRecentTime; // last recent time save item
453 ULONG uMostUseCount; // most use count item.
454 int index; // index sorting..
457 typedef struct _MsgHeader {
461 char szReturnPath[MSG_ADDR_LEN + 1];
462 char szDate[MSG_DATE_LEN];
463 char szSubject[MSG_LOCALE_SUBJ_LEN + 1];
464 char szMsgID[MSG_MSG_ID_LEN + 1];
471 char szOrgFilePath[MSG_FILEPATH_LEN_MAX];
472 MsgType presentationType;
473 MsgBody *pPresentationBody;
478 MsgMultipart *pMultipart;
479 MsgMessage *pMessage;
483 struct _MsgMultipart {
496 typedef struct _MMS_MESSAGE_S {
498 msg_message_id_t msgID;
499 int mailbox; // mailbox type,MMS_MAILBOX_XXX
500 char szFileName[MSG_FILENAME_LEN_MAX];
501 char szTrID[MMS_TR_ID_LEN + 1];
502 char szMsgID[MMS_MSG_ID_LEN + 1];
503 char szForwardMsgID[MMS_MSG_ID_LEN + 1];
504 char szContentLocation[MMS_LOCATION_LEN + 1];
510 struct _MsgHeaderAddress {
512 MsgHeaderAddress *pNext;
516 bool MmsInitMsgType(MsgType *pMsgType);
517 bool MmsInitMsgBody(MsgBody *pMsgBody);
518 bool MmsInitMsgContentParam(MsgContentParam *pMsgContentParam);
519 bool MmsInitMsgAttrib(MmsAttrib *pAttrib);
520 bool MmsSetMsgAddressList(MmsAttrib *pAttrib, const MSG_MESSAGE_INFO_S *pMsgInfo);
521 char *MmsComposeAddress(const MSG_MESSAGE_INFO_S *pMsgInfo, int recipientType);
522 bool MmsGetMsgBodyfromMsgInfo(const MSG_MESSAGE_INFO_S *pMsgInfo, MMS_MESSAGE_DATA_S *pMsgBody, char *pFileData);
523 bool MmsGetSmilRawData(MMS_MESSAGE_DATA_S *pMsgBody, char *pRawData, int *nSize);
524 bool MmsInsertPresentation(MmsMsg *pMsg, MsgContentType mimeType, char *pData, int size);
525 bool MmsInsertPartFromFile(MmsMsg *pMsg, char *szTitleName, char *szOrgFilePath, char *szContentID);
526 bool MmsIsMultipart(int type);
527 bool MmsGetTypeByFileName(int *type, char *szFileName);
528 MsgMultipart *MmsMakeMultipart(MsgContentType mimeType, char *szTitleName, char *szOrgFilePath, void *pData, int offset, int size, char *szContentID);
529 bool MmsIsText(int type);
530 bool MmsIsVitemContent(int type, char *pszName);
531 bool MmsComposeMessage(MmsMsg *pMmsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMsgData, char *pFileData);
532 void MmsComposeNotiMessage(MmsMsg *pMmsMsg, msg_message_id_t msgID);
533 bool MmsGetMmsMessageBody(MmsMsg *pMmsMsg, char *retrievedFilePath);
534 bool MmsComposeForwardHeader(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsgInfo);
535 bool MmsComposeForwardMessage(MmsMsg *pMmsMsg, char *retrievedFilePath);
536 #ifdef MMS_DELIEVERY_IND_ENABLED
537 MmsMsgMultiStatus *MmsComposeDeliveryIndMessage(MmsMsg *pMmsMsg, msg_message_id_t msgId);
539 void MmsComposeReadReportMessage(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsgInfo, msg_message_id_t selectedMsgId);
540 MmsMsgMultiStatus *MmsGetMultiStatus(msg_message_id_t msgId);
541 int MmsSearchMsgId(char *toNumber, char *szMsgID);
542 MsgMultipart *MmsAllocMultipart(void);
543 msg_error_t MmsAddAttachment(MMS_MESSAGE_DATA_S *pMsgData, MMS_MEDIA_S *pMedia);
544 bool MmsCheckAdditionalMedia(MMS_MESSAGE_DATA_S *pMsgData, MsgType *partHeader);
545 bool MmsRemovePims(MMS_MESSAGE_DATA_S *pMsgData);
546 #ifdef __SUPPORT_DRM__
547 bool __MsgInitMsgDRMInfo(MsgDRMInfo *pMsgDrmInfo);
550 msg_error_t MmsMakePreviewInfo(int msgId, MMS_MESSAGE_DATA_S *pMmsMsg);