void CAimProto::avatar_retrieval_handler(const char* sn, const char* hash, const char* data, int data_len) { bool res = false; PROTO_AVATAR_INFORMATIONT AI = {0}; AI.cbSize = sizeof(AI); AI.hContact = contact_from_sn(sn); if (data_len > 0) { const TCHAR *type; AI.format = detect_image_type(data, type); get_avatar_filename(AI.hContact, AI.filename, SIZEOF(AI.filename), type); int fileId = _topen(AI.filename, _O_CREAT | _O_TRUNC | _O_WRONLY | O_BINARY, _S_IREAD | _S_IWRITE); if (fileId >= 0) { _write(fileId, data, data_len); _close(fileId); res = true; char *my_sn = getSetting(AIM_KEY_SN); if (!_strcmps(sn, my_sn)) CallService(MS_AV_REPORTMYAVATARCHANGED, (WPARAM)m_szModuleName, 0); mir_free(my_sn); } // else // ShowError("Cannot set avatar. File '%s' could not be created/overwritten", file); } else LOG("AIM sent avatar of zero length for %s.(Usually caused by repeated request for the same icon)", sn); sendBroadcast(AI.hContact, ACKTYPE_AVATAR, res ? ACKRESULT_SUCCESS : ACKRESULT_FAILED, &AI, 0); }
void CAimProto::avatar_request_handler(HANDLE hContact, char* hash, unsigned char type)//checks to see if the avatar needs requested { if (hContact == NULL) { hash = hash_lg ? hash_lg : hash_sm; type = hash_lg ? 12 : 1; } char* saved_hash = getSetting(hContact, AIM_KEY_AH); if (hash && _stricmp(hash, "0201d20472") && _stricmp(hash, "2b00003341")) //gaim default icon fix- we don't want their blank icon displaying. { if (_strcmps(saved_hash, hash)) { setByte(hContact, AIM_KEY_AHT, type); setString(hContact, AIM_KEY_AH, hash); sendBroadcast(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, 0); } } else { if (saved_hash) { deleteSetting(hContact, AIM_KEY_AHT); deleteSetting(hContact, AIM_KEY_AH); sendBroadcast(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, 0); } } mir_free(saved_hash); }
int __cdecl CAimProto::SetAwayMsg(int status, const TCHAR* msg) { char** msgptr = get_status_msg_loc(status); if (msgptr == NULL) return 1; char* nmsg = mir_utf8encodeT(msg); mir_free(*msgptr); *msgptr = nmsg; switch (status) { case ID_STATUS_FREECHAT: status = ID_STATUS_ONLINE; break; case ID_STATUS_DND: case ID_STATUS_OCCUPIED: case ID_STATUS_ONTHEPHONE: #ifdef ALLOW_BUSY status = ID_STATUS_OCCUPIED; break; #endif case ID_STATUS_OUTTOLUNCH: case ID_STATUS_NA: status = ID_STATUS_AWAY; break; } if (state == 1 && status == m_iStatus) { if (!_strcmps(last_status_msg, nmsg)) return 0; mir_free(last_status_msg); last_status_msg = mir_strdup(nmsg); aim_set_statusmsg(hServerConn, seqno, nmsg); aim_set_away(hServerConn, seqno, nmsg, status == ID_STATUS_AWAY || status == ID_STATUS_OCCUPIED); } return 0; }