Ejemplo n.º 1
0
Archivo: args.c Proyecto: mchasal/SFCB
static CMPIData
__aft_getArgAt(const CMPIArgs * args,
               unsigned int i, CMPIString **name, CMPIStatus *rc)
{
  ClArgs         *ca = (ClArgs *) args->hdl;
  char           *n;
  CMPIData        rv = { 0, CMPI_notFound, {0} };

  if (ClArgsGetArgAt(ca, i, &rv, name ? &n : NULL)) {
    if (rc)
      CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND);
    return rv;
  }
  if (rv.type == CMPI_chars) {
    rv.value.string = sfcb_native_new_CMPIString(rv.value.chars, NULL, 0);
    rv.type = CMPI_string;
  } else if (rv.type == CMPI_ref) {
    rv.value.ref = getObjectPath((char *)
                                 ClObjectGetClString(&ca->hdr,
                                                     (ClString *) &
                                                     rv.value.chars),
                                 NULL);
  } else if (rv.type & CMPI_ARRAY && rv.value.array) {
    rv.value.array =
        internal_native_make_CMPIArray((CMPIData *) rv.value.array, NULL,
                                       &ca->hdr, MEM_TRACKED);
  }
  if (name) {
    *name = sfcb_native_new_CMPIString(n, NULL, 0);
  }
  if (rc)
    CMSetStatus(rc, CMPI_RC_OK);
  return rv;
}
Ejemplo n.º 2
0
Properties::Properties(const QString &objectPath,
                       const QString &interface,
                       QObject *parent)
    : SystemBusInterface(parent),
      mObjectPath(objectPath),
      mInterface(interface)
{
   qDebug() << "Connected" <<
               QDBusConnection::systemBus().connect(getServiceName(), getObjectPath(), getInterfaceName(), "PropertiesChanged", this, SLOT(PropertiesChanged(QString,QMap<QString,QVariant>,QList<QString>)));

}
Ejemplo n.º 3
0
CMPIData
getPropertyQualsAt(CMPIConstClass * cc, CMPICount i, CMPIString **name,
                   unsigned long *quals, CMPIString **refName,
                   CMPIStatus *rc)
{
  ClClass        *cls = (ClClass *) cc->hdl;
  char           *n;
  char           *rName = NULL;
  CMPIData        rv = { 0, CMPI_notFound, {0} };
  if (ClClassGetPropertyAt(cls, i, &rv, name ? &n : NULL, quals, &rName)) {
    if (rc)
      CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND);
    return rv;
  }
  if (rv.type == CMPI_chars) {
    rv.value.string = sfcb_native_new_CMPIString(rv.value.chars, NULL, 0);
    rv.type = CMPI_string;
  } else if (rv.type == CMPI_ref) {
    if ((rv.state & CMPI_nullValue) == 0)
      rv.value.ref = getObjectPath((char *)
                                   ClObjectGetClString(&cls->hdr,
                                                       (ClString *) &
                                                       rv.value.chars),
                                   NULL);
  }
  if (rv.type & CMPI_ARRAY && rv.value.array) {
    rv.value.array =
        native_make_CMPIArray((CMPIData *) rv.value.array, NULL,
                              &cls->hdr);
  }
  if (name) {
    *name = sfcb_native_new_CMPIString(n, NULL, 0);
  }
  if (refName && rName) {
    *refName = sfcb_native_new_CMPIString(rName, NULL, 0);
  } else {
    if (refName) {
      *refName = NULL;
    }
  }
  if (rc)
    CMSetStatus(rc, CMPI_RC_OK);
  return rv;
}
Ejemplo n.º 4
0
Killswitch::Killswitch(UrfEnumType type)
{
    QDBusConnection conn = QDBusConnection::systemBus();
    if (!QDBusConnection::systemBus().isConnected()) {
        qDebug() << "Cannot connect to the D-Bus system bus.";

        return;
    }

    QString objPath = getObjectPath(type);
    killswitchIface = new QDBusInterface(URFKILL_SERVICE, objPath, URFKILL_KILLSWITCH_INTERFACE, conn, this);
    if (!killswitchIface->isValid()) {
        qDebug() << "Can not create DBus interface!";
        qDebug() << QDBusConnection::systemBus().lastError().message();

        return;
    }

    refreshState();

    connect(killswitchIface, SIGNAL(StateChanged(int)), this, SLOT(stateChanged(int)));
}
Ejemplo n.º 5
0
CMPIStatus
InternalProviderEnumInstanceNames(CMPIInstanceMI * mi,
                                  const CMPIContext *ctx,
                                  const CMPIResult *rslt,
                                  const CMPIObjectPath * ref)
{
  CMPIStatus      st = { CMPI_RC_OK, NULL };
  CMPIStatus      sti = { CMPI_RC_OK, NULL };
  BlobIndex      *bi;
  CMPIString     *cn = CMGetClassName(ref, NULL);
  CMPIString     *ns = CMGetNameSpace(ref, NULL);
  CMPIObjectPath *cop;
  const char     *nss = ns->ft->getCharPtr(ns, NULL);
  const char     *cns = cn->ft->getCharPtr(cn, NULL);
  const char     *bnss = repositoryNs(nss);
  size_t          ekl;
  int             i,
                  ac = 0;
  char            copKey[8192] = "";
  char           *kp;
  CMPIArgs       *in,
                 *out;
  CMPIObjectPath *op;
  CMPIArray      *ar;
  CMPIData        rv;

  _SFCB_ENTER(TRACE_INTERNALPROVIDER, "InternalProviderEnumInstanceNames");
  _SFCB_TRACE(1, ("%s %s", nss, cns));

  in = CMNewArgs(Broker, NULL);
  out = CMNewArgs(Broker, NULL);
  CMAddArg(in, "class", cns, CMPI_chars);
  op = CMNewObjectPath(Broker, bnss, "$ClassProvider$", &sti);
  rv = CBInvokeMethod(Broker, ctx, op, "getallchildren", in, out, &sti);
  ar = CMGetArg(out, "children", NULL).value.array;
  if (ar)
    ac = CMGetArrayCount(ar, NULL);

  for (i = 0; cns; i++) {
    if ((bi = _getIndex(bnss, cns)) != NULL) {
      if (ipGetFirst(bi, NULL, &kp, &ekl)) {
        while (1) {
          strcpy(copKey, nss);
          strcat(copKey, ":");
          strcat(copKey, cns);
          strcat(copKey, ".");
          strncat(copKey, kp, ekl);

          cop = getObjectPath(copKey, NULL);
          if (cop)
            CMReturnObjectPath(rslt, cop);
          else {
            CMPIStatus      st = { CMPI_RC_ERR_FAILED, NULL };
            return st;
          }
          if (bi->next < bi->dSize && ipGetNext(bi, NULL, &kp, &ekl)) {
            continue;
          }
          break;
        }
      }
      freeBlobIndex(&bi, 1);
    }
    if (i < ac)
      cns = (char *) CMGetArrayElementAt(ar, i, NULL).value.string->hdl;
    else
      cns = NULL;
  }
  _SFCB_RETURN(st);
}
Ejemplo n.º 6
0
static CMPIData make_cmpi_data( type_type lextype, int arrayspec, 
				value_chain * vals )
{
  CMPIData data;
  CMPIData arr_data;
  int i = 0;
  
  data.type = make_cmpi_type(lextype,arrayspec);
  data.value.uint64 = 0L;        /* set to binary zeros */
  
  if ( vals == NULL )  {
    data.state = CMPI_nullValue;
  } else if (vals -> val_value == NULL) {
    fprintf (stderr,"*** fatal error in backend: NULL value recieved.\n");
    abort();  /* paranoia */
  }else { 
    data.state = CMPI_goodValue;
  }    
  
  if ( data.state == CMPI_goodValue ) {
    if (data.type & CMPI_ARRAY) {
      /* process array entries */
      data.value.array = 
	CMNewArray(Broker,0,data.type&~CMPI_ARRAY,NULL);
      while (vals && vals -> val_value) {
	arr_data = make_cmpi_data(lextype,-1,vals);
        sfcb_simpleArrayAdd(data.value.array, &arr_data.value, data.type&~CMPI_ARRAY);
	i++;
	vals = vals -> val_next;
      }
    } else {
      switch (data.type & ~CMPI_ARRAY) {
      case CMPI_uint8:
	sscanf(vals -> val_value, "%hhu", &data.value.uint8 );
	break;
      case CMPI_sint8:
	sscanf(vals -> val_value, "%hhd", &data.value.sint8 );
	break;
      case CMPI_uint16:
	sscanf(vals -> val_value, "%hu", &data.value.uint16 );
	break;
      case CMPI_sint16:
	sscanf(vals -> val_value, "%hd", &data.value.sint16 );
	break;
      case CMPI_uint32:
	sscanf(vals -> val_value, "%u", &data.value.uint32 );
	break;
      case CMPI_sint32:
	sscanf(vals -> val_value, "%d", &data.value.sint32 );
	break;
      case CMPI_uint64:
	sscanf(vals -> val_value, "%llu", &data.value.uint64);
	break;
      case CMPI_sint64:
	sscanf(vals -> val_value, "%lld", &data.value.uint64 );
	break;
      case CMPI_real32:
	sscanf(vals -> val_value, "%f", &data.value.real32 );
	break;
      case CMPI_real64:
	sscanf(vals -> val_value, "%lf", &data.value.real64 );
	break;
      case CMPI_char16:
	/* this one is suspect to produce garbage */
	sscanf(vals -> val_value, "%c", &data.value.uint8 );
	break;
      case CMPI_string:
	data.value.string = CMNewString(Broker,vals -> val_value,NULL);
	break;
      case CMPI_boolean:
	if (strcasecmp("true",vals -> val_value) == 0) {
	  data.value.boolean = 1;
	} else {
	  data.value.boolean = 0;
	}
	break;
      case CMPI_dateTime:
	data.value.dateTime = 
	  CMNewDateTimeFromChars(Broker,vals -> val_value,NULL);
	if (data.value.dateTime == NULL) {
	  fprintf(stderr,"failed to build datetime from %s", vals -> val_value);
	  data.state = CMPI_nullValue;
	}
	break;
      default:  {
			char *msg=NULL;
			data.value.ref = getObjectPath(vals -> val_value, &msg);
			if(msg) {
				fprintf(stderr, "Problem with Objectpath %s: %s\n", vals -> val_value, msg);
				exit(0);
			}
	    }
      }
    }
  }
  return data;
}