/usr/share/pyshared/PreludeNotify/pnstatusicon.py is in prelude-notify 0.9.1-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 157 158 159 160 161 162 163 164 165 166 167 | # Copyright (C) 2008 PreludeIDS Technologies. All Rights Reserved.
# Author: Sebastien Tricaud <toady@inl.fr>
# Alexandre De Dommelin <adedommelin@tuxz.net>
#
# This file is part of the Prelude-Notify program.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# 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; see the file COPYING. If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
import gtk
import gobject
import pnconfig
class PreludeStatusIcon:
def __init__(self, gloop, config):
self.config = config
self.gloop = gloop
self.icon = gtk.status_icon_new_from_file(self.config.getIconOk())
self.icon.connect('popup-menu', self.menu)
def MissedAlerts(self):
self.icon.set_from_file(self.config.getIconBad())
def SeenAlerts(self):
self.icon.set_from_file(self.config.getIconOk())
def menu(self, icon, event_button, event_time):
m = gtk.Menu()
item = gtk.ImageMenuItem(gtk.STOCK_EXECUTE, 'Configure...')
label = item.get_children()[0]
label.set_label("Configure...")
item.connect('activate', self.configure)
item.show()
m.append(item)
item = gtk.SeparatorMenuItem()
item.show()
m.append(item)
item = gtk.ImageMenuItem(gtk.STOCK_ABOUT, 'About')
item.connect('activate', self.about)
item.show()
m.append(item)
item = gtk.ImageMenuItem(gtk.STOCK_QUIT, 'Quit')
item.connect('activate', self.quit)
item.show()
m.append(item)
m.popup(None, None, gtk.status_icon_position_menu, event_button,
event_time, icon)
def configure(self, widget):
dialog = gtk.Dialog("Configure prelude notify", None, 0,
(gtk.STOCK_OK, gtk.RESPONSE_OK,
gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
profile_entry = gtk.Entry()
prewikka_url_entry = gtk.Entry()
idle_entry = gtk.Entry()
threshold_entry = gtk.Entry()
idmef_filter_entry = gtk.Entry()
manager_addr_entry = gtk.Entry()
theme_entry = gtk.Entry()
table = gtk.Table(2,7)
table.set_row_spacings(4)
table.set_col_spacings(4)
dialog.vbox.pack_start(table, False, False, 0)
label = gtk.Label("Profile: ")
table.attach(label, 0, 1, 0, 1)
profile_entry.set_text(self.config.get("idmef","profile"))
table.attach(profile_entry, 1, 2, 0, 1)
label = gtk.Label("Manager Addresses: ")
table.attach(label, 0, 1, 1, 2)
manager_addr_entry.set_text(self.config.get("manager", "addresses"))
table.attach(manager_addr_entry, 1, 2, 1, 2)
label = gtk.Label("IDMEF filter: ")
table.attach(label, 0, 1, 2, 3)
idmef_filter_entry.set_text(self.config.get("idmef", "filter"))
table.attach(idmef_filter_entry, 1, 2, 2, 3)
idlecheck = gtk.CheckButton("Idle: ")
idlecheck.connect('toggled', self.idle_toggled, idle_entry)
idletime = self.config.get("general", "x11_idle_timeout")
if idletime:
idlecheck.set_active(True)
idle_entry.set_editable(True)
else:
idlecheck.set_active(False)
idle_entry.set_editable(False)
table.attach(idlecheck, 0, 1, 3, 4)
table.attach(idle_entry, 1, 2, 3, 4)
idle_entry.set_text(self.config.get("general", "x11_idle_timeout"))
threshold = gtk.Label("Threshold: ")
table.attach(threshold, 0, 1, 4, 5)
table.attach(threshold_entry, 1, 2, 4, 5)
threshold_entry.set_text(self.config.get("general", "threshold_timeout"))
label = gtk.Label("Prewikka URL: ")
table.attach(label, 0, 1, 5, 6)
prewikka_url_entry.set_text(self.config.get("prewikka", "url"))
table.attach(prewikka_url_entry, 1, 2, 5, 6)
label = gtk.Label("Theme: ")
table.attach(label, 0, 1, 6, 7)
theme_entry.set_text(self.config.get("ui", "theme"))
table.attach(theme_entry, 1, 2, 6, 7)
dialog.show_all()
response = dialog.run()
if response == gtk.RESPONSE_OK:
self.config.set("idmef", "profile", profile_entry.get_text())
self.config.set("manager", "addresses", manager_addr_entry.get_text())
self.config.set("idmef", "filter", idmef_filter_entry.get_text())
self.config.set("prewikka", "url", prewikka_url_entry.get_text())
self.config.set("ui", "theme", theme_entry.get_text())
self.config.set("general", "threshold_timeout", threshold_entry.get_text())
if idlecheck.get_active():
self.config.set("general", "x11_idle_timeout", idle_entry.get_text())
else:
self.config.set("general", "x11_idle_timeout", "")
self.config.update()
dialog.destroy()
def about(self, widget):
dialog = gtk.AboutDialog()
try:
dialog.set_program_name("Prelude Notify")
except AttributeError:
print "Cannot add the dialog program name"
try:
dialog.set_copyright("Sebastien Tricaud, Alexandre De Dommelin (c) 2010")
except AttributeError:
print "Cannot add the dialog copyright"
try:
dialog.set_comments("Systray Notification for Prelude IDS")
except AttributeError:
print "Cannot add the dialog comments"
dialog.run()
dialog.destroy()
def quit(self, widget):
self.gloop.quit()
#
# Callbacks
#
def idle_toggled(self, widget, idle_entry):
if widget.get_active():
idle_entry.set_editable(True)
else:
idle_entry.set_editable(False)
|