int CMsnProto::OnWindowEvent(WPARAM, LPARAM lParam) { MessageWindowEventData* msgEvData = (MessageWindowEventData*)lParam; if (msgEvData->uType == MSG_WINDOW_EVT_OPENING) { if (m_iStatus == ID_STATUS_OFFLINE || m_iStatus == ID_STATUS_INVISIBLE) return 0; if (!MSN_IsMyContact(msgEvData->hContact)) return 0; char tEmail[MSN_MAX_EMAIL_LEN]; if (MSN_IsMeByContact(msgEvData->hContact, tEmail)) return 0; int netId = Lists_GetNetId(tEmail); if (netId != NETID_MSN && netId != NETID_LCS) return 0; if (Lists_IsInList(LIST_BL, tEmail)) return 0; bool isOffline; ThreadData* thread = MSN_StartSB(tEmail, isOffline); if (thread == NULL && !isOffline) MsgQueue_Add(tEmail, 'X', NULL, 0); } return 0; }
INT_PTR CMsnProto::SendNudge(WPARAM hContact, LPARAM) { if (!msnLoggedIn) return 0; char tEmail[MSN_MAX_EMAIL_LEN]; if (MSN_IsMeByContact(hContact, tEmail)) return 0; int netId = Lists_GetNetId(tEmail); #ifdef OBSOLETE static const char nudgemsg[] = "Content-Type: text/x-msnmsgr-datacast\r\n\r\n" "ID: 1\r\n\r\n"; switch (netId) { case NETID_UNKNOWN: hContact = MSN_GetChatInernalHandle(hContact); case NETID_MSN: case NETID_LCS: { bool isOffline; ThreadData* thread = MSN_StartSB(tEmail, isOffline); if (thread == NULL) { if (isOffline) return 0; MsgQueue_Add(tEmail, 'N', nudgemsg, -1); } else { int tNnetId = netId == NETID_UNKNOWN ? NETID_MSN : netId; thread->sendMessage('N', tEmail, tNnetId, nudgemsg, MSG_DISABLE_HDR); } } break; case NETID_YAHOO: msnNsThread->sendMessage('3', tEmail, netId, nudgemsg, MSG_DISABLE_HDR); break; default: break; } #else msnNsThread->sendMessage('3', tEmail, netId, "", MSG_NUDGE); #endif return 0; }
// MsnUserIsTyping - notify another contact that we're typing a message int __cdecl CMsnProto::UserIsTyping(MCONTACT hContact, int type) { if (!msnLoggedIn) return 0; char tEmail[MSN_MAX_EMAIL_LEN]; if (MSN_IsMeByContact(hContact, tEmail)) return 0; bool typing = type == PROTOTYPE_SELFTYPING_ON; int netId = Lists_GetNetId(tEmail); #ifdef OBSOLETE switch (netId) { case NETID_UNKNOWN: case NETID_MSN: case NETID_LCS: bool isOffline; { ThreadData* thread = MSN_StartSB(tEmail, isOffline); if (thread == NULL) { if (isOffline) return 0; MsgQueue_Add(tEmail, 2571, NULL, 0, NULL, typing); } else MSN_StartStopTyping(thread, typing); } break; case NETID_YAHOO: if (typing) MSN_SendTyping(msnNsThread, tEmail, netId); break; default: break; } #endif if (getWord(hContact, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) MSN_SendTyping(msnNsThread, tEmail, netId, typing); return 0; }
int __cdecl CMsnProto::UserIsTyping(HANDLE hContact, int type) { if (!msnLoggedIn) return 0; char tEmail[MSN_MAX_EMAIL_LEN]; if (MSN_IsMeByContact(hContact, tEmail)) return 0; bool typing = type == PROTOTYPE_SELFTYPING_ON; int netId = Lists_GetNetId(tEmail); switch (netId) { case NETID_UNKNOWN: case NETID_MSN: case NETID_LCS: { bool isOffline; ThreadData* thread = MSN_StartSB(tEmail, isOffline); if (thread == NULL) { if (isOffline) return 0; MsgQueue_Add(tEmail, 2571, NULL, 0, NULL, typing); } else MSN_StartStopTyping(thread, typing); } break; case NETID_YAHOO: if (typing) MSN_SendTyping(msnNsThread, tEmail, netId); break; default: break; } return 0; }
int __cdecl CMsnProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc) { const char *errMsg = NULL; if (!msnLoggedIn) { errMsg = MSN_Translate("Protocol is offline"); ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, 999999, errMsg, this)); return 999999; } char tEmail[MSN_MAX_EMAIL_LEN]; if (MSN_IsMeByContact(hContact, tEmail)) { errMsg = MSN_Translate("You cannot send message to yourself"); ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, 999999, errMsg, this)); return 999999; } char *msg = (char*)pszSrc; if (msg == NULL) return 0; if (flags & PREF_UNICODE) { char* p = strchr(msg, '\0'); if (p != msg) { while (*(++p) == '\0') {} msg = mir_utf8encodeW((wchar_t*)p); } else msg = mir_strdup(msg); } else msg = (flags & PREF_UTF) ? mir_strdup(msg) : mir_utf8encode(msg); int rtlFlag = (flags & PREF_RTL) ? MSG_RTL : 0; int seq = 0; int netId = Lists_GetNetId(tEmail); switch (netId) { case NETID_MOB: if (strlen(msg) > 133) { errMsg = MSN_Translate("Message is too long: SMS page limited to 133 UTF8 chars"); seq = 999997; } else { errMsg = NULL; seq = msnNsThread->sendMessage('1', tEmail, netId, msg, rtlFlag); } ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this)); break; case NETID_YAHOO: if (strlen(msg) > 1202) { seq = 999996; errMsg = MSN_Translate("Message is too long: MSN messages are limited by 1202 UTF8 chars"); ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this)); } else { seq = msnNsThread->sendMessage('1', tEmail, netId, msg, rtlFlag); ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, NULL, this)); } break; default: if (strlen(msg) > 1202) { seq = 999996; errMsg = MSN_Translate("Message is too long: MSN messages are limited by 1202 UTF8 chars"); ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this)); } else { const char msgType = MyOptions.SlowSend ? 'A' : 'N'; bool isOffline; ThreadData* thread = MSN_StartSB(tEmail, isOffline); if (thread == NULL) { if (isOffline) { if (netId != NETID_LCS) { seq = msnNsThread->sendMessage('1', tEmail, netId, msg, rtlFlag | MSG_OFFLINE); ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, NULL, this)); } else { seq = 999993; errMsg = MSN_Translate("Offline messaging is not allowed for LCS contacts"); ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this)); } } else seq = MsgQueue_Add(tEmail, msgType, msg, 0, 0, rtlFlag); } else { seq = thread->sendMessage(msgType, tEmail, netId, msg, rtlFlag); if (!MyOptions.SlowSend) ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, NULL, this)); } } break; } mir_free(msg); return seq; }
// MsnSendMessage - sends the message to a server int __cdecl CMsnProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc) { const char *errMsg = NULL; if (!msnLoggedIn) { errMsg = Translate("Protocol is offline"); ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, 999999, errMsg, this)); return 999999; } char tEmail[MSN_MAX_EMAIL_LEN]; if (MSN_IsMeByContact(hContact, tEmail)) { errMsg = Translate("You cannot send message to yourself"); ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, 999999, errMsg, this)); return 999999; } char *msg = (char*)pszSrc; if (msg == NULL) return 0; int rtlFlag = (flags & PREF_RTL) ? MSG_RTL : 0; int seq = 0; int netId = Lists_GetNetId(tEmail); switch (netId) { case NETID_MOB: if (mir_strlen(msg) > 133) { errMsg = Translate("Message is too long: SMS page limited to 133 UTF8 chars"); seq = 999997; } else { errMsg = NULL; seq = msnNsThread->sendMessage('1', tEmail, netId, msg, rtlFlag); } ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this)); break; case NETID_YAHOO: if (mir_strlen(msg) > 1202) { seq = 999996; errMsg = Translate("Message is too long: MSN messages are limited by 1202 UTF8 chars"); ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this)); } else { seq = msnNsThread->sendMessage('1', tEmail, netId, msg, rtlFlag); ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, NULL, this)); } break; default: if (mir_strlen(msg) > 1202) { seq = 999996; errMsg = Translate("Message is too long: MSN messages are limited by 1202 UTF8 chars"); ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this)); } else { #ifdef OBSOLETE const char msgType = MyOptions.SlowSend ? 'A' : 'N'; bool isOffline; ThreadData *thread = MSN_StartSB(tEmail, isOffline); #else /* MSNP24 doesn't have a switchboard anymore */ bool isOffline = true; ThreadData *thread = NULL; #endif if (thread == NULL) { if (isOffline) { if (netId != NETID_LCS) { seq = msnNsThread->sendMessage('1', tEmail, netId, msg, rtlFlag | MSG_OFFLINE); ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, NULL, this)); } else { seq = 999993; errMsg = Translate("Offline messaging is not allowed for LCS contacts"); ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this)); } } #ifdef OBSOLETE else seq = MsgQueue_Add(tEmail, msgType, msg, 0, 0, rtlFlag); } else { seq = thread->sendMessage(msgType, tEmail, netId, msg, rtlFlag); if (!MyOptions.SlowSend) ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, NULL, this)); #endif } } break; } return seq; }