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 :)


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

vBulletin® Version 3.8.8