void CMailViewPlugins::Configure()
{
  FarMenu mnu( MMailboxes );

  FarIntArray Indices;
  for ( int i = 0; i < m_Libs.Count(); i ++ )
  {
    FarString Name = CMailbox::getLongName( (HINSTANCE)m_Libs[ i ] );
    if ( Name.IsEmpty() )
      Name = CMailbox::getShortName( (HINSTANCE)m_Libs[ i ] );
    if ( Name.IsEmpty() )
      Name = FarFileName( m_Names[ i ] ).GetName();

    mnu.AddItem( Name )->SetData( Indices.Add( i ) );
  }

  FarMenu::PItem Item;
  while ( ( Item = mnu.Show() ) != NULL )
  {
    int nIdx = Indices[ Item->GetData() ];

    FarString Default = CMailbox::getFilesMasks( (HINSTANCE)m_Libs[ nIdx ] );
    FarString Current = m_Masks[ nIdx ];
    if ( Current.IsEmpty() )
      Current = Default;

    if ( ConfigureFileMasksDlg( Item->GetText(), Default, Current ) )
    {
      m_Masks.Insert( nIdx, Current );
      m_Masks.Delete( nIdx + 1 );
    }

    mnu.SelectItem( Item );
  }
}
示例#2
0
bool CMailViewTpl::View( bool bEditor, bool bLock )
{
  FarFileName TempFile = FarFileName::MakeTemp( "mvt" );
  CreateDirectory( TempFile.GetBuffer() );
  TempFile.ReleaseBuffer();
  TempFile.AddEndSlash();
  TempFile.SetName( FarFileName::MakeTemp( "mvt" ) );
  TempFile.SetExt( ".msg" );

  if ( SaveToFile( TempFile ) == false )
    return false;

  FarString Subj = m_origMsg->GetSubject();
  if ( Subj.IsEmpty() )
    Subj = "<none>";

  SetFileAttributes( TempFile, GetFileAttributes( TempFile )|(bLock?FILE_ATTRIBUTE_READONLY:0) );

  if ( bEditor )
    Far::Editor( TempFile, Subj, 0, 0, -1, -1, 0, 1,
      EF_DELETEONCLOSE|EF_DISABLEHISTORY|EF_ENABLE_F6|EF_NONMODAL );
  else
    Far::Viewer( TempFile, Subj, 0, 0, -1, -1,
      VF_DELETEONCLOSE|VF_DISABLEHISTORY|VF_ENABLE_F6|VF_NONMODAL );

  return true;
}
示例#3
0
int FarXMLScanner::ParseEntity()
{
  FarString entityName;
  while (1)
  {
    char c = NextChar();
    if (c == ';')
      break;
    entityName += c;
  }
  if (entityName.IsEmpty())
  {
    ReportError ("entity name");
    return -1;
  }
  if (entityName [0] == '#')
    return DecodeEntity (entityName);
  if (entityName == "quot")
    return '\"';
  if (entityName == "apos")
    return '\'';
  if (entityName == "gt")
    return '<';
  if (entityName == "lt")
    return '>';
  if (entityName == "amp")
    return '&';
  ReportError ("known entity name");
  return -1;
}
示例#4
0
bool FarXMLScanner::ParseAttribute (FarXMLNode *node)
{
    FarString attrName = NextName();
  if (attrName.IsEmpty())
    return false;
    SkipWhitespace();
  if (!NextExpectedChar ('='))
    return false;
  SkipWhitespace();

  char valueDelimiter = NextChar();
  if (valueDelimiter != '\'' && valueDelimiter != '\"')
  {
    ReportError ("\" or \'");
    return false;
  }

  FarString attrValue;
  while (1)
  {
    char c = NextChar();
    if (c == valueDelimiter)
      break;
    else if (c == '&')
    {
      int entityValue = ParseEntity();
      if (entityValue == -1)
        return false;
      attrValue += (char) entityValue;
    }
    else
            attrValue += c;
  }
  node->AddAttr (attrName, attrValue);
  return true;
}
示例#5
0
FarXMLNode *FarXMLScanner::ParseChildNode()
{
    SkipWhitespace();

  int tagStartLine = fCurLine;
  int tagStartCol = GetCurColumn();
  if (!NextExpectedChar ('<'))
    return NULL;

  FarString tagName = NextName();
    if (tagName.IsEmpty())
    return NULL;

    FarXMLNode *theNode = new FarXMLNode();
  theNode->SetTag (tagName);
  theNode->SetStartPosition (tagStartLine, tagStartCol);

  while (1)
  {
    SkipWhitespace();
    char c = PeekNextChar();
    if (c == '/')
    {
      NextChar();
      if (!NextExpectedChar ('>'))
      {
        delete theNode;
        return NULL;
      }
      break;
    }
    else if (c == '>')
    {
      NextChar();
      SkipWhitespace();
      while (1)
      {
        if (PeekNextChar() == '<' && PeekNextChar (1) == '/')
          break;
        FarXMLNode *nextChild = ParseChildNode();
        if (!nextChild)
        {
          delete theNode;
          return NULL;
        }
        theNode->AddChild (nextChild);
        SkipWhitespace();
      }
      NextChar(); // <
      NextChar(); // /
      FarString closeTagName = NextName();
      if (closeTagName != tagName)
      {
        ReportError (tagName);
        delete theNode;
        return NULL;
      }
      SkipWhitespace();
      if (!NextExpectedChar ('>'))
      {
        delete theNode;
        return NULL;
      }
      break;
    }
    else
    {
      if (!ParseAttribute (theNode))
      {
        delete theNode;
        return NULL;
      }
    }
  }
  theNode->SetEndPosition (fCurLine, GetCurColumn());
  SkipWhitespace();

  return theNode;
}