blob: e264b66e1179920f336feeb7e608a82eb2711de2 [file] [log] [blame]
Pau Espin Pedrol996651a2017-05-30 15:13:29 +02001# osmo_gsm_tester: DBUS client to talk to ofono
2#
3# Copyright (C) 2016-2017 by sysmocom - s.f.m.c. GmbH
4#
5# Author: Neels Hofmeyr <neels@hofmeyr.de>
6#
7# This program is free software: you can redistribute it and/or modify
Harald Welte27205342017-06-03 09:51:45 +02008# it under the terms of the GNU General Public License as
Pau Espin Pedrol996651a2017-05-30 15:13:29 +02009# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Harald Welte27205342017-06-03 09:51:45 +020015# GNU General Public License for more details.
Pau Espin Pedrol996651a2017-05-30 15:13:29 +020016#
Harald Welte27205342017-06-03 09:51:45 +020017# You should have received a copy of the GNU General Public License
Pau Espin Pedrol996651a2017-05-30 15:13:29 +020018# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20class Sms:
21 _last_sms_idx = 0
22 msg = None
23
Pau Espin Pedrol2d16f6f2017-05-30 15:33:57 +020024 def __init__(self, src_msisdn=None, dst_msisdn=None, *tokens):
Pau Espin Pedrol996651a2017-05-30 15:13:29 +020025 Sms._last_sms_idx += 1
Pau Espin Pedrol2d16f6f2017-05-30 15:33:57 +020026 self._src_msisdn = src_msisdn
27 self._dst_msisdn = dst_msisdn
Pau Espin Pedrol996651a2017-05-30 15:13:29 +020028 msgs = ['message nr. %d' % Sms._last_sms_idx]
29 msgs.extend(tokens)
Pau Espin Pedrol2d16f6f2017-05-30 15:33:57 +020030 if src_msisdn:
31 msgs.append('from %s' % src_msisdn)
32 if dst_msisdn:
33 msgs.append('to %s' % dst_msisdn)
Pau Espin Pedrol996651a2017-05-30 15:13:29 +020034 self.msg = ', '.join(msgs)
35
36 def __str__(self):
37 return self.msg
38
39 def __repr__(self):
40 return repr(self.msg)
41
42 def __eq__(self, other):
43 if isinstance(other, Sms):
44 return self.msg == other.msg
Neels Hofmeyrb3b31042017-05-31 20:38:56 +020045 return self.msg == other
Pau Espin Pedrol996651a2017-05-30 15:13:29 +020046
Pau Espin Pedrol2d16f6f2017-05-30 15:33:57 +020047 def src_msisdn(self):
48 return self._src_msisdn
49
50 def dst_msisdn(self):
51 return self._dst_msisdn
52
Pau Espin Pedrol996651a2017-05-30 15:13:29 +020053 def matches(self, msg):
54 return self.msg == msg
55
56# vim: expandtab tabstop=4 shiftwidth=4