'|  EXISTING STATE          |  DELIVER?  |  NEW STATE               |
|  "None"                  |  no        |  no state change         |
|  "None + Pending Out"    |  no        |  no state change         |
|  "None + Pending In"     |  yes *     |  "None"                  |
|  "None + Pending Out/In" |  yes *     |  "None + Pending Out"    |
|  "To"                    |  no        |  no state change         |
|  "To + Pending In"       |  yes *     |  "To"                    |
|  "From"                  |  yes *     |  "None"                  |
|  "From + Pending Out"    |  yes *     |  "None + Pending Out     |
|  "Both"                  |  yes *     |  "To"                    |'

def handle_unsubscribe(self, presence):

    if self.xmpp.is_component:
        if ((not self['from']) and self['pending_in']):
            self['pending_in'] = False
            self._unsubscribed()
        elif self['from']:
            self['from'] = False
            self._unsubscribed()
            self.xmpp.event('roster_subscription_remove', presence)
        self.save()
    else:
        self.xmpp.event('roster_subscription_remove', presence)
