![]() |
2010-12-16
, 17:57
|
Posts: 187 |
Thanked: 41 times |
Joined on May 2010
|
#2
|
def del_sms(id): OSSO_CTX = osso.Context("some_context_here", "0.1") OSSO_EL = ctypes.CDLL('librtcom-eventlogger.so.1') OSSO_OBJ = OSSO_EL.rtcom_el_new() OSSO_EL.rtcom_el_delete_event(OSSO_OBJ,int(id),None)
![]() |
2010-12-17
, 17:31
|
|
Posts: 249 |
Thanked: 345 times |
Joined on Aug 2010
@ Italy
|
#3
|
i'd like to know how to insert an event in the database via python ...
![]() |
2010-12-18
, 01:15
|
Posts: 187 |
Thanked: 41 times |
Joined on May 2010
|
#4
|
Doesn't work
The script does not give me an error, but the event is not deleted and i must stop the execution with "Ctrl+Z"
Please, have you any idea how to resolve?
Via sqlite3 or via rtcom?
try to look at this script
http://www.frals.se/maemo/rtcom.py
![]() |
2010-12-18
, 04:28
|
Posts: 187 |
Thanked: 41 times |
Joined on May 2010
|
#5
|
gboolean rtcom_el_delete_by_group_uids ( RTComEl * el, const gchar ** group_uids )
![]() |
2010-12-19
, 07:35
|
Posts: 187 |
Thanked: 41 times |
Joined on May 2010
|
#7
|
![]() |
2010-12-26
, 18:36
|
Posts: 9 |
Thanked: 0 times |
Joined on Dec 2010
|
#8
|
i really dont know what the problem is...
i use that same piece of code in a very complex program listening dbus events and handling the call backs ... maybe it only works in a dbus loop ... no idea though...
i was able to send the gchar ** using pointer(pointer(char)) from ctypes...
now i am finally able to force send the damn refreshhint signal...
sorry for my poor English.
I made a script in python and sqlite3 to delete SMS from certain phone numbers.
The script works fine, but sometimes I found mismatch between rtcom-messaging-ui and the database rt-com-eventolgger.
I would then use the rtcom_el_delete_event, but I can not understand how to use it. I'm trying to use some examples, but always i get "segmentation error fault".
Could someone help me? Thanks.
Script python/sqlite3:
import sqlite3
import array
elimina = []
# limite = numero sms da mantenere
# limite = max number of SMS
limite = 2
# elimina = numeri da cui provengono gli sms - non inserire i nomi presenti in agenda, ma i numeri/nomi reali
# elimina = phone number to delete
elimina = "Ovi Store", "+39...."
conn=sqlite3.connect("/home/user/.rtcom-eventlogger/el-v1.db")
cur = conn.cursor()
if limite < 0: limite = 0
for item in elimina:
# print item
# trova numero di record totali
cur.execute("select count(remote_uid) from events where service_id = 3 and remote_uid = ?",([item]))
righe_t = cur.fetchone()
righe_totali = righe_t[0]
cancella = righe_totali - limite
while cancella > 0:
cur.execute("select id from events where service_id = 3 and remote_uid = ?", [item])
id_sms = cur.fetchone()
riga = id_sms
#print "riga", riga
cur.execute("select * from events where id = ?", (riga))
record_da_cancellare = cur.fetchall()
# cancellazione record
cur.execute("select group_uid from events where service_id = 3 and remote_uid = ?", [item])
gruppo = cur.fetchone()
cur.execute("select total_events from groupcache where group_uid = ?", (gruppo))
totali = cur.fetchone()
cur.execute("delete from events where id = ?", (riga))
if limite == 0 : cur.execute("update groupcache set total_events = 0, read_events = 0 where group_uid = ?", gruppo)
#if limite == 0 : cur.execute("delete from groupcache where group_uid = ?", gruppo)
cancella = cancella - 1
conn.commit();
cur.close();
import sqlite3
import array
import ctypes
elimina = []
# limite = numero sms da mantenere
# limite = max number of SMS
limite = 2
# elimina = numeri da cui provengono gli sms - non inserire i nomi presenti in agenda, ma i numeri/nomi reali
# elimina = phone number to delete
elimina = "Ovi Store", "+39...."
# added for deleting messaging via rtcom
class RTComElEvent(ctypes.Structure):
_fields_ = [("_mask", ctypes.c_int),
("event_id", ctypes.c_int)]
def del_sms(id_):
rtcom = ctypes.CDLL('librtcom-eventlogger.so.1.1.0') # PR 1.3 ?
#rtcom = ctypes.CDLL('librtcom-eventlogger.so.1') # PR 1.2
#rtcom = ctypes.CDLL('librtcom-eventlogger.so.0') # PR 1.1
el = ctypes.cast(rtcom.rtcom_el_delete_event (), ctypes.c_void_p)
event = ctypes.cast(rtcom.rtcom_el_delete_event (), ctypes.POINTER(RTComElEvent))[0]
event._mask |= 1 << 6
event.fld_ = id_
rtcom.rtcom_el_event_free(ctypes.byref(event))
rtcom.rtcom_el_event_free_content(ctypes.byref(event)) # aggiunta io
conn=sqlite3.connect("/home/user/.rtcom-eventlogger/el-v1.db")
cur = conn.cursor()
if limite < 0: limite = 0
for item in elimina:
print item
# trova numero di record totali
cur.execute("select count(remote_uid) from events where service_id = 3 and remote_uid = ?",([item]))
righe_t = cur.fetchone()
righe_totali = righe_t[0]
cancella = righe_totali - limite
while cancella > 0:
cur.execute("select id from events where service_id = 3 and remote_uid = ?", [item])
id_sms = cur.fetchone()
print "id_sms ", id_sms[0]
riga = id_sms
print "riga", riga
cur.execute("select * from events where id = ?", (riga))
record_da_cancellare = cur.fetchall()
# cancellazione record
cur.execute("select group_uid from events where service_id = 3 and remote_uid = ?", [item])
gruppo = cur.fetchone()
cur.execute("select total_events from groupcache where group_uid = ?", (gruppo))
totali = cur.fetchone()
cancella = cancella - 1
# added for deleting messaging via rtcom
del_sms(id_sms)
conn.commit();
cur.close();
Last edited by m750; 2010-11-04 at 18:08.