Author: lslezak
Date: Thu Sep 4 13:58:10 2008
New Revision: 50659
URL: http://svn.opensuse.org/viewcvs/yast?rev=50659&view=rev
Log:
- added support for services, new functions: Pkg::ServiceAliases(),
Pkg::ServiceAdd() Pkg::ServiceDelete(), Pkg::ServiceGet(),
Pkg::ServiceSet(), Pkg::ServicesSave(), Pkg::ServicesLoad(),
Pkg::ServiceRefresh(), Pkg::ServicesReset()
- 2.17.9
Added:
trunk/pkg-bindings/src/Service.cc
Modified:
trunk/pkg-bindings/VERSION
trunk/pkg-bindings/doc/builtins.xml
trunk/pkg-bindings/package/yast2-pkg-bindings.changes
trunk/pkg-bindings/src/Makefile.am
trunk/pkg-bindings/src/PkgFunctions.h
trunk/pkg-bindings/src/ServiceManager.cc
Modified: trunk/pkg-bindings/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/VERSION?rev=50659&r1=50658&r2=50659&view=diff
==============================================================================
--- trunk/pkg-bindings/VERSION (original)
+++ trunk/pkg-bindings/VERSION Thu Sep 4 13:58:10 2008
@@ -1 +1 @@
-2.17.8
+2.17.9
Modified: trunk/pkg-bindings/doc/builtins.xml
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/doc/builtins.xml?rev=50659&r1=50658&r2=50659&view=diff
==============================================================================
--- trunk/pkg-bindings/doc/builtins.xml (original)
+++ trunk/pkg-bindings/doc/builtins.xml Thu Sep 4 13:58:10 2008
@@ -22,6 +22,7 @@
<!ENTITY PkgModuleFunctionsSource_Load SYSTEM "Source_Load.xml">
<!ENTITY PkgModuleFunctionsSource_Save SYSTEM "Source_Save.xml">
<!ENTITY PkgModuleFunctionsSource_Set SYSTEM "Source_Set.xml">
+<!ENTITY PkgModuleFunctionsService SYSTEM "Service.xml">
<!ENTITY PkgModuleFunctionsTarget_DU SYSTEM "Target_DU.xml">
<!ENTITY PkgModuleFunctionsTarget_Load SYSTEM "Target_Load.xml">
<!ENTITY PkgModuleFunctionsTarget SYSTEM "Target.xml">
@@ -75,6 +76,7 @@
&PkgModuleFunctionsSource_Load;
&PkgModuleFunctionsSource_Save;
&PkgModuleFunctionsSource_Set;
+ &PkgModuleFunctionsService;
&PkgModuleFunctionsTarget_DU;
&PkgModuleFunctionsTarget_Load;
&PkgModuleFunctionsTarget;
Modified: trunk/pkg-bindings/package/yast2-pkg-bindings.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/package/yast2-pkg-bindings.changes?rev=50659&r1=50658&r2=50659&view=diff
==============================================================================
--- trunk/pkg-bindings/package/yast2-pkg-bindings.changes (original)
+++ trunk/pkg-bindings/package/yast2-pkg-bindings.changes Thu Sep 4 13:58:10 2008
@@ -1,4 +1,13 @@
-------------------------------------------------------------------
+Thu Sep 4 12:53:53 CEST 2008 - lslezak@suse.cz
+
+- added support for services, new functions: Pkg::ServiceAliases(),
+ Pkg::ServiceAdd() Pkg::ServiceDelete(), Pkg::ServiceGet(),
+ Pkg::ServiceSet(), Pkg::ServicesSave(), Pkg::ServicesLoad(),
+ Pkg::ServiceRefresh(), Pkg::ServicesReset()
+- 2.17.9
+
+-------------------------------------------------------------------
Thu Aug 21 14:02:01 CEST 2008 - lslezak@suse.cz
- 2.17.8
Modified: trunk/pkg-bindings/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Makefile.am?rev=50659&r1=50658&r2=50659&view=diff
==============================================================================
--- trunk/pkg-bindings/src/Makefile.am (original)
+++ trunk/pkg-bindings/src/Makefile.am Thu Sep 4 13:58:10 2008
@@ -53,6 +53,7 @@
YRepo.h YRepo.cc \
PkgService.cc PkgService.h \
ServiceManager.cc ServiceManager.h \
+ Service.cc \
HelpTexts.h i18n.h log.h
Modified: trunk/pkg-bindings/src/PkgFunctions.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/PkgFunctions.h?rev=50659&r1=50658&r2=50659&view=diff
==============================================================================
--- trunk/pkg-bindings/src/PkgFunctions.h (original)
+++ trunk/pkg-bindings/src/PkgFunctions.h Thu Sep 4 13:58:10 2008
@@ -51,6 +51,8 @@
#include
#include
+#include "ServiceManager.h"
+
#include "PkgError.h"
class PkgProgress;
@@ -176,6 +178,8 @@
bool target_log_set;
+ ServiceManager service_manager;
+
/**
* Logging helper:
* search for a repository and in case of exception, log error
@@ -754,6 +758,27 @@
/* TYPEINFO: boolean(string)*/
YCPValue SourceMoveDownloadArea (const YCPString & path);
+ // services related functions
+ /* TYPEINFO: list<string>()*/
+ YCPValue ServiceAliases();
+ /* TYPEINFO: boolean(string,string)*/
+ YCPValue ServiceAdd(const YCPString&, const YCPString&);
+ /* TYPEINFO: boolean(string)*/
+ YCPValue ServiceDelete(const YCPString&);
+ /* TYPEINFO: map(string)*/
+ YCPValue ServiceGet(const YCPString&);
+ /* TYPEINFO: boolean(string,map)*/
+ YCPValue ServiceSet(const YCPString&, const YCPMap&);
+ /* TYPEINFO: boolean()*/
+ YCPValue ServicesSave();
+ /* TYPEINFO: boolean()*/
+ YCPValue ServicesLoad();
+ /* TYPEINFO: boolean(string)*/
+ YCPValue ServiceRefresh(const YCPString&);
+ /* TYPEINFO: void()*/
+ YCPValue ServicesReset();
+
+
YCPValue ResolvablePropertiesEx(const YCPString& name, const YCPSymbol& kind_r, const YCPString& version, bool dependencies);
YCPValue ResolvableSetPatches(const YCPSymbol& kind_r, bool preselect);
Added: trunk/pkg-bindings/src/Service.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Service.cc?rev=50659&view=auto
==============================================================================
--- trunk/pkg-bindings/src/Service.cc (added)
+++ trunk/pkg-bindings/src/Service.cc Thu Sep 4 13:58:10 2008
@@ -0,0 +1,271 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2008 Novell, Inc. All Rights Reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of version 2 of the GNU General Public License as published by the
+ * Free Software Foundation.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may find
+ * current contact information at www.novell.com.
+ * ------------------------------------------------------------------------------
+ */
+
+/*
+ File: $Id$
+ Author: Ladislav Slezák
+ Summary: Functions for accessing services in the package management
+ Namespace: Pkg
+*/
+
+#include "PkgFunctions.h"
+#include "log.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+/**
+ @builtin ServiceAliases
+ @short Returns aliases of all known services.
+ @return list<string> list of known aliases
+*/
+YCPValue PkgFunctions::ServiceAliases()
+{
+ YCPList ret;
+
+ ServiceManager::Services services = service_manager.GetServices();
+
+ for_(it, services.begin(), services.end())
+ {
+ ret->add(YCPString(it->alias()));
+ }
+
+ return ret;
+}
+
+/**
+ @builtin ServiceAdd
+ @short Add a new service
+ @param alias alias of the new service, must be unique
+ @param url URL of the serivce
+ @return boolean false if failed
+*/
+YCPValue PkgFunctions::ServiceAdd(const YCPString &alias, const YCPString &url)
+{
+ try
+ {
+ if (alias.isNull() || url.isNull())
+ {
+ y2error("Found nil parameter in Pkg::ServiceAdd()");
+ return YCPBoolean(false);
+ }
+
+ return YCPBoolean(service_manager.AddService(alias->value(), url->value()));
+ }
+ catch(...)
+ {
+ }
+
+ return YCPBoolean(false);
+}
+
+/**
+ @builtin ServiceDelete
+ @short Remove a service
+ @param alias alias of the service to remove
+ @return boolean false if failed
+*/
+YCPValue PkgFunctions::ServiceDelete(const YCPString &alias)
+{
+ try
+ {
+ if (alias.isNull())
+ {
+ y2error("Found nil parameter in Pkg::ServiceDelete()");
+ return YCPBoolean(false);
+ }
+
+ return YCPBoolean(service_manager.RemoveService(alias->value()));
+ }
+ catch(...)
+ {
+ }
+
+ return YCPBoolean(false);
+}
+
+
+/**
+ @builtin ServiceGet
+ @short Get detailed properties of a service
+ @param alias alias of the service
+ @return map Service data in map $[ "alias":string, "name":string, "url":string, "autorefresh":boolean, "enabled":boolean, "file":string ]. "file" is name of the file from which the service has been read, it is empty if the service has not been saved yet
+*/
+YCPValue PkgFunctions::ServiceGet(const YCPString &alias)
+{
+ if (alias.isNull())
+ {
+ y2error("Error: nil service name");
+ return YCPVoid();
+ }
+
+ YCPMap ret;
+ zypp::ServiceInfo s(service_manager.GetService(alias->value()));
+
+ ret->add(YCPString("alias"), YCPString(s.alias()));
+ ret->add(YCPString("name"), YCPString(s.name()));
+ ret->add(YCPString("url"), YCPString(s.url().asString()));
+ ret->add(YCPString("autorefresh"), YCPBoolean(s.autorefresh()));
+ ret->add(YCPString("enabled"), YCPBoolean(s.enabled()));
+ ret->add(YCPString("file"), YCPString(s.filepath().asString()));
+
+ return ret;
+}
+
+/**
+ @builtin ServiceSet
+ @short Set properties of a service
+ @param alias old of the service, if the service is being renamed here is the old alias, the new alias is in the map (the second parameter)
+ @param service new properties of the service, see Pkg::ServiceGet() for the description
+ @return boolean false if failed
+*/
+YCPValue PkgFunctions::ServiceSet(const YCPString &old_alias, const YCPMap &service)
+{
+ if (old_alias.isNull() || service.isNull())
+ {
+ y2error("Error: nil parameter");
+ return YCPBoolean(false);
+ }
+
+ try
+ {
+ zypp::ServiceInfo s(service_manager.GetService(old_alias->value()));
+ YCPValue v;
+
+ v = service->value(YCPString("alias"));
+ if(!v.isNull() && v->isString())
+ {
+ s.setAlias(v->asString()->value());
+ }
+
+ v = service->value(YCPString("name"));
+ if(!v.isNull() && v->isString())
+ {
+ s.setName(v->asString()->value());
+ }
+
+ v = service->value(YCPString("url"));
+ if(!v.isNull() && v->isString())
+ {
+ s.setUrl(v->asString()->value());
+ }
+
+ v = service->value(YCPString("autorefresh"));
+ if(!v.isNull() && v->isBoolean())
+ {
+ s.setAutorefresh(v->asBoolean()->value());
+ }
+
+ v = service->value(YCPString("enabled"));
+ if(!v.isNull() && v->isBoolean())
+ {
+ s.setEnabled(v->asBoolean()->value());
+ }
+
+ // note: do not allow to change the file name?
+
+ return YCPBoolean(service_manager.SetService(old_alias->value(), s));
+ }
+ catch(...)
+ {
+ }
+
+ return YCPBoolean(false);
+}
+
+/**
+ @builtin ServicesSave
+ @short Save the current service configuration to disk.
+ @return boolean false if failed
+*/
+YCPValue PkgFunctions::ServicesSave()
+{
+ try
+ {
+ zypp::RepoManager repomanager = CreateRepoManager();
+ return YCPBoolean(service_manager.SaveServices(repomanager));
+ }
+ catch(...)
+ {
+ }
+
+ return YCPBoolean(false);
+}
+
+/**
+ @builtin ServicesLoad
+ @short Load service configurations from disk. If the services have alrady been loaded it does nothing.
+ @return boolean false if failed
+*/
+YCPValue PkgFunctions::ServicesLoad()
+{
+ try
+ {
+ zypp::RepoManager repomanager = CreateRepoManager();
+ return YCPBoolean(service_manager.LoadServices(repomanager));
+ }
+ catch(...)
+ {
+ }
+
+ return YCPBoolean(false);
+}
+
+/**
+ @builtin ServiceRefresh
+ @short Refresh the service, the service must already be saved on the system!
+ @param alias alias of the service to refresh
+ @return boolean false if failed
+*/
+YCPValue PkgFunctions::ServiceRefresh(const YCPString &alias)
+{
+ try
+ {
+ if (alias.isNull())
+ {
+ y2error("Error: nil parameter");
+ return YCPBoolean(false);
+ }
+
+ zypp::RepoManager repomanager = CreateRepoManager();
+ return YCPBoolean(service_manager.RefreshService(alias->value(), repomanager));
+ }
+ catch(...)
+ {
+ }
+
+ return YCPBoolean(false);
+}
+
+/**
+ @builtin ServicesReset
+ @short Reset the list of known services. All changes are lost.
+*/
+YCPValue PkgFunctions::ServicesReset()
+{
+ service_manager.Reset();
+ return YCPVoid();
+}
+
Modified: trunk/pkg-bindings/src/ServiceManager.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/ServiceManager.cc?rev=50659&r1=50658&r2=50659&view=diff
==============================================================================
--- trunk/pkg-bindings/src/ServiceManager.cc (original)
+++ trunk/pkg-bindings/src/ServiceManager.cc Thu Sep 4 13:58:10 2008
@@ -106,7 +106,7 @@
}
catch(...)
{
- y2error("Cannot service %s", alias.c_str());
+ y2error("Cannot save service %s", alias.c_str());
ret = false;
}
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org