1 /* Copyright (c) 2006, Nokia Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of the Nokia Corporation nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include <modest-platform.h>
31 #include <libgnomevfs/gnome-vfs-mime.h>
32 #include <libgnomeui/gnome-icon-lookup.h>
33 #include <tny-gnome-device.h>
36 modest_platform_init (void)
38 return TRUE; /* nothing to do */
43 modest_platform_get_new_device (void)
45 return TNY_DEVICE (tny_gnome_device_new ());
50 modest_platform_get_file_icon_name (const gchar* name, const gchar* mime_type,
51 gchar **effective_mime_type)
53 GString *mime_str = NULL;
54 gchar *icon_name = NULL;
56 const static gchar* octet_stream = "application/octet-stream";
58 g_return_val_if_fail (name || mime_type, NULL);
60 if (!mime_type || g_ascii_strcasecmp (mime_type, octet_stream))
61 mime_str = g_string_new(gnome_vfs_mime_type_from_name_or_default
62 (name, "application/octet-stream"));
64 mime_str = g_string_new (mime_type);
65 g_string_ascii_down (mime_str);
68 uri = g_strconcat ("file:///", name ? name : "dummy", NULL);
69 icon_name = gnome_icon_lookup (gtk_icon_theme_get_default(), NULL,
70 uri, NULL, NULL, mime_str->str, 0, 0);
73 if (effective_mime_type)
74 *effective_mime_type = g_string_free (mime_str, FALSE);
76 g_string_free (mime_str, TRUE);