Added Deserializer logging
This commit is contained in:
parent
cf589597b0
commit
091c6deefb
7 changed files with 36 additions and 14 deletions
|
|
@ -22,7 +22,8 @@ public enum Flag {
|
|||
CONVERSATIONS,
|
||||
PERIODIC,
|
||||
SQL,
|
||||
FOLDER_NORMALIZATION;
|
||||
FOLDER_NORMALIZATION,
|
||||
DESERIALIZER;
|
||||
|
||||
public inline bool is_all_set(Flag flags) {
|
||||
return (flags & this) == flags;
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ public class Geary.Imap.ListParameter : Geary.Imap.Parameter {
|
|||
// Because Deserializer doesn't produce NilParameters, check manually if this Parameter
|
||||
// can legally be NIL according to IMAP grammer.
|
||||
StringParameter? stringp = param as StringParameter;
|
||||
if (stringp != null && NilParameter.is_nil(stringp.value))
|
||||
if (stringp != null && NilParameter.is_nil(stringp))
|
||||
return null;
|
||||
|
||||
if (!param.get_type().is_a(type)) {
|
||||
|
|
@ -199,7 +199,6 @@ public class Geary.Imap.ListParameter : Geary.Imap.Parameter {
|
|||
* @see get_as_string
|
||||
* @throws ImapError.TYPE_ERROR if literal is longer than MAX_STRING_LITERAL_LENGTH.
|
||||
*/
|
||||
|
||||
public StringParameter? get_as_nullable_string(int index) throws ImapError {
|
||||
Parameter? param = get_as_nullable(index, typeof(Parameter));
|
||||
if (param == null)
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ public class Geary.Imap.NilParameter : Geary.Imap.Parameter {
|
|||
* means that the mailbox is actually named NIL and does not represent an empty string or empty
|
||||
* list.
|
||||
*/
|
||||
public static bool is_nil(string str) {
|
||||
return String.ascii_equali(VALUE, str);
|
||||
public static bool is_nil(StringParameter stringp) {
|
||||
return String.ascii_equali(VALUE, stringp.value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -390,8 +390,8 @@ public class Geary.Imap.ClientConnection : BaseObject {
|
|||
|
||||
// not buffering the Serializer because it buffers using a MemoryOutputStream and not
|
||||
// buffering the Deserializer because it uses a DataInputStream, which is buffered
|
||||
ser = new Serializer(ios.output_stream);
|
||||
des = new Deserializer(ios.input_stream);
|
||||
ser = new Serializer(to_string(), ios.output_stream);
|
||||
des = new Deserializer(to_string(), ios.input_stream);
|
||||
|
||||
des.parameters_ready.connect(on_parameters_ready);
|
||||
des.bytes_received.connect(on_bytes_received);
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ public class Geary.Imap.Deserializer : BaseObject {
|
|||
"Geary.Imap.Deserializer", State.TAG, State.COUNT, Event.COUNT,
|
||||
state_to_string, event_to_string);
|
||||
|
||||
private string identifier;
|
||||
private ConverterInputStream cins;
|
||||
private DataInputStream dins;
|
||||
private Geary.State.Machine fsm;
|
||||
|
|
@ -129,7 +130,9 @@ public class Geary.Imap.Deserializer : BaseObject {
|
|||
*/
|
||||
public signal void deserialize_failure();
|
||||
|
||||
public Deserializer(InputStream ins) {
|
||||
public Deserializer(string identifier, InputStream ins) {
|
||||
this.identifier = identifier;
|
||||
|
||||
cins = new ConverterInputStream(ins, midstream);
|
||||
cins.set_close_base_stream(false);
|
||||
dins = new DataInputStream(cins);
|
||||
|
|
@ -278,11 +281,15 @@ public class Geary.Imap.Deserializer : BaseObject {
|
|||
size_t bytes_read;
|
||||
string? line = dins.read_line_async.end(result, out bytes_read);
|
||||
if (line == null) {
|
||||
Logging.debug(Logging.Flag.DESERIALIZER, "[%s] line EOS", to_string());
|
||||
|
||||
push_eos();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Logging.debug(Logging.Flag.DESERIALIZER, "[%s] line %s", to_string(), line);
|
||||
|
||||
bytes_received(bytes_read);
|
||||
|
||||
push_line(line);
|
||||
|
|
@ -301,11 +308,15 @@ public class Geary.Imap.Deserializer : BaseObject {
|
|||
// happens when actually pulling data
|
||||
size_t bytes_read = dins.read_async.end(result);
|
||||
if (bytes_read == 0 && literal_length_remaining > 0) {
|
||||
Logging.debug(Logging.Flag.DESERIALIZER, "[%s] block EOS", to_string());
|
||||
|
||||
push_eos();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Logging.debug(Logging.Flag.DESERIALIZER, "[%s] block %lub", to_string(), bytes_read);
|
||||
|
||||
bytes_received(bytes_read);
|
||||
|
||||
// adjust the current buffer's size to the amount that was actually read in
|
||||
|
|
@ -487,6 +498,10 @@ public class Geary.Imap.Deserializer : BaseObject {
|
|||
return State.TAG;
|
||||
}
|
||||
|
||||
public string to_string() {
|
||||
return "des:%s/%s".printf(identifier, fsm.get_state_string(fsm.get_state()));
|
||||
}
|
||||
|
||||
//
|
||||
// Transition handlers
|
||||
//
|
||||
|
|
@ -791,9 +806,5 @@ public class Geary.Imap.Deserializer : BaseObject {
|
|||
|
||||
return State.FAILED;
|
||||
}
|
||||
|
||||
public string to_string() {
|
||||
return "%s/%s".printf(fsm.to_string(), get_mode().to_string());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,13 +20,15 @@
|
|||
*/
|
||||
|
||||
public class Geary.Imap.Serializer : BaseObject {
|
||||
private string identifier;
|
||||
private OutputStream outs;
|
||||
private ConverterOutputStream couts;
|
||||
private MemoryOutputStream mouts;
|
||||
private DataOutputStream douts;
|
||||
private Geary.Stream.MidstreamConverter midstream = new Geary.Stream.MidstreamConverter("Serializer");
|
||||
|
||||
public Serializer(OutputStream outs) {
|
||||
public Serializer(string identifier, OutputStream outs) {
|
||||
this.identifier = identifier;
|
||||
this.outs = outs;
|
||||
|
||||
couts = new ConverterOutputStream(outs, midstream);
|
||||
|
|
@ -100,7 +102,7 @@ public class Geary.Imap.Serializer : BaseObject {
|
|||
for (size_t ctr = 0; ctr < length; ctr++)
|
||||
builder.append_c((char) mouts.get_data()[ctr]);
|
||||
|
||||
Logging.debug(Logging.Flag.SERIALIZER, "COMMIT:\n%s", builder.str);
|
||||
Logging.debug(Logging.Flag.SERIALIZER, "[%s] send %s", to_string(), builder.str.strip());
|
||||
}
|
||||
|
||||
ssize_t index = 0;
|
||||
|
|
@ -120,5 +122,9 @@ public class Geary.Imap.Serializer : BaseObject {
|
|||
yield couts.flush_async(priority, cancellable);
|
||||
yield outs.flush_async(priority, cancellable);
|
||||
}
|
||||
|
||||
public string to_string() {
|
||||
return "ser:%s".printf(identifier);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue