~cszikszoy/do-plugins/fix-confluence

« back to all changes in this revision

Viewing changes to GCalendar/DoGCal.cs

  • Committer: Alex Launi
  • Date: 2008-04-03 16:42:36 UTC
  • mfrom: (85 do-plugins)
  • mto: This revision was merged to the branch mainline in revision 87.
  • Revision ID: alex.launi@gmail.com-20080403164236-6ut2l710phmv92o5
clean up

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* DoGCal.cs
 
2
 *
 
3
 * GNOME Do is the legal property of its developers. Please refer to the
 
4
 * COPYRIGHT file distributed with this
 
5
 * source distribution.
 
6
 *
 
7
 * This program is free software: you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation, either version 3 of the License, or
 
10
 * (at your option) any later version.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
 */
 
20
 
 
21
using System;
 
22
using System.IO;
 
23
using System.Net;
 
24
 
 
25
using Google.GData.Client;
 
26
using Google.GData.Calendar;
 
27
 
 
28
using GConf;
 
29
 
 
30
namespace Do.GCalendar
 
31
{
 
32
        public class DoGCal
 
33
        {
 
34
                string username, password;
 
35
                CalendarService service;
 
36
                
 
37
                public DoGCal ()
 
38
                {
 
39
                        GConf.Client gconf = new GConf.Client ();
 
40
                        try {
 
41
                                username = gconf.Get ("/apps/gnome-do/plugins/gcal/username") as string;
 
42
                                password = gconf.Get ("/apps/gnome-do/plugins/gcal/password") as string;
 
43
                        } catch (GConf.NoSuchKeyException) {
 
44
                                gconf.Set ("/apps/gnome-do/plugins/gcal/username","");
 
45
                                gconf.Set ("/apps/gnome-do/plugins/gcal/password","");
 
46
                        }
 
47
                        Connect ();
 
48
                }
 
49
 
 
50
                public void Connect () 
 
51
                {
 
52
                        service = new CalendarService("alexLauni-gnomeDoGCalPlugin-1");
 
53
            service.setUserCredentials(username, password);     
 
54
                }
 
55
                
 
56
                public AtomFeed GetCalendars ()
 
57
                {
 
58
                        FeedQuery query = new FeedQuery ();
 
59
            query.Uri = new Uri ("http://www.google.com/calendar/feeds/default");
 
60
            
 
61
            return service.Query (query);
 
62
                }
 
63
                
 
64
                public EventFeed GetEvents (string calUrl)
 
65
                {
 
66
                    DateTime now = DateTime.Now;
 
67
                        return GetEvents (calUrl, now, new DateTime(now.Year + 4,12,21));
 
68
                }
 
69
                
 
70
                public EventFeed GetEvents (string calUrl, DateTime startTime,
 
71
                                            DateTime endTime)
 
72
        {
 
73
            EventQuery query = new EventQuery (calUrl);
 
74
            query.StartTime = startTime;
 
75
            query.EndTime = endTime;
 
76
                    
 
77
            return service.Query (query) as EventFeed;
 
78
        }
 
79
        
 
80
        public EventFeed SearchEvents (string calUrl, string needle) 
 
81
        {
 
82
            EventQuery query = new EventQuery(calUrl);
 
83
            query.Query = needle;
 
84
 
 
85
            return service.Query(query) as EventFeed;
 
86
        }
 
87
        
 
88
        public EventEntry NewEvent (string calUrl, string data) 
 
89
        {
 
90
            EventEntry entry = new EventEntry ();
 
91
            entry.QuickAdd = true;
 
92
            entry.Content.Content = data;
 
93
            Uri post_uri = new Uri(calUrl);
 
94
            
 
95
            return (EventEntry) service.Insert(post_uri, entry);
 
96
        }
 
97
        }
 
98
}