~ubuntu-branches/ubuntu/jaunty/gnome-do-plugins/jaunty-proposed

1.1.4 by Iain Lane
Import upstream version 0.8.1.3+dfsg
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.IO;
18
using System.Collections;
19
using System.Text;
20
using System.Net;
21
using Google.GData.Client;
22
using Google.GData.Extensions;
23
24
25
namespace Google.GData.Spreadsheets 
26
{
27
28
    /// <summary>
29
    /// The SpreadsheetsService class extends the basic Service abstraction
30
    /// to define a service that is preconfigured for access to the
31
    /// Google Spreadsheets data API.
32
    /// </summary>
33
    public class SpreadsheetsService : Service 
34
    {
35
        /// <summary>The Spreadsheets service's name</summary>
36
        public const string GSpreadsheetsService = "wise";
37
38
39
40
        /// <summary>
41
        /// Constructor
42
        /// </summary>
43
        /// <param name="applicationName">The name of the client application 
44
        /// using this service.</param>
45
        public SpreadsheetsService(string applicationName)
46
        : base(GSpreadsheetsService, applicationName)
47
        {
48
            this.NewFeed += new ServiceEventHandler(this.OnNewFeed); 
49
        }
50
51
        /// <summary>
52
        ///  overwritten Query method
53
        /// </summary>
54
        /// <param name="feedQuery">The FeedQuery touse</param>
55
        /// <returns>the retrieved CellFeed</returns>
56
        public CellFeed Query(CellQuery feedQuery)
57
        {
58
            return base.Query(feedQuery) as CellFeed;
59
        }
60
61
        /// <summary>
62
        ///  overwritten Query method
63
        /// </summary>
64
        /// <param name="feedQuery">The FeedQuery touse</param>
65
        /// <returns>the retrieved ListFeed</returns>
66
        public ListFeed Query(ListQuery feedQuery)
67
        {
68
            return base.Query(feedQuery) as ListFeed;
69
        }
70
71
        /// <summary>
72
        ///  overwritten Query method
73
        /// </summary>
74
        /// <param name="feedQuery">The FeedQuery to use</param>
75
        /// <returns>the retrieved SpreadsheetFeed</returns>
76
        public SpreadsheetFeed Query(SpreadsheetQuery feedQuery)
77
        {
78
            return base.Query(feedQuery) as SpreadsheetFeed;
79
        }
80
81
        /// <summary>
82
        ///  overwritten Query method
83
        /// </summary>
84
        /// <param name="feedQuery">The FeedQuery to use</param>
85
        /// <returns>the retrieved WorksheetFeed</returns>
86
        public WorksheetFeed Query(WorksheetQuery feedQuery)
87
        {
88
            return base.Query(feedQuery) as WorksheetFeed;
89
        }
90
91
92
93
        //////////////////////////////////////////////////////////////////////
94
        /// <summary>eventchaining. We catch this by from the base service, which 
95
        /// would not by default create an atomFeed</summary> 
96
        /// <param name="sender"> the object which send the event</param>
97
        /// <param name="e">FeedParserEventArguments, holds the feedentry</param> 
98
        /// <returns> </returns>
99
        //////////////////////////////////////////////////////////////////////
100
        protected void OnNewFeed(object sender, ServiceEventArgs e)
101
        {
102
            Tracing.TraceMsg("Created new Spreadsheet Feed");
103
            if (e == null)
104
            {
105
                throw new ArgumentNullException("e"); 
106
            }
107
            if (e.Uri.AbsoluteUri.IndexOf("/" + 
108
                  GDataSpreadsheetsNameTable.FeedCell + "/") != -1)
109
            {
110
                e.Feed = new CellFeed(e.Uri, e.Service);
111
            } 
112
            else if (e.Uri.AbsoluteUri.IndexOf("/" + 
113
                  GDataSpreadsheetsNameTable.FeedList + "/") != -1)
114
            {
115
                e.Feed = new ListFeed(e.Uri, e.Service);
116
            }
117
            else if(e.Uri.AbsoluteUri.IndexOf("/" + 
118
                  GDataSpreadsheetsNameTable.FeedSpreadsheet + "/") != -1)
119
            {
120
                e.Feed = new SpreadsheetFeed(e.Uri, e.Service);
121
            }
122
            else if(e.Uri.AbsoluteUri.IndexOf("/" + 
123
                  GDataSpreadsheetsNameTable.FeedWorksheet + "/") != -1)
124
            {
125
                e.Feed = new WorksheetFeed(e.Uri, e.Service);
126
            }
127
        }
128
        /////////////////////////////////////////////////////////////////////////////
129
    }
130
}