×

Discussion Board

Page 8 of 10 FirstFirst 12345678910 LastLast
Results 106 to 120 of 142

Thread: Python for UIQ

  1. #106
    Registered User
    Join Date
    Jul 2005
    Posts
    33

    Re: Python for UIQ

    Quote Originally Posted by cassioli
    I think I got it:
    Java:
    Code:
    public class myclass implements CallListener {
         public void callActive(CallEvent event) {
    Jython:
    Code:
    class className(java.awt.Frame, javax.telephony.CallListener):
        def callActive(self,event):
            print  "Incoming call!"
    I think you got it,too.
    or ... (I don't think it work,but it may give you an idea.)
    Code:
    try:
        terminal = myprovider.getTerminal("1234567890",callChangedEvent=self.myHandle)
    except Exception:
        print "Can’t get Terminal"
        System.exit(0)
    
    def myHandle(self,event):
        pass
    Quote Originally Posted by gotan
    is it possible to re-compile Jython for another Symbian JDK?
    Jython can run on Java1.1 or above.
    It don't work on Java2ME.
    So UIQ(those have PersonalJava) are only Symbian that can run Jython-compiled class file.

  2. #107
    Registered User
    Join Date
    Dec 2004
    Posts
    44

    Re: Python for UIQ

    Quote Originally Posted by bpitk
    Jython can run on Java1.1 or above.
    It don't work on Java2ME.
    So UIQ(those have PersonalJava) are only Symbian that can run Jython-compiled class file.
    Why what are the problems? It compiles to Java Bytecode after all, and the JAVA VMs should be the similar?

  3. #108
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: Python for UIQ

    Quote Originally Posted by gotan
    Why what are the problems? It compiles to Java Bytecode after all, and the JAVA VMs should be the similar?
    of course not: J2ME has a stripped down JVM, which a lot fewer features/methods/possibilites than standard Java (J2SE).
    J2ME <-> CLDC (Connected Limited Device Configuration) <-> KVM (Kilobyte Virtual Machine)
    Personal Java <-> CDC (Connected Device Configuration) <-> JVM

    Personal Profile is actually a J2ME profile and it is an evolution of Personal Java: if your phone supports J2ME, it COULD support Personal Profile... but it usually happens only in high-end devices (such as PDAs). look at your phone specifications.

  4. #109
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: Python for UIQ

    This damned code is not working!
    Code:
    import javax.telephony.events
    import os
    import java.lang
    import com.symbian.javax.telephony.mobile
    import com.symbian.javax.telephony
    import com.symbian.epoc.etel
    import java.lang.Integer
    import java.lang.String
    import javax.net.datagram
    import com.symbian.javax.net.datagram
    from java.awt import Frame,MenuBar,Menu,MenuItem,TextArea,FileDialog
    from java.awt.event import ActionEvent
    class test(java.awt.Frame, com.symbian.epoc.etel.EtelLineListener):
        def __init__(self):
            self.size=(208,276)
            self.myOutput=java.awt.TextArea("Hello UIQ from Jython!!!\n")
            self.add("Center",self.myOutput)
            self.myMenuBar=java.awt.MenuBar()
            self.myMenu=java.awt.Menu("Menu")
            self.myReadFile=java.awt.MenuItem("Read File",actionPerformed=self.doRead)
            self.myMenuExit=java.awt.MenuItem("Exit",actionPerformed=self.doExit)
            self.myMenuBar.add(self.myMenu)
            self.myMenu.add(self.myReadFile)
            self.myMenu.add(self.myMenuExit)
            self.setMenuBar(self.myMenuBar)
            self.setVisible(1)
        def doRead(self,event):
            p=com.symbian.javax.telephony.mobile.EpocGsmMobileProvider()
            ts=p.getTerminals()
            t=ts[0]
            tads=t.getAddresses()
            tad=tads[0] 
            m=com.symbian.javax.telephony.mobile.EpocGsmMobileTerminal(tad,p)
            mads=m.getAddresses()
            m=mads[0]
            print "Numero SIM:",m.getSubscriptionId()
            IMSIFile=open("c:\\system\\data\\e32user.bin",'r')
            IMSI=IMSIFile.read()
            print "Numero registrato: ",IMSI
            if java.lang.Integer.toString(m.getSubscriptionId()) != IMSI:
                print "BRUTTO LADRONE!!!"
                jnd=javax.net.datagram
                dns=jnd.DatagramNameService
                addr=com.symbian.javax.net.datagram.SMSAddress("NUMBER")
                ds=jnd.DatagramService
                serv=ds.getService(addr)
                mex=java.lang.String("ti hanno fregato il cellulare!!!").getBytes()
                d=jnd.Datagram(mex,addr)
                serv.send(d)
        def doExit(self,event):
            java.lang.System.exit(0)
        def callActive(self,event): #callListener
            print "chiamata rilevata!"
            incomingCall=event.getCall()
            conns=incomingCall.getConnections()
            addr=conns[0].getAddress()
            print "chiamata attiva:  ",addr.getName()
        def callEventTransmissionEnded(self,event): #callListener
            print "chiamata finita"
            incomingCall=event.getCall()
            conns=incomingCall.getConnections()
            addr=conns[0].getAddress()
            numero=addr.getName()
            self.myOutput.appendText("fine chiamata:"+numero+"\n")
        def incomingCall(self,line,call): # evento generato da EtelLineListener
        	print "Rilevata chiamata entrante: "
            conns=call.getConnections()
            addr=conns[0].getAddress()
            print addr.getName() + "\n"    	
    
    if __name__=="__main__":
        myApp=test()
    
    #peer=com.symbian.javax.telephony.EpocJtapiPeer()
    #p=peer.getProvider("EpocGsmMobileProvider")
    p = com.symbian.javax.telephony.mobile.EpocGsmMobileProvider()
    #terms=p.getTerminals()
    #term=terms[0]
    addrs=p.getAddresses()
    addr=addrs[0]
    term=com.symbian.javax.telephony.mobile.EpocGsmMobileTerminal(addr,p)
    # il sistema forse assegna da solo un listener al Terminale???
    print "Pronti Terminale '" + term.getName() + "' e Address '" + addr.getName() + "' ."
    It works for detecting IMSI and sending SMS if it's different from stored one;
    it works for detecting the number of an incoming call;
    but it does not work in detecting an incoming call! It "detects" a call only upon hanging up: that's when I am able to read the caller number. But I can't detect callActive and incomingCall events of callListener and EtelLineListener! why???

    Once I can detect incoming call, it will be easy to build programs which:
    - hang up undesired calls
    - send auto-message to specified caller upon receiving calls from them
    - maybe (in the future) display an image or play a sound upon receiving a call...

    ...but I need a bit of help here.

  5. #110
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: Python for UIQ

    Note:
    I think I need to use addLineListener on a terminal... but such a method does not exist!

    And for callListener, I tried adding in class definition,. but with no success.

  6. #111
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: Python for UIQ

    Ok, guys, it was absolutely, incredibly, defintely HARD to figure out how to detect and imcoming call and let the program answer or reject it, but I eventually got it!
    The only LITTLE problem is that once my application answers/rejects call, main Phone application keeps waiting for user to answer/reject call, and its dialog never disappears, and I must reboot the phone to get it usable gaian!

    So, the question is: how can I send keypresses to other applications in Jython? is it possibile? Looks like it is the only way I can use to answer/reject a call: by emulating keypresses in phone application!

    Here it is my new code. Methods ststusChange() and incomingCall() from EtelCallListener are what allows program to monitor calls.

    Soxurce also contains some constants I found while decompiling javaphone.

    Code:
    import javax.telephony.events
    import os
    import java.lang
    import com.symbian.javax.telephony.mobile
    import com.symbian.javax.telephony
    import com.symbian.epoc.etel
    import java.lang.Integer
    import java.lang.String
    import javax.net.datagram
    import com.symbian.javax.net.datagram
    from java.awt import Frame,MenuBar,Menu,MenuItem,TextArea,FileDialog
    from java.awt.event import ActionEvent
    #class test(java.awt.Frame, javax.telephony.ConnectionListener, com.symbian.epoc.etel.EtelLineListener):
    class test(java.awt.Frame, com.symbian.epoc.etel.EtelLineListener):
    	def __init__(self):
    		self.size=(208,276)
    		self.myOutput=java.awt.TextArea("Hello UIQ from Jython!!!\n")
    		self.add("Center",self.myOutput)
    		self.myMenuBar=java.awt.MenuBar()
    		self.myMenu=java.awt.Menu("Menu")
    		self.myReadFile=java.awt.MenuItem("Read File",actionPerformed=self.doRead)
    		self.myMenuExit=java.awt.MenuItem("Exit",actionPerformed=self.doExit)
    		self.myMenuBar.add(self.myMenu)
    		self.myMenu.add(self.myReadFile)
    		self.myMenu.add(self.myMenuExit)
    		self.setMenuBar(self.myMenuBar)
    		self.setVisible(1)
    	def doRead(self,event):
    		p=com.symbian.javax.telephony.mobile.EpocGsmMobileProvider()
    		ts=p.getTerminals()
    		t=ts[0]
    		tads=t.getAddresses()
    		tad=tads[0] 
    		m=com.symbian.javax.telephony.mobile.EpocGsmMobileTerminal(tad,p)
    		mads=m.getAddresses()
    		m=mads[0]
    		print "Numero SIM:",m.getSubscriptionId()
    		IMSIFile=open("c:\\system\\data\\e32user.bin",'r')
    		IMSI=IMSIFile.read()
    		print "Numero registrato: \n",IMSI
    		if java.lang.Integer.toString(m.getSubscriptionId()) != IMSI:
    			print "BRUTTO LADRONE!!!\n"
    			jnd=javax.net.datagram
    			dns=jnd.DatagramNameService
    			addr=com.symbian.javax.net.datagram.SMSAddress("xxxxx")
    			ds=jnd.DatagramService
    			serv=ds.getService(addr)
    			mex=java.lang.String("ti hanno fregato il cellulare!!!").getBytes()
    			d=jnd.Datagram(mex,addr)
    			serv.send(d)
    	def doExit(self,event):
    		java.lang.System.exit(0)
    
    	def callActive(self,event): #callListener
    		print "callActive (callListener)\n"
    	def callInvalid(self,event): #callListener
    		print "callInvalid (callListener)"
    	def callEventTransmissionEnded(self,event): #callListener
    		print "eventocallEventTransmissionEnded:  ( callListener)", event	
    	def statusChange(self, line, num): # etelline, status (da EtelLineListener)
    		print "*********STATUSCHANGE*********"
    		print "Stato attuale: ", num , "\n"
    		self.myOutput.appendText("Current call status: " + java.lang.Integer.toString(num)+ "\n")
    	def incomingCall(self, line, call): # etelline, etelcall (da EtelLineListener)
    		print " ----- INCOMING CALL -----"
    		self.myOutput.appendText("INCOMING  " + call.getCallerId() + "...\n")
    		print "->incoming call '" + call.getCallerId() 	
    	#	print "prima rispondo,..."
    	#	call.answer()
    	#	print "...poi riattacco!"
    	#	call.hangup()	
    	def connectionAlerting(self,event):
    		print "Chiamata in arrivo da numero "
    		incomingCall=event.getCall()
    		conns=incomingCall.getConnections()		
    #		print "Numero connessioni ALERTING: ",len(conns)			
    		addr1=conns[0].getAddress()
    		addr2=conns[1].getAddress()		
    		numero1=addr1.getName() # Probabilmente numero LOCALE.
    		numero2=addr2.getName()		
    #		print "1: " + numero1 + "\n"	
    		self.myOutput.appendText("Chiamata in arrivo da " + numero2 + "...")
    		print numero2 + "\n"	
    		#da qui non si puo' riagganciare: solo da metodo incomingCall().
    """
    	def connectionConnected(self,event):
    		print "connectionConnected"
    	def connectionCreated(self,event):
    		print "connectionCreated: ", event
    	def connectionDisconnected(self,event):
    		print "connectionDisconnected"
    	def connectionFailed(self,event):
    		print "connectionFailed"
    	def connectionInProgress(self,event):
    		print "connectionInProgress"
    	def connectionUnknown(self,event):
    		print "connectionUnknown"
    """
    		
    if __name__=="__main__":
    	myApp=test()
    
    peer=com.symbian.javax.telephony.EpocJtapiPeer()
    p=peer.getProvider("EpocGsmMobileProvider")
    terms=p.getTerminals()
    term=terms[0]
    addrs=p.getAddresses()
    addr=addrs[0]
    lines1 =  p.getPhone().getVoiceLines()
    line1 = lines1[0]
    lines2 = p.getVoiceLines()
    line2 = lines2[0]
    #addr.addCallListener(test()) # aggancia Listener all'Address
    term=com.symbian.javax.telephony.mobile.EpocGsmMobileTerminal(addr,p)
    #term.addCallListener(test())
    line1.addLineListener(test())
    
    
    print "READY."
    
    
    """
    ETEL CALL
        public static final int STATUS_UNKNOWN = 0;
        public static final int STATUS_IDLE = 1;
        public static final int STATUS_DIALLING = 2;
        public static final int STATUS_RINGING = 3;
        public static final int STATUS_ANSWERING = 4;
        public static final int STATUS_CONNECTING = 5;
        public static final int STATUS_CONNECTED = 6;
        public static final int STATUS_HANGING_UP = 7;
    
    CONNECTION
        public static final int IDLE = 48;
        public static final int INPROGRESS = 49;
        public static final int ALERTING = 50;
        public static final int CONNECTED = 51;
        public static final int DISCONNECTED = 52;
        public static final int FAILED = 53;
        public static final int UNKNOWN = 54;
        	
    TERMINAL CONNECTION
       public static final int IDLE = 64;
        public static final int RINGING = 65;
        public static final int PASSIVE = 66;
        public static final int ACTIVE = 67;
        public static final int DROPPED = 68;
        public static final int UNKNOWN = 69;
    
    TERMINAL CONNECTION EVENT
        public static final int TERMINAL_CONNECTION_ACTIVE = 115;
        public static final int TERMINAL_CONNECTION_CREATED = 116;
        public static final int TERMINAL_CONNECTION_DROPPED = 117;
        public static final int TERMINAL_CONNECTION_PASSIVE = 118;
        public static final int TERMINAL_CONNECTION_RINGING = 119;
        public static final int TERMINAL_CONNECTION_UNKNOWN = 120;
        
    CALL    
        public static final int IDLE = 32;
        public static final int ACTIVE = 33;
        public static final int INVALID = 34;
        
    CALL EVENT
        public static final int CALL_ACTIVE = 101;
        public static final int CALL_INVALID = 102;
        public static final int CALL_EVENT_TRANSMISSION_ENDED = 103;
    	
    CONNECTION EVENT
        public static final int CONNECTION_ALERTING = 104;
        public static final int CONNECTION_CONNECTED = 105;
        public static final int CONNECTION_CREATED = 106;
        public static final int CONNECTION_DISCONNECTED = 107;
        public static final int CONNECTION_FAILED = 108;
        public static final int CONNECTION_IN_PROGRESS = 109;
        public static final int CONNECTION_UNKNOWN = 110;
    
    SINGLE CALL META EVENT
        public static final int SINGLECALL_META_PROGRESS_STARTED = 210;
        public static final int SINGLECALL_META_PROGRESS_ENDED = 211;
        public static final int SINGLECALL_META_SNAPSHOT_STARTED = 212;
        public static final int SINGLECALL_META_SNAPSHOT_ENDED = 213;	    
    
    ADDRESS_EVENT_TRANSMISSION_ENDED = 100
        
    """

  7. #112
    Registered User
    Join Date
    Jul 2005
    Posts
    33

    Re: Python for UIQ

    main Phone application keeps waiting for user to answer/reject call, and its dialog never disappears
    Are you run your app. as script on AWT-console?
    Try run it as main application.To do this you have to...
    -change JythonQ.txt(or jRun.txt) last word(awtcons.py) into your app. name(test.py).
    -Don't use function "print"(use appendind your TextArea).

    So your app. can come back(Visible),when click JythonQ-icon(or jRun-icon).

  8. #113
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: Python for UIQ

    Quote Originally Posted by bpitk
    Are you run your app. as script on AWT-console?
    Try run it as main application.To do this you have to...
    -change JythonQ.txt(or jRun.txt) last word(awtcons.py) into your app. name(test.py).
    -Don't use function "print"(use appendind your TextArea).

    So your app. can come back(Visible),when click JythonQ-icon(or jRun-icon).
    How couold I run such a HUGE program from console?
    I stored it into a script and I run it using jRun.

    But Phone App has priority over any other application, and if I... "steal" call information "from under its foot", it gets crazy not being designed for such an event, it displays the damned dialog, and it indefinitely waits for user input... But when I click the buttons, it does not know how to handle the "answer call" or "reject call", being the call already been handled by somebody else...

  9. #114
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: Python for UIQ

    I successfully compiled .py scripts into jar files!

    Set classpath:

    set classpath = C:\Symbian\UIQ_21\erj\Ext\qawt.jar;C:\Symbian\UIQ_21\erj\Ext\util.jar;C:\Symbian\UIQ_21\epoc32\Java\ext\javaphone.jar;C:\Symbian\UIQ_21\epoc32\Java\lib\classes.zip

    Generate the .class files:
    jythonc -J "-classpath C:\Symbian\UIQ_21\erj\Ext\qawt.jar;C:\Symbian\UIQ_21\erj\Ext\util.jar;C:\Symbian\UIQ_21\epoc32\Java\ext\javaphone.jar;C:\Symbian\UIQ_21\epoc32\Java\lib\classes.zip" -CC:\Programmi\internet\Java\j2sdk1.4.2_10\bin\javac jython_script.py

    Go to jpywork folder in Jython folder and generate .jar file:
    -jar -cf jython_script.jar jython_script*.class

    Use aifbuilder to generate proper aif/app/txt file

    Move aif/app/txt/jar file to c:\system\app\jython_script folder

    Well, now comes the bad part: application does NOT start properly, due to well known NoClassDefFoundError , but maybe here somebody else can help me?

  10. #115
    Registered User
    Join Date
    Jul 2005
    Posts
    33

    Re: Python for UIQ

    When you make .aif file,make sure that classpath(after "-cp") include full path of...
    -your new .jar(jython-compiled)
    -classes.zip
    -qawt.jar
    -util.jar
    -javaphone.jar
    -jython home

  11. #116
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: Python for UIQ

    Quote Originally Posted by bpitk
    When you make .aif file,make sure that classpath(after "-cp") include full path of...
    -your new .jar(jython-compiled)
    -classes.zip
    -qawt.jar
    -util.jar
    -javaphone.jar
    -jython home
    looks like real device has no qawt.jar and util.jar files!
    But an application I installed ("Prosit") has them, so I used this classpath:
    jython-compiled.jar;z:\system\java\lib\classes.zip;z:\system\java\ext\javaphone.jar;c:\system\apps\prosit\qawt.jar;c:\system\apps\prosit\util.jar;d:\jython

    well... my phone reboots as soon as I attempt starting the jar!!!

  12. #117
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: Python for UIQ

    I tried with a simple test script containing just a PRINT "hello" line: it compiles fine into a JAR, but I still can't launch it!
    Are you able to do it?

  13. #118
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: Python for UIQ

    This line works on PC:
    java -cp .;D:\programmi\programmazione\jython\jython.jar -Dpython.home=D:\jython guardian

    (for guardian.py script already compiled)

    What's the equivalent for the phone??? There's no jython.jar on the phone!

  14. #119
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: Python for UIQ

    Quote Originally Posted by cassioli
    This line works on PC:
    java -cp .;D:\programmi\programmazione\jython\jython.jar -Dpython.home=D:\jython guardian

    (for guardian.py script already compiled)

    What's the equivalent for the phone??? There's no jython.jar on the phone!
    I can't get it working even after copying jython.jar to phone or compiling with "--all" option in jythonc!!
    I REALLY NEED HELP

  15. #120
    Registered User
    Join Date
    Jul 2005
    Posts
    33

    Re: Python for UIQ

    Quote Originally Posted by cassioli
    looks like real device has no qawt.jar and util.jar files!
    I've never used qawt.jar and util.jar before.
    You can try put them in C:\java\ext in UIQ.
    And add "C:\java\ext\qawt.jar;C:\java\ext\util.jar" in -cp.

    Quote Originally Posted by cassioli
    I tried with a simple test script containing just a PRINT "hello" line: it compiles fine into a JAR, but I still can't launch it!
    Are you able to do it?
    "PRINT" function need to run on console.
    If you try to run it as standalone app.,"PRINT" function will do nothing,try using TextArea&TextArea method.

    Quote Originally Posted by cassioli
    This line works on PC:
    java -cp .;D:\programmi\programmazione\jython\jython.jar -Dpython.home=D:\jython guardian

    (for guardian.py script already compiled)

    What's the equivalent for the phone??? There's no jython.jar on the phone!
    on PC
    "java -cp .\myApp.jar;C:\jython\jython.jar -Dpython.home=C:\jython myApp"

    is equivalent to this on Phone.
    "-cp myApp.jar;D:\jython -Dpython.home=D:\jython myApp"

    In our Jython on phone,we Extract jython.jar in D:\jython(to make it faster),so "-cp"(on phone) should be add "D:\jython".

Similar Threads

  1. Please help installing Python libraries on S60
    By ericroijen in forum Symbian
    Replies: 11
    Last Post: 2009-07-18, 10:43
  2. Python for Series 60 released on Forum Nokia!
    By eriksmartt in forum Symbian
    Replies: 5
    Last Post: 2009-07-14, 17:00
  3. Python 2.2? 2.3?
    By mflux in forum Symbian
    Replies: 3
    Last Post: 2006-06-26, 22:36
  4. Python C++ Extension with Callback crashing
    By diggerdeep in forum Symbian
    Replies: 2
    Last Post: 2005-11-10, 16:33
  5. Replies: 0
    Last Post: 2004-07-18, 00:56

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×