void ConstructRequestData(const CUserReport& report) { // Construct the POST request data in the application/x-www-form-urlencoded format std::string r; r += "user_id="; AppendEscaped(r, m_UserID); r += "&time=" + CStr::FromInt64(report.m_Time); r += "&type="; AppendEscaped(r, report.m_Type); r += "&version=" + CStr::FromInt(report.m_Version); r += "&data="; AppendEscaped(r, report.m_Data); // Compress the content with zlib to save bandwidth. // (Note that we send a request with unlabelled compressed data instead // of using Content-Encoding, because Content-Encoding is a mess and causes // problems with servers and breaks Content-Length and this is much easier.) std::string compressed; compressed.resize(compressBound(r.size())); uLongf destLen = compressed.size(); int ok = compress((Bytef*)compressed.c_str(), &destLen, (const Bytef*)r.c_str(), r.size()); ENSURE(ok == Z_OK); compressed.resize(destLen); m_RequestData.swap(compressed); }
// --------------------------------------------------------- // RFavouritesSrvTable::SetFiltersL // --------------------------------------------------------- // void RFavouritesSrvTable::SetFiltersL( const TFavouritesFilter& aFilter ) { HBufC* buf = HBufC::NewLC( KFavouritesMaxSql ); TPtr sql = buf->Des(); HBufC* tmpBuf = HBufC::NewLC( KFavouritesMaxSql ); TPtr tmpPtr = tmpBuf->Des(); _LIT( KNone, "" ); _LIT( KAnd, "and" ); TPtrC sConn; sConn.Set( KNone ); if ( aFilter.iName ) { // "name like 'foo*'" _LIT( KFormat1, "%S like '" ); sql.Format( KFormat1, &KFavouritesDbNameColName ); AppendEscaped( sql, *aFilter.iName ); sql.Append( TChar('\'') ); sConn.Set( KAnd ); } if ( aFilter.iType != CFavouritesItem::ENone ) { // "and type = 0" _LIT( KFormat2, " %S %S = %d" ); tmpPtr.Format ( KFormat2, &sConn, &KFavouritesDbTypeColName, aFilter.iType ); sConn.Set( KAnd ); sql.Append( tmpPtr ); } if ( aFilter.iParentFolder != KFavouritesNullUid ) { // "and parent = 7" _LIT( KFormat3, " %S %S = %d" ); tmpPtr.Format( KFormat3, &sConn, &KFavouritesDbParentColName, aFilter.iParentFolder ); sConn.Set( KAnd ); sql.Append( tmpPtr ); } if ( aFilter.iContextId != KFavouritesNullContextId ) { // "and contextid = 7" _LIT( KFormat3, " %S %S = %d" ); tmpPtr.Format( KFormat3, &sConn, &KFavouritesDbContextIdColName, aFilter.iContextId ); sConn.Set( KAnd ); sql.Append( tmpPtr ); } // Clear old one, if any. ClearFilters(); if ( sql.Length() > 0 ) { // Make new constraint, if there is any filter set. // Otherwise there will be no constraint. User::LeaveIfError ( iFilter.Open( *this, TDbQuery( sql, EDbCompareFolded ) ) ); iFiltering = ETrue; } CleanupStack::PopAndDestroy( 2 ); // tmpBuf, buf }