polychromatic thoughts……………..

September 7, 2008

MOBIVISION WORKSHOP DAY 3 AND 4…..OVERVIEW

Filed under: mobile — maniacmind @ 6:02 PM

AS PROMISED ITS SUNDAY AND I M WRITEING THE DOCUMENTATION OF THE THIRD DAY OF WORKSHOP………………

we covered messaging here is a sample code with comments explaining the process…

# import the messaging module
import appuifw
import messaging

# create text input field
data = appuifw.query(u"Type your name:", "text")

# define the mobile numbers here
nbr1 = "123456"
nbr2 = "234567"

# define the text that the sms shall contain
txt = u"Greetings from:" +data

# create a query with type: "query" -> appuifw.query(label, type)
# by using an if statement one can check whether the user has pressed "ok" -> True or "cancel" -> False
if appuifw.query(u"Send message to your 2 friends","query") == True:
    # send out the sms; include the mobile number and the text to be sent
    messaging.sms_send(nbr1, txt)
    messaging.sms_send(nbr2, txt)

    # confirm with a pop-up note that the sms has been sent out
    appuifw.note(u"Messages sent", "info")
else:
    # in case the user had pressed "cancel", send a pop-up note that the messages have not been sent out
    appuifw.note(u"Well, your Messages are not sent then", "info")

then we learned how to create an appilictaion menu…

# this script lets you create a simple application menu

# NOTE:
# press the options key in order to open the applicaion menu
# when running the script!

import appuifw, e32

# create the "callback functions" for the application menu
def item1():
appuifw.note(u"booooom", "info")

def item2():
appuifw.note(u"gotcha", "info")

# define an exit handler function
def quit():
app_lock.signal()

# create the application menu include the selectable options (one, two)
# and the related callback functions (item1, item2)
appuifw.app.menu = [(u"one", item1),
(u"two", item2)]

appuifw.app.exit_key_handler = quit

# create an active object
app_lock = e32.Ao_lock()

# start a scheduler
app_lock.wait()

then we learned how to make forms Here is the code tried in the workshop….

import appuifw
import e32

# create an Active Object
app_lock = e32.Ao_lock()

def forming():
# create a list to be used in 'combo' selection mode
model = [u'6600', u'6630', u'7610', u'N90', u'N70']

 # define the field list (consists of tuples: (label, type ,value)); label is a unicode string
# type is one of the following strings: 'text', 'number', 'date', 'time',or 'combo'
data = [(u'Mobile','text', u'Nokia'),(u'Model','combo', (model,0)),(u'Amount','number', 5),(u'Date','date'),(u'Time','time')]

# set the view/edit mode of the form 
flags = appuifw.FFormEditModeOnly

# creates the form
f = appuifw.Form(data, flags)

 # make the form visible on the UI
f.execute()

def exit_key_handler():
app_lock.signal()

# set the title of the script
appuifw.app.title = u'Form'

# call the function that creates the form
forming()

appuifw.app.exit_key_handler = exit_key_handler
app_lock.wait()
a saple of form

a sample of form

then location id script was written its as follows:-

import e32
import appuifw
import location   #we imported a module named location whose function will beome clear as we move dowm the script

class gsm_location :
	def __init__(self) :
		self.text = u""

	def gsm_location(self) :
		(self.mcc, self.mnc, self.lac, self.cellid) = location.gsm_location()
		self.text = u"MCC: %s\nMNC: %s\nLAC: %s\nCell id: %s\n" % (self.mcc, self.mnc, self.lac, self.cellid)
		return self.text

	def close(self) :
		pass

e32.ao_yield() 

class gsm_location_app:
    def __init__(self):
        self.lock = e32.Ao_lock()

        self.old_title = appuifw.app.title
        appuifw.app.title = u"GSM Location"

        self.exit_flag = False
        appuifw.app.exit_key_handler = self.abort

        self.db = gsm_location()

        appuifw.app.body = appuifw.Text()
        appuifw.app.menu = [(u"Refresh", self.refresh)] 

    def loop(self):
        try:
            self.refresh()
            self.lock.wait()
            while not self.exit_flag:
                self.refresh()
                self.lock.wait()
        finally:
            self.db.close()

    def close(self):
        appuifw.app.menu = []
        appuifw.app.body = None
        appuifw.app.exit_key_handler = None
        appuifw.app.title = self.old_title

    def abort(self):
        # Exit-key handler.
        self.exit_flag = True
        self.lock.signal()

    def refresh(self):
		self.db.gsm_location()
		appuifw.app.body.set(self.db.text)

def main():
    app = gsm_location_app()
    try:
        app.loop()
    finally:
        app.close()

if __name__ == "__main__":
    main()

well this was the program after which the programming basics like classes ,objects and modules were
undertaken for all that stuff please refer books if stiil got a problem discuss it on forums.lugmanipal.org

Now we wrote the scripts for getting battery information of the mobile

import appuifw
import e32
import sysinfo

def check_battery_level():
    batty = sysinfo.battery()
    print batty

def exit_key_handler():
    script_lock.signal()
    appuifw.app.set_exit()

script_lock = e32.Ao_lock()

appuifw.app.title = u"Battery level"

appuifw.app.menu = [(u"check battery", check_battery_level)]

appuifw.app.exit_key_handler = exit_key_handler
script_lock.wait()

here we defined a function called check_battery_life and used the module sysinfo

now i will end with the keyboard script done on the last day for any explainations please ask your mentors or leave a comment here…with your email-id

# Dialing script by Jurgen Scheible

import appuifw
import e32
import telephone

def main_menu_setup():
    appuifw.app.menu = [(u"dial", dialing),\
                        (u"hang-up", hangingup)]

def hangingup():
    telephone.hang_up()
    main_menu_setup()

def dialing():
    number = u'+1234566'
    telephone.dial(number)
    main_menu_setup()

def exit_key_handler():
    global script_lock
    script_lock.signal()

script_lock = e32.Ao_lock()

old_title = appuifw.app.title
appuifw.app.title = u"Dialer"
main_menu_setup()
appuifw.app.exit_key_handler = exit_key_handler
script_lock.wait()

if i have left of forgotten something please leave a comment or email me on shane2418@gmail.com

2 Comments »

  1. i had attended the mobivision workshop, and want to ask a question(it is not related to the workshop but to symbian in general)

    if there is a number stores in ur phonebook as
    9008420111 or +919008420111 then is u change the 3rd digit of the mobile number and dial it manually, it will still show the name matching to the number

    example

    +919008420747 is stored in my phonebook as akash

    then if i dial manually
    +919038420747 then it will still show akash on the screen

    replace the 3 with any no. doesnt make any difference

    tried it on 6600,N70,N70music edition,5300 Xpress music and this happens on all

    any idea why this happens??

    Comment by akash — October 25, 2008 @ 11:14 PM

  2. well akash thanx for telling me that ….that’s a news for me i have to have a look at it before i can say anything…..i try it and get back to you ….in the mean time you can ask the same question in nokia forums….i think you will get your answer there …do tell me if you get it before me….
    it would be better if you leave your email adress here or rather mail it to me at 1988.shashank@gmail.com

    Comment by maniacmind — November 1, 2008 @ 9:57 PM


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.