示例#1
0
void CAliasDlg::OnConvertToRegexp() 
{
CString strText = GetText (m_ctlAliasName);

// check for foolishly using ** in a non-regular expression
if (strText.Find ("**") != -1 && !m_bRegexp)
  {
  CCreditsDlg dlg;

  dlg.m_iResourceID = IDR_MULTIPLE_ASTERISKS;
  dlg.m_strTitle = "Warning";

  dlg.DoModal ();	

  return;
  }

 strText = ConvertToRegularExpression (strText);

 m_ctlAliasName.SetWindowText (strText);

 m_ctlRegexp.SetCheck (TRUE);
	
}
示例#2
0
void CTabItem_MainTabBn::OnLButtonDown(UINT /*nFlags*/, CPoint /*point*/)
{
	CRect	rtItem(GetRectInScreen());

	CCmdMainTabOp	cmdMainTabOp;

	/*CMenu	file;
	file.CreateMenu();
	file.AppendMenu(MF_STRING, 8, GetResString(IDS_NEWTASK));
	file.AppendMenu(MF_SEPARATOR);
	file.AppendMenu(MF_STRING, 3, GetResString(IDS_IMPORT_UNFINISHED));*/

	CMenu tool;
	tool.CreateMenu();
	tool.AppendMenu(MF_STRING, 8, GetResString(IDS_NEWTASK));
	tool.AppendMenu(MF_STRING, 3, GetResString(IDS_IMPORT_UNFINISHED));
	

	CMenu   help;
	help.CreateMenu();
	help.AppendMenu(MF_STRING, 2, GetResString(IDS_HELP_));
	help.AppendMenu(MF_STRING, 5, GetResString(IDS_BUGREPORT));
	help.AppendMenu(MF_STRING, 6, GetResString(IDS_NEWVERSIONREPORT));
	help.AppendMenu(MF_SEPARATOR);
	help.AppendMenu(MF_STRING, 4, GetResString(IDS_VERSIONCHECK));
	help.AppendMenu(MF_SEPARATOR);
	help.AppendMenu(MF_STRING, 9, GetResString(IDS_ABOUTBOX));

	CMenu	menu;
	menu.CreatePopupMenu();
	/*menu.AppendMenu(MF_STRING|MF_POPUP,(UINT_PTR)file.m_hMenu, GetResString(IDS_FILE));*/
	menu.AppendMenu(MF_STRING, 1, GetResString(IDS_EM_PREFS));
	menu.AppendMenu(MF_SEPARATOR);
	menu.AppendMenu(MF_STRING|MF_POPUP,(UINT_PTR)tool.m_hMenu, GetResString(IDS_TOOLS));
	menu.AppendMenu(MF_STRING|MF_POPUP,(UINT_PTR)help.m_hMenu, GetResString(IDS_HELP));
	menu.AppendMenu(MF_SEPARATOR);

	const static int SHOW_TAB_CMD_START = 7;

	if (cmdMainTabOp.IsTabShowed(CMainTabWnd::TI_ADVANCE))
		menu.AppendMenu(MF_STRING | MF_CHECKED, SHOW_TAB_CMD_START, GetResString(IDS_ADVANCE_));
	else
		menu.AppendMenu(MF_STRING, SHOW_TAB_CMD_START, GetResString(IDS_ADVANCE_));


	int iRet = menu.TrackPopupMenu(TPM_RETURNCMD, rtItem.left, rtItem.bottom, ::AfxGetMainWnd());

	menu.DestroyMenu();

	switch(iRet)
	{
	case 1:
		CmdFuncs::OpenPreferencesWnd();
		break;
	case 2:
		CmdFuncs::GotoGuide();
		break;
	case 3:
		CmdFuncs::ImportUnfinishedTasks();
		break;
	case 4:
		theApp.emuledlg->DoVersioncheck(true);
		break;
	case 5:
		CmdFuncs::OpenNewUrl(_T("http://beta.verycd.com/groups/eMuleBug"), GetResString(IDS_BUGREPORT));
		break;
	case 6:
		CmdFuncs::OpenNewUrl(_T("http://beta.verycd.com/groups/eMuleBeta/"), GetResString(IDS_NEWVERSIONREPORT));
		break;
	case SHOW_TAB_CMD_START:
		if (cmdMainTabOp.IsTabShowed(CMainTabWnd::TI_ADVANCE))
		{
			cmdMainTabOp.RemoveTabById(CMainTabWnd::TI_ADVANCE);
		}
		else
		{
			cmdMainTabOp.AddTabById(CMainTabWnd::TI_ADVANCE);
		}
		break;
	case 8:
		CmdFuncs::PopupNewTaskDlg();
		break;
	case 9:
		{
			CCreditsDlg dlgAbout;
			dlgAbout.DoModal();
			break;
		}
	default:
		break;
	}

}
示例#3
0
void CAliasDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);

  if(!pDX->m_bSaveAndValidate)
    {
    if (m_current_alias && m_current_alias->bIncluded)
      m_strIncluded = "(included)";
    else 
      m_strIncluded.Empty ();
    }

	//{{AFX_DATA_MAP(CAliasDlg)
	DDX_Control(pDX, IDC_SEND_TO, m_ctlSendTo);
	DDX_Control(pDX, IDC_VARIABLE, m_ctlVariable);
	DDX_Control(pDX, IDC_REGEXP, m_ctlRegexp);
	DDX_Control(pDX, IDC_ALIAS_CONTENTS, m_ctlAliasContents);
	DDX_Control(pDX, IDC_ALIAS_NAME, m_ctlAliasName);
	DDX_Text(pDX, IDC_ALIAS_CONTENTS, m_contents);
	DDX_Text(pDX, IDC_ALIAS_NAME, m_name);
	DDX_Text(pDX, IDC_ALIAS_LABEL, m_strLabel);
	DDX_Check(pDX, IDC_ENABLED, m_bEnabled);
	DDX_Text(pDX, IDC_SCRIPT_NAME, m_strProcedure);
	DDX_Check(pDX, IDC_IGNORE_CASE, m_bIgnoreCase);
	DDX_Check(pDX, IDC_EXPAND_VARIABLES, m_bExpandVariables);
	DDX_Check(pDX, IDC_OMIT_FROM_LOG, m_bOmitFromLogFile);
	DDX_Check(pDX, IDC_REGEXP, m_bRegexp);
	DDX_Check(pDX, IDC_OMIT_FROM_OUTPUT, m_bOmitFromOutput);
	DDX_Check(pDX, IDC_ALIAS_MENU, m_bMenu);
	DDX_Check(pDX, IDC_TEMPORARY_ALIAS, m_bTemporary);
	DDX_Text(pDX, IDC_GROUP, m_strGroup);
	DDX_Text(pDX, IDC_VARIABLE, m_strVariable);
	DDX_CBIndex(pDX, IDC_SEND_TO, m_iSendTo);
	DDX_Check(pDX, IDC_KEEP_EVALUATING, m_bKeepEvaluating);
	DDX_Text(pDX, IDC_SEQUENCE, m_iSequence);
	DDV_MinMaxInt(pDX, m_iSequence, 0, 10000);
	DDX_Check(pDX, IDC_ECHO_ALIAS, m_bEchoAlias);
	DDX_Check(pDX, IDC_OMIT_FROM_COMMAND_HISTORY, m_bOmitFromCommandHistory);
	DDX_Text(pDX, IDC_INCLUDED, m_strIncluded);
	DDX_Text(pDX, IDC_REGEXP_ERROR, m_strRegexpError);
	DDX_Check(pDX, IDC_ONE_SHOT, m_bOneShot);
	//}}AFX_DATA_MAP

 if(pDX->m_bSaveAndValidate)
   {
    POSITION pos;
    CAlias * alias_item;

    m_strLabel.TrimLeft ();
    m_strLabel.TrimRight ();

    m_strProcedure.TrimLeft ();
    m_strProcedure.TrimRight ();

    m_strGroup.TrimLeft ();
    m_strGroup.TrimRight ();

    m_strVariable.TrimLeft ();
    m_strVariable.TrimRight ();

    if (m_name.IsEmpty ())
        {
        ::TMessageBox("The alias cannot be blank.");
        DDX_Text(pDX, IDC_ALIAS_NAME, m_name);
        pDX->Fail();
        }     // end of alias being blank

    // check for foolishly using ** in a non-regular expression
    if (m_name.Find ("**") != -1 && !m_bRegexp)
      {
      CCreditsDlg dlg;

      dlg.m_iResourceID = IDR_MULTIPLE_ASTERISKS;
      dlg.m_strTitle = "Warning";

      dlg.DoModal ();	

      DDX_Text(pDX, IDC_ALIAS_NAME, m_name);
      pDX->Fail();

      }

    int iInvalidPos = m_name.FindOneOf ("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"); 

    if (iInvalidPos != -1)
        {
        char c = m_name [iInvalidPos];

        ::UMessageBox(TFormat (
           "The alias 'match' text contains an invalid non-printable character (hex %02X) at position %i.", c, iInvalidPos + 1), MB_ICONSTOP);
        DDX_Text(pDX, IDC_ALIAS_NAME, m_name);
        pDX->Fail();
        }     // end of alias match having weird characters in it


    // we allow carriage-return, linefeed, tab here
    iInvalidPos = m_contents.FindOneOf ("\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0E\x0F"); 

    if (iInvalidPos != -1)
        {
        char c = m_contents [iInvalidPos];

        ::UMessageBox(TFormat (
           "The alias 'send' text contains an invalid non-printable character (hex %02X) at position %i.", c, iInvalidPos + 1), MB_ICONSTOP);
        DDX_Text(pDX, IDC_ALIAS_CONTENTS, m_contents);
        pDX->Fail();
        }     // end of alias send having weird characters in it


    // compile regular expression to check it
    if (m_bRegexp)
      {
      if (!CheckRegularExpression (m_name, (m_bIgnoreCase ?  0 : PCRE_CASELESS) 
          | (m_pDoc->m_bUTF_8 ? PCRE_UTF8 : 0)
#if ALIASES_USE_UTF8
                                  | (m_pDoc->m_bUTF_8 ? PCRE_UTF8 : 0)
#endif // ALIASES_USE_UTF8
          
          ))
        {   // failed check
        DDX_Text(pDX, IDC_ALIAS_NAME, m_name);
        pDX->Fail();
        }
      } // end of checking regular expression

    CString strAliasName;

    for (pos = m_pAliasMap->GetStartPosition (); pos; )
      {
      m_pAliasMap->GetNextAssoc (pos, strAliasName, alias_item);

// don't compare against itself

      if (alias_item == m_current_alias)
        continue;

      /*
      
      bool bDuplicate = false;

      // if either one is case-insensitive, compare insensitive
      if ((alias_item->bIgnoreCase || m_bIgnoreCase) &&
           alias_item->name.CompareNoCase (m_name) == 0)
            bDuplicate = true; 
      // if both are case-sensitive, compare exactly
      else if (alias_item->name == m_name)
            bDuplicate = true; 

      // we won't consider it a match if they send to different places
      if (alias_item->iSendTo != m_iSendTo)
         bDuplicate = false;

      if (bDuplicate)
        {
        ::TMessageBox("This alias is already in the list of aliases.");
        DDX_Text(pDX, IDC_ALIAS_NAME, m_name);
        pDX->Fail();
        }

         */

// now check the label for duplicates

      if (!m_strLabel.IsEmpty ())    // we can have duplicate blank names
        if (m_strLabel.CompareNoCase (alias_item->strLabel) == 0)
          {
          CString strMsg;
          strMsg = TFormat ("The alias label \"%s\" is already in the list of aliases.",
                          (LPCTSTR) m_strLabel);
          ::UMessageBox(strMsg);
          DDX_Text(pDX, IDC_ALIAS_LABEL, m_strLabel);
          pDX->Fail();
          }

      }   // end of checking each alias

    if (!m_strLabel.IsEmpty ())    // we can have blank labels
      {

// check label is valid

      if (CheckLabel (m_strLabel))
        {
        ::TMessageBox("The label must start with a letter and consist of letters"
                        ", numbers or the underscore character.");
        DDX_Text(pDX, IDC_ALIAS_LABEL, m_strLabel);
        pDX->Fail();
        }

      }   // end of having non-blank label

    if (m_strVariable.IsEmpty ())    // we can have blank variables
      {
      if (m_iSendTo == eSendToVariable)
        {
        ::TMessageBox("When sending to a variable you must specify a variable name. ",
                        MB_ICONSTOP);
        DDX_Text(pDX, IDC_VARIABLE, m_strVariable);
        pDX->Fail();
        }
      }
    else
      {

// check variable name is valid

      if (CheckLabel (m_strVariable))
        {
        ::TMessageBox("The variable name must start with a letter and consist of letters"
                        ", numbers or the underscore character.");
        DDX_Text(pDX, IDC_VARIABLE, m_strVariable);
        pDX->Fail();
        }

      }   // end of having non-blank variable

    // check for speed walking OK, unless they are substituting

    if (!m_bExpandVariables || m_contents.Find ('@') == -1)
      if (m_iSendTo == eSendToSpeedwalk && m_contents.Find ('%') == -1)
        {

        CString strResult = m_pDoc->DoEvaluateSpeedwalk (m_contents);

        if (!strResult.IsEmpty ())
          {
          if (strResult [0] == '*')    // error in speedwalk string?
            {
            ::UMessageBox (strResult.Mid (1));
            DDX_Text(pDX, IDC_ALIAS_CONTENTS, m_contents);
            pDX->Fail();
            }   // end of error message
          } // end of non-empty speedwalk          
        }   // end of speed walking wanted


    if(m_contents.IsEmpty () && m_strProcedure.IsEmpty ())
        {
        ::TMessageBox("The alias contents cannot be blank unless you specify a script subroutine.");
        DDX_Text(pDX, IDC_ALIAS_CONTENTS, m_contents);
        pDX->Fail();
        }     // end of contents being blank

    
    if (!m_strProcedure.IsEmpty ())    // blank procedure is OK
      {

// check procedure is valid

      if (CheckLabel (m_strProcedure, true))
        {
        ::TMessageBox("The script subroutine name must start with a letter and consist of letters"
                        ", numbers or the underscore character.");
        DDX_Text(pDX, IDC_SCRIPT_NAME, m_strProcedure);
        pDX->Fail();
        }

      }   // end of having non-blank procedure

   } // end of saving and validating
  else
    if (App.m_bFixedFontForEditing)
      {     
      FixFont (m_font, m_ctlAliasName, App.m_strFixedPitchFont, App.m_iFixedPitchFontSize, FW_NORMAL, DEFAULT_CHARSET);
      FixFont (m_font2, m_ctlAliasContents, App.m_strFixedPitchFont, App.m_iFixedPitchFontSize, FW_NORMAL, DEFAULT_CHARSET);
      }

}