Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing getters/setters for most of the properties in AS::Component #117

Merged
merged 1 commit into from Jun 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -32,6 +32,9 @@ set(APPSTREAMQT_SRC
release.cpp
bundle.cpp
suggested.cpp
contentrating.cpp
launchable.cpp
translation.cpp
)

set(APPSTREAMQT_PUBLIC_HEADERS
@@ -45,6 +48,9 @@ set(APPSTREAMQT_PUBLIC_HEADERS
release.h
bundle.h
suggested.h
contentrating.h
launchable.h
translation.h
)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}
@@ -60,6 +60,11 @@ class AppStream::BundleData : public QSharedData {
return rd.m_bundle == m_bundle;
}

AsBundle *bundle() const
{
return m_bundle;
}

AsBundle* m_bundle;
};

@@ -88,6 +93,11 @@ bool Bundle::operator==(const Bundle &other) const
return false;
}

_AsBundle * AppStream::Bundle::asBundle() const
{
return d->bundle();
}

Bundle::Kind Bundle::kind() const
{
return Bundle::Kind(as_bundle_get_kind(d->m_bundle));
@@ -40,6 +40,11 @@ class APPSTREAMQT_EXPORT Bundle {
Bundle& operator=(const Bundle& bundle);
bool operator==(const Bundle& r) const;

/**
* \returns the internally stored AsBundle
*/
_AsBundle *asBundle() const;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these really necessary? I would argue that this is only needed in case the Qt/C++ interface is incomplete and someone therefore wants to use the C library directly. In that case, we should rather fix the Qt binding to include the missing stuff, and not give library users the means to hack around it and not report the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use these internally, i.e. in as_component_add_icon() or as_component_add_screenshot() and so on, because those methods takes AsIcon or AsScreenshot only.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we should make the symbols internal and hide them from the public API... The tricky bit is that they're class members...
(I will take a look on whether it's possible to even have them as internal members, probably the only way to do that is to make them private and use friend classes for access. - in any case, just leave this as it is for now :-) )


enum Kind {
KindUnknown,
KindPackage,
@@ -42,6 +42,11 @@ class AppStream::CategoryData : public QSharedData {
return rd.m_category == m_category;
}

AsCategory *category() const
{
return m_category;
}

AsCategory* m_category;
};

@@ -66,6 +71,11 @@ bool Category::operator==(const Category &other) const
return false;
}

_AsCategory * AppStream::Category::asCategory() const
{
return d->category();
}

QString Category::id() const
{
return valueWrap(as_category_get_id(d->m_category));
@@ -41,6 +41,11 @@ class APPSTREAMQT_EXPORT Category {
Category& operator=(const Category& category);
bool operator==(const Category& r) const;

/**
* \returns the internally stored AsCategory
*/
_AsCategory *asCategory() const;

QString id() const;
QString name() const;
QString summary() const;
@@ -52,6 +52,29 @@ inline QStringList valueWrap(GPtrArray *array)
return res;
}

inline QStringList valueWrap(GList *list)
{
GList *l;
QStringList res;
res.reserve(g_list_length(list));
for (l = list; l != NULL; l = l->next) {
auto strval = (const gchar*) l->data;
res.append (QString::fromUtf8(strval));
}
return res;
}

inline char ** stringListToCharArray(const QStringList& list)
{
char **array = (char**) g_malloc(sizeof(char*) * list.size());
for (int i = 0; i < list.size(); ++i) {
const QByteArray string = list[i].toLocal8Bit();
array[i] = (char*) g_malloc(sizeof(char) * (string.size() + 1));
strcpy(array[i], string.constData());
}
return array;
}

}

#endif // APPSTREAMQT_CHELPERS_H