Skip to contentSkip to conversation

Fix mmsd to work with T-mobile

PATCH New [email protected] 1 participant 1 message Feb 19, 2021 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix mmsd to work with T-mobile

This commit is taken from anteater https://sr.ht/~anteater/mms-stack/
and has an additional change to fix a hack that was put in there.

This commit enables mmsd to work on T-mobile USA.

---
 Makefile.am       |   3 +-
 gweb/gresolv.c    |  73 ++++++++++++++-
 gweb/gweb.c       |   1 +
 plugins/ofono.c   |  11 ++-
 src/mmsutil.c     | 233 ++++++++++++++++++++++++++++++++++++++--------
 src/mmsutil.h     |  17 ++++
 src/service.c     |  59 ++++++++++--
 test/send-message |  24 ++---
 8 files changed, 357 insertions(+), 64 deletions(-)
Makefile.am +2 -1
index ee2c715..99fdb76 100644
@@ -88,7 +88,8 @@ unit_test_wsputil_SOURCES = unit/test-wsputil.c src/wsputil.c src/wsputil.h
 unit_test_wsputil_LDADD = @GLIB_LIBS@
 
 unit_test_mmsutil_SOURCES = unit/test-mmsutil.c src/mmsutil.c src/mmsutil.h \
-						src/wsputil.c src/wsputil.h
+						src/wsputil.c src/wsputil.h \
+						src/log.c src/log.h
 unit_test_mmsutil_LDADD = @GLIB_LIBS@
 
 TESTS = unit/test-wsputil unit/test-mmsutil
gweb/gresolv.c +68 -5

132 lines not on this page · raw message

gweb/gweb.c +1 -0
index 4c2f95c..f72e137 100644
@@ -1008,6 +1008,7 @@ static inline int bind_socket(int sk, int index, int family)
 	if (if_indextoname(index, interface) == NULL)
 		return -1;
 
+	printf("binding %s\n", interface);
 	err = setsockopt(sk, SOL_SOCKET, SO_BINDTODEVICE,
 					interface, IF_NAMESIZE);
 	if (err < 0)
plugins/ofono.c +9 -2
index e7324a7..24a147a 100644
@@ -396,11 +396,14 @@ static void check_context_active(struct modem_data *modem,
 		g_free(modem->context_proxy);
 		modem->context_proxy = NULL;
 
+		DBG("context_active = false");
 		mms_service_bearer_notify(modem->service, FALSE, NULL, NULL);
-	} else if (modem->context_proxy != NULL)
+	} else if (modem->context_proxy != NULL) {
+		DBG("nonnull proxy");
 		mms_service_bearer_notify(modem->service, TRUE,
 						modem->context_interface,
 						modem->context_proxy);
+	}
 }
 
 static void check_context_settings(struct modem_data *modem,
@@ -452,6 +455,7 @@ static void check_context_settings(struct modem_data *modem,
 	if (modem->context_active == FALSE)
 		return;
 
+	DBG("about to bearer_notify");
 	mms_service_bearer_notify(modem->service, TRUE,
 					modem->context_interface,
 					modem->context_proxy);
@@ -692,6 +696,7 @@ static void set_context_reply(DBusPendingCall *call, void *user_data)
 	dbus_error_init(&err);
 
 	if (dbus_set_error_from_message(&err, reply) == TRUE) {
+		DBG("set_ctx reply failure (%s: %s), about to bearer_notify", err.name, err.message);
 		dbus_error_free(&err);
 		mms_service_bearer_notify(modem->service, FALSE, NULL, NULL);
 	}
@@ -739,15 +744,17 @@ static void bearer_handler(mms_bool_t active, void *user_data)
 {
 	struct modem_data *modem = user_data;
 
-	DBG("path %s active %d", modem->path, active);
+	DBG("path %s active %d context_active %d", modem->path, active, modem->context_active);
 
 	if (active == TRUE && modem->context_active == TRUE) {
+		DBG("active and context_active, bearer_notify");
 		mms_service_bearer_notify(modem->service, TRUE,
 						modem->context_interface,
 						modem->context_proxy);
 		return;
 	}
 
+	DBG("checking for failure");
 	if (active == FALSE && modem->context_active == FALSE) {
 		mms_service_bearer_notify(modem->service, FALSE, NULL, NULL);
 		return;
src/mmsutil.c +195 -38

359 lines not on this page · raw message

src/mmsutil.h +17 -0
index e32c761..00ecc39 100644
@@ -50,6 +50,23 @@ enum mms_message_rsp_status {
 	MMS_MESSAGE_RSP_STATUS_ERR_PERM_LACK_OF_PREPAID =		235,
 };
 
+enum mms_message_retr_status {
+	MMS_MESSAGE_RETR_STATUS_OK =				128,
+	MMS_MESSAGE_RETR_STATUS_ERR_TRANS_MIN =			192,
+	MMS_MESSAGE_RETR_STATUS_ERR_TRANS_FAILURE =		192,
+	MMS_MESSAGE_RETR_STATUS_ERR_TRANS_MESSAGE_NOT_FOUND =	194,
+	MMS_MESSAGE_RETR_STATUS_ERR_PERM_MIN =			224,
+	MMS_MESSAGE_RETR_STATUS_ERR_PERM_FAILURE =		224,
+	MMS_MESSAGE_RETR_STATUS_ERR_PERM_SERVICE_DENIED =	225,
+	MMS_MESSAGE_RETR_STATUS_ERR_PERM_MESSAGE_NOT_FOUND =	226,
+	MMS_MESSAGE_RETR_STATUS_ERR_PERM_CONTENT_UNSUPPORTED =	227,
+};
+
+enum mms_message_read_status {
+	MMS_MESSAGE_READ_STATUS_READ =			128,
+	MMS_MESSAGE_READ_STATUS_DELETED_UNREAD =	129,
+};
+
 enum mms_message_notify_status {
 	MMS_MESSAGE_NOTIFY_STATUS_RETRIEVED =		129,
 	MMS_MESSAGE_NOTIFY_STATUS_REJECTED =		130,
src/service.c +53 -6

219 lines not on this page · raw message

test/send-message +12 -12
index 558fdaa..8477e79 100755
@@ -5,23 +5,23 @@ import dbus
 import csv
 
 if (len(sys.argv) < 4):
-	print "Usage: %s"\
+	print("Usage: {}"\
 		" <recipient>,..."\
 		" <smil-file-path>"\
 		" <<content-id>,<content-type>,<file-path>>,..."\
-		% (sys.argv[0])
-	print "Sample(Related): %s"\
+		.format(sys.argv[0]))
+	print("Sample(Related): {}"\
 		" \"+33611111111,+33622222222\""\
 		" \"smil.txt\""\
 		" \"cid-1,text/plain,text.txt\""\
 		" \"cid-2,image/jpeg,image.jpg\""\
-		% (sys.argv[0])
-	print "Sample(Mixed): %s"\
+		.format(sys.argv[0]))
+	print("Sample(Mixed): {}"\
 		" \"+33611111111,+33622222222\""\
 		" \"\""\
 		" \"cid-1,text/plain,text.txt\""\
 		" \"cid-2,image/jpeg,image.jpg\""\
-		% (sys.argv[0])
+		.format(sys.argv[0]))
 	sys.exit(1)
 
 bus = dbus.SessionBus()
@@ -38,23 +38,23 @@ service = dbus.Interface(bus.get_object('org.ofono.mms', path),
 recipients = dbus.Array([],signature=dbus.Signature('s'))
 reader = csv.reader([sys.argv[1]])
 for r in reader:
-	print "Recipient list: %s" % r
+	print("Recipient list: {}".format(r))
 	for i in r:
 		recipients.append(dbus.String(i))
 
 
 if sys.argv[2] == "":
-	print "Send MMS as Mixed"
+	print("Send MMS as Mixed")
 	smil = ""
 else:
-	print "Send MMS as Related"
-	print "Smil path: %s" % (sys.argv[2])
+	print("Send MMS as Related")
+	print("Smil path: {}".format(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
+	print("Attachment: ({})".format(a))
 	reader = csv.reader([a])
 	for r in reader:
 		attachments.append(dbus.Struct((dbus.String(r[0]),
@@ -64,4 +64,4 @@ for a in sys.argv[3:]:
 
 path = service.SendMessage(recipients, smil, attachments)
 
-print path
+print(path)
Signature · 1 line
2.20.1