From e1c3726a272737d8ae45eb2f7adc207cfcae4aee Mon Sep 17 00:00:00 2001 From: f4exb Date: Sat, 4 Sep 2021 05:58:06 +0200 Subject: [PATCH] API: added GET /sdrangel/featurepresets and DELETE /sdrangel/featurepreset --- sdrbase/resources/webapi/doc/html2/index.html | 876 +++++++++++++++++- .../resources/webapi/doc/swagger/swagger.yaml | 103 ++ sdrbase/webapi/webapiadapter.cpp | 73 ++ sdrbase/webapi/webapiadapter.h | 8 + sdrbase/webapi/webapiadapterinterface.cpp | 2 + sdrbase/webapi/webapiadapterinterface.h | 32 + sdrbase/webapi/webapirequestmapper.cpp | 83 ++ sdrbase/webapi/webapirequestmapper.h | 3 + sdrgui/mainwindow.cpp | 8 + swagger/sdrangel/api/swagger/swagger.yaml | 103 ++ swagger/sdrangel/code/html2/index.html | 876 +++++++++++++++++- .../code/qt5/client/SWGFeaturePresetGroup.cpp | 162 ++++ .../code/qt5/client/SWGFeaturePresetGroup.h | 73 ++ .../qt5/client/SWGFeaturePresetIdentifier.cpp | 135 +++ .../qt5/client/SWGFeaturePresetIdentifier.h | 65 ++ .../code/qt5/client/SWGFeaturePresetItem.cpp | 110 +++ .../code/qt5/client/SWGFeaturePresetItem.h | 59 ++ .../code/qt5/client/SWGFeaturePresets.cpp | 137 +++ .../code/qt5/client/SWGFeaturePresets.h | 66 ++ .../code/qt5/client/SWGInstanceApi.cpp | 107 +++ .../sdrangel/code/qt5/client/SWGInstanceApi.h | 12 + .../code/qt5/client/SWGModelFactory.h | 24 + 22 files changed, 3115 insertions(+), 2 deletions(-) create mode 100644 swagger/sdrangel/code/qt5/client/SWGFeaturePresetGroup.cpp create mode 100644 swagger/sdrangel/code/qt5/client/SWGFeaturePresetGroup.h create mode 100644 swagger/sdrangel/code/qt5/client/SWGFeaturePresetIdentifier.cpp create mode 100644 swagger/sdrangel/code/qt5/client/SWGFeaturePresetIdentifier.h create mode 100644 swagger/sdrangel/code/qt5/client/SWGFeaturePresetItem.cpp create mode 100644 swagger/sdrangel/code/qt5/client/SWGFeaturePresetItem.h create mode 100644 swagger/sdrangel/code/qt5/client/SWGFeaturePresets.cpp create mode 100644 swagger/sdrangel/code/qt5/client/SWGFeaturePresets.h diff --git a/sdrbase/resources/webapi/doc/html2/index.html b/sdrbase/resources/webapi/doc/html2/index.html index 18c58b2e3..3cb284e88 100644 --- a/sdrbase/resources/webapi/doc/html2/index.html +++ b/sdrbase/resources/webapi/doc/html2/index.html @@ -4834,6 +4834,66 @@ margin-bottom: 20px; } }, "description" : "Summarized information about feature plugin" +}; + defs.FeaturePresetGroup = { + "required" : [ "groupName", "nbPresets" ], + "properties" : { + "groupName" : { + "type" : "string", + "description" : "Name of the preset group" + }, + "nbPresets" : { + "type" : "integer", + "description" : "Number of presets in the group" + }, + "presets" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/FeaturePresetItem" + } + } + }, + "description" : "Group of feature presets" +}; + defs.FeaturePresetIdentifier = { + "required" : [ "description", "groupName" ], + "properties" : { + "groupName" : { + "type" : "string", + "description" : "Name of the feature preset group" + }, + "description" : { + "type" : "string", + "description" : "Descriptive name of the preset" + } + }, + "description" : "Feature settings preset item" +}; + defs.FeaturePresetItem = { + "required" : [ "description" ], + "properties" : { + "description" : { + "type" : "string", + "description" : "Descriptive name of the preset" + } + }, + "description" : "Feature settings preset item" +}; + defs.FeaturePresets = { + "required" : [ "nbGroups" ], + "properties" : { + "nbGroups" : { + "type" : "integer", + "description" : "Number of preset groups" + }, + "groups" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/FeaturePresetGroup" + } + } + }, + "description" : "Feature settings presets" }; defs.FeatureReport = { "required" : [ "featureType" ], @@ -12635,6 +12695,12 @@ margin-bottom: 20px;
  • instanceDevices
  • +
  • + instanceFeaturePresetDelete +
  • +
  • + instanceFeaturePresetGet +
  • instanceFeatureSetsGet
  • @@ -40393,6 +40459,814 @@ except ApiException as e:
    +
    +
    +
    +

    instanceFeaturePresetDelete

    +

    +
    +
    +
    +

    +

    Deletes a feature preset

    +

    +
    +
    /sdrangel/featurepreset
    +

    +

    Usage and SDK Samples

    +

    + + +
    +
    +
    curl -X DELETE "http://localhost/sdrangel/featurepreset"
    +
    +
    +
    import SWGSDRangel.*;
    +import SWGSDRangel.auth.*;
    +import SWGSDRangel.model.*;
    +import SWGSDRangel.api.InstanceApi;
    +
    +import java.io.File;
    +import java.util.*;
    +
    +public class InstanceApiExample {
    +
    +    public static void main(String[] args) {
    +        
    +        InstanceApi apiInstance = new InstanceApi();
    +        FeaturePresetIdentifier body = ; // FeaturePresetIdentifier | delete this feature preset
    +        try {
    +            FeaturePresetIdentifier result = apiInstance.instanceFeaturePresetDelete(body);
    +            System.out.println(result);
    +        } catch (ApiException e) {
    +            System.err.println("Exception when calling InstanceApi#instanceFeaturePresetDelete");
    +            e.printStackTrace();
    +        }
    +    }
    +}
    +
    + +
    +
    import SWGSDRangel.api.InstanceApi;
    +
    +public class InstanceApiExample {
    +
    +    public static void main(String[] args) {
    +        InstanceApi apiInstance = new InstanceApi();
    +        FeaturePresetIdentifier body = ; // FeaturePresetIdentifier | delete this feature preset
    +        try {
    +            FeaturePresetIdentifier result = apiInstance.instanceFeaturePresetDelete(body);
    +            System.out.println(result);
    +        } catch (ApiException e) {
    +            System.err.println("Exception when calling InstanceApi#instanceFeaturePresetDelete");
    +            e.printStackTrace();
    +        }
    +    }
    +}
    +
    + +
    +
    FeaturePresetIdentifier *body = ; // delete this feature preset
    +
    +InstanceApi *apiInstance = [[InstanceApi alloc] init];
    +
    +[apiInstance instanceFeaturePresetDeleteWith:body
    +              completionHandler: ^(FeaturePresetIdentifier output, NSError* error) {
    +                            if (output) {
    +                                NSLog(@"%@", output);
    +                            }
    +                            if (error) {
    +                                NSLog(@"Error: %@", error);
    +                            }
    +                        }];
    +
    +
    + +
    +
    var SdRangel = require('sd_rangel');
    +
    +var api = new SdRangel.InstanceApi()
    +
    +var body = ; // {FeaturePresetIdentifier} delete this feature preset
    +
    +
    +var callback = function(error, data, response) {
    +  if (error) {
    +    console.error(error);
    +  } else {
    +    console.log('API called successfully. Returned data: ' + data);
    +  }
    +};
    +api.instanceFeaturePresetDelete(body, callback);
    +
    +
    + + +
    +
    using System;
    +using System.Diagnostics;
    +using SWGSDRangel.Api;
    +using SWGSDRangel.Client;
    +using SWGSDRangel.Model;
    +
    +namespace Example
    +{
    +    public class instanceFeaturePresetDeleteExample
    +    {
    +        public void main()
    +        {
    +            
    +            var apiInstance = new InstanceApi();
    +            var body = new FeaturePresetIdentifier(); // FeaturePresetIdentifier | delete this feature preset
    +
    +            try
    +            {
    +                FeaturePresetIdentifier result = apiInstance.instanceFeaturePresetDelete(body);
    +                Debug.WriteLine(result);
    +            }
    +            catch (Exception e)
    +            {
    +                Debug.Print("Exception when calling InstanceApi.instanceFeaturePresetDelete: " + e.Message );
    +            }
    +        }
    +    }
    +}
    +
    +
    + +
    +
    <?php
    +require_once(__DIR__ . '/vendor/autoload.php');
    +
    +$api_instance = new Swagger\Client\Api\InstanceApi();
    +$body = ; // FeaturePresetIdentifier | delete this feature preset
    +
    +try {
    +    $result = $api_instance->instanceFeaturePresetDelete($body);
    +    print_r($result);
    +} catch (Exception $e) {
    +    echo 'Exception when calling InstanceApi->instanceFeaturePresetDelete: ', $e->getMessage(), PHP_EOL;
    +}
    +?>
    +
    + +
    +
    use Data::Dumper;
    +use SWGSDRangel::Configuration;
    +use SWGSDRangel::InstanceApi;
    +
    +my $api_instance = SWGSDRangel::InstanceApi->new();
    +my $body = SWGSDRangel::Object::FeaturePresetIdentifier->new(); # FeaturePresetIdentifier | delete this feature preset
    +
    +eval { 
    +    my $result = $api_instance->instanceFeaturePresetDelete(body => $body);
    +    print Dumper($result);
    +};
    +if ($@) {
    +    warn "Exception when calling InstanceApi->instanceFeaturePresetDelete: $@\n";
    +}
    +
    + +
    +
    from __future__ import print_statement
    +import time
    +import swagger_sdrangel
    +from swagger_sdrangel.rest import ApiException
    +from pprint import pprint
    +
    +# create an instance of the API class
    +api_instance = swagger_sdrangel.InstanceApi()
    +body =  # FeaturePresetIdentifier | delete this feature preset
    +
    +try: 
    +    api_response = api_instance.instance_feature_preset_delete(body)
    +    pprint(api_response)
    +except ApiException as e:
    +    print("Exception when calling InstanceApi->instanceFeaturePresetDelete: %s\n" % e)
    +
    +
    + +

    Parameters

    + + + +
    Body parameters
    + + + + + + + + + +
    NameDescription
    body * + + + +
    +
    + + + +

    Responses

    +

    Status: 202 - On successful sending of the message the selected feature preset identification is returned

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 400 - Invalid JSON request

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 404 - Preset not found

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 500 - Error

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 501 - Function not implemented

    + + + +
    +
    +
    + +
    + +
    +
    + +
    +
    +
    +
    +
    +
    +

    instanceFeaturePresetGet

    +

    +
    +
    +
    +

    +

    List all feature presets in the instance

    +

    +
    +
    /sdrangel/featurepresets
    +

    +

    Usage and SDK Samples

    +

    + + +
    +
    +
    curl -X GET "http://localhost/sdrangel/featurepresets"
    +
    +
    +
    import SWGSDRangel.*;
    +import SWGSDRangel.auth.*;
    +import SWGSDRangel.model.*;
    +import SWGSDRangel.api.InstanceApi;
    +
    +import java.io.File;
    +import java.util.*;
    +
    +public class InstanceApiExample {
    +
    +    public static void main(String[] args) {
    +        
    +        InstanceApi apiInstance = new InstanceApi();
    +        try {
    +            FeaturePresets result = apiInstance.instanceFeaturePresetGet();
    +            System.out.println(result);
    +        } catch (ApiException e) {
    +            System.err.println("Exception when calling InstanceApi#instanceFeaturePresetGet");
    +            e.printStackTrace();
    +        }
    +    }
    +}
    +
    + +
    +
    import SWGSDRangel.api.InstanceApi;
    +
    +public class InstanceApiExample {
    +
    +    public static void main(String[] args) {
    +        InstanceApi apiInstance = new InstanceApi();
    +        try {
    +            FeaturePresets result = apiInstance.instanceFeaturePresetGet();
    +            System.out.println(result);
    +        } catch (ApiException e) {
    +            System.err.println("Exception when calling InstanceApi#instanceFeaturePresetGet");
    +            e.printStackTrace();
    +        }
    +    }
    +}
    +
    + +
    +
    
    +InstanceApi *apiInstance = [[InstanceApi alloc] init];
    +
    +[apiInstance instanceFeaturePresetGetWithCompletionHandler: 
    +              ^(FeaturePresets output, NSError* error) {
    +                            if (output) {
    +                                NSLog(@"%@", output);
    +                            }
    +                            if (error) {
    +                                NSLog(@"Error: %@", error);
    +                            }
    +                        }];
    +
    +
    + +
    +
    var SdRangel = require('sd_rangel');
    +
    +var api = new SdRangel.InstanceApi()
    +
    +var callback = function(error, data, response) {
    +  if (error) {
    +    console.error(error);
    +  } else {
    +    console.log('API called successfully. Returned data: ' + data);
    +  }
    +};
    +api.instanceFeaturePresetGet(callback);
    +
    +
    + + +
    +
    using System;
    +using System.Diagnostics;
    +using SWGSDRangel.Api;
    +using SWGSDRangel.Client;
    +using SWGSDRangel.Model;
    +
    +namespace Example
    +{
    +    public class instanceFeaturePresetGetExample
    +    {
    +        public void main()
    +        {
    +            
    +            var apiInstance = new InstanceApi();
    +
    +            try
    +            {
    +                FeaturePresets result = apiInstance.instanceFeaturePresetGet();
    +                Debug.WriteLine(result);
    +            }
    +            catch (Exception e)
    +            {
    +                Debug.Print("Exception when calling InstanceApi.instanceFeaturePresetGet: " + e.Message );
    +            }
    +        }
    +    }
    +}
    +
    +
    + +
    +
    <?php
    +require_once(__DIR__ . '/vendor/autoload.php');
    +
    +$api_instance = new Swagger\Client\Api\InstanceApi();
    +
    +try {
    +    $result = $api_instance->instanceFeaturePresetGet();
    +    print_r($result);
    +} catch (Exception $e) {
    +    echo 'Exception when calling InstanceApi->instanceFeaturePresetGet: ', $e->getMessage(), PHP_EOL;
    +}
    +?>
    +
    + +
    +
    use Data::Dumper;
    +use SWGSDRangel::Configuration;
    +use SWGSDRangel::InstanceApi;
    +
    +my $api_instance = SWGSDRangel::InstanceApi->new();
    +
    +eval { 
    +    my $result = $api_instance->instanceFeaturePresetGet();
    +    print Dumper($result);
    +};
    +if ($@) {
    +    warn "Exception when calling InstanceApi->instanceFeaturePresetGet: $@\n";
    +}
    +
    + +
    +
    from __future__ import print_statement
    +import time
    +import swagger_sdrangel
    +from swagger_sdrangel.rest import ApiException
    +from pprint import pprint
    +
    +# create an instance of the API class
    +api_instance = swagger_sdrangel.InstanceApi()
    +
    +try: 
    +    api_response = api_instance.instance_feature_preset_get()
    +    pprint(api_response)
    +except ApiException as e:
    +    print("Exception when calling InstanceApi->instanceFeaturePresetGet: %s\n" % e)
    +
    +
    + +

    Parameters

    + + + + + + +

    Responses

    +

    Status: 200 - On success return feature preset list

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 500 - Error

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 501 - Function not implemented

    + + + +
    +
    +
    + +
    + +
    +
    + +
    +
    +
    @@ -48111,7 +48985,7 @@ except ApiException as e:
    - Generated 2021-08-31T23:36:40.361+02:00 + Generated 2021-09-03T22:11:29.377+02:00
    diff --git a/sdrbase/resources/webapi/doc/swagger/swagger.yaml b/sdrbase/resources/webapi/doc/swagger/swagger.yaml index e5b69abfb..d6130d173 100644 --- a/sdrbase/resources/webapi/doc/swagger/swagger.yaml +++ b/sdrbase/resources/webapi/doc/swagger/swagger.yaml @@ -883,6 +883,57 @@ paths: "501": $ref: "#/responses/Response_501" + /sdrangel/featurepresets: + x-swagger-router-controller: instance + get: + description: List all feature presets in the instance + operationId: instanceFeaturePresetGet + tags: + - Instance + responses: + "200": + description: On success return feature preset list + schema: + $ref: "#/definitions/FeaturePresets" + "500": + $ref: "#/responses/Response_500" + "501": + $ref: "#/responses/Response_501" + + /sdrangel/featurepreset: + x-swagger-router-controller: instance + delete: + description: Deletes a feature preset + operationId: instanceFeaturePresetDelete + tags: + - Instance + consumes: + - application/json + parameters: + - name: body + in: body + description: delete this feature preset + required: true + schema: + $ref: "#/definitions/FeaturePresetIdentifier" + responses: + "202": + description: On successful sending of the message the selected feature preset identification is returned + schema: + $ref: "#/definitions/FeaturePresetIdentifier" + "400": + description: Invalid JSON request + schema: + $ref: "#/definitions/ErrorResponse" + "404": + description: Preset not found + schema: + $ref: "#/definitions/ErrorResponse" + "500": + $ref: "#/responses/Response_500" + "501": + $ref: "#/responses/Response_501" + /sdrangel/devicesets: x-swagger-router-controller: instance get: @@ -3031,6 +3082,58 @@ definitions: preset: $ref: "#/definitions/PresetIdentifier" + FeaturePresets: + description: "Feature settings presets" + required: + - nbGroups + properties: + nbGroups: + description: "Number of preset groups" + type: integer + groups: + type: array + items: + $ref: "#/definitions/FeaturePresetGroup" + + FeaturePresetGroup: + description: "Group of feature presets" + required: + - groupName + - nbPresets + properties: + groupName: + description: "Name of the preset group" + type: string + nbPresets: + description: "Number of presets in the group" + type: integer + presets: + type: array + items: + $ref: "#/definitions/FeaturePresetItem" + + FeaturePresetItem: + description: "Feature settings preset item" + required: + - description + properties: + description: + description: "Descriptive name of the preset" + type: string + + FeaturePresetIdentifier: + description: "Feature settings preset item" + required: + - groupName + - description + properties: + groupName: + description: "Name of the feature preset group" + type: string + description: + description: "Descriptive name of the preset" + type: string + responses: Response_500: diff --git a/sdrbase/webapi/webapiadapter.cpp b/sdrbase/webapi/webapiadapter.cpp index d052922c8..964499396 100644 --- a/sdrbase/webapi/webapiadapter.cpp +++ b/sdrbase/webapi/webapiadapter.cpp @@ -71,6 +71,10 @@ #include "SWGLimeRFEDevices.h" #include "SWGLimeRFESettings.h" #include "SWGLimeRFEPower.h" +#include "SWGFeaturePresets.h" +#include "SWGFeaturePresetGroup.h" +#include "SWGFeaturePresetItem.h" +#include "SWGFeaturePresetIdentifier.h" #include "SWGFeatureSetList.h" #include "SWGFeatureSettings.h" #include "SWGFeatureReport.h" @@ -1406,6 +1410,75 @@ int WebAPIAdapter::instancePresetDelete( return 202; } +int WebAPIAdapter::instanceFeaturePresetsGet( + SWGSDRangel::SWGFeaturePresets& response, + SWGSDRangel::SWGErrorResponse& error) +{ + (void) error; + int nbPresets = m_mainCore->m_settings.getFeatureSetPresetCount(); + int nbGroups = 0; + int nbPresetsThisGroup = 0; + QString groupName; + response.init(); + QList *groups = response.getGroups(); + QList *swgPresets = 0; + int i = 0; + + // Presets are sorted by group first + + for (; i < nbPresets; i++) + { + const FeatureSetPreset *preset = m_mainCore->m_settings.getFeatureSetPreset(i); + + if ((i == 0) || (groupName != preset->getGroup())) // new group + { + if (i > 0) { groups->back()->setNbPresets(nbPresetsThisGroup); } + groups->append(new SWGSDRangel::SWGFeaturePresetGroup); + groups->back()->init(); + groupName = preset->getGroup(); + *groups->back()->getGroupName() = groupName; + swgPresets = groups->back()->getPresets(); + nbGroups++; + nbPresetsThisGroup = 0; + } + + swgPresets->append(new SWGSDRangel::SWGFeaturePresetItem); + swgPresets->back()->init(); + *swgPresets->back()->getDescription() = preset->getDescription(); + nbPresetsThisGroup++; + } + + if (i > 0) { groups->back()->setNbPresets(nbPresetsThisGroup); } + response.setNbGroups(nbGroups); + + return 200; +} + +int WebAPIAdapter::instanceFeaturePresetDelete( + SWGSDRangel::SWGFeaturePresetIdentifier& response, + SWGSDRangel::SWGErrorResponse& error) +{ + const FeatureSetPreset *selectedPreset = m_mainCore->m_settings.getFeatureSetPreset(*response.getGroupName(), + *response.getDescription()); + + if (selectedPreset == nullptr) + { + error.init(); + *error.getMessage() = QString("There is no feature preset [%1, %2]") + .arg(*response.getGroupName()) + .arg(*response.getDescription()); + return 404; + } + + *response.getGroupName() = selectedPreset->getGroup(); + *response.getDescription() = selectedPreset->getDescription(); + + MainCore::MsgDeleteFeatureSetPreset *msg = MainCore::MsgDeleteFeatureSetPreset::create(const_cast(selectedPreset)); + m_mainCore->m_mainMessageQueue->push(msg); + + return 202; +} + int WebAPIAdapter::instanceDeviceSetsGet( SWGSDRangel::SWGDeviceSetList& response, SWGSDRangel::SWGErrorResponse& error) diff --git a/sdrbase/webapi/webapiadapter.h b/sdrbase/webapi/webapiadapter.h index 765b3a8b8..4969345db 100644 --- a/sdrbase/webapi/webapiadapter.h +++ b/sdrbase/webapi/webapiadapter.h @@ -195,6 +195,14 @@ public: SWGSDRangel::SWGPresetIdentifier& response, SWGSDRangel::SWGErrorResponse& error); + virtual int instanceFeaturePresetsGet( + SWGSDRangel::SWGFeaturePresets& response, + SWGSDRangel::SWGErrorResponse& error); + + virtual int instanceFeaturePresetDelete( + SWGSDRangel::SWGFeaturePresetIdentifier& response, + SWGSDRangel::SWGErrorResponse& error); + virtual int instanceDeviceSetsGet( SWGSDRangel::SWGDeviceSetList& response, SWGSDRangel::SWGErrorResponse& error); diff --git a/sdrbase/webapi/webapiadapterinterface.cpp b/sdrbase/webapi/webapiadapterinterface.cpp index 41cc11603..3633a99d4 100644 --- a/sdrbase/webapi/webapiadapterinterface.cpp +++ b/sdrbase/webapi/webapiadapterinterface.cpp @@ -40,6 +40,8 @@ QString WebAPIAdapterInterface::instanceLimeRFEPowerURL = "/sdrangel/limerfe/pow QString WebAPIAdapterInterface::instancePresetsURL = "/sdrangel/presets"; QString WebAPIAdapterInterface::instancePresetURL = "/sdrangel/preset"; QString WebAPIAdapterInterface::instancePresetFileURL = "/sdrangel/preset/file"; +QString WebAPIAdapterInterface::instanceFeaturePresetsURL = "/sdrangel/featurepresets"; +QString WebAPIAdapterInterface::instanceFeaturePresetURL = "/sdrangel/featurepreset"; QString WebAPIAdapterInterface::instanceDeviceSetsURL = "/sdrangel/devicesets"; QString WebAPIAdapterInterface::instanceDeviceSetURL = "/sdrangel/deviceset"; QString WebAPIAdapterInterface::instanceFeatureSetsURL = "/sdrangel/featuresets"; diff --git a/sdrbase/webapi/webapiadapterinterface.h b/sdrbase/webapi/webapiadapterinterface.h index bc52e75ba..ebf1ab8c1 100644 --- a/sdrbase/webapi/webapiadapterinterface.h +++ b/sdrbase/webapi/webapiadapterinterface.h @@ -63,6 +63,8 @@ namespace SWGSDRangel class SWGChannelReport; class SWGChannelActions; class SWGSuccessResponse; + class SWGFeaturePresets; + class SWGFeaturePresetIdentifier; class SWGFeatureSetList; class SWGFeatureSet; class SWGFeatureSettings; @@ -649,6 +651,34 @@ public: return 501; } + /** + * Handler of /sdrangel/featurepresets (GET) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels + * returns the Http status code (default 501: not implemented) + */ + virtual int instanceFeaturePresetsGet( + SWGSDRangel::SWGFeaturePresets& response, + SWGSDRangel::SWGErrorResponse& error) + { + (void) response; + error.init(); + *error.getMessage() = QString("Function not implemented"); + return 501; + } + + /** + * Handler of /sdrangel/featurepreset (DELETE) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels + * returns the Http status code (default 501: not implemented) + */ + virtual int instanceFeaturePresetDelete( + SWGSDRangel::SWGFeaturePresetIdentifier& response, + SWGSDRangel::SWGErrorResponse& error) + { + (void) response; + error.init(); + *error.getMessage() = QString("Function not implemented"); + return 501; + } + /** * Handler of /sdrangel/devicesets (GET) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels * returns the Http status code (default 501: not implemented) @@ -1389,6 +1419,8 @@ public: static QString instancePresetsURL; static QString instancePresetURL; static QString instancePresetFileURL; + static QString instanceFeaturePresetsURL; + static QString instanceFeaturePresetURL; static QString instanceDeviceSetsURL; static QString instanceDeviceSetURL; static QString instanceFeatureSetsURL; diff --git a/sdrbase/webapi/webapirequestmapper.cpp b/sdrbase/webapi/webapirequestmapper.cpp index 847682cd8..c8df6a498 100644 --- a/sdrbase/webapi/webapirequestmapper.cpp +++ b/sdrbase/webapi/webapirequestmapper.cpp @@ -53,6 +53,8 @@ #include "SWGChannelActions.h" #include "SWGSuccessResponse.h" #include "SWGErrorResponse.h" +#include "SWGFeaturePresets.h" +#include "SWGFeaturePresetIdentifier.h" #include "SWGFeatureSetList.h" #include "SWGFeatureSettings.h" #include "SWGFeatureReport.h" @@ -150,6 +152,10 @@ void WebAPIRequestMapper::service(qtwebapp::HttpRequest& request, qtwebapp::Http instancePresetService(request, response); } else if (path == WebAPIAdapterInterface::instancePresetFileURL) { instancePresetFileService(request, response); + } else if (path == WebAPIAdapterInterface::instanceFeaturePresetsURL) { + instanceFeaturePresetsService(request, response); + } else if (path == WebAPIAdapterInterface::instanceFeaturePresetURL) { + instanceFeaturePresetService(request, response); } else if (path == WebAPIAdapterInterface::instanceDeviceSetsURL) { instanceDeviceSetsService(request, response); } else if (path == WebAPIAdapterInterface::instanceDeviceSetURL) { @@ -1367,6 +1373,78 @@ void WebAPIRequestMapper::instancePresetFileService(qtwebapp::HttpRequest& reque } } +void WebAPIRequestMapper::instanceFeaturePresetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) +{ + SWGSDRangel::SWGErrorResponse errorResponse; + response.setHeader("Content-Type", "application/json"); + response.setHeader("Access-Control-Allow-Origin", "*"); + + if (request.getMethod() == "GET") + { + SWGSDRangel::SWGFeaturePresets normalResponse; + int status = m_adapter->instanceFeaturePresetsGet(normalResponse, errorResponse); + response.setStatus(status); + + if (status/100 == 2) { + response.write(normalResponse.asJson().toUtf8()); + } else { + response.write(errorResponse.asJson().toUtf8()); + } + } +} + +void WebAPIRequestMapper::instanceFeaturePresetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) +{ + SWGSDRangel::SWGErrorResponse errorResponse; + response.setHeader("Content-Type", "application/json"); + response.setHeader("Access-Control-Allow-Origin", "*"); + + if (request.getMethod() == "DELETE") + { + SWGSDRangel::SWGFeaturePresetIdentifier normalResponse; + QString jsonStr = request.getBody(); + QJsonObject jsonObject; + + if (parseJsonBody(jsonStr, jsonObject, response)) + { + normalResponse.fromJson(jsonStr); + + if (validateFeaturePresetIdentifer(normalResponse)) + { + int status = m_adapter->instanceFeaturePresetDelete(normalResponse, errorResponse); + response.setStatus(status); + + if (status/100 == 2) { + response.write(normalResponse.asJson().toUtf8()); + } else { + response.write(errorResponse.asJson().toUtf8()); + } + } + else + { + response.setStatus(400,"Invalid JSON request"); + errorResponse.init(); + *errorResponse.getMessage() = "Invalid JSON request"; + response.write(errorResponse.asJson().toUtf8()); + } + } + else + { + response.setStatus(400,"Invalid JSON format"); + errorResponse.init(); + *errorResponse.getMessage() = "Invalid JSON format"; + response.write(errorResponse.asJson().toUtf8()); + } + } + else + { + response.setStatus(405,"Invalid HTTP method"); + errorResponse.init(); + *errorResponse.getMessage() = "Invalid HTTP method"; + response.write(errorResponse.asJson().toUtf8()); + } +} + void WebAPIRequestMapper::instanceDeviceSetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) { SWGSDRangel::SWGErrorResponse errorResponse; @@ -2990,6 +3068,11 @@ bool WebAPIRequestMapper::validatePresetIdentifer(SWGSDRangel::SWGPresetIdentifi return (presetIdentifier.getGroupName() && presetIdentifier.getName() && presetIdentifier.getType()); } +bool WebAPIRequestMapper::validateFeaturePresetIdentifer(SWGSDRangel::SWGFeaturePresetIdentifier& presetIdentifier) +{ + return (presetIdentifier.getGroupName() && presetIdentifier.getDescription()); +} + bool WebAPIRequestMapper::validatePresetExport(SWGSDRangel::SWGPresetExport& presetExport) { if (presetExport.getFilePath() == 0) { diff --git a/sdrbase/webapi/webapirequestmapper.h b/sdrbase/webapi/webapirequestmapper.h index 65fb3ea1a..0eb282e52 100644 --- a/sdrbase/webapi/webapirequestmapper.h +++ b/sdrbase/webapi/webapirequestmapper.h @@ -76,6 +76,8 @@ private: void instancePresetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response); void instancePresetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response); void instancePresetFileService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response); + void instanceFeaturePresetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response); + void instanceFeaturePresetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response); void instanceDeviceSetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response); void instanceDeviceSetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response); void instanceFeatureSetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response); @@ -115,6 +117,7 @@ private: bool validateDeviceActions(SWGSDRangel::SWGDeviceActions& deviceActions, QJsonObject& jsonObject, QStringList& deviceActionsKeys); bool validateChannelSettings(SWGSDRangel::SWGChannelSettings& channelSettings, QJsonObject& jsonObject, QStringList& channelSettingsKeys); bool validateChannelActions(SWGSDRangel::SWGChannelActions& channelActions, QJsonObject& jsonObject, QStringList& channelActionsKeys); + bool validateFeaturePresetIdentifer(SWGSDRangel::SWGFeaturePresetIdentifier& presetIdentifier); bool validateFeatureSettings(SWGSDRangel::SWGFeatureSettings& featureSettings, QJsonObject& jsonObject, QStringList& featureSettingsKeys); bool validateFeatureActions(SWGSDRangel::SWGFeatureActions& featureActions, QJsonObject& jsonObject, QStringList& featureActionsKeys); bool validateAudioInputDevice(SWGSDRangel::SWGAudioInputDevice& audioInputDevice, QJsonObject& jsonObject, QStringList& audioInputDeviceKeys); diff --git a/sdrgui/mainwindow.cpp b/sdrgui/mainwindow.cpp index 02994878e..852a40ecd 100644 --- a/sdrgui/mainwindow.cpp +++ b/sdrgui/mainwindow.cpp @@ -1054,6 +1054,14 @@ bool MainWindow::handleMessage(const Message& cmd) m_mainCore->m_settings.deletePreset(presetToDelete); return true; } + else if (MainCore::MsgDeleteFeatureSetPreset::match(cmd)) + { + MainCore::MsgDeleteFeatureSetPreset& notif = (MainCore::MsgDeleteFeatureSetPreset&) cmd; + const FeatureSetPreset *presetToDelete = notif.getPreset(); + // remove preset from settings + m_mainCore->m_settings.deleteFeatureSetPreset(presetToDelete); + return true; + } else if (MainCore::MsgAddDeviceSet::match(cmd)) { MainCore::MsgAddDeviceSet& notif = (MainCore::MsgAddDeviceSet&) cmd; diff --git a/swagger/sdrangel/api/swagger/swagger.yaml b/swagger/sdrangel/api/swagger/swagger.yaml index f93f606a1..abefcea7d 100644 --- a/swagger/sdrangel/api/swagger/swagger.yaml +++ b/swagger/sdrangel/api/swagger/swagger.yaml @@ -883,6 +883,57 @@ paths: "501": $ref: "#/responses/Response_501" + /sdrangel/featurepresets: + x-swagger-router-controller: instance + get: + description: List all feature presets in the instance + operationId: instanceFeaturePresetGet + tags: + - Instance + responses: + "200": + description: On success return feature preset list + schema: + $ref: "#/definitions/FeaturePresets" + "500": + $ref: "#/responses/Response_500" + "501": + $ref: "#/responses/Response_501" + + /sdrangel/featurepreset: + x-swagger-router-controller: instance + delete: + description: Deletes a feature preset + operationId: instanceFeaturePresetDelete + tags: + - Instance + consumes: + - application/json + parameters: + - name: body + in: body + description: delete this feature preset + required: true + schema: + $ref: "#/definitions/FeaturePresetIdentifier" + responses: + "202": + description: On successful sending of the message the selected feature preset identification is returned + schema: + $ref: "#/definitions/FeaturePresetIdentifier" + "400": + description: Invalid JSON request + schema: + $ref: "#/definitions/ErrorResponse" + "404": + description: Preset not found + schema: + $ref: "#/definitions/ErrorResponse" + "500": + $ref: "#/responses/Response_500" + "501": + $ref: "#/responses/Response_501" + /sdrangel/devicesets: x-swagger-router-controller: instance get: @@ -3031,6 +3082,58 @@ definitions: preset: $ref: "#/definitions/PresetIdentifier" + FeaturePresets: + description: "Feature settings presets" + required: + - nbGroups + properties: + nbGroups: + description: "Number of preset groups" + type: integer + groups: + type: array + items: + $ref: "#/definitions/FeaturePresetGroup" + + FeaturePresetGroup: + description: "Group of feature presets" + required: + - groupName + - nbPresets + properties: + groupName: + description: "Name of the preset group" + type: string + nbPresets: + description: "Number of presets in the group" + type: integer + presets: + type: array + items: + $ref: "#/definitions/FeaturePresetItem" + + FeaturePresetItem: + description: "Feature settings preset item" + required: + - description + properties: + description: + description: "Descriptive name of the preset" + type: string + + FeaturePresetIdentifier: + description: "Feature settings preset item" + required: + - groupName + - description + properties: + groupName: + description: "Name of the feature preset group" + type: string + description: + description: "Descriptive name of the preset" + type: string + responses: Response_500: diff --git a/swagger/sdrangel/code/html2/index.html b/swagger/sdrangel/code/html2/index.html index 18c58b2e3..3cb284e88 100644 --- a/swagger/sdrangel/code/html2/index.html +++ b/swagger/sdrangel/code/html2/index.html @@ -4834,6 +4834,66 @@ margin-bottom: 20px; } }, "description" : "Summarized information about feature plugin" +}; + defs.FeaturePresetGroup = { + "required" : [ "groupName", "nbPresets" ], + "properties" : { + "groupName" : { + "type" : "string", + "description" : "Name of the preset group" + }, + "nbPresets" : { + "type" : "integer", + "description" : "Number of presets in the group" + }, + "presets" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/FeaturePresetItem" + } + } + }, + "description" : "Group of feature presets" +}; + defs.FeaturePresetIdentifier = { + "required" : [ "description", "groupName" ], + "properties" : { + "groupName" : { + "type" : "string", + "description" : "Name of the feature preset group" + }, + "description" : { + "type" : "string", + "description" : "Descriptive name of the preset" + } + }, + "description" : "Feature settings preset item" +}; + defs.FeaturePresetItem = { + "required" : [ "description" ], + "properties" : { + "description" : { + "type" : "string", + "description" : "Descriptive name of the preset" + } + }, + "description" : "Feature settings preset item" +}; + defs.FeaturePresets = { + "required" : [ "nbGroups" ], + "properties" : { + "nbGroups" : { + "type" : "integer", + "description" : "Number of preset groups" + }, + "groups" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/FeaturePresetGroup" + } + } + }, + "description" : "Feature settings presets" }; defs.FeatureReport = { "required" : [ "featureType" ], @@ -12635,6 +12695,12 @@ margin-bottom: 20px;
  • instanceDevices
  • +
  • + instanceFeaturePresetDelete +
  • +
  • + instanceFeaturePresetGet +
  • instanceFeatureSetsGet
  • @@ -40393,6 +40459,814 @@ except ApiException as e:
    +
    +
    +
    +

    instanceFeaturePresetDelete

    +

    +
    +
    +
    +

    +

    Deletes a feature preset

    +

    +
    +
    /sdrangel/featurepreset
    +

    +

    Usage and SDK Samples

    +

    + + +
    +
    +
    curl -X DELETE "http://localhost/sdrangel/featurepreset"
    +
    +
    +
    import SWGSDRangel.*;
    +import SWGSDRangel.auth.*;
    +import SWGSDRangel.model.*;
    +import SWGSDRangel.api.InstanceApi;
    +
    +import java.io.File;
    +import java.util.*;
    +
    +public class InstanceApiExample {
    +
    +    public static void main(String[] args) {
    +        
    +        InstanceApi apiInstance = new InstanceApi();
    +        FeaturePresetIdentifier body = ; // FeaturePresetIdentifier | delete this feature preset
    +        try {
    +            FeaturePresetIdentifier result = apiInstance.instanceFeaturePresetDelete(body);
    +            System.out.println(result);
    +        } catch (ApiException e) {
    +            System.err.println("Exception when calling InstanceApi#instanceFeaturePresetDelete");
    +            e.printStackTrace();
    +        }
    +    }
    +}
    +
    + +
    +
    import SWGSDRangel.api.InstanceApi;
    +
    +public class InstanceApiExample {
    +
    +    public static void main(String[] args) {
    +        InstanceApi apiInstance = new InstanceApi();
    +        FeaturePresetIdentifier body = ; // FeaturePresetIdentifier | delete this feature preset
    +        try {
    +            FeaturePresetIdentifier result = apiInstance.instanceFeaturePresetDelete(body);
    +            System.out.println(result);
    +        } catch (ApiException e) {
    +            System.err.println("Exception when calling InstanceApi#instanceFeaturePresetDelete");
    +            e.printStackTrace();
    +        }
    +    }
    +}
    +
    + +
    +
    FeaturePresetIdentifier *body = ; // delete this feature preset
    +
    +InstanceApi *apiInstance = [[InstanceApi alloc] init];
    +
    +[apiInstance instanceFeaturePresetDeleteWith:body
    +              completionHandler: ^(FeaturePresetIdentifier output, NSError* error) {
    +                            if (output) {
    +                                NSLog(@"%@", output);
    +                            }
    +                            if (error) {
    +                                NSLog(@"Error: %@", error);
    +                            }
    +                        }];
    +
    +
    + +
    +
    var SdRangel = require('sd_rangel');
    +
    +var api = new SdRangel.InstanceApi()
    +
    +var body = ; // {FeaturePresetIdentifier} delete this feature preset
    +
    +
    +var callback = function(error, data, response) {
    +  if (error) {
    +    console.error(error);
    +  } else {
    +    console.log('API called successfully. Returned data: ' + data);
    +  }
    +};
    +api.instanceFeaturePresetDelete(body, callback);
    +
    +
    + + +
    +
    using System;
    +using System.Diagnostics;
    +using SWGSDRangel.Api;
    +using SWGSDRangel.Client;
    +using SWGSDRangel.Model;
    +
    +namespace Example
    +{
    +    public class instanceFeaturePresetDeleteExample
    +    {
    +        public void main()
    +        {
    +            
    +            var apiInstance = new InstanceApi();
    +            var body = new FeaturePresetIdentifier(); // FeaturePresetIdentifier | delete this feature preset
    +
    +            try
    +            {
    +                FeaturePresetIdentifier result = apiInstance.instanceFeaturePresetDelete(body);
    +                Debug.WriteLine(result);
    +            }
    +            catch (Exception e)
    +            {
    +                Debug.Print("Exception when calling InstanceApi.instanceFeaturePresetDelete: " + e.Message );
    +            }
    +        }
    +    }
    +}
    +
    +
    + +
    +
    <?php
    +require_once(__DIR__ . '/vendor/autoload.php');
    +
    +$api_instance = new Swagger\Client\Api\InstanceApi();
    +$body = ; // FeaturePresetIdentifier | delete this feature preset
    +
    +try {
    +    $result = $api_instance->instanceFeaturePresetDelete($body);
    +    print_r($result);
    +} catch (Exception $e) {
    +    echo 'Exception when calling InstanceApi->instanceFeaturePresetDelete: ', $e->getMessage(), PHP_EOL;
    +}
    +?>
    +
    + +
    +
    use Data::Dumper;
    +use SWGSDRangel::Configuration;
    +use SWGSDRangel::InstanceApi;
    +
    +my $api_instance = SWGSDRangel::InstanceApi->new();
    +my $body = SWGSDRangel::Object::FeaturePresetIdentifier->new(); # FeaturePresetIdentifier | delete this feature preset
    +
    +eval { 
    +    my $result = $api_instance->instanceFeaturePresetDelete(body => $body);
    +    print Dumper($result);
    +};
    +if ($@) {
    +    warn "Exception when calling InstanceApi->instanceFeaturePresetDelete: $@\n";
    +}
    +
    + +
    +
    from __future__ import print_statement
    +import time
    +import swagger_sdrangel
    +from swagger_sdrangel.rest import ApiException
    +from pprint import pprint
    +
    +# create an instance of the API class
    +api_instance = swagger_sdrangel.InstanceApi()
    +body =  # FeaturePresetIdentifier | delete this feature preset
    +
    +try: 
    +    api_response = api_instance.instance_feature_preset_delete(body)
    +    pprint(api_response)
    +except ApiException as e:
    +    print("Exception when calling InstanceApi->instanceFeaturePresetDelete: %s\n" % e)
    +
    +
    + +

    Parameters

    + + + +
    Body parameters
    + + + + + + + + + +
    NameDescription
    body * + + + +
    +
    + + + +

    Responses

    +

    Status: 202 - On successful sending of the message the selected feature preset identification is returned

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 400 - Invalid JSON request

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 404 - Preset not found

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 500 - Error

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 501 - Function not implemented

    + + + +
    +
    +
    + +
    + +
    +
    + +
    +
    +
    +
    +
    +
    +

    instanceFeaturePresetGet

    +

    +
    +
    +
    +

    +

    List all feature presets in the instance

    +

    +
    +
    /sdrangel/featurepresets
    +

    +

    Usage and SDK Samples

    +

    + + +
    +
    +
    curl -X GET "http://localhost/sdrangel/featurepresets"
    +
    +
    +
    import SWGSDRangel.*;
    +import SWGSDRangel.auth.*;
    +import SWGSDRangel.model.*;
    +import SWGSDRangel.api.InstanceApi;
    +
    +import java.io.File;
    +import java.util.*;
    +
    +public class InstanceApiExample {
    +
    +    public static void main(String[] args) {
    +        
    +        InstanceApi apiInstance = new InstanceApi();
    +        try {
    +            FeaturePresets result = apiInstance.instanceFeaturePresetGet();
    +            System.out.println(result);
    +        } catch (ApiException e) {
    +            System.err.println("Exception when calling InstanceApi#instanceFeaturePresetGet");
    +            e.printStackTrace();
    +        }
    +    }
    +}
    +
    + +
    +
    import SWGSDRangel.api.InstanceApi;
    +
    +public class InstanceApiExample {
    +
    +    public static void main(String[] args) {
    +        InstanceApi apiInstance = new InstanceApi();
    +        try {
    +            FeaturePresets result = apiInstance.instanceFeaturePresetGet();
    +            System.out.println(result);
    +        } catch (ApiException e) {
    +            System.err.println("Exception when calling InstanceApi#instanceFeaturePresetGet");
    +            e.printStackTrace();
    +        }
    +    }
    +}
    +
    + +
    +
    
    +InstanceApi *apiInstance = [[InstanceApi alloc] init];
    +
    +[apiInstance instanceFeaturePresetGetWithCompletionHandler: 
    +              ^(FeaturePresets output, NSError* error) {
    +                            if (output) {
    +                                NSLog(@"%@", output);
    +                            }
    +                            if (error) {
    +                                NSLog(@"Error: %@", error);
    +                            }
    +                        }];
    +
    +
    + +
    +
    var SdRangel = require('sd_rangel');
    +
    +var api = new SdRangel.InstanceApi()
    +
    +var callback = function(error, data, response) {
    +  if (error) {
    +    console.error(error);
    +  } else {
    +    console.log('API called successfully. Returned data: ' + data);
    +  }
    +};
    +api.instanceFeaturePresetGet(callback);
    +
    +
    + + +
    +
    using System;
    +using System.Diagnostics;
    +using SWGSDRangel.Api;
    +using SWGSDRangel.Client;
    +using SWGSDRangel.Model;
    +
    +namespace Example
    +{
    +    public class instanceFeaturePresetGetExample
    +    {
    +        public void main()
    +        {
    +            
    +            var apiInstance = new InstanceApi();
    +
    +            try
    +            {
    +                FeaturePresets result = apiInstance.instanceFeaturePresetGet();
    +                Debug.WriteLine(result);
    +            }
    +            catch (Exception e)
    +            {
    +                Debug.Print("Exception when calling InstanceApi.instanceFeaturePresetGet: " + e.Message );
    +            }
    +        }
    +    }
    +}
    +
    +
    + +
    +
    <?php
    +require_once(__DIR__ . '/vendor/autoload.php');
    +
    +$api_instance = new Swagger\Client\Api\InstanceApi();
    +
    +try {
    +    $result = $api_instance->instanceFeaturePresetGet();
    +    print_r($result);
    +} catch (Exception $e) {
    +    echo 'Exception when calling InstanceApi->instanceFeaturePresetGet: ', $e->getMessage(), PHP_EOL;
    +}
    +?>
    +
    + +
    +
    use Data::Dumper;
    +use SWGSDRangel::Configuration;
    +use SWGSDRangel::InstanceApi;
    +
    +my $api_instance = SWGSDRangel::InstanceApi->new();
    +
    +eval { 
    +    my $result = $api_instance->instanceFeaturePresetGet();
    +    print Dumper($result);
    +};
    +if ($@) {
    +    warn "Exception when calling InstanceApi->instanceFeaturePresetGet: $@\n";
    +}
    +
    + +
    +
    from __future__ import print_statement
    +import time
    +import swagger_sdrangel
    +from swagger_sdrangel.rest import ApiException
    +from pprint import pprint
    +
    +# create an instance of the API class
    +api_instance = swagger_sdrangel.InstanceApi()
    +
    +try: 
    +    api_response = api_instance.instance_feature_preset_get()
    +    pprint(api_response)
    +except ApiException as e:
    +    print("Exception when calling InstanceApi->instanceFeaturePresetGet: %s\n" % e)
    +
    +
    + +

    Parameters

    + + + + + + +

    Responses

    +

    Status: 200 - On success return feature preset list

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 500 - Error

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 501 - Function not implemented

    + + + +
    +
    +
    + +
    + +
    +
    + +
    +
    +
    @@ -48111,7 +48985,7 @@ except ApiException as e:
    - Generated 2021-08-31T23:36:40.361+02:00 + Generated 2021-09-03T22:11:29.377+02:00
    diff --git a/swagger/sdrangel/code/qt5/client/SWGFeaturePresetGroup.cpp b/swagger/sdrangel/code/qt5/client/SWGFeaturePresetGroup.cpp new file mode 100644 index 000000000..42bc2e706 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGFeaturePresetGroup.cpp @@ -0,0 +1,162 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time --- + * + * OpenAPI spec version: 6.0.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +#include "SWGFeaturePresetGroup.h" + +#include "SWGHelpers.h" + +#include +#include +#include +#include + +namespace SWGSDRangel { + +SWGFeaturePresetGroup::SWGFeaturePresetGroup(QString* json) { + init(); + this->fromJson(*json); +} + +SWGFeaturePresetGroup::SWGFeaturePresetGroup() { + group_name = nullptr; + m_group_name_isSet = false; + nb_presets = 0; + m_nb_presets_isSet = false; + presets = nullptr; + m_presets_isSet = false; +} + +SWGFeaturePresetGroup::~SWGFeaturePresetGroup() { + this->cleanup(); +} + +void +SWGFeaturePresetGroup::init() { + group_name = new QString(""); + m_group_name_isSet = false; + nb_presets = 0; + m_nb_presets_isSet = false; + presets = new QList(); + m_presets_isSet = false; +} + +void +SWGFeaturePresetGroup::cleanup() { + if(group_name != nullptr) { + delete group_name; + } + + if(presets != nullptr) { + auto arr = presets; + for(auto o: *arr) { + delete o; + } + delete presets; + } +} + +SWGFeaturePresetGroup* +SWGFeaturePresetGroup::fromJson(QString &json) { + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject jsonObject = doc.object(); + this->fromJsonObject(jsonObject); + return this; +} + +void +SWGFeaturePresetGroup::fromJsonObject(QJsonObject &pJson) { + ::SWGSDRangel::setValue(&group_name, pJson["groupName"], "QString", "QString"); + + ::SWGSDRangel::setValue(&nb_presets, pJson["nbPresets"], "qint32", ""); + + + ::SWGSDRangel::setValue(&presets, pJson["presets"], "QList", "SWGFeaturePresetItem"); +} + +QString +SWGFeaturePresetGroup::asJson () +{ + QJsonObject* obj = this->asJsonObject(); + + QJsonDocument doc(*obj); + QByteArray bytes = doc.toJson(); + delete obj; + return QString(bytes); +} + +QJsonObject* +SWGFeaturePresetGroup::asJsonObject() { + QJsonObject* obj = new QJsonObject(); + if(group_name != nullptr && *group_name != QString("")){ + toJsonValue(QString("groupName"), group_name, obj, QString("QString")); + } + if(m_nb_presets_isSet){ + obj->insert("nbPresets", QJsonValue(nb_presets)); + } + if(presets && presets->size() > 0){ + toJsonArray((QList*)presets, obj, "presets", "SWGFeaturePresetItem"); + } + + return obj; +} + +QString* +SWGFeaturePresetGroup::getGroupName() { + return group_name; +} +void +SWGFeaturePresetGroup::setGroupName(QString* group_name) { + this->group_name = group_name; + this->m_group_name_isSet = true; +} + +qint32 +SWGFeaturePresetGroup::getNbPresets() { + return nb_presets; +} +void +SWGFeaturePresetGroup::setNbPresets(qint32 nb_presets) { + this->nb_presets = nb_presets; + this->m_nb_presets_isSet = true; +} + +QList* +SWGFeaturePresetGroup::getPresets() { + return presets; +} +void +SWGFeaturePresetGroup::setPresets(QList* presets) { + this->presets = presets; + this->m_presets_isSet = true; +} + + +bool +SWGFeaturePresetGroup::isSet(){ + bool isObjectUpdated = false; + do{ + if(group_name && *group_name != QString("")){ + isObjectUpdated = true; break; + } + if(m_nb_presets_isSet){ + isObjectUpdated = true; break; + } + if(presets && (presets->size() > 0)){ + isObjectUpdated = true; break; + } + }while(false); + return isObjectUpdated; +} +} + diff --git a/swagger/sdrangel/code/qt5/client/SWGFeaturePresetGroup.h b/swagger/sdrangel/code/qt5/client/SWGFeaturePresetGroup.h new file mode 100644 index 000000000..051ccb522 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGFeaturePresetGroup.h @@ -0,0 +1,73 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time --- + * + * OpenAPI spec version: 6.0.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +/* + * SWGFeaturePresetGroup.h + * + * Group of feature presets + */ + +#ifndef SWGFeaturePresetGroup_H_ +#define SWGFeaturePresetGroup_H_ + +#include + + +#include "SWGFeaturePresetItem.h" +#include +#include + +#include "SWGObject.h" +#include "export.h" + +namespace SWGSDRangel { + +class SWG_API SWGFeaturePresetGroup: public SWGObject { +public: + SWGFeaturePresetGroup(); + SWGFeaturePresetGroup(QString* json); + virtual ~SWGFeaturePresetGroup(); + void init(); + void cleanup(); + + virtual QString asJson () override; + virtual QJsonObject* asJsonObject() override; + virtual void fromJsonObject(QJsonObject &json) override; + virtual SWGFeaturePresetGroup* fromJson(QString &jsonString) override; + + QString* getGroupName(); + void setGroupName(QString* group_name); + + qint32 getNbPresets(); + void setNbPresets(qint32 nb_presets); + + QList* getPresets(); + void setPresets(QList* presets); + + + virtual bool isSet() override; + +private: + QString* group_name; + bool m_group_name_isSet; + + qint32 nb_presets; + bool m_nb_presets_isSet; + + QList* presets; + bool m_presets_isSet; + +}; + +} + +#endif /* SWGFeaturePresetGroup_H_ */ diff --git a/swagger/sdrangel/code/qt5/client/SWGFeaturePresetIdentifier.cpp b/swagger/sdrangel/code/qt5/client/SWGFeaturePresetIdentifier.cpp new file mode 100644 index 000000000..6e4a6e541 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGFeaturePresetIdentifier.cpp @@ -0,0 +1,135 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time --- + * + * OpenAPI spec version: 6.0.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +#include "SWGFeaturePresetIdentifier.h" + +#include "SWGHelpers.h" + +#include +#include +#include +#include + +namespace SWGSDRangel { + +SWGFeaturePresetIdentifier::SWGFeaturePresetIdentifier(QString* json) { + init(); + this->fromJson(*json); +} + +SWGFeaturePresetIdentifier::SWGFeaturePresetIdentifier() { + group_name = nullptr; + m_group_name_isSet = false; + description = nullptr; + m_description_isSet = false; +} + +SWGFeaturePresetIdentifier::~SWGFeaturePresetIdentifier() { + this->cleanup(); +} + +void +SWGFeaturePresetIdentifier::init() { + group_name = new QString(""); + m_group_name_isSet = false; + description = new QString(""); + m_description_isSet = false; +} + +void +SWGFeaturePresetIdentifier::cleanup() { + if(group_name != nullptr) { + delete group_name; + } + if(description != nullptr) { + delete description; + } +} + +SWGFeaturePresetIdentifier* +SWGFeaturePresetIdentifier::fromJson(QString &json) { + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject jsonObject = doc.object(); + this->fromJsonObject(jsonObject); + return this; +} + +void +SWGFeaturePresetIdentifier::fromJsonObject(QJsonObject &pJson) { + ::SWGSDRangel::setValue(&group_name, pJson["groupName"], "QString", "QString"); + + ::SWGSDRangel::setValue(&description, pJson["description"], "QString", "QString"); + +} + +QString +SWGFeaturePresetIdentifier::asJson () +{ + QJsonObject* obj = this->asJsonObject(); + + QJsonDocument doc(*obj); + QByteArray bytes = doc.toJson(); + delete obj; + return QString(bytes); +} + +QJsonObject* +SWGFeaturePresetIdentifier::asJsonObject() { + QJsonObject* obj = new QJsonObject(); + if(group_name != nullptr && *group_name != QString("")){ + toJsonValue(QString("groupName"), group_name, obj, QString("QString")); + } + if(description != nullptr && *description != QString("")){ + toJsonValue(QString("description"), description, obj, QString("QString")); + } + + return obj; +} + +QString* +SWGFeaturePresetIdentifier::getGroupName() { + return group_name; +} +void +SWGFeaturePresetIdentifier::setGroupName(QString* group_name) { + this->group_name = group_name; + this->m_group_name_isSet = true; +} + +QString* +SWGFeaturePresetIdentifier::getDescription() { + return description; +} +void +SWGFeaturePresetIdentifier::setDescription(QString* description) { + this->description = description; + this->m_description_isSet = true; +} + + +bool +SWGFeaturePresetIdentifier::isSet(){ + bool isObjectUpdated = false; + do{ + if(group_name && *group_name != QString("")){ + isObjectUpdated = true; break; + } + if(description && *description != QString("")){ + isObjectUpdated = true; break; + } + }while(false); + return isObjectUpdated; +} +} + diff --git a/swagger/sdrangel/code/qt5/client/SWGFeaturePresetIdentifier.h b/swagger/sdrangel/code/qt5/client/SWGFeaturePresetIdentifier.h new file mode 100644 index 000000000..12bcbc943 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGFeaturePresetIdentifier.h @@ -0,0 +1,65 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time --- + * + * OpenAPI spec version: 6.0.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +/* + * SWGFeaturePresetIdentifier.h + * + * Feature settings preset item + */ + +#ifndef SWGFeaturePresetIdentifier_H_ +#define SWGFeaturePresetIdentifier_H_ + +#include + + +#include + +#include "SWGObject.h" +#include "export.h" + +namespace SWGSDRangel { + +class SWG_API SWGFeaturePresetIdentifier: public SWGObject { +public: + SWGFeaturePresetIdentifier(); + SWGFeaturePresetIdentifier(QString* json); + virtual ~SWGFeaturePresetIdentifier(); + void init(); + void cleanup(); + + virtual QString asJson () override; + virtual QJsonObject* asJsonObject() override; + virtual void fromJsonObject(QJsonObject &json) override; + virtual SWGFeaturePresetIdentifier* fromJson(QString &jsonString) override; + + QString* getGroupName(); + void setGroupName(QString* group_name); + + QString* getDescription(); + void setDescription(QString* description); + + + virtual bool isSet() override; + +private: + QString* group_name; + bool m_group_name_isSet; + + QString* description; + bool m_description_isSet; + +}; + +} + +#endif /* SWGFeaturePresetIdentifier_H_ */ diff --git a/swagger/sdrangel/code/qt5/client/SWGFeaturePresetItem.cpp b/swagger/sdrangel/code/qt5/client/SWGFeaturePresetItem.cpp new file mode 100644 index 000000000..0b659edd4 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGFeaturePresetItem.cpp @@ -0,0 +1,110 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time --- + * + * OpenAPI spec version: 6.0.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +#include "SWGFeaturePresetItem.h" + +#include "SWGHelpers.h" + +#include +#include +#include +#include + +namespace SWGSDRangel { + +SWGFeaturePresetItem::SWGFeaturePresetItem(QString* json) { + init(); + this->fromJson(*json); +} + +SWGFeaturePresetItem::SWGFeaturePresetItem() { + description = nullptr; + m_description_isSet = false; +} + +SWGFeaturePresetItem::~SWGFeaturePresetItem() { + this->cleanup(); +} + +void +SWGFeaturePresetItem::init() { + description = new QString(""); + m_description_isSet = false; +} + +void +SWGFeaturePresetItem::cleanup() { + if(description != nullptr) { + delete description; + } +} + +SWGFeaturePresetItem* +SWGFeaturePresetItem::fromJson(QString &json) { + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject jsonObject = doc.object(); + this->fromJsonObject(jsonObject); + return this; +} + +void +SWGFeaturePresetItem::fromJsonObject(QJsonObject &pJson) { + ::SWGSDRangel::setValue(&description, pJson["description"], "QString", "QString"); + +} + +QString +SWGFeaturePresetItem::asJson () +{ + QJsonObject* obj = this->asJsonObject(); + + QJsonDocument doc(*obj); + QByteArray bytes = doc.toJson(); + delete obj; + return QString(bytes); +} + +QJsonObject* +SWGFeaturePresetItem::asJsonObject() { + QJsonObject* obj = new QJsonObject(); + if(description != nullptr && *description != QString("")){ + toJsonValue(QString("description"), description, obj, QString("QString")); + } + + return obj; +} + +QString* +SWGFeaturePresetItem::getDescription() { + return description; +} +void +SWGFeaturePresetItem::setDescription(QString* description) { + this->description = description; + this->m_description_isSet = true; +} + + +bool +SWGFeaturePresetItem::isSet(){ + bool isObjectUpdated = false; + do{ + if(description && *description != QString("")){ + isObjectUpdated = true; break; + } + }while(false); + return isObjectUpdated; +} +} + diff --git a/swagger/sdrangel/code/qt5/client/SWGFeaturePresetItem.h b/swagger/sdrangel/code/qt5/client/SWGFeaturePresetItem.h new file mode 100644 index 000000000..6aad6ada3 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGFeaturePresetItem.h @@ -0,0 +1,59 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time --- + * + * OpenAPI spec version: 6.0.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +/* + * SWGFeaturePresetItem.h + * + * Feature settings preset item + */ + +#ifndef SWGFeaturePresetItem_H_ +#define SWGFeaturePresetItem_H_ + +#include + + +#include + +#include "SWGObject.h" +#include "export.h" + +namespace SWGSDRangel { + +class SWG_API SWGFeaturePresetItem: public SWGObject { +public: + SWGFeaturePresetItem(); + SWGFeaturePresetItem(QString* json); + virtual ~SWGFeaturePresetItem(); + void init(); + void cleanup(); + + virtual QString asJson () override; + virtual QJsonObject* asJsonObject() override; + virtual void fromJsonObject(QJsonObject &json) override; + virtual SWGFeaturePresetItem* fromJson(QString &jsonString) override; + + QString* getDescription(); + void setDescription(QString* description); + + + virtual bool isSet() override; + +private: + QString* description; + bool m_description_isSet; + +}; + +} + +#endif /* SWGFeaturePresetItem_H_ */ diff --git a/swagger/sdrangel/code/qt5/client/SWGFeaturePresets.cpp b/swagger/sdrangel/code/qt5/client/SWGFeaturePresets.cpp new file mode 100644 index 000000000..40e6aaa7d --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGFeaturePresets.cpp @@ -0,0 +1,137 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time --- + * + * OpenAPI spec version: 6.0.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +#include "SWGFeaturePresets.h" + +#include "SWGHelpers.h" + +#include +#include +#include +#include + +namespace SWGSDRangel { + +SWGFeaturePresets::SWGFeaturePresets(QString* json) { + init(); + this->fromJson(*json); +} + +SWGFeaturePresets::SWGFeaturePresets() { + nb_groups = 0; + m_nb_groups_isSet = false; + groups = nullptr; + m_groups_isSet = false; +} + +SWGFeaturePresets::~SWGFeaturePresets() { + this->cleanup(); +} + +void +SWGFeaturePresets::init() { + nb_groups = 0; + m_nb_groups_isSet = false; + groups = new QList(); + m_groups_isSet = false; +} + +void +SWGFeaturePresets::cleanup() { + + if(groups != nullptr) { + auto arr = groups; + for(auto o: *arr) { + delete o; + } + delete groups; + } +} + +SWGFeaturePresets* +SWGFeaturePresets::fromJson(QString &json) { + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject jsonObject = doc.object(); + this->fromJsonObject(jsonObject); + return this; +} + +void +SWGFeaturePresets::fromJsonObject(QJsonObject &pJson) { + ::SWGSDRangel::setValue(&nb_groups, pJson["nbGroups"], "qint32", ""); + + + ::SWGSDRangel::setValue(&groups, pJson["groups"], "QList", "SWGFeaturePresetGroup"); +} + +QString +SWGFeaturePresets::asJson () +{ + QJsonObject* obj = this->asJsonObject(); + + QJsonDocument doc(*obj); + QByteArray bytes = doc.toJson(); + delete obj; + return QString(bytes); +} + +QJsonObject* +SWGFeaturePresets::asJsonObject() { + QJsonObject* obj = new QJsonObject(); + if(m_nb_groups_isSet){ + obj->insert("nbGroups", QJsonValue(nb_groups)); + } + if(groups && groups->size() > 0){ + toJsonArray((QList*)groups, obj, "groups", "SWGFeaturePresetGroup"); + } + + return obj; +} + +qint32 +SWGFeaturePresets::getNbGroups() { + return nb_groups; +} +void +SWGFeaturePresets::setNbGroups(qint32 nb_groups) { + this->nb_groups = nb_groups; + this->m_nb_groups_isSet = true; +} + +QList* +SWGFeaturePresets::getGroups() { + return groups; +} +void +SWGFeaturePresets::setGroups(QList* groups) { + this->groups = groups; + this->m_groups_isSet = true; +} + + +bool +SWGFeaturePresets::isSet(){ + bool isObjectUpdated = false; + do{ + if(m_nb_groups_isSet){ + isObjectUpdated = true; break; + } + if(groups && (groups->size() > 0)){ + isObjectUpdated = true; break; + } + }while(false); + return isObjectUpdated; +} +} + diff --git a/swagger/sdrangel/code/qt5/client/SWGFeaturePresets.h b/swagger/sdrangel/code/qt5/client/SWGFeaturePresets.h new file mode 100644 index 000000000..dd02101ee --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGFeaturePresets.h @@ -0,0 +1,66 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time --- + * + * OpenAPI spec version: 6.0.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +/* + * SWGFeaturePresets.h + * + * Feature settings presets + */ + +#ifndef SWGFeaturePresets_H_ +#define SWGFeaturePresets_H_ + +#include + + +#include "SWGFeaturePresetGroup.h" +#include + +#include "SWGObject.h" +#include "export.h" + +namespace SWGSDRangel { + +class SWG_API SWGFeaturePresets: public SWGObject { +public: + SWGFeaturePresets(); + SWGFeaturePresets(QString* json); + virtual ~SWGFeaturePresets(); + void init(); + void cleanup(); + + virtual QString asJson () override; + virtual QJsonObject* asJsonObject() override; + virtual void fromJsonObject(QJsonObject &json) override; + virtual SWGFeaturePresets* fromJson(QString &jsonString) override; + + qint32 getNbGroups(); + void setNbGroups(qint32 nb_groups); + + QList* getGroups(); + void setGroups(QList* groups); + + + virtual bool isSet() override; + +private: + qint32 nb_groups; + bool m_nb_groups_isSet; + + QList* groups; + bool m_groups_isSet; + +}; + +} + +#endif /* SWGFeaturePresets_H_ */ diff --git a/swagger/sdrangel/code/qt5/client/SWGInstanceApi.cpp b/swagger/sdrangel/code/qt5/client/SWGInstanceApi.cpp index 0ece46e18..aeba75b7d 100644 --- a/swagger/sdrangel/code/qt5/client/SWGInstanceApi.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGInstanceApi.cpp @@ -1056,6 +1056,113 @@ SWGInstanceApi::instanceDevicesCallback(SWGHttpRequestWorker * worker) { } } +void +SWGInstanceApi::instanceFeaturePresetDelete(SWGFeaturePresetIdentifier& body) { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/sdrangel/featurepreset"); + + + + SWGHttpRequestWorker *worker = new SWGHttpRequestWorker(); + SWGHttpRequestInput input(fullPath, "DELETE"); + + + + QString output = body.asJson(); + input.request_body.append(output); + + + + foreach(QString key, this->defaultHeaders.keys()) { + input.headers.insert(key, this->defaultHeaders.value(key)); + } + + connect(worker, + &SWGHttpRequestWorker::on_execution_finished, + this, + &SWGInstanceApi::instanceFeaturePresetDeleteCallback); + + worker->execute(&input); +} + +void +SWGInstanceApi::instanceFeaturePresetDeleteCallback(SWGHttpRequestWorker * worker) { + QString msg; + QString error_str = worker->error_str; + QNetworkReply::NetworkError error_type = worker->error_type; + + if (worker->error_type == QNetworkReply::NoError) { + msg = QString("Success! %1 bytes").arg(worker->response.length()); + } + else { + msg = "Error: " + worker->error_str; + } + + + QString json(worker->response); + SWGFeaturePresetIdentifier* output = static_cast(create(json, QString("SWGFeaturePresetIdentifier"))); + worker->deleteLater(); + + if (worker->error_type == QNetworkReply::NoError) { + emit instanceFeaturePresetDeleteSignal(output); + } else { + emit instanceFeaturePresetDeleteSignalE(output, error_type, error_str); + emit instanceFeaturePresetDeleteSignalEFull(worker, error_type, error_str); + } +} + +void +SWGInstanceApi::instanceFeaturePresetGet() { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/sdrangel/featurepresets"); + + + + SWGHttpRequestWorker *worker = new SWGHttpRequestWorker(); + SWGHttpRequestInput input(fullPath, "GET"); + + + + + + foreach(QString key, this->defaultHeaders.keys()) { + input.headers.insert(key, this->defaultHeaders.value(key)); + } + + connect(worker, + &SWGHttpRequestWorker::on_execution_finished, + this, + &SWGInstanceApi::instanceFeaturePresetGetCallback); + + worker->execute(&input); +} + +void +SWGInstanceApi::instanceFeaturePresetGetCallback(SWGHttpRequestWorker * worker) { + QString msg; + QString error_str = worker->error_str; + QNetworkReply::NetworkError error_type = worker->error_type; + + if (worker->error_type == QNetworkReply::NoError) { + msg = QString("Success! %1 bytes").arg(worker->response.length()); + } + else { + msg = "Error: " + worker->error_str; + } + + + QString json(worker->response); + SWGFeaturePresets* output = static_cast(create(json, QString("SWGFeaturePresets"))); + worker->deleteLater(); + + if (worker->error_type == QNetworkReply::NoError) { + emit instanceFeaturePresetGetSignal(output); + } else { + emit instanceFeaturePresetGetSignalE(output, error_type, error_str); + emit instanceFeaturePresetGetSignalEFull(worker, error_type, error_str); + } +} + void SWGInstanceApi::instanceFeatureSetsGet() { QString fullPath; diff --git a/swagger/sdrangel/code/qt5/client/SWGInstanceApi.h b/swagger/sdrangel/code/qt5/client/SWGInstanceApi.h index b2700bfb4..faeefcfcc 100644 --- a/swagger/sdrangel/code/qt5/client/SWGInstanceApi.h +++ b/swagger/sdrangel/code/qt5/client/SWGInstanceApi.h @@ -23,6 +23,8 @@ #include "SWGDVSerialDevices.h" #include "SWGDeviceSetList.h" #include "SWGErrorResponse.h" +#include "SWGFeaturePresetIdentifier.h" +#include "SWGFeaturePresets.h" #include "SWGFeatureSetList.h" #include "SWGInstanceChannelsResponse.h" #include "SWGInstanceConfigResponse.h" @@ -76,6 +78,8 @@ public: void instanceDelete(); void instanceDeviceSetsGet(); void instanceDevices(qint32 direction); + void instanceFeaturePresetDelete(SWGFeaturePresetIdentifier& body); + void instanceFeaturePresetGet(); void instanceFeatureSetsGet(); void instanceFeatures(); void instanceLimeRFEConfigGet(QString* serial); @@ -116,6 +120,8 @@ private: void instanceDeleteCallback (SWGHttpRequestWorker * worker); void instanceDeviceSetsGetCallback (SWGHttpRequestWorker * worker); void instanceDevicesCallback (SWGHttpRequestWorker * worker); + void instanceFeaturePresetDeleteCallback (SWGHttpRequestWorker * worker); + void instanceFeaturePresetGetCallback (SWGHttpRequestWorker * worker); void instanceFeatureSetsGetCallback (SWGHttpRequestWorker * worker); void instanceFeaturesCallback (SWGHttpRequestWorker * worker); void instanceLimeRFEConfigGetCallback (SWGHttpRequestWorker * worker); @@ -156,6 +162,8 @@ signals: void instanceDeleteSignal(SWGInstanceSummaryResponse* summary); void instanceDeviceSetsGetSignal(SWGDeviceSetList* summary); void instanceDevicesSignal(SWGInstanceDevicesResponse* summary); + void instanceFeaturePresetDeleteSignal(SWGFeaturePresetIdentifier* summary); + void instanceFeaturePresetGetSignal(SWGFeaturePresets* summary); void instanceFeatureSetsGetSignal(SWGFeatureSetList* summary); void instanceFeaturesSignal(SWGInstanceFeaturesResponse* summary); void instanceLimeRFEConfigGetSignal(SWGLimeRFESettings* summary); @@ -195,6 +203,8 @@ signals: void instanceDeleteSignalE(SWGInstanceSummaryResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str); void instanceDeviceSetsGetSignalE(SWGDeviceSetList* summary, QNetworkReply::NetworkError error_type, QString& error_str); void instanceDevicesSignalE(SWGInstanceDevicesResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str); + void instanceFeaturePresetDeleteSignalE(SWGFeaturePresetIdentifier* summary, QNetworkReply::NetworkError error_type, QString& error_str); + void instanceFeaturePresetGetSignalE(SWGFeaturePresets* summary, QNetworkReply::NetworkError error_type, QString& error_str); void instanceFeatureSetsGetSignalE(SWGFeatureSetList* summary, QNetworkReply::NetworkError error_type, QString& error_str); void instanceFeaturesSignalE(SWGInstanceFeaturesResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str); void instanceLimeRFEConfigGetSignalE(SWGLimeRFESettings* summary, QNetworkReply::NetworkError error_type, QString& error_str); @@ -234,6 +244,8 @@ signals: void instanceDeleteSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void instanceDeviceSetsGetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void instanceDevicesSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); + void instanceFeaturePresetDeleteSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); + void instanceFeaturePresetGetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void instanceFeatureSetsGetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void instanceFeaturesSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void instanceLimeRFEConfigGetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); diff --git a/swagger/sdrangel/code/qt5/client/SWGModelFactory.h b/swagger/sdrangel/code/qt5/client/SWGModelFactory.h index 8d21beeec..c7affe57e 100644 --- a/swagger/sdrangel/code/qt5/client/SWGModelFactory.h +++ b/swagger/sdrangel/code/qt5/client/SWGModelFactory.h @@ -104,6 +104,10 @@ #include "SWGFeatureActions.h" #include "SWGFeatureConfig.h" #include "SWGFeatureListItem.h" +#include "SWGFeaturePresetGroup.h" +#include "SWGFeaturePresetIdentifier.h" +#include "SWGFeaturePresetItem.h" +#include "SWGFeaturePresets.h" #include "SWGFeatureReport.h" #include "SWGFeatureSet.h" #include "SWGFeatureSetList.h" @@ -734,6 +738,26 @@ namespace SWGSDRangel { obj->init(); return obj; } + if(QString("SWGFeaturePresetGroup").compare(type) == 0) { + SWGFeaturePresetGroup *obj = new SWGFeaturePresetGroup(); + obj->init(); + return obj; + } + if(QString("SWGFeaturePresetIdentifier").compare(type) == 0) { + SWGFeaturePresetIdentifier *obj = new SWGFeaturePresetIdentifier(); + obj->init(); + return obj; + } + if(QString("SWGFeaturePresetItem").compare(type) == 0) { + SWGFeaturePresetItem *obj = new SWGFeaturePresetItem(); + obj->init(); + return obj; + } + if(QString("SWGFeaturePresets").compare(type) == 0) { + SWGFeaturePresets *obj = new SWGFeaturePresets(); + obj->init(); + return obj; + } if(QString("SWGFeatureReport").compare(type) == 0) { SWGFeatureReport *obj = new SWGFeatureReport(); obj->init();