1 /*****************************************************************************
2 * messages.cpp : WinCE gui plugin for VLC
3 *****************************************************************************
4 * Copyright (C) 2000-2004 VideoLAN
7 * Authors: Marodon Cedric <cedric_marodon@yahoo.fr>
8 * Gildas Bazin <gbazin@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
28 #include <stdlib.h> /* malloc(), free() */
29 #include <string.h> /* strerror() */
43 #define NMAXFILE 512 // at least 256
47 #define TEXTMAXBUF 512 // at least 500
50 /*****************************************************************************
52 *****************************************************************************/
54 Messages::Messages( intf_thread_t *_p_intf, HINSTANCE _hInst )
60 b_verbose = VLC_FALSE;
63 /***********************************************************************
69 Processes messages sent to the main window.
71 ***********************************************************************/
72 LRESULT Messages::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
76 TCHAR psz_text[TEXTMAXBUF];
84 shidi.dwMask = SHIDIM_FLAGS;
85 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
86 SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
88 SHInitDialog( &shidi );
91 GetClientRect( hwnd, &rect );
92 hListView = CreateWindow( WC_LISTVIEW, NULL,
93 WS_VISIBLE | WS_CHILD | LVS_REPORT |
94 LVS_SHOWSELALWAYS | WS_VSCROLL | WS_HSCROLL |
95 WS_BORDER /*| LVS_NOCOLUMNHEADER */,
96 rect.left + 20, rect.top + 50,
97 rect.right - rect.left - ( 2 * 20 ),
98 rect.bottom - rect.top - 50 - 20,
99 hwnd, NULL, hInst, NULL );
100 ListView_SetExtendedListViewStyle( hListView, LVS_EX_FULLROWSELECT );
103 lv.mask = LVCF_WIDTH | LVCF_FMT | LVCF_TEXT;
104 lv.fmt = LVCFMT_LEFT ;
105 GetClientRect( hwnd, &rect );
106 lv.cx = rect.right - rect.left;
107 lv.pszText = _T("Messages");
109 ListView_InsertColumn( hListView, 0, &lv);
111 SetTimer( hwnd, 1, 500 /*milliseconds*/, NULL );
113 SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
121 EndDialog( hwnd, LOWORD( wp ) );
128 EndDialog( hwnd, LOWORD( wp ) );
132 ListView_DeleteAllItems( hListView );
136 memset( &(ofn), 0, sizeof(ofn) );
137 ofn.lStructSize = sizeof(ofn);
138 ofn.hwndOwner = hwnd;
139 ofn.lpstrFile = _T("");
140 ofn.nMaxFile = NMAXFILE;
141 ofn.lpstrFilter = _T("Text (*.txt)\0*.txt\0");
142 ofn.lpstrTitle = _T("Save File As");
143 ofn.Flags = OFN_HIDEREADONLY;
144 ofn.lpstrDefExt = _T("txt");
146 if( GetSaveFileName( (LPOPENFILENAME)&ofn ) )
148 fichier = CreateFile( ofn.lpstrFile, GENERIC_WRITE,
149 FILE_SHARE_READ|FILE_SHARE_WRITE,
151 FILE_ATTRIBUTE_NORMAL, NULL );
153 if( fichier != INVALID_HANDLE_VALUE )
157 //SetFilePointer( fichier, 0, NULL, FILE_END );
158 for( n = 0; n < ListView_GetItemCount( hListView ); n++ )
160 ListView_GetItemText( hListView, n, 0, psz_text,
162 string text_out = (string)_TOMB(psz_text) + "\n";
163 WriteFile( fichier, text_out.c_str(), text_out.size(),
164 (LPDWORD)&i_dummy, NULL );
166 FlushFileBuffers( fichier );
167 CloseHandle(fichier);
171 SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
185 void Messages::UpdateLog()
187 msg_subscription_t *p_sub = p_intf->p_sys->p_sub;
191 vlc_mutex_lock( p_sub->p_lock );
192 i_stop = *p_sub->pi_stop;
193 vlc_mutex_unlock( p_sub->p_lock );
195 if( p_sub->i_start != i_stop )
197 for( i_start = p_sub->i_start; i_start != i_stop;
198 i_start = (i_start+1) % VLC_MSG_QSIZE )
200 if( !b_verbose && VLC_MSG_ERR != p_sub->p_msg[i_start].i_type )
203 /* Append all messages to log window */
204 debug = p_sub->p_msg[i_start].psz_module;
206 switch( p_sub->p_msg[i_start].i_type )
215 debug += " warning: ";
224 debug += p_sub->p_msg[i_start].psz_msg;
228 lv.pszText = TEXT("");
231 lv.iItem = ListView_GetItemCount( hListView );
232 ListView_InsertItem( hListView, &lv );
233 ListView_SetItemText( hListView, lv.iItem, 0,
234 (TCHAR *)_FROMMB(debug.c_str()) );
237 vlc_mutex_lock( p_sub->p_lock );
238 p_sub->i_start = i_start;
239 vlc_mutex_unlock( p_sub->p_lock );