Hi all ,

I got two questions :

How to convert the time of a message from "127558161.23" to 03/06/2010 12:42pm ?


When I receive a message and I want to know the number of the sender so I can resend him a message it returns me his name - if it's exist in my contact data base - and error happens , and I found some codes talking about searching the data base based on this name and fetching the first mobile number ......

But what if the sender in my contacts has more than mobile phone number , that means that I may Resend SMS to the Unactive number !!!! ???


So , What can I do to get the right phone number of a message ??


Ex:

http://http://sites.google.com/site/...s/inbox_module


Many thanks in advance.

Symbian module description

You can check there and come with some code questions. ;)

I also program on that platform. Cheers! ;)

Again... lol

for your time question

import time
timestamp = time.time()
convertedtime = time.strftime("%a, %d %b %Y %H:%M:%S", timestamp)

The string "127558161.23" would not convert using the time module because it is not a 9 digit integer. Truncating the decimals yields the following result using gmtime() but is not close to the desired date and time. So it appears that the format is not "epoch second" which means a custom conversion routine will have to be used. I don't know if this comes from a Symbian platform or not, but the question should probably be asked on the phone maker's forum. Once the format is known, it can then be converted using Python or any other programming language.

time.struct_time(tm_year=1974, tm_mon=1, tm_mday=16, tm_hour=8, tm_min=49, tm_sec=21, tm_wday=2, tm_yday=16, tm_isdst=0)

Many thanks ihatehippies for your answer , but It gives me error:
"argument must be 9 item sequence not float"

Many thanks woooee for your answer , but I'm newbie in symbian and python , so I don't understand your idea , if you can give more help that would be appreciated.


anyone how use pys60 , how could you get the time of arrived SMS in normal date

ex:5/6/2010 10:20 pm

I need a function that works , I'm new in python.

Many thanks in advance.

Here's a test script I've written some time ago. Hope it helps.

And to all the experts, I'm just beginning python and symbian, don't be to arsh on me. :D

import appuifw
import audio
import contacts
import e32 
import inbox
import time

appuifw.app.title = u"->>SMSTalk v1"
appuifw.note(u"Loading ->>SMSTalk v1 by Beat_Slayer...", 'info')
print "\nLoading ->>SMSTalk v1 by Beat_Slayer..."

def now():
    t = time.time()
    hh, mm, ss = time.localtime(t)[3:6] 
    return (str(hh) + "h:" + str(mm) + "m:" + str(ss)) + "s"

def readsms(index):
    sendernumber = inbox.address(index)
    sender = list.find(sendernumber)
    name = sender[0].title
    smstime = inbox.time(index)
    content = inbox.content(index)
    readit = appuifw.query(u"SMS from " + name + ". Read it?", 'query')
    if readit == True:
        audio.say(content)
        print "\n->>SMSTalk read a message from " + name + " at " + now() + "."
    else:
        print "\n->>SMSTalk ignored a message from " + name + " at " + now() + "."


def exit_key_handler():
    appuifw.note(u"->>SMSTalk v1 successfull!",'conf')
    print "\n->>SMSTalk v1 successfull!"
    print "Beat_Slayer 2010"
    lock.signal()

lock = e32.Ao_lock() 
inbox = inbox.Inbox() 
list = contacts.open()
print "\n->>SMSTalk v1 waiting for incoming SMS..."
inbox.bind(readsms)

appuifw.app.exit_key_handler = exit_key_handler
lock.wait()

Many thanks Beat_Slayer for your reply , but ...

If I receive a message from a number saved in my contact , "sendername" will return me his name not the number.

ex:

Sender : Ashraf (0117185638 - 0122798480)

Now if Ashraf sent me SMS from his second number and I want to make auto reply , how could I do that , most code you can find arround looking for the first number in contacts db , And I'm sure you understand my question , cause my Auto Replay program will send the SMS to the first number (Which may not be active at this moment) !!

Can you post some code to make it more clear.

From my experience the sendernumber given by line 18 is the number that sent you the sms. If you reply to that number the sms will go to who sent you.

But if you pick the sendername pick by line 20 then you can have thosekind of problems.

I want to help.

First of all , Many thanks for your patient and your help.

this is my code :

import appuifw, e32, inbox, audio, graphics, messaging, sysinfo, sys, globalui, logs, contacts, codecs,globalui,os

def Quit():
    app_lock.signal()


def message_received(msg_id):
	
	box = inbox.Inbox()
	sms_text = box.content(msg_id)
	sender = box.address(msg_id)#that's my code which returns the contact name if he is saved my Contacts data base.




#To handle received messages.	
box = inbox.Inbox()
box.bind(message_received)

#To handle Exit
appuifw.app.exit_key_handler = Quit
app_lock = e32.Ao_lock()
app_lock.wait()

I hope to correct my fault here.

Many thanks in advance.

Hi again Beat_Slayer ,

I tried your code again but it shows me an error :
"SymbianError:[Errno -21]
KErrAccessDenied"

This error in line 18.

By the way ,I'm testing your code by sending an SMS to my self , And I got my number recorded into my contact data base . Do you think this is the reason for the error ??

Looking forward to hear from you.

Hi, you don't need all those imports.

You get the correct number that actually sent you the sms with your code.

About mine code, it runs smoothly here.

import appuifw
import e32
import inbox

def Quit():
    app_lock.signal()

def message_received(msg_id):
	box = inbox.Inbox()
	sms_text = box.content(msg_id)
	sender = box.address(msg_id)

#To handle received messages.	
box = inbox.Inbox()
box.bind(message_received)

#To handle Exit
appuifw.app.exit_key_handler = Quit
app_lock = e32.Ao_lock()
app_lock.wait()

Many thanks for your reply , I tested your code without any modification

And as I said if the number who sending me a message saved in contacts ...

sender returns me his name in my contacts not his number , and I tested to delete this contact from my contacts and then sender returns my the number.

I hope you got the problem here in python function that doesn't give us to choose between the sender name or the sender phone number.

I hope we can figure this out one day.

Many thanks.

How about some crossing between the two scripts. ;)

Cumps.

import appuifw
import e32
import inbox
import logs

def Quit():
    app_lock.signal()

def message_received(msg_id):
	box = inbox.Inbox()
	sms_text = box.content(msg_id)
	sender = box.address(msg_id)
        sender_number = sms_log_in[0]['number']

#To handle received messages.	
box = inbox.Inbox()
box.bind(message_received)

#To catch last number by the logs last received message
sms_log_in = logs.sms(mode='in')

#To handle Exit
appuifw.app.exit_key_handler = Quit
app_lock = e32.Ao_lock()
app_lock.wait()

Hi Beat_Slayer , Good thinking .. I figured it out too based in your first answer

Great Minds Think A Like.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.