Example #1
0
SESSION_INFO* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO* currSession, SESSION_INFO* prevSession, const TCHAR* pszOriginal, const TCHAR* pszCurrent)
{
	SESSION_INFO* pResult = NULL;
	if (prevSession == NULL && my_strstri(currSession->ptszName, pszOriginal) == currSession->ptszName) {
		pResult = currSession;
	} else {
		TCHAR* pszName = NULL;
		SESSION_INFO* pTemp = m_WndList;
		if (currSession == prevSession) {
			pszCurrent = pszOriginal;
		}
		while (pTemp != NULL) {
			if (pTemp != currSession && !lstrcmpiA(pszModule, pTemp->pszModule)) {
				if (my_strstri(pTemp->ptszName, pszOriginal) == pTemp->ptszName) {
					if (prevSession != pTemp && lstrcmpi(pTemp->ptszName, pszCurrent) > 0 && (!pszName || lstrcmpi(pTemp->ptszName, pszName) < 0)) {
						pResult = pTemp;
						pszName = pTemp->ptszName;
					}
				}
			}
			pTemp = pTemp->next;
		}
	}
	return pResult;

}
Example #2
0
INT_PTR CIrcProto::CallChatEvent(WPARAM wParam, LPARAM lParam)
{
    GCEVENT * gce = (GCEVENT *)lParam;
    INT_PTR iVal = 0;

    // first see if the scripting module should modify or stop this event
    if ( m_bMbotInstalled && m_scriptingEnabled && gce
            && gce->time != 0 && (gce->pDest->pszID == NULL
                                  || lstrlen(gce->pDest->ptszID) != 0 && lstrcmpi(gce->pDest->ptszID , SERVERWINDOW)))
    {
        GCEVENT *gcevent= (GCEVENT*) lParam;
        GCEVENT *gcetemp = NULL;
        WPARAM wp = wParam;
        gcetemp = (GCEVENT *)mir_alloc(sizeof(GCEVENT));
        gcetemp->pDest = (GCDEST *)mir_alloc(sizeof(GCDEST));
        gcetemp->pDest->iType = gcevent->pDest->iType;
        gcetemp->dwFlags = gcevent->dwFlags;
        gcetemp->bIsMe = gcevent->bIsMe;
        gcetemp->cbSize = sizeof(GCEVENT);
        gcetemp->dwItemData = gcevent->dwItemData;
        gcetemp->time = gcevent->time;
        gcetemp->pDest->ptszID = mir_tstrdup( gcevent->pDest->ptszID );
        gcetemp->pDest->pszModule = mir_strdup( gcevent->pDest->pszModule );
        gcetemp->ptszText = mir_tstrdup( gcevent->ptszText );
        gcetemp->ptszUID = mir_tstrdup( gcevent->ptszUID );
        gcetemp->ptszNick = mir_tstrdup( gcevent->ptszNick );
        gcetemp->ptszStatus = mir_tstrdup( gcevent->ptszStatus );
        gcetemp->ptszUserInfo = mir_tstrdup( gcevent->ptszUserInfo );

        if ( Scripting_TriggerMSPGuiIn( &wp, gcetemp ) && gcetemp ) {
            //MBOT CORRECTIONS
            //if ( gcetemp && gcetemp->pDest && gcetemp->pDest->ptszID ) {
            if ( gcetemp && gcetemp->pDest && gcetemp->pDest->ptszID &&
                    !my_strstri(gcetemp->pDest->ptszID, (IsConnected()) ? m_info.sNetwork.c_str() : TranslateT("Offline")) ) {

                CMString sTempId = MakeWndID( gcetemp->pDest->ptszID );
                mir_realloc( gcetemp->pDest->ptszID, sizeof(TCHAR)*(sTempId.GetLength() + 1));
                lstrcpyn(gcetemp->pDest->ptszID, sTempId.c_str(), sTempId.GetLength()+1);
            }
            iVal = CallServiceSync(MS_GC_EVENT, wp, (LPARAM) gcetemp);
        }

        if ( gcetemp ) {
            mir_free(( void* )gcetemp->pszNick);
            mir_free(( void* )gcetemp->pszUID);
            mir_free(( void* )gcetemp->pszStatus);
            mir_free(( void* )gcetemp->pszUserInfo);
            mir_free(( void* )gcetemp->pszText);
            mir_free(( void* )gcetemp->pDest->pszID);
            mir_free(( void* )gcetemp->pDest->pszModule);
            mir_free(( void* )gcetemp->pDest);
            mir_free(( void* )gcetemp);
        }

        return iVal;
    }

    return CallServiceSync( MS_GC_EVENT, wParam, ( LPARAM )gce );
}
Example #3
0
SESSION_INFO* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO* currSession, SESSION_INFO* prevSession, const TCHAR* pszOriginal, const TCHAR* pszCurrent)
{
	if (prevSession == NULL && my_strstri(currSession->ptszName, pszOriginal) == currSession->ptszName)
		return currSession;

	TCHAR* pszName = NULL;
	if (currSession == prevSession)
		pszCurrent = pszOriginal;

	SESSION_INFO *pResult = NULL;
	for (SESSION_INFO *si = pci->wndList; si; si = si->next)
		if (si != currSession && !mir_strcmpi(pszModule, si->pszModule))
			if (my_strstri(si->ptszName, pszOriginal) == si->ptszName)
				if (prevSession != si && mir_tstrcmpi(si->ptszName, pszCurrent) > 0 && (!pszName || mir_tstrcmpi(si->ptszName, pszName) < 0)) {
					pResult = si;
					pszName = si->ptszName;
				}

	return pResult;
}
TCHAR* UM_FindUserAutoComplete(USERINFO* pUserList, const TCHAR* pszOriginal, const TCHAR* pszCurrent)
{
	TCHAR* pszName = NULL;
	USERINFO *pTemp = pUserList;

	if (!pUserList || !pszOriginal || !pszCurrent)
		return NULL;

	while ( pTemp != NULL ) {
		if ( pTemp->pszNick && my_strstri( pTemp->pszNick, pszOriginal) == pTemp->pszNick )
			if ( lstrcmpi( pTemp->pszNick, pszCurrent ) > 0 && ( !pszName || lstrcmpi( pTemp->pszNick, pszName ) < 0) )
				pszName = pTemp->pszNick;

		pTemp = pTemp->next;
	}
	return pszName;
}
char* UM_FindUserAutoComplete(USERINFO* pUserList, char * pszOriginal, char* pszCurrent)
{
	char * pszName = NULL;
	USERINFO *pTemp = pUserList, *pLast = NULL;

	if(!pUserList || !pszOriginal || !pszCurrent)
		return NULL;

	while (pTemp != NULL)
	{
		if (my_strstri(pTemp->pszNick,pszOriginal) == pTemp->pszNick)
		{
			if(lstrcmpiA(pTemp->pszNick, pszCurrent) > 0 && (!pszName || lstrcmpiA(pTemp->pszNick, pszName) < 0) )
				pszName =pTemp->pszNick;
		}
		pLast = pTemp;
		pTemp = pTemp->next;
	}
	return pszName;
}