INT_PTR QuotesMenu_EditSettings(WPARAM wp, LPARAM) { MCONTACT hContact = MCONTACT(wp); if (NULL != hContact) ShowSettingsDlg(hContact); return 0; }
int FacebookProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM) { MCONTACT hContact = MCONTACT(wParam); bool bIsChatroom = isChatRoom(hContact); Menu_ShowItem(g_hContactMenuVisitProfile, !bIsChatroom); Menu_ShowItem(g_hContactMenuVisitFriendship, !bIsChatroom); Menu_ShowItem(g_hContactMenuVisitConversation, true); Menu_ShowItem(g_hContactMenuPostStatus, !bIsChatroom); if (!isOffline() && !bIsChatroom) { bool ctrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0; BYTE type = getByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, 0); Menu_ShowItem(g_hContactMenuAuthAsk, ctrlPressed || type == CONTACT_NONE || !type); Menu_ShowItem(g_hContactMenuAuthGrant, ctrlPressed || type == CONTACT_APPROVE); Menu_ShowItem(g_hContactMenuAuthDeny, ctrlPressed || type == CONTACT_APPROVE); Menu_ShowItem(g_hContactMenuAuthRevoke, ctrlPressed || type == CONTACT_FRIEND); Menu_ShowItem(g_hContactMenuAuthCancel, ctrlPressed || type == CONTACT_REQUEST); Menu_ShowItem(g_hContactMenuPoke, true); } return 0; }
INT_PTR FacebookProto::OnMind(WPARAM wParam, LPARAM lParam) { if (!isOnline()) return 1; MCONTACT hContact = MCONTACT(wParam); wall_data *wall = new wall_data(); wall->user_id = ptrA(getStringA(hContact, FACEBOOK_KEY_ID)); wall->isPage = false; if (wall->user_id == facy.self_.user_id) { wall->title = _tcsdup(TranslateT("Own wall")); } else wall->title = getTStringA(hContact, FACEBOOK_KEY_NICK); post_status_data *data = new post_status_data(this, wall); if (wall->user_id == facy.self_.user_id) { for (std::map<std::string, std::string>::iterator iter = facy.pages.begin(); iter != facy.pages.end(); ++iter) { data->walls.push_back(new wall_data(iter->first, mir_utf8decodeT(iter->second.c_str()), true)); } } HWND hDlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_MIND), (HWND)0, FBMindProc, reinterpret_cast<LPARAM>(data)); ShowWindow(hDlg, SW_SHOW); return 0; }
int Quotes_PrebuildContactMenu(WPARAM wp, LPARAM) { Menu_EnableItem(g_hMenuEditSettings, false); Menu_EnableItem(g_hMenuOpenLogFile, false); #ifdef CHART_IMPLEMENT Menu_EnableItem(g_hMenuChart,false); #endif Menu_EnableItem(g_hMenuRefresh, false); MCONTACT hContact = MCONTACT(wp); if (NULL == hContact) { return 0; } Menu_EnableItem(g_hMenuEditSettings, true); Menu_EnableItem(g_hMenuRefresh, true); tstring sLogFileName; bool bThereIsLogFile = (true == get_log_file(hContact, sLogFileName)) && (false == sLogFileName.empty()) && (0 == _taccess(sLogFileName.c_str(), 04)); if (true == bThereIsLogFile) { #ifdef CHART_IMPLEMENT Menu_EnableItem(g_hMenuChart,true); #endif Menu_EnableItem(g_hMenuOpenLogFile, true); } return 0; }
INT_PTR CMsnProto::MsnSendNetMeeting(WPARAM wParam, LPARAM) { if (!msnLoggedIn) return 0; MCONTACT hContact = MCONTACT(wParam); char szEmail[MSN_MAX_EMAIL_LEN]; if (MSN_IsMeByContact(hContact, szEmail)) return 0; ThreadData* thread = MSN_GetThreadByContact(szEmail); if (thread == NULL) { MessageBox(NULL, TranslateT("You must be talking to start Netmeeting"), TranslateT("MSN Protocol"), MB_OK | MB_ICONERROR); return 0; } char msg[1024]; mir_snprintf(msg, _countof(msg), "Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n\r\n" "Application-Name: NetMeeting\r\n" "Application-GUID: {44BBA842-CC51-11CF-AAFA-00AA00B6015C}\r\n" "Session-Protocol: SM1\r\n" "Invitation-Command: INVITE\r\n" "Invitation-Cookie: %i\r\n" "Session-ID: {1A879604-D1B8-11D7-9066-0003FF431510}\r\n\r\n", MSN_GenRandom()); thread->sendMessage('N', NULL, 1, msg, MSG_DISABLE_HDR); return 0; }
INT_PTR MirandaContact::onMenuCommandTransliterate(WPARAM wParam, LPARAM) { MCONTACT hContact = MCONTACT(wParam); if (!CallService(MS_DB_CONTACT_IS, wParam, 0)) return 0; save(hContact, !bIsActive(hContact)); return 0; }
int MirandaContact::onPreBuildContactMenu(WPARAM wParam, LPARAM) { if (!hTransliterateCmdMenuItem) return 0; MCONTACT hContact = MCONTACT(wParam); if (!CallService(MS_DB_CONTACT_IS, wParam, 0)) return 0; Menu_ModifyItem(hTransliterateCmdMenuItem, NULL, INVALID_HANDLE_VALUE, bIsActive(hContact) ? CMIF_CHECKED : 0); return 0; }
int QuotesEventFunc_OnContactDeleted(WPARAM wParam, LPARAM) { MCONTACT hContact = MCONTACT(wParam); const CModuleInfo::TQuotesProvidersPtr& pProviders = CModuleInfo::GetQuoteProvidersPtr(); CQuotesProviders::TQuotesProviderPtr pProvider = pProviders->GetContactProviderPtr(hContact); if (pProvider) pProvider->DeleteContact(hContact); return 0; }
INT_PTR QuotesMenu_OpenLogFile(WPARAM wp, LPARAM) { MCONTACT hContact = MCONTACT(wp); if (NULL == hContact) return 0; tstring sLogFileName; if ((true == get_log_file(hContact, sLogFileName)) && (false == sLogFileName.empty())) ::ShellExecute(NULL, _T("open"), sLogFileName.c_str(), NULL, NULL, SW_SHOWNORMAL); return 0; }
INT_PTR QuotesMenu_RefreshContact(WPARAM wp, LPARAM) { MCONTACT hContact = MCONTACT(wp); if (NULL == hContact) return 0; CQuotesProviders::TQuotesProviderPtr pProvider = CModuleInfo::GetQuoteProvidersPtr()->GetContactProviderPtr(hContact); if (!pProvider) return 0; pProvider->RefreshContact(hContact); return 0; }
INT_PTR FacebookProto::Poke(WPARAM wParam,LPARAM lParam) { if (wParam == NULL || isOffline()) return 1; MCONTACT hContact = MCONTACT(wParam); ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); if (id == NULL) return 1; ForkThread(&FacebookProto::SendPokeWorker, new std::string(id)); return 0; }
INT_PTR FacebookProto::RequestFriendship(WPARAM wParam,LPARAM lParam) { if (wParam == NULL || isOffline()) return 1; MCONTACT hContact = MCONTACT(wParam); ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); if (id == NULL) return 1; ForkThread(&FacebookProto::AddContactToServer, new std::string(id)); return 0; }
INT_PTR FacebookProto::VisitFriendship(WPARAM wParam,LPARAM lParam) { MCONTACT hContact = MCONTACT(wParam); if (wParam == 0 || !IsMyContact(hContact)) return 1; ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); std::string url = FACEBOOK_URL_PROFILE; url += facy.self_.user_id; url += "&and=" + std::string(id); OpenUrl(url); return 0; }
static INT_PTR CALLBACK QuoteInfoDlgProc1(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) { MCONTACT hContact = NULL; MWindowList hWL; switch (msg) { case WM_INITDIALOG: hContact = MCONTACT(lParam); hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX_INFO, false); assert(hWL); WindowList_Add(hWL, hdlg, hContact); ::SetWindowLongPtr(hdlg, GWLP_USERDATA, hContact); Utils_RestoreWindowPositionNoSize(hdlg, hContact, QUOTES_MODULE_NAME, WINDOW_PREFIX_INFO); ::ShowWindow(hdlg, SW_SHOW); break; case WM_CLOSE: DestroyWindow(hdlg); return FALSE; case WM_DESTROY: hContact = get_contact(hdlg); if (hContact) { SetWindowLongPtr(hdlg, GWLP_USERDATA, 0); hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX_INFO, false); assert(hWL); WindowList_Remove(hWL, hdlg); Utils_SaveWindowPosition(hdlg, hContact, QUOTES_MODULE_NAME, WINDOW_PREFIX_INFO); } return FALSE; case WM_COMMAND: if (LOWORD(wParam) == IDOK) { ::DestroyWindow(hdlg); return FALSE; } default: hContact = get_contact(hdlg); break; } return QuoteInfoDlgProcImpl(hContact, hdlg, msg, wParam, lParam); }
INT_PTR FacebookProto::VisitConversation(WPARAM wParam, LPARAM) { MCONTACT hContact = MCONTACT(wParam); if (wParam == 0 || !IsMyContact(hContact, true)) return 1; bool isChat = isChatRoom(hContact); ptrA id(getStringA(hContact, isChat ? FACEBOOK_KEY_TID : FACEBOOK_KEY_ID)); if (id == NULL) return 1; std::string url = FACEBOOK_URL_CONVERSATION + std::string(isChat ? "conversation-" : "") + std::string(id); OpenUrl(url); return 0; }
static int PrebuildContactMenu(WPARAM wParam, LPARAM lParam) { // Hide our all contact menu items first Menu_ShowItem(g_hContactMenuVisitProfile, false); Menu_ShowItem(g_hContactMenuVisitFriendship, false); Menu_ShowItem(g_hContactMenuAuthRevoke, false); Menu_ShowItem(g_hContactMenuAuthAsk, false); Menu_ShowItem(g_hContactMenuAuthGrant, false); Menu_ShowItem(g_hContactMenuAuthCancel, false); Menu_ShowItem(g_hContactMenuAuthDeny, false); Menu_ShowItem(g_hContactMenuPoke, false); Menu_ShowItem(g_hContactMenuPostStatus, false); Menu_ShowItem(g_hContactMenuVisitConversation, false); // Process them in correct account FacebookProto *proto = GetInstanceByHContact(MCONTACT(wParam)); return proto ? proto->OnPrebuildContactMenu(wParam, lParam) : 0; }
int WhatsAppProto::RequestFriendship(WPARAM wParam, LPARAM lParam) { if (wParam == NULL || isOffline()) return 0; MCONTACT hContact = MCONTACT(wParam); DBVARIANT dbv; if ( !getString(hContact, WHATSAPP_KEY_ID, &dbv)) { std::string id(dbv.pszVal); this->connection->sendQueryLastOnline(id); this->connection->sendPresenceSubscriptionRequest(id); db_free(&dbv); } return 0; }
INT_PTR FacebookProto::VisitConversation(WPARAM wParam, LPARAM lParam) { MCONTACT hContact = MCONTACT(wParam); if (wParam == 0 || !IsMyContact(hContact, true)) return 1; std::string url = FACEBOOK_URL_CONVERSATION; if (isChatRoom(hContact)) { url += "conversation-"; url += ptrA(getStringA(hContact, FACEBOOK_KEY_TID)); } else { url += ptrA(getStringA(hContact, FACEBOOK_KEY_ID)); } OpenUrl(url); return 0; }
int Quotes_OnContactDoubleClick(WPARAM wp, LPARAM/* lp*/) { MCONTACT hContact = MCONTACT(wp); if (CModuleInfo::GetQuoteProvidersPtr()->GetContactProviderPtr(hContact)) { MWindowList hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX_INFO, true); assert(hWL); HWND hWnd = WindowList_Find(hWL, hContact); if (NULL != hWnd) { SetForegroundWindow(hWnd); SetFocus(hWnd); } else if (true == IsMyContact(hContact)) CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG_QUOTE_INFO_1), NULL, QuoteInfoDlgProc1, LPARAM(hContact)); return 1; } return 0; }
INT_PTR FacebookProto::CancelFriendship(WPARAM wParam, LPARAM lParam) { if (wParam == NULL || isOffline()) return 1; bool deleting = (lParam == 1); MCONTACT hContact = MCONTACT(wParam); // Ignore groupchats and, if deleting, also not-friends if (isChatRoom(hContact) || (deleting && getByte(hContact, FACEBOOK_KEY_CONTACT_TYPE) != CONTACT_FRIEND)) return 0; ptrT tname(getTStringA(hContact, FACEBOOK_KEY_NICK)); if (tname == NULL) tname = getTStringA(hContact, FACEBOOK_KEY_ID); if (tname == NULL) return 1; TCHAR tstr[256]; mir_sntprintf(tstr, TranslateT("Do you want to cancel your friendship with '%s'?"), tname); if (MessageBox(0, tstr, m_tszUserName, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2) == IDYES) { ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); if (id == NULL) return 1; std::string *val = new std::string(id); if (deleting) { facebook_user *fbu = facy.buddies.find(*val); if (fbu != NULL) fbu->handle = NULL; } ForkThread(&FacebookProto::DeleteContactFromServer, val); } return 0; }
MCONTACT CQuotesProviderBase::CreateNewContact(const tstring& rsName) { MCONTACT hContact = MCONTACT(CallService(MS_DB_CONTACT_ADD, 0, 0)); if (hContact) { if (0 == Proto_AddToContact(hContact, QUOTES_PROTOCOL_NAME)) { tstring sProvName = GetInfo().m_sName; db_set_ts(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_PROVIDER, sProvName.c_str()); db_set_ts(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_SYMBOL, rsName.c_str()); db_set_ts(hContact, LIST_MODULE_NAME, CONTACT_LIST_NAME, rsName.c_str()); mir_cslock lck(m_cs); m_aContacts.push_back(hContact); } else { CallService(MS_DB_CONTACT_DELETE, WPARAM(hContact), 0); hContact = NULL; } } return hContact; }
int QuotesEventFunc_OnUserInfoInit(WPARAM wp, LPARAM lp) { MCONTACT hContact = MCONTACT(lp); if (NULL == hContact) return 0; if (false == IsMyContact(hContact)) return 0; g_hContact = hContact; OPTIONSDIALOGPAGE odp = { 0 }; odp.hInstance = g_hInstance; odp.hIcon = Quotes_LoadIconEx(ICON_STR_MAIN); odp.pfnDlgProc = QuoteInfoDlgProc; odp.position = -2000000000; odp.pszTemplate = MAKEINTRESOURCEA(IDD_DIALOG_QUOTE_INFO); odp.pszTitle = LPGEN("Quote"); UserInfo_AddPage(wp, &odp); return 0; }
INT_PTR FacebookProto::VisitProfile(WPARAM wParam,LPARAM lParam) { MCONTACT hContact = MCONTACT(wParam); std::string url = FACEBOOK_URL_PROFILE; ptrA val(getStringA(hContact, "Homepage")); if (val != NULL) { // Homepage link already present, get it url = val; } else { // No homepage link, create and save it val = getStringA(hContact, FACEBOOK_KEY_ID); if (val != NULL) { url += val; setString(hContact, "Homepage", url.c_str()); } } OpenUrl(url); return 0; }
//----------------------------------------------------------------------------- // Description : External hook //----------------------------------------------------------------------------- INT_PTR status(WPARAM wParam, LPARAM lParam) { return g_speak_config->status(reinterpret_cast<WCHAR *>(lParam), MCONTACT(wParam)); }
INT_PTR GlobalService(WPARAM wParam, LPARAM lParam) { FacebookProto *proto = GetInstanceByHContact(MCONTACT(wParam)); return proto ? (proto->*Fcn)(wParam, lParam) : 0; }
//----------------------------------------------------------------------------- // Description : an status change event occured //----------------------------------------------------------------------------- int eventStatusChange(WPARAM wParam, LPARAM lParam) { g_speak_announce->statusChange(reinterpret_cast<DBCONTACTWRITESETTING *>(lParam), MCONTACT(wParam)); return 0; }
INT_PTR message(WPARAM wParam, LPARAM lParam) { return g_speak_config->message(reinterpret_cast<WCHAR *>(lParam), MCONTACT(wParam)); }
inline MCONTACT get_contact(HWND hWnd) { return MCONTACT(GetWindowLongPtr(hWnd, GWLP_USERDATA)); }