×

Discussion Board

Results 1 to 15 of 15
  1. #1
    Registered User
    Join Date
    Feb 2005
    Location
    Belgium (Europe)
    Posts
    1,352

    Lightbulb [PyS60 1.4.4] SMS read/unread status example

    Hello ,

    Here's an example from Nokia for set/unset read sms status !
    this example only works with PyS60 1.4.4

    Code:
    # Copyright (c) 2008 Nokia Corporation
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #     http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    
    # NOTE: Sets/Get the status(1=unread, 0=read) of SMS.
    import inbox, appuifw, e32
    
    inb = inbox.Inbox()
    sms_ids = inb.sms_messages()
    msgs = []
    msg_unread = []
    msg_read = []
    
    for id in sms_ids:
        msgs.append(inb.content(id))
    
    def setreadunread(message, status):
        global msgs
        i = 0
        for msg in msgs:
            if message == msg:
                if status == 1:
                    inb.set_unread(sms_ids[i],1)
                else:
                    inb.set_unread(sms_ids[i],0)      
            i = i+1                                
                
    def get_readandunreadmessages_inlist():
        global msg_unread
        global msg_read
        msg_unread = []
        msg_read = []
        for id in sms_ids:
            if inb.unread(id):
                msg_unread.append(inb.content(id))
            else:
                msg_read.append(inb.content(id))
    
    def setmessageunread():
        global msg_read
        get_readandunreadmessages_inlist()
        index = appuifw.selection_list(msg_read, 1)
        if index != None and index >= 0:
            print index
            setreadunread(msg_read[index], 1)
            print "Done"
    
    def setmessageread():
        global msg_unread
        get_readandunreadmessages_inlist()
        index = appuifw.selection_list(msg_unread, 1)
        if index != None and index >= 0:
            print index
            setreadunread(msg_unread[index], 0)
            print "Done"
    
    def showmessagestatus():
        global sms_ids
        for id in sms_ids:
            print inb.content(id)[:20]
            print inb.unread(id)
    
    def quit():
        app_lock.signal()
        
    appuifw.app.exit_key_handler = quit
    appuifw.app.menu = [(u"Mark_read", setmessageread),
                        (u"Mark_unread", setmessageunread),
                        (u"Show_read/unread_status", showmessagestatus)]
    app_lock = e32.Ao_lock()
    app_lock.wait()
    Happy Pythoning
    Cyke64
    pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !

    Find my pys60 extension modules on cyke64.googlepages.com

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: [PyS60 1.4.4] SMS read/unread status example

    hi cyke
    thankx for explaining how to use the new things in the latest version of our PyS60.
    For future use and reference i have written a wiki article on all these new advantages.
    have look at this.

  3. #3
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    115

    Re: [PyS60 1.4.4] SMS read/unread status example

    Excellent example mate so thanx

  4. #4
    Registered User
    Join Date
    Jul 2008
    Posts
    8

    Re: [PyS60 1.4.4] SMS read/unread status example

    Quote Originally Posted by cyke64 View Post
    Hello ,

    Here's an example from Nokia for set/unset read sms status !
    this example only works with PyS60 1.4.4

    Code:
    # Copyright (c) 2008 Nokia Corporation
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #     http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    
    # NOTE: Sets/Get the status(1=unread, 0=read) of SMS.
    import inbox, appuifw, e32
    
    inb = inbox.Inbox()
    sms_ids = inb.sms_messages()
    msgs = []
    msg_unread = []
    msg_read = []
    
    for id in sms_ids:
        msgs.append(inb.content(id))
    
    def setreadunread(message, status):
        global msgs
        i = 0
        for msg in msgs:
            if message == msg:
                if status == 1:
                    inb.set_unread(sms_ids[i],1)
                else:
                    inb.set_unread(sms_ids[i],0)      
            i = i+1                                
                
    def get_readandunreadmessages_inlist():
        global msg_unread
        global msg_read
        msg_unread = []
        msg_read = []
        for id in sms_ids:
            if inb.unread(id):
                msg_unread.append(inb.content(id))
            else:
                msg_read.append(inb.content(id))
    
    def setmessageunread():
        global msg_read
        get_readandunreadmessages_inlist()
        index = appuifw.selection_list(msg_read, 1)
        if index != None and index >= 0:
            print index
            setreadunread(msg_read[index], 1)
            print "Done"
    
    def setmessageread():
        global msg_unread
        get_readandunreadmessages_inlist()
        index = appuifw.selection_list(msg_unread, 1)
        if index != None and index >= 0:
            print index
            setreadunread(msg_unread[index], 0)
            print "Done"
    
    def showmessagestatus():
        global sms_ids
        for id in sms_ids:
            print inb.content(id)[:20]
            print inb.unread(id)
    
    def quit():
        app_lock.signal()
        
    appuifw.app.exit_key_handler = quit
    appuifw.app.menu = [(u"Mark_read", setmessageread),
                        (u"Mark_unread", setmessageunread),
                        (u"Show_read/unread_status", showmessagestatus)]
    app_lock = e32.Ao_lock()
    app_lock.wait()
    Happy Pythoning
    Cyke64

    Hello,
    I've used the above at Interactive Command Prompt at my S60 device and everything works fine.
    After i compile the source to sis (with ensymble.py py2sis) i get an error at the compiled app:
    "KErrPermissionDenied"

    Anyone have a clue?

    Thanks ahead, Liran.

  5. #5
    Nokia Developer Moderator
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: [PyS60 1.4.4] SMS read/unread status example

    Hi Liran and welcome to the Python discussion board.

    You most likely need to sign the sis file with some extra capabilities. So go to www.symbiansigned.com, Open Signed Online, enter your information there, tick all the capabilities available (and specify them when creating the sis file with ensymble) and submit the application for signing. It should work after that.

  6. #6
    Registered User
    Join Date
    Jul 2008
    Posts
    8

    Re: [PyS60 1.4.4] SMS read/unread status example

    Hello Bogdan,

    10x for the warm wellcome

    I've already signed my app.

  7. #7
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: [PyS60 1.4.4] SMS read/unread status example

    hi NakeD
    can you explain the procedure you used to make the sis so that it will be easy to spot the error.

  8. #8
    Registered User
    Join Date
    Jul 2008
    Posts
    8

    Re: [PyS60 1.4.4] SMS read/unread status example

    I'm using Ensymble.PY witch can be found on the web:


    Ensymble developer utilities for Symbian OS

    usage: ensymble.py py2sis
    [--uid=0x01234567] [--appname=AppName] [--version=1.0.0]
    [--lang=EN,...] [--icon=icon.svg] [--shortcaption="App. Name",...]
    [--caption="Application Name",...] [--drive=C]
    [--textfile=mytext_%C.txt] [--cert=mycert.cer] [--privkey=mykey.key]
    [--passphrase=12345] [--caps=Cap1+Cap2+...]
    [--vendor="Vendor Name",...] [--autostart] [--runinstall]
    [--encoding=terminal,filesystem] [--verbose]
    <src> [sisfile]

    Create a SIS package for a "Python for S60" application.

  9. #9
    Registered User
    Join Date
    Jul 2008
    Posts
    8

    Re: [PyS60 1.4.4] SMS read/unread status example

    but again, as i mentioned, this occurs only when i'm using the compiled version of my program (the sis file) as the file seem to have no permissions to access the phone's msgs for editing.
    at the interactive run of python i can get to msgs editing.

    anyone have a clue?

  10. #10
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,777

    Re: [PyS60 1.4.4] SMS read/unread status example

    Quote Originally Posted by NaKeD View Post
    but again, as i mentioned, this occurs only when i'm using the compiled version of my program (the sis file) as the file seem to have no permissions to access the phone's msgs for editing.
    at the interactive run of python i can get to msgs editing.

    anyone have a clue?
    The problem seems to be with your signing.

    Also you missed out to add --caps when making the SIS file.

    Best Regards,
    Croozeus
    Pankaj Nathani
    www.croozeus.com

  11. #11
    Registered User
    Join Date
    Jul 2008
    Posts
    8

    Re: [PyS60 1.4.4] SMS read/unread status example

    Hi Pankaj,

    10XXX. You were right. I recompile the app using:
    --caps=WriteUserData+WriteDeviceData+ReadDeviceData+ReadUserData+NetworkServices

    and it works like a charm.

    Gr8 work mate.

  12. #12
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,777

    Re: [PyS60 1.4.4] SMS read/unread status example

    Quote Originally Posted by NaKeD View Post
    Hi Pankaj,

    and it works like a charm.
    Glad to know that

    Br,
    Croozeus
    Pankaj Nathani
    www.croozeus.com

  13. #13
    Registered User
    Join Date
    Dec 2008
    Posts
    6

    Re: [PyS60 1.4.4] SMS read/unread status example

    nice application, can anyone show me how to view address and content on selection list view. i have trial and error but still don't work.

    BS

  14. #14
    Regular Contributor
    Join Date
    Nov 2008
    Posts
    73

    Re: [PyS60 1.4.4] SMS read/unread status example

    Quote Originally Posted by NaKeD View Post
    Hi Pankaj,

    10XXX. You were right. I recompile the app using:
    --caps=WriteUserData+WriteDeviceData+ReadDeviceData+ReadUserData+NetworkServices

    and it works like a charm.

    Gr8 work mate.
    -------------------------------
    how to make a sis for the 2nd edition?the explain on the wiki is so complex,but what's is pysisng?
    can you help me ?

  15. #15
    Super Contributor
    Join Date
    Feb 2008
    Location
    Belo Horizonte, Brazil
    Posts
    744

    Re: [PyS60 1.4.4] SMS read/unread status example

    Quote Originally Posted by xiaobu View Post
    -------------------------------
    how to make a sis for the 2nd edition?the explain on the wiki is so complex,but what's is pysisng?
    can you help me ?
    Hi xiaobu,

    The name itself already tells you what it is: py2sis. It is the process to transform your .py file(script) into a .sis, so you will have a icon on the menu with your application.

    Check the PyS60 FAQ. There is a answer about making a .sis for 2nd edition


    Hope it helps,

    Rafael.

Similar Threads

  1. Problem with Push registry for SMS interceptor
    By iworktech_kiran in forum Mobile Java General
    Replies: 4
    Last Post: 2007-11-02, 22:13
  2. AT command for SMS status
    By saeedspd in forum General Messaging
    Replies: 2
    Last Post: 2004-08-16, 22:07
  3. Replies: 1
    Last Post: 2002-07-22, 11:08
  4. Replies: 0
    Last Post: 2002-06-03, 03:13
  5. Replies: 0
    Last Post: 2002-06-03, 03:11

Posting Permissions

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