1
// EmpathyChatAction.cs
4
// Xavier Calland <xavier.calland@gmail.com>
8
// This program is free software: you can redistribute it and/or modify
9
// it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
18
// You should have received a copy of the GNU Lesser 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;
29
namespace EmpathyPlugin
31
public class EmpathyChatAction : Act
33
public EmpathyChatAction ()
37
public override string Name
39
get { return AddinManager.CurrentLocalizer.GetString ("Chat"); }
42
public override string Description
44
get { return AddinManager.CurrentLocalizer.GetString ("Send an instant message to a friend."); }
47
public override string Icon
49
get { return EmpathyPlugin.ChatIcon; }
52
public override IEnumerable<Type> SupportedItemTypes
55
yield return typeof (ContactItem);
59
public override bool SupportsItem (Item item)
61
if (item is ContactItem) {
62
ContactItem contact = item as ContactItem;
64
return contact.Details.Contains("is-empathy");
69
public override IEnumerable<Type> SupportedModifierItemTypes
71
get { yield return typeof (ITextItem); }
74
public override bool ModifierItemsOptional
79
public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
84
message = (modItems.First () as ITextItem).Text;
86
foreach (Item item in items) {
87
if (item is ContactItem) {
88
ContactItem contactItem = item as ContactItem;
89
string contactId = contactItem["email"];
91
if (!string.IsNullOrEmpty (message))
92
EmpathyPlugin.OpenConversationWithBuddy (contactId, message);
94
EmpathyPlugin.OpenConversationWithBuddy (contactId);