89 |
91 |
90 delete uniEditorGenUtils; |
92 delete uniEditorGenUtils; |
91 } |
93 } |
92 |
94 |
93 //--------------------------------------------------------------- |
95 //--------------------------------------------------------------- |
94 // MsgMonitor::checkMsgTypeChange |
96 // MsgMonitor::handleContentChange |
95 // @see header file |
97 // @see header file |
96 //--------------------------------------------------------------- |
98 //--------------------------------------------------------------- |
97 void MsgMonitor::checkMsgTypeChange() |
99 void MsgMonitor::handleContentChange() |
98 { |
100 { |
99 // fetch editor's content |
101 // get the projected message type & show the type change note |
100 MsgUnifiedEditorBody* edBody = view()->mBody; |
102 ConvergedMessage::MessageType newMsgType = projectedMsgType(); |
101 QStringList objList = edBody->mediaContent(); |
103 if(mMessageType != newMsgType) |
102 QString bodyText = edBody->text(); |
104 { |
103 |
105 mMessageType = newMsgType; |
104 MsgUnifiedEditorSubject* edSubject = view()->mSubjectField; |
|
105 ConvergedMessage::Priority priority = ConvergedMessage::Normal; |
|
106 QString subjectText; |
|
107 if(edSubject) |
|
108 { |
|
109 priority = edSubject->priority(); |
|
110 subjectText = edSubject->text(); |
|
111 } |
|
112 |
|
113 MsgUnifiedEditorAddress* edCc = view()->mCcField; |
|
114 MsgUnifiedEditorAddress* edBcc = view()->mBccField; |
|
115 int ccCount = 0; |
|
116 int bccCount = 0; |
|
117 if(edCc && edBcc) |
|
118 { |
|
119 ccCount = edCc->addressCount(); |
|
120 bccCount = edBcc->addressCount(); |
|
121 } |
|
122 |
|
123 MsgAttachmentContainer* edContainer = view()->mAttachmentContainer; |
|
124 bool hasMMAttachmentContent = false; |
|
125 int attachmentCount = 0; |
|
126 if(edContainer) |
|
127 { |
|
128 hasMMAttachmentContent = edContainer->hasMMContent(); |
|
129 attachmentCount = edContainer->count(); |
|
130 } |
|
131 |
|
132 // find out the msgtype based on content |
|
133 ConvergedMessage::MessageType projectedMsgType = ConvergedMessage::Sms; |
|
134 |
|
135 // check for presence of MMS content |
|
136 // 1. If any media-object is present inside body |
|
137 // 2. If priority is set to other than Normal |
|
138 // 3. If subject has some content |
|
139 // 4. If CC/BCC has some content |
|
140 // 5. If MM attachments are present |
|
141 // 6. If only one non-MM attachment is present e.g. vcf |
|
142 // and body text is also present |
|
143 // 7. If body text size exceeds sms text-size limit |
|
144 if( !objList.isEmpty() || |
|
145 (priority != ConvergedMessage::Normal) || |
|
146 !subjectText.isEmpty() || |
|
147 (ccCount || bccCount) || |
|
148 hasMMAttachmentContent || |
|
149 ((attachmentCount == 1) && !bodyText.isEmpty()) |
|
150 ) |
|
151 { |
|
152 projectedMsgType = ConvergedMessage::Mms; |
|
153 } |
|
154 else |
|
155 { |
|
156 projectedMsgType = ConvergedMessage::Sms; |
|
157 } |
|
158 |
|
159 // optimization 1: if projected type is still sms means |
|
160 // the message under composition has only plain text |
|
161 if(projectedMsgType == ConvergedMessage::Sms) |
|
162 { |
|
163 bool hasUnicodeText = edBody->isUnicode(); |
|
164 int bodyTextSize = mUniEditorGenUtils->UTF8Size(bodyText); |
|
165 int maxSmsSize = mUniEditorGenUtils->MaxSmsMsgSizeL(hasUnicodeText); |
|
166 if(bodyTextSize > maxSmsSize) |
|
167 { |
|
168 projectedMsgType = ConvergedMessage::Mms; |
|
169 } |
|
170 } |
|
171 |
|
172 // show type change note, if needed |
|
173 if(mMessageType != projectedMsgType) |
|
174 { |
|
175 mMessageType = projectedMsgType; |
|
176 QString noteStr; |
106 QString noteStr; |
177 if(projectedMsgType == ConvergedMessage::Sms) |
107 if(newMsgType == ConvergedMessage::Sms) |
178 { |
108 { |
179 noteStr = LOC_POP_MESSAGE_CHANGE_TEXT; |
109 noteStr = LOC_POP_MESSAGE_CHANGE_TEXT; |
180 } |
110 } |
181 else |
111 else |
182 { |
112 { |
183 noteStr = LOC_POP_MESSAGE_CHANGE_MUL; |
113 noteStr = LOC_POP_MESSAGE_CHANGE_MUL; |
184 |
|
185 //Disable char counter |
|
186 edBody->disableCharCounter(); |
|
187 } |
114 } |
188 showPopup(noteStr); |
115 showPopup(noteStr); |
189 } |
116 } |
|
117 |
|
118 HbWidget* senderWidget = qobject_cast<HbWidget*>(sender()); |
|
119 updateMsgInfo(senderWidget); |
|
120 } |
|
121 |
|
122 //--------------------------------------------------------------- |
|
123 // MsgMonitor::projectedMsgType |
|
124 // @see header file |
|
125 //--------------------------------------------------------------- |
|
126 ConvergedMessage::MessageType MsgMonitor::projectedMsgType() |
|
127 { |
|
128 ConvergedMessage::MessageType newMsgType = ConvergedMessage::Sms; |
|
129 |
|
130 // check if MMS content is present in any of the editor component |
|
131 if( bodyHasMMSContent() || |
|
132 subjectHasMMSContent() || |
|
133 containerHasMMSContent() || |
|
134 otherMMSCriteriaMet() ) |
|
135 { |
|
136 newMsgType = ConvergedMessage::Mms; |
|
137 } |
|
138 return newMsgType; |
|
139 } |
|
140 |
|
141 //--------------------------------------------------------------- |
|
142 // MsgMonitor::updateMsgInfo |
|
143 // @see header file |
|
144 //--------------------------------------------------------------- |
|
145 void MsgMonitor::updateMsgInfo(HbWidget* senderWidget) |
|
146 { |
|
147 if(mMessageType == ConvergedMessage::Mms) |
|
148 { |
|
149 //Disable char counter & add subject |
|
150 view()->mBody->disableCharCounter(); |
|
151 view()->addSubject(); |
|
152 } |
|
153 |
|
154 // check if sent by body widget |
|
155 MsgUnifiedEditorBody* body = NULL; |
|
156 body = qobject_cast<MsgUnifiedEditorBody*>(senderWidget); |
|
157 if(body) |
|
158 { |
|
159 mBodySize = view()->mBody->bodySize(); |
|
160 view()->setAttachOptionEnabled( |
|
161 MsgUnifiedEditorView::TBE_PHOTO, !view()->mBody->hasImage()); |
|
162 view()->setAttachOptionEnabled( |
|
163 MsgUnifiedEditorView::TBE_SOUND, !view()->mBody->hasAudio()); |
|
164 return; |
|
165 } |
190 |
166 |
191 // update size of editor component |
167 // check if sent by subject widget |
192 HbWidget* senderWidget = qobject_cast<HbWidget*>(sender()); |
168 MsgUnifiedEditorSubject* subject = NULL; |
193 updateSizeInfo(senderWidget); |
169 subject = qobject_cast<MsgUnifiedEditorSubject*>(senderWidget); |
194 } |
170 if(subject) |
195 |
171 { |
196 //--------------------------------------------------------------- |
172 mSubjectSize = view()->mSubjectField->subjectSize(); |
197 // MsgMonitor::updateSizeInfo |
|
198 // @see header file |
|
199 //--------------------------------------------------------------- |
|
200 void MsgMonitor::updateSizeInfo(HbWidget* aWidget) |
|
201 { |
|
202 // if sent by body widget |
|
203 MsgUnifiedEditorBody* body = NULL; |
|
204 body = qobject_cast<MsgUnifiedEditorBody*>(aWidget); |
|
205 if(body) |
|
206 { |
|
207 mBodySize = view()->mBody->bodySize(); |
|
208 return; |
173 return; |
209 } |
174 } |
210 |
175 |
211 // if sent by attachment container widget |
176 // check if sent by attachment container widget |
212 MsgAttachmentContainer* container = NULL; |
177 MsgAttachmentContainer* container = NULL; |
213 container = qobject_cast<MsgAttachmentContainer*>(aWidget); |
178 container = qobject_cast<MsgAttachmentContainer*>(senderWidget); |
214 if(container) |
179 if(container) |
215 { |
180 { |
216 mContainerSize = view()->mAttachmentContainer->containerSize(); |
181 mContainerSize = view()->mAttachmentContainer->containerSize(); |
217 return; |
182 return; |
218 } |
183 } |
219 |
184 |
220 // if sent by subject widget |
185 // handle content change from other widgets e.g. To, Cc, Bcc address field |
221 MsgUnifiedEditorSubject* subject = NULL; |
186 int totalAddressCount = view()->mToField->addressCount(); |
222 subject = qobject_cast<MsgUnifiedEditorSubject*>(aWidget); |
187 if(view()->mCcField && view()->mBccField) |
223 if(subject) |
188 { |
224 { |
189 totalAddressCount += view()->mCcField->addressCount() + |
225 mSubjectSize = view()->mSubjectField->subjectSize(); |
190 view()->mBccField->addressCount(); |
226 } |
191 } |
|
192 mMsgCurrAddressCount = totalAddressCount; |
|
193 return; |
227 } |
194 } |
228 |
195 |
229 //--------------------------------------------------------------- |
196 //--------------------------------------------------------------- |
230 // MsgMonitor::showPopup |
197 // MsgMonitor::showPopup |
231 // @see header file |
198 // @see header file |
252 MsgUnifiedEditorView* MsgMonitor::view() |
219 MsgUnifiedEditorView* MsgMonitor::view() |
253 { |
220 { |
254 return static_cast<MsgUnifiedEditorView*>(this->parent()); |
221 return static_cast<MsgUnifiedEditorView*>(this->parent()); |
255 } |
222 } |
256 |
223 |
|
224 //--------------------------------------------------------------- |
|
225 // MsgMonitor::bodyHasMMSContent |
|
226 // @see header file |
|
227 //--------------------------------------------------------------- |
|
228 bool MsgMonitor::bodyHasMMSContent() |
|
229 { |
|
230 MsgUnifiedEditorBody* edBody = view()->mBody; |
|
231 // If any media-object is present inside body |
|
232 if(!edBody->mediaContent().isEmpty()) |
|
233 { |
|
234 return true; |
|
235 } |
|
236 |
|
237 int bodyTextSize = mUniEditorGenUtils->UTF8Size(edBody->text()); |
|
238 int maxSmsSize = 0; |
|
239 TRAP_IGNORE(maxSmsSize = |
|
240 mUniEditorGenUtils->MaxSmsMsgSizeL(edBody->isUnicode())); |
|
241 // If body text size exceeds sms text-size limit |
|
242 if(bodyTextSize > maxSmsSize) |
|
243 { |
|
244 return true; |
|
245 } |
|
246 return false; |
|
247 } |
|
248 |
|
249 //--------------------------------------------------------------- |
|
250 // MsgMonitor::subjectHasMMSContent |
|
251 // @see header file |
|
252 //--------------------------------------------------------------- |
|
253 bool MsgMonitor::subjectHasMMSContent() |
|
254 { |
|
255 MsgUnifiedEditorSubject* edSubject = view()->mSubjectField; |
|
256 ConvergedMessage::Priority priority = ConvergedMessage::Normal; |
|
257 QString subjectText; |
|
258 if(edSubject) |
|
259 { |
|
260 priority = edSubject->priority(); |
|
261 subjectText = edSubject->text(); |
|
262 } |
|
263 // If priority is set to other than Normal or |
|
264 // If subject has some content |
|
265 if( (priority != ConvergedMessage::Normal) || |
|
266 !subjectText.isEmpty() ) |
|
267 { |
|
268 return true; |
|
269 } |
|
270 return false; |
|
271 } |
|
272 |
|
273 //--------------------------------------------------------------- |
|
274 // MsgMonitor::containerHasMMSContent |
|
275 // @see header file |
|
276 //--------------------------------------------------------------- |
|
277 bool MsgMonitor::containerHasMMSContent() |
|
278 { |
|
279 QString bodyText = view()->mBody->text(); |
|
280 MsgAttachmentContainer* edContainer = view()->mAttachmentContainer; |
|
281 bool hasMMAttachmentContent = false; |
|
282 int attachmentCount = 0; |
|
283 if(edContainer) |
|
284 { |
|
285 hasMMAttachmentContent = edContainer->hasMMContent(); |
|
286 attachmentCount = edContainer->count(); |
|
287 } |
|
288 // If MM attachments are present or |
|
289 // If only one non-MM attachment is present e.g. vcf along with body text |
|
290 if( hasMMAttachmentContent || |
|
291 ((attachmentCount == 1) && !bodyText.isEmpty()) ) |
|
292 { |
|
293 return true; |
|
294 } |
|
295 return false; |
|
296 } |
|
297 |
|
298 //--------------------------------------------------------------- |
|
299 // MsgMonitor::otherMMSCriteriaMet |
|
300 // @see header file |
|
301 //--------------------------------------------------------------- |
|
302 bool MsgMonitor::otherMMSCriteriaMet() |
|
303 { |
|
304 MsgUnifiedEditorAddress* edCc = view()->mCcField; |
|
305 MsgUnifiedEditorAddress* edBcc = view()->mBccField; |
|
306 int ccCount = 0; |
|
307 int bccCount = 0; |
|
308 if(edCc && edBcc) |
|
309 { |
|
310 ccCount = edCc->addressCount(); |
|
311 bccCount = edBcc->addressCount(); |
|
312 } |
|
313 // If CC/BCC has some content or |
|
314 // If to-recipients count exceeds max sms recipient count |
|
315 if( ccCount || bccCount || |
|
316 (view()->mToField->addressCount() > mMaxSmsRecipients) ) |
|
317 { |
|
318 return true; |
|
319 } |
|
320 |
|
321 // If to-field contains an email address |
|
322 bool isEmailPresent = false; |
|
323 ConvergedMessageAddressList addrList = view()->mToField->addresses(); |
|
324 TRAP_IGNORE(isEmailPresent = mUniEditorGenUtils->VerifyEmailAddressesL(addrList)); |
|
325 if(isEmailPresent) |
|
326 { |
|
327 return true; |
|
328 } |
|
329 return false; |
|
330 } |
|
331 |
257 //EOF |
332 //EOF |