No issues found
Tool | Failure ID | Location | Function | Message | Data |
---|---|---|---|---|---|
clang-analyzer | no-output-found | test-metadata.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None |
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2006 Jonathan Matthew <jonathan@kaolin.hn.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * The Rhythmbox authors hereby grant permission for non-GPL compatible
11 * GStreamer plugins to be used and distributed together with GStreamer
12 * and Rhythmbox. This permission is above and beyond the permissions granted
13 * by the GPL license by which Rhythmbox is covered. If you modify this code
14 * you may extend this exception to your version of the code, but you are not
15 * obligated to do so. If you do not wish to do so, delete this exception
16 * statement from your version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26 *
27 */
28
29 /*
30 * Test client for out-of-process metadata reader.
31 */
32
33 #include <config.h>
34 #include <stdlib.h>
35 #include <stdio.h>
36 #include <string.h>
37 #include <unistd.h>
38
39 #include "rb-metadata.h"
40 #include "rb-metadata-dbus.h"
41 #include "rb-debug.h"
42
43 static RBMetaData *md = NULL;
44
45 static gboolean debug = FALSE;
46 static gboolean can_save = FALSE;
47
48 static GOptionEntry entries [] = {
49 { "debug", 0, 0, G_OPTION_ARG_NONE, &debug, NULL, NULL },
50 { "can-save", 0, 0, G_OPTION_ARG_NONE, &can_save, NULL, NULL },
51 { NULL }
52 };
53
54 static void
55 print_metadata_string (RBMetaData *md, RBMetaDataField field, const char *name)
56 {
57 GValue v = {0,};
58 if (rb_metadata_get (md, field, &v)) {
59 char *s;
60
61 s = g_strdup_value_contents (&v);
62 printf ("%s: %s\n", name, s);
63 g_free (s);
64 g_value_unset (&v);
65 }
66 }
67
68 static gboolean
69 check_can_save_cb (gpointer mt)
70 {
71 char *media_type = (char *)mt;
72
73 if (rb_metadata_can_save (md, media_type)) {
74 printf ("Can save %s\n", media_type);
75 } else {
76 printf ("Unable to save %s\n", media_type);
77 }
78
79 return FALSE;
80 }
81
82 static gboolean
83 load_metadata_cb (gpointer file)
84 {
85 char *uri = (char *)file;
86 char **missing_plugins;
87 char **plugin_descriptions;
88 GError *error = NULL;
89 RBMetaDataField f;
90
91 if (strncmp (uri, "file://", 7)) {
92 if (uri[0] == '/') {
93 uri = g_filename_to_uri (uri, NULL, NULL);
94 } else {
95 char buf[1024];
96 if (getcwd (buf, sizeof (buf)) != NULL) {
97 char *filename;
98
99 filename = g_build_filename (buf, uri, NULL);
100 uri = g_filename_to_uri (filename, NULL, NULL);
101 g_free (filename);
102 }
103 }
104 }
105 printf ("%s\n", (const char *)uri);
106
107 rb_metadata_load (md, (const char *)uri, &error);
108
109 if (error) {
110 printf ("error: %s\n", error->message);
111 g_clear_error (&error);
112 }
113
114 printf ("type: %s\n", rb_metadata_get_media_type (md));
115 for (f =(RBMetaDataField)0; f < RB_METADATA_FIELD_LAST; f++)
116 print_metadata_string (md, f, rb_metadata_get_field_name (f));
117
118 printf ("has audio: %d\n", rb_metadata_has_audio (md));
119 printf ("has video: %d\n", rb_metadata_has_video (md));
120 printf ("has other data: %d\n", rb_metadata_has_other_data (md));
121
122 if (rb_metadata_get_missing_plugins (md, &missing_plugins, &plugin_descriptions)) {
123 int i = 0;
124 g_print ("missing plugins:\n");
125 while (missing_plugins[i] != NULL) {
126 g_print ("\t%s (%s)\n", missing_plugins[i], plugin_descriptions[i]);
127 i++;
128 }
129 g_strfreev (missing_plugins);
130 }
131 printf ("---\n");
132 return FALSE;
133 }
134
135 static gboolean
136 bye (gpointer nah)
137 {
138 g_main_loop_quit ((GMainLoop *)nah);
139 return FALSE;
140 }
141
142 int main(int argc, char **argv)
143 {
144 GMainLoop *loop;
145 int filecount = 0;
146 GOptionContext *context;
147 gboolean retval;
148 GError *error = NULL;
149
150 g_type_init ();
151
152 context = g_option_context_new (NULL);
153 g_option_context_add_main_entries (context, entries, NULL);
154 retval = g_option_context_parse (context, &argc, &argv, &error);
155
156 g_option_context_free (context);
157
158 if (! retval) {
159 g_warning ("%s", error->message);
160 g_error_free (error);
161 exit (1);
162 }
163
164 if (debug) {
165 rb_debug_init (TRUE);
166 }
167
168 loop = g_main_loop_new (NULL, FALSE);
169 md = rb_metadata_new ();
170 while (argv[1] != NULL) {
171 if (can_save) {
172 g_idle_add (check_can_save_cb, argv[1]);
173 } else {
174 g_idle_add (load_metadata_cb, argv[1]);
175 }
176 argv++;
177 filecount++;
178 }
179 g_idle_add (bye, loop);
180
181 g_main_loop_run (loop);
182
183 if (can_save) {
184 printf ("%d file type(s) checked\n", filecount);
185 } else {
186 printf ("%d file(s) read\n", filecount);
187 }
188 g_object_unref (G_OBJECT (md));
189 return 0;
190 }