1
// EmpathyAccountItemSource.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/>.
22
using System.Collections.Generic;
27
namespace EmpathyPlugin
29
public class EmpathyAccountItemSource : ItemSource
34
public EmpathyAccountItemSource ()
36
items = new List<Item> ();
39
public override string Name
41
get { return AddinManager.CurrentLocalizer.GetString ("Empathy Accounts"); }
44
public override string Description
46
get { return AddinManager.CurrentLocalizer.GetString ("Available Empathy IM Accounts"); }
49
public override string Icon
51
get { return "empathy"; }
54
public override IEnumerable<Type> SupportedItemTypes
57
yield return typeof (EmpathyAccountItem);
58
yield return typeof (IApplicationItem);
59
yield return typeof (EmpathyBrowseAccountItem);
63
public override IEnumerable<Item> ChildrenOfItem (Item item)
65
if (EmpathyPlugin.IsTelepathy (item))
67
yield return new EmpathyBrowseAccountItem ();
69
else if (item is EmpathyBrowseAccountItem)
71
foreach (EmpathyAccountItem account in items)
78
public override IEnumerable<Item> Items
83
public override void UpdateItems ()
85
if (EmpathyPlugin.IsInstanceRunning ()) {
88
foreach (Account account in EmpathyPlugin.GetAllAccounts ()) {
89
items.Add (new EmpathyAccountItem (account));
91
} catch (Exception e) {
92
Log<EmpathyAccountItemSource>.Error ("Could not get Empathy accounts: {0}", e.Message);
93
Log<EmpathyAccountItemSource>.Debug (e.StackTrace);