87
87
" <arg type='s' name='reason' direction='in' />"
88
88
" <arg type='i' name='cookie' direction='out' />"
90
" <method name='PauseForProcess'>"
91
" <arg type='s' name='application' direction='in' />"
92
" <arg type='s' name='reason' direction='in' />"
93
" <arg type='i' name='cookie' direction='out' />"
90
95
" <method name='Resume'>"
91
96
" <arg type='i' name='cookie' direction='in' />"
162
169
static void pause_data_destroy (gpointer data);
163
170
static PauseData *pause_data_new (const gchar *application,
164
const gchar *reason);
172
const gchar *watch_name,
173
guint watch_name_id);
165
174
static void handle_method_call (GDBusConnection *connection,
166
175
const gchar *sender,
167
176
const gchar *object_path,
838
857
return g_hash_table_size (miner->priv->pauses);
861
pause_process_disappeared_cb (GDBusConnection *connection,
866
PauseData *pd = NULL;
867
GError *error = NULL;
873
g_message ("Process with name:'%s' has disappeared", name);
875
g_hash_table_iter_init (&iter, miner->priv->pauses);
876
while (g_hash_table_iter_next (&iter, &key, &value)) {
877
PauseData *pd_iter = value;
879
if (g_strcmp0 (name, pd_iter->watch_name) == 0) {
886
g_critical ("Could not find PauseData for process with name:'%s'", name);
891
g_message ("Resuming pause associated with process");
893
tracker_miner_resume (miner, pd->cookie, &error);
896
g_warning ("Could not resume miner, %s", error->message);
897
g_error_free (error);
842
tracker_miner_pause_internal (TrackerMiner *miner,
843
const gchar *application,
902
miner_pause_internal (TrackerMiner *miner,
903
const gchar *application,
905
const gchar *calling_name,
848
909
GHashTableIter iter;
849
910
gpointer key, value;
911
guint watch_name_id = 0;
851
913
/* Check this is not a duplicate pause */
852
914
g_hash_table_iter_init (&iter, miner->priv->pauses);
865
pd = pause_data_new (application, reason);
928
g_message ("Watching process with name:'%s'", calling_name);
929
watch_name_id = g_bus_watch_name (G_BUS_TYPE_SESSION,
931
G_BUS_NAME_WATCHER_FLAGS_NONE,
933
pause_process_disappeared_cb,
938
pd = pause_data_new (application, reason, calling_name, watch_name_id);
867
940
g_hash_table_insert (miner->priv->pauses,
868
941
GINT_TO_POINTER (pd->cookie),
917
990
application = miner->priv->name;
920
return tracker_miner_pause_internal (miner, application, reason, error);
993
return miner_pause_internal (miner, application, reason, NULL, error);
1145
cookie = tracker_miner_pause_internal (miner, application, reason, &local_error);
1218
cookie = miner_pause_internal (miner, application, reason, NULL, &local_error);
1220
tracker_dbus_request_end (request, local_error);
1222
g_dbus_method_invocation_return_gerror (invocation, local_error);
1224
g_error_free (local_error);
1229
tracker_dbus_request_end (request, NULL);
1230
g_dbus_method_invocation_return_value (invocation,
1231
g_variant_new ("(i)", cookie));
1235
handle_method_call_pause_for_process (TrackerMiner *miner,
1236
GDBusMethodInvocation *invocation,
1237
GVariant *parameters)
1239
GError *local_error = NULL;
1241
const gchar *application = NULL, *reason = NULL;
1242
TrackerDBusRequest *request;
1244
g_variant_get (parameters, "(&s&s)", &application, &reason);
1246
tracker_gdbus_async_return_if_fail (application != NULL, invocation);
1247
tracker_gdbus_async_return_if_fail (reason != NULL, invocation);
1249
request = tracker_g_dbus_request_begin (invocation,
1250
"%s(application:'%s', reason:'%s')",
1251
__PRETTY_FUNCTION__,
1255
cookie = miner_pause_internal (miner,
1258
g_dbus_method_invocation_get_sender (invocation),
1146
1260
if (cookie == -1) {
1147
1261
tracker_dbus_request_end (request, local_error);
1245
1359
if (g_strcmp0 (method_name, "IgnoreNextUpdate") == 0) {
1246
1360
handle_method_call_ignore_next_update (miner, invocation, parameters);
1248
if (g_strcmp0 (method_name, "Resume") == 0) {
1361
} else if (g_strcmp0 (method_name, "Resume") == 0) {
1249
1362
handle_method_call_resume (miner, invocation, parameters);
1251
if (g_strcmp0 (method_name, "Pause") == 0) {
1363
} else if (g_strcmp0 (method_name, "Pause") == 0) {
1252
1364
handle_method_call_pause (miner, invocation, parameters);
1254
if (g_strcmp0 (method_name, "GetPauseDetails") == 0) {
1365
} else if (g_strcmp0 (method_name, "PauseForProcess") == 0) {
1366
handle_method_call_pause_for_process (miner, invocation, parameters);
1367
} else if (g_strcmp0 (method_name, "GetPauseDetails") == 0) {
1255
1368
handle_method_call_get_pause_details (miner, invocation, parameters);
1257
if (g_strcmp0 (method_name, "GetProgress") == 0) {
1369
} else if (g_strcmp0 (method_name, "GetProgress") == 0) {
1258
1370
handle_method_call_get_progress (miner, invocation, parameters);
1260
if (g_strcmp0 (method_name, "GetStatus") == 0) {
1371
} else if (g_strcmp0 (method_name, "GetStatus") == 0) {
1261
1372
handle_method_call_get_status (miner, invocation, parameters);
1263
1374
g_assert_not_reached ();