You Are Here:

Community: Developer Discussion Boards

#1 Old Lightbulb [PyS60 1.4.4] SMS read/unread status example - 2008-06-29, 02:55

Join Date: Feb 2005
Posts: 1,353
Location: Belgium (Europe)
cyke64's Avatar
cyke64
Offline
Super Contributor
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,1.9.7,pygame,PyS60 CE on E90 , N810 with Python 2.5.2 and ... last PyS60 1.9.7 with touch ui on 5800 !

pys60 extension modules on http://cyke64.googlepages.com/
Reply With Quote

#2 Old Re: [PyS60 1.4.4] SMS read/unread status example - 2008-06-29, 09:56

Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
Send a message via Yahoo to gaba88 Send a message via Skype™ to gaba88
gaba88's Avatar
gaba88
Offline
Forum Nokia Champion
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.


Gargi Das- http://gargidas.blogsot.com

Forum Nokia Python Wiki


Learn Python at http://mobapps.org/PyS60
Reply With Quote

#3 Old Re: [PyS60 1.4.4] SMS read/unread status example - 2008-06-29, 23:47

Join Date: Mar 2003
Posts: 115
Dansco
Offline
Regular Contributor
Excellent example mate so thanx
Reply With Quote

#4 Old Re: [PyS60 1.4.4] SMS read/unread status example - 2008-07-02, 17:13

Join Date: Jul 2008
Posts: 8
NaKeD
Offline
Registered User
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.
Reply With Quote

#5 Old Re: [PyS60 1.4.4] SMS read/unread status example - 2008-07-02, 17:40

Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
bogdan.galiceanu's Avatar
bogdan.galiceanu
Offline
Forum Nokia Champion
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.
Reply With Quote

#6 Old Re: [PyS60 1.4.4] SMS read/unread status example - 2008-07-02, 18:37

Join Date: Jul 2008
Posts: 8
NaKeD
Offline
Registered User
Hello Bogdan,

10x for the warm wellcome

I've already signed my app.
Reply With Quote

#7 Old Re: [PyS60 1.4.4] SMS read/unread status example - 2008-07-02, 19:43

Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
Send a message via Yahoo to gaba88 Send a message via Skype™ to gaba88
gaba88's Avatar
gaba88
Offline
Forum Nokia Champion
hi NakeD
can you explain the procedure you used to make the sis so that it will be easy to spot the error.


Gargi Das- http://gargidas.blogsot.com

Forum Nokia Python Wiki


Learn Python at http://mobapps.org/PyS60
Reply With Quote

#8 Old Re: [PyS60 1.4.4] SMS read/unread status example - 2008-07-02, 22:13

Join Date: Jul 2008
Posts: 8
NaKeD
Offline
Registered User
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.
Reply With Quote

#9 Old Re: [PyS60 1.4.4] SMS read/unread status example - 2008-07-03, 18:50

Join Date: Jul 2008
Posts: 8
NaKeD
Offline
Registered User
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?
Reply With Quote

#10 Old Re: [PyS60 1.4.4] SMS read/unread status example - 2008-07-03, 18:57

Join Date: May 2007
Posts: 2,738
Location: 21.46 N 72.11 E
croozeus's Avatar
croozeus
Offline
Forum Nokia Champion
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
Reply With Quote

#11 Old Re: [PyS60 1.4.4] SMS read/unread status example - 2008-07-03, 21:15

Join Date: Jul 2008
Posts: 8
NaKeD
Offline
Registered User
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.
Reply With Quote

#12 Old Re: [PyS60 1.4.4] SMS read/unread status example - 2008-07-04, 06:00

Join Date: May 2007
Posts: 2,738
Location: 21.46 N 72.11 E
croozeus's Avatar
croozeus
Offline
Forum Nokia Champion
Quote:
Originally Posted by NaKeD View Post
Hi Pankaj,

and it works like a charm.
Glad to know that

Br,
Croozeus
Reply With Quote

#13 Old Re: [PyS60 1.4.4] SMS read/unread status example - 2008-12-13, 12:03

Join Date: Dec 2008
Posts: 6
samsee
Offline
Registered User
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
Reply With Quote

#14 Old Re: [PyS60 1.4.4] SMS read/unread status example - 2008-12-13, 14:09

Join Date: Nov 2008
Posts: 73
xiaobu
Offline
Regular Contributor
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 ?
Reply With Quote

#15 Old Re: [PyS60 1.4.4] SMS read/unread status example - 2008-12-13, 15:13

Join Date: Feb 2008
Posts: 743
Location: Belo Horizonte, Brazil
Send a message via Skype™ to Rafael T.
Rafael T.'s Avatar
Rafael T.
Offline
Forum Nokia Champion
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.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Push registry for SMS interceptor iworktech_kiran Mobile Java General 4 2007-11-02 23:13
AT command for SMS status saeedspd General Messaging 2 2004-08-16 23:07
D211Ctl perform illegal operation when trying to send sms by Req_Sms_Send bcchong General Messaging 1 2002-07-22 12:08
D211Ctl perform illegal operation when trying to send sms by Req_Sms_Send bcchong Symbian Tools & SDKs 0 2002-06-03 04:13
The D211Ctl Illegal operation when trying to send sms using Req_Sms_Send! bcchong Multimodecards 0 2002-06-03 04:11

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia