Пример #1
0
int appsync_stop(void)
{
  GList *iter = 0;

  for( iter = sync_list; iter; iter = g_list_next(iter) )
  {
    struct list_elem *data = iter->data;

    if(data->systemd)
    {
        if(!systemd_control_service(data->name, SYSTEMD_STOP))
		log_debug("Failed to stop %s\n", data->name);
    }
#ifdef UPSTART
    else if(data->upstart)
    {
      log_debug("Stopping %s\n", data->launch);
      if(upstart_control_job(data->name, UPSTART_STOP))
	log_debug("Failed to stop %s\n", data->name);
    }
#endif /* UPSTART */
  }

  return(0);
}
Пример #2
0
int appsync_stop(void)
{
  GList *iter = 0;

  for( iter = sync_list; iter; iter = g_list_next(iter) )
  {
    struct list_elem *data = iter->data;
    if(data->upstart)
    {
      log_debug("Stopping %s\n", data->launch);
      if(upstart_control_job(data->name, UPSTART_STOP))
	log_debug("Failed to stop %s\n", data->name);
    }
  }

  return(0);
}
Пример #3
0
int activate_sync_post(const char *mode)
{
  GList *iter;

  log_debug("activate post sync");

  if( sync_list == 0 )
  {
    log_debug("No sync list! skipping post sync\n");
    return 0;
  }

#ifdef APP_SYNC_DBUS
  /* check dbus initialisation, skip dbus activated services if this fails */
  if(!usb_moded_app_sync_init())
  {
      log_debug("dbus setup failed => skipping dbus launched apps \n");
      no_dbus = 1;
   }
#endif /* APP_SYNC_DBUS */

  /* go through list and launch apps */
  for( iter = sync_list; iter; iter = g_list_next(iter) )
  {
    struct list_elem *data = iter->data;
    if(!strcmp(mode, data->mode))
    {
      /* launch only items marked as post, others are already running */
      if(!data->post)
	continue;
      log_debug("launching app %s\n", data->name);
      if(data->systemd)
      {
        if(systemd_control_service(data->name, SYSTEMD_START))
		goto error;
      }
#ifdef UPSTART
      else if(data->upstart)
      {
	if(upstart_control_job(data->name, UPSTART_START))	
		goto error;
      }
#endif /* UPSTART */
      else if(data->launch)
      {
		/* skipping if dbus session bus is not available,
		   or not compiled in */
		if(no_dbus)
			continue;
#ifdef APP_SYNC_DBUS
		else
			if(usb_moded_dbus_app_launch(data->launch != 0))
				goto error;
#endif /* APP_SYNC_DBUS */
      }
    }
  }

  return(0);

error:
  log_warning("Error launching a service!\n");
  return(1);
}
Пример #4
0
/* @return 0 on succes, 1 if there is a failure */
int activate_sync(const char *mode)
{
  GList *iter;
  int count = 0, count2 = 0;

  log_debug("activate sync");

  /* Bump tag, see enumerate_usb() */
  ++sync_tag; gettimeofday(&sync_tv, 0);

  if( sync_list == 0 )
  {
    log_debug("No sync list! Enumerating\n");
    enumerate_usb(NULL);
    return 0;
  }

  /* set list to inactive, mark other modes as active already */
  for( iter = sync_list; iter; iter = g_list_next(iter) )
  {
    struct list_elem *data = iter->data;

    count++;
    if(!strcmp(data->mode, mode))
    	data->active = 0;
    else
    {
	count2++;
	data->active = 1;
    }
  }

  /* if the number of active modes is equal to the number of existing modes
     we enumerate immediately */
  if(count == count2)
  {
      log_debug("Nothing to launch.\n");
      enumerate_usb(NULL);
      return(0);
   }

#ifdef APP_SYNC_DBUS
  /* check dbus initialisation, skip dbus activated services if this fails */
  if(!usb_moded_app_sync_init())
  {
      log_debug("dbus setup failed => skipping dbus launched apps \n");
      no_dbus = 1;
   }
#endif /* APP_SYNC_DBUS */

  /* start timer */
  log_debug("Starting appsync timer\n");
  g_timeout_add_seconds(2, enumerate_usb, NULL);

  /* go through list and launch apps */
  for( iter = sync_list; iter; iter = g_list_next(iter) )
  {
    struct list_elem *data = iter->data;
    if(!strcmp(mode, data->mode))
    {
      /* launch items marked as post, will be launched after usb is up */
      if(data->post)
      {
	mark_active(data->name);
	continue;
      }
      log_debug("launching app %s\n", data->name);
      if(data->systemd)
      {
        if(!systemd_control_service(data->name, SYSTEMD_START))
		mark_active(data->name);
	else
		goto error;
      }
#ifdef UPSTART
      else if(data->upstart)
      {
	if(!upstart_control_job(data->name, UPSTART_START))	
		mark_active(data->name);
	else
		goto error;
      }
#endif /* UPSTART */
      else if(data->launch)
      {
		/* skipping if dbus session bus is not available,
		   or not compiled in */
		if(no_dbus)
			mark_active(data->name);
#ifdef APP_SYNC_DBUS
		else
			if(!usb_moded_dbus_app_launch(data->launch))
				mark_active(data->name);
			else
				goto error;
#endif /* APP_SYNC_DBUS */
      }
    }
  }

  return(0);

error:
  log_warning("Error launching a service!\n");
  return(1);
}
Пример #5
0
int activate_sync(const char *mode)
{
  GList *iter;
  int count = 0, count2 = 0;

  log_debug("activate sync");

  /* Bump tag, see enumerate_usb() */
  ++sync_tag; gettimeofday(&sync_tv, 0);

  if( sync_list == 0 )
  {
    enumerate_usb(NULL);
    return 0;
  }

  /* set list to inactive, mark other modes as active already */
  for( iter = sync_list; iter; iter = g_list_next(iter) )
  {
    struct list_elem *data = iter->data;

    count++;
    if(!strcmp(data->mode, mode))
    	data->active = 0;
    else
    {
	count2++;
	data->active = 1;
    }
  }

  /* if the number of active modes is equal to the number of existing modes
     we enumerate immediately */
  if(count == count2)
  {
      log_debug("Nothing to launch.\n");
      enumerate_usb(NULL);
      return(1);
   }

  /* add dbus filter. Use session bus for ready method call? */
  if(!usb_moded_app_sync_init())
  {
      log_debug("dbus setup failed => activate immediately \n");
      enumerate_usb(NULL);
      return(1);
   }

  /* start timer */
  log_debug("Starting appsync timer\n");
  g_timeout_add_seconds(2, enumerate_usb, NULL);

  /* go through list and launch apps */
  for( iter = sync_list; iter; iter = g_list_next(iter) )
  {
    struct list_elem *data = iter->data;
    if(!strcmp(mode, data->mode))
    {
      log_debug("launching app %s\n", data->launch);
#ifdef UPSTART
      if(data->upstart)
      {
	if(!upstart_control_job(data->name, UPSTART_START))	
		mark_active(data->name);
      }
      else
#endif /* UPSTART */
      	usb_moded_dbus_app_launch(data->launch);
    }
  }

  return(0);
}