Server Localization Question
| Thu, 2005-05-05 15:22 | |
|
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. |
|






Forum posts: 51
http://www3.symbian.com/faq.nsf/0/20313FA4BE38D6B680256A570051B8C9?OpenDocument
B
Forum posts: 8
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.
Forum posts: 1379
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:
// 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
Forum posts: 8
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.
Forum posts: 276
Don't you have to call ConfirmSignatureL() before calling AllocReadLC in
Regards
Dennis
Today is a gift by GOD, that's why it is called the present.
Forum posts: 1379
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
Forum posts: 276
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.
Forum posts: 276
Dennis
Today is a gift by GOD, that's why it is called the present.
Forum posts: 1379
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
Forum posts: 276
But I am working on UIQ 2.0 emulator.....
Dennis
Today is a gift by GOD, that's why it is called the present.
Forum posts: 1379
didster
Forum posts: 276
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.
Forum posts: 1379
Anyway, it's probably a good idea to call it for both UIQ and S60 regardless.
didster
Forum posts: 276
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.
Forum posts: 4
The API doc states ConfirmSig, is required to be called before using:
http://www.symbian.com/developer/techlib/v70sdocs/doc_source/reference/cpp/InterfaceToResourceFiles/RResourceFileClass.html#%3a%3aRResourceFile%3a%3aConfirmSignatureL%28%29