示例#1
0
    NewTrackDialog::NewTrackDialog(QWidget* parent)
        : QDialog(parent)
    {
        widgets_.setupUi(this);

        connect(widgets_.widthSlider, SIGNAL(valueChanged(int)), widgets_.widthSpinBox, SLOT(setValue(int)));
        connect(widgets_.heightSlider, SIGNAL(valueChanged(int)), widgets_.heightSpinBox, SLOT(setValue(int)));

        connect(widgets_.widthSpinBox, SIGNAL(valueChanged(int)), widgets_.widthSlider, SLOT(setValue(int)));
        connect(widgets_.heightSpinBox, SIGNAL(valueChanged(int)), widgets_.heightSlider, SLOT(setValue(int)));

        connect(widgets_.widthSlider, SIGNAL(valueChanged(int)), this, SLOT(use_custom_size_preset(int)));
        connect(widgets_.heightSlider, SIGNAL(valueChanged(int)), this, SLOT(use_custom_size_preset(int)));

        connect(widgets_.widthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(use_custom_size_preset(int)));
        connect(widgets_.heightSpinBox, SIGNAL(valueChanged(int)), this, SLOT(use_custom_size_preset(int)));

        connect(widgets_.sizePreset_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(use_size_preset(int)));

        connect(widgets_.browseLocation, SIGNAL(clicked()), this, SLOT(browse_locations()));
        connect(widgets_.confirmButton, SIGNAL(accepted()), this, SLOT(confirm_track_creation()));
        connect(widgets_.confirmButton, SIGNAL(rejected()), this, SLOT(cancel_track_creation()));

        connect(widgets_.trackName, SIGNAL(textChanged(const QString&)), this, SLOT(validate_track_name(const QString&)));

        widgets_.addAssetButton->setDefaultAction(widgets_.actionAddAsset);
        widgets_.removeAssetButton->setDefaultAction(widgets_.actionRemoveAsset);

        connect(widgets_.actionAddAsset, SIGNAL(triggered()), this, SLOT(add_asset()));
        connect(widgets_.actionRemoveAsset, SIGNAL(triggered()), this, SLOT(remove_asset()));
    }
示例#2
0
文件: assets.c 项目: Ammaro/prads
short update_asset_arp(u_int8_t arp_sha[MAC_ADDR_LEN], packetinfo *pi)
{
    if (asset_lookup(pi) == SUCCESS) {
        if (pi->asset != NULL) {
            goto arp_update;
        } else {
            printf("\nBAD ERROR in update_asset_arp\n");
            return ERROR;
        }
    } else {

        add_asset(pi);
        update_asset(pi);

        if ( pi->asset == NULL ) {
            elog("update_asset(pi) failed! Asset does not exist! Cant enter MAC!!! die();\n");
            return ERROR;
        }
        if (update_asset_arp(arp_sha, pi) == SUCCESS) {
            return SUCCESS;
        } else {
            return ERROR;
        }
    }

arp_update:
    /* Check the ARP data structure for an existing entry */
    if (memcmp(pi->asset->mac_addr, arp_sha, MAC_ADDR_LEN) == 0) {
        /* UPDATE TIME STAMP */
        pi->asset->last_seen = pi->pheader->ts.tv_sec;
        return SUCCESS;
    } else {
        /* UPDATE MAC AND TIME STAMP */
        /* XXX: this handler suxx! */
        if(memcmp(pi->asset->mac_addr, "\0\0\0\0\0\0", 6)){
            printf("ACHTUNG! MAC changed! : ");
            print_mac(pi->asset->mac_addr);
            printf(" -> ");

            print_mac(arp_sha);
            printf("\n");

        }
        if(pi->asset->macentry == NULL) {
           // vendor entry did not exist.
           mac_entry *match = match_mac(config.sig_mac, arp_sha, 48);
           pi->asset->macentry = match;
        }
        memcpy(&pi->asset->mac_addr, arp_sha, MAC_ADDR_LEN);
        pi->asset->last_seen = pi->pheader->ts.tv_sec;
        log_asset_arp(pi->asset);
        return SUCCESS;
    }
}
示例#3
0
文件: assets.c 项目: Ammaro/prads
void update_asset(packetinfo *pi)
{
    if (asset_lookup(pi) == SUCCESS) {
        if (pi->asset != NULL) {
            pi->asset->vlan = pi->vlan;
            pi->asset->last_seen = pi->pheader->ts.tv_sec;
        } else {
            printf("\nBAD ERROR in update_asset\n");
        }
    } else {
        add_asset(pi);
    }
    return;
}
示例#4
0
int main (int argc, char **argv) {
    int c, j;
    int reel_count=0;
    int height = 0;
    int width  = 0;
    char buffer[80];
    opendcp_t *opendcp;
    reel_list_t reel_list[MAX_REELS];

    if ( argc <= 1 ) {
        dcp_usage();
    }

    opendcp = opendcp_create();

    /* parse options */
    while (1)
    {
        static struct option long_options[] =
        {
            {"annotation",     required_argument, 0, 'a'},
            {"base",           required_argument, 0, 'b'},
            {"digest",         no_argument,       0, 'd'},
            {"duration",       required_argument, 0, 'n'},
            {"entry",          required_argument, 0, 'e'},
            {"help",           no_argument,       0, 'h'},
            {"issuer",         required_argument, 0, 'i'},
            {"kind",           required_argument, 0, 'k'},
            {"log_level",      required_argument, 0, 'l'},
            {"rating",         required_argument, 0, 'm'},
            {"reel",           required_argument, 0, 'r'},
            {"title",          required_argument, 0, 't'},
            {"root",           required_argument, 0, '1'},
            {"ca",             required_argument, 0, '2'},
            {"signer",         required_argument, 0, '3'},
            {"privatekey",     required_argument, 0, 'p'},
            {"sign",           no_argument,       0, 's'},
            {"height",         required_argument, 0, 'y'},
            {"width",          required_argument, 0, 'x'},
            {"version",        no_argument,       0, 'v'},
            {0, 0, 0, 0}
        };

        /* getopt_long stores the option index here. */
        int option_index = 0;

        c = getopt_long (argc, argv, "a:b:e:svdhi:k:r:l:m:n:t:x:y:p:1:2:3:",
                         long_options, &option_index);

        /* Detect the end of the options. */
        if (c == -1)
            break;

        switch (c)
        {
            case 0:
                /* If this option set a flag, do nothing else now. */
                if (long_options[option_index].flag != 0)
                   break;
            break;

            case 'a':
               sprintf(opendcp->dcp.annotation,"%.128s",optarg);
            break;

            case 'b':
               sprintf(opendcp->dcp.basename,"%.80s",optarg);
            break;

            case 'd':
               opendcp->dcp.digest_flag = 1;
            break;

            case 'e':
               opendcp->entry_point = atoi(optarg);
            break;

            case 'h':
               dcp_usage();
            break;

            case 'i':
               sprintf(opendcp->dcp.issuer,"%.80s",optarg);
            break;

            case 'k':
               sprintf(opendcp->dcp.kind,"%.15s",optarg);
            break;

            case 'l':
               opendcp->log_level = atoi(optarg);
            break;

            case 'm':
               if ( !strcmp(optarg,"G")
                    || !strcmp(optarg,"PG")
                    || !strcmp(optarg,"PG-13")
                    || !strcmp(optarg,"R")
                    || !strcmp(optarg,"NC-17") ) {
                   sprintf(opendcp->dcp.rating,"%.5s",optarg);
               } else {
                   sprintf(buffer,"Invalid rating %s\n",optarg);
                   dcp_fatal(opendcp,buffer);
               }
            break;

            case 'n':
               opendcp->duration = atoi(optarg);
            break;

            case 'r':
               j = 0;
               optind--;
               while ( optind<argc && strncmp("-",argv[optind],1) != 0) {
                   sprintf(reel_list[reel_count].asset_list[j++].filename,"%s",argv[optind++]);
               }
               reel_list[reel_count++].asset_count = j--;
            break;

#ifdef XMLSEC
            case 's':
                opendcp->xml_signature.sign = 1;
            break;
#endif

            case 't':
               sprintf(opendcp->dcp.title,"%.80s",optarg);
            break;

            case 'x':
               width = atoi(optarg);
            break;

            case 'y':
               height = atoi(optarg);
            break;

            case '1':
               opendcp->xml_signature.root = optarg;
               opendcp->xml_signature.use_external = 1;
            break;

            case '2':
               opendcp->xml_signature.ca = optarg;
               opendcp->xml_signature.use_external = 1;
            break;

            case '3':
               opendcp->xml_signature.signer = optarg;
               opendcp->xml_signature.use_external = 1;
            break;

            case 'p':
               opendcp->xml_signature.private_key = optarg;
               opendcp->xml_signature.use_external = 1;
            break;

            case 'v':
               version();
            break;

            default:
               dcp_usage();
        }
    }

    /* set log level */
    dcp_set_log_level(opendcp->log_level);

    if (opendcp->log_level > 0) {
        printf("\nOpenDCP XML %s %s\n",OPENDCP_VERSION,OPENDCP_COPYRIGHT);
    }

    if (reel_count < 1) {
        dcp_fatal(opendcp,"No reels supplied");
    }

    /* check cert files */
    if (opendcp->xml_signature.sign && opendcp->xml_signature.use_external == 1) {
        FILE *tp;
        if (opendcp->xml_signature.root) {
            tp = fopen(opendcp->xml_signature.root,"rb");
            if (tp) {
                fclose(tp);
            } else {
                dcp_fatal(opendcp,"Could not read root certificate");
            }
        } else {
            dcp_fatal(opendcp,"XML digital signature certifcates enabled, but root certificate file not specified");
        }
        if (opendcp->xml_signature.ca) {
            tp = fopen(opendcp->xml_signature.ca,"rb");
            if (tp) {
                fclose(tp);
            } else {
                dcp_fatal(opendcp,"Could not read ca certificate");
            }
        } else {
            dcp_fatal(opendcp,"XML digital signature certifcates enabled, but ca certificate file not specified");
        }
        if (opendcp->xml_signature.signer) {
            tp = fopen(opendcp->xml_signature.signer,"rb");
            if (tp) {
                fclose(tp);
            } else {
                dcp_fatal(opendcp,"Could not read signer certificate");
            }
        } else {
            dcp_fatal(opendcp,"XML digital signature certifcates enabled, but signer certificate file not specified");
        }
        if (opendcp->xml_signature.private_key) {
            tp = fopen(opendcp->xml_signature.private_key,"rb");
            if (tp) {
                fclose(tp);
            } else {
                dcp_fatal(opendcp,"Could not read private key file");
            }
        } else {
            dcp_fatal(opendcp,"XML digital signature certifcates enabled, but private key file not specified");
        }
    }

    /* set aspect ratio override */
    if (width || height) {
        if (!height) {
            dcp_fatal(opendcp,"You must specify height, if you specify width");
        }

        if (!width) {
            dcp_fatal(opendcp,"You must specify widht, if you specify height");
        }

        sprintf(opendcp->dcp.aspect_ratio,"%d %d",width,height);
    }

    /* add pkl to the DCP (only one PKL currently support) */
    pkl_t pkl;
    create_pkl(opendcp->dcp, &pkl);
    add_pkl_to_dcp(&opendcp->dcp, pkl);

    /* add cpl to the DCP/PKL (only one CPL currently support) */
    cpl_t cpl;
    create_cpl(opendcp->dcp, &cpl);
    add_cpl_to_pkl(&opendcp->dcp.pkl[0], cpl);

    /* set the callbacks (optional) for the digest generator */
    if (opendcp->log_level>0 && opendcp->log_level<3) {
        opendcp->dcp.sha1_update.callback = sha1_update_done_cb;
    }

    /* Add and validate reels */
    for (c = 0; c<reel_count; c++) {
        int a;
        reel_t reel;
        create_reel(opendcp->dcp, &reel);

        for (a = 0; a < reel_list[c].asset_count; a++) {
            val   = 0;
            asset_t asset;
            add_asset(opendcp, &asset, reel_list[c].asset_list[a].filename);
            sprintf(progress_string, "%-.25s %.25s", asset.filename, "Digest Calculation");
            total = atoi(asset.size) / read_size;
            if (opendcp->log_level>0 && opendcp->log_level<3) {
                printf("\n");
                progress_bar();
            }
            calculate_digest(opendcp, asset.filename, asset.digest);
            add_asset_to_reel(opendcp, &reel, asset);
        }

        if (validate_reel(opendcp, &reel, c) == OPENDCP_NO_ERROR) {
            add_reel_to_cpl(&opendcp->dcp.pkl[0].cpl[0], reel);
        } else {
            sprintf(buffer,"Could not validate reel %d\n",c+1);
            dcp_fatal(opendcp,buffer);
        }
    }

    /* set ASSETMAP/VOLINDEX path */
    if (opendcp->ns == XML_NS_SMPTE) {
        sprintf(opendcp->dcp.assetmap.filename,"%s","ASSETMAP.xml");
        sprintf(opendcp->dcp.volindex.filename,"%s","VOLINDEX.xml");
    } else {
        sprintf(opendcp->dcp.assetmap.filename,"%s","ASSETMAP");
        sprintf(opendcp->dcp.volindex.filename,"%s","VOLINDEX");
    }

    /* Write CPL File */
    if (opendcp->log_level>0 && opendcp->log_level<3) {
        printf("\n");
        sprintf(progress_string, "%-.50s", opendcp->dcp.pkl[0].cpl[0].filename);
        progress_bar();
    }
    if (write_cpl(opendcp, &opendcp->dcp.pkl[0].cpl[0]) != OPENDCP_NO_ERROR)
        dcp_fatal(opendcp,"Writing composition playlist failed");

    /* Write PKL File */
    if (opendcp->log_level>0 && opendcp->log_level<3) {
        printf("\n");
        sprintf(progress_string, "%-.50s", opendcp->dcp.pkl[0].filename);
        progress_bar();
    }
    if (write_pkl(opendcp, &opendcp->dcp.pkl[0]) != OPENDCP_NO_ERROR)
        dcp_fatal(opendcp,"Writing packing list failed");

    if (opendcp->log_level>0 && opendcp->log_level<3) {
        printf("\n");
        sprintf(progress_string, "%-.50s", opendcp->dcp.assetmap.filename);
        progress_bar();
    }
    if (write_volumeindex(opendcp) != OPENDCP_NO_ERROR)
        dcp_fatal(opendcp,"Writing volume index failed");

    if (opendcp->log_level>0 && opendcp->log_level<3) {
        printf("\n");
        sprintf(progress_string, "%-.50s", opendcp->dcp.volindex.filename);
        progress_bar();
    }
    if (write_assetmap(opendcp) != OPENDCP_NO_ERROR)
        dcp_fatal(opendcp,"Writing asset map failed");

    dcp_log(LOG_INFO,"DCP Complete");

    if (opendcp->log_level > 0) {
        printf("\nDCP Creation Done\n");
    }

    opendcp_delete(opendcp);

    exit(0);
}