4
* GNOME Do is the legal property of its developers, whose names are too numerous
5
* to list here. Please refer to the COPYRIGHT file distributed with this
8
* This program is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
11
* (at your option) any later version.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23
using System.Threading;
24
using System.Collections.Generic;
27
using Twitterizer.Framework;
31
public sealed class TweetAction : IAction
34
get { return "Tweet"; }
37
public string Description {
38
get { return "Update Twitter status"; }
42
get { return "twitter-icon.png@" + GetType ().Assembly.FullName; }
45
public Type[] SupportedItemTypes {
53
public bool SupportsItem (IItem item)
58
public Type[] SupportedModifierItemTypes {
66
public bool ModifierItemsOptional {
70
public bool SupportsModifierItemForItems (IItem[] items, IItem modItem)
72
return (modItem as ContactItem)["twitter.screenname"] != null;
75
public IItem[] DynamicModifierItemsForItem (IItem item)
80
public IItem[] Perform (IItem[] items, IItem[] modItems)
82
TwitterAction.Status = (items[0] as ITextItem).Text;
83
if (modItems.Length > 0)
84
TwitterAction.Status = BuildTweet (items[0], modItems[0]);
86
Thread updateRunner = new Thread (new ThreadStart (TwitterAction.Tweet));
87
updateRunner.Start ();
92
private string BuildTweet(IItem t, IItem c)
94
ITextItem text = t as ITextItem;
95
ContactItem contact = c as ContactItem;
98
//Handle situations without a contact
99
if (contact == null) return text.Text;
102
if (text.Text.Substring (0,2).Equals ("d "))
103
tweet = "d " + contact["twitter.screenname"] +
104
" " + text.Text.Substring (2);
107
tweet = "@" + contact["twitter.screenname"] + " " + text.Text;
b'\\ No newline at end of file'