Exemple #1
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 );
}
Exemple #2
0
void __stdcall RemoveLinebreaks( CMString& Message )
{
    while ( Message.Find( _T("\r\n\r\n"), 0) != -1 )
        ReplaceString( Message, _T("\r\n\r\n"), _T("\r\n"));

    if (Message.Find( _T("\r\n"), 0) == 0)
        Message.Delete(0,2);

    if ( (Message.GetLength() > 1) && (Message.Find(_T("\r\n"), Message.GetLength()-2) == 0) )
        Message.Delete(Message.GetLength()-2, 2);
}
Exemple #3
0
CVKNewsItem* CVkProto::GetVkNotificationsItem(const JSONNode &jnItem, OBJLIST<CVkUserInfo> &vkUsers)
{
    debugLogA("CVkProto::GetVkNotificationsItem");
    if (!jnItem)
        return NULL;

    CMString tszType(jnItem["type"].as_mstring());
    VKObjType vkFeedbackType = vkNull, vkParentType = vkNull;
    CMString tszNotificationTranslate = SpanVKNotificationType(tszType, vkFeedbackType, vkParentType);

    const JSONNode &jnFeedback = jnItem["feedback"];
    const JSONNode &jnParent = jnItem["parent"];

    if (!jnFeedback || !jnParent)
        return NULL;

    CVkUserInfo *vkUser = NULL;
    CMString tszFeedback = GetVkFeedback(jnFeedback, vkFeedbackType, vkUsers, vkUser);
    CVKNewsItem* vkNotification = GetVkParent(jnParent, vkParentType);

    if (!vkNotification)
        return NULL;

    if (vkNotification && !tszFeedback.IsEmpty()) {
        CMString tszNotificaton;
        tszNotificaton.AppendFormat(tszFeedback, tszNotificationTranslate, vkNotification->tszText);
        vkNotification->tszText = tszNotificaton;

        tszFeedback = RemoveBBC(tszFeedback);
        int idx = tszFeedback.Find(_T(" %s %s"));

        vkNotification->tszPopupTitle.AppendFormat(_T("%s %s"), tszFeedback.Mid(0, idx), tszNotificationTranslate);
        if (tszFeedback.GetLength() > idx + 7) {
            if (!vkNotification->tszPopupText.IsEmpty())
                vkNotification->tszPopupText += _T("\n>> ");
            vkNotification->tszPopupText += tszFeedback.Mid(idx + 7, tszFeedback.GetLength() - idx - 7);
        }

        vkNotification->tszType = tszType;
        vkNotification->tDate = jnItem["date"].as_int();
        vkNotification->vkFeedbackType = vkFeedbackType;
        vkNotification->vkParentType = vkParentType;
        vkNotification->vkUser = vkUser;
        return vkNotification;
    }

    delete vkNotification;
    return NULL;
}
Exemple #4
0
CMString ExpandPath(const TCHAR *format)
{
	CMString res;

	if (ServiceExists(MS_VARS_FORMATSTRING))
		res = VARST(ptrT(variables_parse((TCHAR*)format, NULL, NULL)));
	else
		res = VARST(format);

	res.Replace(PROFILE_PATHT, szCurrentProfilePath);
	res.Replace(CURRENT_PROFILET, szCurrentProfile);
	res.Replace(MIRANDA_PATHT, szMirandaPath);
	res.Replace(MIRANDA_USERDATAT, szUserDataPath);
	res.Trim();

	// also remove the trailing slash
	if (!res.IsEmpty()) {
		int iNewSize = res.GetLength() - 1;
		switch (res[iNewSize]) {
		case '\\': case '/':
			res.Truncate(iNewSize);
		}
	}

	return res;
}
Exemple #5
0
int NFAEndOfLineUNode::match(const CMString & str, WCMatcher * matcher, const int curInd) const
{
	if (curInd >= str.GetLength() || str[curInd] == '\n' || str[curInd] == '\r')
		return next->match(str, matcher, curInd);

	return -1;
}
Exemple #6
0
int NFACIClassUNode::match(const CMString & str, WCMatcher * matcher, const int curInd) const
{
	if (curInd < str.GetLength() && ((vals.find(to_lower(str[curInd])) != vals.end()) ^ inv))
		return next->match(str, matcher, curInd + 1);

	return -1;
}
Exemple #7
0
bool GetSmileyFile(CMString& url, const CMString& packstr)
{
	_TPattern *urlsplit = _TPattern::compile(_T(".*/(.*)"));
	_TMatcher *m0 = urlsplit->createTMatcher(url);

	m0->findFirstMatch();

	CMString filename;
	filename.AppendFormat(_T("%s\\%s\\"), cachepath, packstr.c_str());
	int pathpos = filename.GetLength();
	filename += m0->getGroup(1);

	delete m0;
	delete urlsplit;

	bool needext = filename.Find('.') == -1;
	if (needext)
		filename += _T(".*");

	_tfinddata_t c_file;
	INT_PTR hFile = _tfindfirst((TCHAR*)filename.c_str(), &c_file);
	if (hFile > -1) {
		_findclose(hFile);
		filename.Truncate(pathpos);
		filename += c_file.name;
		url = filename;
		return false;
	}
	if (needext)
		filename.Truncate(filename.GetLength() - 1);

	WaitForSingleObject(g_hDlMutex, 3000);
	dlQueue.insert(new QueueElem(url, filename, needext));
	ReleaseMutex(g_hDlMutex);

	if (!threadRunning) {
		threadRunning = true;
		mir_forkthread(SmileyDownloadThread, NULL);
	}

	url = filename;
	return false;
}
CMString  CMString::operator+(const CMString&str)const
{
    if(str.GetLength()==0)
        return *this;
    WCHAR *temp=NULL;
    INT32 len=str.GetLength()+GetLength();
    temp = new WCHAR[len+1];
    ASSERT(temp!=NULL);
    if(len>0)
    {
        wcscpy(temp,m_sData);
        wcscat(temp,str.m_sData);
    }
    else
        temp[0]=L'\0';
    CMString stv = temp;
    delete []temp;
    temp = NULL;
    return stv;
}
Exemple #9
0
int NFAReferenceUNode::match(const CMString & str, WCMatcher * matcher, const int curInd) const
{
	int len = matcher->ends[gi] - matcher->starts[gi];
	int ni = -1;
	if (gi < 1 || matcher->ends[gi] < matcher->starts[gi] || len == 0)   ni = curInd;
	else if (curInd + len > (int)str.GetLength())                        return -1;
	else if (str.Mid(curInd, len) != str.Mid(matcher->starts[gi], len))  return -1;
	else                                                                 ni = curInd + len;

	return next->match(str, matcher, ni);
}
Exemple #10
0
int NFAWordBoundaryUNode::match(const CMString & str, WCMatcher * matcher, const int curInd) const
{
	int len = str.GetLength();

	wchar_t c1 = (curInd - 1 < len && curInd > 0) ? str[curInd - 1] : '\n';
	wchar_t c2 = (curInd < len) ? str[curInd] : '\n';

	if (curInd == len) return next->match(str, matcher, curInd);
	bool ok = is_alpha(c1) != is_alpha(c2);
	if (ok && pos) return next->match(str, matcher, curInd);
	return -1;
}
Exemple #11
0
int NFAEndUNode::match(const CMString & str, WCMatcher * matcher, const int curInd) const
{
	matcher->ends[0] = curInd;
	if ((matcher->getFlags() & WCMatcher::MATCH_ENTIRE_STRING) != 0) {
		if (curInd == str.GetLength())
			return curInd;

		matcher->ends[0] = -1;
		return -1;
	}
	return curInd;
}
CMString::CMString(const CMString& str)
{
	m_cdata = NULL;
	INT32 len=str.GetLength();
    m_sData=new WCHAR[len+1];
    ASSERT(m_sData!=NULL);
     if(len>0)
         wcscpy(m_sData,str.m_sData);
     else
         m_sData[0]=L'\0';

}
Exemple #13
0
CMString WCPattern::classNegate(CMString s1) const
{
	wchar_t * out = new wchar_t[66000];
	int i, ind = 0;
	std::map<wchar_t, bool> m;

	for (i = 0; i < s1.GetLength(); ++i) m[s1[i]] = 1;
	for (i = 0xFF; i >= 0; --i) if (m.find((wchar_t)i) == m.end()) out[ind++] = (wchar_t)i;
	out[ind] = 0;
	CMString ret(out, ind);
	delete[] out;
	return ret;
}
Exemple #14
0
// we assume that it could be called only for the metacontacts
static int Meta_SrmmIconClicked(WPARAM hMeta, LPARAM lParam)
{
	StatusIconClickData *sicd = (StatusIconClickData*)lParam;
	if (lstrcmpA(sicd->szModule, META_PROTO))
		return 0;

	DBCachedContact *cc = CheckMeta(hMeta);
	if (cc == NULL)
		return 0;

	HMENU hMenu = CreatePopupMenu();
	int iDefault = Meta_GetContactNumber(cc, db_mc_getSrmmSub(cc->contactID));

	MENUITEMINFO mii = { sizeof(mii) };
	mii.fMask = MIIM_ID | MIIM_STATE | MIIM_STRING;
	for (int i = 0; i < cc->nSubs; i++)	{
		char *szProto = GetContactProto(cc->pSubs[i]);
		if (szProto == NULL) continue;

		PROTOACCOUNT *pa = ProtoGetAccount(szProto);
		if (pa == NULL)
			continue;

		CMString tszNick;
		if (options.menu_contact_label == DNT_DID)
			tszNick = cli.pfnGetContactDisplayName(cc->pSubs[i], 0);
		else
			Meta_GetSubNick(hMeta, i, tszNick);
		tszNick.AppendFormat(_T(" [%s]"), pa->tszAccountName);

		mii.wID = i + 1;
		mii.fState = (i == iDefault) ? MFS_CHECKED : MFS_ENABLED;
		mii.dwTypeData = tszNick.GetBuffer();
		mii.cch = tszNick.GetLength();
		InsertMenuItem(hMenu, i, TRUE, &mii);
	}

	UINT res = TrackPopupMenu(hMenu, TPM_NONOTIFY | TPM_RETURNCMD | TPM_BOTTOMALIGN | TPM_LEFTALIGN, sicd->clickLocation.x, sicd->clickLocation.y, 0, cli.hwndContactTree, NULL);
	if (res > 0) {
		MCONTACT hChosen = Meta_GetContactHandle(cc, res - 1);

		MetaSrmmData tmp = { cc->contactID };
		if (MetaSrmmData *p = arMetaWindows.find(&tmp))
			p->m_hSub = hChosen;

		db_mc_setDefault(cc->contactID, hChosen, true);
	}
	return 0;
}
Exemple #15
0
MIR_CORE_DLL(void) Bitmap_GetFilter(TCHAR *dest, size_t destLen)
{
	if (dest == NULL)
		return;

	CMString filter;
	filter.AppendFormat(_T("%s (*.bmp;*.jpg;*.gif;*.png)%c*.BMP;*.RLE;*.JPG;*.JPEG;*.GIF;*.PNG%c"), TranslateT("All Files"), 0, 0);
	filter.AppendFormat(_T("%s (*.bmp;*.rle)%c*.BMP;*.RLE%c"), TranslateT("Windows bitmaps"), 0, 0);
	filter.AppendFormat(_T("%s (*.jpg;*.jpeg)%c*.JPG;*.JPEG%c"), TranslateT("JPEG bitmaps"), 0, 0);
	filter.AppendFormat(_T("%s (*.gif)%c*.GIF%c"), TranslateT("GIF bitmaps"), 0, 0);
	filter.AppendFormat(_T("%s (*.png)%c*.PNG%c"), TranslateT("PNG bitmaps"), 0, 0);
	filter.AppendChar(0);

	_tcsncpy_s(dest, destLen, filter, filter.GetLength());
}
Exemple #16
0
BOOL CMPath::PathExist(const CMString& sPathName)
{
    CMString str = sPathName;
#ifdef PLAT_SYMBIAN
     TPtrC ptr((const TUint16*)str.GetBuffer(),str.GetLength());
    if(BaflUtils::PathExists(CCoeEnv::Static()->FsSession(), ptr)==EFalse)  
        return FALSE;
#else
	::WIN32_FIND_DATA fd;
	HANDLE hd=::FindFirstFile(str,&fd);
	if(hd==INVALID_HANDLE_VALUE)
		return FALSE;
	::CloseHandle(hd);
#endif
    return TRUE;
}
Exemple #17
0
int NFAEndOfInputUNode::match(const CMString & str, WCMatcher * matcher, const int curInd) const
{
	int len = str.GetLength();
	if (curInd == len) return next->match(str, matcher, curInd);
	else if (term)
	{
		if (curInd == len - 1 && (str[curInd] == '\r' || str[curInd] == '\n'))
		{
			return next->match(str, matcher, curInd);
		}
		else if (curInd == len - 2 && str.Mid(curInd, 2) == L"\r\n")
		{
			return next->match(str, matcher, curInd);
		}
	}
	return -1;
}
Exemple #18
0
void SmileyCategoryListType::AddAllProtocolsAsCategory(void)
{
	CMString displayName = TranslateT("Standard");
	CMString tname = _T("Standard");
	AddCategory(tname, displayName, smcStd);

	const CMString &defaultFile = GetSmileyCategory(tname)->GetFilename();

	PROTOCOLDESCRIPTOR **proto;
	int protoCount = 0;
	Proto_EnumProtocols(&protoCount, &proto);

	for (int i = 0; i < protoCount; i++) {
		PROTOCOLDESCRIPTOR *pd = proto[i];
		if (pd->type == PROTOTYPE_PROTOCOL && pd->cbSize == sizeof(*pd))
			AddProtoAsCategory(pd->szName, defaultFile);
	}

	PROTOACCOUNT **accList;
	Proto_EnumAccounts(&protoCount, &accList);
	for (int i = 0; i < protoCount; i++)
		AddAccountAsCategory(accList[i], defaultFile);

	for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
		AddContactTransportAsCategory(hContact, defaultFile);

	CMString cats;
	opt.ReadCustomCategories(cats);

	int cppv = 0;
	for (;;) {
		int cp = cats.Find('#', cppv);
		if (cp == -1)
			break;

		displayName = cats.Mid(cppv, cp - cppv);
		AddCategory(displayName, displayName, smcCustom, defaultFile);
		cppv = cp + 1;
	}

	if (cppv != cats.GetLength()) {
		displayName = cats.Mid(cppv);
		AddCategory(displayName, displayName, smcCustom, defaultFile);
	}
}
Exemple #19
0
int NFAStartUNode::match(const CMString & str, WCMatcher * matcher, const int curInd) const
{
	int ret = -1, ci = curInd;

	matcher->starts[0] = curInd;
	if ((matcher->getFlags() & WCMatcher::MATCH_ENTIRE_STRING) == (unsigned int)WCMatcher::MATCH_ENTIRE_STRING) {
		if (curInd != 0) {
			matcher->starts[0] = -1;
			return -1;
		}
		return next->match(str, matcher, 0);
	}

	while ((ret = next->match(str, matcher, ci)) == -1 && ci < str.GetLength()) {
		matcher->clearGroups();
		matcher->starts[0] = ++ci;
	}

	if (ret < 0)
		matcher->starts[0] = -1;
	return ret;
}
Exemple #20
0
std::vector<CMString> WCPattern::split(const CMString & str, const bool keepEmptys, const unsigned long limit)
{
	unsigned long lim = (limit == 0 ? MAX_QMATCH : limit);
	int li = 0;
	std::vector<CMString> ret;

	matcher->setString(str);

	while (matcher->findNextMatch() && ret.size() < lim) {
		if (matcher->getStartingIndex() == 0 && keepEmptys) ret.push_back(L"");
		if ((matcher->getStartingIndex() != matcher->getEndingIndex()) || keepEmptys) {
			if (li != matcher->getStartingIndex() || keepEmptys)
				ret.push_back(str.Mid(li, matcher->getStartingIndex() - li));

			li = matcher->getEndingIndex();
		}
	}

	if (li < str.GetLength())
		ret.push_back(str.Mid(li));

	return ret;
}
Exemple #21
0
/**
 * normalize the status message with proper cr/lf sequences.
 * @param src TCHAR*:		original status message
 * @param fStripAll bool:	strip all cr/lf sequences and replace them with spaces (use for title bar)
 * @return TCHAR*:			converted status message. CALLER is responsible to mir_free it, MUST use mir_free()
 */
TCHAR* CContactCache::getNormalizedStatusMsg(const TCHAR *src, bool fStripAll)
{
	if (src == 0 || mir_tstrlen(src) < 2)
		return 0;

	CMString dest;

	for (int i = 0; src[i] != 0; i++) {
		if (src[i] == 0x0d || src[i] == '\t')
			continue;
		if (i && src[i] == (TCHAR)0x0a) {
			if (fStripAll) {
				dest.AppendChar(' ');
				continue;
			}
			dest.AppendChar('\n');
			continue;
		}
		dest.AppendChar(src[i]);
	}

	return mir_tstrndup(dest, dest.GetLength());
}
Exemple #22
0
LPTSTR CJabberProto::GetResourceList(LPCTSTR jid)
{
	if (jid == NULL)
		return NULL;

	mir_cslock lck(m_csLists);
	JABBER_LIST_ITEM *item = NULL;
	if ((item = ListGetItemPtr(LIST_VCARD_TEMP, jid)) == NULL)
		item = ListGetItemPtr(LIST_ROSTER, jid);
	if (item == NULL)
		return NULL;

	if (!item->arResources.getCount())
		return NULL;

	CMString res;
	for (int i=0; i < item->arResources.getCount(); i++) {
		res.Append(item->arResources[i]->m_tszResourceName);
		res.AppendChar(0);
	}
	res.AppendChar(0);

	return mir_tstrndup(res, res.GetLength());
}
Exemple #23
0
int NFAQuoteUNode::match(const CMString & str, WCMatcher * matcher, const int curInd) const
{
	if (curInd + qStr.GetLength() > str.GetLength()) return -1;
	if (str.Mid(curInd, qStr.GetLength()) != qStr) return -1;
	return next->match(str, matcher, curInd + qStr.GetLength());
}
Exemple #24
0
static CMString FormatOutput (const CIrcMessage* pmsg)
{
	CMString sMessage;

	if ( pmsg->m_bIncoming ) { // Is it an incoming message?
		if ( pmsg->sCommand == _T("WALLOPS") && pmsg->parameters.getCount() > 0 ) {
			TCHAR temp[200]; *temp = '\0';
			mir_sntprintf(temp, SIZEOF(temp), TranslateT("WallOps from %s: "), pmsg->prefix.sNick.c_str());
			sMessage = temp;
			for ( int i=0; i < (int)pmsg->parameters.getCount(); i++ ) {
				sMessage += pmsg->parameters[i];
				if (i != pmsg->parameters.getCount()-1)
					sMessage += _T(" ");
			}
			goto THE_END;
		}
		
		if ( pmsg->sCommand == _T("INVITE") && pmsg->parameters.getCount() > 1 ) {
			TCHAR temp[256]; *temp = '\0';
			mir_sntprintf(temp, SIZEOF(temp), TranslateT("%s invites you to %s"), pmsg->prefix.sNick.c_str(), pmsg->parameters[1].c_str());
			sMessage = temp;
			for ( int i=2; i < (int)pmsg->parameters.getCount(); i++ ) {
				sMessage += _T(": ") + pmsg->parameters[i];
				if ( i != pmsg->parameters.getCount()-1 )
					sMessage += _T(" ");
			}
			goto THE_END;
		}
		
		int index = StrToInt( pmsg->sCommand.c_str());
		if ( index == 301 && pmsg->parameters.getCount() > 0 ) {
			TCHAR temp[500]; *temp = '\0';
			mir_sntprintf(temp, SIZEOF(temp), TranslateT("%s is away"), pmsg->parameters[1].c_str());
			sMessage = temp;
			for ( int i=2; i < (int)pmsg->parameters.getCount(); i++ ) {
				sMessage += _T(": ") + pmsg->parameters[i];
				if ( i != pmsg->parameters.getCount()-1 )
					sMessage += _T(" ");
			}
			goto THE_END;
		}
		
		if (( index == 443 || index == 441 ) && pmsg->parameters.getCount() > 3 )
			return pmsg->parameters[1] + _T(" ") + pmsg->parameters[3] + _T(": ") + pmsg->parameters[2];
		
		if ( index == 303 ) {  // ISON command
			sMessage = TranslateT("These are online: ");
			for ( int i=1; i < (int)pmsg->parameters.getCount(); i++ ) {
				sMessage += pmsg->parameters[i];
				if (i != pmsg->parameters.getCount()-1)
					sMessage += _T(", ");
			}
			goto THE_END;
		}
		
		if (( index > 400 || index < 500) && pmsg->parameters.getCount() > 2 && pmsg->sCommand[0] == '4' ) //all error messages
			return pmsg->parameters[2] + _T(": ") + pmsg->parameters[1];
	}
	else if ( pmsg->sCommand == _T("NOTICE") && pmsg->parameters.getCount() > 1 ) {
		TCHAR temp[500]; *temp = '\0';

		int l = pmsg->parameters[1].GetLength();
		if ( l > 3 && pmsg->parameters[1][0] == 1 && pmsg->parameters[1][ l-1 ] == 1 ) {
			// CTCP reply
			CMString tempstr = pmsg->parameters[1];
			tempstr.Delete(0,1);
			tempstr.Delete(tempstr.GetLength()-1,1);
			CMString type = GetWord(tempstr.c_str(), 0);
			if ( lstrcmpi(type.c_str(), _T("ping")) == 0)
				mir_sntprintf(temp, SIZEOF(temp), TranslateT("CTCP %s reply sent to %s"), type.c_str(), pmsg->parameters[0].c_str());
			else
				mir_sntprintf(temp, SIZEOF(temp), TranslateT("CTCP %s reply sent to %s: %s"), type.c_str(), pmsg->parameters[0].c_str(), GetWordAddress(tempstr.c_str(), 1));
			sMessage = temp;
		}
		else {
			mir_sntprintf(temp, SIZEOF(temp), TranslateT("Notice to %s: "), pmsg->parameters[0].c_str());
			sMessage = temp;
			for ( int i=1; i < (int)pmsg->parameters.getCount(); i++ ) {
				sMessage += pmsg->parameters[i];
				if (i != pmsg->parameters.getCount()-1)
					sMessage += _T(" ");
		}	}
		goto THE_END;
	}

	// Default Message handler.	

	if ( pmsg->m_bIncoming ) {
		if ( pmsg->parameters.getCount() < 2 && pmsg->parameters.getCount() > 0 )
			return pmsg->sCommand + _T(" : ") + pmsg->parameters[0];
	
		if ( pmsg->parameters.getCount() > 1 )
			for ( int i=1; i < (int)pmsg->parameters.getCount(); i++ )
				sMessage += pmsg->parameters[i] + _T(" ");
	}
	else {
		if ( pmsg->prefix.sNick.GetLength())
			sMessage = pmsg->prefix.sNick + _T(" ");
		sMessage += pmsg->sCommand + _T(" ");
		for ( int i=0; i < (int)pmsg->parameters.getCount(); i++ )
			sMessage += pmsg->parameters[i] + _T(" ");
	}

THE_END:
	return sMessage;
}
Exemple #25
0
int NFACICharUNode::match(const CMString & str, WCMatcher * matcher, const int curInd) const
{
	if (curInd < str.GetLength() && to_lower(str[curInd]) == ch)
		return next->match(str, matcher, curInd + 1);
	return -1;
}
Exemple #26
0
NFAClassUNode::NFAClassUNode(const CMString & clazz, const bool invert)
{
	inv = invert;
	for (int i = 0; i < clazz.GetLength(); ++i)
		vals[clazz[i]] = 1;
}
Exemple #27
0
NFACIClassUNode::NFACIClassUNode(const CMString & clazz, const bool invert)
{
	inv = invert;
	for (int i = 0; i < (int)clazz.GetLength(); ++i)
		vals[to_lower(clazz[i])] = 1;
}
Exemple #28
0
NFAUNode * WCPattern::parse(const bool inParen, const bool inOr, NFAUNode ** end)
{
	NFAUNode * start, *cur, *next = NULL;
	CMString t;
	int grc = groupCount++;
	bool inv, quo;
	bool ahead = 0, pos = 0, noncap = 0, indep = 0;
	unsigned long oldFlags = flags;

	if (inParen) {
		if (pattern[curInd] == '?') {
			++curInd;
			--groupCount;
			if (pattern[curInd] == ':')   { noncap = 1; ++curInd;     grc = --nonCapGroupCount; }
			else if (pattern[curInd] == '=')   { ++curInd;     ahead = 1;  pos = 1; }
			else if (pattern[curInd] == '!')   { ++curInd;     ahead = 1;  pos = 0; }
			else if (pattern.Mid(curInd, 2) == L"<=")  { curInd += 2;  return parseBehind(1, end); }
			else if (pattern.Mid(curInd, 2) == L"<!")  { curInd += 2;  return parseBehind(0, end); }
			else if (pattern[curInd] == '>')   { ++curInd;     indep = 1; }
			else {
				bool negate = false, done = false;
				while (!done) {
					if (curInd >= pattern.GetLength()) {
						raiseError();
						return NULL;
					}
					else if (negate) {
						switch (pattern[curInd]) {
						case 'i': flags &= ~WCPattern::CASE_INSENSITIVE;   break;
						case 'd': flags &= ~WCPattern::UNIX_LINE_MODE;     break;
						case 'm': flags &= ~WCPattern::MULTILINE_MATCHING; break;
						case 's': flags &= ~WCPattern::DOT_MATCHES_ALL;    break;
						case ':': done = true;                             break;
						case ')':
							++curInd;
							*end = registerNode(new NFALookBehindUNode(L"", true));
							return *end;
						case '-':
						default:
							raiseError();
							return NULL;
						}
					}
					else {
						switch (pattern[curInd]) {
						case 'i': flags |= WCPattern::CASE_INSENSITIVE;    break;
						case 'd': flags |= WCPattern::UNIX_LINE_MODE;      break;
						case 'm': flags |= WCPattern::MULTILINE_MATCHING;  break;
						case 's': flags |= WCPattern::DOT_MATCHES_ALL;     break;
						case ':': done = true;                             break;
						case '-': negate = true;                           break;
						case ')':
							++curInd;
							*end = registerNode(new NFALookBehindUNode(L"", true));
							return *end;
						default:
							raiseError();
							return NULL;
						}
					}
					++curInd;
				}
				noncap = 1;
				grc = --nonCapGroupCount;
			}

			if (noncap) cur = start = registerNode(new NFAGroupHeadUNode(grc));
			else        cur = start = registerNode(new NFASubStartUNode);
		}
		else cur = start = registerNode(new NFAGroupHeadUNode(grc));
	}
	else cur = start = registerNode(new NFASubStartUNode);

	while (curInd < pattern.GetLength()) {
		wchar_t ch = pattern[curInd++];

		next = NULL;
		if (error) return NULL;
		switch (ch) {
		case '^':
			if ((flags & WCPattern::MULTILINE_MATCHING) != 0) next = registerNode(new NFAStartOfLineUNode);
			else                                            next = registerNode(new NFAStartOfInputUNode);
			break;
		case '$':
			if ((flags & WCPattern::MULTILINE_MATCHING) != 0) next = registerNode(new NFAEndOfLineUNode);
			else                                            next = registerNode(new NFAEndOfInputUNode(0));
			break;
		case '|':
			--groupCount;
			cur->next = registerNode(new NFAAcceptUNode);
			cur = start = registerNode(new NFAOrUNode(start, parse(inParen, 1)));
			break;
		case '\\':
			if (curInd < pattern.GetLength()) {
				bool eoi = 0;
				switch (pattern[curInd]) {
				case '1':
				case '2':
				case '3':
				case '4':
				case '5':
				case '6':
				case '7':
				case '8':
				case '9': next = parseBackref(); break;
				case 'A': ++curInd; next = registerNode(new NFAStartOfInputUNode);     break;
				case 'B': ++curInd; next = registerNode(new NFAWordBoundaryUNode(0));  break;
				case 'b': ++curInd; next = registerNode(new NFAWordBoundaryUNode(1));  break;
				case 'G': ++curInd; next = registerNode(new NFAEndOfMatchUNode);       break;
				case 'Z': eoi = 1;
				case 'z': ++curInd; next = registerNode(new NFAEndOfInputUNode(eoi));  break;
				default:
					t = parseEscape(inv, quo);
					//printf("inv quo classes { %c %c %s }\n", inv ? 't' : 'f', quo ? 't' : 'f', t.c_str());
					if (!quo) {
						if (t.GetLength() > 1 || inv) {
							if ((flags & WCPattern::CASE_INSENSITIVE) != 0) next = registerNode(new NFACIClassUNode(t, inv));
							else                                            next = registerNode(new NFAClassUNode(t, inv));
						}
						else next = registerNode(new NFACharUNode(t[0]));
					}
					else next = parseQuote();
				}
			}
			else raiseError();
			break;
		case '[':
			if ((flags & WCPattern::CASE_INSENSITIVE) == 0) {
				NFAClassUNode * clazz = new NFAClassUNode();
				CMString s = parseClass();
				for (int i = 0; i < (int)s.GetLength(); ++i) clazz->vals[s[i]] = 1;
				next = registerNode(clazz);
			}
			else {
				NFACIClassUNode * clazz = new NFACIClassUNode();
				CMString s = parseClass();
				for (int i = 0; i < s.GetLength(); ++i) clazz->vals[to_lower(s[i])] = 1;
				next = registerNode(clazz);
			}
			break;
		case '.':
			{
				bool useN = 1, useR = 1;
				NFAClassUNode * clazz = new NFAClassUNode(1);
				if ((flags & WCPattern::UNIX_LINE_MODE) != 0) useR = 0;
				if ((flags & WCPattern::DOT_MATCHES_ALL) != 0) useN = useR = 0;
				if (useN) clazz->vals['\n'] = 1;
				if (useR) clazz->vals['\r'] = 1;
				next = registerNode(clazz);
			}
			break;
		case '(':
			{
				NFAUNode *end, *t1, *t2;
				t1 = parse(1, 0, &end);
				if (!t1) raiseError();
				else if (t1->isGroupHeadNode() && (t2 = quantifyGroup(t1, end, grc)) != NULL) {
					cur->next = t2;
					cur = t2->next;
				}
				else {
					cur->next = t1;
					cur = end;
				}
			}
			break;
		case ')':
			if (!inParen) raiseError();
			else if (inOr) {
				--curInd;
				cur = cur->next = registerNode(new NFAAcceptUNode);
				flags = oldFlags;
				return start;
			}
			else {
				if (ahead) {
					cur = cur->next = registerNode(new NFAAcceptUNode);
					flags = oldFlags;
					return *end = registerNode(new NFALookAheadUNode(start, pos));
				}
				else if (indep) {
					cur = cur->next = registerNode(new NFAAcceptUNode);
					flags = oldFlags;
					return *end = registerNode(new NFAPossessiveQuantifierUNode(this, start, 1, 1));
				}
				else { // capping or noncapping, it doesnt matter
					*end = cur = cur->next = registerNode(new NFAGroupTailUNode(grc));
					next = quantifyGroup(start, *end, grc);
					if (next) {
						start = next;
						*end = next->next;
					}
					flags = oldFlags;
					return start;
				}
			}
			break;
		case '{': // registered pattern
			cur->next = parseRegisteredWCPattern(&next);
			if (cur->next) cur = next;
			break;
		case '*':
		case '+':
		case '?':
			//    case '}':
			//    case ']':
			raiseError();
			break;
		default:
			if ((flags & WCPattern::CASE_INSENSITIVE) != 0) next = registerNode(new NFACICharUNode(ch));
			else                                          next = registerNode(new NFACharUNode(ch));
			break;
		}
		if (next) cur = cur->next = quantify(next);
	}
	if (inParen) raiseError();
	else {
		if (inOr) cur = cur->next = registerNode(new NFAAcceptUNode);
		if (end) *end = cur;
	}

	flags = oldFlags;
	if (error) return NULL;

	return start;
}
Exemple #29
0
int NFACIQuoteUNode::match(const CMString & str, WCMatcher * matcher, const int curInd) const
{
	if (curInd + qStr.GetLength() > str.GetLength()) return -1;
	if (str_icmp(str.Mid(curInd, qStr.GetLength()).c_str(), qStr.c_str())) return -1;
	return next->match(str, matcher, qStr.GetLength());
}
static LRESULT CALLBACK PluginListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg) {
	case WM_CHAR:
		if (wParam == '\b') {
			if (szFilter.GetLength() > 0)
				szFilter.Truncate(szFilter.GetLength() - 1);
		}
		else {
			szFilter.AppendChar(wParam);

			for (int i = 0; i < arPluginList.getCount(); i++) {
				PluginListItemData *p = arPluginList[i];
				if (!_tcsnicmp(szFilter, p->fileName, szFilter.GetLength())) {
					LVFINDINFO lvfi;
					lvfi.flags = LVFI_PARAM;
					lvfi.lParam = (LPARAM)p;
					int idx = ListView_FindItem(hwnd, 0, &lvfi);
					if (idx != -1) {
						ListView_SetItemState(hwnd, idx, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
						ListView_EnsureVisible(hwnd, idx, FALSE);
						if (timerID != 0)
							KillTimer(hwnd, timerID);
						timerID = SetTimer(hwnd, 1, 1500, 0);
						return TRUE;
					}
				}
			}

			szFilter.Truncate(szFilter.GetLength() - 1);
			MessageBeep((UINT)-1);
		}
		return TRUE;

	case WM_TIMER:
		if (wParam == 1) {
			KillTimer(hwnd, timerID);
			timerID = 0;
			szFilter.Empty();
		}
		break;

	case WM_LBUTTONDOWN:
		LVHITTESTINFO hi;
		hi.pt.x = LOWORD(lParam);
		hi.pt.y = HIWORD(lParam);
		ListView_SubItemHitTest(hwnd, &hi);
		// Dynamically load/unload a plugin
		if ((hi.iSubItem == 0) && (hi.flags & LVHT_ONITEMICON)) {
			LVITEM lvi = { 0 };
			lvi.mask = LVIF_IMAGE | LVIF_PARAM;
			lvi.stateMask = -1;
			lvi.iItem = hi.iItem;
			lvi.iSubItem = 0;
			if (ListView_GetItem(hwnd, &lvi)) {
				lvi.mask = LVIF_IMAGE;
				PluginListItemData *dat = (PluginListItemData*)lvi.lParam;
				if (lvi.iImage == 3) {
					// load plugin
					if (LoadPluginDynamically(dat)) {
						lvi.iImage = 2;
						ListView_SetItem(hwnd, &lvi);
					}
				}
				else if (lvi.iImage == 2) {
					// unload plugin
					if (UnloadPluginDynamically(dat)) {
						lvi.iImage = 3;
						ListView_SetItem(hwnd, &lvi);
					}
				}
				LoadStdPlugins();
			}
		}
	}

	return mir_callNextSubclass(hwnd, PluginListWndProc, msg, wParam, lParam);
}