1
/* GCalendarItemSource.cs
3
* GNOME Do is the legal property of its developers. Please refer to the
4
* COPYRIGHT file distributed with this
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.
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.
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/>.
24
using System.Collections.Generic;
29
using Google.GData.Client;
30
using Google.GData.Calendar;
31
using Google.GData.Extensions;
33
namespace Do.GCalendar
35
public class GCalendarItemSource : IItemSource
39
public GCalendarItemSource ()
41
items = new List<IItem> ();
44
public string Name { get { return "Google Calendars"; } }
45
public string Description { get { return "Indexes your Google Calendars"; } }
46
public string Icon { get { return "date"; } }
48
public Type[] SupportedItemTypes
52
typeof (GCalendarItem),
53
typeof (GCalendarEventItem),
58
public ICollection<IItem> Items
63
public ICollection<IItem> ChildrenOfItem (IItem parent)
65
GCalendarItem calItem = parent as GCalendarItem;
66
DoGCal cal = new DoGCal ();
67
List<IItem> children = new List<IItem> ();
68
string eventUrl, eventDesc, start;
69
EventFeed events = cal.GetEvents (calItem.URL);
70
/*for (int i = 0 ; i < events.Entries.Count; i++) {
71
Console.WriteLine(events.Entries[i].Times.StartTime);
72
eventUrl = events.Entries[i].AlternateUri.Content;
73
eventDesc = events.Entries[i].Content.Content;
74
children.Add (new GCalendarEventItem (events.Entries[i].Title.Text, eventUrl,
77
foreach (EventEntry entry in events.Entries) {
78
eventUrl = entry.AlternateUri.Content;
79
eventDesc = entry.Content.Content;
80
if (entry.Times.Count > 0) {
81
start = entry.Times[0].StartTime.ToString ();
82
start = start.Substring (0,start.IndexOf (' '));
83
eventDesc = start + " - " + eventDesc;
85
children.Add (new GCalendarEventItem (entry.Title.Text, eventUrl,
91
public void UpdateItems ()
94
DoGCal cal = new DoGCal ();
95
AtomFeed calList = cal.GetCalendars ();
96
for (int i = 0; i < calList.Entries.Count; i++) {
97
string calUrl = calList.Entries[i].Id.Uri.ToString ();
98
items.Add (new GCalendarItem (calList.Entries[i].Title.Text,
99
calUrl.Replace ("/default","") + "/private/full"));