CMsnProto::CMsnProto(const char* aProtoName, const TCHAR* aUserName) : contList(10, CompareLists), grpList(10, CompareId), sttThreads(10, PtrKeySortT), sessionList(10, PtrKeySortT), dcList(10, PtrKeySortT), msgQueueList(1), msgCache(5, CompareId) { char path[MAX_PATH]; m_iVersion = 2; m_tszUserName = mir_tstrdup(aUserName); m_szModuleName = mir_strdup(aProtoName); m_szProtoName = mir_strdup(aProtoName); _strlwr(m_szProtoName); m_szProtoName[0] = (char)toupper(m_szProtoName[0]); mir_snprintf(path, sizeof(path), "%s/Status", m_szModuleName); MSN_CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)path); mir_snprintf(path, sizeof(path), "%s/IdleTS", m_szModuleName); MSN_CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)path); mir_snprintf(path, sizeof(path), "%s/p2pMsgId", m_szModuleName); MSN_CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)path); mir_snprintf(path, sizeof(path), "%s/MobileEnabled", m_szModuleName); MSN_CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)path); mir_snprintf(path, sizeof(path), "%s/MobileAllowed", m_szModuleName); MSN_CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)path); // Protocol services and events... hMSNNudge = CreateProtoEvent("/Nudge"); CreateProtoService(PS_CREATEACCMGRUI, &CMsnProto::SvcCreateAccMgrUI); CreateProtoService(PS_GETAVATARINFOT, &CMsnProto::GetAvatarInfo); CreateProtoService(PS_GETMYAWAYMSG, &CMsnProto::GetMyAwayMsg); CreateProtoService(PS_LEAVECHAT, &CMsnProto::OnLeaveChat); CreateProtoService(PS_GETMYAVATART, &CMsnProto::GetAvatar); CreateProtoService(PS_SETMYAVATART, &CMsnProto::SetAvatar); CreateProtoService(PS_GETAVATARCAPS, &CMsnProto::GetAvatarCaps); CreateProtoService(PS_GET_LISTENINGTO, &CMsnProto::GetCurrentMedia); CreateProtoService(PS_SET_LISTENINGTO, &CMsnProto::SetCurrentMedia); CreateProtoService(PS_SETMYNICKNAME, &CMsnProto::SetNickName); CreateProtoService(MSN_SEND_NUDGE, &CMsnProto::SendNudge); CreateProtoService(MSN_GETUNREAD_EMAILCOUNT, &CMsnProto::GetUnreadEmailCount); // service to get from protocol chat buddy info // CreateProtoService(MS_GC_PROTO_GETTOOLTIPTEXT, &CMsnProto::GCGetToolTipText); HookProtoEvent(ME_MSG_WINDOWPOPUP, &CMsnProto::OnWindowPopup); // HookProtoEvent(ME_MSG_WINDOWEVENT, &CMsnProto::OnWindowEvent); HookProtoEvent(ME_CLIST_GROUPCHANGE, &CMsnProto::OnGroupChange); HookProtoEvent(ME_OPT_INITIALISE, &CMsnProto::OnOptionsInit); HookProtoEvent(ME_CLIST_DOUBLECLICKED, &CMsnProto::OnContactDoubleClicked); LoadOptions(); HANDLE hContact = (HANDLE)MSN_CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); while (hContact != NULL) { if (MSN_IsMyContact(hContact)) { deleteSetting(hContact, "Status"); deleteSetting(hContact, "IdleTS"); deleteSetting(hContact, "p2pMsgId"); deleteSetting(hContact, "AccList"); // DBDeleteContactSetting(hContact, "CList", "StatusMsg"); } hContact = (HANDLE)MSN_CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact, 0); } deleteSetting(NULL, "MobileEnabled"); deleteSetting(NULL, "MobileAllowed"); if (getStaticString(NULL, "LoginServer", path, sizeof(path)) == 0 && (strcmp(path, MSN_DEFAULT_LOGIN_SERVER) == 0 || strcmp(path, MSN_DEFAULT_GATEWAY) == 0)) deleteSetting(NULL, "LoginServer"); if (MyOptions.SlowSend) { if (DBGetContactSettingDword(NULL, "SRMsg", "MessageTimeout", 10000) < 60000) DBWriteContactSettingDword(NULL, "SRMsg", "MessageTimeout", 60000); if (DBGetContactSettingDword(NULL, "SRMM", "MessageTimeout", 10000) < 60000) DBWriteContactSettingDword(NULL, "SRMM", "MessageTimeout", 60000); } mailsoundname = (char*)mir_alloc(64); mir_snprintf(mailsoundname, 64, "%s:Hotmail", m_szModuleName); SkinAddNewSoundExT(mailsoundname, m_tszUserName, LPGENT("Live Mail")); alertsoundname = (char*)mir_alloc(64); mir_snprintf(alertsoundname, 64, "%s:Alerts", m_szModuleName); SkinAddNewSoundExT(alertsoundname, m_tszUserName, LPGENT("Live Alert")); m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; MSN_InitThreads(); Lists_Init(); MsgQueue_Init(); P2pSessions_Init(); InitCustomFolders(); TCHAR szBuffer[MAX_PATH]; char szDbsettings[64]; NETLIBUSER nlu1 = {0}; nlu1.cbSize = sizeof(nlu1); nlu1.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_TCHAR; nlu1.szSettingsModule = szDbsettings; nlu1.ptszDescriptiveName = szBuffer; mir_snprintf(szDbsettings, sizeof(szDbsettings), "%s_HTTPS", m_szModuleName); mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s plugin HTTPS connections"), m_tszUserName); hNetlibUserHttps = (HANDLE)MSN_CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu1); NETLIBUSER nlu = {0}; nlu.cbSize = sizeof(nlu); nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_TCHAR; nlu.szSettingsModule = m_szModuleName; nlu.ptszDescriptiveName = szBuffer; nlu.szHttpGatewayUserAgent = (char*)MSN_USER_AGENT; nlu.pfnHttpGatewayInit = msn_httpGatewayInit; nlu.pfnHttpGatewayWrapSend = msn_httpGatewayWrapSend; nlu.pfnHttpGatewayUnwrapRecv = msn_httpGatewayUnwrapRecv; mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s plugin connections"), m_tszUserName); hNetlibUser = (HANDLE)MSN_CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); }
CMsnProto::CMsnProto(const char* aProtoName, const TCHAR* aUserName) : PROTO<CMsnProto>(aProtoName, aUserName), contList(10, CompareLists), grpList(10, CompareId), sttThreads(10, PtrKeySortT), sessionList(10, PtrKeySortT), dcList(10, PtrKeySortT), lsMessageQueue(1), lsAvatarQueue(1), msgCache(5, CompareId) { db_set_resident(m_szModuleName, "Status"); db_set_resident(m_szModuleName, "IdleTS"); db_set_resident(m_szModuleName, "p2pMsgId"); db_set_resident(m_szModuleName, "MobileEnabled"); db_set_resident(m_szModuleName, "MobileAllowed"); // Protocol services and events... hMSNNudge = CreateProtoEvent("/Nudge"); CreateProtoService(PS_CREATEACCMGRUI, &CMsnProto::SvcCreateAccMgrUI); CreateProtoService(PS_GETAVATARINFOT, &CMsnProto::GetAvatarInfo); CreateProtoService(PS_GETMYAWAYMSG, &CMsnProto::GetMyAwayMsg); CreateProtoService(PS_LEAVECHAT, &CMsnProto::OnLeaveChat); CreateProtoService(PS_GETMYAVATART, &CMsnProto::GetAvatar); CreateProtoService(PS_SETMYAVATART, &CMsnProto::SetAvatar); CreateProtoService(PS_GETAVATARCAPS, &CMsnProto::GetAvatarCaps); CreateProtoService(PS_GET_LISTENINGTO, &CMsnProto::GetCurrentMedia); CreateProtoService(PS_SET_LISTENINGTO, &CMsnProto::SetCurrentMedia); CreateProtoService(PS_SETMYNICKNAME, &CMsnProto::SetNickName); CreateProtoService(PS_SEND_NUDGE, &CMsnProto::SendNudge); CreateProtoService(PS_GETUNREADEMAILCOUNT, &CMsnProto::GetUnreadEmailCount); // event hooks HookProtoEvent(ME_MSG_WINDOWPOPUP, &CMsnProto::OnWindowPopup); HookProtoEvent(ME_CLIST_GROUPCHANGE, &CMsnProto::OnGroupChange); HookProtoEvent(ME_OPT_INITIALISE, &CMsnProto::OnOptionsInit); HookProtoEvent(ME_CLIST_DOUBLECLICKED, &CMsnProto::OnContactDoubleClicked); LoadOptions(); for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { delSetting(hContact, "Status"); delSetting(hContact, "IdleTS"); delSetting(hContact, "p2pMsgId"); delSetting(hContact, "AccList"); } delSetting("MobileEnabled"); delSetting("MobileAllowed"); char path[MAX_PATH]; if (db_get_static(NULL, m_szModuleName, "LoginServer", path, sizeof(path)) == 0 && (strcmp(path, MSN_DEFAULT_LOGIN_SERVER) == 0 || strcmp(path, MSN_DEFAULT_GATEWAY) == 0)) delSetting("LoginServer"); if (MyOptions.SlowSend) { if (db_get_dw(NULL, "SRMsg", "MessageTimeout", 10000) < 60000) db_set_dw(NULL, "SRMsg", "MessageTimeout", 60000); if (db_get_dw(NULL, "SRMM", "MessageTimeout", 10000) < 60000) db_set_dw(NULL, "SRMM", "MessageTimeout", 60000); } mailsoundname = (char*)mir_alloc(64); mir_snprintf(mailsoundname, 64, "%s:Hotmail", m_szModuleName); SkinAddNewSoundExT(mailsoundname, m_tszUserName, LPGENT("Live Mail")); alertsoundname = (char*)mir_alloc(64); mir_snprintf(alertsoundname, 64, "%s:Alerts", m_szModuleName); SkinAddNewSoundExT(alertsoundname, m_tszUserName, LPGENT("Live Alert")); MSN_InitThreads(); Lists_Init(); MsgQueue_Init(); AvatarQueue_Init(); P2pSessions_Init(); InitCustomFolders(); TCHAR szBuffer[MAX_PATH]; char szDbsettings[64]; NETLIBUSER nlu1 = {0}; nlu1.cbSize = sizeof(nlu1); nlu1.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_TCHAR; nlu1.szSettingsModule = szDbsettings; nlu1.ptszDescriptiveName = szBuffer; mir_snprintf(szDbsettings, sizeof(szDbsettings), "%s_HTTPS", m_szModuleName); mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s plugin HTTPS connections"), m_tszUserName); hNetlibUserHttps = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu1); NETLIBUSER nlu = {0}; nlu.cbSize = sizeof(nlu); nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_TCHAR; nlu.szSettingsModule = m_szModuleName; nlu.ptszDescriptiveName = szBuffer; nlu.szHttpGatewayUserAgent = (char*)MSN_USER_AGENT; nlu.pfnHttpGatewayInit = msn_httpGatewayInit; nlu.pfnHttpGatewayWrapSend = msn_httpGatewayWrapSend; nlu.pfnHttpGatewayUnwrapRecv = msn_httpGatewayUnwrapRecv; mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s plugin connections"), m_tszUserName); m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); }