Archived:How to set/unset read SMS status in PySymbian
Aquivado: Este artigo foi arquivado, pois o conteúdo não é mais considerado relevante para se criar soluções comerciais atuais. Se você achar que este artigo ainda é importante, inclua o template {{ForArchiveReview|escreva a sua justificativa}}.
All PySymbian articles have been archived. PySymbian is no longer maintained by Nokia and is not guaranteed to work on more recent Symbian devices. It is not possible to submit apps to Nokia Store.
All PySymbian articles have been archived. PySymbian is no longer maintained by Nokia and is not guaranteed to work on more recent Symbian devices. It is not possible to submit apps to Nokia Store.
Article Metadata
We can set or unset the status of message in the new PySymbian 1.4.4. Below code shows how to do that.
# 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
for i, msg in enumerate(msgs):
if message == msg:
if status == 1:
inb.set_unread(sms_ids[i],1)
else:
inb.set_unread(sms_ids[i],0)
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()


Copied from PySymbian 1.4.4 SMS read/unread status example
--kiran10182 11:23, 29 June 2008 (EEST)
Hi Pankaj, It seems to be a good article. Let's discuss about it before you delete it.
--kiran10182 14:09, 29 June 2008 (EEST)
Hi Pankaj, I do not understand what's wrong here but article seems to be fine to be placed on Wiki. I am rollbacking your changes. Please discuss it here before you delete it or make any change. I hope you can understand.
--kiran10182 17:39, 29 June 2008 (EEST)
Hi Kiran,
I had created new pages for the same title and deleted the ones without the copyright note; but as you directly restored the pages from the Deleted Pages Log, they simply got overwritten! Now finally I have edited the code and added the copyright notes, so there shouldn't be any challenges henceforth.
--croozeus
Hi Pankaj, I wanted to convey this. Now it seems to be more understandable. I appreciate your work.
Cheers,
--kiran10182 20:45, 29 June 2008 (EEST)