~cszikszoy/do-plugins/pastebin

« back to all changes in this revision

Viewing changes to Pidgin/src/PidginAccountItemSource.cs

  • Committer: David Siegel
  • Date: 2008-06-02 16:09:11 UTC
  • Revision ID: dave@x-20080602160911-5bc56q3okv27pg7y
Added GNOME Terminal plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// PidginAccountItemSource.cs
 
2
// 
 
3
// Copyright (C) 2008 [name of author]
 
4
//
 
5
// This program 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
// This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
//
 
18
 
 
19
using System;
 
20
using System.Collections.Generic;
 
21
 
 
22
using Do.Universe;
 
23
 
 
24
namespace Do.Addins.Pidgin
 
25
{
 
26
        public class PidginAccountItemSource : IItemSource
 
27
        {
 
28
                List<IItem> items;
 
29
                public PidginAccountItemSource ()
 
30
                {
 
31
                        items = new List<IItem> ();
 
32
                        UpdateItems ();
 
33
                }
 
34
                
 
35
                public string Name { get { return "Pidgin Accounts"; } }
 
36
                public string Description { get { return "Available Pidgin IM Accounts"; } }
 
37
                public string Icon { get { return "pidgin"; } }
 
38
                
 
39
                public Type [] SupportedItemTypes {
 
40
                        get {
 
41
                                return new Type [] {
 
42
                                        typeof (PidginAccountItem),
 
43
                                };
 
44
                        }
 
45
                }
 
46
                
 
47
                public ICollection<IItem> Items {
 
48
                        get { return items; }
 
49
                }
 
50
                
 
51
                public ICollection<IItem> ChildrenOfItem (IItem item)
 
52
                {
 
53
                        return null;
 
54
                }
 
55
                
 
56
                public void UpdateItems ()
 
57
                {
 
58
                        Pidgin.IPurpleObject prpl;
 
59
                        prpl = Pidgin.GetPurpleObject ();
 
60
                        string name, proto;
 
61
                        
 
62
                        items.Clear ();
 
63
                        try {
 
64
                                foreach (int account in prpl.PurpleAccountsGetAll ()) {
 
65
                                        proto = prpl.PurpleAccountGetProtocolName (account);
 
66
                                        name = prpl.PurpleAccountGetUsername (account);
 
67
                                        items.Add (new PidginAccountItem (name, proto, account));
 
68
                                }
 
69
                        } catch { 
 
70
                        }
 
71
                }
 
72
        }
 
73
}