busybox: enable mkfs.vfat
[openembedded.git] / recipes / packagekit / files / repository-ping.patch
1 diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
2 index 5714e9f..162e6ce 100644
3 --- a/backends/dummy/pk-backend-dummy.c
4 +++ b/backends/dummy/pk-backend-dummy.c
5 @@ -777,6 +777,16 @@ backend_what_provides (PkBackend *backend, PkFilterEnum filters, PkProvidesEnum
6  }
7  
8  /**
9 + * backend_repos_ping:
10 + */ 
11 +static PkNetworkEnum
12 +backend_repos_ping (PkBackend *backend)
13 +{
14 +       pk_backend_finished (backend);
15 +       return PK_NETWORK_ENUM_UNKNOWN;
16 +}
17 +
18 +/**
19   * backend_get_packages:
20   */
21  static void
22 @@ -821,6 +831,7 @@ PK_BACKEND_OPTIONS (
23         backend_service_pack,                   /* service_pack */
24         backend_update_packages,                /* update_packages */
25         backend_update_system,                  /* update_system */
26 -       backend_what_provides                   /* what_provides */
27 +       backend_what_provides,                  /* what_provides */
28 +       backend_repos_ping                      /* repos_ping */
29  );
30  
31 diff --git a/backends/opkg/pk-backend-opkg.c b/backends/opkg/pk-backend-opkg.c
32 index 02966c9..a20769f 100644
33 --- a/backends/opkg/pk-backend-opkg.c
34 +++ b/backends/opkg/pk-backend-opkg.c
35 @@ -705,6 +705,16 @@ backend_get_details (PkBackend *backend, const gchar *package_id)
36         pk_backend_thread_create (backend, backend_get_details_thread);
37  }
38  
39 +static PkNetworkEnum 
40 +backend_repos_ping (PkBackend *backend)
41 +{
42 +       int opkg_ret = opkg_repository_accessibility_check(opkg);
43 +       pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
44 +       pk_backend_finished (backend);
45 +       pk_debug("opkg repos_ping ret = %d\n", opkg_ret);
46 +       return opkg_ret ? PK_NETWORK_ENUM_OFFLINE : PK_NETWORK_ENUM_ONLINE;
47 +}
48 +
49  PK_BACKEND_OPTIONS (
50         "opkg",                                 /* description */
51         "Thomas Wood <thomas@openedhand.com>",  /* author */
52 @@ -737,6 +747,7 @@ PK_BACKEND_OPTIONS (
53         NULL,                                   /* service_pack */
54         backend_update_packages,                /* update_packages */
55         backend_update_system,                  /* update_system */
56 -       NULL                                    /* what_provides */
57 +       NULL,                                   /* what_provides */
58 +       backend_repos_ping                      /* repos_ping */
59  );
60  
61 diff --git a/backends/test/pk-backend-test-dbus.c b/backends/test/pk-backend-test-dbus.c
62 index 76686dc..9ef733d 100644
63 --- a/backends/test/pk-backend-test-dbus.c
64 +++ b/backends/test/pk-backend-test-dbus.c
65 @@ -105,6 +105,7 @@ PK_BACKEND_OPTIONS (
66         NULL,                                   /* service_pack */
67         NULL,                                   /* update_packages */
68         NULL,                                   /* update_system */
69 -       NULL                                    /* what_provides */
70 +       NULL,                                   /* what_provides */
71 +       NULL                                    /* repos_ping */
72  );
73  
74 diff --git a/backends/test/pk-backend-test-fail.c b/backends/test/pk-backend-test-fail.c
75 index b429c1b..a70564a 100644
76 --- a/backends/test/pk-backend-test-fail.c
77 +++ b/backends/test/pk-backend-test-fail.c
78 @@ -275,6 +275,7 @@ PK_BACKEND_OPTIONS (
79         NULL,                                   /* service_pack */
80         backend_update_packages,                /* update_packages */
81         backend_update_system,                  /* update_system */
82 -       NULL                                    /* what_provides */
83 +       NULL,                                   /* what_provides */
84 +       NULL                                    /* repos_ping */
85  );
86  
87 diff --git a/backends/test/pk-backend-test-nop.c b/backends/test/pk-backend-test-nop.c
88 index 3526fa5..a715b9b 100644
89 --- a/backends/test/pk-backend-test-nop.c
90 +++ b/backends/test/pk-backend-test-nop.c
91 @@ -55,6 +55,7 @@ PK_BACKEND_OPTIONS (
92         NULL,                                   /* service_pack */
93         NULL,                                   /* update_package */
94         NULL,                                   /* update_system */
95 -       NULL                                    /* what_provides */
96 +       NULL,                                   /* what_provides */
97 +       NULL                                    /* repos_ping */
98  );
99  
100 diff --git a/backends/test/pk-backend-test-spawn.c b/backends/test/pk-backend-test-spawn.c
101 index 584f44c..424c7d4 100644
102 --- a/backends/test/pk-backend-test-spawn.c
103 +++ b/backends/test/pk-backend-test-spawn.c
104 @@ -96,6 +96,7 @@ PK_BACKEND_OPTIONS (
105         NULL,                                   /* service_pack */
106         NULL,                                   /* update_package */
107         NULL,                                   /* update_system */
108 -       NULL                                    /* what_provides */
109 +       NULL,                                   /* what_provides */
110 +       NULL                                    /* repos_ping */
111  );
112  
113 diff --git a/backends/test/pk-backend-test-succeed.c b/backends/test/pk-backend-test-succeed.c
114 index c046c1d..116d4fe 100644
115 --- a/backends/test/pk-backend-test-succeed.c
116 +++ b/backends/test/pk-backend-test-succeed.c
117 @@ -304,6 +304,16 @@ backend_what_provides (PkBackend *backend, PkFilterEnum filters, PkProvidesEnum
118  }
119  
120  /**
121 + * backend_repos_ping
122 + */ 
123 +static PkNetworkEnum
124 +backend_repos_ping (PkBackend *backend)
125 +{
126 +       pk_backend_finished(backend);
127 +       return PK_NETWORK_ENUM_UNKNOWN;
128 +}
129 +
130 +/**
131   * backend_get_packages:
132   */
133  static void
134 @@ -344,6 +354,7 @@ PK_BACKEND_OPTIONS (
135         backend_service_pack,                   /* service_pack */
136         backend_update_packages,                /* update_packages */
137         backend_update_system,                  /* update_system */
138 -       backend_what_provides                   /* what_provides */
139 +       backend_what_provides,                  /* what_provides */
140 +       backend_repos_ping                      /* repos_ping */
141  );
142  
143 diff --git a/backends/test/pk-backend-test-thread.c b/backends/test/pk-backend-test-thread.c
144 index 46ee862..a00cd26 100644
145 --- a/backends/test/pk-backend-test-thread.c
146 +++ b/backends/test/pk-backend-test-thread.c
147 @@ -168,6 +168,7 @@ PK_BACKEND_OPTIONS (
148         NULL,                                   /* service_pack */
149         NULL,                                   /* update_package */
150         NULL,                                   /* update_system */
151 -       NULL                                    /* what_provides */
152 +       NULL,                                   /* what_provides */
153 +       NULL                                    /* repos_ping */
154  );
155  
156 diff --git a/src/pk-backend-internal.h b/src/pk-backend-internal.h
157 index 2bffaff..f46159c 100644
158 --- a/src/pk-backend-internal.h
159 +++ b/src/pk-backend-internal.h
160 @@ -71,6 +71,8 @@ PkGroupEnum    pk_backend_get_groups                  (PkBackend      *backend);
161  PkFilterEnum    pk_backend_get_filters                 (PkBackend      *backend);
162  PkRoleEnum      pk_backend_get_actions                 (PkBackend      *backend);
163  
164 +PkNetworkEnum    pk_backend_repos_ping                 (PkBackend      *backend);
165 +
166  G_END_DECLS
167  
168  #endif /* __PK_BACKEND_INTERNAL_H */
169 diff --git a/src/pk-backend.c b/src/pk-backend.c
170 index 6efa55e..32ff276 100644
171 --- a/src/pk-backend.c
172 +++ b/src/pk-backend.c
173 @@ -165,6 +165,23 @@ pk_backend_get_filters (PkBackend *backend)
174  }
175  
176  /**
177 + */
178 +PkNetworkEnum    
179 +pk_backend_repos_ping (PkBackend      *backend) 
180 +{
181 +       g_return_val_if_fail (PK_IS_BACKEND (backend), PK_NETWORK_ENUM_UNKNOWN);
182 +       g_return_val_if_fail (backend->priv->locked != FALSE, PK_NETWORK_ENUM_UNKNOWN);
183 +
184 +       /* not compulsory */
185 +       if (backend->desc->repos_ping == NULL) {
186 +               return PK_NETWORK_ENUM_UNKNOWN;
187 +       }
188 +
189 +       pk_debug("Runing backend's repos_ping\n");
190 +       return backend->desc->repos_ping (backend);
191 +}
192 +
193 +/**
194   * pk_backend_get_actions:
195   **/
196  PkRoleEnum
197 diff --git a/src/pk-backend.h b/src/pk-backend.h
198 index a7ba754..1f41c6c 100644
199 --- a/src/pk-backend.h
200 +++ b/src/pk-backend.h
201 @@ -258,6 +258,7 @@ typedef struct {
202                                                          PkFilterEnum    filters,
203                                                          PkProvidesEnum  provides,
204                                                          const gchar    *search);
205 +       PkNetworkEnum   (*repos_ping)                   (PkBackend      *backend);
206         gpointer        padding[10];
207  } PkBackendDesc;
208  
209 @@ -266,7 +267,7 @@ typedef struct {
210                            get_update_detail, get_updates, install_files, install_packages,             \
211                            install_signature, refresh_cache, remove_packages, repo_enable,              \
212                            repo_set_data, resolve, rollback, search_details, search_file, search_group, \
213 -                          search_name, service_pack, update_packages, update_system, what_provides)    \
214 +                          search_name, service_pack, update_packages, update_system, what_provides, repos_ping)        \
215         G_MODULE_EXPORT const PkBackendDesc pk_backend_desc = {                                         \
216                 description,            \
217                 author,                 \
218 @@ -300,6 +301,7 @@ typedef struct {
219                 update_packages,        \
220                 update_system,          \
221                 what_provides,          \
222 +               repos_ping,             \
223                 {0}                     \
224         }
225  
226 diff --git a/src/pk-engine.c b/src/pk-engine.c
227 index 14ecf41..f9359f2 100644
228 --- a/src/pk-engine.c
229 +++ b/src/pk-engine.c
230 @@ -279,8 +279,11 @@ pk_engine_get_network_state (PkEngine *engine, gchar **state, GError **error)
231  {
232         PkNetworkEnum network;
233         g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
234 -       /* get the network state */
235 -       network = pk_network_get_network_state (engine->priv->network);
236 +       network = pk_backend_repos_ping(engine->priv->backend);
237 +       if (network == PK_NETWORK_ENUM_UNKNOWN)  {
238 +               /* get the network state */
239 +               network = pk_network_get_network_state (engine->priv->network);
240 +       }
241         *state = g_strdup (pk_network_enum_to_text (network));
242         return TRUE;
243  }