void *Services::processEvent(Event *e) { if (e->type() == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->EventAgentFound){ JabberAgentsInfo *data = (JabberAgentsInfo*)(e->param()); if ((data->Client == m_client) && data->Register){ AGENTS_MAP::iterator it = m_agents.find(data->ID); if (it == m_agents.end()){ agentInfo info; info.search = NULL; info.name = data->Name; m_agents.insert(AGENTS_MAP::value_type(data->ID, info)); m_client->get_agent_info(data->ID, "register"); } } return NULL; } if (e->type() == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->EventAgentInfo){ JabberAgentInfo *data = (JabberAgentInfo*)(e->param()); AGENTS_MAP::iterator it = m_agents.find(data->ID); if (it != m_agents.end()){ agentInfo &info = (*it).second; if (info.search == NULL){ info.search = new JabberSearch(this, m_client, data->ID, QString::fromUtf8(info.name.c_str())); unsigned id = cmbAgents->count(); wndInfo->addWidget(info.search, id + 1); cmbAgents->insertItem(QString::fromUtf8(info.name.c_str())); if (id == 0){ cmbAgents->setCurrentItem(0); selectAgent(0); textChanged(""); } } info.search->addWidget(data); } return NULL; } if (e->type() == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->EventAgentRegister){ agentRegisterInfo *info = (agentRegisterInfo*)(e->param()); if (m_reg_id != info->id) return NULL; if (!info->bOK){ QString err; if (info->error && *info->error){ err = i18n(info->error); }else{ err = i18n("Registration failed"); } BalloonMsg::message(err, btnRegister); } btnRegister->setEnabled(true); return NULL; } switch (e->type()){ case EventClientChanged: if ((Client*)(e->param()) == m_client) statusChanged(); break; } return NULL; }
/*! * Sets the squad and selects the first selectable agent. * Pre existing selection has been cleared. * \param pSquad The current squad. */ void SquadSelection::setSquad(Squad *pSquad) { clear(); pSquad_ = pSquad; for (size_t i = AgentManager::kSlot1; i < AgentManager::kMaxSlot; i++) { // try to select agent. if true means agent has been selected if (selectAgent(i, false)) { break; } } }
void *Services::processEvent(Event *e) { if (e->type() == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->EventAgentFound){ JabberAgentsInfo *data = (JabberAgentsInfo*)(e->param()); if ((data->Client == m_client) && data->Register){ AGENTS_MAP::iterator it = m_agents.find(data->ID); if (it == m_agents.end()){ agentInfo info; info.search = NULL; info.name = data->Name; m_agents.insert(AGENTS_MAP::value_type(data->ID, info)); m_client->get_agent_info(data->ID, NULL, "register"); } } return NULL; } if (e->type() == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->EventAgentInfo){ JabberAgentInfo *data = (JabberAgentInfo*)(e->param()); if (data->ID == NULL) return NULL; AGENTS_MAP::iterator it = m_agents.find(data->ID); if (it != m_agents.end()){ agentInfo &info = (*it).second; if (info.search == NULL){ info.search = new JabberSearch(this, m_client, data->ID, NULL, QString::fromUtf8(info.name.c_str()), true); unsigned id = cmbAgents->count(); wndInfo->addWidget(info.search, id + 1); cmbAgents->insertItem(QString::fromUtf8(info.name.c_str())); if (id == 0){ cmbAgents->setCurrentItem(0); selectAgent(0); textChanged(""); } } info.search->addWidget(data); } return NULL; } if (e->type() == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->EventAgentRegister){ agentRegisterInfo *info = (agentRegisterInfo*)(e->param()); if (m_reg_id != info->id) return NULL; if (info->err_code){ QString err; if (info->error && *info->error) err = i18n(info->error); if (err.isEmpty()) err = i18n("Error %1") .arg(info->err_code); BalloonMsg::message(err, btnRegister); } btnRegister->setEnabled(true); return NULL; } switch (e->type()){ case EventClientChanged: if ((Client*)(e->param()) == m_client) statusChanged(); break; case EventContactChanged:{ Contact *contact = (Contact*)(e->param()); ClientDataIterator it(contact->clientData, m_client); JabberUserData *data; while ((data = ((JabberUserData*)(++it))) != NULL){ if (!m_client->isAgent(data->ID)) continue; QListViewItem *item; for (item = lstAgents->firstChild(); item; item = item->nextSibling()) if ((item->text(COL_JID) + "/registered") == QString::fromUtf8(data->ID)) break; if (item == NULL) makeAgentItem(data, contact->id()); } break; } case EventMessageReceived:{ Message *msg = (Message*)(e->param()); if (msg->type() != MessageStatus) break; Contact *contact = getContacts()->contact(msg->contact()); if (contact == NULL) break; ClientDataIterator it(contact->clientData, m_client); JabberUserData *data; while ((data = ((JabberUserData*)(++it))) != NULL){ if (!m_client->isAgent(data->ID)) continue; QListViewItem *item; for (item = lstAgents->firstChild(); item; item = item->nextSibling()) if ((item->text(COL_JID) + "/registered") == QString::fromUtf8(data->ID)) break; if (item) setAgentStatus(data, item); } break; } case EventContactDeleted:{ Contact *contact = (Contact*)(e->param()); for (QListViewItem *item = lstAgents->firstChild(); item; ){ QListViewItem *next = item->nextSibling(); if (item->text(COL_ID) == QString::number(contact->id())) delete item; item = next; } break; } } return NULL; }