cheese r433 - in trunk: . data src



Author: jhaitsma
Date: Sat Jan 26 17:21:24 2008
New Revision: 433
URL: http://svn.gnome.org/viewvc/cheese?rev=433&view=rev

Log:
Write logging to file ~/.gnome2/cheese/log and send this along in bug-buddy reports. Patch by <ruledbyfaith gmail com>. Fixes http://code.google.com/p/google-highly-open-participation-gnome/issues/detail?id=108 and bug #510270


Added:
   trunk/data/cheese-bugreport.sh
Modified:
   trunk/ChangeLog
   trunk/configure.ac
   trunk/data/Makefile.am
   trunk/data/cheese.desktop.in.in
   trunk/src/cheese-fileutil.c
   trunk/src/cheese-fileutil.h
   trunk/src/cheese.c

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Sat Jan 26 17:21:24 2008
@@ -19,6 +19,26 @@
 
 
 #*******************************************************************************
+# Expanded dirs
+#*******************************************************************************
+# This macro expands DIR and assigns it to RET.
+# If DIR is NONE, then it's replaced by DEFAULT.
+# Based on AC_DEFINE_DIR
+AC_DEFUN([CHEESE_FULLPATH], [
+  test "x$prefix" = xNONE && prefix="$ac_default_prefix"
+  test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+  ac_expand=[$]$1
+  test "x$ac_expand" = xNONE && ac_expand="[$]$2"
+  ac_expand=`eval echo [$]ac_expand`
+  $3=`eval echo [$]ac_expand`
+])
+
+# FULL_LIBDIR is used for X-GNOME-Bugzilla-ExtraInfoScript expansion
+# in data/cheese.desktop.in.in
+CHEESE_FULLPATH(libdir, NONE, FULL_LIBDIR)
+AC_SUBST(FULL_LIBDIR)
+
+#*******************************************************************************
 # Internationalization
 #*******************************************************************************
 GETTEXT_PACKAGE=cheese

Modified: trunk/data/Makefile.am
==============================================================================
--- trunk/data/Makefile.am	(original)
+++ trunk/data/Makefile.am	Sat Jan 26 17:21:24 2008
@@ -20,6 +20,9 @@
 	$(schema_in_files)				\
 	$(pkgdata_DATA)
 
+bugreportdir      = $(libdir)/cheese
+bugreport_SCRIPTS = cheese-bugreport.sh
+
 if GCONF_SCHEMAS_INSTALL
 install-data-local:
 	-GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) \

Added: trunk/data/cheese-bugreport.sh
==============================================================================
--- (empty file)
+++ trunk/data/cheese-bugreport.sh	Sat Jan 26 17:21:24 2008
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+echo "Cheese log:"
+cat $HOME/.gnome2/cheese/log

Modified: trunk/data/cheese.desktop.in.in
==============================================================================
--- trunk/data/cheese.desktop.in.in	(original)
+++ trunk/data/cheese.desktop.in.in	Sat Jan 26 17:21:24 2008
@@ -11,3 +11,4 @@
 X-GNOME-Bugzilla-Product=cheese
 X-GNOME-Bugzilla-Component=general
 X-GNOME-Bugzilla-Version= VERSION@
+X-GNOME-Bugzilla-ExtraInfoScript= FULL_LIBDIR@/cheese/cheese-bugreport.sh

Modified: trunk/src/cheese-fileutil.c
==============================================================================
--- trunk/src/cheese-fileutil.c	(original)
+++ trunk/src/cheese-fileutil.c	Sat Jan 26 17:21:24 2008
@@ -28,11 +28,23 @@
 #include "cheese-fileutil.h"
 
 char *
+cheese_fileutil_get_path ()
+{
+  char *path;
+
+  path = g_strjoin (G_DIR_SEPARATOR_S, g_get_home_dir(), ".gnome2", "cheese", NULL);
+  return path;
+}
+
+char *
 cheese_fileutil_get_media_path ()
 {
   char *path;
+  char *cheese_path;
 
-  path = g_strjoin (G_DIR_SEPARATOR_S, g_get_home_dir(), ".gnome2", "cheese", "media", NULL);
+  cheese_path = cheese_fileutil_get_path ();
+  path = g_strjoin (G_DIR_SEPARATOR_S, cheese_path, "media", NULL);
+  g_free (cheese_path);
 
   return path;
 }
@@ -66,9 +78,9 @@
   filename_num++;
 
   if (mode == CHEESE_MEDIA_MODE_PHOTO)
-    filename = g_strdup_printf ("%s/%04d%s", path, filename_num, PHOTO_NAME_SUFFIX);
+    filename = g_strdup_printf ("%s%s%04d%s", path, G_DIR_SEPARATOR_S, filename_num, PHOTO_NAME_SUFFIX);
   else
-    filename = g_strdup_printf ("%s/%04d%s", path, filename_num, VIDEO_NAME_SUFFIX);
+    filename = g_strdup_printf ("%s%s%04d%s", path, G_DIR_SEPARATOR_S, filename_num, VIDEO_NAME_SUFFIX);
 
   g_free (path);
   return filename;

Modified: trunk/src/cheese-fileutil.h
==============================================================================
--- trunk/src/cheese-fileutil.h	(original)
+++ trunk/src/cheese-fileutil.h	Sat Jan 26 17:21:24 2008
@@ -30,6 +30,7 @@
   CHEESE_MEDIA_MODE_VIDEO
 } CheeseMediaMode;
 
+char *cheese_fileutil_get_path(void);
 char *cheese_fileutil_get_media_path (void);
 char *cheese_fileutil_get_new_media_filename (CheeseMediaMode mode);
 

Modified: trunk/src/cheese.c
==============================================================================
--- trunk/src/cheese.c	(original)
+++ trunk/src/cheese.c	Sat Jan 26 17:21:24 2008
@@ -22,12 +22,14 @@
 #include <cheese-config.h>
 #endif
 
+#include <stdio.h>
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include <gst/gst.h>
 #include <libgnomevfs/gnome-vfs.h>
 
+#include "cheese-fileutil.h"
 #include "cheese-window.h"
 
 struct _CheeseOptions
@@ -36,9 +38,28 @@
   char *hal_device_id;
 } CheeseOptions;
 
-void cheese_printerr_handler(char *string)
+void cheese_print_handler(char *string)
 {
-  if (CheeseOptions.verbose) 
+  static FILE *fp = NULL;
+  GDir *dir;
+  char *filename, *path;
+
+  if (fp == NULL) {
+    path = cheese_fileutil_get_path ();
+    dir = g_dir_open (path, 0, NULL);
+    if (!dir)
+      return;
+
+    filename = g_build_filename (path, "log", NULL);
+    fp = fopen(filename, "w");
+
+    g_free(filename);
+  }
+
+  if (fp)
+    fputs(string, fp);
+
+  if (CheeseOptions.verbose)
     fprintf (stdout, "%s", string);
 }
 
@@ -63,9 +84,9 @@
   g_set_application_name (_("Cheese"));
 
   context = g_option_context_new (N_("- Take photos and videos from your webcam"));
-	g_option_context_add_main_entries(context, options, GETTEXT_PACKAGE);
-	g_option_context_add_group (context, gtk_get_option_group (TRUE));
-	g_option_context_add_group (context, gst_init_get_option_group ());
+  g_option_context_add_main_entries(context, options, GETTEXT_PACKAGE);
+  g_option_context_add_group (context, gtk_get_option_group (TRUE));
+  g_option_context_add_group (context, gst_init_get_option_group ());
   g_option_context_parse(context, &argc, &argv, NULL);
   g_option_context_free(context);
 
@@ -73,7 +94,7 @@
   gst_init (&argc, &argv);
   gnome_vfs_init ();
 
-  g_set_print_handler ((GPrintFunc) cheese_printerr_handler);
+  g_set_print_handler ((GPrintFunc) cheese_print_handler);
 
   gtk_window_set_default_icon_name ("cheese");
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]