size_t FileRequest::ParseHeader(void *header, size_t size, size_t length, void *ptr) { FileRequest *us = reinterpret_cast<FileRequest *>(ptr); BString headerStr((char *)header, length); int32 colon = headerStr.IFindFirst(":"); if (colon != B_ERROR) { BString value(headerStr); headerStr.Truncate(colon); value.Remove(0, colon + 2); if (headerStr.ICompare("Content-Length") == 0) { value.IReplaceAll("\r", ""); value.IReplaceAll("\n", ""); value.IReplaceAll(" ", ""); us->fExpectedSize = atol(value.String()); }; if (headerStr.ICompare("Content-Type") == 0) { value.IReplaceAll("\r", ""); value.IReplaceAll("\n", ""); value.IReplaceAll(" ", ""); us->fMIME = value; }; }; return size * length; };
SlmUi::SlmUi(QWidget* _uiPanel) { ztpm = new ZTPManager(3320,QHostAddress("224.102.228.40")); connect(ztpm,SIGNAL(readyRead()),this,SLOT(procNetPkg())); int table_w = 260; int table_h = 350; table1 = new QTableWidget(0,2,_uiPanel); table1->resize(table_w,table_h); QString headerStr("slm1,slm2"); table1->setHorizontalHeaderLabels(headerStr.split(QChar(','))); QRect rect = table1->geometry(); rect.setLeft(_uiPanel->size().width()/2- 20 -table_w); rect.setTop((_uiPanel->size().height() - table_h)/3); rect.setWidth(table_w); rect.setHeight(table_h); table1->setGeometry(rect); table2 = new QTableWidget(0,2,_uiPanel); table2->setHorizontalHeaderLabels(headerStr.split(QChar(','))); rect.setLeft(_uiPanel->size().width()/2+ 20); rect.setWidth(table_w); rect.setHeight(table_h); table2->setGeometry(rect); table1->horizontalHeader()->setResizeMode(QHeaderView::Stretch); table2->horizontalHeader()->setResizeMode(QHeaderView::Stretch); }
// ----------------------------------------------------------------------------- // CHttpCacheManager::VSSRequestCheck // // ----------------------------------------------------------------------------- // TBool CHttpCacheManager::VSSRequestCheckL( const RHTTPTransaction& aTrans, const RHTTPHeaders& aHttpHeader, const TDesC8& aUrl ) { TBool VSSTransaction ( EFalse ); if ( iVSSCacheEnabled && HttpCacheUtil::VSSCacheContent( aUrl, iVSSWhiteList ) ) { RStringPool strP = aTrans.Session().StringPool(); #ifdef __CACHELOG__ RHTTPHeaders headers ( aHttpHeader ); HBufC8* responseHeaderStr8 = HttpCacheUtil::HeadersToBufferLC( headers, strP ); HBufC* responseHeaderStr; if( responseHeaderStr8 ) { responseHeaderStr = HBufC::NewL( responseHeaderStr8->Length() ); responseHeaderStr->Des().Copy( responseHeaderStr8->Des() ); CleanupStack::PopAndDestroy(); // responseHeaderStr8; TPtrC headerStr( responseHeaderStr->Des() ); HttpCacheUtil::WriteLog( 0, _L("========== VSS Header Start =========\n") ); HttpCacheUtil::WriteLog( 0, responseHeaderStr->Des() ); HttpCacheUtil::WriteLog( 0, _L("========== VSS Header End =========\n") ); delete responseHeaderStr; } #endif TPtrC8 nameStr ( KVSSHeaderFieldName() ); RStringF VSSnameStr = strP.OpenFStringL( nameStr ); CleanupClosePushL<RStringF>( VSSnameStr); THTTPHdrVal tempVal; if ( aHttpHeader.GetField( VSSnameStr, 0, tempVal ) == KErrNone ) { TPtrC8 valueStr ( KVSSHeaderFieldValue() ); RStringF VSSValueStr = strP.OpenFStringL( valueStr ); CleanupClosePushL<RStringF>( VSSValueStr ); if ( tempVal == VSSValueStr ) { VSSTransaction = ETrue; } CleanupStack::PopAndDestroy(); // VSSValueStr } CleanupStack::PopAndDestroy(); // VSSnameStr } //end if( iVSSCacheEnabled && HttpCacheUtil::VSSCacheContent( aUrl, iVSSWhiteList ) ) return VSSTransaction; }
bool FormClassWizardParameters::generateCpp(QString *header, QString *source, int indentation) const { const QString indent = QString(indentation, QLatin1Char(' ')); QString formBaseClass; QString uiClassName; if (!FormTemplateWizardPage::getUIXmlData(uiTemplate, &formBaseClass, &uiClassName)) { qWarning("Unable to determine the form base class from %s.", uiTemplate.toUtf8().constData()); return false; } // Build the ui class (Ui::Foo) name relative to the namespace (which is the same): const QString colonColon = QLatin1String("::"); const int lastSeparator = uiClassName.lastIndexOf(colonColon); if (lastSeparator != -1) uiClassName.remove(0, lastSeparator + colonColon.size()); uiClassName.insert(0, QLatin1String(uiNamespaceC) + colonColon); // Do we have namespaces? QStringList namespaceList = className.split(colonColon); if (namespaceList.empty()) // Paranoia! return false; const QString unqualifiedClassName = namespaceList.takeLast(); // Include guards const QString guard = Core::Utils::headerGuard(unqualifiedClassName); QString uiInclude = QLatin1String("ui_"); uiInclude += QFileInfo(uiFile).baseName(); uiInclude += QLatin1String(".h"); // 1) Header file QTextStream headerStr(header); headerStr << "#ifndef " << guard << "\n#define " << guard << '\n' << '\n'; // Include 'ui_' if (embedding != PointerAggregatedUiClass) { Core::Utils::writeIncludeFileDirective(uiInclude, false, headerStr); } else { // Todo: Can we obtain the header from the code model for custom widgets? // Alternatively, from Designer. if (formBaseClass.startsWith(QLatin1Char('Q'))) { QString baseInclude = QLatin1String("QtGui/"); baseInclude += formBaseClass; Core::Utils::writeIncludeFileDirective(baseInclude, true, headerStr); } } const QString namespaceIndent = Core::Utils::writeOpeningNameSpaces(namespaceList, indent, headerStr); // Forward-declare the UI class if (embedding == PointerAggregatedUiClass) { headerStr << '\n' << namespaceIndent << "namespace " << uiNamespaceC << " {\n" << namespaceIndent << indent << "class " << FormTemplateWizardPage::stripNamespaces(uiClassName) << ";\n" << namespaceIndent << "}\n"; } // Class declaration headerStr << '\n' << namespaceIndent << "class " << unqualifiedClassName << " : public " << formBaseClass; if (embedding == InheritedUiClass) { headerStr << ", private " << uiClassName; } headerStr << " {\n" << namespaceIndent << indent << "Q_OBJECT\n" << namespaceIndent << indent << "Q_DISABLE_COPY(" << unqualifiedClassName << ")\n" << namespaceIndent << "public:\n" << namespaceIndent << indent << "explicit " << unqualifiedClassName << "(QWidget *parent = 0);\n"; if (embedding == PointerAggregatedUiClass) headerStr << namespaceIndent << indent << "virtual ~" << unqualifiedClassName << "();\n"; // retranslation if (languageChange) headerStr << '\n' << namespaceIndent << "protected:\n" << namespaceIndent << indent << "virtual void changeEvent(QEvent *e);\n"; // Member variable if (embedding != InheritedUiClass) { headerStr << '\n' << namespaceIndent << "private:\n" << namespaceIndent << indent << uiClassName << ' '; if (embedding == PointerAggregatedUiClass) headerStr << '*'; headerStr << uiMemberC << ";\n"; } headerStr << namespaceIndent << "};\n\n"; Core::Utils::writeClosingNameSpaces(namespaceList, indent, headerStr); headerStr << "#endif // "<< guard << '\n'; // 2) Source file QTextStream sourceStr(source); Core::Utils::writeIncludeFileDirective(headerFile, false, sourceStr); if (embedding == PointerAggregatedUiClass) Core::Utils::writeIncludeFileDirective(uiInclude, false, sourceStr); // NameSpaces( Core::Utils::writeOpeningNameSpaces(namespaceList, indent, sourceStr); // Constructor with setupUi sourceStr << '\n' << namespaceIndent << unqualifiedClassName << "::" << unqualifiedClassName << "(QWidget *parent) :\n" << namespaceIndent << indent << formBaseClass << "(parent)"; if (embedding == PointerAggregatedUiClass) sourceStr << ",\n" << namespaceIndent << indent << uiMemberC << "(new " << uiClassName << ")\n"; sourceStr << namespaceIndent << "{\n" << namespaceIndent << indent; if (embedding != InheritedUiClass) sourceStr << uiMemberC << (embedding == PointerAggregatedUiClass ? "->" : "."); sourceStr << "setupUi(this);\n" << namespaceIndent << "}\n"; // Deleting destructor for ptr if (embedding == PointerAggregatedUiClass) { sourceStr << '\n' << namespaceIndent << unqualifiedClassName << "::~" << unqualifiedClassName << "()\n" << namespaceIndent << "{\n" << namespaceIndent << indent << "delete " << uiMemberC << ";\n" << namespaceIndent << "}\n"; } // retranslation if (languageChange) { sourceStr << '\n' << namespaceIndent << "void " << unqualifiedClassName << "::" << "changeEvent(QEvent *e)\n" << namespaceIndent << "{\n" << namespaceIndent << indent << "switch (e->type()) {\n" << namespaceIndent << indent << "case QEvent::LanguageChange:\n" << namespaceIndent << indent << indent; if (embedding != InheritedUiClass) sourceStr << uiMemberC << (embedding == PointerAggregatedUiClass ? "->" : "."); sourceStr << "retranslateUi(this);\n" << namespaceIndent << indent << indent << "break;\n" << namespaceIndent << indent << "default:\n" << namespaceIndent << indent << indent << "break;\n" << namespaceIndent << indent << "}\n" << namespaceIndent << "}\n"; } Core::Utils::writeClosingNameSpaces(namespaceList, indent, sourceStr); return true; }
bool QtDesignerFormClassCodeGenerator::generateCpp(const FormClassWizardParameters ¶meters, QString *header, QString *source, int indentation) { Internal::FormClassWizardGenerationParameters generationParameters; generationParameters.fromSettings(Core::ICore::settings()); const QString indent = QString(indentation, QLatin1Char(' ')); QString formBaseClass; QString uiClassName; if (!Internal::FormTemplateWizardPage::getUIXmlData(parameters.uiTemplate, &formBaseClass, &uiClassName)) { qWarning("Unable to determine the form base class from %s.", qPrintable(parameters.uiTemplate)); return false; } // Build the ui class (Ui::Foo) name relative to the namespace (which is the same): const QString colonColon = QLatin1String("::"); const int lastSeparator = uiClassName.lastIndexOf(colonColon); if (lastSeparator != -1) uiClassName.remove(0, lastSeparator + colonColon.size()); uiClassName.insert(0, QLatin1String(uiNamespaceC) + colonColon); // Do we have namespaces? QStringList namespaceList = parameters.className.split(colonColon); if (namespaceList.empty()) // Paranoia! return false; const QString unqualifiedClassName = namespaceList.takeLast(); const QString headerLicense = CppTools::AbstractEditorSupport::licenseTemplate(parameters.headerFile, parameters.className); const QString sourceLicense = CppTools::AbstractEditorSupport::licenseTemplate(parameters.sourceFile, parameters.className); // Include guards const QString guard = Utils::headerGuard(parameters.headerFile, namespaceList); QString uiInclude = QLatin1String("ui_"); uiInclude += QFileInfo(parameters.uiFile).completeBaseName(); uiInclude += QLatin1String(".h"); // 1) Header file QTextStream headerStr(header); headerStr << headerLicense << "#ifndef " << guard << "\n#define " << guard << '\n' << '\n'; // Include 'ui_' if (generationParameters.embedding != Internal::PointerAggregatedUiClass) { Utils::writeIncludeFileDirective(uiInclude, false, headerStr); } else { // Todo: Can we obtain the header from the code model for custom widgets? // Alternatively, from Designer. if (formBaseClass.startsWith(QLatin1Char('Q'))) { if (generationParameters.includeQtModule) { if (generationParameters.addQtVersionCheck) { Utils::writeBeginQtVersionCheck(headerStr); Utils::writeIncludeFileDirective(QLatin1String("QtWidgets/") + formBaseClass, true, headerStr); headerStr << "#else\n"; Utils::writeIncludeFileDirective(QLatin1String("QtGui/") + formBaseClass, true, headerStr); headerStr << "#endif\n"; } else { Utils::writeIncludeFileDirective(QLatin1String("QtGui/") + formBaseClass, true, headerStr); } } else { Utils::writeIncludeFileDirective(formBaseClass, true, headerStr); } } } const QString namespaceIndent = Utils::writeOpeningNameSpaces(namespaceList, generationParameters.indentNamespace ? indent : QString(), headerStr); // Forward-declare the UI class if (generationParameters.embedding == Internal::PointerAggregatedUiClass) { headerStr << '\n' << namespaceIndent << "namespace " << uiNamespaceC << " {\n" << namespaceIndent << indent << "class " << Internal::FormTemplateWizardPage::stripNamespaces(uiClassName) << ";\n" << namespaceIndent << "}\n"; } // Class declaration headerStr << '\n' << namespaceIndent << "class " << unqualifiedClassName << " : public " << formBaseClass; if (generationParameters.embedding == Internal::InheritedUiClass) { headerStr << ", private " << uiClassName; } headerStr << "\n{\n" << namespaceIndent << indent << "Q_OBJECT\n\n" << namespaceIndent << "public:\n" << namespaceIndent << indent << "explicit " << unqualifiedClassName << "(QWidget *parent = 0);\n"; if (generationParameters.embedding == Internal::PointerAggregatedUiClass) headerStr << namespaceIndent << indent << "~" << unqualifiedClassName << "();\n"; // retranslation if (generationParameters.retranslationSupport) headerStr << '\n' << namespaceIndent << "protected:\n" << namespaceIndent << indent << "void changeEvent(QEvent *e);\n"; // Member variable if (generationParameters.embedding != Internal::InheritedUiClass) { headerStr << '\n' << namespaceIndent << "private:\n" << namespaceIndent << indent << uiClassName << ' '; if (generationParameters.embedding == Internal::PointerAggregatedUiClass) headerStr << '*'; headerStr << uiMemberC << ";\n"; } headerStr << namespaceIndent << "};\n\n"; Utils::writeClosingNameSpaces(namespaceList, generationParameters.indentNamespace ? indent : QString(), headerStr); headerStr << "#endif // "<< guard << '\n'; // 2) Source file QTextStream sourceStr(source); sourceStr << sourceLicense; Utils::writeIncludeFileDirective(parameters.headerFile, false, sourceStr); if (generationParameters.embedding == Internal::PointerAggregatedUiClass) Utils::writeIncludeFileDirective(uiInclude, false, sourceStr); // NameSpaces( Utils::writeOpeningNameSpaces(namespaceList, generationParameters.indentNamespace ? indent : QString(), sourceStr); // Constructor with setupUi sourceStr << '\n' << namespaceIndent << unqualifiedClassName << "::" << unqualifiedClassName << "(QWidget *parent) :\n" << namespaceIndent << indent << formBaseClass << "(parent)"; if (generationParameters.embedding == Internal::PointerAggregatedUiClass) sourceStr << ",\n" << namespaceIndent << indent << uiMemberC << "(new " << uiClassName << ")"; sourceStr << '\n' << namespaceIndent << "{\n" << namespaceIndent << indent; writeUiMemberAccess(generationParameters, sourceStr); sourceStr << "setupUi(this);\n" << namespaceIndent << "}\n"; // Deleting destructor for ptr if (generationParameters.embedding == Internal::PointerAggregatedUiClass) { sourceStr << '\n' << namespaceIndent << unqualifiedClassName << "::~" << unqualifiedClassName << "()\n" << namespaceIndent << "{\n" << namespaceIndent << indent << "delete " << uiMemberC << ";\n" << namespaceIndent << "}\n"; } // retranslation if (generationParameters.retranslationSupport) { sourceStr << '\n' << namespaceIndent << "void " << unqualifiedClassName << "::" << "changeEvent(QEvent *e)\n" << namespaceIndent << "{\n" << namespaceIndent << indent << formBaseClass << "::changeEvent(e);\n" << namespaceIndent << indent << "switch (e->type()) {\n" << namespaceIndent << indent << "case QEvent::LanguageChange:\n" << namespaceIndent << indent << indent; writeUiMemberAccess(generationParameters, sourceStr); sourceStr << "retranslateUi(this);\n" << namespaceIndent << indent << indent << "break;\n" << namespaceIndent << indent << "default:\n" << namespaceIndent << indent << indent << "break;\n" << namespaceIndent << indent << "}\n" << namespaceIndent << "}\n"; } Utils::writeClosingNameSpaces(namespaceList, generationParameters.indentNamespace ? indent : QString(), sourceStr); return true; }
nsresult nsMimeHtmlDisplayEmitter::BroadcastHeaders(nsIMsgHeaderSink * aHeaderSink, int32_t aHeaderMode, bool aFromNewsgroup) { // two string enumerators to pass out to the header sink nsRefPtr<nsMimeStringEnumerator> headerNameEnumerator = new nsMimeStringEnumerator(); NS_ENSURE_TRUE(headerNameEnumerator, NS_ERROR_OUT_OF_MEMORY); nsRefPtr<nsMimeStringEnumerator> headerValueEnumerator = new nsMimeStringEnumerator(); NS_ENSURE_TRUE(headerValueEnumerator, NS_ERROR_OUT_OF_MEMORY); nsCString extraExpandedHeaders; nsTArray<nsCString> extraExpandedHeadersArray; nsAutoCString convertedDateString; nsresult rv; nsCOMPtr<nsIPrefBranch> pPrefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv)); if (pPrefBranch) { pPrefBranch->GetCharPref("mailnews.headers.extraExpandedHeaders", getter_Copies(extraExpandedHeaders)); // todo - should make this upper case if (!extraExpandedHeaders.IsEmpty()) { ToLowerCase(extraExpandedHeaders); ParseString(extraExpandedHeaders, ' ', extraExpandedHeadersArray); } } for (int32_t i=0; i<mHeaderArray->Count(); i++) { headerInfoType * headerInfo = (headerInfoType *) mHeaderArray->ElementAt(i); if ( (!headerInfo) || (!headerInfo->name) || (!(*headerInfo->name)) || (!headerInfo->value) || (!(*headerInfo->value))) continue; const char * headerValue = headerInfo->value; // optimization: if we aren't in view all header view mode, we only show a small set of the total # of headers. // don't waste time sending those out to the UI since the UI is going to ignore them anyway. if (aHeaderMode != VIEW_ALL_HEADERS && (mFormat != nsMimeOutput::nsMimeMessageFilterSniffer)) { nsDependentCString headerStr(headerInfo->name); if (PL_strcasecmp("to", headerInfo->name) && PL_strcasecmp("from", headerInfo->name) && PL_strcasecmp("cc", headerInfo->name) && PL_strcasecmp("newsgroups", headerInfo->name) && PL_strcasecmp("bcc", headerInfo->name) && PL_strcasecmp("followup-to", headerInfo->name) && PL_strcasecmp("reply-to", headerInfo->name) && PL_strcasecmp("subject", headerInfo->name) && PL_strcasecmp("organization", headerInfo->name) && PL_strcasecmp("user-agent", headerInfo->name) && PL_strcasecmp("content-base", headerInfo->name) && PL_strcasecmp("sender", headerInfo->name) && PL_strcasecmp("date", headerInfo->name) && PL_strcasecmp("x-mailer", headerInfo->name) && PL_strcasecmp("content-type", headerInfo->name) && PL_strcasecmp("message-id", headerInfo->name) && PL_strcasecmp("x-newsreader", headerInfo->name) && PL_strcasecmp("x-mimeole", headerInfo->name) && PL_strcasecmp("references", headerInfo->name) && PL_strcasecmp("in-reply-to", headerInfo->name) && PL_strcasecmp("list-post", headerInfo->name) && PL_strcasecmp("delivered-to", headerInfo->name) && // make headerStr lower case because IndexOf is case-sensitive (!extraExpandedHeadersArray.Length() || (ToLowerCase(headerStr), extraExpandedHeadersArray.IndexOf(headerStr) == extraExpandedHeadersArray.NoIndex))) continue; } headerNameEnumerator->Append(headerInfo->name); headerValueEnumerator->Append(headerValue); // Add a localized version of the date header if we encounter it. if (!PL_strcasecmp("Date", headerInfo->name)) { headerNameEnumerator->Append("X-Mozilla-LocalizedDate"); GenerateDateString(headerValue, convertedDateString, false); headerValueEnumerator->Append(convertedDateString); } } aHeaderSink->ProcessHeaders(headerNameEnumerator, headerValueEnumerator, aFromNewsgroup); return rv; }
nsresult nsMultiMixedConv::ParseHeaders(nsIChannel *aChannel, char *&aPtr, uint32_t &aLen, bool *_retval) { // NOTE: this data must be ascii. // NOTE: aPtr is NOT null terminated! nsresult rv = NS_OK; char *cursor = aPtr, *newLine = nullptr; uint32_t cursorLen = aLen; bool done = false; uint32_t lineFeedIncrement = 1; // We only create an nsHttpResponseHead for packaged app channels // It may already be initialized, from a previous call of ParseHeaders // since the headers for a single part may come in more then one chunk if (mPackagedApp && !mResponseHead) { mResponseHead = new nsHttpResponseHead(); } mContentLength = UINT64_MAX; // XXX what if we were already called? while (cursorLen && (newLine = (char *) memchr(cursor, nsCRT::LF, cursorLen))) { // adjust for linefeeds if ((newLine > cursor) && (newLine[-1] == nsCRT::CR) ) { // CRLF lineFeedIncrement = 2; newLine--; } else lineFeedIncrement = 1; // reset if (newLine == cursor) { // move the newLine beyond the linefeed marker NS_ASSERTION(cursorLen >= lineFeedIncrement, "oops!"); cursor += lineFeedIncrement; cursorLen -= lineFeedIncrement; done = true; break; } char tmpChar = *newLine; *newLine = '\0'; // cursor is now null terminated if (mResponseHead) { // ParseHeaderLine is destructive. We create a copy nsAutoCString tmpHeader(cursor); mResponseHead->ParseHeaderLine(tmpHeader.get()); } char *colon = (char *) strchr(cursor, ':'); if (colon) { *colon = '\0'; nsAutoCString headerStr(cursor); headerStr.CompressWhitespace(); *colon = ':'; nsAutoCString headerVal(colon + 1); headerVal.CompressWhitespace(); // examine header if (headerStr.LowerCaseEqualsLiteral("content-type")) { mContentType = headerVal; } else if (headerStr.LowerCaseEqualsLiteral("content-length")) { mContentLength = nsCRT::atoll(headerVal.get()); } else if (headerStr.LowerCaseEqualsLiteral("content-disposition")) { mContentDisposition = headerVal; } else if (headerStr.LowerCaseEqualsLiteral("set-cookie")) { nsCOMPtr<nsIHttpChannelInternal> httpInternal = do_QueryInterface(aChannel); if (httpInternal) { httpInternal->SetCookie(headerVal.get()); } } else if (headerStr.LowerCaseEqualsLiteral("content-range") || headerStr.LowerCaseEqualsLiteral("range") ) { // something like: Content-range: bytes 7000-7999/8000 char* tmpPtr; tmpPtr = (char *) strchr(colon + 1, '/'); if (tmpPtr) *tmpPtr = '\0'; // pass the bytes-unit and the SP char *range = (char *) strchr(colon + 2, ' '); if (!range) return NS_ERROR_FAILURE; do { range++; } while (*range == ' '); if (range[0] == '*'){ mByteRangeStart = mByteRangeEnd = 0; } else { tmpPtr = (char *) strchr(range, '-'); if (!tmpPtr) return NS_ERROR_FAILURE; tmpPtr[0] = '\0'; mByteRangeStart = nsCRT::atoll(range); tmpPtr++; mByteRangeEnd = nsCRT::atoll(tmpPtr); } mIsByteRangeRequest = true; if (mContentLength == UINT64_MAX) mContentLength = uint64_t(mByteRangeEnd - mByteRangeStart + 1); } } *newLine = tmpChar; newLine += lineFeedIncrement; cursorLen -= (newLine - cursor); cursor = newLine; } aPtr = cursor; aLen = cursorLen; *_retval = done; return rv; }
void LibraryParameters::generateCode(QtProjectParameters:: Type t, const QString &projectTarget, const QString &headerName, const QString &sharedHeader, const QString &exportMacro, int indentation, QString *header, QString *source) const { QString rc; QTextStream headerStr(header); const QString indent = QString(indentation, QLatin1Char(' ')); // Do we have namespaces? QStringList namespaceList = className.split(QLatin1String("::")); if (namespaceList.empty()) // Paranoia! return; const QString unqualifiedClassName = namespaceList.takeLast(); // 1) Header const QString guard = Utils::headerGuard(headerFileName, namespaceList); headerStr << "#ifndef " << guard << "\n#define " << guard << '\n' << '\n'; if (!sharedHeader.isEmpty()) Utils::writeIncludeFileDirective(sharedHeader, false, headerStr); // include base class header if (!baseClassName.isEmpty()) { QString include; if (!baseClassModule.isEmpty()) { include += baseClassModule; include += QLatin1Char('/'); } include += baseClassName; Utils::writeIncludeFileDirective(include, true, headerStr); headerStr << '\n'; } const QString namespaceIndent = Utils::writeOpeningNameSpaces(namespaceList, indent, headerStr); // Class declaraction headerStr << '\n' << namespaceIndent << "class "; if (t == QtProjectParameters::SharedLibrary && !exportMacro.isEmpty()) headerStr << exportMacro << ' '; headerStr << unqualifiedClassName; if (!baseClassName.isEmpty()) headerStr << " : public " << baseClassName; headerStr << "\n{\n"; // Is this a QObject (plugin) const bool inheritsQObject = t == QtProjectParameters::Qt4Plugin; if (inheritsQObject) { headerStr << namespaceIndent << indent << "Q_OBJECT\n"; } headerStr << namespaceIndent << "public:\n"; if (inheritsQObject) { headerStr << namespaceIndent << indent << unqualifiedClassName << "(QObject *parent = 0);\n"; } else { headerStr << namespaceIndent << indent << unqualifiedClassName << "();\n"; } headerStr << namespaceIndent << "};\n\n"; Utils::writeClosingNameSpaces(namespaceList, indent, headerStr); headerStr << "#endif // "<< guard << '\n'; /// 2) Source QTextStream sourceStr(source); Utils::writeIncludeFileDirective(headerName, false, sourceStr); sourceStr << '\n'; Utils::writeOpeningNameSpaces(namespaceList, indent, sourceStr); // Constructor sourceStr << '\n' << namespaceIndent << unqualifiedClassName << "::" << unqualifiedClassName; if (inheritsQObject) { sourceStr << "(QObject *parent) :\n" << namespaceIndent << indent << baseClassName << "(parent)\n"; } else { sourceStr << "()\n"; } sourceStr << namespaceIndent << "{\n" << namespaceIndent << "}\n"; Utils::writeClosingNameSpaces(namespaceList, indent, sourceStr); if (t == QtProjectParameters::Qt4Plugin) sourceStr << '\n' << "Q_EXPORT_PLUGIN2(" << projectTarget << ", " << className << ")\n"; }
void LibraryParameters::generateCode(QtProjectParameters:: Type t, const QString &projectTarget, const QString &headerName, const QString &sharedHeader, const QString &exportMacro, const QString &pluginJsonFileName, int indentation, QString *header, QString *source) const { QTextStream headerStr(header); const QString indent = QString(indentation, QLatin1Char(' ')); // Do we have namespaces? QStringList namespaceList = className.split(QLatin1String("::")); if (namespaceList.empty()) // Paranoia! return; const QString unqualifiedClassName = namespaceList.takeLast(); // 1) Header const QString guard = Utils::headerGuard(headerFileName, namespaceList); headerStr << "#ifndef " << guard << "\n#define " << guard << '\n' << '\n'; if (!sharedHeader.isEmpty()) Utils::writeIncludeFileDirective(sharedHeader, false, headerStr); // include base class header if (!baseClassName.isEmpty()) { Utils::writeIncludeFileDirective(baseClassName, true, headerStr); headerStr << '\n'; } const QString namespaceIndent = Utils::writeOpeningNameSpaces(namespaceList, indent, headerStr); // Class declaraction headerStr << '\n' << namespaceIndent << "class "; if (t == QtProjectParameters::SharedLibrary && !exportMacro.isEmpty()) headerStr << exportMacro << ' '; headerStr << unqualifiedClassName; if (!baseClassName.isEmpty()) headerStr << " : public " << baseClassName; headerStr << "\n{\n"; // Is this a QObject (plugin) const bool inheritsQObject = t == QtProjectParameters::Qt4Plugin; if (inheritsQObject) headerStr << namespaceIndent << indent << "Q_OBJECT\n"; if (t == QtProjectParameters::Qt4Plugin) { // Write Qt 5 plugin meta data. const QString qt5InterfaceName = LibraryWizardDialog::pluginInterface(baseClassName); if (!qt5InterfaceName.isEmpty()) { headerStr << "#if QT_VERSION >= 0x050000\n" << namespaceIndent << indent << "Q_PLUGIN_METADATA(IID \"" << qt5InterfaceName << '"'; if (!pluginJsonFileName.isEmpty()) headerStr << " FILE \"" << pluginJsonFileName << '"'; headerStr << ")\n#endif // QT_VERSION >= 0x050000\n"; } } headerStr << namespaceIndent << "\npublic:\n"; if (inheritsQObject) headerStr << namespaceIndent << indent << unqualifiedClassName << "(QObject *parent = 0);\n"; else headerStr << namespaceIndent << indent << unqualifiedClassName << "();\n"; headerStr << namespaceIndent << "};\n\n"; Utils::writeClosingNameSpaces(namespaceList, indent, headerStr); headerStr << "#endif // "<< guard << '\n'; /// 2) Source QTextStream sourceStr(source); Utils::writeIncludeFileDirective(headerName, false, sourceStr); sourceStr << '\n'; Utils::writeOpeningNameSpaces(namespaceList, indent, sourceStr); // Constructor sourceStr << '\n' << namespaceIndent << unqualifiedClassName << "::" << unqualifiedClassName; if (inheritsQObject) { sourceStr << "(QObject *parent) :\n" << namespaceIndent << indent << baseClassName << "(parent)\n"; } else { sourceStr << "()\n"; } sourceStr << namespaceIndent << "{\n" << namespaceIndent << "}\n"; Utils::writeClosingNameSpaces(namespaceList, indent, sourceStr); if (t == QtProjectParameters::Qt4Plugin) { // Qt 4 plugin export sourceStr << "\n#if QT_VERSION < 0x050000\n" << "Q_EXPORT_PLUGIN2(" << projectTarget << ", " << className << ")\n" << "#endif // QT_VERSION < 0x050000\n"; } }
void FLSmtpClient::startSend() { emit sendStarted(); emit sendTotalSteps(attachments_.count() + 3); int step = 0; emit sendStepNumber(++step); changeStatus(tr("Componiendo mensaje"), Composing); // only send logo when configured if (FLUtil::readSettingEntry("email/sendMailLogo", "true").toBool()) { QString logo(FLUtil::readSettingEntry("email/mailLogo", AQ_DATA + "/logo_mail.png").toString()); if (!QFile::exists(logo)) { logo = AQ_DISKCACHE_DIRPATH + "/logo.png"; QPixmap::fromMimeSource("logo_abanq.png").save(logo, "PNG"); } attachments_ << logo; mapAttachCid_.insert(logo, QFileInfo(logo).fileName() + "@3d8b627b6292"); } QString headerStr(QString::fromLatin1("from: ") + from_); if (!replyTo_.isEmpty()) headerStr += QString::fromLatin1("\nreply-to: ") + replyTo_; headerStr += QString::fromLatin1("\nto: ") + to_ + QString::fromLatin1("\nsubject: ") + subject_; if (!cc_.isEmpty()) headerStr += QString::fromLatin1("\ncc: ") + cc_; if (!bcc_.isEmpty()) headerStr += QString::fromLatin1("\nbcc: ") + bcc_; if (!organization_.isEmpty()) headerStr += QString::fromLatin1("\norganization: ") + organization_; if (priority_ > 0) headerStr += QString::fromLatin1("\npriority: ") + QString::number(priority_); CharSets chS; HeaderClass hdr(headerStr.local8Bit()); MessageClass msg(hdr); LocalMailFolder folder(AQ_DISKCACHE_DIRPATH + '/'); QString idMessage = folder.createMessage(body_.local8Bit(), QCString(), QDateTime::currentDateTime(), "", &msg); IndexClass *idx = folder.indexIDict()[ idMessage ]; MessageDevice msgDev(idx); MimePart *part0 = new MimePart(); part0->charset = chS.getDefaultCharset(); part0->mimetype = (mimeType_.isEmpty() ? "text/plain" : mimeType_); part0->encoding = "quoted-printable"; part0->name = "body"; part0->type = "text"; QByteArray partData0 = body_.local8Bit(); part0->length = partData0.count(); int npart0 = idx->addPart(part0, false); msgDev.setPartData(npart0, partData0); emit sendStepNumber(++step); for (uint i = 0; i < textParts_.count(); i += 2) { part0 = new MimePart(); part0->charset = chS.getDefaultCharset(); part0->mimetype = textParts_[i + 1]; part0->encoding = "quoted-printable"; part0->type = "text"; partData0 = textParts_[i].local8Bit(); part0->length = partData0.count(); npart0 = idx->addPart(part0, false); msgDev.setPartData(npart0, partData0); emit sendStepNumber(++step); } QStringList::Iterator itAttach; QString fileName; for (uint i = 0; i < attachments_.count(); i++) { itAttach = attachments_.at(i); fileName = *itAttach; changeStatus(tr("Adjuntando %1").arg(QFileInfo(fileName).fileName()), Attach); MimePart *part1 = new MimePart(); part1->charset = chS.getDefaultCharset(); QFile f(fileName); f.open(IO_Raw | IO_ReadOnly); QByteArray partData1 = f.readAll(); f.close(); part1->length = partData1.count(); part1->name = QFileInfo(fileName).fileName(); if (mapAttachCid_.contains(fileName)) part1->cid = mapAttachCid_[fileName]; const QMimeSource *mime = 0; QMimeSourceFactory *mimeFactory = mimeSourceFactory(); if (mimeFactory) { mime = mimeFactory->data(fileName); } else { mime = QMimeSourceFactory::defaultFactory()->data(fileName); } if (mime && mime->format()) { part1->mimetype = mime->format(); part1->encoding = "base64"; } int npart1 = idx->addPart(part1, false); msgDev.setPartData(npart1, partData1); emit sendStepNumber(++step); } QStringList rcpts(hdr.To.toQStringList()); rcpts += hdr.Cc.toQStringList(); rcpts += hdr.Bcc.toQStringList(); Smtp *smtp = new Smtp(from_, rcpts, msgDev.rfc822Header(), mailServer_, port_, this); smtp->setUser(user_); smtp->setPassword(password_); smtp->setConnectionType(connectionType_); smtp->setAuthMethod(authMethod_); emit sendStepNumber(++step); connect(smtp, SIGNAL(destroyed()), this, SIGNAL(sendEnded())); connect(smtp, SIGNAL(statusChanged(const QString &, int)), this, SLOT(changeStatus(const QString &, int))); smtp->init(); }
void nsEnigMimeListener::ParseHeader(const char* header, PRUint32 count) { //DEBUG_LOG(("nsEnigMimeListener::ParseHeader: header='%s'\n", header)); if (!header || (count <= 0) ) return; // Create header string nsCAutoString headerStr(header, count); //DEBUG_LOG(("nsEnigMimeListener::ParseHeader: header='%s'\n", headerStr.get())); PRInt32 colonOffset; colonOffset = headerStr.FindChar(':'); if (colonOffset < 0) return; // Null header key not allowed if (colonOffset == 0) return; // Extract header key (not case-sensitive) nsCAutoString headerKey = (nsCString) nsDependentCSubstring (headerStr, 0, colonOffset); ToLowerCase(headerKey); // Extract header value, trimming leading/trailing whitespace nsCAutoString buf = (nsCString) nsDependentCSubstring (headerStr, colonOffset+1, headerStr.Length() - colonOffset); buf.Trim(" ", PR_TRUE, PR_TRUE); //DEBUG_LOG(("nsEnigMimeListener::ParseHeader: '%s': %s\n", headerKey.get(), buf.get())); PRInt32 semicolonOffset = buf.FindChar(';'); nsCString headerValue; if (semicolonOffset < 0) { // No parameters headerValue = ((nsCString)buf).get(); } else { // Extract value to left of parameters headerValue = nsDependentCSubstring (buf, 0, semicolonOffset); } // Trim leading and trailing spaces in header value headerValue.Trim(" ", PR_TRUE, PR_TRUE); if (headerKey.Equals("content-type")) { mContentType = headerValue; DEBUG_LOG(("nsEnigMimeListener::ParseHeader: ContentType=%s\n", mContentType.get())); if (!buf.IsEmpty()) { char *charset = MimeHeaders_get_parameter(buf.get(), HEADER_PARM_CHARSET, NULL, NULL); char *boundary = MimeHeaders_get_parameter(buf.get(), HEADER_PARM_BOUNDARY, NULL, NULL); char *protocol = MimeHeaders_get_parameter(buf.get(), PARAM_PROTOCOL, NULL, NULL); char *micalg = MimeHeaders_get_parameter(buf.get(), PARAM_MICALG, NULL, NULL); if (charset) mContentCharset = charset; if (boundary) mContentBoundary = boundary; if (protocol) mContentProtocol = protocol; if (micalg) mContentMicalg = micalg; PR_FREEIF(charset); PR_FREEIF(boundary); PR_FREEIF(protocol); PR_FREEIF(micalg); DEBUG_LOG(("nsEnigMimeListener::ParseHeader: ContentCharset=%s\n", mContentCharset.get())); DEBUG_LOG(("nsEnigMimeListener::ParseHeader: ContentBoundary=%s\n", mContentBoundary.get())); DEBUG_LOG(("nsEnigMimeListener::ParseHeader: ContentProtocol=%s\n", mContentProtocol.get())); DEBUG_LOG(("nsEnigMimeListener::ParseHeader: ContentMicalg=%s\n", mContentMicalg.get())); } } else if (headerKey.Equals("content-transfer-encoding")) { mContentEncoding = buf; ToLowerCase(mContentEncoding); DEBUG_LOG(("nsEnigMimeListener::ParseHeader: ContentEncoding=%s\n", mContentEncoding.get())); } else if (headerKey.Equals("content-disposition")) { mContentDisposition = buf; DEBUG_LOG(("nsEnigMimeListener::ParseHeader: ContentDisposition=%s\n", mContentDisposition.get())); } else if (headerKey.Equals("content-length")) { nsresult status; PRInt32 value = headerValue.ToInteger(&status); if (NS_SUCCEEDED(status)) mContentLength = value; DEBUG_LOG(("nsEnigMimeListener::ParseHeader: ContenLengtht=%d\n", mContentLength)); } return; }
void CFileSpraySoapBindingEx::downloadFile(IEspContext &context, CHttpRequest* request, CHttpResponse* response) { try { StringBuffer netAddressStr, osStr, pathStr, nameStr; request->getParameter("NetAddress", netAddressStr); request->getParameter("OS", osStr); request->getParameter("Path", pathStr); request->getParameter("Name", nameStr); #if 0 StringArray files; IProperties* params = request->queryParameters(); Owned<IPropertyIterator> iter = params->getIterator(); if (iter && iter->first()) { while (iter->isValid()) { const char *keyname=iter->getPropKey(); if (!keyname || strncmp(keyname, "Names", 5)) continue; files.append(params->queryProp(iter->getPropKey())); iter->next(); } } #endif if (netAddressStr.length() < 1) throw MakeStringException(ECLWATCH_INVALID_INPUT, "Network address not specified."); if (pathStr.length() < 1) throw MakeStringException(ECLWATCH_INVALID_INPUT, "Path not specified."); if (nameStr.length() < 1) throw MakeStringException(ECLWATCH_INVALID_INPUT,"File name not specified."); char pathSep = '/'; if ((osStr.length() > 1) && (atoi(osStr.str())== OS_WINDOWS)) { pathSep = '\\'; } pathStr.replace(pathSep=='\\'?'/':'\\', pathSep); if (*(pathStr.str() + pathStr.length() -1) != pathSep) pathStr.append( pathSep ); StringBuffer fullName; fullName.appendf("%s%s", pathStr.str(), nameStr.str()); StringBuffer headerStr("attachment;"); headerStr.appendf("filename=%s", nameStr.str()); RemoteFilename rfn; rfn.setRemotePath(fullName.str()); SocketEndpoint ep(netAddressStr.str()); rfn.setIp(ep); Owned<IFile> rFile = createIFile(rfn); if (!rFile) throw MakeStringException(ECLWATCH_CANNOT_OPEN_FILE,"Cannot open file %s.",fullName.str()); OwnedIFileIO rIO = rFile->openShared(IFOread,IFSHfull); if (!rIO) throw MakeStringException(ECLWATCH_CANNOT_READ_FILE,"Cannot read file %s.",fullName.str()); IFileIOStream* ioS = createIOStream(rIO); context.addCustomerHeader("Content-disposition", headerStr.str()); response->setContent(ioS); response->setContentType(HTTP_TYPE_OCTET_STREAM); response->send(); } catch(IException* e) { FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR); } return; }