~ubuntu-branches/ubuntu/wily/epiphany-browser/wily

« back to all changes in this revision

Viewing changes to lib/ephy-profile-utils.c

  • Committer: Package Import Robot
  • Author(s): Gustavo Noronha Silva, Jeremy Bicha, Emilio Pozuelo Monfort, Gustavo Noronha Silva
  • Date: 2012-12-10 11:40:01 UTC
  • mfrom: (1.8.8) (105.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20121210114001-42jjyg3qw3eyz00a
Tags: 3.6.1-1
[ Jeremy Bicha ]
* New upstream unstable release
* debian/control.in:
  - Bump minimum intltool to 0.50
* debian/epiphany-browser-data.install:
  - The developers no longer provide help files to install since they were
    too outdated
* Dropped upstream patches:
  - 01_email-as-user-for-password-remembering.patch
  - 13_toolbar_size_fixes.patch
* debian/watch: Watch for unstable releases.

[ Emilio Pozuelo Monfort ]
* New upstream release.
  + debian/patches/14_pkglibdir.patch:
    - Removed, applied upstream.
  + debian/control.in:
    - Update (build-)dependencies.

[ Gustavo Noronha Silva ]
* debian/control.in:
- Build-Depend on gnome-common >= 3.6, needed for the code
  coverage feature

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 */
21
21
 
22
22
#include "config.h"
 
23
#include "ephy-profile-utils.h"
23
24
 
24
25
#include "ephy-debug.h"
25
26
#include "ephy-file-helpers.h"
26
 
#include "ephy-profile-utils.h"
 
27
 
27
28
#include <libsoup/soup.h>
28
29
 
29
30
#define PROFILE_MIGRATION_FILE ".migrated"
47
48
      result = sscanf(contents, "%d", &latest);
48
49
 
49
50
    g_free (contents);
50
 
    g_free (migrated_file);
51
51
 
52
52
    if (result != 1)
53
53
      latest = 0;
 
54
  } else if (ephy_dot_dir_is_default () == FALSE) {
 
55
    /* Since version 8, we need to migrate also profile directories
 
56
       other than the default one. Profiles in such directories work
 
57
       perfectly fine without going through the first 7 migration
 
58
       steps, so it is safe to assume that any non-default profile
 
59
       directory without a migration file can be migrated starting
 
60
       from the step 8. */
 
61
    latest = 7;
54
62
  }
55
63
 
 
64
  g_free (migrated_file);
 
65
 
56
66
  return latest;
57
67
}
58
68
 
186
196
  soup_uri_free (key);
187
197
  g_free (key_str);
188
198
}
 
199
 
 
200
#define EPHY_PROFILE_MIGRATOR "ephy-profile-migrator"
 
201
 
 
202
gboolean
 
203
ephy_profile_utils_do_migration (const char *profile_directory, int test_to_run, gboolean debug)
 
204
{
 
205
  gboolean ret;
 
206
  GError *error = NULL;
 
207
  char *index = NULL, *version = NULL;
 
208
  int status;
 
209
  char *argv[6] = { EPHY_PROFILE_MIGRATOR, "-v" };
 
210
  int i = 2; /* index for argv, start filling at 2. */
 
211
  char **envp;
 
212
 
 
213
  envp = g_environ_setenv (g_get_environ (),
 
214
                           "EPHY_LOG_MODULES", "ephy-profile",
 
215
                           TRUE);
 
216
  /* To avoid breaking test-ephy-migrator */
 
217
  envp = g_environ_unsetenv (envp, EPHY_UUID_ENVVAR);
 
218
 
 
219
  argv[i++] = version = g_strdup_printf ("%d", EPHY_PROFILE_MIGRATION_VERSION);
 
220
 
 
221
  if (test_to_run != -1) {
 
222
    index = g_strdup_printf ("%d", test_to_run);
 
223
 
 
224
    argv[i++] = "-d";
 
225
    argv[i++] = index;
 
226
  }
 
227
 
 
228
  if (profile_directory != NULL) {
 
229
    argv[i++] = "-p";
 
230
    argv[i++] = (char *)profile_directory;
 
231
  }
 
232
 
 
233
  argv[i++] = NULL;
 
234
 
 
235
  if (debug)
 
236
    argv[0] = ABS_TOP_BUILD_DIR"/lib/"EPHY_PROFILE_MIGRATOR;
 
237
 
 
238
  ret = g_spawn_sync (NULL, argv, envp, G_SPAWN_SEARCH_PATH,
 
239
                      NULL, NULL, NULL, NULL,
 
240
                      &status, &error);
 
241
  g_free (index);
 
242
  g_free (version);
 
243
  g_strfreev (envp);
 
244
    
 
245
  if (error) {
 
246
    LOG ("Failed to run migrator: %s", error->message);
 
247
    g_error_free (error);
 
248
  }
 
249
 
 
250
  if (status != 0)
 
251
    ret = FALSE;
 
252
 
 
253
  return ret;
 
254
}