Appui.cpp The code below is called first
HTML Code:
case ECommand1:
{
iAppView->GetGPSInfoL();
}
break;
appview.cpp
HTML Code:
void CLBSSampleAppView::GetGPSInfoL()
{
// create CGpsPositionRequest object and put it into cleanup stack;
// pass application name as argument
CGpsPositionRequest* request = CGpsPositionRequest::NewL(
_L("LBS_0xEA962394"));
CleanupStack::PushL( request );
// get current location (this operation can be long up to 30 seconds);
// progress dialog is shown to user during this time
TBool result = request->FetchCurrentPostionL(latitude, longitude);
// delete request object
CleanupStack::PopAndDestroy(request);
if(result)
{
// Setup a file in the filesystem to download the map
SetupFileDownload();
// send HtTp request to download map
SendHTTPRequestL();
}
}
void CLBSSampleAppView::Draw( const TRect& aRect ) const
{
// Get the standard graphics context
CWindowGc& gc = SystemGc();
// Gets the control's extent
TRect drawRect( Rect());
// Clears the screen
gc.Clear( drawRect );
// Display the Map
if(iJPG_Reader)
{
if(iJPG_Reader->Bitmap())
{
if(iJPG_Reader->Bitmap()->Handle())
{
gc.DrawBitmap(aRect, iJPG_Reader->Bitmap());
}
}
}
}
void CLBSSampleAppView::SendHTTPRequestL()
{
const TInt KMaxFolatLength = 8;
const TInt KDecimalPos = 5;
TRealFormat format( KMaxFolatLength, KDecimalPos );
format.iType = KRealFormatFixed | KDoNotUseTriads;
TBuf8<KDefaultBufferSize> uri8;
uri8.Append( KGoogleMapURL );
//uri8.Append( KGoogleMapKey );
HBufC8* longitudeDes = HBufC8::NewLC(257);
longitudeDes->Des().Num(longitude,format);
HBufC8* latitudeDes = HBufC8::NewLC(257);
latitudeDes->Des().Num(latitude,format);
TBuf8<KDefaultBufferSize> TempBuffer;
TempBuffer.Format(uri8,latitudeDes,longitudeDes);
CleanupStack::PopAndDestroy(2);
// Start transaction
TRAPD(err, iEngine->IssueHTTPGetL(TempBuffer));
// TODO: Error handling
if (err)
{
}
}
// -----------------------------------------------------------------------------
// CLBSSampleAppView::SetupFileDownload()
// wset up a file in the filesystem where to download and save the corresponding map
// -----------------------------------------------------------------------------
//
void CLBSSampleAppView::SetupFileDownload()
{
_LIT(KXMLFilePath, "c:\\Data\\Images\\");
TFileName iCurrentFileName;
iCurrentFileName.Append(KXMLFilePath);
iCurrentFileName.Append(_L("drew.jpg"));
TInt err=iRLbsImage.Open(CCoeEnv::Static()->FsSession(),iCurrentFileName,EFileWrite);
if (err==KErrNotFound) // file does not exist - create it
{
err=iRLbsImage.Create(CCoeEnv::Static()->FsSession(),iCurrentFileName,EFileWrite);
}
}
// -----------------------------------------------------------------------------
//
// // Listener from the client engine
// -----------------------------------------------------------------------------
//
void CLBSSampleAppView::ClientEvent(const TDesC& aEventDescription)
{
}
// -----------------------------------------------------------------------------
//
// // Listener from the client engine to save map
// -----------------------------------------------------------------------------
//
void CLBSSampleAppView::ClientBodyReceived(const TDesC8& aBodyData)
{
TInt aPos=0;
iRLbsImage.Seek(ESeekCurrent, aPos);
iRLbsImage.Write(aBodyData); //save the file being downloaded
}
// -----------------------------------------------------------------------------
//
// // Listener from the client engine saying that map download is completed
// -----------------------------------------------------------------------------
//
void CLBSSampleAppView::ClientBodyCompleted()
{
iRLbsImage.Close();
//delete iRLbsImage;
SetImage();
}
void CLBSSampleAppView::SetImageL()
{
DrawNow();
}
// -----------------------------------------------------------------------------
//
// // Listener from the CImageReader that creation of the map to be displayed is completed.
// -----------------------------------------------------------------------------
//
void CLBSSampleAppView::ImageReadyL(const TInt& state)
{
DrawNow();
}
// -----------------------------------------------------------------------------
//
// //Start creation of the map to be displayed
// -----------------------------------------------------------------------------
//
_LIT(KTxtFileName, "c:\\Data\\Images\\drew.jpg");
void CLBSSampleAppView::SetImage()
{
iJPG_Reader = new(ELeave)CImageReader(*this);
iJPG_Reader->ConstructL(KTxtFileName);
}
HTML Code:
_LIT(KGoogleMapURL,"http://abc.com/som/image.jpg");
//global declaration
I am using LBSSample example http://wiki.forum.nokia.com/index.ph...Api_in_Symbian
Please suggest me.