send-message 1.6 KB
Newer Older
1
2
3
4
5
6
7
#!/usr/bin/python

import sys
import dbus
import csv

if (len(sys.argv) < 4):
8
	print("Usage: {}"\
9
10
11
		" <recipient>,..."\
		" <smil-file-path>"\
		" <<content-id>,<content-type>,<file-path>>,..."\
12
13
		.format(sys.argv[0]))
	print("Sample(Related): {}"\
14
15
16
17
		" \"+33611111111,+33622222222\""\
		" \"smil.txt\""\
		" \"cid-1,text/plain,text.txt\""\
		" \"cid-2,image/jpeg,image.jpg\""\
18
19
		.format(sys.argv[0]))
	print("Sample(Mixed): {}"\
20
21
22
23
		" \"+33611111111,+33622222222\""\
		" \"\""\
		" \"cid-1,text/plain,text.txt\""\
		" \"cid-2,image/jpeg,image.jpg\""\
24
		.format(sys.argv[0]))
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
	sys.exit(1)

bus = dbus.SessionBus()

manager = dbus.Interface(bus.get_object('org.ofono.mms', '/org/ofono/mms'),
					'org.ofono.mms.Manager')

services = manager.GetServices()
path = services[0][0]

service = dbus.Interface(bus.get_object('org.ofono.mms', path),
						'org.ofono.mms.Service')

recipients = dbus.Array([],signature=dbus.Signature('s'))
reader = csv.reader([sys.argv[1]])
for r in reader:
41
	print("Recipient list: {}".format(r))
42
43
44
	for i in r:
		recipients.append(dbus.String(i))

45
46

if sys.argv[2] == "":
47
	print("Send MMS as Mixed")
48
49
	smil = ""
else:
50
51
	print("Send MMS as Related")
	print("Smil path: {}".format(sys.argv[2]))
52
53
	file = open(sys.argv[2],"r")
	smil = dbus.String(file.read())
54
55
56

attachments = dbus.Array([],signature=dbus.Signature('(sss)'))
for a in sys.argv[3:]:
57
	print("Attachment: ({})".format(a))
58
59
60
61
62
63
64
65
66
	reader = csv.reader([a])
	for r in reader:
		attachments.append(dbus.Struct((dbus.String(r[0]),
						dbus.String(r[1]),
						dbus.String(r[2])
						), signature=None))

path = service.SendMessage(recipients, smil, attachments)

67
print(path)