Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 27468) +++ trunk/scconfig/Rev.h (revision 27469) @@ -1 +1 @@ -static const int myrev = 27454; +static const int myrev = 27468; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 27468) +++ trunk/scconfig/Rev.tab (revision 27469) @@ -1,3 +1,4 @@ +27468 configure order pcbway now depends on libxml2 27454 configure order plugin config file 27403 configure tEDAx: new source file for etest save 27401 configure remove cairo from optional dependencies Index: trunk/scconfig/hooks.c =================================================================== --- trunk/scconfig/hooks.c (revision 27468) +++ trunk/scconfig/hooks.c (revision 27469) @@ -426,7 +426,7 @@ want_gtk = want_gtk2; /* plus |gtkN */ want_gd = plug_is_enabled("export_png") || plug_is_enabled("import_pxm_gd") || plug_is_enabled("export_gcode"); want_stroke = plug_is_enabled("stroke"); - want_xml2 = plug_is_enabled("io_eagle"); + want_xml2 = plug_is_enabled("io_eagle") || plug_is_enabled("order_pcbway"); want_freetype2 = plug_is_enabled("import_ttf"); want_fuse = plug_is_enabled("export_vfs_fuse"); @@ -598,8 +598,9 @@ require("libs/sul/libxml2/presents", 0, 0); if (!istrue(get("libs/sul/libxml2/presents"))) { report("libxml2 is not available, disabling io_eagle...\n"); - report_repeat("WARNING: Since there's no libxml2 found, disabling the Eagle IO plugin...\n"); + report_repeat("WARNING: Since there's no libxml2 found, disabling the Eagle IO and pcbway order plugins...\n"); hook_custom_arg("disable-io_eagle", NULL); + hook_custom_arg("disable-order_pcbway", NULL); } put("/local/pcb/want_libxml2", strue); } Index: trunk/src_plugins/order/order_dlg.c =================================================================== --- trunk/src_plugins/order/order_dlg.c (revision 27468) +++ trunk/src_plugins/order/order_dlg.c (revision 27469) @@ -30,11 +30,13 @@ vtp0_set(&order_ctx.names, n, NULL); PCB_DAD_BEGIN_VBOX(order_ctx.dlg); + PCB_DAD_COMPFLAG(order_ctx.dlg, PCB_HATF_EXPFILL); PCB_DAD_BEGIN_TABBED(order_ctx.dlg, order_ctx.names.array); PCB_DAD_COMPFLAG(order_ctx.dlg, PCB_HATF_EXPFILL | PCB_HATF_LEFT_TAB); for(n = 0; n < pcb_order_imps.used; n++) { imp = pcb_order_imps.array[n]; PCB_DAD_BEGIN_VBOX(order_ctx.dlg); + PCB_DAD_COMPFLAG(order_ctx.dlg, PCB_HATF_EXPFILL); imp->populate_dad(pcb_order_imps.array[n], &order_ctx); PCB_DAD_END(order_ctx.dlg); } Index: trunk/src_plugins/order_pcbway/Plug.tmpasm =================================================================== --- trunk/src_plugins/order_pcbway/Plug.tmpasm (revision 27468) +++ trunk/src_plugins/order_pcbway/Plug.tmpasm (revision 27469) @@ -7,6 +7,15 @@ @] switch /local/pcb/order_pcbway/controls + case {disable} end; + default + put /local/pcb/mod/CFLAGS /target/libs/sul/libxml2/cflags + put /local/pcb/mod/LDFLAGS /target/libs/sul/libxml2/ldflags + end +end + + +switch /local/pcb/order_pcbway/controls case {buildin} include /local/pcb/tmpasm/buildin; end; case {plugin} include /local/pcb/tmpasm/plugin; end; case {disable} include /local/pcb/tmpasm/disable; end; Index: trunk/src_plugins/order_pcbway/pcbway.c =================================================================== --- trunk/src_plugins/order_pcbway/pcbway.c (revision 27468) +++ trunk/src_plugins/order_pcbway/pcbway.c (revision 27469) @@ -27,6 +27,8 @@ #include "config.h" #include +#include +#include #include "board.h" #include "pcb-printf.h" @@ -105,8 +107,58 @@ return res; } + + +static xmlDoc *pcbway_xml_load(const char *fn) +{ + xmlDoc *doc; + FILE *f; + char *efn = NULL; + + f = pcb_fopen_fn(NULL, fn, "r", &efn); + if (f == NULL) { + pcb_message(PCB_MSG_ERROR, "pcbway: can't open '%s' (%s) for read\n", fn, efn); + free(efn); + return -1; + } + fclose(f); + + doc = xmlReadFile(efn, NULL, 0); + if (doc == NULL) { + pcb_message(PCB_MSG_ERROR, "xml parsing error on file %s (%s)\n", fn, efn); + free(efn); + return -1; + } + free(efn); + + return doc; +} + +static int pcbway_populate_dad_(pcb_hidlib_t *hidlib, pcb_order_imp_t *imp, order_ctx_t *octx, xmlNode *root) +{ + xmlNode *n; + for(root = root->children; (root != NULL) && (xmlStrcmp(root->name, (xmlChar *)"PcbQuotationRequest") != 0); root = root->next) ; + + if (root == NULL) + return -1; + + PCB_DAD_BEGIN_VBOX(octx->dlg); + PCB_DAD_COMPFLAG(octx->dlg, PCB_HATF_SCROLL | PCB_HATF_EXPFILL); + for(n = root->children; n != NULL; n = n->next) { + if (n->type == XML_TEXT_NODE) + continue; + PCB_DAD_LABEL(octx->dlg, (char *)n->name); + } + PCB_DAD_END(octx->dlg); + return 0; +} + static void pcbway_populate_dad(pcb_order_imp_t *imp, order_ctx_t *octx) { + char *cachedir, *path; + xmlDoc *doc; + xmlNode *root; + if ((CFG.api_key == NULL) || (*CFG.api_key == '\0')) { PCB_DAD_LABEL(octx->dlg, "Error: no api_key available."); return -1; @@ -115,7 +167,22 @@ PCB_DAD_LABEL(octx->dlg, "Error: failed to update the cache."); return -1; } - PCB_DAD_LABEL(octx->dlg, "pcbway!"); + + cachedir = pcb_build_fn(&PCB->hidlib, conf_order.plugins.order.cache); + path = pcb_strdup_printf("%s%cPCBWay_Api.xml", cachedir, PCB_DIR_SEPARATOR_C); + doc = pcbway_xml_load(path); + + root = xmlDocGetRootElement(doc); + if (xmlStrcmp(root->name, (xmlChar *)"PCBWayAPI") == 0) { + if (pcbway_populate_dad_(&PCB->hidlib, imp, octx, root) != 0) + PCB_DAD_LABEL(octx->dlg, "xml error: invalid API xml\n"); + } + else + PCB_DAD_LABEL(octx->dlg, "xml error: root is not \n"); + + xmlFreeDoc(doc); + free(cachedir); + free(path); } static pcb_order_imp_t pcbway = {