}\r
\r
}\r
- else if (type == NS_PROVIDER_CACHE_MESSAGE)\r
- {\r
- NS_LOG(DEBUG, "Type is MESSAGE");\r
-\r
- NSCacheMsgData * msgData = (NSCacheMsgData *) newObj->data;\r
- NSCacheElement * it = NSStorageRead(list, msgData->id);\r
-\r
- if (it)\r
- {\r
- NSCacheMsgData * itData = (NSCacheMsgData *) it->data;\r
-\r
- if (strcmp(itData->id, msgData->id) == 0)\r
- {\r
-\r
- itData->messageType = msgData->messageType;\r
- NS_LOG(DEBUG, "Updated messageType");\r
- pthread_mutex_unlock(&NSCacheMutex);\r
- return NS_OK;\r
-\r
- }\r
- }\r
- }\r
\r
if (list->head == NULL)\r
{\r
return NS_OK;\r
}\r
\r
-NSResult NSStorageDelete(NSCacheList * list, const char * delId)\r
-{\r
- pthread_mutex_lock(&NSCacheMutex);\r
- NSCacheElement * prev = list->head;\r
- NSCacheElement * del = list->head;\r
-\r
- NSCacheType type = list->cacheType;\r
-\r
- if (NSProviderCompareIdCacheData(type, del->data, delId))\r
- {\r
- if (del == list->head) // first object\r
- {\r
- if (del == list->tail) // first object (one object)\r
- {\r
- list->tail = del->next;\r
- }\r
-\r
- list->head = del->next;\r
-\r
- NSProviderDeleteCacheData(type, del->data);\r
- OICFree(del);\r
- pthread_mutex_unlock(&NSCacheMutex);\r
- return NS_OK;\r
- }\r
- }\r
-\r
- del = del->next;\r
- while (del)\r
- {\r
- if (NSProviderCompareIdCacheData(type, del->data, delId))\r
- {\r
- if (del == list->tail) // delete object same to last object\r
- {\r
- list->tail = prev;\r
- }\r
-\r
- prev->next = del->next;\r
- NSProviderDeleteCacheData(type, del->data);\r
- OICFree(del);\r
- pthread_mutex_unlock(&NSCacheMutex);\r
- return NS_OK;\r
- }\r
-\r
- prev = del;\r
- del = del->next;\r
- }\r
- pthread_mutex_unlock(&NSCacheMutex);\r
- return NS_OK;\r
-}\r
-\r
NSResult NSStorageDestroy(NSCacheList * list)\r
{\r
NSCacheElement * iter = list->head;\r
return false;\r
\r
}\r
- else if (type == NS_PROVIDER_CACHE_MESSAGE)\r
- {\r
- NSCacheMsgData * msgData = (NSCacheMsgData *) data;\r
-\r
- if (strcmp(msgData->id, id) == 0)\r
- {\r
- NS_LOG(DEBUG, "Message Data is Same");\r
- return true;\r
- }\r
-\r
- NS_LOG(DEBUG, "Message Data is Not Same");\r
- return false;\r
- }\r
\r
NS_LOG(DEBUG, "NSProviderCompareIdCacheData - OUT");\r
\r
\r
return NS_OK;\r
}\r
- else if (type == NS_PROVIDER_CACHE_MESSAGE)\r
- {\r
- NSCacheMsgData * msgData = (NSCacheMsgData *) data;\r
-\r
- if (msgData->id)\r
- {\r
- OICFree(msgData->id);\r
- msgData->id = NULL;\r
- }\r
-\r
- if (msgData->nsMessage)\r
- {\r
- NSFreeMessage(msgData->nsMessage);\r
- }\r
-\r
- OICFree(msgData);\r
-\r
- return NS_OK;\r
- }\r
\r
return NS_OK;\r
}\r