blob: 92a84ef9788778c6bb6e4bb54fe9c019f1de85ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#include "stdafx.h"
#include "Xfire_avatar_loader.h"
Xfire_avatar_loader::Xfire_avatar_loader(xfirelib::Client* client) {
threadrunning = FALSE;
this->client = client;
}
Xfire_avatar_loader::~Xfire_avatar_loader() {
//liste leeren, damit der laufende thread abgebrochen wird
list.clear();
}
void Xfire_avatar_loader::loadThread(void *arg) {
Xfire_avatar_loader *loader = (Xfire_avatar_loader*)arg;
//kein loader, dann abbruch
if (!loader)
return;
mir_cslock lck(loader->avatarMutex);
loader->threadrunning = TRUE;
while (1){
//keinen avatarload auftrag mehr
if (!loader->list.size())
break;
//letzten load process holen
Xfire_avatar_process process = loader->list.back();
//buddyinfo abfragen
GetBuddyInfo buddyinfo;
buddyinfo.userid = process.userid;
if (loader->client)
if (loader->client->connected)
{
loader->client->send(&buddyinfo);
}
else //nicht mehr verbunden? dann liste leeren und schleife abbrechen
{
loader->list.clear();
break;
}
//auftrag entfernen
loader->list.pop_back();
Sleep(1000);
}
loader->threadrunning = FALSE;
return;
}
BOOL Xfire_avatar_loader::loadAvatar(MCONTACT hcontact, char*username, unsigned int userid)
{
Xfire_avatar_process process = { 0 };
//struktur füllen
process.hcontact = hcontact;
if (username)
strcpy_s(process.username, 128, username);
process.userid = userid;
//Avataranfrage an die liste übergeben
this->list.push_back(process);
if (!threadrunning && client != NULL) {
mir_forkthread(Xfire_avatar_loader::loadThread, this);
}
return TRUE;
}
|