1
by Yves-Alexis Perez
Import upstream version 0.1.2 |
1 |
/* $Id: tvm-camera-device.c 2340 2007-01-11 23:11:32Z benny $ */
|
2 |
/*-
|
|
3 |
* Copyright (c) 2007 Benedikt Meurer <benny@xfce.org>.
|
|
4 |
*
|
|
5 |
* This program is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License as published by the Free
|
|
7 |
* Software Foundation; either version 2 of the License, or (at your option)
|
|
8 |
* any later version.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
13 |
* more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License along with
|
|
16 |
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
17 |
* Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18 |
*/
|
|
19 |
||
20 |
#ifdef HAVE_CONFIG_H
|
|
21 |
#include <config.h> |
|
22 |
#endif
|
|
23 |
||
24 |
#ifdef HAVE_MEMORY_H
|
|
25 |
#include <memory.h> |
|
26 |
#endif
|
|
27 |
#ifdef HAVE_STRING_H
|
|
28 |
#include <string.h> |
|
29 |
#endif
|
|
30 |
||
31 |
#include <thunar-volman/tvm-camera-device.h> |
|
32 |
#include <thunar-volman/tvm-prompt.h> |
|
33 |
#include <thunar-volman/tvm-run.h> |
|
34 |
||
35 |
||
36 |
||
37 |
/**
|
|
38 |
* tvm_block_camera_added:
|
|
39 |
* @preferences : a #TvmPreferences.
|
|
40 |
* @context : a #LibHalContext.
|
|
41 |
* @udi : the HAL device UDI of the newly added camera device.
|
|
42 |
* @capability : the capability, which caused this handler to be run.
|
|
43 |
* @error : return location for errors or %NULL.
|
|
44 |
*
|
|
45 |
* See #TvmDeviceCallback for further information.
|
|
46 |
*
|
|
47 |
* Return value: %TRUE if handled, %FALSE if not handled or an
|
|
48 |
* unrecoverable error occurred.
|
|
49 |
**/
|
|
50 |
gboolean
|
|
51 |
tvm_camera_device_added (TvmPreferences *preferences, |
|
52 |
LibHalContext *context, |
|
53 |
const gchar *udi, |
|
54 |
const gchar *capability, |
|
55 |
GError **error) |
|
56 |
{
|
|
57 |
gboolean result = FALSE; |
|
58 |
gboolean autophoto; |
|
59 |
gchar *autophoto_command; |
|
60 |
gchar *access_method; |
|
61 |
||
62 |
g_return_val_if_fail (exo_hal_udi_validate (udi, -1, NULL), FALSE); |
|
63 |
g_return_val_if_fail (TVM_IS_PREFERENCES (preferences), FALSE); |
|
64 |
g_return_val_if_fail (error == NULL || *error == NULL, FALSE); |
|
65 |
g_return_val_if_fail (capability != NULL, FALSE); |
|
66 |
g_return_val_if_fail (context != NULL, FALSE); |
|
67 |
||
68 |
/* check if this is a non-mass-storage camera device, handled by gphoto2 */
|
|
69 |
access_method = libhal_device_get_property_string (context, udi, "camera.access_method", NULL); |
|
70 |
if ((access_method != NULL && strcmp (access_method, "ptp") == 0) |
|
71 |
|| libhal_device_get_property_bool (context, udi, "camera.libgphoto2.support", NULL)) |
|
72 |
{
|
|
73 |
/* check if autophoto support is enabled */
|
|
74 |
g_object_get (G_OBJECT (preferences), "autophoto", &autophoto, "autophoto-command", &autophoto_command, NULL); |
|
75 |
if (G_LIKELY (autophoto && autophoto_command != NULL && *autophoto_command != '\0')) |
|
76 |
{
|
|
77 |
/* run the preferred photo management application */
|
|
78 |
result = tvm_run_command (context, udi, autophoto_command, NULL, NULL, error); |
|
79 |
}
|
|
80 |
g_free (autophoto_command); |
|
81 |
}
|
|
82 |
libhal_free_string (access_method); |
|
83 |
||
84 |
return result; |
|
85 |
}
|
|
86 |
||
87 |
||
88 |
||
89 |