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 |
| 22 | msg = None |
| 23 | |
| 24 | def __init__(self, from_msisdn=None, to_msisdn=None, *tokens): |
| 25 | Sms._last_sms_idx += 1 |
| 26 | msgs = ['message nr. %d' % Sms._last_sms_idx] |
| 27 | msgs.extend(tokens) |
| 28 | if from_msisdn: |
| 29 | msgs.append('from %s' % from_msisdn) |
| 30 | if to_msisdn: |
| 31 | msgs.append('to %s' % to_msisdn) |
| 32 | self.msg = ', '.join(msgs) |
| 33 | |
| 34 | def __str__(self): |
| 35 | return self.msg |
| 36 | |
| 37 | def __repr__(self): |
| 38 | return repr(self.msg) |
| 39 | |
| 40 | def __eq__(self, other): |
| 41 | if isinstance(other, Sms): |
| 42 | return self.msg == other.msg |
Neels Hofmeyr | b3b3104 | 2017-05-31 20:38:56 +0200 | [diff] [blame] | 43 | return self.msg == other |
Pau Espin Pedrol | 996651a | 2017-05-30 15:13:29 +0200 | [diff] [blame] | 44 | |
| 45 | def matches(self, msg): |
| 46 | return self.msg == msg |
| 47 | |
| 48 | # vim: expandtab tabstop=4 shiftwidth=4 |