int MHwrapper::deleteMbox(const FolderP&tfolder) { init_storage(); if (!m_storage) { return 0; } if (!tfolder) return 0; if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); if (r != MAIL_NO_ERROR) { odebug << "error deleting mail box" << oendl; return 0; } QString cmd = "rm -rf "+tfolder->getName(); QStringList command; command << "/bin/sh"; command << "-c"; command << cmd.latin1(); OProcess *process = new OProcess(); connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), this, SLOT( processEnded(Opie::Core::OProcess*))); connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); *process << command; removeMboxfailed = false; if(!process->start(OProcess::Block, OProcess::All) ) { odebug << "could not start process" << oendl; return 0; } odebug << "mail box deleted" << oendl; return 1; }
void SipMessage::parseStartLine( QString startline ) { unsigned int lastend, i; QString method; QString requri; QString verstr; if (KStatics::debugLevel == 2) cout << "\n" << startline.latin1(); // Get method lastend = 0; while ( ( lastend < startline.length() ) && ( !( startline[ lastend ].isSpace() ) ) ) { lastend++; } method = startline.left( lastend ); lastend++; // Skip the space i = 0; while ( ( ( lastend + i ) < startline.length() ) && ( !( startline[ lastend + i ].isSpace() ) ) ) { i++; } requri = startline.mid( lastend, i ); lastend += i + 1; // Skip the space verstr = startline.mid( lastend ).simplifyWhiteSpace(); if ( method == getVersionString() ) { // Input is a response setType( Response ); status.setCode( requri.toUInt() ); status.setReasonPhrase( verstr ); } else { setType( Request ); setMethod( Sip::matchMethod( method ) ); setRequestUri( SipUri( requri ) ); } }
int main( int argc, char* argv[] ) { QApplication myapp( argc, argv ); frmListLevvillkor* mywidget = new frmListLevvillkor(); QString rcfil; QString bibl; QStringList lines; QString homeDir( QDir::homeDirPath() ); rcfil.append(homeDir); rcfil.append("/.olfixrc"); // configfil // Läs in config filen här QFile file(rcfil); if ( file.open( IO_ReadOnly ) ) { QTextStream stream( &file ); QString line; while ( !stream.eof() ) { line = stream.readLine(); // line of text excluding '\n' int i = line.find( QRegExp("PATH="), 0 ); // i == 1 if ( i == 0){ int l =line.length(); bibl = line.mid(5,l); } lines += line; } file.close(); }else{ qWarning( "Cannot find the $HOME/.olfixrc file" ); fprintf(stdout,"%s\n", rcfil.latin1() ); } QDir::setCurrent ( bibl ); myapp.setMainWidget(mywidget); mywidget->show(); return myapp.exec(); }
void Split::onMessageSendRequested(ChatWidget *chat) { kdebugf(); if (!config_file.readBoolEntry("PowerKadu", "enable_split_message", false)) return; const unsigned int maxL = 1000; unsigned int length; unsigned char *format; QTextDocument doc; QString text = chat->edit()->text(); text.replace("\n", "\r\n"); doc.setHtml(text); text = doc.toPlainText(); text.replace("\r\n", "\n"); kdebugm(KDEBUG_INFO, "Tekst: %s\n", text.latin1()); QStringList splitedMessages; if(text.length() > maxL) { unsigned int pos = 0; QString tmpStr; while(pos < text.length()) { tmpStr = text.mid(pos, maxL); if(tmpStr != "") splitedMessages += tmpStr; pos += maxL; } fillEditor(chat, splitedMessages); SendSplitted *send = new SendSplitted(chat, splitedMessages, this, "send_splited"); send->name(); } kdebugf2(); }
bool validDatabase(const QString& db) { if (getenv("PGUSER") == NULL || getenv("DBROOT") == NULL) { qDebug("DMC is missing environment variables"); /* DMC will lock up if these environment variables are not set */ return false; } PIOGroup *g = PIOOpenVoidGrp(const_cast<char*>(db.latin1()), const_cast<char*>("r")); if (g) { PIOCloseVoidGrp(&g); // the call PIOOpenVoidGrp open the database, // the PIOCloseVoidGrp call do not close it // once one db is opened, // any subsequent open call will fail unless it is the same database // lets close it int rtc; rtc = PIOQuitDB(); if(rtc != 0) { // closing failed, dont care } return true; } return false; }
int PackageDialog::insertFile(const QString& FileName, QFile& File, QDataStream& Stream) { QByteArray FileContent; if(!File.open(QIODevice::ReadOnly)) { QMessageBox::critical(this, tr("Error"), tr("Cannot open \"%1\"!").arg(FileName)); return -1; } Q_ULONG Count = File.size(); char *p = (char*)malloc(Count+FileName.length()+2); strcpy(p, FileName.latin1()); File.readBlock(p+FileName.length()+1, Count); File.close(); Count += FileName.length()+1; FileContent = qCompress((unsigned char*)p, Count); free(p); Stream.writeBytes(FileContent.data(), FileContent.size()); return 0; }
void KJFileInfo::timeUpdate(int) { if (!napp->player()->current()) return; const PlaylistItem &item = napp->player()->current(); QString prop; if ( mInfoType == "mp3khzwindow" ) { prop = item.property("samplerate"); prop.truncate(2); // we just want 44 instead of 44100 } else if ( mInfoType == "mp3kbpswindow" ) { prop = item.property("bitrate"); } else // for safety: no infoType we know of return; if (prop.isNull()) prop=""; prepareString( prop.latin1() ); }
int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool ) { init_storage(); if (!m_storage) { return 0; } QString f; if (!pfolder) { // toplevel folder f = buildPath(folder); } else { f = pfolder->getName(); f+="/"; f+=folder; } odebug << f << oendl; int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); if (r != MAIL_NO_ERROR) { odebug << "error creating folder " << r << "" << oendl; return 0; } odebug << "Folder created" << oendl; return 1; }
mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) { mailmime * filePart = 0; mailmime_fields * fields = 0; mailmime_content * content = 0; mailmime_parameter * param = 0; char*name = 0; char*file = 0; int err; int pos = filename.findRev( '/' ); if (filename.length()>0) { QString tmp = filename.right( filename.length() - ( pos + 1 ) ); name = strdup( tmp.latin1() ); // just filename file = strdup( filename.latin1() ); // full name with path } int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; int mechanism = MAILMIME_MECHANISM_BASE64; if ( mimetype.startsWith( "text/" ) ) { param = mailmime_parameter_new( strdup( "charset" ), strdup( "iso-8859-1" ) ); mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; } fields = mailmime_fields_new_filename( disptype, name, mechanism ); content = mailmime_content_new_with_str( (char*)mimetype.latin1() ); if (content!=0 && fields != 0) { if (param) { clist_append(content->ct_parameters,param); param = 0; } if (filename.length()>0) { QFileInfo f(filename); param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); clist_append(content->ct_parameters,param); param = 0; } filePart = mailmime_new_empty( content, fields ); } if (filePart) { if (filename.length()>0) { err = mailmime_set_body_file( filePart, file ); } else { err = mailmime_set_body_text(filePart,strdup(TextContent.data()),TextContent.length()); } if (err != MAILIMF_NO_ERROR) { odebug << "Error setting body with file " << file << "" << oendl; mailmime_free( filePart ); filePart = 0; } } if (!filePart) { if ( param != NULL ) { mailmime_parameter_free( param ); } if (content) { mailmime_content_free( content ); } if (fields) { mailmime_fields_free( fields ); } else { if (name) { free( name ); } if (file) { free( file ); } } } return filePart; // Success :) }
QString USBDevice::dump() { QString r; r = "<qml><h2><center>" + product() + "</center></h2><br/><hl/>"; if (!_manufacturer.isEmpty()) r += i18n("<b>Manufacturer:</b> ") + _manufacturer + "<br/>"; if (!_serial.isEmpty()) r += i18n("<b>Serial #:</b> ") + _serial + "<br/>"; r += "<br/><table>"; QString c = QString("<td>%1</td>").arg(_class); QString cname = _db->cls(_class); if (!cname.isEmpty()) c += "<td>(" + i18n(cname.latin1()) +")</td>"; r += i18n("<tr><td><i>Class</i></td>%1</tr>").arg(c); QString sc = QString("<td>%1</td>").arg(_sub); QString scname = _db->subclass(_class, _sub); if (!scname.isEmpty()) sc += "<td>(" + i18n(scname.latin1()) +")</td>"; r += i18n("<tr><td><i>Subclass</i></td>%1</tr>").arg(sc); QString pr = QString("<td>%1</td>").arg(_prot); QString prname = _db->protocol(_class, _sub, _prot); if (!prname.isEmpty()) pr += "<td>(" + prname +")</td>"; r += i18n("<tr><td><i>Protocol</i></td>%1</tr>").arg(pr); #ifndef Q_OS_FREEBSD r += i18n("<tr><td><i>USB Version</i></td><td>%1.%2</td></tr>") .arg(_verMajor,0,16) .arg(QString::number(_verMinor,16).prepend('0').right(2)); #endif r += "<tr><td></td></tr>"; QString v = QString::number(_vendorID,16); QString name = _db->vendor(_vendorID); if (!name.isEmpty()) v += "<td>(" + name +")</td>"; r += i18n("<tr><td><i>Vendor ID</i></td><td>0x%1</td></tr>").arg(v); QString p = QString::number(_prodID,16); QString pname = _db->device(_vendorID, _prodID); if (!pname.isEmpty()) p += "<td>(" + pname +")</td>"; r += i18n("<tr><td><i>Product ID</i></td><td>0x%1</td></tr>").arg(p); r += i18n("<tr><td><i>Revision</i></td><td>%1.%2</td></tr>") .arg(_revMajor,0,16) .arg(QString::number(_revMinor,16).prepend('0').right(2)); r += "<tr><td></td></tr>"; r += i18n("<tr><td><i>Speed</i></td><td>%1 Mbit/s</td></tr>").arg(_speed); r += i18n("<tr><td><i>Channels</i></td><td>%1</td></tr>").arg(_channels); #ifdef Q_OS_FREEBSD if ( _power ) r += i18n("<tr><td><i>Power Consumption</i></td><td>%1 mA</td></tr>").arg(_power); else r += i18n("<tr><td><i>Power Consumption</i></td><td>self powered</td></tr>"); r += i18n("<tr><td><i>Attached Devicenodes</i></td><td>%1</td></tr>").arg(*_devnodes.at(0)); if ( _devnodes.count() > 1 ) for ( QStringList::Iterator it = _devnodes.at(1); it != _devnodes.end(); ++it ) r += "<tr><td></td><td>" + *it + "</td></tr>"; #else r += i18n("<tr><td><i>Max. Packet Size</i></td><td>%1</td></tr>").arg(_maxPacketSize); #endif r += "<tr><td></td></tr>"; if (_hasBW) { r += i18n("<tr><td><i>Bandwidth</i></td><td>%1 of %2 (%3%)</td></tr>").arg(_bwUsed).arg(_bwTotal).arg(_bwPercent); r += i18n("<tr><td><i>Intr. requests</i></td><td>%1</td></tr>").arg(_bwIntr); r += i18n("<tr><td><i>Isochr. requests</i></td><td>%1</td></tr>").arg(_bwIso); r += "<tr><td></td></tr>"; } r += "</table>"; return r; }
QString RKComponentBase::value (const QString &modifier) { RK_TRACE (PLUGIN); RK_DO (qDebug ("Component type %d does not have a value. Remaining modifier is: '%s'", type (), modifier.latin1 ()), PLUGIN, DL_WARNING); return QString (); }
void HTMLDocumentImpl::determineParseMode(const QString &str) { // kdDebug() << "DocumentImpl::determineParseMode str=" << str<< endl; int oldPMode = pMode; // This code more or less mimics Mozilla's implementation (specifically the // doctype parsing implemented by David Baron in Mozilla's nsParser.cpp). // // There are three possible parse modes: // COMPAT - quirks mode emulates WinIE // and NS4. CSS parsing is also relaxed in this mode, e.g., unit types can // be omitted from numbers. // ALMOST STRICT - This mode is identical to strict mode // except for its treatment of line-height in the inline box model. For // now (until the inline box model is re-written), this mode is identical // to STANDARDS mode. // STRICT - no quirks apply. Web pages will obey the specifications to // the letter. QString systemID, publicID; int resultFlags = 0; if(parseDocTypeDeclaration(str, &resultFlags, publicID, systemID)) { if(resultFlags & PARSEMODE_HAVE_DOCTYPE) { m_doctype->setName("HTML"); m_doctype->setPublicId(publicID); m_doctype->setSystemId(systemID); } if(!(resultFlags & PARSEMODE_HAVE_DOCTYPE)) { // No doctype found at all. Default to quirks mode and Html4. pMode = Compat; hMode = Html4; } else if((resultFlags & PARSEMODE_HAVE_INTERNAL) || !(resultFlags & PARSEMODE_HAVE_PUBLIC_ID)) { // Internal subsets always denote full standards, as does // a doctype without a public ID. pMode = Strict; hMode = Html4; } else { // We have to check a list of public IDs to see what we // should do. QString lowerPubID = publicID.lower(); const char *pubIDStr = lowerPubID.latin1(); // Look up the entry in our gperf-generated table. const PubIDInfo *doctypeEntry = findDoctypeEntry(pubIDStr, publicID.length()); if(!doctypeEntry) { // The DOCTYPE is not in the list. Assume strict mode. // ### Doesn't make any sense, but it's what Mozilla does. pMode = Strict; hMode = Html4; return; } switch((resultFlags & PARSEMODE_HAVE_SYSTEM_ID) ? doctypeEntry->mode_if_sysid : doctypeEntry->mode_if_no_sysid) { case PubIDInfo::eQuirks3: pMode = Compat; hMode = Html3; break; case PubIDInfo::eQuirks: pMode = Compat; hMode = Html4; break; case PubIDInfo::eAlmostStandards: pMode = Transitional; hMode = Html4; break; default: assert(false); } } } else { // Malformed doctype implies quirks mode. pMode = Compat; hMode = Html3; } // This needs to be done last, see tests/parser/compatmode_xhtml_mixed.html if(hMode == Html4 && !m_htmlRequested) { // this part is still debatable and possibly UA dependent hMode = XHtml; pMode = Transitional; } m_styleSelector->strictParsing = !inCompatMode(); // kdDebug() << "DocumentImpl::determineParseMode: publicId =" << publicID << " systemId = " << systemID << endl; // kdDebug() << "DocumentImpl::determineParseMode: htmlMode = " << hMode<< endl; if(pMode == Strict) kdDebug(6030) << " using strict parseMode" << endl; else if(pMode == Compat) kdDebug(6030) << " using compatibility parseMode" << endl; else kdDebug(6030) << " using transitional parseMode" << endl; // not sure this is needed if(pMode != oldPMode && styleSelector()) recalcStyleSelector(); }
bool FirebirdConn::connect(const QString& database, const QString& userName, const QString& password) { FirebirdConfig config; if (!config.load()) return error("Can't read firebird.cfg file"); // Get codec for text conversions QTextCodec* codec = QTextCodec::codecForName(config.charSet); if (codec == NULL) return error("Character set not supported by Qt: " + config.charSet); // Verify values are not too large if (userName.length() + password.length() + config.charSet.length() > 4000) return error("Username/password are too long"); // Database param buffer char dpb_buffer[4096]; char* dpb = dpb_buffer; // Initialize param buffer *dpb++ = isc_dpb_version1; // Turn on forced writes *dpb++ = isc_dpb_force_write; *dpb++ = 1; *dpb++ = 1; // Add username *dpb++ = isc_dpb_user_name; *dpb++ = strlen(userName); strcpy(dpb, userName); dpb += strlen(userName); // Add password *dpb++ = isc_dpb_password; *dpb++ = strlen(password); strcpy(dpb, password); dpb += strlen(password); // Add character set *dpb++ = isc_dpb_lc_ctype; *dpb++ = strlen(config.charSet); strcpy(dpb, config.charSet); dpb += strlen(config.charSet); // Build database connection name QString dbName = config.hostname; if (config.port != 3050) dbName += "/" + QString::number(config.port); if (!dbName.isEmpty()) dbName += ":"; dbName += database; // Connect ISC_STATUS status[20]; isc_db_handle db = 0L; char* dbname = strdup(dbName.latin1()); _procs->isc_attach_database(status, 0, dbname, &db, dpb - dpb_buffer, dpb_buffer); free(dbname); if (status[0] == 1 && status[1]) { _procs->isc_print_status(status); return error("connect failed"); } disconnect(); _db = db; _codec = codec; return true; }
// same-name slots, connecting to Packet signals // this packet is variable in length. everything is dwords except the "idFile" field // which can be variable void SpawnShell::newGroundItem(const uint8_t* data, size_t len, uint8_t dir) { if (m_zoneMgr->isZoning()) return; if (dir != DIR_Server) return; if (!data) return; NetStream netStream(data, len); makeDropStruct ds; QString name; union { uint32_t n; float f; } x; memset(&ds, 0, sizeof(makeDropStruct)); // read drop id ds.dropId = netStream.readUInt32NC(); // read name name = netStream.readText(); if(name.length()) { strcpy(ds.idFile, name.latin1()); } // read past zone id netStream.readUInt32NC(); // read past zone instance netStream.readUInt32NC(); // read past unknown dword field netStream.readUInt32NC(); // read heading x.n = netStream.readUInt32NC(); ds.heading = x.f; // read past unknown dword field netStream.readUInt32NC(); // read past unknown dword field netStream.readUInt32NC(); // read past unknown dword field netStream.readUInt32NC(); // read y pos x.n = netStream.readUInt32NC(); ds.y = x.f; // read x pos x.n = netStream.readUInt32NC(); ds.x = x.f; // read z pos x.n = netStream.readUInt32NC(); ds.z = x.f; #ifdef SPAWNSHELL_DIAG seqDebug("SpawnShell::newGroundItem(makeDropStruct *)"); #endif Drop* item = (Drop*)m_drops.find(ds.dropId); if (item != NULL) { item->update(&ds, name); if (!showeq_params->fast_machine) item->setDistanceToPlayer(m_player->calcDist2DInt(*item)); else item->setDistanceToPlayer(m_player->calcDist(*item)); updateFilterFlags(item); item->updateLastChanged(); emit changeItem(item, tSpawnChangedALL); } else { item = new Drop(&ds, name); if (!showeq_params->fast_machine) item->setDistanceToPlayer(m_player->calcDist2DInt(*item)); else item->setDistanceToPlayer(m_player->calcDist(*item)); updateFilterFlags(item); m_drops.insert(ds.dropId, item); emit addItem(item); } }
QT_BEGIN_NAMESPACE int runUic3(int argc, char * argv[]) { bool impl = false; bool wrap = false; bool subcl = false; bool extract = false; bool imagecollection = false; bool imagecollection_tmpfile = false; bool convert = false; QStringList images; const char *error = 0; const char* fileName = 0; const char* className = 0; const char* headerFile = 0; const char* convertedUiFile = 0; QByteArray outputFile; QString qrcOutputFile; QByteArray image_tmpfile; const char* projectName = 0; const char* trmacro = 0; bool fix = false; bool deps = false; unsigned readerOptions = Ui3Reader::ImplicitIncludes|Ui3Reader::CustomWidgetForwardDeclarations; QByteArray pchFile; QApplication app(argc, argv, false); for (int n = 1; n < argc && error == 0; n++) { QByteArray arg = argv[n]; if (arg[0] == '-') { // option QByteArray opt = arg.data() + 1; if (opt[0] == 'o') { // output redirection if (opt[1] == '\0') { if (!(n < argc-1)) { error = "Missing output-file name"; break; } outputFile = argv[++n]; } else outputFile = opt.data() + 1; } else if (opt[0] == 'i' || opt == "impl") { impl = true; if (opt == "impl" || opt[1] == '\0') { if (!(n < argc-1)) { error = "Missing name of header file"; break; } headerFile = argv[++n]; } else headerFile = opt.data() + 1; } else if (opt[0] == 'w' || opt == "wrap") { wrap = true; if (opt == "wrap" || opt[1] == '\0') { if (!(n < argc-1)) { error = "Missing name of converted UI file"; break; } convertedUiFile = argv[++n]; } else convertedUiFile = opt.data() + 1; } else if (opt == "extract") { // output redirection extract = true; if (!(n < argc-1)) { error = "Missing output qrc-file name"; break; } qrcOutputFile = QFile::decodeName(argv[++n]); } else if ( opt[0] == 'e' || opt == "embed" ) { imagecollection = true; if ( opt == "embed" || opt[1] == '\0' ) { if ( !(n < argc-1) ) { error = "Missing name of project"; break; } projectName = argv[++n]; } else { projectName = opt.data() + 1; } if ( argc > n+1 && qstrcmp( argv[n+1], "-f" ) == 0 ) { imagecollection_tmpfile = true; image_tmpfile = argv[n+2]; n += 2; } } else if (opt == "d") { deps = true; } else if (opt == "no-implicit-includes") { readerOptions &= ~Ui3Reader::ImplicitIncludes; } else if (opt == "nofwd") { readerOptions &= ~Ui3Reader::CustomWidgetForwardDeclarations; } else if (opt == "layout-names") { readerOptions |= Ui3Reader::PreserveLayoutNames; } else if (opt == "limit-xpm-linelength") { readerOptions |= Ui3Reader::LimitXPM_LineLength; } else if (opt == "nounload") { // skip } else if (opt == "convert") { convert = true; } else if (opt == "subdecl") { subcl = true; if (!(n < argc-2)) { error = "Missing arguments"; break; } className = argv[++n]; headerFile = argv[++n]; } else if (opt == "subimpl") { subcl = true; impl = true; if (!(n < argc-2)) { error = "Missing arguments"; break; } className = argv[++n]; headerFile = argv[++n]; } else if (opt == "tr") { if (opt == "tr" || opt[1] == '\0') { if (!(n < argc-1)) { error = "Missing tr macro."; break; } trmacro = argv[++n]; } else { trmacro = opt.data() + 1; } } else if (opt == "L") { if (!(n < argc-1)) { error = "Missing plugin path."; break; } ++n; // ignore the next argument } else if (opt == "version") { fprintf(stderr, "Qt User Interface Compiler version %s\n", QT_VERSION_STR); return 1; } else if (opt == "help") { break; } else if (opt == "fix") { fix = true; } else if (opt == "pch") { if (!(n < argc-1)) { error = "Missing name of PCH file"; break; } pchFile = argv[++n]; } else { error = "Unrecognized option"; } } else { if (imagecollection && !imagecollection_tmpfile) images << QLatin1String(argv[n]); else if (fileName) // can handle only one file error = "Too many input files specified"; else fileName = argv[n]; } } if (argc < 2 || error || (!fileName && !imagecollection)) { fprintf(stderr, "Qt User Interface Compiler version %s\n", QT_VERSION_STR); if (error) fprintf(stderr, "uic: %s\n", error); fprintf(stderr, "Usage: %s [options] [mode] <uifile>\n\n" "Convert a UI file to version 4:\n" " %s [options] -convert <uifile>\n" "Generate declaration:\n" " %s [options] <uifile>\n" "\t<uiheaderfile> name of the data file\n" " %s [options] -decl <uiheaderfile> <uifile>\n" "\t<uiheaderfile> name of the data file\n" " %s [options] -wrap <converteduifile> <uifile>\n" "\t<converteduifile> name of the converted UI file\n" "Generate implementation:\n" " %s [options] -impl <headerfile> <uifile>\n" "\t<headerfile> name of the declaration file\n" "Generate image collection:\n" " %s [options] -embed <project> <image1> <image2> <image3> ...\n" "or\n" " %s [options] -embed <project> -f <temporary file containing image names>\n" "\t<project> project name\n" "\t<image[1-N]> image files\n" "Generate subclass declaration:\n" " %s [options] -subdecl <subclassname> <baseclassheaderfile> <uifile>\n" "\t<subclassname> name of the subclass to generate\n" "\t<baseclassheaderfile> declaration file of the baseclass\n" "Generate subclass implementation:\n" " %s [options] -subimpl <subclassname> <subclassheaderfile> <uifile>\n" "\t<subclassname> name of the subclass to generate\n" "\t<subclassheaderfile> declaration file of the subclass\n" "Options:\n" "\t-o file Write output to file rather than stdout\n" "\t-extract qrcFile Create resource file and extract embedded images into \"image\" dir\n" "\t-limit-xpm-linelength Limit the line length of XPM files for -extract.\n" "\t-pch file Add #include \"file\" as the first statement in implementation\n" "\t-nofwd Omit forward declarations of custom classes\n" "\t-layout-names Preserve layout names of Qt Designer 3\n" "\t-no-implicit-includes Do not generate #include-directives for custom classes\n" "\t-nounload Do not unload plugins after processing\n" "\t-tr func Use func() instead of tr() for i18n\n" "\t-L path Additional plugin search path\n" "\t-version Display version of uic\n" "\t-help Display this information\n" , argv[0], argv[0], argv[0], argv[0], argv[0], argv[0], argv[0], argv[0], argv[0], argv[0] ); return 1; } if (imagecollection_tmpfile) { QFile ifile(QFile::decodeName(image_tmpfile)); if (ifile.open(QIODevice::ReadOnly)) { QTextStream ts(&ifile); QString s = ts.read(); s = s.simplified(); images = s.split(QLatin1Char(' ')); for (QStringList::Iterator it = images.begin(); it != images.end(); ++it) *it = (*it).simplified(); } } QFile fileOut; if (!outputFile.isEmpty()) { fileOut.setFileName(QFile::decodeName(outputFile)); if (!fileOut.open(QIODevice::WriteOnly)) { fprintf(stderr, "%s: Could not open output file '%s'\n", argv[0], outputFile.data()); return 1; } } else { fileOut.open(QIODevice::WriteOnly, stdout); } QTextStream out(&fileOut); Ui3Reader ui3(out, readerOptions); ui3.setExtractImages(extract, qrcOutputFile); if (projectName && imagecollection) { out.setEncoding(QTextStream::Latin1); ui3.embed(projectName, images); return 0; } out.setEncoding(QTextStream::UnicodeUTF8); QFile file(QFile::decodeName(fileName)); if (!file.open(QIODevice::ReadOnly)) { fprintf(stderr, "%s: Could not open file '%s'\n", argv[0], fileName); return 1; } QDomDocument doc; QString errMsg; int errLine; if (!doc.setContent(&file, &errMsg, &errLine)) { fprintf(stderr, "%s: Failed to parse %s: %s in line %d\n", argv[0], fileName, errMsg.latin1(), errLine); return 1; } QDomElement e = doc.firstChild().toElement(); double version = e.attribute(QLatin1String("version"), QLatin1String("3.0")).toDouble(); if (version > 3.3) { fprintf(stderr, "%s: File generated with too recent version of Qt Designer (%s vs. %s)\n", argv[0], e.attribute(QLatin1String("version")).latin1(), "3.3"); return 1; } DomTool::fixDocument(doc); if (fix) { out << doc.toString(); return 0; } if (imagecollection) { out.setEncoding(QTextStream::Latin1); ui3.embed(projectName, images); return 0; } else if (deps) { QStringList globalIncludes, localIncludes; ui3.computeDeps(e, globalIncludes, localIncludes, impl); foreach (const QString &i, globalIncludes) printf("%s\n", i.toLatin1().constData()); foreach (const QString &i, localIncludes) printf("%s\n", i.toLatin1().constData()); if (impl) printf("%s\n", headerFile); return 0; } else if (convert) {
KstJSUIBuilder::KstJSUIBuilder(const QString& ui, KstJS *js) : QObject(js, ui.latin1()), _helper(new KstJSUIHelper(ui, js)) { //new KAction(i18n("LALALALA..."), 0, 0, 0, 0, js->actionCollection(), "kst_scalar_trigger"); }
/*! Creates a KDGanttViewTaskLink according to the specification in a DOM element. \param element the DOM element from which to read the specification \return the newly created task link */ KDGanttViewTaskLink* KDGanttViewTaskLink::createFromDomElement( QDomElement& element ) { QDomNode node = element.firstChild(); QStringList fromList, toList; bool highlight = false, visible = false; QColor color, highlightColor; QString tooltipText, whatsThisText, group; LinkType linktype=None; while( !node.isNull() ) { QDomElement element = node.toElement(); if( !element.isNull() ) { // was really an element QString tagName = element.tagName(); if( tagName == "FromItems" ) { QDomNode node = element.firstChild(); while( !node.isNull() ) { QDomElement element = node.toElement(); if( !element.isNull() ) { // was really an element QString tagName = element.tagName(); if( tagName == "Item" ) { QString value; if( KDGanttXML::readStringNode( element, value ) ) fromList << value; } else { qDebug( "Unrecognized tag name: %s", tagName.latin1() ); Q_ASSERT( false ); } } node = node.nextSibling(); } } else if( tagName == "ToItems" ) { QDomNode node = element.firstChild(); while( !node.isNull() ) { QDomElement element = node.toElement(); if( !element.isNull() ) { // was really an element QString tagName = element.tagName(); if( tagName == "Item" ) { QString value; if( KDGanttXML::readStringNode( element, value ) ) toList << value; } else { qDebug( "Unrecognized tag name: %s", tagName.latin1() ); Q_ASSERT( false ); } } node = node.nextSibling(); } } else if( tagName == "Highlight" ) { bool value; if( KDGanttXML::readBoolNode( element, value ) ) highlight = value; } else if( tagName == "Visible" ) { bool value; if( KDGanttXML::readBoolNode( element, value ) ) visible = value; } else if( tagName == "Color" ) { QColor value; if( KDGanttXML::readColorNode( element, value ) ) color = value; } else if( tagName == "HighlightColor" ) { QColor value; if( KDGanttXML::readColorNode( element, value ) ) highlightColor = value; } else if( tagName == "TooltipText" ) { QString value; if( KDGanttXML::readStringNode( element, value ) ) tooltipText = value; } else if( tagName == "WhatsThisText" ) { QString value; if( KDGanttXML::readStringNode( element, value ) ) whatsThisText = value; } else if( tagName == "Group" ) { QString value; if( KDGanttXML::readStringNode( element, value ) ) group = value; } else if( tagName == "Linktype" ) { QString value; if( KDGanttXML::readStringNode( element, value ) ) linktype = stringToLinkType( value ); } else { qDebug( "Unrecognized tag name: %s", tagName.latin1() ); Q_ASSERT( false ); } } node = node.nextSibling(); } QPtrList<KDGanttViewItem> fromItemList; QPtrList<KDGanttViewItem> toItemList; for( QStringList::const_iterator fromIt = fromList.begin(); fromIt != fromList.end(); ++fromIt ) { KDGanttViewItem* item = KDGanttViewItem::find( *fromIt ); if( item ) fromItemList.append( item ); } for( QStringList::const_iterator toIt = toList.begin(); toIt != toList.end(); ++toIt ) { KDGanttViewItem* item = KDGanttViewItem::find( *toIt ); if( item ) toItemList.append( item ); } // safeguard aginst incorrect names if (fromItemList.isEmpty()) { qDebug("Cannot create link: fromItemList is empty"); return 0; } if (toItemList.isEmpty()) { qDebug("Cannot create link: toItemList is empty"); return 0; } KDGanttViewTaskLink* tl = new KDGanttViewTaskLink( fromItemList, toItemList ); tl->setLinkType( linktype ); tl->setVisible( visible ); tl->setHighlight( highlight ); tl->setColor( color ); tl->setHighlightColor( highlightColor ); tl->setTooltipText( tooltipText ); tl->setWhatsThisText( whatsThisText ); KDGanttViewTaskLinkGroup* gr = KDGanttViewTaskLinkGroup::find( group ); if( gr ) tl->setGroup( gr ); return tl; }
//================================================================================== //Use this as our connection instead of connect bool pqxxSqlConnection::drv_useDatabase( const QString &dbName, bool *cancelled, MessageHandler* msgHandler ) { Q_UNUSED(cancelled); Q_UNUSED(msgHandler); KexiDBDrvDbg << "pqxxSqlConnection::drv_useDatabase: " << dbName << endl; QString conninfo; QString socket; QStringList sockets; if (data()->hostName.isEmpty() || data()->hostName == "localhost") { if (data()->localSocketFileName.isEmpty()) { sockets.append("/tmp/.s.PGSQL.5432"); for(QStringList::ConstIterator it = sockets.constBegin(); it != sockets.constEnd(); it++) { if(QFile(*it).exists()) { socket = (*it); break; } } } else { socket=data()->localSocketFileName; //data()->fileName(); } } else { conninfo = "host='" + data()->hostName + "'"; } //Build up the connection string if (data()->port == 0) data()->port = 5432; conninfo += QString::fromLatin1(" port='%1'").arg(data()->port); conninfo += QString::fromLatin1(" dbname='%1'").arg(dbName); if (!data()->userName.isNull()) conninfo += QString::fromLatin1(" user='******'").arg(data()->userName); if (!data()->password.isNull()) conninfo += QString::fromLatin1(" password='******'").arg(data()->password); try { d->pqxxsql = new pqxx::connection( conninfo.latin1() ); drv_executeSQL( "SET DEFAULT_WITH_OIDS TO ON" ); //Postgres 8.1 changed the default to no oids but we need them if (d->version) { //! @todo set version using the connection pointer when we drop libpqxx for libpq } return true; } catch(const std::exception &e) { KexiDBDrvDbg << "pqxxSqlConnection::drv_useDatabase:exception - " << e.what() << endl; d->errmsg = QString::fromUtf8( e.what() ); } catch(...) { d->errmsg = i18n("Unknown error."); } return false; }
int32_t SpawnShell::fillSpawnStruct(spawnStruct *spawn, const uint8_t *data, size_t len, bool checkLen) { /* This reads data from the variable-length spawn struct */ NetStream netStream(data, len); int32_t retVal; uint32_t race; uint8_t i; QString name = netStream.readText(); if(name.length()) strcpy(spawn->name, name.latin1()); spawn->spawnId = netStream.readUInt32NC(); spawn->level = netStream.readUInt8(); // skip the next 4 bytes netStream.skipBytes(4); spawn->NPC = netStream.readUInt8(); spawn->miscData = netStream.readUInt32NC(); spawn->otherData = netStream.readUInt8(); // skip unknown3, unknown4 netStream.skipBytes(8); if(spawn->otherData & 1) { // it's a chest or untargetable do i = netStream.readUInt8(); while(i); do i = netStream.readUInt8(); while(i); do i = netStream.readUInt8(); while(i); // skip next 3 longs netStream.skipBytes(12); // next it loops through 9 longs, but we can just skip them netStream.skipBytes(36); // skip 1 byte netStream.skipBytes(1); // skip the last long netStream.skipBytes(4); } // skip facestyle, walk/run speeds, unknown5 netStream.skipBytes(13); spawn->race = netStream.readUInt32NC(); spawn->charProperties = netStream.readUInt8(); if(spawn->charProperties) { spawn->bodytype = netStream.readUInt32NC(); for(i = 1; i < spawn->charProperties; i++) { // extra character properties netStream.skipBytes(4); } } spawn->curHp = netStream.readUInt8(); // skip hair and face stuff netStream.skipBytes(18); spawn->holding = netStream.readUInt8(); spawn->deity = netStream.readUInt32NC(); spawn->guildID = netStream.readUInt32NC(); spawn->guildstatus = netStream.readUInt32NC(); spawn->class_ = netStream.readUInt8(); netStream.skipBytes(1); spawn->state = netStream.readUInt8(); spawn->light = netStream.readUInt8(); netStream.skipBytes(5); name = netStream.readText(); if(name.length()) { strcpy(spawn->lastName, name.latin1()); } netStream.skipBytes(5); spawn->petOwnerId = netStream.readUInt32NC(); netStream.skipBytes(25); spawn->posData[0] = netStream.readUInt32NC(); spawn->posData[1] = netStream.readUInt32NC(); spawn->posData[2] = netStream.readUInt32NC(); spawn->posData[3] = netStream.readUInt32NC(); spawn->posData[4] = netStream.readUInt32NC(); // skip color netStream.skipBytes(36); race = spawn->race; // this is how the client checks if equipment should be read. if(spawn->NPC == 0 || race <= 12 || race == 128 || race == 130 || race == 330 || race == 522) { for(i = 0; i < 9; i++) { spawn->equipment[i].itemId = netStream.readUInt32NC(); spawn->equipment[i].equip1 = netStream.readUInt32NC(); spawn->equipment[i].equip0 = netStream.readUInt32NC(); } } if(spawn->otherData & 4) { name = netStream.readText(); strcpy(spawn->title, name.latin1()); } if(spawn->otherData & 8) { name = netStream.readText(); strcpy(spawn->suffix, name.latin1()); } // unknowns netStream.skipBytes(8); spawn->isMercenary = netStream.readUInt8(); // unknowns netStream.skipBytes(28); // now we're at the end retVal = netStream.pos() - netStream.data(); if(checkLen && (int32_t)len != retVal) { seqDebug("SpawnShell::fillSpawnStruct - expected length: %d, read: %d for spawn '%s'", len, retVal, spawn->name); } return retVal; }
int coReadSTP3::getTransformation(const char *filename, double *mat, double *inv) { #if 0 FILE *fp = fopen(filename, "rb"); if(!fp) { fprintf(stderr, "failed to open %s\n", filename); return -1; } // read transformation header uint32_t file_type; if (fread(&file_type,sizeof(file_type), 1, fp)!=sizeof(file_type)) { fprintf(stderr,"fread_32 failed in ReadSTP3.cpp"); } byteSwap(file_type); uint32_t ser_head_len; if (fread(&ser_head_len,sizeof(ser_head_len), 1, fp)!=sizeof(ser_head_len)) { fprintf(stderr,"fread_33 failed in ReadSTP3.cpp"); } byteSwap(ser_head_len); uint32_t block_len; if (fread(&block_len,sizeof(block_len), 1, fp)!=sizeof(block_len)) { fprintf(stderr,"fread_34 failed in ReadSTP3.cpp"); } byteSwap(block_len); fprintf(stderr, "blocklen=%d, serheadlen=%d\n", block_len, ser_head_len); char patient_name[81]; if (fread(patient_name, 1, 80, fp)!= 1) { fprintf(stderr,"fread_35 failed in ReadSTP3.cpp"); } patient_name[80] = '\0'; char comm[81]; if (fread(comm, 1, 80, fp)!= 1) { fprintf(stderr,"fread_36 failed in ReadSTP3.cpp"); } comm[80] = '\0'; char date[81]; if (fread(date, 1, 80, fp)!= 1) { fprintf(stderr,"fread_37 failed in ReadSTP3.cpp"); } date[80] = '\0'; uint32_t serial_num; if (fread(&serial_num,sizeof(serial_num), 1, fp)!=sizeof(serial_num)) { fprintf(stderr,"fread_38 failed in ReadSTP3.cpp"); } byteSwap(serial_num); uint32_t num_slices; if (fread(&num_slices,sizeof(num_slices), 1, fp)!=sizeof(num_slices)) { fprintf(stderr,"fread_39 failed in ReadSTP3.cpp"); } byteSwap(num_slices); vector<double *> mats, invs; uint32_t trafo_type, is_axial; // read transformation for each slice for(int i = 0; i < num_slices; i++) { fseek(fp, block_len * (i+1) + ser_head_len, SEEK_SET); if (fread(&trafo_type,sizeof(trafo_type), 1, fp)!=sizeof(trafo_type)) { fprintf(stderr,"fread_40 failed in ReadSTP3.cpp"); } byteSwap(trafo_type); uint32_t calculated; if (fread(&calculated,sizeof(calculated), 1, fp)!=sizeof(calculated)) { fprintf(stderr,"fread_41 failed in ReadSTP3.cpp"); } byteSwap(calculated); if (fread(&is_axial,sizeof(is_axial), 1, fp)!=sizeof(is_axial)) { fprintf(stderr,"fread_42 failed in ReadSTP3.cpp"); } byteSwap(is_axial); double marker[12][2]; if (fread(marker,sizeof(marker), 1, fp)!=sizeof(marker)) { fprintf(stderr,"fread_43 failed in ReadSTP3.cpp"); } double plate[16][2]; if (fread(plate,sizeof(plate), 1, fp)!=sizeof(plate)) { fprintf(stderr,"fread_44 failed in ReadSTP3.cpp"); } uint32_t missing; if (fread(&missing,sizeof(missing), 1, fp)!=sizeof(missing)) { fprintf(stderr,"fread_45 failed in ReadSTP3.cpp"); } byteSwap(missing); double *m= new double[16]; if (fread(m,sizeof(*m)*16, 1, fp)!=sizeof(*m)*16) { fprintf(stderr,"fread_46 failed in ReadSTP3.cpp"); } byteSwapM(m, 16); mats.push_back(m); m = new double[16]; if (fread(m,sizeof(*m)*16, 1, fp)!=sizeof(*m)*16) { fprintf(stderr,"fread_47 failed in ReadSTP3.cpp"); } byteSwapM(m, 16); invs.push_back(m); } fclose(fp); memcpy(mat, mats[num_slices/2],sizeof(double)*16); memcpy(inv, invs[num_slices/2],sizeof(double)*16); for(int i=0; i<mats.size(); i++) { delete[] mats[i]; delete[] invs[i]; } return 0; #endif struct patient_struct patient; strcpy(patient.Tra_File, filename); patient.Resolution = resolution; patient.No_Slices = num_slices; patient.Pixel_size = pixel_size; for (int i = 0; i < num_slices; i++) { patient.Z_Table[i] = slice_z[i]; } QString result; int ret = read_ct_tran(&patient, &result); memcpy(mat, &patient.Global_Tra_Matrix[0][0], sizeof(double) * 16); memcpy(inv, &patient.Rev_Global_Tra_Matrix[0][0], sizeof(double) * 16); mat[14] -= 100.; //inv[14] += 100.; cerr << result.latin1() << endl; return ret; }
void cTextField::onKeyDown(QKeyEvent *e) { int key = e->key(); Qt::ButtonState state = e->state(); // Handle special chars if (key == Qt::Key_Backspace) { // Replace the selection with an empty string if (selection_ != 0) { replaceSelection(""); } else if (caret_ > 0) { setCaret(caret_ - 1); text_.remove(caret_, 1); invalidateText(); } } else if (key == Qt::Key_Delete) { if (selection_ != 0) { replaceSelection(""); } else if (caret_ < text_.length()) { text_.remove(caret_, 1); invalidateText(); } } else if (key == Qt::Key_Left) { if (caret_ > 0) { setCaret(caret_ - 1); if ((state & Qt::ShiftButton) != 0) { selection_++; invalidateText(); } else { if (selection_ != 0) { selection_ = 0; invalidateText(); } } } } else if (key == Qt::Key_Right) { if (caret_ < text_.length()) { setCaret(caret_ + 1); if ((state & Qt::ShiftButton) != 0) { selection_--; invalidateText(); } else { if (selection_ != 0) { selection_ = 0; invalidateText(); } } } } else if (key == Qt::Key_V && (state & Qt::ControlButton) != 0) { QClipboard *clipboard = qApp->clipboard(); QString text = clipboard->text(); if (!text.isEmpty()) { QCString ltext = text.latin1(); replaceSelection(ltext); } } else if (key == Qt::Key_C && (state & Qt::ControlButton) != 0) { QClipboard *clipboard = qApp->clipboard(); QCString text = getSelection(); if (!text.isEmpty()) { clipboard->setText(QString(text), QClipboard::Clipboard); } } else if (key == Qt::Key_X && (state & Qt::ControlButton) != 0) { QClipboard *clipboard = qApp->clipboard(); QCString text = getSelection(); if (!text.isEmpty()) { clipboard->setText(QString(text), QClipboard::Clipboard); replaceSelection(""); } } else if (key == Qt::Key_Return) { onEnter(); } else if (key == Qt::Key_Home) { int oldCaret = caret_; selection_ = 0; setCaret(0); invalidateText(); /*if (key.mod & KMOD_SHIFT) { selection_--; invalidateText(); } else { if (selection_ != 0) { selection_ = 0; invalidateText(); } }*/ } else if (key == Qt::Key_End) { setCaret(text_.length()); selection_ = 0; invalidateText(); } else if (text_.length() < maxLength_) { char ch = e->text().at(0).latin1(); // Check if the character is supported by the current font. if (ch != 0) { cSurface *chs = AsciiFonts->getCharacter(font_, ch); if (chs) { QCString replacement; replacement.insert(0, ch); replaceSelection(replacement); } } } }
int main(int argc, char *argv[]) { if (argc > 1) { QApplication application(argc, argv, FALSE); QString databaseURL; QString username; QString passwd; QString arguments; for (int counter = 1; counter < argc; counter++) { arguments = argv[counter]; if (arguments.contains("-databaseURL=")) databaseURL = arguments.right(arguments.length() - 13); else if (arguments.contains("-username="******"-passwd=")) passwd = arguments.right(arguments.length() - 8); } if ( (databaseURL != "") && (username != "") ) { QSqlDatabase *db; QString hostName; QString dbName; QString port; // Open the Database Driver db = QSqlDatabase::addDatabase("QPSQL7"); if (!db) { printf("Could not load the specified database driver.\n"); exit(-1); } // Try to connect to the Database parseDatabaseURL(databaseURL, hostName, dbName, port); bool valport = FALSE; int iport = port.toInt(&valport); if(!valport) iport = 5432; db->setDatabaseName(dbName); db->setPort(iport); db->setUserName(username); if(!passwd.isEmpty()) db->setPassword(passwd); db->setHostName(hostName); if (!db->open()) { printf( "Host=%s, Database=%s, port=%s\n", (const char *)hostName, (const char *)dbName, (const char *)port ); printf( "Could not log into database. System Error: %s\n", (const char *)db->lastError().driverText() ); exit(-1); } QSqlQuery().exec("SELECT login();"); // first we need to determine if there is already a report in the database of the same // name and if so then we will perform an update instead of an insert QSqlQuery qry; qry.prepare("SELECT report_name, report_grade, report_source " " FROM report;"); qry.exec(); if(!qry.exec()) { QSqlError err = qry.lastError(); printf("Error: %s\n\t%s\n", (const char*)err.driverText(), (const char*)err.databaseText()); exit(-1); } QString fname; while(qry.next()) { fname = QString("%1-%2.xml").arg(qry.value(0).toString()).arg(qry.value(1).toString()); fname.replace('/',"-"); QFile file(fname); if(file.open(IO_WriteOnly)) { QTextStream stream( &file ); stream << qry.value(2).toString(); file.close(); } else printf("Error: Could not open file %s: %s\n", fname.latin1(), file.errorString().latin1()); } } else if (databaseURL == "") printf("You must specify a Database URL by using the -databaseURL= parameter.\n"); else if (username == "") printf("You must specify a Database Username by using the -username= parameter.\n"); } else printf( "Usage: exportrpt -databaseURL='$' -username='******' -passwd='$'\n"); return 0; }
bool OPCodeXmlContentHandler::startElement(const QString&, const QString&, const QString& name, const QXmlAttributes& attr) { if (name == "opcode") { bool ok = false; // get the index of the id attribute int index = attr.index("id"); if (index == -1) { seqWarn("OPCodeXmlContentHandler::startElement(): opcode element without id!"); return false; // this is an error, something is wrong } // the id attribute is the opcode value uint16_t opcode = attr.value(index).toUShort(&ok, 16); #if 0 // ZBTEMP opcode += 2; #endif if (!ok) { seqWarn("OPCodeXmlContentHandler::startElement(): opcode '%s' failed to convert to uint16_t (result: %#04x)", attr.value(index).latin1(), opcode); return false; // this is an error } // get the index of the name attribute index = attr.index("name"); // if name attribute was found, set the opcode objects name if (index == -1) { seqWarn("OPCodeXmlContentHandler::startElement(): opcode %#04x missing name parameter!", opcode); return false; } // add/create the new opcode object m_currentOPCode = m_opcodeDB.add(opcode, attr.value(index)); if (!m_currentOPCode) { seqWarn("Failed to add opcode %04x", opcode); return false; } // get the index of the updated attribute index = attr.index("updated"); // if the updated attribute was found, set the objects updated field if (index != -1) m_currentOPCode->setUpdated(attr.value(index)); // get the index of the implicitlen attribute index = attr.index("implicitlen"); // if implicitlen attribute was found, set the objects implicitLen field if (index != -1) m_currentOPCode->setImplicitLen(attr.value(index).toUShort()); return true; } if ((name == "comment") && (m_currentOPCode)) { // clear any current comment m_currentComment = ""; m_inComment = true; return true; } if ((name == "payload") && (m_currentOPCode)) { // create a new payload object and make it the current one m_currentPayload = new EQPacketPayload(); // add the payload object to the opcode m_currentOPCode->append(m_currentPayload); // check for direction attribute int index = attr.index("dir"); // if an index attribute exists, then use it if (index != -1) { QString value = attr.value(index); if (value == "both") m_currentPayload->setDir(DIR_Client | DIR_Server); else if (value == "server") m_currentPayload->setDir(DIR_Server); else if (value == "client") m_currentPayload->setDir(DIR_Client); } // get the typename attribute index = attr.index("typename"); // if a typename attribute exist, then set the payload type if (index != -1) { QString value = attr.value(index); if (!value.isEmpty()) { if (!m_currentPayload->setType(m_typeDB, value)) seqWarn("Unknown payload typename '%s' for opcode '%04x'", value.latin1(), m_currentOPCode->opcode()); } } // attempt to retrieve the sizechecktype index = attr.index("sizechecktype"); // if a sizechecktype exists, then set the payload size check type if (index != -1) { QString value = attr.value(index); if (value.isEmpty() || (value == "none")) m_currentPayload->setSizeCheckType(SZC_None); else if (value == "match") m_currentPayload->setSizeCheckType(SZC_Match); else if (value == "modulus") m_currentPayload->setSizeCheckType(SZC_Modulus); } return true; } return true; }
/** * Parses the output of a Cscope process. * Implements a state machine, where states correspond to the output of the * controlled Cscope process. * @param sToken The current token read (the token delimiter is determined * by the current state) * @return A value indicating the way this token should be treated: dropped, * added to the token queue, or finishes a new record */ Frontend::ParseResult GrepFrontend::parseStdout(QString& sToken, ParserDelim /* ignored */) { qDebug() << "Frontend::ParseResult \n"; int nFiles, nTotal, nRecords; ParseResult result = DiscardToken; ParserState stPrev; #if 0 // Remember previous state stPrev = m_state; // Handle the token according to the current state switch (m_state) { case BuildStart: if (sToken == "Building cross-reference...") { m_state = BuildSymbol; m_delim = WSpace; } else if (sToken == "Building inverted index...") { emit buildInvIndex(); } result = DiscardToken; break; case BuildSymbol: // A single angle bracket is the prefix of a progress indication, // while double brackets is Cscope's prompt for a new query if (sToken == ">") { m_state = Building; m_delim = Newline; } result = DiscardToken; break; case Building: // Try to get building progress if (sscanf(sToken.latin1(), BUILD_STR, &nFiles, &nTotal) == 2) { emit progress(nFiles, nTotal); // Check for last progress message if (nFiles == nTotal) { m_state = BuildStart; m_delim = Newline; result = DiscardToken; break; } } // Wait for another progress line or the "ready" symbol m_state = BuildSymbol; m_delim = WSpace; result = DiscardToken; break; case SearchSymbol: // Check for more search progress, or the end of the search, // designated by a line in the format of "cscope: X lines" if (sToken == ">") { m_state = Searching; m_delim = Newline; result = DiscardToken; break; } else if (sToken == "cscope:") { m_state = SearchEnd; m_delim = Newline; result = DiscardToken; break; } case File: // Is this the first entry? If so, signal that the query is complete if (stPrev != LineText) emit progress(1, 1); // Treat the token as the name of the file in this record m_state = Func; result = AcceptToken; break; case Searching: // Try to get the search progress value (ignore other messages) if ((sscanf(sToken.latin1(), SEARCH_STR, &nFiles, &nTotal) == 2) || (sscanf(sToken.latin1(), INV_STR, &nFiles, &nTotal) == 2) || (sscanf(sToken.latin1(), REGEXP_STR, &nFiles, &nTotal) == 2)) { emit progress(nFiles, nTotal); } m_state = SearchSymbol; m_delim = WSpace; result = DiscardToken; break; case SearchEnd: // Get the number of results found in this search if ((sscanf(sToken.latin1(), SEARCHEND_STR, &nRecords) == 1) && (m_nMaxRecords > 0) && (nRecords > m_nMaxRecords)) { result = Abort; } else { m_state = File; m_delim = WSpace; result = DiscardToken; } break; case Func: // Treat the token as the name of the function in this record if (sToken.toInt()) { // In case of a global definition, there is no function name, and // instead the line number is given immediately m_state = LineText; m_delim = Newline; } else { // Not a number, it is the name of the function m_state = Line; } result = AcceptToken; break; case Line: // Treat the token as the line number in this record m_state = LineText; m_delim = Newline; result = AcceptToken; break; case LineText: // Treat the token as the text of this record, and report a new // record m_state = File; m_delim = WSpace; result = RecordReady; break; default: // Do nothing (prevents a compilation warning for unused enum values) break; } #endif return result; }
/** * now we will send the file. * * we request an fd. The IOLayer should be closed * then we will setup a pipe for progress communication * then we will dup2 the m_fd in the forked process * to do direct IO from and to the fd */ void FileTransfer::sendFile( const QString& file ) { m_prog =-1; m_fd = layer()->rawIO(); // // m_fd = ::open("/dev/ttyS0", O_RDWR); m_file = file; if ( pipe( m_comm ) < 0 ) m_comm[0] = m_comm[1] = 0; if ( pipe( m_info ) < 0 ) m_info[0] = m_info[1] = 0; m_pid = fork(); switch( m_pid ) { case -1: emit error( StartError, tr("Was not able to fork") ); slotExec(); break; case 0:{ setupChild(); /* exec */ char* verbose = "-vv"; char* binray = "-b"; char* typus; switch(m_type ) { default: case SZ: typus = ""; break; case SX: typus = "-X"; break; case SY: typus = "--ymodem"; break; } /* we should never return from here */ execlp("sz", "sz", verbose, binray, file.latin1(), typus, NULL ); /* communication for error!*/ char resultByte =1; if (m_info[1] ) write(m_info[1], &resultByte, 1 ); _exit( -1 ); break; } default:{ if ( m_info[1] ) close( m_info[1] ); if ( m_info[0] ) for (;;) { char resultByte; int len; len = read(m_info[0], &resultByte, 1 ); /* len == 1 start up failed */ if ( len == 1 ) { emit error( StartError, tr("Could not start") ); return; } if ( len == -1 ) if ( (errno == ECHILD ) || (errno == EINTR ) ) continue; // len == 0 or something like this break; } if ( m_info[0] ) close( m_info[0] ); /* replace by QSocketNotifier!!! */ m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read ); connect(m_not, SIGNAL(activated(int) ), this, SLOT(slotRead() ) ); if ( pipe(m_term) < 0 ) m_term[0] = m_term[1] = 0; ProcCtl::self()->add(m_pid, m_term[1] ); m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read ); connect(m_proc, SIGNAL(activated(int) ), this, SLOT(slotExec() ) ); } break; } }
/** read the project file. The semantic net and the image description*/ void Analysis::readProject(QString fname) { #if 0 qDebug("Analysis::readProject: file: %s", (const char *) fname); QFile fp(fname); if (!fp.open(IO_ReadOnly)) { emit message(QString(). sprintf("Project %s not found", (const char *) fname)); qDebug("GeoImageList::read(%s): file not founed", (const char *) fname); return; } // if (geoImageList_) delete geoImageList_; // geoImageList_ = new GeoImageList; MLParser parser(&fp); QString keywords[] = { "geoproject", "geosemnet", "geoimagelist", "geoinstancenet", "" }; enum { TOK_GEOPROJECT = 1, TOK_GEOSEMNET, TOK_GEOIMAGELIST, TOK_GEOINSTANCENET }; const MLTagTable nodeTagTable(keywords); int tag, flag = 0; do { tag = parser.tag(nodeTagTable); switch (tag) { case TOK_GEOPROJECT:{ flag = 1; break; } case TOK_GEOSEMNET:{ if (flag == 1) { ArgDict *args = parser.args(); QString dir = "", netfile = ""; MLParser::setString(netfile, args, "file"); //read tempor. MLParser::setString(dir, args, "dir"); //read tempor. dir += "/" + netfile; readSemNet(netfile); delete args; } break; } case TOK_GEOIMAGELIST:{ if (flag == 1) { geoImageList_.read(parser); } break; } case TOK_GEOINSTANCENET:{ if (flag == 1) { ArgDict *args = parser.args(); QString dir = "", netfile = ""; QString map = ""; MLParser::setString(netfile, args, "file"); //read tempor. MLParser::setString(dir, args, "dir"); //read tempor. MLParser::setString(map, args, "dir"); //read tempor. dir += "/" + netfile; readInstanceNet(netfile); qDebug("Analysis::readProject: map=%s", map.latin1()); delete args; } break; } default:{ ArgDict *args = parser.args(); delete args; break; } } } while ((tag != MLParser::END_OF_FILE) && (tag != -TOK_GEOPROJECT)); fp.close(); #endif }
void FLPosPrinter::flush() { if (!file) initFile(); QString fileName(AQ_DISKCACHE_DIRPATH + "/outposprinter.tmp"); for (int i = 0; i < idxBuffer; i++) { if (escBuffer && escBuffer->contains(i)) { const QString &esc = (*escBuffer)[i]; for (int j = 0; j < esc.length(); j++) file->putch(esc[j]); } if (strBuffer && strBuffer->contains(i)) file->putch((*strBuffer)[i]); } file->flush(); file->close(); if (printerName_.isNull()) printerName_ = "localhost:tpv"; int posdots = printerName_.find(":"); QString server = printerName_.left(posdots); QString name = printerName_.right(printerName_.length() - posdots - 1); #ifdef AQ_LPR_EXTERNAL QProcess *proc = new QProcess(); proc->addArgument("lpr.exe"); proc->addArgument("-S"); proc->addArgument(server); proc->addArgument("-P"); proc->addArgument(name); proc->addArgument("-o"); proc->addArgument("l"); proc->addArgument(fileName); if (!proc->start()) qWarning("FLPosPrinter::flush() : Error escribiendo en impresora " + printerName_); while (proc->isRunning()) qApp->processEvents(); qApp->processEvents(); if (proc) delete proc; #else int optc = 6; char *optv[optc]; optv[0] = (char *) "-H"; optv[1] = (char *) server.latin1(); optv[2] = (char *) "-P"; optv[3] = (char *) name.latin1(); optv[4] = (char *) "-l"; optv[5] = (char *) fileName.latin1(); if (lpr_main(optc, optv) != 0) qWarning("FLPosPrinter::flush() : Error escribiendo en impresora /usr/bin/lpr -P " + printerName_); #endif }
/*! Sets the name of the cursor to \a name. If \a autopopulate is true (the default), the \a name must correspond to a valid table or view name in the database. Also, note that all references to the cursor edit buffer become invalidated when fields are auto-populated. See the Q3SqlCursor constructor documentation for more information. */ void Q3SqlCursor::setName(const QString& name, bool autopopulate) { d->nm = name; if (autopopulate) { if (driver()) { d->infoBuffer = driver()->record(name); *this = d->infoBuffer.toRecord(); d->editBuffer = *this; d->priIndx = driver()->primaryIndex(name); } if (isEmpty()) qWarning("Q3SqlCursor::setName: unable to build record, does '%s' exist?", name.latin1()); } }
void testAssert(bool result, const QString& text = "Unknown") { if (!result) { KstTestFailed(); printf("Test [%s] failed.\n", text.latin1()); } }
/** No descriptions */ bool MoTranslator::loadMoFile(QString filename,const char* context) { int max_len = 0; int word_size; bool big_endian; char* orig_string = 0; char* trans_string; Q_UINT32 magic_number; qint32 file_revision; qint32 string_number; qint32 original_offset; qint32 translation_offset; QFile mofile(filename); if(!qSysInfo(&word_size,&big_endian)) return false; if(mofile.open(IO_ReadOnly) == false) return false; QDataStream ds(&mofile); //read magic number ds >> magic_number; if(magic_number == 0xde120495) { //The file has been saved in reversed byte order in comparison //to this machine. //If this machines byte order is big endian, than the files //byte order is little endian and vice versa. qDebug("Reverse mo file byte order."); if(big_endian == true) { ds.setByteOrder(QDataStream::BigEndian); } else { ds.setByteOrder(QDataStream::LittleEndian); } } else if(magic_number != 0x950412de) { //wrong file format mofile.close(); qDebug("mo file has wrong magic number."); return false; } //read file revision ds >> file_revision; if(file_revision != 0) { //wrong file format mofile.close(); qDebug("Wrong mo file revision."); return false; } //read number of strings ds >> string_number; //read offset to original strings ds >> original_offset; //read offset to translation strings ds >> translation_offset; //We do not use the hash table; in fact, a mo file isn't required to contain a hash //table at all. qDebug("string number: %u",string_number); qDebug("orig offset: %u",original_offset); qDebug("trans offset: %u",translation_offset); QVector<qint32> orig_table(string_number*2); QVector<qint32> trans_table(string_number*2); //read original table if(ds.device()->at(original_offset)) { for(qint32 i=0;i<string_number;i++) { ds >> orig_table[i*2]; ds >> orig_table[i*2+1]; if(orig_table[i*2] > max_len) max_len = orig_table[i*2]; } } //read translation table if(ds.device()->at(translation_offset)) { for(qint32 i=0;i<string_number;i++) { ds >> trans_table[i*2]; ds >> trans_table[i*2+1]; if(trans_table[i*2] > max_len) max_len = trans_table[i*2]; } } QString trans; orig_string = new char [max_len+10]; trans_string = new char [max_len+10]; for(int i=0;i<string_number;i++) { if(ds.device()->at(orig_table[i*2+1])) { ds.readRawBytes(orig_string,orig_table[i*2]+1); qDebug("orig: %s",orig_string); } if(ds.device()->at(trans_table[i*2+1])) { ds.readRawBytes(trans_string,trans_table[i*2]+1); trans = QString::fromUtf8(trans_string); qDebug("trans: %s",trans.latin1()); } QTranslatorMessage tm(context,orig_string,0,trans); insert(tm); } delete [] orig_string; delete [] trans_string; mofile.close(); squeeze(Stripped); return true; }