Пример #1
0
void PrintDialog::on_buttonBox_clicked(QAbstractButton *button)
{
    QPrintDialog *print_dlg;
    QPageSetupDialog *ps_dlg;

    switch (pd_ui_->buttonBox->buttonRole(button)) {
    case QDialogButtonBox::ActionRole:
        int result;
        print_dlg = new QPrintDialog(&printer_, this);
        result = print_dlg->exec();
        if (result == QDialog::Accepted) {
            printPackets(&printer_, false);
            done(result);
        }
        break;
    case QDialogButtonBox::ResetRole:
        ps_dlg = new QPageSetupDialog(&printer_, this);
        ps_dlg->exec();
        preview_->updatePreview();
        break;
    default: // Help, Cancel
        break;
    }
}
Пример #2
0
void PrintDialog::paintPreview(QPrinter *printer)
{
    printPackets(printer, true);
}
int OfferRequestService::processTCP(void* receivedPacket) {
    if (DEBUG) std::cout << __FILE__ << "(" << __LINE__ << ")"  << "[" << __FUNCTION__<< "] OFFER SERVICE" << std::endl;
    if (DEBUG) std::cout << __FILE__ << "(" << __LINE__ << ")"  << "[" << __FUNCTION__<< "] ------------ " << std::endl;

    pthread_mutex_t storageMutex = getContextPacketsMutex();

    int rc;	/* contain mutex lock/unlock results */

    /* lock the mutex, to assure exclusive access to 'a' and 'b'. */
    rc = pthread_mutex_lock(&storageMutex);

    /* an error has occurred */
    if (rc) {
        perror("pthread_mutex_lock");
        pthread_exit(NULL);
    }

    std::vector<ContextPacket*>* store_vector;
    store_vector = getContextPackets(((ContextPacket*) receivedPacket)->getRootCIC()->context);

    if (DEBUG) std::cout << __FILE__ << "(" << __LINE__ << ")"  << "[" << __FUNCTION__<< "] :"
                             " push_back at index " << (uint) ((ContextPacket*) receivedPacket)->getRootCIC()->context << std::endl;

    int update = 0;
    if(store_vector->size() > 0) {


        for (std::vector<ContextPacket*>::iterator iter = store_vector->begin(); iter != store_vector->end(); ++iter) {

            if(equalContextPacketContents((*iter), (ContextPacket*) receivedPacket)) {

                if (DEBUG) std::cout << __FILE__ << "(" << __LINE__ << ")"  << "[" << __FUNCTION__<< "] : Erase CIP with equal CIC-Bricks' content from storage." << getUuidString(*(*iter)->getUuid()) << std::endl;

                store_vector->erase(iter);

                update = 1;

                break;
            }
        }
    }

    store_vector->push_back((ContextPacket*) receivedPacket);

    if(update) {
        std::cout << getUuidString(*((ContextPacket*) receivedPacket)->getUuid()) << " : " << "TCP Offer Service updates CIP : " << ctime(((ContextPacket*) receivedPacket)->getTime()) << std::ends;
    }
    else {
        std::cout << getUuidString(*((ContextPacket*) receivedPacket)->getUuid()) << " : " << "TCP Offer Service stores CIP : " << ctime(((ContextPacket*) receivedPacket)->getTime()) << std::ends;
    }

    /* unlock mutex */
    rc = pthread_mutex_unlock(&storageMutex);

    if (rc) {
        perror("pthread_mutex_unlock");
        pthread_exit(NULL);
    }

    if (PRINT_PACKETS_DEBUG) printPackets();

    if (PRINT_PACKET_DEBUG) ((ContextPacket*) receivedPacket)->printPacket();

    return 0;
}