3
# Copyright (C) 2007 Canonical Ltd.
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License along
16
# with this program; if not, write to the Free Software Foundation, Inc.,
17
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
from xml.dom.xmlbuilder import *
24
class MimeTypeDescription:
26
def __init__ (mimetype):
27
self.mimetype = mimetype
28
self.pluginResults = None
31
class PluginDescription:
33
def __init__ ( self, \
41
manualInstallationURL, \
47
self.guid = "{" + str(uuid.uuid1()) + "}"
48
self.id="urn:mozilla:plugin:" + self.guid + ":"
50
self.requestedMimetype = requestedMimetype
51
self.version = version
52
self.IconUrl = IconUrl
53
self.XPILocation = XPILocation
54
self.InstallerShowsUI = InstallerShowsUI
55
self.manualInstallationURL = manualInstallationURL
56
self.licenseURL = licenseURL
57
self.needsRestart = needsRestart
58
self.filehint = filehint
59
self.description = description
61
def to_element (self, doc):
62
root_elem = doc.createElement( \
64
root_elem.setAttribute("about", self.id)
66
name_elem = doc.createElement( \
68
root_elem.appendChild(name_elem)
69
name_text = doc.createTextNode(self.name)
70
name_elem.appendChild(name_text)
72
requestedMimetype_elem = doc.createElement( \
73
"pfs:requestedMimetype")
74
root_elem.appendChild(requestedMimetype_elem)
76
if not self.requestedMimetype is None:
77
requestedMimetype_text = doc.createTextNode(self.requestedMimetype)
78
requestedMimetype_elem.appendChild(requestedMimetype_text)
80
guid_elem = doc.createElement( \
83
root_elem.appendChild(guid_elem)
84
if not self.guid is None:
85
guid_text = doc.createTextNode(self.guid)
86
guid_elem.appendChild(guid_text)
88
version_elem = doc.createElement( \
90
root_elem.appendChild(version_elem)
91
if not self.version is None:
92
# version_text = doc.createTextNode(self.version)
93
version_elem.appendChild(version_text)
95
IconUrl_elem = doc.createElement( \
97
root_elem.appendChild(IconUrl_elem)
98
if not self.IconUrl is None:
99
IconUrl_text = doc.createTextNode(self.IconUrl)
100
IconUrl_elem.appendChild(IconUrl_text)
102
XPILocation_elem = doc.createElement( \
104
root_elem.appendChild(XPILocation_elem)
105
if not self.XPILocation is None:
106
XPILocation_text = doc.createTextNode(self.XPILocation)
107
XPILocation_elem.appendChild(XPILocation_text)
109
manualInstallationURL_elem = doc.createElement( \
110
"pfs:manualInstallationURL")
111
root_elem.appendChild(manualInstallationURL_elem)
112
if not self.manualInstallationURL is None:
113
manualInstallationURL_text = doc.createTextNode(self.manualInstallationURL)
114
manualInstallationURL_elem.appendChild(manualInstallationURL_text)
116
licenseURL_elem = doc.createElement( \
118
root_elem.appendChild(licenseURL_elem)
119
if not self.licenseURL is None:
120
licenseURL_text = doc.createTextNode(self.licenseURL)
121
licenseURL_elem.appendChild(licenseURL_text)
123
needsRestart_elem = doc.createElement( \
125
root_elem.appendChild(needsRestart_elem)
126
if not self.needsRestart is None:
127
needsRestart_text = doc.createTextNode(self.needsRestart)
128
needsRestart_elem.appendChild(needsRestart_text)
130
filehint_elem = doc.createElement( \
132
root_elem.appendChild(filehint_elem)
133
if not self.filehint is None:
134
filehint_text = doc.createTextNode(self.filehint)
135
filehint_elem.appendChild(filehint_text)
137
description_elem = doc.createElement( \
139
root_elem.appendChild(description_elem)
140
if not self.description is None:
141
description_text = doc.createTextNode(self.description)
142
description_elem.appendChild(description_text)