~cszikszoy/do-plugins/pastebin

« back to all changes in this revision

Viewing changes to Pidgin/src/PidginSavedStatusItemSource.cs

  • Committer: Christopher Halse Rogers
  • Date: 2008-08-24 08:44:24 UTC
  • mfrom: (244.1.2 do-plugins)
  • Revision ID: raof@ubuntu.com-20080824084424-8gp5ff6v9nku9z21
Merge in the tip of 0.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// PidginStatusItemSource.cs created with MonoDevelop
 
2
// User: alex at 12:19 PM 4/8/2008
 
3
//
 
4
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
 
5
//
 
6
 
 
7
using System;
 
8
using System.Collections.Generic;
 
9
 
 
10
using Do.Universe;
 
11
using Mono.Unix;
 
12
 
 
13
namespace Do.Addins.Pidgin
 
14
{
 
15
        public class PidginSavedStatusItemSource : IItemSource
 
16
        {
 
17
                private List<IItem> statuses;
 
18
                
 
19
                public PidginSavedStatusItemSource() {
 
20
                        statuses = new List<IItem> ();
 
21
                        //UpdateItems();
 
22
                }
 
23
                
 
24
                public string Name { get { return Catalog.GetString ("Pidgin Statuses"); } }
 
25
                public string Description { get { return Catalog.GetString ("Saved Pidgin statuses"); } }
 
26
                public string Icon {get { return "pidgin"; } }
 
27
                
 
28
                public Type[] SupportedItemTypes {
 
29
                        get {
 
30
                                return new Type[] {
 
31
                                        typeof (PidginSavedStatusItem),
 
32
                                };
 
33
                        }
 
34
                }
 
35
                
 
36
                public ICollection<IItem> Items {
 
37
                        get { return statuses; }
 
38
                }
 
39
                
 
40
                public ICollection<IItem> ChildrenOfItem (IItem item)
 
41
                {
 
42
                        return null;
 
43
                }
 
44
                
 
45
                public void UpdateItems () 
 
46
                {                       
 
47
                        Pidgin.IPurpleObject prpl;
 
48
                        int [] rawStatuses;
 
49
                        try {
 
50
                                prpl = Pidgin.GetPurpleObject ();
 
51
                                statuses.Clear ();
 
52
                                rawStatuses = prpl.PurpleSavedstatusesGetAll ();
 
53
                                foreach (int status in rawStatuses) {
 
54
                                        if (!prpl.PurpleSavedstatusIsTransient (status)) {
 
55
                                                string title, message;
 
56
                                                int id, statId;
 
57
                                                
 
58
                                                title = prpl.PurpleSavedstatusGetTitle (status);
 
59
                                                message = prpl.PurpleSavedstatusGetMessage (status);
 
60
                                                id = prpl.PurpleSavedstatusFind (title);
 
61
                                                statId = prpl.PurpleSavedstatusGetType (status);
 
62
                                                
 
63
                                                statuses.Add (new PidginSavedStatusItem (title,message,id,statId));
 
64
                                        }
 
65
                                }
 
66
                        } catch { }
 
67
                }
 
68
        }
 
69
}