def __init__(self, blink_contact): NSBundle.loadNibNamed_owner_("Contact", self) self.window.setTitle_(NSLocalizedString("Edit Contact", "Window title")) self.addButton.setTitle_(NSLocalizedString("OK", "Button title")) self.dealloc_timer = None self.blink_contact = blink_contact self.belonging_groups = self.model.getBlinkGroupsForBlinkContact( blink_contact) self.all_groups = [ g for g in self.groupsList if g.group is not None and not isinstance(g.group, VirtualGroup) and g.add_contact_allowed ] self.nameText.setStringValue_(blink_contact.name or "") key = NSLocalizedString( "Public key: %s", "Label" ) % blink_contact.contact.public_key_checksum if blink_contact.contact.public_key_checksum else '' self.publicKey.setStringValue_(key) self.organizationText.setStringValue_(blink_contact.organization or "") self.photoImage.setImage_(blink_contact.icon) self.preferred_media = blink_contact.preferred_media address_types = list( item.title() for item in self.addressTypesPopUpButton.itemArray()) for item in blink_contact.contact.uris: type = format_uri_type(item.type) if type not in address_types: self.addressTypesPopUpButton.addItemWithTitle_(type) self.addButton.setEnabled_( True if blink_contact.contact.uris else False) self.default_uri = self.blink_contact.contact.uris.default self.autoanswerCheckbox.setState_( NSOnState if blink_contact.auto_answer else NSOffState) self.uris = sorted(blink_contact.contact.uris, key=lambda uri: uri.position if uri.position is not None else sys.maxsize) # TODO: how to handle xmmp: uris? #for uri in self.uris: #if uri.type is not None and uri.type.lower() == 'xmpp' and ';xmpp' in uri.uri: # uri.uri = uri.uri.replace(';xmpp', '') self.update_default_uri() self.addressTable.reloadData() self.subscriptions = { 'presence': { 'subscribe': blink_contact.contact.presence.subscribe, 'policy': blink_contact.contact.presence.policy }, 'dialog': { 'subscribe': blink_contact.contact.dialog.subscribe, 'policy': blink_contact.contact.dialog.policy } } self.defaultButton.setEnabled_(False) self.updateSubscriptionMenus() self.updatePreferredMediaMenus() self.loadGroupNames()
def __init__(self, uri=None, name=None, group=None, type=None): NSBundle.loadNibNamed_owner_("Contact", self) self.window.setTitle_(NSLocalizedString("Add Contact", "Window title")) self.dealloc_timer = None self.default_uri = None self.preferred_media = 'audio' self.uris = [ContactURI(uri=uri, type=format_uri_type(type))] if uri else [] self.update_default_uri() self.subscriptions = {'presence': {'subscribe': True, 'policy': 'allow'}, 'dialog': {'subscribe': False, 'policy': 'block'}} self.all_groups = [g for g in self.groupsList if g.group is not None and not isinstance(g.group, VirtualGroup) and g.add_contact_allowed] self.belonging_groups = [] if group is not None: self.belonging_groups.append(group) self.nameText.setStringValue_(name or "") self.photoImage.setImage_(self.defaultPhotoImage) self.defaultButton.setEnabled_(False) self.updateSubscriptionMenus() self.loadGroupNames() self.addButton.setEnabled_(True if self.uris else False)
def __init__(self, blink_contact): NSBundle.loadNibNamed_owner_("Contact", self) self.window.setTitle_(NSLocalizedString("Edit Contact", "Window title")) self.addButton.setTitle_(NSLocalizedString("OK", "Button title")) self.dealloc_timer = None self.blink_contact = blink_contact self.belonging_groups = self.model.getBlinkGroupsForBlinkContact(blink_contact) self.all_groups = [g for g in self.groupsList if g.group is not None and not isinstance(g.group, VirtualGroup) and g.add_contact_allowed] self.nameText.setStringValue_(blink_contact.name or "") self.photoImage.setImage_(blink_contact.icon) self.preferred_media = blink_contact.preferred_media address_types = list(item.title() for item in self.addressTypesPopUpButton.itemArray()) for item in blink_contact.contact.uris: type = format_uri_type(item.type) if type not in address_types: self.addressTypesPopUpButton.addItemWithTitle_(type) self.addButton.setEnabled_(True if blink_contact.contact.uris else False) self.default_uri = blink_contact.default_uri self.uris = list(blink_contact.contact.uris) # TODO: how to handle xmmp: uris? #for uri in self.uris: #if uri.type is not None and uri.type.lower() == 'xmpp' and ';xmpp' in uri.uri: # uri.uri = uri.uri.replace(';xmpp', '') self.update_default_uri() self.addressTable.reloadData() self.subscriptions = { 'presence': {'subscribe': blink_contact.contact.presence.subscribe, 'policy': blink_contact.contact.presence.policy}, 'dialog': {'subscribe': blink_contact.contact.dialog.subscribe, 'policy': blink_contact.contact.dialog.policy} } self.defaultButton.setEnabled_(False) self.updateSubscriptionMenus() self.updatePreferredMediaMenus() self.loadGroupNames()
def __init__(self, uris=[], name=None, group=None): NSBundle.loadNibNamed_owner_("Contact", self) self.window.setTitle_(NSLocalizedString("Add Contact", "Window title")) self.dealloc_timer = None self.default_uri = None self.preferred_media = 'audio' self.uris = [] for (uri, type) in uris: self.uris.append(ContactURI(uri=uri.strip(), type=format_uri_type(type))) self.update_default_uri() self.subscriptions = {'presence': {'subscribe': True, 'policy': 'allow'}, 'dialog': {'subscribe': False, 'policy': 'block'}} self.all_groups = [g for g in self.groupsList if g.group is not None and not isinstance(g.group, VirtualGroup) and g.add_contact_allowed] self.belonging_groups = [] if group is not None: self.belonging_groups.append(group) self.nameText.setStringValue_(name or "") self.photoImage.setImage_(self.defaultPhotoImage) self.defaultButton.setEnabled_(False) self.updateSubscriptionMenus() self.loadGroupNames() self.addButton.setEnabled_(True if self.uris else False)