Tuesday, July 31, 2007

How to Install an empty file or directory (which is not included in the SIS file).

Pre-Symbian OS v9.0:
""-"C:\Documents\deleteme", FN
""-"C:\Documents\deleteme1\", FN
""-"C:\Documents\deleteme2\*.*", FN
""-"C:\Documents\created.txt", FN
Symbian OS v9.0 and beyond:

""-"C:\private\<process SID>\deleteme", FN
""-"C:\private\<process SID>\deleteme1\", FN
""-"C:\private\<process SID>\deleteme2\*.*", FN
""-"C:\private\<process SID>\created.txt", FN

Monday, July 30, 2007

How to Sending SMS in Symbian 9

User::LeaveIfError(sendAs.Connect());
CleanupClosePushL(sendAs);

RSendAsMessage sendAsMessage;
sendAsMessage.CreateL(sendAs, KUidMsgTypeSMS);
CleanupClosePushL(sendAsMessage);

// prepare the message
sendAsMessage.AddRecipientL(aRecipient, RSendAsMessage::ESendAsRecipientTo);
sendAsMessage.SetBodyTextL(aMessageBody);

// send the message
sendAsMessage.SendMessageAndCloseL();

// sendAsMessage (already closed)
CleanupStack::Pop();

// sendAs
CleanupStack::PopAndDestroy();

Sunday, July 29, 2007

How to get the free space of every drive

Following Code can get you the free space in a drive.

RFs iFs;
iFs.Connect();
TInt err = iFs.Volume( volinfo, EDriveC );
TInt64 space = volinfo.iFree;
iFs.Close();
"iFree" is the amount of free space on the disk in bytes.

Note: Volume() will return KErrNotReady if the drive contains no media.

Saturday, July 28, 2007

Increase the heap size of an application

The default heap size of an application is 1MB, that means on target if you application tried to allocate more than 1MB memory, the allocation will fail. Probably new (ELeave) will leave.

What if you really want your application to allcoate more than 1MB memory? For example, you are developing an image processing application which needs to load big pictures.

There's a way to use a user define heap instead of the default heap, you can do this like:

GLDEF_C TInt E32Main()
{
RHeap *heap = UserHeap::ChunkHeap( NULL, 1024 * 4, 1024 * 1024 * 2 ); // 2MB
if( heap )
{
User::SwitchHeap( heap );
}
TInt ret = EikStart::RunApplication( NewApplication );
if ( heap )
{
heap->Close();
}
return ret;
}

You switch the heap to your own one, which allow you to allocate 2MB in this case

Friday, July 27, 2007

Prevent object being created on stack

In Symbian, sometimes we don't want the calling function to create a object of your class on stack, because the stack resource is rare. Is there any way we can restrict do this?

Answer is Yes.

We should make class destructor private, rather than public or protected.

Example

class CTest : public CBase
{
private:
~CTest ();
}

Thursday, July 26, 2007

When to use () and [] in PKG files?

The () are used for software dependencies, while [] are used for product dependencies. () will work in most cases, but it will throw an error if you state your file supports both UIQ 3 and S60 (which is valid for shared DLLs).

Note that, as the time of this writing, some of the documentation uses
(0x101F6300), 3, 0, 0, {"UIQ30ProductID"}
(0x101F6300), 3, 0, 0, {"Series60ProductID"}
when it should have instead
[0x101F6300], 3, 0, 0, {"UIQ30ProductID"}
[0x101F6300], 3, 0, 0, {"Series60ProductID"}

Wednesday, July 25, 2007

[Revisiting] Bluetooth Power Status Check
In my last post i showed how to detect that Blue tooth is ON / OFF in S60 v3 but in Pre-S60v3 SDKs it is bit tricky. Here is one way of achiving same thing using libs from OLD S60 v1.2 SDK. [I found this method in Forum Nokia Posted by a respected member.]
Note : Use it on your Own Rsk.


#ifndef BT_ENG_HACK_H
#define BT_ENG_HACK_H
// link against BTENG.LIB copied from SDK 1.2

// these are headers that are just not included
// in the SDK, so I had to reverse engineer them
//C:\Symbian\tilion\group>"c:\Program Files\Borland\CBuilder6\Bin\expdump.exe"
// C:\Symbian\Series60_1_2_B\epoc32\release\winsb\udeb\BTENG.LIB
class MBTMCMSettingsCB
{
};
class CBTMCMSettings;
class CBTMCMSettings
{
public:

static CBTMCMSettings* NewLC(MBTMCMSettingsCB *x);
static CBTMCMSettings* NewL(MBTMCMSettingsCB *x);

void SetPowerStateL(TBool a, TBool b);
void GetPowerStateL(TBool &a);
TInt GetConnectionStatus(int &a);
};
#endif




Powered by Qumana

Tuesday, July 24, 2007

New Blogging Tool [Qumma]

Hello Guys i got a new Tool to Blog. It is Qumana. Looks good till now let me see if it can meet my requiments.


Powered by Qumana


Bluetooth Power Status Check

Here is the Code that shows How to check that BlueTooth is ON or OFF in Symbian V9





CRepository *cRepository = CRepository::NewL(KCRUidBluetoothPowerState);
TInt bluetoothStatus=0;
User::LeaveIfError( cRepository ->Get(KBTPowerState, bluetoothStatus) );



Monday, July 23, 2007

How to Launch the browser in an embedded mode.
LaunchBrowserEmbedded()
{
CApaProcess *pApaProcess = Document()->Process();

TUid id;
id.iUid = 0x10008d39;
iDoc = pApaProcess->AddNewDocumentL(KNullDesC , id);

iDoc->EditL(this, ETrue);

TApaTaskList taskList( iEikonEnv->WsSession() );
id.iUid = 0x10208b93;//this
TApaTask task = taskList.FindApp( id );
if ( task.Exists() )
{
task.SendMessage(TUid::Uid(0), _L8("4 http://news.google.com/xhtml"));
}
}
Note:
you have to provide NotifyExit() in your AppUi to delete iDoc.

Sunday, July 22, 2007

Compress / Decompress A File with less memory usage.

void CompressAFile(TDesC& aSrcName, TDesC& aDstName)
{
RFs fs;
User::LeaveIfError(fs.Connect());
fs.SetSessionPath(_L("C:\\")); // change to your req. Path

RFile file;
TInt err = file.Open(fs,aDstName,EFileRead);

CEZFileToGZip* zip = CEZFileToGZip::NewLC(fs, aSrcName, file);
TInt tempi = 0;
while(zip->DeflateL()) // while loop req. donot remove
{
tempi++;
}
CleanupStack::PopAndDestroy(); // zip

file.Close();
fs.Close();
}


void DeCompressAFile(TDesC& aSrcName, TDesC& aDstName)
{
RFs fs;
User::LeaveIfError(fs.Connect());
fs.SetSessionPath(_L("C:\\")); // change to your req. Path

RFile file;
TInt err = file.Open(fs,aDstName,EFileRead);

CEZGZipToFile *zip = CEZGZipToFile::NewLC(fs, aSrcName, file);
TInt tempi = 0;
while(zip->InflateL()) // while loop req. donot remove
{
tempi++;
}
CleanupStack::PopAndDestroy(); // zip

file.Close();
fs.Close();
}

Saturday, July 21, 2007

Retrieving Phone's Manufacturer ,Model & IMEI number Using CTelephony

---- Header --------
CTelephony* iTel;
CTelephony:: TPhoneIdV1Pckg iInfoPkg;
CTelephony:: TPhoneIdV1 iInfo;


---- CPP File ------

void Request()
{
iTel=CTelephony::NewL();
iTel->GetPhoneId(iStatus,iInfoPkg);
SetActive();
}

void RunL()
{
switch(iStatus.Int())
{
case KErrNone:
{
TBuf
CTelephony::KPhoneModelIdSize + CTelephony::KPhoneSerialNumberSize> phoneInfo;
phoneInfo.Copy(iInfo.iManufacturer);
phoneInfo.Append(iInfo.iModel);
phoneInfo.Append(iInfo..iSerialNumber);
}
break;
default:
{
//Return error
}
break;
}
}

Friday, July 20, 2007

How to get Names of all installed applications

The following code sample shows how to get an array containing names of the installed applications.

CDesCArray* GetInstallAppListL(void)
{
CDesCArrayFlat* appArray = new(ELeave)CDesCArrayFlat(10);
CleanupStack::PushL(appArray);

RApaLsSession apaSession;
TRAPD(err, apaSession.Connect());

if(err != KErrNone)
{
CleanupStack::Pop(appArray);
return NULL;
}

CleanupClosePushL(apaSession);

TRAPD(errn, apaSession.GetAllApps());

if(err != KErrNone)
{
CleanupStack::Pop(appArray);
CleanupStack::PopAndDestroy(apaSession);
return NULL;
}

TInt errno(KErrNone);
TApaAppInfo appInfo;

do
{
errno = apaSession.GetNextApp(appInfo);
if(KErrNone == errno && appInfo.iCaption.Length())
{
appArray->AppendL(appInfo.iCaption);
}

}while(KErrNone == errno);

CleanupStack::PopAndDestroy(apaSession);

CleanupStack::Pop(appArray);
return appArray;
}
stats counter