void JabberInfo::apply(Client *client, void *_data) { if (client != m_client) return; JabberUserData *data = m_client->toJabberUserData((SIM::IMContact*)_data); // FIXME unsafe type conversion data->setFirstName(edtFirstName->text()); data->setNick(edtNick->text()); data->setBirthday(edtDate->getDate().toString(Qt::ISODate)); data->setUrl(edtUrl->text()); }
void JabberWorkInfo::apply(Client *client, void *_data) { if (client != m_client) return; JabberUserData *data = m_client->toJabberUserData((SIM::IMContact*)_data); // FIXME unsafe type conversion data->setOrgName(edtCompany->text()); data->setOrgUnit(edtDepartment->text()); data->setTitle(edtTitle->text()); data->setRole(edtRole->text()); }
bool JabberWorkInfo::processEvent(Event *e) { if (e->type() == eEventContact){ EventContact *ec = static_cast<EventContact*>(e); if(ec->action() != EventContact::eChanged) return false; Contact *contact = ec->contact(); if (contact->have(m_data)) fill(m_data); } else if ((e->type() == eEventClientChanged) && (m_data == 0)){ EventClientChanged *ecc = static_cast<EventClientChanged*>(e); if (ecc->client() == m_client) fill(m_data); } else if (m_data && (e->type() == eEventVCard)){ EventVCard *evc = static_cast<EventVCard*>(e); JabberUserData *data = evc->data(); if (m_data->getId() == data->getId() && m_data->getNode() == data->getNode()) fill(data); } return false; }
void JabberInfo::fill() { JabberUserData *data = m_data; if (data == NULL) data = &m_client->data.owner; edtID->setText(data->getId()); edtFirstName->setText(data->getFirstName()); edtNick->setText(data->getNick()); edtDate->setDate(QDate::fromString(data->getBirthday(), Qt::ISODate)); edtUrl->setText(data->getUrl()); urlChanged(edtUrl->text()); cmbResource->clear(); if (data->getNResources()){ for (unsigned i = 1; i <= data->getNResources(); i++) cmbResource->addItem(data->getResource(i)); cmbResource->setEnabled(data->getNResources() > 1); }else{ if (!data->getResource().isEmpty()) cmbResource->addItem(data->getResource()); cmbResource->setEnabled(false); } resourceActivated(0); if (m_data == NULL) password->setEnabled(m_client->getState() == Client::Connected); }
void JabberInfo::resourceActivated(int i) { JabberUserData *data = m_data; if (data == NULL) data = &m_client->data.owner; unsigned n = i + 1; unsigned status = STATUS_OFFLINE; unsigned statusTime; unsigned onlineTime; QString autoReply; QString clientName, clientVersion, clientOS; if ((n == 0) || (n > data->getNResources())) { status = m_data ? m_data->getStatus() : m_client->getStatus(); statusTime = data->getStatusTime(); onlineTime = data->getOnlineTime(); } else { status = data->getResourceStatus(n).toUInt(); statusTime = data->getResourceStatusTime(n).toUInt(); onlineTime = data->getResourceOnlineTime(n).toUInt(); autoReply = data->getResourceReply(n); clientName = data->getResourceClientName(n); clientVersion = data->getResourceClientVersion(n); clientOS = data->getResourceClientOS(n); } int current = 0; const char *text = NULL; for (const CommandDef *cmd = m_client->protocol()->statusList(); cmd->id; cmd++){ if (cmd->flags & COMMAND_CHECK_STATE) continue; if (status == cmd->id){ current = cmbStatus->count(); text = cmd->text.toLocal8Bit().data(); } cmbStatus->addItem(Icon(cmd->icon), i18n(cmd->text)); } cmbStatus->setCurrentIndex(current); disableWidget(cmbStatus); if (status == STATUS_OFFLINE){ lblOnline->setText(i18n("Last online") + ':'); edtOnline->setText(formatDateTime(statusTime)); lblOnline->show(); edtOnline->show(); lblNA->hide(); edtNA->hide(); }else{ if (onlineTime){ edtOnline->setText(formatDateTime(onlineTime)); lblOnline->show(); edtOnline->show(); }else{ lblOnline->hide(); edtOnline->hide(); } if ((status == STATUS_ONLINE) || (text == NULL)){ lblNA->hide(); edtNA->hide(); }else{ lblNA->setText(i18n(text)); edtNA->setText(formatDateTime(statusTime)); lblNA->show(); edtNA->show(); } } if (autoReply.isEmpty()){ edtAutoReply->hide(); }else{ edtAutoReply->show(); edtAutoReply->setPlainText(autoReply); } if (clientName.isEmpty()){ edtClient->setEnabled(false); }else{ edtClient->setEnabled(true); QString clientString = clientName + ' ' + clientVersion; if (!clientOS.isEmpty()) clientString += " / " + clientOS; edtClient->setText(clientString); } }