void CSupLoginServiceProvider::HandleMessageL(const TDesC8 &aResponce) { __LOGSTR_TOFILE("CSupLoginServiceProvider::HandleMessageL() begins"); if (aResponce.Length() > 0) { // Construct the parser object CParser* parser = CParser::NewL(KXmlMimeType, *this); CleanupStack::PushL(parser); parser->ParseBeginL(); // Start parsing XML from a descriptor // Current class will receive events // generated by the parser parser->ParseL(aResponce); parser->ParseEndL(); // Destroy the parser when done. CleanupStack::PopAndDestroy(parser); } else { // Current logging status iLogged = EFalse; iRequestObserver->HandleRequestCompletedL(KErrUnknown); return; } __LOGSTR_TOFILE("CSupLoginServiceProvider::HandleMessageL() ends"); }
void CSupLoginServiceProvider::ConstructL() { __LOGSTR_TOFILE("CSupLoginServiceProvider::ConstructL() begins"); // Form full path to credentials settings file RFs &fs = CCoeEnv::Static()->FsSession(); TFileName privatePath; fs.PrivatePath(privatePath); TParse parser; TFileName processFileName(RProcess().FileName()); User::LeaveIfError(parser.Set(KLoginProviderSettingsFilename, &privatePath, &processFileName)); iSettingsFile = parser.FullName(); // Read credentials from settings file ReadDataFromFileL(); if (iMemberID && iUsername && iPassword) iLogged = ETrue; // Discover and retrieve description of the web service CSenXmlServiceDescription* serviceDesc = CSenXmlServiceDescription::NewLC( KServiceEndpointMemberId, KNullDesC8 ); serviceDesc->SetFrameworkIdL(KDefaultBasicWebServicesFrameworkID); // Create connection to web service iConnection = CSenServiceConnection::NewL(*this, *serviceDesc); CleanupStack::PopAndDestroy(); // serviceDesc __LOGSTR_TOFILE("CSupLoginServiceProvider::ConstructL() ends"); }
int CAafSocketUtils::SocketWrite(struct soap *soap, const char *s, size_t n) { __LOGSTR_TOFILE("CAafSocketUtils::SocketWrite() begins"); // Get thread entry point data MGSoapData* entryPointData = reinterpret_cast<MGSoapData*>(soap->user); TRequestStatus status; // Convert char* to descriptor HBufC8* data = CAafUtils::StringToDescriptor8LC(s); // Write data to socket entryPointData->GetSocketInstance()->Write(*data, status); User::WaitForRequest(status); CleanupStack::PopAndDestroy(data); __LOGSTR_TOFILE("CAafSocketUtils::SocketWrite() ends"); if (status.Int() == KErrNone) return SOAP_OK; return SOAP_ERR; }
size_t CAafSocketUtils::SocketRead(struct soap *soap, char *s, size_t n) { __LOGSTR_TOFILE("CAafSocketUtils::SocketRead() begins"); // Get thread entry point data MGSoapData* entryPointData = reinterpret_cast<MGSoapData*>(soap->user); // Return value size_t bufferLength = 0; // Status object TRequestStatus status; // Initialize memory for income buffer TUint8* desBuffer = new TUint8[TInt(n)]; TPtr8 bufPtr(NULL, 0); bufPtr.Set(desBuffer, 0, TInt(n)); // Read socket content entryPointData->GetSocketInstance()->Read(bufPtr, status); User::WaitForRequest(status); // Convert retrieved buffer to temp char* pointer char* tempString = reinterpret_cast<char*>(desBuffer); // Find last occurrence of the '>' symbol char* lastOccurrence = NULL; lastOccurrence = strrchr(tempString, '>'); if (lastOccurrence) { // Get position of the last occurrence of the '>' symbol int pos = lastOccurrence - tempString; // Copy read buffer content to output array Mem::Copy(s, tempString, pos+1); // Set end null value s[pos+1] = '\0'; delete [] desBuffer; desBuffer = NULL; // Get read buffer length bufferLength = strlen(s); } __LOGSTR_TOFILE("CAafSocketUtils::SocketRead() ends"); // In case of success return size of read buffer if (status.Int() == KErrNone || status.Int() == KErrEof) return bufferLength; return 0; }
void CAafAppCameraView::StartViewFinderL() { __LOGSTR_TOFILE("CAafAppCameraView::StartViewFinderL() begins"); if (iContainer) { iContainer->StartViewFinderL(); } __LOGSTR_TOFILE("CAafAppCameraView::StartViewFinderL() ends"); }
void CSupLoginServiceProvider::CancelLogin() { __LOGSTR_TOFILE("CSupLoginServiceProvider::CancelLogin() begins"); // Set cancel status iCancelStatus = ETrue; if (iConnection) { iConnection->Cancel(); } __LOGSTR_TOFILE("CSupLoginServiceProvider::CancelLogin() ends"); }
SOAP_SOCKET CAafSocketUtils::SocketOpen(struct soap *soap, const char *endpoint, const char *host, int port) { __LOGSTR_TOFILE("CAafSocketUtils::SocketOpen() begins"); // Set endpoint if (endpoint) strncpy(soap->endpoint, endpoint, sizeof(soap->endpoint)-1); // Get thread entry point data MGSoapData* entryPointData = reinterpret_cast<MGSoapData*>(soap->user); // Open socket entryPointData->GetSocketInstance()->Open(*entryPointData->GetConnectionManager()->GetSocketServ(), KAfInet, KSockStream, KProtocolInetTcp, *entryPointData->GetConnectionManager()->GetConnection()); RHostResolver hostResolver; // Open resolver socket User::LeaveIfError(hostResolver.Open(*entryPointData->GetConnectionManager()->GetSocketServ(), KAfInet, KProtocolInetTcp)) ; TNameEntry hostAddress; TRequestStatus status; HBufC* serverName = CAafUtils::StringToDescriptorLC(host); // Attempt to resolve name hostResolver.GetByName(*serverName, hostAddress, status); CleanupStack::PopAndDestroy(serverName); User::WaitForRequest(status); // Connect to the specified host TInetAddr addrOnPort; addrOnPort = hostAddress().iAddr; addrOnPort.SetPort((TUint)port); entryPointData->GetSocketInstance()->Connect(addrOnPort, status); User::WaitForRequest(status); __LOGSTR_TOFILE("CAafSocketUtils::SocketOpen() ends"); if (status.Int() == KErrNone) return SOAP_OK; return SOAP_ERR; }
void CSMSSender::SendSMSL(const TDesC& aText, const TDesC& aAddress, TRequestStatus& aStatus) /** Send an SMS message Asynchronously @param aText buffer containing ascii contents of message to send @param aAddress buffer with telephone number of SMS receiver @param aStatus TRequestStatus which receives completion notification following a Send @capability NetworkServices @capability ReadUserData */ { __LOGSTR_TOFILE("create message"); CreateSMSMessageL(aText, aAddress); __LOGSTR_TOFILE("socket ioctl"); iSocket.Ioctl(KIoctlSendSmsMessage, aStatus, &iBuf, KSolSmsProv); __LOGSTR_TOFILE("send sms end"); }
TInt CAafAppCameraView::CountComponentControls() const { __LOGSTR_TOFILE("CAafAppCameraView::CountComponentControls() is called"); if (!iContainer) return 0; return 1; // returns number of controls inside the container }
// Activates this view, called by framework void CAafAppCameraView::ViewActivatedL(const TVwsViewId &aPrevViewId, TUid aCustomMessageId, const TDesC8 &aCustomMessage) { __LOGSTR_TOFILE("CAafAppCameraView::ViewActivatedL() ends"); if (!iContainer) { __LOGSTR_TOFILE("CAafAppCameraView::ViewActivatedL() iContainer initialization begins"); iContainer = CAafCameraContainer::NewL( Rect() ); iContainer->SetContainerWindowL( *this ); iContainer->ActivateL(); __LOGSTR_TOFILE("CAafAppCameraView::ViewActivatedL() iContainer initialization ends"); } else { iContainer->ActivateL(); iContainer->InitCameraL(); } // Set menubar and CBA CEikonEnv* eikonEnv = CEikonEnv::Static(); MEikAppUiFactory* appUiFactory = eikonEnv->AppUiFactory(); CEikMenuBar* menuBar = appUiFactory->MenuBar(); CEikButtonGroupContainer* cba = appUiFactory->Cba(); // If any menubar is displayed - stop displaying if (menuBar) menuBar->StopDisplayingMenuBar(); menuBar->SetMenuTitleResourceId(R_AAF_CAMERA_VIEW_MENUBAR); cba->SetCommandSetL(R_AAF_CBA_STANDART); cba->DrawDeferred(); // Bring this view to the top of windows stack Window().SetOrdinalPosition(0); MakeVisible(ETrue); __LOGSTR_TOFILE("CAafAppCameraView::ViewActivatedL() ends"); }
void CFileBrowserEngine::GetFileDescriptionL(const TInt &aPosition, TEntry &aFileEntry, TFileName &aFolder) { __LOGSTR_TOFILE("CFileBrowserEngine::GetFileDescriptionL() begins"); if(aPosition <= iFileList.Count()) { // Get specified file description aFileEntry = iFileList[aPosition]; aFolder.Copy(iDirList[aPosition]); } else { __LOGSTR_TOFILE("CFileBrowserEngine::GetFileDescriptionL() ends with panic EFileBrowserInvalidIndex"); Panic(EFileBrowserIvalidIndex); } __LOGSTR_TOFILE("CFileBrowserEngine::GetFileDescriptionL() ends"); }
void CAafAppFileBrowserView::ShowFileProperties() { __LOGSTR_TOFILE("CAafAppFileBrowserView::ShowFileProperties() begins"); if (!IsCurrentItemDir()) { TEntry fileEntry; TFileName folderPath; __LOGSTR_TOFILE("CAafAppFileBrowserView::ShowFileProperties() step 01"); // File description iBrowserEngine->GetFileDescription2L(iListBox->CurrentItemIndex(), fileEntry, folderPath); // Load dialog from resources CAknMessageQueryDialog* dlg = new (ELeave)CAknMessageQueryDialog(); dlg->PrepareLC(R_FILEPROPERTIES_DIALOG); // Set dialog title dlg->QueryHeading()->SetTextL(fileEntry.iName); // Form dialog body text folderPath = TFileName(KNullDesC); _LIT(KSizeString, "Size:\t%d Kb\n\nDate,\ntime:\t"); folderPath.Format(KSizeString, fileEntry.iSize/(1 << 10)); TBuf<30> dateString(KNullDesC); _LIT(KDateString, "%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B"); fileEntry.iModified.FormatL(dateString, KDateString); folderPath.Append(dateString); dlg->SetMessageTextL(folderPath); __LOGSTR_TOFILE("CAafAppFileBrowserView::ShowFileProperties() step 02"); // Run dialog dlg->RunLD(); } __LOGSTR_TOFILE("CSupAppFileBrowserView::ShowFileProperties() ends"); }
// --------------------------------------------------------- // CAafCameraContainer::OfferKeyEventL() // Handling key events // --------------------------------------------------------- // TKeyResponse CAafCameraContainer::OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType) { __LOGSTR_TOFILE("CAafCameraContainer::OfferKeyEventL() begins"); if(aKeyEvent.iScanCode == EStdKeyDevice3 && aType == EEventKey) { iEngine->CaptureL(); return EKeyWasConsumed; } return EKeyWasNotConsumed; }
int CAafSocketUtils::SocketClose(struct soap *soap) { __LOGSTR_TOFILE("CAafSocketUtils::SocketClose() begins"); // Get thread entry point data MGSoapData* entryPointData = reinterpret_cast<MGSoapData*>(soap->user); if (entryPointData->GetSocketInstance()) { entryPointData->GetSocketInstance()->Close(); } else { return SOAP_ERR; } __LOGSTR_TOFILE("CAafSocketUtils::SocketClose() ends"); return SOAP_OK; }
CSupLoginServiceProvider* CSupLoginServiceProvider::InstanceL() { __LOGSTR_TOFILE("CSupLoginServiceProvider::InstanceL() begins"); CSupLoginServiceProvider* controllerInstance = static_cast<CSupLoginServiceProvider*> ( CCoeEnv::Static( KUidSupLoginController ) ); if (!controllerInstance) { // Create instance controllerInstance = new (ELeave)CSupLoginServiceProvider; CleanupStack::PushL( controllerInstance ); controllerInstance->ConstructL(); CleanupStack::Pop(); } __LOGSTR_TOFILE("CSupLoginServiceProvider::InstanceL() ends"); return controllerInstance; }
// ----------------------------------------------------------------------------- // CAafAppCameraView::ConstructL() // Symbian 2nd phase constructor can leave. // ----------------------------------------------------------------------------- // void CAafAppCameraView::ConstructL( const TRect& aRect ) { __LOGSTR_TOFILE("CAafAppCameraView::ConstructL() begins"); // Create a window for this application view CreateWindowL(); #if USE_SKIN_SUPPORT iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain, aRect, ETrue); #endif // Set the windows size SetRect( aRect ); __LOGSTR_TOFILE("CAafAppCameraView::ConstructL() before ActivateL()"); // Activate the window, which makes it ready to be drawn ActivateL(); __LOGSTR_TOFILE("CAafAppCameraView::ConstructL() ends"); }
void CSupLoginServiceProvider::HandleErrorL(const TInt aErrorCode, const TDesC8 &aMessage) { __LOGSTR_TOFILE2("CSupLoginServiceProvider::HandleErrorL() begins with aErrorCode == %d and aMessage == %S", aErrorCode, &aMessage); // Re-read credentials data from file ReadDataFromFileL(); // Callback to the request observer iRequestObserver->HandleRequestCompletedL(aErrorCode); __LOGSTR_TOFILE("CSupLoginServiceProvider::HandleErrorL() ends"); }
TFileName CFileBrowserEngine::GetFileNameL(TInt aPosition) { __LOGSTR_TOFILE1("CFileBrowserEngine::GetFileNameL() begins with aPosition == %d", aPosition); TFileName filePath(KNullDesC);//= iDirList[aPosition]; if(aPosition <= iFileList.Count()) { // Get specified file's full path filePath.Append(iFileList[aPosition].iName); } else { __LOGSTR_TOFILE("CFileBrowserEngine::GetFileNameL() ends with panic == EFileBrowserInvalidIndex"); Panic(EFileBrowserIvalidIndex); } __LOGSTR_TOFILE("CFileBrowserEngine::GetFileNameL() ends"); return filePath; }
TInt CSupLoginServiceProvider::RequestMemberID(const TDesC8 &aRequestUsername, const TDesC8 &aRequestPassword) { __LOGSTR_TOFILE("CSupLoginServiceProvider::RequestMemberID() begins"); // If current operation should be cancelled if (iCancelStatus) return KErrCancel; // Create empty SOAP message to hold the controller application CSenSoapMessage* soapRequest = CSenSoapMessage::NewL(); CleanupStack::PushL(soapRequest); // Set SOAP action HTTP header soapRequest->SetSoapActionL(KSoapActionMemberId); // Get handle to SOAP body element CSenElement& messageBody = soapRequest->BodyL(); // Add new GetMemberID element into SOAP body CSenElement& memberidRequest = messageBody.AddElementL(KServiceXmlns, _L8("GetMemberID")); // Add username child element into the SOAP body CSenElement& usernameString = memberidRequest.AddElementL(_L8("NickName")); usernameString.SetContentL( aRequestUsername ); // Add password element to the request CSenElement& passwordString = memberidRequest.AddElementL(_L8("WebPassword")); passwordString.SetContentL( aRequestPassword ); // Submit SOAP async request TInt retValue = iConnection->SendL(*soapRequest); CleanupStack::PopAndDestroy(); // soapRequest __LOGSTR_TOFILE("CSupLoginServiceProvider::RequestMemberID() ends"); return retValue; }
void CFileBrowserEngine::GetFileDescription2L(const TInt &aPosition, TEntry &aFileEntry, TFileName &aFolder) { __LOGSTR_TOFILE("CFileBrowserEngine::GetFileDescription2L() begins"); if(aPosition >= iCurrentFolders.Count() && aPosition <= (iCurrentFolders.Count() + iCurrentFiles.Count())) { // Get specified file description if (iCurrentDirectory.Length() == 0) aFileEntry = iCurrentFiles[aPosition-iCurrentFolders.Count()]; else aFileEntry = iCurrentFiles[aPosition-iCurrentFolders.Count()-1]; aFolder.Copy(iCurrentDirectory); } else { __LOGSTR_TOFILE("CFileBrowserEngine::GetFileDescription2L() ends with panic EFileBrowserInvalidIndex"); Panic(EFileBrowserIvalidIndex); } __LOGSTR_TOFILE("CFileBrowserEngine::GetFileDescription2L() ends"); }
TInt CSupLoginServiceProvider::StartLoginL(MRequestObserver* aObserver, const TDesC8 &aUsername, const TDesC8 &aPassword) { __LOGSTR_TOFILE("CSupLoginServiceProvider::StartLoginL() begins"); // If current operation should be cancelled if (iCancelStatus) return KErrCancel; __ASSERT_ALWAYS(aObserver, Panic(ENoObserver)); // Set observer of the login request iRequestObserver = aObserver; // Code should be added later if (iUsername) { delete iUsername; iUsername = NULL; } iUsername = aUsername.AllocL(); if (iPassword) { delete iPassword; iPassword = NULL; } iPassword = aPassword.AllocL(); __LOGSTR_TOFILE2("CSupLoginServiceProvider::StartLoginL() iUsername == %S and iPassword == %S", iUsername, iPassword); // Request for the member id TInt retValue = RequestMemberID(*iUsername, *iPassword); __LOGSTR_TOFILE("CSupLoginServiceProvider::StartLoginL() ends"); return retValue; }
// ----------------------------------------------------------------------------- // CAafAppCameraView::SizeChanged() // Called by framework when the view size is changed. // ----------------------------------------------------------------------------- // void CAafAppCameraView::SizeChanged() { __LOGSTR_TOFILE("CAafAppCameraView::SizeChanged() begins"); #if USE_SKIN_SUPPORT if(iBgContext) { iBgContext->SetRect(Rect()); if ( &Window() ) { iBgContext->SetParentPos( PositionRelativeToScreen() ); } } #endif if ( iContainer ) { CAafAppUi* appUi = (CAafAppUi*)iCoeEnv->AppUi(); iContainer->SetRect( appUi->ClientRect() ); } __LOGSTR_TOFILE("CAafAppCameraView::SizeChanged() ends"); }
TBool CFileBrowserEngine::RemoveCurrentItems(CDesCArray* aItems) { __LOGSTR_TOFILE("CFileBrowserEngine::RemoveCurrentItemsL() begins"); if (iCurrentFolders.Count()+iCurrentFiles.Count()) { if (iCurrentDirectory.Length() == 0) { aItems->Delete(0, (iCurrentFolders.Count()+iCurrentFiles.Count())); } else { aItems->Delete(0, (iCurrentFolders.Count()+iCurrentFiles.Count()+1)); } __LOGSTR_TOFILE("CFileBrowserEngine::RemoveCurrentItemsL() returns ETrue"); return ETrue; } __LOGSTR_TOFILE("CFileBrowserEngine::RemoveCurrentItemsL() returns EFalse"); return EFalse; }
TBool CSupLoginServiceProvider::WriteDataToFileL() { __LOGSTR_TOFILE("CSupLoginServiceProvider::WriteDataToFileL() begins"); // If current operation should be cancelled if (iCancelStatus) return EFalse; // Return value TBool retValue = EFalse; // If credentials data is not empty if (iMemberID && iUsername && iPassword) { retValue = ETrue; RFs fsSession; RFileWriteStream writeStream; // Write file stream // Install write file session User::LeaveIfError(fsSession.Connect()); CleanupClosePushL(fsSession); // Open file stream // if already exists - replace with newer version TInt err = writeStream.Replace(fsSession, iSettingsFile, EFileStream | EFileWrite | EFileShareExclusive); CleanupClosePushL(writeStream); // Return EFalse if failed to open stream if (err != KErrNone) { retValue = EFalse; __LOGSTR_TOFILE("CSupLoginServiceProvider::WriteDataToFileL() failed to open file"); } if (retValue) { __LOGSTR_TOFILE("CSupLoginServiceProvider::WriteDataToFileL() succeed to open the file"); // Write data // iMemberID writeStream.WriteInt32L(iMemberID->Des().MaxLength()); writeStream << *iMemberID; // iUsername writeStream.WriteInt32L(iUsername->Des().MaxLength()); writeStream << *iUsername; // iPassword writeStream.WriteInt32L(iPassword->Des().MaxLength()); writeStream << *iPassword; // Just to ensure that any buffered data is written to the stream writeStream.CommitL(); } // Free resource handlers CleanupStack::PopAndDestroy(&writeStream); CleanupStack::PopAndDestroy(&fsSession); } __LOGSTR_TOFILE("CSupLoginServiceProvider::WriteDataToFileL() ends"); return retValue; }
CCoeControl* CAafAppCameraView::ComponentControl(TInt aIndex) const { __LOGSTR_TOFILE("CAafAppCameraView::ComponentControl() is called"); return iContainer; }
void CFileBrowserEngine::GetCurrentItemsL(CDesCArray* aItems) { __LOGSTR_TOFILE("CFileBrowserEngine::GetCurrentItemsL() begins"); aItems->Reset(); // If the current directory is not the first one, // add '...' entry as the first element of the listbox if (iCurrentDirectory.Length() > 0) { TFileName upperLevel(KNullDesC); upperLevel.Format(KStringUp, 2); aItems->AppendL(upperLevel); } // Retrieve folders names TFileName folderName(KNullDesC); if (iCurrentDirectory.Length() == 0) { // Get CCoeEnv instance CEikonEnv* eikonEnv = CEikonEnv::Static(); HBufC* stringHolder1 = StringLoader::LoadL(R_FILEBROWSER_PHONEMEMORY, eikonEnv ); HBufC* stringHolder2 = StringLoader::LoadL(R_FILEBROWSER_CARDMEMORY, eikonEnv ); for (TInt i = 0; i < iCurrentFolders.Count(); i++) { // As icon we use folder icon (index 0) if ( i == 0) { TFileName fileName = iCurrentFolders[i].iName; fileName.Append(*stringHolder1); folderName.Format(KStringIcon, 3, &fileName); } else { TFileName fileName = iCurrentFolders[i].iName; fileName.Append(*stringHolder2); folderName.Format(KStringIcon, 4, &fileName); } aItems->AppendL(folderName); } delete stringHolder2; stringHolder2 = NULL; delete stringHolder1; stringHolder1 = NULL; } else { for (TInt i = 0; i < iCurrentFolders.Count(); i++) { // As icon we use folder icon (index 0) folderName.Format(KStringIcon, 0, &iCurrentFolders[i].iName); aItems->AppendL(folderName); } } // Retrieve files names TFileName fileName(KNullDesC); for (TInt i = 0; i < iCurrentFiles.Count(); i++) { // As folder we use file icon (index 1) fileName.Format(KStringIcon, 1, &iCurrentFiles[i].iName); aItems->AppendL(fileName); } __LOGSTR_TOFILE("CFileBrowserEngine::GetCurrentItemsL() ends"); }
TInt CFileBrowserEngine::OpenOrLaunchCurrentL(TInt aPosition) { __LOGSTR_TOFILE1("CFileBrowserEngine::OpenOrLaunchCurretnL() begins aPosition == %d", aPosition); // Return value TInt retValue = KErrNone; // Shift correction to the item position, // for the case when '...' item is used TInt posShift = 0; if (iCurrentDirectory.Length() > 0 && aPosition > 0) { posShift = 1; } // If passed index is valid if(aPosition >= 0 && (aPosition < (iCurrentFiles.Count() + iCurrentFolders.Count() + posShift) || (iCurrentFolders.Count() + iCurrentFiles.Count()) == 0)) { TFileName descr = iCurrentDirectory; // Open the file if (aPosition > iCurrentFolders.Count() && aPosition <= iCurrentFiles.Count()+iCurrentFiles.Count()) { __LOGSTR_TOFILE("CFileBrowserEngine::OpenOrLaunchCurretnL() opens file"); // Add filename to be launched descr.Append(iCurrentFiles[aPosition-iCurrentFolders.Count()-1].iName); // Create nullType. This makes the DocumentHandler to figure out the posfix for us. TDataType nullType; // Launch the appropriate application for this file iDocHandler->OpenFileEmbeddedL(descr, nullType); iDocHandler->SetExitObserver(this); iDocEmbedded = ETrue; } // Open folder else { // Go to upper level if (aPosition == 0 && iCurrentDirectory.Length() > 0) { // If we are in the KDirPictures directory // Go to first level TFileName phoneRoot = PathInfo::PhoneMemoryRootPath(); TFileName cardRoot = PathInfo::MemoryCardRootPath(); phoneRoot.Append(KDirPictures); cardRoot.Append(KDirPictures); // Open root directory if (iCurrentDirectory == phoneRoot || iCurrentDirectory == cardRoot) { __LOGSTR_TOFILE("CFileBrowserEngine::OpenOrLaunchCurretnL() goes upper to root directory"); TFileName firstDirectory = TFileName(KNullDesC); GetEntriesL(firstDirectory); } // Otherwise // just go the upper level else { // Delete the last one directory in the path iCurrentDirectory.Delete(iCurrentDirectory.Length()-1, 1); TInt slashPos = iCurrentDirectory.LocateReverse('\\'); if (slashPos >= 0 && slashPos < iCurrentDirectory.Length()-1) { iCurrentDirectory.Delete(slashPos+1, iCurrentDirectory.Length()-slashPos-1); } __LOGSTR_TOFILE1("CFileBrowserEngine::OpenOrLaunchCurretnL() goes upper to directory %S", &iCurrentDirectory); RDebug::Print(_L("Formed folder: %S"), &iCurrentDirectory); GetEntriesL(iCurrentDirectory); } } // Open directory else { // If the current directory is the first folder if (iCurrentDirectory.Length() == 0) { TFileName folderPath = TFileName(KNullDesC); if (aPosition == 0) { folderPath = PathInfo::PhoneMemoryRootPath(); } else if (aPosition == 1) { folderPath = PathInfo::MemoryCardRootPath(); } folderPath.Append(iCurrentFolders[aPosition].iName); folderPath.Append(KSlash); __LOGSTR_TOFILE1("CFileBrowserEngine::OpenOrLaunchCurretnL() opens folder %S", &folderPath); RDebug::Print(_L("Formed folder: %S"), &folderPath); GetEntriesL(folderPath); } // Otherwise else { TFileName folderPath = iCurrentDirectory; folderPath.Append(iCurrentFolders[aPosition-1].iName); folderPath.Append(KSlash); __LOGSTR_TOFILE1("CFileBrowserEngine::OpenOrLaunchCurretnL() opens folder %S", &folderPath); RDebug::Print(_L("Formed folder: %S"), &folderPath); GetEntriesL(folderPath); } } } } // Otherwise else { retValue = KErrUnknown; } __LOGSTR_TOFILE("CFileBrowserEngine::OpenOrLaunchCurretnL() ends"); return retValue; }
void CFileBrowserEngine::GetEntriesL(TFileName &aFolder) { __LOGSTR_TOFILE1("CFileBrowserEngine::GetEntriesL() begins with aFolder == %S", &aFolder); // If passed argument is empty // retrieve first level folders (i.e. memory root and flash images start folders) if (aFolder.Length() == 0) { iCurrentDirectory = TFileName(KNullDesC); iCurrentFiles.Reset(); iCurrentFolders.Reset(); TFileName phoneRoot = PathInfo::PhoneMemoryRootPath(); TFileName cardRoot = PathInfo::MemoryCardRootPath(); phoneRoot.Append(KDirPictures); cardRoot.Append(KDirPictures); if (BaflUtils::PathExists(iFsSession, phoneRoot)) { RDebug::Print(_L("Phone images root: %S"), &phoneRoot); TEntry phoneEntry; iFsSession.Entry(phoneRoot, phoneEntry); iCurrentFolders.Append(phoneEntry); } if (BaflUtils::PathExists(iFsSession, cardRoot)) { RDebug::Print(_L("Card images root: %S"), &cardRoot); TEntry cardEntry; iFsSession.Entry(cardRoot, cardEntry); iCurrentFolders.Append(cardEntry); } } // Otherwise else { // If specified folder doesn't exist - just return if(!BaflUtils::PathExists(iFsSession, aFolder)) { __LOGSTR_TOFILE1("CFileBrowserEngine::GetEntriesL() specifed folder doesn't exist: %S", &aFolder); RDebug::Print(_L("Specified folder doesn't exist: %S"), &aFolder); return; } // Otherwise retrieve lists of directories and files inside CDir* folders = 0; CDir* files = 0; iCurrentFolders.Reset(); iCurrentFiles.Reset(); // Get directory KEntryAttNormal means that no hidden files or directories are included User::LeaveIfError(iFsSession.GetDir(aFolder, KEntryAttNormal, ESortByName, files, folders)); CleanupStack::PushL(folders); CleanupStack::PushL(files); // Get folders in the specified folder for( TInt i = 0; i < folders->Count(); i++ ) { // Exclude directories beginning with '_' as they can // contain system-generated thumbnails etc. if( (*folders)[i].iName[0] != '_') { iCurrentFolders.Append( (*folders)[i] ); } } // Get files in the specified folder for( TInt i = 0; i < files->Count(); i++ ) { #if USE_FILEBROWSER_FILTER if ((*files)[i].iName.Right(4) == KPngExt || (*files)[i].iName.Right(4) == KJpgExt) { #endif iCurrentFiles.Append( (*files)[i] ); #if USE_FILEBROWSER_FILTER } #endif } CleanupStack::PopAndDestroy( 2, folders); iCurrentDirectory = aFolder; } __LOGSTR_TOFILE("CFileBrowserEngine::GetEntriesL() ends"); }
TBool CSupLoginServiceProvider::ReadDataFromFileL() { __LOGSTR_TOFILE("CSupLoginServiceProvider::ReadDataFromFileL() begins"); // If current operation should be cancelled if (iCancelStatus) return EFalse; TBool retValue = ETrue; RFs fsSession; RFileReadStream readStream; // Read stream from file // Install read file session User::LeaveIfError(fsSession.Connect()); CleanupClosePushL(fsSession); TInt err = readStream.Open(fsSession, iSettingsFile, EFileStream | EFileRead | EFileShareExclusive); CleanupClosePushL(readStream); // If file does not exist - return EFalse if (err != KErrNone) { retValue = EFalse; __LOGSTR_TOFILE("CSupLoginServiceProvider::ReadDataFromFileL() failed to open"); } if (retValue) { TInt valueMaxLen = 0; HBufC8* tempValue = NULL; // iMemberID valueMaxLen = readStream.ReadInt32L(); __LOGSTR_TOFILE("CSupLoginServiceProvider::ReadDataFromFileL() reading member id"); tempValue = HBufC8::NewL(readStream, valueMaxLen); if (tempValue) { if (iMemberID) { delete iMemberID; iMemberID = NULL; } iMemberID = tempValue->Des().AllocL(); delete tempValue; tempValue = NULL; } // iUsername valueMaxLen = readStream.ReadInt32L(); __LOGSTR_TOFILE("CSupLoginServiceProvider::ReadDataFromFileL() reading username"); tempValue = HBufC8::NewL(readStream, valueMaxLen); if (tempValue) { if (iUsername) { delete iUsername; iUsername = NULL; } iUsername = tempValue->Des().AllocL(); delete tempValue; tempValue = NULL; } // iPassword valueMaxLen = readStream.ReadInt32L(); __LOGSTR_TOFILE("CSupLoginServiceProvider::ReadDataFromFileL() reading password"); tempValue = HBufC8::NewL(readStream, valueMaxLen); if (tempValue) { if (iPassword) { delete iPassword; iPassword = NULL; } iPassword = tempValue->Des().AllocL(); delete tempValue; tempValue = NULL; } } // Free resource handlers CleanupStack::PopAndDestroy(&readStream); CleanupStack::PopAndDestroy(&fsSession); __LOGSTR_TOFILE("CSupLoginServiceProvider::ReadDataFromFileL() ends"); return retValue; }
void CSMSSender::CreateSMSMessageL(const TDesC& aText, const TDesC& aAddress) /** Prepare SMS specific objects ready to send via ESOCK @param aText buffer containing ascii contents of message to send @param aAddress buffer with telephone number of SMS receiver */ { #ifndef __WINS__ TSmsAddr smsAddr; smsAddr.SetSmsAddrFamily(ESmsAddrSendOnly); smsAddr.SetPort(smsAddr.Port() + 1);//ycf __LOGSTR_TOFILE("sockent bind"); iSocket.Bind(smsAddr); CSmsBuffer* smsBuffer = CSmsBuffer::NewL(); //CleanupStack::PushL(smsBuffer) is NOT used because CSmsMessage takes ownership of our buffer :-) CSmsMessage* smsMsg = CSmsMessage::NewL(iFs, CSmsPDU::ESmsSubmit, smsBuffer); CleanupStack::PushL(smsMsg); TSmsUserDataSettings smsSettings; smsSettings.SetAlphabet(TSmsDataCodingScheme::ESmsAlphabetUCS2); smsSettings.SetTextCompressed(EFalse); smsMsg->SetUserDataSettingsL(smsSettings); TBuf<KMaxAddressSize> toAddress; toAddress.Copy(aAddress); smsMsg->SetToFromAddressL(toAddress); //Get service centre address. // The method used here assumes the SMS settings are provisioned, which is true in known cases. // There are alternative partner-only APIs, however this allow this source to be kept public #ifdef EKA2 CSmsSettings* smsSCSettings = CSmsSettings::NewL(); CleanupStack::PushL(smsSCSettings); CSmsAccount* smsAccount=CSmsAccount::NewLC(); smsAccount->LoadSettingsL(*smsSCSettings); // index of the default service centre address for this service TInt defIndex; User::LeaveIfError(defIndex = smsSCSettings->DefaultServiceCenter()); // Get the service center address CSmsServiceCenter& scAddr = smsSCSettings->GetServiceCenter(defIndex); TPtrC theAddress=scAddr.Address(); HBufC* serviceCentreAddress=HBufC::NewLC(theAddress.Length()); *serviceCentreAddress=theAddress; smsMsg->SmsPDU().SetServiceCenterAddressL(*serviceCentreAddress); CleanupStack::PopAndDestroy(serviceCentreAddress);// CleanupStack::PopAndDestroy(smsAccount); CleanupStack::PopAndDestroy(smsSCSettings); #else TMsvId serviceId; CObserver* pObserver = new (ELeave) CObserver(); CleanupStack::PushL(pObserver); CMsvSession* pSession = CMsvSession::OpenSyncL(*pObserver); CleanupStack::PushL(pSession); TSmsUtilities::ServiceIdL(*pSession, serviceId, KUidMsgTypeSMS); CMsvEntry* service = pSession->GetEntryL(serviceId); CleanupStack::PushL(service); CMsvStore* msvstore = service->ReadStoreL(); CleanupStack::PushL(msvstore); CSmsSettings* smsSCSettings = CSmsSettings::NewL(); CleanupStack::PushL(smsSCSettings); smsSCSettings->RestoreL(*msvstore); TInt defIndex; User::LeaveIfError(defIndex = smsSCSettings->DefaultSC()); defIndex = smsSCSettings->DefaultSC(); // Get the default service center address CSmsNumber& scAddr = smsSCSettings->SCAddress(defIndex); TPtrC theAddress=scAddr.Address(); HBufC* serviceCentreAddress=HBufC::NewLC(theAddress.Length()); *serviceCentreAddress=theAddress; smsMsg->SmsPDU().SetServiceCenterAddressL(*serviceCentreAddress); CleanupStack::PopAndDestroy(serviceCentreAddress);// CleanupStack::PopAndDestroy(smsSCSettings); //smsSettings CleanupStack::PopAndDestroy(msvstore); CleanupStack::PopAndDestroy(service); CleanupStack::PopAndDestroy(pSession); CleanupStack::PopAndDestroy(pObserver); #endif //convert to wide HBufC* payload = HBufC::NewL(aText.Length()); CleanupStack::PushL(payload); TPtr pPayload=payload->Des(); pPayload.Copy(aText); //copy from narrow to wide and convert smsBuffer->InsertL(0, pPayload); //copies payload RSmsSocketWriteStream writeStream(iSocket); CleanupClosePushL(writeStream); writeStream << *smsMsg; // remember << operator _CAN_ leave __LOGSTR_TOFILE("write stream commit"); writeStream.CommitL(); CleanupStack::PopAndDestroy(&writeStream); CleanupStack::PopAndDestroy(2);//smsMsg, payload #endif }