summaryrefslogtreecommitdiff
path: root/protocols/SkypeClassic/src/msgq.cpp
diff options
context:
space:
mode:
authorPiotr Piastucki <leech.miranda@gmail.com>2014-08-13 13:46:55 +0000
committerPiotr Piastucki <leech.miranda@gmail.com>2014-08-13 13:46:55 +0000
commit96674592dd3493682a6cccb0b3dcf8ca019fd7a4 (patch)
treef42a68584d07fc2fd4a70c5866181327471e8f53 /protocols/SkypeClassic/src/msgq.cpp
parent3cf0b793fe90993ff333ba53104796f0c280118a (diff)
Made SkypeClassic plugin compatible with Miranda IM again so that plugins for both IMs can be maintained with one codebase.
Compatibility wrapper for Miranda IM is in ng-compat/m_core.h Changed files back to C and removed C++ code. Changed Miranda NG project files so that the c files compile as C++ in order to be compatible with Miranda NG headers (/TP). Added back build scripts and make file to automatically build Miranda IM version using Makefile. git-svn-id: http://svn.miranda-ng.org/main/trunk@10177 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeClassic/src/msgq.cpp')
-rw-r--r--protocols/SkypeClassic/src/msgq.cpp90
1 files changed, 0 insertions, 90 deletions
diff --git a/protocols/SkypeClassic/src/msgq.cpp b/protocols/SkypeClassic/src/msgq.cpp
deleted file mode 100644
index e1ab0d1998..0000000000
--- a/protocols/SkypeClassic/src/msgq.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Implements a simple message queue for send and receive queue.
- * We could use memlist.c, but it's not efficient
- * enough for this purpose (would always memmove on removing first
- * element), therefore it's implemented as tail queue.
- */
-
-#include "skype.h"
-#include "msgq.h"
-#include "debug.h"
-
-
-void MsgQ_Init(TYP_MSGQ *q)
-{
- TAILQ_INIT(&q->l);
- InitializeCriticalSection (&q->cs);
-}
-
-void MsgQ_Exit(TYP_MSGQ *q)
-{
- struct MsgQueue *ptr;
-
- EnterCriticalSection(&q->cs);
- while ((ptr=q->l.tqh_first) != NULL)
- free(MsgQ_RemoveMsg(q, ptr));
- LeaveCriticalSection(&q->cs);
- DeleteCriticalSection (&q->cs);
-}
-
-BOOL MsgQ_Add(TYP_MSGQ *q, char *msg)
-{
- struct MsgQueue *ptr;
-
- if ((ptr=(struct MsgQueue*)malloc(sizeof(struct MsgQueue))) == NULL)
- return FALSE;
- ptr->message = _strdup(msg); // Don't forget to free!
- ptr->tAdded = SkypeTime(NULL);
- SkypeTime(&ptr->tReceived);
- EnterCriticalSection(&q->cs);
- TAILQ_INSERT_TAIL(&q->l, ptr, l);
- //LOG (("MsgQ_Add (%s) @%lu/%ld", msg, ptr->tReceived, ptr->tAdded));
- LeaveCriticalSection(&q->cs);
- return TRUE;
-}
-
-char *MsgQ_RemoveMsg(TYP_MSGQ *q, struct MsgQueue *ptr)
-{
- char *msg;
-
- if (!ptr) return NULL;
- EnterCriticalSection(&q->cs);
- TAILQ_REMOVE(&q->l, ptr, l);
- LeaveCriticalSection(&q->cs);
- msg=ptr->message;
- free(ptr);
- return msg;
-}
-
-char *MsgQ_Get(TYP_MSGQ *q)
-{
- char *msg;
-
- msg=MsgQ_RemoveMsg(q, q->l.tqh_first);
- return msg;
-}
-
-int MsgQ_CollectGarbage(TYP_MSGQ *q, time_t age)
-{
- struct MsgQueue *ptr;
- int i=0;
-
- EnterCriticalSection(&q->cs);
- ptr=q->l.tqh_first;
- while (ptr)
- {
- if (ptr->tAdded && SkypeTime(NULL)-ptr->tAdded>age)
- {
- struct MsgQueue *ptr_;
- LOG(("GarbageCollector throwing out message: %s", ptr->message));
- ptr_=ptr;
- ptr=ptr->l.tqe_next;
- free(MsgQ_RemoveMsg(q, ptr_));
- i++;
- continue;
- }
- ptr=ptr->l.tqe_next;
- }
- LeaveCriticalSection(&q->cs);
- return i;
-}