Exemple #1
0
EXPORT string make_packet_string(LogInfo *l)
{
    string m;
    if (l->packet_id){
        PacketType *type = getContacts()->getPacketType(l->packet_id);
        if (type == NULL)
            return m;
        Buffer *b = (Buffer*)(l->log_info);
        unsigned start = b->packetStartPos();
        time_t now;
        time(&now);
        struct tm *tm = localtime(&now);
        string name = type->name();
        if (l->add_info && *l->add_info){
            name += ".";
            name += l->add_info;
        }
        format(m, "%02u:%02u:%02u [%s] %s %u bytes\n", tm->tm_hour, tm->tm_min, tm->tm_sec,
               name.c_str(),
               (l->log_level & L_PACKET_IN) ? "Read" : "Write",
               b->size() - start);
        if (type->isText()){
            m.append(b->data(start), b->size() - start);
        }else{
            char line[81];
            char *p1 = line;
            char *p2 = line;
            unsigned n = 20;
            unsigned offs = 0;
            for (unsigned i = start; i < b->size(); i++, n++){
                char buf[32];
                if (n == 16){
                    m += line;
                    m += "\n";
                }
                if (n >= 16){
                    memset(line, ' ', 80);
                    line[80] = 0;
                    snprintf(buf, sizeof(buf), "%04X: ", offs);
                    memcpy(line, buf, strlen(buf));
                    p1 = line + strlen(buf);
                    p2 = p1 + 52;
                    n = 0;
                    offs += 0x10;
                }
                if (n == 8) p1++;
                unsigned char c = (unsigned char)*(b->data(i));
                *(p2++) = ((c >= ' ') && (c != 0x7F)) ? c : '.';
                snprintf(buf, sizeof(buf), "%02X ", c);
                memcpy(p1, buf, 3);
                p1 += 3;
            }
            if (n <= 16) m += line;
        }
    }else{
        m = (const char*)(l->log_info);
    }
    return m;
}
Exemple #2
0
void LogConfig::fill()
{
    lstLevel->clear();
    addItem(I18N_NOOP("Error"), (m_plugin->getLogLevel() & L_ERROR) != 0, L_ERROR, 0);
    addItem(I18N_NOOP("Warning"), (m_plugin->getLogLevel() & L_WARN) != 0, L_WARN, 0);
    addItem(I18N_NOOP("Debug"), (m_plugin->getLogLevel() & L_DEBUG) != 0, L_DEBUG, 0);
    PacketType *type;
    ContactList::PacketIterator it;
    while ((type = ++it) != NULL){
        addItem(type->name(), m_plugin->isLogType(type->id()), 0, type->id());
    }
}
void MonitorWindow::adjustLog()
{
    menuLog->clear();
    PacketType *packet;
    ContactList::PacketIterator it;
    while ((packet = ++it) != NULL){
        menuLog->insertItem(i18n(packet->name()), packet->id());
        menuLog->setItemChecked(packet->id(), m_plugin->isLogType(packet->id()));
    }
    menuLog->insertSeparator();
    for (const level_def *d = levels; d->name; d++){
        menuLog->insertItem(i18n(d->name), d->level);
        menuLog->setItemChecked(d->level, (m_plugin->getLogLevel() & d->level) != 0);
    }
}
Exemple #4
0
void LogConfig::fill()
{
    for (BOX_MAP::iterator it = m_boxes.begin(); it != m_boxes.end(); ++it)
        delete (*it).second;
    m_boxes.clear();
    QVBoxLayout *lay = static_cast<QVBoxLayout*>(layout());
    PacketType *packet;
    ContactList::PacketIterator it_packet;
    unsigned pos = 4;
    while ((packet = ++it_packet) != NULL){
        QCheckBox *box = new QCheckBox(i18n(packet->name()), this);
        lay->insertWidget(pos++, box);
        box->setChecked(m_plugin->isLogType(packet->id()));
        m_boxes.insert(BOX_MAP::value_type(packet->id(), box));
    }
	setMinimumSize(sizeHint());
}