summaryrefslogtreecommitdiff
path: root/plugins/!NotAdopted/IMO2sProxy/src/imo2skype/callqueue.c
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2012-12-22 21:43:08 +0000
committerKirill Volinsky <mataes2007@gmail.com>2012-12-22 21:43:08 +0000
commit07ddfbd5994267e0f1aba52040a25db90ed8924b (patch)
treee33f1fe629f4e74b4bb31cbdcf41a2c2451bf599 /plugins/!NotAdopted/IMO2sProxy/src/imo2skype/callqueue.c
parent3c0a624abd362e45502619648670ace62b2efa3e (diff)
IMO2sProxy reverted. maybe will be needed later
git-svn-id: http://svn.miranda-ng.org/main/trunk@2809 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/!NotAdopted/IMO2sProxy/src/imo2skype/callqueue.c')
-rw-r--r--plugins/!NotAdopted/IMO2sProxy/src/imo2skype/callqueue.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/plugins/!NotAdopted/IMO2sProxy/src/imo2skype/callqueue.c b/plugins/!NotAdopted/IMO2sProxy/src/imo2skype/callqueue.c
new file mode 100644
index 0000000000..f579eb184e
--- /dev/null
+++ b/plugins/!NotAdopted/IMO2sProxy/src/imo2skype/callqueue.c
@@ -0,0 +1,95 @@
+/* Module: callqueue.c
+ Purpose: Queue for incoming calls
+ Author: leecher
+ Date: 02.09.2009
+
+ Fixme: Sort on insert, do a binary search instead of iterating list.
+*/
+
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include "callqueue.h"
+
+static volatile unsigned int m_uMsgNr=0;
+static void FreeEntry(void *pPEntry);
+
+// -----------------------------------------------------------------------------
+// Interface
+// -----------------------------------------------------------------------------
+
+TYP_LIST *CallQueue_Init(void)
+{
+ TYP_LIST *hList = List_Init(16);
+
+ return hList;
+}
+
+// -----------------------------------------------------------------------------
+
+void CallQueue_Exit(TYP_LIST *hList)
+{
+ Queue_Exit (hList, FreeEntry);
+}
+
+// -----------------------------------------------------------------------------
+
+CALLENTRY *CallQueue_Insert(TYP_LIST *hList, cJSON *pNick, int iDirection)
+{
+ CALLENTRY *pEntry;
+ cJSON *pStream, *pVal, *pPipe;
+
+ if (!(pEntry = Queue_InsertEntry(hList, sizeof(CALLENTRY), ++m_uMsgNr,
+ FreeEntry))) return NULL;
+ pEntry->pszUser = strdup(cJSON_GetObjectItem(pNick, "buid")->valuestring);
+ time (&pEntry->timestamp);
+ strcpy (pEntry->szStatus, "RINGING");
+
+ if (pStream = cJSON_GetObjectItem(pNick, "send_stream"))
+ {
+ strcpy (pEntry->szSendStream, pStream->valuestring);
+ if (pStream = cJSON_GetObjectItem(pNick, "recv_stream"))
+ strcpy (pEntry->szRecvStream, pStream->valuestring);
+ }
+ else
+ {
+ // Copy pipe to Call object
+ if (pPipe = cJSON_GetObjectItem(pNick, "pipe"))
+ {
+ if (pVal = cJSON_GetObjectItem(pPipe, "ip"))
+ strncpy (pEntry->szIP, pVal->valuestring, sizeof(pEntry->szIP));
+ if (pVal = cJSON_GetObjectItem(pPipe, "conv"))
+ strncpy (pEntry->szConv, pVal->valuestring, sizeof(pEntry->szConv));
+ if (pVal = cJSON_GetObjectItem(pPipe, "role"))
+ pEntry->iRole = pVal->valueint;
+ }
+ }
+ pEntry->iDirection = iDirection;
+ return pEntry;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL CallQueue_Remove(TYP_LIST *hList, unsigned int uMsgNr)
+{
+ return Queue_Remove (hList, uMsgNr, FreeEntry);
+}
+
+// -----------------------------------------------------------------------------
+
+CALLENTRY *CallQueue_Find(TYP_LIST *hList, unsigned int uMsgNr)
+{
+ return (CALLENTRY*)Queue_Find(hList, uMsgNr);
+}
+
+// -----------------------------------------------------------------------------
+// Static
+// -----------------------------------------------------------------------------
+
+static void FreeEntry(void *pPEntry)
+{
+ CALLENTRY *pEntry = (CALLENTRY*)pPEntry;
+
+ free (pEntry->pszUser);
+}
+