• R/O
  • SSH
  • HTTPS

timerabbit: Commit


Commit MetaInfo

Revision7 (tree)
Time2009-10-04 04:03:28
Authorjkawamoto

Log Message

(empty log message)

Change Summary

Incremental Difference

--- TimeLogger/trunk/src/org/timerabbit/logger/SendTweetImpl.java (nonexistent)
+++ TimeLogger/trunk/src/org/timerabbit/logger/SendTweetImpl.java (revision 7)
@@ -0,0 +1,50 @@
1+/*
2+ * Copyright 2009 Junpei Kawamoto
3+ *
4+ * This file is part of TimeRabbit project TimeLogger.
5+ * TimeRabbit project TimeLogger is free software: you can redistribute it and/or modify
6+ * it under the terms of the GNU General Public License as published by
7+ * the Free Software Foundation, either version 3 of the License, or
8+ * (at your option) any later version.
9+ *
10+ * TimeRabbit project TimeLogger is distributed in the hope that it will be useful,
11+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+ * GNU General Public License for more details.
14+ *
15+ * You should have received a copy of the GNU General Public License
16+ * along with TimeRabbit project TimeLogger. If not, see <http://www.gnu.org/licenses/>.
17+ */
18+package org.timerabbit.logger;
19+
20+import javafx.async.RunnableFuture;
21+import winterwell.jtwitter.Twitter;
22+import winterwell.jtwitter.TwitterException;
23+
24+class SendTweetImpl implements RunnableFuture{
25+
26+ private final String tweet;
27+
28+ public SendTweetImpl(final String tweet){
29+
30+ this.tweet = tweet;
31+
32+ }
33+
34+ @Override
35+ public void run() throws Exception {
36+
37+ try{
38+
39+ final Twitter jtweet = new Twitter();
40+ jtweet.setStatus(this.tweet);
41+
42+ }catch(final TwitterException e){
43+
44+ System.err.println(e.getLocalizedMessage());
45+
46+ }
47+
48+ }
49+
50+}
--- TimeLogger/trunk/src/org/timerabbit/logger/LoadCalendarInfoImpl.java (nonexistent)
+++ TimeLogger/trunk/src/org/timerabbit/logger/LoadCalendarInfoImpl.java (revision 7)
@@ -0,0 +1,73 @@
1+/*
2+ * Copyright 2009 Junpei Kawamoto
3+ *
4+ * This file is part of TimeRabbit project TimeLogger.
5+ * TimeRabbit project TimeLogger is free software: you can redistribute it and/or modify
6+ * it under the terms of the GNU General Public License as published by
7+ * the Free Software Foundation, either version 3 of the License, or
8+ * (at your option) any later version.
9+ *
10+ * TimeRabbit project TimeLogger is distributed in the hope that it will be useful,
11+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+ * GNU General Public License for more details.
14+ *
15+ * You should have received a copy of the GNU General Public License
16+ * along with TimeRabbit project TimeLogger. If not, see <http://www.gnu.org/licenses/>.
17+ */
18+package org.timerabbit.logger;
19+
20+import com.google.gdata.client.calendar.CalendarService;
21+import com.google.gdata.data.calendar.CalendarEntry;
22+import com.google.gdata.data.calendar.CalendarFeed;
23+import com.google.gdata.util.AuthenticationException;
24+import java.net.URL;
25+import java.util.List;
26+import javafx.async.RunnableFuture;
27+import javafx.ext.swing.SwingComboBoxItem;
28+
29+class LoadCalendarInfoImpl implements RunnableFuture{
30+
31+ private final String id;
32+ private final String pass;
33+ private final List<SwingComboBoxItem> items;
34+
35+ public LoadCalendarInfoImpl(final String id, final String pass, final List<SwingComboBoxItem> items){
36+
37+ this.id = id;
38+ this.pass = pass;
39+ this.items = items;
40+
41+ }
42+
43+ @Override
44+ public void run() throws Exception {
45+
46+ try{
47+
48+ final CalendarService sp = new CalendarService("TimeRabbitProject-TimeLogger-0.1");
49+ sp.setUserCredentials(this.id, this.pass);
50+
51+ final URL feedUrl = new URL("http://www.google.com/calendar/feeds/default/owncalendars/full");
52+ final CalendarFeed resultFeed = sp.getFeed(feedUrl, CalendarFeed.class);
53+
54+ for(final CalendarEntry e : resultFeed.getEntries()){
55+
56+ final String url = e.getId();
57+ final SwingComboBoxItem item = new SwingComboBoxItem();
58+ item.set$text(e.getTitle().getPlainText());
59+ item.set$value(url.substring(url.lastIndexOf("/")+1));
60+
61+ this.items.add(item);
62+
63+ }
64+
65+ }catch(final AuthenticationException e){
66+
67+ System.err.println(e.getLocalizedMessage());
68+
69+ }
70+
71+ }
72+
73+}
--- TimeLogger/trunk/src/org/timerabbit/logger/SendCalendarEventImpl.java (nonexistent)
+++ TimeLogger/trunk/src/org/timerabbit/logger/SendCalendarEventImpl.java (revision 7)
@@ -0,0 +1,79 @@
1+/*
2+ * Copyright 2009 Junpei Kawamoto
3+ *
4+ * This file is part of TimeRabbit project TimeLogger.
5+ * TimeRabbit project TimeLogger is free software: you can redistribute it and/or modify
6+ * it under the terms of the GNU General Public License as published by
7+ * the Free Software Foundation, either version 3 of the License, or
8+ * (at your option) any later version.
9+ *
10+ * TimeRabbit project TimeLogger is distributed in the hope that it will be useful,
11+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+ * GNU General Public License for more details.
14+ *
15+ * You should have received a copy of the GNU General Public License
16+ * along with TimeRabbit project TimeLogger. If not, see <http://www.gnu.org/licenses/>.
17+ */
18+package org.timerabbit.logger;
19+
20+import com.google.gdata.client.calendar.CalendarService;
21+import com.google.gdata.data.DateTime;
22+import com.google.gdata.data.PlainTextConstruct;
23+import com.google.gdata.data.calendar.CalendarEventEntry;
24+import com.google.gdata.data.extensions.When;
25+import com.google.gdata.util.AuthenticationException;
26+import java.net.URL;
27+import java.util.TimeZone;
28+import javafx.async.RunnableFuture;
29+
30+class SendCalendarEventImpl implements RunnableFuture{
31+
32+ private final String id;
33+ private final String pass;
34+ private final String url;
35+ private final long start;
36+ private final long end;
37+ private final String title;
38+
39+ private static final TimeZone timezone = TimeZone.getDefault();
40+
41+
42+ public SendCalendarEventImpl(final String id, final String pass, final String url, final long start, final long end, final String title){
43+
44+ this.id = id;
45+ this.pass = pass;
46+ this.url = url;
47+ this.start = start;
48+ this.end = end;
49+ this.title = title;
50+
51+ }
52+
53+ @Override
54+ public void run() throws Exception {
55+
56+ try{
57+
58+ final When eventTime = new When();
59+ eventTime.setStartTime(new DateTime(start + timezone.getOffset(start)));
60+ eventTime.setEndTime(new DateTime(end + timezone.getOffset(end)));
61+
62+ final CalendarEventEntry entry = new CalendarEventEntry();
63+ entry.setTitle(new PlainTextConstruct(title));
64+ entry.addTime(eventTime);
65+
66+ final CalendarService sp = new CalendarService("TimeRabbitProject-TimeLogger-0.1");
67+ sp.setUserCredentials(this.id, this.pass);
68+
69+ sp.insert(new URL(String.format("http://www.google.com/calendar/feeds/%s/private/full", this.url)), entry);
70+
71+ }catch(final AuthenticationException e){
72+
73+ System.err.println(e.getLocalizedMessage());
74+
75+ }
76+
77+ }
78+
79+}
Show on old repository browser