示例#1
0
def _create_contact_from_buddy_xml_node(user, node):
    # Notice: a buddy could belongs to two groups
    attr = node.getAttribute

    contact = Contact(user = user)
    contact.uri = attr("u")
    contact.sid = get_sid_from_uri(contact.uri)
    contact.user_id = attr("i")
    contact.nickname = to_unicode_obj(attr("n"))
    contact.relation_status = int(attr("r"))

    buddy_list_id = attr("l")
    if buddy_list_id:
        gids = [gid for gid in buddy_list_id.split(";") if gid.strip() and int(gid) >= DEFAULT_GID]
        if len(gids) != 1:
            logger.error("!!! User (SID: %s) has multiple GID" % contact.sid)
            print "gids:", gids
        gid = int(gids[0])
    else:
        gid = DEFAULT_GID
    contact.set_gid(gid)

    contact.portrait_crc = 0

    return contact
示例#2
0
def _parse_blacklist_node(user, contact_list_node):
    blacklist_node = contact_list_node.getElementsByTagName("blacklist")[0]

    for cat_node in blacklist_node.childNodes:
        if cat_node.nodeType == minidom.Node.TEXT_NODE:
            continue

        contact = Contact(user)
        contact.set_gid(BLACKLIST_GROUP_GID)
        attr = cat_node.getAttribute
        contact.uri = attr("u")
        contact.sid = get_sid_from_uri(contact.uri)
        contact.user_id = attr("i")
        user.group_agent.add_contact(contact)
示例#3
0
def _parse_chat_friends_node(user, contact_list_node):
    # strangers group list
    chat_friends_node = contact_list_node.getElementsByTagName("chat-friends")[0]

    for cat_node in chat_friends_node.childNodes:
        if cat_node.nodeType == minidom.Node.TEXT_NODE:
            continue

        contact = Contact(user)
        contact.set_gid(STRANGER_GROUP_GID)
        attr = cat_node.getAttribute
        contact.uri = attr("u")
        contact.sid = get_sid_from_uri(contact.uri)
        contact.user_id = attr("i")
        user.group_agent.add_contact(contact)