Alright, so, I got it.
I'm going put some notes here to help others should they need it. telepathy-ofono is a middle man for the ubuntu message app. I'm not using that here, my goal is to build something for the PinePhone no matter what OS they choose. With that, I'm talking directly to ofono.
Here is the dbus call you need to replicate. This is a group MMS message sent with text.
method call time=1580999265.497178 sender=:1.19 -> destination=org.ofono.mms serial=407 path=/org/ofono/mms/302220546062670; interface=org.ofono.mms.Service; member=SendMessage
array [
string "613xxxyyyy"
string "613xxxzzzz"
]
array [
struct {
string "text_0.txt"
string "text/plain"
string "/home/phablet/.local/share/telepathy-ofono/attachments/attachmentLh3156"
}
struct {
string "smil.xml"
string "application/smil"
string "/home/phablet/.local/share/telepathy-ofono/attachments/attachmentnS3156"
}
]
the path (/home/phablet/.local/share/telepathy-ofono/attachments/) does not matter. The directory above is from telepathy-ofono so you can put it anywhere.
The plaintext file (attachmentLh3156) is just that, the text of the message you want to send.
MMS message testing
The smil.xml (attachmentnS3156) will change depending on the amount of attachments (not recipents). If you're just sending text, like above your smil file will look like
<smil> <head> <layout> <region id="Text" width="100%" height="100%" fit="scroll" /> </layout> </head> <body> <par dur="3s"> <text src="text_0.txt" region="Text" /> </par> </body> </smil>
As an example, if you want to send a picture in this group chat you'd have to change the smil file to:
<smil> <head> <layout> <region id="Image" width="100%" height="100%" fit="meet" /> </layout> </head> <body> <par dur="5000ms"> <img src="pic.jpg" region="Image" /> </par> </body> </smil>
and of course you'd need to attach a picture. Pictures are limited in their size for me, I can only send pictures under 300KB. This is just the jpg file you're sending you dont have to do anything fancy.
The code I used is VERY lazily modified from the python script I posted in my question. There are errors and some of the code isn't use. my only goal was to test it, not make it look pretty I'm going to spend my weekend translating this to C and cleaning it up.
phablet@ubuntu-phablet:~$ cat ./sendmms.py
#!/home/phablet/.cache/libertine-container/learning/rootfs/usr/bin/python
import sys
import dbus
import csv
if (len(sys.argv) < 4):
print "Usage: %s"\
" <recipient>,..."\
" <smil-file-path>"\
" <<content-id>,<content-type>,<file-path>>,..."\
% (sys.argv[0])
print "Sample(Related): %s"\
" \"+33611111111,+33622222222\""\
" \"smil.txt\""\
" \"cid-1,text/plain,text.txt\""\
" \"cid-2,image/jpeg,image.jpg\""\
% (sys.argv[0])
print "Sample(Mixed): %s"\
" \"+33611111111,+33622222222\""\
" \"\""\
" \"cid-1,text/plain,text.txt\""\
" \"cid-2,image/jpeg,image.jpg\""\
% (sys.argv[0])
sys.exit(1)
bus = dbus.SessionBus()
manager = dbus.Interface(bus.get_object('org.ofono.mms', '/org/ofono/mms'),
'org.ofono.mms.Manager')
print bus
print manager
#services = manager.GetServices()
services = "org.ofono.mms.Service"
#path = services[0][0]
path = "/org/ofono/mms/302220546062670"
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:
print "Recipient list: %s" % r
for i in r:
recipients.append(dbus.String(i))
if sys.argv[2] == "":
print "Send MMS as Mixed"
smil = ""
else:
print "Send MMS as Related"
print "Smil path: %s" % (sys.argv[2])
file = open(sys.argv[2],"r")
smil = dbus.String(file.read())
attachments = dbus.Array([],signature=dbus.Signature('(sss)'))
for a in sys.argv[3:]:
print "Attachment: (%s)" % a
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))
print "hello"
path = service.SendMessage(recipients, attachments)
print "hello2"
print path
phablet@ubuntu-phablet:~$
and finally the command I used to send it:
phablet@ubuntu-phablet:~$ ./sendmms.py "613xxxyyyy,613xxxzzz" "" "smil.xml,application/smil,/pic.smil" "pic.jpg,image/jpeg,/pic.jpg"
<dbus._dbus.SessionBus (session) at 0xb66ba090>
<Interface <ProxyObject wrapping <dbus._dbus.SessionBus (session) at 0xb66ba090> :1.4 /org/ofono/mms at 0xb66b4410> implementing 'org.ofono.mms.Manager' at 0xb66bc6b0>
Recipient list: ['613xxxyyyy', '613xxxzzz']
Send MMS as Mixed
Attachment: (smil.xml,application/smil,/pic.smil)
Attachment: (pic.jpg,image/jpeg,/pic.jpg)
hello
ERROR:dbus.proxies:Introspect error on :1.4:/org/ofono/mms/302220546062670: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
hello2
/org/ofono/mms/302220546062670/3c49e41edd7b06b4d51eaf3b28d1fd3b
phablet@ubuntu-phablet:~$
EDIT:
here is the smil for a picture and some text in an MMS. the filenames inside the smil dont matter.
<smil> <head> <layout> <region id="Image" width="100%" height="100%" fit="meet" /><region id="Text" width="100%" height="100%" fit="scroll" /> </layout> </head> <body> <par dur="5000ms"> <img src="5129919622724107199.jpg" region="Image" /> </par><par dur="3s"> <text src="text_0.txt" region="Text" /> </par> </body> </smil>
Edit2: very rough C code from someone whos just learning.... Back to building my app! thanks everyone!
#include <stdio.h>
#include <stdlib.h>
#include <gio/gio.h>
#include <string.h>
static gchar *object_name = "org.ofono.mms";
static gchar *object_path = "/org/ofono/mms/302220546062670";
static gchar *object_interface = "org.ofono.mms.Service";
int main( ) {
GOptionContext *opt_context;
opt_context = g_option_context_new ("Web-Messages-send_mms");
GError *error;
GDBusProxy *proxy;
proxy = NULL;
error = NULL;
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
NULL, /* GDBusInterfaceInfo */
object_name,
object_path,
object_interface,
NULL, /* GCancellable */
&error);
GVariant *variant;
GVariantBuilder *builder;
builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
g_variant_builder_add(builder, "s", "613xxxyyyy");
g_variant_builder_add(builder, "s", "613xxxzzzz");
variant = g_variant_new("as", builder);
g_variant_builder_unref(builder);
GVariant *value1;
GVariant *value2;
value1 = g_variant_new ("(sss)", "smil.xml", "application/smil", "/text.smil");
value2 = g_variant_new ("(sss)", "text_0.txt", "text/plain", "/text_0.txt");
GVariant *variant2;
GVariantBuilder *builder2;
builder2 = g_variant_builder_new(G_VARIANT_TYPE("a*"));
g_variant_builder_add(builder2, "*", value1);
g_variant_builder_add(builder2, "*", value2);
variant2 = g_variant_new("a*", builder2);
g_variant_builder_unref(builder2);
GVariant *package;
package = g_variant_new ("(**)", variant, variant2);
gchar *parameters_str;
parameters_str = g_variant_print (package, TRUE);
g_print ("parameters_str: \"%s\" \n", parameters_str);
g_free (parameters_str);
if (proxy == NULL) {
g_printerr ("Error creating proxy: %s\n", error->message);
g_error_free (error);
}
else {
g_dbus_proxy_call_sync (proxy,
"SendMessage",
package,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error);
}
if (proxy != NULL)
g_object_unref (proxy);
g_option_context_free (opt_context);
return 0;
}
Edit again:
For people here from google, I decided to go with Python. My script to bridge to matrix is here. There is a send SMS and a send MMS function that should be helpful.