~ubuntu-branches/ubuntu/oneiric/docky/oneiric

« back to all changes in this revision

Viewing changes to StandardPlugins/GMail/src/GMailAtom.cs

  • Committer: Bazaar Package Importer
  • Author(s): Rico Tzschichholz
  • Date: 2010-07-01 21:21:50 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20100701212150-1dqehqxey8rrvtlo
Tags: 2.0.5-1
* New upstream release 2.0.5 "Be proud of your dock",
  changes include:
  + remove --debug flag from launcher for lower memory usage
  + update the about dialog credits to list documenters and make translation 
    tab easier to read
  + change url in about dialog to the launchpad project page
  + Window-Matching
    - fix for applications commandline
    - properly match qt creator (LP: #594814)
    - prefer local over global launchers (LP: #588073) (LP: #592841)
    - match prefix for gksudo (LP: #516433)
    - fix nautilus items showing active indicator when desktop 
      is focused (LP: #487113)
    - fix matching wine apps that use a prefixed launcher (LP: #596092)
  + Memory Leaks
    - dispose of calendar painter when the clock item is disposed
    - fix leak in AutoHideManager
    - several fixes using Cairo.Context.Target and Pango.Layout
    - fix leak in PagingPainters
    - fix leak in recursive file-deletion
    - fix leaking SeparatorItems, WnckDockItems
    - fix leaks with FileEmblems
    - fix Pixbuf related leaks
    - fix some leaks regarding FileMonitors
    - fix leaks regarding Tiles and AbtractTileObjects
    - fix leaking Glib.FileAdapter caused by unreferenced Action in 
      FileDockItem
  + Handle invalid desktopfile entry and UriFormatException in 
    FileApplicationProvider (LP: #595921)
  + fix potential crash for invalid HelperMetadata
  + handle drops correctly
  + fix handling of Helpers in HelperService
  + make the sliders in preferences behave better
  + fix drawing of rotated items
  + fix HoveredItem click-position
  + avoids fatal errors on console when loading embedded icons when no 
    height or width is specified and when dock items have a null Icon
  + fix icon theme change not refreshing the dock icons (LP: #590205)
  + fix SVG rendering bug
  + fix iconsize temporarily getting large when adding to full dock 
    (LP: #579576)
  + fix the 'crash in PinToDock' (LP: #588073)
  + make 3d background height more consistent and a tad larger (LP: #503038)
  + fix dragging multiple files to a folder on the dock, which caused 
    a crash and data corruption (LP: #579049)
  + don't request animations if urgent state is removed from a window and 
    fix glow location (LP: #596422)
  + fix window previews being offset (LP: #495065)
  + fix broken zoom after shrinking icon size (LP: #598924)
  + fix problem with hovers still visible when painters show
  + fix displaying default icon in place of missing file emblem (LP: #534651)
  + fix crash when gconf key for menus_have_icons is not set (LP: #573751)
  + make sure painters fit on screen (LP: #589978)
  + fix icon minimize animations not working immediately for some newly 
    opened windows
  + don't dispose our static DockyItem
  + fix CurrentDesktopOnly not working when dragging a window across desktops
    (LP: #600290)
  + GMail: 
    - fix thread-guards and remove deprecated code
    - fix problem with feeds that don't have an author entry (LP: #595530)
  + NPR: fix bug where removing your last NPR station unloaded the docklet
    and fix station icon
  + NetworkManager: fix crash caused when NM goes away
    and fix icons and add another fallback icon (LP: #588581)
  + Mounter:
    - fixed some leaks
    - only remove mounted items if they were successfully unmounted 
      (LP: #597637)
    - fix duplicate icons showing in mounter (LP: #525306)
  + Weather: fix feels like temp showing incorrect for metric (LP: #597670)
  + RecentDocuments: 
    - fixed some leaks
    - fix sensitivity of recent docs clear menu item - even if docky shows 
      the list as empty does not mean it cant be cleared
* debian/patches/01_use_cli_for_wrapper.patch:
  + patch wrapper script to meet the Debian CLI Policy
* debian/control:
  + Bump Standards version to 3.9.0 (no changes needed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//  
2
2
// Copyright (C) 2009 Robert Dyer
 
3
// Copyright (C) 2010 Robert Dyer
3
4
// 
4
5
// This program is free software: you can redistribute it and/or modify
5
6
// it under the terms of the GNU General Public License as published by
30
31
using Docky.Services;
31
32
using Docky.Widgets;
32
33
 
33
 
// disable the warning message about System.Net.ServicePointManager.CertificatePolicy being obsolete
34
 
#pragma warning disable 618
35
 
 
36
34
namespace GMail
37
35
{
38
36
        public enum GMailState
43
41
                Error
44
42
        }
45
43
        
46
 
        // remove when ServicePointManager.ServerCertificateValidationCallback implemented in mono
47
 
        class CertHandler : System.Net.ICertificatePolicy
48
 
        {
49
 
                public bool CheckValidationResult(System.Net.ServicePoint srvPoint, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Net.WebRequest request, int certificateProblem)
50
 
                {
51
 
                return true;
52
 
                }
53
 
        } 
54
 
        
55
44
        public struct UnreadMessage
56
45
        {
57
46
                public string Topic;
84
73
                public int NewCount { get; protected set; }
85
74
                
86
75
                public bool HasUnread {
87
 
                        get {
88
 
                                return UnreadCount > 0 && State != GMailState.Error;
89
 
                        }
 
76
                        get { return UnreadCount > 0 && State != GMailState.Error; }
90
77
                }
91
78
 
92
79
                bool IsChecking { get; set; }
95
82
                {
96
83
                        CurrentLabel = label;
97
84
                        State = GMailState.ManualReload;
 
85
                        
 
86
                        ServicePointManager.ServerCertificateValidationCallback += delegate { return true; };
 
87
                        
98
88
                        DockServices.System.ConnectionStatusChanged += HandleNeedReset;
99
 
                        // this is not implemented in mono yet
100
 
//                      ServicePointManager.ServerCertificateValidationCallback +=
101
 
//                              (sender, cert, chain, errors) => { return true; };
102
89
                        ResetNeeded += HandleNeedReset;
103
90
                }
104
91
                
105
92
                Thread checkerThread;
106
93
                
107
 
                public void Dispose ()
108
 
                {
109
 
                        DockServices.System.ConnectionStatusChanged -= HandleNeedReset;
110
 
                        ResetNeeded -= HandleNeedReset;
111
 
                }
112
 
                
113
94
                void HandleNeedReset (object o, EventArgs state)
114
95
                {
115
96
                        ResetTimer ();
118
99
                List<UnreadMessage> messages = new List<UnreadMessage> ();
119
100
                
120
101
                public IEnumerable<UnreadMessage> Messages {
121
 
                        get {
122
 
                                return messages as IEnumerable<UnreadMessage>;
123
 
                        }
 
102
                        get { return messages as IEnumerable<UnreadMessage>; }
124
103
                }
125
104
                
126
105
                uint UpdateTimer { get; set; }
146
125
                {
147
126
                        StopTimer ();
148
127
                        
149
 
                        if (!DockServices.System.NetworkConnected)
150
 
                                return;
151
 
                        
152
 
                        if (!IsChecking) {
153
 
                                IsChecking = true;
154
 
                                CheckGMail ();
155
 
                        }
 
128
                        CheckGMail ();
156
129
                        
157
130
                        UpdateTimer = GLib.Timeout.Add (GMailPreferences.RefreshRate * 60 * 1000, () => { 
158
 
                                if (!IsChecking && DockServices.System.NetworkConnected) 
159
 
                                        CheckGMail (); 
 
131
                                CheckGMail (); 
160
132
                                return true; 
161
133
                        });
162
134
                }
180
152
                                request.Credentials = new NetworkCredential (username, password);
181
153
                                if (DockServices.System.UseProxy)
182
154
                                        request.Proxy = DockServices.System.Proxy;
183
 
                                // FIXME: remove when ServicePointManager.ServerCertificateValidationCallback implemented in mono
184
 
                                System.Net.ServicePointManager.CertificatePolicy = new CertHandler ();
185
155
                                
186
156
                                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse ())
187
157
                                        try { } finally {
196
166
                
197
167
                void CheckGMail ()
198
168
                {
 
169
                        if (IsChecking || !DockServices.System.NetworkConnected)
 
170
                                return;
 
171
                        
199
172
                        string password = GMailPreferences.Password;
200
173
                        if (string.IsNullOrEmpty (GMailPreferences.User) || string.IsNullOrEmpty (password)) {
201
174
                                Gtk.Application.Invoke (delegate {
204
177
                                return;
205
178
                        }
206
179
                        
 
180
                        IsChecking = true;
 
181
                        
207
182
                        checkerThread = DockServices.System.RunOnThread (() => {
208
183
                                try {
209
184
                                        Gtk.Application.Invoke (delegate { OnGMailChecking (); });
223
198
                                        request.Credentials = new NetworkCredential (GMailPreferences.User, password);
224
199
                                        if (DockServices.System.UseProxy)
225
200
                                                request.Proxy = DockServices.System.Proxy;
226
 
                                        // FIXME remove when ServicePointManager.ServerCertificateValidationCallback implemented in mono
227
 
                                        System.Net.ServicePointManager.CertificatePolicy = new CertHandler ();
228
201
                                        
229
202
                                        XmlDocument xml = new XmlDocument ();
230
203
                                        XmlNamespaceManager nsmgr = new XmlNamespaceManager (xml.NameTable);
282
255
                                        messages = tmp;
283
256
                                        Gtk.Application.Invoke (delegate { OnGMailChecked (); });
284
257
                                } catch (ThreadAbortException) {
285
 
                                        // do nothing
 
258
                                        Log<GMailAtom>.Debug ("Stoping Atom thread");
286
259
                                } catch (NullReferenceException) {
287
260
                                        Gtk.Application.Invoke (delegate {
288
261
                                                OnGMailFailed (Catalog.GetString ("Feed Error"));
309
282
                                        Gtk.Application.Invoke (delegate {
310
283
                                                OnGMailFailed (Catalog.GetString ("General Error"));
311
284
                                        });
 
285
                                } finally {
 
286
                                        IsChecking = false;
312
287
                                }
313
288
                        });
314
289
                }
315
290
                
316
291
                void OnGMailChecked ()
317
292
                {
318
 
                        IsChecking = false;
319
293
                        State = GMailState.Normal;
320
294
                        if (GMailChecked != null)
321
295
                                GMailChecked (null, EventArgs.Empty);
323
297
                
324
298
                void OnGMailChecking ()
325
299
                {
326
 
                        IsChecking = true;
327
300
                        if (State != GMailState.ManualReload)
328
301
                                State = GMailState.Reloading;
329
302
                        if (GMailChecking != null)
332
305
                
333
306
                void OnGMailFailed (string error)
334
307
                {
335
 
                        IsChecking = false;
336
308
                        State = GMailState.Error;
337
309
                        if (GMailFailed != null)
338
310
                                GMailFailed (null, new GMailErrorArgs (error));
339
311
                }
 
312
                
 
313
                public void Dispose ()
 
314
                {
 
315
                        StopTimer ();
 
316
                        DockServices.System.ConnectionStatusChanged -= HandleNeedReset;
 
317
                        ResetNeeded -= HandleNeedReset;
 
318
                }
340
319
        }
341
320
}