| Reply | « Previous Thread | Next Thread » |
|
I'm developing an application that connects to the internet to upload some data.
I try to avoid the annoying popup of apn selection everytime a connection is needed, so I use the following function: Code:
def select_apn(): global apo, apid apid = socket.select_access_point() apo = socket.access_point(apid) socket.set_default_access_point(apo) Code:
if appuifw.query(u"Game Over. Score:"+str(score)+u" Upload online?", "query") == True:
global apo
if apo == None:select_apn()
name = checkuserid()
try:
params = urllib.urlencode({'Name': name, 'Score': score})
f = urllib.urlopen("http://xxxxx", params)
result=f.read()
if result.find("Success")>0:
appuifw.note(u"Score was submitted succesfully!", "info")
else:
if appuifw.note(u"Database Error! Try again?", "query")==True:tryagain=1
except:
if appuifw.note(u"No valid network found!", "query")==True:tryagain=1
apo.stop()
Any ideas? |
| paravantinos |
| View Public Profile |
| Find all posts by paravantinos |
|
Hi,
I would suggest you to use the following code for setting and unsetting the default access points. You can add your upload statements to this script after the set_accesspoint function call and see if it works. Code:
import appuifw,socket,urllib
def unset_accesspoint():
f = open('e:\\apid.txt','w')
f.write(repr(None))
f.close()
appuifw.note(u"Default access point is unset ", "info")
def set_accesspoint():
apid = socket.select_access_point()
if appuifw.query(u"Set as default access point","query") == True:
f = open('e:\\apid.txt','w')
f.write(repr(apid))
f.close()
appuifw.note(u"Saved default access point ", "info")
apo = socket.access_point(apid)
socket.set_default_access_point(apo)
def download():
#---------------------- copy from here ---------------------------------------
try:
f=open('e:\\apid.txt','rb')
setting = f.read()
apid = eval(setting)
f.close()
if not apid == None :
apo = socket.access_point(apid)
socket.set_default_access_point(apo)
else:
set_accesspoint()
except:
set_accesspoint()
#------------------------- copy till here --------------------------------------
# and put it before the line of code in your script that invokes a connection to the internet
# like here with urllib.urlretrieve(url, tempfile)
# your own code here
url = "http://www.leninsgodson.com/courses/pys60/resources/vid001.3gp"
tempfile = 'e:\\Videos\\video.3gp'
urllib.urlretrieve(url, tempfile)
appuifw.note(u"Video downloaded" , "info")
def quit():
app_lock.signal()
appuifw.app.set_exit()
appuifw.app.menu = [(u"unset ap",unset_accesspoint),(u"download",download)]
appuifw.app.exit_key_handler = quit
app_lock = e32.Ao_lock()
app_lock.wait()
Kandyfloss V 7.0642.0 18-10-06 RH-51 Nokia 7610 |
| kandyfloss |
| View Public Profile |
| Find all posts by kandyfloss |
|
Hi Kandyfloss and thanks for the reply!
When I run your code as it is, it works perfectly, But when I try to integrate it within my application, the same behaviour pops up. It crashes after apn selection. I suspect that it has something to do with canvas callbacks etc, as I use canvas for the application UI. I'm new to Symbian development, I don't understand well the terms threading, ao, callbacks etc Do you believe that the problem has to do with canvas interaction with socket? |
| paravantinos |
| View Public Profile |
| Find all posts by paravantinos |
|
Ok, i found it...
The application uses sensor, and for some reason I had to disconnect sensor before calling socket. Now it works! Could someone explain me why that happened? |
| paravantinos |
| View Public Profile |
| Find all posts by paravantinos |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Call Log Problem | map123 | General Symbian C++ | 7 | 2007-03-07 17:08 |
| Topic: Voice call status problem Need Help!!! | hoy_cpe | General Symbian C++ | 3 | 2006-06-09 00:48 |
| Hang up a call problem | Bill_Murray | General Symbian C++ | 0 | 2006-04-01 10:35 |
| Setup call problem | bakakaba | General Symbian C++ | 2 | 2005-08-23 16:15 |
| Problem in trying to connect to Incoming Call | Rajagopalan | General Symbian C++ | 10 | 2004-09-10 06:29 |