static INT_PTR setEmoFace(WPARAM wParam, LPARAM lParam) { FLASHAVATAR* hFA = (FLASHAVATAR*)wParam; flash_avatar_item key(hFA->hContact, *hFA, NULL); Lock l(cs); flash_avatar_item *item = FlashList.find(&key); if (item && item->pFlash) { IShockwaveFlash* flash = item->pFlash; flash->SetVariable(L"face.emotion", (BSTR)lParam); } return 0; }
static int statusChanged(WPARAM wParam, LPARAM lParam) { WORD status = HIWORD(lParam); Lock l(cs); for(int i = 0; i < FlashList.getCount(); i++) { flash_avatar_item *item = FlashList[i]; if (item->hContact == wParam) { IShockwaveFlash* flash = item->pFlash; if (flash) { getFace(); flash->SetVariable(L"face.emotion", _bstr_t(face).copy()); } } else if (item->hContact > wParam) break; // the list is sorted by hContact } return 0; }
static int ownStatusChanged(WPARAM wParam, LPARAM lParam) { WORD status = (WORD)wParam; const char* proto = (char*)lParam; Lock l(cs); for(int i = 0; i < FlashList.getCount(); i++) { flash_avatar_item *item = FlashList[i]; if(item->hContact == NULL && (!proto || (strcmpnull(item->hFA.cProto, proto) == 0))) { IShockwaveFlash* flash = item->pFlash; if (flash) { getFace(); flash->SetVariable(L"face.emotion", _bstr_t(face).copy()); } } else if (item->hContact) break; // the list is sorted by hContact } return 0; }
static int eventAdded(WPARAM wParam, LPARAM lParam) { DBEVENTINFO dbei = { sizeof(dbei) }; dbei.cbBlob = db_event_getBlobSize((HANDLE)lParam); if (dbei.cbBlob == 0xFFFFFFFF) return 0; dbei.pBlob = new BYTE[dbei.cbBlob]; db_event_get((HANDLE)lParam, &dbei); if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_READ)) { Lock l(cs); if(FlashList.getCount() > 0) { //size_t aLen = strlen((char *)dbei.pBlob)+1; char* face = NULL; if ( (strstr((char*)dbei.pBlob, (char*)":-)") != NULL) || (strstr((char*)dbei.pBlob, (char*)":)") != NULL) || (strstr((char*)dbei.pBlob, (char*)";)") != NULL) || (strstr((char*)dbei.pBlob, (char*)";-)") != NULL) || (strstr((char*)dbei.pBlob, (char*)"*THUMBS UP*") != NULL) || (strstr((char*)dbei.pBlob, (char*)"O:-)") != NULL) || (strstr((char*)dbei.pBlob, (char*)":P") != NULL) || (strstr((char*)dbei.pBlob, (char*)":-P") != NULL) || (strstr((char*)dbei.pBlob, (char*)"*Drink*") != NULL)) { face = AV_SMILE; } else if ( (strstr((char*)dbei.pBlob, (char*)":-(") != NULL) || (strstr((char*)dbei.pBlob, (char*)":-$") != NULL) || (strstr((char*)dbei.pBlob, (char*)":-!") != NULL) || (strstr((char*)dbei.pBlob, (char*)":-X") != NULL)) { face = AV_SAD; } else if ( (strstr((char*)dbei.pBlob, (char*)"*JOKINGLY*") != NULL) || (strstr((char*)dbei.pBlob, (char*)":-D") != NULL)) { face = AV_LAUGH; } else if ( (strstr((char*)dbei.pBlob, (char*)":'(") != NULL) || (strstr((char*)dbei.pBlob, (char*)":'-(") != NULL)) { face = AV_CRY; } else if ( (strstr((char*)dbei.pBlob, (char*)">:o") != NULL) || (strstr((char*)dbei.pBlob, (char*)":-@") != NULL) || (strstr((char*)dbei.pBlob, (char*)"*STOP*") != NULL) || (strstr((char*)dbei.pBlob, (char*)"]:->") != NULL) || (strstr((char*)dbei.pBlob, (char*)"@=") != NULL)) { face = AV_MAD; } else if ( (strstr((char*)dbei.pBlob, (char*)":-*") != NULL) || (strstr((char*)dbei.pBlob, (char*)":-[") != NULL) || (strstr((char*)dbei.pBlob, (char*)"*KISSED*") != NULL) || (strstr((char*)dbei.pBlob, (char*)"*KISSING*") != NULL) || (strstr((char*)dbei.pBlob, (char*)"@}->--") != NULL) || (strstr((char*)dbei.pBlob, (char*)"*IN LOVE*") != NULL)) { face = AV_LOVE; } else { face = AV_NORMAL; } MCONTACT hContact = (dbei.flags & DBEF_SENT) ? 0 : wParam; for(int i=0; i<FlashList.getCount(); i++) { flash_avatar_item *item = FlashList[i]; if (item->hContact == hContact && !strcmpnull(dbei.szModule, item->getProto())) { IShockwaveFlash* flash = item->pFlash; flash->SetVariable(L"face.emotion", _bstr_t(face).copy()); //break; } else if (item->hContact > hContact) break; // the list is sorted } } } delete[] dbei.pBlob; return 0; }
static void __cdecl loadFlash_Thread(void *p) { debug("Avatar thread executed...\n"); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE); flash_avatar_item* fai = (flash_avatar_item*)p; IShockwaveFlash* flash = fai->pFlash; if ( _tcschr(fai->hFA.cUrl, '?') == NULL) { // make hash of url debug("Making TTH hash from URL...\n"); TigerHash th; th.update(fai->hFA.cUrl, _tcslen(fai->hFA.cUrl)); th.finalize(); // create local path name TCHAR name[MAX_PATH], path[MAX_PATH]; TCHAR tth[((TigerHash::HASH_SIZE * 8) / 5) + 2]; FOLDERSGETDATA fgd = {0}; fgd.cbSize = sizeof(FOLDERSGETDATA); fgd.nMaxPathSize = MAX_PATH; fgd.szPathT = path; fgd.flags = FF_TCHAR; if (!hAvatarsFolder || CallService(MS_FOLDERS_GET_PATH, (WPARAM)hAvatarsFolder, (LPARAM)&fgd)) { if(ServiceExists(MS_UTILS_REPLACEVARS)) mir_sntprintf(path, MAX_PATH, _T("%s\\%s"), VARST(_T("%miranda_avatarcache%")), _T("Flash")); else PathToAbsoluteT( _T("Flash"), path); } else { if(_tcslen(path) && path[_tcslen(path)-1]=='\\') path[_tcslen(path)-1] = 0; } CreateDirectory(path, NULL); // create directory if it doesn't exist mir_sntprintf(name, MAX_PATH, _T("%s\\%s.swf"), path, th.toBase32(tth)); // download remote file if it doesn't exist if (GetFileAttributes(name) == 0xFFFFFFFF) { debug("Downloading flash file...\n"); DownloadFlashFile( _T2A(fai->hFA.cUrl), name, 0); } // load and play local flash movie debug("Loading flash movie...\n"); flash->LoadMovie(0, _bstr_t(name).copy()); } Sleep(100); flash->Play(); // change flash frame according user's status int status; if (fai->hFA.hContact) status = db_get_w(fai->hFA.hContact, fai->getProto(), "Status", ID_STATUS_OFFLINE); else status = CallProtoService(fai->getProto(), PS_GETSTATUS, 0, 0); getFace(); flash->SetVariable(L"face.emotion", _bstr_t(face).copy()); flash->Release(); }