#include "skype_proto.h" int CSkypeProto::OnModulesLoaded(WPARAM, LPARAM) { this->InitChat(); this->InitNetLib(); this->InitCustomFolders(); this->InitInstanceHookList(); if (::ServiceExists(MS_BB_ADDBUTTON)) { BBButton bbd = { sizeof(bbd) }; bbd.pszModuleName = MODULE; bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON; bbd.ptszTooltip = ::TranslateT("Invite to conference"); bbd.hIcon = CSkypeProto::GetIconHandle("confInvite"); bbd.dwButtonID = BBB_ID_CONF_INVITE; bbd.dwDefPos = 100 + bbd.dwButtonID; ::CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd); bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISRSIDEBUTTON; bbd.ptszTooltip = ::TranslateT("Spawn conference"); bbd.hIcon = CSkypeProto::GetIconHandle("confSpawn"); bbd.dwButtonID = BBB_ID_CONF_SPAWN; bbd.dwDefPos = 100 + bbd.dwButtonID; ::CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd); HookEvent(ME_MSG_WINDOWEVENT, &CSkypeProto::OnSrmmWindowOpen); } return 0; } int CSkypeProto::OnPreShutdown(WPARAM, LPARAM) { if (::ServiceExists(MS_BB_REMOVEBUTTON)) { BBButton bbd = { sizeof(bbd) }; bbd.pszModuleName = MODULE; bbd.dwButtonID = BBB_ID_CONF_INVITE; ::CallService(MS_BB_REMOVEBUTTON, 0, (LPARAM)&bbd); bbd.dwButtonID = BBB_ID_CONF_SPAWN; ::CallService(MS_BB_REMOVEBUTTON, 0, (LPARAM)&bbd); } this->SetStatus(ID_STATUS_OFFLINE); this->UninitNetLib(); return 0; } int CSkypeProto::OnContactDeleted(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; if (hContact && this->IsOnline()) { if (this->IsChatRoom(hContact)) { ptrW chatID(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN)); this->LeaveChat(chatID); ConversationRef conversation; this->GetConversationByIdentity(::mir_utf8encodeW(chatID), conversation); if (conversation) { conversation->RetireFrom(); conversation->Delete(); } } else this->RevokeAuth(wParam, lParam); } return 0; } INT_PTR __cdecl CSkypeProto::OnAccountManagerInit(WPARAM wParam, LPARAM lParam) { return (int)::CreateDialogParam( g_hInstance, MAKEINTRESOURCE(IDD_ACCMGR), (HWND)lParam, &CSkypeProto::SkypeMainOptionsProc, (LPARAM)this); } int __cdecl CSkypeProto::OnOptionsInit(WPARAM wParam, LPARAM lParam) { OPTIONSDIALOGPAGE odp = {0}; odp.cbSize = sizeof(odp); odp.hInstance = g_hInstance; odp.ptszTitle = m_tszUserName; odp.dwInitParam = LPARAM(this); odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR | ODPF_DONTTRANSLATE; odp.position = 271828; odp.ptszGroup = LPGENT("Network"); odp.ptszTab = LPGENT("Account"); odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_MAIN); odp.pfnDlgProc = SkypeMainOptionsProc; ::Options_AddPage(wParam, &odp); return 0; } int __cdecl CSkypeProto::OnUserInfoInit(WPARAM wParam, LPARAM lParam) { if ((!this->IsProtoContact((HANDLE)lParam)) && lParam) return 0; OPTIONSDIALOGPAGE odp = {0}; odp.cbSize = sizeof(odp); odp.flags = ODPF_TCHAR | ODPF_USERINFOTAB | ODPF_DONTTRANSLATE; odp.hInstance = g_hInstance; odp.dwInitParam = LPARAM(this); odp.position = -1900000000; odp.ptszTitle = this->m_tszUserName; HANDLE hContact = (HANDLE)lParam; if (hContact) { char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); if (szProto != NULL && !strcmp(szProto, m_szModuleName)) { odp.pfnDlgProc = SkypeDlgProc; odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_SKYPE); UserInfo_AddPage(wParam, &odp); } } else { NeedUpdate = 0; odp.pfnDlgProc = ContactSkypeDlgProc; odp.pszTemplate = MAKEINTRESOURCEA(IDD_OWNINFO_CONTACT); odp.ptszTab = LPGENT("Contacts"); UserInfo_AddPage(wParam, &odp); odp.pfnDlgProc = HomeSkypeDlgProc; odp.pszTemplate = MAKEINTRESOURCEA(IDD_OWNINFO_HOME); odp.ptszTab = LPGENT("Home"); UserInfo_AddPage(wParam, &odp); odp.pfnDlgProc = PersonalSkypeDlgProc; odp.pszTemplate = MAKEINTRESOURCEA(IDD_OWNINFO_PERSONAL); odp.ptszTab = LPGENT("General"); UserInfo_AddPage(wParam, &odp); } return 0; } int __cdecl CSkypeProto::OnSrmmWindowOpen(WPARAM, LPARAM lParam) { MessageWindowEventData *ev = (MessageWindowEventData*)lParam; if (ev->uType == MSG_WINDOW_EVT_OPENING && ev->hContact) { BBButton bbd = { sizeof(bbd) }; bbd.pszModuleName = MODULE; bbd.bbbFlags = (!strcmp( GetContactProto(ev->hContact), this->m_szModuleName)) ? 0 : BBSF_HIDDEN | BBSF_DISABLED; bbd.dwButtonID = BBB_ID_CONF_INVITE; ::CallService(MS_BB_SETBUTTONSTATE, (WPARAM)ev->hContact, (LPARAM)&bbd); bbd.dwButtonID = BBB_ID_CONF_SPAWN; ::CallService(MS_BB_SETBUTTONSTATE, (WPARAM)ev->hContact, (LPARAM)&bbd); } return 0; } int __cdecl CSkypeProto::OnTabSRMMButtonPressed(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; CustomButtonClickData *cbcd = (CustomButtonClickData *)lParam; switch (cbcd->dwButtonId) { case BBB_ID_CONF_INVITE: if (this->IsOnline() && this->IsChatRoom(hContact)) { StringList targets = this->GetChatUsers(ptrW(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN))); this->StartChat(targets); } break; case BBB_ID_CONF_SPAWN: if (this->IsOnline() && !this->IsChatRoom(hContact)) { StringList targets; targets.insert(ptrW(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN))); this->StartChat(targets); } break; } return 1; } void CSkypeProto::OnMessage ( const MessageRef & message, const bool & changesInboxTimestamp, const MessageRef & supersedesHistoryMessage, const ConversationRef & conversation) { CMessage::TYPE messageType; message->GetPropType(messageType); switch (messageType) { case CMessage::POSTED_EMOTE: case CMessage::POSTED_TEXT: case CMessage::STARTED_LIVESESSION: case CMessage::ENDED_LIVESESSION: { CConversation::TYPE type; conversation->GetPropType(type); if (type == 0 || type == CConversation::DIALOG) this->OnMessageEvent(conversation, message); else this->OnChatEvent(conversation, message); } break; case CMessage::ADDED_CONSUMERS: case CMessage::RETIRED: case CMessage::RETIRED_OTHERS: case CMessage::SPAWNED_CONFERENCE: this->OnChatEvent(conversation, message); break; case CMessage::POSTED_FILES: this->OnFileEvent(conversation, message); break; case CMessage::POSTED_CONTACTS: this->OnContactsEvent(conversation, message); break; //case CMessage::REQUESTED_AUTH: // break; //case CMessage::GRANTED_AUTH: // break; //case CMessage::BLOCKED: // break; } } void CSkypeProto::OnConversationChanged(const ConversationRef &conversation, int prop) { if (prop == Conversation::P_LOCAL_LIVESTATUS) { Conversation::LOCAL_LIVESTATUS liveStatus; conversation->GetPropLocalLivestatus(liveStatus); if (liveStatus == Conversation::RINGING_FOR_ME) { SEString data; CConversation::TYPE type; conversation->GetPropType(type); if (type == 0 || type == CConversation::DIALOG) { ParticipantRefs participants; conversation->GetParticipants(participants, Conversation::OTHER_CONSUMERS); participants[0]->GetPropIdentity(data); ContactRef author; this->GetContact(data, author); HANDLE hContact = this->AddContact(author); char *message = ::mir_utf8encode(::Translate("Incoming call received")); this->AddDBEvent( hContact, SKYPE_DB_EVENT_TYPE_CALL, time(NULL), DBEF_UTF, (DWORD)::strlen(message) + 1, (PBYTE)message); } //temp popup TCHAR popuptext[MAX_PATH]; mir_sntprintf(popuptext, SIZEOF(popuptext), TranslateT("Incoming call from %s. Use offical skype for calling."), ptrW(::mir_utf8decodeW(data))); this->ShowNotification(popuptext); } } }