summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/SeenPlugin/src/main.cpp4
-rw-r--r--plugins/SeenPlugin/src/seen.h3
-rw-r--r--plugins/SeenPlugin/src/utils.cpp24
3 files changed, 15 insertions, 16 deletions
diff --git a/plugins/SeenPlugin/src/main.cpp b/plugins/SeenPlugin/src/main.cpp
index 4cd3e6b492..8468421e53 100644
--- a/plugins/SeenPlugin/src/main.cpp
+++ b/plugins/SeenPlugin/src/main.cpp
@@ -48,6 +48,8 @@ DBVTranslation idleTr[TRANSNUMBER]={
BOOL includeIdle;
LIST<logthread_info> arContacts(16, HandleKeySortT);
+CRITICAL_SECTION csContacts;
+
int MainInit(WPARAM,LPARAM)
{
@@ -97,6 +99,7 @@ extern "C" __declspec(dllexport) int Load(void)
mir_getLP(&pluginInfo);
g_hShutdownEvent = CreateEvent(0, TRUE, FALSE, 0);
+ InitializeCriticalSection(&csContacts);
HookEvent(ME_SYSTEM_MODULESLOADED, MainInit);
HookEvent(ME_SYSTEM_PRESHUTDOWN, OnShutdown);
@@ -114,6 +117,7 @@ extern "C" __declspec(dllexport) int Unload(void)
UnhookEvent(ehmissed);
arContacts.destroy();
+ DeleteCriticalSection(&csContacts);
CloseHandle(g_hShutdownEvent);
return 0;
}
diff --git a/plugins/SeenPlugin/src/seen.h b/plugins/SeenPlugin/src/seen.h
index 34d70efe26..e9846be1ce 100644
--- a/plugins/SeenPlugin/src/seen.h
+++ b/plugins/SeenPlugin/src/seen.h
@@ -123,4 +123,5 @@ extern HANDLE ehuserinfo, ehmissed_proto;
extern HGENMENU hmenuitem;
extern DWORD dwmirver;
-extern LIST<logthread_info> arContacts; \ No newline at end of file
+extern LIST<logthread_info> arContacts;
+extern CRITICAL_SECTION csContacts; \ No newline at end of file
diff --git a/plugins/SeenPlugin/src/utils.cpp b/plugins/SeenPlugin/src/utils.cpp
index 66fe989393..c7e0705a7d 100644
--- a/plugins/SeenPlugin/src/utils.cpp
+++ b/plugins/SeenPlugin/src/utils.cpp
@@ -516,17 +516,6 @@ void myPlaySound(HANDLE hcontact, WORD newStatus, WORD oldStatus)
}
//will add hContact to queue and will return position;
-static logthread_info* addContactToQueue(HANDLE hContact)
-{
- if (!hContact)
- return NULL;
-
- logthread_info *p = (logthread_info*)mir_calloc(sizeof(logthread_info));
- p->hContact = hContact;
- arContacts.insert(p);
- return p;
-}
-
static void waitThread(void *param)
{
logthread_info* infoParam = (logthread_info*)param;
@@ -547,8 +536,10 @@ static void waitThread(void *param)
db_set_w(infoParam->hContact,S_MOD,"StatusTriger",infoParam->currStatus);
}
}
-
- arContacts.remove(infoParam);
+ {
+ mir_cslock lck(csContacts);
+ arContacts.remove(infoParam);
+ }
mir_free(infoParam);
}
@@ -626,13 +617,16 @@ int UpdateValues(WPARAM wparam,LPARAM lparam)
db_set_b(hContact, S_MOD, "Offline", 0);
}
}
- else if (IsWatchedProtocol(cws->szModule)) {
+ else if (hContact && IsWatchedProtocol(cws->szModule)) {
//here we will come when <User>/<module>/Status is changed or it is idle event and if <module> is watched
if ( CallProtoService(cws->szModule,PS_GETSTATUS,0,0) > ID_STATUS_OFFLINE){
+ mir_cslock lck(csContacts);
logthread_info *p = arContacts.find((logthread_info*)&hContact);
if (p == NULL) {
- p = addContactToQueue(hContact);
+ p = (logthread_info*)mir_calloc(sizeof(logthread_info));
+ p->hContact = hContact;
strncpy(p->sProtoName, cws->szModule, MAXMODULELABELLENGTH);
+ arContacts.insert(p);
mir_forkthread(waitThread, p);
}
p->currStatus = isIdleEvent ? db_get_w(hContact, cws->szModule, "Status", ID_STATUS_OFFLINE) : cws->value.wVal;