Ejemplo n.º 1
0
void ShowPopup(SHOWPOPUP_DATA *sd)
{
	TCString PopupText;
	if (sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_SHOWPREVCLIENT)) {
		mir_snwprintf(PopupText.GetBuffer(MAX_MSG_LEN), MAX_MSG_LEN, TranslateT("changed client to %s (was %s)"), (const wchar_t*)sd->MirVer, (const wchar_t*)sd->OldMirVer);
		PopupText.ReleaseBuffer();
	}
	else {
		mir_snwprintf(PopupText.GetBuffer(MAX_MSG_LEN), MAX_MSG_LEN, TranslateT("changed client to %s"), (const wchar_t*)sd->MirVer);
		PopupText.ReleaseBuffer();
	}

	PLUGIN_DATA *pdata = (PLUGIN_DATA*)calloc(1, sizeof(PLUGIN_DATA));
	POPUPDATAT ppd = { 0 };
	ppd.lchContact = sd->hContact;
	char *szProto = GetContactProto(sd->hContact);
	pdata->hIcon = ppd.lchIcon = Finger_GetClientIcon(sd->MirVer, false);
	_ASSERT(ppd.lchIcon);
	if (!ppd.lchIcon || (INT_PTR)ppd.lchIcon == CALLSERVICE_NOTFOUND) {
		// if we didn't succeed retrieving client icon, show the usual status icon instead
		ppd.lchIcon = Skin_LoadProtoIcon(szProto, db_get_w(sd->hContact, szProto, "Status", ID_STATUS_OFFLINE));
		pdata->hIcon = nullptr;
	}
	wcsncpy(ppd.lptzContactName, Clist_GetContactDisplayName(sd->hContact), _countof(ppd.lptzContactName) - 1);
	wcsncpy(ppd.lptzText, PopupText, _countof(ppd.lptzText) - 1);
	ppd.colorBack = (sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_DEFBGCOLOUR) ? 0 : sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_BGCOLOUR));
	ppd.colorText = (sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_DEFTEXTCOLOUR) ? 0 : sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_TEXTCOLOUR));
	ppd.PluginWindowProc = PopupWndProc;
	pdata->PopupLClickAction = sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_LCLICK_ACTION);
	pdata->PopupRClickAction = sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_RCLICK_ACTION);
	ppd.iSeconds = sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_POPUPDELAY);
	ppd.PluginData = pdata;
	PUAddPopupT(&ppd);
}
Ejemplo n.º 2
0
void ShowPopup(SHOWPOPUP_DATA *sd)
{
	TCString PopupText;
	if (sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_SHOWPREVCLIENT)) {
		mir_sntprintf(PopupText.GetBuffer(MAX_MSG_LEN), MAX_MSG_LEN, TranslateT("changed client to %s (was %s)"), (const TCHAR*)sd->MirVer, (const TCHAR*)sd->OldMirVer);
		PopupText.ReleaseBuffer();
	}
	else {
		mir_sntprintf(PopupText.GetBuffer(MAX_MSG_LEN), MAX_MSG_LEN, TranslateT("changed client to %s"), (const TCHAR*)sd->MirVer);
		PopupText.ReleaseBuffer();
	}

	PLUGIN_DATA *pdata = (PLUGIN_DATA*)calloc(1, sizeof(PLUGIN_DATA));
	POPUPDATAT ppd = {0};
	ppd.lchContact = sd->hContact;
	char *szProto = GetContactProto(sd->hContact);
	pdata->hIcon = ppd.lchIcon = Finger_GetClientIcon(sd->MirVer, false);
	_ASSERT(ppd.lchIcon);
	if (!ppd.lchIcon || (DWORD)ppd.lchIcon == CALLSERVICE_NOTFOUND) {
		// if we didn't succeed retrieving client icon, show the usual status icon instead
		ppd.lchIcon = LoadSkinnedProtoIcon(szProto, db_get_w(sd->hContact, szProto, "Status", ID_STATUS_OFFLINE));
		pdata->hIcon = NULL;
	}
	_tcsncpy(ppd.lptzContactName, (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)sd->hContact, GCDNF_TCHAR), lengthof(ppd.lptzContactName) - 1);
	_tcsncpy(ppd.lptzText, PopupText, lengthof(ppd.lptzText) - 1);
	ppd.colorBack = (sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_DEFBGCOLOUR) ? 0 : sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_BGCOLOUR));
	ppd.colorText = (sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_DEFTEXTCOLOUR) ? 0 : sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_TEXTCOLOUR));
	ppd.PluginWindowProc = PopupWndProc;
	pdata->PopupLClickAction = sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_LCLICK_ACTION);
	pdata->PopupRClickAction = sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_RCLICK_ACTION);
	ppd.iSeconds = sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_POPUPDELAY);
	ppd.PluginData = pdata;
	PUAddPopupT(&ppd);
}
Ejemplo n.º 3
0
int CJabberProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM)
{
    if (hContact == NULL)
        return 0;

    bool bIsChatRoom = isChatRoom(hContact);
    bool bIsTransport = getBool(hContact, "IsTransport", false);

    if ((bIsChatRoom == GCW_CHATROOM) || bIsChatRoom == 0) {
        if (ptrT(getTStringA(hContact, bIsChatRoom ? (char*)"ChatRoomID" : (char*)"jid")) != NULL) {
            Menu_ShowItem(g_hMenuConvert, TRUE);
            Menu_ModifyItem(g_hMenuConvert, bIsChatRoom ? LPGENT("&Convert to Contact") : LPGENT("&Convert to Chat Room"));
        }
    }

    if (!m_bJabberOnline)
        return 0;

    Menu_ShowItem(g_hMenuDirectPresence[0], TRUE);
    for (int i = 0; i < _countof(PresenceModeArray); i++)
        Menu_ModifyItem(g_hMenuDirectPresence[i + 1], NULL, Skin_LoadProtoIcon(m_szModuleName, PresenceModeArray[i].mode));

    if (bIsChatRoom) {
        ptrT roomid(getTStringA(hContact, "ChatRoomID"));
        if (roomid != NULL) {
            Menu_ShowItem(g_hMenuRosterAdd, FALSE);

            if (ListGetItemPtr(LIST_BOOKMARK, roomid) == NULL)
                if (m_ThreadInfo && m_ThreadInfo->jabberServerCaps & JABBER_CAPS_PRIVATE_STORAGE)
                    Menu_ShowItem(g_hMenuAddBookmark, TRUE);
        }
    }

    if (bIsChatRoom == GCW_CHATROOM)
        return 0;

    if (bIsTransport) {
        Menu_ShowItem(g_hMenuLogin, TRUE);
        Menu_ShowItem(g_hMenuRefresh, TRUE);
    }

    ptrT jid(getTStringA(hContact, "jid"));
    if (jid == NULL)
        return 0;

    JabberCapsBits jcb = GetTotalJidCapabilites(jid);
    JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid);
    if (item == NULL)
        return 0;

    bool bCtrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
    Menu_ShowItem(g_hMenuRequestAuth, item->subscription == SUB_FROM || item->subscription == SUB_NONE || bCtrlPressed);
    Menu_ShowItem(g_hMenuGrantAuth, bCtrlPressed);
    Menu_ShowItem(g_hMenuRevokeAuth, item->subscription == SUB_FROM || item->subscription == SUB_BOTH || bCtrlPressed);
    Menu_ShowItem(g_hMenuCommands, ((jcb & JABBER_CAPS_COMMANDS) != 0) || bCtrlPressed);
    Menu_ShowItem(g_hMenuSendNote, TRUE);

    if (item->arResources.getCount() == 0)
        return 0;

    Menu_ShowItem(g_hMenuResourcesRoot, TRUE);
    Menu_ModifyItem(g_hMenuResourcesRoot, NULL, m_hProtoIcon);
    Menu_ModifyItem(g_hMenuResourcesActive, NULL, m_hProtoIcon, (item->resourceMode == RSMODE_LASTSEEN) ? CMIF_CHECKED : 0);
    Menu_ModifyItem(g_hMenuResourcesServer, NULL, m_hProtoIcon, (item->resourceMode == RSMODE_SERVER) ? CMIF_CHECKED : 0);

    int nMenuResourceItemsNew = m_nMenuResourceItems;
    if (m_nMenuResourceItems < item->arResources.getCount()) {
        m_phMenuResourceItems = (HGENMENU*)mir_realloc(m_phMenuResourceItems, item->arResources.getCount() * sizeof(HGENMENU));
        nMenuResourceItemsNew = item->arResources.getCount();
    }

    char text[256];
    CMenuItem mi;
    mi.pszService = text;

    CMString szTmp;
    for (int i = 0; i < nMenuResourceItemsNew; i++) {
        mir_snprintf(text, "/UseResource_%d", i);
        if (i >= m_nMenuResourceItems) {
            CreateProtoServiceParam(text, &CJabberProto::OnMenuHandleResource, MENUITEM_RESOURCES + i);
            mi.name.a = "";
            mi.position = i;
            mi.root = g_hMenuResourcesRoot;
            m_phMenuResourceItems[i] = Menu_AddContactMenuItem(&mi, m_szModuleName);
        }
        if (i < item->arResources.getCount()) {
            pResourceStatus r(item->arResources[i]);

            HICON hIcon = (HICON)INVALID_HANDLE_VALUE;
            Menu_SetChecked(m_phMenuResourceItems[i], item->resourceMode == RSMODE_MANUAL && item->m_pManualResource == r);

            if (ServiceExists(MS_FP_GETCLIENTICONT)) {
                FormatMirVer(r, szTmp);
                hIcon = Finger_GetClientIcon(szTmp, 0);
            }
            szTmp.Format(_T("%s [%s, %d]"), r->m_tszResourceName, pcli->pfnGetStatusModeDescription(r->m_iStatus, 0), r->m_iPriority);
            Menu_ModifyItem(m_phMenuResourceItems[i], szTmp, hIcon);
            DestroyIcon(hIcon);
        }
        else Menu_ShowItem(m_phMenuResourceItems[i], FALSE);
    }

    m_nMenuResourceItems = nMenuResourceItemsNew;
    return 0;
}