blob: 01185170c63bc436cf5c66fe3347a4222ae3f07d [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
Pau Espin Pedrol996651a2017-05-30 15:13:29 +020022
Pau Espin Pedrol2d16f6f2017-05-30 15:33:57 +020023 def __init__(self, src_msisdn=None, dst_msisdn=None, *tokens):
Pau Espin Pedrol996651a2017-05-30 15:13:29 +020024 Sms._last_sms_idx += 1
Pau Espin Pedrol2d16f6f2017-05-30 15:33:57 +020025 self._src_msisdn = src_msisdn
26 self._dst_msisdn = dst_msisdn
Pau Espin Pedrol996651a2017-05-30 15:13:29 +020027 msgs = ['message nr. %d' % Sms._last_sms_idx]
28 msgs.extend(tokens)
Pau Espin Pedrol2d16f6f2017-05-30 15:33:57 +020029 if src_msisdn:
30 msgs.append('from %s' % src_msisdn)
31 if dst_msisdn:
32 msgs.append('to %s' % dst_msisdn)
Pau Espin Pedrol996651a2017-05-30 15:13:29 +020033 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 Hofmeyrb3b31042017-05-31 20:38:56 +020044 return self.msg == other
Pau Espin Pedrol996651a2017-05-30 15:13:29 +020045
Pau Espin Pedrol2d16f6f2017-05-30 15:33:57 +020046 def src_msisdn(self):
47 return self._src_msisdn
48
49 def dst_msisdn(self):
50 return self._dst_msisdn
51
Pau Espin Pedrol996651a2017-05-30 15:13:29 +020052 def matches(self, msg):
53 return self.msg == msg
54
55# vim: expandtab tabstop=4 shiftwidth=4