Pau Espin Pedrol | 996651a | 2017-05-30 15:13:29 +0200 | [diff] [blame] | 1 | # 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 Welte | 2720534 | 2017-06-03 09:51:45 +0200 | [diff] [blame] | 8 | # it under the terms of the GNU General Public License as |
Pau Espin Pedrol | 996651a | 2017-05-30 15:13:29 +0200 | [diff] [blame] | 9 | # 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 Welte | 2720534 | 2017-06-03 09:51:45 +0200 | [diff] [blame] | 15 | # GNU General Public License for more details. |
Pau Espin Pedrol | 996651a | 2017-05-30 15:13:29 +0200 | [diff] [blame] | 16 | # |
Harald Welte | 2720534 | 2017-06-03 09:51:45 +0200 | [diff] [blame] | 17 | # You should have received a copy of the GNU General Public License |
Pau Espin Pedrol | 996651a | 2017-05-30 15:13:29 +0200 | [diff] [blame] | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | |
| 20 | class Sms: |
| 21 | _last_sms_idx = 0 |
Pau Espin Pedrol | 996651a | 2017-05-30 15:13:29 +0200 | [diff] [blame] | 22 | |
Pau Espin Pedrol | 2d16f6f | 2017-05-30 15:33:57 +0200 | [diff] [blame] | 23 | def __init__(self, src_msisdn=None, dst_msisdn=None, *tokens): |
Pau Espin Pedrol | 996651a | 2017-05-30 15:13:29 +0200 | [diff] [blame] | 24 | Sms._last_sms_idx += 1 |
Pau Espin Pedrol | 2d16f6f | 2017-05-30 15:33:57 +0200 | [diff] [blame] | 25 | self._src_msisdn = src_msisdn |
| 26 | self._dst_msisdn = dst_msisdn |
Pau Espin Pedrol | 996651a | 2017-05-30 15:13:29 +0200 | [diff] [blame] | 27 | msgs = ['message nr. %d' % Sms._last_sms_idx] |
| 28 | msgs.extend(tokens) |
Pau Espin Pedrol | 2d16f6f | 2017-05-30 15:33:57 +0200 | [diff] [blame] | 29 | if src_msisdn: |
| 30 | msgs.append('from %s' % src_msisdn) |
| 31 | if dst_msisdn: |
| 32 | msgs.append('to %s' % dst_msisdn) |
Pau Espin Pedrol | 996651a | 2017-05-30 15:13:29 +0200 | [diff] [blame] | 33 | self.msg = ', '.join(msgs) |
| 34 | |
| 35 | def __str__(self): |
| 36 | return self.msg |
| 37 | |
| 38 | def __repr__(self): |
| 39 | return repr(self.msg) |
| 40 | |
| 41 | def __eq__(self, other): |
| 42 | if isinstance(other, Sms): |
| 43 | return self.msg == other.msg |
Neels Hofmeyr | b3b3104 | 2017-05-31 20:38:56 +0200 | [diff] [blame] | 44 | return self.msg == other |
Pau Espin Pedrol | 996651a | 2017-05-30 15:13:29 +0200 | [diff] [blame] | 45 | |
Pau Espin Pedrol | 2d16f6f | 2017-05-30 15:33:57 +0200 | [diff] [blame] | 46 | def src_msisdn(self): |
| 47 | return self._src_msisdn |
| 48 | |
| 49 | def dst_msisdn(self): |
| 50 | return self._dst_msisdn |
| 51 | |
Pau Espin Pedrol | 996651a | 2017-05-30 15:13:29 +0200 | [diff] [blame] | 52 | def matches(self, msg): |
| 53 | return self.msg == msg |
| 54 | |
| 55 | # vim: expandtab tabstop=4 shiftwidth=4 |