diff options
author | Vadim Dashevskiy <watcherhd@gmail.com> | 2012-07-28 19:25:08 +0000 |
---|---|---|
committer | Vadim Dashevskiy <watcherhd@gmail.com> | 2012-07-28 19:25:08 +0000 |
commit | 66526765714b08969548a414d3fa87dbe333242d (patch) | |
tree | d3fc2027140f97edfdfc5023e70ff8b4db920c11 /plugins/!NotAdopted/IMO2sProxy/src/imo2skype/avatarlist.c | |
parent | 3ccd712341ed9e76252bd595c5a797d6c8ea8992 (diff) |
"!Deprecated" folders moved from root directory to plugins
git-svn-id: http://svn.miranda-ng.org/main/trunk@1230 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/!NotAdopted/IMO2sProxy/src/imo2skype/avatarlist.c')
-rw-r--r-- | plugins/!NotAdopted/IMO2sProxy/src/imo2skype/avatarlist.c | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/plugins/!NotAdopted/IMO2sProxy/src/imo2skype/avatarlist.c b/plugins/!NotAdopted/IMO2sProxy/src/imo2skype/avatarlist.c new file mode 100644 index 0000000000..f1c78f0567 --- /dev/null +++ b/plugins/!NotAdopted/IMO2sProxy/src/imo2skype/avatarlist.c @@ -0,0 +1,110 @@ +/* Module: avatarlist.c
+ Purpose: Manages the avatars of your buddies
+ Author: leecher
+ Date: 18.08.2011
+*/
+
+#include <stdlib.h>
+#include <string.h>
+#include "memlist.h"
+#include "avatarlist.h"
+
+static void SetEntry(AVATARENTRY *pEntry, cJSON *pNick);
+
+// -----------------------------------------------------------------------------
+// Interface
+// -----------------------------------------------------------------------------
+
+TYP_LIST *AvatarList_Init(void)
+{
+ TYP_LIST *hList = List_Init(16);
+
+ return hList;
+}
+
+// -----------------------------------------------------------------------------
+
+void AvatarList_Exit(TYP_LIST *hList)
+{
+ AVATARENTRY *pEntry;
+
+ while (pEntry=(AVATARENTRY*)List_Pop(hList))
+ {
+ AvatarList_FreeEntry(pEntry);
+ free (pEntry);
+ }
+ List_Exit(hList);
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL AvatarList_Insert(TYP_LIST *hList, cJSON *pIcon)
+{
+ AVATARENTRY *pEntry;
+
+ if (pEntry=AvatarList_Find (hList, cJSON_GetObjectItem(pIcon, "buid")->valuestring))
+ AvatarList_FreeEntry (pEntry);
+ else
+ {
+ if (!(pEntry = calloc (1, sizeof(AVATARENTRY)))) return FALSE;
+ if (!List_Push(hList, pEntry)) return FALSE;
+ }
+ SetEntry(pEntry, pIcon);
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL AvatarList_Remove(TYP_LIST *hList, AVATARENTRY *pEntry)
+{
+ AVATARENTRY *pListEntry;
+ int i, nCount;
+
+ for (i=0, nCount=List_Count(hList); i<nCount; i++)
+ {
+ pListEntry = List_ElementAt (hList, i);
+ if (pListEntry == pEntry) break;
+ }
+ if (i<nCount)
+ {
+ AvatarList_FreeEntry (pEntry);
+ List_RemoveElementAt(hList, i);
+ free (pEntry);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+// -----------------------------------------------------------------------------
+
+AVATARENTRY *AvatarList_Find(TYP_LIST *hList, char *pszUser)
+{
+ int i, nCount;
+ AVATARENTRY *pEntry;
+
+ for (i=0, nCount=List_Count(hList); i<nCount; i++)
+ {
+ pEntry = List_ElementAt (hList, i);
+ if (strcmp(pEntry->pszUser, pszUser) == 0)
+ return pEntry;
+ }
+ return NULL;
+}
+
+// -----------------------------------------------------------------------------
+
+void AvatarList_FreeEntry(AVATARENTRY *pEntry)
+{
+ if (pEntry->pszUser) free (pEntry->pszUser);
+ if (pEntry->pszIcon) free (pEntry->pszIcon);
+}
+
+// -----------------------------------------------------------------------------
+// Static
+// -----------------------------------------------------------------------------
+
+static void SetEntry(AVATARENTRY *pEntry, cJSON *pNick)
+{
+ pEntry->pszUser = strdup(cJSON_GetObjectItem(pNick, "buid")->valuestring);
+ pEntry->pszIcon = strdup(cJSON_GetObjectItem(pNick, "icon")->valuestring);
+}
|