maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Maemo 5 / Fremantle (https://talk.maemo.org/forumdisplay.php?f=40)
-   -   Modify (mangle) incoming SMS messages? (https://talk.maemo.org/showthread.php?t=67376)

stas123 2010-12-24 01:25

Modify (mangle) incoming SMS messages?
 
HI everyone,

Mobilicity is my provider, and it doesn't support incoming Unicode messages yet. Instead, it displays each unicode character as a pair of characters from GSM 03.38.

I want to write a bit of code to detect this and to display these messages as proper unicode on my phone.

How do I intercept incoming SMS messages and modify their content?

Captwheeto 2010-12-24 11:12

Re: Modify (mangle) incoming SMS messages?
 
Look into working with the dbus? I wish I knew too, I'd like to grep and less my messages but I don't think they're stored plaintext anywhere.

I don't actually know much about this but hope someone else can help

zimon 2010-12-24 11:35

Re: Modify (mangle) incoming SMS messages?
 
look how SMScon does it

droll 2011-12-30 11:57

Re: Modify (mangle) incoming SMS messages?
 
does SMScon modify the messages and reinsert them into the inbox? i'm looking for a solution to this. reason the operator i'm on sends missed call smses with the phone number of the person who called. problem is, it doesn't do a lookup against my phone book so i have no idea who's calling until i tap on the number.

i'm trying to write a bit of code to watch for incoming smses, grab the body of the sms, then check a few things like FROM and body of the text to figure out if it's in the right format before doing a phone book lookup and injecting the contact's name into the sms.

vi_ 2011-12-30 12:07

Re: Modify (mangle) incoming SMS messages?
 
Listen on dbus for incoming txt message. Then read txt from inbox sqlite db, make changes then write it back to sql db.

droll 2012-04-06 10:01

Re: Modify (mangle) incoming SMS messages?
 
finally got around to writing the code in python. the aboe suggestion doesn't work. my dbus handler is called first before the sms is inserted into the sqlite db. i have to use time.sleep() to poll the db...not a good approach. any ideas anyone??

race condition problem. sigh.

nicolai 2012-04-06 12:21

Re: Modify (mangle) incoming SMS messages?
 
Hi droll,

here is a small python example that uses the "NewEvent" signal
from rtcom-eventlogger. This example reads incoming messages
from the db and changes the messagetext to uppercase.
BUT, the conversion app is listening on the "NewEvent"
signal too, and it reads the message before you can change it.
So you have to close and reopen the conversation app, to
see the new updated text.

Code:

import dbus, gobject
import sqlite3 as db
from dbus.mainloop.glib import DBusGMainLoop

con = None
def new_msg_func(id, local_uid, remote_uid, remote_ebook_uid, group_uid, service):
  #handle only chat/sms events
  if service != "RTCOM_EL_SERVICE_SMS" and service!="RTCOM_EL_SERVICE_CHAT":
    return
 
  cur = con.cursor()
  # select free_text (message body) and outgoing/incoming flag
  cur.execute("select free_text,outgoing from events where id = ?", (id,));
  data = cur.fetchone()

  #incoming (0) or outgoing (1) message?
  if data[1] == 0:
    # update message
    cur.execute("update events set free_text = ? where id = ?", (data[0].upper(), id))
 

dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
bus.add_signal_receiver(new_msg_func, dbus_interface="rtcomeventlogger.signal", signal_name="NewEvent")
con = db.connect('/home/user/.rtcom-eventlogger/el-v1.db', isolation_level=None)
loop = gobject.MainLoop()
loop.run()


droll 2012-04-07 10:39

Re: Modify (mangle) incoming SMS messages?
 
thanx nicolai! got your code patches into mine in 3 minutes and it works like a charm! danke danke :)

as for the conversation app issue, it is a small annoyance for the app i am writing. i have a theory on how to force it to refresh but since i'm new to python, it'll take me a while to hack something up.

nevertheless, thanks again!

droll 2012-04-07 17:10

Re: Modify (mangle) incoming SMS messages?
 
it's actually a small pet project that i did with a carry over history from the windows mobile 6 days. the script is mostly done and works quite well. but since you are on harmattan, i doubt it would work for you. sorry.

Estel 2012-04-07 18:10

Re: Modify (mangle) incoming SMS messages?
 
Quote:

Originally Posted by Sorrow (Post 1189235)
[s]droll
Im' eager to see your app for putting Contact name into "missed call" sms. Wanted! :)

This would be nice feature to have, and I'm *very* glad that we might have this for Maemo :)

droll 2012-04-08 14:39

Re: Modify (mangle) incoming SMS messages?
 
i face a different issue now. i hv managed to find a way for the conversation app to update itself. however. i hv issues with the yellow notification bubble.
first, it shows the old contentof the sms. i can live with that. but when i tap on it, it opens up a conversation view for the new sms and it shows the old content as well even though the sqlite db has been updated and the conversation ui too has been updated to show the new contents of the sms.

some kinda caching going on??

droll 2012-04-08 15:57

Re: Modify (mangle) incoming SMS messages?
 
which component / class handles all this?

is there a way i can force the conversation / thread view for the sms to be updated?? it seems disconnected from the main conversation view (the one that shows the list of smses).

droll 2012-04-09 03:05

Re: Modify (mangle) incoming SMS messages?
 
1 Attachment(s)
i checked dbus and saw the RefreshHint signal being issued when i do some stuff in the conversations app to change the underlying messages. manually issuing this signal with dbus-send does nothing. sigh.

guess this will have to be a limitation that i have to live with. :(

to anyone interested in this little script, i've attached it in this message. btw, i don't take credit for a lot of the code inside. i'm new to python so i just went around piecing bits and pieces of other people's work. :)

installation is simple enough. drop to x-term and run it in the background like so "python NameLookup.py &"

it currently watches for incoming smses from "Maxis" and "Voicemail". that's the way it works for the telcos where i live anyway. i could change it to be more generic and watch for any sms messages that has phone numbers in the body and do a name lookup if people are interested.

thanks.

droll 2012-04-10 07:58

Re: Modify (mangle) incoming SMS messages?
 
1 Attachment(s)
fixed some stoopid bugs in the script during text parng. here is the updated version.
i've also changed the behaviour so that any incoming smses with phone numbers in them gets the name lookup treatment. probably more useful to everyone.

hv a nice day :)

ajack 2012-04-17 00:53

Re: Modify (mangle) incoming SMS messages?
 
Works on DiGi (MY)... ^_^

droll 2012-04-17 01:26

Re: Modify (mangle) incoming SMS messages?
 
thank you. oi, reply to the draw something request la.... :P


All times are GMT. The time now is 05:46.

vBulletin® Version 3.8.8