~ubuntu-branches/ubuntu/jaunty/tomboy/jaunty

« back to all changes in this revision

Viewing changes to Mono.Addins/Mono.Addins/Mono.Addins/AddinInfo.cs

  • Committer: Bazaar Package Importer
  • Author(s): Pedro Fragoso
  • Date: 2009-02-17 03:08:19 UTC
  • mfrom: (1.1.46 upstream)
  • Revision ID: james.westby@ubuntu.com-20090217030819-87k5mkna0w5tvvqf
Tags: 0.13.5-0ubuntu1
* New upstream release
  - Removed bundled Mono.Addins. Mono.Addins is
    now a hard dependency.
  - Update printing to use Gtk.Print (#512369, Benjamin Podszun)
    Still buggy.
  - Fix multi-page printing of exported note HTML (#548198)
  - Fix crash when clicking link and browser not set (#569639).
  - 64-bit Windows support (#558272, Jay R. Wren).
  - Search window position saved on Windows/Mac (#559663).
  - Fix lingering tray icon in Windows (#569709, Benjamin Podszun).
  - Fix bug with font settings (#559724, Benjamin Podszun).
  - Mac MonoDevelop solution now easier to build (Doug Johnston et al).
  - Other fixes: #562846 (James Westby) #570917, #570918.
  - Additional updates to note printing (#512369, #572024
    , Benjamin Podszun).
  - Windows installer now requires Novell's GTK# >= 2.12.8 (#569324).
  - Increase/Decrease Indent shortcuts now appear in menu
    (#570334, Benjamin Podszun).
  - No longer writes to disk every 40 seconds (#514434).
  - Fixes to note linking (#323845, Florian).
  - Add GConf preference for auto-accepting SSL Certs in 
    WebDAV sync (#531364).
  - After succcessfully configuring sync, offer to perform 
    first sync (#553079).
* debian/control:
  - Use libgconf2.24-cil and libgnome2.24-cil (LP: #314516)
  - Build-dep on libgnomepanel2.24-cil
  - Remove Build-dep on libgnomeprint and libgnomeprintui
  - Add Vcs headers
* .bzr-builddeb/default.conf: added
* debian/patches/02_configurable_compiler.patch:
  - Removed, merged upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
// AddinInfo.cs
3
 
//
4
 
// Author:
5
 
//   Lluis Sanchez Gual
6
 
//
7
 
// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
8
 
//
9
 
// Permission is hereby granted, free of charge, to any person obtaining
10
 
// a copy of this software and associated documentation files (the
11
 
// "Software"), to deal in the Software without restriction, including
12
 
// without limitation the rights to use, copy, modify, merge, publish,
13
 
// distribute, sublicense, and/or sell copies of the Software, and to
14
 
// permit persons to whom the Software is furnished to do so, subject to
15
 
// the following conditions:
16
 
// 
17
 
// The above copyright notice and this permission notice shall be
18
 
// included in all copies or substantial portions of the Software.
19
 
// 
20
 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
 
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
 
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
 
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24
 
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25
 
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26
 
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
 
//
28
 
 
29
 
using System;
30
 
using System.IO;
31
 
using System.Collections;
32
 
using System.Xml;
33
 
using System.Xml.Serialization;
34
 
using Mono.Addins.Description;
35
 
 
36
 
namespace Mono.Addins
37
 
{
38
 
        internal class AddinInfo
39
 
        {
40
 
                string id = "";
41
 
                string namspace = "";
42
 
                string name = "";
43
 
                string version = "";
44
 
                string baseVersion = "";
45
 
                string author = "";
46
 
                string copyright = "";
47
 
                string url = "";
48
 
                string description = "";
49
 
                string category = "";
50
 
                bool defaultEnabled = true;
51
 
                bool isroot;
52
 
                DependencyCollection dependencies;
53
 
                DependencyCollection optionalDependencies;
54
 
                
55
 
                public AddinInfo ()
56
 
                {
57
 
                        dependencies = new DependencyCollection ();
58
 
                        optionalDependencies = new DependencyCollection ();
59
 
                }
60
 
                
61
 
                public string Id {
62
 
                        get { return Addin.GetFullId (namspace, id, version); }
63
 
                }
64
 
                
65
 
                [XmlElement ("Id")]
66
 
                public string LocalId {
67
 
                        get { return id; }
68
 
                        set { id = value; }
69
 
                }
70
 
                
71
 
                public string Namespace {
72
 
                        get { return namspace; }
73
 
                        set { namspace = value; }
74
 
                }
75
 
                
76
 
                public bool IsRoot {
77
 
                        get { return isroot; }
78
 
                        set { isroot = value; }
79
 
                }
80
 
                
81
 
                public string Name {
82
 
                        get {
83
 
                                if (name != null && name.Length > 0)
84
 
                                        return name;
85
 
                                string sid = id;
86
 
                                if (sid.StartsWith ("__"))
87
 
                                        sid = sid.Substring (2);
88
 
                                return Addin.GetFullId (namspace, sid, null); 
89
 
                        }
90
 
                        set { name = value; }
91
 
                }
92
 
                
93
 
                public string Version {
94
 
                        get { return version; }
95
 
                        set { version = value; }
96
 
                }
97
 
                
98
 
                public string BaseVersion {
99
 
                        get { return baseVersion; }
100
 
                        set { baseVersion = value; }
101
 
                }
102
 
                
103
 
                public string Author {
104
 
                        get { return author; }
105
 
                        set { author = value; }
106
 
                }
107
 
                
108
 
                public string Copyright {
109
 
                        get { return copyright; }
110
 
                        set { copyright = value; }
111
 
                }
112
 
                
113
 
                public string Url {
114
 
                        get { return url; }
115
 
                        set { url = value; }
116
 
                }
117
 
                
118
 
                public string Description {
119
 
                        get { return description; }
120
 
                        set { description = value; }
121
 
                }
122
 
                
123
 
                public string Category {
124
 
                        get { return category; }
125
 
                        set { category = value; }
126
 
                }
127
 
                
128
 
                public bool EnabledByDefault {
129
 
                        get { return defaultEnabled; }
130
 
                        set { defaultEnabled = value; }
131
 
                }
132
 
                
133
 
                [XmlArrayItem ("AddinDependency", typeof(AddinDependency))]
134
 
                [XmlArrayItem ("AssemblyDependency", typeof(AssemblyDependency))]
135
 
                public DependencyCollection Dependencies {
136
 
                        get { return dependencies; }
137
 
                }
138
 
                
139
 
                [XmlArrayItem ("AddinDependency", typeof(AddinDependency))]
140
 
                [XmlArrayItem ("AssemblyDependency", typeof(AssemblyDependency))]
141
 
                public DependencyCollection OptionalDependencies {
142
 
                        get { return optionalDependencies; }
143
 
                }
144
 
                
145
 
                public static AddinInfo ReadFromAddinFile (StreamReader r)
146
 
                {
147
 
                        XmlDocument doc = new XmlDocument ();
148
 
                        doc.Load (r);
149
 
                        r.Close ();
150
 
                        
151
 
                        AddinInfo info = new AddinInfo ();
152
 
                        info.id = doc.DocumentElement.GetAttribute ("id");
153
 
                        info.namspace = doc.DocumentElement.GetAttribute ("namespace");
154
 
                        info.name = doc.DocumentElement.GetAttribute ("name");
155
 
                        if (info.id == "") info.id = info.name;
156
 
                        info.version = doc.DocumentElement.GetAttribute ("version");
157
 
                        info.author = doc.DocumentElement.GetAttribute ("author");
158
 
                        info.copyright = doc.DocumentElement.GetAttribute ("copyright");
159
 
                        info.url = doc.DocumentElement.GetAttribute ("url");
160
 
                        info.description = doc.DocumentElement.GetAttribute ("description");
161
 
                        info.category = doc.DocumentElement.GetAttribute ("category");
162
 
                        info.baseVersion = doc.DocumentElement.GetAttribute ("compatVersion");
163
 
                        
164
 
                        string s = doc.DocumentElement.GetAttribute ("defaultEnabled");
165
 
                        info.defaultEnabled = s.Length == 0 || s == "true" || s == "yes";
166
 
 
167
 
                        s = doc.DocumentElement.GetAttribute ("isRoot");
168
 
                        if (s.Length == 0) s = doc.DocumentElement.GetAttribute ("isroot");
169
 
                        info.isroot = s == "true" || s == "yes";
170
 
                        
171
 
                        ReadDependencies (info.Dependencies, info.OptionalDependencies, doc.DocumentElement);
172
 
                
173
 
                        return info;
174
 
                }
175
 
                
176
 
                static void ReadDependencies (DependencyCollection deps, DependencyCollection opDeps, XmlElement elem)
177
 
                {
178
 
                        foreach (XmlElement dep in elem.SelectNodes ("Dependencies/Addin")) {
179
 
                                AddinDependency adep = new AddinDependency ();
180
 
                                adep.AddinId = dep.GetAttribute ("id");
181
 
                                string v = dep.GetAttribute ("version");
182
 
                                if (v.Length != 0)
183
 
                                        adep.Version = v;
184
 
                                deps.Add (adep);
185
 
                        }
186
 
                        
187
 
                        foreach (XmlElement dep in elem.SelectNodes ("Dependencies/Assembly")) {
188
 
                                AssemblyDependency adep = new AssemblyDependency ();
189
 
                                adep.FullName = dep.GetAttribute ("name");
190
 
                                adep.Package = dep.GetAttribute ("package");
191
 
                                deps.Add (adep);
192
 
                        }
193
 
                        
194
 
                        foreach (XmlElement mod in elem.SelectNodes ("Module"))
195
 
                                ReadDependencies (opDeps, opDeps, mod);
196
 
                }
197
 
                
198
 
                internal static AddinInfo ReadFromDescription (AddinDescription description)
199
 
                {
200
 
                        AddinInfo info = new AddinInfo ();
201
 
                        info.id = description.LocalId;
202
 
                        info.namspace = description.Namespace;
203
 
                        info.name = description.Name;
204
 
                        info.version = description.Version;
205
 
                        info.author = description.Author;
206
 
                        info.copyright = description.Copyright;
207
 
                        info.url = description.Url;
208
 
                        info.description = description.Description;
209
 
                        info.category = description.Category;
210
 
                        info.baseVersion = description.CompatVersion;
211
 
                        info.isroot = description.IsRoot;
212
 
                        info.defaultEnabled = description.EnabledByDefault;
213
 
                        
214
 
                        foreach (Dependency dep in description.MainModule.Dependencies)
215
 
                                info.Dependencies.Add (dep);
216
 
                                
217
 
                        foreach (ModuleDescription mod in description.OptionalModules) {
218
 
                                foreach (Dependency dep in mod.Dependencies)
219
 
                                        info.OptionalDependencies.Add (dep);
220
 
                        }
221
 
                        return info;
222
 
                }
223
 
                
224
 
                public bool SupportsVersion (string version)
225
 
                {
226
 
                        if (Addin.CompareVersions (Version, version) > 0)
227
 
                                return false;
228
 
                        if (baseVersion == "")
229
 
                                return true;
230
 
                        return Addin.CompareVersions (BaseVersion, version) >= 0;
231
 
                }
232
 
                
233
 
                public int CompareVersionTo (AddinInfo other)
234
 
                {
235
 
                        return Addin.CompareVersions (this.version, other.Version);
236
 
                }
237
 
        }
238
 
}