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/>.
25
using Google.GData.Client;
26
using Google.GData.Calendar;
30
namespace Do.GCalendar
34
string username, password;
35
CalendarService service;
39
GConf.Client gconf = new GConf.Client ();
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","");
50
public void Connect ()
52
service = new CalendarService("alexLauni-gnomeDoGCalPlugin-1");
53
service.setUserCredentials(username, password);
56
public AtomFeed GetCalendars ()
58
FeedQuery query = new FeedQuery ();
59
query.Uri = new Uri ("http://www.google.com/calendar/feeds/default");
61
return service.Query (query);
64
public EventFeed GetEvents (string calUrl)
66
return GetEvents (calUrl, DateTime.Now, DateTime.Now.AddYears(1));
69
public EventFeed GetEvents (string calUrl, DateTime startTime,
72
EventQuery query = new EventQuery (calUrl);
73
query.StartTime = startTime;
74
query.EndTime = endTime;
76
return service.Query (query) as EventFeed;
79
public EventFeed SearchEvents (string calUrl, string needle)
81
EventQuery query = new EventQuery(calUrl);
84
return service.Query(query) as EventFeed;
87
public EventEntry NewEvent (string calUrl, string data)
89
EventEntry entry = new EventEntry ();
90
entry.QuickAdd = true;
91
entry.Content.Content = data;
92
Uri post_uri = new Uri(calUrl);
94
return (EventEntry) service.Insert(post_uri, entry);