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 __cdecl CMsnProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT* pre) { char tEmail[MSN_MAX_EMAIL_LEN]; db_get_static(hContact, m_szModuleName, "e-mail", tEmail, sizeof(tEmail)); if (Lists_IsInList(LIST_FL, tEmail)) db_unset(hContact, "CList", "Hidden"); return Proto_RecvMessage(hContact, pre); }
int CMsnProto::OnDbSettingChanged(WPARAM hContact, LPARAM lParam) { DBCONTACTWRITESETTING* cws = (DBCONTACTWRITESETTING*)lParam; if (!msnLoggedIn || MyOptions.netId != NETID_MSN) return 0; if (hContact == NULL) { if (MyOptions.SlowSend && strcmp(cws->szSetting, "MessageTimeout") == 0 && (strcmp(cws->szModule, "SRMM") == 0 || strcmp(cws->szModule, "SRMsg") == 0)) { if (cws->value.dVal < 60000) MessageBox(NULL, TranslateT("MSN requires message send timeout in your Message window plugin to be not less then 60 sec. Please correct the timeout value."), TranslateT("MSN Protocol"), MB_OK | MB_ICONINFORMATION); } return 0; } if (!strcmp(cws->szSetting, "ApparentMode")) { char tEmail[MSN_MAX_EMAIL_LEN]; if (!db_get_static(hContact, m_szModuleName, "wlid", tEmail, sizeof(tEmail)) || !db_get_static(hContact, m_szModuleName, "e-mail", tEmail, sizeof(tEmail))) { bool isBlocked = Lists_IsInList(LIST_BL, tEmail); if (isBlocked && (cws->value.type == DBVT_DELETED || cws->value.wVal == 0)) { MSN_AddUser(hContact, tEmail, 0, LIST_BL + LIST_REMOVE); MSN_AddUser(hContact, tEmail, 0, LIST_AL); } else if (!isBlocked && cws->value.wVal == ID_STATUS_OFFLINE) { MSN_AddUser(hContact, tEmail, 0, LIST_AL + LIST_REMOVE); MSN_AddUser(hContact, tEmail, 0, LIST_BL); } } } if (!strcmp(cws->szSetting, "MyHandle") && !strcmp(cws->szModule, "CList")) { bool isMe = MSN_IsMeByContact(hContact); if (!isMe || !nickChg) { char szContactID[100]; if (!db_get_static(hContact, m_szModuleName, "ID", szContactID, sizeof(szContactID))) { if (cws->value.type != DBVT_DELETED) { if (cws->value.type == DBVT_UTF8) MSN_ABUpdateNick(cws->value.pszVal, szContactID); else MSN_ABUpdateNick(UTF8(cws->value.pszVal), szContactID); } else MSN_ABUpdateNick(NULL, szContactID); } if (isMe) displayEmailCount(hContact); } } return 0; }
int __cdecl CMsnProto::RecvMsg(HANDLE hContact, PROTORECVEVENT* pre) { char tEmail[MSN_MAX_EMAIL_LEN]; getStaticString(hContact, "e-mail", tEmail, sizeof(tEmail)); if (Lists_IsInList(LIST_FL, tEmail)) DBDeleteContactSetting(hContact, "CList", "Hidden"); CCSDATA ccs = { hContact, PSR_MESSAGE, 0, (LPARAM)pre }; MSN_CallService(MS_PROTO_RECVMSG, 0, (LPARAM)&ccs); return 0; }
// MsnRecvMessage - creates a database event from the message been received int __cdecl CMsnProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT* pre) { char tEmail[MSN_MAX_EMAIL_LEN]; if (!db_get_static(hContact, m_szModuleName, "wlid", tEmail, sizeof(tEmail)) || !db_get_static(hContact, m_szModuleName, "e-mail", tEmail, sizeof(tEmail))) { if (Lists_IsInList(LIST_FL, tEmail) && db_get_b(hContact, "MetaContacts", "IsSubcontact", 0) == 0) db_unset(hContact, "CList", "Hidden"); } return Proto_RecvMessage(hContact, pre); }
INT_PTR CMsnProto::MsnBlockCommand(WPARAM hContact, LPARAM) { if (msnLoggedIn) { char tEmail[MSN_MAX_EMAIL_LEN]; if (db_get_static(hContact, m_szModuleName, "wlid", tEmail, sizeof(tEmail))) db_get_static(hContact, m_szModuleName, "e-mail", tEmail, sizeof(tEmail)); if (Lists_IsInList(LIST_BL, tEmail)) delSetting(hContact, "ApparentMode"); else setWord(hContact, "ApparentMode", ID_STATUS_OFFLINE); } return 0; }
// MsnBasicSearch - search contacts by e-mail void __cdecl CMsnProto::MsnSearchAckThread(void* arg) { const TCHAR* emailT = (TCHAR*)arg; T2Utf email(emailT); if (Lists_IsInList(LIST_FL, email)) { MSN_ShowPopup(emailT, TranslateT("Contact already in your contact list"), MSN_ALLOW_MSGBOX, NULL); ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0); mir_free(arg); return; } if (MyOptions.netId == NETID_SKYPE) MSN_SKYABSearch(email, arg); else { unsigned res = MSN_ABContactAdd(email, NULL, NETID_MSN, NULL, 1, true); switch (res) { case 0: case 2: case 3: { PROTOSEARCHRESULT psr = { 0 }; psr.cbSize = sizeof(psr); psr.flags = PSR_TCHAR; psr.id.t = (TCHAR*)emailT; psr.nick.t = (TCHAR*)emailT; psr.email.t = (TCHAR*)emailT; ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, arg, (LPARAM)&psr); ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0); } break; case 1: if (strstr(email, "@yahoo.com") == NULL) ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0); #ifdef OBSOLETE else { msnSearchId = arg; MSN_FindYahooUser(email); } #endif break; default: ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0); break; } } mir_free(arg); }
void __cdecl CMsnProto::MsnSearchAckThread(void* arg) { const TCHAR* emailT = (TCHAR*)arg; char *email = mir_utf8encodeT(emailT); if (Lists_IsInList(LIST_FL, email)) { MSN_ShowPopup(emailT, _T("Contact already in your contact list"), MSN_ALLOW_MSGBOX, NULL); SendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0); mir_free(arg); return; } unsigned res = MSN_ABContactAdd(email, NULL, NETID_MSN, NULL, 1, true); switch(res) { case 0: case 2: case 3: { PROTOSEARCHRESULT isr = {0}; isr.cbSize = sizeof(isr); isr.flags = PSR_TCHAR; isr.id = (TCHAR*)emailT; isr.nick = (TCHAR*)emailT; isr.email = (TCHAR*)emailT; SendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, arg, (LPARAM)&isr); SendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0); } break; case 1: if (strstr(email, "@yahoo.com") == NULL) SendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0); else { msnSearchId = arg; MSN_FindYahooUser(email); } break; default: SendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0); break; } mir_free(email); mir_free(arg); }
int CMsnProto::OnContactDeleted(WPARAM hContact, LPARAM) { if (!msnLoggedIn) //should never happen for MSN contacts return 0; if (isChatRoom(hContact)) { DBVARIANT dbv; if (!getTString(hContact, "ChatRoomID", &dbv)) { MSN_KillChatSession(dbv.ptszVal); db_free(&dbv); } } else { char szEmail[MSN_MAX_EMAIL_LEN]; if (MSN_IsMeByContact(hContact, szEmail)) pcli->pfnRemoveEvent(hContact, 1); if (szEmail[0]) { debugLogA("Deleted Handler Email"); if (Lists_IsInList(LIST_FL, szEmail)) { DeleteParam param = { this, hContact }; DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_DELETECONTACT), NULL, DlgDeleteContactUI, (LPARAM)¶m); MsnContact *msc = Lists_Get(szEmail); if (msc) msc->hContact = NULL; } if (Lists_IsInList(LIST_LL, szEmail)) MSN_AddUser(hContact, szEmail, 0, LIST_LL | LIST_REMOVE); } } return 0; }
INT_PTR CMsnProto::MsnBlockCommand(WPARAM wParam, LPARAM) { if (msnLoggedIn) { const HANDLE hContact = (HANDLE)wParam; char tEmail[MSN_MAX_EMAIL_LEN]; getStaticString(hContact, "e-mail", tEmail, sizeof(tEmail)); if (Lists_IsInList(LIST_BL, tEmail)) deleteSetting(hContact, "ApparentMode"); else setWord(hContact, "ApparentMode", ID_STATUS_OFFLINE); } return 0; }