This file is indexed.

/usr/share/pyshared/dockmanager/dockmanager.py is in python-dockmanager 0.1.0-0ubuntu1.

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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#  
#  Copyright (C) 2009-2010 Jason Smith, Robert Dyer
# 
#  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 3 of the License, 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.  If not, see <http://www.gnu.org/licenses/>.
#

import gobject
import time
import glib
import dbus
import dbus.glib
import sys
import urllib
import os
import subprocess


DOCKMANAGER_BUS   = 'net.launchpad.DockManager'
DOCKMANAGER_PATH  = '/net/launchpad/DockManager'
DOCKMANAGER_IFACE = 'net.launchpad.DockManager'

DOCKITEM_IFACE    = 'net.launchpad.DockItem'

RESOURCESDIR = "/usr/share/dockmanager/data"

class DockManagerItem():
	def __init__(self, sink, path):
		self.sink = sink;
		self.path = path
		self.bus = dbus.SessionBus()
		self.id_map = {}
		self.id_info = {}
		
		try:
			obj = self.bus.get_object(DOCKMANAGER_BUS, self.path)
			self.iface = dbus.Interface(obj, DOCKITEM_IFACE)

			self.bus.add_signal_receiver(self.menu_pressed_signal, "MenuItemActivated", DOCKITEM_IFACE, DOCKMANAGER_BUS, self.path)
			if "x-docky-uses-menu-confirmation" in self.sink.capabilities:
				self.bus.add_signal_receiver(self.menu_item_confirmation_needed, "MenuItemConfirmationNeeded", DOCKITEM_IFACE, DOCKMANAGER_BUS, self.path)
		except dbus.DBusException, e:
			print "DockManagerItem(): %s" % e
			sys.exit(0)
		
	def add_menu_item(self, name, icon, group=None):
		try:
			hints = {"label":name}
			if group:
				hints["container-title"] = group
			if icon and not icon == "":
				hint = "icon-name" if not os.path.isabs(icon) else "icon-file"
				hints[hint] = icon
			menu_id = self.iface.AddMenuItem(hints)
		except dbus.DBusException, e:
			return None
		self.id_map[menu_id] = name
		return menu_id

	def add_menu_item_uri(self, uri, group, title=None):
		try:
			if "menu-item-with-uri" in self.sink.capabilities:
				menu_id = self.iface.AddMenuItem({"uri":uri, "container-title":group})
				self.id_map[menu_id] = uri
				return menu_id
		except dbus.DBusException, e:
			return None
		return add_menu_item(title or uri, None, group)

	def remove_menu_item(self, menu_id):
		if menu_id in self.id_map:
			try:
				self.iface.RemoveMenuItem(menu_id)
			except dbus.DBusException, e:
				return None
			del self.id_map[menu_id]

	def menu_pressed_signal(self, menu_id):
		if self.id_map.has_key(menu_id):
			self.menu_pressed(menu_id)
	
	def menu_pressed(self, menu_id):
		if self.id_info.has_key(menu_id):
			subprocess.Popen(['xdg-open', self.id_info[menu_id]])
	
	def menu_item_confirmation_needed(self):
		if "x-docky-uses-menu-confirmation" in self.sink.capabilities:
			for menu_id, title in self.id_map.iteritems():
				try:
					self.iface.ConfirmMenuItem(menu_id)
				except dbus.DBusException, e:
					pass
	
	def set_tooltip(self, text):
		if ("dock-item-tooltip" in self.sink.capabilities):
			try:
				self.iface.UpdateDockItem({"tooltip":text})
			except dbus.DBusException, e:
				pass
	
	def reset_tooltip(self):
		self.set_tooltip("")
	
	def set_badge(self, text):
		if ("dock-item-badge" in self.sink.capabilities):
			try:
				self.iface.UpdateDockItem({"badge":text})
			except dbus.DBusException, e:
				pass
	
	def reset_badge(self):
		self.set_badge("")
	
	def set_icon(self, icon):
		if ("dock-item-icon-file" in self.sink.capabilities):
			try:
				self.iface.UpdateDockItem({"icon-file":icon})
			except dbus.DBusException, e:
				pass
	
	def reset_icon(self):
		self.set_icon("")
	
	def set_attention(self):
		if ("dock-item-attention" in self.sink.capabilities):
			try:
				self.iface.UpdateDockItem({"attention":True})
			except dbus.DBusException, e:
				pass
	
	def unset_attention(self):
		if ("dock-item-attention" in self.sink.capabilities):
			try:
				self.iface.UpdateDockItem({"attention":False})
			except dbus.DBusException, e:
				pass
	
	def set_waiting(self):
		if ("dock-item-waiting" in self.sink.capabilities):
			try:
				self.iface.UpdateDockItem({"waiting":True})
			except dbus.DBusException, e:
				pass
	
	def unset_waiting(self):
		if ("dock-item-waiting" in self.sink.capabilities):
			try:
				self.iface.UpdateDockItem({"waiting":False})
			except dbus.DBusException, e:
				pass
	
	def set_progress(self, progress):
		if ("dock-item-progress" in self.sink.capabilities):
			try:
				self.iface.UpdateDockItem({"progress":progress})
			except dbus.DBusException, e:
				pass
	
	def reset_progress(self):
		self.set_progress(-1)
	
	def dispose(self):
		try:
			self.reset_tooltip()
			self.reset_badge()
			self.reset_icon()
			for menu_id in self.id_map.keys():
				self.iface.RemoveMenuItem(menu_id)
		except dbus.DBusException, e:
			return


class DockManagerSink():
	def __init__(self):
		self.bus = dbus.SessionBus()
		self.capabilities = []
		self.items = {}

		try:
			obj = self.bus.get_object(DOCKMANAGER_BUS, DOCKMANAGER_PATH)
			iface = dbus.Interface(obj, DOCKMANAGER_IFACE)

			self.capabilities = iface.GetCapabilities()

			for pathtoitem in iface.GetItems():
				self.item_added(pathtoitem)

			self.bus.add_signal_receiver(self.item_added,   "ItemAdded",   DOCKMANAGER_IFACE, DOCKMANAGER_BUS, DOCKMANAGER_PATH)
			self.bus.add_signal_receiver(self.item_removed, "ItemRemoved", DOCKMANAGER_IFACE, DOCKMANAGER_BUS, DOCKMANAGER_PATH)

			self.bus.add_signal_receiver(self.name_owner_changed_cb, dbus_interface='org.freedesktop.DBus', signal_name='NameOwnerChanged')
		except dbus.DBusException, e:
			print "DockManagerSink(): %s" % e
			sys.exit(0)

	def item_path_found(self, path, item):
		pass
	
	def item_added(self, path):
		obj = self.bus.get_object(DOCKMANAGER_BUS, path)
		item = dbus.Interface(obj, DOCKITEM_IFACE)
		self.item_path_found(path, item)

	def item_removed(self, path):
		if path in self.items:
			self.items[path].dispose()
			del self.items[path]

	def name_owner_changed_cb(self, name, old_owner, new_owner):
		if name == DOCKMANAGER_BUS and not new_owner:
			print "DockManagerDBus %s is gone, quitting now..." % name
			self.shut_down()				
	
	def dispose(self):
		self.bus.remove_signal_receiver(self.item_added,   "ItemAdded",   DOCKMANAGER_IFACE, DOCKMANAGER_BUS, DOCKMANAGER_PATH)
		self.bus.remove_signal_receiver(self.item_removed, "ItemRemoved", DOCKMANAGER_IFACE, DOCKMANAGER_BUS, DOCKMANAGER_PATH)
		for path in self.items.keys():
			self.item_removed(path)
	
	def shut_down(self):
		gobject.idle_add(quit, 1)