UINT32 CHXDataSourceCContent::Read( void *pBuf, ULONG32 size, ULONG32 count) { TInt requestSize = size*count; TInt err; TPtr8 ptr8((TUint8 *)pBuf, 0, requestSize); err = m_pCData->Read(ptr8); UINT32 bytesRead; if (err == KErrNone) { // return the number of bytes read bytesRead = ptr8.Length(); m_ulPosition += bytesRead; } else { bytesRead = 0; HXLOGL1(HXLOG_FILE, "CHXDataSourceCContent::Read error=%d", err); } return bytesRead; }
/** create test messages to use where aTestCase represents the message index for multiple messages. Tests: 0 & 1- Chineese character encoding 2- Message with Creation and Expires time @param aTestCase message index value for selecting a test message @return void */ void CInvalidWAPDTDMessages::PrepareTestMessageL(TInt aTestCase) { // create hardcoded SIC test message const TUint8 KMessageHeader[] = { 0xAF, // Content type "application/vnd.wap.sl" 0x82, // Accept-Charset Short int - 0x02 represent x-wap-application:push.ua }; iHeadersBuf.Append(KMessageHeader, sizeof(KMessageHeader)); HBufC8* msg = HBufC8::NewLC ( KBufferSize ); TPtr8 ptr8 ( msg->Des() ); ptr8.Copy ( KXMLVersion() ); ptr8.Append ( KDocType() ); switch ( aTestCase ) { case 0 : ptr8.Append ( KInvalidDTD1() ); break; case 1: ptr8.Append ( KInvalidDTD2() ); break; } // copy data to iBodyBuf iBodyBuf.Delete(0,KBufferSize); iBodyBuf = msg->Des(); CleanupStack::PopAndDestroy(1); // msg }
// --------------------------------------------------------------------------- // --------------------------------------------------------------------------- void CIpsPlgMessagePartStorerOperation::StoreTextHtmlPartL( CFSMailMessagePart* aPart) { User::LeaveIfNull(aPart); // Text buffer for html text content HBufC* data16 = aPart->GetLocalTextContentLC(); // Convert from 16 to 8 bit data - data must exist until request is completed iDataBuffer = HBufC8::NewL((data16->Length() * 2) + 1); TPtr8 ptr8(iDataBuffer->Des()); CnvUtfConverter::ConvertFromUnicodeToUtf8(ptr8, *data16); // Get text/html part file for write RFile file = aPart->GetContentFileL(ETrue); CleanupClosePushL(file); // if we don't do SetSize(0) characters from the original mail are left in the end of the mail // if the modified mail contains less characters. User::LeaveIfError( file.SetSize( 0 ) ); // Write new content to text/html part file - async function file.Write( 0, *iDataBuffer, iDataBuffer->Length(), iStatus ); CleanupStack::PopAndDestroy(2, data16); SetActive(); }
/** * Converts the CString to Descriptor */ HBufC* CSmsPlatformServiceS60Impl::convertToDes(const char* aData, const int aMsgType, const int aLength) { HBufC* smsData = 0; smsData = HBufC::New(aLength+1); if (aData != NULL) { if (aMsgType == MESSAGE_TEXT) { TPtr ptr = smsData->Des(); TPtr16 ptr16((TUint16 *)aData,aLength); ptr16.SetLength(aLength); ptr.Copy(ptr16); ptr.ZeroTerminate(); } else { TPtr ptr = smsData->Des(); TPtr8 ptr8((TUint8 *)aData,aLength); ptr8.SetLength(aLength); ptr.Copy(ptr8); ptr.ZeroTerminate(); } } return smsData; }
UINT32 CHXDataSourceDescriptor::Read( void *pBuf, ULONG32 size, ULONG32 count) { TInt requestSize = size*count; TInt err; if (m_ulPosition + requestSize > m_pData->Size()) { // shouldn't read beyond the descriptor. requestSize = m_pData->Size() - m_ulPosition; } if(requestSize <= 0) { return 0; } TPtr8 ptr8((TUint8 *)pBuf, 0, requestSize); ptr8.Copy(m_pData->Ptr() + m_ulPosition, requestSize); m_ulPosition += requestSize; return requestSize; }
/** Reads a descriptor setting. @param aKey Key of setting to be read. @param aValue Returns the value of the setting if it is a descriptor. @return KErrNone if successful, KErrNotFound if the setting does not exist, KErrArgument if the setting exists but is not a descriptor, KErrOverflow if the descriptor is too small to receive the value in the repository, plus other system-wide error codes. @post Transactions fail only on those "other system-wide error codes". @capability Dependent Caller must satisfy the read access policy of that key in the repository. */ EXPORT_C TInt CRepository::Get(TUint32 aKey, TDes16& aValue) { TPtr8 ptr8((TUint8*)aValue.Ptr(), 0, aValue.MaxSize()); TInt ret=Get(aKey,ptr8); if (ret==KErrNone) aValue.SetLength(ptr8.Length()/2); return ret; }
TInt CDatabaseManagerServerSession::ServiceNamesL(const RMessage2& aMessage) { TPtrC8 ptr8((TUint8*)(iByteArray->constData()), iByteArray->size()); aMessage.Write(0, ptr8); delete iByteArray; iByteArray = NULL; return 0; }
/** Reads a descriptor setting. @param aKey Key of setting to be read. @param aValue Returns the value of the setting if it is a descriptor. @param aActualLength Returns the actual length of the setting if it is a descriptor. @return KErrNone if successful, KErrNotFound if the setting does not exist, KErrArgument if the setting exists but is not a descriptor, KErrOverflow if the descriptor is too small to receive the value in the repository, plus other system-wide error codes. @post Transactions fail only on those "other system-wide error codes". @capability Dependent Caller must satisfy the read access policy of that key in the repository. */ EXPORT_C TInt CRepository::Get(TUint32 aKey, TDes16& aValue, TInt& aActualLength) { TInt actualLength8; TPtr8 ptr8((TUint8*)aValue.Ptr(), 0, aValue.MaxSize()); TInt ret=Get(aKey,ptr8,actualLength8); aValue.SetLength(ptr8.Length()/2); aActualLength=actualLength8/2; return ret; }
// ----------------------------------------------------------------------------- // CHttpCacheEntry::InternalizeL // // ----------------------------------------------------------------------------- // void CHttpCacheEntry::InternalizeL( RReadStream& aReadStream, const TDesC& aDirectory ) { // url length TInt len; len = aReadStream.ReadInt32L(); delete iUrl; iUrl=NULL; iUrl = HBufC8::NewL( len ); TPtr8 ptr8( iUrl->Des() ); // url aReadStream.ReadL( ptr8, len ); // calculate full path and filename length // aDirectory/ + "x/xxxxxxxx" : note aDirectory has trailing '/' len = aDirectory.Length() + KSubdirNameLength + KFilenameLength; HBufC* filename = HBufC::NewLC( len ); TPtr ptr( filename->Des() ); // Read max char length of filename. // NOTE: The filename and filename length is calculated by the code in // HttpCacheUtil::GenerateNameLC. The sub directory is the same as the // last char of the filename, e.g. ..\A\0123DCBA TBuf<KFilenameLength> uniqueFilename; aReadStream.ReadL( uniqueFilename , KFilenameLength ); TPtrC uniqueSubDir = uniqueFilename.Right(1); // assemble path and filename ptr.Format(_L("%S%S\\%S"), &aDirectory, &uniqueSubDir, &uniqueFilename); // SetFileNameL( filename->Des() ); // CleanupStack::PopAndDestroy(); // filename // la TReal64 la; la = aReadStream.ReadReal64L(); iLastAccessed = la; // ref iRef = aReadStream.ReadUint32L(); // size iBodySize = aReadStream.ReadUint32L( ); // size iHeaderSize = aReadStream.ReadUint32L( ); // protected iProtected = aReadStream.ReadInt32L(); // header data delete iHeaderBuffer; iHeaderBuffer = NULL; len = aReadStream.ReadInt32L(); iHeaderBuffer = HBufC8::NewL(len); TPtr8 header_ptr( iHeaderBuffer->Des() ); aReadStream.ReadL( header_ptr, len ); // SetState( ECacheComplete ); }
void LogFilePrint(TRefByValue<const TDesC> aFormat, ...) { // Connect to file server. This wastes time and resources, but ensures // that the debug macros don't depend on anything else being initialized. RFs fs; PanicIfError(fs.Connect()); // Open file. Append to the end of the file if it exists, or create new // if it doesn't. RFile file; TInt err = file.Open(fs, KLogFileName, EFileWrite | EFileShareExclusive); if ( err == KErrNone ) { TInt pos = 0; PanicIfError(file.Seek(ESeekEnd, pos)); } else if ( err == KErrNotFound ) { PanicIfError(file.Create(fs, KLogFileName, EFileWrite | EFileShareExclusive)); } else { User::Panic(KPanic, err); } // Ugly: Buffer for the message. We don't know how much space is really // needed HBufC *buf = HBufC::New(KFormatBufferSize); if ( !buf ) { User::Panic(KPanic, 1); } TPtr ptr = buf->Des(); // Create a timestamp and write it first on the line TTime time; time.HomeTime(); TRAP(err, time.FormatL(ptr, KTimestampFormat)); PanicIfError(err); TPtrC8 ptr8((TUint8*)ptr.Ptr(), ptr.Size()); PanicIfError(file.Write(ptr8)); // Format the message, and write it VA_LIST args; VA_START(args, aFormat); ptr.FormatList(aFormat, args); VA_END(args); ptr8.Set((TUint8*)ptr.Ptr(), ptr.Size()); PanicIfError(file.Write(ptr8)); // End with a linefeed ptr = KCRLF; ptr8.Set((TUint8*)ptr.Ptr(), ptr.Size()); PanicIfError(file.Write(ptr8)); delete buf; file.Close(); fs.Close(); }
TInt ReadIntoBuffer() { TRequestStatus status; TPtr8 ptr8((TUint8*)buffer, sizeof(buffer), sizeof(buffer)); TSockXfrLength tlen; socket.RecvOneOrMore(ptr8, 0, status, tlen); User::WaitForRequest(status); bufferTop = tlen(); bufferBottom = 0; return status.Int(); }
void CCntItemMsgHandler::FindAsyncTextDefInitL(const RMessage2& aMessage) { /* Initialisation for asynchronous find using CContactTextDef and array of "find words" constructed on the client-side and required on the server-side for matching. **/ CheckForManagerL(); // CContactTextDef can be NULL in which case the client will have // passed an empty descriptor. CContactTextDef* textDef = NULL; // Assuming that a KNullDesC parameter results in max length of 0. if(aMessage.GetDesLengthL(1) > 0) { // Use packager to unpack CContactTextDef. iPackager.SetBufferFromMessageL(aMessage,1); textDef = iPackager.UnpackCntTextDefLC(); CleanupStack::Pop(textDef); } // Unpack the CDesCArray manually as the packager does not package // both. CBufFlat* bufFlat = CBufFlat::NewL(1 << 8); CleanupStack::PushL(bufFlat); bufFlat->ExpandL(0,aMessage.GetDesLengthL(0)); TPtr8 ptr8(bufFlat->Ptr(0)); aMessage.ReadL(0,ptr8); RBufReadStream readStream; readStream.Open(*bufFlat); TInt count = readStream.ReadInt32L(); CDesCArray* unpacked = new (ELeave) CDesCArrayFlat(8); CleanupStack::PushL(unpacked); for(TInt i=0;i<count;++i) { TBuf<256> buf; TInt length = readStream.ReadInt32L(); readStream.ReadL(buf,length); unpacked->AppendL(buf); } readStream.Close(); // Persistence Layer does the actual initialisation and also takes // ownership of textDef. MLplCollection& collection = iManager->GetPersistenceLayer().FactoryL().GetCollectorL(); collection.FindAsyncTextDefInitL(*unpacked,textDef); CleanupStack::PopAndDestroy(unpacked); CleanupStack::PopAndDestroy(bufFlat); aMessage.Complete(KErrNone); }
bool QMessageContentContainerPrivate::createAttachment(const QString& attachmentPath) { //set the attachment data if (!QFile::exists(attachmentPath)) { return false; } QFile attachmentFile(attachmentPath); if (!attachmentFile.open(QIODevice::ReadOnly)) { return false; } _content = attachmentFile.readAll(); _available = true; _size = attachmentFile.size(); attachmentFile.close(); QFileInfo fi(attachmentPath); _name = fi.fileName().toLatin1(); //set the mime-type QByteArray mimeType; QString type; TBuf8<255> fileBuffer; RApaLsSession session; QString fileString = fi.fileName(); TPtrC16 filePtr(reinterpret_cast<const TUint16*>(fileString.utf16())); TBuf8<20> fileType; TPtrC8 ptr8((TUint8 *)(_content.constData()), _content.length()); if(session.Connect() == KErrNone){ TDataRecognitionResult fileDataType; session.RecognizeData(filePtr, ptr8, fileDataType); fileType.Copy(fileDataType.iDataType.Des8()); mimeType = QByteArray((const char*)fileType.Ptr(), fileType.Length()); session.Close(); } QString extension(fi.suffix()); int index = mimeType.indexOf("/"); if (index != -1) { _type = mimeType.left(index).trimmed(); _subType = mimeType.mid(index + 1).trimmed(); } // set the whole filepath to _filename _filename = fi.filePath().toLatin1(); return true; }
HBufC8 *CIkev1Dialog::ConvertPwdToOctetString(TDesC &aUnicodeBfr) { /*-------------------------------------------------------------------- * * Convert password from Unicode string to 8-bit octet string * *---------------------------------------------------------------------*/ HBufC8 *octet_data = HBufC8::New(aUnicodeBfr.Length()); if ( octet_data ) { TPtr8 ptr8(octet_data->Des()); ptr8.Copy(aUnicodeBfr); } return octet_data; }
IoValue *IoSocket_write(IoSocket *self, IoValue *locals, IoMessage *m) { IoState* state = (IoState*)self->tag->state; IoString *ioText = (IoString*)IoMessage_locals_stringArgAt_(m, locals, 0); char* text = CSTRING(ioText); int len = strlen(text); TRequestStatus status; TPtr8 ptr8((TUint8*)text, len, len); self->socket->socket.Write(ptr8, status); User::WaitForRequest(status); if(status.Int() != 0) { IoState_error_description_(state, "IoSocket.write", "RSocket.Write: '%d'\n", status.Int()); } return (IoValue*)self; }
/*! Converts a QByteArray to a Symbian S60 8 bit descriptor. Note: Ownership of the returned descriptor (string) is transferred to the caller \param byteArray QByteArray to be converted \return Pointer to an 8 bit Symbian S60 descriptor string on success; otherwise returns NULL pointer */ HBufC8* XQConversions::qByteArrayToS60Desc8(const QByteArray& byteArray) { TPtrC8 ptr8((TUint8*)(byteArray.constData())); return ptr8.Alloc(); }
void RunL() { switch(state) { case READ_STATE_BUFFER_UNDERFLOW: { TPtr8 ptr8((TUint8*)socket->buffer, SOCKET_BUFFER_SIZE, SOCKET_BUFFER_SIZE); socket->socket.RecvOneOrMore(ptr8, 0, iStatus, tlen); state = READ_STATE_BUFFER_POST_UNDERFLOW; SetActive(); break; } case READ_STATE_BUFFER_POST_UNDERFLOW: { socket->bufferTop = tlen(); socket->bufferBottom = 0; state = READ_STATE_BUFFER_READ; SetActive(); TRequestStatus* tempStatus = &iStatus; User::RequestComplete(tempStatus, KErrNone); break; } case READ_STATE_BUFFER_READ: { if(length == 0) { state = READ_STATE_BUFFER_COMPLETE; SetActive(); TRequestStatus* tempStatus = &iStatus; User::RequestComplete(tempStatus, KErrNone); break; } else if(socket->bufferTop == socket->bufferBottom) { state = READ_STATE_BUFFER_UNDERFLOW; SetActive(); TRequestStatus* tempStatus = &iStatus; User::RequestComplete(tempStatus, KErrNone); break; } else if(socket->bufferTop - socket->bufferBottom >= length) { char* start = socket->buffer + socket->bufferBottom; char* end = socket->buffer + length; while(start != end) { char c = *start++; if(c == 13) { lineState = 1; } else if(c == 10) { if(lineState == 1) { lineState = 2; socket->bufferBottom = start - socket->buffer; length = 0; state = READ_STATE_BUFFER_COMPLETE; SetActive(); TRequestStatus* tempStatus = &iStatus; User::RequestComplete(tempStatus, KErrNone); return; } else { *buffer++ = c; } } else { if(lineState == 1) { *buffer++ = 13; } else { *buffer++ = c; } state = 0; } } socket->bufferBottom += length; length = 0; state = READ_STATE_BUFFER_COMPLETE; SetActive(); TRequestStatus* tempStatus = &iStatus; User::RequestComplete(tempStatus, KErrNone); return; } else { int l = min(length, socket->bufferTop - socket->bufferBottom); char* start = socket->buffer + socket->bufferBottom; char* end = socket->buffer + l; while(lineState != 2 && start != end) { char c = *start++; if(c == 13) { lineState = 1; } else if(c == 10) { if(lineState == 1) { lineState = 2; socket->bufferBottom = start - socket->buffer; state = READ_STATE_BUFFER_COMPLETE; SetActive(); TRequestStatus* tempStatus = &iStatus; User::RequestComplete(tempStatus, KErrNone); return; } else { *buffer++ = c; } } else { if(lineState == 1) { *buffer++ = 13; } else { *buffer++ = c; } lineState = 0; } } length -= l; buffer += l; socket->bufferBottom += l; } state = READ_STATE_BUFFER_READ; SetActive(); TRequestStatus* tempStatus = &iStatus; User::RequestComplete(tempStatus, KErrNone); break; } case READ_STATE_BUFFER_COMPLETE: { ioSocket->lineRead = originalBuffer; break; } } }
PJ_END_DECL /* Get Symbian phone model info, returning length of model info */ unsigned pj_symbianos_get_model_info(char *buf, unsigned buf_size) { pj_str_t model_name; /* Get machine UID */ TInt hal_val; HAL::Get(HAL::EMachineUid, hal_val); pj_ansi_snprintf(buf, buf_size, "0x%08X", hal_val); pj_strset2(&model_name, buf); /* Get model name */ const pj_str_t st_copyright = {"(C)", 3}; const pj_str_t st_nokia = {"Nokia", 5}; char tmp_buf[64]; pj_str_t tmp_str; _LIT(KModelFilename,"Z:\\resource\\versions\\model.txt"); RFile file; RFs fs; TInt err; fs.Connect(1); err = file.Open(fs, KModelFilename, EFileRead); if (err == KErrNone) { TFileText text; text.Set(file); TBuf16<64> ModelName16; err = text.Read(ModelName16); if (err == KErrNone) { TPtr8 ptr8((TUint8*)tmp_buf, sizeof(tmp_buf)); ptr8.Copy(ModelName16); pj_strset(&tmp_str, tmp_buf, ptr8.Length()); pj_strtrim(&tmp_str); } file.Close(); } fs.Close(); if (err != KErrNone) goto on_return; /* The retrieved model name is usually in long format, e.g: * "© Nokia N95 (01.01)", "(C) Nokia E52". As we need only * the short version, let's clean it up. */ /* Remove preceding non-ASCII chars, e.g: "©" */ char *p = tmp_str.ptr; while (!pj_isascii(*p)) { p++; } pj_strset(&tmp_str, p, tmp_str.slen - (p - tmp_str.ptr)); /* Remove "(C)" */ p = pj_stristr(&tmp_str, &st_copyright); if (p) { p += st_copyright.slen; pj_strset(&tmp_str, p, tmp_str.slen - (p - tmp_str.ptr)); } /* Remove "Nokia" */ p = pj_stristr(&tmp_str, &st_nokia); if (p) { p += st_nokia.slen; pj_strset(&tmp_str, p, tmp_str.slen - (p - tmp_str.ptr)); } /* Remove language version, e.g: "(01.01)" */ p = pj_strchr(&tmp_str, '('); if (p) { tmp_str.slen = p - tmp_str.ptr; } pj_strtrim(&tmp_str); if (tmp_str.slen == 0) goto on_return; if ((unsigned)tmp_str.slen > buf_size - model_name.slen - 3) tmp_str.slen = buf_size - model_name.slen - 3; pj_strcat2(&model_name, "("); pj_strcat(&model_name, &tmp_str); pj_strcat2(&model_name, ")"); /* Zero terminate */ buf[model_name.slen] = '\0'; on_return: return model_name.slen; }
// ----------------------------------------------------------------------------- // CRhodesAppUi::HandleCommandL() // Takes care of command handling. // ----------------------------------------------------------------------------- // void CRhodesAppUi::HandleCommandL(TInt aCommand) { switch (aCommand) { case EEikCmdExit: case EAknSoftkeyExit: if ( iSyncEngineWrap ) iSyncEngineWrap->TerminateThread(); Exit(); break; case EHelp: { CArrayFix<TCoeHelpContext>* buf = CCoeAppUi::AppHelpContextL(); HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), buf); } break; case EAbout: { CAknMessageQueryDialog* dlg = new (ELeave)CAknMessageQueryDialog(); dlg->PrepareLC(R_ABOUT_QUERY_DIALOG); HBufC* title = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TITLE); dlg->QueryHeading()->SetTextL(*title); CleanupStack::PopAndDestroy(); //title HBufC* msg = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TEXT); dlg->SetMessageTextL(*msg); CleanupStack::PopAndDestroy(); //msg dlg->RunLD(); } break; #ifdef ENABLE_RUBY_VM_STAT case EStat: { CAknMessageQueryDialog* dlg = new (ELeave)CAknMessageQueryDialog(); dlg->PrepareLC(R_STAT_QUERY_DIALOG); HBufC* title = iEikonEnv->AllocReadResourceLC(R_STAT_DIALOG_TITLE); dlg->QueryHeading()->SetTextL(*title); CleanupStack::PopAndDestroy(); //title char buf[500] = {0}; sprintf( buf, "stat:\n___________________\n" "iceq stat:\n " "iseq binread: %u%s\n" "iseq marshal: %u%s\n" "require_compiled: %u%s\n" "httpd thread loaded: %d\n" "sync thread loaded: %d\n", g_iseq_binread_msec, "msec", g_iseq_marshal_load_msec, "msec", g_require_compiled_msec, "msec", g_httpd_thread_loaded, g_sync_thread_loaded); TPtrC8 ptr8((TUint8*)buf); HBufC *msg = HBufC::NewLC(ptr8.Length()); msg->Des().Copy(ptr8); dlg->SetMessageTextL(*msg); CleanupStack::PopAndDestroy(msg); dlg->RunLD(); } break; #endif default: iAppView->HandleCommandL(aCommand); break; } }
/* Get certificate info from CX509Certificate. */ static void get_cert_info(pj_pool_t *pool, pj_ssl_cert_info *ci, const CX509Certificate *x) { enum { tmp_buf_len = 512 }; char *tmp_buf; unsigned len; pj_assert(pool && ci && x); /* Init */ tmp_buf = new char[tmp_buf_len]; pj_bzero(ci, sizeof(*ci)); /* Version */ ci->version = x->Version(); /* Serial number */ len = x->SerialNumber().Length(); if (len > sizeof(ci->serial_no)) len = sizeof(ci->serial_no); pj_memcpy(ci->serial_no + sizeof(ci->serial_no) - len, x->SerialNumber().Ptr(), len); /* Subject */ { HBufC *subject = NULL; TRAPD(err, subject = x->SubjectL()); if (err == KErrNone) { TPtr16 ptr16(subject->Des()); len = ptr16.Length(); TPtr8 ptr8((TUint8*)pj_pool_alloc(pool, len), len); ptr8.Copy(ptr16); pj_strset(&ci->subject.cn, (char*)ptr8.Ptr(), ptr8.Length()); } pj_str_t tmp = get_cert_name(tmp_buf, tmp_buf_len, x->SubjectName()); pj_strdup(pool, &ci->subject.info, &tmp); } /* Issuer */ { HBufC *issuer = NULL; TRAPD(err, issuer = x->IssuerL()); if (err == KErrNone) { TPtr16 ptr16(issuer->Des()); len = ptr16.Length(); TPtr8 ptr8((TUint8*)pj_pool_alloc(pool, len), len); ptr8.Copy(ptr16); pj_strset(&ci->issuer.cn, (char*)ptr8.Ptr(), ptr8.Length()); } pj_str_t tmp = get_cert_name(tmp_buf, tmp_buf_len, x->IssuerName()); pj_strdup(pool, &ci->issuer.info, &tmp); } /* Validity */ const CValidityPeriod &valid_period = x->ValidityPeriod(); TTime base_time(TDateTime(1970, EJanuary, 0, 0, 0, 0, 0)); TTimeIntervalSeconds tmp_sec; valid_period.Start().SecondsFrom(base_time, tmp_sec); ci->validity.start.sec = tmp_sec.Int(); valid_period.Finish().SecondsFrom(base_time, tmp_sec); ci->validity.end.sec = tmp_sec.Int(); /* Deinit */ delete [] tmp_buf; }
/*! Handle an IPC request. \param aMessage Message object. */ void CServiceSymbianSession::handleRequestL(const RMessage2& aMessage) { XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::handleRequestL"); // Store the message iMessage = aMessage; // Convert from Symbian to QT HBufC* request = ReadDesLC(aMessage, 0); HBufC8* data = ReadDes8LC(aMessage, 1); XQSharableFile *file = 0; if (aMessage.Function() == KIPCOperationWithSharableFile) { // Only one file support now ! file = new XQSharableFile(); AdoptSharableFile(aMessage, file); } // Shallow copy only, we want a deep copy QString d = QString::fromUtf16(request->Ptr(), request->Length()); QString operation; operation += d; XQSERVICE_DEBUG_PRINT("operation: %s", qPrintable(operation)); //QByteArray convertData; TPtr8 ptr8(data->Des()); const char* ptrz = reinterpret_cast<const char*> (ptr8.PtrZ()); //convertData.append(ptrz); QByteArray convertData(ptrz,data->Length()); XQSERVICE_DEBUG_PRINT("convertData: %s", convertData.constData()); // New request if (iCurRequest) { iObserver->handleDeleteRequest(iCurRequest); delete iCurRequest; } iCurRequest = NULL; iCurRequest = new ServiceIPCRequest(this, 0, operation); iData.clear(); // Get client info ClientInfo *client = new ClientInfo(); client->setProcessId(aMessage.SecureId().iId); client->setVendorId(aMessage.VendorId().iId); RThread clientThread; aMessage.ClientL(clientThread); CleanupClosePushL(clientThread); RProcess clientProc; CleanupClosePushL(clientProc); clientThread.Process(clientProc); client->setName(QString::fromUtf16(clientProc.Name().Ptr(), clientProc.Name().Length())); client->setCapabilities(ClientCapabilities(aMessage)); CleanupStack::PopAndDestroy(2, &clientThread); // Set the picked sharable file if any if (file != 0) { // Support only one sharable file iCurRequest->addSharableFile(file, 0); } // Add data and callback to the observer // iCurRequest->addRequestdata(convertData); iCurRequest->setClientInfo(client); // ownership passed iObserver->handleRequest(iCurRequest); CleanupStack::PopAndDestroy(2, request); }
// ---------------------------------------------------- // CRhodesAppView::HandleCommandL(TInt aCommand) // ---------------------------------------------------- // void CRhodesAppView::HandleCommandL(TInt aCommand) { /*if ( iBrCtlInterface ) { iBrCtlInterface->ClearCache(); }*/ switch ( aCommand ) { case ECmdAppRestoreSetting: { if (iBrCtlInterface) { TRect rect( Position(), Size() ); iBrCtlInterface->SetRect( rect ); iBrCtlInterface->SetBrowserSettingL(TBrCtlDefs::ESettingsSmallScreen, 1); iBrCtlInterface->SetBrowserSettingL(TBrCtlDefs::ESettingsSecurityWarnings, 1); iBrCtlInterface->SetBrowserSettingL(TBrCtlDefs::ESettingsAutoLoadImages, 1); iBrCtlInterface->SetBrowserSettingL(TBrCtlDefs::ESettingsCSSFetchEnabled, 1); iBrCtlInterface->SetBrowserSettingL(TBrCtlDefs::ESettingsECMAScriptEnabled, 1); iBrCtlInterface->SetBrowserSettingL(TBrCtlDefs::ESettingsBrowserUtf8Encoding, 1); } break; } case ECmdAppReload: { /*if (iBrCtlInterface) { iBrCtlInterface->HandleCommandL(iCommandBase + TBrCtlDefs::ECommandReload); }*/ webview_refresh(); break; } case EAknSoftkeyBack: { if (iBrCtlInterface) { //iBrCtlInterface->ClearCache(); TBrCtlDefs::TBrCtlElementType type = iBrCtlInterface->FocusedElementType(); if(type == TBrCtlDefs::EElementActivatedInputBox ) break; } } case ECmdAppBack: { if (iBrCtlInterface) { //iBrCtlInterface->ClearCache(); iBrCtlInterface->HandleCommandL(iCommandBase + TBrCtlDefs::ECommandBack); } break; } case ECmdAppForward: { if (iBrCtlInterface) { iBrCtlInterface->HandleCommandL(iCommandBase + TBrCtlDefs::ECommandForward); } break; } case ECmdAppHome: { if (iBrCtlInterface) { iBrCtlInterface->LoadUrlL(iStartPage); } break; } case EOptions: { if (iBrCtlInterface) { iBrCtlInterface->LoadUrlL(iOptionsPage); //iBrCtlInterface->ClearCache(); } break; } case ECmdTakePicture: { iRhoCamera->StopViewFinder(); iRhoCamera->StartViewFinderL(); break; } case ECmdChoosePicture: { ChoosePicture(); break; } case ELoggingOptions: { iBrCtlInterface->SetDimmed( ETrue); iBrCtlInterface->MakeVisible( EFalse ); iBrCtlInterface->DrawNow(); CLogOptionsDialog::RunDlgLD(); iBrCtlInterface->SetDimmed( EFalse ); iBrCtlInterface->MakeVisible( ETrue ); iBrCtlInterface->DrawNow(); break; } case ELogView: { rho::String strText; LOGCONF().getLogText(strText); TPtrC8 ptr8((TUint8*)strText.c_str()); HBufC *msg = HBufC::NewLC(ptr8.Length()); msg->Des().Copy(ptr8); CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL(*msg); dlg->PrepareLC(R_STAT_QUERY_DIALOG); HBufC* title = iEikonEnv->AllocReadResourceLC(R_LOG_VIEW_DIALOG_TITLE); dlg->QueryHeading()->SetTextL(*title); CleanupStack::PopAndDestroy(); //title dlg->SetExtentToWholeScreen(); dlg->RunLD(); CleanupStack::PopAndDestroy(msg); break; } /*case EAknSoftkeyCancel: { CEikButtonGroupContainer* current = CEikButtonGroupContainer::Current(); if ( current ) { current->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK ); current->SetFocus(EFalse, EDrawNow); } break; }*/ default: if (aCommand >= iCommandBase && aCommand < iCommandBase + TBrCtlDefs::ECommandIdWMLBase && iBrCtlInterface) { iBrCtlInterface->HandleCommandL(aCommand); } if (aCommand >= iCommandBase + TBrCtlDefs::ECommandIdWMLBase && aCommand < iCommandBase + TBrCtlDefs::ECommandIdRange && iBrCtlInterface) { iBrCtlInterface->HandleCommandL(aCommand); } break; } }
//----------------------------------------------------------------------------- //Function Name : void* __dlopen_r(const char* filename, int flag) //Description : To open the given dll filename. //Return Value : Valid handle value if no error, Null if dll couldn't be loaded //----------------------------------------------------------------------------- void* __dlopen_r(const char* filename,const int flag) { //convert filename to TFileName TPtrC8 ptr8( (unsigned char*)filename); TFileName fileNameBuf; CnvUtfConverter::ConvertToUnicodeFromUtf8(fileNameBuf, ptr8); TParsePtr filePathName(fileNameBuf); //if file name contains wild character if ( filePathName.IsWild() ) { SetError(KDlOpenErrNoSupport); return NULL; } //to load dll RLibrary library; TInt err; TBool isLibraryLoaded = EFalse; RFs fs; err = fs.Connect(); if ( KErrNone == err ) { TUint tempAtt; //if path is there load from this path if ( filePathName.PathPresent() ) { err = fs.Att(filePathName.FullName(), tempAtt); fs.Close(); if ( KErrNotFound != err && KErrPathNotFound != err) { err = library.Load(filePathName.FullName()); if ( KErrNone != err ) { SetError(KDlOpenErrLoading); return NULL; } isLibraryLoaded = ETrue; } } else//if there is no path its only file name { TPtrC fileName(filePathName.NameAndExt()); char* envPathName = getenv("LD_LIBRARY_PATH"); if ( envPathName ) { TPtrC8 tempPtr8((unsigned char*)envPathName); TFileName envPathBuf; CnvUtfConverter::ConvertToUnicodeFromUtf8(envPathBuf, tempPtr8); TPtrC envPath(envPathBuf); TChar delim(';'); TFileName fileToLoad; TInt pos = envPath.Locate(delim); //if delim does not found and still envPath contains value //i.e. this one is last path without delim(';') so take //this also, for this length is checked while ( KErrNotFound != pos || envPath.Length()) { //if there is no delim if (KErrNotFound == pos ) {// so last path without delim pos = envPath.Length(); } TPtrC thisPath(envPath.Left(pos)); fileToLoad = thisPath; fileToLoad.Trim(); //to check ";;" and "; ;" if (fileToLoad.Length()) { //if path does not conatin trailing \ add one if ( L'\\' != fileToLoad[fileToLoad.Length()-1] ) { fileToLoad.Append(TChar(L'\\')); } fileToLoad.Append(fileName); err = fs.Att(fileToLoad, tempAtt); if ( KErrNotFound != err && KErrPathNotFound != err) { //load file from this path err = library.Load(fileToLoad); if ( KErrNone == err ) { // dll loaded successfully from thispath isLibraryLoaded = ETrue; break; } } } if ( pos == envPath.Length()) { break; } else { envPath.Set(envPath.Mid(pos + 1)); } pos = envPath.Locate(delim); } fs.Close(); } else//load dll if only name is there and LD_LIBRARY_PATH path not set { fs.Close(); TInt err = library.Load(filePathName.NameAndExt()); if ( KErrNone != err ) { SetError(KDlOpenErrLoading); return NULL; } isLibraryLoaded = ETrue; } } //if library is loaded if ( isLibraryLoaded ) { //handle value to return void* handle = NULL; //lock list before any operation LoadedDlls()->Lock(); //is this dll already there TInt listIdx = LoadedDlls()->Find(library); //if not already open if ( KErrNotFound == listIdx ) { TDllEntry dllEntry(library, flag); dllEntry.iSymbolHeader = (TE32ExpSymInfoHdr*)library.Lookup(0); err = dllEntry.iLibrary.Duplicate(RThread()); //Close the library irrespective of the result of duplicate library.Close(); if ( KErrNone != err ) { SetError(KDlOpenErrLoading); LoadedDlls()->UnLock(); return NULL; } //add to list err = LoadedDlls()->Add(dllEntry); handle = (void*) dllEntry.iLibrary.Handle(); LoadedDlls()->UnLock(); if ( KErrNone != err ) { SetError(KDlOpenErrNoMemory); dllEntry.iLibrary.Close(); return NULL; } } else//if this dll is already in list. { //close library we already have loaded library.Close(); TDllEntry& dllEntry = LoadedDlls()->At(listIdx); //if flag is RTLD_GLOBAL store it otherwise ignore //as RTLD_LAZY and RTLD_NOW both means RTLD_NOW //so can be ignored. RTLD_LOCAL does not change previous flag if ( flag & RTLD_GLOBAL ) { dllEntry.iFlags |= RTLD_GLOBAL; } dllEntry.iRefCount++; handle = (void*) dllEntry.iLibrary.Handle(); LoadedDlls()->UnLock(); } return handle; } } SetError(KDlOpenErrLoading); return NULL; }