Sync with tizen 2.4
[platform/core/messaging/msg-service.git] / framework / transaction-manager / MsgCmdHandlerFilter.cpp
index 7034931..63198f1 100755 (executable)
@@ -1,17 +1,17 @@
 /*
-* Copyright 2012  Samsung Electronics Co., Ltd
-*
-* Licensed under the Flora License, Version 1.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*    http://www.tizenopensource.org/license
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
 */
 
 #include "MsgDebug.h"
@@ -111,6 +111,40 @@ int MsgDeleteFilterHandler(const MSG_CMD_S *pCmd, char **ppEvent)
 }
 
 
+int MsgSetFilterActivationHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       msg_error_t err = MSG_SUCCESS;
+
+       int eventSize = 0;
+
+       // Get Filter Structure
+       msg_filter_id_t  *pFilterId = (msg_filter_id_t *)pCmd->cmdData;
+
+       bool setFlag = false;
+
+       memcpy(&setFlag, pCmd->cmdData+sizeof(msg_filter_id_t), sizeof(bool));
+
+       MSG_DEBUG("Filter id : %d", *pFilterId);
+
+       // Delete Filter
+       err = MsgStoSetFilterActivation(*pFilterId, setFlag);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoSetFilterActivation()");
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoSetFilterActivation()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_SET_FILTER_ACTIVATION, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
 int MsgGetFilterListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
 {
        msg_error_t err = MSG_SUCCESS;
@@ -132,7 +166,15 @@ int MsgGetFilterListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
                // Encoding Filter List Data
                dataSize = MsgEncodeFilterList(&filterList, &encodedData);
 
-               delete [] filterList.msg_struct_info;
+               if (filterList.msg_struct_info) {
+                       msg_struct_s *msg_struct;
+                       for (int i = 0; i < filterList.nCount; i++) {
+                               msg_struct = (msg_struct_s *)filterList.msg_struct_info[i];
+                               delete (MSG_FILTER_S *)msg_struct->data;
+                               delete msg_struct;
+                       }
+                       g_free(filterList.msg_struct_info);
+               }
        }
        else
        {