×

Discussion Board

Page 5 of 10 FirstFirst 12345678910 LastLast
Results 61 to 75 of 142

Thread: Python for UIQ

  1. #61
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: Python for UIQ

    Quote Originally Posted by c4
    thanks man,

    2 things

    1. do you mean i have to create a .j9 file with the above command and run it?
    i'm at work now i'll get to do this once i'm home

    2. about the APIs? how do i get a list of them, if you see s60 python

    http://www.mobilenin.com/pys60/side/comano.php

    they have APIs for almost every thing in the phone.
    this is the big lack of Jython: it CAN'T use standard Python's APIs! They are written in c++, Jython is written in Java, so there's no way to interconnect them.
    BUT I know Personal Java supports Javaphone API, which allow accessing phone features. I don't know "How" and "if" it is possible to access javaphone API using Jython. I think bptik can help us?

  2. #62
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: Python for UIQ

    Quote Originally Posted by bpitk
    Now check in your C:\ (of UIQ),You will see file result.txt contained "hello world,something".
    And you can use the same code on any Python on any Platform.
    No need extra C++ code.
    I was talking about C++ as I'd like to use files to allow jython scripts to commuicate with c++ apps.
    Or is there another method to exchange data between jython and c++ programs?

    My phone does support javaphone.... but I don't know how to use java packages from within jython! Actually, I don't know so well even how to use them from java itself...

    This is a sample PJ source to access contacts (found in Javaphone documentation); any idea about how to port it to Jython?

    Code:
    /*
    * Copyright 1999 Sun Microsystems Inc, All rights reserved.
    */
    import javax.pim.addressbook.*;
    import javax.pim.database.*;
    /**
    * This example program shows how to lookup the phone number for
    * one or more persons.
    */
    public class ContactSample1 {
    ContactDatabase addressbook; // The open addressbook
    /**
    * The arguments to this program are the names of the people to
    * lookup. For each person, print the prefered telephone number.
    *
    * @param args the array of Strings containing each persons name.
    */
    public static void main(String[] args) {
    ContactSample1 sample = new ContactSample1();
    if (sample.open()) {
    for (int i = 0; i < args.length; i++) {
    sample.lookup(args[i]);
    }
    sample.close();
    }
    }
    /*
    JavaPhone Specification 1.0 50
    Design Goals 22 Mar 2000
    * Lookup a name in the database and print the prefered voice phone
    * numbers available for it.
    *
    * @param name the name to look up
    */
    void lookup(String name) {
    try {
    Iterator it = addressbook.items();
    while(it.hasNext()) {
    ContactCard card = (ContactCard)it.next();
    if (card.getName().indexOf(name) != -1) {
    String[] tel =
    card.getPreferredPhoneNumbers(ContactDatabase.VOICE);
    for (int i = 0; i < tel.length; i++) {
    System.out.println("Name: " + card.getName() +
    ": " + tel[i]);
    }
    }
    }
    } catch (DatabaseException ex) {
    System.out.println("Error getting contact information for " +
    name + ": " +
    ex.getMessage());
    }
    }
    /*
    * Open the database.
    *
    * @return true if open was successful
    */
    boolean open() {
    try {
    // Open the contact database.
    addressbook = ContactDatabase.openDatabase();
    } catch (DatabaseException ex) {
    System.out.println("Unable to open ContactDatabase: " +
    ex.getMessage());
    return false;
    }
    return true; // Addressbook opened successfully
    }
    /*
    * Close the contact database.
    *
    * @return true if close was successful
    */
    boolean close() {
    try {
    // Close the contact database.
    if (addressbook != null )
    addressbook.close();
    } catch (DatabaseException ex) {
    System.out.println("Unable to close the ContactDatabase: " +
    ex.getMessage());
    return false;

  3. #63
    Registered User
    Join Date
    Jul 2005
    Posts
    33

    Re: Python for UIQ

    My Phone is not support JavaPhone API,
    and I've never used any Phone that support JavaPhone before.(I've used UIQ for only 2mo.)
    So it hard (for me) to know how to use JavaPhone API on Jython.
    But I got some idea.
    When You add any class(new javaAPI) for Jython,You add it(.jar) to classpath.
    But I JythonUIQ-case,it will proceed faster if you extract .jar into .class(and folders) and place it in D:\jython.
    So try this.
    Find javaPhone.jar in your SmartPhone.
    (It may not named JavaPhone.jar ,but (when you extract) it has folder "javax"(and folder "pim" inside).
    Then,place (the big) javax folder (+com folder+.class (from that JavaPhone.jar)) in D:\jython.
    (If you have problem with com folder.Put content of com folder from JavaPhone.jar in com folder in D:\jython)
    After that,You can access JavaPhone.Try...

    >>> import javax
    >>> dir(javax)

    You will see list of API in javax,including "pim".If you Phone support JavaPhoneAPI,you can use it.

    My knowledge about C++ on Symbian is very tiny,so I can't advice Symbian-File programming in C++.
    Last edited by bpitk; 2007-01-24 at 09:11.

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

    Re: Python for UIQ

    i found javaphone.jar .
    I renamed to .zip.
    I extracted JAVAX folder (whic contains PIM, COMM, NET, POWER and TELEPHONY folders) into d:\jython
    But IMPORT does not find any "javax" module.

  5. #65
    Registered User
    Join Date
    Jul 2005
    Posts
    33

    Re: Python for UIQ

    Quote Originally Posted by cassioli
    i found javaphone.jar .
    I renamed to .zip.
    I extracted JAVAX folder (whic contains PIM, COMM, NET, POWER and TELEPHONY folders) into d:\jython
    But IMPORT does not find any "javax" module.
    You may need restart Jython,or try...
    >> reload(javax)

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

    Re: Python for UIQ

    i copied javax contents to java folder and imported java again, and now dir(java) shows all new modules!
    what now?

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

    Re: Python for UIQ

    Quote Originally Posted by cassioli
    i copied javax contents to java folder and imported java again, and now dir(java) shows all new modules!
    what now?
    You make the pacakges confused,it should be...
    javax.pim.addressbook.*, javax.pim.database.*
    (Don't forget to add other Folders in JavaPhone.jar)

    not java.pim...

    You should try,until you can ...
    >>> import javax.pim

    and,then...
    >>> x=javax.pim.addressbook.ContactDatabase.openDatabase()

    ,but I can't go beyon that,because my phone showed UnsatisfiedLinkError(No JavaPhone support).I think you have the idea now.

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

    Re: Python for UIQ

    Quote Originally Posted by bpitk
    You make the pacakges confused,it should be...
    javax.pim.addressbook.*, javax.pim.database.*
    (Don't forget to add other Folders in JavaPhone.jar)

    not java.pim...

    You should try,until you can ...
    >>> import javax.pim

    and,then...
    >>> x=javax.pim.addressbook.ContactDatabase.openDatabase()

    ,but I can't go beyon that,because my phone showed UnsatisfiedLinkError(No JavaPhone support).I think you have the idea now.
    IT WOOOOORKS!!!
    >>> print x
    com.symbian.javax.pim.addressbook.EpocContactDatabase@522979

    No idea of what it means and how to go on , but it is not an error message, so I guess "something is working"...
    I continue trying...

    BTW, is it possible to get awtconsole supporting commands history?

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

    Re: Python for UIQ

    >>> it=x.items()
    >>> card = it.next()
    >>> print card.getName()
    Business

    I don't understand (yet) how to read the various fields value of each card...

    I past again personaljava source (snippet) for reference:
    Code:
    void lookup(String name) {
    try {
    Iterator it = addressbook.items();
    while(it.hasNext()) {
    ContactCard card = (ContactCard)it.next();
    if (card.getName().indexOf(name) != -1) {
    String[] tel =
    card.getPreferredPhoneNumbers(ContactDatabase.VOICE);
    for (int i = 0; i < tel.length; i++) {
    System.out.println("Name: " + card.getName() +
    ": " + tel[i]);
    }
    }
    }
    }

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

    Re: Python for UIQ

    Quote Originally Posted by cassioli
    IT WOOOOORKS!!!
    >>> print x
    com.symbian.javax.pim.addressbook.EpocContactDatabase@522979

    No idea of what it means and how to go on , but it is not an error message, so I guess "something is working"...
    I continue trying...

    BTW, is it possible to get awtconsole supporting commands history?
    My new awtcons.py support Command History.(I told you before.)
    http://isiam.info/dl/awtcons02.zip

    I can't help you anymore.(Because I never use Iterator in Jython.)
    You should tranform this part of code by yourself.
    Code:
    try {
        Iterator it = x.items();
        while(it.hasNext()) {
           ContactCard card = (ContactCard)it.next();
           if (card.getName().indexOf(name) != -1) {
                String[] tel = card.getPreferredPhoneNumbers(ContactDatabase.VOICE);
                for (int i = 0; i < tel.length; i++) {
                    System.out.println("Name: " + card.getName() +": " + tel[i]);
    Last edited by bpitk; 2007-01-24 at 09:59.

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

    Re: Python for UIQ

    After this:

    >>> it=x.items()
    >>> card = it.next()
    >>> print card.getName()
    Business


    this works:

    >>> tel=card.getPreferredPhoneNumbers("WORK")

    but print tel[1] does not (index out of range, also using "0"): Why?

    >>> print card.getPreferredPhoneNumbers("WORK")
    array([],java.lang.String)

  12. #72
    Registered User
    Join Date
    Jul 2005
    Posts
    33

    Re: Python for UIQ

    try...
    >>> it=x.items()
    >>> card = it.next()
    >>> tel=card.getPreferredPhoneNumbers(javax.pim.addressbook.ContactDatabase.VOICE)
    >>> print card.getName()
    >>> print tel
    and then...
    >>> card = it.next()
    >>> tel=card.getPreferredPhoneNumbers(javax.pim.addressbook.ContactDatabase.VOICE)
    >>> print card.getName()
    >>> print tel
    again and again ... see some clue?

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

    Re: Python for UIQ

    Quote Originally Posted by bpitk
    try...
    >>> it=x.items()
    >>> card = it.next()
    >>> tel=card.getPreferredPhoneNumbers(javax.pim.addressbook.ContactDatabase.VOICE)
    >>> print card.getName()
    >>> print tel
    and then...
    >>> card = it.next()
    >>> tel=card.getPreferredPhoneNumbers(javax.pim.addressbook.ContactDatabase.VOICE)
    >>> print card.getName()
    >>> print tel
    again and again ... see some clue?
    i got the point, but I can't print array contents! both printing TEL or card.getPreferredPhoneNumbers("WORK") results in :
    array([],java.lang.String)
    and printing tel[1] results in "index error".
    "length" appears not to be an attribute of TEL .

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

    Re: Python for UIQ

    wait, my mistake:
    >>> tel=card.getPreferredPhoneNumbers("WORK")
    >>> print tel
    array([],java.lang.String)

    THought this was an error....Actual it is an empty value!!

    >>> tel=card.getPreferredPhoneNumbers("VOICE")
    >>> print tel
    array([xxxxxxxxx], java.lang.String)

    (where xxxxxxxx is the contact number).



    I wonder how to get just the xxxxxxxxxxx intoa variable!

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

    Re: Python for UIQ

    Quote Originally Posted by cassioli
    I wonder how to get just the xxxxxxxxxxx intoa variable!
    >>> card = it.next()
    >>> tel=card.getPreferredPhoneNumbers(javax.pim.addressbook.ContactDatabase.VOICE)
    >>> print card.getName()
    >>> print tel

    You should search one by one,from begin to end(all over again),to get Name and Number You need.
    (Because it's Iterator)
    Congratulation...bye.
    Last edited by bpitk; 2007-01-24 at 10:40.

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
  •  
×