Beispiel #1
0
VALUE shape_object::get_shape_parts(VALUE self)
{
  shape_object *object = unwrap(self);

  CHECK_VALID_HANDLE(object->value());

  return INT2FIX(object->value()->nParts);
}
Beispiel #2
0
VALUE shape_object::get_m_max(VALUE self)
{
  shape_object *object = unwrap(self);

  CHECK_VALID_HANDLE(object->value());

  return rb_float_new(object->value()->dfMMax);
}
Beispiel #3
0
VALUE shape_object::get_shape_type(VALUE self)
{
  shape_object *object = unwrap(self);

  CHECK_VALID_HANDLE(object->value());

  return INT2FIX(object->value()->nSHPType);
}
Beispiel #4
0
VALUE shape_object::get_z_min(VALUE self)
{
  shape_object *object = unwrap(self);

  CHECK_VALID_HANDLE(object->value());

  return rb_float_new(object->value()->dfZMin);
}
Beispiel #5
0
VALUE shape_object::get_vertex_count(VALUE self)
{
  shape_object *object = unwrap(self);

  CHECK_VALID_HANDLE(object->value());

  return INT2FIX(object->value()->nVertices);
}
Beispiel #6
0
VALUE shape_object::compute_extents(VALUE self)
{
  shape_object *object = unwrap(self);

  CHECK_VALID_HANDLE(object->value());

  SHPComputeExtents(object->value());

  return object->wrapped();
}
Beispiel #7
0
VALUE shape_object::destroy(VALUE self)
{
  shape_object *object = unwrap(self);

  CHECK_VALID_HANDLE(object->value());

  if (object->value()) {
    SHPDestroyObject(object->value());
    object->_handle = NULL;
  }

  return Qnil;
}
Beispiel #8
0
VALUE shape_object::get_shape_part_types(VALUE self)
{
  shape_object *object = unwrap(self);

  CHECK_VALID_HANDLE(object->value());

  VALUE result = rb_ary_new();

  SHPObject *obj = object->value();

  if (obj && obj->panPartType) {
    for (int i = 0; i < obj->nParts; ++i) {
      rb_ary_push(result, INT2FIX(obj->panPartType[i]));
    }
  }

  return result;
}
Beispiel #9
0
VALUE shape_object::get_m(VALUE self)
{
  shape_object *object = unwrap(self);

  CHECK_VALID_HANDLE(object->value());

  VALUE result = rb_ary_new();

  SHPObject *obj = object->value();

  if (obj && obj->padfM) {
    for (int i = 0; i < obj->nVertices; ++i) {
      rb_ary_push(result, rb_float_new(obj->padfM[i]));
    }
  }

  return result;
}
void ancsSetNotificationRequest(GANCS *ancs, bool notifications_enable, uint8 characteristic)
{
    bool success = FALSE;
    uint16 endHandle = 0;
    uint16 startHandle = 0;
    gatt_ancs_status_t status = gatt_ancs_status_failed;
    gatt_manager_client_service_data_t client_data;

    client_data.start_handle = APPLE_NOTIFICATION_INVALID_HANDLE;
    client_data.end_handle = APPLE_NOTIFICATION_INVALID_HANDLE;
    if (!GattManagerGetClientData(&ancs->lib_task, &client_data))
    {
        GATT_APPLE_NOTIFICATION_PANIC(("ANCS: Could not get client data\n"));
    }
    
    switch(characteristic)
    {
        case GATT_APPLE_NOTIFICATION_NS:
        {
            if (CHECK_VALID_HANDLE(ancs->notification_source))
            {
                /* First check if ccd handle is found, else find it */
                if(!CHECK_VALID_HANDLE(ancs->ns_ccd))
                {
                    startHandle = ((ancs->notification_source + 1) > client_data.end_handle) ? client_data.end_handle : (ancs->notification_source + 1);
                    endHandle = findEndHandleForCharDesc(ancs, startHandle, client_data.end_handle, GATT_APPLE_NOTIFICATION_NS);
                    /* Find client configuration descriptor */
                    if(startHandle && endHandle)
                    {
                        success = ancsDiscoverAllCharacteristicDescriptors(ancs, startHandle, endHandle);
                    }
                }
                else
                {
                     if (writeClientConfigNotifyValue(ancs, notifications_enable, ancs->ns_ccd))
                     {
                        ancs->pending_cmd = ancs_pending_write_ns_cconfig;
                        return;
                     }
                }
            }
        }
        break;

        case GATT_APPLE_NOTIFICATION_DS:
        {
            if (CHECK_VALID_HANDLE(ancs->data_source))
            {
                /* First check if the ccd handle is found, else find it */
                if(!CHECK_VALID_HANDLE(ancs->ds_ccd))
                {
                    startHandle = ((ancs->data_source + 1) > client_data.end_handle) ? client_data.end_handle : (ancs->data_source + 1);
                    endHandle = findEndHandleForCharDesc(ancs, startHandle, client_data.end_handle, GATT_APPLE_NOTIFICATION_DS);
                    /* Find client configuration descriptor */
                    if(startHandle && endHandle)
                    {
                        success = ancsDiscoverAllCharacteristicDescriptors(ancs, startHandle, endHandle);
                    }
                }
                else
                {
                    if (writeClientConfigNotifyValue(ancs, notifications_enable, ancs->ds_ccd))
                    {
                        ancs->pending_cmd = ancs_pending_write_ds_cconfig;
                        return;
                    }
                }
            }
            else
            {
                /* Data Source Characteristics are not available. That's fine, because Apple Specification does
                 * not mandate this charateristic. Respond to app that remote doesn't support it */
                 status = gatt_ancs_status_not_supported;
            }
        }
        break;

        default:
            /* This is not a desirable chareteristic for notification */
            GATT_APPLE_NOTIFICAITON_DEBUG_INFO(("Not a valid characteristic for notifications"));
        break;
    }

    if (success)
    {
        if (notifications_enable)
        {
            ancs->pending_cmd = (characteristic == GATT_APPLE_NOTIFICATION_NS) ? ancs_pending_set_ns_notify_enable :
            ancs_pending_set_ds_notify_enable;
        }
        else
        {
            ancs->pending_cmd = (characteristic == GATT_APPLE_NOTIFICATION_NS) ? ancs_pending_set_ns_notify_disable :
            ancs_pending_set_ds_notify_disable;
        }
    }
    else
    {
        makeAncsSetNotificationCfmMsg(ancs, status, characteristic);
    }
}