Sunday, March 18, 2007

Get Caller Number

Below is the code illustarating how to get the remote party's telephone number. It is different for S60 3rd Edition and previous versions.

In V8 and Below
#include

void GetRemotePartyPhoneNumberL(TDes& aPhoneNumber)
{
RTelServer etel;

// Connect to ETel server
User::LeaveIfError(etel.Connect());
CleanupClosePushL(etel);

// Load phone module. This is just to be on the safe side
// because it should have been loaded already
_LIT(KTsyName, "phonetsy.tsy");
User::LeaveIfError(etel.LoadPhoneModule(KTsyName));

RTelServer::TPhoneInfo phoneInfo;

// Get phone info. We need phone's name to open a phone
const TInt KPhoneIndex = 0;
User::LeaveIfError(etel.GetPhoneInfo(KPhoneIndex, phoneInfo));

RPhone phone;

// Open the phone
User::LeaveIfError(phone.Open(etel, phoneInfo.iName));
CleanupClosePushL(phone);

RPhone::TLineInfo lineInfo;

// Get line info. We need line's name to open it
const TInt KLineIndex = 0;
User::LeaveIfError(phone.GetLineInfo(KLineIndex, lineInfo));

RLine line;

// Open the line
User::LeaveIfError(line.Open(phone, lineInfo.iName));
CleanupClosePushL(line);

RLine::TCallInfo callInfo;

// Get call info. We need call's name to open it and get the info we need
const TInt KCallIndex = 0;
User::LeaveIfError(line.GetCallInfo(KCallIndex, callInfo));

RMobileCall call;

// Open the call
User::LeaveIfError(call.OpenExistingCall(line, callInfo.iCallName));
CleanupClosePushL(call);

RMobileCall::TMobileCallInfoV1 mobCallInfo;
RMobileCall::TMobileCallInfoV1Pckg mobCallInfoPckg(mobCallInfo);

// Get the call's info
User::LeaveIfError(call.GetMobileCallInfo(mobCallInfoPckg));

// We successfully got the call's info.
// Now copy the remote party's phone number to the target descriptor
aPhoneNumber.Copy(mobCallInfoPckg().iRemoteParty.iRemoteNumber.iTelNumber);

// Close all handles
CleanupStack::PopAndDestroy(4); // call, line, phone, etel
}

In V9 and above
void GetRemotePartyPhoneNumberL(TDes& aPhoneNumber)
{
// Create a CTelephony object
CTelephony* telephony = CTelephony::NewLC();

CTelephony::TCallInfoV1 callInfoV1;
CTelephony::TCallInfoV1Pckg callInfoV1Pckg(callInfoV1);

CTelephony::TCallSelectionV1 callSelectionV1;
CTelephony::TCallSelectionV1Pckg callSelectionV1Pckg(callSelectionV1);

CTelephony::TRemotePartyInfoV1 remotePartyInfoV1;
CTelephony::TRemotePartyInfoV1Pckg remotePartyInfoV1Pckg(remotePartyInfoV1);

callSelectionV1.iLine = CTelephony::EVoiceLine;
callSelectionV1.iSelect = CTelephony::EInProgressCall;

// Get the call info
User::LeaveIfError(telephony->GetCallInfo(callSelectionV1Pckg,
callInfoV1Pckg, remotePartyInfoV1Pckg));
// Copy the remote party's phone number to the target descriptor
aPhoneNumber.Copy(remotePartyInfoV1Pckg().iRemoteNumber.iTelNumber);

CleanupStack::PopAndDestroy(); // telephony
}

Thursday, March 15, 2007

How to guide for pre-installed applications

Introduction
---------------

In preinstalled applications, application files such as binaries are already in place in their target folders on a memory card. When a memory card with preinstalled applications is inserted into a device, the preinstalled applications are automatically installed so that the user can use them without having to install them manually.


In addition to the application files, a .sis file created with a PA type must also exist in the \private\10202dce folder on the memory card. This .sis file is also known as a "stub" .sis file since it contains sis controller data but no files.

How to create PA package
-----------------------------


Creating PA sis package
---------------------------


* Make sure that the package type is PA in the .pkg file.
* In the .pkg file, change the target drive for each file to the MMC drive.
* Make sure that correct product dependency is specified in the package file.
* Get certification for the final .sis file, ie. submit the application to Symbian Signed. When submitting, include the PA type sis, .pkg file and corresponding binaries to a .zip file. Arrange the binaries in the .zip file according to the correct structure so that binaries are located in the correct directories under
o private
o resource
o sys

You need to be aware of the folowing for PA packages:
* Do not use FR (FILERUN) options since they are not invoked in PA packages.
* The FN option can be used if the stub file is not read-only.

Do not use the FT (FILETEXT) option. It is skipped/ignored for PA packages.
* The PA .sis file cannot have embedded .sis file(s).
Sample .pkg file content for PA application:
[CODE]
;Languages
&EN

;Header
#{"Test Application"},(0x11223344),1,0,0, TYPE=PA

;Localized Vendor name
%{"Test"}

;Unique Vendor name
:"Test"

;Dependency for S60 3rd Edition
[0x101F7961], 0, 0, 0, {"Series60ProductID"}

;Preinstalled files
"MyTestApp.exe" - "e:\sys\bin\MyTestApp.exe"
"MyTestApp_reg.rsc" - "e:\private\10003a3f\import\apps\MyTestApp_reg.rsc"
"input.dat" - "e:\private\11223344\input.dat"
[/CODE]

In the development phase, you can use developer certificate to sign the PA type sis. Create the .sis file and sign it with a trusted certificate and key:

makesis.exe mytestpa.pkg mytestpa.sis

signsis.exe mytestpa.sis mytestpa_signed.sis

Publishing files to target locations on memory card

Make sure that files referred in PA package exist on memory card.

Publish PA sis file to the \private\10202dce\ folder on the memory card. Publish package files to their location as specified in .pkg file.


IMPORTANT: You need to make sure that the .pkg file used to create the PA .sis file doesn’t list files that are updated/modified during run time. These files still need to be on the memory card but they will no longer be protected against tampering. If any of the installed files (e.g., the configuration file) is updated/modified, propagation won't work when the memory card is inserted to another device or when the C drive is formatted. One possible solution to this problem is that if a file (e.g., a configuration file) is updated, application(s) will not touch the original file (only reading). Instead they will make a copy of this file and update the copy.

Upgrading pre-installed applications
-----------------------------------------

Preinstalled applications can be upgraded by overwriting the PA files with an SA package. When an SA package is installed to a memory card, it is propagated. This means that it will behave like a PA package when the memory card is inserted into another device.

Preinstalled applications cannot be upgraded by using Partial Upgrade (PU) packages. SIS Patch (SP) packages can be used to upgrade preinstalled applications but the upgrade is not propagated to the memory card. Thus, it will not be in place when the memory card is inserted into another device.

Wednesday, March 14, 2007

Moving an application to foreground / to background

1. Being notified of the focus change
Override HandleForegroundEventL() function In AppUi Class Like

void CMyAppUi::HandleForegroundEventL(TBool aForeground)
{
// Call Base class method
CAknAppUi::HandleForegroundEventL(aForeground);

if(aForeground)
{
// We have gained the focus
...
}
else
{
// We have lost the focus
...
}
}

2. Bring Application To ForeGround

void CMyAppUi::BringToForeground()
{
// Construct en empty TApaTask object
// giving it a reference to the Window Server session
TApaTask task(iEikonEnv->WsSession( ));

// Initialise the object with the window group id of
// our application (so that it represent our app)
task.SetWgId(CEikonEnv::Static()->RootWin().Identifier());

// Request window server to bring our application
// to foreground
task.BringToForeground();
}

3. Send Application To BackGround
void CMyAppUi::BringToForeground()
{
// Construct en empty TApaTask object
// giving it a reference to the Window Server session
TApaTask task(iEikonEnv->WsSession( ));

// Initialise the object with the window group id of
// our application (so that it represent our app)
task.SetWgId(CEikonEnv::Static()->RootWin().Identifier());

// Request window server to Snedour application
// to BackGround
task.SendToBackground();
}

Other Method If you want to Send or Bring Focus to Other Application

TApaTaskList tasklist(iCoeEnv->WsSession());
TApaTask task(tasklist.FindApp(_L("TestApp")));
task.SendToBackground(); // or BringToForeground()


Library: apgrfx.lib

Thursday, March 01, 2007

How to lock your phone from Code.

RAknKeyLock keyLock; // first step

User::LeaveIfError(keyLock.Connect()); // second step
CleanupClosePushL(keyLock);

keyLock.EnableKeyLock(); // third step

keyLock.Close(); // fourth step
CleanupStack::PopAndDestroy(); // keyLock
stats counter