wrt-plugins-tizen_0.4.23
[framework/web/wrt-plugins-tizen.git] / src / Calendar / CalendarFilter.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 260f6db..0f27ff5
 // limitations under the License.
 //
 
-
-#include <dpl/log/log.h>
 #include "CalendarFilter.h"
 #include <Commons/Exception.h>
-#include <calendar2.h>
-#include <map>
 #include <sstream>
-
 #include "CalendarUtility.h"
+#include <Logger.h>
 
 using namespace WrtDeviceApis::Commons;
 
@@ -141,7 +137,7 @@ CalendarFilter::CalendarFilter()
 
 CalendarFilter::~CalendarFilter()
 {
-    LogDebug("Clear internal structs for filters.");
+    LoggerD("Clear internal structs for filters.");
     if(m_query) {
         calendar_query_destroy(m_query);
     }
@@ -180,7 +176,7 @@ void CalendarFilter::visitPreComposite(DeviceAPI::Tizen::FilterType& type, int d
 
 void CalendarFilter::visitInComposite(DeviceAPI::Tizen::FilterType& type, int depth)
 {
-       LogDebug("Composite type: "<<type);
+       LoggerD("Composite type: "<<type);
        if(type == DeviceAPI::Tizen::UNION_FILTER) {
                calendar_filter_add_operator(m_filter, CALENDAR_FILTER_OPERATOR_OR);
                calendar_filter_add_operator(m_normalInstanceFilter, CALENDAR_FILTER_OPERATOR_OR);
@@ -199,11 +195,11 @@ void CalendarFilter::visitPostComposite(DeviceAPI::Tizen::FilterType& type, int
 void CalendarFilter::visitAttribute(std::string& attrName, DeviceAPI::Tizen::MatchFlag& matchFlag, DeviceAPI::Tizen::AnyPtr& matchValue, int depth)
 {
        if(NULL==matchValue) {
-        LogWarning("Empty match value.");
+        LoggerW("Empty match value.");
                return;
        }
 
-       LogDebug("attrName: "<<attrName<<", value string: "<<matchValue->toString()<<", matchFlag: "<<matchFlag<<", depth:"<<depth);
+       LoggerD("attrName: "<<attrName<<", value string: "<<matchValue->toString()<<", matchFlag: "<<matchFlag<<", depth:"<<depth);
 
     calendar_match_str_flag_e strMatchFlag = CALENDAR_MATCH_EXACTLY;
     calendar_match_int_flag_e intMatchFlag = CALENDAR_MATCH_EQUAL;
@@ -222,7 +218,7 @@ void CalendarFilter::visitAttribute(std::string& attrName, DeviceAPI::Tizen::Mat
        }else if( DeviceAPI::Tizen::MATCH_EXISTS==matchFlag) {
         strMatchFlag = CALENDAR_MATCH_EXISTS;
        } else {
-               LogWarning("Invalid matchFlag!");
+               LoggerW("Invalid matchFlag!");
        }
 
     if(CALENDAR_FILTER_ATTRIBUTE_VISIBILITY==attrName ||
@@ -247,7 +243,7 @@ void CalendarFilter::visitAttribute(std::string& attrName, DeviceAPI::Tizen::Mat
             calendar_filter_add_int(m_normalInstanceFilter, m_normalInstanceAttributeMap[attrName], intMatchFlag, value);
             calendar_filter_add_int(m_alldayInstanceFilter, m_alldayInstanceAttributeMap[attrName], intMatchFlag, value);
         }
-        LogDebug("Added int filter with value: "<<value);
+        LoggerD("Added int filter with value: "<<value);
     } else if(CALENDAR_FILTER_ATTRIBUTE_ID_UID==attrName ||
         CALENDAR_FILTER_ATTRIBUTE_ID==attrName) {
         int id;
@@ -269,7 +265,7 @@ void CalendarFilter::visitAttribute(std::string& attrName, DeviceAPI::Tizen::Mat
             calendar_filter_add_operator(m_alldayInstanceFilter, CALENDAR_FILTER_OPERATOR_OR);
             calendar_filter_add_int(m_alldayInstanceFilter, _calendar_instance_allday_calendar_book.original_event_id, CALENDAR_MATCH_EQUAL, id);
         }
-        LogDebug("Added int filter with id: "<<id);
+        LoggerD("Added int filter with id: "<<id);
     } else if(CALENDAR_FILTER_ATTRIBUTE_LAST_MODIFIED_DATE==attrName ||
         CALENDAR_FILTER_ATTRIBUTE_COMPLETED_DATE==attrName) {
                long long int time = getTimeTFromTZDateAny(matchValue);
@@ -280,7 +276,7 @@ void CalendarFilter::visitAttribute(std::string& attrName, DeviceAPI::Tizen::Mat
             calendar_filter_add_lli(m_normalInstanceFilter, m_normalInstanceAttributeMap[attrName], intMatchFlag, time);
             calendar_filter_add_lli(m_alldayInstanceFilter, m_alldayInstanceAttributeMap[attrName], intMatchFlag, time);
         }
-        LogDebug("Added lli filter with value: "<<time);
+        LoggerD("Added lli filter with value: "<<time);
     } else if(CALENDAR_FILTER_ATTRIBUTE_DESCRIPTION==attrName ||
         CALENDAR_FILTER_ATTRIBUTE_SUMMARY==attrName ||
         CALENDAR_FILTER_ATTRIBUTE_LOCATION==attrName ||
@@ -292,7 +288,7 @@ void CalendarFilter::visitAttribute(std::string& attrName, DeviceAPI::Tizen::Mat
             calendar_filter_add_str(m_normalInstanceFilter, m_normalInstanceAttributeMap[attrName], strMatchFlag, matchValue->getString().c_str());
                calendar_filter_add_str(m_alldayInstanceFilter, m_alldayInstanceAttributeMap[attrName], strMatchFlag, matchValue->getString().c_str());
         }
-        LogDebug("Added str filter with value: "<<matchValue->getString());
+        LoggerD("Added str filter with value: "<<matchValue->getString());
     } else if(CALENDAR_FILTER_ATTRIBUTE_IS_ALL_DAY==attrName) {
         if(CalendarEvent::TASK_TYPE==m_type) {
             calendar_filter_add_int(m_filter, m_taskAttributeMap[attrName], CALENDAR_MATCH_EQUAL, matchValue->getBool() ? 1 : 0);
@@ -306,7 +302,7 @@ void CalendarFilter::visitAttribute(std::string& attrName, DeviceAPI::Tizen::Mat
                    calendar_filter_add_int(m_alldayInstanceFilter, m_alldayInstanceAttributeMap[CALENDAR_FILTER_ATTRIBUTE_ID_UID], CALENDAR_MATCH_EQUAL, -999);
                        }
         }
-        LogDebug("Added int filter with value: "<<matchValue->getBool());
+        LoggerD("Added int filter with value: "<<matchValue->getBool());
     } else if(CALENDAR_FILTER_ATTRIBUTE_START_DATE==attrName ||
         CALENDAR_FILTER_ATTRIBUTE_DUE_DATE==attrName ||
         CALENDAR_FILTER_ATTRIBUTE_END_DATE==attrName) {
@@ -320,7 +316,7 @@ void CalendarFilter::visitAttribute(std::string& attrName, DeviceAPI::Tizen::Mat
             calendar_filter_add_caltime(m_normalInstanceFilter, m_normalInstanceAttributeMap[attrName], intMatchFlag, calTime);
             calendar_filter_add_caltime(m_alldayInstanceFilter, m_alldayInstanceAttributeMap[attrName], intMatchFlag, calTime);
         }
-        LogDebug("Added caltime filter with value: "<<time);
+        LoggerD("Added caltime filter with value: "<<time);
     } else if(CALENDAR_FILTER_ATTRIBUTE_LATITUDE==attrName ||
         CALENDAR_FILTER_ATTRIBUTE_LONGITUDE==attrName) {
         if(CalendarEvent::TASK_TYPE==m_type) {
@@ -330,7 +326,7 @@ void CalendarFilter::visitAttribute(std::string& attrName, DeviceAPI::Tizen::Mat
             calendar_filter_add_double(m_normalInstanceFilter, m_normalInstanceAttributeMap[attrName], intMatchFlag, matchValue->getDouble());
             calendar_filter_add_double(m_alldayInstanceFilter, m_alldayInstanceAttributeMap[attrName], intMatchFlag, matchValue->getDouble());
         }
-        LogDebug("Added double filter with value: "<<matchValue->getDouble());
+        LoggerD("Added double filter with value: "<<matchValue->getDouble());
     } else if(CALENDAR_FILTER_ATTRIBUTE_ALARMS==attrName ||
         CALENDAR_FILTER_ATTRIBUTE_ATTENDEES==attrName) {
         if(CalendarEvent::TASK_TYPE==m_type) {
@@ -361,7 +357,7 @@ void CalendarFilter::visitAttribute(std::string& attrName, DeviceAPI::Tizen::Mat
                    calendar_filter_add_int(m_alldayInstanceFilter, m_normalInstanceAttributeMap[attrName], CALENDAR_MATCH_EQUAL, 1);
                        }
         }
-        LogDebug("Added int filter.");
+        LoggerD("Added int filter.");
     } else if(CALENDAR_FILTER_ATTRIBUTE_CATEGORIES==attrName) {
         if(CalendarEvent::TASK_TYPE==m_type) {
             calendar_filter_add_str(m_filter, m_taskAttributeMap[attrName], CALENDAR_MATCH_CONTAINS, matchValue->getString().c_str());
@@ -370,19 +366,19 @@ void CalendarFilter::visitAttribute(std::string& attrName, DeviceAPI::Tizen::Mat
             calendar_filter_add_str(m_normalInstanceFilter, m_normalInstanceAttributeMap[attrName], CALENDAR_MATCH_CONTAINS, matchValue->getString().c_str());
             calendar_filter_add_str(m_alldayInstanceFilter, m_alldayInstanceAttributeMap[attrName], CALENDAR_MATCH_CONTAINS, matchValue->getString().c_str());
         }
-        LogDebug("Added str filter for categories with value: "<<matchValue->getString());
+        LoggerD("Added str filter for categories with value: "<<matchValue->getString());
     } else if(CALENDAR_FILTER_ATTRIBUTE_IS_DETACHED==attrName) {
         if(CalendarEvent::TASK_TYPE==m_type) {
-            LogWarning("isDetached not supported for a task.");
+            LoggerW("isDetached not supported for a task.");
         } else {
             calendar_filter_add_int(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN, 0);
             calendar_filter_add_int(m_normalInstanceFilter, m_normalInstanceAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN, 0);
             calendar_filter_add_int(m_alldayInstanceFilter, m_alldayInstanceAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN, 0);
         }
-        LogDebug("Added int filter for isDetached with value 0.");
+        LoggerD("Added int filter for isDetached with value 0.");
     } else if(CALENDAR_FILTER_ATTRIBUTE_RECURRENCE_RULE==attrName) {
         if(CalendarEvent::TASK_TYPE==m_type) {
-            LogWarning("rrule not supported for a task.");
+            LoggerW("rrule not supported for a task.");
         } else {
                        if( DeviceAPI::Tizen::MATCH_EXACTLY==matchFlag ) {
                                if( matchValue->isNullOrUndefined() ) {
@@ -394,29 +390,29 @@ void CalendarFilter::visitAttribute(std::string& attrName, DeviceAPI::Tizen::Mat
                        calendar_filter_add_int(m_normalInstanceFilter, m_normalInstanceAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN, 0);
                        calendar_filter_add_int(m_alldayInstanceFilter, m_alldayInstanceAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN, 0);
                        }
-                       LogDebug("Added int filter for rrule EXACTLY flag.");
+                       LoggerD("Added int filter for rrule EXACTLY flag.");
                        } else {
                    calendar_filter_add_int(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN, 0);
                        calendar_filter_add_int(m_normalInstanceFilter, m_normalInstanceAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN, 0);
                        calendar_filter_add_int(m_alldayInstanceFilter, m_alldayInstanceAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN, 0);
-                       LogDebug("Added int filter for rrule.");
+                       LoggerD("Added int filter for rrule.");
                        }
         }
     } else {
-        LogWarning("Not supported filter attribute: "<<attrName);
+        LoggerW("Not supported filter attribute: "<<attrName);
     }
 
-       LogDebug("Attribute visit done.");
+       LoggerD("Attribute visit done.");
 }
 
 void CalendarFilter::visitAttributeRange(std::string& attrName, DeviceAPI::Tizen::AnyPtr& initialValue, DeviceAPI::Tizen::AnyPtr& endValue, int depth)
 {
        if(initialValue == NULL && endValue == NULL) {
-        LogWarning("Both initial/end values are empty.");
+        LoggerW("Both initial/end values are empty.");
                return;
        }
 
-    LogDebug("attrName: " <<attrName<<", initialValue: "<<initialValue->toString()<<", endValue: " <<endValue->toString()<<", depth: "<<depth);
+    LoggerD("attrName: " <<attrName<<", initialValue: "<<initialValue->toString()<<", endValue: " <<endValue->toString()<<", depth: "<<depth);
 
     if(CALENDAR_FILTER_ATTRIBUTE_START_DATE==attrName ||
         CALENDAR_FILTER_ATTRIBUTE_DUE_DATE==attrName ||
@@ -498,7 +494,7 @@ void CalendarFilter::visitAttributeRange(std::string& attrName, DeviceAPI::Tizen
 
                        calendar_filter_add_filter(m_filter, subFilter);
 
-                       LogDebug("Query for normal instances.");
+                       LoggerD("Query for normal instances.");
                        calendar_filter_h subFilterNormal = NULL;
                        calendar_filter_create(_calendar_instance_normal_calendar_book._uri, &subFilterNormal);
 
@@ -513,7 +509,7 @@ void CalendarFilter::visitAttributeRange(std::string& attrName, DeviceAPI::Tizen
             }
                        calendar_filter_add_filter(m_normalInstanceFilter, subFilterNormal);
 
-                       LogDebug("Query for allday instances.");
+                       LoggerD("Query for allday instances.");
                        calendar_filter_h subFilterAllday = NULL;
                        calendar_filter_create(_calendar_instance_allday_calendar_book._uri, &subFilterAllday);
 
@@ -528,10 +524,10 @@ void CalendarFilter::visitAttributeRange(std::string& attrName, DeviceAPI::Tizen
             }
                        calendar_filter_add_filter(m_alldayInstanceFilter, subFilterAllday);
 
-                       LogDebug("Enable the instance table search.");
+                       LoggerD("Enable the instance table search.");
                        m_enableInstanceSearch = true;
         }
-        LogDebug("Added caltime range filter with initial value: "<<startTime.time.utime<<", end value: "<<endTime.time.utime);
+        LoggerD("Added caltime range filter with initial value: "<<startTime.time.utime<<", end value: "<<endTime.time.utime);
     } else if(CALENDAR_FILTER_ATTRIBUTE_LATITUDE==attrName ||
         CALENDAR_FILTER_ATTRIBUTE_LONGITUDE==attrName) {
         if(CalendarEvent::TASK_TYPE==m_type) {
@@ -561,7 +557,7 @@ void CalendarFilter::visitAttributeRange(std::string& attrName, DeviceAPI::Tizen
                 calendar_filter_add_double(m_alldayInstanceFilter, m_alldayInstanceAttributeMap[attrName], CALENDAR_MATCH_LESS_THAN_OR_EQUAL, endValue->getDouble());
             }
         }
-        LogDebug("Added double range filter with initial value: "<<initialValue->getDouble()<<", end value: "<<endValue->getDouble());
+        LoggerD("Added double range filter with initial value: "<<initialValue->getDouble()<<", end value: "<<endValue->getDouble());
     } else if(CALENDAR_FILTER_ATTRIBUTE_COMPLETED_DATE==attrName ||
         CALENDAR_FILTER_ATTRIBUTE_LAST_MODIFIED_DATE==attrName) {
         if(CalendarEvent::TASK_TYPE==m_type) {
@@ -591,7 +587,7 @@ void CalendarFilter::visitAttributeRange(std::string& attrName, DeviceAPI::Tizen
                 calendar_filter_add_lli(m_alldayInstanceFilter, m_alldayInstanceAttributeMap[attrName], CALENDAR_MATCH_LESS_THAN_OR_EQUAL, getTimeTFromTZDateAny(endValue));
             }
         }
-        LogDebug("Added lli range filter with initial value: "<<getTimeTFromTZDateAny(initialValue)<<", end value: "<<getTimeTFromTZDateAny(endValue));
+        LoggerD("Added lli range filter with initial value: "<<getTimeTFromTZDateAny(initialValue)<<", end value: "<<getTimeTFromTZDateAny(endValue));
     } else if(CALENDAR_FILTER_ATTRIBUTE_PROGRESS==attrName) {
         if(CalendarEvent::TASK_TYPE==m_type) {
             if (!initialValue->isNullOrUndefined()) {
@@ -604,14 +600,14 @@ void CalendarFilter::visitAttributeRange(std::string& attrName, DeviceAPI::Tizen
                 calendar_filter_add_int(m_filter, m_taskAttributeMap[attrName], CALENDAR_MATCH_LESS_THAN_OR_EQUAL, endValue->getLong());
             }
         } else {
-                       LogWarning("progress not supported for an event");
+                       LoggerW("progress not supported for an event");
         }
-        LogDebug("Added double range filter with initial value: "<<initialValue->getLong()<<", end value: "<<endValue->getLong());
+        LoggerD("Added double range filter with initial value: "<<initialValue->getLong()<<", end value: "<<endValue->getLong());
     } else {
-        LogWarning("Not supported filter attribute: "<<attrName);
+        LoggerW("Not supported filter attribute: "<<attrName);
     }
 
-    LogDebug("Attribute range visit done.");
+    LoggerD("Attribute range visit done.");
 }
 
 void CalendarFilter::setType(CalendarEvent::CalendarType type)
@@ -692,7 +688,7 @@ void CalendarFilter::setSortMode(DeviceAPI::Tizen::SortModeArrayPtr attr)
     // The first sort mode only.
        attrName = (*it)->getAttributeName();
        if (attrName.compare("") != 0) {
-        LogDebug("Setting the sort mode with attrName: "<<attrName);
+        LoggerD("Setting the sort mode with attrName: "<<attrName);
                if ((*it)->getOrder()==DeviceAPI::Tizen::ASCENDING_SORT_ORDER) {
             if(CalendarEvent::TASK_TYPE==m_type) {
                        calendar_query_set_sort(m_query, m_taskAttributeMap[attrName], true);
@@ -711,7 +707,7 @@ void CalendarFilter::setSortMode(DeviceAPI::Tizen::SortModeArrayPtr attr)
             }
                }
        } else {
-           LogWarning("Empty attribute name.");
+           LoggerW("Empty attribute name.");
        }
 }
 
@@ -732,11 +728,11 @@ void CalendarFilter::executeQuery()
     if( CALENDAR_ERROR_NONE!=ret ) {
         ThrowMsg(PlatformException, "Can't get the item count: "<<ret);
     } else {
-        LogDebug("Item count: "<<m_recordCount);
+        LoggerD("Item count: "<<m_recordCount);
     }
 
        if(m_enableInstanceSearch) {
-               LogDebug("Perform query for instances.");
+               LoggerD("Perform query for instances.");
            ret = calendar_query_set_filter(m_normalInstanceQuery, m_normalInstanceFilter);
            if( CALENDAR_ERROR_NONE!=ret ) {
                ThrowMsg(PlatformException, "Setting a normal instance filter failed: "<<ret);
@@ -749,7 +745,7 @@ void CalendarFilter::executeQuery()
            if( CALENDAR_ERROR_NONE!=ret ) {
                ThrowMsg(PlatformException, "Can't get a normal instance item count: "<<ret);
            } else {
-               LogDebug("Normal instance item count: "<<m_normalInstanceRecordCount);
+               LoggerD("Normal instance item count: "<<m_normalInstanceRecordCount);
            }
 
            ret = calendar_query_set_filter(m_alldayInstanceQuery, m_alldayInstanceFilter);
@@ -764,10 +760,10 @@ void CalendarFilter::executeQuery()
            if( CALENDAR_ERROR_NONE!=ret ) {
                ThrowMsg(PlatformException, "Can't get an allday instance item count: "<<ret);
            } else {
-               LogDebug("Allday instance item count: "<<m_alldayInstanceRecordCount);
+               LoggerD("Allday instance item count: "<<m_alldayInstanceRecordCount);
            }
        } else {
-               LogDebug("No need to perform query for instances.");
+               LoggerD("No need to perform query for instances.");
        }
 }
 
@@ -803,7 +799,7 @@ calendar_list_h CalendarFilter::getAlldayInstanceResultRecordList() const
 
 int CalendarFilter::convertStringToIntValue(const std::string attrName, const std::string valueString)
 {
-       LogDebug("attrName: "<<attrName<<", valueString: "<<valueString);
+       LoggerD("attrName: "<<attrName<<", valueString: "<<valueString);
 
     if(attrName==CALENDAR_FILTER_ATTRIBUTE_VISIBILITY)
     {
@@ -814,7 +810,7 @@ int CalendarFilter::convertStringToIntValue(const std::string attrName, const st
         } else if(valueString=="CONFIDENTIAL") {
             return CALENDAR_SENSITIVITY_CONFIDENTIAL;
         } else {
-            LogWarning("Wrong visibility value.");
+            LoggerW("Wrong visibility value.");
         }
     }
     else if(attrName==CALENDAR_FILTER_ATTRIBUTE_STATUS)
@@ -832,7 +828,7 @@ int CalendarFilter::convertStringToIntValue(const std::string attrName, const st
         } else if(valueString=="COMPLETED") {
             return CALENDAR_TODO_STATUS_COMPLETED;
         } else {
-            LogWarning("Wrong status value.");
+            LoggerW("Wrong status value.");
         }
     }
     else if(attrName==CALENDAR_FILTER_ATTRIBUTE_PRIORITY)
@@ -844,7 +840,7 @@ int CalendarFilter::convertStringToIntValue(const std::string attrName, const st
         } else if(valueString=="LOW") {
             return CALENDAR_EVENT_PRIORITY_LOW;
         } else {
-            LogWarning("Wrong priority value.");
+            LoggerW("Wrong priority value.");
         }
     }
     else if(attrName==CALENDAR_FILTER_ATTRIBUTE_AVAILABILITY)
@@ -854,10 +850,10 @@ int CalendarFilter::convertStringToIntValue(const std::string attrName, const st
         } else if(valueString=="FREE") {
             return CALENDAR_EVENT_BUSY_STATUS_FREE;
         } else {
-            LogWarning("Wrong availability value.");
+            LoggerW("Wrong availability value.");
         }
     } else {
-        LogWarning("Invalid attrName");
+        LoggerW("Invalid attrName");
     }
 
     return -1;