~ubuntu-branches/ubuntu/vivid/libunity-webapps/vivid

« back to all changes in this revision

Viewing changes to src/webapps-service/unity-webapps-service.c

  • Committer: Ken VanDine
  • Author(s): Michael Terry
  • Date: 2012-09-21 23:41:19 UTC
  • mfrom: (260.241.90)
  • Revision ID: ken.vandine@canonical.com-20120921234119-nswef23t15c2hol6
Tags: 2.3.8-0ubuntu2
* debian/patches/fix-race.patch:
  - Fix race condition, preventing the amazon icon from hiding
    immediately sometimes (hiding and popping up is a separate issue)

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
 
45
45
#include "unity-webapps-app-db.h"
46
46
 
 
47
#define UNITY_WEBAPPS_SCHEMA_NAME "com.canonical.unity.webapps"
 
48
#define INDEX_UPDATE_TIME_KEY "index-update-time"
 
49
#define MINIMUM_UPDATE_TIME 60*60
 
50
 
47
51
static GMainLoop *mainloop = NULL;
48
52
 
49
53
guint context_ready_signal_subscription;
57
61
  };
58
62
 
59
63
static void
 
64
unity_webapps_service_spawn_index_updater ()
 
65
{
 
66
  GError *error;
 
67
  
 
68
  error = NULL;
 
69
  g_spawn_command_line_async ("ubuntu-webapps-update-index", &error);
 
70
  
 
71
  if (error != NULL)
 
72
    {
 
73
      g_critical ("Failed to spawn ubuntu-webapps-update-index: %s", error->message);
 
74
      g_error_free (error);
 
75
    }
 
76
 
 
77
}
 
78
 
 
79
static void
60
80
unity_webapps_service_emit_context_appeared (GDBusConnection *connection,
61
81
                                             const gchar *context)
62
82
{
1359
1379
  return;  
1360
1380
}
1361
1381
 
 
1382
static gboolean
 
1383
indexer_spawn_callback (gpointer user_data)
 
1384
{
 
1385
  unity_webapps_service_spawn_index_updater ();
 
1386
  return TRUE;
 
1387
}
 
1388
 
 
1389
static gint
 
1390
unity_webapps_service_get_index_updater_timeout ()
 
1391
{
 
1392
  GSettings *settings;
 
1393
  gint time;
 
1394
  
 
1395
  settings = g_settings_new (UNITY_WEBAPPS_SCHEMA_NAME);
 
1396
  
 
1397
  time = g_settings_get_int (settings, INDEX_UPDATE_TIME_KEY);
 
1398
  
 
1399
  g_object_unref (G_OBJECT (settings));
 
1400
  
 
1401
  if (time < MINIMUM_UPDATE_TIME)
 
1402
    {
 
1403
      time = MINIMUM_UPDATE_TIME;
 
1404
    }
 
1405
  
 
1406
  return time;
 
1407
}
 
1408
 
1362
1409
gint 
1363
1410
main (gint argc, gchar **argv)
1364
1411
{
1391
1438
  
1392
1439
  UNITY_WEBAPPS_NOTE (SERVICE, "Starting Unity Webapps Service");
1393
1440
  
 
1441
  unity_webapps_service_spawn_index_updater ();
 
1442
  
1394
1443
  service = unity_webapps_service_new ();
1395
1444
  
1396
1445
  owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, UNITY_WEBAPPS_SERVICE_NAME,
1401
1450
                             service /* userdata */,
1402
1451
                             NULL /* userdata free*/);
1403
1452
                             
 
1453
  g_timeout_add_seconds (unity_webapps_service_get_index_updater_timeout (), 
 
1454
                         indexer_spawn_callback, NULL);
1404
1455
  
1405
1456
  mainloop = g_main_loop_new(NULL, FALSE);
1406
1457
  g_main_loop_run(mainloop);