d99d3255ec6c62a262e922031ff157f42d74caba
[profile/ivi/wrt-plugins-tizen.git] / src / platform / API / Messaging / StorageChangesMessageGenerator.cpp
1 /*
2 * Copyright (c) 2011 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  * StorageChangesMessageGenerator.cpp
18  *
19  *  Created on: 2011. 10. 28.
20  *      Author: sangtai
21  */
22
23 #include "StorageChangesMessageGenerator.h"
24 #include "StorageChangesMessageFilterValidatorFactory.h"
25 #include "API/Messaging/ConversationFilterValidatorFactory.h"
26
27 #include "IMessagingTypes.h"
28
29 #include <emf-types.h>
30
31 #include <dpl/log/log.h>
32
33 using namespace std;
34 using namespace TizenApis::Api::Tizen;
35
36 namespace TizenApis {
37         namespace Platform {
38                 namespace Messaging {
39
40                 const std::string StorageChangesMessageGenerator::STRING_MATCH_EXCACTLY        = "EXACTLY";
41                 const std::string StorageChangesMessageGenerator::STRING_MATCH_CONTAINS        = "CONTAINS";
42                 const std::string StorageChangesMessageGenerator::STRING_MATCH_STARTSWITH      = "STARTSWITH";
43                 const std::string StorageChangesMessageGenerator::STRING_MATCH_ENDSWITH        = "ENDSWITH";
44 //              const std::string StorageChangesMessageGenerator::STRING_MATCH_CASESENSITIVE   = "CASESENSITIVE";
45
46                 const int StorageChangesMessageGenerator::MESSAGE_TYPE_NOT_INITIALIZED = -1;
47
48                 StorageChangesMessageGenerator::StorageChangesMessageGenerator(Api::Messaging::IMessagePtr msg):m_messageType(MESSAGE_TYPE_NOT_INITIALIZED) {
49
50                         m_type = msg->getMessageType();
51                         m_folder = msg->getCurrentFolder();
52                         m_dateTime = msg->getDateTime();
53                         m_from = msg->getFrom();
54
55                         Recipents = msg->getToRecipientsPtr();
56
57                         if(m_type == Api::Messaging::SMS)
58                         {
59                                 LogDebug("size :" << Recipents->getRecipientSize());
60                         
61                                 if(Recipents->getRecipientSize()>0)
62                                 {
63                                 m_to = Recipents->getRecipientsRef();
64                                         LogDebug("m_to :" << m_to[0]);                                          
65                                 }
66                         }
67                         else if(m_type == Api::Messaging::MMS)
68                         {
69                                 LogDebug("to size :" << Recipents->getRecipientSize());
70                         
71                                 Api::Messaging::IMmsPtr mms = DPL::DynamicPointerCast<Api::Messaging::IMms >(msg);
72                                 if(Recipents->getRecipientSize() > 0)
73                                 {
74                                         m_to = Recipents->getRecipientsRef();
75                                         LogDebug("m_to :" << m_to[0]);          
76                                 }
77
78                                 Recipents = mms->getCcRecipientsPtr();
79                                 LogDebug("cc size :" << Recipents->getRecipientSize());
80                                 
81                                 if(Recipents->getRecipientSize() > 0)
82                                 {
83                                         m_cc = Recipents->getRecipientsRef();
84                                 }
85
86                                 Recipents = mms->getBccRecipientsPtr();
87                                 LogDebug("bcc size :" << Recipents->getRecipientSize());
88                                 
89                                 if(Recipents->getRecipientSize() > 0)
90                                 {
91                                         m_bcc = Recipents->getRecipientsRef();
92                                 }
93                         }
94                         else if(m_type == Api::Messaging::EMAIL)
95                         {
96                                 LogDebug("to size :" << Recipents->getRecipientSize());
97                         
98                                 Api::Messaging::IEmailPtr email = DPL::DynamicPointerCast<Api::Messaging::IEmail >(msg);                        
99                                 if(Recipents->getRecipientSize() > 0)
100                                 {
101                                         m_to = Recipents->getRecipientsRef();
102                                         LogDebug("m_to :" << m_to[0]);          
103                                 }
104
105                                 Recipents = email->getCcRecipientsPtr();
106                                 LogDebug("cc size :" << Recipents->getRecipientSize());
107                                 
108                                 if(Recipents->getRecipientSize() > 0)
109                                 {
110                                         m_cc = Recipents->getRecipientsRef();
111                                 }
112
113                                 Recipents = email->getBccRecipientsPtr();
114                                 LogDebug("bcc size :" << Recipents->getRecipientSize());
115                                 
116                                 if(Recipents->getRecipientSize() > 0)
117                                 {
118                                         m_bcc = Recipents->getRecipientsRef();
119                                 }
120                                 
121                         }
122
123
124                         
125                         m_body = msg->getBody();
126                         m_isRead = msg->isRead();
127                         m_priority = msg->getPriority();
128                         m_subject = msg->getSubject();
129                         
130                         LogDebug("m_type:" << m_type );
131                         LogDebug("m_folder:" << m_folder );
132                         LogDebug("m_dateTime year:" << m_dateTime.tm_year + 1900 );
133                         LogDebug("m_dateTime mon:" << m_dateTime.tm_mon );
134                         LogDebug("m_dateTime day:" << m_dateTime.tm_mday );
135                         LogDebug("m_dateTime hour:" << m_dateTime.tm_hour );
136                         LogDebug("m_dateTime min:" << m_dateTime.tm_min );
137                         LogDebug("m_dateTime sec:" << m_dateTime.tm_sec );                      
138                         LogDebug("m_from:" << m_from );
139                         LogDebug("m_body:" << m_body );
140                         LogDebug("m_isRead:" << m_isRead );
141                         LogDebug("m_priority:" << m_priority );
142                         LogDebug("m_subject:" << m_subject );
143                         
144                 }
145
146                 StorageChangesMessageGenerator::~StorageChangesMessageGenerator() {
147                 }
148
149                 void StorageChangesMessageGenerator::visitPreComposite(Api::Tizen::FilterType& type, int depth){
150                         LogDebug("<<<");
151                         m_operand.push_back(leftblank);                                         
152                         LogDebug("Left_blank");                 
153                         LogDebug(">>>");
154                 }
155
156                 void StorageChangesMessageGenerator::visitInComposite(Api::Tizen::FilterType& type, int depth){
157                         LogDebug("<<<");
158                         if(type ==  UNION_FILTER ){
159                                 LogDebug("UNION_FILTER");
160                                 m_operand.push_back(operandUnion);                              
161                         }else if(type == INTERSECTION_FILTER){
162                                 LogDebug("INTERSECTION_FILTER");
163                                 m_operand.push_back(operandIntersection);                               
164                         }else{
165                                 LogError("[ERROR] invalid Filter type:" << type);
166                         }
167
168                         LogDebug(">>>");
169                 }
170
171                 void StorageChangesMessageGenerator::visitPostComposite(Api::Tizen::FilterType& type, int depth){
172                         LogDebug("<<<");
173                         bool data1, data2;
174                         do
175                         {
176                                 LogDebug("m_result size =" << m_result.size());
177                                 data1 = m_result.back();
178                                 m_result.pop_back();
179                                 data2 = m_result.back();
180                                 m_result.pop_back();
181                                 LogDebug("m_result size =" << m_result.size());                         
182                                 LogDebug("m_operand.back() =" << m_operand.back());     
183                                 LogDebug("m_operand size =" << m_operand.size());                                                               
184                                 if(m_operand.back() == operandUnion)
185                                 {
186                                         LogDebug("Union");                              
187                                         LogDebug("data1 = " << data1);
188                                         LogDebug("data2 = " << data2);
189                                         LogDebug("data1 || data2 = " << (data1 || data2));                                      
190                                         m_operand.pop_back();
191                                         m_result.push_back(data1 || data2);
192                                         LogDebug("result" << m_result.back());
193                                         LogDebug("m_result size =" << m_result.size());
194                                 }
195                                 else if(m_operand.back() == operandIntersection)
196                                 {
197                                         LogDebug("Intersection");                               
198                                         LogDebug("data1 = " << data1);
199                                         LogDebug("data2 = " << data2);
200                                         LogDebug("data1 && data2 = " << (data1 && data2));                                      
201                                         m_operand.pop_back();                           
202                                         m_result.push_back(data1 && data2);
203                                         LogDebug("result" << m_result.back());
204                                         LogDebug("m_result size =" << m_result.size());                                 
205                         
206                         }
207                         }while(m_operand.back() != leftblank);
208                         m_operand.pop_back();
209                         LogDebug("elase leftblank from m_operand");                     
210                         LogDebug("m_operand size =" << m_operand.size());                                                                                       
211                         LogDebug(">>>");
212                 }
213
214                 struct tm StorageChangesMessageGenerator::convertToTimeFormat(const std::string& timeString){
215                         LogDebug("<<< timeString:[" << timeString << "]");
216
217                         struct tm tm_Time;
218
219                         int nextStart = 0;
220
221                         int yearLength = 4;
222                         tm_Time.tm_year = atoi(timeString.substr(0, yearLength).c_str())-1900;
223                         nextStart = nextStart + yearLength;
224                         LogDebug("<<< tm_Time.tm_year:[" << tm_Time.tm_year << "]");
225
226                         int monthLength = 2;
227                         tm_Time.tm_mon = atoi(timeString.substr(nextStart, monthLength).c_str());
228                         nextStart = nextStart + monthLength;
229                         LogDebug("<<< initTime.tm_mon:[" << tm_Time.tm_mon << "]");
230
231                         int dateLength = 2;
232                         tm_Time.tm_mday = atoi(timeString.substr(nextStart, dateLength).c_str());
233                         nextStart = nextStart + dateLength;
234                         LogDebug("<<< initTime.tm_mday:[" << tm_Time.tm_mday << "]");
235
236                         int hourLength = 2;
237                         tm_Time.tm_hour = atoi(timeString.substr(nextStart, hourLength).c_str());
238                         nextStart = nextStart + hourLength;
239                         LogDebug("<<< initTime.tm_hour:[" << tm_Time.tm_hour << "]");
240
241                         int minuteLength = 2;
242                         tm_Time.tm_min = atoi(timeString.substr(nextStart, minuteLength).c_str());
243                         nextStart = nextStart + minuteLength;
244                         LogDebug("<<< initTime.tm_min:[" << tm_Time.tm_min << "]");
245
246                         int secondLength = 2;
247                         tm_Time.tm_sec = atoi(timeString.substr(nextStart, secondLength).c_str());
248                         LogDebug("<<< initTime.tm_sec:[" << tm_Time.tm_sec << "]");
249
250                         return tm_Time;
251                 }
252
253                 bool StorageChangesMessageGenerator::getMatchExactlyClause(std::string& attrName, Api::Tizen::AnyPtr& value)
254                 {
255                         std::string valueString = value->toString();
256                         LogDebug("<<< attrName : " << attrName);
257                         LogDebug("<<< valueString : " << valueString);
258                         LogDebug("<<< attrName.compare(valueString) : " << attrName.compare(valueString));
259                         
260                         if(attrName.compare(valueString) == 0)
261                         {
262                                 LogDebug("<<< getMatchExactlyClause SAME >>>");
263                                 return TRUE;                            
264                         }
265                         else{
266                                 LogDebug("<<< getMatchExactlyClause DIFF >>>");
267                                 return FALSE;                                                           
268                         }
269                         }
270
271                 bool StorageChangesMessageGenerator::getMatchContainsClause(std::string& attrName, Api::Tizen::AnyPtr& value)
272                 {
273                         std::string valueString = value->toString();
274                         LogDebug("<<< attrName : " << attrName);
275                         LogDebug("<<< valueString : " << valueString);
276                         LogDebug("<<< attrName.find(valueString) : " << attrName.find(valueString));
277                         
278                         if(attrName.find(valueString) != std::string::npos)
279                         {
280                                 LogDebug("<<< getMatchContainsClause CONTAINS >>>");
281                                 return TRUE;                            
282                         }else{
283                                 LogDebug("<<< getMatchContainsClause NOT CONTAINS >>>");
284                                 return FALSE;                                                           
285                         }
286                 }
287
288                 bool StorageChangesMessageGenerator::getMatchStartwithClause(std::string& attrName, Api::Tizen::AnyPtr& value)
289                 {
290                         std::string valueString = value->toString();
291                         LogDebug("<<< attrName : " << attrName);
292                         LogDebug("<<< valueString : " << valueString);
293                         LogDebug("<<< attrName.compare(0,valueString.size(), valueString) : " << attrName.compare(0,valueString.size(), valueString));
294
295                         
296                         if(attrName.size()-valueString.size() < 0)
297                                 return FALSE;
298                                 
299                         if(attrName.compare(0,valueString.size(), valueString) == 0)
300                         {
301                                 LogDebug("<<< getMatchStartwithClause START WITH >>>");
302                         return TRUE;
303                 }
304                         else{
305                                 LogDebug("<<< getMatchStartwithClause NOT START WITH >>>");
306                                 return FALSE;                                                           
307                         }
308                 }
309
310                 bool StorageChangesMessageGenerator::getMatchEndwithClause(std::string& attrName, Api::Tizen::AnyPtr& value)
311                 {
312                         std::string valueString = value->toString();
313
314                         LogDebug("<<< attrName : " << attrName);
315                         LogDebug("<<< valueString : " << valueString);
316                         LogDebug("<<< attrName.compare(attrName.size()-valueString.size(),valueString.size(), valueString) : " << attrName.compare(attrName.size()-valueString.size(),valueString.size(), valueString));
317
318
319                         if(attrName.size()-valueString.size() < 0)
320                                 return FALSE;
321                         
322                         if(attrName.compare(attrName.size()-valueString.size(),valueString.size(), valueString) == 0 )
323                         {
324                                 LogDebug("<<< getMatchEndwithClause END WITH >>>");
325                                 return TRUE;                            
326                         }
327                         else{
328                                 LogDebug("<<< getMatchEndwithClause NOT END WITH >>>");
329                                 return FALSE;                                                           
330                         }
331                 }
332                 
333                 bool StorageChangesMessageGenerator::getBetweenRangeClause(struct tm initialValue, struct tm endValue)
334                 {
335                         time_t init_time, mid_time, end_time;
336                         init_time = mktime(&initialValue);
337                         mid_time = mktime(&m_dateTime);
338                         end_time = mktime(&endValue);
339                         LogDebug("<<< mktime(initialValue):[" << init_time << "]");
340                         LogDebug("<<< mktime(m_dateTime):[" << mid_time << "]");
341                         LogDebug("<<< mktime(endValue):[" << end_time << "]");
342                         LogDebug("<<< mid_time - init_time:[" << mid_time - init_time << "]");
343                         LogDebug("<<< end_time - mid_time:[" << end_time - mid_time << "]");
344                         
345                         if(((mid_time - init_time) >= 0 ) && ((end_time - mid_time) >= 0 ))
346                                 return TRUE;
347                         else
348                                 return FALSE;
349                                 
350                 }
351
352                 void StorageChangesMessageGenerator::visitAttribute(std::string& attrName,
353                                 Api::Tizen::AnyArrayPtr& values, std::string& matchFlag, bool caseSensitive, int depth){
354                         LogDebug("<<< attrName:[" << attrName << "], matchFlag:[" << matchFlag << "]");
355                         LogDebug("values->size():" << values->size());
356
357                         Api::Tizen::FilterType filterType = UNION_FILTER;
358
359                         if(matchFlag.compare("EXIST")==0){
360                                 //TODO implement for EXIST
361                         }else if(values->size() == 1){
362                                 AnyPtr matchValue = values->at(0);
363                                 visitAttributeEach(attrName, matchValue, matchFlag, depth);
364                         }else{
365                                 visitPreComposite(filterType, depth);
366                         
367                                 AnyArray::iterator iter;
368                                 for(iter=values->begin(); iter!= values->end(); iter++){
369                         
370                                         if(iter != values->begin()){
371                         
372                                                 visitInComposite(filterType, depth);
373                                         }
374                         
375                                         AnyPtr matchValue = *iter;
376                                         visitAttributeEach(attrName, matchValue, matchFlag, depth);
377                                 }
378                         
379                                 visitPostComposite(filterType, depth);
380                         }
381                         LogDebug(">>>");
382                 }
383                 
384                 void StorageChangesMessageGenerator::visitAttributeEach(std::string& attrName, Api::Tizen::AnyPtr& value, std::string& matchFlag, int depth){
385                         LogDebug("<<< attrName:[" << attrName << "], value:[" << value->toString() << "]");
386                         std::string valueString;
387
388 //  Check msg_type and filter_type
389                         if(attrName.compare("type")==0){
390                                 LogDebug("<<< value:[" << value << "]");
391                                 m_currentType = value->toString();
392                                 m_messageType = convertMessageType(m_currentType);
393                                 if((int)m_type == m_messageType)
394                                 {
395                                         m_result.push_back(TRUE);
396                                         LogDebug("<<< Type is same");
397                                 }
398                                 else
399                                 {
400                                         m_result.push_back(FALSE);
401                                         LogDebug("<<< Type is different");
402                                 }
403                                 return;
404                                 }
405                         if(attrName.compare("folder")==0){
406                                 LogDebug("<<< value:[" << value << "]");
407                                 std::string convertType = value->toString();
408                                 int nType = convertFolderType(convertType);
409                                 if((int)m_folder == nType)
410                                 {
411                                         m_result.push_back(TRUE);
412                                         LogDebug("<<< folder is same");
413                                 }
414                                 else
415                                 {
416                                         m_result.push_back(FALSE);
417                                         LogDebug("<<< folder is different");
418                                 }
419                                 return;
420                         }
421                         if(attrName.compare("isRead")==0){
422                                 LogDebug("<<< value:[" << value << "]");
423                                 int nType = value->toString().compare("true");
424                                 if((int)m_isRead == nType)
425                                 {
426                                         m_result.push_back(TRUE);
427                                         LogDebug("<<< isRead is same");
428                                 }
429                                 else
430                                 {
431                                         m_result.push_back(FALSE);
432                                         LogDebug("<<< isRead is different");
433                                 }
434                                 return;
435                         }
436                         if(attrName.compare("priority")==0){
437                                 LogDebug("<<< value:[" << value->toString() << "]");
438                                 if(value->toString().compare("true") == 0)
439                                 {
440                                         if((int)m_priority == Api::Messaging::MessagePriority::Priority::HIGH)
441                                         {
442                                                 m_result.push_back(TRUE);
443                                                 LogDebug("<<< priority is HIGH");
444                                         }
445                                         else
446                                         {
447                                                 m_result.push_back(FALSE);
448                                                 LogDebug("<<< priority is LOW OR NORMAL");
449                                         }
450                                 }
451                                 else
452                                 {
453                                         if((int)m_priority == Api::Messaging::MessagePriority::Priority::HIGH)
454                                         {
455                                                 m_result.push_back(FALSE);
456                                                 LogDebug("<<< priority is HIGH");
457                                         }
458                                         else
459                                         {
460                                                 m_result.push_back(TRUE);
461                                                 LogDebug("<<< priority is LOW OR NORMAL");
462                                         }
463                                 }
464                                 return;
465                         }
466                         if(attrName.compare("body")==0){
467                                 LogDebug("<<< value:[" << value << "]");
468                                 LogDebug("<<< value->toString():[" << value->toString() << "]");
469                                 LogDebug("<<< m_body:[" << m_body << "]");
470
471                                 valueString = m_body;
472                                 if(getMatchFlagResult(value, valueString, matchFlag))
473                                 {
474                                         m_result.push_back(TRUE);
475                                         LogDebug("<<< body is same");
476                                 }
477                                 else
478                                 {
479                                         m_result.push_back(FALSE);
480                                         LogDebug("<<< body is different");
481                                 }
482                                 return;
483                         }
484
485                         if(attrName.compare("subject")==0){
486                                 LogDebug("<<< value:[" << value << "]");
487                                 LogDebug("<<< value->toString():[" << value->toString() << "]");
488                                 LogDebug("<<< m_subject:[" << m_subject << "]");
489
490                                 valueString = m_subject;
491                                 if(getMatchFlagResult(value, valueString, matchFlag))
492                                 {
493                                         m_result.push_back(TRUE);
494                                         LogDebug("<<< subject is same");
495                                 }
496                                 else
497                                 {
498                                         m_result.push_back(FALSE);
499                                         LogDebug("<<< subject is different");
500                                 }
501                                 return;
502                         }
503
504                         if(attrName.compare("from")==0){
505                                 LogDebug("<<< value:[" << value << "]");
506                                 LogDebug("<<< value->toString():[" << value->toString() << "]");
507                                 LogDebug("<<< m_from:[" << m_from << "]");
508
509                                 valueString = m_from;
510                                 if(getMatchFlagResult(value, valueString, matchFlag))
511                                 {
512                                         m_result.push_back(TRUE);
513                                         LogDebug("<<< from is same");
514                                 }
515                                 else
516                                 {
517                                         m_result.push_back(FALSE);
518                                         LogDebug("<<< from is different");
519                                 }
520                                 return;
521                         }
522
523                         if(attrName.compare("to")==0){
524                                 LogDebug("<<< value:[" << value << "]");
525                                 LogDebug("<<< value->toString():[" << value->toString() << "]");
526                                 LogDebug("<<< m_to.size :[" << m_to.size() << "]");
527
528                                 bool result = FALSE;
529                                 for(unsigned int i=0; i < m_to.size(); i++)
530                                 {
531                                         valueString = m_to[i];
532                                         result = result || getMatchFlagResult(value, valueString, matchFlag);
533                                 }
534                                 LogDebug("<<< to compare result is :" << result);
535                                 m_result.push_back(result);
536                                 return;
537                         }
538
539                         if(attrName.compare("cc")==0){
540                                 LogDebug("<<< value:[" << value << "]");
541                                 LogDebug("<<< value->toString():[" << value->toString() << "]");
542                                 LogDebug("<<< m_cc.size :[" << m_cc.size() << "]");
543
544                                 bool result = FALSE;
545                                 for(unsigned int i=0; i < m_cc.size(); i++)
546                                 {
547                                         valueString = m_cc[i];
548                                         result = result || getMatchFlagResult(value, valueString, matchFlag);
549                                 }
550                                 LogDebug("<<< cc compare result is : " << result);
551                                 m_result.push_back(result);
552                                 return;
553                         }
554
555                         if(attrName.compare("bcc")==0){
556                                 LogDebug("<<< value:[" << value << "]");
557                                 LogDebug("<<< value->toString():[" << value->toString() << "]");
558                                 LogDebug("<<< m_cc.size :[" << m_bcc.size() << "]");
559
560                                 bool result = FALSE;
561                                 for(unsigned int i=0; i < m_bcc.size(); i++)
562                                 {
563                                         valueString = m_bcc[i];
564                                         result = result || getMatchFlagResult(value, valueString, matchFlag);
565                                 }
566                                 LogDebug("<<< bcc compare result is : " << result);
567                                 m_result.push_back(result);
568                                 return;
569                         }
570
571                         LogDebug(">>>");
572                 }
573
574                 int StorageChangesMessageGenerator::convertMessageType(std::string& stringType){
575                         LogDebug("<<< stringType:[" << stringType << "]");
576
577                         int retMessageType = -1;
578
579                         if(stringType.compare("tizen.sms") ==0){
580                                 retMessageType = Api::Messaging::SMS;
581                         }else if(stringType.compare("tizen.mms") ==0){
582                                 retMessageType = Api::Messaging::MMS;
583                         }else if(stringType.compare("tizen.email") ==0){
584                                 retMessageType = Api::Messaging::EMAIL;
585                         }else{
586                                 LogError("invalid type:[" << stringType << "]");
587                                 return -1;
588                         }
589
590                         LogDebug(">>> retMessageType:" << retMessageType);
591                         return retMessageType;
592                 }
593
594                 int StorageChangesMessageGenerator::convertFolderType(std::string& stringType){
595                         LogDebug("<<< stringType:[" << stringType << "]");
596
597                         int retMessageType = -1;
598
599                         if(stringType.compare("INBOX") ==0){
600                                 retMessageType = Api::Messaging::INBOX;
601                         }else if(stringType.compare("OUTBOX") ==0){
602                                 retMessageType = Api::Messaging::OUTBOX;
603                         }else if(stringType.compare("DRAFTBOX") ==0){
604                                 retMessageType = Api::Messaging::DRAFTBOX;
605                         }else if(stringType.compare("SENTBOX") ==0){
606                                 retMessageType = Api::Messaging::SENTBOX;
607                         }else{
608                                 LogError("invalid type:[" << stringType << "]");
609                                 return -1;
610                         }
611
612                         LogDebug(">>> retMessageType:" << retMessageType);
613                         return retMessageType;
614                 }
615
616                 void StorageChangesMessageGenerator::visitAttributeRange(std::string& attrName, Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth) {
617                         struct tm startTime;
618                         struct tm endTime;
619                         bool result = FALSE;
620
621                         if(attrName.compare("timestamp")==0){
622                                 startTime = convertToTimeFormat(initialValue->toString());
623                                 endTime = convertToTimeFormat(endValue->toString());
624                                 result = getBetweenRangeClause(startTime, endTime);
625                                 if(result == TRUE)
626                                 {
627                                         LogDebug("<<< timestamp is in range");
628                                         m_result.push_back(TRUE);
629                                 }else{
630                                         LogDebug("<<< timestamp is out of range");
631                                         m_result.push_back(FALSE);
632                                 }
633                         }
634                 }
635
636                 bool StorageChangesMessageGenerator::getMatchFlagResult(Api::Tizen::AnyPtr& value, std::string& valueString, std::string& matchFlag)
637                 {
638                                 std::vector<std::string>::iterator iter;
639                         bool result = FALSE;
640                         if(matchFlag.compare(STRING_MATCH_EXCACTLY) == 0){
641                                 LogDebug("STRING_MATCH_EXCACTLY");
642                                 result = result || getMatchExactlyClause(valueString, value);
643                         }else if(matchFlag.compare(STRING_MATCH_CONTAINS) == 0){
644                                 LogDebug("STRING_MATCH_CONTAINS");
645                                 result = result || getMatchContainsClause(valueString, value);                                          
646                         }else if(matchFlag.compare(STRING_MATCH_STARTSWITH) == 0){
647                                 LogDebug("STRING_MATCH_STARTSWITH");
648                                 result = result || getMatchStartwithClause(valueString, value);
649                         }else if(matchFlag.compare(STRING_MATCH_ENDSWITH) == 0){
650                                 LogDebug("STRING_MATCH_ENDSWITH");
651                                 result = result || getMatchEndwithClause(valueString, value);                           
652                         }else{
653                                 LogDebug("[ERROR]invalid match flag : iter:" << *iter);
654                         }
655                         return result;
656                 }
657
658                 bool StorageChangesMessageGenerator::getCompareResult()
659                 {
660                         bool result;
661                         LogDebug("m_result.size() " << m_result.size());                                
662                         result = m_result.back();
663                         m_result.pop_back();
664                         LogDebug("result = " << result);        
665                         return result;
666                 }
667         }
668         }               //namespace Platform
669 }               //namespace WrtPlugins