~ubuntu-branches/ubuntu/precise/gnome-do/precise-backports

« back to all changes in this revision

Viewing changes to debian/patches/03_fix_gks_crashers.dpatch

  • Committer: Christopher James Halse Rogers
  • Date: 2010-04-14 04:52:32 UTC
  • Revision ID: christopher.halse.rogers@canonical.com-20100414045232-p479l309h3xvkn8l
Tags: 0.8.3.1+dfsg-1ubuntu1
* debian/patches/03_fix_gks_crashers.dpatch:
  + Proxy keyring calls to the GTK main thread.  Prevents libgnome-keyring
    taking down Do with an assert().  (LP: #55137)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh /usr/share/dpatch/dpatch-run
 
2
## 03_fix_gks_crahers.dpatch by Christopher James Halse Rogers <raof@ubuntu.com>
 
3
##
 
4
## All lines beginning with `## DP:' are a description of the patch.
 
5
## DP: No description.
 
6
 
 
7
@DPATCH@
 
8
diff -urNad fix-lp555137~/Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/GnomeKeyringSecurePreferencesService.cs fix-lp555137/Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/GnomeKeyringSecurePreferencesService.cs
 
9
--- fix-lp555137~/Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/GnomeKeyringSecurePreferencesService.cs   2010-04-14 11:42:39.000000000 +1000
 
10
+++ fix-lp555137/Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/GnomeKeyringSecurePreferencesService.cs    2010-04-14 12:27:33.252245271 +1000
 
11
@@ -20,6 +20,7 @@
 
12
 
 
13
 using System;
 
14
 using System.Collections;
 
15
+using System.Threading;
 
16
 using System.ComponentModel;
 
17
 
 
18
 using Mono.Unix;
 
19
@@ -61,52 +62,76 @@
 
20
                public bool Set (string key, string val)
 
21
                {
 
22
                        Hashtable keyData;
 
23
-                       
 
24
+
 
25
                        if (!Ring.Available) {
 
26
                                Log.Error (KeyringUnavailableMessage);
 
27
                                return false;
 
28
                        }
 
29
 
 
30
                        keyData = new Hashtable ();
 
31
-                       keyData [AbsolutePathForKey (key)] = key;
 
32
-                       
 
33
-                       try {
 
34
-                               Ring.CreateItem (Ring.GetDefaultKeyring (), ItemType.GenericSecret, AbsolutePathForKey (key), keyData, val.ToString (), true);
 
35
-                       } catch (KeyringException e) {
 
36
-                               Log.Error (ErrorSavingMessage, key, e.Message);
 
37
-                               Log.Debug (e.StackTrace);
 
38
+                       keyData[AbsolutePathForKey (key)] = key;
 
39
+
 
40
+                       bool success = false;
 
41
+                       AutoResetEvent completed = new AutoResetEvent (false);
 
42
+
 
43
+                       Services.Application.RunOnMainThread (delegate {
 
44
+                               try {
 
45
+                                       Ring.CreateItem (Ring.GetDefaultKeyring (), ItemType.GenericSecret, AbsolutePathForKey (key), keyData, val.ToString (), true);
 
46
+                                       success = true;
 
47
+                               } catch (KeyringException e) {
 
48
+                                       Log.Error (ErrorSavingMessage, key, e.Message);
 
49
+                                       Log.Debug (e.StackTrace);
 
50
+                                       success = false;
 
51
+                               } finally {
 
52
+                                       completed.Set ();
 
53
+                               }
 
54
+                       });
 
55
+                       if (!completed.WaitOne (200)) {
 
56
                                return false;
 
57
                        }
 
58
-
 
59
-                       return true;
 
60
+                       return success;
 
61
                }
 
62
 
 
63
                public bool TryGet (string key, out string val)
 
64
                {
 
65
                        Hashtable keyData;
 
66
-                       
 
67
-                       val = "";
 
68
-                       
 
69
+
 
70
+                       string secret = "";
 
71
+
 
72
                        if (!Ring.Available) {
 
73
                                Log.Error (KeyringUnavailableMessage);
 
74
+                               val = "";
 
75
                                return false;
 
76
                        }
 
77
 
 
78
                        keyData = new Hashtable ();
 
79
-                       keyData [AbsolutePathForKey (key)] = key;
 
80
+                       keyData[AbsolutePathForKey (key)] = key;
 
81
                        
 
82
-                       try {
 
83
-                               foreach (ItemData item in Ring.Find (ItemType.GenericSecret, keyData)) {
 
84
-                                       if (!item.Attributes.ContainsKey (AbsolutePathForKey (key))) continue;
 
85
+                       bool success = false;
 
86
+                       AutoResetEvent completed = new AutoResetEvent (false);
 
87
 
 
88
-                                       val = item.Secret;
 
89
-                                       return true;
 
90
+                       Services.Application.RunOnMainThread (delegate {
 
91
+                               try {
 
92
+                                       foreach (ItemData item in Ring.Find (ItemType.GenericSecret, keyData)) {
 
93
+                                               if (!item.Attributes.ContainsKey (AbsolutePathForKey (key)))
 
94
+                                                       continue;
 
95
+
 
96
+                                               secret = item.Secret;
 
97
+                                               success = true;
 
98
+                                               break;
 
99
+                                       }
 
100
+                               } catch (KeyringException) {
 
101
+                                       Log.Debug (KeyNotFoundMessage, AbsolutePathForKey (key));
 
102
+                                       success = false;
 
103
+                               } finally {
 
104
+                                       completed.Set ();
 
105
                                }
 
106
-                       } catch (KeyringException) {
 
107
-                               Log.Debug (KeyNotFoundMessage, AbsolutePathForKey (key));
 
108
+                       });
 
109
+                       if (!completed.WaitOne (200)) {
 
110
+                               success = false;
 
111
                        }
 
112
-
 
113
-                       return false;
 
114
+                       val = secret;
 
115
+                       return success;
 
116
                }
 
117
                
 
118
                #endregion