Example #1
0
static INT_PTR CALLBACK EngineDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	WORD param;
	BOOL bTranslated = FALSE;
	static bool loading = true;
	static int changeCount = 0;
	switch (uMsg) {
	case WM_INITDIALOG:
		loading = true;
		TranslateDialogDefault(hwndDlg);
		CheckDlgButton(hwndDlg, IDC_ENGINE_SILENT, Config.EngineStaySilent ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwndDlg, IDC_ENGINE_LOWERCASE, Config.EngineMakeLowerCase ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwndDlg, IDC_ENGINE_UNDERSTAND_ALWAYS, Config.EngineUnderstandAlways ? BST_CHECKED : BST_UNCHECKED);
		SetDlgItemText(hwndDlg, IDC_MINDFILE, Config.MindFileName);
		EnableWindow(GetDlgItem(hwndDlg, IDC_BTNSAVE), blInit);
		UpdateUnderstandAlwaysCheckbox(hwndDlg);
		loading = false;
		return TRUE;
	
	case WM_COMMAND:
		param = LOWORD(wParam);
		if (param == IDC_ENGINE_SILENT && HIWORD(wParam) == BN_CLICKED)
			UpdateUnderstandAlwaysCheckbox(hwndDlg);

		switch (param) {
		case IDC_BTNPATH:
			{
				const size_t fileNameSize = 5000;
				TCHAR *filename = new TCHAR[fileNameSize];
				TCHAR *fullname = GetFullName(Config.MindFileName);
				mir_tstrcpy(filename, fullname);
				if (fullname != Config.MindFileName)
					delete[] fullname;

				OPENFILENAME ofn = { 0 };
				ofn.lStructSize = sizeof(OPENFILENAME);
				ofn.hwndOwner = GetParent(hwndDlg);

				TCHAR *mind = TranslateTS(MIND_FILE_DESC);
				TCHAR *anyfile = TranslateTS(ALL_FILES_DESC);
				CMString filt(FORMAT, MIND_DIALOG_FILTER, mind, anyfile);
				filt.Replace('\1', '\0');

				ofn.lpstrFilter = filt;
				ofn.lpstrFile = filename;
				ofn.nMaxFile = fileNameSize;
				ofn.Flags = OFN_FILEMUSTEXIST;
				ofn.lpstrInitialDir = tszPath;
				if (!GetOpenFileName(&ofn)) {
					delete[] filename;
					break;
				}

				TCHAR *origf = filename;
				TCHAR *f = filename;
				TCHAR *p = tszPath;
				while (*p && *f) {
					TCHAR p1 = (TCHAR)CharLower((TCHAR*)(long)*p++);
					TCHAR f1 = (TCHAR)CharLower((TCHAR*)(long)*f++);
					if (p1 != f1)
						break;
				}
				if (!*p)
					filename = f;
				Config.MindFileName = filename;
				SetDlgItemText(hwndDlg, IDC_MINDFILE, filename);
				delete[] origf;
			}

		case IDC_BTNRELOAD:
			{
				const TCHAR *c = Config.MindFileName;
				int line;
				bTranslated = blInit = LoadMind(c, line);
				if (!bTranslated) {
					TCHAR message[5000];
					mir_sntprintf(message, TranslateTS(FAILED_TO_LOAD_BASE), line, c);
					MessageBox(NULL, message, TranslateTS(BOLTUN_ERROR), MB_ICONERROR | MB_TASKMODAL | MB_OK);
				}
			}
			break;

		default:
			if (!loading) {
				if (param == IDC_MINDFILE/* && HIWORD(wParam) != EN_CHANGE*/)
					break;
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			}
		}
		break;

	case WM_NOTIFY:
		NMHDR *nmhdr = (NMHDR*)lParam;
		switch (nmhdr->code) {
		case PSN_APPLY:
		case PSN_KILLACTIVE:
			Config.EngineStaySilent = IsDlgButtonChecked(hwndDlg, IDC_ENGINE_SILENT) == BST_CHECKED ? TRUE : FALSE;
			Config.EngineMakeLowerCase = IsDlgButtonChecked(hwndDlg, IDC_ENGINE_LOWERCASE) == BST_CHECKED ? TRUE : FALSE;
			Config.EngineUnderstandAlways = IsDlgButtonChecked(hwndDlg, IDC_ENGINE_UNDERSTAND_ALWAYS) == BST_CHECKED ? TRUE : FALSE;
			UpdateEngine();
			TCHAR c[MAX_MIND_FILE];
			bTranslated = GetDlgItemText(hwndDlg, IDC_MINDFILE, c, _countof(c));
			if (bTranslated)
				Config.MindFileName = c;
			else
				Config.MindFileName = DEFAULT_MIND_FILE;
			return TRUE;
		}
		break;
	}
	return 0;
}
Example #2
0
static void fillListBox(HWND hWnd, LPSTR lpszDir) 
{
  HWND hWndLB = GetDlgItem(hWnd, ID_LIST_DIR);
  HWND hWndTempLB = GetDlgItem(hWnd, ID_LISTTEMP_DIR);
  HWND hWndEdit = GetDlgItem(hWnd, ID_EDIT_DIR);
  if((hWndLB == NULL) || (lpszDir == NULL))
    return;
  
  int iLastChar = lstrlen(lpszDir);
  if(lpszDir[iLastChar - 1] == '\\')
    lpszDir[iLastChar - 1] = '\0';

  SetWindowRedraw(hWndLB, FALSE);
  ListBox_ResetContent(hWndLB);
  ListBox_ResetContent(hWndTempLB);

  LPSTR lpszLast;
  lpszLast = CharLower(lpszDir);

  SetWindowText(hWndLB, lpszDir);

  char szDir[_MAX_DIR];
  char szFullDir[_MAX_DIR];
  sprintf(szFullDir, "%s", lpszDir);
  sprintf(szDir, "%s\\*.*", lpszDir);

  BOOL bFirst = TRUE;
  char ch;
  int index;
  while (TRUE) 
  {
    LPSTR lpsz;
    if((lpszDir[0] == '\\') && (lpszDir[1] == '\\') && bFirst)
      lpsz = strchr(lpszLast + lstrlen(szUNCRoot), '\\');
    else
      lpsz = strchr(lpszLast, '\\');
    if(lpsz != NULL) {
      if (bFirst)
        ch = *(++lpsz);
      else
        ch = *lpsz;
      *lpsz = 0;
    } 
    else 
    {
      //If we're looking at a drive only, then append a backslash
      if (lpszLast == lpszDir && bFirst)
        lstrcat(lpszLast, "\\");
    }
    //Add the drive string--includes the last one where lpsz == NULL
    index = ListBox_AddString(hWndLB, lpszLast);

    UINT i = (NULL != lpsz) ? ID_ICON_FOLDEROPEN : ID_ICON_OPENSELECT;
    ListBox_SetItemData(hWndLB, index, MAKELONG(index, i));

    if(NULL == lpsz)
      break;

      //Restore last character.
    *lpsz = ch;
    lpsz += (bFirst) ? 0 : 1;

    bFirst=FALSE;
    lpszLast = lpsz;
  }
  int indent = index + 1;

  //Get available directories
  fillTempLBWithDirs(hWndTempLB, lpszDir);

  int itemCount = ListBox_GetCount(hWndTempLB);

  int i=0;
  for (i = 0; i < itemCount; i++) {
    index = ListBox_GetText(hWndTempLB, i, lpszDir);
    //Skip directories beginning with . (skipping . and ..)
    if(lpszDir[1] == '.')
      continue;
    //Remove the ending ']'
    iLastChar = lstrlen(lpszDir);
    lpszDir[iLastChar - 1] = '\0';
    //Add the string to the real directory list.
    index = ListBox_AddString(hWndLB, lpszDir + 1);
    ListBox_SetItemData(hWndLB, index, MAKELONG(indent, ID_ICON_FOLDERCLOSED));
  }
  //Force a listbox repaint.
  SetWindowRedraw(hWndLB, TRUE);
  InvalidateRect(hWndLB, NULL, TRUE);

  if(szFullDir[lstrlen(szFullDir) - 1] == ':')
    lstrcat(szFullDir, "\\");
  Edit_SetText(hWndEdit, szFullDir);

  GetScrollRange(hWndLB, SB_VERT, (LPINT)&i, (LPINT)&index);

  if(!(i == 0 && index == 0))
    ListBox_SetTopIndex(hWndLB, max((int)(index - 2), 0));

  ListBox_SetCurSel(hWndLB, indent - 1);
}
Example #3
0
char WINAPI ToLower(char ch)
{
	return (char)(DWORD_PTR)CharLower((LPTSTR)(DWORD_PTR)MK_DWORD(0,ch));
}
Example #4
0
File: Menu.c Project: tobynet/clcl
/*
 * menu_create_text - アクセラレータ付き文字文字列の作成
 */
static void menu_create_text(const int index, const TCHAR *buf, TCHAR *ret)
{
	TCHAR *p = option.menu_text_format;
	TCHAR *r;
	int base;
	int num;
	int i;

	if (*p == TEXT('\0')) {
		lstrcpy(ret, buf);
		return;
	}
	while (*p != TEXT('\0')) {
#ifndef UNICODE
		if (IsDBCSLeadByte((BYTE)*p) == TRUE) {
			*(ret++) = *(p++);
			if (*p == TEXT('\0')) {
				break;
			}
			*(ret++) = *(p++);
			continue;
		}
#endif	// UNICODE
		if (*p != TEXT('%')) {
			*(ret++) = *(p++);
			continue;
		}
		r = p;
		p++;

		// ベース値
		if (*p >= TEXT('0') && *p <= TEXT('9')) {
			base = _ttoi(p);
			for (; *p >= TEXT('0') && *p <= TEXT('9'); p++)
				;
		} else {
			base = 0;
		}
		num = index + base;

		switch (*p) {
		case TEXT('d'):
		case TEXT('D'):
			// 数字 (10進数)
			_itot(num, ret, 10);
			ret += lstrlen(ret);
			break;

		case TEXT('x'):
			// 数字 (16進数) (小文字)
			_itot(num, ret, 16);
			CharLower(ret);
			ret += lstrlen(ret);
			break;

		case TEXT('X'):
			// 数字 (16進数)
			_itot(num, ret, 16);
			CharUpper(ret);
			ret += lstrlen(ret);
			break;

		case TEXT('n'):
		case TEXT('N'):
			// 1桁の数字
			*(ret++) = TEXT('0') + num % 10;
			break;

		case TEXT('a'):
			// アルファベット (小文字)
			*(ret++) = TEXT('a') + num % 26;
			break;

		case TEXT('A'):
			// アルファベット
			*(ret++) = TEXT('A') + num % 26;
			break;

		case TEXT('b'):
			// アルファベット + 数字 (小文字)
			i = num % (26 + 10);
			*(ret++) = (i < 26) ? TEXT('a') + i : TEXT('0') + i - 26;
			break;

		case TEXT('B'):
			// アルファベット + 数字
			i = num % (26 + 10);
			*(ret++) = (i < 26) ? TEXT('A') + i : TEXT('0') + i - 26;
			break;

		case TEXT('c'):
			// 数字 + アルファベット (小文字)
			i = num % (26 + 10);
			*(ret++) = (i < 10) ? TEXT('0') + i : TEXT('a') + i - 10;
			break;

		case TEXT('C'):
			// 数字 + アルファベット
			i = num % (26 + 10);
			*(ret++) = (i < 10) ? TEXT('0') + i : TEXT('A') + i - 10;
			break;

		case TEXT('t'):
		case TEXT('T'):
			// タイトル
			lstrcpyn(ret, buf, BUF_SIZE);
			ret += lstrlen(ret);
			break;

		case TEXT('%'):
			// %
			*(ret++) = *p;
			break;

		default:
			*(ret++) = *r;
			p = r;
			break;

		}
		if (*p == TEXT('\0')) {
			break;
		}
		p++;
	}
	*ret = TEXT('\0');
}
Example #5
0
/**
 * @brief Compare two files (as earlier specified).
 * @return DIFFCODE as a result of compare.
 */
int DiffUtils::diffutils_compare_files()
{
	int bin_flag = 0;
	int bin_file = 0; // bitmap for binary files

	// Do the actual comparison (generating a change script)
	struct change *script = NULL;
	bool success = Diff2Files(&script, 0, &bin_flag, false, &bin_file);
	if (!success)
	{
		return DIFFCODE::FILE | DIFFCODE::TEXT | DIFFCODE::CMPERR;
	}
	UINT code = DIFFCODE::FILE | DIFFCODE::TEXT | DIFFCODE::SAME;

	// make sure to start counting diffs at 0
	// (usually it is -1 at this point, for unknown)
	m_ndiffs = 0;
	m_ntrivialdiffs = 0;

	if (script)
	{
		struct change *next = script;
		struct change *thisob = 0, *end = 0;

		String asLwrCaseExt;
		String LowerCaseExt = CA2T(m_inf[0].name);
		int PosOfDot = LowerCaseExt.rfind('.');
		if (PosOfDot != -1)
		{
			LowerCaseExt.erase(0, PosOfDot + 1);
			CharLower(&*LowerCaseExt.begin());
			asLwrCaseExt = LowerCaseExt;
		}

		while (next)
		{
			/* Find a set of changes that belong together.  */
			thisob = next;
			end = find_change(next);

			/* Disconnect them from the rest of the changes,
			making them a hunk, and remember the rest for next iteration.  */
			next = end->link;
			end->link = 0;
#ifdef _DEBUG
			debug_script(thisob);
#endif

			{
				/* Determine range of line numbers involved in each file.  */
				int first0 = 0, last0 = 0, first1 = 0, last1 = 0, deletes = 0, inserts = 0;
				analyze_hunk(thisob, &first0, &last0, &first1, &last1, &deletes, &inserts);
				if (deletes || inserts || thisob->trivial)
				{
					/* Print the lines that the first file has.  */
					int trans_a0 = 0, trans_b0 = 0, trans_a1 = 0, trans_b1 = 0;
					translate_range(&m_inf[0], first0, last0, &trans_a0, &trans_b0);
					translate_range(&m_inf[1], first1, last1, &trans_a1, &trans_b1);

					//Determine quantity of lines in this block for both sides
					int QtyLinesLeft = (trans_b0 - trans_a0);
					int QtyLinesRight = (trans_b1 - trans_a1);


					if(m_pOptions->m_filterCommentsLines || m_pOptions->m_bIgnoreBlankLines || m_pOptions->m_bIgnoreCase)
					{
						OP_TYPE op = OP_NONE;
						if (!deletes && !inserts)
							op = OP_TRIVIAL;
						else
							op = OP_DIFF;

						DIFFOPTIONS options = {0};
						options.nIgnoreWhitespace = m_pOptions->m_ignoreWhitespace;
						options.bIgnoreBlankLines = m_pOptions->m_bIgnoreBlankLines;
						options.bFilterCommentsLines = m_pOptions->m_filterCommentsLines;
						options.bIgnoreCase = m_pOptions->m_bIgnoreCase;
						options.bIgnoreEol = m_pOptions->m_bIgnoreEOLDifference;
						m_pDiffWrapper->SetOptions(&options);
  						m_pDiffWrapper->PostFilter(thisob->line0, QtyLinesLeft+1, thisob->line1, QtyLinesRight+1, op, *m_FilterCommentsManager, asLwrCaseExt.c_str());
						if(op == OP_TRIVIAL)
						{
							thisob->trivial = 1;
						}
					}

					// Match lines against regular expression filters
					// Our strategy is that every line in both sides must
					// match regexp before we mark difference as ignored.
					if(m_pFilterList && m_pFilterList->HasRegExps())
					{
						bool match2 = false;
						bool match1 = RegExpFilter(thisob->line0, thisob->line0 + QtyLinesLeft, 0);
						if (match1)
							match2 = RegExpFilter(thisob->line1, thisob->line1 + QtyLinesRight, 1);
						if (match1 && match2)
							thisob->trivial = 1;
					}

				}
				/* Reconnect the script so it will all be freed properly.  */
				end->link = next;
			}
		}
	}


	// Free change script (which we don't want)
	if (script != NULL)
	{
		struct change *p, *e;
		for (e = script; e; e = p)
		{
			if (!e->trivial)
				++m_ndiffs;
			else
				++m_ntrivialdiffs;
			p = e->link;
			free(e);
		}
		if (m_ndiffs > 0)
			code = code & ~DIFFCODE::SAME | DIFFCODE::DIFF;
	}

	// diff_2_files set bin_flag to -1 if different binary
	// diff_2_files set bin_flag to +1 if same binary

	if (bin_flag != 0)
	{
		// Clear text-flag, set binary flag
		// We don't know diff counts for binary files
		code = code & ~DIFFCODE::TEXT;
		switch (bin_file)
		{
		case BINFILE_SIDE1:
			code |= DIFFCODE::BINSIDE1;
			break;
		case BINFILE_SIDE2:
			code |= DIFFCODE::BINSIDE2;
			break;
		case BINFILE_SIDE1 | BINFILE_SIDE2:
			code |= DIFFCODE::BIN;
			break;
		default:
			_RPTF1(_CRT_ERROR, "Invalid bin_file value: %d", bin_file);
			break;
		}
		m_ndiffs = CDiffContext::DIFFS_UNKNOWN;
	}

	if (bin_flag < 0)
	{
		// Clear same-flag, set diff-flag
		code = code & ~DIFFCODE::SAME | DIFFCODE::DIFF;
	}

	return code;
}
void CHttpRequest::RunResponse(HINTERNET hURL)
{
	DWORD nLength = 255;
	BYTE nNull = 0;
	
	if ( ! HttpQueryInfo( hURL, HTTP_QUERY_STATUS_TEXT,
		m_sStatusString.GetBuffer( nLength ), &nLength, 0 ) ) nLength = 0;
	m_sStatusString.ReleaseBuffer( nLength );
	if ( m_sStatusString.IsEmpty() ) return;
	
	if ( m_pResponse != NULL ) delete m_pResponse;
	m_pResponse = new CBuffer();
	
    DWORD nRemaining;
	for ( ; InternetQueryDataAvailable( hURL, &nRemaining, 0, 0 ) && nRemaining > 0 && ! m_bCancel ; )
	{
		m_pResponse->EnsureBuffer( nRemaining );
		if ( ! InternetReadFile( hURL, m_pResponse->m_pBuffer + m_pResponse->m_nLength,
			nRemaining, &nRemaining ) ) break;
		m_pResponse->m_nLength += nRemaining;
		if ( m_nLimit > 0 && m_pResponse->m_nLength > m_nLimit ) break;
	}
	
	if ( nRemaining > 0 ) return;
	
	nLength = 0;
	HttpQueryInfo( hURL, HTTP_QUERY_RAW_HEADERS, &nNull, &nLength, 0 );
	if ( nLength == 0 ) return;
	
	LPTSTR pszHeaders = new TCHAR[ nLength + 1 ];
	pszHeaders[0] = pszHeaders[1] = 0;
	HttpQueryInfo( hURL, HTTP_QUERY_RAW_HEADERS, pszHeaders, &nLength, 0 );
	
	for ( LPTSTR pszHeader = pszHeaders ; *pszHeader ; )
	{
		CString strHeader( pszHeader );
		pszHeader += strHeader.GetLength() + 1;
		
		int nColon = strHeader.Find( ':' );
		
		if ( nColon > 0 )
		{
			CString strValue, strName = strHeader.Left( nColon );
			strName.Trim(); 
			CharLower( strName.GetBuffer() );
			strName.ReleaseBuffer();
			
			while ( m_pResponseHeaders.Lookup( strName, strValue ) ) strName += _T('_');

			strValue = strHeader.Mid( nColon + 1 );
			strValue.Trim();
			m_pResponseHeaders.SetAt( strName, strValue );
		}
	}
	
	delete [] pszHeaders;
	
	nLength = 4;
	m_nStatusCode = 0;
	HttpQueryInfo( hURL, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER,
		&m_nStatusCode, &nLength, 0 );
}
Example #7
0
int LoadNewPluginsModule(void)
{
	TCHAR exe[MAX_PATH];
	TCHAR* slice;
	pluginEntry* p;
	pluginEntry* clist = NULL;
	int useWhiteList, i;
	bool msgModule = false;

	// make full path to the plugin
	GetModuleFileName(NULL, exe, SIZEOF(exe));
	slice = _tcsrchr(exe, '\\');
	if (slice) *slice = 0;

	// remember some useful options
	askAboutIgnoredPlugins=(UINT) GetPrivateProfileInt( _T("PluginLoader"), _T("AskAboutIgnoredPlugins"), 0, mirandabootini);

	// if Crash Dumper is present, load it to provide Crash Reports
	if (pluginList_crshdmp != NULL && isPluginOnWhiteList(pluginList_crshdmp->pluginname)) 
    {
		if ( pluginList_crshdmp->bpi.Load(&pluginCoreLink) == 0 )
			pluginList_crshdmp->pclass |= PCLASS_LOADED | PCLASS_LAST;
		else
			Plugin_Uninit( pluginList_crshdmp );
    }

	// if freeimage is present, load it to provide the basic core functions
	if ( pluginList_freeimg != NULL ) {
		BASIC_PLUGIN_INFO bpi;
		mir_sntprintf(slice, &exe[SIZEOF(exe)] - slice, _T("\\Plugins\\%s"), pluginList_freeimg->pluginname);
		if ( checkAPI(exe, &bpi, mirandaVersion, CHECKAPI_NONE, NULL) ) {
			pluginList_freeimg->bpi = bpi;
			pluginList_freeimg->pclass |= PCLASS_OK | PCLASS_BASICAPI;
			if ( bpi.Load(&pluginCoreLink) == 0 )
				pluginList_freeimg->pclass |= PCLASS_LOADED;
			else
				Plugin_Uninit( pluginList_freeimg );
	}	}

	// first load the clist cos alot of plugins need that to be present at Load()
	for ( useWhiteList = 1; useWhiteList >= 0 && clist == NULL; useWhiteList-- )
		clist=getCListModule(exe, slice, useWhiteList);
	/* the loop above will try and get one clist DLL to work, if all fail then just bail now */
	if ( clist == NULL ) {
		// result = 0, no clist_* can be found
		if ( pluginListUI )
			MessageBox(NULL, TranslateT("Unable to start any of the installed contact list plugins, I even ignored your preferences for which contact list couldn't load any."), _T("Miranda IM"), MB_OK | MB_ICONINFORMATION);
		else
			MessageBox(NULL, TranslateT("Can't find a contact list plugin! you need clist_classic or any other clist plugin.") , _T("Miranda IM"), MB_OK | MB_ICONINFORMATION);
		return 1;
	}

	/* enable and disable as needed  */
	p = pluginListUI;
	while ( p != NULL ) {
		SetPluginOnWhiteList(p->pluginname, clist != p ? 0 : 1 );
		p = p->nextclass;
	}
	/* now loop thru and load all the other plugins, do this in one pass */

	for ( i=0; i < pluginList.getCount(); i++ ) {
		p = pluginList[i];
		CharLower(p->pluginname);
		if (!(p->pclass & (PCLASS_LOADED | PCLASS_DB | PCLASS_CLIST))) 
		{
			if (isPluginOnWhiteList(p->pluginname))
			{
				BASIC_PLUGIN_INFO bpi;
				mir_sntprintf(slice, &exe[SIZEOF(exe)] - slice, _T("\\Plugins\\%s"), p->pluginname);
				if ( checkAPI(exe, &bpi, mirandaVersion, CHECKAPI_NONE, NULL) ) {
					int rm = bpi.pluginInfo->replacesDefaultModule;
					p->bpi = bpi;
					p->pclass |= PCLASS_OK | PCLASS_BASICAPI;

					if ( pluginDefModList[rm] == NULL ) {
						pluginListAddr.insert( p );
						if ( bpi.Load(&pluginCoreLink) == 0 ) {
							p->pclass |= PCLASS_LOADED;
							msgModule |= (bpi.pluginInfo->replacesDefaultModule == DEFMOD_SRMESSAGE);
						}
						else {
							Plugin_Uninit( p );
							i--;
						}
						if ( rm ) pluginDefModList[rm]=p;
					} //if
					else {
						SetPluginOnWhiteList( p->pluginname, 0 );
						Plugin_Uninit( p );
						i--;
					}
				}
				else p->pclass |= PCLASS_FAILED;
			}
			else {
				Plugin_Uninit( p );
				i--;
			}
		}
		else if ( p->bpi.hInst != NULL )
		{
			pluginListAddr.insert( p );
			p->pclass |= PCLASS_LOADED;
		}
	}
	if (!msgModule)
		MessageBox(NULL, TranslateT("No messaging plugins loaded. Please install/enable one of the messaging plugins, for instance, \"srmm.dll\""), _T("Miranda IM"), MB_OK | MB_ICONINFORMATION);

	HookEvent(ME_OPT_INITIALISE, PluginOptionsInit);
	return 0;
}
Example #8
0
static int mail_extracthdr(char *headers, char *name, char *buf, int bufsize)
{
	char *p = headers, *q;
	char hdrname[256];
	int i;

	if (headers == NULL || name == NULL || buf == NULL || bufsize <= 0) return 1;
	while (*p == '\r' || *p == '\n' || *p == ' ' || *p == '\t') p++;

	while (*p) {
		for (i=0; i<(sizeof(hdrname)-1);) {
			char c = *p++;
			if (c == 0) break;
			if (c == ':' || c == '\r' || c == '\n') { p--; break; }
			if (c == '\t') c=' ';
			if (i>0 && c==' ') { if(hdrname[i-1]==' ') continue; }
			if (i==0 && c==' ') continue;
			hdrname[i++] = c;
		}
		hdrname[i] = 0;

		if (*p == 0) break;

		if (hdrname[lstrlen(hdrname)-1] == ' ') hdrname[lstrlen(hdrname)-1] = 0;
		if (hdrname[0] == 0) break;

		if (*p == ':') {
			CharLower(hdrname);
			if (lstrcmpi(hdrname, name) == 0) {
				p++;
				goto hdr_found;
			}
		}

		while (*p != '\n' && *p != '\r' && *p) p++;
		if (*p == 0) break;

		if (*p == '\n') {
			p++;
			if (*p == '\r') p++;
		} else if (*p == '\r') {
			p++;
			if (*p == '\n') p++;
		}
		if (*p == '\n' || *p == '\r') break;
	}

	return 1;

hdr_found:
	if (*p == ' ' || *p == '\t') p++;
	for (i=0; i<(bufsize-1);) {
		char c = *p++;
		if (c == '\r' || c == '\n') {
			q = p--;
			while (*q == '\n' || *q == '\r') q++;
			if (*q != ' ' && *q != '\t') break;

			while (*p == '\n' || *p == '\r') p++;
			continue;
		}
		buf[i++] = c;
	}
	buf[i] = 0;
	return 0;
}
Example #9
0
// ------------------------------------------
// Global Functions 
// ------------------------------------------
LONG RegisterAsioDriver (CLSID clsid,char *szdllname,char *szregname,char *szasiodesc,char *szthreadmodel)
{
	HMODULE			hMod;
	char			szDLLPath[MAX_PATH_LEN];
	char			szModuleName[MAX_PATH_LEN];
	char			szregpath[MAX_PATH_LEN];
	char			szclsid[CLSID_STRING_LEN];
	LPOLESTR		wszCLSID = NULL;
	BOOL			newregentry = FALSE;
	LONG			rc;

	hMod = GetModuleHandle(szdllname);
	if (!hMod) return ERRSREG_MODULE_NOT_FOUND;
	szModuleName[0] = 0;
	GetModuleFileName(hMod,szModuleName,MAX_PATH_LEN);
	if (!szModuleName[0]) return ERRSREG_MODPATH_NOT_FOUND;
	CharLower((LPTSTR)szModuleName);

	rc = (LONG)StringFromCLSID(clsid,&wszCLSID);
	if (rc != S_OK) return ERRSREG_STRING_FROM_CLSID;
	rc = (LONG)WideCharToMultiByte(CP_ACP,0,(LPWSTR)wszCLSID,-1,szclsid,CLSID_STRING_LEN,0,0);
	if (!rc) return ERRSREG_CHAR_TO_MULTIBYTE;

	sprintf(szregpath,"%s\\%s",SZREGSTR_CLSID,szclsid);
	rc = findRegPath(HKEY_CLASSES_ROOT,szregpath);
	if (rc) {
		sprintf(szregpath,"%s\\%s\\%s",SZREGSTR_CLSID,szclsid,SZREGSTR_INPROCSERVER32);
		getRegString (HKEY_CLASSES_ROOT,szregpath,0,(LPVOID)szDLLPath,MAX_PATH_LEN);
		CharLower((LPTSTR)szDLLPath);
		rc = (LONG)strcmp(szDLLPath,szModuleName);
		if (rc) {
			// delete old regentry
			sprintf(szregpath,"%s",SZREGSTR_CLSID);
			deleteRegPath(HKEY_CLASSES_ROOT,szregpath,szclsid);
			newregentry = TRUE;
		}
	}
	else newregentry = TRUE;

	if (newregentry) {
		// HKEY_CLASSES_ROOT\CLSID\{...}
		sprintf(szregpath,"%s",SZREGSTR_CLSID);
		createRegPath (HKEY_CLASSES_ROOT,szregpath,szclsid);
		// HKEY_CLASSES_ROOT\CLSID\{...} -> Description
		sprintf(szregpath,"%s\\%s",SZREGSTR_CLSID,szclsid);
		createRegStringValue(HKEY_CLASSES_ROOT,szregpath,0,szasiodesc);
		// HKEY_CLASSES_ROOT\CLSID\InProcServer32
		sprintf(szregpath,"%s\\%s",SZREGSTR_CLSID,szclsid);
		createRegPath (HKEY_CLASSES_ROOT,szregpath,SZREGSTR_INPROCSERVER32);
		// HKEY_CLASSES_ROOT\CLSID\InProcServer32 -> DLL path
		sprintf(szregpath,"%s\\%s\\%s",SZREGSTR_CLSID,szclsid,SZREGSTR_INPROCSERVER32);
		createRegStringValue(HKEY_CLASSES_ROOT,szregpath,0,szModuleName);
		// HKEY_CLASSES_ROOT\CLSID\InProcServer32 -> ThreadingModel
		createRegStringValue(HKEY_CLASSES_ROOT,szregpath,SZREGSTR_THREADINGMODEL,szthreadmodel);
	}

	// HKEY_LOCAL_MACHINE\SOFTWARE\ASIO
	sprintf(szregpath,"%s\\%s",SZREGSTR_SOFTWARE,SZREGSTR_ASIO);
	rc = findRegPath(HKEY_LOCAL_MACHINE,szregpath);
	if (rc) {
		sprintf(szregpath,"%s\\%s\\%s",SZREGSTR_SOFTWARE,SZREGSTR_ASIO,szregname);
		rc = findRegPath(HKEY_LOCAL_MACHINE,szregpath);
		if (rc) {
			sprintf(szregpath,"%s\\%s",SZREGSTR_SOFTWARE,SZREGSTR_ASIO);
			deleteRegPath(HKEY_LOCAL_MACHINE,szregpath,szregname);
		}
	}
	else {
		// HKEY_LOCAL_MACHINE\SOFTWARE\ASIO
		sprintf(szregpath,"%s",SZREGSTR_SOFTWARE);
		createRegPath (HKEY_LOCAL_MACHINE,szregpath,SZREGSTR_ASIO);
	}

	// HKEY_LOCAL_MACHINE\SOFTWARE\ASIO\<szregname>
	sprintf(szregpath,"%s\\%s",SZREGSTR_SOFTWARE,SZREGSTR_ASIO);
	createRegPath (HKEY_LOCAL_MACHINE,szregpath,szregname);

	// HKEY_LOCAL_MACHINE\SOFTWARE\ASIO\<szregname> -> CLSID 
	// HKEY_LOCAL_MACHINE\SOFTWARE\ASIO\<szregname> -> Description
	sprintf(szregpath,"%s\\%s\\%s",SZREGSTR_SOFTWARE,SZREGSTR_ASIO,szregname);
	createRegStringValue(HKEY_LOCAL_MACHINE,szregpath,SZREGSTR_CLSID,szclsid);
	createRegStringValue(HKEY_LOCAL_MACHINE,szregpath,SZREGSTR_DESCRIPTION,szasiodesc);

	return 0;
}
void CCommandLineDisplay::AutoCompleteSearch (void)

//	AutocompleteSearch
//
//	Searches the global symbol table for matches to the current command.

	{
	const CString sCurCmd = GetCurrentCmd();
	CString sCommon;
	CString sHelp;

	ClearHint();
	if (sCurCmd.IsBlank())
		return;

	//	Get the list of global symbols

	ICCItem *pGlobals = g_pUniverse->GetCC().GetGlobals();

	int iMatches = 0;

	for (int i = 0; i < pGlobals->GetCount(); i++)
		{
		CString sGlobal = pGlobals->GetKey(i);

		//	Partial match
		if (strStartsWith(sGlobal, sCurCmd))
			{
			if (iMatches == 0)
				sCommon = sGlobal;
			//	If we have multiple matching commands then find the longest common stem
			else
				{
				int iLen = min(sCommon.GetLength(), sGlobal.GetLength());
				char *pPos1 = sCommon.GetPointer();
				char *pPos2 = sGlobal.GetPointer();
				int i;
				for (i = 0; i < iLen; i++)
					{
					if (CharLower((LPTSTR)(BYTE)(*pPos1)) != CharLower((LPTSTR)(BYTE)(*pPos2)))
						break;
					pPos1++;
					pPos2++;
					}
				sCommon.Truncate(i);
				m_sHint.Append(CONSTLIT(" "));
				}
			//	Append the command to the auto complete hint
			m_sHint.Append(sGlobal);
			iMatches++;
			}

		if (strEquals(sGlobal, sCurCmd))
			{
			//	Exact match - get help text
			ICCItem *pItem = pGlobals->GetElement(i);
			if (pItem->IsPrimitive())
				sHelp = pItem->GetHelp();
			}
		}

	//	If the common stem is longer than the current command, then auto complete
	if (sCommon.GetLength() > sCurCmd.GetLength())
		Input(strSubString(sCommon, sCurCmd.GetLength(), -1));

	//	If we only have one match then no need to show hint as we have either
	//	auto completed or will show help text insead
	if (iMatches == 1)
		m_sHint = NULL_STR;

	if (!sHelp.IsBlank())
		{
		if (!m_sHint.IsBlank())
			m_sHint.Append(CONSTLIT("\n"));
		m_sHint.Append(sHelp);
		}
	}
Example #11
0
INT_PTR CALLBACK UserDetailsDlgProc(HWND m_hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	UserDetailsDlgProcParam* p = ( UserDetailsDlgProcParam* )GetWindowLongPtr( m_hwnd, GWLP_USERDATA );
	switch (msg) {
	case WM_INITDIALOG:
		p = new UserDetailsDlgProcParam( NULL, ( HANDLE )lParam );
		SetWindowLongPtr( m_hwnd, GWLP_USERDATA, ( LPARAM )p );
		break;

	case WM_NOTIFY:
		if ((( LPNMHDR )lParam )->idFrom == 0 && (( LPNMHDR )lParam )->code == PSN_PARAMCHANGED ) {
			p->ppro = ( CIrcProto* )(( PSHNOTIFY* )lParam )->lParam;

			DBVARIANT dbv;
			BYTE bAdvanced = p->ppro->getByte( p->hContact, "AdvancedMode", 0);

			TranslateDialogDefault( m_hwnd);

			CheckDlgButton( m_hwnd, IDC_RADIO1, bAdvanced?BST_UNCHECKED:BST_CHECKED);
			CheckDlgButton( m_hwnd, IDC_RADIO2, bAdvanced?BST_CHECKED:BST_UNCHECKED);
			EnableWindow(GetDlgItem( m_hwnd, IDC_WILDCARD), bAdvanced);

			if ( !bAdvanced ) {
				SetDlgItemText( m_hwnd, IDC_DEFAULT, TranslateT(STR_BASIC));
				if ( !p->ppro->getTString( p->hContact, "Default", &dbv)) {
					SetDlgItemText( m_hwnd, IDC_WILDCARD, dbv.ptszVal);
					DBFreeVariant(&dbv);
				}
			}
			else {
				SetDlgItemText( m_hwnd, IDC_DEFAULT, TranslateT(STR_ADVANCED));
				if ( !p->ppro->getTString( p->hContact, "UWildcard", &dbv)) {
					SetDlgItemText( m_hwnd, IDC_WILDCARD, dbv.ptszVal);
					DBFreeVariant(&dbv);
			}	}

			if ( !p->ppro->getTString( p->hContact, "UUser", &dbv)) {
				SetDlgItemText( m_hwnd, IDC_USER, dbv.ptszVal);
				DBFreeVariant(&dbv);
			}

			if ( !p->ppro->getTString( p->hContact, "UHost", &dbv)) {
				SetDlgItemText( m_hwnd, IDC_HOST, dbv.ptszVal);
				DBFreeVariant(&dbv);
			}
			ProtoBroadcastAck(p->ppro->m_szModuleName, p->hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
		}
		break;

	case WM_COMMAND:
		if (( LOWORD(wParam) == IDC_WILDCARD || LOWORD(wParam) == IDC_USER || LOWORD(wParam) == IDC_HOST ) &&
			 ( HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()))
			return true;

		EnableWindow(GetDlgItem( m_hwnd, IDC_BUTTON), true);
		EnableWindow(GetDlgItem( m_hwnd, IDC_BUTTON2), true);

		if( HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_BUTTON ) {
			TCHAR temp[500];
			GetDlgItemText( m_hwnd, IDC_WILDCARD, temp, SIZEOF(temp));
			DBVARIANT dbv;

			BYTE bAdvanced = IsDlgButtonChecked( m_hwnd, IDC_RADIO1)?0:1;
			if ( bAdvanced ) {
				if ( GetWindowTextLength(GetDlgItem( m_hwnd, IDC_WILDCARD)) == 0 ||
					  GetWindowTextLength(GetDlgItem( m_hwnd, IDC_USER)) == 0 ||
					  GetWindowTextLength(GetDlgItem( m_hwnd, IDC_HOST)) == 0)
				{
					MessageBox( NULL, TranslateT(STR_ERROR2), TranslateT("IRC error"), MB_OK|MB_ICONERROR);
					return FALSE;
				}

				if ( !p->ppro->getTString( p->hContact, "Default", &dbv )) {
					CMString S = _T(STR_ERROR);
					S += _T(" (");
					S += dbv.ptszVal;
					S += _T(")");
					if (( lstrlen(temp) < 4 && lstrlen(temp)) || !WCCmp(CharLower(temp), CharLower(dbv.ptszVal))) {
						MessageBox( NULL, TranslateTS( S.c_str()), TranslateT( "IRC error" ), MB_OK | MB_ICONERROR );
						DBFreeVariant( &dbv );
						return FALSE;
					}
					DBFreeVariant( &dbv );
				}

				GetDlgItemText( m_hwnd, IDC_WILDCARD, temp, SIZEOF(temp));
				if ( lstrlen( GetWord(temp, 0).c_str()))
					p->ppro->setTString( p->hContact, "UWildcard", GetWord(temp, 0).c_str());
				else
					DBDeleteContactSetting( p->hContact, p->ppro->m_szModuleName, "UWildcard");
			}

			p->ppro->setByte( p->hContact, "AdvancedMode", bAdvanced);

			GetDlgItemText( m_hwnd, IDC_USER, temp, SIZEOF(temp));
			if (lstrlen(GetWord(temp, 0).c_str()))
				p->ppro->setTString( p->hContact, "UUser", GetWord(temp, 0).c_str());
			else
				DBDeleteContactSetting( p->hContact, p->ppro->m_szModuleName, "UUser");

			GetDlgItemText( m_hwnd, IDC_HOST, temp, SIZEOF(temp));
			if (lstrlen(GetWord(temp, 0).c_str()))
				p->ppro->setTString( p->hContact, "UHost", GetWord(temp, 0).c_str());
			else
				DBDeleteContactSetting( p->hContact, p->ppro->m_szModuleName, "UHost");

			EnableWindow(GetDlgItem( m_hwnd, IDC_BUTTON), FALSE);
		}

		if ( HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_BUTTON2 ) {
			if ( IsDlgButtonChecked( m_hwnd, IDC_RADIO2 ))
				SetDlgItemTextA( m_hwnd, IDC_WILDCARD, "");
			SetDlgItemTextA( m_hwnd, IDC_HOST, "" );
			SetDlgItemTextA( m_hwnd, IDC_USER, "" );
			DBDeleteContactSetting( p->hContact, p->ppro->m_szModuleName, "UWildcard");
			DBDeleteContactSetting( p->hContact, p->ppro->m_szModuleName, "UUser");
			DBDeleteContactSetting( p->hContact, p->ppro->m_szModuleName, "UHost");
			EnableWindow(GetDlgItem( m_hwnd, IDC_BUTTON), FALSE );
			EnableWindow(GetDlgItem( m_hwnd, IDC_BUTTON2), FALSE );
		}

		if ( HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_RADIO1 ) {
			SetDlgItemText( m_hwnd, IDC_DEFAULT, TranslateT(STR_BASIC));

			DBVARIANT dbv;
			if ( !p->ppro->getTString( p->hContact, "Default", &dbv )) {
				SetDlgItemText( m_hwnd, IDC_WILDCARD, dbv.ptszVal );
				DBFreeVariant( &dbv );
			}
			EnableWindow(GetDlgItem( m_hwnd, IDC_WILDCARD), FALSE );
		}

		if ( HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_RADIO2 ) {
			DBVARIANT dbv;
			SetDlgItemText( m_hwnd, IDC_DEFAULT, TranslateT(STR_ADVANCED));
			if ( !p->ppro->getTString( p->hContact, "UWildcard", &dbv )) {
				SetDlgItemText( m_hwnd, IDC_WILDCARD, dbv.ptszVal );
				DBFreeVariant( &dbv );
			}
			EnableWindow(GetDlgItem( m_hwnd, IDC_WILDCARD), true);
		}
		break;
	}
	return FALSE;
}
Example #12
0
LPTSTR Lowercase( LPTSTR psz )
/************************************************************************/
{
    return CharLower( psz );
}
Example #13
0
void CEdit::FindReplaceSelection()
{
	if ( g_FindReplaceData.m_bPreserveCase )
	{
		///////////////////////////////////////
		//
		// Format the replace text such that it follows the same
		// case pattern of the find text:
		//
		// a) All lower
		// b) All upper
		// c) First n chars all upper
		//
		//
		HGLOBAL hMem = NULL;
		// Selection should be normalized by caller!
		ASSERT( m_Selection.GetStartRow() <= m_Selection.GetEndRow() );
		ASSERT( m_Selection.GetStartRow() < m_Selection.GetEndRow() || m_Selection.GetStartCol() < m_Selection.GetEndCol() );
		VERIFY( m_Buffer.GetText( m_Selection.GetStartRow(), m_Selection.GetStartCol(), m_Selection.GetEndRow(), m_Selection.GetEndCol(), hMem, FALSE, FALSE ) );
		ASSERT( hMem );
		LPCTSTR pszFind = ( LPCTSTR ) GlobalLock( hMem );
		BOOL bUpper = TRUE;
		BOOL bLower = TRUE;
		int nFirstUpper = 0;

		LPCTSTR psz = pszFind;
		while ( *psz )
		{
			TCHAR chUpper = g_UpperConv[ ( BYTE ) *psz ];
			bUpper &= ( chUpper == *psz );
			bLower &= ( chUpper != *psz );
			if ( bUpper )
			{
				nFirstUpper++;
			}
			psz++;
		}
		
		LPTSTR pszOut = new TCHAR[ _tcslen( g_FindReplaceData.m_pszReplaceText ) + 1 ];
		_tcscpy( pszOut, g_FindReplaceData.m_pszReplaceText );

		if ( bUpper )
		{
			CharUpper( pszOut );
		}
		else if ( bLower )
		{
			CharLower( pszOut );
		}
		else if ( nFirstUpper )
		{
			CharLower( pszOut );
			LPTSTR psz = pszOut;
			while ( nFirstUpper-- && *psz )
			{
				*psz = g_UpperConv[ ( BYTE ) *psz ];
				psz++;
			}
		}

		ReplaceSelection( pszOut, FALSE );

		delete [] pszOut;
		GlobalUnlock( hMem );
		GlobalFree( hMem );

	}
	else
	{
		ReplaceSelection( g_FindReplaceData.m_pszReplaceText, FALSE );
	}
}
Example #14
0
HANDLE CIrcProto::CList_FindContact (CONTACT* user) 
{
	if ( !user || !user->name )
		return 0;
	
	TCHAR* lowercasename = mir_tstrdup( user->name );
	CharLower(lowercasename);
	
	DBVARIANT dbv1;
	DBVARIANT dbv2;	
	DBVARIANT dbv3;	
	DBVARIANT dbv4;	
	DBVARIANT dbv5;	

	for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
		if ( isChatRoom(hContact))
			continue;

		HANDLE hContact_temp = NULL;
		TCHAR* DBDefault = NULL;
		TCHAR* DBNick = NULL;
		TCHAR* DBWildcard = NULL;
		TCHAR* DBUser = NULL;
		TCHAR* DBHost = NULL;
		if ( !getTString(hContact, "Default",   &dbv1)) DBDefault = dbv1.ptszVal;
		if ( !getTString(hContact, "Nick",      &dbv2)) DBNick = dbv2.ptszVal;
		if ( !getTString(hContact, "UWildcard", &dbv3)) DBWildcard = dbv3.ptszVal;
		if ( !getTString(hContact, "UUser",     &dbv4)) DBUser = dbv4.ptszVal;
		if ( !getTString(hContact, "UHost",     &dbv5)) DBHost = dbv5.ptszVal;
				
		if ( DBWildcard )
			CharLower( DBWildcard );
		if ( IsChannel( user->name )) {
			if ( DBDefault && !lstrcmpi( DBDefault, user->name ))
				hContact_temp = (HANDLE)-1;
		}
		else if ( user->ExactNick && DBNick && !lstrcmpi( DBNick, user->name ))
			hContact_temp = hContact;
				
		else if ( user->ExactOnly && DBDefault && !lstrcmpi( DBDefault, user->name ))
			hContact_temp = hContact;
			
		else if ( user->ExactWCOnly ) {
			if ( DBWildcard && !lstrcmpi( DBWildcard, lowercasename ) 
				|| ( DBWildcard && !lstrcmpi( DBNick, lowercasename ) && !WCCmp( DBWildcard, lowercasename ))
				|| ( !DBWildcard && !lstrcmpi(DBNick, lowercasename)))
			{
				hContact_temp = hContact;
			}
		}
		else if ( _tcschr(user->name, ' ' ) == 0 ) {
			if (( DBDefault && !lstrcmpi(DBDefault, user->name) || DBNick && !lstrcmpi(DBNick, user->name) || 
					DBWildcard && WCCmp( DBWildcard, lowercasename ))
				&& ( WCCmp(DBUser, user->user) && WCCmp(DBHost, user->host)))
			{
				hContact_temp = hContact;
		}	}

		if ( DBDefault )   db_free(&dbv1);
		if ( DBNick )      db_free(&dbv2);
		if ( DBWildcard )  db_free(&dbv3);
		if ( DBUser )      db_free(&dbv4);
		if ( DBHost )      db_free(&dbv5);

		if ( hContact_temp != NULL ) {
			mir_free(lowercasename);
			if ( hContact_temp != (HANDLE)-1 )
				return hContact_temp;
			return 0;
		}
	}
	mir_free(lowercasename);
	return 0;
}
void MechLabScreen::begin()
{
	componentCount = 0;
	bSaveDlg = 0;
	status = RUNNING;
	bDragLeft= 0;
	bErrorDlg = 0;

	if ( !pVariant ) // if we are coming directly from the main menu
	{
		pVariant = LogisticsData::instance->getMechToModify()->getVariant();

		variantList.ListBox().removeAllItems(true);

		int maxCount = 0;
		LogisticsVariant** pVar = NULL;
		int addedCount = 0;

		LogisticsData::instance->getChassisVariants( pVariant->getChassis(),pVar, maxCount );
		if ( maxCount )
		{
			maxCount ++;
			pVar = (LogisticsVariant**)_alloca( maxCount* sizeof (LogisticsVariant*) );
			LogisticsData::instance->getChassisVariants( pVariant->getChassis(),pVar, maxCount );

			for ( int i = 0; i < maxCount; i++ )
			{
				if ( pVar[i]->allComponentsAvailable() )
				{
					variantList.AddItem( pVar[i]->getName(), rects[1].getColor() );
					if ( pVar[i]->getName().Compare( pVariant->getName() )  == 0 )
					{
						variantList.SelectItem( i );
						variantList.EditBox().setEntry( pVar[i]->getName() );
					}

					addedCount++;
				}
			}

		}
		if ( !addedCount ) // this is a mech we don't have access to yet
		{
			variantList.AddItem( pVariant->getName(), rects[1].getColor() );
			variantList.SelectItem( 0 );
			variantList.EditBox().setEntry(pVariant->getName() );

		}
		


		

		// no changes, set cost to 0
		textObjects[5].setText( "0" );
	}
	

	if ( pVariant )
	{
		textObjects[3].setText( pVariant->getChassisName() );
		originalCost = pVariant->getCost();


		char path[256];
		strcpy( path, artPath );
		strcat( path, "MCL_MC_" );
		char mechName[64];
		EString fileName = pVariant->getFileName( );
		_splitpath( fileName, NULL, NULL, mechName, NULL );
		strcat( path, mechName );
		strcat( path, "_B.tga" );
		CharLower( path );

		for ( int i = 51; i < 54; i++ )
			statics[i].setTexture( path );

		strcpy( path, artPath );
		strcat( path, "MCL_MC_" );
		strcat( path, mechName );
		strcat( path, "_A.tga" );
		CharLower( path );

		statics[50].setTexture( path );


		for ( i = COMPONENT_FORM_WEAPON_ENERGY; i < COMPONENT_FORM_JUMPJET + 1; i++ )
		{
			aButton* pButton = getButton( i );
			if ( pButton )
			{
				pButton->press( 0 );
			}
		}
		componentListBox.removeAllItems( 0 );

		componentListBox.setType( COMPONENT_FORM_WEAPON_BALLISTIC, -1, -1 );
		getButton( COMPONENT_FORM_WEAPON_BALLISTIC )->press( true );

		updateDiagram();

		if ( -1 == selectFirstDiagramComponent() )
			selectFirstLBComponent();

		oldCBillsAmount = 0;
	}

	// init CBills
	char text[32];
	sprintf( text, "%ld ", LogisticsData::instance->getCBills() );
	textObjects[1].setText( text );


	variantList.EditBox().getEntry(varName);

	if ( pVariant->getChassis()->jumpJetsAllowed() )
	{
		statics[54].showGUIWindow( true );
	}
	else
		statics[54].showGUIWindow( false );



}