From 89c5b2369413025e1fe7dfe5c5d0bf3bedd8558d Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Mon, 23 Jul 2012 13:52:57 +0000 Subject: git-svn-id: http://svn.miranda-ng.org/main/trunk@1123 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/IMO2sProxy/src/imo2skype/buddylist.c | 204 --------------------------- 1 file changed, 204 deletions(-) delete mode 100644 plugins/IMO2sProxy/src/imo2skype/buddylist.c (limited to 'plugins/IMO2sProxy/src/imo2skype/buddylist.c') diff --git a/plugins/IMO2sProxy/src/imo2skype/buddylist.c b/plugins/IMO2sProxy/src/imo2skype/buddylist.c deleted file mode 100644 index 6d228ae4b9..0000000000 --- a/plugins/IMO2sProxy/src/imo2skype/buddylist.c +++ /dev/null @@ -1,204 +0,0 @@ -/* Module: buddylist.c - Purpose: Manages your list of buddies in memory - Author: leecher - Date: 30.08.2009 -*/ - -#include -#include -#include -#include "memlist.h" -#include "buddylist.h" - -static void SetEntry(NICKENTRY *pEntry, cJSON *pNick); - -// ----------------------------------------------------------------------------- -// Interface -// ----------------------------------------------------------------------------- - -TYP_LIST *BuddyList_Init(void) -{ - TYP_LIST *hList = List_Init(16); - - return hList; -} - -// ----------------------------------------------------------------------------- - -void BuddyList_Exit(TYP_LIST *hList) -{ - NICKENTRY *pEntry; - - while (pEntry=(NICKENTRY*)List_Pop(hList)) - { - BuddyList_FreeEntry(pEntry, TRUE); - free (pEntry); - } - List_Exit(hList); -} - -// ----------------------------------------------------------------------------- - -BOOL BuddyList_Insert(TYP_LIST *hList, cJSON *pNick) -{ - NICKENTRY *pEntry; - cJSON *pElem; - - if (pEntry=BuddyList_Find (hList, cJSON_GetObjectItem(pNick, "buid")->valuestring)) - BuddyList_FreeEntry (pEntry, FALSE); - else - { - if (!(pEntry = calloc (1, sizeof(NICKENTRY)))) return FALSE; - if ((pElem=cJSON_GetObjectItem(pNick, "group")) && strcmp(pElem->valuestring, "Skype")) - { - char szBUID[256]; - NICKENTRY *pGroup; - - // Buddy Belongs to a chatgroup - sprintf (szBUID, "%s;", pElem->valuestring); - pGroup = BuddyList_Find (hList, szBUID); - - if (pGroup) // Group not yet created? Shouldn't be the case - { - if (!pGroup->hGCMembers) pGroup->hGCMembers=List_Init(1); - hList = pGroup->hGCMembers; - pEntry->pGroup = pGroup; - } - } - if (!List_Push(hList, pEntry)) return FALSE; - } - SetEntry(pEntry, pNick); - pEntry->iBuddyStatus = 3; - return TRUE; -} - -// ----------------------------------------------------------------------------- - -BOOL BuddyList_AddTemporaryUser(TYP_LIST *hList, char *pszUser) -{ - NICKENTRY *pEntry; - - if (BuddyList_Find (hList, pszUser)) return TRUE; - if (!(pEntry = calloc (1, sizeof(NICKENTRY)))) return FALSE; - pEntry->pszUser = strdup(pszUser); - pEntry->pszAlias = strdup(pszUser); - strcpy (pEntry->szStatus, "OFFLINE"); - pEntry->iBuddyStatus = 2; - return List_Push(hList, pEntry); -} - -// ----------------------------------------------------------------------------- - -BOOL BuddyList_Remove(TYP_LIST *hList, NICKENTRY *pEntry) -{ - NICKENTRY *pListEntry; - int i, nCount; - - if (pEntry->pGroup) hList=pEntry->pGroup->hGCMembers; - for (i=0, nCount=List_Count(hList); ipszUser, pszUser) == 0) - return pEntry; - else if (pEntry->hGCMembers) - { - if (pEntry = BuddyList_Find(pEntry->hGCMembers, pszUser)) - return pEntry; - } - } - return NULL; -} - -// ----------------------------------------------------------------------------- - -BOOL BuddyList_SetStatus(TYP_LIST *hList, cJSON *pNick) -{ - NICKENTRY *pEntry; - - if ((pEntry = BuddyList_Find(hList, cJSON_GetObjectItem(pNick, "buid")->valuestring))) - { - BuddyList_FreeEntry(pEntry, FALSE); - SetEntry(pEntry, pNick); - return TRUE; - } - return FALSE; -} - -// ----------------------------------------------------------------------------- - -void BuddyList_FreeEntry(NICKENTRY *pEntry, BOOL bFreeGC) -{ - if (pEntry->pszAlias) - { - free (pEntry->pszAlias); - pEntry->pszAlias = NULL; - } - if (pEntry->pszUser) - { - free (pEntry->pszUser); - pEntry->pszUser = NULL; - } - if (pEntry->pszStatusText) - { - free(pEntry->pszStatusText); - pEntry->pszStatusText = NULL; - } - if (pEntry->pszDisplay) - { - free(pEntry->pszDisplay); - pEntry->pszDisplay = NULL; - } - if (bFreeGC && pEntry->hGCMembers) - { - NICKENTRY *pNick; - - while (pNick=(NICKENTRY*)List_Pop(pEntry->hGCMembers)) - { - BuddyList_FreeEntry(pNick, bFreeGC); - free (pNick); - } - List_Exit (pEntry->hGCMembers); - pEntry->hGCMembers = NULL; - } -} - -// ----------------------------------------------------------------------------- -// Static -// ----------------------------------------------------------------------------- - -static void SetEntry(NICKENTRY *pEntry, cJSON *pNick) -{ - cJSON *obj; - - if ((obj=cJSON_GetObjectItem(pNick, "alias")) && obj->valuestring) - pEntry->pszAlias = strdup(obj->valuestring); - pEntry->pszUser = strdup(cJSON_GetObjectItem(pNick, "buid")->valuestring); - if ((obj=cJSON_GetObjectItem(pNick, "status")) && obj->valuestring) - pEntry->pszStatusText = strdup(obj->valuestring); - if ((obj=cJSON_GetObjectItem(pNick, "primitive")) && obj->valuestring) - strcpy (pEntry->szStatus, obj->valuestring); - if ((obj=cJSON_GetObjectItem(pNick, "display")) && obj->valuestring) - pEntry->pszDisplay = strdup(obj->valuestring); -} -- cgit v1.2.3