Server Localization Question

Login to reply to this topic.
Thu, 2005-05-05 15:22
Joined: 2005-03-21
Forum posts: 8
Hi folks,

Ok - I know the topic may sound a bit daft at first, but bear with me.

I've got a server app, that runs quietly in the background doing its thing, but upon occasion it needs to throw up a warning message to the user. No problem so far (RNotifier or CAknGlobalMsgQuery on S60) can do the trick there. At the moment the message text is hard-coded into the server.

The catch is - I can't see how to add in multi-language support - so that the text changes to the appropriate language. So far as I can see, all the resource file stuff (CCoeEnv::AllocReadResourceL and StringLoader::Load) is dependent on CCoeEnv (or derived classes).

With some reservations, I tried instantiating CCoeEnv in my server. Initially, I had a problem which was that CCoeEnv tried to install a second CActiveScheduler - so I got rid of my own scheduler. But now there's lots of E32USER-CBase panics to do with the clean up stack and TRAP - I've had panics 63, 66 and 71 when trying a few things. I guess these are down to more CCoeEnv side-effects hitting me.

Now, I'm not really convinced that servers should have CCoeEnv objects - are they meant to be used in apps only?

I could mess around with CCoeEnv for days - but it may be fated to never work. So can anyone tell me if it should be possible to do this? i.e. I just need to persevere and I'll get there VERSUS This is daft and can never work? OR...

Is there another way to get into those resource files? Or am I stuck as far as Symbian built-in methods are concerned. Time for a bit of DIY?

Help! Suggestions welcomed.

Thanks a lot.

Fri, 2005-05-06 03:11
Joined: 2004-05-31
Forum posts: 51
Server Localization Question
Fri, 2005-05-06 08:40
Joined: 2005-03-21
Forum posts: 8
Server Localization Question
Thanks. That topic does confirm that CCoeEnv can be available to exe's - hence presumably servers. So it does help, thanks.

I was already doing what that FAQ suggests however. But that confirmation is nice. I'll spend some more time trying to figure out what I'm doing wrong then.

However, if anyone thinks I'm barking up the wrong tree and there's an easier way to get resource info into a server/exe file, please shout.

Cheers.
Fri, 2005-05-06 08:44
Joined: 2004-07-28
Forum posts: 1379
Server Localization Question
You really don't need to mess about with CONE into EXEs if all you want to do is read a text resource:

Code:
_LIT(KResFile, "MyApp.rsc");

RResourceFile iResFile;

CMyApp::~CMyApp()
{
iResFile.Close();
}

void CMyApp::ConstructL()
{
TFileName aFile(KResFile);
BaflUtils::NearestLanguageFile(iFs, aFile);
iResFile.OpenL(iFs, aFile);
}

HBufC* CMyApp::ReadResourceLC(TInt aId)
{
HBufC8* readBuffer = iResFile.AllocReadLC(aId);
TResourceReader theReader;
theReader.SetBuffer(readBuffer);
TPtrC textdata = theReader.ReadTPtrC();

HBufC16* textBuffer = HBufC16::NewL(textdata.Length());
*textBuffer = textdata;
CleanupStack::PopAndDestroy(readBuffer);
CleanupStack::PushL(textBuffer);
return textBuffer;
}

Will read and return the text based resource, in the same way CONE does.

Your RSS file will need to be sligtly different to usual though.  Here is an example of one which will work with the above code:

Code:

//  INCLUDES
#include <eikon.rh>
#include "MyApp.loc"

//
// Locallisation
///////////////////////////////
STRUCT STRING
   {
   LTEXT text;
   }

RESOURCE STRING r_confirm { text = q_confirm; }
RESOURCE STRING r_done { text = q_done; }


Now you just call ReadResourceLC(R_CONFIRM)

As you would do if using CONE.

didster

Fri, 2005-05-06 09:54
Joined: 2005-03-21
Forum posts: 8
Server Localization Question
Excellent. That's just what I was looking/hoping for.

As with all things Symbian, it's easy when you know how. The trick is knowing - or having luck with search engines - not to mention luck with book indexes. Luck which deserted me in this case. Actually, even now I know the answer - RResourceFile isn't in the index of the book I had. Fortunately, the Richard Harrison books arrived in the post this morning and they do have it - so hopefully, they'll give me the clues I need in future.

Anyway, thanks again - and thanks for taking the trouble to stick in all that example code too. You're a star.
Wed, 2005-05-11 04:35
Joined: 2004-12-03
Forum posts: 276
Server Localization Question
Hi didster,

Don't you have to call ConfirmSignatureL() before calling AllocReadLC in

Code:
HBufC8* readBuffer = iResFile.AllocReadLC(aId);

Regards
Dennis

Today is a gift by GOD, that's why it is called the present.

Wed, 2005-05-11 09:21
Joined: 2004-07-28
Forum posts: 1379
Server Localization Question
Nope, not to my knowledge.

I have used that code many a time to localize a EXE.  In fact, it's copied and pasted out of a working bit of code for one.

didster

Wed, 2005-05-11 10:02
Joined: 2004-12-03
Forum posts: 276
Server Localization Question
Hi,

I am saying this because I am also using the same piece of code.... and it is crashing in my emulator..... but if use ConfirmSignatureL then it runs smoothly.....

I hope you have gone through the following link
http://www.cs.tut.fi/~mobo/Symbianv6onedocs/devlib/Common/APIReference/InterfaceToResourceFiles/RResourceFileClass.html#%3a%3aRResourceFile%3a%3aConfirmSignatureL%28%29

So what do you thing am I doing wrong here..... what might be the difference in your code and mine that makes the same piece run on your end but not mine...

Dennis

Today is a gift by GOD, that's why it is called the present.

Wed, 2005-05-11 10:04
Joined: 2004-12-03
Forum posts: 276
Server Localization Question
My code is crashing in AllocReadLC if I don't use ConfirmSignatureL......

Dennis

Today is a gift by GOD, that's why it is called the present.

Wed, 2005-05-11 10:05
Joined: 2004-07-28
Forum posts: 1379
Server Localization Question
Wired.

On what emulator?  I use that on Series 60 1.2 (build with the 1.2 SDK) and S60 2.0 (built with either the 2.0 SDK or the 1.2 SDK) and it works fine on both the emulator or on target.

Are you using a resource file just like that, or do you have anything else in it?

The SDK claims you must call it before calling Alloc etc, so it probably should be in there.

didster

Wed, 2005-05-11 10:07
Joined: 2004-12-03
Forum posts: 276
Server Localization Question
I am using the same format of the resource file.....

But I am working on UIQ 2.0 emulator.....

Dennis

Today is a gift by GOD, that's why it is called the present.

Wed, 2005-05-11 10:10
Joined: 2004-07-28
Forum posts: 1379
Server Localization Question
Perhaps thats it then

didster

Wed, 2005-05-11 10:14
Joined: 2004-12-03
Forum posts: 276
Server Localization Question
The actual problem is that if I don't call ConfirmSignatureL then resource file offset is by default 0. (you will get the offset of the resource file from Offset() function)

And AllocReadLC fetches the resource by extracting 16 bits of LSB of resource ID passed... it then adds this offset to the resource offset which by default is 0.... so you get the wrong offset.... thus you get KErrNotFound error.....

But if use ConfirmSignatureL then Offset() will return the correct offset and thus no problem in AllocReadLC.....

Dennis

Today is a gift by GOD, that's why it is called the present.

Wed, 2005-05-11 10:20
Joined: 2004-07-28
Forum posts: 1379
Server Localization Question
It must be some small difference in the SDK somewhere.

Anyway, it's probably a good idea to call it for both UIQ and S60 regardless.

didster

Wed, 2005-05-11 10:23
Joined: 2004-12-03
Forum posts: 276
Server Localization Question
Yes, I agree with you....

Meanwhile I will also test the same in series 60......

And thanks for you valuable inputs

Dennis

Today is a gift by GOD, that's why it is called the present.

Wed, 2008-04-09 19:45
Joined: 2008-04-09
Forum posts: 4
Re: Server Localization Question
  • Login to reply to this topic.