Package: goplay
Version: 0.3-1+b2
Severity: wishlist
Tags: patch

Hello,

I am preparing a new version of libept after quite aggressively
simplifying its code.

I'm now testing its reverse dependencies to see how the libept changes
impact their code and functions.

I'm posting here, for reference, the patch needed to make goplay work
with the version of libept I just committed to the libept git repo.
There is no functionality loss in goplay, just the code got a bit
simpler and a bit more readable.

When I'm ready to upload libept 1.0, we can then followup with the
goplay update.


Ciao,

Enrico

-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-trunk-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages goplay depends on:
ii  apt [libapt-pkg-libc6.9 0.7.25.3         Advanced front-end for dpkg
ii  debtags                 1.7.10           Enables support for package tags
ii  ept-cache               1.0              Commandline tool to search the pac
ii  games-thumbnails        20090628         thumbnails of games in Debian
ii  libc6                   2.10.2-6         Embedded GNU C Library: Shared lib
ii  libept0                 0.5.30           High-level library for managing De
ii  libfltk1.1              1.1.10-2         Fast Light Toolkit - shared librar
ii  libgcc1                 1:4.4.2-9        GCC support library
ii  libstdc++6              4.4.2-9          The GNU Standard C++ Library v3
ii  libxapian15             1.0.19-1         Search engine library
ii  zlib1g                  1:1.2.3.4.dfsg-3 compression library - runtime

goplay recommends no packages.

goplay suggests no packages.

-- no debconf information
diff --git a/debian/control b/debian/control
index d10e901..dc104ff 100644
--- a/debian/control
+++ b/debian/control
@@ -5,7 +5,7 @@ Maintainer: Debian Games Team <[email protected]>
 Uploaders: Miriam Ruiz <[email protected]>, Enrico Zini <[email protected]>, Jonas Smedegaard <[email protected]>
 Build-Depends: debhelper (>= 5), autotools-dev,
  c++abi2-dev, dh-buildinfo, pkg-config,
- libept-dev (>= 0.5.10), libept-dev (<< 0.6),
+ libept-dev (>= 1.0), libept-dev (<< 2),
  libwibble-dev (>= 0.1.9), libwibble-dev (<< 0.2),
  libfltk1.1-dev, fluid
 Standards-Version: 3.7.3
diff --git a/src/Engine.cpp b/src/Engine.cpp
index 866e5bf..297eb41 100644
--- a/src/Engine.cpp
+++ b/src/Engine.cpp
@@ -56,11 +56,11 @@ struct EngineMatchDecider : public Xapian::MatchDecider
 
 static Xapian::Query allGames(Vocabulary& voc, const std::string& facet="game")
 {
-	set<Tag> games = voc.tags(facet);
+	set<std::string> games = voc.tags(facet);
 	vector<string> terms;
-	for (set<Tag>::const_iterator i = games.begin();
+	for (set<std::string>::const_iterator i = games.begin();
 			i != games.end(); ++i)
-		terms.push_back("XT" + i->fullname());
+		terms.push_back("XT" + *i);
 	return Xapian::Query(Xapian::Query::OP_OR, terms.begin(), terms.end());
 }
 
@@ -73,10 +73,10 @@ Xapian::Query Engine::makeQuery()
 
 	if (!m_filter_keywords.empty())
 		kwquery = m_textsearch.makePartialORQuery(m_filter_keywords);
-	if (m_filter_type.valid())
-		typequery = Xapian::Query("XT"+m_filter_type.fullname());
-	if (m_filter_iface.valid())
-		ifacequery = Xapian::Query("XT"+m_filter_iface.fullname());
+	if (!m_filter_type.empty())
+		typequery = Xapian::Query("XT"+m_filter_type);
+	if (!m_filter_iface.empty())
+		ifacequery = Xapian::Query("XT"+m_filter_iface);
 		
 	if (kwquery.empty())
 		if (typequery.empty())
@@ -126,11 +126,11 @@ void Engine::recompute()
 	//cerr << "Engine recompute:" << endl;
 
 	// Compute the types
-	if (m_filter_type.valid())
+	if (!m_filter_type.empty())
 	{
 		//cerr << "  filter type: " << m_filter_type.fullname() << endl;
-		Tag tmp = m_filter_type;
-		m_filter_type = Tag();
+		std::string tmp = m_filter_type;
+		m_filter_type = std::string();
 		Xapian::Enquire enquire(m_textsearch.db());
 		enquire.set_query(makeQuery());
 
@@ -144,10 +144,10 @@ void Engine::recompute()
 			for (Xapian::MSetIterator i = matches.begin(); i != matches.end(); ++i)
 			{
 				// Get all the game and interface tags in the result set
-				set<Tag> tags = m_debtags.getTagsOfItem(i.get_document().get_data());
-				for (set<Tag>::const_iterator j = tags.begin();
+				set<std::string> tags = m_debtags.getTagsOfItem(i.get_document().get_data());
+				for (set<std::string>::const_iterator j = tags.begin();
 						j != tags.end(); ++j)
-					if (j->facet().name() == mainFacet)
+					if (voc::getfacet(*j) == mainFacet)
 						m_types.insert(*j);
 			}
 		}
@@ -157,11 +157,11 @@ void Engine::recompute()
 	}
 
 	// Compute the interfaces
-	if (m_filter_iface.valid())
+	if (!m_filter_iface.empty())
 	{
 		//cerr << "  filter iface: " << m_filter_iface.fullname() << endl;
-		Tag tmp = m_filter_iface;
-		m_filter_iface = Tag();
+		std::string tmp = m_filter_iface;
+		m_filter_iface = std::string();
 		Xapian::Enquire enquire(m_textsearch.db());
 		enquire.set_query(makeQuery());
 
@@ -175,10 +175,10 @@ void Engine::recompute()
 			for (Xapian::MSetIterator i = matches.begin(); i != matches.end(); ++i)
 			{
 				// Get all the game and interface tags in the result set
-				set<Tag> tags = m_debtags.getTagsOfItem(i.get_document().get_data());
-				for (set<Tag>::const_iterator j = tags.begin();
+				set<std::string> tags = m_debtags.getTagsOfItem(i.get_document().get_data());
+				for (set<std::string>::const_iterator j = tags.begin();
 						j != tags.end(); ++j)
-					if (j->facet().name() == secondaryFacet)
+					if (voc::getfacet(*j) == secondaryFacet)
 						m_interfaces.insert(*j);
 			}
 		}
@@ -221,22 +221,22 @@ void Engine::recompute()
 
 			// Get all the game and interface tags in the result set
 			// only for type or filter when they are not set
-			if (!m_filter_type.valid() || !m_filter_iface.valid())
+			if (m_filter_type.empty() || m_filter_iface.empty())
 			{
-				set<Tag> tags = m_debtags.getTagsOfItem(res.name);
-				for (set<Tag>::const_iterator j = tags.begin();
+				set<std::string> tags = m_debtags.getTagsOfItem(res.name);
+				for (set<std::string>::const_iterator j = tags.begin();
 						j != tags.end(); ++j)
-					if (!m_filter_type.valid() && j->facet().name() == mainFacet)
+					if (m_filter_type.empty() && voc::getfacet(*j) == mainFacet)
 						m_types.insert(*j);
-					else if (!m_filter_iface.valid() && j->facet().name() == secondaryFacet)
+					else if (m_filter_iface.empty() && voc::getfacet(*j) == secondaryFacet)
 						m_interfaces.insert(*j);
 			}
 		}
 	}
 	// Always keep the currently selected items in the lists
-	if (m_filter_type.valid())
+	if (!m_filter_type.empty())
 		m_types.insert(m_filter_type);
-	if (m_filter_iface.valid())
+	if (!m_filter_iface.empty())
 		m_interfaces.insert(m_filter_iface);
 
 
@@ -284,13 +284,13 @@ void Engine::setKeywordFilter(const std::string& keywords)
 	m_dirty = true;
 }
 
-void Engine::setTypeFilter(const ept::debtags::Tag& tag)
+void Engine::setTypeFilter(const std::string& tag)
 {
 	m_filter_type = tag;
 	m_dirty = true;
 }
 
-void Engine::setInterfaceFilter(const ept::debtags::Tag& tag)
+void Engine::setInterfaceFilter(const std::string& tag)
 {
 	m_filter_iface = tag;
 	m_dirty = true;
diff --git a/src/Engine.h b/src/Engine.h
index 4369d08..a760915 100644
--- a/src/Engine.h
+++ b/src/Engine.h
@@ -23,6 +23,7 @@
 
 #include <ept/apt/apt.h>
 #include <ept/debtags/debtags.h>
+#include <ept/debtags/vocabulary.h>
 #include <ept/textsearch/textsearch.h>
 #include <ept/popcon/popcon.h>
 #include <string>
@@ -58,6 +59,9 @@ protected:
 	/// Debtags data provider
 	ept::debtags::Debtags m_debtags;
 
+	/// Vocabulary data provider
+	ept::debtags::Vocabulary m_vocabulary;
+
 	/// Xapian data provider
 	ept::textsearch::TextSearch m_textsearch;
 
@@ -65,15 +69,15 @@ protected:
 	ept::popcon::Popcon m_popcon;
 
 	std::string m_filter_keywords;
-	ept::debtags::Tag m_filter_type;
-	ept::debtags::Tag m_filter_iface;
+	std::string m_filter_type;
+	std::string m_filter_iface;
 	Engine::State m_filter_state;
 
 	bool m_dirty;
 
 	std::vector<Result> m_results;
-	std::set<ept::debtags::Tag> m_types;
-	std::set<ept::debtags::Tag> m_interfaces;
+	std::set<std::string> m_types;
+	std::set<std::string> m_interfaces;
 
 	float m_max;
 	float m_res_max;
@@ -100,20 +104,20 @@ public:
 	ept::debtags::Debtags& debtags() { return m_debtags; }
 
 	/// Access the tag vocabulary
-	ept::debtags::Vocabulary& voc() { return m_debtags.vocabulary(); }
+	ept::debtags::Vocabulary& voc() { return m_vocabulary; }
 
 	/// Access the popcon data source
 	ept::popcon::Popcon& popcon() { return m_popcon; }
 
 	/// Get the list of available game types
-	const std::set<ept::debtags::Tag>& types()
+	const std::set<std::string>& types()
 	{
 		if (m_dirty) recompute();
 		return m_types;
 	}
 
 	/// Get the list of available interfaces
-	const std::set<ept::debtags::Tag>& interfaces()
+	const std::set<std::string>& interfaces()
 	{
 		if (m_dirty) recompute();
 		return m_interfaces;
@@ -144,12 +148,12 @@ public:
 	/**
 	 * Set the game type filter
 	 */
-	void setTypeFilter(const ept::debtags::Tag& tag = ept::debtags::Tag());
+	void setTypeFilter(const std::string& tag = std::string());
 
 	/**
 	 * Set the interface type filter
 	 */
-	void setInterfaceFilter(const ept::debtags::Tag& tag = ept::debtags::Tag());
+	void setInterfaceFilter(const std::string& tag = std::string());
 
 	/**
 	 * Set the installed state filter
diff --git a/src/filter.cpp b/src/filter.cpp
index a59c553..bc1ee88 100644
--- a/src/filter.cpp
+++ b/src/filter.cpp
@@ -20,7 +20,6 @@
 #include "taghandler.h"
 
 #include <string>
-#include <ept/debtags/tag.h>
 
 #define FACET_VIOLENCE "rating:violence"
 #define FACET_SEX "rating:sex"
@@ -86,26 +85,22 @@ int PackageFilter::TagValue(const Tag &tag)
 
 bool PackageFilter::GreenTag(const Tag &tag)
 {
-	std::string name = tag.fullname();
-	return tagdata.CheckTag(&green_tags, name);
+	return tagdata.CheckTag(&green_tags, tag);
 }
 
 bool PackageFilter::YellowTag(const Tag &tag)
 {
-	std::string name = tag.fullname();
-	return tagdata.CheckTag(&yellow_tags, name);
+	return tagdata.CheckTag(&yellow_tags, tag);
 }
 
 bool PackageFilter::RedTag(const Tag &tag)
 {
-	std::string name = tag.fullname();
-	return tagdata.CheckTag(&red_tags, name);
+	return tagdata.CheckTag(&red_tags, tag);
 }
 
 bool PackageFilter::BlackTag(const Tag &tag)
 {
-	std::string name = tag.fullname();
-	return tagdata.CheckTag(&black_tags, name);
+	return tagdata.CheckTag(&black_tags, tag);
 }
 
 int PackageFilter::TagsValue(const TagSet &tags)
diff --git a/src/filter.h b/src/filter.h
index 4cd5467..357dda2 100644
--- a/src/filter.h
+++ b/src/filter.h
@@ -22,7 +22,6 @@
 #include "taghandler.h"
 
 #include <set>
-#include <ept/debtags/tag.h>
 
 class PackageFilter
 {
@@ -38,8 +37,8 @@ public:
 		Black,     // Mayday, mayday, the tag/package might be really dangerous!
 	};
 
-	typedef ept::debtags::Tag Tag;
-	typedef std::set<Tag> TagSet;
+	typedef std::string Tag;
+	typedef std::set<std::string> TagSet;
 
 	bool GreenTag(const Tag &tag);
 	bool YellowTag(const Tag &tag);
diff --git a/src/goplay.cpp b/src/goplay.cpp
index c85d77e..03c629e 100644
--- a/src/goplay.cpp
+++ b/src/goplay.cpp
@@ -93,14 +93,14 @@ using namespace ept::debtags;
 using namespace ept::apt;
 using namespace ept::textsearch;
 
-char* tagString(const Tag& tag)
+char* tagString(const std::string& tag)
 {
 	static map<string, char*> table;
-	map<string, char*>::iterator i = table.find(tag.fullname());
+	map<string, char*>::iterator i = table.find(tag);
 	if (i == table.end())
 	{
 		pair< map<string, char*>::iterator, bool > tmp =
-			table.insert(make_pair(tag.fullname(), strdup(tag.fullname().c_str())));
+			table.insert(make_pair(tag, strdup(tag.c_str())));
 		i = tmp.first;
 	}
 	return i->second;
@@ -128,18 +128,18 @@ void printResults(Engine& engine)
 		cerr << "PKG " << pkg.package() << " - " << pkg.shortDescription() << endl;
 	}
 
-	const set<Tag>& ttags = engine.types();
-	for (set<Tag>::const_iterator i = ttags.begin();
+	const set<string>& ttags = engine.types();
+	for (set<string>::const_iterator i = ttags.begin();
 			i != ttags.end(); ++i)
 	{
-		cerr << "TTAG " << i->fullname() << endl;
+		cerr << "TTAG " << *i << endl;
 	}
 
-	const set<Tag>& ftags = engine.interfaces();
-	for (set<Tag>::const_iterator i = ftags.begin();
+	const set<string>& ftags = engine.interfaces();
+	for (set<string>::const_iterator i = ftags.begin();
 			i != ftags.end(); ++i)
 	{
-		cerr << "ITAG " << i->fullname() << endl;
+		cerr << "ITAG " << *i << endl;
 	}
 }
 
@@ -186,26 +186,30 @@ static void UpdateUILists(GamesUI& ui)
 
 	// FIXME: there are better ways to remember the previous item
 	
-	const set<Tag> types = engine.types();
+	const set<string> types = engine.types();
 	int newIdx = 0;
-	for (set<Tag>::const_iterator i = types.begin();
+	for (set<string>::const_iterator i = types.begin();
 			i != types.end(); ++i)
 	{
-		int idx = ui.TypeSelection->add(gettext(i->shortDescription().c_str()),
+		const voc::TagData* td = engine.voc().tagData(*i);
+		if (!td) continue;
+		int idx = ui.TypeSelection->add(gettext(td->shortDescription().c_str()),
 							0, NULL, tagString(*i), FL_NORMAL_LABEL);
-		if (i->fullname() == oldType)
+		if (*i == oldType)
 			newIdx = idx;
 	}
 	ui.TypeSelection->value(newIdx);
 	
-	const set<Tag> ifaces = engine.interfaces();
+	const set<std::string> ifaces = engine.interfaces();
 	newIdx = 0;
-	for (set<Tag>::const_iterator i = ifaces.begin();
+	for (set<std::string>::const_iterator i = ifaces.begin();
 			i != ifaces.end(); ++i)
 	{
-		int idx = ui.InterfaceSelection->add(gettext(i->shortDescription().c_str()),
+		const voc::TagData* td = engine.voc().tagData(*i);
+		if (!td) continue;
+		int idx = ui.InterfaceSelection->add(gettext(td->shortDescription().c_str()),
 							0, NULL, tagString(*i), FL_NORMAL_LABEL);
-		if (i->fullname() == oldIface)
+		if (*i == oldIface)
 			newIdx = idx;
 	}
 	ui.InterfaceSelection->value(newIdx);
@@ -225,7 +229,7 @@ static void UpdateUILists(GamesUI& ui)
 
 		Fl_Color bk(FL_WHITE);
 		Fl_Color fr(FL_BLACK);
-		set<Tag> tags = ui.engine->debtags().getTagsOfItem((const char *)rec.package().c_str());
+		set<std::string> tags = ui.engine->debtags().getTagsOfItem((const char *)rec.package().c_str());
 		switch (filter.TagsValue(tags))
 		{
 			case PackageFilter::Green:
@@ -267,8 +271,7 @@ static void CallBackTypeSelection(Fl_Choice* choice, void *data)
 	//printf("CallBackTypeSelection\n");
 	//fflush(stdout);
 	GamesUI& ui = *static_cast<GamesUI*>(data);
-	Tag tag = ui.engine->voc().tagByName(ReadFlChoice(*choice));
-	ui.engine->setTypeFilter(tag);
+	ui.engine->setTypeFilter(ReadFlChoice(*choice));
 	UpdateUILists(ui);
 }
 
@@ -277,8 +280,7 @@ static void CallBackInterfaceSelection(Fl_Choice* choice, void *data)
 	//printf("CallBackInterfaceSelection\n");
 	//fflush(stdout);
 	GamesUI& ui = *static_cast<GamesUI*>(data);
-	Tag tag = ui.engine->voc().tagByName(ReadFlChoice(*choice));
-	ui.engine->setInterfaceFilter(tag);
+	ui.engine->setInterfaceFilter(ReadFlChoice(*choice));
 	UpdateUILists(ui);
 }
 
diff --git a/src/pkgbrowser.cpp b/src/pkgbrowser.cpp
index f39f02b..19b0c0f 100644
--- a/src/pkgbrowser.cpp
+++ b/src/pkgbrowser.cpp
@@ -221,11 +221,15 @@ void PackageBrowser::item_select(void *p, int s)
 			ui->DebTagsBrowser->column_widths(widths);
 			ui->DebTagsBrowser->add(_("@b...@c7@[email protected]\t@b...@c7@[email protected]"));
 
-			set<Tag> tags = ui->engine->debtags().getTagsOfItem((const char *)data);
+			set<std::string> tags = ui->engine->debtags().getTagsOfItem((const char *)data);
 			PackageFilter filter;
 			char *tag_txt = new char[512];
-			for (set<Tag>::const_iterator i = tags.begin(); i != tags.end(); ++i)
+			for (set<std::string>::const_iterator i = tags.begin(); i != tags.end(); ++i)
 			{
+				const voc::FacetData* fd = ui->engine->voc().facetData(voc::getfacet(*i));
+				const voc::TagData* td = ui->engine->voc().tagData(*i);
+				if (!fd || !td) continue;
+
 				// Available Colors: FL_BLACK, FL_BLUE, FL_CYAN, FL_DARK_BLUE,
 				// FL_DARK_CYAN, FL_DARK_GREEN FL_DARK_MAGENTA, FL_DARK_RED,
 				// FL_DARK_YELLOW, FL_GREEN, FL_MAGENTA, FL_RED, FL_WHITE, FL_YELLOW
@@ -247,9 +251,9 @@ void PackageBrowser::item_select(void *p, int s)
 				}
 				snprintf(tag_txt, 512, "@b...@c%d@.%...@b%d@c...@.%s",
 					bk, fr,
-					gettext(i->facet().shortDescription().c_str()),
+					gettext(fd->shortDescription().c_str()),
 					bk, fr,
-					gettext(i->shortDescription().c_str())
+					gettext(td->shortDescription().c_str())
 				);
 				ui->DebTagsBrowser->add(tag_txt);
 			}

Reply via email to