~ubuntu-branches/debian/sid/docky/sid

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Mirco Bauer
  • Date: 2010-09-05 14:06:40 UTC
  • mfrom: (1.1.6 upstream) (9.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20100905140640-im9ljgthb3e1lfi7
Tags: 2.0.6-2
Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
153
153
                                if (DockServices.System.UseProxy)
154
154
                                        request.Proxy = DockServices.System.Proxy;
155
155
                                
156
 
                                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse ())
 
156
                                using (HttpWebResponse response = (HttpWebResponse) request.GetResponse ())
157
157
                                        try { } finally {
158
158
                                                response.Close ();
159
159
                                        }
160
160
                        } catch (WebException e) {
161
 
                                if (e.Message.IndexOf ("401") != -1) return false;
 
161
                                if (e.Message.IndexOf ("401") != -1)
 
162
                                        Log<GMailAtom>.Error ("Invalid username: {0}", e.Message);
 
163
                                else
 
164
                                        Log<GMailAtom>.Error ("Network error: {0}", e.Message);
 
165
                                HttpWebResponse response = (HttpWebResponse) e.Response;
 
166
                                Log<GMailAtom>.Debug ("Response status: {0} - {1}", response.StatusCode, response.StatusDescription);
 
167
                                
 
168
                                return false;
162
169
                        } catch (Exception) { }
163
170
                        
164
171
                        return true;
219
226
                                                
220
227
                                                UnreadMessage message = new UnreadMessage ();
221
228
                                                message.Topic = HttpUtility.HtmlDecode (item.SelectSingleNode ("atom:title", nsmgr).InnerText);
222
 
                                                message.FromName = HttpUtility.HtmlDecode (item.SelectSingleNode ("atom:author/atom:name", nsmgr).InnerText);
223
 
                                                message.FromEmail = item.SelectSingleNode ("atom:author/atom:email", nsmgr).InnerText;
 
229
                                                // apparently random mailing lists can have no author information - bug 595530
 
230
                                                XmlNode from = item.SelectSingleNode ("atom:author/atom:name", nsmgr);
 
231
                                                if (from != null)
 
232
                                                        message.FromName = HttpUtility.HtmlDecode (from.InnerText);
 
233
                                                from = item.SelectSingleNode ("atom:author/atom:email", nsmgr);
 
234
                                                if (from != null)
 
235
                                                        message.FromEmail = from.InnerText;
224
236
                                                message.From = message.FromName + " <" + message.FromEmail + ">";
225
237
                                                try {
226
238
                                                        message.SendDate = DateTime.Parse (item.SelectSingleNode ("atom:modified", nsmgr).InnerText);
256
268
                                        Gtk.Application.Invoke (delegate { OnGMailChecked (); });
257
269
                                } catch (ThreadAbortException) {
258
270
                                        Log<GMailAtom>.Debug ("Stoping Atom thread");
259
 
                                } catch (NullReferenceException) {
 
271
                                } catch (NullReferenceException e) {
 
272
                                        Log<GMailAtom>.Debug (e.Message);
260
273
                                        Gtk.Application.Invoke (delegate {
261
274
                                                OnGMailFailed (Catalog.GetString ("Feed Error"));
262
275
                                        });
263
 
                                } catch (XmlException) {
 
276
                                } catch (XmlException e) {
 
277
                                        Log<GMailAtom>.Error ("Error parsing XML: {0}", e.Message);
264
278
                                        Gtk.Application.Invoke (delegate {
265
279
                                                OnGMailFailed (Catalog.GetString ("Feed Error"));
266
280
                                        });
267
281
                                } catch (WebException e) {
 
282
                                        Log<GMailAtom>.Error ("Network error: {0}", e.Message);
268
283
                                        if (e.Message.IndexOf ("401") != -1)
269
284
                                                Gtk.Application.Invoke (delegate {
270
285
                                                        OnGMailFailed (Catalog.GetString ("Invalid Username"));
273
288
                                                Gtk.Application.Invoke (delegate {
274
289
                                                        OnGMailFailed (Catalog.GetString ("Network Error"));
275
290
                                                });
 
291
                                        HttpWebResponse response = (HttpWebResponse) e.Response;
 
292
                                        Log<GMailAtom>.Debug ("Response status: {0} - {1}", response.StatusCode, response.StatusDescription);
276
293
                                } catch (ObjectDisposedException) {
277
294
                                        Gtk.Application.Invoke (delegate {
278
295
                                                OnGMailFailed (Catalog.GetString ("Network Error"));
279
296
                                        });
280
297
                                } catch (Exception e) {
281
 
                                        Log<GMailAtom>.Error (e.ToString ());
 
298
                                        Log<GMailAtom>.Error (e.Message);
282
299
                                        Gtk.Application.Invoke (delegate {
283
300
                                                OnGMailFailed (Catalog.GetString ("General Error"));
284
301
                                        });