summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/libmsi-summary-info.h31
-rw-r--r--libmsi/libmsi-summary-info.c238
-rw-r--r--tests/testdatabase.c156
-rw-r--r--tests/testsuminfo.c201
-rw-r--r--tools/msibuild.c123
-rw-r--r--tools/msiinfo.c25
6 files changed, 414 insertions, 360 deletions
diff --git a/include/libmsi-summary-info.h b/include/libmsi-summary-info.h
index 1f289d7..a6216b3 100644
--- a/include/libmsi-summary-info.h
+++ b/include/libmsi-summary-info.h
@@ -41,10 +41,33 @@ struct _LibmsiSummaryInfoClass
GType libmsi_summary_info_get_type (void) G_GNUC_CONST;
-LibmsiSummaryInfo * libmsi_summary_info_new (LibmsiDatabase *database, unsigned update_count, GError **error);
-LibmsiResult libmsi_summary_info_get_property (LibmsiSummaryInfo *, LibmsiPropertyType,unsigned *,int *,guint64*,char *,unsigned *);
-LibmsiResult libmsi_summary_info_set_property (LibmsiSummaryInfo *, LibmsiPropertyType, unsigned, int, guint64*, const char *);
-LibmsiResult libmsi_summary_info_persist (LibmsiSummaryInfo *);
+LibmsiSummaryInfo * libmsi_summary_info_new (LibmsiDatabase *database,
+ unsigned update_count,
+ GError **error);
+const gchar * libmsi_summary_info_get_string (LibmsiSummaryInfo *si,
+ LibmsiProperty prop,
+ GError **error);
+gint libmsi_summary_info_get_int (LibmsiSummaryInfo *si,
+ LibmsiProperty prop,
+ GError **error);
+guint64 libmsi_summary_info_get_filetime (LibmsiSummaryInfo *si,
+ LibmsiProperty prop,
+ GError **error);
+gboolean libmsi_summary_info_set_string (LibmsiSummaryInfo *si,
+ LibmsiProperty prop,
+ const gchar *value,
+ GError **error);
+gboolean libmsi_summary_info_set_int (LibmsiSummaryInfo *si,
+ LibmsiProperty prop,
+ gint value,
+ GError **error);
+gboolean libmsi_summary_info_set_filetime (LibmsiSummaryInfo *si,
+ LibmsiProperty prop,
+ guint64 value,
+ GError **error);
+gboolean libmsi_summary_info_persist (LibmsiSummaryInfo *si,
+ GError **error);
+
LibmsiResult libmsi_summary_info_get_property_count (LibmsiSummaryInfo *,unsigned *);
diff --git a/libmsi/libmsi-summary-info.c b/libmsi/libmsi-summary-info.c
index 11ebc89..cc257ea 100644
--- a/libmsi/libmsi-summary-info.c
+++ b/libmsi/libmsi-summary-info.c
@@ -580,7 +580,7 @@ LibmsiResult libmsi_database_get_summary_info( LibmsiDatabase *db,
return ret;
}
-LibmsiResult libmsi_summary_info_get_property_count(LibmsiSummaryInfo *si, unsigned *pCount)
+LibmsiResult libmsi_summary_info_get_property_count (LibmsiSummaryInfo *si, unsigned *pCount)
{
TRACE("%d %p\n", si, pCount);
@@ -595,72 +595,116 @@ LibmsiResult libmsi_summary_info_get_property_count(LibmsiSummaryInfo *si, unsig
return LIBMSI_RESULT_SUCCESS;
}
-LibmsiResult libmsi_summary_info_get_property(
- LibmsiSummaryInfo *si, unsigned uiProperty, unsigned *puiDataType, int *pintvalue,
- guint64 *pftValue, char *szValueBuf, unsigned *pcchValueBuf)
+static void _summary_info_get_property (LibmsiSummaryInfo *si, unsigned uiProperty,
+ unsigned *puiDataType, int *pintvalue,
+ guint64 *pftValue, char *szValueBuf,
+ unsigned *pcchValueBuf, const gchar **str,
+ GError **error)
{
LibmsiOLEVariant *prop;
- unsigned ret = LIBMSI_RESULT_SUCCESS;
+ LibmsiPropertyType type;
- TRACE("%d %d %p %p %p %p %p\n", si, uiProperty, puiDataType,
- pintvalue, pftValue, szValueBuf, pcchValueBuf);
-
- if ( uiProperty >= MSI_MAX_PROPS )
- {
- if (puiDataType) *puiDataType = LIBMSI_PROPERTY_TYPE_EMPTY;
- return LIBMSI_RESULT_UNKNOWN_PROPERTY;
+ if (uiProperty >= MSI_MAX_PROPS) {
+ g_set_error (error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_UNKNOWN_PROPERTY,
+ "Unknown property");
+ return;
}
- if( !si )
- return LIBMSI_RESULT_INVALID_HANDLE;
-
- g_object_ref(si);
+ g_object_ref (si);
prop = &si->property[uiProperty];
- switch( prop->vt )
- {
+ switch (prop->vt) {
case OLEVT_I2:
case OLEVT_I4:
- if( puiDataType )
- *puiDataType = LIBMSI_PROPERTY_TYPE_INT;
-
- if( pintvalue )
+ type = LIBMSI_PROPERTY_TYPE_INT;
+ if (pintvalue)
*pintvalue = prop->intval;
break;
case OLEVT_LPSTR:
- if( puiDataType )
- *puiDataType = LIBMSI_PROPERTY_TYPE_STRING;
-
- if( pcchValueBuf )
- {
+ type = LIBMSI_PROPERTY_TYPE_STRING;
+ if (str)
+ *str = prop->strval;
+ if (pcchValueBuf) {
unsigned len = 0;
- len = strlen( prop->strval );
- if( szValueBuf )
- strcpyn(szValueBuf, prop->strval, *pcchValueBuf );
+ len = strlen (prop->strval);
+ if (szValueBuf)
+ strcpyn (szValueBuf, prop->strval, *pcchValueBuf);
if (len >= *pcchValueBuf)
- ret = LIBMSI_RESULT_MORE_DATA;
+ g_set_error (error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_MORE_DATA, "");
*pcchValueBuf = len;
}
break;
case OLEVT_FILETIME:
- if( puiDataType )
- *puiDataType = LIBMSI_PROPERTY_TYPE_FILETIME;
-
- if( pftValue )
+ type = LIBMSI_PROPERTY_TYPE_FILETIME;
+ if (pftValue)
*pftValue = prop->filetime;
break;
case OLEVT_EMPTY:
- if( puiDataType )
- *puiDataType = LIBMSI_PROPERTY_TYPE_EMPTY;
-
+ // FIXME: should be replaced by a has_property() instead?
+ g_set_error (error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_SUCCESS, "Empty property");
+ type = LIBMSI_PROPERTY_TYPE_EMPTY;
break;
default:
- FIXME("Unknown property variant type\n");
+ g_warn_if_reached ();
break;
}
- g_object_unref(si);
- return ret;
+
+ if (puiDataType)
+ *puiDataType = type;
+
+ g_object_unref (si);
+}
+
+gint
+libmsi_summary_info_get_int (LibmsiSummaryInfo *self, LibmsiProperty prop,
+ GError **error)
+{
+ LibmsiPropertyType type;
+ gint val;
+
+ g_return_val_if_fail (LIBMSI_SUMMARY_INFO (self), FALSE);
+ g_return_val_if_fail (!error || *error == NULL, FALSE);
+
+ type = LIBMSI_PROPERTY_TYPE_INT;
+ _summary_info_get_property (self, prop, &type, &val,
+ NULL, NULL, NULL, NULL, error);
+
+ return val;
+}
+
+guint64
+libmsi_summary_info_get_filetime (LibmsiSummaryInfo *self, LibmsiProperty prop,
+ GError **error)
+{
+ LibmsiPropertyType type;
+ guint64 val;
+
+ g_return_val_if_fail (LIBMSI_SUMMARY_INFO (self), FALSE);
+ g_return_val_if_fail (!error || *error == NULL, FALSE);
+
+ type = LIBMSI_PROPERTY_TYPE_FILETIME;
+ _summary_info_get_property (self, prop, &type, NULL,
+ &val, NULL, NULL, NULL, error);
+
+ return val;
+}
+
+const gchar *
+libmsi_summary_info_get_string (LibmsiSummaryInfo *self, LibmsiProperty prop,
+ GError **error)
+{
+ LibmsiPropertyType type;
+ const gchar *str;
+
+ g_return_val_if_fail (LIBMSI_SUMMARY_INFO (self), FALSE);
+ g_return_val_if_fail (!error || *error == NULL, FALSE);
+
+ type = LIBMSI_PROPERTY_TYPE_STRING;
+ _summary_info_get_property (self, prop, &type, NULL,
+ NULL, NULL, NULL, &str, error);
+
+ return str;
}
static LibmsiResult _libmsi_summary_info_set_property( LibmsiSummaryInfo *si, unsigned uiProperty,
@@ -718,40 +762,77 @@ end:
return ret;
}
-LibmsiResult libmsi_summary_info_set_property( LibmsiSummaryInfo *si, unsigned uiProperty,
- unsigned uiDataType, int intvalue, guint64* pftValue, const char *szValue )
+gboolean
+libmsi_summary_info_set_string (LibmsiSummaryInfo *self, LibmsiProperty prop,
+ const gchar *value, GError **error)
+{
+ LibmsiResult ret;
+
+ g_return_val_if_fail (LIBMSI_IS_SUMMARY_INFO (self), FALSE);
+ g_return_val_if_fail (!error || *error == NULL, FALSE);
+
+ if (get_type (prop) != OLEVT_LPSTR) {
+ g_set_error (error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH, G_STRFUNC);
+ return FALSE;
+ }
+
+ ret = _libmsi_summary_info_set_property (self, prop, OLEVT_LPSTR, 0, 0, value);
+ if (ret != LIBMSI_RESULT_SUCCESS) {
+ g_set_error (error, LIBMSI_RESULT_ERROR, ret, G_STRFUNC);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+gboolean
+libmsi_summary_info_set_int (LibmsiSummaryInfo *self, LibmsiProperty prop,
+ gint value, GError **error)
{
+ LibmsiResult ret;
int type;
- TRACE("%p %u %u %i %p %p\n", si, uiProperty, type, intvalue,
- pftValue, szValue );
+ g_return_val_if_fail (LIBMSI_IS_SUMMARY_INFO (self), FALSE);
+ g_return_val_if_fail (!error || *error == NULL, FALSE);
- if( !si )
- return LIBMSI_RESULT_INVALID_HANDLE;
+ type = get_type (prop);
+ if (type != OLEVT_I2 && type != OLEVT_I4) {
+ g_set_error (error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH, G_STRFUNC);
+ return FALSE;
+ }
- type = get_type( uiProperty );
- switch (type) {
- case OLEVT_EMPTY:
- return LIBMSI_RESULT_DATATYPE_MISMATCH;
- case OLEVT_I2:
- case OLEVT_I4:
- if (uiDataType != LIBMSI_PROPERTY_TYPE_INT) {
- return LIBMSI_RESULT_DATATYPE_MISMATCH;
- }
- break;
- case OLEVT_LPSTR:
- if (uiDataType != LIBMSI_PROPERTY_TYPE_STRING) {
- return LIBMSI_RESULT_DATATYPE_MISMATCH;
- }
- break;
- case OLEVT_FILETIME:
- if (uiDataType != LIBMSI_PROPERTY_TYPE_FILETIME) {
- return LIBMSI_RESULT_DATATYPE_MISMATCH;
- }
- break;
+ ret = _libmsi_summary_info_set_property (self, prop, type, value, 0, NULL);
+ if (ret != LIBMSI_RESULT_SUCCESS) {
+ g_set_error (error, LIBMSI_RESULT_ERROR, ret, G_STRFUNC);
+ return FALSE;
}
- return _libmsi_summary_info_set_property( si, uiProperty, type, intvalue, pftValue, szValue );
+ return TRUE;
+}
+
+gboolean
+libmsi_summary_info_set_filetime (LibmsiSummaryInfo *self, LibmsiProperty prop,
+ guint64 value, GError **error)
+{
+ LibmsiResult ret;
+ int type;
+
+ g_return_val_if_fail (LIBMSI_IS_SUMMARY_INFO (self), FALSE);
+ g_return_val_if_fail (!error || *error == NULL, FALSE);
+
+ type = get_type (prop);
+ if (type != OLEVT_FILETIME) {
+ g_set_error (error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH, G_STRFUNC);
+ return FALSE;
+ }
+
+ ret = _libmsi_summary_info_set_property (self, prop, type, 0, &value, NULL);
+ if (ret != LIBMSI_RESULT_SUCCESS) {
+ g_set_error (error, LIBMSI_RESULT_ERROR, ret, G_STRFUNC);
+ return FALSE;
+ }
+
+ return TRUE;
}
static unsigned parse_prop( const char *prop, const char *value, unsigned *pid, int *int_value,
@@ -837,20 +918,25 @@ end:
return r;
}
-LibmsiResult libmsi_summary_info_persist( LibmsiSummaryInfo *si )
+gboolean libmsi_summary_info_persist (LibmsiSummaryInfo *si, GError **error)
{
unsigned ret;
- TRACE("%d\n", si );
+ g_return_val_if_fail (!error || *error == NULL, FALSE);
- if( !si )
- return LIBMSI_RESULT_INVALID_HANDLE;
+ TRACE("%p\n", si);
- g_object_ref(si);
- ret = suminfo_persist( si );
- g_object_unref(si);
+ if (!si)
+ return FALSE;
- return ret;
+ g_object_ref (si);
+ ret = suminfo_persist (si);
+ g_object_unref (si);
+
+ if (ret != LIBMSI_RESULT_SUCCESS)
+ g_set_error_literal (error, LIBMSI_RESULT_ERROR, ret, G_STRFUNC);
+
+ return ret == LIBMSI_RESULT_SUCCESS;
}
LibmsiSummaryInfo*
diff --git a/tests/testdatabase.c b/tests/testdatabase.c
index 85fe1f9..8b8482b 100644
--- a/tests/testdatabase.c
+++ b/tests/testdatabase.c
@@ -1076,6 +1076,7 @@ static void create_file_data(const char *name, const char *data, unsigned size)
static void test_streamtable(void)
{
+ GError *error = NULL;
LibmsiDatabase *hdb = 0;
LibmsiRecord *rec;
LibmsiQuery *query;
@@ -1143,11 +1144,11 @@ static void test_streamtable(void)
r = libmsi_database_get_summary_info( hdb, 1, &hsi );
ok( r == LIBMSI_RESULT_SUCCESS, "Failed to get summary information handle: %u\n", r );
- r = libmsi_summary_info_set_property( hsi, LIBMSI_PROPERTY_SECURITY, LIBMSI_PROPERTY_TYPE_INT, 2, NULL, NULL );
- ok( r == LIBMSI_RESULT_SUCCESS, "Failed to set property: %u\n", r );
+ libmsi_summary_info_set_int(hsi, LIBMSI_PROPERTY_SECURITY, 2, &error);
+ ok(!error, "Failed to set property\n");
- r = libmsi_summary_info_persist( hsi );
- ok( r == LIBMSI_RESULT_SUCCESS, "Failed to save summary information: %u\n", r );
+ r = libmsi_summary_info_persist( hsi, NULL );
+ ok(r, "Failed to save summary information: %u\n", r );
g_object_unref( hsi );
@@ -1702,14 +1703,15 @@ static unsigned add_table_to_db(LibmsiDatabase *hdb, const char *table_data)
static void test_suminfo_import(void)
{
+ GError *error = NULL;
LibmsiDatabase *hdb;
LibmsiSummaryInfo *hsi;
LibmsiQuery *query = 0;
const char *sql;
- unsigned r, count, size, type;
- char str_value[50];
+ unsigned r, count, type;
+ const char *str_value;
int int_value;
- uint64_t ft_value;
+ guint64 ft_value;
r = libmsi_database_open(msifile, LIBMSI_DB_OPEN_CREATE, &hdb);
ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r);
@@ -1734,89 +1736,59 @@ static void test_suminfo_import(void)
ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r);
ok(count == 14, "Expected 14, got %u\n", count);
- r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_CODEPAGE, &type, &int_value, NULL, NULL, NULL);
- ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r);
- ok(type == LIBMSI_PROPERTY_TYPE_INT, "Expected VT_I2, got %u\n", type);
+ int_value = libmsi_summary_info_get_int (hsi, LIBMSI_PROPERTY_CODEPAGE, &error);
+ ok(!error, "Expected success\n");
ok(int_value == 1252, "Expected 1252, got %d\n", int_value);
- size = sizeof(str_value);
- r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_TITLE, &type, NULL, NULL, str_value, &size);
- ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r);
- ok(type == LIBMSI_PROPERTY_TYPE_STRING, "Expected VT_LPSTR, got %u\n", type);
- ok(size == 18, "Expected 18, got %u\n", size);
- ok(!strcmp(str_value, "Installer Database"),
- "Expected \"Installer Database\", got %s\n", str_value);
+ str_value = libmsi_summary_info_get_string (hsi, LIBMSI_PROPERTY_TITLE, &error);
+ ok(!error, "Expected no error\n");
+ g_assert_cmpstr (str_value, ==, "Installer Database");
- size = sizeof(str_value);
- r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_SUBJECT, &type, NULL, NULL, str_value, &size);
- ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r);
- ok(type == LIBMSI_PROPERTY_TYPE_STRING, "Expected VT_LPSTR, got %u\n", type);
- ok(!strcmp(str_value, "Installer description"),
- "Expected \"Installer description\", got %s\n", str_value);
+ str_value = libmsi_summary_info_get_string (hsi, LIBMSI_PROPERTY_SUBJECT, &error);
+ ok(!error, "Expected no error\n");
+ g_assert_cmpstr (str_value, ==, "Installer description");
- size = sizeof(str_value);
- r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_AUTHOR, &type, NULL, NULL, str_value, &size);
- ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r);
- ok(type == LIBMSI_PROPERTY_TYPE_STRING, "Expected VT_LPSTR, got %u\n", type);
- ok(!strcmp(str_value, "WineHQ"),
- "Expected \"WineHQ\", got %s\n", str_value);
+ str_value = libmsi_summary_info_get_string (hsi, LIBMSI_PROPERTY_AUTHOR, &error);
+ ok(!error, "Expected no error\n");
+ g_assert_cmpstr (str_value, ==, "WineHQ");
- size = sizeof(str_value);
- r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_KEYWORDS, &type, NULL, NULL, str_value, &size);
- ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r);
- ok(type == LIBMSI_PROPERTY_TYPE_STRING, "Expected VT_LPSTR, got %u\n", type);
- ok(!strcmp(str_value, "Installer"),
- "Expected \"Installer\", got %s\n", str_value);
+ str_value = libmsi_summary_info_get_string (hsi, LIBMSI_PROPERTY_KEYWORDS, &error);
+ ok(!error, "Expected no error\n");
+ g_assert_cmpstr (str_value, ==, "Installer");
- size = sizeof(str_value);
- r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_COMMENTS, &type, NULL, NULL, str_value, &size);
- ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r);
- ok(type == LIBMSI_PROPERTY_TYPE_STRING, "Expected VT_LPSTR, got %u\n", type);
- ok(!strcmp(str_value, "Installer comments"),
- "Expected \"Installer comments\", got %s\n", str_value);
+ str_value = libmsi_summary_info_get_string (hsi, LIBMSI_PROPERTY_COMMENTS, &error);
+ ok(!error, "Expected no error\n");
+ g_assert_cmpstr (str_value, ==, "Installer comments");
- size = sizeof(str_value);
- r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_TEMPLATE, &type, NULL, NULL, str_value, &size);
- ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r);
- ok(type == LIBMSI_PROPERTY_TYPE_STRING, "Expected VT_LPSTR, got %u\n", type);
- ok(!strcmp(str_value, "Intel;1033,2057"),
- "Expected \"Intel;1033,2057\", got %s\n", str_value);
+ str_value = libmsi_summary_info_get_string (hsi, LIBMSI_PROPERTY_TEMPLATE, &error);
+ ok(!error, "Expected no error\n");
+ g_assert_cmpstr (str_value, ==, "Intel;1033,2057");
- size = sizeof(str_value);
- r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_UUID, &type, NULL, NULL, str_value, &size);
- ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r);
- ok(type == LIBMSI_PROPERTY_TYPE_STRING, "Expected VT_LPSTR, got %u\n", type);
- ok(!strcmp(str_value, "{12345678-1234-1234-1234-123456789012}"),
- "Expected \"{12345678-1234-1234-1234-123456789012}\", got %s\n", str_value);
+ str_value = libmsi_summary_info_get_string (hsi, LIBMSI_PROPERTY_UUID, &error);
+ ok(!error, "Expected no error\n");
+ g_assert_cmpstr (str_value, ==, "{12345678-1234-1234-1234-123456789012}");
- r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_CREATED_TM, &type, NULL, &ft_value, NULL, NULL);
- ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r);
- ok(type == LIBMSI_PROPERTY_TYPE_FILETIME, "Expected VT_FILETIME, got %u\n", type);
+ ft_value = libmsi_summary_info_get_filetime (hsi, LIBMSI_PROPERTY_CREATED_TM, &error);
+ ok(!error, "Expected no error\n");
- r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_LASTSAVED_TM, &type, NULL, &ft_value, NULL, NULL);
- ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r);
- ok(type == LIBMSI_PROPERTY_TYPE_FILETIME, "Expected VT_FILETIME, got %u\n", type);
+ ft_value = libmsi_summary_info_get_filetime (hsi, LIBMSI_PROPERTY_LASTSAVED_TM, &error);
+ ok(!error, "Expected no error\n");
- r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_VERSION, &type, &int_value, NULL, NULL, NULL);
- ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r);
- ok(type == LIBMSI_PROPERTY_TYPE_INT, "Expected VT_I4, got %u\n", type);
+ int_value = libmsi_summary_info_get_int (hsi, LIBMSI_PROPERTY_VERSION, &error);
+ ok(!error, "Expected success\n");
ok(int_value == 200, "Expected 200, got %d\n", int_value);
- r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_SOURCE, &type, &int_value, NULL, NULL, NULL);
- ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r);
- ok(type == LIBMSI_PROPERTY_TYPE_INT, "Expected VT_I4, got %u\n", type);
+ int_value = libmsi_summary_info_get_int (hsi, LIBMSI_PROPERTY_SOURCE, &error);
+ ok(!error, "Expected success\n");
ok(int_value == 2, "Expected 2, got %d\n", int_value);
- r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_SECURITY, &type, &int_value, NULL, NULL, NULL);
- ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r);
- ok(type == LIBMSI_PROPERTY_TYPE_INT, "Expected VT_I4, got %u\n", type);
+ int_value = libmsi_summary_info_get_int (hsi, LIBMSI_PROPERTY_SECURITY, &error);
+ ok(!error, "Expected success\n");
ok(int_value == 2, "Expected 2, got %d\n", int_value);
- size = sizeof(str_value);
- r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_APPNAME, &type, NULL, NULL, str_value, &size);
- ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r);
- ok(type == LIBMSI_PROPERTY_TYPE_STRING, "Expected VT_LPSTR, got %u\n", type);
- ok(!strcmp(str_value, "Vim"), "Expected \"Vim\", got %s\n", str_value);
+ str_value = libmsi_summary_info_get_string (hsi, LIBMSI_PROPERTY_APPNAME, &error);
+ ok(!error, "Expected no error\n");
+ g_assert_cmpstr (str_value, ==, "Vim");
g_object_unref(hsi);
g_object_unref(hdb);
@@ -2440,6 +2412,7 @@ static void generate_transform_manual(void)
static unsigned set_summary_info(LibmsiDatabase *hdb)
{
+ GError *error = NULL;
unsigned res;
LibmsiSummaryInfo *suminfo;
@@ -2447,34 +2420,29 @@ static unsigned set_summary_info(LibmsiDatabase *hdb)
res = libmsi_database_get_summary_info(hdb, 7, &suminfo);
ok( res == LIBMSI_RESULT_SUCCESS , "Failed to open summaryinfo\n" );
- res = libmsi_summary_info_set_property(suminfo,2, LIBMSI_PROPERTY_TYPE_STRING, 0,NULL,
- "Installation Database");
- ok( res == LIBMSI_RESULT_SUCCESS , "Failed to set summary info\n" );
+ libmsi_summary_info_set_string (suminfo, 2, "Installation Database", &error);
+ ok(!error, "Failed to set summary info\n");
- res = libmsi_summary_info_set_property(suminfo,3, LIBMSI_PROPERTY_TYPE_STRING, 0,NULL,
- "Installation Database");
- ok( res == LIBMSI_RESULT_SUCCESS , "Failed to set summary info\n" );
+ libmsi_summary_info_set_string (suminfo, 3, "Installation Database", &error);
+ ok(!error, "Failed to set summary info\n");
- res = libmsi_summary_info_set_property(suminfo,4, LIBMSI_PROPERTY_TYPE_STRING, 0,NULL,
- "Wine Hackers");
- ok( res == LIBMSI_RESULT_SUCCESS , "Failed to set summary info\n" );
+ libmsi_summary_info_set_string (suminfo, 4, "Wine Hackers", &error);
+ ok(!error, "Failed to set summary info\n");
- res = libmsi_summary_info_set_property(suminfo,7, LIBMSI_PROPERTY_TYPE_STRING, 0,NULL,
- ";1033,2057");
- ok( res == LIBMSI_RESULT_SUCCESS , "Failed to set summary info\n" );
+ libmsi_summary_info_set_string (suminfo, 7, ";1033,2057", &error);
+ ok(!error, "Failed to set summary info\n");
- res = libmsi_summary_info_set_property(suminfo,9, LIBMSI_PROPERTY_TYPE_STRING, 0,NULL,
- "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
- ok( res == LIBMSI_RESULT_SUCCESS , "Failed to set summary info\n" );
+ libmsi_summary_info_set_string (suminfo, 9, "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}", &error);
+ ok(!error, "Failed to set summary info\n");
- res = libmsi_summary_info_set_property(suminfo, 14, LIBMSI_PROPERTY_TYPE_INT, 100, NULL, NULL);
- ok( res == LIBMSI_RESULT_SUCCESS , "Failed to set summary info\n" );
+ libmsi_summary_info_set_int (suminfo, 14, 100, &error);
+ ok(!error, "Failed to set summary info\n");
- res = libmsi_summary_info_set_property(suminfo, 15, LIBMSI_PROPERTY_TYPE_INT, 0, NULL, NULL);
- ok( res == LIBMSI_RESULT_SUCCESS , "Failed to set summary info\n" );
+ libmsi_summary_info_set_int (suminfo, 15, 0, &error);
+ ok(!error, "Failed to set summary info\n");
- res = libmsi_summary_info_persist(suminfo);
- ok( res == LIBMSI_RESULT_SUCCESS , "Failed to make summary info persist\n" );
+ res = libmsi_summary_info_persist(suminfo, NULL);
+ ok( res , "Failed to make summary info persist\n" );
g_object_unref( suminfo);
diff --git a/tests/testsuminfo.c b/tests/testsuminfo.c
index 522b8b3..a1b0191 100644
--- a/tests/testsuminfo.c
+++ b/tests/testsuminfo.c
@@ -35,13 +35,14 @@ static const WCHAR msifileW[] = {
static void test_suminfo(void)
{
+ GError *error = NULL;
LibmsiDatabase *hdb = 0;
LibmsiSummaryInfo *hsuminfo;
unsigned r, count, type;
unsigned sz;
int val;
uint64_t ft;
- char buf[0x10];
+ const gchar *str;
DeleteFile(msifile);
@@ -71,47 +72,17 @@ static void test_suminfo(void)
ok(r == LIBMSI_RESULT_SUCCESS, "getpropcount failed\n");
ok(count == 0, "count should be zero\n");
- r = libmsi_summary_info_get_property(hsuminfo, 0, NULL, NULL, NULL, 0, NULL);
- ok(r == LIBMSI_RESULT_SUCCESS, "getpropcount failed\n");
-
- r = libmsi_summary_info_get_property(hsuminfo, -1, NULL, NULL, NULL, 0, NULL);
- ok(r == LIBMSI_RESULT_UNKNOWN_PROPERTY, "libmsi_summary_info_get_property wrong error\n");
-
- r = libmsi_summary_info_get_property(hsuminfo, LIBMSI_PROPERTY_SECURITY+1, NULL, NULL, NULL, 0, NULL);
- ok(r == LIBMSI_RESULT_UNKNOWN_PROPERTY, "libmsi_summary_info_get_property wrong error\n");
-
- type = -1;
- r = libmsi_summary_info_get_property(hsuminfo, 0, &type, NULL, NULL, 0, NULL);
- ok(r == LIBMSI_RESULT_SUCCESS, "getpropcount failed\n");
- ok(type == 0, "wrong type\n");
-
- type = -1;
- val = 1234;
- r = libmsi_summary_info_get_property(hsuminfo, 0, &type, &val, NULL, 0, NULL);
- ok(r == LIBMSI_RESULT_SUCCESS, "getpropcount failed\n");
- ok(type == 0, "wrong type\n");
- ok(val == 1234, "wrong val\n");
-
- buf[0]='x';
- buf[1]=0;
- sz = 0x10;
- r = libmsi_summary_info_get_property(hsuminfo, LIBMSI_PROPERTY_UUID, &type, &val, NULL, buf, &sz);
- ok(r == LIBMSI_RESULT_SUCCESS, "getpropcount failed\n");
- ok(buf[0]=='x', "cleared buffer\n");
- ok(sz == 0x10, "count wasn't zero\n");
+ type = libmsi_summary_info_get_property_type(hsuminfo, LIBMSI_PROPERTY_UUID, &error);
+ ok(!error, "returned error");
ok(type == LIBMSI_PROPERTY_TYPE_EMPTY, "should be empty\n");
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_TITLE, LIBMSI_PROPERTY_TYPE_STRING, 0, NULL, "Mike");
- ok(r == LIBMSI_RESULT_FUNCTION_FAILED, "libmsi_summary_info_set_property wrong error\n");
-
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_TITLE, LIBMSI_PROPERTY_TYPE_STRING, 1, NULL, "JungAh");
- ok(r == LIBMSI_RESULT_FUNCTION_FAILED, "libmsi_summary_info_set_property wrong error\n");
+ libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_TITLE, "Mike", &error);
+ ok(error, "libmsi_summary_info_set_property wrong error\n");
+ g_clear_error(error);
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_TITLE, LIBMSI_PROPERTY_TYPE_STRING, 1, &ft, "Mike");
- ok(r == LIBMSI_RESULT_FUNCTION_FAILED, "libmsi_summary_info_set_property wrong error\n");
-
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_CODEPAGE, LIBMSI_PROPERTY_TYPE_INT, 1, &ft, "JungAh");
- ok(r == LIBMSI_RESULT_FUNCTION_FAILED, "libmsi_summary_info_set_property wrong error\n");
+ libmsi_summary_info_set_int(hsuminfo, LIBMSI_PROPERTY_CODEPAGE, 1, &error);
+ ok(error, "libmsi_summary_info_set_property wrong error\n");
+ g_clear_error(error);
g_object_unref(hsuminfo);
@@ -119,66 +90,55 @@ static void test_suminfo(void)
r = libmsi_database_get_summary_info(hdb, 1, &hsuminfo);
ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_database_get_summary_info failed\n");
- r = libmsi_summary_info_set_property(hsuminfo, 0, LIBMSI_PROPERTY_TYPE_STRING, 1, NULL, NULL);
- ok(r == LIBMSI_RESULT_DATATYPE_MISMATCH, "libmsi_summary_info_set_property wrong error\n");
-
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_CODEPAGE, LIBMSI_PROPERTY_TYPE_STRING, 1, NULL, NULL);
- ok(r == LIBMSI_RESULT_DATATYPE_MISMATCH, "libmsi_summary_info_set_property wrong error\n");
-
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_TITLE, LIBMSI_PROPERTY_TYPE_INT, 0, NULL, "Mike");
- ok(r == LIBMSI_RESULT_DATATYPE_MISMATCH, "libmsi_summary_info_set_property wrong error\n");
-
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_AUTHOR, LIBMSI_PROPERTY_TYPE_INT, 0, NULL, "JungAh");
- ok(r == LIBMSI_RESULT_DATATYPE_MISMATCH, "libmsi_summary_info_set_property wrong error\n");
-
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_KEYWORDS, LIBMSI_PROPERTY_TYPE_INT, 0, NULL, "Mike");
- ok(r == LIBMSI_RESULT_DATATYPE_MISMATCH, "libmsi_summary_info_set_property wrong error\n");
+ libmsi_summary_info_set_string(hsuminfo, 0, NULL, &error);
+ g_assert_error(error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH);
+ g_clear_error(error);
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_COMMENTS, LIBMSI_PROPERTY_TYPE_FILETIME, 0, NULL, "JungAh");
- ok(r == LIBMSI_RESULT_DATATYPE_MISMATCH, "libmsi_summary_info_set_property wrong error\n");
+ libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_CODEPAGE, NULL, &error);
+ g_assert_error(error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH);
+ g_clear_error(error);
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_TEMPLATE, LIBMSI_PROPERTY_TYPE_INT, 0, NULL, "Mike");
- ok(r == LIBMSI_RESULT_DATATYPE_MISMATCH, "libmsi_summary_info_set_property wrong error\n");
+ libmsi_summary_info_set_int(hsuminfo, LIBMSI_PROPERTY_TITLE, NULL, &error);
+ g_assert_error(error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH);
+ g_clear_error(error);
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_LASTAUTHOR, LIBMSI_PROPERTY_TYPE_STRING, 0, NULL, NULL);
- ok(r == LIBMSI_RESULT_INVALID_PARAMETER, "libmsi_summary_info_set_property wrong error\n");
+ libmsi_summary_info_set_int(hsuminfo, LIBMSI_PROPERTY_AUTHOR, 0, &error);
+ g_assert_error(error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH);
+ g_clear_error(error);
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_LASTSAVED_TM, LIBMSI_PROPERTY_TYPE_FILETIME, 0, NULL, NULL);
- ok(r == LIBMSI_RESULT_INVALID_PARAMETER, "libmsi_summary_info_set_property wrong error\n");
+ libmsi_summary_info_set_int(hsuminfo, LIBMSI_PROPERTY_KEYWORDS, 0, &error);
+ g_assert_error(error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH);
+ g_clear_error(error);
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_LASTAUTHOR, VT_LPWSTR, 0, NULL, "h\0i\0\0");
- ok(r == LIBMSI_RESULT_DATATYPE_MISMATCH, "libmsi_summary_info_set_property wrong error\n");
+ libmsi_summary_info_set_filetime(hsuminfo, LIBMSI_PROPERTY_COMMENTS, 0, &error);
+ g_assert_error(error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH);
+ g_clear_error(error);
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_UUID, LIBMSI_PROPERTY_TYPE_INT, 0, NULL, "Jungah");
- ok(r == LIBMSI_RESULT_DATATYPE_MISMATCH, "libmsi_summary_info_set_property wrong error\n");
+ libmsi_summary_info_set_int(hsuminfo, LIBMSI_PROPERTY_TEMPLATE, 0, &error);
+ g_assert_error(error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH);
+ g_clear_error(error);
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_VERSION, LIBMSI_PROPERTY_TYPE_STRING, 1, NULL, NULL);
- ok(r == LIBMSI_RESULT_DATATYPE_MISMATCH, "libmsi_summary_info_set_property wrong error\n");
+ libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_LASTAUTHOR, NULL, &error);
+ g_assert_error(error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_INVALID_PARAMETER);
+ g_clear_error(error);
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_TITLE, LIBMSI_PROPERTY_TYPE_STRING, 0, NULL, "Mike");
- ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_summary_info_set_property failed\n");
+ libmsi_summary_info_set_int(hsuminfo, LIBMSI_PROPERTY_UUID, 0, &error);
+ g_assert_error(error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH);
+ g_clear_error(error);
- sz = 2;
- strcpy(buf,"x");
- r = libmsi_summary_info_get_property(hsuminfo, LIBMSI_PROPERTY_TITLE, &type, NULL, NULL, buf, &sz );
- ok(r == LIBMSI_RESULT_MORE_DATA, "libmsi_summary_info_set_property failed\n");
- ok(sz == 4, "count was wrong\n");
- ok(type == LIBMSI_PROPERTY_TYPE_STRING, "type was wrong\n");
- ok(!strcmp(buf,"M"), "buffer was wrong\n");
+ libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_VERSION, NULL, &error);
+ g_assert(error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH);
+ g_clear_error(error);
- sz = 4;
- strcpy(buf,"x");
- r = libmsi_summary_info_get_property(hsuminfo, LIBMSI_PROPERTY_TITLE, &type, NULL, NULL, buf, &sz );
- ok(r == LIBMSI_RESULT_MORE_DATA, "libmsi_summary_info_set_property failed\n");
- ok(sz == 4, "count was wrong\n");
- ok(type == LIBMSI_PROPERTY_TYPE_STRING, "type was wrong\n");
- ok(!strcmp(buf,"Mik"), "buffer was wrong\n");
+ libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_TITLE, "Mike", &error);
+ ok(!error, "libmsi_summary_info_set_property failed\n");
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_TITLE, LIBMSI_PROPERTY_TYPE_STRING, 0, NULL, "JungAh");
- ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_summary_info_set_property failed\n");
+ str = libmsi_summary_info_get_string(hsuminfo, LIBMSI_PROPERTY_TITLE, &error);
+ ok(!error, "got error");
+ ok(!strcpy(str, "Mike"));
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_CODEPAGE, LIBMSI_PROPERTY_TYPE_INT, 1, &ft, "Mike");
- ok(r == LIBMSI_RESULT_FUNCTION_FAILED, "libmsi_summary_info_set_property wrong error\n");
+ libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_TITLE, "JungAh", &error);
+ ok(!error, "libmsi_summary_info_set_property failed\n");
g_object_unref(hsuminfo);
@@ -186,23 +146,24 @@ static void test_suminfo(void)
r = libmsi_database_get_summary_info(hdb, 10, &hsuminfo);
ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_database_get_summary_info failed\n");
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_TITLE, LIBMSI_PROPERTY_TYPE_STRING, 0, NULL, "JungAh");
- ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_summary_info_set_property failed\n");
+ libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_TITLE, "JungAh", &error);
+ ok(!error, "libmsi_summary_info_set_property failed\n");
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_CODEPAGE, LIBMSI_PROPERTY_TYPE_STRING, 1, NULL, NULL);
- ok(r == LIBMSI_RESULT_DATATYPE_MISMATCH, "libmsi_summary_info_set_property wrong error\n");
+ libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_CODEPAGE, "", &error);
+ g_assert(error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH);
+ g_clear_error(&error);
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_CODEPAGE, LIBMSI_PROPERTY_TYPE_INT, 1, NULL, NULL);
- ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_summary_info_set_property wrong error\n");
+ libmsi_summary_info_set_int(hsuminfo, LIBMSI_PROPERTY_CODEPAGE, 1, &error);
+ ok(!error, "libmsi_summary_info_set_property failed\n");
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_CODEPAGE, LIBMSI_PROPERTY_TYPE_INT, 1, &ft, "Mike");
- ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_summary_info_set_property wrong error\n");
+ libmsi_summary_info_set_int(hsuminfo, LIBMSI_PROPERTY_CODEPAGE, 1, &error);
+ ok(!error, "libmsi_summary_info_set_property failed\n");
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_AUTHOR, LIBMSI_PROPERTY_TYPE_STRING, 1, &ft, "Mike");
- ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_summary_info_set_property wrong error\n");
+ libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_AUTHOR, "Mike", &error);
+ ok(!error, "libmsi_summary_info_set_property failed\n");
r = libmsi_summary_info_persist(hsuminfo);
- ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_summary_info_persist failed\n");
+ ok(r, "libmsi_summary_info_persist failed\n");
libmsi_database_commit(hdb);
@@ -217,11 +178,11 @@ static void test_suminfo(void)
r = libmsi_database_get_summary_info(hdb, 1, &hsuminfo);
ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_database_get_summary_info failed\n");
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_AUTHOR, LIBMSI_PROPERTY_TYPE_STRING, 1, &ft, "Mike");
+ r = libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_AUTHOR, "Mike", error);
ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_summary_info_set_property wrong error\n");
r = libmsi_summary_info_persist(hsuminfo);
- ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_summary_info_persist failed %u\n", r);
+ ok(r, "libmsi_summary_info_persist failed %u\n", r);
g_object_unref(hsuminfo);
@@ -234,11 +195,12 @@ static void test_suminfo(void)
r = libmsi_database_get_summary_info(hdb, 0, &hsuminfo);
ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_database_get_summary_info failed %u\n", r);
- r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_AUTHOR, LIBMSI_PROPERTY_TYPE_STRING, 1, &ft, "Mike");
- todo_wine ok(r == LIBMSI_RESULT_FUNCTION_FAILED, "libmsi_summary_info_set_property wrong error, %u\n", r);
+ libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_AUTHOR, "Mike", &error);
+ todo_wine ok(error, "libmsi_summary_info_set_property wrong error\n");
+ g_clear_error(&error);
r = libmsi_summary_info_persist(hsuminfo);
- ok(r == LIBMSI_RESULT_FUNCTION_FAILED, "libmsi_summary_info_persist wrong error %u\n", r);
+ ok(!r, "libmsi_summary_info_persist wrong error %u\n", r);
g_object_unref(hsuminfo);
@@ -363,12 +325,12 @@ static void test_create_database_binary(void)
static void test_summary_binary(void)
{
+ GError *error = NULL;
LibmsiDatabase *hdb = 0;
LibmsiSummaryInfo *hsuminfo = 0;
unsigned r, type, count;
int ival;
- unsigned sz;
- char sval[20];
+ const gchar *str;
DeleteFile( msifile );
@@ -389,21 +351,13 @@ static void test_summary_binary(void)
* but it appears that we're not allowed to read it back again.
* We can still read its type though...?
*/
- sz = sizeof sval;
- sval[0] = 0;
- type = 0;
- r = libmsi_summary_info_get_property(hsuminfo, LIBMSI_PROPERTY_LASTPRINTED, &type, NULL, NULL, sval, &sz);
- ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_summary_info_get_property failed\n");
- ok(!strcmp(sval, "") || !strcmp(sval, "7"),
- "Expected empty string or \"7\", got \"%s\"\n", sval);
- todo_wine {
- ok(type == LIBMSI_PROPERTY_TYPE_STRING, "Expected VT_LPSTR, got %d\n", type);
- ok(sz == 0 || sz == 1, "Expected 0 or 1, got %d\n", sz);
- }
-
- ival = -1;
- r = libmsi_summary_info_get_property(hsuminfo, LIBMSI_PROPERTY_SOURCE, &type, &ival, NULL, NULL, NULL);
- ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_summary_info_get_property failed\n");
+ str = libmsi_summary_info_get_string(hsuminfo, LIBMSI_PROPERTY_LASTPRINTED, error);
+ ok(!error);
+ ok(!strcmp(str, "") || !strcmp(str, "7"),
+ "Expected empty string or \"7\", got \"%s\"\n", str);
+
+ ival = libmsi_summary_info_get_int(hsuminfo, LIBMSI_PROPERTY_SOURCE, &error);
+ ok(!error, "libmsi_summary_info_get_property failed\n");
todo_wine ok( ival == 0, "value incorrect\n");
/* looks like msi adds some of its own values in here */
@@ -412,11 +366,12 @@ static void test_summary_binary(void)
ok(r == LIBMSI_RESULT_SUCCESS, "getpropcount failed\n");
todo_wine ok(count == 10, "prop count incorrect\n");
- r = libmsi_summary_info_set_property( hsuminfo, LIBMSI_PROPERTY_TITLE, LIBMSI_PROPERTY_TYPE_STRING, 0, NULL, "Mike" );
- ok(r == LIBMSI_RESULT_FUNCTION_FAILED, "libmsi_summary_info_set_property failed %u\n", r);
+ libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_TITLE, "Mike", &error);
+ ok(error, "libmsi_summary_info_set_property failed\n");
+ g_clear_error(&error);
r = libmsi_summary_info_persist( hsuminfo );
- ok(r == LIBMSI_RESULT_FUNCTION_FAILED, "libmsi_summary_info_persist failed %u\n", r);
+ ok(!r, "libmsi_summary_info_persist failed %u\n", r);
g_object_unref( hsuminfo );
g_object_unref( hdb );
diff --git a/tools/msibuild.c b/tools/msibuild.c
index 3f5d318..28d55a1 100644
--- a/tools/msibuild.c
+++ b/tools/msibuild.c
@@ -32,26 +32,35 @@
#include "sqldelim.h"
-static void init_suminfo(LibmsiSummaryInfo *si)
+static gboolean init_suminfo(LibmsiSummaryInfo *si, GError **error)
{
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_TITLE,
- LIBMSI_PROPERTY_TYPE_STRING, 0, NULL,
- "Installation Database");
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_KEYWORDS,
- LIBMSI_PROPERTY_TYPE_STRING, 0, NULL,
- "Installer, MSI");
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_TEMPLATE,
- LIBMSI_PROPERTY_TYPE_STRING, 0, NULL,
- ";1033");
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_APPNAME,
- LIBMSI_PROPERTY_TYPE_STRING, 0, NULL,
- "libmsi msibuild");
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_VERSION,
- LIBMSI_PROPERTY_TYPE_INT, 200, NULL, NULL);
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_SOURCE,
- LIBMSI_PROPERTY_TYPE_INT, 0, NULL, NULL);
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_RESTRICT,
- LIBMSI_PROPERTY_TYPE_INT, 0, NULL, NULL);
+ if (!libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_TITLE,
+ "Installation Database", error))
+ return FALSE;
+
+ if (!libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_KEYWORDS,
+ "Installer, MSI", error))
+ return FALSE;
+
+ if (!libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_TEMPLATE,
+ ";1033", error))
+ return FALSE;
+
+ if (!libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_APPNAME,
+ "libmsi msibuild", error))
+ return FALSE;
+
+ if (!libmsi_summary_info_set_int(si, LIBMSI_PROPERTY_VERSION,
+ 200, error))
+ return FALSE;
+
+ if (!libmsi_summary_info_set_int(si, LIBMSI_PROPERTY_SOURCE,
+ 0, error))
+ return FALSE;
+
+ if (!libmsi_summary_info_set_int(si, LIBMSI_PROPERTY_RESTRICT,
+ 0, error))
+ return FALSE;
#ifdef HAVE_LIBUUID
{
@@ -61,14 +70,17 @@ static void init_suminfo(LibmsiSummaryInfo *si)
uustr[0] = '{';
uuid_unparse_upper(uu, uustr + 1);
strcat(uustr, "}");
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_UUID,
- LIBMSI_PROPERTY_TYPE_STRING, 0, NULL, uustr);
+ if (!libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_UUID,
+ uustr, error))
+ return FALSE;
}
#endif
+
+ return TRUE;
}
static LibmsiResult open_database(const char *msifile, LibmsiDatabase **db,
- LibmsiSummaryInfo **si)
+ LibmsiSummaryInfo **si, GError **error)
{
LibmsiResult r;
struct stat st;
@@ -89,7 +101,8 @@ static LibmsiResult open_database(const char *msifile, LibmsiDatabase **db,
return r;
}
- init_suminfo(*si);
+ if (!init_suminfo(*si, error))
+ return LIBMSI_RESULT_FUNCTION_FAILED;
r = libmsi_database_commit(*db);
if (r != LIBMSI_RESULT_SUCCESS)
@@ -139,27 +152,26 @@ static int import_table(char *table)
return (r != LIBMSI_RESULT_SUCCESS);
}
-static int add_summary_info(const char *name, const char *author,
- const char *template, const char *uuid)
+static gboolean add_summary_info(const char *name, const char *author,
+ const char *template, const char *uuid,
+ GError **error)
{
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_SUBJECT,
- LIBMSI_PROPERTY_TYPE_STRING,
- 0, NULL, name);
- if (author) {
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_AUTHOR,
- LIBMSI_PROPERTY_TYPE_STRING,
- 0, NULL, author);
- }
- if (template) {
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_TEMPLATE,
- LIBMSI_PROPERTY_TYPE_STRING,
- 0, NULL, template);
- }
- if (uuid) {
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_UUID,
- LIBMSI_PROPERTY_TYPE_STRING,
- 0, NULL, uuid);
- }
+ if (!libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_SUBJECT, name, error))
+ return FALSE;
+
+ if (author &&
+ !libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_AUTHOR, author, error))
+ return FALSE;
+
+ if (template &&
+ !libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_TEMPLATE, template, error))
+ return FALSE;
+
+ if (uuid &&
+ !libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_UUID, uuid, error))
+ return FALSE;
+
+ return TRUE;
}
static int add_stream(const char *stream, const char *file)
@@ -237,10 +249,10 @@ int main(int argc, char *argv[])
/* Accept package after first option for winemsibuilder compatibility. */
if (argc >= 3 && argv[1][0] == '-') {
- r = open_database(argv[2], &db, &si);
+ r = open_database(argv[2], &db, &si, &error);
argv[2] = argv[1];
} else {
- r = open_database(argv[1], &db, &si);
+ r = open_database(argv[1], &db, &si, &error);
}
if (r != LIBMSI_RESULT_SUCCESS) return 1;
@@ -260,10 +272,11 @@ int main(int argc, char *argv[])
if (argv[2] && argv[2][0] != '-') n++;
if (n > 2 && argv[3] && argv[3][0] != '-') n++;
if (n > 3 && argv[4] && argv[4][0] != '-') n++;
- ret = add_summary_info(argv[1],
- n > 2 ? argv[2] : NULL,
- n > 3 ? argv[3] : NULL,
- n > 4 ? argv[4] : NULL);
+ if (!add_summary_info(argv[1],
+ n > 2 ? argv[2] : NULL,
+ n > 3 ? argv[3] : NULL,
+ n > 4 ? argv[4] : NULL, &error))
+ goto end;
argc -= 3, argv += 3;
break;
case 'i':
@@ -305,12 +318,10 @@ int main(int argc, char *argv[])
}
if (r == LIBMSI_RESULT_SUCCESS) {
- r = libmsi_summary_info_persist(si);
- if (r != LIBMSI_RESULT_SUCCESS)
- {
- fprintf(stderr, "failed to commit summary info (%u)\n", r);
- exit(1);
- }
+ libmsi_summary_info_persist(si, &error);
+ if (error)
+ goto end;
+
r = libmsi_database_commit(db);
if (r != LIBMSI_RESULT_SUCCESS)
{
@@ -318,6 +329,8 @@ int main(int argc, char *argv[])
exit(1);
}
}
+
+end:
g_object_unref(si);
g_object_unref(db);
return r != LIBMSI_RESULT_SUCCESS;
diff --git a/tools/msiinfo.c b/tools/msiinfo.c
index 8043f0d..fdf963c 100644
--- a/tools/msiinfo.c
+++ b/tools/msiinfo.c
@@ -260,10 +260,11 @@ static int cmd_tables(struct Command *cmd, int argc, char **argv)
static void print_suminfo(LibmsiSummaryInfo *si, int prop, const char *name)
{
+ GError *error = NULL;
unsigned type;
+ const gchar* str;
int val;
uint64_t valtime;
- char *buf;
unsigned sz;
unsigned r;
time_t t;
@@ -276,20 +277,23 @@ static void print_suminfo(LibmsiSummaryInfo *si, int prop, const char *name)
switch (type) {
case LIBMSI_PROPERTY_TYPE_INT:
+ val = libmsi_summary_info_get_int(si, prop, &error);
+ if (error)
+ goto end;
printf ("%s: %d (%x)\n", name, val, val);
break;
case LIBMSI_PROPERTY_TYPE_STRING:
- buf = g_malloc(++sz);
- r = libmsi_summary_info_get_property(si, prop, NULL, NULL, NULL, buf, &sz);
- if (r) {
- print_libmsi_error(r);
- }
- printf ("%s: %s\n", name, buf);
- free(buf);
+ str = libmsi_summary_info_get_string(si, prop, &error);
+ if (error)
+ goto end;
+ printf ("%s: %s\n", name, str);
break;
case LIBMSI_PROPERTY_TYPE_FILETIME:
+ valtime = libmsi_summary_info_get_filetime(si, prop, &error);
+ if (error)
+ goto end;
/* Convert nanoseconds since 1601 to seconds since Unix epoch. */
t = (valtime / 10000000) - (uint64_t) 134774 * 86400;
printf ("%s: %s", name, ctime(&t));
@@ -301,6 +305,11 @@ static void print_suminfo(LibmsiSummaryInfo *si, int prop, const char *name)
default:
abort();
}
+
+end:
+ if (error)
+ g_warning("Can't print summary info: %s", error->message);
+ g_clear_error(&error);
}
static int cmd_suminfo(struct Command *cmd, int argc, char **argv)