~ubuntu-branches/ubuntu/wily/gnome-software/wily-proposed

« back to all changes in this revision

Viewing changes to src/plugins/gs-plugin-fedora-tagger-usage.c

  • Committer: Package Import Robot
  • Author(s): Michael Biebl
  • Date: 2015-07-22 00:03:04 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20150722000304-ctnkwytku720qft7
Tags: 3.16.4-1
* New upstream release.
* Update Build-Depends as per configure.ac:
  - Add appstream-util.
  - Add libpolkit-gobject-1-dev.
  - Bump libappstream-glib-dev to (>= 0.3.4).
  - Bump libgtk-3-dev to (>= 3.16).
* Drop hard-coded dependency on libappstream-glib7 now that the library
  provides a symbols file.
* Use dh_install's exclude (-X) functionality to not install the .a and .la
  files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <sqlite3.h>
27
27
#include <stdlib.h>
28
28
 
 
29
#include "gs-cleanup.h"
29
30
#include <gs-plugin.h>
30
31
#include <gs-utils.h>
31
32
 
50
51
void
51
52
gs_plugin_initialize (GsPlugin *plugin)
52
53
{
53
 
        GSettings *settings;
 
54
        _cleanup_object_unref_ GSettings *settings = NULL;
54
55
 
55
56
        plugin->priv = GS_PLUGIN_GET_PRIVATE (GsPluginPrivate);
56
57
 
60
61
                gs_plugin_set_enabled (plugin, FALSE);
61
62
                g_debug ("disabling '%s' as 'send-software-usage-stats' "
62
63
                         "disabled in GSettings", plugin->name);
63
 
                goto out;
 
64
                return;
64
65
        }
65
66
 
66
67
        /* check that we are running on Fedora */
67
68
        if (!gs_plugin_check_distro_id (plugin, "fedora")) {
68
69
                gs_plugin_set_enabled (plugin, FALSE);
69
70
                g_debug ("disabling '%s' as we're not Fedora", plugin->name);
70
 
                goto out;
 
71
                return;
71
72
        }
72
 
out:
73
 
        g_object_unref (settings);
74
73
}
75
74
 
76
75
/**
101
100
static gboolean
102
101
gs_plugin_setup_networking (GsPlugin *plugin, GError **error)
103
102
{
104
 
        gboolean ret = TRUE;
105
 
 
106
103
        /* already set up */
107
104
        if (plugin->priv->session != NULL)
108
 
                goto out;
 
105
                return TRUE;
109
106
 
110
107
        /* set up a session */
111
108
        plugin->priv->session = soup_session_sync_new_with_options (SOUP_SESSION_USER_AGENT,
112
109
                                                                    "gnome-software",
113
 
                                                                    SOUP_SESSION_TIMEOUT, 5000,
 
110
                                                                    SOUP_SESSION_TIMEOUT, 60,
 
111
                                                                    SOUP_SESSION_IDLE_TIMEOUT, 60,
114
112
                                                                    NULL);
115
113
        if (plugin->priv->session == NULL) {
116
 
                ret = FALSE;
117
114
                g_set_error (error,
118
115
                             GS_PLUGIN_ERROR,
119
116
                             GS_PLUGIN_ERROR_FAILED,
120
117
                             "%s: failed to setup networking",
121
118
                             plugin->name);
122
 
                goto out;
 
119
                return FALSE;
123
120
        }
124
121
        soup_session_add_feature_by_type (plugin->priv->session,
125
122
                                          SOUP_TYPE_PROXY_RESOLVER_DEFAULT);
126
 
out:
127
 
        return ret;
 
123
        return TRUE;
128
124
}
129
125
 
130
126
/**
136
132
                             gboolean is_install,
137
133
                             GError **error)
138
134
{
139
 
        SoupMessage *msg = NULL;
140
 
        gchar *data = NULL;
141
 
        gchar *error_msg = NULL;
142
 
        gchar *uri = NULL;
143
135
        guint status_code;
 
136
        _cleanup_free_ gchar *data = NULL;
 
137
        _cleanup_free_ gchar *uri = NULL;
 
138
        _cleanup_object_unref_ SoupMessage *msg = NULL;
144
139
 
145
140
        /* create the PUT data */
146
141
        uri = g_strdup_printf ("%s/api/v1/usage/%s/",
165
160
        } else {
166
161
                g_debug ("Got response: %s", msg->response_body->data);
167
162
        }
168
 
 
169
 
        g_free (error_msg);
170
 
        g_free (data);
171
 
        g_free (uri);
172
 
        if (msg != NULL)
173
 
                g_object_unref (msg);
174
163
        return TRUE;
175
164
}
176
165
 
185
174
{
186
175
        GPtrArray *sources;
187
176
        const gchar *pkgname;
188
 
        gboolean ret = TRUE;
 
177
        gboolean ret;
189
178
        guint i;
190
179
 
191
180
        /* get the package name */
192
181
        sources = gs_app_get_sources (app);
193
182
        if (sources->len == 0)
194
 
                goto out;
 
183
                return TRUE;
195
184
 
196
185
        /* ensure networking is set up */
197
 
        ret = gs_plugin_setup_networking (plugin, error);
198
 
        if (!ret)
199
 
                goto out;
 
186
        if (!gs_plugin_setup_networking (plugin, error))
 
187
                return FALSE;
200
188
 
201
189
        /* tell fedora-tagger about this package */
202
190
        for (i = 0; i < sources->len; i++) {
206
194
                                                   is_install,
207
195
                                                   error);
208
196
                if (!ret)
209
 
                        goto out;
 
197
                        return FALSE;
210
198
        }
211
 
out:
212
 
        return ret;
 
199
        return TRUE;
213
200
}
214
201
 
215
202
/**