def userButtonClicked_(self, sender): if sender.tag() == 1: # account popup changed try: account = AccountManager().get_account( self.accountPop.titleOfSelectedItem()) self.account = account and account.id self.refreshPolicyTable() NSUserDefaults.standardUserDefaults().setValue_forKey_( self.account, "SelectedPolicyPresenceAccount") except KeyError: pass elif sender.tag() == 2: # add a new policy entry # the outcome of the operation is a change to an existing contact or the addition of a new one contact # the notifications emitted later by the contact will refresh the UI if self.account: created_new_contact = False i = 0 while not created_new_contact: try: account = AccountManager().get_account(self.account) address = "new_entry@" + account.id.domain if not i else "new_entry" + str( i) + '@' + account.id.domain contact = Contact(address, account=account) self.setContactPolicyForEvent(contact, self.event, self.defaultPolicy) contact.save() self.last_edited_address = contact.uri created_new_contact = True except DuplicateIDError: i += 1 elif sender.tag() == 3: # delete a policy entry # the outcome of the operation is a change to an existing contact or the deletion of a contact # the notifications emitted later by the contact will refresh the UI if self.account: view = self.tabViewForEvent[self.event] if view.selectedRow() >= 0: filter = unicode( self.searchSubscriberBox.stringValue().strip()) i_row = self.filtered_contacts_map[ view.selectedRow()] if filter else view.selectedRow() self.deletePolicyAction( self.account, self.event, self.policy_data[self.account][self.event][i_row]) elif sender.tag() == 4: # close window self.window().close()
def updatePolicyAction(self, account, event, address, policy): # modification made by user clicking buttons # the outcome is a modification of the underlying middleware contact that will generate notifications # finally notifications will repaint the GUI try: account = AccountManager().get_account(account) except KeyError: pass else: try: contact = account.contact_manager.get_contact(address) except KeyError: try: contact = Contact(address, account=account) self.setContactPolicyForEvent(contact, event, policy) contact.save() except DuplicateIDError: NSRunAlertPanel("Invalid Entry", "Policy for %s already exists"%address, "OK", "", "") return else: self.setContactPolicyForEvent(contact, event, policy) contact.save()
def userButtonClicked_(self, sender): if sender.tag() == 1: # account popup changed try: account = AccountManager().get_account(self.accountPop.titleOfSelectedItem()) self.account = account and account.id self.refreshPolicyTable() NSUserDefaults.standardUserDefaults().setValue_forKey_(self.account, "SelectedPolicyPresenceAccount") except KeyError: pass elif sender.tag() == 2: # add a new policy entry # the outcome of the operation is a change to an existing contact or the addition of a new one contact # the notifications emitted later by the contact will refresh the UI if self.account: created_new_contact = False i = 0 while not created_new_contact: try: account = AccountManager().get_account(self.account) address = "new_entry@"+account.id.domain if not i else "new_entry" + str(i) + '@' + account.id.domain contact = Contact(address, account=account) self.setContactPolicyForEvent(contact, self.event, self.defaultPolicy) contact.save() self.last_edited_address = contact.uri created_new_contact = True except DuplicateIDError: i += 1 elif sender.tag() == 3: # delete a policy entry # the outcome of the operation is a change to an existing contact or the deletion of a contact # the notifications emitted later by the contact will refresh the UI if self.account: view = self.tabViewForEvent[self.event] if view.selectedRow() >= 0: filter = unicode(self.searchSubscriberBox.stringValue().strip()) i_row = self.filtered_contacts_map[view.selectedRow()] if filter else view.selectedRow() self.deletePolicyAction(self.account, self.event, self.policy_data[self.account][self.event][i_row]) elif sender.tag() == 4: # close window self.window().close()
def updatePolicyAction(self, account, event, address, policy): # modification made by user clicking buttons # the outcome is a modification of the underlying middleware contact that will generate notifications # finally notifications will repaint the GUI try: account = AccountManager().get_account(account) except KeyError: pass else: try: contact = account.contact_manager.get_contact(address) except KeyError: try: contact = Contact(address, account=account) self.setContactPolicyForEvent(contact, event, policy) contact.save() except DuplicateIDError: NSRunAlertPanel("Invalid Entry", "Policy for %s already exists" % address, "OK", "", "") return else: self.setContactPolicyForEvent(contact, event, policy) contact.save()