void CYahooProto::ext_got_picture_checksum(const char *me, const char *who, int cksum) { LOG(("ext_yahoo_got_picture_checksum for %s checksum: %d", who, cksum)); MCONTACT hContact = getbuddyH(who); if (hContact == NULL) { LOG(("Buddy Not Found. Skipping avatar update")); return; } /* Last thing check the checksum and request new one if we need to */ if (!cksum || cksum == -1) { setDword(hContact, "PictCK", 0); reset_avatar(hContact); } else { if (getDword(hContact, "PictCK", 0) != cksum) { // Now save the new checksum. No rush requesting new avatar yet. setDword(hContact, "PictCK", cksum); // Need to delete the Avatar File!! TCHAR szFile[MAX_PATH]; GetAvatarFileName(hContact, szFile, _countof(szFile) - 1, 0); DeleteFile(szFile); // Reset the avatar and cleanup. reset_avatar(hContact); // Request new avatar here... (might also want to check the sharing status?) if (getByte("ShareAvatar", 0) == 2) request_avatar(who); } } }
void CYahooProto::ext_got_im(const char *me, const char *who, int protocol, const char *msg, long tm, int stat, int utf8, int buddy_icon, const char *seqn, int sendn) { char *umsg; const char *c = msg; int oidx = 0; LOG(("YAHOO_GOT_IM id:%s %s: %s (len: %d) tm:%lu stat:%i utf8:%i buddy_icon: %i", me, who, msg, lstrlenA(msg), tm, stat, utf8, buddy_icon)); if (stat == 2) { char z[1024]; mir_snprintf(z, SIZEOF(z), "Error sending message to %s", who); LOG((z)); ShowError( TranslateT("Yahoo Error"), _A2T(z)); return; } if (!msg) { LOG(("Empty Incoming Message, exiting.")); return; } if (getByte("IgnoreUnknown", 0)) { /* * Check our buddy list to see if we have it there. And if it's not on the list then we don't accept any IMs. */ if (getbuddyH(who) == NULL) { LOG(("Ignoring unknown user messages. User '%s'. Dropping Message.", who)); return; } } if ( BuddyIgnored( who )) { LOG(("User '%s' on our Ignore List. Dropping Message.", who)); return; } // make a bigger buffer for \n -> \r\n conversion (x2) umsg = (char *) alloca(lstrlenA(msg) * 2 + 1); while ( *c != '\0') { // Strip the font tag if (!_strnicmp(c,"<font ",6) || !_strnicmp(c,"</font>",6) || // strip the fade tag !_strnicmp(c, "<FADE ",6) || !_strnicmp(c,"</FADE>",7) || // strip the alternate colors tag !_strnicmp(c, "<ALT ",5) || !_strnicmp(c, "</ALT>",6)) { while ((*c++ != '>') && (*c != '\0')); } else // strip ANSI color combination if ((*c == 0x1b) && (*(c+1) == '[')) { while ((*c++ != 'm') && (*c != '\0')); } else if (*c != '\0') { umsg[oidx++] = *c; /* Adding \r to \r\n conversion */ if (*c == '\r' && *(c + 1) != '\n') umsg[oidx++] = '\n'; c++; } } umsg[oidx++]= '\0'; /* Need to strip off formatting stuff first. Then do all decoding/converting */ LOG(("%s: %s", who, umsg)); HANDLE hContact = add_buddy(who, who, protocol, PALF_TEMPORARY); //setWord(hContact, "yprotoid", protocol); Set_Protocol(hContact, protocol); PROTORECVEVENT pre = { 0 }; pre.flags = (utf8) ? PREF_UTF : 0; if (tm) { HANDLE hEvent = db_event_last(hContact); if (hEvent) { // contact has events DWORD dummy; DBEVENTINFO dbei = { sizeof (dbei) }; dbei.pBlob = (BYTE*)&dummy; dbei.cbBlob = 2; if (!db_event_get(hEvent, &dbei)) // got that event, if newer than ts then reset to current time if ((DWORD)tm < dbei.timestamp) tm = (long)time(NULL); } pre.timestamp = (DWORD)time(NULL); if ((DWORD)tm < pre.timestamp) pre.timestamp = tm; } else pre.timestamp = (DWORD)time(NULL); pre.szMessage = umsg; pre.lParam = 0; // Turn off typing CallService(MS_PROTO_CONTACTISTYPING, (WPARAM) hContact, PROTOTYPE_CONTACTTYPING_OFF); ProtoChainRecvMsg(hContact, &pre); // ack the message we just got if (seqn) yahoo_send_im_ack(m_id, me, who, seqn, sendn); if (buddy_icon < 0) return; //?? Don't generate floods!! setByte(hContact, "AvatarType", (BYTE)buddy_icon); if (buddy_icon != 2) reset_avatar(hContact); else if (getDword(hContact, "PictCK", 0) == 0) /* request the buddy image */ request_avatar(who); }
INT_PTR __cdecl CYahooProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam) { PROTO_AVATAR_INFORMATION* pai = (PROTO_AVATAR_INFORMATION*)lParam; DBVARIANT dbv; int avtType; if (!getString(pai->hContact, YAHOO_LOGINID, &dbv)) { debugLogA("[YAHOO_GETAVATARINFO] For: %s", dbv.pszVal); db_free(&dbv); } else { debugLogA("[YAHOO_GETAVATARINFO]"); } if (!getByte("ShowAvatars", 1) || !m_bLoggedIn) { debugLogA("[YAHOO_GETAVATARINFO] %s", m_bLoggedIn ? "We are not using/showing avatars!" : "We are not logged in. Can't load avatars now!"); return GAIR_NOAVATAR; } avtType = getByte(pai->hContact, "AvatarType", 0); debugLogA("[YAHOO_GETAVATARINFO] Avatar Type: %d", avtType); if (avtType != 2) { if (avtType != 0) debugLogA("[YAHOO_GETAVATARINFO] Not handling this type yet!"); return GAIR_NOAVATAR; } if (getDword(pai->hContact, "PictCK", 0) == 0) return GAIR_NOAVATAR; GetAvatarFileName(pai->hContact, pai->filename, _countof(pai->filename), getByte(pai->hContact, "AvatarType", 0)); pai->format = PA_FORMAT_PNG; debugLogA("[YAHOO_GETAVATARINFO] filename: %s", pai->filename); if (_taccess(pai->filename, 0) == 0) return GAIR_SUCCESS; if ((wParam & GAIF_FORCE) != 0 && pai->hContact != NULL) { /* need to request it again? */ if (getDword(pai->hContact, "PictLoading", 0) != 0 && (time(NULL) - getDword(pai->hContact, "PictLastCheck", 0) < 500)) { debugLogA("[YAHOO_GETAVATARINFO] Waiting for avatar to load!"); return GAIR_WAITFOR; } else if (m_bLoggedIn) { DBVARIANT dbv; if (!getString(pai->hContact, YAHOO_LOGINID, &dbv)) { debugLogA("[YAHOO_GETAVATARINFO] Requesting avatar!"); request_avatar(dbv.pszVal); db_free(&dbv); return GAIR_WAITFOR; } else { debugLogA("[YAHOO_GETAVATARINFO] Can't retrieve user id?!"); } } } debugLogA("[YAHOO_GETAVATARINFO] NO AVATAR???"); return GAIR_NOAVATAR; }