SMS Reading

Login to reply to this topic.
Mon, 2007-12-03 17:06
Joined: 2007-08-04
Forum posts: 6

Hi all,

I am using the below code for SMS receiving in 60 series 3rd edition and using carbide.c++ but i got a error for declaring object;

void CinboxreadAppUi::ConstructL()
{

iSmsreceiver = CSMSReceiver::NewL(iObserver);

}
where i declare the below code in appui.h file

class CSMSReceiver;
class MSMSRecCallBack;

CSMSReceiver* iSmsreceiver;

MSMSRecCallBack* iObserver;

please help me for solving the error i.e.

illegal implicit conversion from MSMSRecCallBack* to MSMSRecCallBack&


Sanjay Singh


Mon, 2007-12-03 19:48
Joined: 2005-11-20
Forum posts: 1058
Re: SMS Reading

Just a guess: Try this, with an added "*" for more C++ fun:

iSmsreceiver = CSMSReceiver::NewL(*iObserver);


René Brunner

Tue, 2007-12-04 08:04
Joined: 2007-08-04
Forum posts: 6
Re: SMS Reading

Thanks for reply but i have already tried this but still getting problem
this time i make changes in SMSReceive.h
class MSMSRecCallBack;
MSMSRecCallBack& iObserver;

and in appui.cpp
iSMSReceiver = CSMSReceiver :: NewL(*iObserver);

but i got error

a pointer/array type was expected for this operation instead of MSMSRecCallBack

& reference member 'iObserver' is not initialise

actually i am using SMSReceiver.cpp and SMSReceiver.h code is there any other way to read the content of inbox message in 9.1.


Sanjay Singh

Tue, 2007-12-04 10:24
Joined: 2004-10-07
Forum posts: 34
Re: SMS Reading

Hi sanjay,
Do little modification as follows:
Derive your Appui class with MSMSRecCallBack and
Implements all methods of MSMSRecCallBack in Appui
Create object of CSMSReceiver iSmsreceiver = CSMSReceiver::NewL(*this);


Thanks & Regards,
Symbi

Wed, 2007-12-05 08:31
Joined: 2007-08-04
Forum posts: 6
Re: SMS Reading

Hi,
I tried this CSMSReceiver iSmsreceiver = CSMSReceiver::NewL(*this); but stll I am getting error.

Please help if there is any alternative.

Thanks.


Sanjay Singh

Wed, 2007-12-05 09:24
Joined: 2007-10-29
Forum posts: 2
Re: SMS Reading

await..... Puzzled

Thu, 2007-12-06 07:02
Joined: 2007-11-02
Forum posts: 37
Re: SMS Reading

Hi,
I am just a beginner and am trying to help!!!!
May not be technicaly so good(neither symbian nor C++).So, please forgive if I write anything wrong....
I am not sure, but ,think something wrong in the way ---------

void CinboxreadAppUi::ConstructL()
{

iSmsreceiver = CSMSReceiver::NewL(iObserver);

}

MSMSRecCallBack* iObserver;

------------------------------------------------------------
Here,
1.Constructor is called to initialise heap memory of AppUi class.
2.All pointer type member variables are initialised to NULL
3.Then 2-phase constructor starts
4.Pointer variables are to be initialised there.
5. iSmsreceiver = CSMSReceiver::NewL(iObserver);
--------This line requires that "iObserver"(which is also a pointer variable) should be initalised inside ConstructL() before a call to this line is made.
------So, it depends on sequence of calls to initialise pointer variables
So, there arises 3 options
a.make sure "iObserver" is initialised before iSmsReceiver(in ur second reply you have used "&iObserver" which gives error "& reference member 'iObserver' is not initialise")
b.else make iObserver a direct variable , not pointer variable(not sure if it can be done)
c.else use inheritance to get "iObserver" object

About other approach->

To read body of incoming sms, there is another approach in osv9.2

derive from MMsvSessionObserver,
and write your code under case EMsvEntries Created:
of HandleSessionEvent()

Sorry if I am wrong!!!!!!!!

Thu, 2007-12-06 09:57
Joined: 2007-09-20
Forum posts: 95
Re: SMS Reading

Hi,

The solution suggested by Rene should work. Eye-wink

Do not change the definition of "iObserver", keep it as a pointer variable.

//In .h header file

class CSMSReceiver;
class MSMSRecCallBack;

CSMSReceiver* iSmsreceiver;

MSMSRecCallBack* iObserver;


//In .cpp file
void CinboxreadAppUi::ConstructL()
{

iSmsreceiver = CSMSReceiver::NewL(*iObserver);
//This must be declared as "  CSMSReceiver::NewL(MSMSRecCallBack& )" in its header file

}


Chao,
Raghav

Tue, 2007-12-11 12:21
Joined: 2007-09-19
Forum posts: 33
Re: SMS Reading

MSMSRecCallBack& iObserver;
This will not work as wheneve u declare a referance it shoul b initialised (irrespective of the type of reference).
So the soln posted by raghav_an sud work .if its not pls tell the error u r getting so that we can help.

Regards,
Amogh


Amogh

  • Login to reply to this topic.