Sunday, October 28, 2007

Minimal Symbian V9.x FrameWork Required to Start a Console Application

Assuming that my Applcation name is MyApp.exe

MyApp_req.rss

#include <appinfo.rh>

UID2 KUidAppRegistrationResourceFile
UID3 0x<your UID>

RESOURCE APP_REGISTRATION_INFO
{
app_file="MyApp";
}

MyApp.MMP to Compile registration file.
START RESOURCE    <your app>_reg.rss
#ifdef WINSCW
TARGETPATH \private\10003a3f\apps
#else
TARGETPATH \private\10003a3f\import\apps
#endif
END


Add this line your PKG File to install the registration File {MyApp_reg.rSC}
"...epoc32\release\data\z\\private\10003a3f\import\apps\MyApp_reg.rsc"-"!:\private\10003a3f\import\apps\MyApp_reg.rsc"
MD5 HexDigest for Symbian

SymbianOS provides a CMD5 class for hashing 8-bit strings, but neglects to supply a hexdigest function to supply the Hash as a hex string, as required by many web services such as Flickr.

Calling CMD5::Hash() returns an 8bit binary descriptor of the hash. This snippet of code provides the HEX representation in ASCII in line with what HexDigest() returns in java and python etc.

 HBufC8* Md5HexDigestLC(const TDes8& aString)
{
CMD5* md5 = CMD5::NewL();
CleanupStack::PushL(md5);

TPtrC8 hashedSig(md5->Hash(aString));

HBufC8* buf = HBufC8::NewL(hashedSig.Length() * 2);
TPtr8 bufPtr = buf->Des();

for(TInt i=0; i< hashedSig.Length(); i++)
{
bufPtr.AppendFormat(_L8("%+02x"),hashedSig[i]);
}
CleanupStack::PopAndDestroy(md5);
CleanupStack::PushL(buf);
return buf;
}
Get a Error Code with Python Script.

The code below Download error code reference from NewLC and stores the error code reference to a c:/temp folder. Forgetting error meaning just pass error code as argument like below.

python geterr -11


The Script is as below


import urllib
import re
import os
import pickle
import sys

temp = "c:\\temp\\"
picklefilename = os.path.join(temp, "kerr_lookupdata.txt")
try:
os.mkdir(temp)
except:
pass

# common variables

def extractErrorInfo(matchstr):

rawstr = r"""<tr class="\D*"><td>\s*<strong class="\D*">(.*)</strong>\s*</td>\s*<td>\s*(.*)\s*</td>\s*<td>\s*<i class="spip">(.*)</i>\s*</td>\s*</tr>"""
rawstr2 = r"""<tr class="\D*"><td>\s*<strong class="\D*">(.*)</strong>\s*</td>\s*<td>\s*(.*)\s*</td><td>\s*.*"""
rawstr3 = r"""<td>\s*(\w*)\s*</td>.*<td>\s*([-0-9]*)\s*</td>"""

# method 1: using a compile object
compile_obj = re.compile(rawstr)
match_obj = compile_obj.search(matchstr)

if(match_obj == None):
compile_obj2 = re.compile(rawstr2)
match_obj = compile_obj2.search(matchstr)

if(match_obj == None):
compile_obj3 = re.compile(rawstr3)
match_obj = compile_obj3.search(matchstr)

if(match_obj):
# Retrieve group(s) from match_obj
all_groups = match_obj.groups()

# Retrieve group(s) by index
group_1 = match_obj.group(1)
group_2 = match_obj.group(2)
try:
poo = group_3 = match_obj.group(3)
except IndexError:
return (group_1.strip(), group_2.strip(), "")
else:
return (group_1.strip(), group_2.strip(), group_3.strip())
else:
return None

def extractcodes(line):
fields = extractErrorInfo(line)
if(fields):
params = list(extractErrorInfo(line))
params[1] = params[1].replace("--","-")
params[0] = params[0].replace("\"","")
params[0] = params[0].replace("\'","")
params[0] = params[0].replace("\\","")
params[2] = params[2].replace("\"","")
params[2] = params[2].replace("\'","")
params[2] = params[2].replace("\\","")

try:
params[1] = int(params[1])
except ValueError:
return None
return params
return None


def test():
tcs = ["""<tr class="row_even"><td> <strong class="spip">KErrNotFound</strong> </td><td>-1</td><td><i class="spip">Unable to find the specified object</i></td></tr>""",
"""<tr class="row_odd"><td><strong class="spip">KErrEtelNotCallOwner</strong> </td><td>-2000</td><td> </td></tr>""",
"""<tr class="row_even"><td> KErrAvctpBadAddress</td><td> -6400 </td><td><i class="spip">AVCTP bad address </i> </td></tr>""",
"""<tr class="row_even"><td> KErrAvctpBadAddress</td><td> --6400 </td><td><i class="spip">AVCTP bad address </i> </td></tr>""",
"""<tr class="row_even"><td> KErrAvctpBadAddress</td><td> MOO </td><td><i class="spip">AVCTP bad address </i> </td></tr>"""]

for testcase in tcs:
print extractcodes(testcase)

def regenerateErrorFile():
file = urllib.urlopen("http://newlc.com/Symbian-OS-Error-Codes.html")
lines = file.readlines()

lookupcode = -5
look_up = {}

for line in lines:
fields = extractcodes(line)
if(fields):
look_up[fields[1]]= (fields[0],fields[2])

output = open(picklefilename,"wb")
pickle.dump(look_up, output)
return look_up

#test()

try:
pkl_file = open(picklefilename, 'rb')
lookup = pickle.load(pkl_file)
pkl_file.close()
except IOError:
print "Re-Generating file"
lookup = regenerateErrorFile()



args = sys.argv
if(len(args)!=2):
print "Usage kerr <errorcode>"
print "e.g kerr -1"
sys.exit()

try:
errtupe = lookup[int(args[1])]
print "%s [%s]"% errtupe
except:
print "Unknown error"

Saturday, October 20, 2007

Nokia and maemo {no capital latter}
Forum Nokia has launched support for the maemo platform to enable our current customers to innovate on maemo platform by providing them an easy way to access needed tools and SDKs and other familiar services. We will also provide maemo application developers a sales channel through Nokia Software Market.

Maemo platform is based on the Linux operating system, and is one of the core platforms for Nokia’s high-end products. Today maemo is the basis of the operating system used in a range of Wi-Fi enabled Internet Tablets. The platform provides you with similar capabilities to a desktop environment. Nokia has already launched three devices based on maemo, and there are more devices on the way.

for more information
http://maemo.org
http://www.forum.nokia.com/main/plat...emo/index.html

Sunday, October 14, 2007

How to change wait note text at runtime

Many a times it is needed to show updates on wait notes. This can be achieved with the following:
The resource file
RESOURCE DIALOG r_waitnote
{
flags = EAknWaitNoteFlags;
buttons = R_AVKON_SOFTKEYS_CANCEL;
items =
{
DLG_LINE
{
type = EAknCtNote;
id = EGeneralNote;
control = AVKON_NOTE
{
layout = EWaitLayout;
singular_label = "Receiving File : %d Bytes";
plural_label ="%d %% Recieved";
imagefile = "z:\\system\data\avkon.mbm";
imageid = EMbmAvkonQgn_note_progress;
imagemask = EMbmAvkonQgn_note_progress_mask;
animation = R_QGN_GRAF_WAIT_BAR_ANIM;
};
}
};
}

Here singular_label is what will be shown as soon as the dialog is executed. To change the label CAknWaitNotes SetTextL function is used.

• Create and Execute the dialog
iDlg = new(ELeave)CAknWaitDialog( (REINTERPRET_CAST(CEikDialog**,&iDlg)));
iDlg->SetTone( CAknNoteDialog::EConfirmationTone );
iDlg->SetCallback( this );
iDlg->SetTextL(_L("Please Wait..."));
iDlg->ExecuteLD(R_WAITNOTE);
• Change label as and when required
_LIT(KFormat,"%d %% Recieved");
str.Format(KFormat,kb);
iDlg->SetTextL(str)

• Dismiss the dialog
if(iDlg)
{
iDlg->ProcessFinishedL();
iDlg = NULL;
}

How to Show Copyright (c) Symbol.

_LIT(KTxtAbout,"Copyright \251 2007");

Wednesday, October 10, 2007

S60 3rd Ed. FP 2 , SDK Beta Includes Web Runtime Engine


Today the S60 3rd Edition, Feature Pack 2 for C++ SDK Beta went live on Forum Nokia and with that a WRT testing environment. Note, this is a beta version, but the included WRT engine is close to final and developers are encouraged to use it. See the Tools and SDK’s: Nokia Tools web page

Additionally, a number of docs went up including
- Introducing Web Run-Time
- Getting Started with Nokia web Widget development
- Web Run-Time API Reference
- Porting Apple Dashboard widgets to S60

The getting started and the Porting guides include example widgets.
See http://www.forum.nokia.com/main/resources/documentation/index.html

Note: What i was looking for is a Partial Screen Widget that i can use in my Symbian.C++ code as a Control. So a Useless Feature to me.....
stats counter