diff options
-rw-r--r-- | mof/60_LMI_Software.mof | 10 | ||||
-rw-r--r-- | src/software-dbus/LMI_SoftwareInstallationServiceCapabilitiesProvider.c | 100 | ||||
-rw-r--r-- | src/software-dbus/sw-utils.c | 3 |
3 files changed, 105 insertions, 8 deletions
diff --git a/mof/60_LMI_Software.mof b/mof/60_LMI_Software.mof index c5ff844..b8611f3 100644 --- a/mof/60_LMI_Software.mof +++ b/mof/60_LMI_Software.mof @@ -692,10 +692,16 @@ class LMI_SoftwareInstallationServiceCapabilities : [Implemented(true), Override("SupportedURISchemes")] uint16 SupportedURISchemes[]; - [Implemented(true), Override("SupportedAsynchronousActions")] + [Implemented(true), Override("SupportedAsynchronousActions"), + ValueMap { "2", "3", "4", "5", "10000" }, + Values { "None supported", "Install From Software Identity", + "Install from ByteStream", "Install from URI", "Verify Software Identity" }] uint16 SupportedAsynchronousActions[]; - [Implemented(true), Override("SupportedSynchronousActions")] + [Implemented(true), Override("SupportedSynchronousActions"), + ValueMap { "2", "3", "4", "5", "10000" }, + Values { "None supported", "Install From Software Identity", + "Install from ByteStream", "Install from URI", "Verify Software Identity" }] uint16 SupportedSynchronousActions[]; }; diff --git a/src/software-dbus/LMI_SoftwareInstallationServiceCapabilitiesProvider.c b/src/software-dbus/LMI_SoftwareInstallationServiceCapabilitiesProvider.c index 8b487bd..92f95bc 100644 --- a/src/software-dbus/LMI_SoftwareInstallationServiceCapabilitiesProvider.c +++ b/src/software-dbus/LMI_SoftwareInstallationServiceCapabilitiesProvider.c @@ -1,10 +1,34 @@ +/* + * Copyright (C) 2013-2014 Red Hat, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Peter Schiffer <pschiffe@redhat.com> + */ + #include <konkret/konkret.h> #include "LMI_SoftwareInstallationServiceCapabilities.h" +#include "LMI_SoftwareInstallationService.h" +#include "sw-utils.h" +#include "config.h" static const CMPIBroker* _cb = NULL; -static void LMI_SoftwareInstallationServiceCapabilitiesInitialize() +static void LMI_SoftwareInstallationServiceCapabilitiesInitialize(const CMPIContext *ctx) { + lmi_init(provider_name, _cb, ctx, provider_config_defaults); } static CMPIStatus LMI_SoftwareInstallationServiceCapabilitiesCleanup( @@ -32,6 +56,76 @@ static CMPIStatus LMI_SoftwareInstallationServiceCapabilitiesEnumInstances( const CMPIObjectPath* cop, const char** properties) { + char instance_id[BUFLEN], buf[BUFLEN]; + + LMI_SoftwareInstallationServiceCapabilities w; + LMI_SoftwareInstallationServiceCapabilities_Init(&w, _cb, KNameSpace(cop)); + + LMI_SoftwareInstallationServiceCapabilities_Set_CanAddToCollection(&w, 1); + LMI_SoftwareInstallationServiceCapabilities_Init_SupportedInstallOptions(&w, 3); + LMI_SoftwareInstallationServiceCapabilities_Set_SupportedInstallOptions_Install(&w, 0); + LMI_SoftwareInstallationServiceCapabilities_Set_SupportedInstallOptions_Update(&w, 1); + LMI_SoftwareInstallationServiceCapabilities_Set_SupportedInstallOptions_Uninstall(&w, 2); + LMI_SoftwareInstallationServiceCapabilities_Init_SupportedSynchronousActions(&w, 1); + LMI_SoftwareInstallationServiceCapabilities_Set_SupportedSynchronousActions_None_supported(&w, 0); + LMI_SoftwareInstallationServiceCapabilities_Init_SupportedTargetTypes(&w, 0); + LMI_SoftwareInstallationServiceCapabilities_Init_SupportedURISchemes(&w, 3); + LMI_SoftwareInstallationServiceCapabilities_Set_SupportedURISchemes_file(&w, 0); + LMI_SoftwareInstallationServiceCapabilities_Set_SupportedURISchemes_http(&w, 1); + LMI_SoftwareInstallationServiceCapabilities_Set_SupportedURISchemes_https(&w, 2); + LMI_SoftwareInstallationServiceCapabilities_Set_ElementName(&w, + "Software Installation Service Capabilities"); + + create_instance_id(LMI_SoftwareInstallationServiceCapabilities_ClassName, + NULL, instance_id, BUFLEN); + LMI_SoftwareInstallationServiceCapabilities_Set_InstanceID(&w, instance_id); + + create_instance_id(LMI_SoftwareInstallationService_ClassName, NULL, + instance_id, BUFLEN); + snprintf(buf, BUFLEN, "Capabilities of %s", instance_id); + LMI_SoftwareInstallationServiceCapabilities_Set_Caption(&w, buf); + snprintf(buf, BUFLEN, + "This instance provides information about capabilities of %s.", + instance_id); + LMI_SoftwareInstallationServiceCapabilities_Set_Description(&w, buf); + +#ifndef RPM_FOUND + LMI_SoftwareInstallationServiceCapabilities_Init_SupportedAsynchronousActions(&w, 2); +#else + LMI_SoftwareInstallationServiceCapabilities_Init_SupportedAsynchronousActions(&w, 3); + LMI_SoftwareInstallationServiceCapabilities_Set_SupportedAsynchronousActions_Verify_Software_Identity(&w, 2); +#endif + LMI_SoftwareInstallationServiceCapabilities_Set_SupportedAsynchronousActions_Install_From_Software_Identity(&w, 0); + LMI_SoftwareInstallationServiceCapabilities_Set_SupportedAsynchronousActions_Install_from_URI(&w, 1); + + LMI_SoftwareInstallationServiceCapabilities_Init_SupportedExtendedResourceTypes(&w, 1); + gchar *backend_name = NULL; + PkControl *control = pk_control_new(); + if (control && pk_control_get_properties(control, NULL, NULL)) { + g_object_get(control, "backend-name", &backend_name, NULL); + if (!backend_name || !*backend_name) { + LMI_SoftwareInstallationServiceCapabilities_Set_SupportedExtendedResourceTypes_Unknown(&w, 0); + } else if (strcmp(backend_name, "yum") == 0 + || strcmp(backend_name, "zypp") == 0 + || strcmp(backend_name, "urpmi") == 0 + || strcmp(backend_name, "hif") == 0 + || strcmp(backend_name, "poldek") == 0) { + LMI_SoftwareInstallationServiceCapabilities_Set_SupportedExtendedResourceTypes_Linux_RPM(&w, 0); + } else if (strcmp(backend_name, "apt") == 0 + || strcmp(backend_name, "aptcc") == 0) { + LMI_SoftwareInstallationServiceCapabilities_Set_SupportedExtendedResourceTypes_Debian_linux_Package(&w, 0); + } else { + LMI_SoftwareInstallationServiceCapabilities_Set_SupportedExtendedResourceTypes_Other(&w, 0); + } + g_free(backend_name); + backend_name = NULL; + g_clear_object(&control); + } else { + LMI_SoftwareInstallationServiceCapabilities_Set_SupportedExtendedResourceTypes_Unknown(&w, 0); + } + + KReturnInstance(cr, w); + CMReturn(CMPI_RC_OK); } @@ -91,7 +185,7 @@ CMInstanceMIStub( LMI_SoftwareInstallationServiceCapabilities, LMI_SoftwareInstallationServiceCapabilities, _cb, - LMI_SoftwareInstallationServiceCapabilitiesInitialize()) + LMI_SoftwareInstallationServiceCapabilitiesInitialize(ctx)) static CMPIStatus LMI_SoftwareInstallationServiceCapabilitiesMethodCleanup( CMPIMethodMI* mi, @@ -118,7 +212,7 @@ CMMethodMIStub( LMI_SoftwareInstallationServiceCapabilities, LMI_SoftwareInstallationServiceCapabilities, _cb, - LMI_SoftwareInstallationServiceCapabilitiesInitialize()) + LMI_SoftwareInstallationServiceCapabilitiesInitialize(ctx)) KUint16 LMI_SoftwareInstallationServiceCapabilities_CreateGoalSettings( const CMPIBroker* cb, diff --git a/src/software-dbus/sw-utils.c b/src/software-dbus/sw-utils.c index 93966c3..7f83603 100644 --- a/src/software-dbus/sw-utils.c +++ b/src/software-dbus/sw-utils.c @@ -373,9 +373,6 @@ void create_instance_from_pkgkit_data(PkPackage *pk_pkg, PkDetails *pk_det, LMI_SoftwareIdentity_Init_Classifications(w, 1); LMI_SoftwareIdentity_Set_Classifications(w, 0, 0); - LMI_SoftwareIdentity_Init_TargetTypes(w, 2); - LMI_SoftwareIdentity_Set_TargetTypes(w, 0, "rpm"); - LMI_SoftwareIdentity_Set_TargetTypes(w, 1, "yum"); LMI_SoftwareIdentity_Set_IsEntity(w, 1); LMI_SoftwareIdentity_Set_Architecture(w, sw_pkg->arch); |