Пример #1
0
void CMailViewTpl::processHeaders( IWriteSink & f )
{
  PKludges Kludges = m_origMsg->GetKludges();

  for ( int i = 0; i < Kludges->Count(); i ++ )
  {
    FarString kludge = Kludges->At( i );

    m_origMsg->DecodeKludge( kludge.GetBuffer() ); kludge.ReleaseBuffer();

    int pos = 1;

    while ( ( pos = kludge.IndexOf( '\t', pos ) ) != -1 )
    {
      FarString ss = kludge.Left( pos );
      if (ss.Length() > 0 && ss[ss.Length() - 1] == ':')
      {
        pos ++;
        continue;
      }
      f.write( ss.c_str(), ss.Length() );
      f.write( "\r\n", 2 );
      kludge = kludge.Right( kludge.Length() - pos );
    }

    f.write( kludge.c_str(), kludge.Length() );

    if ( i < Kludges->Count() - 1 )
      f.write( "\r\n", 2 );
  }
}
Пример #2
0
void CMessageTemplate::writeFormatted( const FarString& str, int len, int fill, IWriteSink & f )
{
  if ( len > 0 )
  {
    f.write( str.c_str(), min( len, str.Length() ) );

    if ( fill != 0 )
    {
      for ( int i = str.Length(); i < len; i ++ )
        f.write( (const char*)&fill, 1 );
    }
  }
  else
    f.write( str.c_str(), str.Length() );

}
Пример #3
0
int FarXMLScanner::DecodeEntity (const FarString &entityName)
{
  int startPos = 1;
  int radix = 10;
  if (entityName [1] == 'x')
  {
    radix = 16;
    startPos++;
  }

  int value = 0;
  for (int pos=startPos; pos<entityName.Length(); pos++)
  {
    value *= radix;
    char c = entityName [pos];
        if (c >= '0' && c <= '9')
      value += c - '0';
    else if (radix == 16 && c >= 'A' && c <= 'F')
      value += c - 'A' + 10;
    else if (radix == 16 && c >= 'a' && c <= 'f')
      value += c - 'a' + 10;
    else
    {
      if (radix == 16)
        ReportError ("hex digit");
      else
        ReportError ("digit");
      return -1;
    }
  }
  return value;
}
Пример #4
0
void CMailViewTpl::processMessageId( int len, int fill, IWriteSink & f )
{
  FarString s = m_origMsg->GetId();
  if ( s.Length() > 2 && s[ 0 ] == '<' )
  {
    s = s.Mid( 1 );
    int pos = s.IndexOf( '>' );
    if ( pos != -1 )
      s = s.Left( pos );
  }
  writeFormatted( s, len, fill, f );
}
Пример #5
0
FarString CMailViewPlugins::MakeKeyName( LPCSTR Root, LPCSTR FileName )
{
  FarString Key = ExtractRelativePath( Root, FileName );
  Key.Insert( 0, "Mailbox_" );
  Key.SetLength( Key.Length() - 4 );
  Key += "_Masks";

  int nIdx = Key.IndexOf( '\\' );
  while ( nIdx != -1 )
  {
    Key[ nIdx ] = '_';
    nIdx = Key.IndexOf( '\\' );
  }

  return Key;
}
Пример #6
0
void CMailViewTpl::processText( int len, IWriteSink & f )
{
  // TODO: check File
  FarFileName bodyFile = FarFileName::MakeTemp( "mvb" );

  File::mkdirs( bodyFile.GetPath() );

  PMsgPart TextPart = m_origMsg->GetTextPart();
  if ( TextPart )
  {
    long Encoding = GetMsgEncoding( m_origMsg, TextPart, m_defaultEncoding );

    if ( len > 20 )
    {
      FarStringArray Src;
      StrPtr sp = { NULL, 0, (LPSTR)TextPart->GetContentData() };
      LPCSTR Last = sp.Nxt + TextPart->GetContentSize();
      while ( sp.Nxt )
      {
        GetStrPtr( sp.Nxt, &sp, Last );
        Src.Add( ToOEMString( FarString( sp.Str, sp.Len ), Encoding ) );
      }
      FarStringArray * Dst = WordWrapLines( Src, len, true );
      for ( int i = 0; i < Dst->Count(); i ++ )
      {
        f.write( Dst->At( i ), strlen( Dst->At( i ) ) );
        f.write( "\r\n", 2 );
      }
      delete Dst;
    }
    else
    {
      FarString s = (LPCSTR)TextPart->GetContentData();

      s.SetLength( TextPart->GetContentSize() );

      s = ToOEMString( s, Encoding );

      f.write( s.c_str(), s.Length() );
    }

    File::deleteit( bodyFile );
  }
}
Пример #7
0
void CMailViewTpl::processKludge( LPCSTR kludge, IWriteSink & f )
{
  FarString s = m_origMsg->GetDecodedKludge( kludge );

  f.write( s.c_str(), s.Length() );
}