~ubuntu-branches/debian/squeeze/gnome-do-plugins/squeeze

« back to all changes in this revision

Viewing changes to BundledLibraries/libgoogle-data-mono-1.4.0.2/src/gdocuments/documentquery.cs

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2009-06-27 16:11:49 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090627161149-b74nc297di2842u1
* New upstream release
  + Pidgin plugin now supports initial text for messages (LP: #338608)
  + Pidgin plugin opens conversations on the correct IM network (LP: #370965)
* debian/rules:
  + Update get-orig-source target.  Upstream no longer ships gdata* binaries,
    so we no longer need to strip them
* debian/patches/00_use_system_gdata
  + Drop.  Upstream now builds against system libgdata.
* debian/patches/04_fix_pidgin_dbus_ints
* debian/patches/10_fix_rhythmbox_file
* debian/patches/15_twitter_api
* debian/patches/20_twitter_overflow:
  + Drop.  Included upstream.
* debian/patches/01_firefox_iceweasel_rename:
  + Refresh for new version
* debian/patches/02_fix_banshee_plugin:
  + Drop refernce to /usr/lib/banshee-1/Banshee.CollectionIndexer.dll.
    This is unnecessary, and causes errors when Banshee isn't installed.
* debian/patches/00_debian_default_plugins:
  + Enable a bunch of useful plugins that do not require configuration from 
    the "Official" plugin set by default.  Makes Do more useful out of the 
    box.
* debian/control:
  + Bump versioned build-dep on gnome-do to 0.8.2
  + Split out gnome-do-plugin-evolution package, now that this is possible.
    libevolution5.0-cil has an annoyingly large dependency stack.
    (LP: #351535) (Closes: #524993).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2006 Google Inc.
2
 
 *
3
 
 * Licensed under the Apache License, Version 2.0 (the "License");
4
 
 * you may not use this file except in compliance with the License.
5
 
 * You may obtain a copy of the License at
6
 
 *
7
 
 *     http://www.apache.org/licenses/LICENSE-2.0
8
 
 *
9
 
 * Unless required by applicable law or agreed to in writing, software
10
 
 * distributed under the License is distributed on an "AS IS" BASIS,
11
 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
 
 * See the License for the specific language governing permissions and
13
 
 * limitations under the License.
14
 
*/
15
 
 
16
 
using System;
17
 
using System.Xml;
18
 
using System.Text;
19
 
using System.Globalization;
20
 
using System.Diagnostics;
21
 
using Google.GData.Client;
22
 
 
23
 
namespace Google.GData.Documents {
24
 
 
25
 
    //////////////////////////////////////////////////////////////////////
26
 
    /// <summary>
27
 
    /// A subclass of FeedQuery, to create an Documents query URI.
28
 
    /// Provides public properties that describe the different
29
 
    /// aspects of the URI, as well as a composite URI.
30
 
    /// 
31
 
    /// Documents List supports the following standard GData query parameters: 
32
 
    ///     alt, author, q, start-index, max-results, updated-min, updated-max, /category
33
 
    /// For more information about the standard parameters, see the GData protocol reference document.
34
 
    /// In addition to the standard GData query parameters, the Documents List data API uses the following parameters.
35
 
    /// Parameter       Meaning                                                 
36
 
    /// title       Specifies the search terms for the title of a document.     
37
 
    ///             This parameter used without title-exact will only submit partial queries, not exact queries.
38
 
    /// 
39
 
    /// title-exact     Specifies whether the title query should be taken as an exact string.   
40
 
    ///             Meaningless without title. Possible values are true and false.
41
 
    /// 
42
 
    /// The Documents List data API supports the following categories.
43
 
    ///     Category: Document Type     
44
 
    ///             Scheme: http://schemas.google.com/g/2005#kind       
45
 
    ///             Term: http://schemas.google.com/docs/2007#type      
46
 
    ///             Label: type     
47
 
    ///             All documents of the corresponding type in the requesting users document list. 
48
 
    ///             Type is currently one of (document|spreadsheet|presentation)
49
 
    ///     Category: Starred Status
50
 
    ///                 Scheme: http://schemas.google.com/g/2005/labels 
51
 
    ///             Term: starred                                           
52
 
    ///             Label: starred          
53
 
    ///             All documents that have been starred by the requesting user
54
 
    ///     Category: Containing Folders        
55
 
    ///             Scheme: http://schemas.google.com/docs/2007/folders/user-email      
56
 
    ///             Term: folder-id     
57
 
    ///             Label: folder-name  
58
 
    ///             All documents inside the given folder for the requesting user
59
 
    ///  </summary>
60
 
    //////////////////////////////////////////////////////////////////////
61
 
    public class DocumentsListQuery : FeedQuery
62
 
    {
63
 
 
64
 
  
65
 
        /// <summary>
66
 
        /// document feed base URI 
67
 
        /// </summary>
68
 
        public static string documentsBaseUri = "http://docs.google.com/feeds/documents/private/full";
69
 
 
70
 
        /// <summary>
71
 
        /// folder base uri
72
 
        /// </summary>
73
 
        /// <returns></returns>
74
 
        public static string folderBaseUri = "http://docs.google.com/feeds/folders/private/full/folder%3A";
75
 
 
76
 
        private static AtomCategory ATOMCATEGORY_DOCUMENTS = new AtomCategory("document");
77
 
        /// <summary>
78
 
        /// predefined query category for documents
79
 
        /// </summary>
80
 
        public static QueryCategory DOCUMENTS = new QueryCategory(ATOMCATEGORY_DOCUMENTS);
81
 
 
82
 
        private static AtomCategory ATOMCATEGORY_SPREADSHEETS = new AtomCategory("spreadsheet");
83
 
        /// <summary>
84
 
        /// predefined query category for spreadsheets
85
 
        /// </summary>
86
 
        public static QueryCategory SPREADSHEETS = new QueryCategory(ATOMCATEGORY_SPREADSHEETS);
87
 
 
88
 
        private static AtomCategory ATOMCATEGORY_PRESENTATIONS = new AtomCategory("presentation");
89
 
        /// <summary>
90
 
        /// predefined query category for presentations
91
 
        /// </summary>
92
 
        public static QueryCategory PRESENTATIONS = new QueryCategory(ATOMCATEGORY_PRESENTATIONS);
93
 
 
94
 
        private static AtomCategory ATOMCATEGORY_PDFS = new AtomCategory("pdf");
95
 
        /// <summary>
96
 
        /// predefined query category for presentations
97
 
        /// </summary>
98
 
        public static QueryCategory PDFS = new QueryCategory(ATOMCATEGORY_PDFS);
99
 
        
100
 
        
101
 
        /// <summary>
102
 
        /// predefined query category for starred documents
103
 
        /// </summary>
104
 
        public static AtomCategory ATOMCATEGORY_STARRED = new AtomCategory("starred");
105
 
        /// <summary>
106
 
        /// predefined query category for starred documents
107
 
        /// </summary>
108
 
        public static QueryCategory STARRED = new QueryCategory(ATOMCATEGORY_STARRED);
109
 
 
110
 
 
111
 
        /// <summary>
112
 
        /// predefined query category for starred documents
113
 
        /// </summary>
114
 
        public static AtomCategory ATOMCATEGORY_FOLDER = new AtomCategory("folder");
115
 
        /// <summary>
116
 
        /// predefined query category for starred documents
117
 
        /// </summary>
118
 
        public static QueryCategory FOLDER = new QueryCategory(ATOMCATEGORY_FOLDER);
119
 
 
120
 
        //Local variable to hold the contents of a title query
121
 
        private string title;
122
 
        //Local variable to hold if the title query we are doing should be exact.
123
 
        private bool titleExact;
124
 
 
125
 
        /// <summary>
126
 
        /// base constructor
127
 
        /// </summary>
128
 
        public DocumentsListQuery()
129
 
        : base(documentsBaseUri)
130
 
        {
131
 
            this.CategoryQueriesAsParameter = true;
132
 
        }
133
 
 
134
 
        /// <summary>
135
 
        /// base constructor, with initial queryUri
136
 
        /// </summary>
137
 
        /// <param name="queryUri">the query to use</param>
138
 
        public DocumentsListQuery(string queryUri)
139
 
        : base(queryUri)
140
 
        {
141
 
            this.CategoryQueriesAsParameter = true;
142
 
        }
143
 
 
144
 
        /// <summary>
145
 
        /// Restricts the results to only starred documents
146
 
        /// </summary>
147
 
        [CLSCompliant(false)]
148
 
        public bool Starred
149
 
        {
150
 
            get
151
 
            {
152
 
                return this.Categories.Contains(DocumentsListQuery.STARRED);
153
 
            }
154
 
            set
155
 
            {
156
 
                if (value)
157
 
                {
158
 
                    this.Categories.Add(DocumentsListQuery.STARRED);
159
 
                }
160
 
                else
161
 
                {
162
 
                    this.Categories.Remove(DocumentsListQuery.STARRED);
163
 
                }
164
 
            }
165
 
        }
166
 
 
167
 
        private bool showFolders;
168
 
        /// <summary>
169
 
        /// shows folders if true in the result
170
 
        /// </summary>
171
 
        [CLSCompliant(false)]
172
 
        public bool ShowFolders
173
 
        {
174
 
            get
175
 
            {
176
 
                return this.showFolders;
177
 
            }
178
 
            set
179
 
            {
180
 
                this.showFolders = value;
181
 
            }
182
 
        }
183
 
 
184
 
        /// <summary>
185
 
        /// Restricts the results to only documents with titles matching a string.
186
 
        /// </summary>
187
 
        public string Title
188
 
        {
189
 
            get
190
 
            {
191
 
                return this.title;
192
 
            }
193
 
            set
194
 
            {
195
 
                this.title = value;
196
 
            }
197
 
        }
198
 
 
199
 
        /// <summary>
200
 
        /// Restricts the results to only documents matching a string provided
201
 
        /// by the Title property exactly. (No partial matches.)
202
 
        /// </summary>
203
 
        public bool TitleExact
204
 
        {
205
 
            get
206
 
            {
207
 
                return this.titleExact;
208
 
            }
209
 
            set
210
 
            {
211
 
                this.titleExact = value;
212
 
            }
213
 
        }
214
 
 
215
 
 
216
 
        /// <summary>
217
 
        /// tries to parse a document id iri and return just the 
218
 
        /// ID portion of it
219
 
        /// </summary>
220
 
        /// <param name="documentUri">the document id link as a string</param>
221
 
        /// <returns>the document id or null if failed</returns>
222
 
        public static string DocumentId(string documentUri)
223
 
        {
224
 
            const string token="%3A"; 
225
 
            if (documentUri == null)
226
 
 
227
 
            {
228
 
                throw new ArgumentNullException("documentUri");
229
 
            }
230
 
            int pos = documentUri.LastIndexOf(token);
231
 
            if (pos > 0)
232
 
            {
233
 
                pos += 3;
234
 
                if (pos < documentUri.Length)
235
 
                {
236
 
                    return documentUri.Substring(pos);
237
 
                }
238
 
            }
239
 
            return null;
240
 
        }
241
 
 
242
 
#if WindowsCE || PocketPC
243
 
#else
244
 
        //////////////////////////////////////////////////////////////////////
245
 
        /// <summary>Parses custom properties out of the incoming URI</summary> 
246
 
        /// <param name="targetUri">A URI representing a query on a feed</param>
247
 
        /// <returns>returns the base uri</returns>
248
 
        //////////////////////////////////////////////////////////////////////
249
 
        protected override Uri ParseUri(Uri targetUri)
250
 
        {
251
 
            base.ParseUri(targetUri);
252
 
            if (targetUri != null)
253
 
            {
254
 
                char[] deli = { '?', '&' };
255
 
 
256
 
                TokenCollection tokens = new TokenCollection(targetUri.Query, deli);
257
 
                foreach (String token in tokens)
258
 
                {
259
 
                    if (token.Length > 0)
260
 
                    {
261
 
                        char[] otherDeli = { '=' };
262
 
                        String[] parameters = token.Split(otherDeli, 2);
263
 
                        switch (parameters[0])
264
 
                        {
265
 
                            case "title-exact":
266
 
                                this.TitleExact = bool.Parse(parameters[1]);
267
 
                                break;
268
 
                            case "title":
269
 
                                this.Title = parameters[1];
270
 
                                break;
271
 
                            case "showfolders":
272
 
                                this.ShowFolders = bool.Parse(parameters[1]);
273
 
                                break;
274
 
                        }
275
 
                    }
276
 
                }
277
 
            }
278
 
            return this.Uri;
279
 
        }
280
 
#endif
281
 
        //////////////////////////////////////////////////////////////////////
282
 
        /// <summary>Creates the partial URI query string based on all
283
 
        ///  set properties.</summary> 
284
 
        /// <returns> A string representing the query part of the URI.</returns>
285
 
        //////////////////////////////////////////////////////////////////////
286
 
        protected override string CalculateQuery(string basePath)
287
 
        {
288
 
            string path = base.CalculateQuery(basePath);
289
 
            StringBuilder newPath = new StringBuilder(path, 2048);
290
 
            char paramInsertion = InsertionParameter(path); 
291
 
 
292
 
            paramInsertion = AppendQueryPart(this.Title, "title", paramInsertion, newPath);            
293
 
 
294
 
            if (this.TitleExact == true)
295
 
            {
296
 
                paramInsertion = AppendQueryPart("true", "title-exact", paramInsertion, newPath);            
297
 
            }
298
 
            if (this.ShowFolders == true)
299
 
            {
300
 
                paramInsertion = AppendQueryPart("true", "showfolders", paramInsertion, newPath);            
301
 
            }
302
 
            return newPath.ToString();
303
 
        }
304
 
    }
305
 
 
306
 
 
307
 
 
308
 
    /// <summary>
309
 
    /// a subclass setup to just retrieve all word processor documents
310
 
    /// </summary>
311
 
    public class TextDocumentQuery : DocumentsListQuery
312
 
    {
313
 
 
314
 
        /// <summary>
315
 
        /// base constructor
316
 
        /// </summary>
317
 
        public TextDocumentQuery()
318
 
        : base()
319
 
        {
320
 
            this.Categories.Add(DocumentsListQuery.DOCUMENTS);
321
 
        }
322
 
   }
323
 
 
324
 
 
325
 
    /// <summary>
326
 
    /// a subclass setup to just retrieve all spreadsheets
327
 
    /// </summary>
328
 
    public class SpreadsheetQuery : DocumentsListQuery
329
 
    {
330
 
 
331
 
        /// <summary>
332
 
        /// base constructor
333
 
        /// </summary>
334
 
        public SpreadsheetQuery()
335
 
        : base()
336
 
        {
337
 
            this.Categories.Add(DocumentsListQuery.SPREADSHEETS);
338
 
        }
339
 
   }
340
 
 
341
 
     /// <summary>
342
 
    /// a subclass setup to just retrieve all presentations
343
 
    /// </summary>
344
 
    public class PresentationsQuery : DocumentsListQuery
345
 
    {
346
 
 
347
 
        /// <summary>
348
 
        /// base constructor
349
 
        /// </summary>
350
 
        public PresentationsQuery()
351
 
        : base()
352
 
        {
353
 
            this.Categories.Add(DocumentsListQuery.PRESENTATIONS);
354
 
        }
355
 
   }
356
 
 
357
 
     /// <summary>
358
 
    /// a subclass setup to just retrieve all PDFs
359
 
    /// </summary>
360
 
    public class PDFsQuery : DocumentsListQuery
361
 
    {
362
 
 
363
 
        /// <summary>
364
 
        /// base constructor
365
 
        /// </summary>
366
 
        public PDFsQuery()
367
 
        : base()
368
 
        {
369
 
            this.Categories.Add(DocumentsListQuery.PDFS);
370
 
        }
371
 
   }    
372
 
 
373
 
 
374
 
    /// <summary>
375
 
    /// a subclass setup to just retrieve all Folders
376
 
    /// </summary>
377
 
    public class FolderQuery : DocumentsListQuery
378
 
    {
379
 
 
380
 
        /// <summary>
381
 
        /// base constructor
382
 
        /// </summary>
383
 
        public FolderQuery()
384
 
        : base()
385
 
        {
386
 
            this.Categories.Add(DocumentsListQuery.FOLDER);
387
 
            this.ShowFolders = true;
388
 
        }
389
 
   }    
390
 
    
391
 
}