bool PrintFile(const WCHAR *fileName, WCHAR *printerName, bool displayErrors, const WCHAR *settings) { ScopedMem<WCHAR> fileName2(path::Normalize(fileName)); BaseEngine *engine = EngineManager::CreateEngine(fileName2); bool ok = PrintFile(engine, printerName, displayErrors, settings); delete engine; return ok; }
int main(int argc, char **argv){ if (argc>=8) { Npata_arg=atoi(argv[1]); beta=atof(argv[2]); dh=atof(argv[3]); x_Offset=atof(argv[4]); y_Offset=atof(argv[5]); z_Offset=atof(argv[6]); phi=atof(argv[7])*pi/180.0; Tripode=atof(argv[8]); } else { ROS_ERROR("Nodo 2::[%d] Indique argumentos!\n",Npata_arg); sleep(5000); return 0; } /*Inicio nodo de ROS*/ std::string nodeName("Nodo2_Parametrizacion_pata"); std::string Id(boost::lexical_cast<std::string>(Npata_arg)); nodeName+=Id; ros::init(argc,argv,nodeName.c_str()); ros::NodeHandle node; //ROS_INFO("Nodo2_Parametrizacion just started\n"); //-- Topicos susbcritos y publicados chatter_pub = node.advertise<camina7::AngulosMotor>("DatosDeMotores", 100); ros::Subscriber subInfo = node.subscribe("/vrep/info",1,infoCallback); //-- Recibe topico especifico ros::Subscriber sub = node.subscribe("datosTrayectoria", 100, datosCallback); //-- Clientes y Servicios client_Cinversa = node.serviceClient<camina7::CinversaParametros>("Cinversa"); client_TransHomogenea = node.serviceClient<camina7::TransHomogeneaParametros>("TransHomogenea"); std::string fileName("../fuerte_workspace/sandbox/TesisMaureen/ROS/camina7/datos/SalidaX"); std::string texto(".txt"); fileName+=Id; fileName+=texto; fp1 = fopen(fileName.c_str(),"w+"); std::string fileName2("../fuerte_workspace/sandbox/TesisMaureen/ROS/camina7/datos/SalidaQ"); fileName2+=Id; fileName2+=texto; fp2 = fopen(fileName2.c_str(),"w+"); while (ros::ok() && simulationRunning) { ros::spinOnce(); } fclose(fp1); fclose(fp2); //ROS_INFO("Adios2!"); ros::shutdown(); return 0; }
void TAGS2DCT::LoeTekstifailist(void) { CFSFileName fileName(FSTSTR("taglist.txt")); CPFSFile in; if(in.Open(fileName, FSTSTR("rb"))==false) throw VEAD(ERR_X_TYKK, ERR_OPN, __FILE__, __LINE__," ", "Ei suuda avada faili taglist.txt"); TMPLPTRARRAYBIN<PCFSAString,CFSAString>::Start(100,10); CFSAString rida; PCFSAString tagStr; // Loeme märgendite loendi mällu while(in.ReadLine(&rida)==true) { tagStr=rida.Mid(4); tagStr.Trim(); if(TMPLPTRARRAYBIN<PCFSAString,CFSAString>::AddClone(tagStr)==NULL) throw VEAD(ERR_HMM_MOOTOR, ERR_NOMEM, __FILE__, __LINE__," "); } in.Close(); printf("Märgendite järjestamine..."); // Garanteerime järjestatuse TMPLPTRARRAYBIN<PCFSAString,CFSAString>::Sort(); // Kontrollime veel üle, et ikka tõesti järjestatud for(int i=1; i<idxLast; i++) { if(*(operator[](i-1)) >= *(operator[](i))) throw VEAD(ERR_X_TYKK, ERR_ROTTEN, __FILE__, __LINE__," ", "Jama märgendite järjekorraga andmefailis taglist.txt"); } printf("OK\n"); gramm1.Start(idxLast); CFSFileName fileName2(FSTSTR("margcnt.txt")); if(in.Open(fileName2, FSTSTR("rb"))==false) throw VEAD(ERR_X_TYKK, ERR_OPN, __FILE__, __LINE__," ", "Ei suuda avada faili margcnt.txt"); for(int i=0; i<idxLast; i++) { if(in.ReadLine(&rida)==false) throw VEAD(ERR_HMM_MOOTOR, ERR_RD, __FILE__, __LINE__," "); int tyhikuPos=rida.Find(' '); if(tyhikuPos<=0) throw VEAD(ERR_HMM_MOOTOR, ERR_RD, __FILE__, __LINE__," "); CFSAString tag(rida.Left(tyhikuPos)); if(tag!=*(operator[](i))) throw VEAD(ERR_HMM_MOOTOR, ERR_RD, __FILE__, __LINE__," "); int nKorda; if(sscanf(((const char*)rida)+tyhikuPos, "%d", &nKorda)!=1) throw VEAD(ERR_HMM_MOOTOR, ERR_RD, __FILE__, __LINE__," "); gramm1.Obj(i)=nKorda; } }
int main() { g_type_init(); Samoyed::Scheduler scheduler(2); char *pwd = g_get_current_dir(); std::string fileName1(pwd); fileName1 += G_DIR_SEPARATOR_S "text-file-saver-test.GBK"; char *uri1 = g_filename_to_uri(fileName1.c_str(), NULL, NULL); if (!uri1) { printf("File name to URI conversion error.\n"); return -1; } boost::shared_ptr<char> textUtf8(g_strdup(TEXT_UTF8), g_free); boost::shared_ptr<Samoyed::TextFileSaver> saver1( new Samoyed::TextFileSaver(scheduler, 1, uri1, textUtf8, -1, "GBK")); saver1->addFinishedCallback(onDone); saver1->addCanceledCallback(onDone); g_free(uri1); std::string fileName2(pwd); fileName2 += G_DIR_SEPARATOR_S "text-file-saver-test.UTF-8"; char *uri2 = g_filename_to_uri(fileName2.c_str(), NULL, NULL); if (!uri2) { printf("File name to URI conversion error.\n"); return -1; } boost::shared_ptr<Samoyed::TextFileSaver> saver2( new Samoyed::TextFileSaver(scheduler, 1, uri2, textUtf8, -1, "UTF-8")); saver2->addFinishedCallback(onDone); saver2->addCanceledCallback(onDone); g_free(uri2); saver1->submit(saver1); saver2->submit(saver2); scheduler.wait(); g_free(pwd); return 0; }
void CMemcardManager::CopyDeleteClick(wxCommandEvent& event) { int index_A = m_MemcardList[SLOT_A]->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); int index_B = m_MemcardList[SLOT_B]->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); int slot = SLOT_B; int slot2 = SLOT_A; std::string fileName2(""); if (index_A != wxNOT_FOUND && page[SLOT_A]) index_A += itemsPerPage * page[SLOT_A]; if (index_B != wxNOT_FOUND && page[SLOT_B]) index_B += itemsPerPage * page[SLOT_B]; int index = index_B; switch (event.GetId()) { case ID_COPYFROM_B: slot = SLOT_A; slot2 = SLOT_B; case ID_COPYFROM_A: index = slot2 ? index_B : index_A; index = memoryCard[slot2]->GetFileIndex(index); if ((index != wxNOT_FOUND)) { CopyDeleteSwitch(memoryCard[slot]->CopyFrom(*memoryCard[slot2], index), slot); } break; case ID_FIXCHECKSUM_A: slot = SLOT_A; case ID_FIXCHECKSUM_B: if (memoryCard[slot]->FixChecksums() && memoryCard[slot]->Save()) { SuccessAlertT("The checksum was successfully fixed"); } else { PanicAlertT(E_SAVEFAILED); } break; case ID_CONVERTTOGCI: fileName2 = "convert"; case ID_SAVEIMPORT_A: slot = SLOT_A; case ID_SAVEIMPORT_B: { wxString fileName = wxFileSelector( _("Select a save file to import"), (strcmp(DefaultIOPath.c_str(), "/Users/GC") == 0) ? StrToWxStr("") : StrToWxStr(DefaultIOPath), wxEmptyString, wxEmptyString, _("GameCube Savegame files(*.gci;*.gcs;*.sav)") + wxString("|*.gci;*.gcs;*.sav|") + _("Native GCI files(*.gci)") + wxString("|*.gci|") + _("MadCatz Gameshark files(*.gcs)") + wxString("|*.gcs|") + _("Datel MaxDrive/Pro files(*.sav)") + wxString("|*.sav"), wxFD_OPEN | wxFD_FILE_MUST_EXIST, this); if (!fileName.empty() && !fileName2.empty()) { wxString temp2 = wxFileSelector(_("Save GCI as..."), wxEmptyString, wxEmptyString, ".gci", _("GCI File(*.gci)") + wxString("|*.gci"), wxFD_OVERWRITE_PROMPT|wxFD_SAVE, this); if (temp2.empty()) break; fileName2 = WxStrToStr(temp2); } if (fileName.length() > 0) { CopyDeleteSwitch(memoryCard[slot]->ImportGci(WxStrToStr(fileName), fileName2), slot); } } break; case ID_SAVEEXPORT_A: slot=SLOT_A; index = index_A; case ID_SAVEEXPORT_B: index = memoryCard[slot]->GetFileIndex(index); if (index != wxNOT_FOUND) { std::string gciFilename; if (!memoryCard[slot]->GCI_FileName(index, gciFilename)) { PanicAlertT("Invalid index"); return; } wxString fileName = wxFileSelector( _("Export save as..."), StrToWxStr(DefaultIOPath), StrToWxStr(gciFilename), ".gci", _("Native GCI files(*.gci)") + wxString("|*.gci|") + _("MadCatz Gameshark files(*.gcs)") + wxString("|*.gcs|") + _("Datel MaxDrive/Pro files(*.sav)") + wxString("|*.sav"), wxFD_OVERWRITE_PROMPT|wxFD_SAVE, this); if (fileName.length() > 0) { if (!CopyDeleteSwitch(memoryCard[slot]->ExportGci(index, WxStrToStr(fileName), ""), -1)) { File::Delete(WxStrToStr(fileName)); } } } break; case ID_EXPORTALL_A: slot=SLOT_A; case ID_EXPORTALL_B: { std::string path1, path2, mpath; mpath = WxStrToStr(m_MemcardPath[slot]->GetPath()); SplitPath(mpath, &path1, &path2, nullptr); path1 += path2; File::CreateDir(path1); if (PanicYesNoT("Warning: This will overwrite any existing saves that are in the folder:\n" "%s\nand have the same name as a file on your memcard\nContinue?", path1.c_str())) for (int i = 0; i < DIRLEN; i++) { CopyDeleteSwitch(memoryCard[slot]->ExportGci(i, "", path1), -1); } break; } case ID_DELETE_A: slot = SLOT_A; index = index_A; case ID_DELETE_B: index = memoryCard[slot]->GetFileIndex(index); if (index != wxNOT_FOUND) { CopyDeleteSwitch(memoryCard[slot]->RemoveFile(index), slot); } break; } }
void CMemcardManager::CopyDeleteClick(wxCommandEvent& event) { int index_A = m_MemcardList[SLOT_A]->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); int index_B = m_MemcardList[SLOT_B]->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); int slot = SLOT_B; int slot2 = SLOT_A; int index = index_B; std::string fileName2(""); if (index_A != wxNOT_FOUND && page[SLOT_A]) index_A += itemsPerPage * page[SLOT_A]; if (index_B != wxNOT_FOUND && page[SLOT_B]) index_B += itemsPerPage * page[SLOT_B]; switch (event.GetId()) { case ID_COPYFROM_B: slot = SLOT_A; slot2 = SLOT_B; case ID_COPYFROM_A: index = slot2 ? index_B : index_A; if ((index != wxNOT_FOUND)) { CopyDeleteSwitch(memoryCard[slot]->CopyFrom(*memoryCard[slot2], index), slot); } break; case ID_FIXCHECKSUM_A: slot = SLOT_A; case ID_FIXCHECKSUM_B: if (memoryCard[slot]->FixChecksums() && memoryCard[slot]->Save()) { SuccessAlertT("The checksum was successfully fixed"); } else PanicAlert(E_SAVEFAILED); break; case ID_CONVERTTOGCI: fileName2 = "convert"; case ID_SAVEIMPORT_A: slot = SLOT_A; case ID_SAVEIMPORT_B: { wxString fileName = wxFileSelector( _("Select a save file to import"), (strcmp(DefaultIOPath.c_str(), "/Users/GC") == 0) ? wxString::FromAscii("") : wxString::From8BitData(DefaultIOPath.c_str()), wxEmptyString, wxEmptyString, _("Native GCI files(*.gci)") + wxString(wxT("|*.gci|")) + _("MadCatz Gameshark files(*.gcs)") + wxString(wxT("|*.gcs|")) + _("Datel MaxDrive/Pro files(*.sav)") + wxString(wxT("|*.sav")), wxFD_OPEN | wxFD_FILE_MUST_EXIST); if (!fileName.empty() && !fileName2.empty()) { wxString temp2 = wxFileSelector(_("Save GCI as..."), wxEmptyString, wxEmptyString, wxT(".gci"), _("GCI File(*.gci)") + wxString(_T("|*.gci")), wxFD_OVERWRITE_PROMPT|wxFD_SAVE); if (temp2.empty()) break; fileName2 = temp2.mb_str(); } if (fileName.length() > 0) { CopyDeleteSwitch(memoryCard[slot]->ImportGci(fileName.mb_str(), fileName2), slot); } } break; case ID_SAVEEXPORT_A: slot=SLOT_A; index = index_A; case ID_SAVEEXPORT_B: if (index != wxNOT_FOUND) { char tempC[10 + DENTRY_STRLEN], tempC2[DENTRY_STRLEN]; memoryCard[slot]->DEntry_GameCode(index,tempC); memoryCard[slot]->DEntry_FileName(index,tempC2); sprintf(tempC, "%s_%s.gci", tempC, tempC2); wxString fileName = wxFileSelector( _("Export save as..."), wxString::From8BitData(DefaultIOPath.c_str()), wxString::From8BitData(tempC), wxT(".gci"), _("Native GCI files(*.gci)") + wxString(wxT("|*.gci|")) + _("MadCatz Gameshark files(*.gcs)") + wxString(wxT("|*.gcs|")) + _("Datel MaxDrive/Pro files(*.sav)") + wxString(wxT("|*.sav")), wxFD_OVERWRITE_PROMPT|wxFD_SAVE); if (fileName.length() > 0) { if (!CopyDeleteSwitch(memoryCard[slot]->ExportGci(index, fileName.mb_str(), NULL), -1)) { File::Delete(std::string(fileName.mb_str())); } } } break; case ID_EXPORTALL_A: slot=SLOT_A; case ID_EXPORTALL_B: { std::string path1, path2, mpath; mpath = m_MemcardPath[slot]->GetPath().mb_str(); SplitPath(mpath, &path1, &path2, NULL); path1 += path2; File::CreateDir(path1); if(PanicYesNoT("Warning: This will overwrite any existing saves that are in the folder:\n" "%s\nand have the same name as a file on your memcard\nContinue?", path1.c_str())) for (int i = 0; i < DIRLEN; i++) { CopyDeleteSwitch(memoryCard[slot]->ExportGci(i, ".", &path1), -1); } break; } case ID_DELETE_A: slot = SLOT_A; index = index_A; case ID_DELETE_B: if (index != wxNOT_FOUND) { CopyDeleteSwitch(memoryCard[slot]->RemoveFile(index), slot); } break; } }
bool PrintFile(const WCHAR *fileName, const WCHAR *printerName, bool displayErrors, const WCHAR *settings) { if (!HasPermission(Perm_PrinterAccess)) return false; ScopedMem<WCHAR> fileName2(path::Normalize(fileName)); BaseEngine *engine = EngineManager::CreateEngine(!gUseEbookUI, fileName2); if (!engine || !engine->AllowsPrinting()) { if (displayErrors) MessageBox(NULL, _TR("Cannot print this file"), _TR("Printing problem."), MB_ICONEXCLAMATION | MB_OK | (IsUIRightToLeft() ? MB_RTLREADING : 0)); return false; } HANDLE printer; bool ok = OpenPrinter((WCHAR *)printerName, &printer, NULL); if (!ok) { if (displayErrors) MessageBox(NULL, _TR("Printer with given name doesn't exist"), _TR("Printing problem."), MB_ICONEXCLAMATION | MB_OK | (IsUIRightToLeft() ? MB_RTLREADING : 0)); return false; } // get printer driver information DWORD needed = 0; GetPrinter(printer, 2, NULL, 0, &needed); ScopedMem<PRINTER_INFO_2> infoData((PRINTER_INFO_2 *)AllocArray<BYTE>(needed)); if (infoData) ok = GetPrinter(printer, 2, (LPBYTE)infoData.Get(), needed, &needed); if (!ok || !infoData || needed <= sizeof(PRINTER_INFO_2)) goto Exit; LONG structSize = DocumentProperties(NULL, printer, /* Handle to our printer. */ (WCHAR *)printerName, /* Name of the printer. */ NULL, /* Asking for size, so */ NULL, /* these are not used. */ 0); /* Zero returns buffer size. */ if (structSize < sizeof(DEVMODE)) { // If failure, inform the user, cleanup and return failure. if (displayErrors) MessageBox(NULL, _TR("Could not obtain Printer properties"), _TR("Printing problem."), MB_ICONEXCLAMATION | MB_OK | (IsUIRightToLeft() ? MB_RTLREADING : 0)); goto Exit; } LPDEVMODE devMode = (LPDEVMODE)malloc(structSize); if (!devMode) goto Exit; // Get the default DevMode for the printer and modify it for your needs. LONG returnCode = DocumentProperties(NULL, printer, (WCHAR *)printerName, devMode, /* The address of the buffer to fill. */ NULL, /* Not using the input buffer. */ DM_OUT_BUFFER); /* Have the output buffer filled. */ if (IDOK != returnCode) { // If failure, inform the user, cleanup and return failure. if (displayErrors) MessageBox(NULL, _TR("Could not obtain Printer properties"), _TR("Printing problem."), MB_ICONEXCLAMATION | MB_OK | (IsUIRightToLeft() ? MB_RTLREADING : 0)); goto Exit; } ClosePrinter(printer); printer = NULL; { Print_Advanced_Data advanced; Vec<PRINTPAGERANGE> ranges; ApplyPrintSettings(settings, engine->PageCount(), ranges, advanced); PrintData pd(engine, infoData, devMode, ranges, advanced); ok = PrintToDevice(pd); if (!ok && displayErrors) MessageBox(NULL, _TR("Couldn't initialize printer"), _TR("Printing problem."), MB_ICONEXCLAMATION | MB_OK | (IsUIRightToLeft() ? MB_RTLREADING : 0)); } Exit: free(devMode); if (printer) ClosePrinter(printer); delete engine; return ok; }
void CIRCDDBGatewayThread::run() { // Truncate the old Links.log file wxString fullName = LINKS_BASE_NAME; if (!m_name.IsEmpty()) { fullName.Append(wxT("_")); fullName.Append(m_name); } wxFileName fileName1(m_logDir, fullName, wxT("log")); wxLogMessage(wxT("Truncating %s"), fileName1.GetFullPath().c_str()); wxFFile file; bool ret = file.Open(fileName1.GetFullPath(), wxT("wt")); if (ret) file.Close(); // Truncate the old StarNet.log file fullName = STARNET_BASE_NAME; if (!m_name.IsEmpty()) { fullName.Append(wxT("_")); fullName.Append(m_name); } wxFileName fileName2(m_logDir, fullName, wxT("log")); wxLogMessage(wxT("Truncating %s"), fileName2.GetFullPath().c_str()); ret = file.Open(fileName2.GetFullPath(), wxT("wt")); if (ret) file.Close(); wxString dextraAddress = m_dextraEnabled ? m_gatewayAddress : LOOPBACK_ADDRESS; m_dextraPool = new CDExtraProtocolHandlerPool(MAX_OUTGOING + 1U, DEXTRA_PORT, dextraAddress); ret = m_dextraPool->open(); if (!ret) { wxLogError(wxT("Could not open the DExtra protocol pool")); delete m_dextraPool; m_dextraPool = NULL; } else { // Allocate the incoming port CDExtraProtocolHandler* handler = m_dextraPool->getHandler(DEXTRA_PORT); CDExtraHandler::setDExtraProtocolIncoming(handler); CDExtraHandler::setDExtraProtocolHandlerPool(m_dextraPool); } wxString dplusAddress = m_dplusEnabled ? m_gatewayAddress : LOOPBACK_ADDRESS; m_dplusPool = new CDPlusProtocolHandlerPool(MAX_OUTGOING + 1U, DPLUS_PORT, dplusAddress); ret = m_dplusPool->open(); if (!ret) { wxLogError(wxT("Could not open the D-Plus protocol pool")); delete m_dplusPool; m_dplusPool = NULL; } else { // Allocate the incoming port CDPlusProtocolHandler* handler = m_dplusPool->getHandler(DPLUS_PORT); CDPlusHandler::setDPlusProtocolIncoming(handler); CDPlusHandler::setDPlusProtocolHandlerPool(m_dplusPool); } wxString dcsAddress = m_dcsEnabled ? m_gatewayAddress : LOOPBACK_ADDRESS; m_dcsPool = new CDCSProtocolHandlerPool(MAX_OUTGOING + 1U, DCS_PORT, dcsAddress); ret = m_dcsPool->open(); if (!ret) { wxLogError(wxT("Could not open the DCS protocol pool")); delete m_dcsPool; m_dcsPool = NULL; } else { // Allocate the incoming port CDCSProtocolHandler* handler = m_dcsPool->getHandler(DCS_PORT); CDCSHandler::setDCSProtocolIncoming(handler); CDCSHandler::setDCSProtocolHandlerPool(m_dcsPool); } m_g2Handler = new CG2ProtocolHandler(G2_DV_PORT, m_gatewayAddress); ret = m_g2Handler->open(); if (!ret) { wxLogError(wxT("Could not open the G2 protocol handler")); delete m_g2Handler; m_g2Handler = NULL; } // Wait here until we have the essentials to run while (!m_killed && (m_dextraPool == NULL || m_dplusPool == NULL || m_dcsPool == NULL || m_g2Handler == NULL || (m_icomRepeaterHandler == NULL && m_hbRepeaterHandler == NULL && m_dummyRepeaterHandler == NULL) || m_gatewayCallsign.IsEmpty())) ::wxMilliSleep(500UL); // 1/2 sec if (m_killed) return; m_stopped = false; wxLogMessage(wxT("Starting the ircDDB Gateway thread")); CHeaderLogger* headerLogger = NULL; if (m_logEnabled) { m_statusTimer1.start(); headerLogger = new CHeaderLogger(m_logDir, m_name); bool ret = headerLogger->open(); if (!ret) { delete headerLogger; headerLogger = NULL; } } loadGateways(); loadReflectors(); CG2Handler::setG2ProtocolHandler(m_g2Handler); CG2Handler::setHeaderLogger(headerLogger); CDExtraHandler::setCallsign(m_gatewayCallsign); CDExtraHandler::setHeaderLogger(headerLogger); CDExtraHandler::setMaxDongles(m_dextraMaxDongles); CDPlusHandler::setCallsign(m_gatewayCallsign); CDPlusHandler::setDPlusLogin(m_dplusLogin); CDPlusHandler::setHeaderLogger(headerLogger); CDPlusHandler::setMaxDongles(m_dplusMaxDongles); if (m_dplusEnabled) CDPlusHandler::startAuthenticator(m_gatewayAddress, &m_cache); CDCSHandler::setGatewayType(m_gatewayType); CDCSHandler::setHeaderLogger(headerLogger); CRepeaterHandler::setLocalAddress(m_gatewayAddress); CRepeaterHandler::setG2Handler(m_g2Handler); if (m_irc != NULL) CRepeaterHandler::setIRC(m_irc); CRepeaterHandler::setCache(&m_cache); CRepeaterHandler::setGateway(m_gatewayCallsign); CRepeaterHandler::setLanguage(m_language); CRepeaterHandler::setDExtraEnabled(m_dextraEnabled); CRepeaterHandler::setDPlusEnabled(m_dplusEnabled); CRepeaterHandler::setDCSEnabled(m_dcsEnabled); CRepeaterHandler::setHeaderLogger(headerLogger); CRepeaterHandler::setAPRSWriter(m_aprsWriter); CRepeaterHandler::setInfoEnabled(m_infoEnabled); CRepeaterHandler::setEchoEnabled(m_echoEnabled); CRepeaterHandler::setDTMFEnabled(m_dtmfEnabled); if (m_whiteList != NULL) { CDExtraHandler::setWhiteList(m_whiteList); CDPlusHandler::setWhiteList(m_whiteList); CDCSHandler::setWhiteList(m_whiteList); } if (m_blackList != NULL) { CDExtraHandler::setBlackList(m_blackList); CDPlusHandler::setBlackList(m_blackList); CDCSHandler::setBlackList(m_blackList); } if (m_restrictList != NULL) CRepeaterHandler::setRestrictList(m_restrictList); CAudioUnit::setLanguage(m_language); CStarNetHandler::setCache(&m_cache); CStarNetHandler::setGateway(m_gatewayCallsign); CStarNetHandler::setG2Handler(m_g2Handler); if (m_irc != NULL) CStarNetHandler::setIRC(m_irc); CStarNetHandler::setLogging(m_logEnabled, m_logDir); #if defined(DEXTRA_LINK) || defined(DCS_LINK) CStarNetHandler::link(); #endif if (m_ddModeEnabled) { CDDHandler::initialise(MAX_DD_ROUTES, m_name); CDDHandler::setLogging(m_logEnabled, m_logDir); CDDHandler::setHeaderLogger(headerLogger); if (m_irc != NULL) CDDHandler::setIRC(m_irc); } wxString ccsAddress = m_ccsEnabled ? m_gatewayAddress : LOOPBACK_ADDRESS; CCCSHandler::setLocalAddress(ccsAddress); CCCSHandler::setHeaderLogger(headerLogger); CCCSHandler::setHost(m_ccsHost); // If no ircDDB then APRS is started immediately if (m_aprsWriter != NULL && m_irc == NULL) m_aprsWriter->setEnabled(true); if (m_remoteEnabled && !m_remotePassword.IsEmpty() && m_remotePort > 0U) { m_remote = new CRemoteHandler(m_remotePassword, m_remotePort, m_gatewayAddress); bool res = m_remote->open(); if (!res) { delete m_remote; m_remote = NULL; } } CRepeaterHandler::startup(); m_statusFileTimer.start(); CCallsignServer* server = NULL; if (m_dextraEnabled || m_dcsEnabled) { server = new CCallsignServer(m_gatewayCallsign, m_gatewayAddress, &m_cache); server->start(); } wxStopWatch stopWatch; stopWatch.Start(); m_statusTimer2.start(); try { while (!m_killed) { if (m_icomRepeaterHandler != NULL) processRepeater(m_icomRepeaterHandler); if (m_hbRepeaterHandler != NULL) processRepeater(m_hbRepeaterHandler); if (m_dummyRepeaterHandler != NULL) processRepeater(m_dummyRepeaterHandler); if (m_irc != NULL) processIrcDDB(); processDExtra(); processDPlus(); processDCS(); processG2(); CCCSHandler::process(); if (m_ddModeEnabled) processDD(); if (m_remote != NULL) m_remote->process(); unsigned long ms = stopWatch.Time(); stopWatch.Start(); CRepeaterHandler::clock(ms); CG2Handler::clock(ms); CDExtraHandler::clock(ms); CDPlusHandler::clock(ms); CDCSHandler::clock(ms); CStarNetHandler::clock(ms); CDDHandler::clock(ms); CCCSHandler::clock(ms); m_statusTimer2.clock(ms); m_statusFileTimer.clock(ms); if (m_statusFileTimer.hasExpired()) { readStatusFiles(); m_statusFileTimer.start(); } if (m_aprsWriter != NULL) m_aprsWriter->clock(ms); if (m_logEnabled) { m_statusTimer1.clock(ms); if (m_statusTimer1.hasExpired()) { bool ret1 = CDExtraHandler::stateChange(); bool ret2 = CDPlusHandler::stateChange(); bool ret3 = CDCSHandler::stateChange(); bool ret4 = CCCSHandler::stateChange(); if (ret1 || ret2 || ret3 || ret4) writeStatus(); m_statusTimer1.start(); } } ::wxMilliSleep(TIME_PER_TIC_MS); } } catch (std::exception& e) { wxString message(e.what(), wxConvLocal); wxLogError(wxT("Exception raised in the main thread - \"%s\""), message.c_str()); } catch (...) { wxLogError(wxT("Unknown exception raised in the main thread")); } wxLogMessage(wxT("Stopping the ircDDB Gateway thread")); // Unlink from all reflectors CDExtraHandler::unlink(); CDPlusHandler::unlink(); CDCSHandler::unlink(); CCCSHandler::disconnect(); if (m_ddModeEnabled) CDDHandler::finalise(); if (server != NULL) server->stop(); m_dextraPool->close(); delete m_dextraPool; m_dplusPool->close(); delete m_dplusPool; m_dcsPool->close(); delete m_dcsPool; m_g2Handler->close(); delete m_g2Handler; if (m_irc != NULL) { m_irc->close(); delete m_irc; } if (m_icomRepeaterHandler != NULL) { m_icomRepeaterHandler->close(); delete m_icomRepeaterHandler; } if (m_hbRepeaterHandler != NULL) { m_hbRepeaterHandler->close(); delete m_hbRepeaterHandler; } if (m_dummyRepeaterHandler != NULL) { m_dummyRepeaterHandler->close(); delete m_dummyRepeaterHandler; } if (m_remote != NULL) { m_remote->close(); delete m_remote; } if (headerLogger != NULL) { headerLogger->close(); delete headerLogger; } }
CTimerControlRepeaterPanel::CTimerControlRepeaterPanel(wxWindow* parent, int id, const wxString& callsign) : wxPanel(parent, id), m_callsign(callsign), m_list(NULL), m_day(NULL), m_hour(NULL), m_minute(NULL), m_reflector(NULL), m_channel(NULL), m_reconnect(NULL), m_item(NULL), m_n(0) { wxBoxSizer* sizer1 = new wxBoxSizer(wxHORIZONTAL); m_list = new wxListCtrl(this, List_Select, wxDefaultPosition, wxSize(LIST_WIDTH, LIST_HEIGHT), wxLC_REPORT | wxLC_SINGLE_SEL); m_list->InsertColumn(0L, _("Day")); m_list->SetColumnWidth(0L, DAY_WIDTH); m_list->InsertColumn(1L, _("Time")); m_list->SetColumnWidth(1L, TIME_WIDTH); m_list->InsertColumn(2L, _("Type")); m_list->SetColumnWidth(2L, TYPE_WIDTH); m_list->InsertColumn(3L, _("Reflector")); m_list->SetColumnWidth(3L, REFLECTOR_WIDTH); sizer1->Add(m_list, 0, wxTOP | wxBOTTOM | wxLEFT | wxEXPAND, BORDER_SIZE); wxBoxSizer* sizer2 = new wxBoxSizer(wxVERTICAL); m_day = new wxChoice(this, -1, wxDefaultPosition, wxSize(DAY_WIDTH, -1)); m_day->Append(_("Sunday")); m_day->Append(_("Monday")); m_day->Append(_("Tuesday")); m_day->Append(_("Wednesday")); m_day->Append(_("Thursday")); m_day->Append(_("Friday")); m_day->Append(_("Saturday")); m_day->Append(_("Every day")); m_day->Append(_("Mon-Fri")); m_day->Append(_("Sat-Sun")); sizer2->Add(m_day, 0, wxALL, BORDER_SIZE); m_day->SetSelection(0); wxBoxSizer* sizer2a = new wxBoxSizer(wxHORIZONTAL); m_hour = new wxChoice(this, -1, wxDefaultPosition, wxSize(HOUR_WIDTH, -1)); m_hour->Append(wxT("00")); m_hour->Append(wxT("01")); m_hour->Append(wxT("02")); m_hour->Append(wxT("03")); m_hour->Append(wxT("04")); m_hour->Append(wxT("05")); m_hour->Append(wxT("06")); m_hour->Append(wxT("07")); m_hour->Append(wxT("08")); m_hour->Append(wxT("09")); m_hour->Append(wxT("10")); m_hour->Append(wxT("11")); m_hour->Append(wxT("12")); m_hour->Append(wxT("13")); m_hour->Append(wxT("14")); m_hour->Append(wxT("15")); m_hour->Append(wxT("16")); m_hour->Append(wxT("17")); m_hour->Append(wxT("18")); m_hour->Append(wxT("19")); m_hour->Append(wxT("20")); m_hour->Append(wxT("21")); m_hour->Append(wxT("22")); m_hour->Append(wxT("23")); sizer2a->Add(m_hour, 0, wxALL, BORDER_SIZE); m_hour->SetSelection(0); wxStaticText* dummy1Label = new wxStaticText(this, -1, wxT(":")); sizer2a->Add(dummy1Label, 0, wxALL, BORDER_SIZE); m_minute = new wxChoice(this, -1, wxDefaultPosition, wxSize(MINUTE_WIDTH, -1)); m_minute->Append(wxT("00")); m_minute->Append(wxT("05")); m_minute->Append(wxT("10")); m_minute->Append(wxT("15")); m_minute->Append(wxT("20")); m_minute->Append(wxT("25")); m_minute->Append(wxT("30")); m_minute->Append(wxT("35")); m_minute->Append(wxT("40")); m_minute->Append(wxT("45")); m_minute->Append(wxT("50")); m_minute->Append(wxT("55")); sizer2a->Add(m_minute, 0, wxALL, BORDER_SIZE); m_minute->SetSelection(0); sizer2->Add(sizer2a); wxStaticText* dummy2Label = new wxStaticText(this, -1, wxEmptyString); sizer2->Add(dummy2Label, 0, wxALL, BORDER_SIZE); wxBoxSizer* sizer3 = new wxBoxSizer(wxHORIZONTAL); m_reflector = new wxChoice(this, -1, wxDefaultPosition, wxSize(REFLECTOR_WIDTH, -1)); m_reflector->Append(_("None")); wxFileName fileName1(wxFileName::GetHomeDir(), DPLUS_HOSTS_FILE_NAME); if (fileName1.IsFileReadable()) { CHostFile file(fileName1.GetFullPath(), false); for (unsigned int i = 0U; i < file.getCount(); i++) m_reflector->Append(file.getName(i).Trim()); } #if defined(__WINDOWS__) wxFileName fileName4(::wxGetCwd(), DPLUS_HOSTS_FILE_NAME); #else wxFileName fileName4(wxT(DATA_DIR), DPLUS_HOSTS_FILE_NAME); #endif if (fileName4.IsFileReadable()) { CHostFile file(fileName4.GetFullPath(), false); for (unsigned int i = 0U; i < file.getCount(); i++) { wxString name = file.getName(i).Trim(); if (m_reflector->FindString(name) == wxNOT_FOUND) m_reflector->Append(name); } } wxFileName fileName2(wxFileName::GetHomeDir(), DEXTRA_HOSTS_FILE_NAME); if (fileName2.IsFileReadable()) { CHostFile file(fileName2.GetFullPath(), false); for (unsigned int i = 0U; i < file.getCount(); i++) m_reflector->Append(file.getName(i).Trim()); } #if defined(__WINDOWS__) wxFileName fileName5(::wxGetCwd(), DEXTRA_HOSTS_FILE_NAME); #else wxFileName fileName5(wxT(DATA_DIR), DEXTRA_HOSTS_FILE_NAME); #endif if (fileName5.IsFileReadable()) { CHostFile file(fileName5.GetFullPath(), false); for (unsigned int i = 0U; i < file.getCount(); i++) { wxString name = file.getName(i).Trim(); if (m_reflector->FindString(name) == wxNOT_FOUND) m_reflector->Append(name); } } wxFileName fileName3(wxFileName::GetHomeDir(), DCS_HOSTS_FILE_NAME); if (fileName3.IsFileReadable()) { CHostFile file(fileName3.GetFullPath(), false); for (unsigned int i = 0U; i < file.getCount(); i++) m_reflector->Append(file.getName(i).Trim()); } #if defined(__WINDOWS__) wxFileName fileName6(::wxGetCwd(), DCS_HOSTS_FILE_NAME); #else wxFileName fileName6(wxT(DATA_DIR), DCS_HOSTS_FILE_NAME); #endif if (fileName6.IsFileReadable()) { CHostFile file(fileName6.GetFullPath(), false); for (unsigned int i = 0U; i < file.getCount(); i++) { wxString name = file.getName(i).Trim(); if (m_reflector->FindString(name) == wxNOT_FOUND) m_reflector->Append(name); } } sizer3->Add(m_reflector, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); m_reflector->SetSelection(0); m_channel = new wxChoice(this, -1, wxDefaultPosition, wxSize(CHANNEL_WIDTH, -1)); m_channel->Append(wxT("A")); m_channel->Append(wxT("B")); m_channel->Append(wxT("C")); m_channel->Append(wxT("D")); m_channel->Append(wxT("E")); m_channel->Append(wxT("F")); m_channel->Append(wxT("G")); m_channel->Append(wxT("H")); m_channel->Append(wxT("I")); m_channel->Append(wxT("J")); m_channel->Append(wxT("K")); m_channel->Append(wxT("L")); m_channel->Append(wxT("M")); m_channel->Append(wxT("N")); m_channel->Append(wxT("O")); m_channel->Append(wxT("P")); m_channel->Append(wxT("Q")); m_channel->Append(wxT("R")); m_channel->Append(wxT("S")); m_channel->Append(wxT("T")); m_channel->Append(wxT("U")); m_channel->Append(wxT("V")); m_channel->Append(wxT("W")); m_channel->Append(wxT("X")); m_channel->Append(wxT("Y")); m_channel->Append(wxT("Z")); sizer3->Add(m_channel, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); m_channel->SetSelection(0); sizer2->Add(sizer3); m_reconnect = new wxChoice(this, -1, wxDefaultPosition, wxSize(RECONNECT_WIDTH, -1)); m_reconnect->Append(_("Never")); m_reconnect->Append(_("Fixed")); m_reconnect->Append(_("5 minutes")); m_reconnect->Append(_("10 minutes")); m_reconnect->Append(_("15 minutes")); m_reconnect->Append(_("20 minutes")); m_reconnect->Append(_("25 minutes")); m_reconnect->Append(_("30 minutes")); m_reconnect->Append(_("60 minutes")); m_reconnect->Append(_("90 minutes")); m_reconnect->Append(_("120 minutes")); m_reconnect->Append(_("180 minutes")); sizer2->Add(m_reconnect, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); m_reconnect->SetSelection(0); wxStaticText* dummy3Label = new wxStaticText(this, -1, wxEmptyString); sizer2->Add(dummy3Label, 0, wxALL, BORDER_SIZE); wxButton* addButton = new wxButton(this, Button_Add, _("Add"), wxDefaultPosition, wxSize(BUTTON_WIDTH, -1)); sizer2->Add(addButton, 0, wxALL, BORDER_SIZE); wxButton* modButton = new wxButton(this, Button_Modify, _("Modify"), wxDefaultPosition, wxSize(BUTTON_WIDTH, -1)); sizer2->Add(modButton, 0, wxALL, BORDER_SIZE); wxButton* delButton = new wxButton(this, Button_Delete, _("Delete"), wxDefaultPosition, wxSize(BUTTON_WIDTH, -1)); sizer2->Add(delButton, 0, wxALL, BORDER_SIZE); sizer1->Add(sizer2); SetAutoLayout(true); SetSizer(sizer1); }
CRemoteControlRepeaterPanel::CRemoteControlRepeaterPanel(wxWindow* parent, int id, const wxString& callsign) : wxPanel(parent, id), m_callsign(callsign), m_list(NULL), m_reflector(NULL), m_channel(NULL), m_reconnect(NULL), m_unlink(NULL), m_selected(-1), m_reflectors(), m_protocols() { wxBoxSizer* sizer1 = new wxBoxSizer(wxHORIZONTAL); m_list = new wxListCtrl(this, List_Reflectors, wxDefaultPosition, wxSize(LIST_WIDTH, LIST_HEIGHT), wxLC_REPORT | wxLC_SINGLE_SEL); m_list->InsertColumn(0L, _("Callsign")); m_list->SetColumnWidth(0L, CALLSIGN_WIDTH); m_list->InsertColumn(1L, _("Protocol")); m_list->SetColumnWidth(1L, PROTOCOL_WIDTH); m_list->InsertColumn(2L, _("Direction")); m_list->SetColumnWidth(2L, DIRECTION_WIDTH); m_list->InsertColumn(3L, _("Type")); m_list->SetColumnWidth(3L, TYPE_WIDTH); m_list->InsertColumn(4L, _("State")); m_list->SetColumnWidth(4L, STATE_WIDTH); sizer1->Add(m_list, 0, wxTOP | wxBOTTOM | wxLEFT | wxEXPAND, BORDER_SIZE); wxBoxSizer* sizer2 = new wxBoxSizer(wxVERTICAL); wxButton* refreshButton = new wxButton(this, Button_Refresh, _("Refresh"), wxDefaultPosition, wxSize(BUTTON_WIDTH, -1)); sizer2->Add(refreshButton, 0, wxALL, BORDER_SIZE); wxStaticText* dummy1Label = new wxStaticText(this, -1, wxEmptyString); sizer2->Add(dummy1Label, 0, wxALL, BORDER_SIZE); wxStaticText* dummy2Label = new wxStaticText(this, -1, wxEmptyString); sizer2->Add(dummy2Label, 0, wxALL, BORDER_SIZE); wxBoxSizer* sizer3 = new wxBoxSizer(wxHORIZONTAL); m_reflector = new wxChoice(this, -1, wxDefaultPosition, wxSize(REFLECTOR_WIDTH, -1)); m_reflector->Append(_("None")); wxFileName fileName1(wxFileName::GetHomeDir(), DPLUS_HOSTS_FILE_NAME); if (fileName1.IsFileReadable()) { CHostFile file(fileName1.GetFullPath(), false); for (unsigned int i = 0U; i < file.getCount(); i++) m_reflector->Append(file.getName(i).Trim()); } #if defined(__WINDOWS__) wxFileName fileName4(::wxGetCwd(), DPLUS_HOSTS_FILE_NAME); #else wxFileName fileName4(wxT(DATA_DIR), DPLUS_HOSTS_FILE_NAME); #endif if (fileName4.IsFileReadable()) { CHostFile file(fileName4.GetFullPath(), false); for (unsigned int i = 0U; i < file.getCount(); i++) { wxString name = file.getName(i).Trim(); if (m_reflector->FindString(name) == wxNOT_FOUND) m_reflector->Append(name); } } wxFileName fileName2(wxFileName::GetHomeDir(), DEXTRA_HOSTS_FILE_NAME); if (fileName2.IsFileReadable()) { CHostFile file(fileName2.GetFullPath(), false); for (unsigned int i = 0U; i < file.getCount(); i++) m_reflector->Append(file.getName(i).Trim()); } #if defined(__WINDOWS__) wxFileName fileName5(::wxGetCwd(), DEXTRA_HOSTS_FILE_NAME); #else wxFileName fileName5(wxT(DATA_DIR), DEXTRA_HOSTS_FILE_NAME); #endif if (fileName5.IsFileReadable()) { CHostFile file(fileName5.GetFullPath(), false); for (unsigned int i = 0U; i < file.getCount(); i++) { wxString name = file.getName(i).Trim(); if (m_reflector->FindString(name) == wxNOT_FOUND) m_reflector->Append(name); } } wxFileName fileName3(wxFileName::GetHomeDir(), DCS_HOSTS_FILE_NAME); if (fileName3.IsFileReadable()) { CHostFile file(fileName3.GetFullPath(), false); for (unsigned int i = 0U; i < file.getCount(); i++) m_reflector->Append(file.getName(i).Trim()); } #if defined(__WINDOWS__) wxFileName fileName6(::wxGetCwd(), DCS_HOSTS_FILE_NAME); #else wxFileName fileName6(wxT(DATA_DIR), DCS_HOSTS_FILE_NAME); #endif if (fileName6.IsFileReadable()) { CHostFile file(fileName6.GetFullPath(), false); for (unsigned int i = 0U; i < file.getCount(); i++) { wxString name = file.getName(i).Trim(); if (m_reflector->FindString(name) == wxNOT_FOUND) m_reflector->Append(name); } } sizer3->Add(m_reflector, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); m_reflector->SetSelection(0); m_channel = new wxChoice(this, -1, wxDefaultPosition, wxSize(CHANNEL_WIDTH, -1)); m_channel->Append(wxT("A")); m_channel->Append(wxT("B")); m_channel->Append(wxT("C")); m_channel->Append(wxT("D")); m_channel->Append(wxT("E")); m_channel->Append(wxT("F")); m_channel->Append(wxT("G")); m_channel->Append(wxT("H")); m_channel->Append(wxT("I")); m_channel->Append(wxT("J")); m_channel->Append(wxT("K")); m_channel->Append(wxT("L")); m_channel->Append(wxT("M")); m_channel->Append(wxT("N")); m_channel->Append(wxT("O")); m_channel->Append(wxT("P")); m_channel->Append(wxT("Q")); m_channel->Append(wxT("R")); m_channel->Append(wxT("S")); m_channel->Append(wxT("T")); m_channel->Append(wxT("U")); m_channel->Append(wxT("V")); m_channel->Append(wxT("W")); m_channel->Append(wxT("X")); m_channel->Append(wxT("Y")); m_channel->Append(wxT("Z")); sizer3->Add(m_channel, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); m_channel->SetSelection(0); sizer2->Add(sizer3); m_reconnect = new wxChoice(this, -1, wxDefaultPosition, wxSize(RECONNECT_WIDTH, -1)); m_reconnect->Append(_("Never")); m_reconnect->Append(_("Fixed")); m_reconnect->Append(_("5 minutes")); m_reconnect->Append(_("10 minutes")); m_reconnect->Append(_("15 minutes")); m_reconnect->Append(_("20 minutes")); m_reconnect->Append(_("25 minutes")); m_reconnect->Append(_("30 minutes")); m_reconnect->Append(_("60 minutes")); m_reconnect->Append(_("90 minutes")); m_reconnect->Append(_("120 minutes")); m_reconnect->Append(_("180 minutes")); sizer2->Add(m_reconnect, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); m_reconnect->SetSelection(0); wxStaticText* dummy3Label = new wxStaticText(this, -1, wxEmptyString); sizer2->Add(dummy3Label, 0, wxALL, BORDER_SIZE); wxButton* linkButton = new wxButton(this, Button_Link, _("Link"), wxDefaultPosition, wxSize(BUTTON_WIDTH, -1)); sizer2->Add(linkButton, 0, wxALL, BORDER_SIZE); m_unlink = new wxButton(this, Button_Unlink, _("Unlink"), wxDefaultPosition, wxSize(BUTTON_WIDTH, -1)); sizer2->Add(m_unlink, 0, wxALL, BORDER_SIZE); m_unlink->Disable(); sizer1->Add(sizer2); SetAutoLayout(true); SetSizer(sizer1); }
bool PrintFile(const WCHAR *fileName, WCHAR *printerName, bool displayErrors, const WCHAR *settings) { bool ok = false; if (!HasPermission(Perm_PrinterAccess)) return false; ScopedMem<WCHAR> fileName2(path::Normalize(fileName)); BaseEngine *engine = EngineManager::CreateEngine(fileName2, true /* prefer Chm2Engine */); #ifndef DISABLE_DOCUMENT_RESTRICTIONS if (engine && !engine->AllowsPrinting()) { delete engine; engine = NULL; } #endif if (!engine) { if (displayErrors) MessageBoxWarning(NULL, _TR("Cannot print this file"), _TR("Printing problem.")); return false; } HANDLE printer; BOOL res = OpenPrinter(printerName, &printer, NULL); if (0 == res) { if (displayErrors) MessageBoxWarning(NULL, _TR("Printer with given name doesn't exist"), _TR("Printing problem.")); return false; } LPDEVMODE devMode = NULL; // get printer driver information DWORD needed = 0; GetPrinter(printer, 2, NULL, 0, &needed); ScopedMem<PRINTER_INFO_2> infoData((PRINTER_INFO_2 *)AllocArray<BYTE>(needed)); if (infoData) res = GetPrinter(printer, 2, (LPBYTE)infoData.Get(), needed, &needed); if ((0 == res) || !infoData || needed <= sizeof(PRINTER_INFO_2)) goto Exit; LONG structSize = DocumentProperties(NULL, printer, printerName, NULL, /* Asking for size, so */ NULL, /* not used. */ 0); /* Zero returns buffer size. */ if (structSize < sizeof(DEVMODE)) { // If failure, inform the user, cleanup and return failure. if (displayErrors) MessageBoxWarning(NULL, _TR("Could not obtain Printer properties"), _TR("Printing problem.")); goto Exit; } devMode = (LPDEVMODE)malloc(structSize); if (!devMode) goto Exit; // Get the default DevMode for the printer and modify it for your needs. LONG returnCode = DocumentProperties(NULL, printer, printerName, devMode, /* The address of the buffer to fill. */ NULL, /* Not using the input buffer. */ DM_OUT_BUFFER); /* Have the output buffer filled. */ if (IDOK != returnCode) { // If failure, inform the user, cleanup and return failure. if (displayErrors) MessageBoxWarning(NULL, _TR("Could not obtain Printer properties"), _TR("Printing problem.")); goto Exit; } ClosePrinter(printer); printer = NULL; { Print_Advanced_Data advanced; Vec<PRINTPAGERANGE> ranges; ApplyPrintSettings(settings, engine->PageCount(), ranges, advanced, devMode); PrintData pd(engine, infoData, devMode, ranges, advanced); ok = PrintToDevice(pd); if (!ok && displayErrors) MessageBoxWarning(NULL, _TR("Couldn't initialize printer"), _TR("Printing problem.")); } Exit: free(devMode); if (printer) ClosePrinter(printer); delete engine; return ok; }