This file is indexed.

/usr/share/pyshared/weboob/applications/qhavedate/events.py is in weboob-qt 0.g-1.

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
# -*- coding: utf-8 -*-

# Copyright(C) 2010-2011 Romain Bignon
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.

from PyQt4.QtGui import QWidget, QTreeWidgetItem, QImage, QIcon, QPixmap
from PyQt4.QtCore import SIGNAL, Qt

from weboob.capabilities.base import NotLoaded
from weboob.tools.application.qt import QtDo, HTMLDelegate

from .ui.events_ui import Ui_Events


class EventsWidget(QWidget):
    def __init__(self, weboob, parent=None):
        QWidget.__init__(self, parent)
        self.ui = Ui_Events()
        self.ui.setupUi(self)

        self.weboob = weboob
        self.photo_processes = {}
        self.event_filter = None

        self.connect(self.ui.eventsList, SIGNAL('itemDoubleClicked(QTreeWidgetItem*, int)'), self.eventDoubleClicked)
        self.connect(self.ui.typeBox, SIGNAL('currentIndexChanged(int)'), self.typeChanged)
        self.connect(self.ui.refreshButton, SIGNAL('clicked()'), self.refreshEventsList)

        self.ui.eventsList.setItemDelegate(HTMLDelegate())
        self.ui.eventsList.sortByColumn(1, Qt.DescendingOrder)

    def load(self):
        self.refreshEventsList()

    def typeChanged(self, i):
        if self.ui.refreshButton.isEnabled():
            self.refreshEventsList()

    def refreshEventsList(self):
        self.ui.eventsList.clear()
        self.ui.refreshButton.setEnabled(False)
        if self.ui.typeBox.currentIndex() >= 0:
            # XXX strangely, in gotEvent() in the loop to check if there is already the
            # event type to try to introduce it in list, itemData() returns the right value.
            # But, I don't know why, here, it will ALWAYS return None...
            # So the filter does not work currently.
            self.events_filter = self.ui.typeBox.itemData(self.ui.typeBox.currentIndex())
        else:
            self.event_filter = None
        self.ui.typeBox.setEnabled(False)
        self.ui.typeBox.clear()
        self.ui.typeBox.addItem('All', None)
        self.process = QtDo(self.weboob, self.gotEvent)
        self.process.do('iter_events')

    def setPhoto(self, contact, item):
        if not contact:
            return False

        try:
            self.photo_processes.pop(contact.id, None)
        except KeyError:
            pass

        img = None
        for photo in contact.photos.itervalues():
            if photo.thumbnail_data:
                img = QImage.fromData(photo.thumbnail_data)
                break

        if img:
            item.setIcon(0, QIcon(QPixmap.fromImage(img)))
            self.ui.eventsList.resizeColumnToContents(0)
            return True

        return False

    def gotEvent(self, backend, event):
        if not backend:
            self.ui.refreshButton.setEnabled(True)
            self.ui.typeBox.setEnabled(True)
            return

        found = False
        for i in xrange(self.ui.typeBox.count()):
            s = self.ui.typeBox.itemData(i)
            if s == event.type:
                found = True
        if not found:
            print event.type
            self.ui.typeBox.addItem(event.type.capitalize(), event.type)
            if event.type == self.event_filter:
                self.ui.typeBox.setCurrentIndex(self.ui.typeBox.count()-1)

        if self.event_filter and self.event_filter != event.type:
            return

        contact = event.contact
        contact.backend = event.backend
        status = ''

        if contact.status == contact.STATUS_ONLINE:
            status = u'Online'
            status_color = 0x00aa00
        elif contact.status == contact.STATUS_OFFLINE:
            status = u'Offline'
            status_color = 0xff0000
        elif contact.status == contact.STATUS_AWAY:
            status = u'Away'
            status_color = 0xffad16
        else:
            status = u'Unknown'
            status_color = 0xaaaaaa

        if contact.status_msg:
            status += u' — %s' % contact.status_msg

        name = '<h2>%s</h2><font color="#%06X">%s</font><br /><i>%s</i>' % (contact.name, status_color, status, event.backend)
        date = event.date.strftime('%Y-%m-%d %H:%M')
        type = event.type
        message = event.message

        item = QTreeWidgetItem(None, [name, date, type, message])
        item.setData(0, Qt.UserRole, event)
        if contact.photos is NotLoaded:
            process = QtDo(self.weboob, lambda b, c: self.setPhoto(c, item))
            process.do('fillobj', contact, ['photos'], backends=contact.backend)
            self.photo_processes[contact.id] = process
        elif len(contact.photos) > 0:
            if not self.setPhoto(contact, item):
                photo = contact.photos.values()[0]
                process = QtDo(self.weboob, lambda b, p: self.setPhoto(contact, item))
                process.do('fillobj', photo, ['thumbnail_data'], backends=contact.backend)
                self.photo_processes[contact.id] = process

        self.ui.eventsList.addTopLevelItem(item)
        self.ui.eventsList.resizeColumnToContents(0)
        self.ui.eventsList.resizeColumnToContents(1)

    def eventDoubleClicked(self, item, col):
        event = item.data(0, Qt.UserRole).toPyObject()
        self.emit(SIGNAL('display_contact'), event.contact)