Use jb_subscr_ in jb_delbuddy()
authorMikael Berthe <mikael@lilotux.net>
Thu, 04 May 2006 17:03:19 +0200
changeset 834 6f913f4fbb2a
parent 833 63707a595c2e
child 835 6a732d2ad4b4
Use jb_subscr_ in jb_delbuddy() (Avoid code duplication)
mcabber/src/jabglue.c
mcabber/src/jabglue.h
--- a/mcabber/src/jabglue.c	Thu May 04 16:02:22 2006 +0200
+++ b/mcabber/src/jabglue.c	Thu May 04 17:03:19 2006 +0200
@@ -436,6 +436,17 @@
   xmlnode_free(x);
 }
 
+//  jb_subscr_request_cancel(jid)
+// Request to cancel jour subscription to jid's presence updates
+void jb_subscr_request_cancel(const char *jid)
+{
+  xmlnode x;
+
+  x = jutil_presnew(JPACKET__UNSUBSCRIBE, (char *)jid, NULL);
+  jab_send(jc, x);
+  xmlnode_free(x);
+}
+
 // Note: the caller should check the jid is correct
 void jb_addbuddy(const char *jid, const char *name, const char *group)
 {
@@ -477,7 +488,7 @@
 
 void jb_delbuddy(const char *jid)
 {
-  xmlnode x, y, z;
+  xmlnode y, z;
   eviqs *iqn;
   char *cleanjid;
 
@@ -498,12 +509,8 @@
   }
 
   // Cancel the subscriptions
-  x = jutil_presnew(JPACKET__UNSUBSCRIBED, cleanjid, 0); // Cancel "from"
-  jab_send(jc, x);
-  xmlnode_free(x);
-  x = jutil_presnew(JPACKET__UNSUBSCRIBE, cleanjid, 0);  // Cancel "to"
-  jab_send(jc, x);
-  xmlnode_free(x);
+  jb_subscr_cancel_auth(cleanjid);    // Cancel "from"
+  jb_subscr_request_cancel(cleanjid); // Cancel "to"
 
   // Ask for removal from roster
   iqn = iqs_new(JPACKET__SET, NS_ROSTER, NULL, IQS_DEFAULT_TIMEOUT);
--- a/mcabber/src/jabglue.h	Thu May 04 16:02:22 2006 +0200
+++ b/mcabber/src/jabglue.h	Thu May 04 17:03:19 2006 +0200
@@ -42,6 +42,7 @@
 void jb_subscr_send_auth(const char *jid);
 void jb_subscr_cancel_auth(const char *jid);
 void jb_subscr_request_auth(const char *jid);
+void jb_subscr_request_cancel(const char *jid);
 void jb_addbuddy(const char *jid, const char *name, const char *group);
 void jb_delbuddy(const char *jid);
 void jb_updatebuddy(const char *jid, const char *name, const char *group);