Logo Search packages:      
Sourcecode: libgphoto2 version File versions  Download package

int gp_abilities_list_detect ( CameraAbilitiesList list,
GPPortInfoList info_list,
CameraList l,
GPContext context 
)

Parameters:
list a CameraAbilitiesList
info_list the GPPortInfoList of ports to use for detection
l a CameraList that contains the autodetected cameras after the call
context a GPContext
Tries to detect any camera connected to the computer using the supplied list of supported cameras and the supplied info_list of ports.

Returns:
a gphoto2 error code

Definition at line 417 of file gphoto2-abilities-list.c.

References _CameraAbilitiesList::abilities, CHECK_NULL, CHECK_RESULT, gp_list_append(), gp_list_reset(), GP_OK, GP_PORT_DISK, gp_port_free(), gp_port_info_list_count(), gp_port_info_list_get_info(), gp_port_new(), GP_PORT_PTPIP, gp_port_set_error(), gp_port_set_info(), CameraAbilities::model, _GPPortInfo::path, and _GPPortInfo::type.

Referenced by gp_camera_init().

{
      GPPortInfo info;
      GPPort *port;
      int i, info_count;

      CHECK_NULL (list && info_list && l);

      gp_list_reset (l);

      CHECK_RESULT (info_count = gp_port_info_list_count (info_list));

      CHECK_RESULT (gp_port_new (&port));
      for (i = 0; i < info_count; i++) {
            int res;

            CHECK_RESULT (gp_port_info_list_get_info (info_list, i, &info));
            CHECK_RESULT (gp_port_set_info (port, info));
            switch (info.type) {
            case GP_PORT_USB: {
                  int ability;
                  res = gp_abilities_list_detect_usb (list, &ability, port);
                  if (res == GP_OK) {
                        gp_list_append(l,
                              list->abilities[ability].model,
                              info.path);
                  } else if (res < 0)
                        gp_port_set_error (port, NULL);

                  break;
            }
            case GP_PORT_DISK: {
                  char  *s, path[1024];
                  struct stat stbuf;
            
                  s = strchr (info.path, ':');
                  if (!s)
                        break;
                  s++;
                  snprintf (path, sizeof(path), "%s/DCIM", s);
                  if (-1 == stat(path, &stbuf)) {
                        snprintf (path, sizeof(path), "%s/dcim", s);
                        if (-1 == stat(path, &stbuf))
                              continue;
                  }
                  gp_list_append (l, "Mass Storage Camera", info.path);
                  break;
            }
            case GP_PORT_PTPIP: {
                  char  *s;

                  s = strchr (info.path, ':');
                  if (!s) break;
                  s++;
                  if (!strlen(s)) break;
                  gp_list_append (l, "PTP/IP Camera", info.path);
                  break;
            }
            default:
                  /*
                   * We currently cannot detect any cameras on this
                   * port
                   */
                  break;
            }
      }

      gp_port_free (port);

      return (GP_OK);
}


Generated by  Doxygen 1.6.0   Back to index