1
// PidginChatCommand.cs (requires package libpurple-bin to use purple-remote)
3
// GNOME Do is the legal property of its developers, whose names are too numerous
4
// to list here. Please refer to the COPYRIGHT file distributed with this
5
// source distribution.
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/>.
21
using System.Threading;
22
using System.Diagnostics;
29
public class PidginChatCommand : ICommand
32
public PidginChatCommand ()
37
get { return "Chat"; }
40
public string Description {
41
get { return "Send an instant message to a friend."; }
45
get { return "internet-group-chat"; }
48
public Type[] SupportedItemTypes {
56
public Type[] SupportedModifierItemTypes {
60
public bool SupportsItem (IItem item)
65
c = item as ContactItem;
66
has_im = c.AIMs.Count > 0 ||
71
public bool SupportsModifierItemForItems (IItem[] items, IItem modItem)
76
public void Perform (IItem[] items, IItem[] modifierItems)
78
string protocol, screenname, dbus_instruction;
81
protocol = screenname = "";
82
foreach (IItem item in items) {
83
if (item is ContactItem) {
84
c = item as ContactItem;
85
if (c.Jabbers.Count > 0) {
87
screenname = c.Jabbers[0];
88
} else if (c.AIMs.Count > 0) {
90
screenname = c.AIMs[0];
93
new Thread ((ThreadStart) delegate {
94
if (!Pidgin.InstanceIsRunning ()) {
95
Process.Start ("pidgin");
96
Thread.Sleep (4 * 1000);
98
dbus_instruction = string.Format ("\"{0}:goim?screenname={1}\"", protocol, screenname);
99
Process.Start ("purple-remote", dbus_instruction);