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

def handle_unsubscribed(self, presence):

    if self.xmpp.is_component:
        if ((not self['to']) and self['pending_out']):
            self['pending_out'] = False
        elif (self['to'] and (not self['pending_out'])):
            self['to'] = False
            self.xmpp.event('roster_subscription_removed', presence)
        self.save()
    else:
        self.xmpp.event('roster_subscription_removed', presence)
