Ejemplo n.º 1
0
        protected virtual bool sendCommand( EmailClientCommand command, String cmd )
        {
            bool error = false;
            System.String response = null;

            //Send cmd and evaluate response
            if (connected) {
                // Send cmd
                error = !client.sendCommand( cmd, commandEnd );
                // Read Response
                error = (error)?true:!client.readResponse(ref response, responseEndSL, true);
                // Evaluate the result
                error = (error)?true:!this.evaluateresponse(response);
                if ( error || !command.Equals(EmailClientCommand.Logout) ) {
                    this.lastResponse = response;
                }
            } else {
                error = true;
            }

            return !error;
        }
Ejemplo n.º 2
0
 private bool parseUntaggedResponse(MemoryStream response, Object[] list, String token, EmailClientCommand cmd )
 {
     bool error = false;
     int msgnum=-1;
     Object value=-1;
     StreamReader resp = new StreamReader(response);
     for ( System.String line=resp.ReadLine(); line!=null; line=resp.ReadLine(), msgnum=-1, value=-1 ) {
         if ( line.StartsWith("*") && line.IndexOf(token)>0 ) {
             String[] values = line.Split( new char[]{' ', '(', ')'} );
             for ( int i=0; i<values.Length; i++ ) {
                 if ( values[i].Equals("*") ) {
                     msgnum = this.parseInteger(values[++i]);
                 } else if ( values[i].Equals(token) ) {
                     if  ( cmd.Equals(anmar.SharpWebMail.EmailClientCommand.ListSize) )
                         value = this.parseInteger(values[++i]);
                     else
                         value = values[++i];
                 }
             }
             if ( ( cmd.Equals(anmar.SharpWebMail.EmailClientCommand.ListUID) || cmd.Equals(anmar.SharpWebMail.EmailClientCommand.ListSize) )
                 && msgnum>0 && list.Length>=msgnum ) {
                 list[msgnum-1]=value;
             } else if ( cmd.Equals(anmar.SharpWebMail.EmailClientCommand.Status) && msgnum>=0 ) {
                 list[0] = msgnum;
             } else if ( log.IsErrorEnabled ) {
                 log.Error ( "Error while parsing response line:" + line);
                 error = true;
             }
         }
     }
     return !error;
 }