Beispiel #1
0
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);
}
Beispiel #2
0
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);
    }
}