]> git.sesse.net Git - vlc/commitdiff
Qt4: apply verbosity filtering within Qt, do not rely on core
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 18 Aug 2011 20:34:36 +0000 (23:34 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 18 Aug 2011 20:34:36 +0000 (23:34 +0300)
include/vlc_messages.h
modules/gui/qt4/dialogs/messages.cpp
modules/gui/qt4/dialogs/messages.hpp

index a8782ab46131c48c63bf1afb65fac3633f3dab0e..ae3ac50f42deb80ae09cbdedf1a30eb6fd391488 100644 (file)
  * @{
  */
 
+/** Message types */
+enum msg_item_type
+{
+    VLC_MSG_INFO=0, /**< Important information */
+    VLC_MSG_ERR,    /**< Error */
+    VLC_MSG_WARN,   /**< Warning */
+    VLC_MSG_DBG,    /**< Debug */
+};
+
 /**
- * Store a single message sent to user.
+ * Log message
  */
 typedef struct
 {
-    int     i_type;                             /**< message type, see below */
-    uintptr_t   i_object_id;
-    const char *psz_object_type;
-    const char *psz_module;
-    const char *psz_header;                     /**< Additional header */
-    char *  psz_msg;                            /**< the message itself */
+    unsigned    i_type;  /**< Message type, see @ref msg_item_type */
+    uintptr_t   i_object_id; /**< Emitter (temporaly) unique object ID or 0 */
+    const char *psz_object_type; /**< Emitter object type name */
+    const char *psz_module; /**< Emitter module (source code) */
+    const char *psz_header; /**< Additional header (used by VLM media) */
+    char       *psz_msg; /**< Message text */
 } msg_item_t;
 
-/* Message types */
-/** standard messages */
-#define VLC_MSG_INFO  0
-/** error messages */
-#define VLC_MSG_ERR   1
-/** warning messages */
-#define VLC_MSG_WARN  2
-/** debug messages */
-#define VLC_MSG_DBG   3
-
 VLC_MALLOC VLC_USED
 static inline msg_item_t *msg_Copy (const msg_item_t *msg)
 {
index 5c356be7d034c4efd85e56e06ec164fcbeb82d34..a64594ed355d862245931e40ea6681163d09c751 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * Messages.cpp : Information about an item
  ****************************************************************************
- * Copyright (C) 2006-2007 the VideoLAN team
+ * Copyright (C) 2006-2011 the VideoLAN team
  * $Id$
  *
  * Authors: Jean-Baptiste Kempf <jb (at) videolan.org>
@@ -25,6 +25,7 @@
 #endif
 
 #include "dialogs/messages.hpp"
+#include <vlc_atomic.h>
 
 #include <QTextEdit>
 #include <QTextCursor>
@@ -73,8 +74,6 @@ struct msg_cb_data_t
     MessagesDialog *self;
 };
 
-static void MsgCallback( msg_cb_data_t *, const msg_item_t * );
-
 MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
                : QVLCFrame( _p_intf )
 {
@@ -92,7 +91,9 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
     /* Buttons and general layout */
     ui.saveLogButton->setToolTip( qtr( "Saves all the displayed logs to a file" ) );
 
-    ui.verbosityBox->setValue( var_InheritInteger( p_intf, "verbose" ) );
+    int verbosity = var_InheritInteger( p_intf, "verbose" );
+    vlc_atomic_set( &this->verbosity, verbosity );
+    ui.verbosityBox->setValue( verbosity );
 
     ui.vbobjectsEdit->setText(config_GetPsz( p_intf, "verbose-objects"));
     ui.vbobjectsEdit->setToolTip( "verbose-objects usage: \n"
@@ -122,7 +123,6 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
     cbData = new msg_cb_data_t;
     cbData->self = this;
     sub = msg_Subscribe( p_intf->p_libvlc, MsgCallback, cbData );
-    changeVerbosity( ui.verbosityBox->value() );
 }
 
 MessagesDialog::~MessagesDialog()
@@ -134,7 +134,7 @@ MessagesDialog::~MessagesDialog()
 
 void MessagesDialog::changeVerbosity( int verbosity )
 {
-    msg_SubscriptionSetVerbosity( sub , verbosity );
+    vlc_atomic_set( &this->verbosity, verbosity );
 }
 
 void MessagesDialog::updateConfig()
@@ -296,11 +296,15 @@ void MessagesDialog::tabChanged( int i )
     updateButton->setVisible( i == 1 );
 }
 
-static void MsgCallback( msg_cb_data_t *data, const msg_item_t *item )
+void MessagesDialog::MsgCallback( msg_cb_data_t *data, const msg_item_t *item )
 {
-    int canc = vlc_savecancel();
+    MessagesDialog *dialog = data->self;
+    int verbosity = vlc_atomic_get( &dialog->verbosity );
 
-    QApplication::postEvent( data->self, new MsgEvent( item ) );
+    if( verbosity < 0 || verbosity < (item->i_type - VLC_MSG_ERR) )
+        return;
 
+    int canc = vlc_savecancel();
+    QApplication::postEvent( dialog, new MsgEvent( item ) );
     vlc_restorecancel( canc );
 }
index 3b9f66cd754df8e2d5bc315b3f40a17195ed3d57..bc360ab2fd1fcfcb1c305d3261cf4ffb76072a56 100644 (file)
@@ -53,6 +53,9 @@ private:
     void customEvent( QEvent * );
     void sinkMessage( MsgEvent * );
 
+    vlc_atomic_t verbosity;
+    static void MsgCallback( msg_cb_data_t *, const msg_item_t * );
+
 private slots:
     bool save();
     void updateConfig();