Ejemplo n.º 1
0
 def __init__(self):
     self.lock = e32.Ao_lock()
     self.sets = Settings()
     self.timert = e32.Ao_timer()
     self.timerip = e32.Ao_timer()
     self.apid_list = [-1] + [ap["iapid"] for ap in socket.access_points()]
     self.ap_list = [u"Ask User"
                     ] + [ap["name"] for ap in socket.access_points()]
     self.i = 1
     self.yesno = [ru("No"), ru("Yes")]
     self.count = 0
     self.developer = "gauravssnl"
Ejemplo n.º 2
0
def retreive_ap():
    access_points = socket.access_points()
    for ap in access_points:
        if not 'iapid' in ap and not 'name' in ap:
            appuifw.note(u"Incorrect return value. Test failed")
    print access_points
    option = appuifw.query(u"Run negative test as well?", 'query')
    if option is not None:
        try:
            socket.access_points("Invalid argument")
        except:
            appuifw.note(u"Exception raised for invalid argument. Test passed")
            raise
Ejemplo n.º 3
0
def my_select_access_point():
    ap_list = socket.access_points()
    names = [ unicode(m["name"]) for m in ap_list ]
    index = appuifw.popup_menu(names, u'Select AP')
    if index is None:
        return None
    return ap_list[index]["iapid"]
Ejemplo n.º 4
0
def input_accesspoint():
    global config
    config['accesspoint'] = socket.select_access_point()
    config['accesspoint_name'] = [
        ap['name'] for ap in socket.access_points()
        if ap['iapid'] == config['accesspoint']
    ][0]
Ejemplo n.º 5
0
 def _select_access_point(self, apid = None):
     """
     Shortcut for socket.select_access_point() 
     TODO: save selected access point to the config
     TODO: allow user to change access point later
     """
     if apid is not None:
         self.apid = apid
     else:
         access_points = socket.access_points()
         sort_key = "iapid"
         decorated = [(dict_[sort_key], dict_) for dict_ in access_points]
         decorated.sort()
         access_points = [dict_ for (key, dict_) in decorated]
         ap_names = [dict_["name"] for dict_ in access_points]
         ap_ids = [dict_["iapid"] for dict_ in access_points]
         selected = appuifw.selection_list(ap_names, search_field=1)
         #print selected, ap_names[selected], ap_ids[selected]
         if selected is not None:
             self.apid = ap_ids[selected]
     if self.apid:
         self.apo = socket.access_point(self.apid)
         socket.set_default_access_point(self.apo)
         self.config["apid"] = self.apid
         self.save_config()
         self._update_menu()
         return self.apid
Ejemplo n.º 6
0
    def startInternet(self):
        if not self.ip:
            import sys
            import socket
            if sys.platform == 'symbian_s60':
                self.feedback(u'Prepare internet:please wait...')
                aps = [ap['name'] for ap in socket.access_points()]
                aps.sort()
                time_taken=0
                while time_taken < 1:
                    started = time.time()
                    apid = appuifw.selection_list(aps,1)
                    time_taken = time.time() - started
                if apid == None:
                    return None
                self.feedback(u'Prepare internet:set access point')

                socket.set_default_access_point(aps[apid])
           
            else:
                import socket
                self.ip = 'some ip'
            
            #one time socket, for just finding out our ip
            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            #anonymity issue here
            s.connect(('www.google.com',80))
            self.ip = s.getsockname()[0]
        return True
Ejemplo n.º 7
0
 def app(self):
     appuifw.app.title = ru(title)
     appuifw.app.exit_key_handler = self.exit
     self.i = 1
     self.console = Console.Console(True)
     self.text = self.console.text
     appuifw.app.body = self.console.text
     self.text.color = 255, 0, 0
     self.text.font = "title", 20
     self.write("%s by %s" % (title, self.developer))
     self.text.color = 0, 0, 0
     self.text.font = "title", 18
     if not len(socket.access_points()):
         self.write(
             "No Access Point is defined.Please add new APN.App will exit")
         e32.ao_sleep(2)
         os.abort()
     else:
         pass
     self.write("Access Point: %s" %
                self.ap_list[self.apid_list.index(self.sets.APN)])
     self.write("Find IP:%s" % self.insta(self.sets.IPHUNT))
     self.write("Run Simple Server: %s" % self.yesno[self.sets.RUNSS])
     appuifw.app.menu = [(ru("Start"), self.start),
                         (ru("Settings"), self.settings),
                         (ru("About"), self.about), (ru("Exit"), self.exit)]
Ejemplo n.º 8
0
def sel_access_point():
    aps = []
    aps.append({'iapid': 1, 'name': u'Easy WLAN'})
    for api in socket.access_points():
        aps.append(api)
    ap_labels = map(lambda x: x['name'], aps)
    item = appuifw.popup_menu(ap_labels, cn('选择接入点:'))
    return aps[item]['iapid']
Ejemplo n.º 9
0
def ask_iap_name():
    # [{'iapid': 17, 'name': u"FooBar"}, ...]
    ap_list = socket.access_points()
    name_list = [r['name'] for r in ap_list]
    index = appuifw.popup_menu(name_list, u'Select IAP')
    if index is None:
        return None
    return name_list[index]
Ejemplo n.º 10
0
def ask_iap_name():
    # [{'iapid': 17, 'name': u"FooBar"}, ...]
    ap_list = socket.access_points()
    name_list = [ r['name'] for r in ap_list ]
    index = appuifw.popup_menu(name_list, u'Select IAP')
    if index is None:
        return None
    return name_list[index]
Ejemplo n.º 11
0
def localIP():
    appuifw.app.menu = []
    try:
        id_list = [ap["iapid"] for ap in socket.access_points()]
        name_list = [ap["name"] for ap in socket.access_points()]
        apnid = socket.select_access_point()
        apn = socket.access_point(apnid)
        apn.start()
        ip = apn.ip()
        body.color = (0, 255, 0)
        slow_print("Your Local IP :\n")
        body.color = (0, 0, 255)
        slow_print(ip)
        slow_print(" \n")
    except:
        body.color = (255, 255, 0)
        slow_print("No Access Point Selected\n")
    appuifw.app.menu = [(ru("Check Internet IP"), internetIP),
                        (ru("Check Local IP"), localIP), (ru("About"), about),
                        (ru("Exit"), quit)]
Ejemplo n.º 12
0
def select_default_access_point():
    """ Select the default access point. Return True if the selection was done or False if not. """
    aps = socket.access_points()
    if not aps:
        note(u"No access points available", "error")
        return False

    ap_labels = [x["name"] for x in aps]
    item = popup_menu(ap_labels, u"Access points:")
    if item is None:
        return False

    socket.set_default_access_point(aps[item]["name"])

    return True
Ejemplo n.º 13
0
def main():
	data = getContactsData()
	ap_names = []
	ap_list_of_dicts = socket.access_points()
	for item in ap_list_of_dicts:
		ap_names.append(item['name'])
	ap_offset = appuifw.popup_menu(ap_names, u"Select default access point")
	if ap_offset is None:
		appuifw.note(u"Cancelled")
		return
	socket.set_default_access_point(ap_names[ap_offset])
	status=UploadData(data)
	if status:
		appuifw.note(u"Backup Successfully")
	else:
		appuifw.note(u"Failed, unknown error")
Ejemplo n.º 14
0
    def sel_access_point(self):
        """ Select and set the default access point.
        Return the access point object if the selection was done or None if not
        """
        aps = socket.access_points()
        if not aps:
            note(u"No access points available", "error")
            return None

        ap_labels = map(lambda x: x['name'], aps)
        item = popup_menu(ap_labels, u"Access points:")
        if item is None:
            return None
        logging.debug('AP set: %s' % item)
        apo = socket.access_point(aps[item]['iapid'])
        socket.set_default_access_point(apo)
        return apo
Ejemplo n.º 15
0
    def sel_access_point(self):
        """ Select and set the default access point.
        Return the access point object if the selection was done or None if not
        """
        aps = socket.access_points()
        if not aps:
            note(u"No access points available","error")
            return None

        ap_labels = map(lambda x: x['name'], aps)
        item = popup_menu(ap_labels,u"Access points:")
        if item is None:
            return None
        logging.debug('AP set: %s' % item)
        apo = socket.access_point(aps[item]['iapid'])
        socket.set_default_access_point(apo)
        return apo
Ejemplo n.º 16
0
def getip(x):
    x = str(x)
    all = socket.access_points()
    for i in range(len(all)):
        iapid = all[i]["iapid"]
        pname = all[i]["name"]
        socket.set_default_access_point(socket.access_point(iapid))
        try:
            ip = socket.gethostbyname(x)
        except:
            continue
        if ip.find("*") > -1:
            continue
        else:
            break
    #print ip
    return ip
Ejemplo n.º 17
0
 def select_access_point(self):
     """ Select the default access point.
         Return True if the selection was done or False if not
         found on <http://croozeus.com/blogs/?p=836>
     """
     aps = socket.access_points()
     if not aps:
         appuifw.note(u"No access points available","error")
         return False
     ap_labels = map(lambda x: x['name'], aps)
     item = appuifw.popup_menu(ap_labels,u"Access points:")
     if item is None:
         return False
     
     self.apo = socket.access_point(aps[item]['iapid'])
     socket.set_default_access_point(self.apo)
     
     return True
Ejemplo n.º 18
0
def main():
    syncday = appuifw.query(u"The date to be uploaded",u"date",time())
    if syncday is None:
        appuifw.note(u"User Cancelled")
        return
    cal = calendar.open()
    entries = cal.daily_instances(syncday,appointments=1,events=1)
    if len(entries)>0:
        ap_names = []
        ap_list_of_dicts = socket.access_points()
        for item in ap_list_of_dicts:
            ap_names.append(item['name'])
        ap_offset = appuifw.popup_menu(ap_names, u"Select default access point")
        if ap_offset is None:
        	appuifw.note(u"Cancelled!")
        	return
        socket.set_default_access_point(ap_names[ap_offset])
        u=appuifw.query(u'email','text',u"@gmail.com")
        p=appuifw.query(u'password','code',u"")
        n=appuifw.query(u'username','text',u"")
        if u is None or p is None or n is None:
            appuifw.note(u"User Cancelled")
            return
        u=u.encode("utf8")
        p=p.encode("utf8")
        n=n.encode("utf8")
        feedloc = '/calendar/feeds/'+u+'/private/full'
        try:
        	auth = GoogleAuth( u, p )
        	sess = SessionUrl( auth, feedloc )
        	for entry in entries:
        		event = cal[entry['id']]
        		dict = dictFromS60Event(event)
        		entry = atomEntryFromDict(u,p,n,dict)
        		entry=entry.encode("utf8")
        		insertGcal(entry,sess,auth)
        		print "  Added : " + event.content
        	print "OK"
        except Exception,msg:
        	#print msg
        	appuifw.note(u"Error")
Ejemplo n.º 19
0
def main():
	ap_names = []
	ap_list_of_dicts = socket.access_points()
	for item in ap_list_of_dicts:
		ap_names.append(item['name'])
	ap_offset = appuifw.popup_menu(ap_names, u"Select default access point")
	if ap_offset is None:
		appuifw.note(u"Cancelled!")
	else:
		socket.set_default_access_point(ap_names[ap_offset])
		client=IPGWClient(PasswordManger())
		try:
			if not client.open():
				appuifw.note(u"Cancelled!")
				return
			ret = client.doConnect()
			appuifw.note(ret.decode("utf8"))
			print ret
		except Exception,e:
			print e
			appuifw.note(u"Cancelled!")
Ejemplo n.º 20
0
    def __init__(self):
        try:
            from envy import set_app_system
            set_app_system(1)
        except:
            ui.note(cn('  注意:由于缺少envy模块,不能直接挂到后台,注意保存!'), 'info')
        #
        from socket import access_points, access_point, select_access_point, set_default_access_point
        self.aps = access_points()  #接入点列表
        self.apid = {}
        self.ap = None

        self.txt_size = 0
        ui.app.title = cn(_name)
        ui.app.body = self.t = ui.Text()
        ui.app.exit_key_handler = self.exit_edit
        self.t.bind(63557, self.addn)
        self.t.bind(63586, self.pop_menu)
        self.menu_list = [
            (cn('文件'), ((cn('新建'), self.new), (cn('打开'), self.read),
                        (cn('保存'), self.save))), (cn('表情'), self.face),
            (cn('转换'), self.rep), (cn('还原'), self.rerep),
            (
                cn('超链'),
                ((cn('插入帖链'), self.bto_url), (cn('直接输入URL'), self.url)),
            ), (cn('图链'), ((cn('输入地址'), self.img), )),
            (cn('社区专用UBB'), (
                (cn('加粗'), lambda: self.add_ubb('b')),
                (cn('下划线'), lambda: self.add_ubb('u')),
                (cn('斜体'), lambda: self.add_ubb('i')),
                (cn('电话'), lambda: self.add_ubb('tel')),
                (cn('日期'), lambda: self.add_ubb('date')),
                (cn('时间'), lambda: self.add_ubb('time')),
                (cn('农历图片'), lambda: self.add_ubb('cct')),
            ))
        ]
        self.pop_menu_list = [
            cn('复制到UC'),
            cn('发表'),
            cn('上翻'),
            cn('下翻'),
            cn('设置'),
            cn('帮助')
        ]
        ui.app.menu = self.menu_list
        self.setting = [
            u'14',  #字体
            u'250,100,100',  #颜色
            u'',  #LXT
            u'5690:PyS\u7f16\u7a0b\u4e13\u533a,6019:\u7834\u89e3\u4e13\u533a',
            u'64:\u5973\u4eba\u5fc3\u4e8b,222:\u7537\u5b69\u522b\u54ed',
            u' ',  #空格
            None,  #接入点
            u'e:\\sys\\bin\\UcWeb60signed.exe'
        ]  #UC路径
        self.sett('read')
        self.up_setting()
        self.face_list = [
            cn('胜利'),
            cn('摆酷'),
            cn('暴汗'),
            cn('晕了'),
            cn('大笑'),
            cn('脸红'),
            cn('偷笑'),
            cn('流泪'),
            cn('色色'),
            cn('惊讶'),
            cn('抽烟'),
            cn('疑问'),
            cn('调皮'),
            cn('飞吻'),
            cn('愤怒'),
            cn('害羞'),
            cn('别吵'),
            cn('欢迎'),
            cn('微笑'),
            cn('睡觉'),
            cn('送花'),
            cn('闭嘴'),
            cn('再见'),
            cn('擦汗'),
            cn('发呆'),
            cn('可怜'),
            cn('捉狂'),
            cn('亲亲'),
            cn('鄙视'),
            cn('咒骂'),
            cn('好困')
        ]
Ejemplo n.º 21
0
def print_iap_list():
    ap_list = socket.access_points()
    print repr(ap_list)
Ejemplo n.º 22
0
def print_iap_list():
    ap_list = socket.access_points()
    print repr(ap_list)
Ejemplo n.º 23
0
import socket

print(repr(socket.access_points()))

print(repr(socket.select_access_point()))
Ejemplo n.º 24
0
def input_accesspoint():
    global config
    config['accesspoint'] = socket.select_access_point()
    config['accesspoint_name'] = [ap['name'] for ap in socket.access_points() if ap['iapid']==config['accesspoint']][0]
Ejemplo n.º 25
0
#this next line brings up the access point menu
#apid = socket.select_access_point()
#if not apid:
#    sys.exit()
#apo = socket.access_point(apid)
#socket.set_default_access_point(apo)
#apo.start()
#try:
#    ip = apo.ip()
#    print u"Connected to WiFi as %s" % ip
#except:
#    print u"Failed to connect to WiFi"


menuitems = []
aps = socket.access_points()
for k in aps:
    menuitems.append(k['name'])
menuitems.append(u'LOCAL')
id = globalui.global_popup_menu(menuitems, u'Select AP')
if id < len(aps):
    print id, aps[id]
    apo = socket.access_point(aps[id]['iapid'])
    socket.set_default_access_point(apo)
    apo.start()
    try:
        ip = apo.ip()
    except:
        globalui.global_note(u"Could not Connect!, EXIT")
        sys.exit()
else:
Ejemplo n.º 26
0
import socket
ap_list = socket.access_points()
print repr(ap_list)