This file is indexed.

/usr/share/pyshared/Wammu/Reader.py is in wammu 0.36-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# -*- coding: UTF-8 -*-
# vim: expandtab sw=4 ts=4 sts=4:
'''
Wammu - Phone manager
Generic reader class
'''
__author__ = 'Michal Čihař'
__email__ = 'michal@cihar.com'
__license__ = '''
Copyright © 2003 - 2010 Michal Čihař

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License version 2 as published by
the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
'''

import Wammu.Thread
import Wammu
if Wammu.gammu_error == None:
    import gammu

class Reader(Wammu.Thread.Thread):
    '''
    Generic thread for reading information from phone.
    '''
    def FallBackStatus(self):
        '''
        Returns fall back status if real can not be obtained.
        '''
        return 200

    def GetNextStart(self):
        '''
        Initiates get next sequence.

        Should be implemented in subclases.
        '''
        raise Exception('Not implemented!')

    def GetNext(self, location):
        '''
        Gets next entry.

        Should be implemented in subclases.
        '''
        raise Exception('Not implemented!')

    def Get(self, location):
        '''
        Gets entry.

        Should be implemented in subclases.
        '''
        raise Exception('Not implemented!')

    def GetStatus(self):
        '''
        Gets status of entries.

        Should be implemented in subclases.
        '''
        raise Exception('Not implemented!')

    def Parse(self):
        '''
        Parses entry.

        Should be implemented in subclases.
        '''
        raise Exception('Not implemented!')

    def Send(self):
        '''
        Sends entries to parent.

        Should be implemented in subclases.
        '''
        raise Exception('Not implemented!')

    def Run(self):
        '''
        Main reader function, executed in thread.
        '''
        self.ShowProgress(0)

        guess = False
        try:
            total = self.GetStatus()
        except gammu.GSMError, val:
            guess = True
            total = self.FallBackStatus()

        remain = total

        data = []

        try:
            start = True
            while remain > 0:
                self.ShowProgress(100 * (total - remain) / total)
                if self.canceled:
                    self.Canceled()
                    return
                try:
                    if start:
                        loc = 0
                        value = self.GetNextStart()
                        if guess and remain == 1:
                            # Read more things if there are some
                            remain = 2
                        start = False
                    else:
                        value = self.GetNext(loc)
                    try:
                        loc = value['Location']
                    except TypeError:
                        loc = value[0]['Location']
                    self.Parse(value)
                    if type(value) == list:
                        for i in range(len(value)):
                            value[i]['Synced'] = True
                    else:
                        value['Synced'] = True
                    data.append(value)
                except gammu.ERR_UNKNOWN:
                    self.ShowMessage(
                            _('Ignoring unknown'),
                            _('While reading, entry on location %d reported unknown error, ignoring it!') % loc)
                    loc = loc + 1
                except gammu.ERR_CORRUPTED:
                    self.ShowMessage(
                            _('Ignoring corrupted'),
                            _('While reading, entry on location %d seems to be corrupted, ignoring it!') % loc)
                    loc = loc + 1
                except gammu.ERR_EMPTY:
                    break

                remain = remain - 1
        except (gammu.ERR_NOTSUPPORTED, gammu.ERR_NOTIMPLEMENTED):
            location = 1
            empty = 0
            while remain > 0:
                self.ShowProgress(100 * (total - remain) / total)
                if self.canceled:
                    self.Canceled()
                    return
                try:
                    value = self.Get(location)
                    self.Parse(value)
                    if type(value) == list:
                        for i in range(len(value)):
                            value[i]['Synced'] = True
                    else:
                        value['Synced'] = True
                    data.append(value)
                    remain = remain - 1
                    # If we didn't know count and reached end, try some more entries
                    if remain == 0 and guess:
                        remain = 20
                        total = total + 20
                    empty = 0
                except gammu.ERR_EMPTY, val:
                    empty = empty + 1
                    # If we didn't know count and saw many empty entries, stop right now
                    if empty >= Wammu.configuration.ReadInt('/Hacks/MaxEmptyGuess') and guess:
                        break
                    # If we didn't read anything for long time, we bail out (workaround bad count reported by phone)
                    if empty >= Wammu.configuration.ReadInt('/Hacks/MaxEmptyKnown') and remain < 10:
                        self.ShowError(val[0])
                        remain = 0
                except gammu.ERR_CORRUPTED:
                    self.ShowMessage(
                            _('Ignoring corrupted'),
                            _('While reading, entry on location %d seems to be corrupted, ignoring it!') % location)
                    remain = remain - 1
                except gammu.ERR_UNKNOWN:
                    self.ShowMessage(
                            _('Ignoring unknown'),
                            _('While reading, entry on location %d reported unknown error, ignoring it!') % location)
                    remain = remain - 1
                except gammu.GSMError, val:
                    self.ShowError(val[0], True)
                    return
                location = location + 1
        except gammu.ERR_INVALIDLOCATION, val:
            # if we reached end with guess, it is okay
            if not guess:
                self.ShowError(val[0], True)
                return
        except gammu.GSMError, val:
            self.ShowError(val[0], True)
            return

        self.Send(data)