Exemple #1
0
	void Plugin::handleRowsInserted (const QModelIndex& parent, int start, int end)
	{
		if (parent.isValid ())
			return;

		bool hasNew = false;
		for (auto i = start; i <= end; ++i)
		{
			const auto& idx = Model_->index (i, 0);

			const auto busnum = idx.data (USBDeviceRole::Busnum).toInt ();
			const auto devnum = idx.data (USBDeviceRole::Devnum).toInt ();

			if (LIBMTP_Check_Specific_Device (busnum, devnum))
			{
				hasNew = true;
				break;
			}
		}

		if (!hasNew)
			return;

		QTimer::singleShot (1000,
				this,
				SLOT (pollDevices ()));
	}
Exemple #2
0
static PyObject *
is_mtp_device(PyObject *self, PyObject *args) {
    int busnum, devnum, ans = 0;

    if (!PyArg_ParseTuple(args, "ii", &busnum, &devnum)) return NULL;

    Py_BEGIN_ALLOW_THREADS;
    ans = LIBMTP_Check_Specific_Device(busnum, devnum);
    Py_END_ALLOW_THREADS;

    if (ans) Py_RETURN_TRUE;

    Py_RETURN_FALSE;

}
Exemple #3
0
int main (int argc, char **argv)
{
  char *fname;
  int busno;
  int devno;
  int ret;

  if (argc < 4) {
    syslog(LOG_INFO, "need device path, busnumber, device number as argument\n");
    printf("0");
    exit(0);
  }

  fname = argv[1];
  busno = atoi(argv[2]);
  devno = atoi(argv[3]);

  syslog(LOG_INFO, "checking bus %d, device %d: \"%s\"\n", busno, devno, fname);

  ret = check_sysfs(fname);
  /*
   * This means that regular directory check either agrees that this may be a
   * MTP device, or that it doesn't know (failed). In that case, kick the deeper
   * check inside LIBMTP.
   */
  if (ret != 0)
    ret = LIBMTP_Check_Specific_Device(busno, devno);
  if (ret) {
    syslog(LOG_INFO, "bus: %d, device: %d was an MTP device\n", busno, devno);
    printf("1");
  } else {
    syslog(LOG_INFO, "bus: %d, device: %d was not an MTP device\n", busno, devno);
    printf("0");
  }

  exit(0);
}