get rid of the ugly policy callbacks while we're breaking the ABI, add new pool_set_c...
authorMichael Schroeder <mls@suse.de>
Wed, 6 Mar 2013 16:53:06 +0000 (17:53 +0100)
committerMichael Schroeder <mls@suse.de>
Wed, 6 Mar 2013 16:53:06 +0000 (17:53 +0100)
src/libsolv.ver
src/policy.c
src/pool.c
src/pool.h
src/solver.h

index aa23112..52b51da 100644 (file)
@@ -90,6 +90,7 @@ SOLV_1.0 {
                pool_rel2id;
                pool_search;
                pool_selection2str;
+               pool_set_custom_vendorcheck;
                pool_set_flag;
                pool_set_installed;
                pool_set_languages;
index 6243e09..916590c 100644 (file)
@@ -601,11 +601,6 @@ prune_to_best_version(Pool *pool, Queue *plist)
 static void
 prune_best_arch_name_version(const Solver *solv, Pool *pool, Queue *plist)
 {
-  if (solv && solv->bestSolvableCb)
-    { /* The application is responsible for */
-      return solv->bestSolvableCb(solv->pool, plist);
-    }
-
   if (plist->count > 1)
     prune_to_best_arch(pool, plist);
   if (plist->count > 1)
@@ -675,11 +670,6 @@ policy_illegal_archchange(Solver *solv, Solvable *s1, Solvable *s2)
   Pool *pool = solv->pool;
   Id a1 = s1->arch, a2 = s2->arch;
 
-  if (solv && solv->archCheckCb)
-    { /* The application is responsible for */
-      return solv->archCheckCb(solv->pool, s1, s2);
-    }
-
   /* we allow changes to/from noarch */
   if (a1 == a2 || a1 == pool->noarchid || a2 == pool->noarchid)
     return 0;
@@ -701,10 +691,9 @@ policy_illegal_vendorchange(Solver *solv, Solvable *s1, Solvable *s2)
   Id v1, v2;
   Id vendormask1, vendormask2;
 
-  if (solv->vendorCheckCb)
-   {   /* The application is responsible for */
-     return solv->vendorCheckCb(pool, s1, s2);
-   }
+  if (pool->custom_vendorcheck)
+     return pool->custom_vendorcheck(pool, s1, s2);
+
   /* treat a missing vendor as empty string */
   v1 = s1->vendor ? s1->vendor : ID_EMPTY;
   v2 = s2->vendor ? s2->vendor : ID_EMPTY;
@@ -869,11 +858,6 @@ policy_findupdatepackages(Solver *solv, Solvable *s, Queue *qs, int allow_all)
 
   queue_empty(qs);
 
-  if (solv && solv->updateCandidateCb)
-    { /* The application is responsible for */
-      return solv->updateCandidateCb(solv->pool, s, qs);
-    }
-
   n = s - pool->solvables;
 
   /*
index b65a1c2..3b27318 100644 (file)
@@ -2199,4 +2199,11 @@ pool_get_rootdir(Pool *pool)
   return pool->rootdir;
 }
 
+/* only used in libzypp */
+void
+pool_set_custom_vendorcheck(Pool *pool, int (*vendorcheck)(Pool *, Solvable *, Solvable *))
+{
+  pool->custom_vendorcheck = vendorcheck;
+}
+
 /* EOF */
index e785cd8..482aefb 100644 (file)
@@ -148,8 +148,8 @@ struct _Pool {
 
   char *rootdir;
 
+  int (*custom_vendorcheck)(struct _Pool *, Solvable *, Solvable *);
 #endif
-
 };
 
 #define DISTTYPE_RPM   0
@@ -223,6 +223,7 @@ extern void pool_debug(Pool *pool, int type, const char *format, ...) __attribut
 extern void pool_setdebugcallback(Pool *pool, void (*debugcallback)(struct _Pool *, void *data, int type, const char *str), void *debugcallbackdata);
 extern void pool_setdebugmask(Pool *pool, int mask);
 extern void pool_setloadcallback(Pool *pool, int (*cb)(struct _Pool *, struct _Repodata *, void *), void *loadcbdata);
+extern void pool_set_custom_vendorcheck(Pool *pool, int (*vendorcheck)(struct _Pool *, Solvable *, Solvable *));
 
 
 extern char *pool_alloctmpspace(Pool *pool, int len);
index a51b173..b735329 100644 (file)
@@ -26,15 +26,6 @@ extern "C" {
 #include "rules.h"
 #include "problems.h"
 
-/*
- * Callback definitions in order to "overwrite" the policies by an external application.
- */
-typedef void (*BestSolvableCb) (Pool *pool, Queue *canditates);
-typedef int  (*ArchCheckCb) (Pool *pool, Solvable *solvable1, Solvable *solvable2);
-typedef int  (*VendorCheckCb) (Pool *pool, Solvable *solvable1, Solvable *solvable2);
-typedef void (*UpdateCandidateCb) (Pool *pool, Solvable *solvable, Queue *canditates);
-
 
 struct _Solver {
   Pool *pool;                          /* back pointer to pool */
@@ -43,46 +34,7 @@ struct _Solver {
   int (*solution_callback)(struct _Solver *solv, void *data);
   void *solution_callback_data;
 
-  /* Callbacks for defining the bahaviour of the solver */
-
-  /* Finding best candidate
-   *
-   * Callback definition:
-   * void  bestSolvable (Pool *pool, Queue *canditates)
-   *     candidates       : List of canditates which has to be sorted by the function call
-   *     return candidates: Sorted list of the candidates(first is the best).
-   */
-  BestSolvableCb bestSolvableCb;
-
-  /* Checking if two solvables has compatible architectures
-   *
-   * Callback definition:
-   *     int  archCheck (Pool *pool, Solvable *solvable1, Solvable *solvable2);
-   *     
-   *     return 0 it the two solvables has compatible architectures
-   */
-  ArchCheckCb archCheckCb;
-
-  /* Checking if two solvables has compatible vendors
-   *
-   * Callback definition:
-   *     int  vendorCheck (Pool *pool, Solvable *solvable1, Solvable *solvable2);
-   *     
-   *     return 0 it the two solvables has compatible architectures
-   */
-  VendorCheckCb vendorCheckCb;
-    
-  /* Evaluate update candidate
-   *
-   * Callback definition:
-   * void UpdateCandidateCb (Pool *pool, Solvable *solvable, Queue *canditates)
-   *     solvable   : for which updates should be search
-   *     candidates : List of candidates (This list depends on other
-   *                  restrictions like architecture and vendor policies too)
-   */
-  UpdateCandidateCb   updateCandidateCb;
-
-  int pooljobcnt;              /* number of pooljob entries in job queue */
+  int pooljobcnt;                      /* number of pooljob entries in job queue */
 
 #ifdef LIBSOLV_INTERNAL
   Repo *installed;                     /* copy of pool->installed */