Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if ($atom =~ m/while\(1\);/) {
- ### Dataformat changed 2012-02-08
- if ($atom =~ s/LABEL=.*\n\)]}'//) {
- # datapack shortcircuit
- # we use this to grab the full text of messages ...
- #
- ## uncomment below to see the datapack structure
- #print "atom:\n$atom\n\n" unless $silent;
- #
- ## as of 2/11/10, we can no longer use the old ui=1 datapack
- ## Unfortunately, the new ui=2 datapack is quite a bit less pleasant
- ## to use, with no nice "mb" cues ...
- #
- #my ($mb, $ma);
- #
- ## if ($atom =~ m/\["ms",.*?,.*?,.*?,.*?,.*?,.*?,.*?,.*?,\[.*?"\].*?\[.*?\[.*?,.*?,.*?,.*?,.*?,"(.*?)",\[/s) {#.*?,.*?,.*?,\[,.*?,.*?,.*?,.*?,.*?,"(.*?)",\[/g);
- ## print "\n\n-----\nYYYYY!\n$1\n";
- ## } else {
- ## print "\n\n-----\nNOPE!\n\n";
- ## }
- #
- ## See what you've made me do, Google?? Just look at this fugly regex ...
- ##while ($atom =~ m/\["ms",.*?,.*?,.*?,.*?,.*?,.*?,.*?,.*?,\[.*?"\].*?\[.*?\[.*?,.*?,.*?,.*?,.*?,"(.*?)",\[/sg) {
- #while ($atom =~ m/\["ms",.*?,.*?,.*?,.*?,.*?,.*?,.*?,.*?,\[.*?"\].*?\[.*?\[.*?,.*?,.*?,.*?,.*?,".*?","(.*?)",\[/sg) {
- #$mb .= "$1";
- #}
- #
- ## ma is the attachment, if any
- ## (I suspect this doesn't work anymore with the new datapack ...)
- #while ($atom =~ m/\["ma",\[(.*?)\]/g) {
- #my $att = $1;
- #$ma = "/mail/images/paperclip.gif"; # default attachment
- ## print "attachment =\n$att\n\n";
- #if ($att =~ m/src\\u003d\\\"(.*?)\\\"/g) {
- #$ma = $1;
- #}
- #}
- #
- #$mb = clean_text_body($mb);
- #print "cleaned text is\n$mb\n\n" unless $silent;
- #
- ## cs is the message id
- #my ($cs) = ($atom =~ m/.*\["ms","(.*?)"/s);
- ### JSON parsing instead of above regexps.
- ### FULL TEXT ###
- my $mb;
- ### Google does not return valid JSON. They use completely
- #empty syntax as in "value1",,"value3" to denote null, when
- #"value1","","value3" is mandated. This regexp fixes that.
- (my $json_raw = $atom ) =~ s/(?<=,),/"",/g;
- ### Google does not return valid JSON. They use ' to delimit
- #the last value of the response, when " is mandated.
- $json_raw =~ s/,'(\w*)'\]$/,"$1"\]/;
- use JSON -support_by_pp;
- my $json_parser = new JSON;
- my @json_array = $json_parser->decode($json_raw);
- ### Some magic array indices below
- ### Number of messages in the conversation.
- my $numconv = $json_array[0]->[0]->[2]->[3];
- ### Fulltext of last message.
- $mb = clean_text_body($json_array[0]->[0]->[$numconv+2]->[13]->[6]);
- ### ATTACHMENTS ###
- my $ma;
- ### Checkgmail does not seem to handle multiple attachments in
- #general, only showing a single icon. See later loop for how
- #one can iterate over attachments. Would be nice to get an icon
- #for every attachment along with a direct link to open/download
- #it.
- if($json_array[0]->[0]->[$numconv+2]->[13]->[7]->[0]->[0]){
- $ma = $json_array[0]->[0]->[$numconv+2]->[13]->[7]->[0]->[0]->[6];
- }
- #for(my $i=0; $json_array[0]->[0]->[$numconv+2]->[13]->[7]->[0]->[$i]; $i++){
- #print '---ATTACHMENT '.$i."\n";
- #print ' Name: '.$json_text[0]->[0]->[$numconv+2]->[13]->[7]->[0]->[$i]->[1]."\n";
- #print ' Type: '.$json_text[0]->[0]->[$numconv+2]->[13]->[7]->[0]->[$i]->[2]."\n";
- #print ' Size: '.$json_text[0]->[0]->[$numconv+2]->[13]->[7]->[0]->[$i]->[3]."\n";
- #print ' Icon: '.$json_text[0]->[0]->[$numconv+2]->[13]->[7]->[0]->[$i]->[6]."\n";
- #print ' Link: '.$json_text[0]->[0]->[$numconv+2]->[13]->[7]->[0]->[$i]->[9]."\n";
- #}
- ### Last message ID.
- my $cs = $json_array[0]->[0]->[$numconv+2]->[1];
- $messages_ext{$cs}->{text} = $mb;
- $messages_ext{$cs}->{shown} = 1;
- $messages_ext{$cs}->{attachment} = $ma;
- notify();
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment