Esempio n. 1
0
ImageFType::ImageFType(const unsigned id, const CMString& file)
	: ImageBase(id)
{
	m_bmp = NULL;

	FREE_IMAGE_FORMAT fif = fei->FI_GetFileTypeT(file.c_str(), 0);
	if (fif == FIF_UNKNOWN)
		fif = fei->FI_GetFIFFromFilenameT(file.c_str());
	if (fif == FIF_UNKNOWN) return;

	FIBITMAP *dib = fei->FI_LoadT(fif, file.c_str(), 0);
	if (dib == NULL) return;

	bool transp = fei->FI_IsTransparent(dib) != 0;
	FREE_IMAGE_TYPE imt = fei->FI_GetImageType(dib);
	unsigned bpp = fei->FI_GetBPP(dib);

	if (transp && bpp != 32 || imt == FIT_RGBA16) {
		FIBITMAP *tdib = fei->FI_ConvertTo32Bits(dib);
		fei->FI_Unload(dib);
		dib = tdib;
	}
	else if (!transp && bpp > 24) {
		FIBITMAP *tdib = fei->FI_ConvertTo24Bits(dib);
		fei->FI_Unload(dib);
		dib = tdib;
	}

	m_bmp = fei->FI_CreateHBITMAPFromDIB(dib);
	fei->FI_Unload(dib);

	if (transp)
		fei->FI_Premultiply(m_bmp);
}
Esempio n. 2
0
void SmileyLookup::Find(const CMString& str, SmileyLocVecType& smlcur, bool firstOnly) const
{
	if (!m_valid) return;

	if (m_text.IsEmpty()) {
		_TMatcher* matcher = m_pattern->createTMatcher(str);
		while (matcher->findNextMatch()) {
			int st = matcher->getStartingIndex();
			int sz = matcher->getEndingIndex() - st;
			if (sz != 0) {
				smlcur.insert(new SmileyLocType(st, sz));
				if (firstOnly && m_ind != -1)
					return;
			}
		}
		delete matcher;
	}
	else {
		const TCHAR* pos = str.c_str();
		while ((pos = _tcsstr(pos, m_text.c_str())) != NULL) {
			smlcur.insert(new SmileyLocType(pos - str.c_str(), m_text.GetLength()));
			pos += m_text.GetLength();
			if (firstOnly && m_ind != -1)
				return;
		}
	}
}
Esempio n. 3
0
void CMVArray::Set(int row,int col,const CMString& str)
{
	if (row>=0 && row<_nrows && col>=0 && col<_ncols) {
		size_t index = row*_ncols + col;
		if (isnumber(str.c_str())) {
			double d = _wtof(str.c_str());
			array[index].e = NULL;
			array[index].dVal = d;
		}
		else {
			CMExpression* e = new CMExpression(str.c_str());
			if (e->IsPolynomial()) arraystate |= containsPolynomials;
			if (e->Fail()) {
				SetState(vsFailed, 1);
				ReportError(XBadVardef, e->GetString());
			}
			array[index].e = e;
		}
		/*
		CMExpression* e = new CMExpression(str.c_str());
		if (e->IsPolynomial()) arraystate |= containsPolynomials;
		if (e->Fail()) {
  		 	SetState(vsFailed,1);
   			ReportError(XBadVardef,e->GetString());
	   }
	   array.AddAt((long)row*ncols+col,e);
	   */
	}
}
Esempio n. 4
0
SmileyLookup::SmileyLookup(const CMString& str, const bool regexs, const int ind, const CMString& smpt)
{
	TCHAR msgtxt[1024];

	m_ind = ind;
	if (regexs) {
		static const CMString testString(_T("Test String"));
		m_pattern = _TPattern::compile(str);
		m_valid = m_pattern != NULL;
		if (m_valid) {
			_TMatcher* matcher = m_pattern->createTMatcher(testString);
			m_valid &= (!matcher->findFirstMatch() ||
				matcher->getStartingIndex() != matcher->getEndingIndex());
			if (!m_valid) {
				static const TCHAR errmsg[] = LPGENT("Regular expression \"%s\" in smiley pack \"%s\" could produce \"empty matches\".");
				mir_sntprintf(msgtxt, TranslateTS(errmsg), str.c_str(), smpt.c_str());
			}
			delete matcher;
		}
		else {
			static const TCHAR errmsg[] = LPGENT("Regular expression \"%s\" in smiley pack \"%s\" malformed.");
			mir_sntprintf(msgtxt, TranslateTS(errmsg), str.c_str(), smpt.c_str());
		}

		if (!m_valid)
			CallService(MS_NETLIB_LOG, (WPARAM)hNetlibUser, _T2A(msgtxt));
	}
	else {
		m_text = str;
		m_pattern = NULL;
		m_valid = !str.IsEmpty();
	}
}
Esempio n. 5
0
BOOL CIrcProto::CList_AddDCCChat(const CMString& name, const CMString& hostmask, unsigned long adr, int port)
{
	MCONTACT hContact;
	TCHAR szNick[256];
	char szService[256];
	bool bFlag = false;

	CONTACT usertemp = { (TCHAR*)name.c_str(), NULL, NULL, false, false, true };
	MCONTACT hc = CList_FindContact(&usertemp);
	if (hc && db_get_b(hc, "CList", "NotOnList", 0) == 0 && db_get_b(hc, "CList", "Hidden", 0) == 0)
		bFlag = true;

	CMString contactname = name; contactname += DCCSTRING;

	CONTACT user = { (TCHAR*)contactname.c_str(), NULL, NULL, false, false, true };
	hContact = CList_AddContact(&user, false, false);
	setByte(hContact, "DCC", 1);

	DCCINFO* pdci = new DCCINFO;
	pdci->sHostmask = hostmask;
	pdci->hContact = hContact;
	pdci->dwAdr = (DWORD)adr;
	pdci->iPort = port;
	pdci->iType = DCC_CHAT;
	pdci->bSender = false;
	pdci->sContactName = name;

	if (m_DCCChatAccept == 3 || m_DCCChatAccept == 2 && bFlag) {
		CDccSession* dcc = new CDccSession(this, pdci);

		CDccSession* olddcc = FindDCCSession(hContact);
		if (olddcc)
			olddcc->Disconnect();

		AddDCCSession(hContact, dcc);
		dcc->Connect();
		if (getByte("MirVerAutoRequest", 1))
			PostIrcMessage(_T("/PRIVMSG %s \001VERSION\001"), name.c_str());
	}
	else {
		CLISTEVENT cle = { sizeof(cle) };
		cle.hContact = hContact;
		cle.hDbEvent = (HANDLE)"dccchat";
		cle.flags = CLEF_TCHAR;
		cle.hIcon = LoadIconEx(IDI_DCC);
		mir_snprintf(szService, sizeof(szService), "%s/DblClickEvent", m_szModuleName);
		cle.pszService = szService;
		mir_sntprintf(szNick, SIZEOF(szNick), TranslateT("CTCP chat request from %s"), name.c_str());
		cle.ptszTooltip = szNick;
		cle.lParam = (LPARAM)pdci;

		if (CallService(MS_CLIST_GETEVENT, hContact, 0))
			CallService(MS_CLIST_REMOVEEVENT, hContact, (LPARAM)"dccchat");
		CallService(MS_CLIST_ADDEVENT, hContact, (LPARAM)&cle);
	}
	return TRUE;
}
Esempio n. 6
0
bool CIrcProto::Connect(const CIrcSessionInfo& info)
{
	codepage = m_codepage;

	NETLIBOPENCONNECTION ncon = { 0 };
	ncon.cbSize = sizeof(ncon);
	ncon.szHost = info.sServer.c_str();
	ncon.wPort = info.iPort;
	con = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&ncon);
	if (con == NULL) {
		TCHAR szTemp[300];
		mir_sntprintf(szTemp, _T("\0035%s \002%s\002 (%S: %u)."),
			TranslateT("Failed to connect to"), si.sNetwork.c_str(), si.sServer.c_str(), si.iPort);
		DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, szTemp, NULL, NULL, NULL, true, false);
		return false;
	}

	FindLocalIP(con); // get the local ip used for filetransfers etc

	if (info.m_iSSL > 0) {
		if (!CallService(MS_NETLIB_STARTSSL, (WPARAM)con, 0) && info.m_iSSL == 2) {
			Netlib_CloseHandle(con);
			con = NULL;
			m_info.Reset();
			return false;
		}
	}

	if (Miranda_Terminated()) {
		Disconnect();
		return false;
	}

	m_info = info;

	// start receiving messages from host
	ForkThread(&CIrcProto::ThreadProc, NULL);
	Sleep(100);
	if (info.sPassword.GetLength())
		NLSend("PASS %s\r\n", info.sPassword.c_str());
	NLSend(_T("NICK %s\r\n"), info.sNick.c_str());

	CMString userID = GetWord(info.sUserID.c_str(), 0);
	TCHAR szHostName[MAX_PATH];
	DWORD cbHostName = _countof(szHostName);
	GetComputerName(szHostName, &cbHostName);
	CMString HostName = GetWord(szHostName, 0);
	if (userID.IsEmpty())
		userID = _T("Miranda");
	if (HostName.IsEmpty())
		HostName = _T("host");
	NLSend(_T("USER %s %s %s :%s\r\n"), userID.c_str(), HostName.c_str(), _T("server"), info.sFullName.c_str());

	return con != NULL;
}
Esempio n. 7
0
INT_PTR CIrcProto::DoEvent(int iEvent, const TCHAR* pszWindow, const TCHAR* pszNick,
                           const TCHAR* pszText, const TCHAR* pszStatus, const TCHAR* pszUserInfo,
                           DWORD_PTR dwItemData, bool bAddToLog, bool bIsMe, time_t timestamp)
{
    GCDEST gcd = {0};
    GCEVENT gce = {0};
    CMString sID;
    CMString sText = _T("");

    if ( iEvent == GC_EVENT_INFORMATION && bIsMe && !bEcho )
        return false;

    if ( pszText ) {
        if (iEvent != GC_EVENT_SENDMESSAGE)
            sText = DoColorCodes(pszText, FALSE, TRUE);
        else
            sText = pszText;
    }

    if ( pszWindow ) {
        if ( lstrcmpi( pszWindow, SERVERWINDOW))
            sID = pszWindow + (CMString)_T(" - ") + m_info.sNetwork;
        else
            sID = pszWindow;
        gcd.ptszID = (TCHAR*)sID.c_str();
    }
    else gcd.ptszID = NULL;

    gcd.pszModule = m_szModuleName;
    gcd.iType = iEvent;

    gce.cbSize = sizeof(GCEVENT);
    gce.pDest = &gcd;
    gce.ptszStatus = pszStatus;
    gce.dwFlags = GC_TCHAR + ((bAddToLog) ? GCEF_ADDTOLOG : 0);
    gce.ptszNick = pszNick;
    gce.ptszUID = pszNick;
    if (iEvent == GC_EVENT_TOPIC)
        gce.ptszUserInfo = pszUserInfo;
    else
        gce.ptszUserInfo = m_showAddresses ? pszUserInfo : NULL;

    if ( !sText.IsEmpty() )
        gce.ptszText = sText.c_str();

    gce.dwItemData = dwItemData;
    if(timestamp == 1)
        gce.time = time(NULL);
    else
        gce.time = timestamp;
    gce.bIsMe = bIsMe;
    return CallChatEvent((WPARAM)0, (LPARAM)&gce);
}
Esempio n. 8
0
int CIrcProto::SetChannelSBText(CMString sWindow, CHANNELINFO * wi)
{
    CMString sTemp = _T("");
    if(wi->pszMode)
    {
        sTemp += _T("[");
        sTemp += wi->pszMode;
        sTemp += _T("] ");
    }
    if(wi->pszTopic)
        sTemp += wi->pszTopic;
    sTemp = DoColorCodes(sTemp.c_str(), TRUE, FALSE);
    return DoEvent(GC_EVENT_SETSBTEXT, sWindow.c_str(), NULL, sTemp.c_str(), NULL, NULL, NULL, FALSE, FALSE, 0);
}
Esempio n. 9
0
void CMVariableOrConstant::Set(const CMString& str)
{
	if (str.is_null())
   	type = Null;
   else {
   	if (isnumber(str.c_str())) {
      	type = Constant;
         u.c = _wtof(str.c_str());
      }
      else {
      	u.v = CMVariable::Find(str);
         type = (u.v==0) ? Null : Variable;
      }
   }
}
Esempio n. 10
0
INT_PTR __cdecl CIrcProto::Scripting_InsertGuiOut(WPARAM, LPARAM lParam)
{
	GCHOOK* gch = (GCHOOK*)lParam;

	if (m_scriptingEnabled && gch) {
		GCHOOK* gchook = new GCHOOK;
		gchook->pDest = new GCDEST;

		gchook->dwData = gch->dwData;
		gchook->pDest->iType = gch->pDest->iType;
		if (gch->ptszText)
			gchook->ptszText = _tcsdup(gch->ptszText);
		else gchook->ptszText = NULL;

		if (gch->ptszUID)
			gchook->ptszUID = _tcsdup(gch->ptszUID);
		else
			gchook->ptszUID = NULL;

		if (gch->pDest->ptszID) {
			CMString S = MakeWndID(gch->pDest->ptszID);
			gchook->pDest->ptszID = _tcsdup(S.c_str());
		}
		else gchook->pDest->ptszID = NULL;

		if (gch->pDest->pszModule)
			gchook->pDest->pszModule = _strdup(gch->pDest->pszModule);
		else gchook->pDest->pszModule = NULL;

		mir_forkthread(GuiOutThread, gchook);
		return 0;
	}

	return 1;
}
Esempio n. 11
0
ImageType::ImageType(const unsigned id, const CMString& file, IStream* pStream)
	: ImageBase(id)
{
	m_bmp = NULL;
	m_pPropertyItem = NULL;
	m_nCurrentFrame = 0;
	m_nFrameCount = 0;

	if (!InitGdiPlus()) return;

	if (pStream)
		m_bmp = new Gdiplus::Bitmap(pStream);
	else
		m_bmp = new Gdiplus::Bitmap(T2W_SM(file.c_str()));

	if (m_bmp->GetLastStatus() != Gdiplus::Ok) {
		delete m_bmp;
		m_bmp = NULL;
		return;
	}

	GUID pageGuid = Gdiplus::FrameDimensionTime;
	m_nFrameCount = m_bmp->GetFrameCount(&pageGuid);

	if (IsAnimated()) {
		int nSize = m_bmp->GetPropertyItemSize(PropertyTagFrameDelay);
		m_pPropertyItem = (Gdiplus::PropertyItem*) new char[nSize];
		m_bmp->GetPropertyItem(PropertyTagFrameDelay, nSize, m_pPropertyItem);
	}
}
Esempio n. 12
0
bool CIrcProto::AddWindowItemData(CMString window, const TCHAR* pszLimit, const TCHAR* pszMode, const TCHAR* pszPassword, const TCHAR* pszTopic)
{
    CHANNELINFO* wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, window.c_str(), NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
    if ( wi ) {
        if ( pszLimit ) {
            wi->pszLimit = ( TCHAR* )realloc( wi->pszLimit, sizeof(TCHAR)*(lstrlen(pszLimit)+1));
            lstrcpy( wi->pszLimit, pszLimit );
        }
        if ( pszMode ) {
            wi->pszMode = ( TCHAR* )realloc( wi->pszMode, sizeof(TCHAR)*(lstrlen(pszMode)+1));
            lstrcpy( wi->pszMode, pszMode );
        }
        if ( pszPassword ) {
            wi->pszPassword = ( TCHAR* )realloc( wi->pszPassword, sizeof(TCHAR)*(lstrlen(pszPassword)+1));
            lstrcpy( wi->pszPassword, pszPassword );
        }
        if ( pszTopic ) {
            wi->pszTopic = ( TCHAR* )realloc( wi->pszTopic, sizeof(TCHAR)*(lstrlen(pszTopic)+1));
            lstrcpy( wi->pszTopic, pszTopic );
        }

        SetChannelSBText(window, wi);
        return true;
    }
    return false;
}
Esempio n. 13
0
void SmileyType::CallSmileyService(MCONTACT hContact)
{
	_TPattern *srvsplit = _TPattern::compile(_T("(.*)\\|(.*)\\|(.*)"));
	_TMatcher *m0 = srvsplit->createTMatcher(GetTriggerText());
	m0->findFirstMatch();

	CMString name = m0->getGroup(1);
	CMString par1 = m0->getGroup(2);
	CMString par2 = m0->getGroup(3);

	delete m0;
	delete srvsplit;

	char str[MAXMODULELABELLENGTH];
	const char *proto = "";

	if (name[0] == '/') {
		proto = (const char*)GetContactProto(hContact);
		if (proto == NULL) return;
	}
	mir_snprintf(str, "%s%s", proto, T2A_SM(name.c_str()));
	CallService(str,
		ConvertServiceParam(hContact, par1.c_str()),
		ConvertServiceParam(hContact, par2.c_str()));
}
Esempio n. 14
0
void CIrcProto::AddToJTemp(TCHAR op, CMString& sCommand)
{
    CMString res;

    int pos = 0;
    for ( ;; ) {
        CMString tmp = sCommand.Tokenize( _T(","), pos );
        if ( pos == -1 )
            break;

        tmp = op + tmp;
        if ( res.IsEmpty() )
            res = tmp;
        else
            res += _T(" ") + tmp;
    }

    DBVARIANT dbv;
    if ( !getTString( "JTemp", &dbv )) {
        res = CMString(dbv.ptszVal) + _T(" ") + res;
        DBFreeVariant( &dbv );
    }

    setTString("JTemp", res.c_str());
}
Esempio n. 15
0
BOOL CIrcProto::ShowMessage (const CIrcMessage* pmsg)
{
	CMString mess = FormatOutput(pmsg);

	if ( !pmsg->m_bIncoming )
		ReplaceString( mess, _T("%%"), _T("%"));

	int iTemp = StrToInt( pmsg->sCommand.c_str());

	//To active window
	if (( iTemp > 400 || iTemp < 500 ) && pmsg->sCommand[0] == '4' //all error messages	
		|| pmsg->sCommand == _T("303")		//ISON command
		|| pmsg->sCommand == _T("INVITE")
		|| ( (pmsg->sCommand == _T("NOTICE")) && ( (pmsg->parameters.getCount() > 2) ? (_tcsstr(pmsg->parameters[1].c_str(), _T("\001"))==NULL) : false)) // CTCP answers should go to m_network Log window!
		|| pmsg->sCommand == _T("515"))		//chanserv error
	{
		DoEvent(GC_EVENT_INFORMATION, NULL, pmsg->m_bIncoming?pmsg->prefix.sNick.c_str():m_info.sNick.c_str(), mess.c_str(), NULL, NULL, NULL, true, pmsg->m_bIncoming?false:true); 
		return TRUE;
	}

	if ( m_useServer ) {
		DoEvent( GC_EVENT_INFORMATION, SERVERWINDOW, 
			( pmsg->m_bIncoming ) ? pmsg->prefix.sNick.c_str() : m_info.sNick.c_str(),
			mess.c_str(), NULL, NULL, NULL, true, pmsg->m_bIncoming ? false : true ); 
		return true;
	}
	return false;
}
Esempio n. 16
0
	HTREEITEM Tree_AddExtraIconGroup(intlist &group, bool selected, HTREEITEM hAfter = TVI_LAST)
	{
		intlist *ids = new intlist();
		CMString desc;
		int img = 0;
		for (int i = 0; i < group.count; i++) {
			BaseExtraIcon *extra = registeredExtraIcons[group.data[i] - 1];
			ids->add(extra->getID());

			if (img == 0 && !IsEmpty(extra->getDescIcon()))
				img = extra->getID();

			if (i > 0)
				desc += _T(" / ");
			desc += extra->getDescription();
		}

		TVINSERTSTRUCT tvis = { 0 };
		tvis.hInsertAfter = hAfter;
		tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE;
		tvis.item.stateMask = TVIS_STATEIMAGEMASK;
		tvis.item.iSelectedImage = tvis.item.iImage = img;
		tvis.item.lParam = (LPARAM)ids;
		tvis.item.pszText = (TCHAR*)desc.c_str();
		tvis.item.state = INDEXTOSTATEIMAGEMASK(selected ? 2 : 1);
		return m_tree.InsertItem(&tvis);
	}
Esempio n. 17
0
void pathToAbsolute(const CMString& pSrc, CMString& pOut) 
{
	TCHAR szOutPath[MAX_PATH];

	TCHAR *szVarPath = Utils_ReplaceVarsT(pSrc.c_str());
	if (szVarPath == (TCHAR*)CALLSERVICE_NOTFOUND || szVarPath == NULL) {
		TCHAR szExpPath[MAX_PATH];
		ExpandEnvironmentStrings(pSrc.c_str(), szExpPath, SIZEOF(szExpPath));
		PathToAbsoluteT(szExpPath, szOutPath);
	}
	else {
		PathToAbsoluteT(szVarPath, szOutPath);
		mir_free(szVarPath);
	}
	pOut = szOutPath;
}
Esempio n. 18
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 );
}
Esempio n. 19
0
int CMPolynomial::add_constant_or_expression(CMString& str)
{
	int ret = -1;
	if (isnumber(str.c_str())) {
		expression.Add(Constant);
		expression.Add((int)constants.Count());
		constants.Add(_wtof(str.c_str()));
	}
	else {
		expression.Add(Expression);
		expression.Add((int)expressions.Count());
		CMPolynomial* p = new CMPolynomial(str.c_str());
		expressions.Add(p);
		ret = p->GetErrorCode();
	}
	return ret;
}
Esempio n. 20
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;
}
Esempio n. 21
0
SmileyPackType* SmileyPackListType::GetSmileyPack(CMString& filename)
{
	CMString modpath;
	pathToAbsolute(filename, modpath);

	for (int i = 0; i < m_SmileyPacks.getCount(); i++) {
		CMString modpath1;
		pathToAbsolute(m_SmileyPacks[i].GetFilename(), modpath1);
		if (mir_tstrcmpi(modpath.c_str(), modpath1.c_str()) == 0) return &m_SmileyPacks[i];
	}
	return NULL;
}
Esempio n. 22
0
ImageType::ImageType(const unsigned id, const CMString& file, const int index, const IcoTypeEnum type)
	: ImageBase(id)
{
	m_bmp = NULL;
	m_pPropertyItem = NULL;
	m_nCurrentFrame = 0;
	m_nFrameCount = 0;

	if (!InitGdiPlus()) return;

	switch (type) {
	case icoDll:
		{
			const HMODULE hModule = LoadDll(file);
			if (hModule != NULL) {
				HICON hIcon = (HICON)LoadImage(hModule, MAKEINTRESOURCE(-index), IMAGE_ICON, 0, 0, 0);
				m_bmp = new Gdiplus::Bitmap(hIcon);
				DestroyIcon(hIcon);
			}
		}
		break;

	case icoFile:
		m_bmp = new Gdiplus::Bitmap(T2W_SM(file.c_str()));
		break;

	default:
		HICON hIcon = NULL;
		ExtractIconEx(file.c_str(), index, NULL, &hIcon, 1);
		m_bmp = new Gdiplus::Bitmap(hIcon);
		DestroyIcon(hIcon);
		break;
	}

	if (m_bmp->GetLastStatus() != Gdiplus::Ok) {
		delete m_bmp;
		m_bmp = NULL;
		return;
	}
}
Esempio n. 23
0
INT_PTR UploadVersionInfo(WPARAM, LPARAM lParam)
{
	CMString buffer;
	PrintVersionInfo(buffer);

	VerTrnsfr *trn = (VerTrnsfr*)mir_alloc(sizeof(VerTrnsfr));
	trn->buf = mir_utf8encodeT(buffer.c_str());
	trn->autot = lParam == 0xa1;

	mir_forkthread(VersionInfoUploadThread, trn);

	return 0;
}
Esempio n. 24
0
INT_PTR GetVersionInfo(WPARAM wParam, LPARAM lParam)
{
	int result = 1; //failure
	if (lParam != NULL) {
		CMString buffer;
		PrintVersionInfo(buffer, (unsigned int)wParam);
		char **retData = (char **)lParam;
		*retData = mir_utf8encodeT(buffer.c_str());
		if (*retData)
			result = 0; //success
	}
	return result;
}
Esempio n. 25
0
IconType::IconType(const unsigned id, const CMString& file, const int index, const IcoTypeEnum type)
	: ImageBase(id)
{
	m_SmileyIcon = NULL;

	switch (type) {
	case icoDll:
		{
			const HMODULE hModule = LoadDll(file);
			if (hModule != NULL)
				m_SmileyIcon = (HICON)LoadImage(hModule, MAKEINTRESOURCE(-index), IMAGE_ICON, 0, 0, 0);
		}
		break;

	case icoFile:
		m_SmileyIcon = (HICON)LoadImage(NULL, file.c_str(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
		break;

	default:
		ExtractIconEx(file.c_str(), index, NULL, &m_SmileyIcon, 1);
		break;
	}
}
Esempio n. 26
0
void UnreadThreadNotification(LPCSTR acc, LPCTSTR jid, LPCTSTR url, LPCTSTR unreadCount, const MAIL_THREAD_NOTIFICATION *mtn)
{
	POPUPDATAT data = { 0 };
	FormatPseudocontactDisplayName(&data.lptzContactName[0], jid, unreadCount);

	CMString tszSenders;
	for (int i = 0; i < SENDER_COUNT; i++) {
		const SENDER &p = mtn->senders[i];
		if (p.addr == NULL)
			break;

		if (p.name)
			tszSenders.AppendFormat(_T("    %s <%s>\n"), p.name, p.addr);
		else
			tszSenders.AppendFormat(_T("    %s\n"), p.addr);
	}

	if (ReadCheckbox(0, IDC_ADDSNIP, (DWORD)TlsGetValue(itlsSettings)))
		mir_sntprintf(data.lptzText, TranslateTS(FULL_NOTIFICATION_FORMAT), mtn->subj, tszSenders.c_str(), mtn->snip);
	else
		mir_sntprintf(data.lptzText, TranslateTS(SHORT_NOTIFICATION_FORMAT), mtn->subj, tszSenders.c_str());

	ShowNotification(acc, &data, jid, url, unreadCount);
}
Esempio n. 27
0
static HMODULE LoadDll(const CMString& file)
{
	WaitForSingleObject(g_hMutexIm, 3000);

	if (lastdllname != file) {
		FreeLibrary(lastmodule);
		lastdllname = file;

		lastmodule = LoadLibraryEx(file.c_str(), NULL, LOAD_LIBRARY_AS_DATAFILE);

	}
	laststamp = time(NULL);

	ReleaseMutex(g_hMutexIm);
	return lastmodule;
}
Esempio n. 28
0
int CMPolynomial::translate_variable_arg(const CMString& str,int& tok,CMString& s)
{
	enum {_t=0,_s,_i,_h,_d,_w,_m,_y};

	s = str;
	int i,len = str.length();

	tok = ArrayIndex;

	for (i=0;i<len && str[i]<=L' ';i++);

	if (i==len)
		return XBadIndex;

	if (str[i] == L'_') {
		int toktype = -1;
		if (i+1 >= len)
			return XBadIndex;
		switch (str[i+1]) {
			case L't': case L'T': toktype = _t; break;
			case L's': case L'S': toktype = _s; break;
			case L'i': case L'I': toktype = _i; break;
			case L'h': case L'H': toktype = _h; break;
			case L'd': case L'D': toktype = _d; break;
			case L'w': case L'W': toktype = _w; break;
			case L'm': case L'M': toktype = _m; break;
			case L'y': case L'Y': toktype = _y; break;
		}
		if (toktype>=0) {
			if (i+2 >= len)
				return XBadIndex;
			if (str[i+2]<=L' ' || str[i+2]==L'+' || str[i+2]==L'-') {
         	int j;
				for (j=i+2;j<len && str[j]<=L' ';j++);
				if (j>=len || !(str[j]==L'+' || str[j]==L'-'))
					return XBadIndex;
				if (str[j] == L'-')
					tok = Lag + toktype;
				else
					tok = Fwd + toktype;
				s = str.c_str()+(j+1);
			}
		}
	}
	return -1;
}
Esempio n. 29
0
bool CIrcProto::FreeWindowItemData(CMString window, CHANNELINFO* wis)
{
    CHANNELINFO* wi;
    if ( !wis )
        wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, window.c_str(), NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
    else
        wi = wis;
    if ( wi ) {
        delete[] wi->pszLimit;
        delete[]wi->pszMode;
        delete[]wi->pszPassword;
        delete[]wi->pszTopic;
        delete wi;
        return true;
    }
    return false;
}
Esempio n. 30
0
EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterIcolib(const char *name, const char *description, const char *descIcon,
	MIRANDAHOOKPARAM OnClick, LPARAM onClickParam, int _hLang)
{
	if (IsEmpty(name) || IsEmpty(description))
		return 0;

	ptrT tszDesc(mir_a2t(description));
	TCHAR *desc = TranslateTH(_hLang, tszDesc);

	BaseExtraIcon *extra = GetExtraIconByName(name);
	if (extra != NULL) {
		if (extra->getType() != EXTRAICON_TYPE_ICOLIB)
			return 0;

		// Found one, now merge it
		if (mir_tstrcmpi(extra->getDescription(), desc)) {
			CMString newDesc = extra->getDescription();
			newDesc += _T(" / ");
			newDesc += desc;
			extra->setDescription(newDesc.c_str());
		}

		if (!IsEmpty(descIcon))
			extra->setDescIcon(descIcon);

		if (OnClick != NULL)
			extra->setOnClick(OnClick, onClickParam);

		if (extra->getSlot() > 0) {
			if (clistRebuildAlreadyCalled)
				extra->rebuildIcons();
			if (clistApplyAlreadyCalled)
				extraIconsByHandle[extra->getID() - 1]->applyIcons();
		}

		return (HANDLE)extra->getID();
	}

	int id = registeredExtraIcons.getCount() + 1;
	extra = new IcolibExtraIcon(id, name, desc, descIcon == NULL ? "" : descIcon, OnClick, onClickParam);
	EI_PostCreate(extra, name, _hLang);
	return (HANDLE)id;
}