Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Perltidy (and some stuff I forget)

  • Loading branch information...
commit ec33dc45890a57a6fc8102707d30432a2694e6c8 1 parent 06f61f9
Sanko Robinson authored

Showing 1 changed file with 56 additions and 32 deletions. Show diff stats Hide diff stats

  1. 88  lib/AnyEvent/MSN.pm
88  lib/AnyEvent/MSN.pm
@@ -209,15 +209,20 @@ package AnyEvent::MSN 0.001;
209 209
         },
210 210
         handles => {'trigger_' . $_ => 'execute_method'},
211 211
         )
212  
-        for qw[im nudge
213  
-        error connect];
214  
-  has connected => (
215  
-      is      => 'rw',
216  
-      isa     => 'Bool',
217  
-      traits  => ['Bool'],
218  
-      default => 0,
219  
-      handles => { _set_connected  => 'set', _unset_connected => 'unset' }
220  
-  );
  212
+        for qw[
  213
+        im nudge
  214
+        error connect
  215
+        addressbook_update
  216
+        buddylist_update
  217
+        user_notification
  218
+    ];
  219
+    has connected => (
  220
+             is      => 'rw',
  221
+             isa     => 'Bool',
  222
+             traits  => ['Bool'],
  223
+             default => 0,
  224
+             handles => {_set_connected => 'set', _unset_connected => 'unset'}
  225
+    );
221 226
 
222 227
     # Auto connect
223 228
     sub BUILD {
@@ -404,7 +409,13 @@ package AnyEvent::MSN 0.001;
404 409
                     $s->_set_connected();
405 410
                     $s->set_status($s->status);    # XXX - Yeah, this is odd
406 411
                 }
  412
+                else {
  413
+                    $s->trigger_user_notification($headers, $xml);
  414
+                }
  415
+
  416
+                #
407 417
             }
  418
+            default {...}
408 419
         }
409 420
     }
410 421
     sub _handle_packet_not { my $s = shift; }
@@ -530,32 +541,22 @@ XML
530 541
                          $s->tid, MIME::Base64::encode_base64($ticket, ''));
531 542
 
532 543
                 #
533  
-                my %contacts;
534  
-                {
535  
-                    for my $contact (
536  
-                             @{  $s->contacts->{'soap:Body'}
537  
-                                     {'ABFindContactsPagedResponse'}
538  
-                                     {'ABFindContactsPagedResult'}{'Contacts'}
539  
-                                     {'Contact'}
540  
-                             }
541  
-                        )
542  
-                    {   my ($user, $domain) = split /\@/,
543  
-                            $contact->{'contactInfo'}{'passportName'}, 2;
544  
-                        push @{$contacts{$domain}}, $user;
545  
-                    }
546  
-                }
547  
-                my $data = sprintf '<ml l="1">%s</ml>', join '', map {
548  
-                    sprintf '<d n="%s">%s</d>', $_, join '', map {
549  
-                        sprintf
550  
-                            '<c n="%s" t="1"><s l="3" n="IM" /><s l="3" n="PE" /><s l="3" n="PF" /></c>',
551  
-                            $_
552  
-                        } sort @{$contacts{$_}}
553  
-                } sort keys %contacts;
554  
-                $s->send("ADL %d %d\r\n%s", $s->tid, length($data), $data);
  544
+                my $x =    # XML modules get it wrong if we only have 1 buddy
  545
+                    $s->contacts->{'soap:Body'}{'ABFindContactsPagedResponse'}
  546
+                    {'ABFindContactsPagedResult'}{'Contacts'}{'Contact'};
  547
+                $x = [$x] if ref $x ne 'ARRAY';
  548
+                $s->add_buddy(map { $_->{contactInfo}{passportName} } @$x);
555 549
             }
556 550
         );
557 551
     }
558 552
 
  553
+    sub _handle_packet_rml {
  554
+        my ($s, $tid, $ok) = @_;
  555
+        use Data::Dump;
  556
+        ddx \@_;
  557
+        ...;
  558
+    }
  559
+
559 560
     sub _handle_packet_sbs {
560 561
         my $s = shift;
561 562
 
@@ -975,7 +976,9 @@ XML
975 976
     </d>
976 977
 </ml>
977 978
 
978  
-        $s->send("ADL %d %d\r\n%s", $s->tid, length($data), $data);
  979
+        my $tid = $s->tid;
  980
+        $s->send("RML %d %d\r\n%s", $tid, length($data), $data);
  981
+        $tid;
979 982
     }
980 983
     after set_status => sub {
981 984
         my ($s, $status) = @_;
@@ -1179,6 +1182,16 @@ This callback is triggered when we meet any sort of error. This callback is
1179 1182
 passed a texual message for display and an optional second argument which
1180 1183
 indicates that this is a fatal error.
1181 1184
 
  1185
+=item on_user_notification
  1186
+
  1187
+    ...
  1188
+    on_user_notification => sub { my ($s, $head, $presence) = @_; ... }
  1189
+    ...
  1190
+
  1191
+This callback is triggered when a contact updates their public information.
  1192
+Simple Online/Offline status changes are included in this as well as friendly
  1193
+name changes and current media (now playing) status.
  1194
+
1182 1195
 =back
1183 1196
 
1184 1197
 =item connect
@@ -1336,6 +1349,17 @@ and may (depending on the buddy's settings) make the IM window giggle around
1336 1349
 the screen for a second. ...which, I suppose, won the contest for the most
1337 1350
 annoying behaviour they could come up with.
1338 1351
 
  1352
+=item remove_buddy
  1353
+
  1354
+    $msn->remove_buddy('buddy@hotmail.com');
  1355
+
  1356
+The remove contacts from your lists. Note that you may only remove people from
  1357
+the FL, AL and BL using this command (which makes sense, seeing as you can
  1358
+also only add people to the FL, AL and BL with the L<add_buddy|/add_buddy>
  1359
+command). Also note that the contact will not be removed from your server-side
  1360
+address book - for this, you will have to use the ABContactDelete SOAP
  1361
+request. ...which we don't support yet.
  1362
+
1339 1363
 =back
1340 1364
 
1341 1365
 =head1 Notes

0 notes on commit ec33dc4

Please sign in to comment.
Something went wrong with that request. Please try again.