当前位置: 首页>>代码示例>>C++>>正文


C++ Contact::getGroup方法代码示例

本文整理汇总了C++中Contact::getGroup方法的典型用法代码示例。如果您正苦于以下问题:C++ Contact::getGroup方法的具体用法?C++ Contact::getGroup怎么用?C++ Contact::getGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Contact的用法示例。


在下文中一共展示了Contact::getGroup方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: it

void *YahooClient::processEvent(Event *e)
{
    if (e->type() == EventContactChanged) {
        Contact *contact = (Contact*)(e->param());
        string grpName;
        string name;
        name = contact->getName().utf8();
        Group *grp = NULL;
        if (contact->getGroup())
            grp = getContacts()->group(contact->getGroup());
        if (grp)
            grpName = grp->getName().utf8();
        ClientDataIterator it(contact->clientData, this);
        YahooUserData *data;
        while ((data = (YahooUserData*)(++it)) != NULL) {
            moveBuddy(data, grpName.c_str());
        }
    }
    if (e->type() == EventContactDeleted) {
        Contact *contact = (Contact*)(e->param());
        ClientDataIterator it(contact->clientData, this);
        YahooUserData *data;
        while ((data = (YahooUserData*)(++it)) != NULL) {
            removeBuddy(data);
        }
    }
    if (e->type() == EventTemplateExpanded) {
        TemplateExpand *t = (TemplateExpand*)(e->param());
        sendStatus(YAHOO_STATUS_CUSTOM, t->tmpl.local8Bit());
    }
    return NULL;
}
开发者ID:,项目名称:,代码行数:32,代码来源:

示例2: messageSound

QString SoundPlugin::messageSound(unsigned type, unsigned long contact_id)
{
    SIM::PropertyHubPtr data;
    Contact *c = getContacts()->contact(contact_id);
    if(!contact_id)
        data = getContacts()->userdata();
    else if(c)
    {
        data = c->getUserData()->root();
        if(!data->value("sound/override").toBool())
        {
            Group* g = getContacts()->group(c->getGroup(), false);
            if(g->userdata()->value("sound/override").toBool())
                data = g->userdata();
            else
                data = getContacts()->userdata();
        }
    }
    QString sound;
    if(data)
        sound = data->value("sound/Receive" + QString::number(type)).toString();
    if(sound == "(nosound)")
        return QString();
    return sound;
}
开发者ID:BackupTheBerlios,项目名称:sim-im,代码行数:25,代码来源:sound.cpp

示例3: loadList

void YahooClient::loadList(const char *str)
{
    Contact *contact;
    ContactList::ContactIterator it;
    while ((contact = ++it) != NULL) {
        YahooUserData *data;
        ClientDataIterator itd(contact->clientData, this);
        while ((data = (YahooUserData*)(++itd)) != NULL) {
            data->bChecked.bValue = (contact->getGroup() == 0);
        }
    }
    if (str) {
        string s = str;
        while (!s.empty()) {
            string line = getToken(s, '\n');
            string grp = getToken(line, ':');
            if (line.empty()) {
                line = grp;
                grp = "";
            }
            while (!line.empty()) {
                string id = getToken(line, ',');
                Contact *contact;
                YahooUserData *data = findContact(id.c_str(), grp.c_str(), contact, false);
                data->bChecked.bValue = true;
            }
        }
    }
    it.reset();
    list<Contact*> forRemove;
    while ((contact = ++it) != NULL) {
        YahooUserData *data;
        ClientDataIterator itd(contact->clientData, this);
        list<YahooUserData*> dataForRemove;
        bool bChanged = false;
        while ((data = (YahooUserData*)(++itd)) != NULL) {
            if (!data->bChecked.bValue) {
                dataForRemove.push_back(data);
                bChanged = true;
            }
        }
        if (!bChanged)
            continue;
        for (list<YahooUserData*>::iterator it = dataForRemove.begin(); it != dataForRemove.end(); ++it)
            contact->clientData.freeData(*it);
        if (contact->clientData.size()) {
            Event e(EventContactChanged, contact);
            e.process();
        } else {
            forRemove.push_back(contact);
        }
    }
    for (list<Contact*>::iterator itr = forRemove.begin(); itr != forRemove.end(); ++itr)
        delete *itr;
}
开发者ID:,项目名称:,代码行数:55,代码来源:

示例4: isGroupSelected

bool UserList::isGroupSelected(unsigned id)
{
    bool bRes = false;
    ContactList::ContactIterator it;
    Contact *contact;
    while ((contact = ++it) != NULL){
        if (contact->getGroup() != id)
            continue;
        if (!isSelected(contact->id()))
            return false;
        bRes = true;
    }
    return bRes;
}
开发者ID:,项目名称:,代码行数:14,代码来源:

示例5: impl_outputRenderRow

void ColGroup::impl_outputRenderRow(ext::ostream& tos, const Contact& contact, DisplayType display)
{
	if (display == asContact)
	{
		ext::string groupName = contact.getGroup();

		// replace subgroup separator with something better (really better?)
		utils::replaceAllInPlace(groupName, _T("\\"), _T(" > "));

		tos << _T("<td>") << utils::htmlEscape(groupName) << _T("</td>") << ext::endl;
	}
	else
	{
		tos << _T("<td>&nbsp;</td>");
	}
}
开发者ID:Seldom,项目名称:miranda-ng,代码行数:16,代码来源:column_group.cpp

示例6: startSearch

void JabberAdd::startSearch()
{
    if (m_result == NULL)
        return;
    JabberClient *client = findClient(cmbServices->currentText().latin1());
    if (client == NULL)
        return;
    if (tabAdd->currentPageIndex() == 0){
        QString jid = edtID->text();
        if (client->add_contact(jid.utf8())){
            unsigned grp_id = 0;
            ContactList::GroupIterator it;
            Group *grp;
            unsigned nGrp = cmbGroup->currentItem();
            while ((grp = ++it) != NULL){
                if (grp->id() == 0)
                    continue;
                if (nGrp-- == 0){
                    grp_id = grp->id();
                    break;
                }
            }
            Contact *contact;
            JabberUserData *data = client->findContact(jid.utf8(), NULL, false, contact);
            if (data && (contact->getGroup() != grp_id)){
                contact->setGroup(grp_id);
                Event e(EventContactChanged, contact);
                e.process();
            }
        }else{
            m_result->setText(i18n("%1 already in contact list") .arg(jid));
        }
    }else if (tabAdd->currentPage()->inherits("JabberSearch")){
        JabberSearch *search = static_cast<JabberSearch*>(tabAdd->currentPage());
        QString condition = search->condition();
        string search_id = client->search(search->id(), NULL, condition.utf8());
        m_result->setSearch(client, search_id.c_str());
    }
}
开发者ID:,项目名称:,代码行数:39,代码来源:

示例7: drawUpdates


//.........这里部分代码省略.........
                    contactItem = new ContactItem(itemOffline, contact, status, style, icons.c_str(), unread);
                }
            }else{
                if (itemOffline){
                    contactItem = findContactItem(contact->id(), itemOffline);
                    if (contactItem){
                        deleteItem(contactItem);
                        if (itemOffline->firstChild() == NULL){
                            deleteItem(itemOffline);
                            itemOffline = NULL;
                        }
                    }
                }
                if (itemOnline == NULL){
                    itemOnline = new DivItem(this, DIV_ONLINE);
                    setOpen(itemOnline, true);
                }
                contactItem = findContactItem(contact->id(), itemOnline);
                if (contactItem){
                    if (contactItem->update(contact, status, style, icons.c_str(), unread))
                        addSortItem(itemOnline);
                    repaintItem(contactItem);
                }else{
                    contactItem = new ContactItem(itemOnline, contact, status, style, icons.c_str(), unread);
                }
            }
            break;
        case 1:
            contactItem = findContactItem(contact->id());
            grpItem = NULL;
            if (contactItem){
                grpItem = static_cast<GroupItem*>(contactItem->parent());
                if (((status == STATUS_OFFLINE) && (unread == 0) && !bShow && m_bShowOnline) ||
                        (contact->getGroup() != grpItem->id())){
                    grpItem->m_nContacts--;
                    if (contactItem->m_bOnline)
                        grpItem->m_nContactsOnline--;
                    addGroupForUpdate(grpItem->id());
                    deleteItem(contactItem);
                    contactItem = NULL;
                    grpItem = NULL;
                }
            }
            if ((status != STATUS_OFFLINE) || unread || bShow || !m_bShowOnline){
                if (grpItem == NULL)
                    grpItem = findGroupItem(contact->getGroup());
                if (grpItem){
                    if (contactItem){
                        if (contactItem->update(contact, status, style, icons.c_str(), unread))
                            addSortItem(grpItem);
                        repaintItem(contactItem);
                        if (!m_bShowOnline &&
                                (contactItem->m_bOnline != (status != STATUS_OFFLINE))){
                            if (status == STATUS_OFFLINE){
                                grpItem->m_nContactsOnline--;
                                contactItem->m_bOnline = false;
                            }else{
                                grpItem->m_nContactsOnline++;
                                contactItem->m_bOnline = true;
                            }
                            addGroupForUpdate(grpItem->id());
                        }
                    }else{
                        contactItem = new ContactItem(grpItem, contact, status, style, icons.c_str(), unread);
                        grpItem->m_nContacts++;
                        if (!m_bShowOnline && (status != STATUS_OFFLINE)){
开发者ID:,项目名称:,代码行数:67,代码来源:

示例8: element_end

void RostersRequest::element_end(const char *el)
{
    if (strcmp(el, "group") == 0){
        m_data = NULL;
        return;
    }
    if (strcmp(el, "item") == 0){
        bool bChanged = false;
        JabberListRequest *lr = m_client->findRequest(m_jid.c_str(), false);
        Contact *contact;
        JabberUserData *data = m_client->findContact(m_jid.c_str(), NULL, m_name.c_str(), false, contact);
        if (data == NULL){
            if (lr && lr->bDelete){
                m_client->findRequest(m_jid.c_str(), true);
            }else{
                bChanged = true;
                data = m_client->findContact(m_jid.c_str(), NULL, m_name.c_str(), true, contact);
                if (m_bSubscription){
                    contact->setTemporary(CONTACT_TEMP);
                    Event eContact(EventContactChanged, contact);
                    eContact.process();
                    m_client->auth_request(m_jid.c_str(), MessageAuthRequest, m_subscription.c_str(), true);
                    data = m_client->findContact(m_jid.c_str(), NULL, m_name.c_str(), false, contact);
                }
            }
        }
        if (data == NULL)
            return;
        if (data->Subscribe != m_subscribe){
            bChanged = true;
            data->Subscribe = m_subscribe;
        }
        data->bChecked = true;
        if (lr == NULL){
            unsigned grp = 0;
            if (!m_grp.empty()){
                Group *group = NULL;
                ContactList::GroupIterator it;
                while ((group = ++it) != NULL){
                    if (m_grp == (const char*)(group->getName().utf8())){
                        grp = group->id();
                        break;
                    }
                }
                if (group == NULL){
                    group = getContacts()->group(0, true);
                    group->setName(QString::fromUtf8(m_grp.c_str()));
                    grp = group->id();
                    Event e(EventGroupChanged, group);
                    e.process();
                }
            }
            if (contact->getGroup() != grp){
                if (grp == 0){
                    void *d = NULL;
                    ClientDataIterator it_d(contact->clientData);
                    while ((d = ++it_d) != NULL){
                        if (d != data)
                            break;
                    }
                    if (d){
                        grp = contact->getGroup();
                        Group *group = getContacts()->group(grp);
                        if (group)
                            m_client->listRequest(data, contact->getName().utf8(), group->getName().utf8(), false);
                    }
                }
                contact->setGroup(grp);
                bChanged = true;
            }
        }
        if (bChanged){
            Event e(EventContactChanged, contact);
            e.process();
        }
    }
}
开发者ID:,项目名称:,代码行数:77,代码来源:

示例9: e


//.........这里部分代码省略.........
                        QWidgetList  *list = QApplication::topLevelWidgets();
                        QWidgetListIt it(*list);
                        QWidget * w;
                        while ((w = it.current()) != NULL){
                            if (w->inherits("Container")){
                                Container *c =  static_cast<Container*>(w);
                                wnd = c->wnd((unsigned)(cmd->param));
                                if (wnd)
                                    break;
                            }
                            ++it;
                        }
                        delete list;
                        if (wnd){
                            delete wnd;
                            return e->param();
                        }
                    }
                    if (cmd->id > CmdSendMessage){
                        Command c;
                        c->id	   = cmd->id - CmdSendMessage;
                        c->menu_id = MenuMessage;
                        c->param   = (void*)(contact->id());
                        Event eCmd(EventCommandExec, c);
                        if (eCmd.process())
                            return e->param();
                    }
                }
            }
            if (cmd->menu_id == MenuContactGroup){
                Contact *contact = getContacts()->contact((unsigned)(cmd->param));
                if (contact){
                    Group *grp = getContacts()->group(cmd->id - CmdContactGroup);
                    if (grp && (grp->id() != contact->getGroup())){
                        contact->setGroup(grp->id());
                        Event eChanged(EventContactChanged, contact);
                        eChanged.process();
                        return e->param();
                    }
                }
            }
            if (cmd->menu_id == MenuContainer){
                Contact *contact = getContacts()->contact((unsigned)(cmd->param));
                if (contact){
                    Container *from = NULL;
                    Container *to = NULL;
                    QWidgetList  *list = QApplication::topLevelWidgets();
                    QWidgetListIt it(*list);
                    QWidget * w;
                    unsigned max_id = 0;
                    while ((w = it.current()) != NULL){
                        if (w->inherits("Container")){
                            Container *c = static_cast<Container*>(w);
                            if (c->getId() == cmd->id)
                                to = c;
                            if (c->wnd(contact->id()))
                                from = c;
                            if (!(c->getId() & CONTAINER_GRP)){
                                if (max_id < c->getId())
                                    max_id = c->getId();
                            }
                        }
                        ++it;
                    }
                    if (from && to && (from == to))
                        return e->param();
开发者ID:,项目名称:,代码行数:67,代码来源:

示例10: answer

void SynPacket::answer(const char *_cmd, vector<string> &args)
{
    string cmd = _cmd;
    if (cmd == "SYN"){
        m_ver = atol(args[0].c_str());
        if (m_ver != m_client->getListVer()){
            ContactList::GroupIterator itg;
            Group *grp;
            while ((grp = ++itg) != NULL){
                MSNUserData *data;
                ClientDataIterator it(grp->clientData, m_client);
                while ((data = (MSNUserData*)(++it)) != NULL){
                    data->sFlags = data->Flags;
                    data->Flags  = 0;
                }
            }
            ContactList::ContactIterator itc;
            Contact *contact;
            while ((contact = ++itc) != NULL){
                MSNUserData *data;
                ClientDataIterator it(contact->clientData, m_client);
                while ((data = (MSNUserData*)(++it)) != NULL){
                    data->sFlags = data->Flags;
                    data->Flags = 0;
                }
            }
        }
    }
    if (cmd == "LSG"){
        if (args.size() < 5){
            log(L_WARN, "Bad LSG size");
            return;
        }
        unsigned id = atol(args[3].c_str());
        if (id == 0)
            return;
        Group *grp;
        string grp_name;
        grp_name = m_client->unquote(QString::fromUtf8(args[4].c_str())).utf8();
        MSNListRequest *lr = m_client->findRequest(id, LR_GROUPxREMOVED);
        if (lr)
            return;
        MSNUserData *data = m_client->findGroup(id, NULL, grp);
        if (data){
            lr = m_client->findRequest(grp->id(), LR_GROUPxCHANGED);
            if (lr){
                data->sFlags |= MSN_CHECKED;
                return;
            }
        }
        data = m_client->findGroup(id, grp_name.c_str(), grp);
        data->sFlags |= MSN_CHECKED;
    }
    if (cmd == "LST"){
        if (args.size() < 6){
            log(L_WARN, "Bad size for LST");
            return;
        }
        string mail;
        mail = m_client->unquote(QString::fromUtf8(args[4].c_str())).utf8();
        string name;
        name = m_client->unquote(QString::fromUtf8(args[5].c_str())).utf8();
        Contact *contact;
        MSNListRequest *lr = m_client->findRequest(mail.c_str(), LR_CONTACTxREMOVED);
        if (lr)
            return;
        bool bNew = false;
        MSNUserData *data = m_client->findContact(mail.c_str(), contact);
        if (data == NULL){
            data = m_client->findContact(mail.c_str(), name.c_str(), contact);
            bNew = true;
        }else{
            set_str(&data->EMail, mail.c_str());
            set_str(&data->ScreenName, name.c_str());
        }
        data->sFlags |= MSN_CHECKED;
        lr = m_client->findRequest(mail.c_str(), LR_CONTACTxCHANGED);
        if (args[0] == "FL"){
            unsigned grp = atol(args[6].c_str());
            data->Group = grp;
            data->Flags |= MSN_FORWARD;
            Group *group = NULL;
            m_client->findGroup(grp, NULL, group);
            if ((lr == NULL) && group && (group->id() != contact->getGroup())){
                unsigned grp = group->id();
                if (grp == 0){
                    void *d;
                    ClientDataIterator it_d(contact->clientData);
                    while ((d = ++it_d) != NULL){
                        if (d != data)
                            break;
                    }
                    if (d){
                        grp = contact->getGroup();
                        m_client->findRequest(data->EMail, LR_CONTACTxCHANGED, true);
                        MSNListRequest lr;
                        lr.Type = LR_CONTACTxCHANGED;
                        lr.Name = data->EMail;
                        m_client->m_requests.push_back(lr);
                        m_client->processRequests();
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例11: snac_lists


//.........这里部分代码省略.........
                ListRequest *lr = findGroupListRequest(data->IcqID);
                if (lr)
                    continue;
                forRemove.push_back(grp);
            }
            for (list<Group*>::iterator it = forRemove.begin(); it != forRemove.end(); ++it){
                delete *it;
            }

            Contact *contact;
            ContactList::ContactIterator it_c;
            while ((contact = ++it_c) != NULL){
                ICQUserData *data;
                ClientDataIterator it_d(contact->clientData);
                bool bOther = (contact->clientData.size() == 0);
				bool bMy = false;
                unsigned long newGroup = 0;
                while ((data = (ICQUserData*)(++it_d)) != NULL){
                    if (it_d.client() != this){
                        bOther = true;
                        continue;
                    }
                    unsigned grpId = data->GrpId;
                    ContactList::GroupIterator it_g;
                    while ((grp = ++it_g) != NULL){
                        ICQUserData *data = (ICQUserData*)(grp->clientData.getData(this));
                        if (data && (data->IcqID == grpId))
                            break;
                    }
                    if (grp)
                        newGroup = grp->id();
					bMy = true;
                }
                if (newGroup != contact->getGroup()){
                    if ((newGroup == 0) && bOther){
						if (bMy)
							addContactRequest(contact);
                    }else{
                        contact->setGroup(newGroup);
                    }
                    Event e(EventContactChanged, contact);
                    e.process();
                }
            }
        }
        getContacts()->save();
    case ICQ_SNACxLISTS_ROSTERxOK:	// FALLTHROUGH
        {
            log(L_DEBUG, "Rosters OK");
            snac(ICQ_SNACxFAM_LISTS, ICQ_SNACxLISTS_UNKNOWN);
            sendPacket();
            QTimer::singleShot(PING_TIMEOUT * 1000, this, SLOT(ping()));
            setPreviousPassword(NULL);
            sendClientReady();
            if (m_bAIM){
                Group *grp;
                ContactList::GroupIterator it;
                while ((grp = ++it) != NULL){
                    if (grp->id())
                        break;
                }
                if (grp == NULL){
                    grp = getContacts()->group(0, true);
                    grp->setName("General");
                    Event e(EventGroupChanged, grp);
                    e.process();
开发者ID:,项目名称:,代码行数:67,代码来源:

示例12: processEvent

bool FilterPlugin::processEvent(Event *e)
{
    switch (e->type()) {
    case eEventContact: {
        EventContact *ec = static_cast<EventContact*>(e);
        if(ec->action() != EventContact::eChanged)
            break;
        Contact *contact = ec->contact();
        if (contact->getGroup()){
            Command cmd;
            cmd->id		= CmdIgnore;
            cmd->flags	= BTN_HIDE;
            cmd->param  = (void*)(contact->id());
            EventCommandShow(cmd).process();
        }
        break;
    }
    case eEventPluginLoadConfig:
    {
        setPropertyHub( ProfileManager::instance()->getPropertyHub("filter") );
        break;
    }
    case eEventMessageReceived: {
        EventMessage *em = static_cast<EventMessage*>(e);
        Message *msg = em->msg();
        if (!msg || (msg->type() == MessageStatus))
            return false;
        Contact *contact = getContacts()->contact(msg->contact());
        PropertyHubPtr data = contact->getUserData("filter");
        // check if we accept only from users on the list
        if (((contact == NULL) || contact->getFlags() & CONTACT_TEMPORARY) &&
                        ((value("FromList").toBool() &&
			  msg->type() != MessageAuthRequest &&
			  msg->type() != MessageAuthGranted &&
			  msg->type() != MessageAuthRefused) ||
                (value("AuthFromList").toBool() && msg->type() <= MessageContacts))) {
            delete msg;
            delete contact;
            return msg;
        }
        if (!contact)
            return false;
        // check if the user is a ignored user
        if (contact->getIgnore()){
            delete msg;
            return true;
        }

        // get filter-data
		if (data && !data->value("SpamList").toString().isEmpty() && (!contact || (contact->getFlags() & CONTACT_TEMPORARY) )) {
            if (checkSpam(msg->getPlainText(), data->value("SpamList").toString())){
                delete msg;
                return true;
            }
		}
        break;
    }
    case eEventCheckCommandState: {
        EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e);
        CommandDef *cmd = ecs->cmd();
        if (cmd->id == CmdIgnore){
            cmd->flags &= ~BTN_HIDE;
            Contact *contact = getContacts()->contact((unsigned long)(cmd->param));
            if (contact && contact->getGroup())
                cmd->flags |= BTN_HIDE;
            return true;
        }
        if (cmd->id == CmdIgnoreText){
            cmd->flags &= ~COMMAND_CHECKED;
            if (cmd->menu_id == MenuMsgView){
                MsgViewBase *edit = (MsgViewBase*)(cmd->param);
                if (edit->textCursor().hasSelection())
                    return true;
            } else
            /*if (cmd->menu_id == MenuTextEdit){
                TextEdit *edit = ((MsgEdit*)(cmd->param))->m_edit;
                if (edit->textCursor().hasSelection())
                    return true;
            }*/							//Fixme Block (crashing on rightclick in msgedit from container)
            return false;
        }
        if (cmd->menu_id == MenuContactGroup){
            if (cmd->id == CmdIgnoreList){
                Contact *contact = getContacts()->contact((unsigned long)(cmd->param));
                if (contact == NULL)
                    return false;
                cmd->flags &= COMMAND_CHECKED;
                if (contact->getIgnore())
                    cmd->flags |= COMMAND_CHECKED;
                return true;
            }
        }
        break;
    }
    case eEventCommandExec: {
        EventCommandExec *ece = static_cast<EventCommandExec*>(e);
        CommandDef *cmd = ece->cmd();
        if (cmd->id == CmdIgnore){
            Contact *contact = getContacts()->contact((unsigned long)(cmd->param));
            if (contact){
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:sim-im,代码行数:101,代码来源:filter.cpp

示例13: fill

void UserListBase::fill()
{
    m_pressedItem = NULL;
    clear();
    GroupItem *grpItem;
    ContactItem *contactItem;
    UserViewItemBase *divItem;
    UserViewItemBase *divItemOnline = NULL;
    UserViewItemBase *divItemOffline = NULL;
    ContactList *list = getContacts();
    ContactList::GroupIterator grp_it;
    ContactList::ContactIterator contact_it;
    Group *grp;
    Contact *contact;
    switch (m_groupMode){
    case 0:
        divItemOnline  = NULL;
        divItemOffline = NULL;
        while ((contact = ++contact_it) != NULL){
            if (contact->getIgnore() || contact->getTemporary())
                continue;
            unsigned style;
            string icons;
            unsigned status = getUserStatus(contact, style, icons);
            unsigned unread = getUnread(contact->id());
			bool bShow = false;
			ListUserData *data = (ListUserData*)contact->getUserData(CorePlugin::m_plugin->list_data_id);
			if (data && data->ShowAllways)
				bShow = true;
            if ((unread == 0) && !bShow && (status == STATUS_OFFLINE) && m_bShowOnline)
                continue;
            divItem = (status == STATUS_OFFLINE) ? divItemOffline : divItemOnline;
            if (divItem == NULL){
                if (status == STATUS_OFFLINE){
                    divItemOffline = new DivItem(this, DIV_OFFLINE);
                    setOpen(divItemOffline, true);
                    divItem = divItemOffline;
                }else{
                    divItemOnline = new DivItem(this, DIV_ONLINE);
                    setOpen(divItemOnline, true);
                    divItem = divItemOnline;
                }
            }
            new ContactItem(divItem, contact, status, style, icons.c_str(), unread);
        }
        break;
    case 1:
        while ((grp = ++grp_it) != NULL){
            if (grp->id() == 0)
                continue;
            grpItem = new GroupItem(this, grp, true);
        }
        grp = list->group(0);
        if (grp){
            grpItem = new GroupItem(this, grp, true);
        }
        while ((contact = ++contact_it) != NULL){
            if (contact->getIgnore() || contact->getTemporary())
                continue;
            unsigned style;
            string icons;
            unsigned status = getUserStatus(contact, style, icons);
            unsigned unread = getUnread(contact->id());
			bool bShow = false;
			ListUserData *data = (ListUserData*)contact->getUserData(CorePlugin::m_plugin->list_data_id);
			if (data && data->ShowAllways)
				bShow = true;
            if ((status == STATUS_OFFLINE) && !bShow && (unread == 0) && m_bShowOnline)
                continue;
            grpItem = findGroupItem(contact->getGroup());
            if (grpItem == NULL)
                continue;
            contactItem = new ContactItem(grpItem, contact, status, style, icons.c_str(), unread);
            grpItem->m_nContacts++;
            if ((status != STATUS_OFFLINE) && !m_bShowOnline){
                grpItem->m_nContactsOnline++;
                contactItem->m_bOnline = true;
            }
        }
        break;
    case 2:
        divItemOnline = new DivItem(this, DIV_ONLINE);
        setOpen(divItemOnline, true);
        while ((grp = ++grp_it) != NULL){
            if (grp->id() == 0)
                continue;
            grpItem = new GroupItem(divItemOnline, grp, false);
        }
        grp = list->group(0);
        if (grp){
            grpItem = new GroupItem(divItemOnline, grp, false);
        }
        if (!m_bShowOnline){
            divItemOffline = new DivItem(this, DIV_OFFLINE);
            setOpen(divItemOffline, true);
            grp_it.reset();
            while ((grp = ++grp_it) != NULL){
                if (grp->id() == 0)
                    continue;
                grpItem = new GroupItem(divItemOffline, grp, true);
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例14: send

bool JabberClient::send(Message *msg, void *_data)
{
    if (getState() != Connected)
        return false;
    JabberUserData *data = (JabberUserData*)_data;
    switch (msg->type()){
    case MessageAuthRefused:{
            string grp;
            Group *group = NULL;
            Contact *contact = getContacts()->contact(msg->contact());
            if (contact && contact->getGroup())
                group = getContacts()->group(contact->getGroup());
            if (group)
                grp = group->getName().utf8();
            listRequest(data, data->Name, grp.c_str(), false);
            if (data->Subscribe & SUBSCRIBE_FROM){
                m_socket->writeBuffer.packetStart();
                m_socket->writeBuffer
                << "<presence to=\""
                << data->ID;
                m_socket->writeBuffer
                << "\" type=\"unsubscribed\"><status>"
                << (const char*)(quoteString(msg->getPlainText(), false).utf8())
                << "</status></presence>";
                sendPacket();
                if ((msg->getFlags() & MESSAGE_NOHISTORY) == 0){
                    msg->setClient(dataName(data).c_str());
                    Event e(EventSent, msg);
                    e.process();
                }
                Event e(EventMessageSent, msg);
                e.process();
                delete msg;
                return true;
            }
        }
    case MessageGeneric:{
            Contact *contact = getContacts()->contact(msg->contact());
            if ((contact == NULL) || (data == NULL))
                return false;
            m_socket->writeBuffer.packetStart();
            m_socket->writeBuffer
            << "<message to=\""
            << data->ID;
            m_socket->writeBuffer
            << "\"><body>"
            << (const char*)msg->getPlainText().utf8()
            << "</body></message>";
            sendPacket();
            if ((msg->getFlags() & MESSAGE_NOHISTORY) == 0){
                msg->setClient(dataName(data).c_str());
                Event e(EventSent, msg);
                e.process();
            }
            Event e(EventMessageSent, msg);
            e.process();
            delete msg;
            return true;
        }
    case MessageAuthRequest:{
            m_socket->writeBuffer.packetStart();
            m_socket->writeBuffer
            << "<presence to=\""
            << data->ID;
            m_socket->writeBuffer
            << "\" type=\"subscribe\"><status>"
            << (const char*)(quoteString(msg->getPlainText(), false).utf8())
            << "</status></presence>";
            sendPacket();
            if ((msg->getFlags() & MESSAGE_NOHISTORY) == 0){
                msg->setClient(dataName(data).c_str());
                Event e(EventSent, msg);
                e.process();
            }
            Event e(EventMessageSent, msg);
            e.process();
            delete msg;
            return true;
        }
    case MessageAuthGranted:{
            m_socket->writeBuffer.packetStart();
            m_socket->writeBuffer
            << "<presence to=\""
            << data->ID;
            m_socket->writeBuffer
            << "\" type=\"subscribed\"></presence>";
            sendPacket();
            if ((msg->getFlags() & MESSAGE_NOHISTORY) == 0){
                msg->setClient(dataName(data).c_str());
                Event e(EventSent, msg);
                e.process();
            }
            Event e(EventMessageSent, msg);
            e.process();
            delete msg;
            return true;
        }
    case MessageJabberOnline:
        if (isAgent(data->ID) && (data->Status == STATUS_OFFLINE)){
            m_socket->writeBuffer.packetStart();
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的Contact::getGroup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。