char *TemplateHTMLBuilder::getAvatar(MCONTACT hContact, const char* szProto) { DBVARIANT dbv; TCHAR tmpPath[MAX_PATH]; TCHAR *result = NULL; if (Options::getAvatarServiceFlags() == Options::AVATARSERVICE_PRESENT) { struct avatarCacheEntry *ace = NULL; if (hContact == NULL) { ace = (struct avatarCacheEntry *)CallService(MS_AV_GETMYAVATAR, 0, (LPARAM)szProto); } else { ace = (struct avatarCacheEntry *)CallService(MS_AV_GETAVATARBITMAP, hContact, 0); } if (ace!=NULL) { if ( ace->cbSize == sizeof(avatarCacheEntry)) result = ace->szFilename; else { // compatibility: in M0.9 it will always be char* MultiByteToWideChar( CP_ACP, 0, (char*)ace->szFilename, -1, tmpPath, SIZEOF(tmpPath)); } } } if (!db_get_ts(hContact, "ContactPhoto", "File", &dbv)) { if (_tcslen(dbv.ptszVal) > 0) { TCHAR* ext = _tcsrchr(dbv.ptszVal, '.'); if (ext && lstrcmpi(ext, _T(".xml")) == 0) { result = ( TCHAR* )getFlashAvatar(dbv.ptszVal, (hContact == NULL) ? 1 : 0); } else { if (result == NULL) { /* relative -> absolute */ _tcscpy (tmpPath, dbv.ptszVal); if ( _tcsncmp(tmpPath, _T("http://"), 7)) PathToAbsoluteT(dbv.ptszVal, tmpPath); result = tmpPath; } } } db_free(&dbv); } char* res = mir_utf8encodeT(result); Utils::convertPath(res); return res; }
char *TemplateHTMLBuilder::getAvatar(HANDLE hContact, const char * szProto) { DBVARIANT dbv; TCHAR tmpPath[MAX_PATH]; TCHAR *result = NULL; if (Options::getAvatarServiceFlags() == Options::AVATARSERVICE_PRESENT) { struct avatarCacheEntry *ace = NULL; if (hContact == NULL) { ace = (struct avatarCacheEntry *)CallService(MS_AV_GETMYAVATAR, (WPARAM)0, (LPARAM)szProto); } else { ace = (struct avatarCacheEntry *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)hContact, (LPARAM)0); } if (ace!=NULL) { if ( ace->cbSize == sizeof(avatarCacheEntry)) result = ace->szFilename; else { // compatibility: in M0.9 it will always be char* #if defined( _UNICODE ) MultiByteToWideChar( CP_ACP, 0, (char*)ace->szFilename, -1, tmpPath, SIZEOF(tmpPath)); #endif } } } if (!DBGetContactSettingTString(hContact, "ContactPhoto", "File", &dbv)) { if (_tcslen(dbv.ptszVal) > 0) { TCHAR* ext = _tcsrchr(dbv.ptszVal, '.'); if (ext && lstrcmpi(ext, _T(".xml")) == 0) { result = ( TCHAR* )getFlashAvatar(dbv.ptszVal, (hContact == NULL) ? 1 : 0); } else { if (result == NULL) { /* relative -> absolute */ _tcscpy (tmpPath, dbv.ptszVal); if (ServiceExists(MS_UTILS_PATHTOABSOLUTET) && _tcsncmp(tmpPath, _T("http://"), 7)) CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM)dbv.ptszVal, (LPARAM)tmpPath); result = tmpPath; } } } DBFreeVariant(&dbv); } char* res = Utils::UTF8Encode(result); Utils::convertPath(res); return res; }
char *TemplateHTMLBuilder::getAvatar(HANDLE hContact, const char * szProto) { DBVARIANT dbv; char tmpPath[MAX_PATH]; char *result = NULL; if (Options::getAvatarServiceFlags() == Options::AVATARSERVICE_PRESENT) { struct avatarCacheEntry *ace = NULL; if (hContact == NULL) { ace = (struct avatarCacheEntry *)CallService(MS_AV_GETMYAVATAR, (WPARAM)0, (LPARAM)szProto); } else { ace = (struct avatarCacheEntry *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)hContact, (LPARAM)0); } if (ace!=NULL) { result = ace->szFilename; } } if (!DBGetContactSetting(hContact, "ContactPhoto", "File",&dbv)) { if (strlen(dbv.pszVal) > 0) { char* ext = strrchr(dbv.pszVal, '.'); if (ext && strcmpi(ext, ".xml") == 0) { result = (char *)getFlashAvatar(dbv.pszVal, (hContact == NULL) ? 1 : 0); } else { if (result == NULL) { /* relative -> absolute */ strcpy (tmpPath, dbv.pszVal); if (ServiceExists(MS_UTILS_PATHTOABSOLUTE)&& strncmp(tmpPath, "http://", 7)) { CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM)dbv.pszVal, (LPARAM)tmpPath); } result = tmpPath; } } } DBFreeVariant(&dbv); } result = Utils::UTF8Encode(result); Utils::convertPath(result); return result; }